nautobot / nautobot-ansible

Ansible Collection for managing Nautobot Data
https://docs.nautobot.com/projects/ansible/en/latest/
GNU General Public License v3.0
48 stars 33 forks source link

Add 'site' - traceback #34

Closed jifox closed 3 years ago

jifox commented 3 years ago
ISSUE TYPE
SOFTWARE VERSIONS
pynautobot

pynautobot==1.0.1

Ansible:
ansible 2.10.8
  config file = /home/ansible/devel/nautobot-transfer/ansible.cfg
  configured module search path = ['/home/ansible/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/ansible/devel/nautobot-transfer/lib64/python3.6/site-packages/ansible
  executable location = /home/ansible/devel/nautobot-transfer/bin/ansible
  python version = 3.6.8 (default, Nov 16 2020, 16:55:22) [GCC 4.8.5 20150623 (Red Hat 4.8.5-44)]
Nautobot:

d7d27ecaeccd (v1.0.0b5)

Collection:
Collection                    Version
----------------------------- -------
amazon.aws                    1.4.1  
ansible.netcommon             1.5.0  
ansible.posix                 1.2.0  
ansible.utils                 2.0.2  
ansible.windows               1.5.0  
arista.eos                    1.3.0  
awx.awx                       17.1.0 
azure.azcollection            1.5.0  
check_point.mgmt              2.0.0  
chocolatey.chocolatey         1.1.0  
cisco.aci                     2.0.0  
cisco.asa                     1.0.4  
cisco.intersight              1.0.12 
cisco.ios                     1.3.0  
cisco.iosxr                   1.2.1  
cisco.meraki                  2.2.1  
cisco.mso                     1.1.0  
cisco.nso                     1.0.3  
cisco.nxos                    1.4.0  
cisco.ucs                     1.6.0  
cloudscale_ch.cloud           2.1.0  
community.aws                 1.4.0  
community.azure               1.0.0  
community.crypto              1.6.1  
community.digitalocean        1.1.1  
community.docker              1.5.0  
community.fortios             1.0.0  
community.general             2.5.1  
community.google              1.0.0  
community.grafana             1.2.1  
community.hashi_vault         1.1.3  
community.hrobot              1.1.1  
community.kubernetes          1.2.1  
community.kubevirt            1.0.0  
community.libvirt             1.0.1  
community.mongodb             1.2.1  
community.mysql               1.4.0  
community.network             2.1.1  
community.okd                 1.1.2  
community.postgresql          1.2.0  
community.proxysql            1.0.0  
community.rabbitmq            1.0.3  
community.routeros            1.1.0  
community.skydive             1.0.0  
community.sops                1.0.6  
community.vmware              1.9.0  
community.windows             1.3.0  
community.zabbix              1.3.0  
containers.podman             1.5.0  
cyberark.conjur               1.1.0  
cyberark.pas                  1.0.6  
dellemc.openmanage            3.2.0  
dellemc.os10                  1.1.1  
dellemc.os6                   1.0.7  
dellemc.os9                   1.0.4  
f5networks.f5_modules         1.9.0  
fortinet.fortimanager         2.0.1  
fortinet.fortios              1.1.9  
frr.frr                       1.0.3  
gluster.gluster               1.0.1  
google.cloud                  1.0.2  
hetzner.hcloud                1.4.2  
ibm.qradar                    1.0.3  
infinidat.infinibox           1.2.4  
inspur.sm                     1.1.2  
junipernetworks.junos         1.3.0  
kubernetes.core               1.2.1  
mellanox.onyx                 1.0.0  
netapp.aws                    20.9.0 
netapp.elementsw              20.11.0
netapp.ontap                  21.4.0 
netapp_eseries.santricity     1.2.7  
netbox.netbox                 2.1.0  
ngine_io.cloudstack           2.1.0  
ngine_io.exoscale             1.0.0  
ngine_io.vultr                1.1.0  
openstack.cloud               1.4.0  
openvswitch.openvswitch       1.2.0  
ovirt.ovirt                   1.4.1  
purestorage.flasharray        1.7.0  
purestorage.flashblade        1.5.0  
sensu.sensu_go                1.9.4  
servicenow.servicenow         1.0.4  
splunk.es                     1.0.2  
t_systems_mms.icinga_director 1.16.0 
theforeman.foreman            1.5.1  
vyos.vyos                     1.1.1  
wti.remote                    1.0.1
SUMMARY

During insert a new site a traceback is shown.

STEPS TO REPRODUCE
    - name: "Add Sites in Nautobot"
      networktocode.nautobot.site:
        url: "{{ nburl }}"
        token: "{{ nbtoken }}"
        validate_certs: no
        state: present
        data: "{{ item }}"
      loop: "{{ nbsites }}"
      tags:
      - sites
nbsites: 
    - name: "DEBE"
       slug: "site-debe"
       status: "active"
       description: "ACME Germany "
       time_zone: "Europe/Berlin
       tenant: "tenant-debe"
       comments: "- ACME Berlin\n- ACME Systems Germany GmbH"
EXPECTED RESULTS

Site is added into Anutobot

ACTUAL RESULTS

TASK [Add Sites in Nautobot] ***************************************************
task path: /home/ansible/devel/develop/nautobot-transfer.yml:91
<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: ansible
<127.0.0.1> EXEC /bin/sh -c 'echo ~ansible && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/ansible/.ansible/tmp `"&& mkdir "` echo /home/ansible/.ansible/tmp/ansible-tmp-1619068766.2322965-1697-137024437752866 `" && echo ansible-tmp-1619068766.2322965-1697-137024437752866="` echo /home/ansible/.ansible/tmp/ansible-tmp-1619068766.2322965-1697-137024437752866 `" ) && sleep 0'
Using module file /home/ansible/.ansible/collections/ansible_collections/networktocode/nautobot/plugins/modules/site.py
<127.0.0.1> PUT /home/ansible/.ansible/tmp/ansible-local-1670a4q5isnj/tmp99xjxkhu TO /home/ansible/.ansible/tmp/ansible-tmp-1619068766.2322965-1697-137024437752866/AnsiballZ_site.py
<127.0.0.1> EXEC /bin/sh -c 'chmod u+x /home/ansible/.ansible/tmp/ansible-tmp-1619068766.2322965-1697-137024437752866/ /home/ansible/.ansible/tmp/ansible-tmp-1619068766.2322965-1697-137024437752866/AnsiballZ_site.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '/home/ansible/devel/develop/nornir/bin/python3 /home/ansible/.ansible/tmp/ansible-tmp-1619068766.2322965-1697-137024437752866/AnsiballZ_site.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c 'rm -f -r /home/ansible/.ansible/tmp/ansible-tmp-1619068766.2322965-1697-137024437752866/ > /dev/null 2>&1 && sleep 0'
The full traceback is:
Traceback (most recent call last):
  File "/home/ansible/.ansible/tmp/ansible-tmp-1619068766.2322965-1697-137024437752866/AnsiballZ_site.py", line 102, in <module>
    _ansiballz_main()
  File "/home/ansible/.ansible/tmp/ansible-tmp-1619068766.2322965-1697-137024437752866/AnsiballZ_site.py", line 94, in _ansiballz_main
    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
  File "/home/ansible/.ansible/tmp/ansible-tmp-1619068766.2322965-1697-137024437752866/AnsiballZ_site.py", line 40, in invoke_module
    runpy.run_module(mod_name='ansible_collections.networktocode.nautobot.plugins.modules.site', init_globals=None, run_name='__main__', alter_sys=True)
  File "/usr/local/lib/python3.7/runpy.py", line 205, in run_module
    return _run_module_code(code, init_globals, run_name, mod_spec)
  File "/usr/local/lib/python3.7/runpy.py", line 96, in _run_module_code
    mod_name, mod_spec, pkg_name, script_name)
  File "/usr/local/lib/python3.7/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/tmp/ansible_networktocode.nautobot.site_payload_svnvmx5c/ansible_networktocode.nautobot.site_payload.zip/ansible_collections/networktocode/nautobot/plugins/modules/site.py", line 283, in <module>
    def check_enableusersite():
  File "/tmp/ansible_networktocode.nautobot.site_payload_svnvmx5c/ansible_networktocode.nautobot.site_payload.zip/ansible_collections/networktocode/nautobot/plugins/modules/site.py", line 278, in main
    if os.path.isdir(sitedir):
  File "/tmp/ansible_networktocode.nautobot.site_payload_svnvmx5c/ansible_networktocode.nautobot.site_payload.zip/ansible_collections/networktocode/nautobot/plugins/module_utils/dcim.py", line 50, in __init__
  File "/tmp/ansible_networktocode.nautobot.site_payload_svnvmx5c/ansible_networktocode.nautobot.site_payload.zip/ansible_collections/networktocode/nautobot/plugins/module_utils/utils.py", line 480, in __init__
  File "/tmp/ansible_networktocode.nautobot.site_payload_svnvmx5c/ansible_networktocode.nautobot.site_payload.zip/ansible_collections/networktocode/nautobot/plugins/module_utils/utils.py", line 813, in _change_choices_id
  File "/tmp/ansible_networktocode.nautobot.site_payload_svnvmx5c/ansible_networktocode.nautobot.site_payload.zip/ansible_collections/networktocode/nautobot/plugins/module_utils/utils.py", line 790, in _fetch_choice_value
