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]: Floors with the same name in different sites is not allowed #1233

Closed
sapergus opened this issue May 17, 2024 · 0 comments
Closed

[Bug]: Floors with the same name in different sites is not allowed #1233

sapergus opened this issue May 17, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@sapergus
Copy link
Contributor

sapergus commented May 17, 2024

Ansible NetBox Collection version

v.3.18.0

Ansible version

ansible [core 2.16.4]
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/home/pergus/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3/dist-packages/ansible
  ansible collection location = /home/pergus/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/bin/ansible
  python version = 3.10.12 (main, Nov 20 2023, 15:14:05) [GCC 11.4.0] (/usr/bin/python3)
  jinja version = 3.0.3
  libyaml = True

NetBox version

v3.7.3

Python version

3.10

Steps to Reproduce

If a site already exists in NetBox with a building and a floor and we then try to add another site with the same name for the building and the floor fails.

It does work if I change the line "parent_location": set(["slug"]), to "parent_location": set("name", "slug", "site"])
on line 501 in plugins/module_utils/netbox_utils.py and then make the parent_location into a dictionary as shown below.

locations__configured_locations:

  • name: Building Y
    site: demo

  • name: Floor 36
    site: demo
    parent_location: <-- make it a dictionary
    name: Building Y
    site: demo

  • name: locations
    netbox.netbox.netbox_location:
    netbox_url: "{{ lookup('env', 'NETBOX_URL') }}"
    netbox_token: "{{ lookup('env', 'NETBOX_TOKEN') }}"
    data: "{{ item }}"
    state: "{{ desired_state }}"
    loop: "{{ locations__configured_locations }}"

Expected Behavior

I expect that different buildings on different sites should be able to have floors with the same name.

Observed Behavior

failed: [localhost] (item={'name': 'Floor 36', 'site': 'demo', 'parent_location': 'Building Y'}) => {"ansible_loop_var": "item", "changed": false, "item": {"name": "Floor 36", "parent_location": "Building Y", "site": "demo"}, "msg": "More than one result returned for parent_location"}

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