diff options
author | beeankha <beeankha@gmail.com> | 2019-09-17 21:49:01 +0200 |
---|---|---|
committer | beeankha <beeankha@gmail.com> | 2019-09-20 17:32:10 +0200 |
commit | 860715d0884a1e2c1b5c2d8ee3ed696f151292b6 (patch) | |
tree | ef5eba00bafde5eef25bdd9a60533a674c429259 /docs/job_events.md | |
parent | Edit AWX docs (diff) | |
download | awx-860715d0884a1e2c1b5c2d8ee3ed696f151292b6.tar.xz awx-860715d0884a1e2c1b5c2d8ee3ed696f151292b6.zip |
More AWX docs edits
Diffstat (limited to 'docs/job_events.md')
-rw-r--r-- | docs/job_events.md | 37 |
1 files changed, 26 insertions, 11 deletions
diff --git a/docs/job_events.md b/docs/job_events.md index 2f4c35ae72..f8144d5fec 100644 --- a/docs/job_events.md +++ b/docs/job_events.md @@ -1,16 +1,22 @@ ## Ansible Callback and Job Events -There is no concept of a job event in Ansible. Job Events are json structures, created when Ansible calls the Tower callback plugin hooks (i.e. `v2_playbook_on_task_start`, `v2_runner_on_ok`, etc.). The Job Event data structures contain data from the parameters of the callback hooks plus unique ids that reference other Job Events. There is usually a 1-1 relationship between a Job Event and an Ansible callback plugin function call. + +There is no concept of a job event in Ansible. Job Events are JSON structures, created when Ansible calls the Tower callback plugin hooks (*i.e.*, `v2_playbook_on_task_start`, `v2_runner_on_ok`, etc.). The Job Event data structures contain data from the parameters of the callback hooks plus unique IDs that reference other Job Events. There is usually a one-to-one relationship between a Job Event and an Ansible callback plugin function call. + ## Job Event Relationships -The Job Event relationship is strictly hierarchical. In the example details below, each Job Event bullet is related to the previous Job Event to form a hierarchy. -* There is always 1 and only 1 `v2_playbook_on_start` event and it is the first event. -* `v2_playbook_on_play_start` is generated once per-play in the playbook. 2 such events would be generated from the playbook example below. -* The `v2_playbook_on_task_start` function is called once for each task under the default execution strategy. Other execution strategies (i.e. free or serial) can result in the `v2_playbook_on_task_start` function being multiple times, one for each host. Tower only creates a Job Event for the **first** `v2_playbook_on_task_start` call. Subsequent calls for the same task do **not** result in Job Events being created. -* `v2_runner_on_[ok, failed, skipped, unreachable, retry, item_on_ok, item_on_failed, item_on_skipped]` One `v2_runner_on_...` Job Event will be created for each `v2_playbook_on_task_start` event. +The Job Event relationship is strictly hierarchical. In the example details below, each Job Event bullet is related to the previous Job Event to form a hierarchy: + +* There is always one and only one `v2_playbook_on_start` event and it is the first event. +* `v2_playbook_on_play_start` is generated once per-play in the playbook; two such events would be generated from the playbook example below. +* The `v2_playbook_on_task_start` function is called once for each task under the default execution strategy. Other execution strategies (*i.e.*, free or serial) can result in the `v2_playbook_on_task_start` function being called multiple times, one for each host. Tower only creates a Job Event for the **first** `v2_playbook_on_task_start` call. Subsequent calls for the same task do **not** result in Job Events being created. +* `v2_runner_on_[ok, failed, skipped, unreachable, retry, item_on_ok, item_on_failed, item_on_skipped]`; one `v2_runner_on_...` Job Event will be created for each `v2_playbook_on_task_start` event. + ## Example -Below is an example inventory and playbook outline along with an example of Job Events generated and their hierarchical relationship. + +Below is an example inventory and playbook outline, along with the Job Events generated and their hierarchical relationship: + ``` # inventory [tower] @@ -45,7 +51,8 @@ hostC when: inventory_hostname == 'C' ``` -Below is a visualization of how Job Events are related to form a hierarchy given a run of the playbook above. +Below is a visualization of how Job Events are related to form a hierarchy given a run of the playbook above: + ``` `-- playbook_on_start |-- playbook_on_play_start-preflight @@ -69,8 +76,12 @@ Below is a visualization of how Job Events are related to form a hierarchy given `-- runner_on_ok_hostC ``` + ## Job Event Creation Patterns -Ansible execution strategy heavily influences the creation order of Job Events. The above examples of Job Events creation an hierarchy are also the order in which they are created when the Ansible default execution strategy is used. When other strategies like free and serial are used, the order in which Job Events are created is slightly different. Let's take the previous example playbook and Job Events and show the order in which the Job Events may be created when the free strategy is used. Notice how `runner_on_*` Job Events can be created **after** a `playbook_on_task_start` for the next task runs. This is not the case for the default Ansible execution strategy. Under the default Ansible execution strategy, all `runner_on_*` Job Events will be created before the next `playbook_on_task_start` is generated. + +The Ansible execution strategy heavily influences the creation order of Job Events. The above examples of Job Events creation and hierarchy are also the order in which they are created when the Ansible default execution strategy is used. When other strategies like `free` and `serial` are used, the order in which Job Events are created is slightly different. + +Let's take the previous example playbook and Job Events and show the order in which the Job Events may be created when the free strategy is used. Notice how `runner_on_*` Job Events can be created **after** a `playbook_on_task_start` for the next task runs. This is not the case for the default Ansible execution strategy. Under the default Ansible execution strategy, all `runner_on_*` Job Events will be created before the next `playbook_on_task_start` is generated: ``` playbook_on_start @@ -95,9 +106,13 @@ playbook_on_play_start-install runner_on_ok_hostA (install_tower) ``` + ## Testing + A management command for event replay exists for replaying jobs at varying speeds and other parameters. Run `awx-manage replay_job_events --help` for additional usage information. To prepare the UI for event replay, load the page for a finished job and then append `_debug` as a parameter to the url. + ## Code References -* More comprehensive list of Job Events and the hierarchy they form https://github.com/ansible/awx/blob/devel/awx/main/models/jobs.py#L870 -* Exhaustive list of Job Events in Tower https://github.com/ansible/awx/blob/devel/awx/main/models/jobs.py#L900 + +* For a more comprehensive list of Job Events and the hierarchy they form, go here: https://github.com/ansible/awx/blob/devel/awx/main/models/jobs.py#L870 +* Exhaustive list of Job Events in Tower: https://github.com/ansible/awx/blob/devel/awx/main/models/jobs.py#L900 |