Hello,

I'm trying to use the setup module with delegation, but I don't understand 
one thing. Here is my test playbook :

- hosts: webservers
  tasks:
    - debug: var=ansible_hostname


    - name: Get sql master facts
      setup:
      delegate_to: "mrk-test-sql1"
      register: sql_master_facts


    - debug: var=sql_master_facts.ansible_facts.ansible_default_ipv4.address


    - debug: var=ansible_hostname

I just want to retrieve the private ip of my master db with Ansible facts 
and add it in the /etc/hosts file of my web servers. Here is the output :

PLAY [webservers] 
************************************************************* 


GATHERING FACTS 
*************************************************************** 
ok: [mrk-test-web1]
ok: [mrk-test-web2]


TASK: [debug var=ansible_hostname] 
******************************************** 
ok: [mrk-test-web1] => {
    "ansible_hostname": "mrk-test-web1"
}
ok: [mrk-test-web2] => {
    "ansible_hostname": "mrk-test-web2"
}


TASK: [Get sql master facts] 
************************************************** 
ok: [mrk-test-web2 -> mrk-test-sql1]
ok: [mrk-test-web1 -> mrk-test-sql1]


TASK: [debug var=sql_master_facts.ansible_facts.ansible_default_ipv4.address
] *** 
ok: [mrk-test-web1] => {
    "sql_master_facts.ansible_facts.ansible_default_ipv4.address": 
"10.240.16.26"
}
ok: [mrk-test-web2] => {
    "sql_master_facts.ansible_facts.ansible_default_ipv4.address": 
"10.240.16.26"
}


TASK: [debug var=ansible_hostname] 
******************************************** 
ok: [mrk-test-web1] => {
    "ansible_hostname": "mrk-test-sql1"
}
ok: [mrk-test-web2] => {
    "ansible_hostname": "mrk-test-sql1"
}



PLAY RECAP 
******************************************************************** 
mrk-test-web1              : ok=5    changed=0    unreachable=0    failed=0 
  
mrk-test-web2              : ok=5    changed=0    unreachable=0    failed=0

All work, but I don't understand the result of the latest task. Why is it 
not like this (like the result of the first task) :

TASK: [debug var=ansible_hostname] 
******************************************** 
ok: [mrk-test-web1] => {
    "ansible_hostname": "mrk-test-web1"
}
ok: [mrk-test-web2] => {
    "ansible_hostname": "mrk-test-web2"
}

Normally, gathering facts with delegate should not overwrite the current 
facts of my web servers ?

My workaround to fix the problem is to recall "setup" for my web server.

Thanks.

Regards,
Antoine Rouaze

-- 
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/9084d4eb-3b53-40d7-b5a7-74253a5c72e5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to