KeyError: 'display_name'
failed: [localhost] (item={'name': 'DEBE', 'slug': 'site-debe', 'description': 'ACME Germany', 'status': 'active', 'time_zone': 'Europe/Berlin', 'tenant': 'tenant-debe', 'comments': '- ACME Berlin\n- ACME Systems Germany GmbH'}) => {
    "ansible_loop_var": "item",
    "changed": false,
    "item": {
        "comments": "- ACME Berlin\",
        "description": "ACME Germany ",
        "name": "DEBE",
        "slug": "site-debe",
        "status": "active",
        "tenant": "tenant-debe",
        "time_zone": "Europe/Berlin"
    },
    "rc": 1
}

MSG:

MODULE FAILURE
See stdout/stderr for the exact error

MODULE_STDERR:

Traceback (most recent call last):
  File "/home/ansible/.ansible/tmp/ansible-tmp-1619087657.4245238-14753-175208244676283/AnsiballZ_site.py", line 102, in <module>
    _ansiballz_main()
  File "/home/ansible/.ansible/tmp/ansible-tmp-1619087657.4245238-14753-175208244676283/AnsiballZ_site.py", line 94, in _ansiballz_main
    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
  File "/home/ansible/.ansible/tmp/ansible-tmp-1619087657.4245238-14753-175208244676283/AnsiballZ_site.py", line 40, in invoke_module
    runpy.run_module(mod_name='ansible_collections.networktocode.nautobot.plugins.modules.site', init_globals=None, run_name='__main__', alter_sys=True)
  File "/usr/lib64/python3.6/runpy.py", line 205, in run_module
    return _run_module_code(code, init_globals, run_name, mod_spec)
  File "/usr/lib64/python3.6/runpy.py", line 96, in _run_module_code
    mod_name, mod_spec, pkg_name, script_name)
  File "/usr/lib64/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/tmp/ansible_networktocode.nautobot.site_payload_5pxu34fm/ansible_networktocode.nautobot.site_payload.zip/ansible_collections/networktocode/nautobot/plugins/modules/site.py", line 283, in <module>

  File "/tmp/ansible_networktocode.nautobot.site_payload_5pxu34fm/ansible_networktocode.nautobot.site_payload.zip/ansible_collections/networktocode/nautobot/plugins/modules/site.py", line 278, in main
    home directory.
  File "/tmp/ansible_networktocode.nautobot.site_payload_5pxu34fm/ansible_networktocode.nautobot.site_payload.zip/ansible_collections/networktocode/nautobot/plugins/module_utils/dcim.py", line 50, in __init__
  File "/tmp/ansible_networktocode.nautobot.site_payload_5pxu34fm/ansible_networktocode.nautobot.site_payload.zip/ansible_collections/networktocode/nautobot/plugins/module_utils/utils.py", line 475, in __init__
  File "/tmp/ansible_networktocode.nautobot.site_payload_5pxu34fm/ansible_networktocode.nautobot.site_payload.zip/ansible_collections/networktocode/nautobot/plugins/module_utils/utils.py", line 811, in _change_choices_id
  File "/tmp/ansible_networktocode.nautobot.site_payload_5pxu34fm/ansible_networktocode.nautobot.site_payload.zip/ansible_collections/networktocode/nautobot/plugins/module_utils/utils.py", line 788, in _fetch_choice_value
KeyError: 'display_name'

PLAY RECAP *********************************************************************
localhost                  : ok=3    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0   
pip freeze

ansible==3.3.0
ansible-base==2.10.8
certifi==2020.12.5
cffi==1.14.5
chardet==4.0.0
cryptography==3.4.7
idna==2.10
Jinja2==2.11.3
MarkupSafe==1.1.1
packaging==20.9
pycparser==2.20
pynautobot==1.0.1
pyparsing==2.4.7
PyYAML==5.4.1
requests==2.25.1
urllib3==1.26.4
jvanderaa commented 3 years ago

This looks to be related to a change from display_name to display.

jvanderaa commented 3 years ago

Closed via #35