Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: netbox_virtual_chassis fails to query by master #1292

Open
shaderecker opened this issue Jul 25, 2024 · 0 comments
Open

[Bug]: netbox_virtual_chassis fails to query by master #1292

shaderecker opened this issue Jul 25, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@shaderecker
Copy link

Ansible NetBox Collection version

3.19.1

Ansible version

ansible [core 2.17.2]
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/home/ubuntu/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/ubuntu/netbox-test/.venv/lib/python3.10/site-packages/ansible
  ansible collection location = /home/ubuntu/.ansible/collections:/usr/share/ansible/collections
  executable location = /home/ubuntu/netbox-test/.venv/bin/ansible
  python version = 3.10.12 (main, Mar 22 2024, 16:50:05) [GCC 11.4.0] (/home/ubuntu/netbox-test/.venv/bin/python3)
  jinja version = 3.1.4
  libyaml = True

NetBox version

v4.0.6

Python version

3.10

Steps to Reproduce

I want to rename a chassis and therefore cannot use the name parameter to search for it.
I set query_params to "master".

Playbook file:

- name: Rename network devices
  hosts: localhost
  gather_facts: false
  vars:
    netbox_uri: '{{ lookup("env", "NETBOX_API") }}'
    netbox_token: '{{ lookup("env", "NETBOX_TOKEN") }}'

  tasks:
    - name: "Update virtual chassis name in Netbox"
      netbox.netbox.netbox_virtual_chassis:
        netbox_url: "{{ netbox_uri }}"
        netbox_token: "{{ netbox_token }}"
        data:
          name: "chassisname"
          master: "mastername"
        query_params:
          - master

Expected Behavior

The existing virtual chassis is queried by the master parameter and updated to the new name.

Observed Behavior

Fails with this error:

The full traceback is:
  File "/tmp/ansible_netbox.netbox.netbox_virtual_chassis_payload_79usucxd/ansible_netbox.netbox.netbox_virtual_chassis_payload.zip/ansible_collections/netbox/netbox/plugins/module_utils/netbox_utils.py", line 795, in _nb_endpoint_get
    response = nb_endpoint.get(**query_params)
  File "/home/ubuntu/netbox-test/.venv/lib/python3.10/site-packages/pynetbox/core/endpoint.py", line 162, in get
    ret = next(resp, None)
  File "/home/ubuntu/netbox-test/.venv/lib/python3.10/site-packages/pynetbox/core/response.py", line 128, in __next__
    next(self.response), self.endpoint.api, self.endpoint
  File "/home/ubuntu/netbox-test/.venv/lib/python3.10/site-packages/pynetbox/core/query.py", line 292, in get
    req = self._make_call(add_params=add_params)
  File "/home/ubuntu/netbox-test/.venv/lib/python3.10/site-packages/pynetbox/core/query.py", line 259, in _make_call
    raise RequestError(req)
fatal: [localhost]: FAILED! => {
    "changed": false,
    "invocation": {
        "module_args": {
            "cert": null,
            "data": {
                "comments": null,
                "custom_fields": null,
                "description": null,
                "domain": null,
                "master": "mastername",
                "name": "chassisname",
                "tags": null
            },
            "netbox_token": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
            "netbox_url": "<redacted>",
            "query_params": [
                "master"
            ],
            "state": "present",
            "validate_certs": true
        }
    },
    "msg": "{\"master\":[\"Select a valid choice. 193 is not one of the available choices.\"]}"
}

So it converts the master name into its id (192) but then fails to work with that.

@shaderecker shaderecker added the bug Something isn't working label Jul 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant