Cisco NDFC Ansible collection

Hi, I am trying to collect switch configuration details from Cisco NDFC controller. I have installed ansible collection with cisco.dcnm = 3.5.1, ansible.netcommon = 7.1.0. Ansible version = 2.14.14.

Ansible_script:

---
- name: Collect switch configuration from Cisco NDFC using cisco.dcnm
  hosts: localhost
  connection: network_cli
  gather_facts: no

  collections:
    - cisco.dcnm
 tasks:
    - name: Get inventory of switches from NDFC fabric
      cisco.dcnm.dcnm_inventory:
        src: inventory
        state: merged
        fabric: "{{ fabric_name }}"
        host: "{{ ndfc_host }}"
        auth_token: "{{ api_key }}"
        validate_certs: "{{ verify_ssl }}"
      register: switch_inventory

    - name: Display switch inventory
      debug:
        msg: "{{ switch_inventory }}"
    - name: Save switch inventory to a file
      copy:
        content: "{{ switch_inventory | to_nice_json }}"
        dest: "/tmp/switch_inventory.json"

Error:

ModuleNotFoundError: No module named 'ansible_collections.ansible.utils'
fatal: [localhost]: FAILED! => {
    "msg": "Unexpected failure during module execution: No module named 'ansible_collections.ansible.utils'",
    "stdout": ""
}
$ ansible-galaxy collection install ansible.utils

Which should automatically happen if you install ansible.netcommon, since that depends on ansible.utils (ansible.netcommon/galaxy.yml at v7.1.0 · ansible-collections/ansible.netcommon · GitHub). How did you install the collections?

1 Like

I have downloaded tar files from ansible-galaxy for ansible.netcommon packages and installed it.

1 Like

Ok, that makes sense. If you are in an air-gapped environment or cannot access galaxy.ansible.com, you must download and install ansible.utils too.

Ok fine, thanks for your reply. Let me check it