Hi,
I have following playbook, which I expect it to run only once, on one of
the `group2` hosts.
site.yml
---
- hosts:
- group1
- group2
roles:
- { role: test }
roles/test/tasks/main.yml
---
- include: test.yml
when: inventory_hostname in groups['group2']
roles/test/tasks/test.yml
---
- name: test - include together with run_once
debug: var='abc'
run_once: true
However, after skipping the `host1` from group1 (since it is the first in
site.yml), it never run on host2.
$ ansible-playbook -i test_inventory site.yml
PLAY [group1;group2]
**********************************************************
GATHERING FACTS
***************************************************************
ok: [host1]
ok: [host2]
TASK: [test | test - include together with run_once]
**************************
skipping: [host1]
PLAY RECAP
********************************************************************
host1 : ok=1 changed=0 unreachable=0 failed=0
host2 : ok=1 changed=0 unreachable=0 failed=0
# cat test_inventory
[group1]
host1
[group2]
host2
Does that mean `run_once` and `when` better not to be used together?
Shouldn't that `include: test.yml` only executed when `inventory_hostname
in groups['group2']` satisfied? Some pointer or explanation would be highly
appreciated.
Thanks,
QY
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/7adbfe07-0526-4e82-b86e-260793fc741f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.