Ah! That seems to be it. The following works:
ansible-playbook dynamic-host2.yml -i /dev/null -vvvv
dynamic-host2.yml:
- hosts: localhost
tasks:
- name: add remote host
add_host:
name: remote
ansible_host: 10.0.0.1
ansible_port: 22
ansible_ssh_common_args: '-o ProxyCommand="ssh -o ForwardAgent=yes
-p 22022 -W %h:%p -q 10.1.0.1"'
- hosts: remote
name: hello world
tasks:
- shell: echo "hello world!"
Den måndag 6 februari 2017 kl. 16:50:55 UTC+1 skrev Johannes Kastl:
>
> On 06.02.17 15:34 Linus Sunde wrote:
>
> > I have two playbooks and a hosts file:
>
> > Any ideas why this is happening?
>
> Second guess:
> By adding the hosts via add_hosts you overwrite your definition in the
> hosts file. And thus none of your options are set anymore. Note that
> this is just in memory, so your hosts file wont get changed.
>
> If you call the static play, it uses the hosts file with parameters.
>
> Solution:
>
> A) Move the parameters to the host_vars for this host.
>
> B) Call add_hosts with the parameters.
>
> Johannes
>
>
--
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/2cacb77e-287b-4d62-b6f6-85e3de099984%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.