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_rack module doesn't distinguish unique site/locations pairs #964

Closed
artiomello opened this issue Mar 31, 2023 · 3 comments
Closed
Assignees
Labels
bug Something isn't working

Comments

@artiomello
Copy link

artiomello commented Mar 31, 2023

Ansible NetBox Collection version

v3.11

Ansible version

Running in AWX. Version is irrelevant to the case.

NetBox version

3.3.7

Python version

3.8

Steps to Reproduce

Racks are created like so:

  - name: Creating racks
    netbox.netbox.netbox_rack:
      data: "{{ rack }}"
      state: present
    loop: "{{ latvia_racks }}"
    loop_control:
      loop_var: rack
      label: "{{ rack.location, rack.name }}"
    tags: LV.racks

using looped values defined like so:

  - name: Rack 1
    location: LVMA Office Data Center
    tenant: xxx
    site: "{{ latvia_defaults.site }}"
    status: Active
    rack_role: Mixed
    facility_id: Rack 1
    tags: "{{ latvia_defaults.tags + [ 'Marupe Office DC' ] }}"

Expected Behavior

netbox_rack module should look at unique site/location pairs, instead of only unique locations, as it is now.

Similar issue has been already discussed and resolved as part of a different module: #958 therefore it should be a quick and easy fix.

Observed Behavior

netbox_rack module fails to create a new rack when there's more than one location with the same name, regardless of them being in different sites:

{
  "changed": false,
  **"msg": "More than one result returned for location",**
  "invocation": {
    "module_args": {
      "netbox_url": "https://netbox",
      "netbox_token": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
      "validate_certs": "/etc/pki/ca-trust/extracted/openssl/ca-bundle.trust.crt",
      "data": {
        "name": "Rack 1",
        "location": "Office Data Center",
        "tenant": "xxx",
        "site": "Marupe",
        "status": "Active",
        "rack_role": "Mixed",
        "facility_id": "Rack 1",
        "tags": [
          "Latvia",
          "Marupe",
          "Marupe Office DC"
        ],
@artiomello artiomello added the bug Something isn't working label Mar 31, 2023
@rodvand rodvand self-assigned this Apr 4, 2023
@rodvand
Copy link
Contributor

rodvand commented Apr 4, 2023

I've added filter options to the location parameter. You will need to use it like this:

  - name: Creating racks
    netbox.netbox.netbox_rack:
      data:
        name: Rack 1
        site: site name
        location:
          name: location name
          site: site name

Will be available in the next collection release.

@rodvand rodvand closed this as completed Apr 4, 2023
@artiomello
Copy link
Author

Hi,

Just saw your comment. Thanks for the fix, but don't you think that putting the same site property twice is unnecessary? If it can't be different (it most definitely shouldn't) then there should be no reason to define it twice in the same module.

I've added filter options to the location parameter. You will need to use it like this:

  - name: Creating racks
    netbox.netbox.netbox_rack:
      data:
        name: Rack 1
        site: site name
        location:
          name: location name
          site: site name

Will be available in the next collection release.

@artiomello
Copy link
Author

@rodvand ?

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

2 participants