As suggested by  @jimi-c (https://github.com/jimi-c), I post here the 
follow-up discussion of this ticket: 
https://github.com/ansible/ansible/issues/6912, which concerns the 
inability and issues to use `add_host` or group_by/set_fact to "dynamically 
add new hosts to playbook inventory and groups for many hosts and not only 
the first host in the inventory"

I have encountered this problem in my playbook (see the follwing code), 
where add_host does not see the whole inventory when I try to use it to add 
new hosts to playbook inventory and groups.  Someone posted there an idea 
to use set_fact and group-by to do this, but I still don't understand how 
to achieve the same dynamic behavior where new hosts should be added to 
groups using set_facts and group-by.. Specifically, I would like toi know 
which facts should I set to achieve the same as with add_host, that in my 
case is used like this: 

- name: Register new LXCs to inventory`

    add_host:
      ansible_user: "{{ item.item.value.operuser }}"
      name: "{{ item.lxc_container.ips.0 }}"
      groups: "lxcs"
      srvname: "{{ ansible_host }}"
  with_items: "{{ lxcs_info.results }}"

In the code above, the <pre>lxcs_info.results</pre> var has alll the item 
data needed for this task to run, but the "add_host" does not add hosts to 
all hosts in the inventory, but only the first host specified in the 
inventory/hosts -file. So please, how can I do this with "add_hosts" or 
the  "set_facts + group_by" -method as suggested by @mpdehaan 
<https://github.com/mpdehaan>, (in the orginal GitHub-thread)  thanks! 

-- 
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/0220afc3-b985-46df-8245-81f400bbc1d2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to