From a6d0d3c63b4064b89c1476531568d8ffb49cff9b Mon Sep 17 00:00:00 2001 From: Ido Don <76511079+Ido-Don@users.noreply.github.com> Date: Fri, 20 Sep 2024 18:31:32 +0300 Subject: [PATCH 01/20] changed the interface to be an ID --- plugins/module_utils/netbox_ipam.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/plugins/module_utils/netbox_ipam.py b/plugins/module_utils/netbox_ipam.py index f8a0131dc..166a6e340 100644 --- a/plugins/module_utils/netbox_ipam.py +++ b/plugins/module_utils/netbox_ipam.py @@ -205,6 +205,11 @@ def run(self): else: name = data.get("name") + if self.endpoint == "ip_addresses": + if 'interface' in data: + data["assigned_object_id"] = data['interface'] + data['assigned_object_type'] = "dcim.interface" + if self.endpoint in SLUG_REQUIRED: if not data.get("slug"): data["slug"] = self._to_slug(name) From 0cbd5b01c2cd8a3b4f7a5294bcd13d5932f4d23f Mon Sep 17 00:00:00 2001 From: Ido Don <76511079+Ido-Don@users.noreply.github.com> Date: Fri, 20 Sep 2024 18:43:49 +0300 Subject: [PATCH 02/20] changed single quetes to duble quetes --- plugins/module_utils/netbox_ipam.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/module_utils/netbox_ipam.py b/plugins/module_utils/netbox_ipam.py index 166a6e340..40bc09825 100644 --- a/plugins/module_utils/netbox_ipam.py +++ b/plugins/module_utils/netbox_ipam.py @@ -207,8 +207,8 @@ def run(self): if self.endpoint == "ip_addresses": if 'interface' in data: - data["assigned_object_id"] = data['interface'] - data['assigned_object_type'] = "dcim.interface" + data["assigned_object_id"] = data["interface"] + data["assigned_object_type"] = "dcim.interface" if self.endpoint in SLUG_REQUIRED: if not data.get("slug"): From 3b2e3c50456dd44d0f2782d89c6392fa14cc523c Mon Sep 17 00:00:00 2001 From: Ido Don <76511079+Ido-Don@users.noreply.github.com> Date: Fri, 20 Sep 2024 23:10:14 +0300 Subject: [PATCH 03/20] changed single quetes to duble quetes --- plugins/module_utils/netbox_ipam.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/module_utils/netbox_ipam.py b/plugins/module_utils/netbox_ipam.py index 40bc09825..8d1b731f4 100644 --- a/plugins/module_utils/netbox_ipam.py +++ b/plugins/module_utils/netbox_ipam.py @@ -206,7 +206,7 @@ def run(self): name = data.get("name") if self.endpoint == "ip_addresses": - if 'interface' in data: + if "interface" in data: data["assigned_object_id"] = data["interface"] data["assigned_object_type"] = "dcim.interface" From 0d255cd867c239fd7e2a7512592d921803202ada Mon Sep 17 00:00:00 2001 From: Ido Don <76511079+Ido-Don@users.noreply.github.com> Date: Sat, 12 Oct 2024 14:57:55 +0300 Subject: [PATCH 04/20] added integration tests to the interface value in v4.1 --- .../targets/v4.1/tasks/netbox_ip_address.yml | 96 +++++++++++++++++++ 1 file changed, 96 insertions(+) diff --git a/tests/integration/targets/v4.1/tasks/netbox_ip_address.yml b/tests/integration/targets/v4.1/tasks/netbox_ip_address.yml index 8813f8dcb..f8de3b167 100644 --- a/tests/integration/targets/v4.1/tasks/netbox_ip_address.yml +++ b/tests/integration/targets/v4.1/tasks/netbox_ip_address.yml @@ -350,3 +350,99 @@ - test_sixteen['diff']['after']['state'] == "present" - test_sixteen['msg'] == "ip_address 10.120.10.1/32 created" - test_sixteen['ip_address']['address'] == "10.120.10.1/32" + +- name: "17 - Create IP address on GigabitEthernet2 with interface value - test100 - State: present" + netbox.netbox.netbox_ip_address: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + family: 4 + address: 10.10.200.30/16 + interface: + name: GigabitEthernet2 + device: test100 + register: test_nine + +- name: 17 - ASSERT + ansible.builtin.assert: + that: + - test_nine is changed + - test_nine['diff']['before']['state'] == "absent" + - test_nine['diff']['after']['state'] == "present" + - test_nine['msg'] == "ip_address 10.10.200.30/16 created" + - test_nine['ip_address']['address'] == "10.10.200.30/16" + - test_nine['ip_address']['family'] == 4 + - test_nine['ip_address']['assigned_object_type'] == "dcim.interface" + - test_nine['ip_address']['assigned_object_id'] == 4 + - test_nine['ip_address']['interface'] == 4 + +- name: "18 - Create IP address on GigabitEthernet2 - test100 with interface value - State: new" + netbox.netbox.netbox_ip_address: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + family: 4 + prefix: 10.10.0.0/16 + interface: + name: GigabitEthernet2 + device: test100 + state: new + register: test_ten + +- name: 18 - ASSERT + ansible.builtin.assert: + that: + - test_ten is changed + - test_ten['diff']['before']['state'] == "absent" + - test_ten['diff']['after']['state'] == "present" + - test_ten['msg'] == "ip_address 10.10.0.1/16 created" + - test_ten['ip_address']['address'] == "10.10.0.1/16" + - test_ten['ip_address']['family'] == 4 + - test_ten['ip_address']['assigned_object_type'] == "dcim.interface" + - test_ten['ip_address']['assigned_object_id'] == 4 + - test_nine['ip_address']['interface'] == 4 + +- name: "19 - Create IP address on GigabitEthernet2 - test100 with interface value - State: present" + netbox.netbox.netbox_ip_address: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + family: 4 + prefix: 192.168.100.0/24 + interface: + name: GigabitEthernet2 + device: test100 + state: present + register: test_eleven + +- name: 19 - ASSERT + ansible.builtin.assert: + that: + - test_eleven is changed + - test_eleven['diff']['before']['state'] == "absent" + - test_eleven['diff']['after']['state'] == "present" + - test_eleven['msg'] == "ip_address 192.168.100.2/24 created" + - test_eleven['ip_address']['address'] == "192.168.100.2/24" + - test_nine['ip_address']['interface'] == 4 + +- name: 20 - Duplicate - 192.168.100.2/24 on interface with interface value + netbox.netbox.netbox_ip_address: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + address: 192.168.100.2/24 + interface: + name: GigabitEthernet2 + device: test100 + state: present + register: test_twelve + +- name: 20 - ASSERT + ansible.builtin.assert: + that: + - not test_twelve['changed'] + - test_twelve['msg'] == "ip_address 192.168.100.2/24 already exists" + - test_twelve['ip_address']['address'] == "192.168.100.2/24" + - test_twelve['ip_address']['assigned_object_type'] == "dcim.interface" + - test_twelve['ip_address']['assigned_object_id'] == 4 + - test_nine['ip_address']['interface'] == 4 From f2847fec65a8f2f3ad30a002e1d46d22d5e2c42d Mon Sep 17 00:00:00 2001 From: Ido Don <76511079+Ido-Don@users.noreply.github.com> Date: Sat, 12 Oct 2024 15:01:19 +0300 Subject: [PATCH 05/20] added integration tests to the interface value in v4.0 --- .../targets/v4.0/tasks/netbox_ip_address.yml | 96 +++++++++++++++++++ 1 file changed, 96 insertions(+) diff --git a/tests/integration/targets/v4.0/tasks/netbox_ip_address.yml b/tests/integration/targets/v4.0/tasks/netbox_ip_address.yml index 8813f8dcb..f8de3b167 100644 --- a/tests/integration/targets/v4.0/tasks/netbox_ip_address.yml +++ b/tests/integration/targets/v4.0/tasks/netbox_ip_address.yml @@ -350,3 +350,99 @@ - test_sixteen['diff']['after']['state'] == "present" - test_sixteen['msg'] == "ip_address 10.120.10.1/32 created" - test_sixteen['ip_address']['address'] == "10.120.10.1/32" + +- name: "17 - Create IP address on GigabitEthernet2 with interface value - test100 - State: present" + netbox.netbox.netbox_ip_address: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + family: 4 + address: 10.10.200.30/16 + interface: + name: GigabitEthernet2 + device: test100 + register: test_nine + +- name: 17 - ASSERT + ansible.builtin.assert: + that: + - test_nine is changed + - test_nine['diff']['before']['state'] == "absent" + - test_nine['diff']['after']['state'] == "present" + - test_nine['msg'] == "ip_address 10.10.200.30/16 created" + - test_nine['ip_address']['address'] == "10.10.200.30/16" + - test_nine['ip_address']['family'] == 4 + - test_nine['ip_address']['assigned_object_type'] == "dcim.interface" + - test_nine['ip_address']['assigned_object_id'] == 4 + - test_nine['ip_address']['interface'] == 4 + +- name: "18 - Create IP address on GigabitEthernet2 - test100 with interface value - State: new" + netbox.netbox.netbox_ip_address: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + family: 4 + prefix: 10.10.0.0/16 + interface: + name: GigabitEthernet2 + device: test100 + state: new + register: test_ten + +- name: 18 - ASSERT + ansible.builtin.assert: + that: + - test_ten is changed + - test_ten['diff']['before']['state'] == "absent" + - test_ten['diff']['after']['state'] == "present" + - test_ten['msg'] == "ip_address 10.10.0.1/16 created" + - test_ten['ip_address']['address'] == "10.10.0.1/16" + - test_ten['ip_address']['family'] == 4 + - test_ten['ip_address']['assigned_object_type'] == "dcim.interface" + - test_ten['ip_address']['assigned_object_id'] == 4 + - test_nine['ip_address']['interface'] == 4 + +- name: "19 - Create IP address on GigabitEthernet2 - test100 with interface value - State: present" + netbox.netbox.netbox_ip_address: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + family: 4 + prefix: 192.168.100.0/24 + interface: + name: GigabitEthernet2 + device: test100 + state: present + register: test_eleven + +- name: 19 - ASSERT + ansible.builtin.assert: + that: + - test_eleven is changed + - test_eleven['diff']['before']['state'] == "absent" + - test_eleven['diff']['after']['state'] == "present" + - test_eleven['msg'] == "ip_address 192.168.100.2/24 created" + - test_eleven['ip_address']['address'] == "192.168.100.2/24" + - test_nine['ip_address']['interface'] == 4 + +- name: 20 - Duplicate - 192.168.100.2/24 on interface with interface value + netbox.netbox.netbox_ip_address: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + address: 192.168.100.2/24 + interface: + name: GigabitEthernet2 + device: test100 + state: present + register: test_twelve + +- name: 20 - ASSERT + ansible.builtin.assert: + that: + - not test_twelve['changed'] + - test_twelve['msg'] == "ip_address 192.168.100.2/24 already exists" + - test_twelve['ip_address']['address'] == "192.168.100.2/24" + - test_twelve['ip_address']['assigned_object_type'] == "dcim.interface" + - test_twelve['ip_address']['assigned_object_id'] == 4 + - test_nine['ip_address']['interface'] == 4 From 426dd3d56a83d23b8cf3812048b414fd44301015 Mon Sep 17 00:00:00 2001 From: Ido Don <76511079+Ido-Don@users.noreply.github.com> Date: Sat, 12 Oct 2024 15:03:42 +0300 Subject: [PATCH 06/20] added integration tests to the interface value in v3.7, v3.6, v3.5 --- .../targets/v3.5/tasks/netbox_ip_address.yml | 96 +++++++++++++++++++ .../targets/v3.6/tasks/netbox_ip_address.yml | 96 +++++++++++++++++++ .../targets/v3.7/tasks/netbox_ip_address.yml | 96 +++++++++++++++++++ 3 files changed, 288 insertions(+) diff --git a/tests/integration/targets/v3.5/tasks/netbox_ip_address.yml b/tests/integration/targets/v3.5/tasks/netbox_ip_address.yml index ce2b125a4..b92a1e873 100644 --- a/tests/integration/targets/v3.5/tasks/netbox_ip_address.yml +++ b/tests/integration/targets/v3.5/tasks/netbox_ip_address.yml @@ -348,3 +348,99 @@ - test_sixteen['diff']['after']['state'] == "present" - test_sixteen['msg'] == "ip_address 10.120.10.1/32 created" - test_sixteen['ip_address']['address'] == "10.120.10.1/32" + +- name: "17 - Create IP address on GigabitEthernet2 with interface value - test100 - State: present" + netbox.netbox.netbox_ip_address: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + family: 4 + address: 10.10.200.30/16 + interface: + name: GigabitEthernet2 + device: test100 + register: test_nine + +- name: 17 - ASSERT + ansible.builtin.assert: + that: + - test_nine is changed + - test_nine['diff']['before']['state'] == "absent" + - test_nine['diff']['after']['state'] == "present" + - test_nine['msg'] == "ip_address 10.10.200.30/16 created" + - test_nine['ip_address']['address'] == "10.10.200.30/16" + - test_nine['ip_address']['family'] == 4 + - test_nine['ip_address']['assigned_object_type'] == "dcim.interface" + - test_nine['ip_address']['assigned_object_id'] == 4 + - test_nine['ip_address']['interface'] == 4 + +- name: "18 - Create IP address on GigabitEthernet2 - test100 with interface value - State: new" + netbox.netbox.netbox_ip_address: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + family: 4 + prefix: 10.10.0.0/16 + interface: + name: GigabitEthernet2 + device: test100 + state: new + register: test_ten + +- name: 18 - ASSERT + ansible.builtin.assert: + that: + - test_ten is changed + - test_ten['diff']['before']['state'] == "absent" + - test_ten['diff']['after']['state'] == "present" + - test_ten['msg'] == "ip_address 10.10.0.1/16 created" + - test_ten['ip_address']['address'] == "10.10.0.1/16" + - test_ten['ip_address']['family'] == 4 + - test_ten['ip_address']['assigned_object_type'] == "dcim.interface" + - test_ten['ip_address']['assigned_object_id'] == 4 + - test_nine['ip_address']['interface'] == 4 + +- name: "19 - Create IP address on GigabitEthernet2 - test100 with interface value - State: present" + netbox.netbox.netbox_ip_address: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + family: 4 + prefix: 192.168.100.0/24 + interface: + name: GigabitEthernet2 + device: test100 + state: present + register: test_eleven + +- name: 19 - ASSERT + ansible.builtin.assert: + that: + - test_eleven is changed + - test_eleven['diff']['before']['state'] == "absent" + - test_eleven['diff']['after']['state'] == "present" + - test_eleven['msg'] == "ip_address 192.168.100.2/24 created" + - test_eleven['ip_address']['address'] == "192.168.100.2/24" + - test_nine['ip_address']['interface'] == 4 + +- name: 20 - Duplicate - 192.168.100.2/24 on interface with interface value + netbox.netbox.netbox_ip_address: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + address: 192.168.100.2/24 + interface: + name: GigabitEthernet2 + device: test100 + state: present + register: test_twelve + +- name: 20 - ASSERT + ansible.builtin.assert: + that: + - not test_twelve['changed'] + - test_twelve['msg'] == "ip_address 192.168.100.2/24 already exists" + - test_twelve['ip_address']['address'] == "192.168.100.2/24" + - test_twelve['ip_address']['assigned_object_type'] == "dcim.interface" + - test_twelve['ip_address']['assigned_object_id'] == 4 + - test_nine['ip_address']['interface'] == 4 diff --git a/tests/integration/targets/v3.6/tasks/netbox_ip_address.yml b/tests/integration/targets/v3.6/tasks/netbox_ip_address.yml index ce2b125a4..b92a1e873 100644 --- a/tests/integration/targets/v3.6/tasks/netbox_ip_address.yml +++ b/tests/integration/targets/v3.6/tasks/netbox_ip_address.yml @@ -348,3 +348,99 @@ - test_sixteen['diff']['after']['state'] == "present" - test_sixteen['msg'] == "ip_address 10.120.10.1/32 created" - test_sixteen['ip_address']['address'] == "10.120.10.1/32" + +- name: "17 - Create IP address on GigabitEthernet2 with interface value - test100 - State: present" + netbox.netbox.netbox_ip_address: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + family: 4 + address: 10.10.200.30/16 + interface: + name: GigabitEthernet2 + device: test100 + register: test_nine + +- name: 17 - ASSERT + ansible.builtin.assert: + that: + - test_nine is changed + - test_nine['diff']['before']['state'] == "absent" + - test_nine['diff']['after']['state'] == "present" + - test_nine['msg'] == "ip_address 10.10.200.30/16 created" + - test_nine['ip_address']['address'] == "10.10.200.30/16" + - test_nine['ip_address']['family'] == 4 + - test_nine['ip_address']['assigned_object_type'] == "dcim.interface" + - test_nine['ip_address']['assigned_object_id'] == 4 + - test_nine['ip_address']['interface'] == 4 + +- name: "18 - Create IP address on GigabitEthernet2 - test100 with interface value - State: new" + netbox.netbox.netbox_ip_address: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + family: 4 + prefix: 10.10.0.0/16 + interface: + name: GigabitEthernet2 + device: test100 + state: new + register: test_ten + +- name: 18 - ASSERT + ansible.builtin.assert: + that: + - test_ten is changed + - test_ten['diff']['before']['state'] == "absent" + - test_ten['diff']['after']['state'] == "present" + - test_ten['msg'] == "ip_address 10.10.0.1/16 created" + - test_ten['ip_address']['address'] == "10.10.0.1/16" + - test_ten['ip_address']['family'] == 4 + - test_ten['ip_address']['assigned_object_type'] == "dcim.interface" + - test_ten['ip_address']['assigned_object_id'] == 4 + - test_nine['ip_address']['interface'] == 4 + +- name: "19 - Create IP address on GigabitEthernet2 - test100 with interface value - State: present" + netbox.netbox.netbox_ip_address: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + family: 4 + prefix: 192.168.100.0/24 + interface: + name: GigabitEthernet2 + device: test100 + state: present + register: test_eleven + +- name: 19 - ASSERT + ansible.builtin.assert: + that: + - test_eleven is changed + - test_eleven['diff']['before']['state'] == "absent" + - test_eleven['diff']['after']['state'] == "present" + - test_eleven['msg'] == "ip_address 192.168.100.2/24 created" + - test_eleven['ip_address']['address'] == "192.168.100.2/24" + - test_nine['ip_address']['interface'] == 4 + +- name: 20 - Duplicate - 192.168.100.2/24 on interface with interface value + netbox.netbox.netbox_ip_address: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + address: 192.168.100.2/24 + interface: + name: GigabitEthernet2 + device: test100 + state: present + register: test_twelve + +- name: 20 - ASSERT + ansible.builtin.assert: + that: + - not test_twelve['changed'] + - test_twelve['msg'] == "ip_address 192.168.100.2/24 already exists" + - test_twelve['ip_address']['address'] == "192.168.100.2/24" + - test_twelve['ip_address']['assigned_object_type'] == "dcim.interface" + - test_twelve['ip_address']['assigned_object_id'] == 4 + - test_nine['ip_address']['interface'] == 4 diff --git a/tests/integration/targets/v3.7/tasks/netbox_ip_address.yml b/tests/integration/targets/v3.7/tasks/netbox_ip_address.yml index 8813f8dcb..f8de3b167 100644 --- a/tests/integration/targets/v3.7/tasks/netbox_ip_address.yml +++ b/tests/integration/targets/v3.7/tasks/netbox_ip_address.yml @@ -350,3 +350,99 @@ - test_sixteen['diff']['after']['state'] == "present" - test_sixteen['msg'] == "ip_address 10.120.10.1/32 created" - test_sixteen['ip_address']['address'] == "10.120.10.1/32" + +- name: "17 - Create IP address on GigabitEthernet2 with interface value - test100 - State: present" + netbox.netbox.netbox_ip_address: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + family: 4 + address: 10.10.200.30/16 + interface: + name: GigabitEthernet2 + device: test100 + register: test_nine + +- name: 17 - ASSERT + ansible.builtin.assert: + that: + - test_nine is changed + - test_nine['diff']['before']['state'] == "absent" + - test_nine['diff']['after']['state'] == "present" + - test_nine['msg'] == "ip_address 10.10.200.30/16 created" + - test_nine['ip_address']['address'] == "10.10.200.30/16" + - test_nine['ip_address']['family'] == 4 + - test_nine['ip_address']['assigned_object_type'] == "dcim.interface" + - test_nine['ip_address']['assigned_object_id'] == 4 + - test_nine['ip_address']['interface'] == 4 + +- name: "18 - Create IP address on GigabitEthernet2 - test100 with interface value - State: new" + netbox.netbox.netbox_ip_address: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + family: 4 + prefix: 10.10.0.0/16 + interface: + name: GigabitEthernet2 + device: test100 + state: new + register: test_ten + +- name: 18 - ASSERT + ansible.builtin.assert: + that: + - test_ten is changed + - test_ten['diff']['before']['state'] == "absent" + - test_ten['diff']['after']['state'] == "present" + - test_ten['msg'] == "ip_address 10.10.0.1/16 created" + - test_ten['ip_address']['address'] == "10.10.0.1/16" + - test_ten['ip_address']['family'] == 4 + - test_ten['ip_address']['assigned_object_type'] == "dcim.interface" + - test_ten['ip_address']['assigned_object_id'] == 4 + - test_nine['ip_address']['interface'] == 4 + +- name: "19 - Create IP address on GigabitEthernet2 - test100 with interface value - State: present" + netbox.netbox.netbox_ip_address: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + family: 4 + prefix: 192.168.100.0/24 + interface: + name: GigabitEthernet2 + device: test100 + state: present + register: test_eleven + +- name: 19 - ASSERT + ansible.builtin.assert: + that: + - test_eleven is changed + - test_eleven['diff']['before']['state'] == "absent" + - test_eleven['diff']['after']['state'] == "present" + - test_eleven['msg'] == "ip_address 192.168.100.2/24 created" + - test_eleven['ip_address']['address'] == "192.168.100.2/24" + - test_nine['ip_address']['interface'] == 4 + +- name: 20 - Duplicate - 192.168.100.2/24 on interface with interface value + netbox.netbox.netbox_ip_address: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + address: 192.168.100.2/24 + interface: + name: GigabitEthernet2 + device: test100 + state: present + register: test_twelve + +- name: 20 - ASSERT + ansible.builtin.assert: + that: + - not test_twelve['changed'] + - test_twelve['msg'] == "ip_address 192.168.100.2/24 already exists" + - test_twelve['ip_address']['address'] == "192.168.100.2/24" + - test_twelve['ip_address']['assigned_object_type'] == "dcim.interface" + - test_twelve['ip_address']['assigned_object_id'] == 4 + - test_nine['ip_address']['interface'] == 4 From d243b87976ee5b707ba661e87bf311d31c16aa15 Mon Sep 17 00:00:00 2001 From: Ido Don <76511079+Ido-Don@users.noreply.github.com> Date: Sat, 12 Oct 2024 15:14:18 +0300 Subject: [PATCH 07/20] added a change fragment --- changelogs/fragments/1323-fixing-bug-#975.yml | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 changelogs/fragments/1323-fixing-bug-#975.yml diff --git a/changelogs/fragments/1323-fixing-bug-#975.yml b/changelogs/fragments/1323-fixing-bug-#975.yml new file mode 100644 index 000000000..558892274 --- /dev/null +++ b/changelogs/fragments/1323-fixing-bug-#975.yml @@ -0,0 +1,3 @@ +bugfixes: + - netbox_ip_address - Fixed the problem preventing assignment of an IP address to a network interface + [#1323](https://github.com/netbox-community/ansible_modules/pull/1323) \ No newline at end of file From 5f0f65953e26f9a8f36aa804a46719c3dfddbf15 Mon Sep 17 00:00:00 2001 From: Ido Don <76511079+Ido-Don@users.noreply.github.com> Date: Sat, 12 Oct 2024 15:26:20 +0300 Subject: [PATCH 08/20] changed some linting errors --- changelogs/fragments/1323-fixing-bug-#975.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/changelogs/fragments/1323-fixing-bug-#975.yml b/changelogs/fragments/1323-fixing-bug-#975.yml index 558892274..b8390e86f 100644 --- a/changelogs/fragments/1323-fixing-bug-#975.yml +++ b/changelogs/fragments/1323-fixing-bug-#975.yml @@ -1,3 +1,3 @@ bugfixes: - - netbox_ip_address - Fixed the problem preventing assignment of an IP address to a network interface - [#1323](https://github.com/netbox-community/ansible_modules/pull/1323) \ No newline at end of file + - netbox_ip_address - Fixed the problem preventing assignment of an IP address to a network interface + [#1323](https://github.com/netbox-community/ansible_modules/pull/1323) From e9d3b2f7c9cea9a53275a3960d945a752bcd8a60 Mon Sep 17 00:00:00 2001 From: Ido Don <76511079+Ido-Don@users.noreply.github.com> Date: Sat, 12 Oct 2024 15:32:40 +0300 Subject: [PATCH 09/20] made a change to v4.1 testing to see if this was the issue --- tests/integration/targets/v4.1/tasks/netbox_ip_address.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/tests/integration/targets/v4.1/tasks/netbox_ip_address.yml b/tests/integration/targets/v4.1/tasks/netbox_ip_address.yml index f8de3b167..9dbf51491 100644 --- a/tests/integration/targets/v4.1/tasks/netbox_ip_address.yml +++ b/tests/integration/targets/v4.1/tasks/netbox_ip_address.yml @@ -374,7 +374,6 @@ - test_nine['ip_address']['family'] == 4 - test_nine['ip_address']['assigned_object_type'] == "dcim.interface" - test_nine['ip_address']['assigned_object_id'] == 4 - - test_nine['ip_address']['interface'] == 4 - name: "18 - Create IP address on GigabitEthernet2 - test100 with interface value - State: new" netbox.netbox.netbox_ip_address: @@ -400,7 +399,6 @@ - test_ten['ip_address']['family'] == 4 - test_ten['ip_address']['assigned_object_type'] == "dcim.interface" - test_ten['ip_address']['assigned_object_id'] == 4 - - test_nine['ip_address']['interface'] == 4 - name: "19 - Create IP address on GigabitEthernet2 - test100 with interface value - State: present" netbox.netbox.netbox_ip_address: @@ -423,7 +421,6 @@ - test_eleven['diff']['after']['state'] == "present" - test_eleven['msg'] == "ip_address 192.168.100.2/24 created" - test_eleven['ip_address']['address'] == "192.168.100.2/24" - - test_nine['ip_address']['interface'] == 4 - name: 20 - Duplicate - 192.168.100.2/24 on interface with interface value netbox.netbox.netbox_ip_address: @@ -445,4 +442,3 @@ - test_twelve['ip_address']['address'] == "192.168.100.2/24" - test_twelve['ip_address']['assigned_object_type'] == "dcim.interface" - test_twelve['ip_address']['assigned_object_id'] == 4 - - test_nine['ip_address']['interface'] == 4 From e2302c9b6888d2a8344047c2488c10d7c1dcb55a Mon Sep 17 00:00:00 2001 From: Ido Don <76511079+Ido-Don@users.noreply.github.com> Date: Sat, 12 Oct 2024 15:54:38 +0300 Subject: [PATCH 10/20] rolled back the tests I added --- .../targets/v3.5/tasks/netbox_ip_address.yml | 96 ------------------- .../targets/v3.6/tasks/netbox_ip_address.yml | 96 ------------------- .../targets/v3.7/tasks/netbox_ip_address.yml | 96 ------------------- .../targets/v4.0/tasks/netbox_ip_address.yml | 96 ------------------- .../targets/v4.1/tasks/netbox_ip_address.yml | 92 ------------------ 5 files changed, 476 deletions(-) diff --git a/tests/integration/targets/v3.5/tasks/netbox_ip_address.yml b/tests/integration/targets/v3.5/tasks/netbox_ip_address.yml index b92a1e873..ce2b125a4 100644 --- a/tests/integration/targets/v3.5/tasks/netbox_ip_address.yml +++ b/tests/integration/targets/v3.5/tasks/netbox_ip_address.yml @@ -348,99 +348,3 @@ - test_sixteen['diff']['after']['state'] == "present" - test_sixteen['msg'] == "ip_address 10.120.10.1/32 created" - test_sixteen['ip_address']['address'] == "10.120.10.1/32" - -- name: "17 - Create IP address on GigabitEthernet2 with interface value - test100 - State: present" - netbox.netbox.netbox_ip_address: - netbox_url: http://localhost:32768 - netbox_token: "0123456789abcdef0123456789abcdef01234567" - data: - family: 4 - address: 10.10.200.30/16 - interface: - name: GigabitEthernet2 - device: test100 - register: test_nine - -- name: 17 - ASSERT - ansible.builtin.assert: - that: - - test_nine is changed - - test_nine['diff']['before']['state'] == "absent" - - test_nine['diff']['after']['state'] == "present" - - test_nine['msg'] == "ip_address 10.10.200.30/16 created" - - test_nine['ip_address']['address'] == "10.10.200.30/16" - - test_nine['ip_address']['family'] == 4 - - test_nine['ip_address']['assigned_object_type'] == "dcim.interface" - - test_nine['ip_address']['assigned_object_id'] == 4 - - test_nine['ip_address']['interface'] == 4 - -- name: "18 - Create IP address on GigabitEthernet2 - test100 with interface value - State: new" - netbox.netbox.netbox_ip_address: - netbox_url: http://localhost:32768 - netbox_token: "0123456789abcdef0123456789abcdef01234567" - data: - family: 4 - prefix: 10.10.0.0/16 - interface: - name: GigabitEthernet2 - device: test100 - state: new - register: test_ten - -- name: 18 - ASSERT - ansible.builtin.assert: - that: - - test_ten is changed - - test_ten['diff']['before']['state'] == "absent" - - test_ten['diff']['after']['state'] == "present" - - test_ten['msg'] == "ip_address 10.10.0.1/16 created" - - test_ten['ip_address']['address'] == "10.10.0.1/16" - - test_ten['ip_address']['family'] == 4 - - test_ten['ip_address']['assigned_object_type'] == "dcim.interface" - - test_ten['ip_address']['assigned_object_id'] == 4 - - test_nine['ip_address']['interface'] == 4 - -- name: "19 - Create IP address on GigabitEthernet2 - test100 with interface value - State: present" - netbox.netbox.netbox_ip_address: - netbox_url: http://localhost:32768 - netbox_token: "0123456789abcdef0123456789abcdef01234567" - data: - family: 4 - prefix: 192.168.100.0/24 - interface: - name: GigabitEthernet2 - device: test100 - state: present - register: test_eleven - -- name: 19 - ASSERT - ansible.builtin.assert: - that: - - test_eleven is changed - - test_eleven['diff']['before']['state'] == "absent" - - test_eleven['diff']['after']['state'] == "present" - - test_eleven['msg'] == "ip_address 192.168.100.2/24 created" - - test_eleven['ip_address']['address'] == "192.168.100.2/24" - - test_nine['ip_address']['interface'] == 4 - -- name: 20 - Duplicate - 192.168.100.2/24 on interface with interface value - netbox.netbox.netbox_ip_address: - netbox_url: http://localhost:32768 - netbox_token: "0123456789abcdef0123456789abcdef01234567" - data: - address: 192.168.100.2/24 - interface: - name: GigabitEthernet2 - device: test100 - state: present - register: test_twelve - -- name: 20 - ASSERT - ansible.builtin.assert: - that: - - not test_twelve['changed'] - - test_twelve['msg'] == "ip_address 192.168.100.2/24 already exists" - - test_twelve['ip_address']['address'] == "192.168.100.2/24" - - test_twelve['ip_address']['assigned_object_type'] == "dcim.interface" - - test_twelve['ip_address']['assigned_object_id'] == 4 - - test_nine['ip_address']['interface'] == 4 diff --git a/tests/integration/targets/v3.6/tasks/netbox_ip_address.yml b/tests/integration/targets/v3.6/tasks/netbox_ip_address.yml index b92a1e873..ce2b125a4 100644 --- a/tests/integration/targets/v3.6/tasks/netbox_ip_address.yml +++ b/tests/integration/targets/v3.6/tasks/netbox_ip_address.yml @@ -348,99 +348,3 @@ - test_sixteen['diff']['after']['state'] == "present" - test_sixteen['msg'] == "ip_address 10.120.10.1/32 created" - test_sixteen['ip_address']['address'] == "10.120.10.1/32" - -- name: "17 - Create IP address on GigabitEthernet2 with interface value - test100 - State: present" - netbox.netbox.netbox_ip_address: - netbox_url: http://localhost:32768 - netbox_token: "0123456789abcdef0123456789abcdef01234567" - data: - family: 4 - address: 10.10.200.30/16 - interface: - name: GigabitEthernet2 - device: test100 - register: test_nine - -- name: 17 - ASSERT - ansible.builtin.assert: - that: - - test_nine is changed - - test_nine['diff']['before']['state'] == "absent" - - test_nine['diff']['after']['state'] == "present" - - test_nine['msg'] == "ip_address 10.10.200.30/16 created" - - test_nine['ip_address']['address'] == "10.10.200.30/16" - - test_nine['ip_address']['family'] == 4 - - test_nine['ip_address']['assigned_object_type'] == "dcim.interface" - - test_nine['ip_address']['assigned_object_id'] == 4 - - test_nine['ip_address']['interface'] == 4 - -- name: "18 - Create IP address on GigabitEthernet2 - test100 with interface value - State: new" - netbox.netbox.netbox_ip_address: - netbox_url: http://localhost:32768 - netbox_token: "0123456789abcdef0123456789abcdef01234567" - data: - family: 4 - prefix: 10.10.0.0/16 - interface: - name: GigabitEthernet2 - device: test100 - state: new - register: test_ten - -- name: 18 - ASSERT - ansible.builtin.assert: - that: - - test_ten is changed - - test_ten['diff']['before']['state'] == "absent" - - test_ten['diff']['after']['state'] == "present" - - test_ten['msg'] == "ip_address 10.10.0.1/16 created" - - test_ten['ip_address']['address'] == "10.10.0.1/16" - - test_ten['ip_address']['family'] == 4 - - test_ten['ip_address']['assigned_object_type'] == "dcim.interface" - - test_ten['ip_address']['assigned_object_id'] == 4 - - test_nine['ip_address']['interface'] == 4 - -- name: "19 - Create IP address on GigabitEthernet2 - test100 with interface value - State: present" - netbox.netbox.netbox_ip_address: - netbox_url: http://localhost:32768 - netbox_token: "0123456789abcdef0123456789abcdef01234567" - data: - family: 4 - prefix: 192.168.100.0/24 - interface: - name: GigabitEthernet2 - device: test100 - state: present - register: test_eleven - -- name: 19 - ASSERT - ansible.builtin.assert: - that: - - test_eleven is changed - - test_eleven['diff']['before']['state'] == "absent" - - test_eleven['diff']['after']['state'] == "present" - - test_eleven['msg'] == "ip_address 192.168.100.2/24 created" - - test_eleven['ip_address']['address'] == "192.168.100.2/24" - - test_nine['ip_address']['interface'] == 4 - -- name: 20 - Duplicate - 192.168.100.2/24 on interface with interface value - netbox.netbox.netbox_ip_address: - netbox_url: http://localhost:32768 - netbox_token: "0123456789abcdef0123456789abcdef01234567" - data: - address: 192.168.100.2/24 - interface: - name: GigabitEthernet2 - device: test100 - state: present - register: test_twelve - -- name: 20 - ASSERT - ansible.builtin.assert: - that: - - not test_twelve['changed'] - - test_twelve['msg'] == "ip_address 192.168.100.2/24 already exists" - - test_twelve['ip_address']['address'] == "192.168.100.2/24" - - test_twelve['ip_address']['assigned_object_type'] == "dcim.interface" - - test_twelve['ip_address']['assigned_object_id'] == 4 - - test_nine['ip_address']['interface'] == 4 diff --git a/tests/integration/targets/v3.7/tasks/netbox_ip_address.yml b/tests/integration/targets/v3.7/tasks/netbox_ip_address.yml index f8de3b167..8813f8dcb 100644 --- a/tests/integration/targets/v3.7/tasks/netbox_ip_address.yml +++ b/tests/integration/targets/v3.7/tasks/netbox_ip_address.yml @@ -350,99 +350,3 @@ - test_sixteen['diff']['after']['state'] == "present" - test_sixteen['msg'] == "ip_address 10.120.10.1/32 created" - test_sixteen['ip_address']['address'] == "10.120.10.1/32" - -- name: "17 - Create IP address on GigabitEthernet2 with interface value - test100 - State: present" - netbox.netbox.netbox_ip_address: - netbox_url: http://localhost:32768 - netbox_token: "0123456789abcdef0123456789abcdef01234567" - data: - family: 4 - address: 10.10.200.30/16 - interface: - name: GigabitEthernet2 - device: test100 - register: test_nine - -- name: 17 - ASSERT - ansible.builtin.assert: - that: - - test_nine is changed - - test_nine['diff']['before']['state'] == "absent" - - test_nine['diff']['after']['state'] == "present" - - test_nine['msg'] == "ip_address 10.10.200.30/16 created" - - test_nine['ip_address']['address'] == "10.10.200.30/16" - - test_nine['ip_address']['family'] == 4 - - test_nine['ip_address']['assigned_object_type'] == "dcim.interface" - - test_nine['ip_address']['assigned_object_id'] == 4 - - test_nine['ip_address']['interface'] == 4 - -- name: "18 - Create IP address on GigabitEthernet2 - test100 with interface value - State: new" - netbox.netbox.netbox_ip_address: - netbox_url: http://localhost:32768 - netbox_token: "0123456789abcdef0123456789abcdef01234567" - data: - family: 4 - prefix: 10.10.0.0/16 - interface: - name: GigabitEthernet2 - device: test100 - state: new - register: test_ten - -- name: 18 - ASSERT - ansible.builtin.assert: - that: - - test_ten is changed - - test_ten['diff']['before']['state'] == "absent" - - test_ten['diff']['after']['state'] == "present" - - test_ten['msg'] == "ip_address 10.10.0.1/16 created" - - test_ten['ip_address']['address'] == "10.10.0.1/16" - - test_ten['ip_address']['family'] == 4 - - test_ten['ip_address']['assigned_object_type'] == "dcim.interface" - - test_ten['ip_address']['assigned_object_id'] == 4 - - test_nine['ip_address']['interface'] == 4 - -- name: "19 - Create IP address on GigabitEthernet2 - test100 with interface value - State: present" - netbox.netbox.netbox_ip_address: - netbox_url: http://localhost:32768 - netbox_token: "0123456789abcdef0123456789abcdef01234567" - data: - family: 4 - prefix: 192.168.100.0/24 - interface: - name: GigabitEthernet2 - device: test100 - state: present - register: test_eleven - -- name: 19 - ASSERT - ansible.builtin.assert: - that: - - test_eleven is changed - - test_eleven['diff']['before']['state'] == "absent" - - test_eleven['diff']['after']['state'] == "present" - - test_eleven['msg'] == "ip_address 192.168.100.2/24 created" - - test_eleven['ip_address']['address'] == "192.168.100.2/24" - - test_nine['ip_address']['interface'] == 4 - -- name: 20 - Duplicate - 192.168.100.2/24 on interface with interface value - netbox.netbox.netbox_ip_address: - netbox_url: http://localhost:32768 - netbox_token: "0123456789abcdef0123456789abcdef01234567" - data: - address: 192.168.100.2/24 - interface: - name: GigabitEthernet2 - device: test100 - state: present - register: test_twelve - -- name: 20 - ASSERT - ansible.builtin.assert: - that: - - not test_twelve['changed'] - - test_twelve['msg'] == "ip_address 192.168.100.2/24 already exists" - - test_twelve['ip_address']['address'] == "192.168.100.2/24" - - test_twelve['ip_address']['assigned_object_type'] == "dcim.interface" - - test_twelve['ip_address']['assigned_object_id'] == 4 - - test_nine['ip_address']['interface'] == 4 diff --git a/tests/integration/targets/v4.0/tasks/netbox_ip_address.yml b/tests/integration/targets/v4.0/tasks/netbox_ip_address.yml index f8de3b167..8813f8dcb 100644 --- a/tests/integration/targets/v4.0/tasks/netbox_ip_address.yml +++ b/tests/integration/targets/v4.0/tasks/netbox_ip_address.yml @@ -350,99 +350,3 @@ - test_sixteen['diff']['after']['state'] == "present" - test_sixteen['msg'] == "ip_address 10.120.10.1/32 created" - test_sixteen['ip_address']['address'] == "10.120.10.1/32" - -- name: "17 - Create IP address on GigabitEthernet2 with interface value - test100 - State: present" - netbox.netbox.netbox_ip_address: - netbox_url: http://localhost:32768 - netbox_token: "0123456789abcdef0123456789abcdef01234567" - data: - family: 4 - address: 10.10.200.30/16 - interface: - name: GigabitEthernet2 - device: test100 - register: test_nine - -- name: 17 - ASSERT - ansible.builtin.assert: - that: - - test_nine is changed - - test_nine['diff']['before']['state'] == "absent" - - test_nine['diff']['after']['state'] == "present" - - test_nine['msg'] == "ip_address 10.10.200.30/16 created" - - test_nine['ip_address']['address'] == "10.10.200.30/16" - - test_nine['ip_address']['family'] == 4 - - test_nine['ip_address']['assigned_object_type'] == "dcim.interface" - - test_nine['ip_address']['assigned_object_id'] == 4 - - test_nine['ip_address']['interface'] == 4 - -- name: "18 - Create IP address on GigabitEthernet2 - test100 with interface value - State: new" - netbox.netbox.netbox_ip_address: - netbox_url: http://localhost:32768 - netbox_token: "0123456789abcdef0123456789abcdef01234567" - data: - family: 4 - prefix: 10.10.0.0/16 - interface: - name: GigabitEthernet2 - device: test100 - state: new - register: test_ten - -- name: 18 - ASSERT - ansible.builtin.assert: - that: - - test_ten is changed - - test_ten['diff']['before']['state'] == "absent" - - test_ten['diff']['after']['state'] == "present" - - test_ten['msg'] == "ip_address 10.10.0.1/16 created" - - test_ten['ip_address']['address'] == "10.10.0.1/16" - - test_ten['ip_address']['family'] == 4 - - test_ten['ip_address']['assigned_object_type'] == "dcim.interface" - - test_ten['ip_address']['assigned_object_id'] == 4 - - test_nine['ip_address']['interface'] == 4 - -- name: "19 - Create IP address on GigabitEthernet2 - test100 with interface value - State: present" - netbox.netbox.netbox_ip_address: - netbox_url: http://localhost:32768 - netbox_token: "0123456789abcdef0123456789abcdef01234567" - data: - family: 4 - prefix: 192.168.100.0/24 - interface: - name: GigabitEthernet2 - device: test100 - state: present - register: test_eleven - -- name: 19 - ASSERT - ansible.builtin.assert: - that: - - test_eleven is changed - - test_eleven['diff']['before']['state'] == "absent" - - test_eleven['diff']['after']['state'] == "present" - - test_eleven['msg'] == "ip_address 192.168.100.2/24 created" - - test_eleven['ip_address']['address'] == "192.168.100.2/24" - - test_nine['ip_address']['interface'] == 4 - -- name: 20 - Duplicate - 192.168.100.2/24 on interface with interface value - netbox.netbox.netbox_ip_address: - netbox_url: http://localhost:32768 - netbox_token: "0123456789abcdef0123456789abcdef01234567" - data: - address: 192.168.100.2/24 - interface: - name: GigabitEthernet2 - device: test100 - state: present - register: test_twelve - -- name: 20 - ASSERT - ansible.builtin.assert: - that: - - not test_twelve['changed'] - - test_twelve['msg'] == "ip_address 192.168.100.2/24 already exists" - - test_twelve['ip_address']['address'] == "192.168.100.2/24" - - test_twelve['ip_address']['assigned_object_type'] == "dcim.interface" - - test_twelve['ip_address']['assigned_object_id'] == 4 - - test_nine['ip_address']['interface'] == 4 diff --git a/tests/integration/targets/v4.1/tasks/netbox_ip_address.yml b/tests/integration/targets/v4.1/tasks/netbox_ip_address.yml index 9dbf51491..8813f8dcb 100644 --- a/tests/integration/targets/v4.1/tasks/netbox_ip_address.yml +++ b/tests/integration/targets/v4.1/tasks/netbox_ip_address.yml @@ -350,95 +350,3 @@ - test_sixteen['diff']['after']['state'] == "present" - test_sixteen['msg'] == "ip_address 10.120.10.1/32 created" - test_sixteen['ip_address']['address'] == "10.120.10.1/32" - -- name: "17 - Create IP address on GigabitEthernet2 with interface value - test100 - State: present" - netbox.netbox.netbox_ip_address: - netbox_url: http://localhost:32768 - netbox_token: "0123456789abcdef0123456789abcdef01234567" - data: - family: 4 - address: 10.10.200.30/16 - interface: - name: GigabitEthernet2 - device: test100 - register: test_nine - -- name: 17 - ASSERT - ansible.builtin.assert: - that: - - test_nine is changed - - test_nine['diff']['before']['state'] == "absent" - - test_nine['diff']['after']['state'] == "present" - - test_nine['msg'] == "ip_address 10.10.200.30/16 created" - - test_nine['ip_address']['address'] == "10.10.200.30/16" - - test_nine['ip_address']['family'] == 4 - - test_nine['ip_address']['assigned_object_type'] == "dcim.interface" - - test_nine['ip_address']['assigned_object_id'] == 4 - -- name: "18 - Create IP address on GigabitEthernet2 - test100 with interface value - State: new" - netbox.netbox.netbox_ip_address: - netbox_url: http://localhost:32768 - netbox_token: "0123456789abcdef0123456789abcdef01234567" - data: - family: 4 - prefix: 10.10.0.0/16 - interface: - name: GigabitEthernet2 - device: test100 - state: new - register: test_ten - -- name: 18 - ASSERT - ansible.builtin.assert: - that: - - test_ten is changed - - test_ten['diff']['before']['state'] == "absent" - - test_ten['diff']['after']['state'] == "present" - - test_ten['msg'] == "ip_address 10.10.0.1/16 created" - - test_ten['ip_address']['address'] == "10.10.0.1/16" - - test_ten['ip_address']['family'] == 4 - - test_ten['ip_address']['assigned_object_type'] == "dcim.interface" - - test_ten['ip_address']['assigned_object_id'] == 4 - -- name: "19 - Create IP address on GigabitEthernet2 - test100 with interface value - State: present" - netbox.netbox.netbox_ip_address: - netbox_url: http://localhost:32768 - netbox_token: "0123456789abcdef0123456789abcdef01234567" - data: - family: 4 - prefix: 192.168.100.0/24 - interface: - name: GigabitEthernet2 - device: test100 - state: present - register: test_eleven - -- name: 19 - ASSERT - ansible.builtin.assert: - that: - - test_eleven is changed - - test_eleven['diff']['before']['state'] == "absent" - - test_eleven['diff']['after']['state'] == "present" - - test_eleven['msg'] == "ip_address 192.168.100.2/24 created" - - test_eleven['ip_address']['address'] == "192.168.100.2/24" - -- name: 20 - Duplicate - 192.168.100.2/24 on interface with interface value - netbox.netbox.netbox_ip_address: - netbox_url: http://localhost:32768 - netbox_token: "0123456789abcdef0123456789abcdef01234567" - data: - address: 192.168.100.2/24 - interface: - name: GigabitEthernet2 - device: test100 - state: present - register: test_twelve - -- name: 20 - ASSERT - ansible.builtin.assert: - that: - - not test_twelve['changed'] - - test_twelve['msg'] == "ip_address 192.168.100.2/24 already exists" - - test_twelve['ip_address']['address'] == "192.168.100.2/24" - - test_twelve['ip_address']['assigned_object_type'] == "dcim.interface" - - test_twelve['ip_address']['assigned_object_id'] == 4 From 1d5b592a76dac1b3448f670ccd44ce2a2c0f525f Mon Sep 17 00:00:00 2001 From: Ido Don <76511079+Ido-Don@users.noreply.github.com> Date: Sat, 12 Oct 2024 15:57:24 +0300 Subject: [PATCH 11/20] added a simple test to see if it would work. this interface should exist and the ip 10.10.200.31/16 should be added to it --- .../targets/v4.1/tasks/netbox_ip_address.yml | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/tests/integration/targets/v4.1/tasks/netbox_ip_address.yml b/tests/integration/targets/v4.1/tasks/netbox_ip_address.yml index 8813f8dcb..ddbb9cb2e 100644 --- a/tests/integration/targets/v4.1/tasks/netbox_ip_address.yml +++ b/tests/integration/targets/v4.1/tasks/netbox_ip_address.yml @@ -350,3 +350,27 @@ - test_sixteen['diff']['after']['state'] == "present" - test_sixteen['msg'] == "ip_address 10.120.10.1/32 created" - test_sixteen['ip_address']['address'] == "10.120.10.1/32" + +- name: "17 - Create IP address on GigabitEthernet2 - test100 with interface value - State: present" + netbox.netbox.netbox_ip_address: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + family: 4 + address: 10.10.200.31/16 + interface: + device: test100 + name: GigabitEthernet2 + register: test_seventeen + +- name: 9 - ASSERT + ansible.builtin.assert: + that: + - test_seventeen is changed + - test_seventeen['diff']['before']['state'] == "absent" + - test_seventeen['diff']['after']['state'] == "present" + - test_seventeen['msg'] == "ip_address 10.10.200.31/16 created" + - test_seventeen['ip_address']['address'] == "10.10.200.31/16" + - test_seventeen['ip_address']['family'] == 4 + - test_seventeen['ip_address']['assigned_object_type'] == "dcim.interface" + - test_seventeen['ip_address']['assigned_object_id'] == 4 From 6eb1e5d7e53d57da196adffc56fa970246d8f71b Mon Sep 17 00:00:00 2001 From: Ido Don <76511079+Ido-Don@users.noreply.github.com> Date: Sat, 12 Oct 2024 16:24:15 +0300 Subject: [PATCH 12/20] added some more tests to v4.1 --- .../targets/v4.1/tasks/netbox_ip_address.yml | 70 ++++++++++++++++++- 1 file changed, 69 insertions(+), 1 deletion(-) diff --git a/tests/integration/targets/v4.1/tasks/netbox_ip_address.yml b/tests/integration/targets/v4.1/tasks/netbox_ip_address.yml index ddbb9cb2e..832786e12 100644 --- a/tests/integration/targets/v4.1/tasks/netbox_ip_address.yml +++ b/tests/integration/targets/v4.1/tasks/netbox_ip_address.yml @@ -363,7 +363,7 @@ name: GigabitEthernet2 register: test_seventeen -- name: 9 - ASSERT +- name: 17 - ASSERT ansible.builtin.assert: that: - test_seventeen is changed @@ -374,3 +374,71 @@ - test_seventeen['ip_address']['family'] == 4 - test_seventeen['ip_address']['assigned_object_type'] == "dcim.interface" - test_seventeen['ip_address']['assigned_object_id'] == 4 + +- name: "18 - Create IP address on GigabitEthernet2 - test100 with interface value - State: new" + netbox.netbox.netbox_ip_address: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + family: 4 + prefix: 10.10.0.0/16 + interface: + name: GigabitEthernet2 + device: test100 + state: new + register: test_eighteen + +- name: 18 - ASSERT + ansible.builtin.assert: + that: + - test_eighteen is changed + - test_eighteen['diff']['before']['state'] == "absent" + - test_eighteen['diff']['after']['state'] == "present" + - test_eighteen['msg'] == "ip_address 10.10.0.1/16 created" + - test_eighteen['ip_address']['address'] == "10.10.0.2/16" + - test_eighteen['ip_address']['family'] == 4 + - test_eighteen['ip_address']['assigned_object_type'] == "dcim.interface" + - test_eighteen['ip_address']['assigned_object_id'] == 4 + +- name: "19 - Create IP address on GigabitEthernet2 - test100 with interface value - State: present" + netbox.netbox.netbox_ip_address: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + family: 4 + prefix: 192.168.100.0/24 + interface: + name: GigabitEthernet2 + device: test100 + state: present + register: test_nineteen + +- name: 19 - ASSERT + ansible.builtin.assert: + that: + - test_nineteen is changed + - test_nineteen['diff']['before']['state'] == "absent" + - test_nineteen['diff']['after']['state'] == "present" + - test_nineteen['msg'] == "ip_address 192.168.100.3/24 created" + - test_nineteen['ip_address']['address'] == "192.168.100.3/24" + +- name: 20 - Duplicate - 192.168.100.2/24 on interface with interface value + netbox.netbox.netbox_ip_address: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + address: 192.168.100.2/24 + interface: + name: GigabitEthernet2 + device: test100 + state: present + register: test_twenty + +- name: 20 - ASSERT + ansible.builtin.assert: + that: + - not test_twenty['changed'] + - test_twenty['msg'] == "ip_address 192.168.100.2/24 already exists" + - test_twenty['ip_address']['address'] == "192.168.100.2/24" + - test_twenty['ip_address']['assigned_object_type'] == "dcim.interface" + - test_twenty['ip_address']['assigned_object_id'] == 4 From 5d96e8dcdad4b68ec356fbe09700b5d327870832 Mon Sep 17 00:00:00 2001 From: Ido Don <76511079+Ido-Don@users.noreply.github.com> Date: Sat, 12 Oct 2024 16:35:06 +0300 Subject: [PATCH 13/20] fixed the 18'th test --- tests/integration/targets/v4.1/tasks/netbox_ip_address.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/integration/targets/v4.1/tasks/netbox_ip_address.yml b/tests/integration/targets/v4.1/tasks/netbox_ip_address.yml index 832786e12..a9ceb1395 100644 --- a/tests/integration/targets/v4.1/tasks/netbox_ip_address.yml +++ b/tests/integration/targets/v4.1/tasks/netbox_ip_address.yml @@ -395,7 +395,7 @@ - test_eighteen['diff']['before']['state'] == "absent" - test_eighteen['diff']['after']['state'] == "present" - test_eighteen['msg'] == "ip_address 10.10.0.1/16 created" - - test_eighteen['ip_address']['address'] == "10.10.0.2/16" + - test_eighteen['ip_address']['address'] == "10.10.0.1/16" - test_eighteen['ip_address']['family'] == 4 - test_eighteen['ip_address']['assigned_object_type'] == "dcim.interface" - test_eighteen['ip_address']['assigned_object_id'] == 4 From 9b7ddccd8d3134de93842d110f95b018bca36744 Mon Sep 17 00:00:00 2001 From: Ido Don <76511079+Ido-Don@users.noreply.github.com> Date: Sat, 12 Oct 2024 16:45:44 +0300 Subject: [PATCH 14/20] fixed the 18'th test again --- tests/integration/targets/v4.1/tasks/netbox_ip_address.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/integration/targets/v4.1/tasks/netbox_ip_address.yml b/tests/integration/targets/v4.1/tasks/netbox_ip_address.yml index a9ceb1395..3cace03b0 100644 --- a/tests/integration/targets/v4.1/tasks/netbox_ip_address.yml +++ b/tests/integration/targets/v4.1/tasks/netbox_ip_address.yml @@ -394,8 +394,8 @@ - test_eighteen is changed - test_eighteen['diff']['before']['state'] == "absent" - test_eighteen['diff']['after']['state'] == "present" - - test_eighteen['msg'] == "ip_address 10.10.0.1/16 created" - - test_eighteen['ip_address']['address'] == "10.10.0.1/16" + - test_eighteen['msg'] == "ip_address 10.10.0.2/16 created" + - test_eighteen['ip_address']['address'] == "10.10.0.2/16" - test_eighteen['ip_address']['family'] == 4 - test_eighteen['ip_address']['assigned_object_type'] == "dcim.interface" - test_eighteen['ip_address']['assigned_object_id'] == 4 From 2aaeb760fe4fa34b8e217def77005217f982bf85 Mon Sep 17 00:00:00 2001 From: Ido Don <76511079+Ido-Don@users.noreply.github.com> Date: Sat, 12 Oct 2024 16:59:26 +0300 Subject: [PATCH 15/20] fixed test 19 --- tests/integration/targets/v4.1/tasks/netbox_ip_address.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/integration/targets/v4.1/tasks/netbox_ip_address.yml b/tests/integration/targets/v4.1/tasks/netbox_ip_address.yml index 3cace03b0..986c3be3c 100644 --- a/tests/integration/targets/v4.1/tasks/netbox_ip_address.yml +++ b/tests/integration/targets/v4.1/tasks/netbox_ip_address.yml @@ -406,7 +406,7 @@ netbox_token: "0123456789abcdef0123456789abcdef01234567" data: family: 4 - prefix: 192.168.100.0/24 + prefix: 192.168.101.0/24 interface: name: GigabitEthernet2 device: test100 @@ -419,8 +419,8 @@ - test_nineteen is changed - test_nineteen['diff']['before']['state'] == "absent" - test_nineteen['diff']['after']['state'] == "present" - - test_nineteen['msg'] == "ip_address 192.168.100.3/24 created" - - test_nineteen['ip_address']['address'] == "192.168.100.3/24" + - test_nineteen['msg'] == "ip_address 192.168.101.1/24 created" + - test_nineteen['ip_address']['address'] == "192.168.101.1/24" - name: 20 - Duplicate - 192.168.100.2/24 on interface with interface value netbox.netbox.netbox_ip_address: From 4a3c2c2bf5c78c7b2b21c0209d50cb845720caaa Mon Sep 17 00:00:00 2001 From: Ido Don <76511079+Ido-Don@users.noreply.github.com> Date: Sat, 12 Oct 2024 17:11:55 +0300 Subject: [PATCH 16/20] fixed test 19 --- .../integration/targets/v4.1/tasks/netbox_ip_address.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tests/integration/targets/v4.1/tasks/netbox_ip_address.yml b/tests/integration/targets/v4.1/tasks/netbox_ip_address.yml index 986c3be3c..c864ea3e4 100644 --- a/tests/integration/targets/v4.1/tasks/netbox_ip_address.yml +++ b/tests/integration/targets/v4.1/tasks/netbox_ip_address.yml @@ -406,7 +406,7 @@ netbox_token: "0123456789abcdef0123456789abcdef01234567" data: family: 4 - prefix: 192.168.101.0/24 + prefix: 10.120.10.0/24 interface: name: GigabitEthernet2 device: test100 @@ -419,8 +419,10 @@ - test_nineteen is changed - test_nineteen['diff']['before']['state'] == "absent" - test_nineteen['diff']['after']['state'] == "present" - - test_nineteen['msg'] == "ip_address 192.168.101.1/24 created" - - test_nineteen['ip_address']['address'] == "192.168.101.1/24" + - test_nineteen['msg'] == "ip_address 10.120.10.2/24 created" + - test_nineteen['ip_address']['address'] == "10.120.10.2/24" + - test_nineteen['ip_address']['assigned_object_type'] == "dcim.interface" + - test_nineteen['ip_address']['assigned_object_id'] == 4 - name: 20 - Duplicate - 192.168.100.2/24 on interface with interface value netbox.netbox.netbox_ip_address: From bd3968c5e8e555955117d3e6feee5999a8a2b85e Mon Sep 17 00:00:00 2001 From: Ido Don <76511079+Ido-Don@users.noreply.github.com> Date: Sat, 12 Oct 2024 17:33:38 +0300 Subject: [PATCH 17/20] removed the unnecessary tests. --- .../targets/v4.1/tasks/netbox_ip_address.yml | 45 ------------------- 1 file changed, 45 deletions(-) diff --git a/tests/integration/targets/v4.1/tasks/netbox_ip_address.yml b/tests/integration/targets/v4.1/tasks/netbox_ip_address.yml index c864ea3e4..328cdfc35 100644 --- a/tests/integration/targets/v4.1/tasks/netbox_ip_address.yml +++ b/tests/integration/targets/v4.1/tasks/netbox_ip_address.yml @@ -399,48 +399,3 @@ - test_eighteen['ip_address']['family'] == 4 - test_eighteen['ip_address']['assigned_object_type'] == "dcim.interface" - test_eighteen['ip_address']['assigned_object_id'] == 4 - -- name: "19 - Create IP address on GigabitEthernet2 - test100 with interface value - State: present" - netbox.netbox.netbox_ip_address: - netbox_url: http://localhost:32768 - netbox_token: "0123456789abcdef0123456789abcdef01234567" - data: - family: 4 - prefix: 10.120.10.0/24 - interface: - name: GigabitEthernet2 - device: test100 - state: present - register: test_nineteen - -- name: 19 - ASSERT - ansible.builtin.assert: - that: - - test_nineteen is changed - - test_nineteen['diff']['before']['state'] == "absent" - - test_nineteen['diff']['after']['state'] == "present" - - test_nineteen['msg'] == "ip_address 10.120.10.2/24 created" - - test_nineteen['ip_address']['address'] == "10.120.10.2/24" - - test_nineteen['ip_address']['assigned_object_type'] == "dcim.interface" - - test_nineteen['ip_address']['assigned_object_id'] == 4 - -- name: 20 - Duplicate - 192.168.100.2/24 on interface with interface value - netbox.netbox.netbox_ip_address: - netbox_url: http://localhost:32768 - netbox_token: "0123456789abcdef0123456789abcdef01234567" - data: - address: 192.168.100.2/24 - interface: - name: GigabitEthernet2 - device: test100 - state: present - register: test_twenty - -- name: 20 - ASSERT - ansible.builtin.assert: - that: - - not test_twenty['changed'] - - test_twenty['msg'] == "ip_address 192.168.100.2/24 already exists" - - test_twenty['ip_address']['address'] == "192.168.100.2/24" - - test_twenty['ip_address']['assigned_object_type'] == "dcim.interface" - - test_twenty['ip_address']['assigned_object_id'] == 4 From 6bf3aa51e695ea9927b0da891f2fce7d34fa3cac Mon Sep 17 00:00:00 2001 From: Ido Don <76511079+Ido-Don@users.noreply.github.com> Date: Sat, 12 Oct 2024 17:35:51 +0300 Subject: [PATCH 18/20] added the tests to 4.0, 3.7, 3.6, 3.5 --- .../targets/v3.5/tasks/netbox_ip_address.yml | 49 +++++++++++++++++++ .../targets/v3.6/tasks/netbox_ip_address.yml | 49 +++++++++++++++++++ .../targets/v3.7/tasks/netbox_ip_address.yml | 49 +++++++++++++++++++ .../targets/v4.0/tasks/netbox_ip_address.yml | 49 +++++++++++++++++++ 4 files changed, 196 insertions(+) diff --git a/tests/integration/targets/v3.5/tasks/netbox_ip_address.yml b/tests/integration/targets/v3.5/tasks/netbox_ip_address.yml index ce2b125a4..c73fb9dfb 100644 --- a/tests/integration/targets/v3.5/tasks/netbox_ip_address.yml +++ b/tests/integration/targets/v3.5/tasks/netbox_ip_address.yml @@ -348,3 +348,52 @@ - test_sixteen['diff']['after']['state'] == "present" - test_sixteen['msg'] == "ip_address 10.120.10.1/32 created" - test_sixteen['ip_address']['address'] == "10.120.10.1/32" + +- name: "17 - Create IP address on GigabitEthernet2 - test100 with interface value - State: present" + netbox.netbox.netbox_ip_address: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + family: 4 + address: 10.10.200.31/16 + interface: + device: test100 + name: GigabitEthernet2 + register: test_seventeen + +- name: 17 - ASSERT + ansible.builtin.assert: + that: + - test_seventeen is changed + - test_seventeen['diff']['before']['state'] == "absent" + - test_seventeen['diff']['after']['state'] == "present" + - test_seventeen['msg'] == "ip_address 10.10.200.31/16 created" + - test_seventeen['ip_address']['address'] == "10.10.200.31/16" + - test_seventeen['ip_address']['family'] == 4 + - test_seventeen['ip_address']['assigned_object_type'] == "dcim.interface" + - test_seventeen['ip_address']['assigned_object_id'] == 4 + +- name: "18 - Create IP address on GigabitEthernet2 - test100 with interface value - State: new" + netbox.netbox.netbox_ip_address: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + family: 4 + prefix: 10.10.0.0/16 + interface: + name: GigabitEthernet2 + device: test100 + state: new + register: test_eighteen + +- name: 18 - ASSERT + ansible.builtin.assert: + that: + - test_eighteen is changed + - test_eighteen['diff']['before']['state'] == "absent" + - test_eighteen['diff']['after']['state'] == "present" + - test_eighteen['msg'] == "ip_address 10.10.0.2/16 created" + - test_eighteen['ip_address']['address'] == "10.10.0.2/16" + - test_eighteen['ip_address']['family'] == 4 + - test_eighteen['ip_address']['assigned_object_type'] == "dcim.interface" + - test_eighteen['ip_address']['assigned_object_id'] == 4 diff --git a/tests/integration/targets/v3.6/tasks/netbox_ip_address.yml b/tests/integration/targets/v3.6/tasks/netbox_ip_address.yml index ce2b125a4..c73fb9dfb 100644 --- a/tests/integration/targets/v3.6/tasks/netbox_ip_address.yml +++ b/tests/integration/targets/v3.6/tasks/netbox_ip_address.yml @@ -348,3 +348,52 @@ - test_sixteen['diff']['after']['state'] == "present" - test_sixteen['msg'] == "ip_address 10.120.10.1/32 created" - test_sixteen['ip_address']['address'] == "10.120.10.1/32" + +- name: "17 - Create IP address on GigabitEthernet2 - test100 with interface value - State: present" + netbox.netbox.netbox_ip_address: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + family: 4 + address: 10.10.200.31/16 + interface: + device: test100 + name: GigabitEthernet2 + register: test_seventeen + +- name: 17 - ASSERT + ansible.builtin.assert: + that: + - test_seventeen is changed + - test_seventeen['diff']['before']['state'] == "absent" + - test_seventeen['diff']['after']['state'] == "present" + - test_seventeen['msg'] == "ip_address 10.10.200.31/16 created" + - test_seventeen['ip_address']['address'] == "10.10.200.31/16" + - test_seventeen['ip_address']['family'] == 4 + - test_seventeen['ip_address']['assigned_object_type'] == "dcim.interface" + - test_seventeen['ip_address']['assigned_object_id'] == 4 + +- name: "18 - Create IP address on GigabitEthernet2 - test100 with interface value - State: new" + netbox.netbox.netbox_ip_address: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + family: 4 + prefix: 10.10.0.0/16 + interface: + name: GigabitEthernet2 + device: test100 + state: new + register: test_eighteen + +- name: 18 - ASSERT + ansible.builtin.assert: + that: + - test_eighteen is changed + - test_eighteen['diff']['before']['state'] == "absent" + - test_eighteen['diff']['after']['state'] == "present" + - test_eighteen['msg'] == "ip_address 10.10.0.2/16 created" + - test_eighteen['ip_address']['address'] == "10.10.0.2/16" + - test_eighteen['ip_address']['family'] == 4 + - test_eighteen['ip_address']['assigned_object_type'] == "dcim.interface" + - test_eighteen['ip_address']['assigned_object_id'] == 4 diff --git a/tests/integration/targets/v3.7/tasks/netbox_ip_address.yml b/tests/integration/targets/v3.7/tasks/netbox_ip_address.yml index 8813f8dcb..328cdfc35 100644 --- a/tests/integration/targets/v3.7/tasks/netbox_ip_address.yml +++ b/tests/integration/targets/v3.7/tasks/netbox_ip_address.yml @@ -350,3 +350,52 @@ - test_sixteen['diff']['after']['state'] == "present" - test_sixteen['msg'] == "ip_address 10.120.10.1/32 created" - test_sixteen['ip_address']['address'] == "10.120.10.1/32" + +- name: "17 - Create IP address on GigabitEthernet2 - test100 with interface value - State: present" + netbox.netbox.netbox_ip_address: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + family: 4 + address: 10.10.200.31/16 + interface: + device: test100 + name: GigabitEthernet2 + register: test_seventeen + +- name: 17 - ASSERT + ansible.builtin.assert: + that: + - test_seventeen is changed + - test_seventeen['diff']['before']['state'] == "absent" + - test_seventeen['diff']['after']['state'] == "present" + - test_seventeen['msg'] == "ip_address 10.10.200.31/16 created" + - test_seventeen['ip_address']['address'] == "10.10.200.31/16" + - test_seventeen['ip_address']['family'] == 4 + - test_seventeen['ip_address']['assigned_object_type'] == "dcim.interface" + - test_seventeen['ip_address']['assigned_object_id'] == 4 + +- name: "18 - Create IP address on GigabitEthernet2 - test100 with interface value - State: new" + netbox.netbox.netbox_ip_address: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + family: 4 + prefix: 10.10.0.0/16 + interface: + name: GigabitEthernet2 + device: test100 + state: new + register: test_eighteen + +- name: 18 - ASSERT + ansible.builtin.assert: + that: + - test_eighteen is changed + - test_eighteen['diff']['before']['state'] == "absent" + - test_eighteen['diff']['after']['state'] == "present" + - test_eighteen['msg'] == "ip_address 10.10.0.2/16 created" + - test_eighteen['ip_address']['address'] == "10.10.0.2/16" + - test_eighteen['ip_address']['family'] == 4 + - test_eighteen['ip_address']['assigned_object_type'] == "dcim.interface" + - test_eighteen['ip_address']['assigned_object_id'] == 4 diff --git a/tests/integration/targets/v4.0/tasks/netbox_ip_address.yml b/tests/integration/targets/v4.0/tasks/netbox_ip_address.yml index 8813f8dcb..328cdfc35 100644 --- a/tests/integration/targets/v4.0/tasks/netbox_ip_address.yml +++ b/tests/integration/targets/v4.0/tasks/netbox_ip_address.yml @@ -350,3 +350,52 @@ - test_sixteen['diff']['after']['state'] == "present" - test_sixteen['msg'] == "ip_address 10.120.10.1/32 created" - test_sixteen['ip_address']['address'] == "10.120.10.1/32" + +- name: "17 - Create IP address on GigabitEthernet2 - test100 with interface value - State: present" + netbox.netbox.netbox_ip_address: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + family: 4 + address: 10.10.200.31/16 + interface: + device: test100 + name: GigabitEthernet2 + register: test_seventeen + +- name: 17 - ASSERT + ansible.builtin.assert: + that: + - test_seventeen is changed + - test_seventeen['diff']['before']['state'] == "absent" + - test_seventeen['diff']['after']['state'] == "present" + - test_seventeen['msg'] == "ip_address 10.10.200.31/16 created" + - test_seventeen['ip_address']['address'] == "10.10.200.31/16" + - test_seventeen['ip_address']['family'] == 4 + - test_seventeen['ip_address']['assigned_object_type'] == "dcim.interface" + - test_seventeen['ip_address']['assigned_object_id'] == 4 + +- name: "18 - Create IP address on GigabitEthernet2 - test100 with interface value - State: new" + netbox.netbox.netbox_ip_address: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + family: 4 + prefix: 10.10.0.0/16 + interface: + name: GigabitEthernet2 + device: test100 + state: new + register: test_eighteen + +- name: 18 - ASSERT + ansible.builtin.assert: + that: + - test_eighteen is changed + - test_eighteen['diff']['before']['state'] == "absent" + - test_eighteen['diff']['after']['state'] == "present" + - test_eighteen['msg'] == "ip_address 10.10.0.2/16 created" + - test_eighteen['ip_address']['address'] == "10.10.0.2/16" + - test_eighteen['ip_address']['family'] == 4 + - test_eighteen['ip_address']['assigned_object_type'] == "dcim.interface" + - test_eighteen['ip_address']['assigned_object_id'] == 4 From df4ba57813e73a52355794fa1a5d7f23e69381b4 Mon Sep 17 00:00:00 2001 From: Ido Don <76511079+Ido-Don@users.noreply.github.com> Date: Sat, 12 Oct 2024 17:43:00 +0300 Subject: [PATCH 19/20] removed the pull request ref --- changelogs/fragments/1323-fixing-bug-#975.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelogs/fragments/1323-fixing-bug-#975.yml b/changelogs/fragments/1323-fixing-bug-#975.yml index b8390e86f..c002348ed 100644 --- a/changelogs/fragments/1323-fixing-bug-#975.yml +++ b/changelogs/fragments/1323-fixing-bug-#975.yml @@ -1,3 +1,3 @@ bugfixes: - netbox_ip_address - Fixed the problem preventing assignment of an IP address to a network interface - [#1323](https://github.com/netbox-community/ansible_modules/pull/1323) + From e7b6ca54f4b5c584c13e371217413e016dde0551 Mon Sep 17 00:00:00 2001 From: Ido Don <76511079+Ido-Don@users.noreply.github.com> Date: Sat, 12 Oct 2024 17:43:36 +0300 Subject: [PATCH 20/20] removed the extra line --- changelogs/fragments/1323-fixing-bug-#975.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/changelogs/fragments/1323-fixing-bug-#975.yml b/changelogs/fragments/1323-fixing-bug-#975.yml index c002348ed..c0ac8b423 100644 --- a/changelogs/fragments/1323-fixing-bug-#975.yml +++ b/changelogs/fragments/1323-fixing-bug-#975.yml @@ -1,3 +1,2 @@ bugfixes: - netbox_ip_address - Fixed the problem preventing assignment of an IP address to a network interface -