Hi Team,

Good Day!! Am not able to use *Connection: local and Delegate_to *together 
in my playbooks. 

*Actual Result *- Both debug outputs give me the same hostname. 
*Expected Result: *First debug should have given me the localhost hostname 
and second debug should have given me the "pocansibletest" as per the 
playbook. But doesnt work as expected.

*Playbook:*
- hosts: pocansibletest
  connection: local
  become: false
  remote_user: admin
  tasks:
    - name: Set VM_Name as fact
      set_fact:
        vm_name: "{{ inventory_hostname }}"  

    - name: Test host name without delegation
      shell: hostname
      register: name_without_del

    - name: Debug host name without delegation
      debug:
        msg: "Debug host name without delegation - {{ 
name_without_del.stdout }}"
   
    - name: Test host name with delegation
      delegate_to: "{{vm_name}}"
      shell: hostname
      register: name_with_del

    - name: Debug host name with delegation
      debug:
        msg: "Debug host name with delegation - {{ name_with_del.stdout 
}}"      

Thanks & Regards,
Vichu

-- 
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/9694ea74-94bf-42cb-a3f9-18af78df392en%40googlegroups.com.

Reply via email to