ansible_modules
ansible_modules copied to clipboard
[Bug]: cable module not working after upgrade to Netbox 3.3.1
Ansible NetBox Collection version
v3.7.1
Ansible version
ansible 2.10.1
config file = /etc/ansible/ansible.cfg
configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /var/lib/awx/venv/python3-ansible2.10.0rc1-2292020/lib/python3.6/site-packages/ansible
executable location = /var/lib/awx/venv/python3-ansible2.10.0rc1-2292020/bin/ansible
python version = 3.6.8 (default, Aug 13 2020, 07:46:32) [GCC 4.8.5 20150623 (Red Hat 4.8.5-39)]
NetBox version
v3.3.1
Python version
3.8
Steps to Reproduce
Creating cable between two dcim.interface objects:
tasks: - name: Creating connection netbox.netbox.netbox_cable: netbox_url: http://netbox.int.kn netbox_token: "{{ api_token }}" data: termination_a_type: dcim.interface termination_a: device: m4200101248 name: swp1 termination_b_type: dcim.interface termination_b: device: usngkvi0003 name: mgmt type: cat7 color: 0000ff length: 3 length_unit: m label: "Test Cables" status: connected state: present
Expected Behavior
New cable created
Observed Behavior
Returned 'Attribute has no object type: "termination_a_type"' due to the API changing in 3.3.1 to accommodate cables with multiple terminations on one end.
{ "module_stdout": "", "module_stderr": "Traceback (most recent call last):\n File \"/var/lib/awx/.ansible/tmp/ansible-tmp-1662492535.5759676-10-144178772028448/AnsiballZ_netbox_cable.py\", line 102, in <module>\n _ansiballz_main()\n File \"/var/lib/awx/.ansible/tmp/ansible-tmp-1662492535.5759676-10-144178772028448/AnsiballZ_netbox_cable.py\", line 94, in _ansiballz_main\n invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n File \"/var/lib/awx/.ansible/tmp/ansible-tmp-1662492535.5759676-10-144178772028448/AnsiballZ_netbox_cable.py\", line 40, in invoke_module\n runpy.run_module(mod_name='ansible_collections.netbox.netbox.plugins.modules.netbox_cable', init_globals=None, run_name='__main__', alter_sys=True)\n File \"/usr/lib64/python3.6/runpy.py\", line 205, in run_module\n return _run_module_code(code, init_globals, run_name, mod_spec)\n File \"/usr/lib64/python3.6/runpy.py\", line 96, in _run_module_code\n mod_name, mod_spec, pkg_name, script_name)\n File \"/usr/lib64/python3.6/runpy.py\", line 85, in _run_code\n exec(code, run_globals)\n File \"/tmp/ansible_netbox.netbox.netbox_cable_payload_xerf1j8f/ansible_netbox.netbox.netbox_cable_payload.zip/ansible_collections/netbox/netbox/plugins/modules/netbox_cable.py\", line 366, in <module>\n File \"/tmp/ansible_netbox.netbox.netbox_cable_payload_xerf1j8f/ansible_netbox.netbox.netbox_cable_payload.zip/ansible_collections/netbox/netbox/plugins/modules/netbox_cable.py\", line 362, in main\n File \"/tmp/ansible_netbox.netbox.netbox_cable_payload_xerf1j8f/ansible_netbox.netbox.netbox_cable_payload.zip/ansible_collections/netbox/netbox/plugins/module_utils/netbox_dcim.py\", line 148, in run\n File \"/tmp/ansible_netbox.netbox.netbox_cable_payload_xerf1j8f/ansible_netbox.netbox.netbox_cable_payload.zip/ansible_collections/netbox/netbox/plugins/module_utils/netbox_dcim.py\", line 149, in <listcomp>\n File \"/var/lib/awx/venv/python3-ansible2.10.0rc1-2292020/lib/python3.6/site-packages/pynetbox/core/response.py\", line 298, in __getattr__\n raise AttributeError('object has no attribute \"{}\"'.format(k))\nAttributeError: object has no attribute \"termination_a_type\"\n", "exception": "Traceback (most recent call last):\n File \"/var/lib/awx/.ansible/tmp/ansible-tmp-1662492535.5759676-10-144178772028448/AnsiballZ_netbox_cable.py\", line 102, in <module>\n _ansiballz_main()\n File \"/var/lib/awx/.ansible/tmp/ansible-tmp-1662492535.5759676-10-144178772028448/AnsiballZ_netbox_cable.py\", line 94, in _ansiballz_main\n invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n File \"/var/lib/awx/.ansible/tmp/ansible-tmp-1662492535.5759676-10-144178772028448/AnsiballZ_netbox_cable.py\", line 40, in invoke_module\n runpy.run_module(mod_name='ansible_collections.netbox.netbox.plugins.modules.netbox_cable', init_globals=None, run_name='__main__', alter_sys=True)\n File \"/usr/lib64/python3.6/runpy.py\", line 205, in run_module\n return _run_module_code(code, init_globals, run_name, mod_spec)\n File \"/usr/lib64/python3.6/runpy.py\", line 96, in _run_module_code\n mod_name, mod_spec, pkg_name, script_name)\n File \"/usr/lib64/python3.6/runpy.py\", line 85, in _run_code\n exec(code, run_globals)\n File \"/tmp/ansible_netbox.netbox.netbox_cable_payload_xerf1j8f/ansible_netbox.netbox.netbox_cable_payload.zip/ansible_collections/netbox/netbox/plugins/modules/netbox_cable.py\", line 366, in <module>\n File \"/tmp/ansible_netbox.netbox.netbox_cable_payload_xerf1j8f/ansible_netbox.netbox.netbox_cable_payload.zip/ansible_collections/netbox/netbox/plugins/modules/netbox_cable.py\", line 362, in main\n File \"/tmp/ansible_netbox.netbox.netbox_cable_payload_xerf1j8f/ansible_netbox.netbox.netbox_cable_payload.zip/ansible_collections/netbox/netbox/plugins/module_utils/netbox_dcim.py\", line 148, in run\n File \"/tmp/ansible_netbox.netbox.netbox_cable_payload_xerf1j8f/ansible_netbox.netbox.netbox_cable_payload.zip/ansible_collections/netbox/netbox/plugins/module_utils/netbox_dcim.py\", line 149, in <listcomp>\n File \"/var/lib/awx/venv/python3-ansible2.10.0rc1-2292020/lib/python3.6/site-packages/pynetbox/core/response.py\", line 298, in __getattr__\n raise AttributeError('object has no attribute \"{}\"'.format(k))\nAttributeError: object has no attribute \"termination_a_type\"\n", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1, "_ansible_no_log": false, "changed": false, "item": "usngkvi0003;iDrac;m4200101248;swp2;15", "ansible_loop_var": "item", "ansible_loop": { "allitems": [ "usngkvi0003;iDrac;m4200101248;swp2;15" ], "index": 1, "index0": 0, "first": true, "last": true, "length": 1, "revindex": 1, "revindex0": 0 }, "_ansible_item_label": "usngkvi0003;iDrac;m4200101248;swp2;15" }
Yes, the cable changes in 3.3 has not been implemented in the ansible modules yet.
Thanks for the confirmation, is there a timeline for when this will be added?
Matt Agresta Systems Engineer
Kuehne + Nagel Inc. 22 Spencer Street Naugatuck, CT 06770, USA
p. +1 203 714 8908 e. @.@.>
Update on Ukraine and Russiahttps://home.kuehne-nagel.com/-/news/update-on-ukraine-and-russia?utm_source=email&utm_campaign=GLUkraineRussiaUpdate2022&utm_medium=signature
us.kuehne-nagel.comhttps://us.kuehne-nagel.com/?utm_source=signatureURLUSA&utm_medium=signatureURLUSA&utm_campaign=signatureURLUSA
From: Martin Rødvand @.> Sent: Wednesday, September 7, 2022 9:53 AM To: netbox-community/ansible_modules @.> Cc: Agresta, Matt / Kuehne + Nagel / Ngk MI-II @.>; Author @.> Subject: Re: [netbox-community/ansible_modules] [Bug]: cable module not working after upgrade to Netbox 3.3.1 (Issue #825)
EXTERNAL EMAIL
Yes, the cable changes in 3.3 has not been implemented in the ansible modules yet.
— Reply to this email directly, view it on GitHubhttps://github.com/netbox-community/ansible_modules/issues/825#issuecomment-1239421614, or unsubscribehttps://github.com/notifications/unsubscribe-auth/A26M2LHKRMBCELNBWWCI6TTV5CM3BANCNFSM6AAAAAAQGZHCN4. You are receiving this because you authored the thread.Message ID: @.@.>>
Impossible to say. The ansible modules rely on the pynetbox library for its changes, and it seems like the cable changes hasn't made it to their codebase yet.
I ended up coding the equivalent using nb_lookup, and uri modules.
Should be fixed in collection 3.11.0.