netbox-community / ansible_modules

NetBox modules for Ansible using Ansible Collections
GNU General Public License v3.0
327 stars 208 forks source link

netbox_cable not working as expected #445

Closed hrv231 closed 3 years ago

hrv231 commented 3 years ago
ISSUE TYPE
SOFTWARE VERSIONS
Ansible:
ansible 2.10.5
  config file = /home/user1/m-ansible/ansible/ansible.cfg
  configured module search path = ["/home/user1/m-ansible/ansible/'/home/user1/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules', '/home/user1/m-ansible/ansible/library'"]
  ansible python module location = /home/user1/m-ansible/lib/python3.7/site-packages/ansible
  executable location = /home/user1/m-ansible/bin/ansible
  python version = 3.7.3 (default, Apr  3 2019, 05:39:12) [GCC 8.3.0]
Netbox:

2.10.4

Collection:
 # /home/user1/.ansible/collections/ansible_collections
Collection             Version
---------------------- -------
ansible.netcommon      1.5.0  
community.general      1.3.4  
community.kubernetes   1.1.1  
google.cloud           1.0.1  
junipernetworks.junos  1.3.0  
netbox.netbox          2.1.0  

# /home/user1/m-ansible/lib/python3.7/site-packages/ansible_collections
Collection                Version
------------------------- -------
ansible.netcommon         1.4.1  
google.cloud              1.0.1  
junipernetworks.junos     1.3.0  
netbox.netbox             2.1.0  

I have more collections.., I put the relevant ones

SUMMARY

I'm following the documentation to create a new cable and I get the following error: "msg": "{\"error\": \"Field 'id' expected a number but got 'device'.\", \"exception\": \"ValueError\", \"netbox_version\": \"2.10.4\", \"python_version\": \"3.8.7\"}"

STEPS TO REPRODUCE
- name: CREATE NEW CABLE
  netbox_cable:
     netbox_url: https://netbox.server.org
     netbox_token: 4444444444444444444444444444444444
     validate_certs: no
     data:
        termination_a_type: dcim.interface
        termination_a:
          device: qfx1.server.location
          name: et-0/0/55
        termination_b_type: dcim.interface
        termination_b:
          device: qfx2.server.location
          name: et-0/0/52
     state: present
EXPECTED RESULTS

Create a new cable with a new id number following the sequence of the id cables.

ACTUAL RESULTS
The full traceback is:
  File "/tmp/ansible_netbox_cable_payload_byjaq5hu/ansible_netbox_cable_payload.zip/ansible_collections/netbox/netbox/plugins/module_utils/netbox_utils.py", line 527, in _nb_endpoint_get
    response = nb_endpoint.get(**query_params)
  File "/home/user1/m-ansible/lib/python3.7/site-packages/pynetbox/core/endpoint.py", line 138, in get
    filter_lookup = self.filter(**kwargs)
  File "/home/user1/m-ansible/lib/python3.7/site-packages/pynetbox/core/endpoint.py", line 230, in filter
    return response_loader(req.get(), self.return_obj, self)
  File "/home/user1/m-ansible/lib/python3.7/site-packages/pynetbox/core/query.py", line 358, in get
    return req_all()
  File "/home/user1/m-ansible/lib/python3.7/site-packages/pynetbox/core/query.py", line 309, in req_all
    req = self._make_call(add_params=add_params)
  File "/home/user1/m-ansible/lib/python3.7/site-packages/pynetbox/core/query.py", line 280, in _make_call
    raise RequestError(req)
fatal: [localhost]: FAILED! => {
    "changed": false,
    "invocation": {
        "module_args": {
            "data": {
                "color": null,
                "label": null,
                "length": null,
                "length_unit": null,
                "status": null,
                "termination_a": {
                    "device": "qfx1.server.location",
                    "name": "et-0/0/55"
                },
                "termination_a_type": "dcim.interface",
                "termination_b": {
                    "device": "qfx2.server.location",
                    "name": "et-0/0/52"
                },
                "termination_b_type": "dcim.interface",
                "type": null
            },
            "netbox_token": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
            "netbox_url": "https://netbox.server.org",
            "query_params": null,
            "state": "present",
            "validate_certs": false
        }
    },
    "msg": "{\"error\": \"Field 'id' expected a number but got 'device'.\", \"exception\": \"ValueError\", \"netbox_version\": \"2.10.4\", \"python_version\": \"3.8.7\"}"
hrv231 commented 3 years ago

Closing this ticket, the device wasn't created yet.