ansible_modules icon indicating copy to clipboard operation
ansible_modules copied to clipboard

[Bug]: netbox_cable errors on existing cables with termination type circuits.circuitterminations

Open saruter opened this issue 2 years ago • 0 comments

Ansible NetBox Collection version

v3.11.0

Ansible version

 config file = /etc/ansible/ansible.cfg
 configured module search path = ['/home/testuser/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
 ansible python module location = /usr/lib/python3.9/site-packages/ansible
 ansible collection location = /home/testuser.ansible/collections:/usr/share/ansible/collections
 executable location = /usr/bin/ansible
 python version = 3.9.14 (main, Dec  5 2022, 13:41:22) [GCC 8.5.0 20210514 (Red Hat 8.5.0-17)] (/usr/bin/python3.9)
 jinja version = 3.1.2
 libyaml = True

Pynetbox: 7.0.1

NetBox version

v3.4.4

Python version

3.9

Steps to Reproduce

Creating a new cable from termination_a_type: dcim.interface to termination_b_type: "circuits.circuittermination" works fine. But running the same playbook again fails with error in module. No Problems on cables with both termination type "dcim.interface".

Simple Task:

 tasks:
    - name: Create Cable
      netbox_cable:
        netbox_url: "{{ netbox_url }}"
        netbox_token:  "{{ netbox_token }}"
        data:
          termination_a_type: "dcim.interface"
          termination_a: 
            device: "Rxyy0001"
            name: "GE0/0/1"
          termination_b_type: "circuits.circuittermination"
          termination_b:
            circuit: "xyz-Primary"
            term_side: "A"
          status: "connected"
          type: "cat6"
        state: present
        validate_certs: false

Expected Behavior

netbox_cable module is idempotent. No errors when executing the same task twice.

Observed Behavior

Error as follows on the second run:

{
    "changed": false,
    "module_stderr": "/home/testuser/.local/lib/python3.9/site-packages/urllib3/connectionpool.py:1045: InsecureRequestWarning: Unverified HTTPS request is being made to host 'dev-netbox.redacted.domain'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/1.26.x/advanced-usage.html#ssl-warnings
  warnings.warn(
/home/testuser/.local/lib/python3.9/site-packages/urllib3/connectionpool.py:1045: InsecureRequestWarning: Unverified HTTPS request is being made to host 'dev-netbox.redacted.domain'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/1.26.x/advanced-usage.html#ssl-warnings
  warnings.warn(
/home/testuser/.local/lib/python3.9/site-packages/urllib3/connectionpool.py:1045: InsecureRequestWarning: Unverified HTTPS request is being made to host 'dev-netbox.redacted.domain'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/1.26.x/advanced-usage.html#ssl-warnings
  warnings.warn(
/home/testuser/.local/lib/python3.9/site-packages/urllib3/connectionpool.py:1045: InsecureRequestWarning: Unverified HTTPS request is being made to host 'dev-netbox.redacted.domain'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/1.26.x/advanced-usage.html#ssl-warnings
  warnings.warn(
/home/testuser/.local/lib/python3.9/site-packages/urllib3/connectionpool.py:1045: InsecureRequestWarning: Unverified HTTPS request is being made to host 'dev-netbox.redacted.domain'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/1.26.x/advanced-usage.html#ssl-warnings
  warnings.warn(
/home/testuser/.local/lib/python3.9/site-packages/urllib3/connectionpool.py:1045: InsecureRequestWarning: Unverified HTTPS request is being made to host 'dev-netbox.redacted.domain'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/1.26.x/advanced-usage.html#ssl-warnings
  warnings.warn(
/home/testuser/.local/lib/python3.9/site-packages/urllib3/connectionpool.py:1045: InsecureRequestWarning: Unverified HTTPS request is being made to host 'dev-netbox.redacted.domain'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/1.26.x/advanced-usage.html#ssl-warnings
  warnings.warn(
/home/testuser/.local/lib/python3.9/site-packages/urllib3/connectionpool.py:1045: InsecureRequestWarning: Unverified HTTPS request is being made to host 'dev-netbox.redacted.domain'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/1.26.x/advanced-usage.html#ssl-warnings
  warnings.warn(
/home/testuser/.local/lib/python3.9/site-packages/urllib3/connectionpool.py:1045: InsecureRequestWarning: Unverified HTTPS request is being made to host 'dev-netbox.redacted.domain'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/1.26.x/advanced-usage.html#ssl-warnings
  warnings.warn(
Traceback (most recent call last):
  File \"/home/testuser/.ansible/tmp/ansible-tmp-1676651550.672949-586458-190443356901962/AnsiballZ_netbox_cable.py\", line 107, in <module>
    _ansiballz_main()
  File \"/home/testuser/.ansible/tmp/ansible-tmp-1676651550.672949-586458-190443356901962/AnsiballZ_netbox_cable.py\", line 99, in _ansiballz_main
    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
  File \"/home/testuser/.ansible/tmp/ansible-tmp-1676651550.672949-586458-190443356901962/AnsiballZ_netbox_cable.py\", line 47, in invoke_module
    runpy.run_module(mod_name='ansible_collections.netbox.netbox.plugins.modules.netbox_cable', init_globals=dict(_module_fqn='ansible_collections.netbox.netbox.plugins.modules.netbox_cable', _modlib_path=modlib_path),
  File \"/usr/lib64/python3.9/runpy.py\", line 225, in run_module
    return _run_module_code(code, init_globals, run_name, mod_spec)
  File \"/usr/lib64/python3.9/runpy.py\", line 97, in _run_module_code
    _run_code(code, mod_globals, init_globals,
  File \"/usr/lib64/python3.9/runpy.py\", line 87, in _run_code
    exec(code, run_globals)
  File \"/tmp/ansible_netbox_cable_payload_etmhvn4n/ansible_netbox_cable_payload.zip/ansible_collections/netbox/netbox/plugins/modules/netbox_cable.py\", line 364, in <module>
  File \"/tmp/ansible_netbox_cable_payload_etmhvn4n/ansible_netbox_cable_payload.zip/ansible_collections/netbox/netbox/plugins/modules/netbox_cable.py\", line 360, in main
  File \"/tmp/ansible_netbox_cable_payload_etmhvn4n/ansible_netbox_cable_payload.zip/ansible_collections/netbox/netbox/plugins/module_utils/netbox_dcim.py\", line 229, in run
  File \"/tmp/ansible_netbox_cable_payload_etmhvn4n/ansible_netbox_cable_payload.zip/ansible_collections/netbox/netbox/plugins/module_utils/netbox_utils.py\", line 1385, in _ensure_object_exists
  File \"/tmp/ansible_netbox_cable_payload_etmhvn4n/ansible_netbox_cable_payload.zip/ansible_collections/netbox/netbox/plugins/module_utils/netbox_utils.py\", line 1339, in _update_netbox_object
  File \"/tmp/ansible_netbox_cable_payload_etmhvn4n/ansible_netbox_cable_payload.zip/ansible_collections/netbox/netbox/plugins/module_utils/netbox_utils.py\", line 1329, in _convert_termination
  File \"/tmp/ansible_netbox_cable_payload_etmhvn4n/ansible_netbox_cable_payload.zip/ansible_collections/netbox/netbox/plugins/module_utils/netbox_utils.py\", line 1057, in _find_app
UnboundLocalError: local variable 'nb_app' referenced before assignment
",
    "module_stdout": "",
    "msg": "MODULE FAILURE
See stdout/stderr for the exact error",
    "rc": 1
}

saruter avatar Feb 17 '23 16:02 saruter