On 30. sep. 2016 02:30, Tristan Muntsinger wrote:
> Using your example (and replacing 'a1' with the host I care about) doesn't
> appear to work. This is what I see:
>
> PLAY [test]
> *******************************************************************
> skipping: no hosts matched
>
> When I directly copy/paste the hostname into hosts in the second play, it
> works as expected.
It works for me with Ansible 2.1.1.
---
- hosts: localhost
tasks:
- command: echo "a1"
register: result
- hosts: "{{ hostvars['localhost']['result']['stdout'] }}"
tasks:
- debug: var=play_hosts
$ ansible-playbook test.yml
PLAY [localhost] **********************************************
TASK [setup] **************************************************
ok: [localhost]
TASK [command] ************************************************
changed: [localhost]
PLAY [a1] *****************************************************
TASK [setup] **************************************************
ok: [a1]
TASK [debug] **************************************************
ok: [a1] => {
"play_hosts": [
"a1"
]
}
PLAY RECAP ***************************************************************
a1 : ok=2 changed=0 unreachable=0 failed=0
localhost : ok=2 changed=1 unreachable=0 failed=0
--
Kai Stian Olstad