On 22.01.2020 18:46, Punit Jain wrote:
run.yml
----------
---
- hosts: all
  connection: local
  gather_facts: no

  tasks:
    - name: include role task
      include_role:
        name: role1
        tasks_from: hello

- hosts: all
  connection: local
  gather_facts: no

  tasks:
    - name: include role task
      include_role:
        name: role1
        tasks_from: bye

then inside role tasks:
------------------------
hello.yml

- name: add host
  add_host:
    name: 'test'
    groups: all

There is no point in adding a host to all, the all group are a special group that all hosts is a member of.


- name: refresh
  meta: refresh_inventory

Here you say, purge my inventory and read it in again.
Then all your dynamic hosts get purged and your inventory is read again which don't have the dynamic ones.
So just remove this task and it should work.

--
Kai Stian Olstad

--
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/fac6182c0599ffb8b24b184ef0513cca%40olstad.com.

Reply via email to