forked from ansible/ansible
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Only mark a role as complete once a task in it executes for the targe…
…t host (ansible#81565) * If all tasks in the role are skipped or unreachable, the role is not marked as complete for the host. * Only mark the role as complete if a task in the role succeeds or fails for the host.
- Loading branch information
Showing
8 changed files
with
67 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
bugfixes: | ||
- role deduplication - don't deduplicate before a role has had a task run for that particular host (https://github.com/ansible/ansible/issues/81486). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
- name: test deduping allows for 1 successful execution of role after it is skipped | ||
hosts: testhost | ||
gather_facts: false | ||
tags: [ 'conditional_skipped' ] | ||
roles: | ||
# Skipped the first time it executes | ||
- role: a | ||
when: role_set_var is defined | ||
|
||
- role: set_var | ||
|
||
# No longer skipped | ||
- role: a | ||
when: role_set_var is defined | ||
# Deduplicated with the previous success | ||
- role: a | ||
when: role_set_var is defined | ||
|
||
- name: test deduping allows for successful execution of role after host is unreachable | ||
hosts: fake,testhost | ||
gather_facts: false | ||
tags: [ 'unreachable' ] | ||
ignore_unreachable: yes | ||
roles: | ||
# unreachable by the first host | ||
- role: test_connectivity | ||
|
||
# unreachable host will try again, | ||
# the successful host will not because it's deduplicated | ||
- role: test_connectivity | ||
|
||
- name: test deduping role for failed host | ||
hosts: testhost,localhost | ||
gather_facts: false | ||
tags: [ 'conditional_failed' ] | ||
ignore_errors: yes | ||
roles: | ||
# Uses run_once to fail on the first host the first time it executes | ||
- role: failed_when | ||
|
||
- role: set_var | ||
- role: recover | ||
|
||
# Deduplicated after the failure, ONLY runs for localhost | ||
- role: failed_when | ||
# Deduplicated with the previous success | ||
- role: failed_when |
4 changes: 4 additions & 0 deletions
4
test/integration/targets/roles/roles/failed_when/tasks/main.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
- debug: | ||
msg: "{{ role_set_var is undefined | ternary('failed_when task failed', 'failed_when task succeeded') }}" | ||
failed_when: role_set_var is undefined | ||
run_once: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
- meta: clear_host_errors |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
- set_fact: | ||
role_set_var: true |
2 changes: 2 additions & 0 deletions
2
test/integration/targets/roles/roles/test_connectivity/tasks/main.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
- ping: | ||
data: 'reachable' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters