Hello Team,

I am trying to run a playbook to gather facts from a nexus switch but
playbook run throws an error: 'Failed to resolve hostname
inventory_hostname'

However, in the debug message, I can see the inventory_hostname.

Here is my host file:

[all]

NEXUS3172P ansible_ssh_host=10.131.88.10 ansible_network_os=nxos
username=xxxx password=xxxxx


Below is the section of the tasks where I am getting error:
- name: '{{ msg_block }} Set CLI parameters'
  set_fact:
    cli:
      host: '{{ inventory_hostname }}'
      username: '{{ username }}'
      password: '{{ password }}'
      timeout: 21600
  no_log: true

- name: '{{ msg_block }} Gather hardware info'
  block:
    - name: '{{ msg_block }} Gather hardware info'
      nxos_facts:
        gather_subset: hardware
provider: '{{ cli }}'
      register: device_facts

[bkb1321@ansible-server playbooks]$ ansible-playbook image_copy_nexus.yaml
-i ../hosts

Enter your finastra email: hh



PLAY [Copy image to network device]
***********************************************************************************************************************



TASK [debug]
**********************************************************************************************************************************************

ok: [NEXUS3172P] => {

    "inventory_hostname": "NEXUS3172P"

}



TASK [NEXUS3172P Normalize variables]
*********************************************************************************************************************

ok: [NEXUS3172P]



TASK [NEXUS3172P Debug normalized variables]
**************************************************************************************************************

skipping: [NEXUS3172P]



TASK [NEXUS3172P image_copy_cisco_nexus.yaml]
*************************************************************************************************************

included: /etc/ansible/playbooks/play_image_copy_nexus.yaml for NEXUS3172P



TASK [NEXUS3172PSet CLI parameters]
***********************************************************************************************************************

ok: [NEXUS3172P]



TASK [NEXUS3172P Gather hardware info]
********************************************************************************************************************

fatal: [NEXUS3172P]: FAILED! => {"ansible_facts":
{"discovered_interpreter_python": "/usr/bin/python3"}, "changed": false,
"msg": "ssh connection failed: ssh connect failed: Failed to resolve
hostname inventory_hostname (Name or service not known)"}



TASK [set_fact]
*******************************************************************************************************************************************

ok: [NEXUS3172P]



Any help is much appreciated.



Thank you.

Bikram

-- 
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/CAEFfMJSobus8ka4OZJD3HevtPOc-EytCs0-_bJ4Tgtqu8YN2Rg%40mail.gmail.com.

Reply via email to