linear - don't treat end_role as a run_once task (#84673)

pull/84707/head
Sloane Hertel 10 months ago committed by GitHub
parent 8d65900974
commit a086c34a91
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -0,0 +1,2 @@
bugfixes:
- linear strategy - fix executing ``end_role`` meta tasks for each host, instead of handling these as implicit run_once tasks (https://github.com/ansible/ansible/issues/84660).

@ -154,7 +154,7 @@ class StrategyModule(StrategyBase):
# for the linear strategy, we run meta tasks just once and for
# all hosts currently being iterated over rather than one host
results.extend(self._execute_meta(task, play_context, iterator, host))
if task.args.get('_raw_params', None) not in ('noop', 'reset_connection', 'end_host', 'role_complete', 'flush_handlers'):
if task.args.get('_raw_params', None) not in ('noop', 'reset_connection', 'end_host', 'role_complete', 'flush_handlers', 'end_role'):
run_once = True
if (task.any_errors_fatal or run_once) and not task.ignore_errors:
any_errors_fatal = True

@ -1,4 +1,4 @@
- hosts: localhost
- hosts: localhost,testhost
gather_facts: false
pre_tasks:
- set_fact:

@ -1,7 +1,8 @@
- set_fact:
role_executed: "{{ role_executed|default(0)|int + 1 }}"
- command: echo
- debug:
changed_when: true
notify: role_handler
- meta: end_role

@ -55,7 +55,7 @@ ANSIBLE_PRIVATE_ROLE_VARS=0 ansible-playbook privacy.yml -e @vars/privacy_vars.y
ansible-playbook privacy.yml -e @vars/privacy_vars.yml "$@"
for strategy in linear free; do
[ "$(ANSIBLE_STRATEGY=$strategy ansible-playbook end_role.yml | grep -c CHECKPOINT)" = "1" ]
[ "$(ANSIBLE_STRATEGY=$strategy ansible-playbook -i testhost, end_role.yml | grep -c CHECKPOINT)" = "2" ]
[ "$(ANSIBLE_STRATEGY=$strategy ansible-playbook -i host1,host2 end_role_nested.yml | grep -c CHECKPOINT)" = "4" ]
done

Loading…
Cancel
Save