Get data from Cisco Catalyst Center using Ansible

I am trying to get some info out of Cisco Catalyst center using Ansible. I followed This tutorial..

As far as I can tell everything is installed correctly.

Im using Cisco sandbox for the Catalyst center and VPN is connected to it.

This is my host file:

dnac_servers:
  hosts:
    dnac_server:
      dnac_host: xx.xx.xx.xx
      dnac_port: 443
      dnac_username: user
      dnac_password: password

This is my playbook:

- hosts: dnac_servers
  tasks:
  - name: DNA test
    cisco.dnac.device_details_info:
      identifier: string
      searchBy: string
    register: result

And the error I get when trying to run:

ansible-playbook -i hosts.yml playbook.yml

PLAY [dnac_servers] *********************************************************************************************************************************************************************************************
TASK [Gathering Facts] ******************************************************************************************************************************************************************************************
fatal: [dnac_server]: UNREACHABLE! => {“changed”: false, “msg”: “Failed to connect to the host via ssh: ssh: Could not resolve hostname dnac_server: Temporary failure in name resolution”, “unreachable”: true}
PLAY RECAP ******************************************************************************************************************************************************************************************************
dnac_server : ok=0 changed=0 unreachable=1 failed=0 skipped=0 rescued=0 ignored=0

I see that there is some problem with resolving the server address. But I cant get around it.

I have searched google for different ways how to define host file etc. Yet I don’t get why this is not working after the mentioned tutorial.

Does it help if you add a ansible_host variable pointing to the IP address? I think this might resolve the “Could not resolve hostname dnac_server” error?

Also the YAML hosts files I have are in the following format, however I realise that what you have matches the documentation, so perhaps this isn’t an issue? :person_shrugging:

all:
  children:
    dnac_servers:
      hosts:
        dnac_server:
          ansible_host: xx.xx.xx.xx
          dnac_host: xx.xx.xx.xx
          dnac_port: 443
          dnac_username: user
          dnac_password: password