0

I am working through a short Cisco DevNet course on Ansible pushing playbooks to a node in CML. I made it through the section using Cisco IOSXE modules with no issue and have now made it to NETCONF. Im recieving a error iter() returned non-iterator of type 'dict_keys' when using these NETCONF plays. I have looked for solutions and have been trying to get this to work for about 6 hours now.

Error received:

fatal: [10.0.15.5]: FAILED! => {"changed": false, "module_stderr": "iter() returned non-iterator of type 'dict_keys'", "module_stdout": "", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error"}

I have tried using variables in the hosts file as well as in a /group_var/cisco.yml file, reboot the CML node, tried on Ubuntu, WSL, and installed a fresh RHEL to start over and try again.

Here are my current files...

Directory

[admin@localhost Automation-Stuff\]$ ls
ansible.cfg   group_vars   hosts   host_vars   play.yml

ansible.cfg

[defaults]
gathering=explicit
inventory=./hosts
host_key_checking=False
deprecation_warnings=False
interpreter_python=/usr/local/bin/python3

hosts

[cisco:vars]
ansible_connection=ansible.netcommon.netconf
netconf_port=830
ansible_user=admin
ansible_password=C1sco12345
ansible_become=yes
ansible_become_method=enable
ansible_network_os=cisco.ios.ios
subnet_id=5

Heres the playbook play.yml

---
- name: NETCONF set NTP server
  hosts: cisco
  gather_facts: false

  tasks:

  - name: set ntp server
    ansible.netcommon.netconf_config:
      content: |
            <config xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
              <native xmlns="http://cisco.com/ns/yang/Cisco-IOS-XE-native" xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0">
                <ntp>
                  <server xmlns="http://cisco.com/ns/yang/Cisco-IOS-XE-ntp">
                    <server-list>
                      <ip-address>10.1.{{subnet_id}}.1</ip-address>
                    </server-list>
                  </server>
                </ntp>
              </native>
            </config>

Here is the play output

[admin@localhost Automation-Stuff]$ ansible-playbook play.yml  
PLAY [NETCONF set NTP server] ************************************************************************************************************************************************************************************************************ 
TASK [set ntp server] ******************************************************************************************************************************************************************************************************************** 
fatal: [10.0.15.5]: FAILED! => {"changed": false, "module_stderr": "iter() returned non-iterator of type 'dict_keys'", "module_stdout": "", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error"} 
PLAY RECAP ******************************************************************************************************************************************************************************************************************************* 
10.0.15.5                  : ok=0    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0
4
  • Since the error seems to be caused by "Python wants an iterator, not a list (or other list-like / dict-like object)", in <ip-address>10.1.{{ subnet_id }}.1</ip-address>, where is the value coming from and how it looks like? Commented Jan 26 at 17:35
  • It should be puilling the value from the variable "subnet_id" within the hosts file like it did when i did this using the iosxe module. To check this I removed the variable fro mthe hosts file and hardcoded the ip address into the play. I recieved the same output with the change. Im curious to know how you determined the error is related to that line in particular? Maybe were o nthe right track here but im not sure why this is such a difficuly when using NETCONF. Oh i also tested a different play to for the same thing and stil lthe same issue. Commented Jan 27 at 3:35
  • "Im curious to know how you determined the error is related to that line in particular?", as that part <server xmlns="http://cisco.com/ns/yang/Cisco-IOS-XE-ntp"> <server-list> <ip-address>10.1.{{ subnet_id }}.1</ip-address> </server-list> </server> is named like it is for a list but not providing a list. Maybe you can test with two IP addresses? Commented Jan 27 at 7:58
  • Unfortunately I have no test environment for such at all and can only rely on documentation examples. Commented Jan 28 at 13:24

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.