napalm-automation / napalm-ansible

Apache License 2.0
245 stars 103 forks source link

Issue with napalm_get_facts #169

Closed mfierbaugh closed 4 years ago

mfierbaugh commented 4 years ago

I am having an issue with the get_facts module where it complains of unsupported parameters being passed.

ansible --version ansible 2.9.6 config file = /etc/ansible/ansible.cfg configured module search path = [u'/Library/Python/2.7/site-packages/napalm_ansible/modules'] ansible python module location = /Library/Python/2.7/site-packages/ansible executable location = /usr/local/bin/ansible python version = 2.7.16 (default, Dec 13 2019, 18:00:32) [GCC 4.2.1 Compatible Apple LLVM 11.0.0 (clang-1100.0.32.4) (-macos10.15-objc-s

Name: napalm Version: 2.5.0 ... Location: /Library/Python/2.7/site-packages Requires: pyIOSXR, netaddr, ciscoconfparse, future, pyYAML, pyeapi, junos-eznc, paramiko, scp, textfsm, netmiko, jinja2, nxapi-plumbing, cffi, setuptools Required-by: napalm-ansible

=== result of playbook ran with -vvv ===

fatal: [node_t2_2]: FAILED! => { "changed": false, "invocation": { "module_args": { "dev_os": "iosxr", "hostname": "172.26.32.154", "password": "cisco123", "provider": { "dev_os": null, "hostname": "172.26.32.154", "password": null, "timeout": 60, "username": "admin" }, "username": "admin" } }, "msg": "Unsupported parameters for (napalm_get_facts) module: provider Supported parameters include: dev_os, hostname, password, username" }

ktbyers commented 4 years ago

Can you post your playbook?

mfierbaugh commented 4 years ago

very simple. It merely a slightly modified version of the example to address the host file input.

run as: ansible-playbook -i hosts.yml test.yml


---
- hosts: all
  connection: local
  vars:
    ansible_python_interpreter: "/usr/bin/env python"
  tasks:
    - napalm_get_facts:
        hostname: "{{ ansible_host }}"
        username: "{{ ansible_user }}"
        password: "{{ ansible_pass }}"
        dev_os: "iosxr"
      register: version

    - debug:
        var=version.ansible_facts.napalm_facts.os_version
ktbyers commented 4 years ago

Hmmm...this worked for me (I switched it to "ios" as I had IOS devices I could very easily test on).

---
- hosts: cisco
  connection: local
  gather_facts: False
  tasks:
    - napalm_get_facts:
        hostname: "{{ ansible_host }}"
        username: "{{ ansible_user }}"
        password: "{{ ansible_ssh_pass }}"
        dev_os: "ios"
      register: version

    - debug:
        var=version.ansible_facts.napalm_facts.os_version

Which version of napalm-ansible are you using? I recommend you install and test the develop branch on github and let me know what you see then.

ktbyers commented 4 years ago

Additional information needed...closing for now. Re-open if you are still having an issue.