Hi,
Lets say I have a playbook with two plays and the first one determines the
hosts on which the second play should run. For instance, lets assume the
first play is a local play that has one task. The task runs a script and
its output provides the server(s) that the next play should run in.
#Play 1
hosts: 127.0.0.1
remote_user: some_user
tasks:
- name: host identifying task
script: scripts/find_my_hosts.sh
register: second_play_hosts
- debug: var=second_play_hosts
Lets assume the script output is properly formatted, with multiple hosts
colon-separated. All hosts are accounted for in the inventory.
Question is, how do I use the value registered in "*second_play_hosts*" to
run my second play on? It appears a hostvars reference does not work for
the "*hosts*" element, i.e -
#Play 2
hosts: "{{ hostvars['127.0.0.1']['second_play_hosts'].stdout }}"
remote_user: some_user
tasks:
- name: random task
shell: echo "Hi"
- doesn't appear to work. The execution merely skips the second play
stating "skipping: no hosts matched", because its not interpreting the
variable reference and is doing a literal comparison.
Any insight into this is appreciated.
Regards
--
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/6dd20a4e-3862-49e9-8f06-f06f70db6f66%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.