From ff4bbf252f42d436b16b640b11ea777c3548770e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20R=C3=B8dvand?= Date: Thu, 30 Mar 2023 21:16:44 +0200 Subject: [PATCH 1/2] Fix filter when trying to create a location named the same in different sites --- plugins/module_utils/netbox_utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/module_utils/netbox_utils.py b/plugins/module_utils/netbox_utils.py index 1b1f750c8..dcab3076f 100644 --- a/plugins/module_utils/netbox_utils.py +++ b/plugins/module_utils/netbox_utils.py @@ -435,7 +435,7 @@ ), "l2vpn": set(["name"]), "lag": set(["name"]), - "location": set(["slug"]), + "location": set(["slug", "site"]), "module_type": set(["model"]), "manufacturer": set(["slug"]), "master": set(["name"]), From 656eae3ac73fba8c4e513f871b5134507fb0556f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20R=C3=B8dvand?= Date: Thu, 30 Mar 2023 22:19:50 +0200 Subject: [PATCH 2/2] Add regression test for issue 958 --- .../targets/regression-v3.4/tasks/main.yml | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/tests/integration/targets/regression-v3.4/tasks/main.yml b/tests/integration/targets/regression-v3.4/tasks/main.yml index 5a7ffb57f..d61cfdead 100644 --- a/tests/integration/targets/regression-v3.4/tasks/main.yml +++ b/tests/integration/targets/regression-v3.4/tasks/main.yml @@ -263,4 +263,21 @@ assert: that: - test_results | community.general.json_query('results[?ip_address.address==`1.121.121.121/32`]') | length == 2 - - test_results | community.general.json_query('results[?ip_address.address==`121.121.121.121/32`]') | length == 2 \ No newline at end of file + - test_results | community.general.json_query('results[?ip_address.address==`121.121.121.121/32`]') | length == 2 + + - name: "Issue #958 - Make sure we can add same location with different sites" + netbox.netbox.netbox_location: + netbox_url: "http://localhost:32768" + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Office Building + site: "{{ item }}" + loop: + - Test Site + - Test Site2 + register: test_results + + - name: "ASSERT ISSUE #957 - Location has different IDs" + ansible.builtin.assert: + that: + - test_results.results.0.location.id != test_results.results.1.location.id \ No newline at end of file