You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- name: Test Inventory #The Task Name
hosts: cisco #This will be in your ansible inventory file
connection: local #Required
gather_facts: no #Do not gather facts
tasks: #Begin Tasks
- name: get facts from device #Task Name
napalm_get_facts: #Call the napalm module, in this case napal_get_facts
hostname: "{{ inventory_hostname }}" #This is a parameter and is derived from your ansible inventory file
username: 'admin' #The username to ssh with
dev_os: 'nxos_ssh' #The hardware operating system
password: 'xxxx' #The line level password
filter: 'facts' #The list of items you want to retrieve. The filter keyword is _inclusive_ of what you want
register: result #Ansible function for collecting output
- name: print results #Task Name
debug: msg="{{ result }}" #Display the collected output
The playbook does not work
(flacommare_venv2.7) florian@ubuntuvm:~/ansible$ ansible-playbook playbooks/get_facts.yaml -i inventory/host.ini
PLAY [Test Inventory] ************************************************************************************************************************************************************************************************************************
TASK [get facts from device] *****************************************************************************************************************************************************************************************************************
fatal: [leaf2]: FAILED! => {"changed": false, "msg": "cannot connect to device: Cannot connect to leaf2"}
fatal: [leaf1]: FAILED! => {"changed": false, "msg": "cannot connect to device: Cannot connect to leaf1"}
fatal: [leaf3]: FAILED! => {"changed": false, "msg": "cannot connect to device: Cannot connect to leaf3"}
fatal: [spine2]: FAILED! => {"changed": false, "msg": "cannot connect to device: Cannot connect to spine2"}
fatal: [spine1]: FAILED! => {"changed": false, "msg": "cannot connect to device: Cannot connect to spine1"}
fatal: [leaf4]: FAILED! => {"changed": false, "msg": "cannot connect to device: Cannot connect to leaf4"}
to retry, use: --limit @/home/florian/ansible/playbooks/get_facts.retry
PLAY RECAP ***********************************************************************************************************************************************************************************************************************************
leaf1 : ok=0 changed=0 unreachable=0 failed=1
leaf2 : ok=0 changed=0 unreachable=0 failed=1
leaf3 : ok=0 changed=0 unreachable=0 failed=1
leaf4 : ok=0 changed=0 unreachable=0 failed=1
spine1 : ok=0 changed=0 unreachable=0 failed=1
spine2 : ok=0 changed=0 unreachable=0 failed=1
Indeed, the module code set the local params to override provider. (
You should follow the last example which doen't use any hostname parameter.
If you don't provide the hostname parameter, ansible_host will be used instead of the inventory hostname if provided in the vars.
Hello guys,
When we follow examples (http://napalm.readthedocs.io/en/latest/tutorials/ansible-napalm.html or https://github.com/napalm-automation/napalm-ansible#examples), the
hostname
is using the{{ inventory_hostname }}
But a classic host file is :
Here's the playbook example :
The playbook does not work
Indeed, the module code set the local params to override provider. (
napalm-ansible/napalm_ansible/modules/napalm_get_facts.py
Line 192 in 8d868d3
So my IP is not use but the "name" of the equipment, which is not a dns entry.
Is there some mistake in my inventory file ? Or maybe the example have a mistake and should use
{{ ansible_host }}
instead ?The text was updated successfully, but these errors were encountered: