On Mon, 30 Dec 2019 12:26:17 +0100
Vladimir Botka <vbo...@gmail.com> wrote:

> On Mon, 30 Dec 2019 02:07:24 -0800 (PST)
> Yehuda Pinhas <yuda.pin...@gmail.com> wrote:
> 
>       - add_host:
>           name: "{{ item.1 }}"
>           groups: "{{ item.0.group }}"
>           ansible_ssh_private_key_file: /home/ansible/.ssh/id_rsa
>           ansible_ssh_common_args: -o StrictHostKeyChecking=no
>                                    -o UserKnownHostsFile=/dev/null
>           ansible_user: ansible
>         loop: "{{ lookup('subelements', my_hosts, 'hosts') }}"

It's possible to put the variables into the "group_vars". For example

       - add_host:
           name: "{{ item.1 }}"
           groups: "{{ item.0.group }}"
         loop: "{{ lookup('subelements', my_hosts, 'hosts') }}"

with the group_vars below give the same results

  $ cat group_vars/POC_ENV.yml 
  ---
  ansible_ssh_private_key_file: /home/ansible/.ssh/id_rsa
  ansible_ssh_common_args: -o StrictHostKeyChecking=no
                           -o UserKnownHostsFile=/dev/null
  ansible_user: admin

HTH,

        -vlado

-- 
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 ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/20191230125521.7ab18dcd%40gmail.com.

Attachment: pgpjsHojfntRI.pgp
Description: OpenPGP digital signature

Reply via email to