From ab639d945080c27522d42f9122b93af7c8793eb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20R=C3=B8dvand?= Date: Mon, 13 Jan 2025 01:07:08 +0100 Subject: [PATCH] Adjust netbox_prefix and netbox_cluster for scope and scope_type (#1367) * Update netbox_prefix for NetBox 4.2 * Adjust test file to include tags for each test * Reformat netbox_prefix * Fix removed_in_version * Linting * Add changelog fragment * Fix fragment section --- changelogs/fragments/scope_prefix_cluster.yml | 3 + plugins/modules/netbox_cluster.py | 59 ++- plugins/modules/netbox_prefix.py | 54 ++- tests/integration/targets/v4.2/tasks/main.yml | 454 +++++++++++++++--- .../targets/v4.2/tasks/netbox_cluster.yml | 14 +- .../targets/v4.2/tasks/netbox_prefix.yml | 27 +- 6 files changed, 535 insertions(+), 76 deletions(-) create mode 100644 changelogs/fragments/scope_prefix_cluster.yml diff --git a/changelogs/fragments/scope_prefix_cluster.yml b/changelogs/fragments/scope_prefix_cluster.yml new file mode 100644 index 000000000..dfdfecd2b --- /dev/null +++ b/changelogs/fragments/scope_prefix_cluster.yml @@ -0,0 +1,3 @@ +minor_changes: + - netbox_prefix - Add options scope and scope_type for NetBox 4.2+ + - netbox_cluster - Add options scope and scope_type for NetBox 4.2+ diff --git a/plugins/modules/netbox_cluster.py b/plugins/modules/netbox_cluster.py index d91e770c6..a89a05588 100644 --- a/plugins/modules/netbox_cluster.py +++ b/plugins/modules/netbox_cluster.py @@ -53,9 +53,28 @@ type: raw site: description: - - Required if I(state=present) and the cluster does not exist yet + - Required if I(state=present) and the cluster does not exist yet (Deprecated in NetBox 4.2+) + - Will be removed in version 5.0.0 required: false type: raw + scope_type: + description: + - Type of scope to be applied (NetBox 4.2+) + required: false + type: str + choices: + - "dcim.location" + - "dcim.rack" + - "dcim.region" + - "dcim.site" + - "dcim.sitegroup" + version_added: "3.21.0" + scope: + description: + - Object related to scope type (NetBox 4.2+) + required: false + type: raw + version_added: "3.21.0" description: description: - The description of the cluster @@ -131,6 +150,19 @@ site: SITE status: planned state: present + + - name: Update the group and scope of an existing cluster (NetBox 4.2+) + netbox.netbox.netbox_cluster: + netbox_url: http://netbox.local + netbox_token: thisIsMyToken + data: + name: Test Cluster + cluster_type: qemu + cluster_group: GROUP + scope_type: "dcim.site" + scope: SITE + status: planned + state: present """ RETURN = r""" @@ -170,7 +202,24 @@ def main(): status=dict(required=False, type="raw"), cluster_type=dict(required=False, type="raw"), cluster_group=dict(required=False, type="raw"), - site=dict(required=False, type="raw"), + site=dict( + required=False, + type="raw", + removed_in_version="5.0.0", + removed_from_collection="netbox.netbox", + ), + scope_type=dict( + required=False, + type="str", + choices=[ + "dcim.location", + "dcim.rack", + "dcim.region", + "dcim.site", + "dcim.sitegroup", + ], + ), + scope=dict(required=False, type="raw"), tenant=dict(required=False, type="raw"), description=dict(required=False, type="str"), comments=dict(required=False, type="str"), @@ -182,9 +231,13 @@ def main(): ) required_if = [("state", "present", ["name"]), ("state", "absent", ["name"])] + required_together = [("scope_type", "scope")] module = NetboxAnsibleModule( - argument_spec=argument_spec, supports_check_mode=True, required_if=required_if + argument_spec=argument_spec, + supports_check_mode=True, + required_if=required_if, + required_together=required_together, ) netbox_cluster = NetboxVirtualizationModule(module, NB_CLUSTERS) diff --git a/plugins/modules/netbox_prefix.py b/plugins/modules/netbox_prefix.py index bfb9bba48..f6135381c 100644 --- a/plugins/modules/netbox_prefix.py +++ b/plugins/modules/netbox_prefix.py @@ -55,9 +55,28 @@ type: int site: description: - - Site that prefix is associated with + - Site that prefix is associated with (Deprecated in NetBox 4.2+) + - Will be removed in version 5.0.0 required: false type: raw + scope_type: + description: + - Type of scope to be applied (NetBox 4.2+) + required: false + type: str + choices: + - "dcim.location" + - "dcim.rack" + - "dcim.region" + - "dcim.site" + - "dcim.sitegroup" + version_added: "3.21.0" + scope: + description: + - Object related to scope type (NetBox 4.2+) + required: false + type: raw + version_added: "3.21.0" vrf: description: - VRF that prefix is associated with @@ -212,6 +231,20 @@ site: Test Site state: present first_available: true + + - name: Create prefix with scope (NetBox 4.2+) + netbox.netbox.netbox_prefix: + netbox_url: http://netbox.local + netbox_token: thisIsMyToken + data: + prefix: 10.156.32.0/19 + scope_type: "dcim.site" + scope: Test Site + vrf: Test VRF + tenant: Test Tenant + status: Reserved + description: Test description + state: present """ RETURN = r""" @@ -252,7 +285,24 @@ def main(): prefix=dict(required=False, type="raw"), parent=dict(required=False, type="raw"), prefix_length=dict(required=False, type="int"), - site=dict(required=False, type="raw"), + site=dict( + required=False, + type="raw", + removed_in_version="5.0.0", + removed_from_collection="netbox.netbox", + ), + scope_type=dict( + required=False, + type="str", + choices=[ + "dcim.location", + "dcim.rack", + "dcim.region", + "dcim.site", + "dcim.sitegroup", + ], + ), + scope=dict(required=False, type="raw"), vrf=dict(required=False, type="raw"), tenant=dict(required=False, type="raw"), vlan=dict(required=False, type="raw"), diff --git a/tests/integration/targets/v4.2/tasks/main.yml b/tests/integration/targets/v4.2/tasks/main.yml index 1d56afb98..9b5b5c21a 100644 --- a/tests/integration/targets/v4.2/tasks/main.yml +++ b/tests/integration/targets/v4.2/tasks/main.yml @@ -1,36 +1,102 @@ --- - name: NETBOX_DEVICE TESTS - ansible.builtin.include_tasks: netbox_device.yml + ansible.builtin.include_tasks: + file: netbox_device.yml + apply: + tags: + - netbox_device + tags: + - netbox_device - name: NETBOX_DEVICE_INTERFACE TESTS - ansible.builtin.include_tasks: netbox_device_interface.yml + ansible.builtin.include_tasks: + file: netbox_device_interface.yml + apply: + tags: + - netbox_device_interface + tags: + - netbox_device_interface - name: NETBOX_DEVICE_INTERFACE_TEMPLATE TESTS - ansible.builtin.include_tasks: netbox_device_interface_template.yml + ansible.builtin.include_tasks: + file: netbox_device_interface_template.yml + apply: + tags: + - netbox_device_interface_template + tags: + - netbox_device_interface_template - name: NETBOX_IP_ADDRESS TESTS - ansible.builtin.include_tasks: netbox_ip_address.yml + ansible.builtin.include_tasks: + file: netbox_ip_address.yml + apply: + tags: + - netbox_ip_address + tags: + - netbox_ip_address - name: NETBOX_PREFIX TESTS - ansible.builtin.include_tasks: netbox_prefix.yml + ansible.builtin.include_tasks: + file: netbox_prefix.yml + apply: + tags: + - netbox_prefix + tags: + - netbox_prefix - name: NETBOX_SITE TESTS - ansible.builtin.include_tasks: netbox_site.yml + ansible.builtin.include_tasks: + file: netbox_site.yml + apply: + tags: + - netbox_site + tags: + - netbox_site - name: NETBOX_SITE_GROUP TESTS - ansible.builtin.include_tasks: netbox_site_group.yml + ansible.builtin.include_tasks: + file: netbox_site_group.yml + apply: + tags: + - netbox_site_group + tags: + - netbox_site_group - name: NETBOX_CONTACT TESTS - ansible.builtin.include_tasks: netbox_contact.yml + ansible.builtin.include_tasks: + file: netbox_contact.yml + apply: + tags: + - netbox_contact + tags: + - netbox_contact - name: NETBOX_CONTACT_ROLE TESTS - ansible.builtin.include_tasks: netbox_contact_role.yml + ansible.builtin.include_tasks: + file: netbox_contact_role.yml + apply: + tags: + - netbox_contact_role + tags: + - netbox_contact_role - name: NETBOX_TENTANT TESTS - ansible.builtin.include_tasks: netbox_tenant.yml + ansible.builtin.include_tasks: + file: netbox_tenant.yml + apply: + tags: + - netbox_tenant + tags: + - netbox_tenant - name: NETBOX_TENTANT_GROUP TESTS - ansible.builtin.include_tasks: netbox_tenant_group.yml + ansible.builtin.include_tasks: + file: netbox_tenant_group.yml + apply: + tags: + - netbox_tenant_group + tags: + - netbox_tenant_group - name: NETBOX_RACK TESTS ansible.builtin.include_tasks: @@ -42,52 +108,148 @@ - netbox_rack - name: NETBOX_RACK_ROLE TESTS - ansible.builtin.include_tasks: netbox_rack_role.yml + ansible.builtin.include_tasks: + file: netbox_rack_role.yml + apply: + tags: + - netbox_rack_role + tags: + - netbox_rack_role - name: NETBOX_LOCATION TESTS - ansible.builtin.include_tasks: netbox_location.yml + ansible.builtin.include_tasks: + file: netbox_location.yml + apply: + tags: + - netbox_location + tags: + - netbox_location - name: NETBOX_MANUFACTURER TESTS - ansible.builtin.include_tasks: netbox_manufacturer.yml + ansible.builtin.include_tasks: + file: netbox_manufacturer.yml + apply: + tags: + - netbox_manufacturer + tags: + - netbox_manufacturer - name: NETBOX_PLATFORM TESTS - ansible.builtin.include_tasks: netbox_platform.yml + ansible.builtin.include_tasks: + file: netbox_platform.yml + apply: + tags: + - netbox_platform + tags: + - netbox_platform - name: NETBOX_DEVICE_TYPE TESTS - ansible.builtin.include_tasks: netbox_device_type.yml + ansible.builtin.include_tasks: + file: netbox_device_type.yml + apply: + tags: + - netbox_device_type + tags: + - netbox_device_type - name: NETBOX_DEVICE_ROLE TESTS - ansible.builtin.include_tasks: netbox_device_role.yml + ansible.builtin.include_tasks: + file: netbox_device_role.yml + apply: + tags: + - netbox_device_role + tags: + - netbox_device_role - name: NETBOX_IPAM_ROLE TESTS - ansible.builtin.include_tasks: netbox_ipam_role.yml + ansible.builtin.include_tasks: + file: netbox_ipam_role.yml + apply: + tags: + - netbox_ipam_role + tags: + - netbox_ipam_role - name: NETBOX_VLAN_GROUP TESTS - ansible.builtin.include_tasks: netbox_vlan_group.yml + ansible.builtin.include_tasks: + file: netbox_vlan_group.yml + apply: + tags: + - netbox_vlan_group + tags: + - netbox_vlan_group - name: NETBOX_VLAN TESTS - ansible.builtin.include_tasks: netbox_vlan.yml + ansible.builtin.include_tasks: + file: netbox_vlan.yml + apply: + tags: + - netbox_vlan + tags: + - netbox_vlan - name: NETBOX_VRF TESTS - ansible.builtin.include_tasks: netbox_vrf.yml + ansible.builtin.include_tasks: + file: netbox_vrf.yml + apply: + tags: + - netbox_vrf + tags: + - netbox_vrf - name: NETBOX_RIR TESTS - ansible.builtin.include_tasks: netbox_rir.yml + ansible.builtin.include_tasks: + file: netbox_rir.yml + apply: + tags: + - netbox_rir + tags: + - netbox_rir - name: NETBOX_AGGREGATE TESTS - ansible.builtin.include_tasks: netbox_aggregate.yml + ansible.builtin.include_tasks: + file: netbox_aggregate.yml + apply: + tags: + - netbox_aggregate + tags: + - netbox_aggregate - name: NETBOX_REGION TESTS - ansible.builtin.include_tasks: netbox_region.yml + ansible.builtin.include_tasks: + file: netbox_region.yml + apply: + tags: + - netbox_region + tags: + - netbox_region - name: NETBOX_DEVICE_BAY TESTS - ansible.builtin.include_tasks: netbox_device_bay.yml + ansible.builtin.include_tasks: + file: netbox_device_bay.yml + apply: + tags: + - netbox_device_bay + tags: + - netbox_device_bay - name: NETBOX_DEVICE_BAY_TEMPLATE TESTS - ansible.builtin.include_tasks: netbox_device_bay_template.yml + ansible.builtin.include_tasks: + file: netbox_device_bay_template.yml + apply: + tags: + - netbox_device_bay_template + tags: + - netbox_device_bay_template - name: NETBOX_INVENTORY_ITEM TESTS - ansible.builtin.include_tasks: netbox_inventory_item.yml + ansible.builtin.include_tasks: + file: netbox_inventory_item.yml + apply: + tags: + - netbox_inventory_item + tags: + - netbox_inventory_item - name: NETBOX_VIRTUAL_MACHINE TESTS ansible.builtin.include_tasks: @@ -99,76 +261,220 @@ - netbox_virtual_machine - name: NETBOX_CLUSTER TESTS - ansible.builtin.include_tasks: netbox_cluster.yml + ansible.builtin.include_tasks: + file: netbox_cluster.yml + apply: + tags: + - netbox_cluster + tags: + - netbox_cluster - name: NETBOX_CLUSTER_GROUP TESTS - ansible.builtin.include_tasks: netbox_cluster_group.yml + ansible.builtin.include_tasks: + file: netbox_cluster_group.yml + apply: + tags: + - netbox_cluster_group + tags: + - netbox_cluster_group - name: NETBOX_CLUSTER_TYPE TESTS - ansible.builtin.include_tasks: netbox_cluster_type.yml + ansible.builtin.include_tasks: + file: netbox_cluster_type.yml + apply: + tags: + - netbox_cluster_type + tags: + - netbox_cluster_type - name: NETBOX_VM_INTERFACE TESTS - ansible.builtin.include_tasks: netbox_vm_interface.yml + ansible.builtin.include_tasks: + file: netbox_vm_interface.yml + apply: + tags: + - netbox_vm_interface + tags: + - netbox_vm_interface - name: NETBOX_PROVIDER TESTS - ansible.builtin.include_tasks: netbox_provider.yml + ansible.builtin.include_tasks: + file: netbox_provider.yml + apply: + tags: + - netbox_provider + tags: + - netbox_provider - name: NETBOX_PROVIDER_NETWORK TESTS - ansible.builtin.include_tasks: netbox_provider_network.yml + ansible.builtin.include_tasks: + file: netbox_provider_network.yml + apply: + tags: + - netbox_provider_network + tags: + - netbox_provider_network - name: NETBOX_CIRCUIT_TYPE TESTS - ansible.builtin.include_tasks: netbox_circuit_type.yml + ansible.builtin.include_tasks: + file: netbox_circuit_type.yml + apply: + tags: + - netbox_circuit_type + tags: + - netbox_circuit_type - name: NETBOX_CIRCUIT TESTS - ansible.builtin.include_tasks: netbox_circuit.yml + ansible.builtin.include_tasks: + file: netbox_circuit.yml + apply: + tags: + - netbox_circuit + tags: + - netbox_circuit - name: NETBOX_CIRCUIT_TERMINATION TESTS - ansible.builtin.include_tasks: netbox_circuit_termination.yml + ansible.builtin.include_tasks: + file: netbox_circuit_termination.yml + apply: + tags: + - netbox_circuit_termination + tags: + - netbox_circuit_termination - name: NETBOX_REAR_PORT TESTS - ansible.builtin.include_tasks: netbox_rear_port.yml + ansible.builtin.include_tasks: + file: netbox_rear_port.yml + apply: + tags: + - netbox_rear_port + tags: + - netbox_rear_port - name: NETBOX_REAR_PORT_TEMPLATE TESTS - ansible.builtin.include_tasks: netbox_rear_port_template.yml + ansible.builtin.include_tasks: + file: netbox_rear_port_template.yml + apply: + tags: + - netbox_rear_port_template + tags: + - netbox_rear_port_template - name: NETBOX_FRONT_PORT TESTS - ansible.builtin.include_tasks: netbox_front_port.yml + ansible.builtin.include_tasks: + file: netbox_front_port.yml + apply: + tags: + - netbox_front_port + tags: + - netbox_front_port - name: NETBOX_FRONT_PORT_TEMPLATE TESTS - ansible.builtin.include_tasks: netbox_front_port_template.yml + ansible.builtin.include_tasks: + file: netbox_front_port_template.yml + apply: + tags: + - netbox_front_port_template + tags: + - netbox_front_port_template - name: NETBOX_CONSOLE_PORT TESTS - ansible.builtin.include_tasks: netbox_console_port.yml + ansible.builtin.include_tasks: + file: netbox_console_port.yml + apply: + tags: + - netbox_console_port + tags: + - netbox_console_port - name: NETBOX_CONSOLE_PORT_TEMPLATE TESTS - ansible.builtin.include_tasks: netbox_console_port_template.yml + ansible.builtin.include_tasks: + file: netbox_console_port_template.yml + apply: + tags: + - netbox_console_port_template + tags: + - netbox_console_port_template - name: NETBOX_CONSOLE_SERVER_PORT TESTS - ansible.builtin.include_tasks: netbox_console_server_port.yml + ansible.builtin.include_tasks: + file: netbox_console_server_port.yml + apply: + tags: + - netbox_console_server_port + tags: + - netbox_console_server_port - name: NETBOX_CONSOLE_SERVER_PORT_TEMPLATE TESTS - ansible.builtin.include_tasks: netbox_console_server_port_template.yml + ansible.builtin.include_tasks: + file: netbox_console_server_port_template.yml + apply: + tags: + - netbox_console_server_port_template + tags: + - netbox_console_server_port_template - name: NETBOX_POWER_PANEL TESTS - ansible.builtin.include_tasks: netbox_power_panel.yml + ansible.builtin.include_tasks: + file: netbox_power_panel.yml + apply: + tags: + - netbox_power_panel + tags: + - netbox_power_panel - name: NETBOX_POWER_FEED TESTS - ansible.builtin.include_tasks: netbox_power_feed.yml + ansible.builtin.include_tasks: + file: netbox_power_feed.yml + apply: + tags: + - netbox_power_feed + tags: + - netbox_power_feed - name: NETBOX_POWER_PORT TESTS - ansible.builtin.include_tasks: netbox_power_port.yml + ansible.builtin.include_tasks: + file: netbox_power_port.yml + apply: + tags: + - netbox_power_port + tags: + - netbox_power_port - name: NETBOX_POWER_PORT_TEMPLATE TESTS - ansible.builtin.include_tasks: netbox_power_port_template.yml + ansible.builtin.include_tasks: + file: netbox_power_port_template.yml + apply: + tags: + - netbox_power_port_template + tags: + - netbox_power_port_template - name: NETBOX_POWER_OUTLET TESTS - ansible.builtin.include_tasks: netbox_power_outlet.yml + ansible.builtin.include_tasks: + file: netbox_power_outlet.yml + apply: + tags: + - netbox_power_outlet + tags: + - netbox_power_outlet - name: NETBOX_POWER_OUTLET_TEMPLATE TESTS - ansible.builtin.include_tasks: netbox_power_outlet_template.yml + ansible.builtin.include_tasks: + file: netbox_power_outlet_template.yml + apply: + tags: + - netbox_power_outlet_template + tags: + - netbox_power_outlet_template - name: NETBOX_VIRTUAL_CHASSIS TESTS - ansible.builtin.include_tasks: netbox_virtual_chassis.yml + ansible.builtin.include_tasks: + file: netbox_virtual_chassis.yml + apply: + tags: + - netbox_virtual_chassis + tags: + - netbox_virtual_chassis - name: NETBOX_USER_TESTS ansible.builtin.include_tasks: @@ -189,7 +495,13 @@ - netbox_user_group - name: NETBOX_PERMISSION TESTS - ansible.builtin.include_tasks: netbox_permission.yml + ansible.builtin.include_tasks: + file: netbox_permission.yml + apply: + tags: + - netbox_permission + tags: + - netbox_permission - name: NETBOX_TOKEN_TESTS ansible.builtin.include_tasks: @@ -205,10 +517,22 @@ # include_tasks: "netbox_cable.yml" - name: NETBOX_SERVICE TESTS - ansible.builtin.include_tasks: netbox_service.yml + ansible.builtin.include_tasks: + file: netbox_service.yml + apply: + tags: + - netbox_service + tags: + - netbox_service - name: NETBOX_LOOKUP TESTS - ansible.builtin.include_tasks: netbox_lookup.yml + ansible.builtin.include_tasks: + file: netbox_lookup.yml + apply: + tags: + - netbox_lookup + tags: + - netbox_lookup - name: NETBOX_TAG_TESTS ansible.builtin.include_tasks: @@ -338,10 +662,22 @@ - netbox_service_template - name: NETBOX_ASN TESTS - ansible.builtin.include_tasks: netbox_asn.yml + ansible.builtin.include_tasks: + file: netbox_asn.yml + apply: + tags: + - netbox_asn + tags: + - netbox_asn - name: NETBOX_FHRP_GROUP TESTS - ansible.builtin.include_tasks: netbox_fhrp_group.yml + ansible.builtin.include_tasks: + file: netbox_fhrp_group.yml + apply: + tags: + - netbox_fhrp_group + tags: + - netbox_fhrp_group - name: NETBOX_JOURNAL_ENTRY TESTS ansible.builtin.include_tasks: @@ -362,7 +698,11 @@ - netbox_fhrp_group_assignmen - name: NETBOX_CONFIG_TEMPLATE - ansible.builtin.include_tasks: netbox_config_template.yml + ansible.builtin.include_tasks: + file: netbox_config_template.yml + apply: + tags: + - netbox_config_template tags: - netbox_config_template diff --git a/tests/integration/targets/v4.2/tasks/netbox_cluster.yml b/tests/integration/targets/v4.2/tasks/netbox_cluster.yml index b2810a1be..54047f6dd 100644 --- a/tests/integration/targets/v4.2/tasks/netbox_cluster.yml +++ b/tests/integration/targets/v4.2/tasks/netbox_cluster.yml @@ -50,7 +50,8 @@ name: Test Cluster One cluster_type: Test Cluster Type cluster_group: Test Cluster Group - site: Test Site + scope_type: "dcim.site" + scope: Test Site comments: Updated cluster tenant: Test Tenant tags: @@ -63,20 +64,22 @@ that: - test_three is changed - test_three['diff']['after']['group'] == 1 - - test_three['diff']['after']['site'] == 1 + - test_three['diff']['after']['scope'] == 1 + - test_three['diff']['after']['scope_type'] == "dcim.site" - test_three['diff']['after']['comments'] == "Updated cluster" - test_three['diff']['after']['tags'][0] == 4 - test_three['diff']['after']['tenant'] == 1 - test_three['cluster']['name'] == "Test Cluster One" - test_three['cluster']['type'] == 1 - test_three['cluster']['group'] == 1 - - test_three['cluster']['site'] == 1 + - test_three['cluster']['scope'] == 1 + - test_three['cluster']['scope_type'] == "dcim.site" - test_three['cluster']['comments'] == "Updated cluster" - test_three['cluster']['tags'][0] == 4 - test_three['cluster']['tenant'] == 1 - test_three['msg'] == "cluster Test Cluster One updated" -- name: "CLUSTER 4: ASSERT - Delete" +- name: "CLUSTER 4: Delete" netbox.netbox.netbox_cluster: netbox_url: http://localhost:32768 netbox_token: "0123456789abcdef0123456789abcdef01234567" @@ -92,7 +95,8 @@ - test_four['cluster']['name'] == "Test Cluster One" - test_four['cluster']['type'] == 1 - test_four['cluster']['group'] == 1 - - test_four['cluster']['site'] == 1 + - test_four['cluster']['scope'] == 1 + - test_four['cluster']['scope_type'] == "dcim.site" - test_four['cluster']['comments'] == "Updated cluster" - test_four['cluster']['tags'][0] == 4 - test_four['msg'] == "cluster Test Cluster One deleted" diff --git a/tests/integration/targets/v4.2/tasks/netbox_prefix.yml b/tests/integration/targets/v4.2/tasks/netbox_prefix.yml index 64adae855..4b42d748e 100644 --- a/tests/integration/targets/v4.2/tasks/netbox_prefix.yml +++ b/tests/integration/targets/v4.2/tasks/netbox_prefix.yml @@ -44,7 +44,8 @@ netbox_token: "0123456789abcdef0123456789abcdef01234567" data: prefix: 10.156.0.0/19 - site: Test Site + scope_type: "dcim.site" + scope: Test Site status: Reserved description: This prefix has been updated state: present @@ -54,12 +55,14 @@ ansible.builtin.assert: that: - test_three is changed - - test_three['diff']['after']['site'] == 1 + - test_three['diff']['after']['scope'] == 1 + - test_three['diff']['after']['scope_type'] == "dcim.site" - test_three['diff']['after']['status'] == "reserved" - test_three['diff']['after']['description'] == "This prefix has been updated" - test_three['msg'] == "prefix 10.156.0.0/19 updated" - test_three['prefix']['prefix'] == "10.156.0.0/19" - - test_three['prefix']['site'] == 1 + - test_three['prefix']['scope'] == 1 + - test_three['prefix']['scope_type'] == "dcim.site" - test_three['prefix']['status'] == "reserved" - test_three['prefix']['description'] == "This prefix has been updated" @@ -87,7 +90,8 @@ data: family: 4 prefix: 10.156.32.0/19 - site: Test Site + scope_type: "dcim.site" + scope: Test Site vrf: Test VRF tenant: Test Tenant vlan: @@ -113,7 +117,8 @@ - test_five['msg'] == "prefix 10.156.32.0/19 created" - test_five['prefix']['prefix'] == "10.156.32.0/19" - test_five['prefix']['family'] == 4 - - test_five['prefix']['site'] == 1 + - test_five['prefix']['scope'] == 1 + - test_five['prefix']['scope_type'] == "dcim.site" - test_five['prefix']['vrf'] == 1 - test_five['prefix']['tenant'] == 1 - test_five['prefix']['vlan'] == 4 @@ -185,7 +190,8 @@ data: prefix: 10.157.0.0/19 vrf: Test VRF - site: Test Site + scope_type: "dcim.site" + scope: Test Site state: present register: test_nine @@ -197,7 +203,8 @@ - test_nine['diff']['after']['state'] == "present" - test_nine['msg'] == "prefix 10.157.0.0/19 created" - test_nine['prefix']['prefix'] == "10.157.0.0/19" - - test_nine['prefix']['site'] == 1 + - test_nine['prefix']['scope'] == 1 + - test_nine['prefix']['scope_type'] == "dcim.site" - test_nine['prefix']['vrf'] == 1 - name: 10 - Get a new /24 inside 10.157.0.0/19 within NetBox with additional values @@ -208,7 +215,8 @@ parent: 10.157.0.0/19 prefix_length: 24 vrf: Test VRF - site: Test Site + scope_type: "dcim.site" + scope: Test Site state: present first_available: true register: test_ten @@ -221,7 +229,8 @@ - test_ten['diff']['after']['state'] == "present" - test_ten['msg'] == "prefix 10.157.0.0/24 created" - test_ten['prefix']['prefix'] == "10.157.0.0/24" - - test_ten['prefix']['site'] == 1 + - test_ten['prefix']['scope'] == 1 + - test_ten['prefix']['scope_type'] == "dcim.site" - test_ten['prefix']['vrf'] == 1 - name: 11 - Get a new /24 inside 10.156.0.0/19 within NetBox