mirror of https://github.com/ansible/ansible.git
Fixes #75568
(cherry picked from commit 9c2f44b884
)
pull/75623/head
parent
999c2e603d
commit
a6f24c407c
@ -0,0 +1,2 @@
|
||||
bugfixes:
|
||||
- Fix templating task action with host-specific vars (https://github.com/ansible/ansible/issues/75568)
|
@ -1,3 +1,3 @@
|
||||
[local]
|
||||
testhost ansible_connection=local
|
||||
testhost2 ansible_connection=local
|
||||
testhost ansible_connection=local ansible_python_interpreter="{{ ansible_playbook_python }}"
|
||||
testhost2 ansible_connection=local ansible_python_interpreter="{{ ansible_playbook_python }}"
|
||||
|
@ -0,0 +1,26 @@
|
||||
- hosts: testhost,testhost2
|
||||
gather_facts: no
|
||||
tasks:
|
||||
- set_fact:
|
||||
module_to_run: 'debug'
|
||||
when: inventory_hostname == 'testhost'
|
||||
|
||||
- set_fact:
|
||||
module_to_run: 'ping'
|
||||
when: inventory_hostname == 'testhost2'
|
||||
|
||||
- action:
|
||||
module: '{{ module_to_run }}'
|
||||
register: out
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "'msg' in out"
|
||||
- "'ping' not in out"
|
||||
when: inventory_hostname == 'testhost'
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "'ping' in out"
|
||||
- "'msg' not in out"
|
||||
when: inventory_hostname == 'testhost2'
|
Loading…
Reference in New Issue