On 04.06.2019 14:58, Piotr Owcarz wrote:
Hello All
I have the following inventory:
...
[group1]
host1
[group2]
host2
[all]
host1
host2
...
and a playbook:
- name: play1
hosts: group1
tasks:
- add_host:
name: "{{groups[group2] | first}}"
groups: temp_group
- debug: var=groups.temp_group
- name: play2
hosts: temp_group
tasks:
- debug: msg="yay"
My intention is to execute a play on host1, where I read a host on
which
next play is going to be executed, and execute the second play on that
host, but when I execute the playbook with --limit group1 even though
the
host2 is added to temp_group, ansible won't match any hosts to run the
second play on. The output (writing from top of my head) :
$ ansible-playbook playbook.yml --limit group1
PLAY [play1] ***************
TASK [add_host] ************
ok: [host1]
TASK [debug] ***************
ok: [host1] => {
"groups.temp_group" : [
"host2"
]
}
PLAY [play2] ***************
skipping: no hosts matched
Is there any way to make the add_host work with --limit?
The whole point with limit is to say, only run on this/these host(s), so
no unless you add that host to the limit statement.
Since you only have one host in group1 limit is not needed.
--
Kai Stian Olstad
--
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/3f2542fd49b0223306379344ae6356f8%40olstad.com.
For more options, visit https://groups.google.com/d/optout.