diff --git a/.github/ISSUE_TEMPLATE/bug_report.yaml b/.github/ISSUE_TEMPLATE/bug_report.yaml index d736a85ff..da3cbcbff 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yaml +++ b/.github/ISSUE_TEMPLATE/bug_report.yaml @@ -67,7 +67,7 @@ body: Describe in detail the exact steps that someone else can take to reproduce this bug using the current stable release of the Ansible NetBox collection. Include any sanatized playbooks, variables, & tasks specifically showing just the issue. - #placeholder: | + # placeholder: | validations: required: true diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index cc7604f9e..ce2534bda 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -15,13 +15,20 @@ jobs: - name: Run black uses: psf/black@stable + - name: Run yamllint + uses: ibiqlik/action-yamllint@v3 + with: + file_or_dir: . + config_file: .yamllint.yml + strict: true + unit_testing: runs-on: ubuntu-24.04 needs: linting strategy: fail-fast: false matrix: - python-version: ["3.13"] + python-version: ["3.11", "3.12", "3.13"] steps: @@ -66,13 +73,13 @@ jobs: strategy: fail-fast: false matrix: - include: - - VERSION: "v4.0" - NETBOX_DOCKER_VERSION: 2.9.1 + include: - VERSION: "v4.1" NETBOX_DOCKER_VERSION: 3.0.1 - VERSION: "v4.2" - NETBOX_DOCKER_VERSION: 3.1.0 + NETBOX_DOCKER_VERSION: 3.2.1 + - VERSION: "v4.3" + NETBOX_DOCKER_VERSION: 3.3.0 steps: @@ -114,7 +121,7 @@ jobs: docker container ls docker logs netbox-docker-netbox-1 timeout 300 bash -c 'while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' localhost:32768/login/)" != "200" ]]; do echo "waiting for NetBox"; sleep 5; done' || false - working-directory: /home/runner/.ansible/collections/ansible_collections/netbox/netbox + working-directory: /home/runner/.ansible/collections/ansible_collections/netbox/netbox - name: Pre-populate NetBox run: ./tests/integration/netbox-deploy.py @@ -126,13 +133,13 @@ jobs: ansible-test integration -v --color --coverage --python ${{ env.python-version }} inventory-${{ matrix.VERSION }} working-directory: /home/runner/.ansible/collections/ansible_collections/netbox/netbox - - name: Run regression tests + - name: Run regression tests continue-on-error: true - run: | - ansible-test integration -v --color --coverage --python ${{ env.python-version }} regression-${{ matrix.VERSION }} + run: | + ansible-test integration -v --color --coverage --python ${{ env.python-version }} regression-${{ matrix.VERSION }} working-directory: /home/runner/.ansible/collections/ansible_collections/netbox/netbox - - name: Run integration tests + - name: Run integration tests run: | ansible-test integration -v --color --coverage --python ${{ env.python-version }} ${{ matrix.VERSION }} ansible-test coverage report --all --omit "tests/*,hacking/*,docs/*" --show-missing diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 27bbe478d..afed9c715 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,7 +1,7 @@ --- name: Deploy collection to Ansible Galaxy on: - create: + push: tags: - "v*" jobs: diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index b077abb14..e3c4ebd84 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -47,4 +47,4 @@ jobs: '${{ needs.unit-galaxy.result }}', '${{ needs.unit-source.result }}', '${{ needs.ansible-lint.result }}' - ])" \ No newline at end of file + ])" diff --git a/.yamllint.yml b/.yamllint.yml new file mode 100644 index 000000000..264a92f68 --- /dev/null +++ b/.yamllint.yml @@ -0,0 +1,52 @@ +--- +extends: default + +# see rules at https://yamllint.readthedocs.io/en/latest/rules.html +ignore: | + - .cache/ + - .venv/ + - .github/ + +rules: + braces: + max-spaces-inside: 20 + level: error + brackets: + max-spaces-inside: 20 + level: error + colons: + max-spaces-before: 1 + max-spaces-after: 20 + level: error + commas: + max-spaces-before: 50 + min-spaces-after: 1 + max-spaces-after: 20 + level: error + comments: + min-spaces-from-content: 1 + comments-indentation: disable + document-start: + present: true + empty-lines: + max: 3 + level: error + hyphens: + level: error + indentation: + spaces: 2 + indent-sequences: whatever + check-multi-line-strings: false + key-duplicates: enable + line-length: + max: 230 + level: warning + allow-non-breakable-words: true + allow-non-breakable-inline-mappings: true + new-line-at-end-of-file: enable + new-lines: + type: unix + trailing-spaces: enable + truthy: disable + octal-values: + forbid-explicit-octal: true diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 8ba64c61b..16459d94a 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -4,6 +4,52 @@ NetBox.NetBox Release Notes .. contents:: Topics +v3.22.0 +======= + +Minor Changes +------------- + +- Add integration tests for contact groups +- Add support for custom headers for all modules +- Change `netbox_contact.contact_group` to `contact_groups` +- Fix ansible-bad-import-from pylint errors +- Fix broken code path when using old api path on old netbox systems +- Make the unit-test data structures more flexible. +- Remove abandoned unit-test data. +- add workaround to _build_query_params for services and Netbox 4.3.0 - 4.4.3 (wrong parent_object_type data type) +- add yamllint to project pipeline. +- improve version_check_greater to be more universal +- netbox_circuit_termination - Add parameters termination_id and termination_type for NetBox 4.2+ +- netbox_tag - Add support for object_types on tags +- rename variable full_version to netbox_version. +- rename variable version to api_version. +- sanitize netbox versions received from api +- test suite expanded to run on Python 3.11, 3.12, and 3.13. +- user.groups, user.permissions, user_group.permissions, permission.actions, and permission.object_types are now treated as unordered sets for update comparison purposes. + +Bugfixes +-------- + +- Add netbox version check to support service creation for netbox version prior of 4.3 +- Fix integration test for circuit termination, missing assignment +- Fix integration test for service +- Fix task duplicate task name in documentation that cause ansible-lint error +- Fix typos in tag integration tests. +- Support for related_object_filter when related_object_type is "object" +- Use dedicated function to check netbox version istead of self.full_version for rack. +- add parent_object_type and parent_object_id to services ALLOWED_QUERY_PARAMS +- nb_device_interface: Fix specifying primary_mac_address objects by id for disambiguation +- nb_inventory - Fix service collection for version greater than 4.3 +- nb_inventory - Fixed empty inventory results when netbox server URL is a non-root path +- netbox_service - Fix issue 1426 - broken netbox_service module + +New Modules +----------- + +- netbox.netbox.netbox_contact_assignment - Manage contact assignments in NetBox +- netbox.netbox.netbox_data_source - Manage data sources in NetBox + v3.21.0 ======= diff --git a/README.md b/README.md index 710222533..bc5ab7b4f 100644 --- a/README.md +++ b/README.md @@ -9,11 +9,11 @@ This Ansible collection consists of a set of modules to define the intended netw - You must be running one of the two most recent releases of NetBox - A NetBox write-enabled API token when using modules or a read-only token for the `nb_lookup` and `nb_inventory` plugins. -- Python 3.10+ +- Python 3.11+ - Python modules: - pytz - pynetbox -- Ansible 2.15+ +- Ansible 2.18+ ## Installation diff --git a/changelogs/changelog.yaml b/changelogs/changelog.yaml index 049c52a1b..e2bf09e03 100644 --- a/changelogs/changelog.yaml +++ b/changelogs/changelog.yaml @@ -1,3 +1,4 @@ +--- ancestor: null releases: 0.1.0: @@ -851,6 +852,71 @@ releases: name: netbox_mac_address namespace: '' release_date: '2025-03-04' + 3.22.0: + changes: + minor_changes: + - Change `netbox_contact.contact_group` to `contact_groups` + - Add integration tests for contact groups + - Add support for custom headers for all modules + - Fix ansible-bad-import-from pylint errors + - Fix broken code path when using old api path on old netbox systems + - add workaround to _build_query_params for services and Netbox 4.3.0 - 4.4.3 (wrong parent_object_type data type) + - netbox_circuit_termination - Add parameters termination_id and termination_type for NetBox 4.2+ + - netbox_tag - Add support for object_types on tags + - improve version_check_greater to be more universal + - sanitize netbox versions received from api + - test suite expanded to run on Python 3.11, 3.12, and 3.13. + - Make the unit-test data structures more flexible. + - Remove abandoned unit-test data. + - user.groups, user.permissions, user_group.permissions, permission.actions, and permission.object_types are now treated as unordered sets for update comparison purposes. + - rename variable version to api_version. + - rename variable full_version to netbox_version. + - add yamllint to project pipeline. + bugfixes: + - Fix task duplicate task name in documentation that cause ansible-lint error + - nb_inventory - Fix service collection for version greater than 4.3 + - Add netbox version check to support service creation for netbox version prior of 4.3 + - Use dedicated function to check netbox version istead of self.full_version for rack. + - Fix typos in tag integration tests. + - Fix integration test for circuit termination, missing assignment + - Fix integration test for service + - "nb_device_interface: Fix specifying primary_mac_address objects by id for disambiguation" + - add parent_object_type and parent_object_id to services ALLOWED_QUERY_PARAMS + - nb_inventory - Fixed empty inventory results when netbox server URL is a non-root path + - Support for related_object_filter when related_object_type is "object" + - netbox_service - Fix issue 1426 - broken netbox_service module + modules: + - description: Manage data sources in NetBox + name: netbox_data_source + namespace: '' + - description: Manage contact assignments in NetBox + name: netbox_contact_assignment + namespace: '' + fragments: + - 1182-fix-contact-groups.yml + - 1433-add-custom-headers.yml + - 1435-fix-duplicate-task-name.yml + - 1438-fix-inventory-service-collection.yml + - 1439-fix-sevral-bug-discovered-by-integration-tests.yml + - 1459-add-netbox-data-sources.yml + - 1462-fix-pylint-errors.yml + - 1464-fix-mac-lookup-by-id.yml + - 1469-fix-old-apis.yml + - 1479-fix-services_parent_object.yml + - contacts.yml + - nb_inventory.yml + - netbox_circuit_termination.yml + - netbox_custom_field.yml + - netbox_service.yml + - netbox_tag.yml + - netbox_version_check_greater.yml + - netbox_version_sanitize.yml + - python_versions.yml + - unit_test_data.yml + - users-ordering.yml + - version_api.yml + - version_netbox.yml + - yamllint.yml 3.3.0: changes: minor_changes: diff --git a/docs/conf.py b/docs/conf.py index 3783ca6d4..2594c8798 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -27,7 +27,7 @@ author = "Mikhail Yohman <@FragmentedPacket>" # The full version, including alpha/beta/rc tags -release = "3.21.0" +release = "3.22.0" # -- General configuration --------------------------------------------------- diff --git a/docs/getting_started/contributing/modules/architecture.rst b/docs/getting_started/contributing/modules/architecture.rst index edeac7a56..8980045d3 100644 --- a/docs/getting_started/contributing/modules/architecture.rst +++ b/docs/getting_started/contributing/modules/architecture.rst @@ -284,14 +284,15 @@ We set several instance attributes that are used within other methods throughout url = self.module.params["netbox_url"] token = self.module.params["netbox_token"] ssl_verify = self.module.params["validate_certs"] + headers = self.module.params["headers"] # Attempt to initiate connection to NetBox if nb_client is None: - self.nb = self._connect_netbox_api(url, token, ssl_verify) + self.nb = self._connect_netbox_api(url, token, ssl_verify, headers) else: self.nb = nb_client try: - self.version = self.nb.version + self.api_version = self.nb.version except AttributeError: self.module.fail_json(msg="Must have pynetbox >=4.1.0") diff --git a/docs/getting_started/how-to-use/advanced.rst b/docs/getting_started/how-to-use/advanced.rst index d1129fc37..0679fa4ed 100644 --- a/docs/getting_started/how-to-use/advanced.rst +++ b/docs/getting_started/how-to-use/advanced.rst @@ -224,7 +224,7 @@ To make this possible, every module accepts the ``query_params`` argument. This you want to use to search for the object. Let's start with another example. We will continue to use :ref:`netbox.netbox.netbox_ip_address`. We created **192.168.100.1/24** as a duplicate IP address within -the global IP address space within NetBox. This task should fail saying there was more than result returned. +the global IP address space within NetBox. This task should fail saying there was more than one result returned. .. code-block:: yaml @@ -304,7 +304,9 @@ Hopefully this shines some light on this useful feature to allow you, as the use Using Module defaults groups -------------------------------------------- -Ansible-core >= 2.12 provide a useful feature called [Module defaults groups](https://docs.ansible.com/ansible/latest/user_guide/playbooks_module_defaults.html#module-defaults-groups) that lets us specify default parameters for a group of modules in a single place. We can use the action_group ``netbox`` that contains all modules from this collection to avoid setting e.g. ``token`` and ``url`` on each task and thus reduce boilerplate code. +Ansible-core >= 2.12 provide a useful feature called `Module defaults groups`_ that lets us specify default parameters for a group of modules in a single place. We can use the action_group ``netbox`` that contains all modules from this collection to avoid setting e.g. ``token`` and ``url`` on each task and thus reduce boilerplate code. + +.. _Module defaults groups: https://docs.ansible.com/ansible/latest/user_guide/playbooks_module_defaults.html#module-defaults-groups .. code-block:: yaml diff --git a/docs/plugins/environment_variables.rst b/docs/plugins/environment_variables.rst index e58c8192a..c8f7f7b03 100644 --- a/docs/plugins/environment_variables.rst +++ b/docs/plugins/environment_variables.rst @@ -1,7 +1,7 @@ :orphan: .. meta:: - :antsibull-docs: 2.13.1 + :antsibull-docs: 2.16.2 .. _list_of_collection_env_vars: diff --git a/docs/plugins/index.rst b/docs/plugins/index.rst index c019dcaae..f712a3a38 100644 --- a/docs/plugins/index.rst +++ b/docs/plugins/index.rst @@ -1,5 +1,5 @@ .. meta:: - :antsibull-docs: 2.13.1 + :antsibull-docs: 2.16.2 .. _plugins_in_netbox.netbox: @@ -7,7 +7,7 @@ Netbox.Netbox ============= -Collection version 3.21.0 +Collection version 3.22.0 .. contents:: :local: @@ -67,11 +67,13 @@ Modules * :ansplugin:`netbox_console_server_port module ` -- Create, update or delete console server ports within NetBox * :ansplugin:`netbox_console_server_port_template module ` -- Create, update or delete console server port templates within NetBox * :ansplugin:`netbox_contact module ` -- Creates or removes contacts from NetBox +* :ansplugin:`netbox_contact_assignment module ` -- Creates or removes contact assignments from NetBox * :ansplugin:`netbox_contact_group module ` -- Creates or removes contact groups from NetBox * :ansplugin:`netbox_contact_role module ` -- Creates or removes contact roles from NetBox * :ansplugin:`netbox_custom_field module ` -- Creates, updates or deletes custom fields within NetBox * :ansplugin:`netbox_custom_field_choice_set module ` -- Creates, updates or deletes custom field choice sets within Netbox * :ansplugin:`netbox_custom_link module ` -- Creates, updates or deletes custom links within NetBox +* :ansplugin:`netbox_data_source module ` -- Creates or removes data sources from NetBox * :ansplugin:`netbox_device module ` -- Create, update or delete devices within NetBox * :ansplugin:`netbox_device_bay module ` -- Create, update or delete device bays within NetBox * :ansplugin:`netbox_device_bay_template module ` -- Create, update or delete device bay templates within NetBox @@ -160,11 +162,13 @@ Modules netbox_console_server_port_module netbox_console_server_port_template_module netbox_contact_module + netbox_contact_assignment_module netbox_contact_group_module netbox_contact_role_module netbox_custom_field_module netbox_custom_field_choice_set_module netbox_custom_link_module + netbox_data_source_module netbox_device_module netbox_device_bay_module netbox_device_bay_template_module diff --git a/docs/plugins/nb_inventory_inventory.rst b/docs/plugins/nb_inventory_inventory.rst index 3909d074a..0dd1be94a 100644 --- a/docs/plugins/nb_inventory_inventory.rst +++ b/docs/plugins/nb_inventory_inventory.rst @@ -6,7 +6,7 @@ :trim: .. meta:: - :antsibull-docs: 2.13.1 + :antsibull-docs: 2.16.2 .. Anchors @@ -22,7 +22,7 @@ netbox.netbox.nb_inventory inventory -- NetBox inventory source .. Collection note .. note:: - This inventory plugin is part of the `netbox.netbox collection `_ (version 3.21.0). + This inventory plugin is part of the `netbox.netbox collection `_ (version 3.22.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -252,7 +252,7 @@ Parameters - INI entry: - .. code-block:: + .. code-block:: ini [inventory] cache = false @@ -304,14 +304,14 @@ Parameters - INI entries: - .. code-block:: + .. code-block:: ini [defaults] fact_caching_connection = VALUE - .. code-block:: + .. code-block:: ini [inventory] cache_connection = VALUE @@ -369,14 +369,14 @@ Parameters - INI entries: - .. code-block:: + .. code-block:: ini [defaults] fact_caching = memory - .. code-block:: + .. code-block:: ini [inventory] cache_plugin = memory @@ -434,14 +434,14 @@ Parameters - INI entries: - .. code-block:: + .. code-block:: ini [defaults] fact_caching_prefix = ansible_inventory_ - .. code-block:: + .. code-block:: ini [inventory] cache_prefix = ansible_inventory_ @@ -499,14 +499,14 @@ Parameters - INI entries: - .. code-block:: + .. code-block:: ini [defaults] fact_caching_timeout = 3600 - .. code-block:: + .. code-block:: ini [inventory] cache_timeout = 3600 @@ -2407,7 +2407,7 @@ Parameters - INI entry: - .. code-block:: + .. code-block:: ini [inventory_plugins] use_extra_vars = false @@ -2673,8 +2673,8 @@ Examples - prefix: status key: status.value - # For use in Ansible Tower (AWX), please see this blog from RedHat: https://www.ansible.com/blog/using-an-inventory-plugin-from-a-collection-in-ansible-tower - # The credential for NetBox will need to expose NETBOX_API and NETBOX_TOKEN as environment variables. + # For use in Ansible Tower (AWX) the credential for NetBox will need to expose NETBOX_API + # and NETBOX_TOKEN as environment variables. # Example Ansible Tower credential Input Configuration: fields: diff --git a/docs/plugins/nb_lookup_lookup.rst b/docs/plugins/nb_lookup_lookup.rst index ec760dfe0..6fc548665 100644 --- a/docs/plugins/nb_lookup_lookup.rst +++ b/docs/plugins/nb_lookup_lookup.rst @@ -6,7 +6,7 @@ :trim: .. meta:: - :antsibull-docs: 2.13.1 + :antsibull-docs: 2.16.2 .. Anchors @@ -22,7 +22,7 @@ netbox.netbox.nb_lookup lookup -- Queries and returns elements from NetBox .. Collection note .. note:: - This lookup plugin is part of the `netbox.netbox collection `_ (version 3.21.0). + This lookup plugin is part of the `netbox.netbox collection `_ (version 3.22.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. diff --git a/docs/plugins/netbox_aggregate_module.rst b/docs/plugins/netbox_aggregate_module.rst index ef8c2684b..df799acd9 100644 --- a/docs/plugins/netbox_aggregate_module.rst +++ b/docs/plugins/netbox_aggregate_module.rst @@ -6,7 +6,7 @@ :trim: .. meta:: - :antsibull-docs: 2.13.1 + :antsibull-docs: 2.16.2 .. Anchors @@ -22,7 +22,7 @@ netbox.netbox.netbox_aggregate module -- Creates or removes aggregates from NetB .. Collection note .. note:: - This module is part of the `netbox.netbox collection `_ (version 3.21.0). + This module is part of the `netbox.netbox collection `_ (version 3.22.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -499,6 +499,40 @@ Parameters + * - .. raw:: html + +
+
+ + .. _ansible_collections.netbox.netbox.netbox_aggregate_module__parameter-headers: + + .. rst-class:: ansible-option-title + + **headers** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`dictionary` + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Dictionary of headers to be passed to the NetBox API. + + + .. raw:: html + +
+ * - .. raw:: html
diff --git a/docs/plugins/netbox_asn_module.rst b/docs/plugins/netbox_asn_module.rst index b0452bf88..b1478b1d3 100644 --- a/docs/plugins/netbox_asn_module.rst +++ b/docs/plugins/netbox_asn_module.rst @@ -6,7 +6,7 @@ :trim: .. meta:: - :antsibull-docs: 2.13.1 + :antsibull-docs: 2.16.2 .. Anchors @@ -22,7 +22,7 @@ netbox.netbox.netbox_asn module -- Create, update or delete ASNs within NetBox .. Collection note .. note:: - This module is part of the `netbox.netbox collection `_ (version 3.21.0). + This module is part of the `netbox.netbox collection `_ (version 3.22.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -409,6 +409,40 @@ Parameters
+ * - .. raw:: html + +
+
+ + .. _ansible_collections.netbox.netbox.netbox_asn_module__parameter-headers: + + .. rst-class:: ansible-option-title + + **headers** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`dictionary` + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Dictionary of headers to be passed to the NetBox API. + + + .. raw:: html + +
+ * - .. raw:: html
diff --git a/docs/plugins/netbox_cable_module.rst b/docs/plugins/netbox_cable_module.rst index 9ff478ec9..0dda0ba2b 100644 --- a/docs/plugins/netbox_cable_module.rst +++ b/docs/plugins/netbox_cable_module.rst @@ -6,7 +6,7 @@ :trim: .. meta:: - :antsibull-docs: 2.13.1 + :antsibull-docs: 2.16.2 .. Anchors @@ -22,7 +22,7 @@ netbox.netbox.netbox_cable module -- Create, update or delete cables within NetB .. Collection note .. note:: - This module is part of the `netbox.netbox collection `_ (version 3.21.0). + This module is part of the `netbox.netbox collection `_ (version 3.22.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -874,6 +874,40 @@ Parameters
+ * - .. raw:: html + +
+
+ + .. _ansible_collections.netbox.netbox.netbox_cable_module__parameter-headers: + + .. rst-class:: ansible-option-title + + **headers** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`dictionary` + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Dictionary of headers to be passed to the NetBox API. + + + .. raw:: html + +
+ * - .. raw:: html
diff --git a/docs/plugins/netbox_circuit_module.rst b/docs/plugins/netbox_circuit_module.rst index 2b18756d9..e05f9b94f 100644 --- a/docs/plugins/netbox_circuit_module.rst +++ b/docs/plugins/netbox_circuit_module.rst @@ -6,7 +6,7 @@ :trim: .. meta:: - :antsibull-docs: 2.13.1 + :antsibull-docs: 2.16.2 .. Anchors @@ -22,7 +22,7 @@ netbox.netbox.netbox_circuit module -- Create, update or delete circuits within .. Collection note .. note:: - This module is part of the `netbox.netbox collection `_ (version 3.21.0). + This module is part of the `netbox.netbox collection `_ (version 3.22.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -619,6 +619,40 @@ Parameters
+ * - .. raw:: html + +
+
+ + .. _ansible_collections.netbox.netbox.netbox_circuit_module__parameter-headers: + + .. rst-class:: ansible-option-title + + **headers** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`dictionary` + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Dictionary of headers to be passed to the NetBox API. + + + .. raw:: html + +
+ * - .. raw:: html
diff --git a/docs/plugins/netbox_circuit_termination_module.rst b/docs/plugins/netbox_circuit_termination_module.rst index 43d8bcaa4..77d78fa72 100644 --- a/docs/plugins/netbox_circuit_termination_module.rst +++ b/docs/plugins/netbox_circuit_termination_module.rst @@ -6,7 +6,7 @@ :trim: .. meta:: - :antsibull-docs: 2.13.1 + :antsibull-docs: 2.16.2 .. Anchors @@ -22,7 +22,7 @@ netbox.netbox.netbox_circuit_termination module -- Create, update or delete circ .. Collection note .. note:: - This module is part of the `netbox.netbox collection `_ (version 3.21.0). + This module is part of the `netbox.netbox collection `_ (version 3.22.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -412,7 +412,9 @@ Parameters
- The provider\_network the circuit termination will be assigned to + The provider\_network the circuit termination will be assigned to. + + This parameter is used with NetBox versions before 4.2.0. .. raw:: html @@ -454,7 +456,9 @@ Parameters
- The site the circuit termination will be assigned to + The site the circuit termination will be assigned to. + + This parameter is used with NetBox versions before 4.2.0. .. raw:: html @@ -507,6 +511,111 @@ Parameters - :ansible-option-choices-entry:`"Z"` + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. raw:: latex + + \hspace{0.02\textwidth}\begin{minipage}[t]{0.3\textwidth} + + .. _ansible_collections.netbox.netbox.netbox_circuit_termination_module__parameter-data/termination_id: + + .. rst-class:: ansible-option-title + + **termination_id** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`integer` + + :ansible-option-versionadded:`added in netbox.netbox 4.2.0` + + + .. raw:: html + +
+ + .. raw:: latex + + \end{minipage} + + - .. raw:: html + +
+ + The ProviderNetwork, Location, Site, Region, or SiteGroup ID of the circuit termination will be assigned to. + + This parameter is used with NetBox versions \>= 4.2.0. + + + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. raw:: latex + + \hspace{0.02\textwidth}\begin{minipage}[t]{0.3\textwidth} + + .. _ansible_collections.netbox.netbox.netbox_circuit_termination_module__parameter-data/termination_type: + + .. rst-class:: ansible-option-title + + **termination_type** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`string` + + :ansible-option-versionadded:`added in netbox.netbox 4.2.0` + + + .. raw:: html + +
+ + .. raw:: latex + + \end{minipage} + + - .. raw:: html + +
+ + The type the circuit termination will be assigned to. + + This parameter is used with NetBox versions \>= 4.2.0. + + + .. rst-class:: ansible-option-line + + :ansible-option-choices:`Choices:` + + - :ansible-option-choices-entry:`"dcim.site"` + - :ansible-option-choices-entry:`"dcim.location"` + - :ansible-option-choices-entry:`"dcim.region"` + - :ansible-option-choices-entry:`"dcim.sitegroup"` + - :ansible-option-choices-entry:`"circuits.providernetwork"` + + .. raw:: html
@@ -596,6 +705,40 @@ Parameters
+ * - .. raw:: html + +
+
+ + .. _ansible_collections.netbox.netbox.netbox_circuit_termination_module__parameter-headers: + + .. rst-class:: ansible-option-title + + **headers** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`dictionary` + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Dictionary of headers to be passed to the NetBox API. + + + .. raw:: html + +
+ * - .. raw:: html
@@ -815,7 +958,19 @@ Examples gather_facts: false tasks: - - name: Create circuit termination within NetBox with only required information + - name: Create circuit termination within NetBox version 4.2.0 or later with only required information + netbox.netbox.netbox_circuit_termination: + netbox_url: http://netbox.local + netbox_token: thisIsMyToken + data: + circuit: Test Circuit + term_side: A + termination_id: 1 + termination_type: dcim.site + port_speed: 10000 + state: present + + - name: Create circuit termination within NetBox versions earlier than 4.2.0 with only required information netbox.netbox.netbox_circuit_termination: netbox_url: http://netbox.local netbox_token: thisIsMyToken diff --git a/docs/plugins/netbox_circuit_type_module.rst b/docs/plugins/netbox_circuit_type_module.rst index fb5ad2dbb..0f3aab9b6 100644 --- a/docs/plugins/netbox_circuit_type_module.rst +++ b/docs/plugins/netbox_circuit_type_module.rst @@ -6,7 +6,7 @@ :trim: .. meta:: - :antsibull-docs: 2.13.1 + :antsibull-docs: 2.16.2 .. Anchors @@ -22,7 +22,7 @@ netbox.netbox.netbox_circuit_type module -- Create, update or delete circuit typ .. Collection note .. note:: - This module is part of the `netbox.netbox collection `_ (version 3.21.0). + This module is part of the `netbox.netbox collection `_ (version 3.22.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -423,6 +423,40 @@ Parameters
+ * - .. raw:: html + +
+
+ + .. _ansible_collections.netbox.netbox.netbox_circuit_type_module__parameter-headers: + + .. rst-class:: ansible-option-title + + **headers** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`dictionary` + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Dictionary of headers to be passed to the NetBox API. + + + .. raw:: html + +
+ * - .. raw:: html
diff --git a/docs/plugins/netbox_cluster_group_module.rst b/docs/plugins/netbox_cluster_group_module.rst index 733f93e9d..39d6529e0 100644 --- a/docs/plugins/netbox_cluster_group_module.rst +++ b/docs/plugins/netbox_cluster_group_module.rst @@ -6,7 +6,7 @@ :trim: .. meta:: - :antsibull-docs: 2.13.1 + :antsibull-docs: 2.16.2 .. Anchors @@ -22,7 +22,7 @@ netbox.netbox.netbox_cluster_group module -- Create, update or delete cluster gr .. Collection note .. note:: - This module is part of the `netbox.netbox collection `_ (version 3.21.0). + This module is part of the `netbox.netbox collection `_ (version 3.22.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -378,6 +378,40 @@ Parameters
+ * - .. raw:: html + +
+
+ + .. _ansible_collections.netbox.netbox.netbox_cluster_group_module__parameter-headers: + + .. rst-class:: ansible-option-title + + **headers** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`dictionary` + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Dictionary of headers to be passed to the NetBox API. + + + .. raw:: html + +
+ * - .. raw:: html
diff --git a/docs/plugins/netbox_cluster_module.rst b/docs/plugins/netbox_cluster_module.rst index aa18978c7..cac122ca8 100644 --- a/docs/plugins/netbox_cluster_module.rst +++ b/docs/plugins/netbox_cluster_module.rst @@ -6,7 +6,7 @@ :trim: .. meta:: - :antsibull-docs: 2.13.1 + :antsibull-docs: 2.16.2 .. Anchors @@ -22,7 +22,7 @@ netbox.netbox.netbox_cluster module -- Create, update or delete clusters within .. Collection note .. note:: - This module is part of the `netbox.netbox collection `_ (version 3.21.0). + This module is part of the `netbox.netbox collection `_ (version 3.22.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -686,6 +686,40 @@ Parameters
+ * - .. raw:: html + +
+
+ + .. _ansible_collections.netbox.netbox.netbox_cluster_module__parameter-headers: + + .. rst-class:: ansible-option-title + + **headers** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`dictionary` + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Dictionary of headers to be passed to the NetBox API. + + + .. raw:: html + +
+ * - .. raw:: html
diff --git a/docs/plugins/netbox_cluster_type_module.rst b/docs/plugins/netbox_cluster_type_module.rst index 5d949bc72..0ec940c53 100644 --- a/docs/plugins/netbox_cluster_type_module.rst +++ b/docs/plugins/netbox_cluster_type_module.rst @@ -6,7 +6,7 @@ :trim: .. meta:: - :antsibull-docs: 2.13.1 + :antsibull-docs: 2.16.2 .. Anchors @@ -22,7 +22,7 @@ netbox.netbox.netbox_cluster_type module -- Create, update or delete cluster typ .. Collection note .. note:: - This module is part of the `netbox.netbox collection `_ (version 3.21.0). + This module is part of the `netbox.netbox collection `_ (version 3.22.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -375,6 +375,40 @@ Parameters
+ * - .. raw:: html + +
+
+ + .. _ansible_collections.netbox.netbox.netbox_cluster_type_module__parameter-headers: + + .. rst-class:: ansible-option-title + + **headers** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`dictionary` + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Dictionary of headers to be passed to the NetBox API. + + + .. raw:: html + +
+ * - .. raw:: html
diff --git a/docs/plugins/netbox_config_context_module.rst b/docs/plugins/netbox_config_context_module.rst index df9fbef0f..eedab5637 100644 --- a/docs/plugins/netbox_config_context_module.rst +++ b/docs/plugins/netbox_config_context_module.rst @@ -6,7 +6,7 @@ :trim: .. meta:: - :antsibull-docs: 2.13.1 + :antsibull-docs: 2.16.2 .. Anchors @@ -22,7 +22,7 @@ netbox.netbox.netbox_config_context module -- Creates, updates or deletes config .. Collection note .. note:: - This module is part of the `netbox.netbox collection `_ (version 3.21.0). + This module is part of the `netbox.netbox collection `_ (version 3.22.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -879,6 +879,40 @@ Parameters
+ * - .. raw:: html + +
+
+ + .. _ansible_collections.netbox.netbox.netbox_config_context_module__parameter-headers: + + .. rst-class:: ansible-option-title + + **headers** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`dictionary` + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Dictionary of headers to be passed to the NetBox API. + + + .. raw:: html + +
+ * - .. raw:: html
diff --git a/docs/plugins/netbox_config_template_module.rst b/docs/plugins/netbox_config_template_module.rst index dd2b09e6a..1279113d5 100644 --- a/docs/plugins/netbox_config_template_module.rst +++ b/docs/plugins/netbox_config_template_module.rst @@ -6,7 +6,7 @@ :trim: .. meta:: - :antsibull-docs: 2.13.1 + :antsibull-docs: 2.16.2 .. Anchors @@ -22,7 +22,7 @@ netbox.netbox.netbox_config_template module -- Creates or removes config templat .. Collection note .. note:: - This module is part of the `netbox.netbox collection `_ (version 3.21.0). + This module is part of the `netbox.netbox collection `_ (version 3.22.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -367,6 +367,40 @@ Parameters
+ * - .. raw:: html + +
+
+ + .. _ansible_collections.netbox.netbox.netbox_config_template_module__parameter-headers: + + .. rst-class:: ansible-option-title + + **headers** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`dictionary` + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Dictionary of headers to be passed to the NetBox API. + + + .. raw:: html + +
+ * - .. raw:: html
diff --git a/docs/plugins/netbox_console_port_module.rst b/docs/plugins/netbox_console_port_module.rst index c7c21f0a6..d21358859 100644 --- a/docs/plugins/netbox_console_port_module.rst +++ b/docs/plugins/netbox_console_port_module.rst @@ -6,7 +6,7 @@ :trim: .. meta:: - :antsibull-docs: 2.13.1 + :antsibull-docs: 2.16.2 .. Anchors @@ -22,7 +22,7 @@ netbox.netbox.netbox_console_port module -- Create, update or delete console por .. Collection note .. note:: - This module is part of the `netbox.netbox collection `_ (version 3.21.0). + This module is part of the `netbox.netbox collection `_ (version 3.22.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -666,6 +666,40 @@ Parameters
+ * - .. raw:: html + +
+
+ + .. _ansible_collections.netbox.netbox.netbox_console_port_module__parameter-headers: + + .. rst-class:: ansible-option-title + + **headers** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`dictionary` + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Dictionary of headers to be passed to the NetBox API. + + + .. raw:: html + +
+ * - .. raw:: html
diff --git a/docs/plugins/netbox_console_port_template_module.rst b/docs/plugins/netbox_console_port_template_module.rst index 8b106309d..00abfcb83 100644 --- a/docs/plugins/netbox_console_port_template_module.rst +++ b/docs/plugins/netbox_console_port_template_module.rst @@ -6,7 +6,7 @@ :trim: .. meta:: - :antsibull-docs: 2.13.1 + :antsibull-docs: 2.16.2 .. Anchors @@ -22,7 +22,7 @@ netbox.netbox.netbox_console_port_template module -- Create, update or delete co .. Collection note .. note:: - This module is part of the `netbox.netbox collection `_ (version 3.21.0). + This module is part of the `netbox.netbox collection `_ (version 3.22.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -302,6 +302,40 @@ Parameters
+ * - .. raw:: html + +
+
+ + .. _ansible_collections.netbox.netbox.netbox_console_port_template_module__parameter-headers: + + .. rst-class:: ansible-option-title + + **headers** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`dictionary` + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Dictionary of headers to be passed to the NetBox API. + + + .. raw:: html + +
+ * - .. raw:: html
diff --git a/docs/plugins/netbox_console_server_port_module.rst b/docs/plugins/netbox_console_server_port_module.rst index 88f722ba0..022cbb8c4 100644 --- a/docs/plugins/netbox_console_server_port_module.rst +++ b/docs/plugins/netbox_console_server_port_module.rst @@ -6,7 +6,7 @@ :trim: .. meta:: - :antsibull-docs: 2.13.1 + :antsibull-docs: 2.16.2 .. Anchors @@ -22,7 +22,7 @@ netbox.netbox.netbox_console_server_port module -- Create, update or delete cons .. Collection note .. note:: - This module is part of the `netbox.netbox collection `_ (version 3.21.0). + This module is part of the `netbox.netbox collection `_ (version 3.22.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -621,6 +621,40 @@ Parameters
+ * - .. raw:: html + +
+
+ + .. _ansible_collections.netbox.netbox.netbox_console_server_port_module__parameter-headers: + + .. rst-class:: ansible-option-title + + **headers** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`dictionary` + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Dictionary of headers to be passed to the NetBox API. + + + .. raw:: html + +
+ * - .. raw:: html
diff --git a/docs/plugins/netbox_console_server_port_template_module.rst b/docs/plugins/netbox_console_server_port_template_module.rst index 7f60c0d2c..a03e50bdf 100644 --- a/docs/plugins/netbox_console_server_port_template_module.rst +++ b/docs/plugins/netbox_console_server_port_template_module.rst @@ -6,7 +6,7 @@ :trim: .. meta:: - :antsibull-docs: 2.13.1 + :antsibull-docs: 2.16.2 .. Anchors @@ -22,7 +22,7 @@ netbox.netbox.netbox_console_server_port_template module -- Create, update or de .. Collection note .. note:: - This module is part of the `netbox.netbox collection `_ (version 3.21.0). + This module is part of the `netbox.netbox collection `_ (version 3.22.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -302,6 +302,40 @@ Parameters
+ * - .. raw:: html + +
+
+ + .. _ansible_collections.netbox.netbox.netbox_console_server_port_template_module__parameter-headers: + + .. rst-class:: ansible-option-title + + **headers** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`dictionary` + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Dictionary of headers to be passed to the NetBox API. + + + .. raw:: html + +
+ * - .. raw:: html
diff --git a/docs/plugins/netbox_contact_assignment_module.rst b/docs/plugins/netbox_contact_assignment_module.rst new file mode 100644 index 000000000..e733789e4 --- /dev/null +++ b/docs/plugins/netbox_contact_assignment_module.rst @@ -0,0 +1,862 @@ +.. Document meta + +:orphan: + +.. |antsibull-internal-nbsp| unicode:: 0xA0 + :trim: + +.. meta:: + :antsibull-docs: 2.16.2 + +.. Anchors + +.. _ansible_collections.netbox.netbox.netbox_contact_assignment_module: + +.. Anchors: short name for ansible.builtin + +.. Title + +netbox.netbox.netbox_contact_assignment module -- Creates or removes contact assignments from NetBox +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +.. Collection note + +.. note:: + This module is part of the `netbox.netbox collection `_ (version 3.22.0). + + It is not included in ``ansible-core``. + To check whether it is installed, run :code:`ansible-galaxy collection list`. + + To install it, use: :code:`ansible-galaxy collection install netbox.netbox`. + You need further requirements to be able to use this module, + see :ref:`Requirements ` for details. + + To use it in a playbook, specify: :code:`netbox.netbox.netbox_contact_assignment`. + +.. version_added + +.. rst-class:: ansible-version-added + +New in netbox.netbox 3.1.0 + +.. contents:: + :local: + :depth: 1 + +.. Deprecated + + +Synopsis +-------- + +.. Description + +- Creates or removes contact assignments from NetBox + + +.. Aliases + + +.. Requirements + +.. _ansible_collections.netbox.netbox.netbox_contact_assignment_module_requirements: + +Requirements +------------ +The below requirements are needed on the host that executes this module. + +- pynetbox + + + + + + +.. Options + +Parameters +---------- + +.. tabularcolumns:: \X{1}{3}\X{2}{3} + +.. list-table:: + :width: 100% + :widths: auto + :header-rows: 1 + :class: longtable ansible-option-table + + * - Parameter + - Comments + + * - .. raw:: html + +
+
+ + .. _ansible_collections.netbox.netbox.netbox_contact_assignment_module__parameter-cert: + + .. rst-class:: ansible-option-title + + **cert** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`any` + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Certificate path + + + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. _ansible_collections.netbox.netbox.netbox_contact_assignment_module__parameter-data: + + .. rst-class:: ansible-option-title + + **data** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`dictionary` / :ansible-option-required:`required` + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Defines the contact configuration + + + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. raw:: latex + + \hspace{0.02\textwidth}\begin{minipage}[t]{0.3\textwidth} + + .. _ansible_collections.netbox.netbox.netbox_contact_assignment_module__parameter-data/contact: + + .. rst-class:: ansible-option-title + + **contact** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`string` / :ansible-option-required:`required` + + .. raw:: html + +
+ + .. raw:: latex + + \end{minipage} + + - .. raw:: html + +
+ + The name of the contact to assign to the object + + + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. raw:: latex + + \hspace{0.02\textwidth}\begin{minipage}[t]{0.3\textwidth} + + .. _ansible_collections.netbox.netbox.netbox_contact_assignment_module__parameter-data/object_name: + + .. rst-class:: ansible-option-title + + **object_name** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`string` / :ansible-option-required:`required` + + .. raw:: html + +
+ + .. raw:: latex + + \end{minipage} + + - .. raw:: html + +
+ + The name of the object the contact is assigned to + + + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. raw:: latex + + \hspace{0.02\textwidth}\begin{minipage}[t]{0.3\textwidth} + + .. _ansible_collections.netbox.netbox.netbox_contact_assignment_module__parameter-data/object_type: + + .. rst-class:: ansible-option-title + + **object_type** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`string` / :ansible-option-required:`required` + + .. raw:: html + +
+ + .. raw:: latex + + \end{minipage} + + - .. raw:: html + +
+ + The type of the object the contact is assigned to + + + .. rst-class:: ansible-option-line + + :ansible-option-choices:`Choices:` + + - :ansible-option-choices-entry:`"circuit"` + - :ansible-option-choices-entry:`"cluster"` + - :ansible-option-choices-entry:`"cluster\_group"` + - :ansible-option-choices-entry:`"device"` + - :ansible-option-choices-entry:`"location"` + - :ansible-option-choices-entry:`"manufacturer"` + - :ansible-option-choices-entry:`"power\_panel"` + - :ansible-option-choices-entry:`"provider"` + - :ansible-option-choices-entry:`"rack"` + - :ansible-option-choices-entry:`"region"` + - :ansible-option-choices-entry:`"site"` + - :ansible-option-choices-entry:`"site\_group"` + - :ansible-option-choices-entry:`"tenant"` + - :ansible-option-choices-entry:`"virtual\_machine"` + + + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. raw:: latex + + \hspace{0.02\textwidth}\begin{minipage}[t]{0.3\textwidth} + + .. _ansible_collections.netbox.netbox.netbox_contact_assignment_module__parameter-data/priority: + + .. rst-class:: ansible-option-title + + **priority** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`string` + + .. raw:: html + +
+ + .. raw:: latex + + \end{minipage} + + - .. raw:: html + +
+ + The priority of this contact + + + .. rst-class:: ansible-option-line + + :ansible-option-choices:`Choices:` + + - :ansible-option-choices-entry:`"primary"` + - :ansible-option-choices-entry:`"secondary"` + - :ansible-option-choices-entry:`"tertiary"` + - :ansible-option-choices-entry:`"inactive"` + + + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. raw:: latex + + \hspace{0.02\textwidth}\begin{minipage}[t]{0.3\textwidth} + + .. _ansible_collections.netbox.netbox.netbox_contact_assignment_module__parameter-data/role: + + .. rst-class:: ansible-option-title + + **role** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`string` / :ansible-option-required:`required` + + .. raw:: html + +
+ + .. raw:: latex + + \end{minipage} + + - .. raw:: html + +
+ + The name of the role the contact has for this object + + + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. raw:: latex + + \hspace{0.02\textwidth}\begin{minipage}[t]{0.3\textwidth} + + .. _ansible_collections.netbox.netbox.netbox_contact_assignment_module__parameter-data/tags: + + .. rst-class:: ansible-option-title + + **tags** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`list` / :ansible-option-elements:`elements=any` + + .. raw:: html + +
+ + .. raw:: latex + + \end{minipage} + + - .. raw:: html + +
+ + Any tags that the contact may need to be associated with + + + .. raw:: html + +
+ + + * - .. raw:: html + +
+
+ + .. _ansible_collections.netbox.netbox.netbox_contact_assignment_module__parameter-headers: + + .. rst-class:: ansible-option-title + + **headers** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`dictionary` + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Dictionary of headers to be passed to the NetBox API. + + + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. _ansible_collections.netbox.netbox.netbox_contact_assignment_module__parameter-netbox_token: + + .. rst-class:: ansible-option-title + + **netbox_token** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`string` / :ansible-option-required:`required` + + .. raw:: html + +
+ + - .. raw:: html + +
+ + The NetBox API token. + + + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. _ansible_collections.netbox.netbox.netbox_contact_assignment_module__parameter-netbox_url: + + .. rst-class:: ansible-option-title + + **netbox_url** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`string` / :ansible-option-required:`required` + + .. raw:: html + +
+ + - .. raw:: html + +
+ + The URL of the NetBox instance. + + Must be accessible by the Ansible control host. + + + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. _ansible_collections.netbox.netbox.netbox_contact_assignment_module__parameter-query_params: + + .. rst-class:: ansible-option-title + + **query_params** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`list` / :ansible-option-elements:`elements=string` + + .. raw:: html + +
+ + - .. raw:: html + +
+ + This can be used to override the specified values in ALLOWED\_QUERY\_PARAMS that are defined + + in plugins/module\_utils/netbox\_utils.py and provides control to users on what may make + + an object unique in their environment. + + + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. _ansible_collections.netbox.netbox.netbox_contact_assignment_module__parameter-state: + + .. rst-class:: ansible-option-title + + **state** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`string` + + .. raw:: html + +
+ + - .. raw:: html + +
+ + The state of the object. + + + .. rst-class:: ansible-option-line + + :ansible-option-choices:`Choices:` + + - :ansible-option-choices-entry-default:`"present"` :ansible-option-choices-default-mark:`← (default)` + - :ansible-option-choices-entry:`"absent"` + + + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. _ansible_collections.netbox.netbox.netbox_contact_assignment_module__parameter-validate_certs: + + .. rst-class:: ansible-option-title + + **validate_certs** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`any` + + .. raw:: html + +
+ + - .. raw:: html + +
+ + If :literal:`no`\ , SSL certificates will not be validated. + + This should only be used on personally controlled sites using a self-signed certificates. + + + .. rst-class:: ansible-option-line + + :ansible-option-default-bold:`Default:` :ansible-option-default:`true` + + .. raw:: html + +
+ + +.. Attributes + + +.. Notes + +Notes +----- + +.. note:: + - Tags should be defined as a YAML list + - This should be ran with connection :literal:`local` and hosts :literal:`localhost` + +.. Seealso + + +.. Examples + +Examples +-------- + +.. code-block:: yaml+jinja + + - name: "Test NetBox module" + connection: local + hosts: localhost + gather_facts: false + tasks: + - name: Assign a contact to a location with only required information + netbox.netbox.netbox_contact_assignment: + netbox_url: http://netbox.local + netbox_token: thisIsMyToken + data: + object_type: location + object_name: My Location + contact: John Doe + role: Supervisor Role + state: present + + - name: Delete contact assignment within netbox + netbox.netbox.netbox_contact_assignment: + netbox_url: http://netbox.local + netbox_token: thisIsMyToken + data: + object_type: location + object_name: My Location + contact: John Doe + role: Supervisor Role + state: absent + + - name: Create contact with all parameters + netbox.netbox.netbox_contact: + netbox_url: http://netbox.local + netbox_token: thisIsMyToken + data: + object_type: location + object_name: My Location + contact: John Doe + role: Supervisor Role + priority: tertiary + tags: + - tagA + - tagB + - tagC + state: present + + + +.. Facts + + +.. Return values + +Return Values +------------- +Common return values are documented :ref:`here `, the following are the fields unique to this module: + +.. tabularcolumns:: \X{1}{3}\X{2}{3} + +.. list-table:: + :width: 100% + :widths: auto + :header-rows: 1 + :class: longtable ansible-option-table + + * - Key + - Description + + * - .. raw:: html + +
+
+ + .. _ansible_collections.netbox.netbox.netbox_contact_assignment_module__return-contact_assignment: + + .. rst-class:: ansible-option-title + + **contact_assignment** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`dictionary` + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Serialized object as created or already existent within NetBox + + + .. rst-class:: ansible-option-line + + :ansible-option-returned-bold:`Returned:` on creation + + + .. raw:: html + +
+ + + * - .. raw:: html + +
+
+ + .. _ansible_collections.netbox.netbox.netbox_contact_assignment_module__return-msg: + + .. rst-class:: ansible-option-title + + **msg** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`string` + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Message indicating failure or info about what has been achieved + + + .. rst-class:: ansible-option-line + + :ansible-option-returned-bold:`Returned:` always + + + .. raw:: html + +
+ + + +.. Status (Presently only deprecated) + + +.. Authors + +Authors +~~~~~~~ + +- Daniel Chiquito (@dchiquito) + + + +.. Extra links + +Collection links +~~~~~~~~~~~~~~~~ + +.. ansible-links:: + + - title: "Issue Tracker" + url: "https://github.com/netbox-community/ansible_modules/issues" + external: true + - title: "Repository (Sources)" + url: "https://github.com/netbox-community/ansible_modules" + external: true + + +.. Parsing errors diff --git a/docs/plugins/netbox_contact_group_module.rst b/docs/plugins/netbox_contact_group_module.rst index 1185db0f0..7e4955603 100644 --- a/docs/plugins/netbox_contact_group_module.rst +++ b/docs/plugins/netbox_contact_group_module.rst @@ -6,7 +6,7 @@ :trim: .. meta:: - :antsibull-docs: 2.13.1 + :antsibull-docs: 2.16.2 .. Anchors @@ -22,7 +22,7 @@ netbox.netbox.netbox_contact_group module -- Creates or removes contact groups f .. Collection note .. note:: - This module is part of the `netbox.netbox collection `_ (version 3.21.0). + This module is part of the `netbox.netbox collection `_ (version 3.22.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -409,6 +409,40 @@ Parameters
+ * - .. raw:: html + +
+
+ + .. _ansible_collections.netbox.netbox.netbox_contact_group_module__parameter-headers: + + .. rst-class:: ansible-option-title + + **headers** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`dictionary` + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Dictionary of headers to be passed to the NetBox API. + + + .. raw:: html + +
+ * - .. raw:: html
diff --git a/docs/plugins/netbox_contact_module.rst b/docs/plugins/netbox_contact_module.rst index d1fe2fcce..3a36a745a 100644 --- a/docs/plugins/netbox_contact_module.rst +++ b/docs/plugins/netbox_contact_module.rst @@ -6,7 +6,7 @@ :trim: .. meta:: - :antsibull-docs: 2.13.1 + :antsibull-docs: 2.16.2 .. Anchors @@ -22,7 +22,7 @@ netbox.netbox.netbox_contact module -- Creates or removes contacts from NetBox .. Collection note .. note:: - This module is part of the `netbox.netbox collection `_ (version 3.21.0). + This module is part of the `netbox.netbox collection `_ (version 3.22.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -275,7 +275,49 @@ Parameters
- Group assignment for the contact + Group that the contact belongs to. Only available in Netbox version \<4.3 + + + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. raw:: latex + + \hspace{0.02\textwidth}\begin{minipage}[t]{0.3\textwidth} + + .. _ansible_collections.netbox.netbox.netbox_contact_module__parameter-data/contact_groups: + + .. rst-class:: ansible-option-title + + **contact_groups** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`list` / :ansible-option-elements:`elements=any` + + .. raw:: html + +
+ + .. raw:: latex + + \end{minipage} + + - .. raw:: html + +
+ + Groups that the contact belongs to. Only available in Netbox versions \>=4.3 .. raw:: html @@ -625,6 +667,40 @@ Parameters
+ * - .. raw:: html + +
+
+ + .. _ansible_collections.netbox.netbox.netbox_contact_module__parameter-headers: + + .. rst-class:: ansible-option-title + + **headers** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`dictionary` + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Dictionary of headers to be passed to the NetBox API. + + + .. raw:: html + +
+ * - .. raw:: html
@@ -868,6 +944,9 @@ Examples title: Mr Contact phone: 123456789 email: contac@contact.com + contact_groups: + - Group 1 + - Group 2 tags: - tagA - tagB diff --git a/docs/plugins/netbox_contact_role_module.rst b/docs/plugins/netbox_contact_role_module.rst index ee03b31aa..08dcef0b3 100644 --- a/docs/plugins/netbox_contact_role_module.rst +++ b/docs/plugins/netbox_contact_role_module.rst @@ -6,7 +6,7 @@ :trim: .. meta:: - :antsibull-docs: 2.13.1 + :antsibull-docs: 2.16.2 .. Anchors @@ -22,7 +22,7 @@ netbox.netbox.netbox_contact_role module -- Creates or removes contact roles fro .. Collection note .. note:: - This module is part of the `netbox.netbox collection `_ (version 3.21.0). + This module is part of the `netbox.netbox collection `_ (version 3.22.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -369,6 +369,40 @@ Parameters
+ * - .. raw:: html + +
+
+ + .. _ansible_collections.netbox.netbox.netbox_contact_role_module__parameter-headers: + + .. rst-class:: ansible-option-title + + **headers** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`dictionary` + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Dictionary of headers to be passed to the NetBox API. + + + .. raw:: html + +
+ * - .. raw:: html
diff --git a/docs/plugins/netbox_custom_field_choice_set_module.rst b/docs/plugins/netbox_custom_field_choice_set_module.rst index f87dd553c..91aa85d4b 100644 --- a/docs/plugins/netbox_custom_field_choice_set_module.rst +++ b/docs/plugins/netbox_custom_field_choice_set_module.rst @@ -6,7 +6,7 @@ :trim: .. meta:: - :antsibull-docs: 2.13.1 + :antsibull-docs: 2.16.2 .. Anchors @@ -22,7 +22,7 @@ netbox.netbox.netbox_custom_field_choice_set module -- Creates, updates or delet .. Collection note .. note:: - This module is part of the `netbox.netbox collection `_ (version 3.21.0). + This module is part of the `netbox.netbox collection `_ (version 3.22.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -388,6 +388,40 @@ Parameters
+ * - .. raw:: html + +
+
+ + .. _ansible_collections.netbox.netbox.netbox_custom_field_choice_set_module__parameter-headers: + + .. rst-class:: ansible-option-title + + **headers** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`dictionary` + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Dictionary of headers to be passed to the NetBox API. + + + .. raw:: html + +
+ * - .. raw:: html
diff --git a/docs/plugins/netbox_custom_field_module.rst b/docs/plugins/netbox_custom_field_module.rst index 717e4ee85..03a12c2cf 100644 --- a/docs/plugins/netbox_custom_field_module.rst +++ b/docs/plugins/netbox_custom_field_module.rst @@ -6,7 +6,7 @@ :trim: .. meta:: - :antsibull-docs: 2.13.1 + :antsibull-docs: 2.16.2 .. Anchors @@ -22,7 +22,7 @@ netbox.netbox.netbox_custom_field module -- Creates, updates or deletes custom f .. Collection note .. note:: - This module is part of the `netbox.netbox collection `_ (version 3.21.0). + This module is part of the `netbox.netbox collection `_ (version 3.22.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -581,6 +581,48 @@ Parameters The content type(s) to apply this custom field to (NetBox 4.0+) + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. raw:: latex + + \hspace{0.02\textwidth}\begin{minipage}[t]{0.3\textwidth} + + .. _ansible_collections.netbox.netbox.netbox_custom_field_module__parameter-data/related_object_filter: + + .. rst-class:: ansible-option-title + + **related_object_filter** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`dictionary` + + .. raw:: html + +
+ + .. raw:: latex + + \end{minipage} + + - .. raw:: html + +
+ + Filter definition for related object selection. To reset the value, set it to an empty dict (null value is ignored by the API) + + .. raw:: html
@@ -1010,6 +1052,40 @@ Parameters
+ * - .. raw:: html + +
+
+ + .. _ansible_collections.netbox.netbox.netbox_custom_field_module__parameter-headers: + + .. rst-class:: ansible-option-title + + **headers** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`dictionary` + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Dictionary of headers to be passed to the NetBox API. + + + .. raw:: html + +
+ * - .. raw:: html
diff --git a/docs/plugins/netbox_custom_link_module.rst b/docs/plugins/netbox_custom_link_module.rst index 81d1d060b..e08dc0722 100644 --- a/docs/plugins/netbox_custom_link_module.rst +++ b/docs/plugins/netbox_custom_link_module.rst @@ -6,7 +6,7 @@ :trim: .. meta:: - :antsibull-docs: 2.13.1 + :antsibull-docs: 2.16.2 .. Anchors @@ -22,7 +22,7 @@ netbox.netbox.netbox_custom_link module -- Creates, updates or deletes custom li .. Collection note .. note:: - This module is part of the `netbox.netbox collection `_ (version 3.21.0). + This module is part of the `netbox.netbox collection `_ (version 3.22.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -644,6 +644,40 @@ Parameters
+ * - .. raw:: html + +
+
+ + .. _ansible_collections.netbox.netbox.netbox_custom_link_module__parameter-headers: + + .. rst-class:: ansible-option-title + + **headers** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`dictionary` + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Dictionary of headers to be passed to the NetBox API. + + + .. raw:: html + +
+ * - .. raw:: html
diff --git a/docs/plugins/netbox_data_source_module.rst b/docs/plugins/netbox_data_source_module.rst new file mode 100644 index 000000000..beaacec18 --- /dev/null +++ b/docs/plugins/netbox_data_source_module.rst @@ -0,0 +1,934 @@ +.. Document meta + +:orphan: + +.. |antsibull-internal-nbsp| unicode:: 0xA0 + :trim: + +.. meta:: + :antsibull-docs: 2.16.2 + +.. Anchors + +.. _ansible_collections.netbox.netbox.netbox_data_source_module: + +.. Anchors: short name for ansible.builtin + +.. Title + +netbox.netbox.netbox_data_source module -- Creates or removes data sources from NetBox +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +.. Collection note + +.. note:: + This module is part of the `netbox.netbox collection `_ (version 3.22.0). + + It is not included in ``ansible-core``. + To check whether it is installed, run :code:`ansible-galaxy collection list`. + + To install it, use: :code:`ansible-galaxy collection install netbox.netbox`. + You need further requirements to be able to use this module, + see :ref:`Requirements ` for details. + + To use it in a playbook, specify: :code:`netbox.netbox.netbox_data_source`. + +.. version_added + +.. rst-class:: ansible-version-added + +New in netbox.netbox 3.22.0 + +.. contents:: + :local: + :depth: 1 + +.. Deprecated + + +Synopsis +-------- + +.. Description + +- Creates or removes data sources from NetBox + + +.. Aliases + + +.. Requirements + +.. _ansible_collections.netbox.netbox.netbox_data_source_module_requirements: + +Requirements +------------ +The below requirements are needed on the host that executes this module. + +- pynetbox + + + + + + +.. Options + +Parameters +---------- + +.. tabularcolumns:: \X{1}{3}\X{2}{3} + +.. list-table:: + :width: 100% + :widths: auto + :header-rows: 1 + :class: longtable ansible-option-table + + * - Parameter + - Comments + + * - .. raw:: html + +
+
+ + .. _ansible_collections.netbox.netbox.netbox_data_source_module__parameter-cert: + + .. rst-class:: ansible-option-title + + **cert** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`any` + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Certificate path + + + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. _ansible_collections.netbox.netbox.netbox_data_source_module__parameter-data: + + .. rst-class:: ansible-option-title + + **data** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`dictionary` / :ansible-option-required:`required` + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Defines the data source configuration + + + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. raw:: latex + + \hspace{0.02\textwidth}\begin{minipage}[t]{0.3\textwidth} + + .. _ansible_collections.netbox.netbox.netbox_data_source_module__parameter-data/comments: + + .. rst-class:: ansible-option-title + + **comments** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`string` + + .. raw:: html + +
+ + .. raw:: latex + + \end{minipage} + + - .. raw:: html + +
+ + Comments about the data source + + + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. raw:: latex + + \hspace{0.02\textwidth}\begin{minipage}[t]{0.3\textwidth} + + .. _ansible_collections.netbox.netbox.netbox_data_source_module__parameter-data/description: + + .. rst-class:: ansible-option-title + + **description** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`string` + + .. raw:: html + +
+ + .. raw:: latex + + \end{minipage} + + - .. raw:: html + +
+ + Description of the data source + + + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. raw:: latex + + \hspace{0.02\textwidth}\begin{minipage}[t]{0.3\textwidth} + + .. _ansible_collections.netbox.netbox.netbox_data_source_module__parameter-data/enabled: + + .. rst-class:: ansible-option-title + + **enabled** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`boolean` + + .. raw:: html + +
+ + .. raw:: latex + + \end{minipage} + + - .. raw:: html + +
+ + Whether or not this data source can be synced + + + .. rst-class:: ansible-option-line + + :ansible-option-choices:`Choices:` + + - :ansible-option-choices-entry:`false` + - :ansible-option-choices-entry:`true` + + + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. raw:: latex + + \hspace{0.02\textwidth}\begin{minipage}[t]{0.3\textwidth} + + .. _ansible_collections.netbox.netbox.netbox_data_source_module__parameter-data/ignore_rules: + + .. rst-class:: ansible-option-title + + **ignore_rules** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`string` + + .. raw:: html + +
+ + .. raw:: latex + + \end{minipage} + + - .. raw:: html + +
+ + Patterns (one per line) matching files to ignore when syncing + + + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. raw:: latex + + \hspace{0.02\textwidth}\begin{minipage}[t]{0.3\textwidth} + + .. _ansible_collections.netbox.netbox.netbox_data_source_module__parameter-data/name: + + .. rst-class:: ansible-option-title + + **name** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`string` / :ansible-option-required:`required` + + .. raw:: html + +
+ + .. raw:: latex + + \end{minipage} + + - .. raw:: html + +
+ + Name of the data source + + + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. raw:: latex + + \hspace{0.02\textwidth}\begin{minipage}[t]{0.3\textwidth} + + .. _ansible_collections.netbox.netbox.netbox_data_source_module__parameter-data/source_url: + + .. rst-class:: ansible-option-title + + **source_url** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`string` + + .. raw:: html + +
+ + .. raw:: latex + + \end{minipage} + + - .. raw:: html + +
+ + URL of the data source to be created + + + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. raw:: latex + + \hspace{0.02\textwidth}\begin{minipage}[t]{0.3\textwidth} + + .. _ansible_collections.netbox.netbox.netbox_data_source_module__parameter-data/sync_interval: + + .. rst-class:: ansible-option-title + + **sync_interval** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`integer` + + .. raw:: html + +
+ + .. raw:: latex + + \end{minipage} + + - .. raw:: html + +
+ + The interval in seconds between syncs + + + .. rst-class:: ansible-option-line + + :ansible-option-choices:`Choices:` + + - :ansible-option-choices-entry:`1` + - :ansible-option-choices-entry:`60` + - :ansible-option-choices-entry:`720` + - :ansible-option-choices-entry:`1440` + - :ansible-option-choices-entry:`10080` + - :ansible-option-choices-entry:`43200` + + + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. raw:: latex + + \hspace{0.02\textwidth}\begin{minipage}[t]{0.3\textwidth} + + .. _ansible_collections.netbox.netbox.netbox_data_source_module__parameter-data/type: + + .. rst-class:: ansible-option-title + + **type** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`string` + + .. raw:: html + +
+ + .. raw:: latex + + \end{minipage} + + - .. raw:: html + +
+ + The origin of the data source + + + .. rst-class:: ansible-option-line + + :ansible-option-choices:`Choices:` + + - :ansible-option-choices-entry:`"local"` + - :ansible-option-choices-entry:`"git"` + - :ansible-option-choices-entry:`"amazon-s3"` + + + .. raw:: html + +
+ + + * - .. raw:: html + +
+
+ + .. _ansible_collections.netbox.netbox.netbox_data_source_module__parameter-headers: + + .. rst-class:: ansible-option-title + + **headers** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`dictionary` + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Dictionary of headers to be passed to the NetBox API. + + + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. _ansible_collections.netbox.netbox.netbox_data_source_module__parameter-netbox_token: + + .. rst-class:: ansible-option-title + + **netbox_token** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`string` / :ansible-option-required:`required` + + .. raw:: html + +
+ + - .. raw:: html + +
+ + The NetBox API token. + + + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. _ansible_collections.netbox.netbox.netbox_data_source_module__parameter-netbox_url: + + .. rst-class:: ansible-option-title + + **netbox_url** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`string` / :ansible-option-required:`required` + + .. raw:: html + +
+ + - .. raw:: html + +
+ + The URL of the NetBox instance. + + Must be accessible by the Ansible control host. + + + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. _ansible_collections.netbox.netbox.netbox_data_source_module__parameter-query_params: + + .. rst-class:: ansible-option-title + + **query_params** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`list` / :ansible-option-elements:`elements=string` + + .. raw:: html + +
+ + - .. raw:: html + +
+ + This can be used to override the specified values in ALLOWED\_QUERY\_PARAMS that are defined + + in plugins/module\_utils/netbox\_utils.py and provides control to users on what may make + + an object unique in their environment. + + + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. _ansible_collections.netbox.netbox.netbox_data_source_module__parameter-state: + + .. rst-class:: ansible-option-title + + **state** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`string` + + .. raw:: html + +
+ + - .. raw:: html + +
+ + The state of the object. + + + .. rst-class:: ansible-option-line + + :ansible-option-choices:`Choices:` + + - :ansible-option-choices-entry-default:`"present"` :ansible-option-choices-default-mark:`← (default)` + - :ansible-option-choices-entry:`"absent"` + + + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. _ansible_collections.netbox.netbox.netbox_data_source_module__parameter-validate_certs: + + .. rst-class:: ansible-option-title + + **validate_certs** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`any` + + .. raw:: html + +
+ + - .. raw:: html + +
+ + If :literal:`no`\ , SSL certificates will not be validated. + + This should only be used on personally controlled sites using a self-signed certificates. + + + .. rst-class:: ansible-option-line + + :ansible-option-default-bold:`Default:` :ansible-option-default:`true` + + .. raw:: html + +
+ + +.. Attributes + + +.. Notes + + +.. Seealso + + +.. Examples + +Examples +-------- + +.. code-block:: yaml+jinja + + - name: "Test NetBox modules" + connection: local + hosts: localhost + gather_facts: false + + tasks: + - name: "Create a new data source with only required information" + netbox.netbox.netbox_data_source: + netbox_url: http://netbox.local + netbox_token: thisIsMyToken + data: + name: "Data Source 1" + type: "local" + source_url: "/tmp/data-source.txt" + enabled: true + state: present + - name: "Update that data source with other fields" + netbox.netbox.netbox_data_source: + netbox_url: http://netbox.local + netbox_token: thisIsMyToken + data: + name: "Data Source 1" + type: "amazon-s3" + source_url: "path/to/bucket" + enabled: false + description: "My first data source" + ignore_rules: ".*\nfoo.txt\n*.yml" + sync_interval: 1440 + comments: "Some commentary on this data source" + state: present + - name: "Delete the data source" + netbox.netbox.netbox_data_source: + netbox_url: http://netbox.local + netbox_token: thisIsMyToken + data: + name: "Data Source 1" + state: absent + + + +.. Facts + + +.. Return values + +Return Values +------------- +Common return values are documented :ref:`here `, the following are the fields unique to this module: + +.. tabularcolumns:: \X{1}{3}\X{2}{3} + +.. list-table:: + :width: 100% + :widths: auto + :header-rows: 1 + :class: longtable ansible-option-table + + * - Key + - Description + + * - .. raw:: html + +
+
+ + .. _ansible_collections.netbox.netbox.netbox_data_source_module__return-data_source: + + .. rst-class:: ansible-option-title + + **data_source** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`dictionary` + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Serialized object as created or already existent within NetBox + + + .. rst-class:: ansible-option-line + + :ansible-option-returned-bold:`Returned:` on creation + + + .. raw:: html + +
+ + + * - .. raw:: html + +
+
+ + .. _ansible_collections.netbox.netbox.netbox_data_source_module__return-msg: + + .. rst-class:: ansible-option-title + + **msg** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`string` + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Message indicating failure or info about what has been achieved + + + .. rst-class:: ansible-option-line + + :ansible-option-returned-bold:`Returned:` always + + + .. raw:: html + +
+ + + +.. Status (Presently only deprecated) + + +.. Authors + +Authors +~~~~~~~ + +- Daniel Chiquito (@dchiquito) + + + +.. Extra links + +Collection links +~~~~~~~~~~~~~~~~ + +.. ansible-links:: + + - title: "Issue Tracker" + url: "https://github.com/netbox-community/ansible_modules/issues" + external: true + - title: "Repository (Sources)" + url: "https://github.com/netbox-community/ansible_modules" + external: true + + +.. Parsing errors diff --git a/docs/plugins/netbox_device_bay_module.rst b/docs/plugins/netbox_device_bay_module.rst index cecae77aa..a8632aa88 100644 --- a/docs/plugins/netbox_device_bay_module.rst +++ b/docs/plugins/netbox_device_bay_module.rst @@ -6,7 +6,7 @@ :trim: .. meta:: - :antsibull-docs: 2.13.1 + :antsibull-docs: 2.16.2 .. Anchors @@ -22,7 +22,7 @@ netbox.netbox.netbox_device_bay module -- Create, update or delete device bays w .. Collection note .. note:: - This module is part of the `netbox.netbox collection `_ (version 3.21.0). + This module is part of the `netbox.netbox collection `_ (version 3.22.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -412,6 +412,40 @@ Parameters
+ * - .. raw:: html + +
+
+ + .. _ansible_collections.netbox.netbox.netbox_device_bay_module__parameter-headers: + + .. rst-class:: ansible-option-title + + **headers** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`dictionary` + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Dictionary of headers to be passed to the NetBox API. + + + .. raw:: html + +
+ * - .. raw:: html
diff --git a/docs/plugins/netbox_device_bay_template_module.rst b/docs/plugins/netbox_device_bay_template_module.rst index 9e4a73bfd..6d6b3eef5 100644 --- a/docs/plugins/netbox_device_bay_template_module.rst +++ b/docs/plugins/netbox_device_bay_template_module.rst @@ -6,7 +6,7 @@ :trim: .. meta:: - :antsibull-docs: 2.13.1 + :antsibull-docs: 2.16.2 .. Anchors @@ -22,7 +22,7 @@ netbox.netbox.netbox_device_bay_template module -- Create, update or delete devi .. Collection note .. note:: - This module is part of the `netbox.netbox collection `_ (version 3.21.0). + This module is part of the `netbox.netbox collection `_ (version 3.22.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -241,6 +241,40 @@ Parameters
+ * - .. raw:: html + +
+
+ + .. _ansible_collections.netbox.netbox.netbox_device_bay_template_module__parameter-headers: + + .. rst-class:: ansible-option-title + + **headers** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`dictionary` + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Dictionary of headers to be passed to the NetBox API. + + + .. raw:: html + +
+ * - .. raw:: html
diff --git a/docs/plugins/netbox_device_interface_module.rst b/docs/plugins/netbox_device_interface_module.rst index b4e2bf0bb..adfd32b4d 100644 --- a/docs/plugins/netbox_device_interface_module.rst +++ b/docs/plugins/netbox_device_interface_module.rst @@ -6,7 +6,7 @@ :trim: .. meta:: - :antsibull-docs: 2.13.1 + :antsibull-docs: 2.16.2 .. Anchors @@ -22,7 +22,7 @@ netbox.netbox.netbox_device_interface module -- Creates or removes interfaces on .. Collection note .. note:: - This module is part of the `netbox.netbox collection `_ (version 3.21.0). + This module is part of the `netbox.netbox collection `_ (version 3.22.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -983,7 +983,7 @@ Parameters .. ansible-option-type-line:: - :ansible-option-type:`string` + :ansible-option-type:`any` .. raw:: html @@ -1355,6 +1355,40 @@ Parameters
+ * - .. raw:: html + +
+
+ + .. _ansible_collections.netbox.netbox.netbox_device_interface_module__parameter-headers: + + .. rst-class:: ansible-option-title + + **headers** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`dictionary` + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Dictionary of headers to be passed to the NetBox API. + + + .. raw:: html + +
+ * - .. raw:: html
diff --git a/docs/plugins/netbox_device_interface_template_module.rst b/docs/plugins/netbox_device_interface_template_module.rst index 9f7d70fce..f5978b587 100644 --- a/docs/plugins/netbox_device_interface_template_module.rst +++ b/docs/plugins/netbox_device_interface_template_module.rst @@ -6,7 +6,7 @@ :trim: .. meta:: - :antsibull-docs: 2.13.1 + :antsibull-docs: 2.16.2 .. Anchors @@ -22,7 +22,7 @@ netbox.netbox.netbox_device_interface_template module -- Creates or removes inte .. Collection note .. note:: - This module is part of the `netbox.netbox collection `_ (version 3.21.0). + This module is part of the `netbox.netbox collection `_ (version 3.22.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -568,6 +568,40 @@ Parameters
+ * - .. raw:: html + +
+
+ + .. _ansible_collections.netbox.netbox.netbox_device_interface_template_module__parameter-headers: + + .. rst-class:: ansible-option-title + + **headers** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`dictionary` + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Dictionary of headers to be passed to the NetBox API. + + + .. raw:: html + +
+ * - .. raw:: html
diff --git a/docs/plugins/netbox_device_module.rst b/docs/plugins/netbox_device_module.rst index c478071ad..47b8e9e4c 100644 --- a/docs/plugins/netbox_device_module.rst +++ b/docs/plugins/netbox_device_module.rst @@ -6,7 +6,7 @@ :trim: .. meta:: - :antsibull-docs: 2.13.1 + :antsibull-docs: 2.16.2 .. Anchors @@ -22,7 +22,7 @@ netbox.netbox.netbox_device module -- Create, update or delete devices within Ne .. Collection note .. note:: - This module is part of the `netbox.netbox collection `_ (version 3.21.0). + This module is part of the `netbox.netbox collection `_ (version 3.22.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -1329,6 +1329,40 @@ Parameters
+ * - .. raw:: html + +
+
+ + .. _ansible_collections.netbox.netbox.netbox_device_module__parameter-headers: + + .. rst-class:: ansible-option-title + + **headers** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`dictionary` + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Dictionary of headers to be passed to the NetBox API. + + + .. raw:: html + +
+ * - .. raw:: html
diff --git a/docs/plugins/netbox_device_role_module.rst b/docs/plugins/netbox_device_role_module.rst index bab31e4b1..7b0188f27 100644 --- a/docs/plugins/netbox_device_role_module.rst +++ b/docs/plugins/netbox_device_role_module.rst @@ -6,7 +6,7 @@ :trim: .. meta:: - :antsibull-docs: 2.13.1 + :antsibull-docs: 2.16.2 .. Anchors @@ -22,7 +22,7 @@ netbox.netbox.netbox_device_role module -- Create, update or delete devices role .. Collection note .. note:: - This module is part of the `netbox.netbox collection `_ (version 3.21.0). + This module is part of the `netbox.netbox collection `_ (version 3.22.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -467,6 +467,40 @@ Parameters
+ * - .. raw:: html + +
+
+ + .. _ansible_collections.netbox.netbox.netbox_device_role_module__parameter-headers: + + .. rst-class:: ansible-option-title + + **headers** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`dictionary` + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Dictionary of headers to be passed to the NetBox API. + + + .. raw:: html + +
+ * - .. raw:: html
diff --git a/docs/plugins/netbox_device_type_module.rst b/docs/plugins/netbox_device_type_module.rst index 04ea01554..e8991cfc7 100644 --- a/docs/plugins/netbox_device_type_module.rst +++ b/docs/plugins/netbox_device_type_module.rst @@ -6,7 +6,7 @@ :trim: .. meta:: - :antsibull-docs: 2.13.1 + :antsibull-docs: 2.16.2 .. Anchors @@ -22,7 +22,7 @@ netbox.netbox.netbox_device_type module -- Create, update or delete device types .. Collection note .. note:: - This module is part of the `netbox.netbox collection `_ (version 3.21.0). + This module is part of the `netbox.netbox collection `_ (version 3.22.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -847,6 +847,40 @@ Parameters
+ * - .. raw:: html + +
+
+ + .. _ansible_collections.netbox.netbox.netbox_device_type_module__parameter-headers: + + .. rst-class:: ansible-option-title + + **headers** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`dictionary` + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Dictionary of headers to be passed to the NetBox API. + + + .. raw:: html + +
+ * - .. raw:: html
@@ -1076,7 +1110,7 @@ Examples manufacturer: Test Manufacturer state: present - - name: Create device type within NetBox with only required information + - name: Create device type within NetBox with more information netbox.netbox.netbox_device_type: netbox_url: http://netbox.local netbox_token: thisIsMyToken diff --git a/docs/plugins/netbox_export_template_module.rst b/docs/plugins/netbox_export_template_module.rst index 950855825..e8a59cd15 100644 --- a/docs/plugins/netbox_export_template_module.rst +++ b/docs/plugins/netbox_export_template_module.rst @@ -6,7 +6,7 @@ :trim: .. meta:: - :antsibull-docs: 2.13.1 + :antsibull-docs: 2.16.2 .. Anchors @@ -22,7 +22,7 @@ netbox.netbox.netbox_export_template module -- Creates, updates or deletes expor .. Collection note .. note:: - This module is part of the `netbox.netbox collection `_ (version 3.21.0). + This module is part of the `netbox.netbox collection `_ (version 3.22.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -549,6 +549,40 @@ Parameters
+ * - .. raw:: html + +
+
+ + .. _ansible_collections.netbox.netbox.netbox_export_template_module__parameter-headers: + + .. rst-class:: ansible-option-title + + **headers** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`dictionary` + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Dictionary of headers to be passed to the NetBox API. + + + .. raw:: html + +
+ * - .. raw:: html
diff --git a/docs/plugins/netbox_fhrp_group_assignment_module.rst b/docs/plugins/netbox_fhrp_group_assignment_module.rst index 040cfb9ed..8807ddcb6 100644 --- a/docs/plugins/netbox_fhrp_group_assignment_module.rst +++ b/docs/plugins/netbox_fhrp_group_assignment_module.rst @@ -6,7 +6,7 @@ :trim: .. meta:: - :antsibull-docs: 2.13.1 + :antsibull-docs: 2.16.2 .. Anchors @@ -22,7 +22,7 @@ netbox.netbox.netbox_fhrp_group_assignment module -- Create, update or delete FH .. Collection note .. note:: - This module is part of the `netbox.netbox collection `_ (version 3.21.0). + This module is part of the `netbox.netbox collection `_ (version 3.22.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -330,6 +330,40 @@ Parameters
+ * - .. raw:: html + +
+
+ + .. _ansible_collections.netbox.netbox.netbox_fhrp_group_assignment_module__parameter-headers: + + .. rst-class:: ansible-option-title + + **headers** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`dictionary` + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Dictionary of headers to be passed to the NetBox API. + + + .. raw:: html + +
+ * - .. raw:: html
diff --git a/docs/plugins/netbox_fhrp_group_module.rst b/docs/plugins/netbox_fhrp_group_module.rst index efa8e43c2..a83398b48 100644 --- a/docs/plugins/netbox_fhrp_group_module.rst +++ b/docs/plugins/netbox_fhrp_group_module.rst @@ -6,7 +6,7 @@ :trim: .. meta:: - :antsibull-docs: 2.13.1 + :antsibull-docs: 2.16.2 .. Anchors @@ -22,7 +22,7 @@ netbox.netbox.netbox_fhrp_group module -- Create, update or delete FHRP groups w .. Collection note .. note:: - This module is part of the `netbox.netbox collection `_ (version 3.21.0). + This module is part of the `netbox.netbox collection `_ (version 3.22.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -517,6 +517,40 @@ Parameters
+ * - .. raw:: html + +
+
+ + .. _ansible_collections.netbox.netbox.netbox_fhrp_group_module__parameter-headers: + + .. rst-class:: ansible-option-title + + **headers** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`dictionary` + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Dictionary of headers to be passed to the NetBox API. + + + .. raw:: html + +
+ * - .. raw:: html
diff --git a/docs/plugins/netbox_front_port_module.rst b/docs/plugins/netbox_front_port_module.rst index f38c2ce4c..5dfaee56a 100644 --- a/docs/plugins/netbox_front_port_module.rst +++ b/docs/plugins/netbox_front_port_module.rst @@ -6,7 +6,7 @@ :trim: .. meta:: - :antsibull-docs: 2.13.1 + :antsibull-docs: 2.16.2 .. Anchors @@ -22,7 +22,7 @@ netbox.netbox.netbox_front_port module -- Create, update or delete front ports w .. Collection note .. note:: - This module is part of the `netbox.netbox collection `_ (version 3.21.0). + This module is part of the `netbox.netbox collection `_ (version 3.22.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -516,6 +516,40 @@ Parameters
+ * - .. raw:: html + +
+
+ + .. _ansible_collections.netbox.netbox.netbox_front_port_module__parameter-headers: + + .. rst-class:: ansible-option-title + + **headers** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`dictionary` + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Dictionary of headers to be passed to the NetBox API. + + + .. raw:: html + +
+ * - .. raw:: html
diff --git a/docs/plugins/netbox_front_port_template_module.rst b/docs/plugins/netbox_front_port_template_module.rst index b77e0cb73..b6b41389e 100644 --- a/docs/plugins/netbox_front_port_template_module.rst +++ b/docs/plugins/netbox_front_port_template_module.rst @@ -6,7 +6,7 @@ :trim: .. meta:: - :antsibull-docs: 2.13.1 + :antsibull-docs: 2.16.2 .. Anchors @@ -22,7 +22,7 @@ netbox.netbox.netbox_front_port_template module -- Create, update or delete fron .. Collection note .. note:: - This module is part of the `netbox.netbox collection `_ (version 3.21.0). + This module is part of the `netbox.netbox collection `_ (version 3.22.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -477,6 +477,40 @@ Parameters
+ * - .. raw:: html + +
+
+ + .. _ansible_collections.netbox.netbox.netbox_front_port_template_module__parameter-headers: + + .. rst-class:: ansible-option-title + + **headers** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`dictionary` + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Dictionary of headers to be passed to the NetBox API. + + + .. raw:: html + +
+ * - .. raw:: html
diff --git a/docs/plugins/netbox_interface_module.rst b/docs/plugins/netbox_interface_module.rst index 8dc389cd7..69056062c 100644 --- a/docs/plugins/netbox_interface_module.rst +++ b/docs/plugins/netbox_interface_module.rst @@ -3,7 +3,7 @@ :orphan: .. meta:: - :antsibull-docs: 2.13.1 + :antsibull-docs: 2.16.2 .. Anchors @@ -17,7 +17,7 @@ netbox.netbox.netbox_interface .. Collection note .. note:: - This plugin was part of the `netbox.netbox collection `_ (version 3.21.0). + This plugin was part of the `netbox.netbox collection `_ (version 3.22.0). This module has been removed in version 0.1.0 of netbox.netbox. diff --git a/docs/plugins/netbox_inventory_item_module.rst b/docs/plugins/netbox_inventory_item_module.rst index 7fe8675e5..1b942990c 100644 --- a/docs/plugins/netbox_inventory_item_module.rst +++ b/docs/plugins/netbox_inventory_item_module.rst @@ -6,7 +6,7 @@ :trim: .. meta:: - :antsibull-docs: 2.13.1 + :antsibull-docs: 2.16.2 .. Anchors @@ -22,7 +22,7 @@ netbox.netbox.netbox_inventory_item module -- Creates or removes inventory items .. Collection note .. note:: - This module is part of the `netbox.netbox collection `_ (version 3.21.0). + This module is part of the `netbox.netbox collection `_ (version 3.22.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -911,6 +911,40 @@ Parameters
+ * - .. raw:: html + +
+
+ + .. _ansible_collections.netbox.netbox.netbox_inventory_item_module__parameter-headers: + + .. rst-class:: ansible-option-title + + **headers** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`dictionary` + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Dictionary of headers to be passed to the NetBox API. + + + .. raw:: html + +
+ * - .. raw:: html
diff --git a/docs/plugins/netbox_inventory_item_role_module.rst b/docs/plugins/netbox_inventory_item_role_module.rst index f17247cc2..2c3009770 100644 --- a/docs/plugins/netbox_inventory_item_role_module.rst +++ b/docs/plugins/netbox_inventory_item_role_module.rst @@ -6,7 +6,7 @@ :trim: .. meta:: - :antsibull-docs: 2.13.1 + :antsibull-docs: 2.16.2 .. Anchors @@ -22,7 +22,7 @@ netbox.netbox.netbox_inventory_item_role module -- Create, update or delete devi .. Collection note .. note:: - This module is part of the `netbox.netbox collection `_ (version 3.21.0). + This module is part of the `netbox.netbox collection `_ (version 3.22.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -411,6 +411,40 @@ Parameters
+ * - .. raw:: html + +
+
+ + .. _ansible_collections.netbox.netbox.netbox_inventory_item_role_module__parameter-headers: + + .. rst-class:: ansible-option-title + + **headers** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`dictionary` + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Dictionary of headers to be passed to the NetBox API. + + + .. raw:: html + +
+ * - .. raw:: html
diff --git a/docs/plugins/netbox_ip_address_module.rst b/docs/plugins/netbox_ip_address_module.rst index aadcf3cc5..d77a58493 100644 --- a/docs/plugins/netbox_ip_address_module.rst +++ b/docs/plugins/netbox_ip_address_module.rst @@ -6,7 +6,7 @@ :trim: .. meta:: - :antsibull-docs: 2.13.1 + :antsibull-docs: 2.16.2 .. Anchors @@ -22,7 +22,7 @@ netbox.netbox.netbox_ip_address module -- Creates or removes IP addresses from N .. Collection note .. note:: - This module is part of the `netbox.netbox collection `_ (version 3.21.0). + This module is part of the `netbox.netbox collection `_ (version 3.22.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -950,6 +950,40 @@ Parameters
+ * - .. raw:: html + +
+
+ + .. _ansible_collections.netbox.netbox.netbox_ip_address_module__parameter-headers: + + .. rst-class:: ansible-option-title + + **headers** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`dictionary` + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Dictionary of headers to be passed to the NetBox API. + + + .. raw:: html + +
+ * - .. raw:: html
diff --git a/docs/plugins/netbox_ipam_role_module.rst b/docs/plugins/netbox_ipam_role_module.rst index b32a27d0e..18dcb7baa 100644 --- a/docs/plugins/netbox_ipam_role_module.rst +++ b/docs/plugins/netbox_ipam_role_module.rst @@ -6,7 +6,7 @@ :trim: .. meta:: - :antsibull-docs: 2.13.1 + :antsibull-docs: 2.16.2 .. Anchors @@ -22,7 +22,7 @@ netbox.netbox.netbox_ipam_role module -- Creates or removes ipam roles from NetB .. Collection note .. note:: - This module is part of the `netbox.netbox collection `_ (version 3.21.0). + This module is part of the `netbox.netbox collection `_ (version 3.22.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -417,6 +417,40 @@ Parameters
+ * - .. raw:: html + +
+
+ + .. _ansible_collections.netbox.netbox.netbox_ipam_role_module__parameter-headers: + + .. rst-class:: ansible-option-title + + **headers** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`dictionary` + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Dictionary of headers to be passed to the NetBox API. + + + .. raw:: html + +
+ * - .. raw:: html
diff --git a/docs/plugins/netbox_journal_entry_module.rst b/docs/plugins/netbox_journal_entry_module.rst index d05d75f8c..4777136dd 100644 --- a/docs/plugins/netbox_journal_entry_module.rst +++ b/docs/plugins/netbox_journal_entry_module.rst @@ -6,7 +6,7 @@ :trim: .. meta:: - :antsibull-docs: 2.13.1 + :antsibull-docs: 2.16.2 .. Anchors @@ -22,7 +22,7 @@ netbox.netbox.netbox_journal_entry module -- Creates a journal entry .. Collection note .. note:: - This module is part of the `netbox.netbox collection `_ (version 3.21.0). + This module is part of the `netbox.netbox collection `_ (version 3.22.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -451,6 +451,40 @@ Parameters
+ * - .. raw:: html + +
+
+ + .. _ansible_collections.netbox.netbox.netbox_journal_entry_module__parameter-headers: + + .. rst-class:: ansible-option-title + + **headers** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`dictionary` + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Dictionary of headers to be passed to the NetBox API. + + + .. raw:: html + +
+ * - .. raw:: html
diff --git a/docs/plugins/netbox_l2vpn_module.rst b/docs/plugins/netbox_l2vpn_module.rst index aeea58e30..c60d78f09 100644 --- a/docs/plugins/netbox_l2vpn_module.rst +++ b/docs/plugins/netbox_l2vpn_module.rst @@ -6,7 +6,7 @@ :trim: .. meta:: - :antsibull-docs: 2.13.1 + :antsibull-docs: 2.16.2 .. Anchors @@ -22,7 +22,7 @@ netbox.netbox.netbox_l2vpn module -- Create, update or delete L2VPNs within NetB .. Collection note .. note:: - This module is part of the `netbox.netbox collection `_ (version 3.21.0). + This module is part of the `netbox.netbox collection `_ (version 3.22.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -580,6 +580,40 @@ Parameters
+ * - .. raw:: html + +
+
+ + .. _ansible_collections.netbox.netbox.netbox_l2vpn_module__parameter-headers: + + .. rst-class:: ansible-option-title + + **headers** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`dictionary` + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Dictionary of headers to be passed to the NetBox API. + + + .. raw:: html + +
+ * - .. raw:: html
diff --git a/docs/plugins/netbox_l2vpn_termination_module.rst b/docs/plugins/netbox_l2vpn_termination_module.rst index 4de8a2f37..c8760577b 100644 --- a/docs/plugins/netbox_l2vpn_termination_module.rst +++ b/docs/plugins/netbox_l2vpn_termination_module.rst @@ -6,7 +6,7 @@ :trim: .. meta:: - :antsibull-docs: 2.13.1 + :antsibull-docs: 2.16.2 .. Anchors @@ -22,7 +22,7 @@ netbox.netbox.netbox_l2vpn_termination module -- Create, update or delete L2VPNs .. Collection note .. note:: - This module is part of the `netbox.netbox collection `_ (version 3.21.0). + This module is part of the `netbox.netbox collection `_ (version 3.22.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -376,6 +376,40 @@ Parameters
+ * - .. raw:: html + +
+
+ + .. _ansible_collections.netbox.netbox.netbox_l2vpn_termination_module__parameter-headers: + + .. rst-class:: ansible-option-title + + **headers** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`dictionary` + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Dictionary of headers to be passed to the NetBox API. + + + .. raw:: html + +
+ * - .. raw:: html
diff --git a/docs/plugins/netbox_location_module.rst b/docs/plugins/netbox_location_module.rst index f418f39a5..f2929c149 100644 --- a/docs/plugins/netbox_location_module.rst +++ b/docs/plugins/netbox_location_module.rst @@ -6,7 +6,7 @@ :trim: .. meta:: - :antsibull-docs: 2.13.1 + :antsibull-docs: 2.16.2 .. Anchors @@ -22,7 +22,7 @@ netbox.netbox.netbox_location module -- Create, update or delete locations withi .. Collection note .. note:: - This module is part of the `netbox.netbox collection `_ (version 3.21.0). + This module is part of the `netbox.netbox collection `_ (version 3.22.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -594,6 +594,40 @@ Parameters
+ * - .. raw:: html + +
+
+ + .. _ansible_collections.netbox.netbox.netbox_location_module__parameter-headers: + + .. rst-class:: ansible-option-title + + **headers** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`dictionary` + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Dictionary of headers to be passed to the NetBox API. + + + .. raw:: html + +
+ * - .. raw:: html
diff --git a/docs/plugins/netbox_mac_address_module.rst b/docs/plugins/netbox_mac_address_module.rst index 835d2a6b9..42d77bb4c 100644 --- a/docs/plugins/netbox_mac_address_module.rst +++ b/docs/plugins/netbox_mac_address_module.rst @@ -6,7 +6,7 @@ :trim: .. meta:: - :antsibull-docs: 2.13.1 + :antsibull-docs: 2.16.2 .. Anchors @@ -22,7 +22,7 @@ netbox.netbox.netbox_mac_address module -- Create, update or delete MAC addresse .. Collection note .. note:: - This module is part of the `netbox.netbox collection `_ (version 3.21.0). + This module is part of the `netbox.netbox collection `_ (version 3.22.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -409,6 +409,40 @@ Parameters
+ * - .. raw:: html + +
+
+ + .. _ansible_collections.netbox.netbox.netbox_mac_address_module__parameter-headers: + + .. rst-class:: ansible-option-title + + **headers** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`dictionary` + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Dictionary of headers to be passed to the NetBox API. + + + .. raw:: html + +
+ * - .. raw:: html
diff --git a/docs/plugins/netbox_manufacturer_module.rst b/docs/plugins/netbox_manufacturer_module.rst index a1004db9d..b2a13b29a 100644 --- a/docs/plugins/netbox_manufacturer_module.rst +++ b/docs/plugins/netbox_manufacturer_module.rst @@ -6,7 +6,7 @@ :trim: .. meta:: - :antsibull-docs: 2.13.1 + :antsibull-docs: 2.16.2 .. Anchors @@ -22,7 +22,7 @@ netbox.netbox.netbox_manufacturer module -- Create or delete manufacturers withi .. Collection note .. note:: - This module is part of the `netbox.netbox collection `_ (version 3.21.0). + This module is part of the `netbox.netbox collection `_ (version 3.22.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -375,6 +375,40 @@ Parameters
+ * - .. raw:: html + +
+
+ + .. _ansible_collections.netbox.netbox.netbox_manufacturer_module__parameter-headers: + + .. rst-class:: ansible-option-title + + **headers** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`dictionary` + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Dictionary of headers to be passed to the NetBox API. + + + .. raw:: html + +
+ * - .. raw:: html
diff --git a/docs/plugins/netbox_module_bay_module.rst b/docs/plugins/netbox_module_bay_module.rst index a372a0e9d..f8e314341 100644 --- a/docs/plugins/netbox_module_bay_module.rst +++ b/docs/plugins/netbox_module_bay_module.rst @@ -6,7 +6,7 @@ :trim: .. meta:: - :antsibull-docs: 2.13.1 + :antsibull-docs: 2.16.2 .. Anchors @@ -22,7 +22,7 @@ netbox.netbox.netbox_module_bay module -- Create, update or delete module bay wi .. Collection note .. note:: - This module is part of the `netbox.netbox collection `_ (version 3.21.0). + This module is part of the `netbox.netbox collection `_ (version 3.22.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -451,6 +451,40 @@ Parameters
+ * - .. raw:: html + +
+
+ + .. _ansible_collections.netbox.netbox.netbox_module_bay_module__parameter-headers: + + .. rst-class:: ansible-option-title + + **headers** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`dictionary` + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Dictionary of headers to be passed to the NetBox API. + + + .. raw:: html + +
+ * - .. raw:: html
diff --git a/docs/plugins/netbox_module_module.rst b/docs/plugins/netbox_module_module.rst index 8d18846be..647f9fa93 100644 --- a/docs/plugins/netbox_module_module.rst +++ b/docs/plugins/netbox_module_module.rst @@ -6,7 +6,7 @@ :trim: .. meta:: - :antsibull-docs: 2.13.1 + :antsibull-docs: 2.16.2 .. Anchors @@ -22,7 +22,7 @@ netbox.netbox.netbox_module module -- Create, update or delete module within Net .. Collection note .. note:: - This module is part of the `netbox.netbox collection `_ (version 3.21.0). + This module is part of the `netbox.netbox collection `_ (version 3.22.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -590,6 +590,40 @@ Parameters
+ * - .. raw:: html + +
+
+ + .. _ansible_collections.netbox.netbox.netbox_module_module__parameter-headers: + + .. rst-class:: ansible-option-title + + **headers** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`dictionary` + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Dictionary of headers to be passed to the NetBox API. + + + .. raw:: html + +
+ * - .. raw:: html
diff --git a/docs/plugins/netbox_module_type_module.rst b/docs/plugins/netbox_module_type_module.rst index 407a3e7d4..b574f2efa 100644 --- a/docs/plugins/netbox_module_type_module.rst +++ b/docs/plugins/netbox_module_type_module.rst @@ -6,7 +6,7 @@ :trim: .. meta:: - :antsibull-docs: 2.13.1 + :antsibull-docs: 2.16.2 .. Anchors @@ -22,7 +22,7 @@ netbox.netbox.netbox_module_type module -- Create, update or delete module types .. Collection note .. note:: - This module is part of the `netbox.netbox collection `_ (version 3.21.0). + This module is part of the `netbox.netbox collection `_ (version 3.22.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -506,6 +506,40 @@ Parameters
+ * - .. raw:: html + +
+
+ + .. _ansible_collections.netbox.netbox.netbox_module_type_module__parameter-headers: + + .. rst-class:: ansible-option-title + + **headers** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`dictionary` + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Dictionary of headers to be passed to the NetBox API. + + + .. raw:: html + +
+ * - .. raw:: html
diff --git a/docs/plugins/netbox_permission_module.rst b/docs/plugins/netbox_permission_module.rst index d9ceac667..53841a81a 100644 --- a/docs/plugins/netbox_permission_module.rst +++ b/docs/plugins/netbox_permission_module.rst @@ -6,7 +6,7 @@ :trim: .. meta:: - :antsibull-docs: 2.13.1 + :antsibull-docs: 2.16.2 .. Anchors @@ -22,7 +22,7 @@ netbox.netbox.netbox_permission module -- Creates or removes permissions from Ne .. Collection note .. note:: - This module is part of the `netbox.netbox collection `_ (version 3.21.0). + This module is part of the `netbox.netbox collection `_ (version 3.22.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -417,6 +417,40 @@ Parameters
+ * - .. raw:: html + +
+
+ + .. _ansible_collections.netbox.netbox.netbox_permission_module__parameter-headers: + + .. rst-class:: ansible-option-title + + **headers** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`dictionary` + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Dictionary of headers to be passed to the NetBox API. + + + .. raw:: html + +
+ * - .. raw:: html
diff --git a/docs/plugins/netbox_platform_module.rst b/docs/plugins/netbox_platform_module.rst index e4fe416d3..b74b007c4 100644 --- a/docs/plugins/netbox_platform_module.rst +++ b/docs/plugins/netbox_platform_module.rst @@ -6,7 +6,7 @@ :trim: .. meta:: - :antsibull-docs: 2.13.1 + :antsibull-docs: 2.16.2 .. Anchors @@ -22,7 +22,7 @@ netbox.netbox.netbox_platform module -- Create or delete platforms within NetBox .. Collection note .. note:: - This module is part of the `netbox.netbox collection `_ (version 3.21.0). + This module is part of the `netbox.netbox collection `_ (version 3.22.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -546,6 +546,40 @@ Parameters
+ * - .. raw:: html + +
+
+ + .. _ansible_collections.netbox.netbox.netbox_platform_module__parameter-headers: + + .. rst-class:: ansible-option-title + + **headers** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`dictionary` + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Dictionary of headers to be passed to the NetBox API. + + + .. raw:: html + +
+ * - .. raw:: html
@@ -782,7 +816,7 @@ Examples config_template: "my_config_template_slug" state: present - - name: Create platform within NetBox with only required information + - name: Create platform within NetBox with more information netbox.netbox.netbox_platform: netbox_url: http://netbox.local netbox_token: thisIsMyToken diff --git a/docs/plugins/netbox_power_feed_module.rst b/docs/plugins/netbox_power_feed_module.rst index 8ab877df3..8c0840159 100644 --- a/docs/plugins/netbox_power_feed_module.rst +++ b/docs/plugins/netbox_power_feed_module.rst @@ -6,7 +6,7 @@ :trim: .. meta:: - :antsibull-docs: 2.13.1 + :antsibull-docs: 2.16.2 .. Anchors @@ -22,7 +22,7 @@ netbox.netbox.netbox_power_feed module -- Create, update or delete power feeds w .. Collection note .. note:: - This module is part of the `netbox.netbox collection `_ (version 3.21.0). + This module is part of the `netbox.netbox collection `_ (version 3.22.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -782,6 +782,40 @@ Parameters
+ * - .. raw:: html + +
+
+ + .. _ansible_collections.netbox.netbox.netbox_power_feed_module__parameter-headers: + + .. rst-class:: ansible-option-title + + **headers** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`dictionary` + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Dictionary of headers to be passed to the NetBox API. + + + .. raw:: html + +
+ * - .. raw:: html
diff --git a/docs/plugins/netbox_power_outlet_module.rst b/docs/plugins/netbox_power_outlet_module.rst index 805ce3e40..83f13727a 100644 --- a/docs/plugins/netbox_power_outlet_module.rst +++ b/docs/plugins/netbox_power_outlet_module.rst @@ -6,7 +6,7 @@ :trim: .. meta:: - :antsibull-docs: 2.13.1 + :antsibull-docs: 2.16.2 .. Anchors @@ -22,7 +22,7 @@ netbox.netbox.netbox_power_outlet module -- Create, update or delete power outle .. Collection note .. note:: - This module is part of the `netbox.netbox collection `_ (version 3.21.0). + This module is part of the `netbox.netbox collection `_ (version 3.22.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -566,6 +566,40 @@ Parameters
+ * - .. raw:: html + +
+
+ + .. _ansible_collections.netbox.netbox.netbox_power_outlet_module__parameter-headers: + + .. rst-class:: ansible-option-title + + **headers** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`dictionary` + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Dictionary of headers to be passed to the NetBox API. + + + .. raw:: html + +
+ * - .. raw:: html
diff --git a/docs/plugins/netbox_power_outlet_template_module.rst b/docs/plugins/netbox_power_outlet_template_module.rst index 1af7a360f..657d1b998 100644 --- a/docs/plugins/netbox_power_outlet_template_module.rst +++ b/docs/plugins/netbox_power_outlet_template_module.rst @@ -6,7 +6,7 @@ :trim: .. meta:: - :antsibull-docs: 2.13.1 + :antsibull-docs: 2.16.2 .. Anchors @@ -22,7 +22,7 @@ netbox.netbox.netbox_power_outlet_template module -- Create, update or delete po .. Collection note .. note:: - This module is part of the `netbox.netbox collection `_ (version 3.21.0). + This module is part of the `netbox.netbox collection `_ (version 3.22.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -437,6 +437,40 @@ Parameters
+ * - .. raw:: html + +
+
+ + .. _ansible_collections.netbox.netbox.netbox_power_outlet_template_module__parameter-headers: + + .. rst-class:: ansible-option-title + + **headers** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`dictionary` + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Dictionary of headers to be passed to the NetBox API. + + + .. raw:: html + +
+ * - .. raw:: html
diff --git a/docs/plugins/netbox_power_panel_module.rst b/docs/plugins/netbox_power_panel_module.rst index af5744340..5712fc505 100644 --- a/docs/plugins/netbox_power_panel_module.rst +++ b/docs/plugins/netbox_power_panel_module.rst @@ -6,7 +6,7 @@ :trim: .. meta:: - :antsibull-docs: 2.13.1 + :antsibull-docs: 2.16.2 .. Anchors @@ -22,7 +22,7 @@ netbox.netbox.netbox_power_panel module -- Create, update or delete power panels .. Collection note .. note:: - This module is part of the `netbox.netbox collection `_ (version 3.21.0). + This module is part of the `netbox.netbox collection `_ (version 3.22.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -510,6 +510,40 @@ Parameters
+ * - .. raw:: html + +
+
+ + .. _ansible_collections.netbox.netbox.netbox_power_panel_module__parameter-headers: + + .. rst-class:: ansible-option-title + + **headers** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`dictionary` + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Dictionary of headers to be passed to the NetBox API. + + + .. raw:: html + +
+ * - .. raw:: html
diff --git a/docs/plugins/netbox_power_port_module.rst b/docs/plugins/netbox_power_port_module.rst index ed03eda68..b1e0824ea 100644 --- a/docs/plugins/netbox_power_port_module.rst +++ b/docs/plugins/netbox_power_port_module.rst @@ -6,7 +6,7 @@ :trim: .. meta:: - :antsibull-docs: 2.13.1 + :antsibull-docs: 2.16.2 .. Anchors @@ -22,7 +22,7 @@ netbox.netbox.netbox_power_port module -- Create, update or delete power ports w .. Collection note .. note:: - This module is part of the `netbox.netbox collection `_ (version 3.21.0). + This module is part of the `netbox.netbox collection `_ (version 3.22.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -602,6 +602,40 @@ Parameters
+ * - .. raw:: html + +
+
+ + .. _ansible_collections.netbox.netbox.netbox_power_port_module__parameter-headers: + + .. rst-class:: ansible-option-title + + **headers** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`dictionary` + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Dictionary of headers to be passed to the NetBox API. + + + .. raw:: html + +
+ * - .. raw:: html
diff --git a/docs/plugins/netbox_power_port_template_module.rst b/docs/plugins/netbox_power_port_template_module.rst index d73e76009..6f49779da 100644 --- a/docs/plugins/netbox_power_port_template_module.rst +++ b/docs/plugins/netbox_power_port_template_module.rst @@ -6,7 +6,7 @@ :trim: .. meta:: - :antsibull-docs: 2.13.1 + :antsibull-docs: 2.16.2 .. Anchors @@ -22,7 +22,7 @@ netbox.netbox.netbox_power_port_template module -- Create, update or delete powe .. Collection note .. note:: - This module is part of the `netbox.netbox collection `_ (version 3.21.0). + This module is part of the `netbox.netbox collection `_ (version 3.22.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -522,6 +522,40 @@ Parameters
+ * - .. raw:: html + +
+
+ + .. _ansible_collections.netbox.netbox.netbox_power_port_template_module__parameter-headers: + + .. rst-class:: ansible-option-title + + **headers** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`dictionary` + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Dictionary of headers to be passed to the NetBox API. + + + .. raw:: html + +
+ * - .. raw:: html
diff --git a/docs/plugins/netbox_prefix_module.rst b/docs/plugins/netbox_prefix_module.rst index 97ea0bb65..1a96ad84b 100644 --- a/docs/plugins/netbox_prefix_module.rst +++ b/docs/plugins/netbox_prefix_module.rst @@ -6,7 +6,7 @@ :trim: .. meta:: - :antsibull-docs: 2.13.1 + :antsibull-docs: 2.16.2 .. Anchors @@ -22,7 +22,7 @@ netbox.netbox.netbox_prefix module -- Creates or removes prefixes from NetBox .. Collection note .. note:: - This module is part of the `netbox.netbox collection `_ (version 3.21.0). + This module is part of the `netbox.netbox collection `_ (version 3.22.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -993,6 +993,40 @@ Parameters - :ansible-option-choices-entry:`true` + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. _ansible_collections.netbox.netbox.netbox_prefix_module__parameter-headers: + + .. rst-class:: ansible-option-title + + **headers** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`dictionary` + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Dictionary of headers to be passed to the NetBox API. + + .. raw:: html
@@ -1216,7 +1250,7 @@ Examples gather_facts: false tasks: - - name: Create prefix within NetBox with only required information + - name: Create prefix within NetBox with only required information before deleting it netbox.netbox.netbox_prefix: netbox_url: http://netbox.local netbox_token: thisIsMyToken diff --git a/docs/plugins/netbox_provider_module.rst b/docs/plugins/netbox_provider_module.rst index 8f5a02ee7..57e3ae41f 100644 --- a/docs/plugins/netbox_provider_module.rst +++ b/docs/plugins/netbox_provider_module.rst @@ -6,7 +6,7 @@ :trim: .. meta:: - :antsibull-docs: 2.13.1 + :antsibull-docs: 2.16.2 .. Anchors @@ -22,7 +22,7 @@ netbox.netbox.netbox_provider module -- Create, update or delete providers withi .. Collection note .. note:: - This module is part of the `netbox.netbox collection `_ (version 3.21.0). + This module is part of the `netbox.netbox collection `_ (version 3.22.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -580,6 +580,40 @@ Parameters
+ * - .. raw:: html + +
+
+ + .. _ansible_collections.netbox.netbox.netbox_provider_module__parameter-headers: + + .. rst-class:: ansible-option-title + + **headers** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`dictionary` + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Dictionary of headers to be passed to the NetBox API. + + + .. raw:: html + +
+ * - .. raw:: html
diff --git a/docs/plugins/netbox_provider_network_module.rst b/docs/plugins/netbox_provider_network_module.rst index 1f3c2e60c..d36882fb7 100644 --- a/docs/plugins/netbox_provider_network_module.rst +++ b/docs/plugins/netbox_provider_network_module.rst @@ -6,7 +6,7 @@ :trim: .. meta:: - :antsibull-docs: 2.13.1 + :antsibull-docs: 2.16.2 .. Anchors @@ -22,7 +22,7 @@ netbox.netbox.netbox_provider_network module -- Create, update or delete provide .. Collection note .. note:: - This module is part of the `netbox.netbox collection `_ (version 3.21.0). + This module is part of the `netbox.netbox collection `_ (version 3.22.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -454,6 +454,40 @@ Parameters
+ * - .. raw:: html + +
+
+ + .. _ansible_collections.netbox.netbox.netbox_provider_network_module__parameter-headers: + + .. rst-class:: ansible-option-title + + **headers** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`dictionary` + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Dictionary of headers to be passed to the NetBox API. + + + .. raw:: html + +
+ * - .. raw:: html
diff --git a/docs/plugins/netbox_rack_group_module.rst b/docs/plugins/netbox_rack_group_module.rst index 2543aa22c..f62dfaabe 100644 --- a/docs/plugins/netbox_rack_group_module.rst +++ b/docs/plugins/netbox_rack_group_module.rst @@ -6,7 +6,7 @@ :trim: .. meta:: - :antsibull-docs: 2.13.1 + :antsibull-docs: 2.16.2 .. Anchors @@ -22,7 +22,7 @@ netbox.netbox.netbox_rack_group module -- Create, update or delete racks groups .. Collection note .. note:: - This module is part of the `netbox.netbox collection `_ (version 3.21.0). + This module is part of the `netbox.netbox collection `_ (version 3.22.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -285,6 +285,40 @@ Parameters
+ * - .. raw:: html + +
+
+ + .. _ansible_collections.netbox.netbox.netbox_rack_group_module__parameter-headers: + + .. rst-class:: ansible-option-title + + **headers** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`dictionary` + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Dictionary of headers to be passed to the NetBox API. + + + .. raw:: html + +
+ * - .. raw:: html
diff --git a/docs/plugins/netbox_rack_module.rst b/docs/plugins/netbox_rack_module.rst index ca93b984f..e62d3b038 100644 --- a/docs/plugins/netbox_rack_module.rst +++ b/docs/plugins/netbox_rack_module.rst @@ -6,7 +6,7 @@ :trim: .. meta:: - :antsibull-docs: 2.13.1 + :antsibull-docs: 2.16.2 .. Anchors @@ -22,7 +22,7 @@ netbox.netbox.netbox_rack module -- Create, update or delete racks within NetBox .. Collection note .. note:: - This module is part of the `netbox.netbox collection `_ (version 3.21.0). + This module is part of the `netbox.netbox collection `_ (version 3.22.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -1274,6 +1274,40 @@ Parameters
+ * - .. raw:: html + +
+
+ + .. _ansible_collections.netbox.netbox.netbox_rack_module__parameter-headers: + + .. rst-class:: ansible-option-title + + **headers** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`dictionary` + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Dictionary of headers to be passed to the NetBox API. + + + .. raw:: html + +
+ * - .. raw:: html
diff --git a/docs/plugins/netbox_rack_role_module.rst b/docs/plugins/netbox_rack_role_module.rst index 10be4d7f2..45d3429f2 100644 --- a/docs/plugins/netbox_rack_role_module.rst +++ b/docs/plugins/netbox_rack_role_module.rst @@ -6,7 +6,7 @@ :trim: .. meta:: - :antsibull-docs: 2.13.1 + :antsibull-docs: 2.16.2 .. Anchors @@ -22,7 +22,7 @@ netbox.netbox.netbox_rack_role module -- Create, update or delete racks roles wi .. Collection note .. note:: - This module is part of the `netbox.netbox collection `_ (version 3.21.0). + This module is part of the `netbox.netbox collection `_ (version 3.22.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -420,6 +420,40 @@ Parameters
+ * - .. raw:: html + +
+
+ + .. _ansible_collections.netbox.netbox.netbox_rack_role_module__parameter-headers: + + .. rst-class:: ansible-option-title + + **headers** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`dictionary` + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Dictionary of headers to be passed to the NetBox API. + + + .. raw:: html + +
+ * - .. raw:: html
diff --git a/docs/plugins/netbox_rear_port_module.rst b/docs/plugins/netbox_rear_port_module.rst index cc61be20a..ffa13dbec 100644 --- a/docs/plugins/netbox_rear_port_module.rst +++ b/docs/plugins/netbox_rear_port_module.rst @@ -6,7 +6,7 @@ :trim: .. meta:: - :antsibull-docs: 2.13.1 + :antsibull-docs: 2.16.2 .. Anchors @@ -22,7 +22,7 @@ netbox.netbox.netbox_rear_port module -- Create, update or delete rear ports wit .. Collection note .. note:: - This module is part of the `netbox.netbox collection `_ (version 3.21.0). + This module is part of the `netbox.netbox collection `_ (version 3.22.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -474,6 +474,40 @@ Parameters
+ * - .. raw:: html + +
+
+ + .. _ansible_collections.netbox.netbox.netbox_rear_port_module__parameter-headers: + + .. rst-class:: ansible-option-title + + **headers** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`dictionary` + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Dictionary of headers to be passed to the NetBox API. + + + .. raw:: html + +
+ * - .. raw:: html
diff --git a/docs/plugins/netbox_rear_port_template_module.rst b/docs/plugins/netbox_rear_port_template_module.rst index c0ab2909f..7377c5c78 100644 --- a/docs/plugins/netbox_rear_port_template_module.rst +++ b/docs/plugins/netbox_rear_port_template_module.rst @@ -6,7 +6,7 @@ :trim: .. meta:: - :antsibull-docs: 2.13.1 + :antsibull-docs: 2.16.2 .. Anchors @@ -22,7 +22,7 @@ netbox.netbox.netbox_rear_port_template module -- Create, update or delete rear .. Collection note .. note:: - This module is part of the `netbox.netbox collection `_ (version 3.21.0). + This module is part of the `netbox.netbox collection `_ (version 3.22.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -435,6 +435,40 @@ Parameters
+ * - .. raw:: html + +
+
+ + .. _ansible_collections.netbox.netbox.netbox_rear_port_template_module__parameter-headers: + + .. rst-class:: ansible-option-title + + **headers** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`dictionary` + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Dictionary of headers to be passed to the NetBox API. + + + .. raw:: html + +
+ * - .. raw:: html
diff --git a/docs/plugins/netbox_region_module.rst b/docs/plugins/netbox_region_module.rst index 687c47b9f..d32c616d4 100644 --- a/docs/plugins/netbox_region_module.rst +++ b/docs/plugins/netbox_region_module.rst @@ -6,7 +6,7 @@ :trim: .. meta:: - :antsibull-docs: 2.13.1 + :antsibull-docs: 2.16.2 .. Anchors @@ -22,7 +22,7 @@ netbox.netbox.netbox_region module -- Creates or removes regions from NetBox .. Collection note .. note:: - This module is part of the `netbox.netbox collection `_ (version 3.21.0). + This module is part of the `netbox.netbox collection `_ (version 3.22.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -420,6 +420,40 @@ Parameters
+ * - .. raw:: html + +
+
+ + .. _ansible_collections.netbox.netbox.netbox_region_module__parameter-headers: + + .. rst-class:: ansible-option-title + + **headers** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`dictionary` + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Dictionary of headers to be passed to the NetBox API. + + + .. raw:: html + +
+ * - .. raw:: html
diff --git a/docs/plugins/netbox_rir_module.rst b/docs/plugins/netbox_rir_module.rst index a346175c1..d3c212885 100644 --- a/docs/plugins/netbox_rir_module.rst +++ b/docs/plugins/netbox_rir_module.rst @@ -6,7 +6,7 @@ :trim: .. meta:: - :antsibull-docs: 2.13.1 + :antsibull-docs: 2.16.2 .. Anchors @@ -22,7 +22,7 @@ netbox.netbox.netbox_rir module -- Create, update or delete RIRs within NetBox .. Collection note .. note:: - This module is part of the `netbox.netbox collection `_ (version 3.21.0). + This module is part of the `netbox.netbox collection `_ (version 3.22.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -425,6 +425,40 @@ Parameters
+ * - .. raw:: html + +
+
+ + .. _ansible_collections.netbox.netbox.netbox_rir_module__parameter-headers: + + .. rst-class:: ansible-option-title + + **headers** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`dictionary` + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Dictionary of headers to be passed to the NetBox API. + + + .. raw:: html + +
+ * - .. raw:: html
diff --git a/docs/plugins/netbox_route_target_module.rst b/docs/plugins/netbox_route_target_module.rst index 96222414d..f3a05067b 100644 --- a/docs/plugins/netbox_route_target_module.rst +++ b/docs/plugins/netbox_route_target_module.rst @@ -6,7 +6,7 @@ :trim: .. meta:: - :antsibull-docs: 2.13.1 + :antsibull-docs: 2.16.2 .. Anchors @@ -22,7 +22,7 @@ netbox.netbox.netbox_route_target module -- Creates or removes route targets fro .. Collection note .. note:: - This module is part of the `netbox.netbox collection `_ (version 3.21.0). + This module is part of the `netbox.netbox collection `_ (version 3.22.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -412,6 +412,40 @@ Parameters
+ * - .. raw:: html + +
+
+ + .. _ansible_collections.netbox.netbox.netbox_route_target_module__parameter-headers: + + .. rst-class:: ansible-option-title + + **headers** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`dictionary` + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Dictionary of headers to be passed to the NetBox API. + + + .. raw:: html + +
+ * - .. raw:: html
diff --git a/docs/plugins/netbox_service_module.rst b/docs/plugins/netbox_service_module.rst index 006952fca..85b701215 100644 --- a/docs/plugins/netbox_service_module.rst +++ b/docs/plugins/netbox_service_module.rst @@ -6,7 +6,7 @@ :trim: .. meta:: - :antsibull-docs: 2.13.1 + :antsibull-docs: 2.16.2 .. Anchors @@ -22,7 +22,7 @@ netbox.netbox.netbox_service module -- Creates or removes service from NetBox .. Collection note .. note:: - This module is part of the `netbox.netbox collection `_ (version 3.21.0). + This module is part of the `netbox.netbox collection `_ (version 3.22.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -622,6 +622,40 @@ Parameters
+ * - .. raw:: html + +
+
+ + .. _ansible_collections.netbox.netbox.netbox_service_module__parameter-headers: + + .. rst-class:: ansible-option-title + + **headers** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`dictionary` + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Dictionary of headers to be passed to the NetBox API. + + + .. raw:: html + +
+ * - .. raw:: html
diff --git a/docs/plugins/netbox_service_template_module.rst b/docs/plugins/netbox_service_template_module.rst index 720b5d6d7..75f38c24b 100644 --- a/docs/plugins/netbox_service_template_module.rst +++ b/docs/plugins/netbox_service_template_module.rst @@ -6,7 +6,7 @@ :trim: .. meta:: - :antsibull-docs: 2.13.1 + :antsibull-docs: 2.16.2 .. Anchors @@ -22,7 +22,7 @@ netbox.netbox.netbox_service_template module -- Create, update or delete service .. Collection note .. note:: - This module is part of the `netbox.netbox collection `_ (version 3.21.0). + This module is part of the `netbox.netbox collection `_ (version 3.22.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -460,6 +460,40 @@ Parameters
+ * - .. raw:: html + +
+
+ + .. _ansible_collections.netbox.netbox.netbox_service_template_module__parameter-headers: + + .. rst-class:: ansible-option-title + + **headers** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`dictionary` + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Dictionary of headers to be passed to the NetBox API. + + + .. raw:: html + +
+ * - .. raw:: html
diff --git a/docs/plugins/netbox_site_group_module.rst b/docs/plugins/netbox_site_group_module.rst index 93fcae45c..237f4fa2f 100644 --- a/docs/plugins/netbox_site_group_module.rst +++ b/docs/plugins/netbox_site_group_module.rst @@ -6,7 +6,7 @@ :trim: .. meta:: - :antsibull-docs: 2.13.1 + :antsibull-docs: 2.16.2 .. Anchors @@ -22,7 +22,7 @@ netbox.netbox.netbox_site_group module -- Create, update, or delete site groups .. Collection note .. note:: - This module is part of the `netbox.netbox collection `_ (version 3.21.0). + This module is part of the `netbox.netbox collection `_ (version 3.22.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -417,6 +417,40 @@ Parameters
+ * - .. raw:: html + +
+
+ + .. _ansible_collections.netbox.netbox.netbox_site_group_module__parameter-headers: + + .. rst-class:: ansible-option-title + + **headers** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`dictionary` + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Dictionary of headers to be passed to the NetBox API. + + + .. raw:: html + +
+ * - .. raw:: html
diff --git a/docs/plugins/netbox_site_module.rst b/docs/plugins/netbox_site_module.rst index ede638e82..f74437c07 100644 --- a/docs/plugins/netbox_site_module.rst +++ b/docs/plugins/netbox_site_module.rst @@ -6,7 +6,7 @@ :trim: .. meta:: - :antsibull-docs: 2.13.1 + :antsibull-docs: 2.16.2 .. Anchors @@ -22,7 +22,7 @@ netbox.netbox.netbox_site module -- Creates or removes sites from NetBox .. Collection note .. note:: - This module is part of the `netbox.netbox collection `_ (version 3.21.0). + This module is part of the `netbox.netbox collection `_ (version 3.22.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -1000,6 +1000,40 @@ Parameters
+ * - .. raw:: html + +
+
+ + .. _ansible_collections.netbox.netbox.netbox_site_module__parameter-headers: + + .. rst-class:: ansible-option-title + + **headers** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`dictionary` + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Dictionary of headers to be passed to the NetBox API. + + + .. raw:: html + +
+ * - .. raw:: html
diff --git a/docs/plugins/netbox_tag_module.rst b/docs/plugins/netbox_tag_module.rst index 5784e8f96..b8dc792b5 100644 --- a/docs/plugins/netbox_tag_module.rst +++ b/docs/plugins/netbox_tag_module.rst @@ -6,7 +6,7 @@ :trim: .. meta:: - :antsibull-docs: 2.13.1 + :antsibull-docs: 2.16.2 .. Anchors @@ -22,7 +22,7 @@ netbox.netbox.netbox_tag module -- Creates or removes tags from NetBox .. Collection note .. note:: - This module is part of the `netbox.netbox collection `_ (version 3.21.0). + This module is part of the `netbox.netbox collection `_ (version 3.22.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -278,6 +278,48 @@ Parameters Tag name + .. raw:: html + +
+ + * - .. raw:: html + +
+
+ + .. raw:: latex + + \hspace{0.02\textwidth}\begin{minipage}[t]{0.3\textwidth} + + .. _ansible_collections.netbox.netbox.netbox_tag_module__parameter-data/object_types: + + .. rst-class:: ansible-option-title + + **object_types** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`list` / :ansible-option-elements:`elements=any` + + .. raw:: html + +
+ + .. raw:: latex + + \end{minipage} + + - .. raw:: html + +
+ + Objects types using the tag + + .. raw:: html
@@ -327,6 +369,40 @@ Parameters + * - .. raw:: html + +
+
+ + .. _ansible_collections.netbox.netbox.netbox_tag_module__parameter-headers: + + .. rst-class:: ansible-option-title + + **headers** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`dictionary` + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Dictionary of headers to be passed to the NetBox API. + + + .. raw:: html + +
+ * - .. raw:: html
@@ -567,6 +643,15 @@ Examples - mgmt - tun + - name: Restrict object types + netbox.netbox.netbox_tag: + netbox_url: http://netbox.local + netbox_token: thisIsMyToken + data: + name: "MyTag" + object_types: + - dcim.prefix + .. Facts diff --git a/docs/plugins/netbox_tenant_group_module.rst b/docs/plugins/netbox_tenant_group_module.rst index a87e62dfa..c017cbde8 100644 --- a/docs/plugins/netbox_tenant_group_module.rst +++ b/docs/plugins/netbox_tenant_group_module.rst @@ -6,7 +6,7 @@ :trim: .. meta:: - :antsibull-docs: 2.13.1 + :antsibull-docs: 2.16.2 .. Anchors @@ -22,7 +22,7 @@ netbox.netbox.netbox_tenant_group module -- Creates or removes tenant groups fro .. Collection note .. note:: - This module is part of the `netbox.netbox collection `_ (version 3.21.0). + This module is part of the `netbox.netbox collection `_ (version 3.22.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -415,6 +415,40 @@ Parameters
+ * - .. raw:: html + +
+
+ + .. _ansible_collections.netbox.netbox.netbox_tenant_group_module__parameter-headers: + + .. rst-class:: ansible-option-title + + **headers** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`dictionary` + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Dictionary of headers to be passed to the NetBox API. + + + .. raw:: html + +
+ * - .. raw:: html
diff --git a/docs/plugins/netbox_tenant_module.rst b/docs/plugins/netbox_tenant_module.rst index 959150eae..e6ffe339e 100644 --- a/docs/plugins/netbox_tenant_module.rst +++ b/docs/plugins/netbox_tenant_module.rst @@ -6,7 +6,7 @@ :trim: .. meta:: - :antsibull-docs: 2.13.1 + :antsibull-docs: 2.16.2 .. Anchors @@ -22,7 +22,7 @@ netbox.netbox.netbox_tenant module -- Creates or removes tenants from NetBox .. Collection note .. note:: - This module is part of the `netbox.netbox collection `_ (version 3.21.0). + This module is part of the `netbox.netbox collection `_ (version 3.22.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -451,6 +451,40 @@ Parameters
+ * - .. raw:: html + +
+
+ + .. _ansible_collections.netbox.netbox.netbox_tenant_module__parameter-headers: + + .. rst-class:: ansible-option-title + + **headers** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`dictionary` + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Dictionary of headers to be passed to the NetBox API. + + + .. raw:: html + +
+ * - .. raw:: html
diff --git a/docs/plugins/netbox_token_module.rst b/docs/plugins/netbox_token_module.rst index fad31cb9e..9eb859d9b 100644 --- a/docs/plugins/netbox_token_module.rst +++ b/docs/plugins/netbox_token_module.rst @@ -6,7 +6,7 @@ :trim: .. meta:: - :antsibull-docs: 2.13.1 + :antsibull-docs: 2.16.2 .. Anchors @@ -22,7 +22,7 @@ netbox.netbox.netbox_token module -- Creates or removes tokens from NetBox .. Collection note .. note:: - This module is part of the `netbox.netbox collection `_ (version 3.21.0). + This module is part of the `netbox.netbox collection `_ (version 3.22.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -375,6 +375,40 @@ Parameters
+ * - .. raw:: html + +
+
+ + .. _ansible_collections.netbox.netbox.netbox_token_module__parameter-headers: + + .. rst-class:: ansible-option-title + + **headers** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`dictionary` + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Dictionary of headers to be passed to the NetBox API. + + + .. raw:: html + +
+ * - .. raw:: html
diff --git a/docs/plugins/netbox_tunnel_group_module.rst b/docs/plugins/netbox_tunnel_group_module.rst index 324b954e3..4882b0494 100644 --- a/docs/plugins/netbox_tunnel_group_module.rst +++ b/docs/plugins/netbox_tunnel_group_module.rst @@ -6,7 +6,7 @@ :trim: .. meta:: - :antsibull-docs: 2.13.1 + :antsibull-docs: 2.16.2 .. Anchors @@ -22,7 +22,7 @@ netbox.netbox.netbox_tunnel_group module -- Create, update or delete tunnel grou .. Collection note .. note:: - This module is part of the `netbox.netbox collection `_ (version 3.21.0). + This module is part of the `netbox.netbox collection `_ (version 3.22.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -369,6 +369,40 @@ Parameters
+ * - .. raw:: html + +
+
+ + .. _ansible_collections.netbox.netbox.netbox_tunnel_group_module__parameter-headers: + + .. rst-class:: ansible-option-title + + **headers** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`dictionary` + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Dictionary of headers to be passed to the NetBox API. + + + .. raw:: html + +
+ * - .. raw:: html
diff --git a/docs/plugins/netbox_tunnel_module.rst b/docs/plugins/netbox_tunnel_module.rst index 0ddce6d3f..ce67c2a31 100644 --- a/docs/plugins/netbox_tunnel_module.rst +++ b/docs/plugins/netbox_tunnel_module.rst @@ -6,7 +6,7 @@ :trim: .. meta:: - :antsibull-docs: 2.13.1 + :antsibull-docs: 2.16.2 .. Anchors @@ -22,7 +22,7 @@ netbox.netbox.netbox_tunnel module -- Create, update or delete tunnels within Ne .. Collection note .. note:: - This module is part of the `netbox.netbox collection `_ (version 3.21.0). + This module is part of the `netbox.netbox collection `_ (version 3.22.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -629,6 +629,40 @@ Parameters
+ * - .. raw:: html + +
+
+ + .. _ansible_collections.netbox.netbox.netbox_tunnel_module__parameter-headers: + + .. rst-class:: ansible-option-title + + **headers** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`dictionary` + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Dictionary of headers to be passed to the NetBox API. + + + .. raw:: html + +
+ * - .. raw:: html
diff --git a/docs/plugins/netbox_user_group_module.rst b/docs/plugins/netbox_user_group_module.rst index 54a152138..1c5ffce63 100644 --- a/docs/plugins/netbox_user_group_module.rst +++ b/docs/plugins/netbox_user_group_module.rst @@ -6,7 +6,7 @@ :trim: .. meta:: - :antsibull-docs: 2.13.1 + :antsibull-docs: 2.16.2 .. Anchors @@ -22,7 +22,7 @@ netbox.netbox.netbox_user_group module -- Creates or removes user groups from Ne .. Collection note .. note:: - This module is part of the `netbox.netbox collection `_ (version 3.21.0). + This module is part of the `netbox.netbox collection `_ (version 3.22.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -283,6 +283,40 @@ Parameters
+ * - .. raw:: html + +
+
+ + .. _ansible_collections.netbox.netbox.netbox_user_group_module__parameter-headers: + + .. rst-class:: ansible-option-title + + **headers** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`dictionary` + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Dictionary of headers to be passed to the NetBox API. + + + .. raw:: html + +
+ * - .. raw:: html
diff --git a/docs/plugins/netbox_user_module.rst b/docs/plugins/netbox_user_module.rst index 06fb79389..6d3d94fd4 100644 --- a/docs/plugins/netbox_user_module.rst +++ b/docs/plugins/netbox_user_module.rst @@ -6,7 +6,7 @@ :trim: .. meta:: - :antsibull-docs: 2.13.1 + :antsibull-docs: 2.16.2 .. Anchors @@ -22,7 +22,7 @@ netbox.netbox.netbox_user module -- Creates or removes users from NetBox .. Collection note .. note:: - This module is part of the `netbox.netbox collection `_ (version 3.21.0). + This module is part of the `netbox.netbox collection `_ (version 3.22.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -551,6 +551,40 @@ Parameters
+ * - .. raw:: html + +
+
+ + .. _ansible_collections.netbox.netbox.netbox_user_module__parameter-headers: + + .. rst-class:: ansible-option-title + + **headers** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`dictionary` + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Dictionary of headers to be passed to the NetBox API. + + + .. raw:: html + +
+ * - .. raw:: html
diff --git a/docs/plugins/netbox_virtual_chassis_module.rst b/docs/plugins/netbox_virtual_chassis_module.rst index 14148e8b9..694bcbb94 100644 --- a/docs/plugins/netbox_virtual_chassis_module.rst +++ b/docs/plugins/netbox_virtual_chassis_module.rst @@ -6,7 +6,7 @@ :trim: .. meta:: - :antsibull-docs: 2.13.1 + :antsibull-docs: 2.16.2 .. Anchors @@ -22,7 +22,7 @@ netbox.netbox.netbox_virtual_chassis module -- Create, update or delete virtual .. Collection note .. note:: - This module is part of the `netbox.netbox collection `_ (version 3.21.0). + This module is part of the `netbox.netbox collection `_ (version 3.22.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -457,6 +457,40 @@ Parameters
+ * - .. raw:: html + +
+
+ + .. _ansible_collections.netbox.netbox.netbox_virtual_chassis_module__parameter-headers: + + .. rst-class:: ansible-option-title + + **headers** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`dictionary` + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Dictionary of headers to be passed to the NetBox API. + + + .. raw:: html + +
+ * - .. raw:: html
diff --git a/docs/plugins/netbox_virtual_disk_module.rst b/docs/plugins/netbox_virtual_disk_module.rst index 8807c3394..4f15d10bc 100644 --- a/docs/plugins/netbox_virtual_disk_module.rst +++ b/docs/plugins/netbox_virtual_disk_module.rst @@ -6,7 +6,7 @@ :trim: .. meta:: - :antsibull-docs: 2.13.1 + :antsibull-docs: 2.16.2 .. Anchors @@ -22,7 +22,7 @@ netbox.netbox.netbox_virtual_disk module -- Creates or removes disks from virtua .. Collection note .. note:: - This module is part of the `netbox.netbox collection `_ (version 3.21.0). + This module is part of the `netbox.netbox collection `_ (version 3.22.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -409,6 +409,40 @@ Parameters
+ * - .. raw:: html + +
+
+ + .. _ansible_collections.netbox.netbox.netbox_virtual_disk_module__parameter-headers: + + .. rst-class:: ansible-option-title + + **headers** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`dictionary` + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Dictionary of headers to be passed to the NetBox API. + + + .. raw:: html + +
+ * - .. raw:: html
diff --git a/docs/plugins/netbox_virtual_machine_module.rst b/docs/plugins/netbox_virtual_machine_module.rst index d953f259e..461a2253d 100644 --- a/docs/plugins/netbox_virtual_machine_module.rst +++ b/docs/plugins/netbox_virtual_machine_module.rst @@ -6,7 +6,7 @@ :trim: .. meta:: - :antsibull-docs: 2.13.1 + :antsibull-docs: 2.16.2 .. Anchors @@ -22,7 +22,7 @@ netbox.netbox.netbox_virtual_machine module -- Create, update or delete virtual\ .. Collection note .. note:: - This module is part of the `netbox.netbox collection `_ (version 3.21.0). + This module is part of the `netbox.netbox collection `_ (version 3.22.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -1009,6 +1009,40 @@ Parameters
+ * - .. raw:: html + +
+
+ + .. _ansible_collections.netbox.netbox.netbox_virtual_machine_module__parameter-headers: + + .. rst-class:: ansible-option-title + + **headers** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`dictionary` + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Dictionary of headers to be passed to the NetBox API. + + + .. raw:: html + +
+ * - .. raw:: html
@@ -1343,17 +1377,17 @@ Common return values are documented :ref:`here `, the foll * - .. raw:: html
-
+
- .. _ansible_collections.netbox.netbox.netbox_virtual_machine_module__return-virtual machine: + .. _ansible_collections.netbox.netbox.netbox_virtual_machine_module__return-virtual_machine: .. rst-class:: ansible-option-title - **virtual machine** + **virtual_machine** .. raw:: html - + .. ansible-option-type-line:: diff --git a/docs/plugins/netbox_vlan_group_module.rst b/docs/plugins/netbox_vlan_group_module.rst index ff8a56055..03f3ba245 100644 --- a/docs/plugins/netbox_vlan_group_module.rst +++ b/docs/plugins/netbox_vlan_group_module.rst @@ -6,7 +6,7 @@ :trim: .. meta:: - :antsibull-docs: 2.13.1 + :antsibull-docs: 2.16.2 .. Anchors @@ -22,7 +22,7 @@ netbox.netbox.netbox_vlan_group module -- Create, update or delete vlans groups .. Collection note .. note:: - This module is part of the `netbox.netbox collection `_ (version 3.21.0). + This module is part of the `netbox.netbox collection `_ (version 3.22.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -660,6 +660,40 @@ Parameters
+ * - .. raw:: html + +
+
+ + .. _ansible_collections.netbox.netbox.netbox_vlan_group_module__parameter-headers: + + .. rst-class:: ansible-option-title + + **headers** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`dictionary` + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Dictionary of headers to be passed to the NetBox API. + + + .. raw:: html + +
+ * - .. raw:: html
diff --git a/docs/plugins/netbox_vlan_module.rst b/docs/plugins/netbox_vlan_module.rst index d375b1928..0b7dfb8aa 100644 --- a/docs/plugins/netbox_vlan_module.rst +++ b/docs/plugins/netbox_vlan_module.rst @@ -6,7 +6,7 @@ :trim: .. meta:: - :antsibull-docs: 2.13.1 + :antsibull-docs: 2.16.2 .. Anchors @@ -22,7 +22,7 @@ netbox.netbox.netbox_vlan module -- Create, update or delete vlans within NetBox .. Collection note .. note:: - This module is part of the `netbox.netbox collection `_ (version 3.21.0). + This module is part of the `netbox.netbox collection `_ (version 3.22.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -622,6 +622,40 @@ Parameters
+ * - .. raw:: html + +
+
+ + .. _ansible_collections.netbox.netbox.netbox_vlan_module__parameter-headers: + + .. rst-class:: ansible-option-title + + **headers** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`dictionary` + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Dictionary of headers to be passed to the NetBox API. + + + .. raw:: html + +
+ * - .. raw:: html
diff --git a/docs/plugins/netbox_vm_interface_module.rst b/docs/plugins/netbox_vm_interface_module.rst index fb73c1208..20e678f04 100644 --- a/docs/plugins/netbox_vm_interface_module.rst +++ b/docs/plugins/netbox_vm_interface_module.rst @@ -6,7 +6,7 @@ :trim: .. meta:: - :antsibull-docs: 2.13.1 + :antsibull-docs: 2.16.2 .. Anchors @@ -22,7 +22,7 @@ netbox.netbox.netbox_vm_interface module -- Creates or removes interfaces from v .. Collection note .. note:: - This module is part of the `netbox.netbox collection `_ (version 3.21.0). + This module is part of the `netbox.netbox collection `_ (version 3.22.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -807,6 +807,40 @@ Parameters
+ * - .. raw:: html + +
+
+ + .. _ansible_collections.netbox.netbox.netbox_vm_interface_module__parameter-headers: + + .. rst-class:: ansible-option-title + + **headers** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`dictionary` + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Dictionary of headers to be passed to the NetBox API. + + + .. raw:: html + +
+ * - .. raw:: html
diff --git a/docs/plugins/netbox_vrf_module.rst b/docs/plugins/netbox_vrf_module.rst index ebc9158ca..f75fca61f 100644 --- a/docs/plugins/netbox_vrf_module.rst +++ b/docs/plugins/netbox_vrf_module.rst @@ -6,7 +6,7 @@ :trim: .. meta:: - :antsibull-docs: 2.13.1 + :antsibull-docs: 2.16.2 .. Anchors @@ -22,7 +22,7 @@ netbox.netbox.netbox_vrf module -- Create, update or delete vrfs within NetBox .. Collection note .. note:: - This module is part of the `netbox.netbox collection `_ (version 3.21.0). + This module is part of the `netbox.netbox collection `_ (version 3.22.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -594,6 +594,40 @@ Parameters
+ * - .. raw:: html + +
+
+ + .. _ansible_collections.netbox.netbox.netbox_vrf_module__parameter-headers: + + .. rst-class:: ansible-option-title + + **headers** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`dictionary` + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Dictionary of headers to be passed to the NetBox API. + + + .. raw:: html + +
+ * - .. raw:: html
diff --git a/docs/plugins/netbox_webhook_module.rst b/docs/plugins/netbox_webhook_module.rst index b090575b4..e9337d183 100644 --- a/docs/plugins/netbox_webhook_module.rst +++ b/docs/plugins/netbox_webhook_module.rst @@ -6,7 +6,7 @@ :trim: .. meta:: - :antsibull-docs: 2.13.1 + :antsibull-docs: 2.16.2 .. Anchors @@ -22,7 +22,7 @@ netbox.netbox.netbox_webhook module -- Creates, updates or deletes webhook confi .. Collection note .. note:: - This module is part of the `netbox.netbox collection `_ (version 3.21.0). + This module is part of the `netbox.netbox collection `_ (version 3.22.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -831,6 +831,40 @@ Parameters
+ * - .. raw:: html + +
+
+ + .. _ansible_collections.netbox.netbox.netbox_webhook_module__parameter-headers: + + .. rst-class:: ansible-option-title + + **headers** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`dictionary` + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Dictionary of headers to be passed to the NetBox API. + + + .. raw:: html + +
+ * - .. raw:: html
diff --git a/docs/plugins/netbox_wireless_lan_group_module.rst b/docs/plugins/netbox_wireless_lan_group_module.rst index edbfeb752..3ff6acb41 100644 --- a/docs/plugins/netbox_wireless_lan_group_module.rst +++ b/docs/plugins/netbox_wireless_lan_group_module.rst @@ -6,7 +6,7 @@ :trim: .. meta:: - :antsibull-docs: 2.13.1 + :antsibull-docs: 2.16.2 .. Anchors @@ -22,7 +22,7 @@ netbox.netbox.netbox_wireless_lan_group module -- Creates or removes Wireless LA .. Collection note .. note:: - This module is part of the `netbox.netbox collection `_ (version 3.21.0). + This module is part of the `netbox.netbox collection `_ (version 3.22.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -409,6 +409,40 @@ Parameters
+ * - .. raw:: html + +
+
+ + .. _ansible_collections.netbox.netbox.netbox_wireless_lan_group_module__parameter-headers: + + .. rst-class:: ansible-option-title + + **headers** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`dictionary` + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Dictionary of headers to be passed to the NetBox API. + + + .. raw:: html + +
+ * - .. raw:: html
diff --git a/docs/plugins/netbox_wireless_lan_module.rst b/docs/plugins/netbox_wireless_lan_module.rst index deaecc04b..92b68243f 100644 --- a/docs/plugins/netbox_wireless_lan_module.rst +++ b/docs/plugins/netbox_wireless_lan_module.rst @@ -6,7 +6,7 @@ :trim: .. meta:: - :antsibull-docs: 2.13.1 + :antsibull-docs: 2.16.2 .. Anchors @@ -22,7 +22,7 @@ netbox.netbox.netbox_wireless_lan module -- Creates or removes Wireless LANs fro .. Collection note .. note:: - This module is part of the `netbox.netbox collection `_ (version 3.21.0). + This module is part of the `netbox.netbox collection `_ (version 3.22.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -641,6 +641,40 @@ Parameters
+ * - .. raw:: html + +
+
+ + .. _ansible_collections.netbox.netbox.netbox_wireless_lan_module__parameter-headers: + + .. rst-class:: ansible-option-title + + **headers** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`dictionary` + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Dictionary of headers to be passed to the NetBox API. + + + .. raw:: html + +
+ * - .. raw:: html
diff --git a/docs/plugins/netbox_wireless_link_module.rst b/docs/plugins/netbox_wireless_link_module.rst index 7e875577c..5ec51d4de 100644 --- a/docs/plugins/netbox_wireless_link_module.rst +++ b/docs/plugins/netbox_wireless_link_module.rst @@ -6,7 +6,7 @@ :trim: .. meta:: - :antsibull-docs: 2.13.1 + :antsibull-docs: 2.16.2 .. Anchors @@ -22,7 +22,7 @@ netbox.netbox.netbox_wireless_link module -- Creates or removes Wireless links f .. Collection note .. note:: - This module is part of the `netbox.netbox collection `_ (version 3.21.0). + This module is part of the `netbox.netbox collection `_ (version 3.22.0). It is not included in ``ansible-core``. To check whether it is installed, run :code:`ansible-galaxy collection list`. @@ -650,6 +650,40 @@ Parameters
+ * - .. raw:: html + +
+
+ + .. _ansible_collections.netbox.netbox.netbox_wireless_link_module__parameter-headers: + + .. rst-class:: ansible-option-title + + **headers** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`dictionary` + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Dictionary of headers to be passed to the NetBox API. + + + .. raw:: html + +
+ * - .. raw:: html
diff --git a/galaxy.yml b/galaxy.yml index 3bc6ec1cb..6a1df5eae 100644 --- a/galaxy.yml +++ b/galaxy.yml @@ -10,7 +10,7 @@ namespace: netbox name: netbox # The version of the collection. Must be compatible with semantic versioning -version: 3.21.0 +version: 3.22.0 # The path to the Markdown (.md) readme file. This path is relative to the root of the collection readme: README.md diff --git a/hacking/local-test.sh b/hacking/local-test.sh index 642dc30f0..dc532b6ac 100755 --- a/hacking/local-test.sh +++ b/hacking/local-test.sh @@ -1,13 +1,30 @@ #!/usr/bin/env bash # Usage: ./hacking/local-test.sh +set -euo pipefail + +# shellcheck disable=SC2317 +cleanup_tests() { + popd >/dev/null 2>&1 || true + rm -rf "${COLLECTION_TMP_DIR}/ansible_collections" +} + +: "${COLLECTION_TMP_DIR:=.}" # Run build, which will remove previously installed versions ./hacking/build.sh # Install new built version -ansible-galaxy collection install netbox-netbox-*.tar.gz -p . +ansible-galaxy collection install netbox-netbox-*.tar.gz \ + --force \ + --collections-path "$COLLECTION_TMP_DIR" + + +trap cleanup_tests EXIT INT TERM # You can now cd into the installed version and run tests -(cd ansible_collections/netbox/netbox/ && ansible-test units -v --python 3.10 && ansible-test sanity --requirements -v --python 3.10 --skip-test pep8 plugins/) -rm -rf ansible_collections +mkdir -p "${COLLECTION_TMP_DIR}" +pushd "${COLLECTION_TMP_DIR}/ansible_collections/netbox/netbox/" >/dev/null || exit 1 +ansible-test units -v --python 3.13 +ansible-test sanity --requirements -v --python 3.13 --skip-test pep8 plugins/ + diff --git a/plugins/doc_fragments/common.py b/plugins/doc_fragments/common.py index 47a7895d9..4bb63c73e 100644 --- a/plugins/doc_fragments/common.py +++ b/plugins/doc_fragments/common.py @@ -50,4 +50,8 @@ class ModuleDocFragment(object): - Certificate path required: false type: raw + headers: + description: Dictionary of headers to be passed to the NetBox API. + required: false + type: dict """ diff --git a/plugins/inventory/nb_inventory.py b/plugins/inventory/nb_inventory.py index b06d0fa7f..dd9d7dca5 100644 --- a/plugins/inventory/nb_inventory.py +++ b/plugins/inventory/nb_inventory.py @@ -325,8 +325,8 @@ - prefix: status key: status.value -# For use in Ansible Tower (AWX), please see this blog from RedHat: https://www.ansible.com/blog/using-an-inventory-plugin-from-a-collection-in-ansible-tower -# The credential for NetBox will need to expose NETBOX_API and NETBOX_TOKEN as environment variables. +# For use in Ansible Tower (AWX) the credential for NetBox will need to expose NETBOX_API +# and NETBOX_TOKEN as environment variables. # Example Ansible Tower credential Input Configuration: fields: @@ -406,7 +406,8 @@ from ansible.module_utils.urls import open_url from ansible.module_utils.six.moves.urllib import error as urllib_error from ansible.module_utils.six.moves.urllib.parse import urlencode -from ansible.module_utils.six import raise_from +from ansible.module_utils.six.moves.urllib.parse import urlparse + try: from packaging import specifiers, version @@ -1148,19 +1149,19 @@ def refresh_prefixes(self): # Pull all prefixes defined in NetBox url = self.api_endpoint + "/api/ipam/prefixes" - if self.fetch_all: - prefixes = self.get_resource_list(url) - else: - prefixes = self.get_resource_list_chunked( - api_url=url, - query_key="site", - query_values=list(self.sites_with_prefixes), - ) + prefixes = self.get_resource_list(url) self.prefixes_sites_lookup = defaultdict(list) # We are only concerned with Prefixes that have actually been assigned to sites for prefix in prefixes: - if prefix.get("site"): + # NetBox >=4.2 + if ( + prefix.get("scope_type") == "dcim.site" + and prefix.get("scope") is not None + ): + self.prefixes_sites_lookup[prefix["scope"]["id"]].append(prefix) + # NetBox <=4.1 + elif prefix.get("site"): self.prefixes_sites_lookup[prefix["site"]["id"]].append(prefix) # Remove "site" attribute, as it's redundant when prefixes are assigned to site del prefix["site"] @@ -1326,6 +1327,15 @@ def refresh_services(self): if self.fetch_all: services = self.get_resource_list(url) + elif self.api_version >= version.parse("4.3.0"): + services = self.get_resource_list_chunked( + api_url=url, + query_key="parent_object_id", + # Query only affected devices and vms and sanitize the list to only contain every ID once + query_values=set( + chain(self.vms_lookup.keys(), self.devices_lookup.keys()) + ), + ) else: device_services = self.get_resource_list_chunked( api_url=url, @@ -1347,15 +1357,26 @@ def refresh_services(self): for service in services: service_id = service["id"] - if service.get("device"): - self.device_services_lookup[service["device"]["id"]][ - service_id - ] = service + if self.api_version >= version.parse("4.3.0"): + if service.get("parent_object_type") == "dcim.device": + self.device_services_lookup[service["parent_object_id"]][ + service_id + ] = service - if service.get("virtual_machine"): - self.vm_services_lookup[service["virtual_machine"]["id"]][ - service_id - ] = service + if service.get("parent_object_type") == "virtualization.virtualmachine": + self.vm_services_lookup[service["parent_object_id"]][ + service_id + ] = service + else: + if service.get("device"): + self.device_services_lookup[service["device"]["id"]][ + service_id + ] = service + + if service.get("virtual_machine"): + self.vm_services_lookup[service["virtual_machine"]["id"]][ + service_id + ] = service def refresh_virtual_disks(self): url_vm_virtual_disks = ( @@ -1627,28 +1648,34 @@ def fetch_api_docs(self): pass self.api_version = version.parse(netbox_api_version) + parsed_endpoint_url = urlparse(self.api_endpoint) + base_path = parsed_endpoint_url.path if self.api_version >= version.parse("3.5.0"): self.allowed_device_query_parameters = [ p["name"] - for p in openapi["paths"]["/api/dcim/devices/"]["get"]["parameters"] + for p in openapi["paths"][base_path + "/api/dcim/devices/"]["get"][ + "parameters" + ] ] self.allowed_vm_query_parameters = [ p["name"] - for p in openapi["paths"]["/api/virtualization/virtual-machines/"][ - "get" - ]["parameters"] + for p in openapi["paths"][ + base_path + "/api/virtualization/virtual-machines/" + ]["get"]["parameters"] ] else: self.allowed_device_query_parameters = [ p["name"] - for p in openapi["paths"]["/dcim/devices/"]["get"]["parameters"] + for p in openapi["paths"][base_path + "/dcim/devices/"]["get"][ + "parameters" + ] ] self.allowed_vm_query_parameters = [ p["name"] - for p in openapi["paths"]["/virtualization/virtual-machines/"]["get"][ - "parameters" - ] + for p in openapi["paths"][ + base_path + "/virtualization/virtual-machines/" + ]["get"]["parameters"] ] def validate_query_parameter(self, parameter, allowed_query_parameters): @@ -2016,10 +2043,9 @@ def _get_host_virtual_chassis_master(self, host): def main(self): # Check if pytz lib is install, and give error if not if PYTZ_IMPORT_ERROR: - raise_from( - AnsibleError("pytz must be installed to use this plugin"), - PYTZ_IMPORT_ERROR, - ) + raise AnsibleError( + "pytz must be installed to use this plugin" + ) from PYTZ_IMPORT_ERROR # Get info about the API - version, allowed query parameters self.fetch_api_docs() diff --git a/plugins/lookup/nb_lookup.py b/plugins/lookup/nb_lookup.py index a3bd0422f..1d88a458a 100644 --- a/plugins/lookup/nb_lookup.py +++ b/plugins/lookup/nb_lookup.py @@ -134,7 +134,6 @@ from ansible.plugins.lookup import LookupBase from ansible.parsing.splitter import parse_kv, split_args from ansible.utils.display import Display -from ansible.module_utils.six import raise_from from importlib.metadata import version try: @@ -328,6 +327,9 @@ def get_endpoint(netbox, term): } netbox_endpoint_map["l2vpns"] = {"endpoint": netbox.ipam.l2vpns} + if netbox_versiontuple >= (4, 2): + netbox_endpoint_map["mac-addresses"] = {"endpoint": netbox.dcim.mac_addresses} + return netbox_endpoint_map[term]["endpoint"] @@ -410,16 +412,14 @@ class LookupModule(LookupBase): def run(self, terms, variables=None, **kwargs): if PYNETBOX_LIBRARY_IMPORT_ERROR: - raise_from( - AnsibleError("pynetbox must be installed to use this plugin"), - PYNETBOX_LIBRARY_IMPORT_ERROR, - ) + raise AnsibleError( + "pynetbox must be installed to use this plugin" + ) from PYNETBOX_LIBRARY_IMPORT_ERROR if REQUESTS_LIBRARY_IMPORT_ERROR: - raise_from( - AnsibleError("requests must be installed to use this plugin"), - REQUESTS_LIBRARY_IMPORT_ERROR, - ) + raise AnsibleError( + "requests must be installed to use this plugin" + ) from REQUESTS_LIBRARY_IMPORT_ERROR netbox_api_token = ( kwargs.get("token") diff --git a/plugins/module_utils/netbox_core.py b/plugins/module_utils/netbox_core.py new file mode 100644 index 000000000..5361d8d50 --- /dev/null +++ b/plugins/module_utils/netbox_core.py @@ -0,0 +1,84 @@ +# -*- coding: utf-8 -*- +# Copyright: (c) 2025, Daniel Chiquito (@dchiquito) +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +from ansible_collections.netbox.netbox.plugins.module_utils.netbox_utils import ( + NetboxModule, + ENDPOINT_NAME_MAPPING, + SLUG_REQUIRED, +) + +NB_DATA_SOURCES = "data_sources" + + +class NetboxCoreModule(NetboxModule): + def __init__(self, module, endpoint): + super().__init__(module, endpoint) + + def _handle_state_new(self, nb_app, nb_endpoint, endpoint_name, data): + if self.state == "new": + self.nb_object, diff = self._create_netbox_object(nb_endpoint, data) + self.result["msg"] = "%s created" % (endpoint_name) + self.result["changed"] = True + self.result["diff"] = diff + + def run(self): + """ + This function should have all necessary code for endpoints within the application + to create/update/delete the endpoint objects + Supported endpoints: + - data_sources + """ + # Used to dynamically set key when returning results + endpoint_name = ENDPOINT_NAME_MAPPING[self.endpoint] + + self.result = {"changed": False} + + application = self._find_app(self.endpoint) + nb_app = getattr(self.nb, application) + nb_endpoint = getattr(nb_app, self.endpoint) + user_query_params = self.module.params.get("query_params") + + data = self.data + + # Used for msg output + if data.get("name"): + name = data["name"] + elif data.get("slug"): + name = data["slug"] + + if self.endpoint in SLUG_REQUIRED: + if not data.get("slug"): + data["slug"] = self._to_slug(name) + + # Make color params lowercase + if data.get("color"): + data["color"] = data["color"].lower() + + # Handle journal entry + if self.state == "new" and endpoint_name == "journal_entry": + self._handle_state_new(nb_app, nb_endpoint, endpoint_name, data) + else: + object_query_params = self._build_query_params( + endpoint_name, data, user_query_params + ) + self.nb_object = self._nb_endpoint_get( + nb_endpoint, object_query_params, name + ) + + if self.state == "present": + self._ensure_object_exists(nb_endpoint, endpoint_name, name, data) + elif self.state == "absent": + self._ensure_object_absent(endpoint_name, name) + + try: + serialized_object = self.nb_object.serialize() + except AttributeError: + serialized_object = self.nb_object + + self.result.update({endpoint_name: serialized_object}) + + self.module.exit_json(**self.result) diff --git a/plugins/module_utils/netbox_dcim.py b/plugins/module_utils/netbox_dcim.py index ccf1b0fc1..489c52af5 100644 --- a/plugins/module_utils/netbox_dcim.py +++ b/plugins/module_utils/netbox_dcim.py @@ -6,7 +6,6 @@ __metaclass__ = type -from ansible.module_utils.basic import missing_required_lib from ansible_collections.netbox.netbox.plugins.module_utils.netbox_utils import ( NetboxModule, ENDPOINT_NAME_MAPPING, @@ -53,22 +52,9 @@ NB_VIRTUAL_CHASSIS = "virtual_chassis" NB_MAC_ADDRESSES = "mac_addresses" -try: - from packaging.version import Version - - HAS_PACKAGING = True - PACKAGING_IMPORT_ERROR = "" -except ImportError as imp_exc: - PACKAGING_IMPORT_ERROR = imp_exc - HAS_PACKAGING = False - class NetboxDcimModule(NetboxModule): def __init__(self, module, endpoint): - if not HAS_PACKAGING: - module.fail_json( - msg=missing_required_lib("packaging"), exception=PACKAGING_IMPORT_ERROR - ) super().__init__(module, endpoint) def run(self): @@ -128,7 +114,9 @@ def run(self): # Handle rack and form_factor if endpoint_name == "rack": - if Version(self.full_version) >= Version("4.1.0"): + if self._version_check_greater( + self.api_version, "4.1", greater_or_equal=True + ): if "type" in data: data["form_factor"] = self._to_slug(data["type"]) del data["type"] @@ -207,7 +195,9 @@ def run(self): data["color"] = data["color"].lower() if self.endpoint == "cables": - if Version(self.full_version) >= Version("3.0.6"): + if self._version_check_greater( + self.api_version, "3.0", greater_or_equal=True + ): cables = [ nb_endpoint.get( termination_a_type=data["termination_a_type"], @@ -236,7 +226,9 @@ def run(self): else: self._handle_errors(msg="More than one result returned for %s" % (name)) - if Version(self.full_version) >= Version("3.3.0"): + if self._version_check_greater( + self.api_version, "3.3", greater_or_equal=True + ): data["a_terminations"] = [ { "object_id": data.pop("termination_a_id"), diff --git a/plugins/module_utils/netbox_ipam.py b/plugins/module_utils/netbox_ipam.py index 8d1b731f4..a70fe97b1 100644 --- a/plugins/module_utils/netbox_ipam.py +++ b/plugins/module_utils/netbox_ipam.py @@ -62,7 +62,9 @@ def _ensure_ip_in_prefix_present_on_netif( "parent": data["prefix"], } - if not self._version_check_greater(self.version, "2.9", greater_or_equal=True): + if not self._version_check_greater( + self.api_version, "2.9", greater_or_equal=True + ): if not data.get("interface") or not data.get("prefix"): self._handle_errors("A prefix and interface is required") data_intf_key = "interface" @@ -162,6 +164,8 @@ def run(self): - vlans - vlan_groups - vrfs + - services + - service_template """ # Used to dynamically set key when returning results endpoint_name = ENDPOINT_NAME_MAPPING[self.endpoint] @@ -214,6 +218,18 @@ def run(self): if not data.get("slug"): data["slug"] = self._to_slug(name) + if self.endpoint == "services" and self._version_check_greater( + self.api_version, "4.3", greater_or_equal=True + ): + if "device" in data: + data["parent_object_type"] = "dcim.device" + data["parent_object_id"] = data["device"] + del data["device"] + elif "virtual_machine" in data: + data["parent_object_type"] = "virtualization.virtualmachine" + data["parent_object_id"] = data["virtual_machine"] + del data["virtual_machine"] + if self.module.params.get("first_available"): first_available = True else: diff --git a/plugins/module_utils/netbox_tenancy.py b/plugins/module_utils/netbox_tenancy.py index dde8e4819..c0df81ae8 100644 --- a/plugins/module_utils/netbox_tenancy.py +++ b/plugins/module_utils/netbox_tenancy.py @@ -15,14 +15,74 @@ NB_TENANTS = "tenants" NB_TENANT_GROUPS = "tenant_groups" NB_CONTACTS = "contacts" +NB_CONTACT_ASSIGNMENTS = "contact_assignments" NB_CONTACT_GROUPS = "contact_groups" NB_CONTACT_ROLES = "contact_roles" +OBJECT_ENDPOINTS = { + "circuit": "circuits", + "cluster": "clusters", + "cluster_group": "cluster_groups", + "contact": "contacts", + "contact_role": "contact_roles", + "device": "devices", + "location": "locations", + "manufacturer": "manufacturers", + "power_panel": "power_panels", + "provider": "providers", + "rack": "racks", + "region": "regions", + "site": "sites", + "site_group": "site_groups", + "tenant": "tenants", + "virtual_machine": "virtual_machines", +} +# See https://netboxlabs.com/docs/netbox/features/contacts/#contacts-1 +OBJECT_TYPES = { + "circuit": "circuits.circuit", + "cluster": "virtualization.cluster", + "cluster_group": "virtualization.clustergroup", + "device": "dcim.device", + "location": "dcim.location", + "manufacturer": "dcim.manufacturer", + "power_panel": "dcim.powerpanel", + "provider": "circuits.provider", + "rack": "dcim.rack", + "region": "dcim.region", + "site": "dcim.site", + "site_group": "dcim.sitegroup", + "tenant": "tenancy.tenant", + "virtual_machine": "virtualization.virtualmachine", +} +OBJECT_NAME_FIELD = { + "circuit": "cid", + # If unspecified, the default is "name" +} + + class NetboxTenancyModule(NetboxModule): def __init__(self, module, endpoint): super().__init__(module, endpoint) + def get_object_by_name(self, object_type: str, object_name: str): + endpoint = OBJECT_ENDPOINTS[object_type] + app = self._find_app(endpoint) + nb_app = getattr(self.nb, app) + nb_endpoint = getattr(nb_app, endpoint) + + name_field = OBJECT_NAME_FIELD.get(object_type) + if name_field is None: + name_field = "name" + + query_params = {name_field: object_name} + result = self._nb_endpoint_get(nb_endpoint, query_params, object_name) + if not result: + self._handle_errors( + msg="Could not resolve id of %s: %s" % (object_type, object_name) + ) + return result + def run(self): """ This function should have all necessary code for endpoints within the application @@ -31,7 +91,9 @@ def run(self): - tenants - tenant groups - contacts + - contact assignments - contact groups + - contact roles """ # Used to dynamically set key when returning results endpoint_name = ENDPOINT_NAME_MAPPING[self.endpoint] @@ -45,6 +107,41 @@ def run(self): data = self.data + # In Netbox 4.3, Contact.contact_group was changed to contact_groups. + # We need to check that the correct field is being used. + if self.endpoint == NB_CONTACTS: + if data.get("groups"): + if not self._version_check_greater( + self.api_version, "4.3", greater_or_equal=True + ): + raise Exception( + f"contact_groups is not available in Netbox {self.api_version}. Use contact_group instead, or upgrade to Netbox 4.3 or greater." + ) + if data.get("group"): + if self._version_check_greater( + self.api_version, "4.3", greater_or_equal=True + ): + raise Exception( + f"contact_group is not available in Netbox {self.api_version}. Use contact_groups instead." + ) + + # For ease and consistency of use, the contact assignment module takes the name of the contact, role, and target object rather than an ID or slug. + # We must massage the data a bit by looking up the ID corresponding to the given name so that we can pass the ID to the API. + if self.endpoint == NB_CONTACT_ASSIGNMENTS: + # Not an identifier, just to populate the message field + name = f"{data['contact']} -> {data['object_name']}" + + object_type = data["object_type"] + obj = self.get_object_by_name(object_type, data["object_name"]) + contact = self.get_object_by_name("contact", data["contact"]) + role = self.get_object_by_name("contact_role", data["role"]) + + data["object_type"] = OBJECT_TYPES[object_type] + data["object_id"] = obj.id + del data["object_name"] # object_id replaces object_name + data["contact"] = contact.id + data["role"] = role.id + # Used for msg output if data.get("name"): name = data["name"] @@ -58,6 +155,12 @@ def run(self): object_query_params = self._build_query_params( endpoint_name, data, user_query_params ) + + # For some reason, when creating a new contact assignment, role must be an ID + # But when querying contact assignments, the role must be a slug + if self.endpoint == "contact_assignments": + object_query_params["role"] = role.slug + self.nb_object = self._nb_endpoint_get(nb_endpoint, object_query_params, name) if self.state == "present": diff --git a/plugins/module_utils/netbox_users.py b/plugins/module_utils/netbox_users.py index 5d3d2f2a0..d8d2880da 100644 --- a/plugins/module_utils/netbox_users.py +++ b/plugins/module_utils/netbox_users.py @@ -10,12 +10,14 @@ ENDPOINT_NAME_MAPPING, ) -NB_CONFIG = "config" NB_GROUPS = "groups" NB_PERMISSIONS = "permissions" NB_TOKENS = "tokens" NB_USERS = "users" +# These suboptions are lists, but need to be modeled as sets for comparison purposes. +LIST_AS_SET_KEYS = set(["permissions", "groups", "actions", "object_types"]) + class NetboxUsersModule(NetboxModule): def __init__(self, module, endpoint): @@ -26,7 +28,6 @@ def run(self): This function should have all necessary code for endpoints within the application to create/update/delete the endpoint objects Supported endpoints: - - config - groups - permissions - tokens @@ -72,18 +73,27 @@ def run(self): self.module.exit_json(**self.result) def _update_netbox_object(self, data): - if self.endpoint == "users": - return self._update_netbox_user(data) + if self.endpoint == NB_TOKENS: + return self._update_netbox_token(data) else: - if self.endpoint == "tokens" and "key" in data: - del data["key"] - return super()._update_netbox_object(data) + return self.__update_netbox_object__(data) + + def _update_netbox_token(self, data): + if "key" in data: + del data["key"] + return self.__update_netbox_object__(data) - def _update_netbox_user(self, data): + def __update_netbox_object__(self, data): serialized_nb_obj = self.nb_object.serialize() updated_obj = serialized_nb_obj.copy() updated_obj.update(data) + if serialized_nb_obj: + for key in LIST_AS_SET_KEYS: + if serialized_nb_obj.get(key) and data.get(key): + serialized_nb_obj[key] = set(serialized_nb_obj[key]) + updated_obj[key] = set(data[key]) + if serialized_nb_obj == updated_obj: return serialized_nb_obj, None else: diff --git a/plugins/module_utils/netbox_utils.py b/plugins/module_utils/netbox_utils.py index 08a756234..12a3f068e 100644 --- a/plugins/module_utils/netbox_utils.py +++ b/plugins/module_utils/netbox_utils.py @@ -39,6 +39,9 @@ "providers": {}, "provider_networks": {}, }, + core={ + "data_sources": {}, + }, dcim={ "cables": {}, "console_ports": {}, @@ -114,6 +117,7 @@ "tenants": {}, "tenant_groups": {}, "contacts": {}, + "contact_assignments": {}, "contact_groups": {}, "contact_roles": {}, }, @@ -155,7 +159,7 @@ cluster_type="slug", config_context="name", config_template="name", - contact_group="name", + contact_groups="name", contact_role="name", custom_field="name", choice_set="name", @@ -247,7 +251,8 @@ "component": "interfaces", "config_context": "config_contexts", "config_template": "config_templates", - "contact_groups": "contact_groups", + "contact_group": "contact_groups", # Netbox version <4.3 + "contact_groups": "contact_groups", # Netbox version >=4.3 "choice_set": "custom_field_choice_sets", "dcim.consoleport": "console_ports", "dcim.consoleserverport": "console_server_ports", @@ -366,11 +371,13 @@ "console_server_ports": "console_server_port", "console_server_port_templates": "console_server_port_template", "contacts": "contact", + "contact_assignments": "contact_assignment", "contact_groups": "contact_group", "contact_roles": "contact_role", "custom_fields": "custom_field", "custom_field_choice_sets": "choice_set", "custom_links": "custom_link", + "data_sources": "data_source", "device_bays": "device_bay", "device_bay_templates": "device_bay_template", "devices": "device", @@ -476,12 +483,14 @@ "console_server_port": set(["name", "device"]), "console_server_port_template": set(["name", "device_type"]), "contact": set(["name", "group"]), + "contact_assignment": set(["object_type", "object_id", "contact", "role"]), "contact_group": set(["name"]), "contact_role": set(["name"]), "custom_field": set(["name"]), "custom_field_choice_set": set(["name"]), "choice_set": set(["name"]), "custom_link": set(["name"]), + "data_source": set(["name"]), "dcim.consoleport": set(["name", "device"]), "dcim.consoleserverport": set(["name", "device"]), "dcim.frontport": set(["name", "device", "rear_port"]), @@ -558,7 +567,17 @@ "rir": set(["slug"]), "role": set(["slug"]), "route_target": set(["name"]), - "services": set(["device", "virtual_machine", "name", "port", "protocol"]), + "services": set( + [ + "device", + "virtual_machine", + "name", + "port", + "protocol", + "parent_object_type", + "parent_object_id", + ] + ), "service_template": set(["name"]), "site": set(["slug", "name"]), "site_group": set(["slug"]), @@ -613,6 +632,7 @@ "console_port_templates": set(["type"]), "console_server_ports": set(["type"]), "console_server_port_templates": set(["type"]), + "contact_assignments": set(["priority"]), "devices": set(["status", "face"]), "device_types": set(["subdevice_role"]), "front_ports": set(["type"]), @@ -643,7 +663,8 @@ "cluster_type": "type", "cluster_group": "group", "component": "component_id", - "contact_group": "group", + "contact_group": "group", # Netbox version <4.3 + "contact_groups": "groups", # Netbox version >=4.3 "device_role": "role", "fhrp_group": "group", "inventory_item_role": "role", @@ -723,6 +744,7 @@ query_params=dict(required=False, type="list", elements="str"), validate_certs=dict(type="raw", default=True), cert=dict(type="raw", required=False), + headers=dict(type="dict", required=False), ) @@ -751,19 +773,22 @@ def __init__(self, module, endpoint, nb_client=None): token = self.module.params["netbox_token"] ssl_verify = self.module.params["validate_certs"] cert = self.module.params["cert"] + headers = self.module.params["headers"] # Attempt to initiate connection to NetBox if nb_client is None: - self.nb = self._connect_netbox_api(url, token, ssl_verify, cert) + self.nb = self._connect_netbox_api(url, token, ssl_verify, cert, headers) else: self.nb = nb_client try: - self.version = self.nb.version + self.api_version = self._version_sanitize(self.nb.version) try: - self.full_version = self.nb.status().get("netbox-version") + self.netbox_version = self._version_sanitize( + self.nb.status().get("netbox-version") + ) except Exception: # For NetBox versions without /api/status endpoint - self.full_version = f"{self.version}.0" + self.netbox_version = f"{self.api_version}.0" except AttributeError: self.module.fail_json(msg="Must have pynetbox >=4.1.0") @@ -777,48 +802,62 @@ def __init__(self, module, endpoint, nb_client=None): data = self._find_ids(choices_data, query_params) self.data = self._convert_identical_keys(data) - def _version_check_greater(self, greater, lesser, greater_or_equal=False): + @staticmethod + def _version_sanitize(raw_value: str) -> str: + """Return sanitized Netbox version. + Sanitize 4.2.9-Docker-3.2.1 and return only 4.2.9. + """ + if not isinstance(raw_value, str): + raise ValueError(f"Invalid value {raw_value!r}: expected a string") + + version_match = re.match(r"^(\d[\d.]*)", raw_value) + if version_match: + return version_match.group(1).rstrip(".") + + raise ValueError( + f"Invalid version {raw_value!r}: must start with a digit (e.g. '1', '2.5', '4.2.9')" + ) + + def _version_check_greater( + self, greater: str, lesser: str, greater_or_equal=False + ) -> bool: """Determine if first argument is greater than second argument. Args: greater (str): decimal string - lesser (str): decimal string + lesser (str): decimal string """ - g_major, g_minor = greater.split(".") - l_major, l_minor = lesser.split(".") - - # convert to ints - g_major = int(g_major) - g_minor = int(g_minor) - l_major = int(l_major) - l_minor = int(l_minor) - - # If major version is higher then return true right off the bat - if g_major > l_major: - return True - elif greater_or_equal and g_major == l_major and g_minor >= l_minor: - return True - # If major versions are equal, and minor version is higher, return True - elif g_major == l_major and g_minor > l_minor: - return True - - return False - - def _connect_netbox_api(self, url, token, ssl_verify, cert): + t_greater = tuple(int(x) for x in self._version_sanitize(greater).split(".")) + t_lesser = tuple(int(x) for x in self._version_sanitize(lesser).split(".")) + + # Pad shorter tuple with zeros + max_len = max(len(t_greater), len(t_lesser)) + t_greater += (0,) * (max_len - len(t_greater)) + t_lesser += (0,) * (max_len - len(t_lesser)) + + return t_greater > t_lesser if not greater_or_equal else t_greater >= t_lesser + + def _connect_netbox_api(self, url, token, ssl_verify, cert, headers=None): try: session = requests.Session() session.verify = ssl_verify + if isinstance(headers, str): + headers = json.load(headers) + if isinstance(headers, dict): + session.headers.update(headers) if cert: session.cert = tuple(i for i in cert) nb = pynetbox.api(url, token=token) nb.http_session = session try: - self.version = nb.version + self.api_version = self._version_sanitize(nb.version) try: - self.full_version = nb.status().get("netbox-version") + self.netbox_version = self._version_sanitize( + nb.status().get("netbox-version") + ) except Exception: # For NetBox versions without /api/status endpoint - self.full_version = f"{self.version}.0" + self.netbox_version = f"{self.api_version}.0" except AttributeError: self.module.fail_json(msg="Must have pynetbox >=4.1.0") except Exception: @@ -902,7 +941,7 @@ def _convert_identical_keys(self, data): :params data (dict): Data dictionary after _find_ids method ran """ temp_dict = dict() - if self._version_check_greater(self.version, "2.7", greater_or_equal=True): + if self._version_check_greater(self.api_version, "2.7", greater_or_equal=True): if data.get("form_factor"): temp_dict["type"] = data.pop("form_factor") @@ -911,7 +950,7 @@ def _convert_identical_keys(self, data): temp_dict[key] = data[key] # TODO: Remove this once the lowest supported Netbox version is 3.6 or greater as we can use default logic of CONVERT_KEYS moving forward. elif key == "device_role" and not self._version_check_greater( - self.version, "3.6", greater_or_equal=True + self.api_version, "3.6", greater_or_equal=True ): temp_dict[key] = data[key] elif key in CONVERT_KEYS: @@ -1004,7 +1043,7 @@ def _build_query_params( parent == "interface" and "device" in module_data and self._version_check_greater( - self.version, "3.6", greater_or_equal=True + self.api_version, "3.6", greater_or_equal=True ) ): query_dict.update( @@ -1091,7 +1130,7 @@ def _build_query_params( elif parent == "rear_port_template" and self.endpoint == "front_port_templates": if isinstance(module_data.get("rear_port_template"), str): if self._version_check_greater( - self.version, "4.0", greater_or_equal=True + self.api_version, "4.0", greater_or_equal=True ): rear_port_template = { "device_type_id": module_data.get("device_type"), @@ -1118,7 +1157,7 @@ def _build_query_params( ): if isinstance(module_data.get("power_port_template"), str): if self._version_check_greater( - self.version, "4.0", greater_or_equal=True + self.api_version, "4.0", greater_or_equal=True ): power_port_template = { "device_type_id": module_data.get("device_type"), @@ -1153,11 +1192,20 @@ def _build_query_params( elif "_template" in parent: if query_dict.get("device_type"): if self._version_check_greater( - self.version, "4.0", greater_or_equal=True + self.api_version, "4.0", greater_or_equal=True ): query_dict["device_type_id"] = query_dict.pop("device_type") else: query_dict["devicetype_id"] = query_dict.pop("device_type") + # TODO workaround for Netbox 4.3.0 - 4.4.3 - #20554 + # Remove 'elif parent == "services":' block after support for + # Netbox 4.3.0 - 4.4.3 is removed + elif parent == "services": + if self._version_check_greater( + self.api_version, "4.3", greater_or_equal=True + ) and self._version_check_greater("4.4.4", self.netbox_version): + query_dict.pop("parent_object_id", None) + query_dict.pop("parent_object_type", None) if not query_dict: provided_kwargs = child.keys() if child else module_data.keys() @@ -1229,13 +1277,15 @@ def _find_app(self, endpoint): if endpoint in v.keys(): if "introduced" in v[endpoint]: pre_introduction = self._version_check_greater( - v[endpoint]["introduced"], self.version + v[endpoint]["introduced"], self.api_version ) if pre_introduction: continue if "deprecated" in v[endpoint]: after_deprecation = self._version_check_greater( - self.version, v[endpoint]["deprecated"], greater_or_equal=True + self.api_version, + v[endpoint]["deprecated"], + greater_or_equal=True, ) if after_deprecation: continue @@ -1255,7 +1305,7 @@ def _find_ids(self, data, user_query_params): if k in CONVERT_TO_ID: if ( not self._version_check_greater( - self.version, "2.9", greater_or_equal=True + self.api_version, "2.9", greater_or_equal=True ) and k == "tags" ) or (self.endpoint == "config_contexts" and k == "tags"): @@ -1479,7 +1529,7 @@ def _update_netbox_object(self, data): updated_obj["tags"] = set(data["tags"]) # Ensure idempotency for site on older netbox versions - version_pre_30 = self._version_check_greater("3.0", self.version) + version_pre_30 = self._version_check_greater("3.0", self.api_version) if ( serialized_nb_obj.get("latitude") and data.get("latitude") @@ -1494,7 +1544,7 @@ def _update_netbox_object(self, data): updated_obj["longitude"] = str(data["longitude"]) # Ensure idempotency for virtual machine on older netbox versions - version_pre_211 = self._version_check_greater("2.11", self.version) + version_pre_211 = self._version_check_greater("2.11", self.api_version) if serialized_nb_obj.get("vcpus") and data.get("vcpus"): if version_pre_211: updated_obj["vcpus"] = int(data["vcpus"]) @@ -1502,7 +1552,7 @@ def _update_netbox_object(self, data): updated_obj["vcpus"] = float(data["vcpus"]) # Ensure idempotency for cable on netbox versions later than 3.3 - version_post_33 = self._version_check_greater(self.version, "3.3", True) + version_post_33 = self._version_check_greater(self.api_version, "3.3", True) if ( serialized_nb_obj.get("a_terminations") and serialized_nb_obj.get("b_terminations") diff --git a/plugins/modules/netbox_circuit_termination.py b/plugins/modules/netbox_circuit_termination.py index 4a05d62cf..6bf5aec2b 100644 --- a/plugins/modules/netbox_circuit_termination.py +++ b/plugins/modules/netbox_circuit_termination.py @@ -49,14 +49,36 @@ required: false type: bool version_added: 3.5.0 + termination_id: + description: + - The ProviderNetwork, Location, Site, Region, or SiteGroup ID of the circuit termination will be assigned to. + - This parameter is used with NetBox versions >= 4.2.0. + required: false + type: int + version_added: 4.2.0 + termination_type: + description: + - The type the circuit termination will be assigned to. + - This parameter is used with NetBox versions >= 4.2.0. + choices: + - dcim.site + - dcim.location + - dcim.region + - dcim.sitegroup + - circuits.providernetwork + required: false + type: str + version_added: 4.2.0 site: description: - - The site the circuit termination will be assigned to + - The site the circuit termination will be assigned to. + - This parameter is used with NetBox versions before 4.2.0. required: false type: raw provider_network: description: - - The provider_network the circuit termination will be assigned to + - The provider_network the circuit termination will be assigned to. + - This parameter is used with NetBox versions before 4.2.0. required: false type: raw port_speed: @@ -93,7 +115,19 @@ gather_facts: false tasks: - - name: Create circuit termination within NetBox with only required information + - name: Create circuit termination within NetBox version 4.2.0 or later with only required information + netbox.netbox.netbox_circuit_termination: + netbox_url: http://netbox.local + netbox_token: thisIsMyToken + data: + circuit: Test Circuit + term_side: A + termination_id: 1 + termination_type: dcim.site + port_speed: 10000 + state: present + + - name: Create circuit termination within NetBox versions earlier than 4.2.0 with only required information netbox.netbox.netbox_circuit_termination: netbox_url: http://netbox.local netbox_token: thisIsMyToken @@ -163,6 +197,18 @@ def main(): circuit=dict(required=True, type="raw"), term_side=dict(required=True, choices=["A", "Z"]), mark_connected=dict(required=False, type="bool"), + termination_id=dict(required=False, type="int"), + termination_type=dict( + required=False, + type="str", + choices=[ + "dcim.site", + "dcim.location", + "dcim.region", + "dcim.sitegroup", + "circuits.providernetwork", + ], + ), site=dict(required=False, type="raw"), provider_network=dict(required=False, type="raw"), port_speed=dict(required=False, type="int"), @@ -180,8 +226,18 @@ def main(): ("state", "absent", ["circuit", "term_side"]), ] + mutually_exclusive = [ + ("termination_id", "site"), + ("termination_type", "site"), + ("termination_id", "provider_network"), + ("termination_type", "provider_network"), + ] + 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, + mutually_exclusive=mutually_exclusive, ) netbox_circuit_termination = NetboxCircuitsModule(module, NB_CIRCUIT_TERMINATIONS) diff --git a/plugins/modules/netbox_contact.py b/plugins/modules/netbox_contact.py index a89cd59c1..c76a10511 100644 --- a/plugins/modules/netbox_contact.py +++ b/plugins/modules/netbox_contact.py @@ -67,9 +67,15 @@ type: str contact_group: description: - - Group assignment for the contact + - Group that the contact belongs to. Only available in Netbox version <4.3 required: false type: raw + contact_groups: + description: + - Groups that the contact belongs to. Only available in Netbox versions >=4.3 + required: false + type: list + elements: raw link: description: - URL associated with the contact @@ -121,6 +127,9 @@ title: Mr Contact phone: 123456789 email: contac@contact.com + contact_groups: + - Group 1 + - Group 2 tags: - tagA - tagB @@ -169,6 +178,7 @@ def main(): description=dict(required=False, type="str"), comments=dict(required=False, type="str"), contact_group=dict(required=False, type="raw"), + contact_groups=dict(required=False, type="list", elements="raw"), link=dict(required=False, type="str"), tags=dict(required=False, type="list", elements="raw"), custom_fields=dict(required=False, type="dict"), diff --git a/plugins/modules/netbox_contact_assignment.py b/plugins/modules/netbox_contact_assignment.py new file mode 100644 index 000000000..b1896633d --- /dev/null +++ b/plugins/modules/netbox_contact_assignment.py @@ -0,0 +1,196 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +# Copyright: (c) 2025, Daniel Chiquito (@dchiquito) +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +DOCUMENTATION = r""" +--- +module: netbox_contact_assignment +short_description: Creates or removes contact assignments from NetBox +description: + - Creates or removes contact assignments from NetBox +notes: + - Tags should be defined as a YAML list + - This should be ran with connection C(local) and hosts C(localhost) +author: + - Daniel Chiquito (@dchiquito) +requirements: + - pynetbox +version_added: "3.1.0" +extends_documentation_fragment: + - netbox.netbox.common +options: + data: + type: dict + description: + - Defines the contact configuration + suboptions: + object_type: + description: + - The type of the object the contact is assigned to + required: true + type: str + choices: + - circuit + - cluster + - cluster_group + - device + - location + - manufacturer + - power_panel + - provider + - rack + - region + - site + - site_group + - tenant + - virtual_machine + object_name: + description: + - The name of the object the contact is assigned to + required: true + type: str + contact: + description: + - The name of the contact to assign to the object + required: true + type: str + role: + description: + - The name of the role the contact has for this object + required: true + type: str + priority: + description: + - The priority of this contact + required: false + type: str + choices: + - primary + - secondary + - tertiary + - inactive + tags: + description: + - Any tags that the contact may need to be associated with + required: false + type: list + elements: raw + required: true +""" + +EXAMPLES = r""" +- name: "Test NetBox module" + connection: local + hosts: localhost + gather_facts: false + tasks: + - name: Assign a contact to a location with only required information + netbox.netbox.netbox_contact_assignment: + netbox_url: http://netbox.local + netbox_token: thisIsMyToken + data: + object_type: location + object_name: My Location + contact: John Doe + role: Supervisor Role + state: present + + - name: Delete contact assignment within netbox + netbox.netbox.netbox_contact_assignment: + netbox_url: http://netbox.local + netbox_token: thisIsMyToken + data: + object_type: location + object_name: My Location + contact: John Doe + role: Supervisor Role + state: absent + + - name: Create contact with all parameters + netbox.netbox.netbox_contact: + netbox_url: http://netbox.local + netbox_token: thisIsMyToken + data: + object_type: location + object_name: My Location + contact: John Doe + role: Supervisor Role + priority: tertiary + tags: + - tagA + - tagB + - tagC + state: present +""" + +RETURN = r""" +contact_assignment: + description: Serialized object as created or already existent within NetBox + returned: on creation + type: dict +msg: + description: Message indicating failure or info about what has been achieved + returned: always + type: str +""" + +from ansible_collections.netbox.netbox.plugins.module_utils.netbox_utils import ( + NetboxAnsibleModule, + NETBOX_ARG_SPEC, +) +from ansible_collections.netbox.netbox.plugins.module_utils.netbox_tenancy import ( + NetboxTenancyModule, + NB_CONTACT_ASSIGNMENTS, + OBJECT_TYPES, +) +from copy import deepcopy + + +def main(): + """ + Main entry point for module execution + """ + argument_spec = deepcopy(NETBOX_ARG_SPEC) + argument_spec.update( + dict( + data=dict( + type="dict", + required=True, + options=dict( + object_type=dict( + required=True, type="str", choices=list(OBJECT_TYPES.keys()) + ), + object_name=dict(required=True, type="str"), + contact=dict(required=True, type="str"), + role=dict(required=True, type="str"), + priority=dict( + required=False, + type="str", + choices=["primary", "secondary", "tertiary", "inactive"], + ), + tags=dict(required=False, type="list", elements="raw"), + ), + ), + ) + ) + + required_if = [ + ("state", "present", ["object_type", "object_name", "contact", "role"]), + ("state", "absent", ["object_type", "object_name", "contact", "role"]), + ] + + module = NetboxAnsibleModule( + argument_spec=argument_spec, supports_check_mode=True, required_if=required_if + ) + + netbox_contact = NetboxTenancyModule(module, NB_CONTACT_ASSIGNMENTS) + netbox_contact.run() + + +if __name__ == "__main__": # pragma: no cover + main() diff --git a/plugins/modules/netbox_custom_field.py b/plugins/modules/netbox_custom_field.py index 65f0bd9ee..2cbdff36c 100644 --- a/plugins/modules/netbox_custom_field.py +++ b/plugins/modules/netbox_custom_field.py @@ -150,6 +150,11 @@ - The name of the choice set to use (for selection fields) required: false type: str + related_object_filter: + description: + - Filter definition for related object selection. To reset the value, set it to an empty dict (null value is ignored by the API) + required: false + type: dict required: true """ @@ -288,6 +293,7 @@ def main(): required=False, type="str", ), + related_object_filter=dict(required=False, type="dict"), ), ) ) diff --git a/plugins/modules/netbox_data_source.py b/plugins/modules/netbox_data_source.py new file mode 100644 index 000000000..9923e2927 --- /dev/null +++ b/plugins/modules/netbox_data_source.py @@ -0,0 +1,190 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +# Copyright: (c) 2025, Daniel Chiquito (@dchiquito) +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +__metaclass__ = type + +DOCUMENTATION = r""" +--- +module: netbox_data_source +short_description: Creates or removes data sources from NetBox +description: + - Creates or removes data sources from NetBox +author: + - Daniel Chiquito (@dchiquito) +requirements: + - pynetbox +version_added: "3.22.0" +extends_documentation_fragment: + - netbox.netbox.common +options: + data: + type: dict + description: + - Defines the data source configuration + suboptions: + name: + description: + - Name of the data source + required: true + type: str + type: + description: + - The origin of the data source + choices: + - local + - git + - amazon-s3 + required: false + type: str + source_url: + description: + - URL of the data source to be created + required: false + type: str + enabled: + description: + - Whether or not this data source can be synced + required: false + type: bool + description: + description: + - Description of the data source + required: false + type: str + ignore_rules: + description: + - Patterns (one per line) matching files to ignore when syncing + required: false + type: str + sync_interval: + description: + - The interval in seconds between syncs + required: false + choices: + - 1 + - 60 + - 720 + - 1440 + - 10080 + - 43200 + type: int + comments: + description: + - Comments about the data source + required: false + type: str + required: true +""" + +EXAMPLES = r""" +- name: "Test NetBox modules" + connection: local + hosts: localhost + gather_facts: false + + tasks: + - name: "Create a new data source with only required information" + netbox.netbox.netbox_data_source: + netbox_url: http://netbox.local + netbox_token: thisIsMyToken + data: + name: "Data Source 1" + type: "local" + source_url: "/tmp/data-source.txt" + enabled: true + state: present + - name: "Update that data source with other fields" + netbox.netbox.netbox_data_source: + netbox_url: http://netbox.local + netbox_token: thisIsMyToken + data: + name: "Data Source 1" + type: "amazon-s3" + source_url: "path/to/bucket" + enabled: false + description: "My first data source" + ignore_rules: ".*\nfoo.txt\n*.yml" + sync_interval: 1440 + comments: "Some commentary on this data source" + state: present + - name: "Delete the data source" + netbox.netbox.netbox_data_source: + netbox_url: http://netbox.local + netbox_token: thisIsMyToken + data: + name: "Data Source 1" + state: absent +""" + +RETURN = r""" +data_source: + description: Serialized object as created or already existent within NetBox + returned: on creation + type: dict +msg: + description: Message indicating failure or info about what has been achieved + returned: always + type: str +""" + + +from ansible_collections.netbox.netbox.plugins.module_utils.netbox_utils import ( + NetboxAnsibleModule, + NETBOX_ARG_SPEC, +) +from ansible_collections.netbox.netbox.plugins.module_utils.netbox_core import ( + NetboxCoreModule, + NB_DATA_SOURCES, +) +from copy import deepcopy + + +def main(): + """ + Main entry point for module execution + """ + argument_spec = deepcopy(NETBOX_ARG_SPEC) + argument_spec.update( + dict( + data=dict( + type="dict", + required=True, + options=dict( + name=dict(required=True, type="str"), + type=dict( + required=False, + choices=["local", "git", "amazon-s3"], + type="str", + ), + source_url=dict(required=False, type="str"), + enabled=dict(required=False, type="bool"), + description=dict(required=False, type="str"), + ignore_rules=dict(required=False, type="str"), + sync_interval=dict( + required=False, + choices=[1, 60, 60 * 12, 60 * 24, 60 * 24 * 7, 60 * 24 * 30], + type="int", + ), + comments=dict(required=False, type="str"), + ), + ), + ) + ) + + required_if = [ + ("state", "present", ["name", "type", "source_url", "enabled"]), + ("state", "absent", ["name"]), + ] + + module = NetboxAnsibleModule( + argument_spec=argument_spec, supports_check_mode=True, required_if=required_if + ) + + netbox_data_source = NetboxCoreModule(module, NB_DATA_SOURCES) + netbox_data_source.run() + + +if __name__ == "__main__": # pragma: no cover + main() diff --git a/plugins/modules/netbox_device_interface.py b/plugins/modules/netbox_device_interface.py index 42d6e73b8..db45ed7a8 100644 --- a/plugins/modules/netbox_device_interface.py +++ b/plugins/modules/netbox_device_interface.py @@ -90,7 +90,7 @@ description: - The primary MAC address of the interface (NetBox 4.2 and later) required: false - type: str + type: raw wwn: description: - The WWN of the interface @@ -340,7 +340,7 @@ def main(): bridge=dict(required=False, type="raw"), mtu=dict(required=False, type="int"), mac_address=dict(required=False, type="str"), - primary_mac_address=dict(required=False, type="str"), + primary_mac_address=dict(required=False, type="raw"), wwn=dict(required=False, type="str"), mgmt_only=dict(required=False, type="bool"), poe_type=dict(required=False, type="raw"), diff --git a/plugins/modules/netbox_device_type.py b/plugins/modules/netbox_device_type.py index 65c82e6ef..b23d80c8e 100644 --- a/plugins/modules/netbox_device_type.py +++ b/plugins/modules/netbox_device_type.py @@ -150,7 +150,7 @@ manufacturer: Test Manufacturer state: present - - name: Create device type within NetBox with only required information + - name: Create device type within NetBox with more information netbox.netbox.netbox_device_type: netbox_url: http://netbox.local netbox_token: thisIsMyToken diff --git a/plugins/modules/netbox_platform.py b/plugins/modules/netbox_platform.py index 61e37d6b6..26b82fef4 100644 --- a/plugins/modules/netbox_platform.py +++ b/plugins/modules/netbox_platform.py @@ -106,7 +106,7 @@ config_template: "my_config_template_slug" state: present - - name: Create platform within NetBox with only required information + - name: Create platform within NetBox with more information netbox.netbox.netbox_platform: netbox_url: http://netbox.local netbox_token: thisIsMyToken diff --git a/plugins/modules/netbox_prefix.py b/plugins/modules/netbox_prefix.py index f6135381c..901fe89ec 100644 --- a/plugins/modules/netbox_prefix.py +++ b/plugins/modules/netbox_prefix.py @@ -153,7 +153,7 @@ gather_facts: false tasks: - - name: Create prefix within NetBox with only required information + - name: Create prefix within NetBox with only required information before deleting it netbox.netbox.netbox_prefix: netbox_url: http://netbox.local netbox_token: thisIsMyToken diff --git a/plugins/modules/netbox_service.py b/plugins/modules/netbox_service.py index 972127127..1974bc86a 100644 --- a/plugins/modules/netbox_service.py +++ b/plugins/modules/netbox_service.py @@ -179,7 +179,7 @@ def main(): # Change port to ports for 2.10+ and convert to a list with the single integer if netbox_service.data.get("port") and netbox_service._version_check_greater( - netbox_service.version, "2.10", greater_or_equal=True + netbox_service.api_version, "2.10", greater_or_equal=True ): netbox_service.data["ports"] = [netbox_service.data.pop("port")] diff --git a/plugins/modules/netbox_tag.py b/plugins/modules/netbox_tag.py index d429e16a9..3994151b1 100644 --- a/plugins/modules/netbox_tag.py +++ b/plugins/modules/netbox_tag.py @@ -50,6 +50,12 @@ - Tag description required: false type: str + object_types: + description: + - Objects types using the tag + required: false + type: list + elements: raw required: true """ @@ -80,6 +86,15 @@ loop: - mgmt - tun + + - name: Restrict object types + netbox.netbox.netbox_tag: + netbox_url: http://netbox.local + netbox_token: thisIsMyToken + data: + name: "MyTag" + object_types: + - dcim.prefix """ RETURN = r""" @@ -119,6 +134,7 @@ def main(): color=dict(required=False, type="str"), description=dict(required=False, type="str"), slug=dict(required=False, type="str"), + object_types=dict(required=False, type="list", elements="raw"), ), ), ) diff --git a/plugins/modules/netbox_virtual_machine.py b/plugins/modules/netbox_virtual_machine.py index b321cc069..e8a0999da 100644 --- a/plugins/modules/netbox_virtual_machine.py +++ b/plugins/modules/netbox_virtual_machine.py @@ -196,7 +196,7 @@ """ RETURN = r""" -virtual machine: +virtual_machine: description: Serialized object as created or already existent within NetBox returned: success (when I(state=present)) type: dict diff --git a/poetry.lock b/poetry.lock index 9f08f2267..af3b2add2 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,4 +1,4 @@ -# This file is automatically @generated by Poetry 1.8.5 and should not be changed by hand. +# This file is automatically @generated by Poetry 2.2.1 and should not be changed by hand. [[package]] name = "aiofiles" @@ -6,6 +6,7 @@ version = "24.1.0" description = "File support for asyncio." optional = false python-versions = ">=3.8" +groups = ["main"] files = [ {file = "aiofiles-24.1.0-py3-none-any.whl", hash = "sha256:b4ec55f4195e3eb5d7abd1bf7e061763e864dd4954231fb8539a0ef8bb8260e5"}, {file = "aiofiles-24.1.0.tar.gz", hash = "sha256:22a075c9e5a3810f0c2e48f3008c94d68c65d763b9b03857924c99e57355166c"}, @@ -13,103 +14,115 @@ files = [ [[package]] name = "aiohappyeyeballs" -version = "2.4.4" +version = "2.6.1" description = "Happy Eyeballs for asyncio" optional = false -python-versions = ">=3.8" +python-versions = ">=3.9" +groups = ["main"] files = [ - {file = "aiohappyeyeballs-2.4.4-py3-none-any.whl", hash = "sha256:a980909d50efcd44795c4afeca523296716d50cd756ddca6af8c65b996e27de8"}, - {file = "aiohappyeyeballs-2.4.4.tar.gz", hash = "sha256:5fdd7d87889c63183afc18ce9271f9b0a7d32c2303e394468dd45d514a757745"}, + {file = "aiohappyeyeballs-2.6.1-py3-none-any.whl", hash = "sha256:f349ba8f4b75cb25c99c5c2d84e997e485204d2902a9597802b0371f09331fb8"}, + {file = "aiohappyeyeballs-2.6.1.tar.gz", hash = "sha256:c3f9d0113123803ccadfdf3f0faa505bc78e6a72d1cc4806cbd719826e943558"}, ] [[package]] name = "aiohttp" -version = "3.11.11" +version = "3.12.14" description = "Async http client/server framework (asyncio)" optional = false python-versions = ">=3.9" -files = [ - {file = "aiohttp-3.11.11-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:a60804bff28662cbcf340a4d61598891f12eea3a66af48ecfdc975ceec21e3c8"}, - {file = "aiohttp-3.11.11-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:4b4fa1cb5f270fb3eab079536b764ad740bb749ce69a94d4ec30ceee1b5940d5"}, - {file = "aiohttp-3.11.11-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:731468f555656767cda219ab42e033355fe48c85fbe3ba83a349631541715ba2"}, - {file = "aiohttp-3.11.11-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:cb23d8bb86282b342481cad4370ea0853a39e4a32a0042bb52ca6bdde132df43"}, - {file = "aiohttp-3.11.11-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:f047569d655f81cb70ea5be942ee5d4421b6219c3f05d131f64088c73bb0917f"}, - {file = "aiohttp-3.11.11-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:dd7659baae9ccf94ae5fe8bfaa2c7bc2e94d24611528395ce88d009107e00c6d"}, - {file = "aiohttp-3.11.11-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:af01e42ad87ae24932138f154105e88da13ce7d202a6de93fafdafb2883a00ef"}, - {file = "aiohttp-3.11.11-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:5854be2f3e5a729800bac57a8d76af464e160f19676ab6aea74bde18ad19d438"}, - {file = "aiohttp-3.11.11-cp310-cp310-musllinux_1_2_aarch64.whl", hash = "sha256:6526e5fb4e14f4bbf30411216780c9967c20c5a55f2f51d3abd6de68320cc2f3"}, - {file = "aiohttp-3.11.11-cp310-cp310-musllinux_1_2_i686.whl", hash = "sha256:85992ee30a31835fc482468637b3e5bd085fa8fe9392ba0bdcbdc1ef5e9e3c55"}, - {file = "aiohttp-3.11.11-cp310-cp310-musllinux_1_2_ppc64le.whl", hash = "sha256:88a12ad8ccf325a8a5ed80e6d7c3bdc247d66175afedbe104ee2aaca72960d8e"}, - {file = "aiohttp-3.11.11-cp310-cp310-musllinux_1_2_s390x.whl", hash = "sha256:0a6d3fbf2232e3a08c41eca81ae4f1dff3d8f1a30bae415ebe0af2d2458b8a33"}, - {file = "aiohttp-3.11.11-cp310-cp310-musllinux_1_2_x86_64.whl", hash = "sha256:84a585799c58b795573c7fa9b84c455adf3e1d72f19a2bf498b54a95ae0d194c"}, - {file = "aiohttp-3.11.11-cp310-cp310-win32.whl", hash = "sha256:bfde76a8f430cf5c5584553adf9926534352251d379dcb266ad2b93c54a29745"}, - {file = "aiohttp-3.11.11-cp310-cp310-win_amd64.whl", hash = "sha256:0fd82b8e9c383af11d2b26f27a478640b6b83d669440c0a71481f7c865a51da9"}, - {file = "aiohttp-3.11.11-cp311-cp311-macosx_10_9_universal2.whl", hash = "sha256:ba74ec819177af1ef7f59063c6d35a214a8fde6f987f7661f4f0eecc468a8f76"}, - {file = "aiohttp-3.11.11-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:4af57160800b7a815f3fe0eba9b46bf28aafc195555f1824555fa2cfab6c1538"}, - {file = "aiohttp-3.11.11-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:ffa336210cf9cd8ed117011085817d00abe4c08f99968deef0013ea283547204"}, - {file = "aiohttp-3.11.11-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:81b8fe282183e4a3c7a1b72f5ade1094ed1c6345a8f153506d114af5bf8accd9"}, - {file = "aiohttp-3.11.11-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:3af41686ccec6a0f2bdc66686dc0f403c41ac2089f80e2214a0f82d001052c03"}, - {file = "aiohttp-3.11.11-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:70d1f9dde0e5dd9e292a6d4d00058737052b01f3532f69c0c65818dac26dc287"}, - {file = "aiohttp-3.11.11-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:249cc6912405917344192b9f9ea5cd5b139d49e0d2f5c7f70bdfaf6b4dbf3a2e"}, - {file = "aiohttp-3.11.11-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:0eb98d90b6690827dcc84c246811feeb4e1eea683c0eac6caed7549be9c84665"}, - {file = "aiohttp-3.11.11-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:ec82bf1fda6cecce7f7b915f9196601a1bd1a3079796b76d16ae4cce6d0ef89b"}, - {file = "aiohttp-3.11.11-cp311-cp311-musllinux_1_2_i686.whl", hash = "sha256:9fd46ce0845cfe28f108888b3ab17abff84ff695e01e73657eec3f96d72eef34"}, - {file = "aiohttp-3.11.11-cp311-cp311-musllinux_1_2_ppc64le.whl", hash = "sha256:bd176afcf8f5d2aed50c3647d4925d0db0579d96f75a31e77cbaf67d8a87742d"}, - {file = "aiohttp-3.11.11-cp311-cp311-musllinux_1_2_s390x.whl", hash = "sha256:ec2aa89305006fba9ffb98970db6c8221541be7bee4c1d027421d6f6df7d1ce2"}, - {file = "aiohttp-3.11.11-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:92cde43018a2e17d48bb09c79e4d4cb0e236de5063ce897a5e40ac7cb4878773"}, - {file = "aiohttp-3.11.11-cp311-cp311-win32.whl", hash = "sha256:aba807f9569455cba566882c8938f1a549f205ee43c27b126e5450dc9f83cc62"}, - {file = "aiohttp-3.11.11-cp311-cp311-win_amd64.whl", hash = "sha256:ae545f31489548c87b0cced5755cfe5a5308d00407000e72c4fa30b19c3220ac"}, - {file = "aiohttp-3.11.11-cp312-cp312-macosx_10_13_universal2.whl", hash = "sha256:e595c591a48bbc295ebf47cb91aebf9bd32f3ff76749ecf282ea7f9f6bb73886"}, - {file = "aiohttp-3.11.11-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:3ea1b59dc06396b0b424740a10a0a63974c725b1c64736ff788a3689d36c02d2"}, - {file = "aiohttp-3.11.11-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:8811f3f098a78ffa16e0ea36dffd577eb031aea797cbdba81be039a4169e242c"}, - {file = "aiohttp-3.11.11-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:bd7227b87a355ce1f4bf83bfae4399b1f5bb42e0259cb9405824bd03d2f4336a"}, - {file = "aiohttp-3.11.11-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:d40f9da8cabbf295d3a9dae1295c69975b86d941bc20f0a087f0477fa0a66231"}, - {file = "aiohttp-3.11.11-cp312-cp312-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:ffb3dc385f6bb1568aa974fe65da84723210e5d9707e360e9ecb51f59406cd2e"}, - {file = "aiohttp-3.11.11-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:a8f5f7515f3552d899c61202d99dcb17d6e3b0de777900405611cd747cecd1b8"}, - {file = "aiohttp-3.11.11-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:3499c7ffbfd9c6a3d8d6a2b01c26639da7e43d47c7b4f788016226b1e711caa8"}, - {file = "aiohttp-3.11.11-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:8e2bf8029dbf0810c7bfbc3e594b51c4cc9101fbffb583a3923aea184724203c"}, - {file = "aiohttp-3.11.11-cp312-cp312-musllinux_1_2_i686.whl", hash = "sha256:b6212a60e5c482ef90f2d788835387070a88d52cf6241d3916733c9176d39eab"}, - {file = "aiohttp-3.11.11-cp312-cp312-musllinux_1_2_ppc64le.whl", hash = "sha256:d119fafe7b634dbfa25a8c597718e69a930e4847f0b88e172744be24515140da"}, - {file = "aiohttp-3.11.11-cp312-cp312-musllinux_1_2_s390x.whl", hash = "sha256:6fba278063559acc730abf49845d0e9a9e1ba74f85f0ee6efd5803f08b285853"}, - {file = "aiohttp-3.11.11-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:92fc484e34b733704ad77210c7957679c5c3877bd1e6b6d74b185e9320cc716e"}, - {file = "aiohttp-3.11.11-cp312-cp312-win32.whl", hash = "sha256:9f5b3c1ed63c8fa937a920b6c1bec78b74ee09593b3f5b979ab2ae5ef60d7600"}, - {file = "aiohttp-3.11.11-cp312-cp312-win_amd64.whl", hash = "sha256:1e69966ea6ef0c14ee53ef7a3d68b564cc408121ea56c0caa2dc918c1b2f553d"}, - {file = "aiohttp-3.11.11-cp313-cp313-macosx_10_13_universal2.whl", hash = "sha256:541d823548ab69d13d23730a06f97460f4238ad2e5ed966aaf850d7c369782d9"}, - {file = "aiohttp-3.11.11-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:929f3ed33743a49ab127c58c3e0a827de0664bfcda566108989a14068f820194"}, - {file = "aiohttp-3.11.11-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:0882c2820fd0132240edbb4a51eb8ceb6eef8181db9ad5291ab3332e0d71df5f"}, - {file = "aiohttp-3.11.11-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:b63de12e44935d5aca7ed7ed98a255a11e5cb47f83a9fded7a5e41c40277d104"}, - {file = "aiohttp-3.11.11-cp313-cp313-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:aa54f8ef31d23c506910c21163f22b124facb573bff73930735cf9fe38bf7dff"}, - {file = "aiohttp-3.11.11-cp313-cp313-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:a344d5dc18074e3872777b62f5f7d584ae4344cd6006c17ba12103759d407af3"}, - {file = "aiohttp-3.11.11-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:0b7fb429ab1aafa1f48578eb315ca45bd46e9c37de11fe45c7f5f4138091e2f1"}, - {file = "aiohttp-3.11.11-cp313-cp313-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:c341c7d868750e31961d6d8e60ff040fb9d3d3a46d77fd85e1ab8e76c3e9a5c4"}, - {file = "aiohttp-3.11.11-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:ed9ee95614a71e87f1a70bc81603f6c6760128b140bc4030abe6abaa988f1c3d"}, - {file = "aiohttp-3.11.11-cp313-cp313-musllinux_1_2_i686.whl", hash = "sha256:de8d38f1c2810fa2a4f1d995a2e9c70bb8737b18da04ac2afbf3971f65781d87"}, - {file = "aiohttp-3.11.11-cp313-cp313-musllinux_1_2_ppc64le.whl", hash = "sha256:a9b7371665d4f00deb8f32208c7c5e652059b0fda41cf6dbcac6114a041f1cc2"}, - {file = "aiohttp-3.11.11-cp313-cp313-musllinux_1_2_s390x.whl", hash = "sha256:620598717fce1b3bd14dd09947ea53e1ad510317c85dda2c9c65b622edc96b12"}, - {file = "aiohttp-3.11.11-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:bf8d9bfee991d8acc72d060d53860f356e07a50f0e0d09a8dfedea1c554dd0d5"}, - {file = "aiohttp-3.11.11-cp313-cp313-win32.whl", hash = "sha256:9d73ee3725b7a737ad86c2eac5c57a4a97793d9f442599bea5ec67ac9f4bdc3d"}, - {file = "aiohttp-3.11.11-cp313-cp313-win_amd64.whl", hash = "sha256:c7a06301c2fb096bdb0bd25fe2011531c1453b9f2c163c8031600ec73af1cc99"}, - {file = "aiohttp-3.11.11-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:3e23419d832d969f659c208557de4a123e30a10d26e1e14b73431d3c13444c2e"}, - {file = "aiohttp-3.11.11-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:21fef42317cf02e05d3b09c028712e1d73a9606f02467fd803f7c1f39cc59add"}, - {file = "aiohttp-3.11.11-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:1f21bb8d0235fc10c09ce1d11ffbd40fc50d3f08a89e4cf3a0c503dc2562247a"}, - {file = "aiohttp-3.11.11-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:1642eceeaa5ab6c9b6dfeaaa626ae314d808188ab23ae196a34c9d97efb68350"}, - {file = "aiohttp-3.11.11-cp39-cp39-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:2170816e34e10f2fd120f603e951630f8a112e1be3b60963a1f159f5699059a6"}, - {file = "aiohttp-3.11.11-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:8be8508d110d93061197fd2d6a74f7401f73b6d12f8822bbcd6d74f2b55d71b1"}, - {file = "aiohttp-3.11.11-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:4eed954b161e6b9b65f6be446ed448ed3921763cc432053ceb606f89d793927e"}, - {file = "aiohttp-3.11.11-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:d6c9af134da4bc9b3bd3e6a70072509f295d10ee60c697826225b60b9959acdd"}, - {file = "aiohttp-3.11.11-cp39-cp39-musllinux_1_2_aarch64.whl", hash = "sha256:44167fc6a763d534a6908bdb2592269b4bf30a03239bcb1654781adf5e49caf1"}, - {file = "aiohttp-3.11.11-cp39-cp39-musllinux_1_2_i686.whl", hash = "sha256:479b8c6ebd12aedfe64563b85920525d05d394b85f166b7873c8bde6da612f9c"}, - {file = "aiohttp-3.11.11-cp39-cp39-musllinux_1_2_ppc64le.whl", hash = "sha256:10b4ff0ad793d98605958089fabfa350e8e62bd5d40aa65cdc69d6785859f94e"}, - {file = "aiohttp-3.11.11-cp39-cp39-musllinux_1_2_s390x.whl", hash = "sha256:b540bd67cfb54e6f0865ceccd9979687210d7ed1a1cc8c01f8e67e2f1e883d28"}, - {file = "aiohttp-3.11.11-cp39-cp39-musllinux_1_2_x86_64.whl", hash = "sha256:1dac54e8ce2ed83b1f6b1a54005c87dfed139cf3f777fdc8afc76e7841101226"}, - {file = "aiohttp-3.11.11-cp39-cp39-win32.whl", hash = "sha256:568c1236b2fde93b7720f95a890741854c1200fba4a3471ff48b2934d2d93fd3"}, - {file = "aiohttp-3.11.11-cp39-cp39-win_amd64.whl", hash = "sha256:943a8b052e54dfd6439fd7989f67fc6a7f2138d0a2cf0a7de5f18aa4fe7eb3b1"}, - {file = "aiohttp-3.11.11.tar.gz", hash = "sha256:bb49c7f1e6ebf3821a42d81d494f538107610c3a705987f53068546b0e90303e"}, +groups = ["main"] +files = [ + {file = "aiohttp-3.12.14-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:906d5075b5ba0dd1c66fcaaf60eb09926a9fef3ca92d912d2a0bbdbecf8b1248"}, + {file = "aiohttp-3.12.14-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:c875bf6fc2fd1a572aba0e02ef4e7a63694778c5646cdbda346ee24e630d30fb"}, + {file = "aiohttp-3.12.14-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:fbb284d15c6a45fab030740049d03c0ecd60edad9cd23b211d7e11d3be8d56fd"}, + {file = "aiohttp-3.12.14-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:38e360381e02e1a05d36b223ecab7bc4a6e7b5ab15760022dc92589ee1d4238c"}, + {file = "aiohttp-3.12.14-cp310-cp310-manylinux_2_17_armv7l.manylinux2014_armv7l.manylinux_2_31_armv7l.whl", hash = "sha256:aaf90137b5e5d84a53632ad95ebee5c9e3e7468f0aab92ba3f608adcb914fa95"}, + {file = "aiohttp-3.12.14-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:e532a25e4a0a2685fa295a31acf65e027fbe2bea7a4b02cdfbbba8a064577663"}, + {file = "aiohttp-3.12.14-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:eab9762c4d1b08ae04a6c77474e6136da722e34fdc0e6d6eab5ee93ac29f35d1"}, + {file = "aiohttp-3.12.14-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:abe53c3812b2899889a7fca763cdfaeee725f5be68ea89905e4275476ffd7e61"}, + {file = "aiohttp-3.12.14-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:5760909b7080aa2ec1d320baee90d03b21745573780a072b66ce633eb77a8656"}, + {file = "aiohttp-3.12.14-cp310-cp310-musllinux_1_2_aarch64.whl", hash = "sha256:02fcd3f69051467bbaa7f84d7ec3267478c7df18d68b2e28279116e29d18d4f3"}, + {file = "aiohttp-3.12.14-cp310-cp310-musllinux_1_2_armv7l.whl", hash = "sha256:4dcd1172cd6794884c33e504d3da3c35648b8be9bfa946942d353b939d5f1288"}, + {file = "aiohttp-3.12.14-cp310-cp310-musllinux_1_2_i686.whl", hash = "sha256:224d0da41355b942b43ad08101b1b41ce633a654128ee07e36d75133443adcda"}, + {file = "aiohttp-3.12.14-cp310-cp310-musllinux_1_2_ppc64le.whl", hash = "sha256:e387668724f4d734e865c1776d841ed75b300ee61059aca0b05bce67061dcacc"}, + {file = "aiohttp-3.12.14-cp310-cp310-musllinux_1_2_s390x.whl", hash = "sha256:dec9cde5b5a24171e0b0a4ca064b1414950904053fb77c707efd876a2da525d8"}, + {file = "aiohttp-3.12.14-cp310-cp310-musllinux_1_2_x86_64.whl", hash = "sha256:bbad68a2af4877cc103cd94af9160e45676fc6f0c14abb88e6e092b945c2c8e3"}, + {file = "aiohttp-3.12.14-cp310-cp310-win32.whl", hash = "sha256:ee580cb7c00bd857b3039ebca03c4448e84700dc1322f860cf7a500a6f62630c"}, + {file = "aiohttp-3.12.14-cp310-cp310-win_amd64.whl", hash = "sha256:cf4f05b8cea571e2ccc3ca744e35ead24992d90a72ca2cf7ab7a2efbac6716db"}, + {file = "aiohttp-3.12.14-cp311-cp311-macosx_10_9_universal2.whl", hash = "sha256:f4552ff7b18bcec18b60a90c6982049cdb9dac1dba48cf00b97934a06ce2e597"}, + {file = "aiohttp-3.12.14-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:8283f42181ff6ccbcf25acaae4e8ab2ff7e92b3ca4a4ced73b2c12d8cd971393"}, + {file = "aiohttp-3.12.14-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:040afa180ea514495aaff7ad34ec3d27826eaa5d19812730fe9e529b04bb2179"}, + {file = "aiohttp-3.12.14-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:b413c12f14c1149f0ffd890f4141a7471ba4b41234fe4fd4a0ff82b1dc299dbb"}, + {file = "aiohttp-3.12.14-cp311-cp311-manylinux_2_17_armv7l.manylinux2014_armv7l.manylinux_2_31_armv7l.whl", hash = "sha256:1d6f607ce2e1a93315414e3d448b831238f1874b9968e1195b06efaa5c87e245"}, + {file = "aiohttp-3.12.14-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:565e70d03e924333004ed101599902bba09ebb14843c8ea39d657f037115201b"}, + {file = "aiohttp-3.12.14-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:4699979560728b168d5ab63c668a093c9570af2c7a78ea24ca5212c6cdc2b641"}, + {file = "aiohttp-3.12.14-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:ad5fdf6af93ec6c99bf800eba3af9a43d8bfd66dce920ac905c817ef4a712afe"}, + {file = "aiohttp-3.12.14-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:4ac76627c0b7ee0e80e871bde0d376a057916cb008a8f3ffc889570a838f5cc7"}, + {file = "aiohttp-3.12.14-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:798204af1180885651b77bf03adc903743a86a39c7392c472891649610844635"}, + {file = "aiohttp-3.12.14-cp311-cp311-musllinux_1_2_armv7l.whl", hash = "sha256:4f1205f97de92c37dd71cf2d5bcfb65fdaed3c255d246172cce729a8d849b4da"}, + {file = "aiohttp-3.12.14-cp311-cp311-musllinux_1_2_i686.whl", hash = "sha256:76ae6f1dd041f85065d9df77c6bc9c9703da9b5c018479d20262acc3df97d419"}, + {file = "aiohttp-3.12.14-cp311-cp311-musllinux_1_2_ppc64le.whl", hash = "sha256:a194ace7bc43ce765338ca2dfb5661489317db216ea7ea700b0332878b392cab"}, + {file = "aiohttp-3.12.14-cp311-cp311-musllinux_1_2_s390x.whl", hash = "sha256:16260e8e03744a6fe3fcb05259eeab8e08342c4c33decf96a9dad9f1187275d0"}, + {file = "aiohttp-3.12.14-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:8c779e5ebbf0e2e15334ea404fcce54009dc069210164a244d2eac8352a44b28"}, + {file = "aiohttp-3.12.14-cp311-cp311-win32.whl", hash = "sha256:a289f50bf1bd5be227376c067927f78079a7bdeccf8daa6a9e65c38bae14324b"}, + {file = "aiohttp-3.12.14-cp311-cp311-win_amd64.whl", hash = "sha256:0b8a69acaf06b17e9c54151a6c956339cf46db4ff72b3ac28516d0f7068f4ced"}, + {file = "aiohttp-3.12.14-cp312-cp312-macosx_10_13_universal2.whl", hash = "sha256:a0ecbb32fc3e69bc25efcda7d28d38e987d007096cbbeed04f14a6662d0eee22"}, + {file = "aiohttp-3.12.14-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:0400f0ca9bb3e0b02f6466421f253797f6384e9845820c8b05e976398ac1d81a"}, + {file = "aiohttp-3.12.14-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:a56809fed4c8a830b5cae18454b7464e1529dbf66f71c4772e3cfa9cbec0a1ff"}, + {file = "aiohttp-3.12.14-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:27f2e373276e4755691a963e5d11756d093e346119f0627c2d6518208483fb6d"}, + {file = "aiohttp-3.12.14-cp312-cp312-manylinux_2_17_armv7l.manylinux2014_armv7l.manylinux_2_31_armv7l.whl", hash = "sha256:ca39e433630e9a16281125ef57ece6817afd1d54c9f1bf32e901f38f16035869"}, + {file = "aiohttp-3.12.14-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:9c748b3f8b14c77720132b2510a7d9907a03c20ba80f469e58d5dfd90c079a1c"}, + {file = "aiohttp-3.12.14-cp312-cp312-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:f0a568abe1b15ce69d4cc37e23020720423f0728e3cb1f9bcd3f53420ec3bfe7"}, + {file = "aiohttp-3.12.14-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:9888e60c2c54eaf56704b17feb558c7ed6b7439bca1e07d4818ab878f2083660"}, + {file = "aiohttp-3.12.14-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:3006a1dc579b9156de01e7916d38c63dc1ea0679b14627a37edf6151bc530088"}, + {file = "aiohttp-3.12.14-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:aa8ec5c15ab80e5501a26719eb48a55f3c567da45c6ea5bb78c52c036b2655c7"}, + {file = "aiohttp-3.12.14-cp312-cp312-musllinux_1_2_armv7l.whl", hash = "sha256:39b94e50959aa07844c7fe2206b9f75d63cc3ad1c648aaa755aa257f6f2498a9"}, + {file = "aiohttp-3.12.14-cp312-cp312-musllinux_1_2_i686.whl", hash = "sha256:04c11907492f416dad9885d503fbfc5dcb6768d90cad8639a771922d584609d3"}, + {file = "aiohttp-3.12.14-cp312-cp312-musllinux_1_2_ppc64le.whl", hash = "sha256:88167bd9ab69bb46cee91bd9761db6dfd45b6e76a0438c7e884c3f8160ff21eb"}, + {file = "aiohttp-3.12.14-cp312-cp312-musllinux_1_2_s390x.whl", hash = "sha256:791504763f25e8f9f251e4688195e8b455f8820274320204f7eafc467e609425"}, + {file = "aiohttp-3.12.14-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:2785b112346e435dd3a1a67f67713a3fe692d288542f1347ad255683f066d8e0"}, + {file = "aiohttp-3.12.14-cp312-cp312-win32.whl", hash = "sha256:15f5f4792c9c999a31d8decf444e79fcfd98497bf98e94284bf390a7bb8c1729"}, + {file = "aiohttp-3.12.14-cp312-cp312-win_amd64.whl", hash = "sha256:3b66e1a182879f579b105a80d5c4bd448b91a57e8933564bf41665064796a338"}, + {file = "aiohttp-3.12.14-cp313-cp313-macosx_10_13_universal2.whl", hash = "sha256:3143a7893d94dc82bc409f7308bc10d60285a3cd831a68faf1aa0836c5c3c767"}, + {file = "aiohttp-3.12.14-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:3d62ac3d506cef54b355bd34c2a7c230eb693880001dfcda0bf88b38f5d7af7e"}, + {file = "aiohttp-3.12.14-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:48e43e075c6a438937c4de48ec30fa8ad8e6dfef122a038847456bfe7b947b63"}, + {file = "aiohttp-3.12.14-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:077b4488411a9724cecc436cbc8c133e0d61e694995b8de51aaf351c7578949d"}, + {file = "aiohttp-3.12.14-cp313-cp313-manylinux_2_17_armv7l.manylinux2014_armv7l.manylinux_2_31_armv7l.whl", hash = "sha256:d8c35632575653f297dcbc9546305b2c1133391089ab925a6a3706dfa775ccab"}, + {file = "aiohttp-3.12.14-cp313-cp313-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:6b8ce87963f0035c6834b28f061df90cf525ff7c9b6283a8ac23acee6502afd4"}, + {file = "aiohttp-3.12.14-cp313-cp313-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:f0a2cf66e32a2563bb0766eb24eae7e9a269ac0dc48db0aae90b575dc9583026"}, + {file = "aiohttp-3.12.14-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:cdea089caf6d5cde975084a884c72d901e36ef9c2fd972c9f51efbbc64e96fbd"}, + {file = "aiohttp-3.12.14-cp313-cp313-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:8a7865f27db67d49e81d463da64a59365ebd6b826e0e4847aa111056dcb9dc88"}, + {file = "aiohttp-3.12.14-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:0ab5b38a6a39781d77713ad930cb5e7feea6f253de656a5f9f281a8f5931b086"}, + {file = "aiohttp-3.12.14-cp313-cp313-musllinux_1_2_armv7l.whl", hash = "sha256:9b3b15acee5c17e8848d90a4ebc27853f37077ba6aec4d8cb4dbbea56d156933"}, + {file = "aiohttp-3.12.14-cp313-cp313-musllinux_1_2_i686.whl", hash = "sha256:e4c972b0bdaac167c1e53e16a16101b17c6d0ed7eac178e653a07b9f7fad7151"}, + {file = "aiohttp-3.12.14-cp313-cp313-musllinux_1_2_ppc64le.whl", hash = "sha256:7442488b0039257a3bdbc55f7209587911f143fca11df9869578db6c26feeeb8"}, + {file = "aiohttp-3.12.14-cp313-cp313-musllinux_1_2_s390x.whl", hash = "sha256:f68d3067eecb64c5e9bab4a26aa11bd676f4c70eea9ef6536b0a4e490639add3"}, + {file = "aiohttp-3.12.14-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:f88d3704c8b3d598a08ad17d06006cb1ca52a1182291f04979e305c8be6c9758"}, + {file = "aiohttp-3.12.14-cp313-cp313-win32.whl", hash = "sha256:a3c99ab19c7bf375c4ae3debd91ca5d394b98b6089a03231d4c580ef3c2ae4c5"}, + {file = "aiohttp-3.12.14-cp313-cp313-win_amd64.whl", hash = "sha256:3f8aad695e12edc9d571f878c62bedc91adf30c760c8632f09663e5f564f4baa"}, + {file = "aiohttp-3.12.14-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:b8cc6b05e94d837bcd71c6531e2344e1ff0fb87abe4ad78a9261d67ef5d83eae"}, + {file = "aiohttp-3.12.14-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:d1dcb015ac6a3b8facd3677597edd5ff39d11d937456702f0bb2b762e390a21b"}, + {file = "aiohttp-3.12.14-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:3779ed96105cd70ee5e85ca4f457adbce3d9ff33ec3d0ebcdf6c5727f26b21b3"}, + {file = "aiohttp-3.12.14-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:717a0680729b4ebd7569c1dcd718c46b09b360745fd8eb12317abc74b14d14d0"}, + {file = "aiohttp-3.12.14-cp39-cp39-manylinux_2_17_armv7l.manylinux2014_armv7l.manylinux_2_31_armv7l.whl", hash = "sha256:b5dd3a2ef7c7e968dbbac8f5574ebeac4d2b813b247e8cec28174a2ba3627170"}, + {file = "aiohttp-3.12.14-cp39-cp39-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:4710f77598c0092239bc12c1fcc278a444e16c7032d91babf5abbf7166463f7b"}, + {file = "aiohttp-3.12.14-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:f3e9f75ae842a6c22a195d4a127263dbf87cbab729829e0bd7857fb1672400b2"}, + {file = "aiohttp-3.12.14-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:5f9c8d55d6802086edd188e3a7d85a77787e50d56ce3eb4757a3205fa4657922"}, + {file = "aiohttp-3.12.14-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:79b29053ff3ad307880d94562cca80693c62062a098a5776ea8ef5ef4b28d140"}, + {file = "aiohttp-3.12.14-cp39-cp39-musllinux_1_2_aarch64.whl", hash = "sha256:23e1332fff36bebd3183db0c7a547a1da9d3b4091509f6d818e098855f2f27d3"}, + {file = "aiohttp-3.12.14-cp39-cp39-musllinux_1_2_armv7l.whl", hash = "sha256:a564188ce831fd110ea76bcc97085dd6c625b427db3f1dbb14ca4baa1447dcbc"}, + {file = "aiohttp-3.12.14-cp39-cp39-musllinux_1_2_i686.whl", hash = "sha256:a7a1b4302f70bb3ec40ca86de82def532c97a80db49cac6a6700af0de41af5ee"}, + {file = "aiohttp-3.12.14-cp39-cp39-musllinux_1_2_ppc64le.whl", hash = "sha256:1b07ccef62950a2519f9bfc1e5b294de5dd84329f444ca0b329605ea787a3de5"}, + {file = "aiohttp-3.12.14-cp39-cp39-musllinux_1_2_s390x.whl", hash = "sha256:938bd3ca6259e7e48b38d84f753d548bd863e0c222ed6ee6ace3fd6752768a84"}, + {file = "aiohttp-3.12.14-cp39-cp39-musllinux_1_2_x86_64.whl", hash = "sha256:8bc784302b6b9f163b54c4e93d7a6f09563bd01ff2b841b29ed3ac126e5040bf"}, + {file = "aiohttp-3.12.14-cp39-cp39-win32.whl", hash = "sha256:a3416f95961dd7d5393ecff99e3f41dc990fb72eda86c11f2a60308ac6dcd7a0"}, + {file = "aiohttp-3.12.14-cp39-cp39-win_amd64.whl", hash = "sha256:196858b8820d7f60578f8b47e5669b3195c21d8ab261e39b1d705346458f445f"}, + {file = "aiohttp-3.12.14.tar.gz", hash = "sha256:6e06e120e34d93100de448fd941522e11dafa78ef1a893c179901b7d66aa29f2"}, ] [package.dependencies] -aiohappyeyeballs = ">=2.3.0" -aiosignal = ">=1.1.2" +aiohappyeyeballs = ">=2.5.0" +aiosignal = ">=1.4.0" attrs = ">=17.3.0" frozenlist = ">=1.1.1" multidict = ">=4.5,<7.0" @@ -117,21 +130,23 @@ propcache = ">=0.2.0" yarl = ">=1.17.0,<2.0" [package.extras] -speedups = ["Brotli", "aiodns (>=3.2.0)", "brotlicffi"] +speedups = ["Brotli ; platform_python_implementation == \"CPython\"", "aiodns (>=3.3.0)", "brotlicffi ; platform_python_implementation != \"CPython\""] [[package]] name = "aiosignal" -version = "1.3.2" +version = "1.4.0" description = "aiosignal: a list of registered asynchronous callbacks" optional = false python-versions = ">=3.9" +groups = ["main"] files = [ - {file = "aiosignal-1.3.2-py2.py3-none-any.whl", hash = "sha256:45cde58e409a301715980c2b01d0c28bdde3770d8290b5eb2173759d9acb31a5"}, - {file = "aiosignal-1.3.2.tar.gz", hash = "sha256:a8c255c66fafb1e499c9351d0bf32ff2d8a0321595ebac3b93713656d2436f54"}, + {file = "aiosignal-1.4.0-py3-none-any.whl", hash = "sha256:053243f8b92b990551949e63930a839ff0cf0b0ebbe0597b0f3fb19e1a0fe82e"}, + {file = "aiosignal-1.4.0.tar.gz", hash = "sha256:f47eecd9468083c2029cc99945502cb7708b082c232f9aca65da147157b251c7"}, ] [package.dependencies] frozenlist = ">=1.1.0" +typing-extensions = {version = ">=4.2", markers = "python_version < \"3.13\""} [[package]] name = "alabaster" @@ -139,6 +154,7 @@ version = "1.0.0" description = "A light, configurable Sphinx theme" optional = false python-versions = ">=3.10" +groups = ["main"] files = [ {file = "alabaster-1.0.0-py3-none-any.whl", hash = "sha256:fc6786402dc3fcb2de3cabd5fe455a2db534b371124f1f21de8731783dec828b"}, {file = "alabaster-1.0.0.tar.gz", hash = "sha256:c00dca57bca26fa62a6d7d0a9fcce65f3e026e9bfe33e9c538fd3fbb2144fd9e"}, @@ -150,6 +166,7 @@ version = "0.7.0" description = "Reusable constraint types to use with typing.Annotated" optional = false python-versions = ">=3.8" +groups = ["main"] files = [ {file = "annotated_types-0.7.0-py3-none-any.whl", hash = "sha256:1f02e8b43a8fbbc3f3e0d4f0f4bfc8131bcb4eebe8849b8e5c773f3a1c582a53"}, {file = "annotated_types-0.7.0.tar.gz", hash = "sha256:aff07c09a53a08bc8cfccb9c85b05f1aa9a2a6f23728d790723543408344ce89"}, @@ -161,6 +178,7 @@ version = "2.18.1" description = "Radically simple IT automation" optional = false python-versions = ">=3.11" +groups = ["main"] files = [ {file = "ansible_core-2.18.1-py3-none-any.whl", hash = "sha256:4a312e416e09c7271188d6b8e2b1062fc6834fefd6a1814d0e02fb8aadb3e1ba"}, {file = "ansible_core-2.18.1.tar.gz", hash = "sha256:14cac1f92bbdae881cb0616eddeb17925e8cb507e486087975e724533d9de74f"}, @@ -179,6 +197,7 @@ version = "0.1.1" description = "Tools for building the Ansible Distribution" optional = false python-versions = ">=3.6.0,<4.0.0" +groups = ["main"] files = [ {file = "ansible-pygments-0.1.1.tar.gz", hash = "sha256:0d0a23cc562f94f4b464f931059ad1688635aac9642962bc68ae3acdb6efbcd0"}, {file = "ansible_pygments-0.1.1-py3-none-any.whl", hash = "sha256:85aa7412a46c83efcfe460c8016da289600c171d2edfa0f474e0dc30a398b002"}, @@ -193,6 +212,7 @@ version = "0.67.0" description = "The antsibull project has been renamed to antsibull-build" optional = false python-versions = ">=3.9" +groups = ["main"] files = [ {file = "antsibull-0.67.0-py3-none-any.whl", hash = "sha256:ede7234d55398a3e132fd1ab5a4a93f2c7214a2a496108a01428aa8f7c8793d0"}, {file = "antsibull-0.67.0.tar.gz", hash = "sha256:f3a1c46758bd1369510cc3a7046ecf67f5c94371a92f524c529b8b0ea2aba229"}, @@ -211,6 +231,7 @@ version = "0.69.0" description = "Tools for building the Ansible Distribution" optional = false python-versions = ">=3.9" +groups = ["main"] files = [ {file = "antsibull_build-0.69.0-py3-none-any.whl", hash = "sha256:4ed583cad27d913d74528b1995fc3c84fd4fc241c48633ab22bf7d8f9f30c768"}, {file = "antsibull_build-0.69.0.tar.gz", hash = "sha256:311d137b777d1318f7685838907c115d22366d288384f5e2e753343326eb60cb"}, @@ -249,6 +270,7 @@ version = "0.31.1" description = "Changelog tool for Ansible-core and Ansible collections" optional = false python-versions = ">=3.9.0" +groups = ["main"] files = [ {file = "antsibull_changelog-0.31.1-py3-none-any.whl", hash = "sha256:4b51878ee037199e42e5212b53122e4a4ccc997a783bb73496f41c7238c452e7"}, {file = "antsibull_changelog-0.31.1.tar.gz", hash = "sha256:e76fcc49969c29ae7b8615e7ea2b4ac275a19ff3afbf3d665f1457ab12493f84"}, @@ -268,7 +290,7 @@ coverage = ["coverage[toml]"] dev = ["black (>=24)", "coverage[toml]", "flake8 (>=3.8.0)", "isort", "mypy", "nox", "pylint", "pytest", "pytest-cov", "pytest-error-for-skips", "reuse", "types-docutils", "types-pyyaml", "types-toml"] formatters = ["black (>=24)", "isort"] test = ["pytest", "pytest-cov", "pytest-error-for-skips"] -toml = ["tomli"] +toml = ["tomli ; python_version < \"3.11\""] typing = ["mypy", "types-docutils", "types-pyyaml", "types-toml"] [[package]] @@ -277,6 +299,7 @@ version = "3.4.0" description = "Tools for building the Ansible Distribution" optional = false python-versions = ">=3.9" +groups = ["main"] files = [ {file = "antsibull_core-3.4.0-py3-none-any.whl", hash = "sha256:7d3368d1821d002612feb0fde7401c4df547149e661ad8157f2bb36764c6da28"}, {file = "antsibull_core-3.4.0.tar.gz", hash = "sha256:7eebcccaac5446d3cc04de8be2908becc0a02bb2395b83791ff39ab211f54492"}, @@ -307,6 +330,7 @@ version = "2.16.2" description = "Tools for building Ansible documentation" optional = false python-versions = ">=3.9" +groups = ["main"] files = [ {file = "antsibull_docs-2.16.2-py3-none-any.whl", hash = "sha256:7a529d6cba2599843c4f483ef1eef2db518b9e4e4f612affc621f434f48caf5d"}, {file = "antsibull_docs-2.16.2.tar.gz", hash = "sha256:144095f705f1a138f832fe94a07808405efcd8b974ec75cb7b129039a358d318"}, @@ -344,6 +368,7 @@ version = "1.1.0" description = "Python library for processing Ansible documentation markup" optional = false python-versions = ">=3.6.1" +groups = ["main"] files = [ {file = "antsibull_docs_parser-1.1.0-py3-none-any.whl", hash = "sha256:b29490908cd51660cc2b98d6af45b64db938e529f50e84aec416971820013450"}, {file = "antsibull_docs_parser-1.1.0.tar.gz", hash = "sha256:9b94400918343677119c38344bf3bd867a937259f8d09fddc68deae2741ba056"}, @@ -363,6 +388,7 @@ version = "1.1.0" description = "Antsibull docutils helpers" optional = false python-versions = ">=3.9.0" +groups = ["main"] files = [ {file = "antsibull_docutils-1.1.0-py3-none-any.whl", hash = "sha256:922dac4c33089c12cf35a73b159ebe86fd29aeb4f697a97f78a7a444734afbd9"}, {file = "antsibull_docutils-1.1.0.tar.gz", hash = "sha256:6fbeb4ebbd957099f98e85f2687d39fa98c9e2ff23745cf368328d0512b3861d"}, @@ -385,6 +411,7 @@ version = "1.1.0" description = "Tools for building the Ansible Distribution" optional = false python-versions = ">=3.9" +groups = ["main"] files = [ {file = "antsibull_fileutils-1.1.0-py3-none-any.whl", hash = "sha256:558c517b41973b3716f2edc726bf04bc2bef5a0662ee609378f04a66d22d2e06"}, {file = "antsibull_fileutils-1.1.0.tar.gz", hash = "sha256:69e35bc5d8025c52eac3660290e32b691e08b1d3603da1a5b20d16d75ec39f98"}, @@ -408,6 +435,7 @@ version = "3.3.8" description = "An abstract syntax tree for Python with inference support." optional = false python-versions = ">=3.9.0" +groups = ["main"] files = [ {file = "astroid-3.3.8-py3-none-any.whl", hash = "sha256:187ccc0c248bfbba564826c26f070494f7bc964fd286b6d9fff4420e55de828c"}, {file = "astroid-3.3.8.tar.gz", hash = "sha256:a88c7994f914a4ea8572fac479459f4955eeccc877be3f2d959a33273b0cf40b"}, @@ -419,6 +447,7 @@ version = "0.6.0" description = "Pool of asyncio coroutines with familiar interface" optional = false python-versions = ">=3.5" +groups = ["main"] files = [ {file = "asyncio_pool-0.6.0-py3-none-any.whl", hash = "sha256:bf4417be93c2776262d93decabbbd633579f7610947fb73d80857823689e1455"}, {file = "asyncio_pool-0.6.0.tar.gz", hash = "sha256:d7ba5e299ba58d4fb0cebbc722989d1f880df4c4b19e37055075b3dabc062c5b"}, @@ -430,18 +459,19 @@ version = "24.3.0" description = "Classes Without Boilerplate" optional = false python-versions = ">=3.8" +groups = ["main"] files = [ {file = "attrs-24.3.0-py3-none-any.whl", hash = "sha256:ac96cd038792094f438ad1f6ff80837353805ac950cd2aa0e0625ef19850c308"}, {file = "attrs-24.3.0.tar.gz", hash = "sha256:8f5c07333d543103541ba7be0e2ce16eeee8130cb0b3f9238ab904ce1e85baff"}, ] [package.extras] -benchmark = ["cloudpickle", "hypothesis", "mypy (>=1.11.1)", "pympler", "pytest (>=4.3.0)", "pytest-codspeed", "pytest-mypy-plugins", "pytest-xdist[psutil]"] -cov = ["cloudpickle", "coverage[toml] (>=5.3)", "hypothesis", "mypy (>=1.11.1)", "pympler", "pytest (>=4.3.0)", "pytest-mypy-plugins", "pytest-xdist[psutil]"] -dev = ["cloudpickle", "hypothesis", "mypy (>=1.11.1)", "pre-commit-uv", "pympler", "pytest (>=4.3.0)", "pytest-mypy-plugins", "pytest-xdist[psutil]"] +benchmark = ["cloudpickle ; platform_python_implementation == \"CPython\"", "hypothesis", "mypy (>=1.11.1) ; platform_python_implementation == \"CPython\" and python_version >= \"3.10\"", "pympler", "pytest (>=4.3.0)", "pytest-codspeed", "pytest-mypy-plugins ; platform_python_implementation == \"CPython\" and python_version >= \"3.10\"", "pytest-xdist[psutil]"] +cov = ["cloudpickle ; platform_python_implementation == \"CPython\"", "coverage[toml] (>=5.3)", "hypothesis", "mypy (>=1.11.1) ; platform_python_implementation == \"CPython\" and python_version >= \"3.10\"", "pympler", "pytest (>=4.3.0)", "pytest-mypy-plugins ; platform_python_implementation == \"CPython\" and python_version >= \"3.10\"", "pytest-xdist[psutil]"] +dev = ["cloudpickle ; platform_python_implementation == \"CPython\"", "hypothesis", "mypy (>=1.11.1) ; platform_python_implementation == \"CPython\" and python_version >= \"3.10\"", "pre-commit-uv", "pympler", "pytest (>=4.3.0)", "pytest-mypy-plugins ; platform_python_implementation == \"CPython\" and python_version >= \"3.10\"", "pytest-xdist[psutil]"] docs = ["cogapp", "furo", "myst-parser", "sphinx", "sphinx-notfound-page", "sphinxcontrib-towncrier", "towncrier (<24.7)"] -tests = ["cloudpickle", "hypothesis", "mypy (>=1.11.1)", "pympler", "pytest (>=4.3.0)", "pytest-mypy-plugins", "pytest-xdist[psutil]"] -tests-mypy = ["mypy (>=1.11.1)", "pytest-mypy-plugins"] +tests = ["cloudpickle ; platform_python_implementation == \"CPython\"", "hypothesis", "mypy (>=1.11.1) ; platform_python_implementation == \"CPython\" and python_version >= \"3.10\"", "pympler", "pytest (>=4.3.0)", "pytest-mypy-plugins ; platform_python_implementation == \"CPython\" and python_version >= \"3.10\"", "pytest-xdist[psutil]"] +tests-mypy = ["mypy (>=1.11.1) ; platform_python_implementation == \"CPython\" and python_version >= \"3.10\"", "pytest-mypy-plugins ; platform_python_implementation == \"CPython\" and python_version >= \"3.10\""] [[package]] name = "babel" @@ -449,6 +479,7 @@ version = "2.16.0" description = "Internationalization utilities" optional = false python-versions = ">=3.8" +groups = ["main"] files = [ {file = "babel-2.16.0-py3-none-any.whl", hash = "sha256:368b5b98b37c06b7daf6696391c3240c938b37767d4584413e8438c5c435fa8b"}, {file = "babel-2.16.0.tar.gz", hash = "sha256:d1f3554ca26605fe173f3de0c65f750f5a42f924499bf134de6423582298e316"}, @@ -463,6 +494,7 @@ version = "24.10.0" description = "The uncompromising code formatter." optional = false python-versions = ">=3.9" +groups = ["main"] files = [ {file = "black-24.10.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:e6668650ea4b685440857138e5fe40cde4d652633b1bdffc62933d0db4ed9812"}, {file = "black-24.10.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:1c536fcf674217e87b8cc3657b81809d3c085d7bf3ef262ead700da345bfa6ea"}, @@ -507,6 +539,7 @@ version = "1.2.2.post1" description = "A simple, correct Python build frontend" optional = false python-versions = ">=3.8" +groups = ["main"] files = [ {file = "build-1.2.2.post1-py3-none-any.whl", hash = "sha256:1d61c0887fa860c01971625baae8bdd338e517b836a2f70dd1f7aa3a6b2fc5b5"}, {file = "build-1.2.2.post1.tar.gz", hash = "sha256:b36993e92ca9375a219c99e606a122ff365a760a2d4bba0caa09bd5278b608b7"}, @@ -519,7 +552,7 @@ pyproject_hooks = "*" [package.extras] docs = ["furo (>=2023.08.17)", "sphinx (>=7.0,<8.0)", "sphinx-argparse-cli (>=1.5)", "sphinx-autodoc-typehints (>=1.10)", "sphinx-issues (>=3.0.0)"] -test = ["build[uv,virtualenv]", "filelock (>=3)", "pytest (>=6.2.4)", "pytest-cov (>=2.12)", "pytest-mock (>=2)", "pytest-rerunfailures (>=9.1)", "pytest-xdist (>=1.34)", "setuptools (>=42.0.0)", "setuptools (>=56.0.0)", "setuptools (>=56.0.0)", "setuptools (>=67.8.0)", "wheel (>=0.36.0)"] +test = ["build[uv,virtualenv]", "filelock (>=3)", "pytest (>=6.2.4)", "pytest-cov (>=2.12)", "pytest-mock (>=2)", "pytest-rerunfailures (>=9.1)", "pytest-xdist (>=1.34)", "setuptools (>=42.0.0) ; python_version < \"3.10\"", "setuptools (>=56.0.0) ; python_version == \"3.10\"", "setuptools (>=56.0.0) ; python_version == \"3.11\"", "setuptools (>=67.8.0) ; python_version >= \"3.12\"", "wheel (>=0.36.0)"] typing = ["build[uv]", "importlib-metadata (>=5.1)", "mypy (>=1.9.0,<1.10.0)", "tomli", "typing-extensions (>=3.7.4.3)"] uv = ["uv (>=0.1.18)"] virtualenv = ["virtualenv (>=20.0.35)"] @@ -530,6 +563,7 @@ version = "2024.12.14" description = "Python package for providing Mozilla's CA Bundle." optional = false python-versions = ">=3.6" +groups = ["main"] files = [ {file = "certifi-2024.12.14-py3-none-any.whl", hash = "sha256:1275f7a45be9464efc1173084eaa30f866fe2e47d389406136d332ed4967ec56"}, {file = "certifi-2024.12.14.tar.gz", hash = "sha256:b650d30f370c2b724812bee08008be0c4163b163ddaec3f2546c1caf65f191db"}, @@ -541,6 +575,8 @@ version = "1.17.1" description = "Foreign Function Interface for Python calling C code." optional = false python-versions = ">=3.8" +groups = ["main"] +markers = "platform_python_implementation != \"PyPy\"" files = [ {file = "cffi-1.17.1-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:df8b1c11f177bc2313ec4b2d46baec87a5f3e71fc8b45dab2ee7cae86d9aba14"}, {file = "cffi-1.17.1-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:8f2cdc858323644ab277e9bb925ad72ae0e67f69e804f4898c070998d50b1a67"}, @@ -620,6 +656,7 @@ version = "3.4.1" description = "The Real First Universal Charset Detector. Open, modern and actively maintained alternative to Chardet." optional = false python-versions = ">=3.7" +groups = ["main"] files = [ {file = "charset_normalizer-3.4.1-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:91b36a978b5ae0ee86c394f5a54d6ef44db1de0815eb43de826d41d21e4af3de"}, {file = "charset_normalizer-3.4.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:7461baadb4dc00fd9e0acbe254e3d7d2112e7f92ced2adc96e54ef6501c5f176"}, @@ -721,6 +758,7 @@ version = "8.1.8" description = "Composable command line interface toolkit" optional = false python-versions = ">=3.7" +groups = ["main"] files = [ {file = "click-8.1.8-py3-none-any.whl", hash = "sha256:63c132bbbed01578a06712a2d1f497bb62d9c1c0d329b7903a866228027263b2"}, {file = "click-8.1.8.tar.gz", hash = "sha256:ed53c9d8990d83c2a27deae68e4ee337473f6330c040a31d4225c9574d16096a"}, @@ -735,6 +773,7 @@ version = "2.1.13" description = "Hosted coverage reports for GitHub, Bitbucket and Gitlab" optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" +groups = ["main"] files = [ {file = "codecov-2.1.13-py2.py3-none-any.whl", hash = "sha256:c2ca5e51bba9ebb43644c43d0690148a55086f7f5e6fd36170858fa4206744d5"}, {file = "codecov-2.1.13.tar.gz", hash = "sha256:2362b685633caeaf45b9951a9b76ce359cd3581dd515b430c6c3f5dfb4d92a8c"}, @@ -750,6 +789,8 @@ version = "0.4.6" description = "Cross-platform colored terminal text." optional = false python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*,>=2.7" +groups = ["main"] +markers = "platform_system == \"Windows\" or sys_platform == \"win32\" or os_name == \"nt\"" files = [ {file = "colorama-0.4.6-py2.py3-none-any.whl", hash = "sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6"}, {file = "colorama-0.4.6.tar.gz", hash = "sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44"}, @@ -761,6 +802,7 @@ version = "7.6.1" description = "Code coverage measurement for Python" optional = false python-versions = ">=3.8" +groups = ["main"] files = [ {file = "coverage-7.6.1-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:b06079abebbc0e89e6163b8e8f0e16270124c154dc6e4a47b413dd538859af16"}, {file = "coverage-7.6.1-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:cf4b19715bccd7ee27b6b120e7e9dd56037b9c0681dcc1adc9ba9db3d417fa36"}, @@ -837,7 +879,7 @@ files = [ ] [package.extras] -toml = ["tomli"] +toml = ["tomli ; python_full_version <= \"3.11.0a6\""] [[package]] name = "cryptography" @@ -845,6 +887,7 @@ version = "44.0.1" description = "cryptography is a package which provides cryptographic recipes and primitives to Python developers." optional = false python-versions = "!=3.9.0,!=3.9.1,>=3.7" +groups = ["main"] files = [ {file = "cryptography-44.0.1-cp37-abi3-macosx_10_9_universal2.whl", hash = "sha256:bf688f615c29bfe9dfc44312ca470989279f0e94bb9f631f85e3459af8efc009"}, {file = "cryptography-44.0.1-cp37-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:dd7c7e2d71d908dc0f8d2027e1604102140d84b155e658c20e8ad1304317691f"}, @@ -883,10 +926,10 @@ files = [ cffi = {version = ">=1.12", markers = "platform_python_implementation != \"PyPy\""} [package.extras] -docs = ["sphinx (>=5.3.0)", "sphinx-rtd-theme (>=3.0.0)"] +docs = ["sphinx (>=5.3.0)", "sphinx-rtd-theme (>=3.0.0) ; python_version >= \"3.8\""] docstest = ["pyenchant (>=3)", "readme-renderer (>=30.0)", "sphinxcontrib-spelling (>=7.3.1)"] -nox = ["nox (>=2024.4.15)", "nox[uv] (>=2024.3.2)"] -pep8test = ["check-sdist", "click (>=8.0.1)", "mypy (>=1.4)", "ruff (>=0.3.6)"] +nox = ["nox (>=2024.4.15)", "nox[uv] (>=2024.3.2) ; python_version >= \"3.8\""] +pep8test = ["check-sdist ; python_version >= \"3.8\"", "click (>=8.0.1)", "mypy (>=1.4)", "ruff (>=0.3.6)"] sdist = ["build (>=1.0.0)"] ssh = ["bcrypt (>=3.1.5)"] test = ["certifi (>=2024)", "cryptography-vectors (==44.0.1)", "pretend (>=0.7)", "pytest (>=7.4.0)", "pytest-benchmark (>=4.0)", "pytest-cov (>=2.10.1)", "pytest-xdist (>=3.5.0)"] @@ -894,21 +937,27 @@ test-randomorder = ["pytest-randomly"] [[package]] name = "deepdiff" -version = "8.1.1" +version = "8.6.1" description = "Deep Difference and Search of any Python object/data. Recreate objects by adding adding deltas to each other." optional = false -python-versions = ">=3.8" +python-versions = ">=3.9" +groups = ["main"] files = [ - {file = "deepdiff-8.1.1-py3-none-any.whl", hash = "sha256:b0231fa3afb0f7184e82535f2b4a36636442ed21e94a0cf3aaa7982157e7ebca"}, - {file = "deepdiff-8.1.1.tar.gz", hash = "sha256:dd7bc7d5c8b51b5b90f01b0e2fe23c801fd8b4c6a7ee7e31c5a3c3663fcc7ceb"}, + {file = "deepdiff-8.6.1-py3-none-any.whl", hash = "sha256:ee8708a7f7d37fb273a541fa24ad010ed484192cd0c4ffc0fa0ed5e2d4b9e78b"}, + {file = "deepdiff-8.6.1.tar.gz", hash = "sha256:ec56d7a769ca80891b5200ec7bd41eec300ced91ebcc7797b41eb2b3f3ff643a"}, ] [package.dependencies] -orderly-set = ">=5.2.3,<6" +orderly-set = ">=5.4.1,<6" [package.extras] -cli = ["click (==8.1.7)", "pyyaml (==6.0.2)"] +cli = ["click (>=8.1.0,<8.2.0)", "pyyaml (>=6.0.0,<6.1.0)"] +coverage = ["coverage (>=7.6.0,<7.7.0)"] +dev = ["bump2version (>=1.0.0,<1.1.0)", "ipdb (>=0.13.0,<0.14.0)", "jsonpickle (>=4.0.0,<4.1.0)", "nox (==2025.5.1)", "numpy (>=2.0,<3.0) ; python_version < \"3.10\"", "numpy (>=2.2.0,<2.3.0) ; python_version >= \"3.10\"", "orjson (>=3.10.0,<3.11.0)", "pandas (>=2.2.0,<2.3.0)", "polars (>=1.21.0,<1.22.0)", "python-dateutil (>=2.9.0,<2.10.0)", "tomli (>=2.2.0,<2.3.0)", "tomli-w (>=1.2.0,<1.3.0)", "uuid6 (==2025.0.1)"] +docs = ["Sphinx (>=6.2.0,<6.3.0)", "sphinx-sitemap (>=2.6.0,<2.7.0)", "sphinxemoji (>=0.3.0,<0.4.0)"] optimize = ["orjson"] +static = ["flake8 (>=7.1.0,<7.2.0)", "flake8-pyproject (>=1.2.3,<1.3.0)", "pydantic (>=2.10.0,<2.11.0)"] +test = ["pytest (>=8.3.0,<8.4.0)", "pytest-benchmark (>=5.1.0,<5.2.0)", "pytest-cov (>=6.0.0,<6.1.0)", "python-dotenv (>=1.0.0,<1.1.0)"] [[package]] name = "dill" @@ -916,6 +965,7 @@ version = "0.3.9" description = "serialize all of Python" optional = false python-versions = ">=3.8" +groups = ["main"] files = [ {file = "dill-0.3.9-py3-none-any.whl", hash = "sha256:468dff3b89520b474c0397703366b7b95eebe6303f108adf9b19da1f702be87a"}, {file = "dill-0.3.9.tar.gz", hash = "sha256:81aa267dddf68cbfe8029c42ca9ec6a4ab3b22371d1c450abc54422577b4512c"}, @@ -931,6 +981,7 @@ version = "0.21.2" description = "Docutils -- Python Documentation Utilities" optional = false python-versions = ">=3.9" +groups = ["main"] files = [ {file = "docutils-0.21.2-py3-none-any.whl", hash = "sha256:dafca5b9e384f0e419294eb4d2ff9fa826435bf15f15b7bd45723e8ad76811b2"}, {file = "docutils-0.21.2.tar.gz", hash = "sha256:3a6b18732edf182daa3cd12775bbb338cf5691468f91eeeb109deff6ebfa986f"}, @@ -942,6 +993,7 @@ version = "2.1.1" description = "execnet: rapid multi-Python deployment" optional = false python-versions = ">=3.8" +groups = ["main"] files = [ {file = "execnet-2.1.1-py3-none-any.whl", hash = "sha256:26dee51f1b80cebd6d0ca8e74dd8745419761d3bef34163928cbebbdc4749fdc"}, {file = "execnet-2.1.1.tar.gz", hash = "sha256:5189b52c6121c24feae288166ab41b32549c7e2348652736540b9e6e7d4e72e3"}, @@ -956,6 +1008,7 @@ version = "1.5.0" description = "A list-like structure which implements collections.abc.MutableSequence" optional = false python-versions = ">=3.8" +groups = ["main"] files = [ {file = "frozenlist-1.5.0-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:5b6a66c18b5b9dd261ca98dffcb826a525334b2f29e7caa54e182255c5f6a65a"}, {file = "frozenlist-1.5.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:d1b3eb7b05ea246510b43a7e53ed1653e55c2121019a97e60cad7efb881a97bb"}, @@ -1057,6 +1110,7 @@ version = "3.10" description = "Internationalized Domain Names in Applications (IDNA)" optional = false python-versions = ">=3.6" +groups = ["main"] files = [ {file = "idna-3.10-py3-none-any.whl", hash = "sha256:946d195a0d259cbba61165e88e65941f16e9b36ea6ddb97f00452bae8b1287d3"}, {file = "idna-3.10.tar.gz", hash = "sha256:12f65c9b470abda6dc35cf8e63cc574b1c52b11df2c86030af0ac09b01b13ea9"}, @@ -1071,6 +1125,7 @@ version = "1.4.1" description = "Getting image size from png/jpeg/jpeg2000/gif file" optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" +groups = ["main"] files = [ {file = "imagesize-1.4.1-py2.py3-none-any.whl", hash = "sha256:0d8d18d08f840c19d0ee7ca1fd82490fdc3729b7ac93f49870406ddde8ef8d8b"}, {file = "imagesize-1.4.1.tar.gz", hash = "sha256:69150444affb9cb0d5cc5a92b3676f0b2fb7cd9ae39e947a5e11a36b4497cd4a"}, @@ -1082,6 +1137,7 @@ version = "8.5.0" description = "Read metadata from Python packages" optional = false python-versions = ">=3.8" +groups = ["main"] files = [ {file = "importlib_metadata-8.5.0-py3-none-any.whl", hash = "sha256:45e54197d28b7a7f1559e60b95e7c567032b602131fbd588f1497f47880aa68b"}, {file = "importlib_metadata-8.5.0.tar.gz", hash = "sha256:71522656f0abace1d072b9e5481a48f07c138e00f079c38c8f883823f9c26bd7"}, @@ -1091,12 +1147,12 @@ files = [ zipp = ">=3.20" [package.extras] -check = ["pytest-checkdocs (>=2.4)", "pytest-ruff (>=0.2.1)"] +check = ["pytest-checkdocs (>=2.4)", "pytest-ruff (>=0.2.1) ; sys_platform != \"cygwin\""] cover = ["pytest-cov"] doc = ["furo", "jaraco.packaging (>=9.3)", "jaraco.tidelift (>=1.4)", "rst.linker (>=1.9)", "sphinx (>=3.5)", "sphinx-lint"] enabler = ["pytest-enabler (>=2.2)"] perf = ["ipython"] -test = ["flufl.flake8", "importlib-resources (>=1.3)", "jaraco.test (>=5.4)", "packaging", "pyfakefs", "pytest (>=6,!=8.1.*)", "pytest-perf (>=0.9.2)"] +test = ["flufl.flake8", "importlib-resources (>=1.3) ; python_version < \"3.9\"", "jaraco.test (>=5.4)", "packaging", "pyfakefs", "pytest (>=6,!=8.1.*)", "pytest-perf (>=0.9.2)"] type = ["pytest-mypy"] [[package]] @@ -1105,13 +1161,14 @@ version = "6.5.2" description = "Read resources from Python packages" optional = false python-versions = ">=3.9" +groups = ["main"] files = [ {file = "importlib_resources-6.5.2-py3-none-any.whl", hash = "sha256:789cfdc3ed28c78b67a06acb8126751ced69a3d5f79c095a98298cd8a760ccec"}, {file = "importlib_resources-6.5.2.tar.gz", hash = "sha256:185f87adef5bcc288449d98fb4fba07cea78bc036455dd44c5fc4a2fe78fed2c"}, ] [package.extras] -check = ["pytest-checkdocs (>=2.4)", "pytest-ruff (>=0.2.1)"] +check = ["pytest-checkdocs (>=2.4)", "pytest-ruff (>=0.2.1) ; sys_platform != \"cygwin\""] cover = ["pytest-cov"] doc = ["furo", "jaraco.packaging (>=9.3)", "jaraco.tidelift (>=1.4)", "rst.linker (>=1.9)", "sphinx (>=3.5)", "sphinx-lint"] enabler = ["pytest-enabler (>=2.2)"] @@ -1124,6 +1181,7 @@ version = "2.0.0" description = "brain-dead simple config-ini parsing" optional = false python-versions = ">=3.7" +groups = ["main"] files = [ {file = "iniconfig-2.0.0-py3-none-any.whl", hash = "sha256:b6a85871a79d2e3b22d2d1b94ac2824226a63c6b741c88f7ae975f18b6778374"}, {file = "iniconfig-2.0.0.tar.gz", hash = "sha256:2d91e135bf72d31a410b17c16da610a82cb55f6b0477d1a902134b24a455b8b3"}, @@ -1135,6 +1193,7 @@ version = "5.13.2" description = "A Python utility / library to sort Python imports." optional = false python-versions = ">=3.8.0" +groups = ["main"] files = [ {file = "isort-5.13.2-py3-none-any.whl", hash = "sha256:8ca5e72a8d85860d5a3fa69b8745237f2939afe12dbf656afbcb47fe72d947a6"}, {file = "isort-5.13.2.tar.gz", hash = "sha256:48fdfcb9face5d58a4f6dde2e72a1fb8dcaf8ab26f95ab49fab84c2ddefb0109"}, @@ -1145,13 +1204,14 @@ colors = ["colorama (>=0.4.6)"] [[package]] name = "jinja2" -version = "3.1.5" +version = "3.1.6" description = "A very fast and expressive template engine." optional = false python-versions = ">=3.7" +groups = ["main"] files = [ - {file = "jinja2-3.1.5-py3-none-any.whl", hash = "sha256:aba0f4dc9ed8013c424088f68a5c226f7d6097ed89b246d7749c2ec4175c6adb"}, - {file = "jinja2-3.1.5.tar.gz", hash = "sha256:8fefff8dc3034e27bb80d67c671eb8a9bc424c0ef4c0826edbff304cceff43bb"}, + {file = "jinja2-3.1.6-py3-none-any.whl", hash = "sha256:85ece4451f492d0c13c5dd7c13a64681a86afae63a5f347908daf103ce6d2f67"}, + {file = "jinja2-3.1.6.tar.gz", hash = "sha256:0137fb05990d35f1275a587e9aee6d56da821fc83491a0fb838183be43f66d6d"}, ] [package.dependencies] @@ -1166,6 +1226,7 @@ version = "1.0.1" description = "JSON Matching Expressions" optional = false python-versions = ">=3.7" +groups = ["main"] files = [ {file = "jmespath-1.0.1-py3-none-any.whl", hash = "sha256:02e2e4cc71b5bcab88332eebf907519190dd9e6e82107fa7f83b1003a6252980"}, {file = "jmespath-1.0.1.tar.gz", hash = "sha256:90261b206d6defd58fdd5e85f478bf633a2901798906be2ad389150c5c60edbe"}, @@ -1177,6 +1238,7 @@ version = "3.0.0" description = "Python port of markdown-it. Markdown parsing, done right!" optional = false python-versions = ">=3.8" +groups = ["main"] files = [ {file = "markdown-it-py-3.0.0.tar.gz", hash = "sha256:e3f60a94fa066dc52ec76661e37c851cb232d92f9886b15cb560aaada2df8feb"}, {file = "markdown_it_py-3.0.0-py3-none-any.whl", hash = "sha256:355216845c60bd96232cd8d8c40e8f9765cc86f46880e43a8fd22dc1a1a8cab1"}, @@ -1201,6 +1263,7 @@ version = "3.0.2" description = "Safely add untrusted strings to HTML/XML markup." optional = false python-versions = ">=3.9" +groups = ["main"] files = [ {file = "MarkupSafe-3.0.2-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:7e94c425039cde14257288fd61dcfb01963e658efbc0ff54f5306b06054700f8"}, {file = "MarkupSafe-3.0.2-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:9e2d922824181480953426608b81967de705c3cef4d1af983af849d7bd619158"}, @@ -1271,6 +1334,7 @@ version = "0.7.0" description = "McCabe checker, plugin for flake8" optional = false python-versions = ">=3.6" +groups = ["main"] files = [ {file = "mccabe-0.7.0-py2.py3-none-any.whl", hash = "sha256:6c2d30ab6be0e4a46919781807b4f0d834ebdd6c6e3dca0bda5a15f863427b6e"}, {file = "mccabe-0.7.0.tar.gz", hash = "sha256:348e0240c33b60bbdf4e523192ef919f28cb2c3d7d5c7794f74009290f236325"}, @@ -1282,6 +1346,7 @@ version = "0.1.2" description = "Markdown URL utilities" optional = false python-versions = ">=3.7" +groups = ["main"] files = [ {file = "mdurl-0.1.2-py3-none-any.whl", hash = "sha256:84008a41e51615a49fc9966191ff91509e3c40b939176e643fd50a5c2196b8f8"}, {file = "mdurl-0.1.2.tar.gz", hash = "sha256:bb413d29f5eea38f31dd4754dd7377d4465116fb207585f97bf925588687c1ba"}, @@ -1293,6 +1358,7 @@ version = "4.0.3" description = "Rolling backport of unittest.mock for all Pythons" optional = false python-versions = ">=3.6" +groups = ["main"] files = [ {file = "mock-4.0.3-py3-none-any.whl", hash = "sha256:122fcb64ee37cfad5b3f48d7a7d51875d7031aaf3d8be7c42e2bee25044eee62"}, {file = "mock-4.0.3.tar.gz", hash = "sha256:7d3fbbde18228f4ff2f1f119a45cdffa458b4c0dee32eb4d2bb2f82554bac7bc"}, @@ -1309,6 +1375,7 @@ version = "6.1.0" description = "multidict implementation" optional = false python-versions = ">=3.8" +groups = ["main"] files = [ {file = "multidict-6.1.0-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:3380252550e372e8511d49481bd836264c009adb826b23fefcc5dd3c69692f60"}, {file = "multidict-6.1.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:99f826cbf970077383d7de805c0681799491cb939c25450b9b5b3ced03ca99f1"}, @@ -1410,6 +1477,7 @@ version = "1.0.0" description = "Type system extensions for programs checked with the mypy type checker." optional = false python-versions = ">=3.5" +groups = ["main"] files = [ {file = "mypy_extensions-1.0.0-py3-none-any.whl", hash = "sha256:4392f6c0eb8a5668a69e23d168ffa70f0be9ccfd32b5cc2d26a34ae5b844552d"}, {file = "mypy_extensions-1.0.0.tar.gz", hash = "sha256:75dbf8955dc00442a438fc4d0666508a9a97b6bd41aa2f0ffe9d2f2725af0782"}, @@ -1417,21 +1485,30 @@ files = [ [[package]] name = "orderly-set" -version = "5.2.3" +version = "5.5.0" description = "Orderly set" optional = false python-versions = ">=3.8" +groups = ["main"] files = [ - {file = "orderly_set-5.2.3-py3-none-any.whl", hash = "sha256:d357cedcf67f4ebff0d4cbd5b0997e98eeb65dd24fdf5c990a501ae9e82c7d34"}, - {file = "orderly_set-5.2.3.tar.gz", hash = "sha256:571ed97c5a5fca7ddeb6b2d26c19aca896b0ed91f334d9c109edd2f265fb3017"}, + {file = "orderly_set-5.5.0-py3-none-any.whl", hash = "sha256:46f0b801948e98f427b412fcabb831677194c05c3b699b80de260374baa0b1e7"}, + {file = "orderly_set-5.5.0.tar.gz", hash = "sha256:e87185c8e4d8afa64e7f8160ee2c542a475b738bc891dc3f58102e654125e6ce"}, ] +[package.extras] +coverage = ["coverage (>=7.6.0,<7.7.0)"] +dev = ["bump2version (>=1.0.0,<1.1.0)", "ipdb (>=0.13.0,<0.14.0)"] +optimize = ["orjson"] +static = ["flake8 (>=7.1.0,<7.2.0)", "flake8-pyproject (>=1.2.3,<1.3.0)"] +test = ["pytest (>=8.3.0,<8.4.0)", "pytest-benchmark (>=5.1.0,<5.2.0)", "pytest-cov (>=6.0.0,<6.1.0)", "python-dotenv (>=1.0.0,<1.1.0)"] + [[package]] name = "packaging" version = "24.2" description = "Core utilities for Python packages" optional = false python-versions = ">=3.8" +groups = ["main"] files = [ {file = "packaging-24.2-py3-none-any.whl", hash = "sha256:09abb1bccd265c01f4a3aa3f7a7db064b36514d2cba19a2f694fe6150451a759"}, {file = "packaging-24.2.tar.gz", hash = "sha256:c228a6dc5e932d346bc5739379109d49e8853dd8223571c7c5b55260edc0b97f"}, @@ -1443,6 +1520,7 @@ version = "0.12.1" description = "Utility library for gitignore style pattern matching of file paths." optional = false python-versions = ">=3.8" +groups = ["main"] files = [ {file = "pathspec-0.12.1-py3-none-any.whl", hash = "sha256:a0d503e138a4c123b27490a4f7beda6a01c6f288df0e4a8b79c7eb0dc7b4cc08"}, {file = "pathspec-0.12.1.tar.gz", hash = "sha256:a482d51503a1ab33b1c67a6c3813a26953dbdc71c31dacaef9a838c4e29f5712"}, @@ -1454,6 +1532,7 @@ version = "0.9.3" description = "A simple, Pythonic file format. Same interface as the" optional = false python-versions = ">=3.6" +groups = ["main"] files = [ {file = "perky-0.9.3-py3-none-any.whl", hash = "sha256:ebe0c58ee35951b1b878d5acb98bda4aa3e2067cd397baf1a3721f7f7da5acd4"}, {file = "perky-0.9.3.tar.gz", hash = "sha256:ae847c4ff1f5e2bde74097eb7a29a1411bc22912142ba4c8cf08d77789823f08"}, @@ -1465,6 +1544,7 @@ version = "4.3.6" description = "A small Python package for determining appropriate platform-specific dirs, e.g. a `user data dir`." optional = false python-versions = ">=3.8" +groups = ["main"] files = [ {file = "platformdirs-4.3.6-py3-none-any.whl", hash = "sha256:73e575e1408ab8103900836b97580d5307456908a03e92031bab39e4554cc3fb"}, {file = "platformdirs-4.3.6.tar.gz", hash = "sha256:357fb2acbc885b0419afd3ce3ed34564c13c9b95c89360cd9563f73aa5e2b907"}, @@ -1481,6 +1561,7 @@ version = "1.5.0" description = "plugin and hook calling mechanisms for python" optional = false python-versions = ">=3.8" +groups = ["main"] files = [ {file = "pluggy-1.5.0-py3-none-any.whl", hash = "sha256:44e1ad92c8ca002de6377e165f3e0f1be63266ab4d554740532335b9d75ea669"}, {file = "pluggy-1.5.0.tar.gz", hash = "sha256:2cffa88e94fdc978c4c574f15f9e59b7f4201d439195c3715ca9e2486f1d0cf1"}, @@ -1496,6 +1577,7 @@ version = "0.2.1" description = "Accelerated property cache" optional = false python-versions = ">=3.9" +groups = ["main"] files = [ {file = "propcache-0.2.1-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:6b3f39a85d671436ee3d12c017f8fdea38509e4f25b28eb25877293c98c243f6"}, {file = "propcache-0.2.1-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:39d51fbe4285d5db5d92a929e3e21536ea3dd43732c5b177c7ef03f918dff9f2"}, @@ -1587,6 +1669,7 @@ version = "1.11.0" description = "library with cross-python path, ini-parsing, io, code, log facilities" optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*" +groups = ["main"] files = [ {file = "py-1.11.0-py2.py3-none-any.whl", hash = "sha256:607c53218732647dff4acdfcd50cb62615cedf612e72d1724fb1a0cc6405b378"}, {file = "py-1.11.0.tar.gz", hash = "sha256:51c75c4126074b472f746a24399ad32f6053d1b34b68d2fa41e558e6f4a98719"}, @@ -1598,6 +1681,8 @@ version = "2.22" description = "C parser in Python" optional = false python-versions = ">=3.8" +groups = ["main"] +markers = "platform_python_implementation != \"PyPy\"" files = [ {file = "pycparser-2.22-py3-none-any.whl", hash = "sha256:c3702b6d3dd8c7abc1afa565d7e63d53a1d0bd86cdc24edd75470f4de499cfcc"}, {file = "pycparser-2.22.tar.gz", hash = "sha256:491c8be9c040f5390f5bf44a5b07752bd07f56edf992381b05c701439eec10f6"}, @@ -1609,6 +1694,7 @@ version = "2.10.5" description = "Data validation using Python type hints" optional = false python-versions = ">=3.8" +groups = ["main"] files = [ {file = "pydantic-2.10.5-py3-none-any.whl", hash = "sha256:4dd4e322dbe55472cb7ca7e73f4b63574eecccf2835ffa2af9021ce113c83c53"}, {file = "pydantic-2.10.5.tar.gz", hash = "sha256:278b38dbbaec562011d659ee05f63346951b3a248a6f3642e1bc68894ea2b4ff"}, @@ -1621,7 +1707,7 @@ typing-extensions = ">=4.12.2" [package.extras] email = ["email-validator (>=2.0.0)"] -timezone = ["tzdata"] +timezone = ["tzdata ; python_version >= \"3.9\" and platform_system == \"Windows\""] [[package]] name = "pydantic-core" @@ -1629,6 +1715,7 @@ version = "2.27.2" description = "Core functionality for Pydantic validation and serialization" optional = false python-versions = ">=3.8" +groups = ["main"] files = [ {file = "pydantic_core-2.27.2-cp310-cp310-macosx_10_12_x86_64.whl", hash = "sha256:2d367ca20b2f14095a8f4fa1210f5a7b78b8a20009ecced6b12818f455b1e9fa"}, {file = "pydantic_core-2.27.2-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:491a2b73db93fab69731eaee494f320faa4e093dbed776be1a829c2eb222c34c"}, @@ -1741,6 +1828,7 @@ version = "2.19.1" description = "Pygments is a syntax highlighting package written in Python." optional = false python-versions = ">=3.8" +groups = ["main"] files = [ {file = "pygments-2.19.1-py3-none-any.whl", hash = "sha256:9ea1544ad55cecf4b8242fab6dd35a93bbce657034b0611ee383099054ab6d8c"}, {file = "pygments-2.19.1.tar.gz", hash = "sha256:61c16d2a8576dc0649d9f39e089b5f02bcd27fba10d8fb4dcc28173f7a45151f"}, @@ -1755,6 +1843,7 @@ version = "3.3.3" description = "python code static checker" optional = false python-versions = ">=3.9.0" +groups = ["main"] files = [ {file = "pylint-3.3.3-py3-none-any.whl", hash = "sha256:26e271a2bc8bce0fc23833805a9076dd9b4d5194e2a02164942cb3cdc37b4183"}, {file = "pylint-3.3.3.tar.gz", hash = "sha256:07c607523b17e6d16e2ae0d7ef59602e332caa762af64203c24b41c27139f36a"}, @@ -1763,7 +1852,10 @@ files = [ [package.dependencies] astroid = ">=3.3.8,<=3.4.0-dev0" colorama = {version = ">=0.4.5", markers = "sys_platform == \"win32\""} -dill = {version = ">=0.3.7", markers = "python_version >= \"3.12\""} +dill = [ + {version = ">=0.3.7", markers = "python_version >= \"3.12\""}, + {version = ">=0.3.6", markers = "python_version == \"3.11\""}, +] isort = ">=4.2.5,<5.13.0 || >5.13.0,<6" mccabe = ">=0.6,<0.8" platformdirs = ">=2.2.0" @@ -1779,6 +1871,7 @@ version = "7.4.1" description = "NetBox API client library" optional = false python-versions = "*" +groups = ["main"] files = [ {file = "pynetbox-7.4.1-py3-none-any.whl", hash = "sha256:f42ce4df6ce97765df91bb4cc0c0e315683d15135265270d78f595114dd20e2b"}, {file = "pynetbox-7.4.1.tar.gz", hash = "sha256:3f82b5964ca77a608aef6cc2fc48a3961f7667fbbdbb60646655373e3dae00c3"}, @@ -1794,6 +1887,7 @@ version = "1.2.0" description = "Wrappers to call pyproject.toml-based build backend hooks." optional = false python-versions = ">=3.7" +groups = ["main"] files = [ {file = "pyproject_hooks-1.2.0-py3-none-any.whl", hash = "sha256:9e5c6bfa8dcc30091c74b0cf803c81fdd29d94f01992a7707bc97babb1141913"}, {file = "pyproject_hooks-1.2.0.tar.gz", hash = "sha256:1e859bd5c40fae9448642dd871adf459e5e2084186e8d2c2a79a824c970da1f8"}, @@ -1805,6 +1899,7 @@ version = "8.3.4" description = "pytest: simple powerful testing with Python" optional = false python-versions = ">=3.8" +groups = ["main"] files = [ {file = "pytest-8.3.4-py3-none-any.whl", hash = "sha256:50e16d954148559c9a74109af1eaf0c945ba2d8f30f0a3d3335edde19788b6f6"}, {file = "pytest-8.3.4.tar.gz", hash = "sha256:965370d062bce11e73868e0335abac31b4d3de0e82f4007408d242b4f8610761"}, @@ -1825,6 +1920,7 @@ version = "1.6.0" description = "run tests in isolated forked subprocesses" optional = false python-versions = ">=3.7" +groups = ["main"] files = [ {file = "pytest-forked-1.6.0.tar.gz", hash = "sha256:4dafd46a9a600f65d822b8f605133ecf5b3e1941ebb3588e943b4e3eb71a5a3f"}, {file = "pytest_forked-1.6.0-py3-none-any.whl", hash = "sha256:810958f66a91afb1a1e2ae83089d8dc1cd2437ac96b12963042fbb9fb4d16af0"}, @@ -1840,6 +1936,7 @@ version = "3.14.0" description = "Thin-wrapper around the mock package for easier use with pytest" optional = false python-versions = ">=3.8" +groups = ["main"] files = [ {file = "pytest-mock-3.14.0.tar.gz", hash = "sha256:2719255a1efeceadbc056d6bf3df3d1c5015530fb40cf347c0f9afac88410bd0"}, {file = "pytest_mock-3.14.0-py3-none-any.whl", hash = "sha256:0b72c38033392a5f4621342fe11e9219ac11ec9d375f8e2a0c164539e0d70f6f"}, @@ -1857,6 +1954,7 @@ version = "3.6.1" description = "pytest xdist plugin for distributed testing, most importantly across multiple CPUs" optional = false python-versions = ">=3.8" +groups = ["main"] files = [ {file = "pytest_xdist-3.6.1-py3-none-any.whl", hash = "sha256:9ed4adfb68a016610848639bb7e02c9352d5d9f03d04809919e2dafc3be4cca7"}, {file = "pytest_xdist-3.6.1.tar.gz", hash = "sha256:ead156a4db231eec769737f57668ef58a2084a34b2e55c4a8fa20d861107300d"}, @@ -1877,6 +1975,7 @@ version = "2024.2" description = "World timezone definitions, modern and historical" optional = false python-versions = "*" +groups = ["main"] files = [ {file = "pytz-2024.2-py2.py3-none-any.whl", hash = "sha256:31c7c1817eb7fae7ca4b8c7ee50c72f93aa2dd863de768e1ef4245d426aa0725"}, {file = "pytz-2024.2.tar.gz", hash = "sha256:2aa355083c50a0f93fa581709deac0c9ad65cca8a9e9beac660adcbd493c798a"}, @@ -1888,6 +1987,7 @@ version = "6.0.2" description = "YAML parser and emitter for Python" optional = false python-versions = ">=3.8" +groups = ["main"] files = [ {file = "PyYAML-6.0.2-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:0a9a2848a5b7feac301353437eb7d5957887edbf81d56e903999a75a3d743086"}, {file = "PyYAML-6.0.2-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:29717114e51c84ddfba879543fb232a6ed60086602313ca38cce623c1d62cfbf"}, @@ -1946,18 +2046,19 @@ files = [ [[package]] name = "requests" -version = "2.32.3" +version = "2.32.4" description = "Python HTTP for Humans." optional = false python-versions = ">=3.8" +groups = ["main"] files = [ - {file = "requests-2.32.3-py3-none-any.whl", hash = "sha256:70761cfe03c773ceb22aa2f671b4757976145175cdfca038c02654d061d6dcc6"}, - {file = "requests-2.32.3.tar.gz", hash = "sha256:55365417734eb18255590a9ff9eb97e9e1da868d4ccd6402399eaf68af20a760"}, + {file = "requests-2.32.4-py3-none-any.whl", hash = "sha256:27babd3cda2a6d50b30443204ee89830707d396671944c998b5975b031ac2b2c"}, + {file = "requests-2.32.4.tar.gz", hash = "sha256:27d0316682c8a29834d3264820024b62a36942083d52caf2f14c0591336d3422"}, ] [package.dependencies] certifi = ">=2017.4.17" -charset-normalizer = ">=2,<4" +charset_normalizer = ">=2,<4" idna = ">=2.5,<4" urllib3 = ">=1.21.1,<3" @@ -1971,6 +2072,7 @@ version = "1.0.1" description = "Resolve abstract dependencies into concrete ones" optional = false python-versions = "*" +groups = ["main"] files = [ {file = "resolvelib-1.0.1-py2.py3-none-any.whl", hash = "sha256:d2da45d1a8dfee81bdd591647783e340ef3bcb104b54c383f70d422ef5cc7dbf"}, {file = "resolvelib-1.0.1.tar.gz", hash = "sha256:04ce76cbd63fded2078ce224785da6ecd42b9564b1390793f64ddecbe997b309"}, @@ -1988,6 +2090,7 @@ version = "13.9.4" description = "Render rich text, tables, progress bars, syntax highlighting, markdown and more to the terminal" optional = false python-versions = ">=3.8.0" +groups = ["main"] files = [ {file = "rich-13.9.4-py3-none-any.whl", hash = "sha256:6049d5e6ec054bf2779ab3358186963bac2ea89175919d699e378b99738c2a90"}, {file = "rich-13.9.4.tar.gz", hash = "sha256:439594978a49a09530cff7ebc4b5c7103ef57baf48d5ea3184f21d9a2befa098"}, @@ -2006,6 +2109,7 @@ version = "6.2.4" description = "Checks syntax of reStructuredText and code blocks nested within it" optional = false python-versions = ">=3.8" +groups = ["main"] files = [ {file = "rstcheck-6.2.4-py3-none-any.whl", hash = "sha256:23de2575ba0af1adcddea87a20d69187f0fb9dd8270f59eb98d63461c95375a7"}, {file = "rstcheck-6.2.4.tar.gz", hash = "sha256:384942563dfbfcc85903a587ecf050447217c46b51e266ed3fe51371bc599015"}, @@ -2020,7 +2124,7 @@ dev = ["rstcheck[docs,sphinx,testing,toml,type-check]", "tox (>=3.15)"] docs = ["myst-parser (>=3)", "sphinx (>=5.0)", "sphinx-autobuild (>=2021.3.14)", "sphinx-click (>=4.0.3)", "sphinx-rtd-theme (>=1.2)", "sphinxcontrib-spelling (>=7.3)"] sphinx = ["sphinx (>=5.0)"] testing = ["coverage-conditional-plugin (>=0.5)", "coverage[toml] (>=6.0)", "pytest (>=7.2)", "pytest-cov (>=3.0)", "pytest-randomly (>=3.0)", "pytest-sugar (>=0.9.5)"] -toml = ["tomli (>=2.0)"] +toml = ["tomli (>=2.0) ; python_version <= \"3.10\""] type-check = ["mypy (>=1.0)"] [[package]] @@ -2029,6 +2133,7 @@ version = "1.2.1" description = "Checks syntax of reStructuredText and code blocks nested within it" optional = false python-versions = ">=3.8" +groups = ["main"] files = [ {file = "rstcheck-core-1.2.1.tar.gz", hash = "sha256:9b330020d912e2864f23f332c1a0569463ca3b06b8fee7b7bdd201b055f7f831"}, {file = "rstcheck_core-1.2.1-py3-none-any.whl", hash = "sha256:1c100de418b6c9e14d9cf6558644d0ab103fdc447f891313882d02df3a3c52ba"}, @@ -2043,7 +2148,7 @@ dev = ["rstcheck-core[docs,sphinx,testing,toml,type-check,yaml]", "tox (>=3.15)" docs = ["m2r2 (>=0.3.2)", "sphinx (>=5.0,!=7.2.5)", "sphinx-autobuild (>=2021.3.14)", "sphinx-autodoc-typehints (>=1.15)", "sphinx-rtd-theme (>=1.2)", "sphinxcontrib-apidoc (>=0.3)", "sphinxcontrib-spelling (>=7.3)"] sphinx = ["sphinx (>=5.0)"] testing = ["coverage-conditional-plugin (>=0.5)", "coverage[toml] (>=6.0)", "pytest (>=7.2)", "pytest-cov (>=3.0)", "pytest-mock (>=3.7)", "pytest-randomly (>=3.0)", "pytest-sugar (>=0.9.5)"] -toml = ["tomli (>=2.0)"] +toml = ["tomli (>=2.0) ; python_version <= \"3.10\""] type-check = ["mypy (>=1.0)", "types-PyYAML (>=6.0.0)", "types-docutils (>=0.18)"] yaml = ["pyyaml (>=6.0.0)"] @@ -2053,13 +2158,14 @@ version = "2.10.0" description = "A library implementing the 'SemVer' scheme." optional = false python-versions = ">=2.7" +groups = ["main"] files = [ {file = "semantic_version-2.10.0-py2.py3-none-any.whl", hash = "sha256:de78a3b8e0feda74cabc54aab2da702113e33ac9d9eb9d2389bcf1f58b7d9177"}, {file = "semantic_version-2.10.0.tar.gz", hash = "sha256:bdabb6d336998cbb378d4b9db3a4b56a1e3235701dc05ea2690d9a997ed5041c"}, ] [package.extras] -dev = ["Django (>=1.11)", "check-manifest", "colorama (<=0.4.1)", "coverage", "flake8", "nose2", "readme-renderer (<25.0)", "tox", "wheel", "zest.releaser[recommended]"] +dev = ["Django (>=1.11)", "check-manifest", "colorama (<=0.4.1) ; python_version == \"3.4\"", "coverage", "flake8", "nose2", "readme-renderer (<25.0) ; python_version == \"3.4\"", "tox", "wheel", "zest.releaser[recommended]"] doc = ["Sphinx", "sphinx-rtd-theme"] [[package]] @@ -2068,6 +2174,7 @@ version = "1.5.4" description = "Tool to Detect Surrounding Shell" optional = false python-versions = ">=3.7" +groups = ["main"] files = [ {file = "shellingham-1.5.4-py2.py3-none-any.whl", hash = "sha256:7ecfff8f2fd72616f7481040475a65b2bf8af90a56c89140852d1120324e8686"}, {file = "shellingham-1.5.4.tar.gz", hash = "sha256:8dbca0739d487e5bd35ab3ca4b36e11c4078f3a234bfce294b0a0291363404de"}, @@ -2079,6 +2186,7 @@ version = "1.17.0" description = "Python 2 and 3 compatibility utilities" optional = false python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,>=2.7" +groups = ["main"] files = [ {file = "six-1.17.0-py2.py3-none-any.whl", hash = "sha256:4721f391ed90541fddacab5acf947aa0d3dc7d27b2e1e8eda2be8970586c3274"}, {file = "six-1.17.0.tar.gz", hash = "sha256:ff70335d468e7eb6ec65b95b99d3a2836546063f63acc5171de367e834932a81"}, @@ -2090,6 +2198,7 @@ version = "2.2.0" description = "This package provides 29 stemmers for 28 languages generated from Snowball algorithms." optional = false python-versions = "*" +groups = ["main"] files = [ {file = "snowballstemmer-2.2.0-py2.py3-none-any.whl", hash = "sha256:c8e1716e83cc398ae16824e5572ae04e0d9fc2c6b985fb0f900f5f0c96ecba1a"}, {file = "snowballstemmer-2.2.0.tar.gz", hash = "sha256:09b16deb8547d3412ad7b590689584cd0fe25ec8db3be37788be3810cbf19cb1"}, @@ -2101,6 +2210,7 @@ version = "8.1.3" description = "Python documentation generator" optional = false python-versions = ">=3.10" +groups = ["main"] files = [ {file = "sphinx-8.1.3-py3-none-any.whl", hash = "sha256:09719015511837b76bf6e03e42eb7595ac8c2e41eeb9c29c5b755c6b677992a2"}, {file = "sphinx-8.1.3.tar.gz", hash = "sha256:43c1911eecb0d3e161ad78611bc905d1ad0e523e4ddc202a58a821773dc4c927"}, @@ -2135,6 +2245,7 @@ version = "2.0.0" description = "sphinxcontrib-applehelp is a Sphinx extension which outputs Apple help books" optional = false python-versions = ">=3.9" +groups = ["main"] files = [ {file = "sphinxcontrib_applehelp-2.0.0-py3-none-any.whl", hash = "sha256:4cd3f0ec4ac5dd9c17ec65e9ab272c9b867ea77425228e68ecf08d6b28ddbdb5"}, {file = "sphinxcontrib_applehelp-2.0.0.tar.gz", hash = "sha256:2f29ef331735ce958efa4734873f084941970894c6090408b079c61b2e1c06d1"}, @@ -2151,6 +2262,7 @@ version = "2.0.0" description = "sphinxcontrib-devhelp is a sphinx extension which outputs Devhelp documents" optional = false python-versions = ">=3.9" +groups = ["main"] files = [ {file = "sphinxcontrib_devhelp-2.0.0-py3-none-any.whl", hash = "sha256:aefb8b83854e4b0998877524d1029fd3e6879210422ee3780459e28a1f03a8a2"}, {file = "sphinxcontrib_devhelp-2.0.0.tar.gz", hash = "sha256:411f5d96d445d1d73bb5d52133377b4248ec79db5c793ce7dbe59e074b4dd1ad"}, @@ -2167,6 +2279,7 @@ version = "2.1.0" description = "sphinxcontrib-htmlhelp is a sphinx extension which renders HTML help files" optional = false python-versions = ">=3.9" +groups = ["main"] files = [ {file = "sphinxcontrib_htmlhelp-2.1.0-py3-none-any.whl", hash = "sha256:166759820b47002d22914d64a075ce08f4c46818e17cfc9470a9786b759b19f8"}, {file = "sphinxcontrib_htmlhelp-2.1.0.tar.gz", hash = "sha256:c9e2916ace8aad64cc13a0d233ee22317f2b9025b9cf3295249fa985cc7082e9"}, @@ -2183,6 +2296,7 @@ version = "1.0.1" description = "A sphinx extension which renders display math in HTML via JavaScript" optional = false python-versions = ">=3.5" +groups = ["main"] files = [ {file = "sphinxcontrib-jsmath-1.0.1.tar.gz", hash = "sha256:a9925e4a4587247ed2191a22df5f6970656cb8ca2bd6284309578f2153e0c4b8"}, {file = "sphinxcontrib_jsmath-1.0.1-py2.py3-none-any.whl", hash = "sha256:2ec2eaebfb78f3f2078e73666b1415417a116cc848b72e5172e596c871103178"}, @@ -2197,6 +2311,7 @@ version = "2.0.0" description = "sphinxcontrib-qthelp is a sphinx extension which outputs QtHelp documents" optional = false python-versions = ">=3.9" +groups = ["main"] files = [ {file = "sphinxcontrib_qthelp-2.0.0-py3-none-any.whl", hash = "sha256:b18a828cdba941ccd6ee8445dbe72ffa3ef8cbe7505d8cd1fa0d42d3f2d5f3eb"}, {file = "sphinxcontrib_qthelp-2.0.0.tar.gz", hash = "sha256:4fe7d0ac8fc171045be623aba3e2a8f613f8682731f9153bb2e40ece16b9bbab"}, @@ -2213,6 +2328,7 @@ version = "2.0.0" description = "sphinxcontrib-serializinghtml is a sphinx extension which outputs \"serialized\" HTML files (json and pickle)" optional = false python-versions = ">=3.9" +groups = ["main"] files = [ {file = "sphinxcontrib_serializinghtml-2.0.0-py3-none-any.whl", hash = "sha256:6e2cb0eef194e10c27ec0023bfeb25badbbb5868244cf5bc5bdc04e4464bf331"}, {file = "sphinxcontrib_serializinghtml-2.0.0.tar.gz", hash = "sha256:e9d912827f872c029017a53f0ef2180b327c3f7fd23c87229f7a8e8b70031d4d"}, @@ -2229,6 +2345,7 @@ version = "0.13.2" description = "Style preserving TOML library" optional = false python-versions = ">=3.8" +groups = ["main"] files = [ {file = "tomlkit-0.13.2-py3-none-any.whl", hash = "sha256:7a974427f6e119197f670fbbbeae7bef749a6c14e793db934baefc1b5f03efde"}, {file = "tomlkit-0.13.2.tar.gz", hash = "sha256:fff5fe59a87295b278abd31bec92c15d9bc4a06885ab12bcea52c71119392e79"}, @@ -2240,6 +2357,7 @@ version = "0.5.1" description = "a Pythonic logger" optional = false python-versions = "*" +groups = ["main"] files = [ {file = "Twiggy-0.5.1-py3-none-any.whl", hash = "sha256:014671fdff7538b7f2396ff01724937ef57e1ac0e08f688747afbbcdeec9f081"}, {file = "Twiggy-0.5.1.tar.gz", hash = "sha256:7938840275972f6ce89994a5bdfb0b84f0386301a043a960af6364952e78ffe4"}, @@ -2254,6 +2372,7 @@ version = "0.15.1" description = "Typer, build great CLIs. Easy to code. Based on Python type hints." optional = false python-versions = ">=3.7" +groups = ["main"] files = [ {file = "typer-0.15.1-py3-none-any.whl", hash = "sha256:7994fb7b8155b64d3402518560648446072864beefd44aa2dc36972a5972e847"}, {file = "typer-0.15.1.tar.gz", hash = "sha256:a0588c0a7fa68a1978a069818657778f86abe6ff5ea6abf472f940a08bfe4f0a"}, @@ -2271,6 +2390,7 @@ version = "4.12.2" description = "Backported and Experimental Type Hints for Python 3.8+" optional = false python-versions = ">=3.8" +groups = ["main"] files = [ {file = "typing_extensions-4.12.2-py3-none-any.whl", hash = "sha256:04e5ca0351e0f3f85c6853954072df659d0d13fac324d0072316b67d7794700d"}, {file = "typing_extensions-4.12.2.tar.gz", hash = "sha256:1a7ead55c7e559dd4dee8856e3a88b41225abfe1ce8df57b7c13915fe121ffb8"}, @@ -2278,20 +2398,21 @@ files = [ [[package]] name = "urllib3" -version = "2.3.0" +version = "2.6.0" description = "HTTP library with thread-safe connection pooling, file post, and more." optional = false python-versions = ">=3.9" +groups = ["main"] files = [ - {file = "urllib3-2.3.0-py3-none-any.whl", hash = "sha256:1cee9ad369867bfdbbb48b7dd50374c0967a0bb7710050facf0dd6911440e3df"}, - {file = "urllib3-2.3.0.tar.gz", hash = "sha256:f8c5449b3cf0861679ce7e0503c7b44b5ec981bec0d1d3795a07f1ba96f0204d"}, + {file = "urllib3-2.6.0-py3-none-any.whl", hash = "sha256:c90f7a39f716c572c4e3e58509581ebd83f9b59cced005b7db7ad2d22b0db99f"}, + {file = "urllib3-2.6.0.tar.gz", hash = "sha256:cb9bcef5a4b345d5da5d145dc3e30834f58e8018828cbc724d30b4cb7d4d49f1"}, ] [package.extras] -brotli = ["brotli (>=1.0.9)", "brotlicffi (>=0.8.0)"] +brotli = ["brotli (>=1.2.0) ; platform_python_implementation == \"CPython\"", "brotlicffi (>=1.2.0.0) ; platform_python_implementation != \"CPython\""] h2 = ["h2 (>=4,<5)"] socks = ["pysocks (>=1.5.6,!=1.5.7,<2.0)"] -zstd = ["zstandard (>=0.18.0)"] +zstd = ["backports-zstd (>=1.0.0) ; python_version < \"3.14\""] [[package]] name = "yarl" @@ -2299,6 +2420,7 @@ version = "1.18.3" description = "Yet another URL library" optional = false python-versions = ">=3.9" +groups = ["main"] files = [ {file = "yarl-1.18.3-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:7df647e8edd71f000a5208fe6ff8c382a1de8edfbccdbbfe649d263de07d8c34"}, {file = "yarl-1.18.3-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:c69697d3adff5aa4f874b19c0e4ed65180ceed6318ec856ebc423aa5850d84f7"}, @@ -2395,20 +2517,21 @@ version = "3.21.0" description = "Backport of pathlib-compatible object wrapper for zip files" optional = false python-versions = ">=3.9" +groups = ["main"] files = [ {file = "zipp-3.21.0-py3-none-any.whl", hash = "sha256:ac1bbe05fd2991f160ebce24ffbac5f6d11d83dc90891255885223d42b3cd931"}, {file = "zipp-3.21.0.tar.gz", hash = "sha256:2c9958f6430a2040341a52eb608ed6dd93ef4392e02ffe219417c1b28b5dd1f4"}, ] [package.extras] -check = ["pytest-checkdocs (>=2.4)", "pytest-ruff (>=0.2.1)"] +check = ["pytest-checkdocs (>=2.4)", "pytest-ruff (>=0.2.1) ; sys_platform != \"cygwin\""] cover = ["pytest-cov"] doc = ["furo", "jaraco.packaging (>=9.3)", "jaraco.tidelift (>=1.4)", "rst.linker (>=1.9)", "sphinx (>=3.5)", "sphinx-lint"] enabler = ["pytest-enabler (>=2.2)"] -test = ["big-O", "importlib-resources", "jaraco.functools", "jaraco.itertools", "jaraco.test", "more-itertools", "pytest (>=6,!=8.1.*)", "pytest-ignore-flaky"] +test = ["big-O", "importlib-resources ; python_version < \"3.9\"", "jaraco.functools", "jaraco.itertools", "jaraco.test", "more-itertools", "pytest (>=6,!=8.1.*)", "pytest-ignore-flaky"] type = ["pytest-mypy"] [metadata] -lock-version = "2.0" -python-versions = "^3.13" -content-hash = "fb917643d30d83ca310e4698cbef9002738d2133ad33083418d0ad7f85e2161a" +lock-version = "2.1" +python-versions = ">=3.11,<3.14" +content-hash = "7d535aae6b77b11cdf20aa281f4e22547383acf6f2f12067645c0ecea99d134b" diff --git a/pyproject.toml b/pyproject.toml index 3b0823fe6..439223d19 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,12 +1,12 @@ [tool.poetry] name = "netbox_ansible_modules" -version = "3.21.0" +version = "3.22.0" description = "Ansible collection to interact with NetBox's API" authors = ["Mikhail Yohman "] license = "GPLv3" [tool.poetry.dependencies] -python = "^3.13" +python = ">=3.11,<3.14" ansible-core = "^2.18" black = "*" codecov = "*" @@ -30,7 +30,10 @@ packaging = "*" importlib-resources = "*" antsibull-docs = "*" -[tool.poetry.dev-dependencies] +[poetry.group.dev.dependencies] + +[tool.ruff] +target-version = "py311" [build-system] requires = ["poetry-core>=1.0.0"] diff --git a/requirements.yml b/requirements.yml index 46c178c76..fbb60e9a5 100644 --- a/requirements.yml +++ b/requirements.yml @@ -1,2 +1,3 @@ +--- collections: - name: . diff --git a/tests/integration/netbox-deploy.py b/tests/integration/netbox-deploy.py index af5a7b5af..5d3b38dc5 100755 --- a/tests/integration/netbox-deploy.py +++ b/tests/integration/netbox-deploy.py @@ -387,6 +387,11 @@ def make_netbox_calls(endpoint, payload): "assigned_object_id": test100_gi2.id, "assigned_object_type": "dcim.interface", }, + { + "mac_address": "AA:BB:CC:DD:EE:FF", # Identical to id 1 + "assigned_object_id": test100_gi2.id, + "assigned_object_type": "dcim.interface", + }, ] created_mac_addresses = make_netbox_calls(nb.dcim.mac_addresses, mac_addresses) diff --git a/tests/integration/targets/inventory-v4.1/compare_inventory_json.py b/tests/integration/targets/inventory-v4.1/compare_inventory_json.py index ccdf8bd52..20b39e83e 100755 --- a/tests/integration/targets/inventory-v4.1/compare_inventory_json.py +++ b/tests/integration/targets/inventory-v4.1/compare_inventory_json.py @@ -141,7 +141,7 @@ def main(): if result: # Dictionary is not empty - print differences - print(json.dumps(result, sort_keys=True, indent=4)) + print(result.to_json(indent=4)) sys.exit(1) else: # Success, no differences diff --git a/tests/integration/targets/inventory-v4.2/compare_inventory_json.py b/tests/integration/targets/inventory-v4.2/compare_inventory_json.py index ccdf8bd52..20b39e83e 100755 --- a/tests/integration/targets/inventory-v4.2/compare_inventory_json.py +++ b/tests/integration/targets/inventory-v4.2/compare_inventory_json.py @@ -141,7 +141,7 @@ def main(): if result: # Dictionary is not empty - print differences - print(json.dumps(result, sort_keys=True, indent=4)) + print(result.to_json(indent=4)) sys.exit(1) else: # Success, no differences diff --git a/tests/integration/targets/inventory-v4.3/.gitignore b/tests/integration/targets/inventory-v4.3/.gitignore new file mode 100644 index 000000000..df76504d5 --- /dev/null +++ b/tests/integration/targets/inventory-v4.3/.gitignore @@ -0,0 +1 @@ +runme_config \ No newline at end of file diff --git a/tests/integration/targets/inventory-v4.3/aliases b/tests/integration/targets/inventory-v4.3/aliases new file mode 100644 index 000000000..a3a2089b9 --- /dev/null +++ b/tests/integration/targets/inventory-v4.3/aliases @@ -0,0 +1 @@ +# https://docs.ansible.com/ansible/devel/dev_guide/testing/sanity/integration-aliases.html diff --git a/tests/integration/targets/inventory-v4.3/compare_inventory_json.py b/tests/integration/targets/inventory-v4.3/compare_inventory_json.py new file mode 100755 index 000000000..20b39e83e --- /dev/null +++ b/tests/integration/targets/inventory-v4.3/compare_inventory_json.py @@ -0,0 +1,152 @@ +#!/usr/bin/env python + +# Inspired by community.aws collection script_inventory_ec2 test +# https://github.com/ansible-collections/community.aws/blob/master/tests/integration/targets/script_inventory_ec2/inventory_diff.py + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +import argparse +import json +import sys +from operator import itemgetter + +from deepdiff import DeepDiff + +# NetBox includes "created" and "last_updated" times on objects. These end up in the interfaces objects that are included verbatim from the NetBox API. +# "url" may be different if local tests use a different host/port +# Remove these from files saved in git as test data +KEYS_REMOVE = frozenset(["created", "last_updated", "url"]) + +# Ignore these when performing diffs as they will be different for each test run +# (Was previously keys specific to NetBox 2.6) +KEYS_IGNORE = frozenset() + +# Rack Groups became hierarchical in NetBox 2.8. Don't bother comparing against test data in NetBox 2.7 +KEYS_IGNORE_27 = frozenset( + [ + "rack_groups", # host var + "rack_group_parent_rack_group", # group, group_names_raw = False + "parent_rack_group", # group, group_names_raw = True + ] +) + + +# Assume the object will not be recursive, as it originally came from JSON +def remove_keys(obj, keys): + if isinstance(obj, dict): + keys_to_remove = keys.intersection(obj.keys()) + for key in keys_to_remove: + del obj[key] + + for key, value in obj.items(): + remove_keys(value, keys) + + elif isinstance(obj, list): + # Iterate over temporary copy, as we may remove items + for item in obj[:]: + if isinstance(item, str) and item in keys: + # List contains a string that we want to remove + # eg. a group name in list of groups + obj.remove(item) + remove_keys(item, keys) + + +def sort_hostvar_arrays(obj): + meta = obj.get("_meta") + if not meta: + return + + hostvars = meta.get("hostvars") + if not hostvars: + return + + for _, host in hostvars.items(): # pylint: disable=disallowed-name + if interfaces := host.get("interfaces"): + host["interfaces"] = sorted(interfaces, key=itemgetter("id")) + + if services := host.get("services"): + host["services"] = sorted(services, key=itemgetter("id")) + + +def read_json(filename): + with open(filename, "r", encoding="utf-8") as file: + return json.loads(file.read()) + + +def write_json(filename, data): + with open(filename, "w", encoding="utf-8") as file: + json.dump(data, file, indent=4) + + +def main(): + parser = argparse.ArgumentParser(description="Diff Ansible inventory JSON output") + parser.add_argument( + "filename_a", + metavar="ORIGINAL.json", + type=str, + help="Original json to test against", + ) + parser.add_argument( + "filename_b", + metavar="NEW.json", + type=str, + help="Newly generated json to compare against original", + ) + parser.add_argument( + "--write", + action="store_true", + help=( + "When comparing files, various keys are removed. " + "This option will not compare the files, and instead writes ORIGINAL.json to NEW.json after removing these keys. " + "This is used to clean the test json files before saving to the git repo. " + "For example, this removes dates. " + ), + ) + parser.add_argument( + "--netbox-version", + metavar="VERSION", + type=str, + help=( + "Apply comparison specific to NetBox version. " + "For example, rack_groups arrays will only contain a single item in v2.7, so are ignored in the comparison." + ), + ) + + args = parser.parse_args() + + data_a = read_json(args.filename_a) + + if args.write: + # When writing test data, only remove "remove_keys" that will change on every git commit. + # This makes diffs more easily readable to ensure changes to test data look correct. + remove_keys(data_a, KEYS_REMOVE) + sort_hostvar_arrays(data_a) + write_json(args.filename_b, data_a) + + else: + data_b = read_json(args.filename_b) + + # Ignore keys that we don't want to diff, in addition to the ones removed that change on every commit + keys = KEYS_REMOVE.union(KEYS_IGNORE) + remove_keys(data_a, keys) + remove_keys(data_b, keys) + + sort_hostvar_arrays(data_a) + sort_hostvar_arrays(data_b) + + # Perform the diff + result = DeepDiff(data_a, data_b, ignore_order=True) + + if result: + # Dictionary is not empty - print differences + print(result.to_json(indent=4)) + sys.exit(1) + else: + # Success, no differences + sys.exit(0) + + +if __name__ == "__main__": + main() diff --git a/tests/integration/targets/inventory-v4.3/files/test-inventory-bearer-token.json b/tests/integration/targets/inventory-v4.3/files/test-inventory-bearer-token.json new file mode 100644 index 000000000..832458310 --- /dev/null +++ b/tests/integration/targets/inventory-v4.3/files/test-inventory-bearer-token.json @@ -0,0 +1,1347 @@ +{ + "_meta": { + "hostvars": { + "R1-Device": { + "asset_tag": "345678901", + "config_context": {}, + "custom_fields": {}, + "device_type": "cisco-test", + "interfaces": [], + "is_virtual": false, + "locations": [], + "manufacturer": "cisco", + "rack": "Test Rack Site 2", + "rack_role": "test-rack-role", + "regions": [], + "role": "core-switch", + "serial": "", + "services": [], + "site": "test-site2", + "site_groups": [], + "status": { + "label": "Active", + "value": "active" + }, + "tags": [] + }, + "Test Nexus One": { + "ansible_host": "172.16.180.12", + "config_context": {}, + "custom_fields": {}, + "device_type": "nexus-parent", + "dns_name": "nexus.example.com", + "interfaces": [ + { + "_occupied": false, + "bridge": null, + "cable": null, + "cable_end": "", + "connected_endpoints": null, + "connected_endpoints_reachable": null, + "connected_endpoints_type": null, + "count_fhrp_groups": 0, + "count_ipaddresses": 1, + "custom_fields": {}, + "description": "", + "device": { + "description": "", + "display": "Test Nexus One", + "id": 4, + "name": "Test Nexus One" + }, + "display": "Ethernet1/1", + "display_url": "http://localhost:32768/dcim/interfaces/1/", + "duplex": null, + "enabled": true, + "id": 1, + "ip_addresses": [ + { + "address": "172.16.180.11/24", + "comments": "", + "custom_fields": {}, + "description": "", + "display": "172.16.180.11/24", + "display_url": "http://localhost:32768/ipam/ip-addresses/3/", + "dns_name": "", + "family": { + "label": "IPv4", + "value": 4 + }, + "id": 3, + "nat_inside": null, + "nat_outside": [], + "role": null, + "status": { + "label": "Active", + "value": "active" + }, + "tags": [], + "tenant": null, + "vrf": null + } + ], + "l2vpn_termination": null, + "label": "", + "lag": null, + "link_peers": [], + "link_peers_type": null, + "mac_address": null, + "mark_connected": false, + "mgmt_only": false, + "mode": null, + "module": null, + "mtu": null, + "name": "Ethernet1/1", + "parent": null, + "poe_mode": null, + "poe_type": null, + "rf_channel": null, + "rf_channel_frequency": null, + "rf_channel_width": null, + "rf_role": null, + "speed": null, + "tagged_vlans": [], + "tags": [], + "tx_power": null, + "type": { + "label": "1000BASE-T (1GE)", + "value": "1000base-t" + }, + "untagged_vlan": null, + "vdcs": [], + "vrf": null, + "wireless_lans": [], + "wireless_link": null, + "wwn": null + }, + { + "_occupied": false, + "bridge": null, + "cable": null, + "cable_end": "", + "connected_endpoints": null, + "connected_endpoints_reachable": null, + "connected_endpoints_type": null, + "count_fhrp_groups": 0, + "count_ipaddresses": 1, + "custom_fields": {}, + "description": "", + "device": { + "description": "", + "display": "Test Nexus Child One", + "id": 5, + "name": "Test Nexus Child One" + }, + "display": "Ethernet2/1", + "display_url": "http://localhost:32768/dcim/interfaces/2/", + "duplex": null, + "enabled": true, + "id": 2, + "ip_addresses": [ + { + "address": "172.16.180.12/24", + "comments": "", + "custom_fields": {}, + "description": "", + "display": "172.16.180.12/24", + "display_url": "http://localhost:32768/ipam/ip-addresses/4/", + "dns_name": "nexus.example.com", + "family": { + "label": "IPv4", + "value": 4 + }, + "id": 4, + "nat_inside": null, + "nat_outside": [], + "role": null, + "status": { + "label": "Active", + "value": "active" + }, + "tags": [], + "tenant": null, + "vrf": null + } + ], + "l2vpn_termination": null, + "label": "", + "lag": null, + "link_peers": [], + "link_peers_type": null, + "mac_address": null, + "mark_connected": false, + "mgmt_only": false, + "mode": null, + "module": null, + "mtu": null, + "name": "Ethernet2/1", + "parent": null, + "poe_mode": null, + "poe_type": null, + "rf_channel": null, + "rf_channel_frequency": null, + "rf_channel_width": null, + "rf_role": null, + "speed": null, + "tagged_vlans": [], + "tags": [], + "tx_power": null, + "type": { + "label": "1000BASE-T (1GE)", + "value": "1000base-t" + }, + "untagged_vlan": null, + "vdcs": [], + "vrf": null, + "wireless_lans": [], + "wireless_link": null, + "wwn": null + }, + { + "_occupied": false, + "bridge": null, + "cable": null, + "cable_end": "", + "connected_endpoints": null, + "connected_endpoints_reachable": null, + "connected_endpoints_type": null, + "count_fhrp_groups": 0, + "count_ipaddresses": 0, + "custom_fields": {}, + "description": "", + "device": { + "description": "", + "display": "Test Nexus One", + "id": 4, + "name": "Test Nexus One" + }, + "display": "wlink1", + "display_url": "http://localhost:32768/dcim/interfaces/6/", + "duplex": null, + "enabled": true, + "id": 6, + "ip_addresses": [], + "l2vpn_termination": null, + "label": "", + "lag": null, + "link_peers": [], + "link_peers_type": null, + "mac_address": null, + "mark_connected": false, + "mgmt_only": false, + "mode": null, + "module": null, + "mtu": null, + "name": "wlink1", + "parent": null, + "poe_mode": null, + "poe_type": null, + "rf_channel": null, + "rf_channel_frequency": null, + "rf_channel_width": null, + "rf_role": null, + "speed": null, + "tagged_vlans": [], + "tags": [], + "tx_power": null, + "type": { + "label": "IEEE 802.11a", + "value": "ieee802.11a" + }, + "untagged_vlan": null, + "vdcs": [], + "vrf": null, + "wireless_lans": [], + "wireless_link": null, + "wwn": null + } + ], + "is_virtual": false, + "locations": [ + "test-rack-group", + "parent-rack-group" + ], + "manufacturer": "cisco", + "primary_ip4": "172.16.180.12", + "regions": [ + "test-region", + "parent-region" + ], + "role": "core-switch", + "serial": "", + "services": [ + { + "comments": "", + "custom_fields": {}, + "description": "", + "device": { + "description": "", + "display": "Test Nexus One", + "id": 4, + "name": "Test Nexus One" + }, + "display": "telnet (TCP/23)", + "display_url": "http://localhost:32768/ipam/services/3/", + "id": 3, + "ipaddresses": [], + "name": "telnet", + "ports": [ + 23 + ], + "protocol": { + "label": "TCP", + "value": "tcp" + }, + "tags": [], + "virtual_machine": null + } + ], + "site": "test-site", + "site_groups": [], + "status": { + "label": "Active", + "value": "active" + }, + "tags": [] + }, + "Test VM With Spaces": { + "cluster": "Test Cluster 2", + "cluster_type": "test-cluster-type", + "config_context": {}, + "custom_fields": {}, + "interfaces": [ + { + "bridge": null, + "count_fhrp_groups": 0, + "count_ipaddresses": 0, + "custom_fields": {}, + "description": "", + "display": "Eth0", + "display_url": "http://localhost:32768/virtualization/interfaces/11/", + "enabled": true, + "id": 11, + "ip_addresses": [], + "l2vpn_termination": null, + "mac_address": null, + "mode": null, + "mtu": null, + "name": "Eth0", + "parent": null, + "tagged_vlans": [], + "tags": [], + "untagged_vlan": null, + "virtual_machine": { + "description": "", + "display": "Test VM With Spaces", + "id": 6, + "name": "Test VM With Spaces" + }, + "vrf": null + }, + { + "bridge": null, + "count_fhrp_groups": 0, + "count_ipaddresses": 0, + "custom_fields": {}, + "description": "", + "display": "Eth1", + "display_url": "http://localhost:32768/virtualization/interfaces/12/", + "enabled": true, + "id": 12, + "ip_addresses": [], + "l2vpn_termination": null, + "mac_address": null, + "mode": null, + "mtu": null, + "name": "Eth1", + "parent": null, + "tagged_vlans": [], + "tags": [], + "untagged_vlan": null, + "virtual_machine": { + "description": "", + "display": "Test VM With Spaces", + "id": 6, + "name": "Test VM With Spaces" + }, + "vrf": null + } + ], + "is_virtual": true, + "locations": [], + "regions": [], + "serial": "", + "services": [ + { + "comments": "", + "custom_fields": {}, + "description": "", + "device": null, + "display": "ssh (TCP/22)", + "display_url": "http://localhost:32768/ipam/services/4/", + "id": 4, + "ipaddresses": [], + "name": "ssh", + "ports": [ + 22 + ], + "protocol": { + "label": "TCP", + "value": "tcp" + }, + "tags": [], + "virtual_machine": { + "description": "", + "display": "Test VM With Spaces", + "id": 6, + "name": "Test VM With Spaces" + } + } + ], + "site_groups": [], + "status": { + "label": "Active", + "value": "active" + }, + "tags": [] + }, + "TestDeviceR1": { + "config_context": {}, + "custom_fields": {}, + "device_type": "cisco-test", + "interfaces": [], + "is_virtual": false, + "locations": [ + "test-rack-group", + "parent-rack-group" + ], + "manufacturer": "cisco", + "rack": "Test Rack", + "regions": [ + "test-region", + "parent-region" + ], + "role": "core-switch", + "serial": "FAB12345678", + "services": [], + "site": "test-site", + "site_groups": [], + "status": { + "label": "Active", + "value": "active" + }, + "tags": [] + }, + "test100": { + "asset_tag": "123456789", + "config_context": { + "ntp_servers": [ + "pool.ntp.org" + ] + }, + "custom_fields": {}, + "device_type": "cisco-test", + "interfaces": [ + { + "_occupied": false, + "bridge": null, + "cable": null, + "cable_end": "", + "connected_endpoints": null, + "connected_endpoints_reachable": null, + "connected_endpoints_type": null, + "count_fhrp_groups": 0, + "count_ipaddresses": 1, + "custom_fields": {}, + "description": "", + "device": { + "description": "", + "display": "test100 (123456789)", + "id": 1, + "name": "test100" + }, + "display": "GigabitEthernet1", + "display_url": "http://localhost:32768/dcim/interfaces/3/", + "duplex": null, + "enabled": true, + "id": 3, + "ip_addresses": [ + { + "address": "172.16.180.1/24", + "comments": "", + "custom_fields": {}, + "description": "", + "display": "172.16.180.1/24", + "display_url": "http://localhost:32768/ipam/ip-addresses/1/", + "dns_name": "", + "family": { + "label": "IPv4", + "value": 4 + }, + "id": 1, + "nat_inside": null, + "nat_outside": [], + "role": null, + "status": { + "label": "Active", + "value": "active" + }, + "tags": [], + "tenant": null, + "vrf": null + } + ], + "l2vpn_termination": null, + "label": "", + "lag": null, + "link_peers": [], + "link_peers_type": null, + "mac_address": null, + "mark_connected": false, + "mgmt_only": false, + "mode": null, + "module": null, + "mtu": null, + "name": "GigabitEthernet1", + "parent": null, + "poe_mode": null, + "poe_type": null, + "rf_channel": null, + "rf_channel_frequency": null, + "rf_channel_width": null, + "rf_role": null, + "speed": null, + "tagged_vlans": [], + "tags": [], + "tx_power": null, + "type": { + "label": "1000BASE-T (1GE)", + "value": "1000base-t" + }, + "untagged_vlan": null, + "vdcs": [], + "vrf": null, + "wireless_lans": [], + "wireless_link": null, + "wwn": null + }, + { + "_occupied": false, + "bridge": null, + "cable": null, + "cable_end": "", + "connected_endpoints": null, + "connected_endpoints_reachable": null, + "connected_endpoints_type": null, + "count_fhrp_groups": 0, + "count_ipaddresses": 1, + "custom_fields": {}, + "description": "", + "device": { + "description": "", + "display": "test100 (123456789)", + "id": 1, + "name": "test100" + }, + "display": "GigabitEthernet2", + "display_url": "http://localhost:32768/dcim/interfaces/4/", + "duplex": null, + "enabled": true, + "id": 4, + "ip_addresses": [ + { + "address": "2001::1:1/64", + "comments": "", + "custom_fields": {}, + "description": "", + "display": "2001::1:1/64", + "display_url": "http://localhost:32768/ipam/ip-addresses/2/", + "dns_name": "", + "family": { + "label": "IPv6", + "value": 6 + }, + "id": 2, + "nat_inside": null, + "nat_outside": [], + "role": null, + "status": { + "label": "Active", + "value": "active" + }, + "tags": [], + "tenant": null, + "vrf": null + } + ], + "l2vpn_termination": null, + "label": "", + "lag": null, + "link_peers": [], + "link_peers_type": null, + "mac_address": null, + "mark_connected": false, + "mgmt_only": false, + "mode": null, + "module": null, + "mtu": null, + "name": "GigabitEthernet2", + "parent": null, + "poe_mode": null, + "poe_type": null, + "rf_channel": null, + "rf_channel_frequency": null, + "rf_channel_width": null, + "rf_role": null, + "speed": null, + "tagged_vlans": [], + "tags": [], + "tx_power": null, + "type": { + "label": "1000BASE-T (1GE)", + "value": "1000base-t" + }, + "untagged_vlan": null, + "vdcs": [], + "vrf": null, + "wireless_lans": [], + "wireless_link": null, + "wwn": null + }, + { + "_occupied": false, + "bridge": null, + "cable": null, + "cable_end": "", + "connected_endpoints": null, + "connected_endpoints_reachable": null, + "connected_endpoints_type": null, + "count_fhrp_groups": 0, + "count_ipaddresses": 0, + "custom_fields": {}, + "description": "", + "device": { + "description": "", + "display": "test100 (123456789)", + "id": 1, + "name": "test100" + }, + "display": "wlink1", + "display_url": "http://localhost:32768/dcim/interfaces/5/", + "duplex": null, + "enabled": true, + "id": 5, + "ip_addresses": [], + "l2vpn_termination": null, + "label": "", + "lag": null, + "link_peers": [], + "link_peers_type": null, + "mac_address": null, + "mark_connected": false, + "mgmt_only": false, + "mode": null, + "module": null, + "mtu": null, + "name": "wlink1", + "parent": null, + "poe_mode": null, + "poe_type": null, + "rf_channel": null, + "rf_channel_frequency": null, + "rf_channel_width": null, + "rf_role": null, + "speed": null, + "tagged_vlans": [], + "tags": [], + "tx_power": null, + "type": { + "label": "IEEE 802.11a", + "value": "ieee802.11a" + }, + "untagged_vlan": null, + "vdcs": [], + "vrf": null, + "wireless_lans": [], + "wireless_link": null, + "wwn": null + } + ], + "is_virtual": false, + "local_context_data": { + "ntp_servers": [ + "pool.ntp.org" + ] + }, + "locations": [ + "test-rack-group", + "parent-rack-group" + ], + "manufacturer": "cisco", + "regions": [ + "test-region", + "parent-region" + ], + "role": "core-switch", + "serial": "FAB01234567", + "services": [ + { + "comments": "", + "custom_fields": {}, + "description": "", + "device": { + "description": "", + "display": "test100 (123456789)", + "id": 1, + "name": "test100" + }, + "display": "ssh (TCP/22)", + "display_url": "http://localhost:32768/ipam/services/1/", + "id": 1, + "ipaddresses": [], + "name": "ssh", + "ports": [ + 22 + ], + "protocol": { + "label": "TCP", + "value": "tcp" + }, + "tags": [], + "virtual_machine": null + }, + { + "comments": "", + "custom_fields": {}, + "description": "", + "device": { + "description": "", + "display": "test100 (123456789)", + "id": 1, + "name": "test100" + }, + "display": "http (TCP/80)", + "display_url": "http://localhost:32768/ipam/services/2/", + "id": 2, + "ipaddresses": [ + { + "address": "172.16.180.1/24", + "description": "", + "display": "172.16.180.1/24", + "family": { + "label": "IPv4", + "value": 4 + }, + "id": 1 + }, + { + "address": "2001::1:1/64", + "description": "", + "display": "2001::1:1/64", + "family": { + "label": "IPv6", + "value": 6 + }, + "id": 2 + } + ], + "name": "http", + "ports": [ + 80 + ], + "protocol": { + "label": "TCP", + "value": "tcp" + }, + "tags": [], + "virtual_machine": null + } + ], + "site": "test-site", + "site_groups": [], + "status": { + "label": "Active", + "value": "active" + }, + "tags": [] + }, + "test100-vm": { + "cluster": "Test Cluster", + "cluster_group": "test-cluster-group", + "cluster_type": "test-cluster-type", + "config_context": {}, + "custom_fields": {}, + "disk": 170, + "interfaces": [ + { + "bridge": null, + "count_fhrp_groups": 0, + "count_ipaddresses": 0, + "custom_fields": {}, + "description": "", + "display": "Eth0", + "display_url": "http://localhost:32768/virtualization/interfaces/1/", + "enabled": true, + "id": 1, + "ip_addresses": [], + "l2vpn_termination": null, + "mac_address": null, + "mode": null, + "mtu": null, + "name": "Eth0", + "parent": null, + "tagged_vlans": [], + "tags": [], + "untagged_vlan": null, + "virtual_machine": { + "description": "", + "display": "test100-vm", + "id": 1, + "name": "test100-vm" + }, + "vrf": null + }, + { + "bridge": null, + "count_fhrp_groups": 0, + "count_ipaddresses": 0, + "custom_fields": {}, + "description": "", + "display": "Eth1", + "display_url": "http://localhost:32768/virtualization/interfaces/2/", + "enabled": true, + "id": 2, + "ip_addresses": [], + "l2vpn_termination": null, + "mac_address": null, + "mode": null, + "mtu": null, + "name": "Eth1", + "parent": null, + "tagged_vlans": [], + "tags": [], + "untagged_vlan": null, + "virtual_machine": { + "description": "", + "display": "test100-vm", + "id": 1, + "name": "test100-vm" + }, + "vrf": null + }, + { + "bridge": null, + "count_fhrp_groups": 0, + "count_ipaddresses": 0, + "custom_fields": {}, + "description": "", + "display": "Eth2", + "display_url": "http://localhost:32768/virtualization/interfaces/3/", + "enabled": true, + "id": 3, + "ip_addresses": [], + "l2vpn_termination": null, + "mac_address": null, + "mode": null, + "mtu": null, + "name": "Eth2", + "parent": null, + "tagged_vlans": [], + "tags": [], + "untagged_vlan": null, + "virtual_machine": { + "description": "", + "display": "test100-vm", + "id": 1, + "name": "test100-vm" + }, + "vrf": null + }, + { + "bridge": null, + "count_fhrp_groups": 0, + "count_ipaddresses": 0, + "custom_fields": {}, + "description": "", + "display": "Eth3", + "display_url": "http://localhost:32768/virtualization/interfaces/4/", + "enabled": true, + "id": 4, + "ip_addresses": [], + "l2vpn_termination": null, + "mac_address": null, + "mode": null, + "mtu": null, + "name": "Eth3", + "parent": null, + "tagged_vlans": [], + "tags": [], + "untagged_vlan": null, + "virtual_machine": { + "description": "", + "display": "test100-vm", + "id": 1, + "name": "test100-vm" + }, + "vrf": null + }, + { + "bridge": null, + "count_fhrp_groups": 0, + "count_ipaddresses": 0, + "custom_fields": {}, + "description": "", + "display": "Eth4", + "display_url": "http://localhost:32768/virtualization/interfaces/5/", + "enabled": true, + "id": 5, + "ip_addresses": [], + "l2vpn_termination": null, + "mac_address": null, + "mode": null, + "mtu": null, + "name": "Eth4", + "parent": null, + "tagged_vlans": [], + "tags": [], + "untagged_vlan": null, + "virtual_machine": { + "description": "", + "display": "test100-vm", + "id": 1, + "name": "test100-vm" + }, + "vrf": null + } + ], + "is_virtual": true, + "locations": [], + "regions": [ + "test-region", + "parent-region" + ], + "serial": "", + "services": [], + "site": "test-site", + "site_groups": [], + "status": { + "label": "Active", + "value": "active" + }, + "tags": [] + }, + "test101-vm": { + "cluster": "Test Cluster", + "cluster_group": "test-cluster-group", + "cluster_type": "test-cluster-type", + "config_context": {}, + "custom_fields": {}, + "interfaces": [ + { + "bridge": null, + "count_fhrp_groups": 0, + "count_ipaddresses": 0, + "custom_fields": {}, + "description": "", + "display": "Eth0", + "display_url": "http://localhost:32768/virtualization/interfaces/6/", + "enabled": true, + "id": 6, + "ip_addresses": [], + "l2vpn_termination": null, + "mac_address": null, + "mode": null, + "mtu": null, + "name": "Eth0", + "parent": null, + "tagged_vlans": [], + "tags": [], + "untagged_vlan": null, + "virtual_machine": { + "description": "", + "display": "test101-vm", + "id": 2, + "name": "test101-vm" + }, + "vrf": null + }, + { + "bridge": null, + "count_fhrp_groups": 0, + "count_ipaddresses": 0, + "custom_fields": {}, + "description": "", + "display": "Eth1", + "display_url": "http://localhost:32768/virtualization/interfaces/7/", + "enabled": true, + "id": 7, + "ip_addresses": [], + "l2vpn_termination": null, + "mac_address": null, + "mode": null, + "mtu": null, + "name": "Eth1", + "parent": null, + "tagged_vlans": [], + "tags": [], + "untagged_vlan": null, + "virtual_machine": { + "description": "", + "display": "test101-vm", + "id": 2, + "name": "test101-vm" + }, + "vrf": null + }, + { + "bridge": null, + "count_fhrp_groups": 0, + "count_ipaddresses": 0, + "custom_fields": {}, + "description": "", + "display": "Eth2", + "display_url": "http://localhost:32768/virtualization/interfaces/8/", + "enabled": true, + "id": 8, + "ip_addresses": [], + "l2vpn_termination": null, + "mac_address": null, + "mode": null, + "mtu": null, + "name": "Eth2", + "parent": null, + "tagged_vlans": [], + "tags": [], + "untagged_vlan": null, + "virtual_machine": { + "description": "", + "display": "test101-vm", + "id": 2, + "name": "test101-vm" + }, + "vrf": null + }, + { + "bridge": null, + "count_fhrp_groups": 0, + "count_ipaddresses": 0, + "custom_fields": {}, + "description": "", + "display": "Eth3", + "display_url": "http://localhost:32768/virtualization/interfaces/9/", + "enabled": true, + "id": 9, + "ip_addresses": [], + "l2vpn_termination": null, + "mac_address": null, + "mode": null, + "mtu": null, + "name": "Eth3", + "parent": null, + "tagged_vlans": [], + "tags": [], + "untagged_vlan": null, + "virtual_machine": { + "description": "", + "display": "test101-vm", + "id": 2, + "name": "test101-vm" + }, + "vrf": null + }, + { + "bridge": null, + "count_fhrp_groups": 0, + "count_ipaddresses": 0, + "custom_fields": {}, + "description": "", + "display": "Eth4", + "display_url": "http://localhost:32768/virtualization/interfaces/10/", + "enabled": true, + "id": 10, + "ip_addresses": [], + "l2vpn_termination": null, + "mac_address": null, + "mode": null, + "mtu": null, + "name": "Eth4", + "parent": null, + "tagged_vlans": [], + "tags": [], + "untagged_vlan": null, + "virtual_machine": { + "description": "", + "display": "test101-vm", + "id": 2, + "name": "test101-vm" + }, + "vrf": null + } + ], + "is_virtual": true, + "locations": [], + "regions": [ + "test-region", + "parent-region" + ], + "serial": "", + "services": [], + "site": "test-site", + "site_groups": [], + "status": { + "label": "Active", + "value": "active" + }, + "tags": [] + }, + "test102-vm": { + "cluster": "Test Cluster", + "cluster_group": "test-cluster-group", + "cluster_type": "test-cluster-type", + "config_context": {}, + "custom_fields": {}, + "interfaces": [], + "is_virtual": true, + "locations": [], + "regions": [ + "test-region", + "parent-region" + ], + "serial": "", + "services": [], + "site": "test-site", + "site_groups": [], + "status": { + "label": "Active", + "value": "active" + }, + "tags": [] + }, + "test103-vm": { + "cluster": "Test Cluster", + "cluster_group": "test-cluster-group", + "cluster_type": "test-cluster-type", + "config_context": {}, + "custom_fields": {}, + "interfaces": [], + "is_virtual": true, + "locations": [], + "regions": [ + "test-region", + "parent-region" + ], + "serial": "", + "services": [], + "site": "test-site", + "site_groups": [], + "status": { + "label": "Active", + "value": "active" + }, + "tags": [] + }, + "test104-vm": { + "cluster": "Test Cluster 2", + "cluster_type": "test-cluster-type", + "config_context": {}, + "custom_fields": {}, + "interfaces": [], + "is_virtual": true, + "locations": [], + "regions": [], + "serial": "", + "services": [], + "site_groups": [], + "status": { + "label": "Active", + "value": "active" + }, + "tags": [] + } + } + }, + "all": { + "children": [ + "ungrouped", + "site_test_site2", + "region_other_region", + "region_parent_region", + "site_group_other_site_group", + "site_group_parent_site_group", + "rack_Test_Rack_Site_2", + "rack_role_test_rack_role", + "role_core_switch", + "device_type_cisco_test", + "manufacturer_cisco", + "status_active", + "device_type_nexus_parent", + "service_telnet", + "rack_Test_Rack", + "service_ssh", + "service_http", + "cluster_Test_Cluster_2", + "cluster_type_test_cluster_type", + "is_virtual", + "cluster_Test_Cluster", + "cluster_group_test_cluster_group" + ] + }, + "cluster_Test_Cluster": { + "hosts": [ + "test100-vm", + "test101-vm", + "test102-vm", + "test103-vm" + ] + }, + "cluster_Test_Cluster_2": { + "hosts": [ + "Test VM With Spaces", + "test104-vm" + ] + }, + "cluster_group_test_cluster_group": { + "hosts": [ + "test100-vm", + "test101-vm", + "test102-vm", + "test103-vm" + ] + }, + "cluster_type_test_cluster_type": { + "hosts": [ + "Test VM With Spaces", + "test100-vm", + "test101-vm", + "test102-vm", + "test103-vm", + "test104-vm" + ] + }, + "device_type_cisco_test": { + "hosts": [ + "R1-Device", + "TestDeviceR1", + "test100" + ] + }, + "device_type_nexus_parent": { + "hosts": [ + "Test Nexus One" + ] + }, + "is_virtual": { + "hosts": [ + "Test VM With Spaces", + "test100-vm", + "test101-vm", + "test102-vm", + "test103-vm", + "test104-vm" + ] + }, + "location_parent_rack_group": { + "children": [ + "location_test_rack_group" + ] + }, + "location_test_rack_group": { + "hosts": [ + "Test Nexus One", + "TestDeviceR1", + "test100" + ] + }, + "manufacturer_cisco": { + "hosts": [ + "R1-Device", + "Test Nexus One", + "TestDeviceR1", + "test100" + ] + }, + "rack_Test_Rack": { + "hosts": [ + "TestDeviceR1" + ] + }, + "rack_Test_Rack_Site_2": { + "hosts": [ + "R1-Device" + ] + }, + "rack_role_test_rack_role": { + "hosts": [ + "R1-Device" + ] + }, + "region_parent_region": { + "children": [ + "region_test_region" + ] + }, + "region_test_region": { + "children": [ + "site_test_site" + ] + }, + "role_core_switch": { + "hosts": [ + "R1-Device", + "Test Nexus One", + "TestDeviceR1", + "test100" + ] + }, + "service_http": { + "hosts": [ + "test100" + ] + }, + "service_ssh": { + "hosts": [ + "test100", + "Test VM With Spaces" + ] + }, + "service_telnet": { + "hosts": [ + "Test Nexus One" + ] + }, + "site_group_parent_site_group": { + "children": [ + "site_group_test_site_group" + ] + }, + "site_test_site": { + "children": [ + "location_parent_rack_group" + ], + "hosts": [ + "test100-vm", + "test101-vm", + "test102-vm", + "test103-vm" + ] + }, + "site_test_site2": { + "hosts": [ + "R1-Device" + ] + }, + "status_active": { + "hosts": [ + "R1-Device", + "Test Nexus One", + "TestDeviceR1", + "test100", + "Test VM With Spaces", + "test100-vm", + "test101-vm", + "test102-vm", + "test103-vm", + "test104-vm" + ] + } +} \ No newline at end of file diff --git a/tests/integration/targets/inventory-v4.3/files/test-inventory-bearer-token.yml b/tests/integration/targets/inventory-v4.3/files/test-inventory-bearer-token.yml new file mode 100644 index 000000000..a19b60db2 --- /dev/null +++ b/tests/integration/targets/inventory-v4.3/files/test-inventory-bearer-token.yml @@ -0,0 +1,32 @@ +--- +plugin: netbox.netbox.nb_inventory +api_endpoint: http://localhost:32768 +token: + type: Token + value: "0123456789abcdef0123456789abcdef01234567" +validate_certs: false + +config_context: true +plurals: false +interfaces: true +services: true + +group_by: + - site + - tenant + - rack + - location + - rack_role + - tag + - role + - device_type + - manufacturer + - platform + - region + - site_group + - cluster + - cluster_group + - cluster_type + - is_virtual + - services + - status diff --git a/tests/integration/targets/inventory-v4.3/files/test-inventory-jinja2-filter.json b/tests/integration/targets/inventory-v4.3/files/test-inventory-jinja2-filter.json new file mode 100644 index 000000000..945e4f378 --- /dev/null +++ b/tests/integration/targets/inventory-v4.3/files/test-inventory-jinja2-filter.json @@ -0,0 +1,1170 @@ +{ + "_meta": { + "hostvars": { + "Test Nexus One": { + "ansible_host": "172.16.180.12", + "config_context": {}, + "custom_fields": {}, + "device_type": "nexus-parent", + "dns_name": "nexus.example.com", + "interfaces": [ + { + "_occupied": false, + "bridge": null, + "cable": null, + "cable_end": "", + "connected_endpoints": null, + "connected_endpoints_reachable": null, + "connected_endpoints_type": null, + "count_fhrp_groups": 0, + "count_ipaddresses": 1, + "custom_fields": {}, + "description": "", + "device": { + "description": "", + "display": "Test Nexus One", + "id": 4, + "name": "Test Nexus One" + }, + "display": "Ethernet1/1", + "display_url": "http://localhost:32768/dcim/interfaces/1/", + "duplex": null, + "enabled": true, + "id": 1, + "ip_addresses": [ + { + "address": "172.16.180.11/24", + "comments": "", + "custom_fields": {}, + "description": "", + "display": "172.16.180.11/24", + "display_url": "http://localhost:32768/ipam/ip-addresses/3/", + "dns_name": "", + "family": { + "label": "IPv4", + "value": 4 + }, + "id": 3, + "nat_inside": null, + "nat_outside": [], + "role": null, + "status": { + "label": "Active", + "value": "active" + }, + "tags": [], + "tenant": null, + "vrf": null + } + ], + "l2vpn_termination": null, + "label": "", + "lag": null, + "link_peers": [], + "link_peers_type": null, + "mac_address": null, + "mark_connected": false, + "mgmt_only": false, + "mode": null, + "module": null, + "mtu": null, + "name": "Ethernet1/1", + "parent": null, + "poe_mode": null, + "poe_type": null, + "rf_channel": null, + "rf_channel_frequency": null, + "rf_channel_width": null, + "rf_role": null, + "speed": null, + "tagged_vlans": [], + "tags": [], + "tx_power": null, + "type": { + "label": "1000BASE-T (1GE)", + "value": "1000base-t" + }, + "untagged_vlan": null, + "vdcs": [], + "vrf": null, + "wireless_lans": [], + "wireless_link": null, + "wwn": null + }, + { + "_occupied": false, + "bridge": null, + "cable": null, + "cable_end": "", + "connected_endpoints": null, + "connected_endpoints_reachable": null, + "connected_endpoints_type": null, + "count_fhrp_groups": 0, + "count_ipaddresses": 1, + "custom_fields": {}, + "description": "", + "device": { + "description": "", + "display": "Test Nexus Child One", + "id": 5, + "name": "Test Nexus Child One" + }, + "display": "Ethernet2/1", + "display_url": "http://localhost:32768/dcim/interfaces/2/", + "duplex": null, + "enabled": true, + "id": 2, + "ip_addresses": [ + { + "address": "172.16.180.12/24", + "comments": "", + "custom_fields": {}, + "description": "", + "display": "172.16.180.12/24", + "display_url": "http://localhost:32768/ipam/ip-addresses/4/", + "dns_name": "nexus.example.com", + "family": { + "label": "IPv4", + "value": 4 + }, + "id": 4, + "nat_inside": null, + "nat_outside": [], + "role": null, + "status": { + "label": "Active", + "value": "active" + }, + "tags": [], + "tenant": null, + "vrf": null + } + ], + "l2vpn_termination": null, + "label": "", + "lag": null, + "link_peers": [], + "link_peers_type": null, + "mac_address": null, + "mark_connected": false, + "mgmt_only": false, + "mode": null, + "module": null, + "mtu": null, + "name": "Ethernet2/1", + "parent": null, + "poe_mode": null, + "poe_type": null, + "rf_channel": null, + "rf_channel_frequency": null, + "rf_channel_width": null, + "rf_role": null, + "speed": null, + "tagged_vlans": [], + "tags": [], + "tx_power": null, + "type": { + "label": "1000BASE-T (1GE)", + "value": "1000base-t" + }, + "untagged_vlan": null, + "vdcs": [], + "vrf": null, + "wireless_lans": [], + "wireless_link": null, + "wwn": null + }, + { + "_occupied": false, + "bridge": null, + "cable": null, + "cable_end": "", + "connected_endpoints": null, + "connected_endpoints_reachable": null, + "connected_endpoints_type": null, + "count_fhrp_groups": 0, + "count_ipaddresses": 0, + "custom_fields": {}, + "description": "", + "device": { + "description": "", + "display": "Test Nexus One", + "id": 4, + "name": "Test Nexus One" + }, + "display": "wlink1", + "display_url": "http://localhost:32768/dcim/interfaces/6/", + "duplex": null, + "enabled": true, + "id": 6, + "ip_addresses": [], + "l2vpn_termination": null, + "label": "", + "lag": null, + "link_peers": [], + "link_peers_type": null, + "mac_address": null, + "mark_connected": false, + "mgmt_only": false, + "mode": null, + "module": null, + "mtu": null, + "name": "wlink1", + "parent": null, + "poe_mode": null, + "poe_type": null, + "rf_channel": null, + "rf_channel_frequency": null, + "rf_channel_width": null, + "rf_role": null, + "speed": null, + "tagged_vlans": [], + "tags": [], + "tx_power": null, + "type": { + "label": "IEEE 802.11a", + "value": "ieee802.11a" + }, + "untagged_vlan": null, + "vdcs": [], + "vrf": null, + "wireless_lans": [], + "wireless_link": null, + "wwn": null + } + ], + "is_virtual": false, + "locations": [ + "test-rack-group", + "parent-rack-group" + ], + "manufacturer": "cisco", + "primary_ip4": "172.16.180.12", + "regions": [ + "test-region", + "parent-region" + ], + "role": "core-switch", + "serial": "", + "services": [ + { + "comments": "", + "custom_fields": {}, + "description": "", + "device": { + "description": "", + "display": "Test Nexus One", + "id": 4, + "name": "Test Nexus One" + }, + "display": "telnet (TCP/23)", + "display_url": "http://localhost:32768/ipam/services/3/", + "id": 3, + "ipaddresses": [], + "name": "telnet", + "ports": [ + 23 + ], + "protocol": { + "label": "TCP", + "value": "tcp" + }, + "tags": [], + "virtual_machine": null + } + ], + "site": "test-site", + "site_groups": [], + "status": { + "label": "Active", + "value": "active" + }, + "tags": [] + }, + "TestDeviceR1": { + "config_context": {}, + "custom_fields": {}, + "device_type": "cisco-test", + "interfaces": [], + "is_virtual": false, + "locations": [ + "test-rack-group", + "parent-rack-group" + ], + "manufacturer": "cisco", + "rack": "Test Rack", + "regions": [ + "test-region", + "parent-region" + ], + "role": "core-switch", + "serial": "FAB12345678", + "services": [], + "site": "test-site", + "site_groups": [], + "status": { + "label": "Active", + "value": "active" + }, + "tags": [] + }, + "test100": { + "asset_tag": "123456789", + "config_context": { + "ntp_servers": [ + "pool.ntp.org" + ] + }, + "custom_fields": {}, + "device_type": "cisco-test", + "interfaces": [ + { + "_occupied": false, + "bridge": null, + "cable": null, + "cable_end": "", + "connected_endpoints": null, + "connected_endpoints_reachable": null, + "connected_endpoints_type": null, + "count_fhrp_groups": 0, + "count_ipaddresses": 1, + "custom_fields": {}, + "description": "", + "device": { + "description": "", + "display": "test100 (123456789)", + "id": 1, + "name": "test100" + }, + "display": "GigabitEthernet1", + "display_url": "http://localhost:32768/dcim/interfaces/3/", + "duplex": null, + "enabled": true, + "id": 3, + "ip_addresses": [ + { + "address": "172.16.180.1/24", + "comments": "", + "custom_fields": {}, + "description": "", + "display": "172.16.180.1/24", + "display_url": "http://localhost:32768/ipam/ip-addresses/1/", + "dns_name": "", + "family": { + "label": "IPv4", + "value": 4 + }, + "id": 1, + "nat_inside": null, + "nat_outside": [], + "role": null, + "status": { + "label": "Active", + "value": "active" + }, + "tags": [], + "tenant": null, + "vrf": null + } + ], + "l2vpn_termination": null, + "label": "", + "lag": null, + "link_peers": [], + "link_peers_type": null, + "mac_address": null, + "mark_connected": false, + "mgmt_only": false, + "mode": null, + "module": null, + "mtu": null, + "name": "GigabitEthernet1", + "parent": null, + "poe_mode": null, + "poe_type": null, + "rf_channel": null, + "rf_channel_frequency": null, + "rf_channel_width": null, + "rf_role": null, + "speed": null, + "tagged_vlans": [], + "tags": [], + "tx_power": null, + "type": { + "label": "1000BASE-T (1GE)", + "value": "1000base-t" + }, + "untagged_vlan": null, + "vdcs": [], + "vrf": null, + "wireless_lans": [], + "wireless_link": null, + "wwn": null + }, + { + "_occupied": false, + "bridge": null, + "cable": null, + "cable_end": "", + "connected_endpoints": null, + "connected_endpoints_reachable": null, + "connected_endpoints_type": null, + "count_fhrp_groups": 0, + "count_ipaddresses": 1, + "custom_fields": {}, + "description": "", + "device": { + "description": "", + "display": "test100 (123456789)", + "id": 1, + "name": "test100" + }, + "display": "GigabitEthernet2", + "display_url": "http://localhost:32768/dcim/interfaces/4/", + "duplex": null, + "enabled": true, + "id": 4, + "ip_addresses": [ + { + "address": "2001::1:1/64", + "comments": "", + "custom_fields": {}, + "description": "", + "display": "2001::1:1/64", + "display_url": "http://localhost:32768/ipam/ip-addresses/2/", + "dns_name": "", + "family": { + "label": "IPv6", + "value": 6 + }, + "id": 2, + "nat_inside": null, + "nat_outside": [], + "role": null, + "status": { + "label": "Active", + "value": "active" + }, + "tags": [], + "tenant": null, + "vrf": null + } + ], + "l2vpn_termination": null, + "label": "", + "lag": null, + "link_peers": [], + "link_peers_type": null, + "mac_address": null, + "mark_connected": false, + "mgmt_only": false, + "mode": null, + "module": null, + "mtu": null, + "name": "GigabitEthernet2", + "parent": null, + "poe_mode": null, + "poe_type": null, + "rf_channel": null, + "rf_channel_frequency": null, + "rf_channel_width": null, + "rf_role": null, + "speed": null, + "tagged_vlans": [], + "tags": [], + "tx_power": null, + "type": { + "label": "1000BASE-T (1GE)", + "value": "1000base-t" + }, + "untagged_vlan": null, + "vdcs": [], + "vrf": null, + "wireless_lans": [], + "wireless_link": null, + "wwn": null + }, + { + "_occupied": false, + "bridge": null, + "cable": null, + "cable_end": "", + "connected_endpoints": null, + "connected_endpoints_reachable": null, + "connected_endpoints_type": null, + "count_fhrp_groups": 0, + "count_ipaddresses": 0, + "custom_fields": {}, + "description": "", + "device": { + "description": "", + "display": "test100 (123456789)", + "id": 1, + "name": "test100" + }, + "display": "wlink1", + "display_url": "http://localhost:32768/dcim/interfaces/5/", + "duplex": null, + "enabled": true, + "id": 5, + "ip_addresses": [], + "l2vpn_termination": null, + "label": "", + "lag": null, + "link_peers": [], + "link_peers_type": null, + "mac_address": null, + "mark_connected": false, + "mgmt_only": false, + "mode": null, + "module": null, + "mtu": null, + "name": "wlink1", + "parent": null, + "poe_mode": null, + "poe_type": null, + "rf_channel": null, + "rf_channel_frequency": null, + "rf_channel_width": null, + "rf_role": null, + "speed": null, + "tagged_vlans": [], + "tags": [], + "tx_power": null, + "type": { + "label": "IEEE 802.11a", + "value": "ieee802.11a" + }, + "untagged_vlan": null, + "vdcs": [], + "vrf": null, + "wireless_lans": [], + "wireless_link": null, + "wwn": null + } + ], + "is_virtual": false, + "local_context_data": { + "ntp_servers": [ + "pool.ntp.org" + ] + }, + "locations": [ + "test-rack-group", + "parent-rack-group" + ], + "manufacturer": "cisco", + "regions": [ + "test-region", + "parent-region" + ], + "role": "core-switch", + "serial": "FAB01234567", + "services": [ + { + "comments": "", + "custom_fields": {}, + "description": "", + "device": { + "description": "", + "display": "test100 (123456789)", + "id": 1, + "name": "test100" + }, + "display": "ssh (TCP/22)", + "display_url": "http://localhost:32768/ipam/services/1/", + "id": 1, + "ipaddresses": [], + "name": "ssh", + "ports": [ + 22 + ], + "protocol": { + "label": "TCP", + "value": "tcp" + }, + "tags": [], + "virtual_machine": null + }, + { + "comments": "", + "custom_fields": {}, + "description": "", + "device": { + "description": "", + "display": "test100 (123456789)", + "id": 1, + "name": "test100" + }, + "display": "http (TCP/80)", + "display_url": "http://localhost:32768/ipam/services/2/", + "id": 2, + "ipaddresses": [ + { + "address": "172.16.180.1/24", + "description": "", + "display": "172.16.180.1/24", + "family": { + "label": "IPv4", + "value": 4 + }, + "id": 1 + }, + { + "address": "2001::1:1/64", + "description": "", + "display": "2001::1:1/64", + "family": { + "label": "IPv6", + "value": 6 + }, + "id": 2 + } + ], + "name": "http", + "ports": [ + 80 + ], + "protocol": { + "label": "TCP", + "value": "tcp" + }, + "tags": [], + "virtual_machine": null + } + ], + "site": "test-site", + "site_groups": [], + "status": { + "label": "Active", + "value": "active" + }, + "tags": [] + }, + "test100-vm": { + "cluster": "Test Cluster", + "cluster_group": "test-cluster-group", + "cluster_type": "test-cluster-type", + "config_context": {}, + "custom_fields": {}, + "disk": 170, + "interfaces": [ + { + "bridge": null, + "count_fhrp_groups": 0, + "count_ipaddresses": 0, + "custom_fields": {}, + "description": "", + "display": "Eth0", + "display_url": "http://localhost:32768/virtualization/interfaces/1/", + "enabled": true, + "id": 1, + "ip_addresses": [], + "l2vpn_termination": null, + "mac_address": null, + "mode": null, + "mtu": null, + "name": "Eth0", + "parent": null, + "tagged_vlans": [], + "tags": [], + "untagged_vlan": null, + "virtual_machine": { + "description": "", + "display": "test100-vm", + "id": 1, + "name": "test100-vm" + }, + "vrf": null + }, + { + "bridge": null, + "count_fhrp_groups": 0, + "count_ipaddresses": 0, + "custom_fields": {}, + "description": "", + "display": "Eth1", + "display_url": "http://localhost:32768/virtualization/interfaces/2/", + "enabled": true, + "id": 2, + "ip_addresses": [], + "l2vpn_termination": null, + "mac_address": null, + "mode": null, + "mtu": null, + "name": "Eth1", + "parent": null, + "tagged_vlans": [], + "tags": [], + "untagged_vlan": null, + "virtual_machine": { + "description": "", + "display": "test100-vm", + "id": 1, + "name": "test100-vm" + }, + "vrf": null + }, + { + "bridge": null, + "count_fhrp_groups": 0, + "count_ipaddresses": 0, + "custom_fields": {}, + "description": "", + "display": "Eth2", + "display_url": "http://localhost:32768/virtualization/interfaces/3/", + "enabled": true, + "id": 3, + "ip_addresses": [], + "l2vpn_termination": null, + "mac_address": null, + "mode": null, + "mtu": null, + "name": "Eth2", + "parent": null, + "tagged_vlans": [], + "tags": [], + "untagged_vlan": null, + "virtual_machine": { + "description": "", + "display": "test100-vm", + "id": 1, + "name": "test100-vm" + }, + "vrf": null + }, + { + "bridge": null, + "count_fhrp_groups": 0, + "count_ipaddresses": 0, + "custom_fields": {}, + "description": "", + "display": "Eth3", + "display_url": "http://localhost:32768/virtualization/interfaces/4/", + "enabled": true, + "id": 4, + "ip_addresses": [], + "l2vpn_termination": null, + "mac_address": null, + "mode": null, + "mtu": null, + "name": "Eth3", + "parent": null, + "tagged_vlans": [], + "tags": [], + "untagged_vlan": null, + "virtual_machine": { + "description": "", + "display": "test100-vm", + "id": 1, + "name": "test100-vm" + }, + "vrf": null + }, + { + "bridge": null, + "count_fhrp_groups": 0, + "count_ipaddresses": 0, + "custom_fields": {}, + "description": "", + "display": "Eth4", + "display_url": "http://localhost:32768/virtualization/interfaces/5/", + "enabled": true, + "id": 5, + "ip_addresses": [], + "l2vpn_termination": null, + "mac_address": null, + "mode": null, + "mtu": null, + "name": "Eth4", + "parent": null, + "tagged_vlans": [], + "tags": [], + "untagged_vlan": null, + "virtual_machine": { + "description": "", + "display": "test100-vm", + "id": 1, + "name": "test100-vm" + }, + "vrf": null + } + ], + "is_virtual": true, + "locations": [], + "regions": [ + "test-region", + "parent-region" + ], + "serial": "", + "services": [], + "site": "test-site", + "site_groups": [], + "status": { + "label": "Active", + "value": "active" + }, + "tags": [] + }, + "test101-vm": { + "cluster": "Test Cluster", + "cluster_group": "test-cluster-group", + "cluster_type": "test-cluster-type", + "config_context": {}, + "custom_fields": {}, + "interfaces": [ + { + "bridge": null, + "count_fhrp_groups": 0, + "count_ipaddresses": 0, + "custom_fields": {}, + "description": "", + "display": "Eth0", + "display_url": "http://localhost:32768/virtualization/interfaces/6/", + "enabled": true, + "id": 6, + "ip_addresses": [], + "l2vpn_termination": null, + "mac_address": null, + "mode": null, + "mtu": null, + "name": "Eth0", + "parent": null, + "tagged_vlans": [], + "tags": [], + "untagged_vlan": null, + "virtual_machine": { + "description": "", + "display": "test101-vm", + "id": 2, + "name": "test101-vm" + }, + "vrf": null + }, + { + "bridge": null, + "count_fhrp_groups": 0, + "count_ipaddresses": 0, + "custom_fields": {}, + "description": "", + "display": "Eth1", + "display_url": "http://localhost:32768/virtualization/interfaces/7/", + "enabled": true, + "id": 7, + "ip_addresses": [], + "l2vpn_termination": null, + "mac_address": null, + "mode": null, + "mtu": null, + "name": "Eth1", + "parent": null, + "tagged_vlans": [], + "tags": [], + "untagged_vlan": null, + "virtual_machine": { + "description": "", + "display": "test101-vm", + "id": 2, + "name": "test101-vm" + }, + "vrf": null + }, + { + "bridge": null, + "count_fhrp_groups": 0, + "count_ipaddresses": 0, + "custom_fields": {}, + "description": "", + "display": "Eth2", + "display_url": "http://localhost:32768/virtualization/interfaces/8/", + "enabled": true, + "id": 8, + "ip_addresses": [], + "l2vpn_termination": null, + "mac_address": null, + "mode": null, + "mtu": null, + "name": "Eth2", + "parent": null, + "tagged_vlans": [], + "tags": [], + "untagged_vlan": null, + "virtual_machine": { + "description": "", + "display": "test101-vm", + "id": 2, + "name": "test101-vm" + }, + "vrf": null + }, + { + "bridge": null, + "count_fhrp_groups": 0, + "count_ipaddresses": 0, + "custom_fields": {}, + "description": "", + "display": "Eth3", + "display_url": "http://localhost:32768/virtualization/interfaces/9/", + "enabled": true, + "id": 9, + "ip_addresses": [], + "l2vpn_termination": null, + "mac_address": null, + "mode": null, + "mtu": null, + "name": "Eth3", + "parent": null, + "tagged_vlans": [], + "tags": [], + "untagged_vlan": null, + "virtual_machine": { + "description": "", + "display": "test101-vm", + "id": 2, + "name": "test101-vm" + }, + "vrf": null + }, + { + "bridge": null, + "count_fhrp_groups": 0, + "count_ipaddresses": 0, + "custom_fields": {}, + "description": "", + "display": "Eth4", + "display_url": "http://localhost:32768/virtualization/interfaces/10/", + "enabled": true, + "id": 10, + "ip_addresses": [], + "l2vpn_termination": null, + "mac_address": null, + "mode": null, + "mtu": null, + "name": "Eth4", + "parent": null, + "tagged_vlans": [], + "tags": [], + "untagged_vlan": null, + "virtual_machine": { + "description": "", + "display": "test101-vm", + "id": 2, + "name": "test101-vm" + }, + "vrf": null + } + ], + "is_virtual": true, + "locations": [], + "regions": [ + "test-region", + "parent-region" + ], + "serial": "", + "services": [], + "site": "test-site", + "site_groups": [], + "status": { + "label": "Active", + "value": "active" + }, + "tags": [] + }, + "test102-vm": { + "cluster": "Test Cluster", + "cluster_group": "test-cluster-group", + "cluster_type": "test-cluster-type", + "config_context": {}, + "custom_fields": {}, + "interfaces": [], + "is_virtual": true, + "locations": [], + "regions": [ + "test-region", + "parent-region" + ], + "serial": "", + "services": [], + "site": "test-site", + "site_groups": [], + "status": { + "label": "Active", + "value": "active" + }, + "tags": [] + }, + "test103-vm": { + "cluster": "Test Cluster", + "cluster_group": "test-cluster-group", + "cluster_type": "test-cluster-type", + "config_context": {}, + "custom_fields": {}, + "interfaces": [], + "is_virtual": true, + "locations": [], + "regions": [ + "test-region", + "parent-region" + ], + "serial": "", + "services": [], + "site": "test-site", + "site_groups": [], + "status": { + "label": "Active", + "value": "active" + }, + "tags": [] + } + } + }, + "all": { + "children": [ + "ungrouped", + "site_test_site2", + "region_other_region", + "region_parent_region", + "site_group_other_site_group", + "site_group_parent_site_group", + "role_core_switch", + "device_type_nexus_parent", + "manufacturer_cisco", + "service_telnet", + "status_active", + "rack_Test_Rack", + "device_type_cisco_test", + "service_ssh", + "service_http", + "cluster_Test_Cluster", + "cluster_group_test_cluster_group", + "cluster_type_test_cluster_type", + "is_virtual" + ] + }, + "cluster_Test_Cluster": { + "hosts": [ + "test100-vm", + "test101-vm", + "test102-vm", + "test103-vm" + ] + }, + "cluster_group_test_cluster_group": { + "hosts": [ + "test100-vm", + "test101-vm", + "test102-vm", + "test103-vm" + ] + }, + "cluster_type_test_cluster_type": { + "hosts": [ + "test100-vm", + "test101-vm", + "test102-vm", + "test103-vm" + ] + }, + "device_type_cisco_test": { + "hosts": [ + "TestDeviceR1", + "test100" + ] + }, + "device_type_nexus_parent": { + "hosts": [ + "Test Nexus One" + ] + }, + "is_virtual": { + "hosts": [ + "test100-vm", + "test101-vm", + "test102-vm", + "test103-vm" + ] + }, + "location_parent_rack_group": { + "children": [ + "location_test_rack_group" + ] + }, + "location_test_rack_group": { + "hosts": [ + "Test Nexus One", + "TestDeviceR1", + "test100" + ] + }, + "manufacturer_cisco": { + "hosts": [ + "Test Nexus One", + "TestDeviceR1", + "test100" + ] + }, + "rack_Test_Rack": { + "hosts": [ + "TestDeviceR1" + ] + }, + "region_parent_region": { + "children": [ + "region_test_region" + ] + }, + "region_test_region": { + "children": [ + "site_test_site" + ] + }, + "role_core_switch": { + "hosts": [ + "Test Nexus One", + "TestDeviceR1", + "test100" + ] + }, + "service_http": { + "hosts": [ + "test100" + ] + }, + "service_ssh": { + "hosts": [ + "test100" + ] + }, + "service_telnet": { + "hosts": [ + "Test Nexus One" + ] + }, + "site_group_parent_site_group": { + "children": [ + "site_group_test_site_group" + ] + }, + "site_test_site": { + "children": [ + "location_parent_rack_group" + ], + "hosts": [ + "test100-vm", + "test101-vm", + "test102-vm", + "test103-vm" + ] + }, + "status_active": { + "hosts": [ + "Test Nexus One", + "TestDeviceR1", + "test100", + "test100-vm", + "test101-vm", + "test102-vm", + "test103-vm" + ] + } +} \ No newline at end of file diff --git a/tests/integration/targets/inventory-v4.3/files/test-inventory-jinja2-filter.yml b/tests/integration/targets/inventory-v4.3/files/test-inventory-jinja2-filter.yml new file mode 100644 index 000000000..49f306a78 --- /dev/null +++ b/tests/integration/targets/inventory-v4.3/files/test-inventory-jinja2-filter.yml @@ -0,0 +1,33 @@ +--- +plugin: netbox.netbox.nb_inventory +api_endpoint: http://localhost:32768 +token: "0123456789abcdef0123456789abcdef01234567" +validate_certs: false + +config_context: true +plurals: false +interfaces: true +services: true + +group_by: + - site + - tenant + - rack + - location + - rack_role + - tag + - role + - device_type + - manufacturer + - platform + - region + - site_group + - cluster + - cluster_group + - cluster_type + - is_virtual + - services + - status + +query_filters: + - site: "{{ 'TEST-SITE' | lower }}" diff --git a/tests/integration/targets/inventory-v4.3/files/test-inventory-jinja2.json b/tests/integration/targets/inventory-v4.3/files/test-inventory-jinja2.json new file mode 100644 index 000000000..0542ee506 --- /dev/null +++ b/tests/integration/targets/inventory-v4.3/files/test-inventory-jinja2.json @@ -0,0 +1,390 @@ +{ + "Test_Cluster": { + "hosts": [ + "test100-vm", + "test101-vm", + "test102-vm", + "test103-vm" + ] + }, + "Test_Cluster_2": { + "hosts": [ + "Test VM With Spaces", + "test104-vm" + ] + }, + "Test_Rack": { + "hosts": [ + "TestDeviceR1" + ] + }, + "Test_Rack_Site_2": { + "hosts": [ + "R1-Device" + ] + }, + "_meta": { + "hostvars": { + "R1-Device": { + "asset_tag": "345678901", + "custom_fields": {}, + "device_type": "cisco-test", + "is_virtual": false, + "locations": [], + "manufacturer": "cisco", + "rack": "Test Rack Site 2", + "rack_id": "1", + "rack_role": "test-rack-role", + "regions": [], + "role": "core-switch", + "serial": "", + "site": "test-site2", + "site_groups": [], + "status": { + "label": "Active", + "value": "active" + }, + "tags": [] + }, + "Test VM With Spaces": { + "cluster": "Test Cluster 2", + "cluster_type": "test-cluster-type", + "custom_fields": {}, + "is_virtual": true, + "locations": [], + "regions": [], + "serial": "", + "site_groups": [], + "status": { + "label": "Active", + "value": "active" + }, + "tags": [] + }, + "TestDeviceR1": { + "custom_fields": {}, + "device_type": "cisco-test", + "is_virtual": false, + "locations": [ + "test-rack-group", + "parent-rack-group" + ], + "manufacturer": "cisco", + "rack": "Test Rack", + "rack_id": "2", + "regions": [ + "test-region", + "parent-region" + ], + "role": "core-switch", + "serial": "FAB12345678", + "site": "test-site", + "site_groups": [], + "status": { + "label": "Active", + "value": "active" + }, + "tags": [] + }, + "VC1": { + "ansible_host": "nexus.example.com", + "custom_fields": {}, + "device_type": "nexus-parent", + "dns_name": "nexus.example.com", + "is_virtual": false, + "locations": [ + "test-rack-group", + "parent-rack-group" + ], + "manufacturer": "cisco", + "primary_ip4": "172.16.180.12", + "regions": [ + "test-region", + "parent-region" + ], + "role": "core-switch", + "serial": "", + "site": "test-site", + "site_groups": [], + "status": { + "label": "Active", + "value": "active" + }, + "tags": [] + }, + "test100": { + "asset_tag": "123456789", + "custom_fields": {}, + "device_type": "cisco-test", + "is_virtual": false, + "local_context_data": { + "ntp_servers": [ + "pool.ntp.org" + ] + }, + "locations": [ + "test-rack-group", + "parent-rack-group" + ], + "manufacturer": "cisco", + "regions": [ + "test-region", + "parent-region" + ], + "role": "core-switch", + "serial": "FAB01234567", + "site": "test-site", + "site_groups": [], + "status": { + "label": "Active", + "value": "active" + }, + "tags": [] + }, + "test100-vm": { + "cluster": "Test Cluster", + "cluster_group": "test-cluster-group", + "cluster_type": "test-cluster-type", + "custom_fields": {}, + "disk": 170, + "is_virtual": true, + "locations": [], + "regions": [ + "test-region", + "parent-region" + ], + "serial": "", + "site": "test-site", + "site_groups": [], + "status": { + "label": "Active", + "value": "active" + }, + "tags": [] + }, + "test101-vm": { + "cluster": "Test Cluster", + "cluster_group": "test-cluster-group", + "cluster_type": "test-cluster-type", + "custom_fields": {}, + "is_virtual": true, + "locations": [], + "regions": [ + "test-region", + "parent-region" + ], + "serial": "", + "site": "test-site", + "site_groups": [], + "status": { + "label": "Active", + "value": "active" + }, + "tags": [] + }, + "test102-vm": { + "cluster": "Test Cluster", + "cluster_group": "test-cluster-group", + "cluster_type": "test-cluster-type", + "custom_fields": {}, + "is_virtual": true, + "locations": [], + "regions": [ + "test-region", + "parent-region" + ], + "serial": "", + "site": "test-site", + "site_groups": [], + "status": { + "label": "Active", + "value": "active" + }, + "tags": [] + }, + "test103-vm": { + "cluster": "Test Cluster", + "cluster_group": "test-cluster-group", + "cluster_type": "test-cluster-type", + "custom_fields": {}, + "is_virtual": true, + "locations": [], + "regions": [ + "test-region", + "parent-region" + ], + "serial": "", + "site": "test-site", + "site_groups": [], + "status": { + "label": "Active", + "value": "active" + }, + "tags": [] + }, + "test104-vm": { + "cluster": "Test Cluster 2", + "cluster_type": "test-cluster-type", + "custom_fields": {}, + "is_virtual": true, + "locations": [], + "regions": [], + "serial": "", + "site_groups": [], + "status": { + "label": "Active", + "value": "active" + }, + "tags": [] + } + } + }, + "active": { + "hosts": [ + "R1-Device", + "VC1", + "TestDeviceR1", + "test100", + "Test VM With Spaces", + "test100-vm", + "test101-vm", + "test102-vm", + "test103-vm", + "test104-vm" + ] + }, + "all": { + "children": [ + "ungrouped", + "test_site2", + "other_region", + "parent_region", + "other_site_group", + "parent_site_group", + "Test_Rack_Site_2", + "test_rack_role", + "core_switch", + "cisco_test", + "cisco", + "active", + "nexus_parent", + "jinja_test_group", + "Test_Rack", + "Test_Cluster_2", + "test_cluster_type", + "is_virtual", + "Test_Cluster", + "test_cluster_group" + ] + }, + "cisco": { + "hosts": [ + "R1-Device", + "VC1", + "TestDeviceR1", + "test100" + ] + }, + "cisco_test": { + "hosts": [ + "R1-Device", + "TestDeviceR1", + "test100" + ] + }, + "core_switch": { + "hosts": [ + "R1-Device", + "VC1", + "TestDeviceR1", + "test100" + ] + }, + "is_virtual": { + "hosts": [ + "Test VM With Spaces", + "test100-vm", + "test101-vm", + "test102-vm", + "test103-vm", + "test104-vm" + ] + }, + "jinja_test_group": { + "hosts": [ + "TestDeviceR1", + "Test VM With Spaces" + ] + }, + "nexus_parent": { + "hosts": [ + "VC1" + ] + }, + "parent_rack_group": { + "children": [ + "test_rack_group" + ] + }, + "parent_region": { + "children": [ + "test_region" + ] + }, + "parent_site_group": { + "children": [ + "test_site_group" + ] + }, + "test_cluster_group": { + "hosts": [ + "test100-vm", + "test101-vm", + "test102-vm", + "test103-vm" + ] + }, + "test_cluster_type": { + "hosts": [ + "Test VM With Spaces", + "test100-vm", + "test101-vm", + "test102-vm", + "test103-vm", + "test104-vm" + ] + }, + "test_rack_group": { + "hosts": [ + "VC1", + "TestDeviceR1", + "test100" + ] + }, + "test_rack_role": { + "hosts": [ + "R1-Device" + ] + }, + "test_region": { + "children": [ + "test_site" + ] + }, + "test_site": { + "children": [ + "parent_rack_group" + ], + "hosts": [ + "test100-vm", + "test101-vm", + "test102-vm", + "test103-vm" + ] + }, + "test_site2": { + "hosts": [ + "R1-Device" + ] + } +} \ No newline at end of file diff --git a/tests/integration/targets/inventory-v4.3/files/test-inventory-jinja2.yml b/tests/integration/targets/inventory-v4.3/files/test-inventory-jinja2.yml new file mode 100644 index 000000000..67f9c49be --- /dev/null +++ b/tests/integration/targets/inventory-v4.3/files/test-inventory-jinja2.yml @@ -0,0 +1,62 @@ +--- +plugin: netbox.netbox.nb_inventory +api_endpoint: http://localhost:32768 +token: "0123456789abcdef0123456789abcdef01234567" +validate_certs: false + +# Cache is not for performance of tests, but to test the caching option works +# Also set on test-inventory-plurals.yml so that we actually hit the cache on one of these runs +cache: true +cache_timeout: 3600 +cache_plugin: jsonfile +cache_connection: /tmp/inventory_netbox + +config_context: false +plurals: false +interfaces: false +services: false +group_names_raw: true +virtual_chassis_name: true +dns_name: true +ansible_host_dns_name: true + +group_by: + - site + - tenant + - rack + - location + - rack_role + - tag + - role + - device_type + - manufacturer + - platform + - region + - site_group + - cluster + - cluster_group + - cluster_type + - is_virtual + - status + +query_filters: "" + +device_query_filters: + - role: "{{ 'CORE-SWITCH' | lower }}" + +vm_query_filters: + - cluster_type: "{{ 'TEST-CLUSTER-TYPE' | lower }}" + +# See Constructed for details +# https://docs.ansible.com/ansible/latest/plugins/inventory/constructed.html + +compose: + rack_id: rack.id + ntp_servers: config_context.ntp_servers + +keyed_groups: + - prefix: rack + key: rack.name + +groups: + jinja_test_group: inventory_hostname.startswith('Test') diff --git a/tests/integration/targets/inventory-v4.3/files/test-inventory-legacy.json b/tests/integration/targets/inventory-v4.3/files/test-inventory-legacy.json new file mode 100644 index 000000000..42794219f --- /dev/null +++ b/tests/integration/targets/inventory-v4.3/files/test-inventory-legacy.json @@ -0,0 +1,441 @@ +{ + "_meta": { + "hostvars": { + "R1-Device": { + "asset_tag": "345678901", + "custom_fields": {}, + "device_roles": [ + "core-switch" + ], + "device_types": [ + "cisco-test" + ], + "is_virtual": false, + "local_context_data": [ + null + ], + "locations": [], + "manufacturers": [ + "cisco" + ], + "rack_role": "test-rack-role", + "racks": [ + "Test Rack Site 2" + ], + "regions": [], + "serial": "", + "services": [], + "site_groups": [], + "sites": [ + "test-site2" + ], + "status": { + "label": "Active", + "value": "active" + }, + "tags": [] + }, + "Test Nexus One": { + "ansible_host": "172.16.180.12", + "custom_fields": {}, + "device_roles": [ + "core-switch" + ], + "device_types": [ + "nexus-parent" + ], + "is_virtual": false, + "local_context_data": [ + null + ], + "locations": [ + "test-rack-group", + "parent-rack-group" + ], + "manufacturers": [ + "cisco" + ], + "primary_ip4": "172.16.180.12", + "regions": [ + "test-region", + "parent-region" + ], + "serial": "", + "services": [ + { + "comments": "", + "custom_fields": {}, + "description": "", + "device": { + "description": "", + "display": "Test Nexus One", + "id": 4, + "name": "Test Nexus One" + }, + "display": "telnet (TCP/23)", + "display_url": "http://localhost:32768/ipam/services/3/", + "id": 3, + "ipaddresses": [], + "name": "telnet", + "ports": [ + 23 + ], + "protocol": { + "label": "TCP", + "value": "tcp" + }, + "tags": [], + "virtual_machine": null + } + ], + "site_groups": [], + "sites": [ + "test-site" + ], + "status": { + "label": "Active", + "value": "active" + }, + "tags": [] + }, + "Test VM With Spaces": { + "cluster": "Test Cluster 2", + "cluster_type": "test-cluster-type", + "custom_fields": {}, + "is_virtual": true, + "local_context_data": [ + null + ], + "locations": [], + "regions": [], + "serial": "", + "services": [ + { + "comments": "", + "custom_fields": {}, + "description": "", + "device": null, + "display": "ssh (TCP/22)", + "display_url": "http://localhost:32768/ipam/services/4/", + "id": 4, + "ipaddresses": [], + "name": "ssh", + "ports": [ + 22 + ], + "protocol": { + "label": "TCP", + "value": "tcp" + }, + "tags": [], + "virtual_machine": { + "description": "", + "display": "Test VM With Spaces", + "id": 6, + "name": "Test VM With Spaces" + } + } + ], + "site_groups": [], + "status": { + "label": "Active", + "value": "active" + }, + "tags": [] + }, + "TestDeviceR1": { + "custom_fields": {}, + "device_roles": [ + "core-switch" + ], + "device_types": [ + "cisco-test" + ], + "is_virtual": false, + "local_context_data": [ + null + ], + "locations": [ + "test-rack-group", + "parent-rack-group" + ], + "manufacturers": [ + "cisco" + ], + "racks": [ + "Test Rack" + ], + "regions": [ + "test-region", + "parent-region" + ], + "serial": "FAB12345678", + "services": [], + "site_groups": [], + "sites": [ + "test-site" + ], + "status": { + "label": "Active", + "value": "active" + }, + "tags": [] + }, + "test100": { + "asset_tag": "123456789", + "custom_fields": {}, + "device_roles": [ + "core-switch" + ], + "device_types": [ + "cisco-test" + ], + "is_virtual": false, + "local_context_data": [ + { + "ntp_servers": [ + "pool.ntp.org" + ] + } + ], + "locations": [ + "test-rack-group", + "parent-rack-group" + ], + "manufacturers": [ + "cisco" + ], + "regions": [ + "test-region", + "parent-region" + ], + "serial": "FAB01234567", + "services": [ + { + "comments": "", + "custom_fields": {}, + "description": "", + "device": { + "description": "", + "display": "test100 (123456789)", + "id": 1, + "name": "test100" + }, + "display": "ssh (TCP/22)", + "display_url": "http://localhost:32768/ipam/services/1/", + "id": 1, + "ipaddresses": [], + "name": "ssh", + "ports": [ + 22 + ], + "protocol": { + "label": "TCP", + "value": "tcp" + }, + "tags": [], + "virtual_machine": null + }, + { + "comments": "", + "custom_fields": {}, + "description": "", + "device": { + "description": "", + "display": "test100 (123456789)", + "id": 1, + "name": "test100" + }, + "display": "http (TCP/80)", + "display_url": "http://localhost:32768/ipam/services/2/", + "id": 2, + "ipaddresses": [ + { + "address": "172.16.180.1/24", + "description": "", + "display": "172.16.180.1/24", + "family": { + "label": "IPv4", + "value": 4 + }, + "id": 1 + }, + { + "address": "2001::1:1/64", + "description": "", + "display": "2001::1:1/64", + "family": { + "label": "IPv6", + "value": 6 + }, + "id": 2 + } + ], + "name": "http", + "ports": [ + 80 + ], + "protocol": { + "label": "TCP", + "value": "tcp" + }, + "tags": [], + "virtual_machine": null + } + ], + "site_groups": [], + "sites": [ + "test-site" + ], + "status": { + "label": "Active", + "value": "active" + }, + "tags": [] + }, + "test100-vm": { + "cluster": "Test Cluster", + "cluster_group": "test-cluster-group", + "cluster_type": "test-cluster-type", + "custom_fields": {}, + "disk": 170, + "is_virtual": true, + "local_context_data": [ + null + ], + "locations": [], + "regions": [ + "test-region", + "parent-region" + ], + "serial": "", + "services": [], + "site_groups": [], + "sites": [ + "test-site" + ], + "status": { + "label": "Active", + "value": "active" + }, + "tags": [] + }, + "test101-vm": { + "cluster": "Test Cluster", + "cluster_group": "test-cluster-group", + "cluster_type": "test-cluster-type", + "custom_fields": {}, + "is_virtual": true, + "local_context_data": [ + null + ], + "locations": [], + "regions": [ + "test-region", + "parent-region" + ], + "serial": "", + "services": [], + "site_groups": [], + "sites": [ + "test-site" + ], + "status": { + "label": "Active", + "value": "active" + }, + "tags": [] + }, + "test102-vm": { + "cluster": "Test Cluster", + "cluster_group": "test-cluster-group", + "cluster_type": "test-cluster-type", + "custom_fields": {}, + "is_virtual": true, + "local_context_data": [ + null + ], + "locations": [], + "regions": [ + "test-region", + "parent-region" + ], + "serial": "", + "services": [], + "site_groups": [], + "sites": [ + "test-site" + ], + "status": { + "label": "Active", + "value": "active" + }, + "tags": [] + }, + "test103-vm": { + "cluster": "Test Cluster", + "cluster_group": "test-cluster-group", + "cluster_type": "test-cluster-type", + "custom_fields": {}, + "is_virtual": true, + "local_context_data": [ + null + ], + "locations": [], + "regions": [ + "test-region", + "parent-region" + ], + "serial": "", + "services": [], + "site_groups": [], + "sites": [ + "test-site" + ], + "status": { + "label": "Active", + "value": "active" + }, + "tags": [] + }, + "test104-vm": { + "cluster": "Test Cluster 2", + "cluster_type": "test-cluster-type", + "custom_fields": {}, + "is_virtual": true, + "local_context_data": [ + null + ], + "locations": [], + "regions": [], + "serial": "", + "services": [], + "site_groups": [], + "status": { + "label": "Active", + "value": "active" + }, + "tags": [] + } + } + }, + "all": { + "children": [ + "ungrouped" + ] + }, + "ungrouped": { + "hosts": [ + "R1-Device", + "Test Nexus One", + "TestDeviceR1", + "test100", + "Test VM With Spaces", + "test100-vm", + "test101-vm", + "test102-vm", + "test103-vm", + "test104-vm" + ] + } +} \ No newline at end of file diff --git a/tests/integration/targets/inventory-v4.3/files/test-inventory-legacy.yml b/tests/integration/targets/inventory-v4.3/files/test-inventory-legacy.yml new file mode 100644 index 000000000..259c3934d --- /dev/null +++ b/tests/integration/targets/inventory-v4.3/files/test-inventory-legacy.yml @@ -0,0 +1,10 @@ +--- +# To generate the json result, I checked out nb_inventory.yml from the v0.2.0 release 2d6894b, +# and then ran it against this inventory with the latest test data. + +# Checks that substantial work on the inventory does not diverge from what existing users are using by default. + +plugin: netbox.netbox.nb_inventory +api_endpoint: http://localhost:32768 +token: "0123456789abcdef0123456789abcdef01234567" +validate_certs: false diff --git a/tests/integration/targets/inventory-v4.3/files/test-inventory-noracks.json b/tests/integration/targets/inventory-v4.3/files/test-inventory-noracks.json new file mode 100644 index 000000000..250a3ea9f --- /dev/null +++ b/tests/integration/targets/inventory-v4.3/files/test-inventory-noracks.json @@ -0,0 +1,1377 @@ +{ + "_meta": { + "hostvars": { + "R1-Device": { + "asset_tag": "345678901", + "config_context": [ + {} + ], + "custom_fields": {}, + "device_roles": [ + "core-switch" + ], + "device_types": [ + "cisco-test" + ], + "interfaces": [], + "is_virtual": false, + "local_context_data": [ + null + ], + "manufacturers": [ + "cisco" + ], + "regions": [], + "serial": "", + "services": [], + "site_groups": [], + "sites": [ + "test-site2" + ], + "status": { + "label": "Active", + "value": "active" + }, + "tags": [] + }, + "Test Nexus One": { + "ansible_host": "172.16.180.12", + "config_context": [ + {} + ], + "custom_fields": {}, + "device_roles": [ + "core-switch" + ], + "device_types": [ + "nexus-parent" + ], + "dns_name": "nexus.example.com", + "interfaces": [ + { + "_occupied": false, + "bridge": null, + "cable": null, + "cable_end": "", + "connected_endpoints": null, + "connected_endpoints_reachable": null, + "connected_endpoints_type": null, + "count_fhrp_groups": 0, + "count_ipaddresses": 1, + "custom_fields": {}, + "description": "", + "device": { + "description": "", + "display": "Test Nexus One", + "id": 4, + "name": "Test Nexus One" + }, + "display": "Ethernet1/1", + "display_url": "http://localhost:32768/dcim/interfaces/1/", + "duplex": null, + "enabled": true, + "id": 1, + "ip_addresses": [ + { + "address": "172.16.180.11/24", + "comments": "", + "custom_fields": {}, + "description": "", + "display": "172.16.180.11/24", + "display_url": "http://localhost:32768/ipam/ip-addresses/3/", + "dns_name": "", + "family": { + "label": "IPv4", + "value": 4 + }, + "id": 3, + "nat_inside": null, + "nat_outside": [], + "role": null, + "status": { + "label": "Active", + "value": "active" + }, + "tags": [], + "tenant": null, + "vrf": null + } + ], + "l2vpn_termination": null, + "label": "", + "lag": null, + "link_peers": [], + "link_peers_type": null, + "mac_address": null, + "mark_connected": false, + "mgmt_only": false, + "mode": null, + "module": null, + "mtu": null, + "name": "Ethernet1/1", + "parent": null, + "poe_mode": null, + "poe_type": null, + "rf_channel": null, + "rf_channel_frequency": null, + "rf_channel_width": null, + "rf_role": null, + "speed": null, + "tagged_vlans": [], + "tags": [], + "tx_power": null, + "type": { + "label": "1000BASE-T (1GE)", + "value": "1000base-t" + }, + "untagged_vlan": null, + "vdcs": [], + "vrf": null, + "wireless_lans": [], + "wireless_link": null, + "wwn": null + }, + { + "_occupied": false, + "bridge": null, + "cable": null, + "cable_end": "", + "connected_endpoints": null, + "connected_endpoints_reachable": null, + "connected_endpoints_type": null, + "count_fhrp_groups": 0, + "count_ipaddresses": 1, + "custom_fields": {}, + "description": "", + "device": { + "description": "", + "display": "Test Nexus Child One", + "id": 5, + "name": "Test Nexus Child One" + }, + "display": "Ethernet2/1", + "display_url": "http://localhost:32768/dcim/interfaces/2/", + "duplex": null, + "enabled": true, + "id": 2, + "ip_addresses": [ + { + "address": "172.16.180.12/24", + "comments": "", + "custom_fields": {}, + "description": "", + "display": "172.16.180.12/24", + "display_url": "http://localhost:32768/ipam/ip-addresses/4/", + "dns_name": "nexus.example.com", + "family": { + "label": "IPv4", + "value": 4 + }, + "id": 4, + "nat_inside": null, + "nat_outside": [], + "role": null, + "status": { + "label": "Active", + "value": "active" + }, + "tags": [], + "tenant": null, + "vrf": null + } + ], + "l2vpn_termination": null, + "label": "", + "lag": null, + "link_peers": [], + "link_peers_type": null, + "mac_address": null, + "mark_connected": false, + "mgmt_only": false, + "mode": null, + "module": null, + "mtu": null, + "name": "Ethernet2/1", + "parent": null, + "poe_mode": null, + "poe_type": null, + "rf_channel": null, + "rf_channel_frequency": null, + "rf_channel_width": null, + "rf_role": null, + "speed": null, + "tagged_vlans": [], + "tags": [], + "tx_power": null, + "type": { + "label": "1000BASE-T (1GE)", + "value": "1000base-t" + }, + "untagged_vlan": null, + "vdcs": [], + "vrf": null, + "wireless_lans": [], + "wireless_link": null, + "wwn": null + }, + { + "_occupied": false, + "bridge": null, + "cable": null, + "cable_end": "", + "connected_endpoints": null, + "connected_endpoints_reachable": null, + "connected_endpoints_type": null, + "count_fhrp_groups": 0, + "count_ipaddresses": 0, + "custom_fields": {}, + "description": "", + "device": { + "description": "", + "display": "Test Nexus One", + "id": 4, + "name": "Test Nexus One" + }, + "display": "wlink1", + "display_url": "http://localhost:32768/dcim/interfaces/6/", + "duplex": null, + "enabled": true, + "id": 6, + "ip_addresses": [], + "l2vpn_termination": null, + "label": "", + "lag": null, + "link_peers": [], + "link_peers_type": null, + "mac_address": null, + "mark_connected": false, + "mgmt_only": false, + "mode": null, + "module": null, + "mtu": null, + "name": "wlink1", + "parent": null, + "poe_mode": null, + "poe_type": null, + "rf_channel": null, + "rf_channel_frequency": null, + "rf_channel_width": null, + "rf_role": null, + "speed": null, + "tagged_vlans": [], + "tags": [], + "tx_power": null, + "type": { + "label": "IEEE 802.11a", + "value": "ieee802.11a" + }, + "untagged_vlan": null, + "vdcs": [], + "vrf": null, + "wireless_lans": [], + "wireless_link": null, + "wwn": null + } + ], + "is_virtual": false, + "local_context_data": [ + null + ], + "manufacturers": [ + "cisco" + ], + "primary_ip4": "172.16.180.12", + "regions": [ + "test-region", + "parent-region" + ], + "serial": "", + "services": [ + { + "comments": "", + "custom_fields": {}, + "description": "", + "device": { + "description": "", + "display": "Test Nexus One", + "id": 4, + "name": "Test Nexus One" + }, + "display": "telnet (TCP/23)", + "display_url": "http://localhost:32768/ipam/services/3/", + "id": 3, + "ipaddresses": [], + "name": "telnet", + "ports": [ + 23 + ], + "protocol": { + "label": "TCP", + "value": "tcp" + }, + "tags": [], + "virtual_machine": null + } + ], + "site_groups": [], + "sites": [ + "test-site" + ], + "status": { + "label": "Active", + "value": "active" + }, + "tags": [] + }, + "Test VM With Spaces": { + "cluster": "Test Cluster 2", + "cluster_type": "test-cluster-type", + "config_context": [ + {} + ], + "custom_fields": {}, + "interfaces": [ + { + "bridge": null, + "count_fhrp_groups": 0, + "count_ipaddresses": 0, + "custom_fields": {}, + "description": "", + "display": "Eth0", + "display_url": "http://localhost:32768/virtualization/interfaces/11/", + "enabled": true, + "id": 11, + "ip_addresses": [], + "l2vpn_termination": null, + "mac_address": null, + "mode": null, + "mtu": null, + "name": "Eth0", + "parent": null, + "tagged_vlans": [], + "tags": [], + "untagged_vlan": null, + "virtual_machine": { + "description": "", + "display": "Test VM With Spaces", + "id": 6, + "name": "Test VM With Spaces" + }, + "vrf": null + }, + { + "bridge": null, + "count_fhrp_groups": 0, + "count_ipaddresses": 0, + "custom_fields": {}, + "description": "", + "display": "Eth1", + "display_url": "http://localhost:32768/virtualization/interfaces/12/", + "enabled": true, + "id": 12, + "ip_addresses": [], + "l2vpn_termination": null, + "mac_address": null, + "mode": null, + "mtu": null, + "name": "Eth1", + "parent": null, + "tagged_vlans": [], + "tags": [], + "untagged_vlan": null, + "virtual_machine": { + "description": "", + "display": "Test VM With Spaces", + "id": 6, + "name": "Test VM With Spaces" + }, + "vrf": null + } + ], + "is_virtual": true, + "local_context_data": [ + null + ], + "regions": [], + "serial": "", + "services": [ + { + "comments": "", + "custom_fields": {}, + "description": "", + "device": null, + "display": "ssh (TCP/22)", + "display_url": "http://localhost:32768/ipam/services/4/", + "id": 4, + "ipaddresses": [], + "name": "ssh", + "ports": [ + 22 + ], + "protocol": { + "label": "TCP", + "value": "tcp" + }, + "tags": [], + "virtual_machine": { + "description": "", + "display": "Test VM With Spaces", + "id": 6, + "name": "Test VM With Spaces" + } + } + ], + "site_groups": [], + "status": { + "label": "Active", + "value": "active" + }, + "tags": [] + }, + "TestDeviceR1": { + "config_context": [ + {} + ], + "custom_fields": {}, + "device_roles": [ + "core-switch" + ], + "device_types": [ + "cisco-test" + ], + "interfaces": [], + "is_virtual": false, + "local_context_data": [ + null + ], + "manufacturers": [ + "cisco" + ], + "regions": [ + "test-region", + "parent-region" + ], + "serial": "FAB12345678", + "services": [], + "site_groups": [], + "sites": [ + "test-site" + ], + "status": { + "label": "Active", + "value": "active" + }, + "tags": [] + }, + "test100": { + "asset_tag": "123456789", + "config_context": [ + { + "ntp_servers": [ + "pool.ntp.org" + ] + } + ], + "custom_fields": {}, + "device_roles": [ + "core-switch" + ], + "device_types": [ + "cisco-test" + ], + "interfaces": [ + { + "_occupied": false, + "bridge": null, + "cable": null, + "cable_end": "", + "connected_endpoints": null, + "connected_endpoints_reachable": null, + "connected_endpoints_type": null, + "count_fhrp_groups": 0, + "count_ipaddresses": 1, + "custom_fields": {}, + "description": "", + "device": { + "description": "", + "display": "test100 (123456789)", + "id": 1, + "name": "test100" + }, + "display": "GigabitEthernet1", + "display_url": "http://localhost:32768/dcim/interfaces/3/", + "duplex": null, + "enabled": true, + "id": 3, + "ip_addresses": [ + { + "address": "172.16.180.1/24", + "comments": "", + "custom_fields": {}, + "description": "", + "display": "172.16.180.1/24", + "display_url": "http://localhost:32768/ipam/ip-addresses/1/", + "dns_name": "", + "family": { + "label": "IPv4", + "value": 4 + }, + "id": 1, + "nat_inside": null, + "nat_outside": [], + "role": null, + "status": { + "label": "Active", + "value": "active" + }, + "tags": [], + "tenant": null, + "vrf": null + } + ], + "l2vpn_termination": null, + "label": "", + "lag": null, + "link_peers": [], + "link_peers_type": null, + "mac_address": null, + "mark_connected": false, + "mgmt_only": false, + "mode": null, + "module": null, + "mtu": null, + "name": "GigabitEthernet1", + "parent": null, + "poe_mode": null, + "poe_type": null, + "rf_channel": null, + "rf_channel_frequency": null, + "rf_channel_width": null, + "rf_role": null, + "speed": null, + "tagged_vlans": [], + "tags": [], + "tx_power": null, + "type": { + "label": "1000BASE-T (1GE)", + "value": "1000base-t" + }, + "untagged_vlan": null, + "vdcs": [], + "vrf": null, + "wireless_lans": [], + "wireless_link": null, + "wwn": null + }, + { + "_occupied": false, + "bridge": null, + "cable": null, + "cable_end": "", + "connected_endpoints": null, + "connected_endpoints_reachable": null, + "connected_endpoints_type": null, + "count_fhrp_groups": 0, + "count_ipaddresses": 1, + "custom_fields": {}, + "description": "", + "device": { + "description": "", + "display": "test100 (123456789)", + "id": 1, + "name": "test100" + }, + "display": "GigabitEthernet2", + "display_url": "http://localhost:32768/dcim/interfaces/4/", + "duplex": null, + "enabled": true, + "id": 4, + "ip_addresses": [ + { + "address": "2001::1:1/64", + "comments": "", + "custom_fields": {}, + "description": "", + "display": "2001::1:1/64", + "display_url": "http://localhost:32768/ipam/ip-addresses/2/", + "dns_name": "", + "family": { + "label": "IPv6", + "value": 6 + }, + "id": 2, + "nat_inside": null, + "nat_outside": [], + "role": null, + "status": { + "label": "Active", + "value": "active" + }, + "tags": [], + "tenant": null, + "vrf": null + } + ], + "l2vpn_termination": null, + "label": "", + "lag": null, + "link_peers": [], + "link_peers_type": null, + "mac_address": null, + "mark_connected": false, + "mgmt_only": false, + "mode": null, + "module": null, + "mtu": null, + "name": "GigabitEthernet2", + "parent": null, + "poe_mode": null, + "poe_type": null, + "rf_channel": null, + "rf_channel_frequency": null, + "rf_channel_width": null, + "rf_role": null, + "speed": null, + "tagged_vlans": [], + "tags": [], + "tx_power": null, + "type": { + "label": "1000BASE-T (1GE)", + "value": "1000base-t" + }, + "untagged_vlan": null, + "vdcs": [], + "vrf": null, + "wireless_lans": [], + "wireless_link": null, + "wwn": null + }, + { + "_occupied": false, + "bridge": null, + "cable": null, + "cable_end": "", + "connected_endpoints": null, + "connected_endpoints_reachable": null, + "connected_endpoints_type": null, + "count_fhrp_groups": 0, + "count_ipaddresses": 0, + "custom_fields": {}, + "description": "", + "device": { + "description": "", + "display": "test100 (123456789)", + "id": 1, + "name": "test100" + }, + "display": "wlink1", + "display_url": "http://localhost:32768/dcim/interfaces/5/", + "duplex": null, + "enabled": true, + "id": 5, + "ip_addresses": [], + "l2vpn_termination": null, + "label": "", + "lag": null, + "link_peers": [], + "link_peers_type": null, + "mac_address": null, + "mark_connected": false, + "mgmt_only": false, + "mode": null, + "module": null, + "mtu": null, + "name": "wlink1", + "parent": null, + "poe_mode": null, + "poe_type": null, + "rf_channel": null, + "rf_channel_frequency": null, + "rf_channel_width": null, + "rf_role": null, + "speed": null, + "tagged_vlans": [], + "tags": [], + "tx_power": null, + "type": { + "label": "IEEE 802.11a", + "value": "ieee802.11a" + }, + "untagged_vlan": null, + "vdcs": [], + "vrf": null, + "wireless_lans": [], + "wireless_link": null, + "wwn": null + } + ], + "is_virtual": false, + "local_context_data": [ + { + "ntp_servers": [ + "pool.ntp.org" + ] + } + ], + "manufacturers": [ + "cisco" + ], + "regions": [ + "test-region", + "parent-region" + ], + "serial": "FAB01234567", + "services": [ + { + "comments": "", + "custom_fields": {}, + "description": "", + "device": { + "description": "", + "display": "test100 (123456789)", + "id": 1, + "name": "test100" + }, + "display": "ssh (TCP/22)", + "display_url": "http://localhost:32768/ipam/services/1/", + "id": 1, + "ipaddresses": [], + "name": "ssh", + "ports": [ + 22 + ], + "protocol": { + "label": "TCP", + "value": "tcp" + }, + "tags": [], + "virtual_machine": null + }, + { + "comments": "", + "custom_fields": {}, + "description": "", + "device": { + "description": "", + "display": "test100 (123456789)", + "id": 1, + "name": "test100" + }, + "display": "http (TCP/80)", + "display_url": "http://localhost:32768/ipam/services/2/", + "id": 2, + "ipaddresses": [ + { + "address": "172.16.180.1/24", + "description": "", + "display": "172.16.180.1/24", + "family": { + "label": "IPv4", + "value": 4 + }, + "id": 1 + }, + { + "address": "2001::1:1/64", + "description": "", + "display": "2001::1:1/64", + "family": { + "label": "IPv6", + "value": 6 + }, + "id": 2 + } + ], + "name": "http", + "ports": [ + 80 + ], + "protocol": { + "label": "TCP", + "value": "tcp" + }, + "tags": [], + "virtual_machine": null + } + ], + "site_groups": [], + "sites": [ + "test-site" + ], + "status": { + "label": "Active", + "value": "active" + }, + "tags": [] + }, + "test100-vm": { + "cluster": "Test Cluster", + "cluster_group": "test-cluster-group", + "cluster_type": "test-cluster-type", + "config_context": [ + {} + ], + "custom_fields": {}, + "disk": 170, + "interfaces": [ + { + "bridge": null, + "count_fhrp_groups": 0, + "count_ipaddresses": 0, + "custom_fields": {}, + "description": "", + "display": "Eth0", + "display_url": "http://localhost:32768/virtualization/interfaces/1/", + "enabled": true, + "id": 1, + "ip_addresses": [], + "l2vpn_termination": null, + "mac_address": null, + "mode": null, + "mtu": null, + "name": "Eth0", + "parent": null, + "tagged_vlans": [], + "tags": [], + "untagged_vlan": null, + "virtual_machine": { + "description": "", + "display": "test100-vm", + "id": 1, + "name": "test100-vm" + }, + "vrf": null + }, + { + "bridge": null, + "count_fhrp_groups": 0, + "count_ipaddresses": 0, + "custom_fields": {}, + "description": "", + "display": "Eth1", + "display_url": "http://localhost:32768/virtualization/interfaces/2/", + "enabled": true, + "id": 2, + "ip_addresses": [], + "l2vpn_termination": null, + "mac_address": null, + "mode": null, + "mtu": null, + "name": "Eth1", + "parent": null, + "tagged_vlans": [], + "tags": [], + "untagged_vlan": null, + "virtual_machine": { + "description": "", + "display": "test100-vm", + "id": 1, + "name": "test100-vm" + }, + "vrf": null + }, + { + "bridge": null, + "count_fhrp_groups": 0, + "count_ipaddresses": 0, + "custom_fields": {}, + "description": "", + "display": "Eth2", + "display_url": "http://localhost:32768/virtualization/interfaces/3/", + "enabled": true, + "id": 3, + "ip_addresses": [], + "l2vpn_termination": null, + "mac_address": null, + "mode": null, + "mtu": null, + "name": "Eth2", + "parent": null, + "tagged_vlans": [], + "tags": [], + "untagged_vlan": null, + "virtual_machine": { + "description": "", + "display": "test100-vm", + "id": 1, + "name": "test100-vm" + }, + "vrf": null + }, + { + "bridge": null, + "count_fhrp_groups": 0, + "count_ipaddresses": 0, + "custom_fields": {}, + "description": "", + "display": "Eth3", + "display_url": "http://localhost:32768/virtualization/interfaces/4/", + "enabled": true, + "id": 4, + "ip_addresses": [], + "l2vpn_termination": null, + "mac_address": null, + "mode": null, + "mtu": null, + "name": "Eth3", + "parent": null, + "tagged_vlans": [], + "tags": [], + "untagged_vlan": null, + "virtual_machine": { + "description": "", + "display": "test100-vm", + "id": 1, + "name": "test100-vm" + }, + "vrf": null + }, + { + "bridge": null, + "count_fhrp_groups": 0, + "count_ipaddresses": 0, + "custom_fields": {}, + "description": "", + "display": "Eth4", + "display_url": "http://localhost:32768/virtualization/interfaces/5/", + "enabled": true, + "id": 5, + "ip_addresses": [], + "l2vpn_termination": null, + "mac_address": null, + "mode": null, + "mtu": null, + "name": "Eth4", + "parent": null, + "tagged_vlans": [], + "tags": [], + "untagged_vlan": null, + "virtual_machine": { + "description": "", + "display": "test100-vm", + "id": 1, + "name": "test100-vm" + }, + "vrf": null + } + ], + "is_virtual": true, + "local_context_data": [ + null + ], + "regions": [ + "test-region", + "parent-region" + ], + "serial": "", + "services": [], + "site_groups": [], + "sites": [ + "test-site" + ], + "status": { + "label": "Active", + "value": "active" + }, + "tags": [] + }, + "test101-vm": { + "cluster": "Test Cluster", + "cluster_group": "test-cluster-group", + "cluster_type": "test-cluster-type", + "config_context": [ + {} + ], + "custom_fields": {}, + "interfaces": [ + { + "bridge": null, + "count_fhrp_groups": 0, + "count_ipaddresses": 0, + "custom_fields": {}, + "description": "", + "display": "Eth0", + "display_url": "http://localhost:32768/virtualization/interfaces/6/", + "enabled": true, + "id": 6, + "ip_addresses": [], + "l2vpn_termination": null, + "mac_address": null, + "mode": null, + "mtu": null, + "name": "Eth0", + "parent": null, + "tagged_vlans": [], + "tags": [], + "untagged_vlan": null, + "virtual_machine": { + "description": "", + "display": "test101-vm", + "id": 2, + "name": "test101-vm" + }, + "vrf": null + }, + { + "bridge": null, + "count_fhrp_groups": 0, + "count_ipaddresses": 0, + "custom_fields": {}, + "description": "", + "display": "Eth1", + "display_url": "http://localhost:32768/virtualization/interfaces/7/", + "enabled": true, + "id": 7, + "ip_addresses": [], + "l2vpn_termination": null, + "mac_address": null, + "mode": null, + "mtu": null, + "name": "Eth1", + "parent": null, + "tagged_vlans": [], + "tags": [], + "untagged_vlan": null, + "virtual_machine": { + "description": "", + "display": "test101-vm", + "id": 2, + "name": "test101-vm" + }, + "vrf": null + }, + { + "bridge": null, + "count_fhrp_groups": 0, + "count_ipaddresses": 0, + "custom_fields": {}, + "description": "", + "display": "Eth2", + "display_url": "http://localhost:32768/virtualization/interfaces/8/", + "enabled": true, + "id": 8, + "ip_addresses": [], + "l2vpn_termination": null, + "mac_address": null, + "mode": null, + "mtu": null, + "name": "Eth2", + "parent": null, + "tagged_vlans": [], + "tags": [], + "untagged_vlan": null, + "virtual_machine": { + "description": "", + "display": "test101-vm", + "id": 2, + "name": "test101-vm" + }, + "vrf": null + }, + { + "bridge": null, + "count_fhrp_groups": 0, + "count_ipaddresses": 0, + "custom_fields": {}, + "description": "", + "display": "Eth3", + "display_url": "http://localhost:32768/virtualization/interfaces/9/", + "enabled": true, + "id": 9, + "ip_addresses": [], + "l2vpn_termination": null, + "mac_address": null, + "mode": null, + "mtu": null, + "name": "Eth3", + "parent": null, + "tagged_vlans": [], + "tags": [], + "untagged_vlan": null, + "virtual_machine": { + "description": "", + "display": "test101-vm", + "id": 2, + "name": "test101-vm" + }, + "vrf": null + }, + { + "bridge": null, + "count_fhrp_groups": 0, + "count_ipaddresses": 0, + "custom_fields": {}, + "description": "", + "display": "Eth4", + "display_url": "http://localhost:32768/virtualization/interfaces/10/", + "enabled": true, + "id": 10, + "ip_addresses": [], + "l2vpn_termination": null, + "mac_address": null, + "mode": null, + "mtu": null, + "name": "Eth4", + "parent": null, + "tagged_vlans": [], + "tags": [], + "untagged_vlan": null, + "virtual_machine": { + "description": "", + "display": "test101-vm", + "id": 2, + "name": "test101-vm" + }, + "vrf": null + } + ], + "is_virtual": true, + "local_context_data": [ + null + ], + "regions": [ + "test-region", + "parent-region" + ], + "serial": "", + "services": [], + "site_groups": [], + "sites": [ + "test-site" + ], + "status": { + "label": "Active", + "value": "active" + }, + "tags": [] + }, + "test102-vm": { + "cluster": "Test Cluster", + "cluster_group": "test-cluster-group", + "cluster_type": "test-cluster-type", + "config_context": [ + {} + ], + "custom_fields": {}, + "interfaces": [], + "is_virtual": true, + "local_context_data": [ + null + ], + "regions": [ + "test-region", + "parent-region" + ], + "serial": "", + "services": [], + "site_groups": [], + "sites": [ + "test-site" + ], + "status": { + "label": "Active", + "value": "active" + }, + "tags": [] + }, + "test103-vm": { + "cluster": "Test Cluster", + "cluster_group": "test-cluster-group", + "cluster_type": "test-cluster-type", + "config_context": [ + {} + ], + "custom_fields": {}, + "interfaces": [], + "is_virtual": true, + "local_context_data": [ + null + ], + "regions": [ + "test-region", + "parent-region" + ], + "serial": "", + "services": [], + "site_groups": [], + "sites": [ + "test-site" + ], + "status": { + "label": "Active", + "value": "active" + }, + "tags": [] + }, + "test104-vm": { + "cluster": "Test Cluster 2", + "cluster_type": "test-cluster-type", + "config_context": [ + {} + ], + "custom_fields": {}, + "interfaces": [], + "is_virtual": true, + "local_context_data": [ + null + ], + "regions": [], + "serial": "", + "services": [], + "site_groups": [], + "status": { + "label": "Active", + "value": "active" + }, + "tags": [] + } + } + }, + "all": { + "children": [ + "ungrouped", + "sites_test_site2", + "region_other_region", + "region_parent_region", + "site_group_other_site_group", + "site_group_parent_site_group", + "device_roles_core_switch", + "device_types_cisco_test", + "manufacturers_cisco", + "status_active", + "device_types_nexus_parent", + "cluster_Test_Cluster_2", + "cluster_type_test_cluster_type", + "is_virtual", + "cluster_Test_Cluster", + "cluster_group_test_cluster_group" + ] + }, + "cluster_Test_Cluster": { + "hosts": [ + "test100-vm", + "test101-vm", + "test102-vm", + "test103-vm" + ] + }, + "cluster_Test_Cluster_2": { + "hosts": [ + "Test VM With Spaces", + "test104-vm" + ] + }, + "cluster_group_test_cluster_group": { + "hosts": [ + "test100-vm", + "test101-vm", + "test102-vm", + "test103-vm" + ] + }, + "cluster_type_test_cluster_type": { + "hosts": [ + "Test VM With Spaces", + "test100-vm", + "test101-vm", + "test102-vm", + "test103-vm", + "test104-vm" + ] + }, + "device_roles_core_switch": { + "hosts": [ + "R1-Device", + "Test Nexus One", + "TestDeviceR1", + "test100" + ] + }, + "device_types_cisco_test": { + "hosts": [ + "R1-Device", + "TestDeviceR1", + "test100" + ] + }, + "device_types_nexus_parent": { + "hosts": [ + "Test Nexus One" + ] + }, + "is_virtual": { + "hosts": [ + "Test VM With Spaces", + "test100-vm", + "test101-vm", + "test102-vm", + "test103-vm", + "test104-vm" + ] + }, + "location_parent_rack_group": { + "children": [ + "location_test_rack_group" + ] + }, + "location_test_rack_group": { + "hosts": [ + "Test Nexus One", + "TestDeviceR1", + "test100" + ] + }, + "manufacturers_cisco": { + "hosts": [ + "R1-Device", + "Test Nexus One", + "TestDeviceR1", + "test100" + ] + }, + "region_parent_region": { + "children": [ + "region_test_region" + ] + }, + "region_test_region": { + "children": [ + "sites_test_site" + ] + }, + "site_group_parent_site_group": { + "children": [ + "site_group_test_site_group" + ] + }, + "sites_test_site": { + "children": [ + "location_parent_rack_group" + ], + "hosts": [ + "test100-vm", + "test101-vm", + "test102-vm", + "test103-vm" + ] + }, + "sites_test_site2": { + "hosts": [ + "R1-Device" + ] + }, + "status_active": { + "hosts": [ + "R1-Device", + "Test Nexus One", + "TestDeviceR1", + "test100", + "Test VM With Spaces", + "test100-vm", + "test101-vm", + "test102-vm", + "test103-vm", + "test104-vm" + ] + } +} \ No newline at end of file diff --git a/tests/integration/targets/inventory-v4.3/files/test-inventory-noracks.yml b/tests/integration/targets/inventory-v4.3/files/test-inventory-noracks.yml new file mode 100644 index 000000000..f21f3ca62 --- /dev/null +++ b/tests/integration/targets/inventory-v4.3/files/test-inventory-noracks.yml @@ -0,0 +1,28 @@ +--- +plugin: netbox.netbox.nb_inventory +api_endpoint: http://localhost:32768 +token: "0123456789abcdef0123456789abcdef01234567" +validate_certs: false + +config_context: true +plurals: true +interfaces: true +services: true +racks: false + +group_by: + - sites + - tenants + - location + - tags + - device_roles + - device_types + - manufacturers + - platforms + - region + - site_group + - cluster + - cluster_group + - cluster_type + - is_virtual + - status diff --git a/tests/integration/targets/inventory-v4.3/files/test-inventory-options-flatten.json b/tests/integration/targets/inventory-v4.3/files/test-inventory-options-flatten.json new file mode 100644 index 000000000..d0698bbbc --- /dev/null +++ b/tests/integration/targets/inventory-v4.3/files/test-inventory-options-flatten.json @@ -0,0 +1,1302 @@ +{ + "Test_Cluster": { + "hosts": [ + "test100-vm", + "test101-vm", + "test102-vm", + "test103-vm" + ] + }, + "Test_Cluster_2": { + "hosts": [ + "Test VM With Spaces", + "test104-vm" + ] + }, + "Test_Rack": { + "hosts": [ + "TestDeviceR1" + ] + }, + "Test_Rack_Site_2": { + "hosts": [ + "R1-Device" + ] + }, + "_meta": { + "hostvars": { + "R1-Device": { + "asset_tag": "345678901", + "device_type": "cisco-test", + "interfaces": [], + "is_virtual": false, + "locations": [], + "manufacturer": "cisco", + "rack": "Test Rack Site 2", + "rack_role": "test-rack-role", + "regions": [], + "role": "core-switch", + "serial": "", + "services": [], + "site": "test-site2", + "site_groups": [], + "status": { + "label": "Active", + "value": "active" + }, + "tags": [] + }, + "Test Nexus One": { + "ansible_host": "172.16.180.12", + "device_type": "nexus-parent", + "dns_name": "nexus.example.com", + "interfaces": [ + { + "_occupied": false, + "bridge": null, + "cable": null, + "cable_end": "", + "connected_endpoints": null, + "connected_endpoints_reachable": null, + "connected_endpoints_type": null, + "count_fhrp_groups": 0, + "count_ipaddresses": 1, + "custom_fields": {}, + "description": "", + "device": { + "description": "", + "display": "Test Nexus One", + "id": 4, + "name": "Test Nexus One" + }, + "display": "Ethernet1/1", + "display_url": "http://localhost:32768/dcim/interfaces/1/", + "duplex": null, + "enabled": true, + "id": 1, + "ip_addresses": [ + { + "address": "172.16.180.11/24", + "comments": "", + "custom_fields": {}, + "description": "", + "display": "172.16.180.11/24", + "display_url": "http://localhost:32768/ipam/ip-addresses/3/", + "dns_name": "", + "family": { + "label": "IPv4", + "value": 4 + }, + "id": 3, + "nat_inside": null, + "nat_outside": [], + "role": null, + "status": { + "label": "Active", + "value": "active" + }, + "tags": [], + "tenant": null, + "vrf": null + } + ], + "l2vpn_termination": null, + "label": "", + "lag": null, + "link_peers": [], + "link_peers_type": null, + "mac_address": null, + "mark_connected": false, + "mgmt_only": false, + "mode": null, + "module": null, + "mtu": null, + "name": "Ethernet1/1", + "parent": null, + "poe_mode": null, + "poe_type": null, + "rf_channel": null, + "rf_channel_frequency": null, + "rf_channel_width": null, + "rf_role": null, + "speed": null, + "tagged_vlans": [], + "tags": [], + "tx_power": null, + "type": { + "label": "1000BASE-T (1GE)", + "value": "1000base-t" + }, + "untagged_vlan": null, + "vdcs": [], + "vrf": null, + "wireless_lans": [], + "wireless_link": null, + "wwn": null + }, + { + "_occupied": false, + "bridge": null, + "cable": null, + "cable_end": "", + "connected_endpoints": null, + "connected_endpoints_reachable": null, + "connected_endpoints_type": null, + "count_fhrp_groups": 0, + "count_ipaddresses": 1, + "custom_fields": {}, + "description": "", + "device": { + "description": "", + "display": "Test Nexus Child One", + "id": 5, + "name": "Test Nexus Child One" + }, + "display": "Ethernet2/1", + "display_url": "http://localhost:32768/dcim/interfaces/2/", + "duplex": null, + "enabled": true, + "id": 2, + "ip_addresses": [ + { + "address": "172.16.180.12/24", + "comments": "", + "custom_fields": {}, + "description": "", + "display": "172.16.180.12/24", + "display_url": "http://localhost:32768/ipam/ip-addresses/4/", + "dns_name": "nexus.example.com", + "family": { + "label": "IPv4", + "value": 4 + }, + "id": 4, + "nat_inside": null, + "nat_outside": [], + "role": null, + "status": { + "label": "Active", + "value": "active" + }, + "tags": [], + "tenant": null, + "vrf": null + } + ], + "l2vpn_termination": null, + "label": "", + "lag": null, + "link_peers": [], + "link_peers_type": null, + "mac_address": null, + "mark_connected": false, + "mgmt_only": false, + "mode": null, + "module": null, + "mtu": null, + "name": "Ethernet2/1", + "parent": null, + "poe_mode": null, + "poe_type": null, + "rf_channel": null, + "rf_channel_frequency": null, + "rf_channel_width": null, + "rf_role": null, + "speed": null, + "tagged_vlans": [], + "tags": [], + "tx_power": null, + "type": { + "label": "1000BASE-T (1GE)", + "value": "1000base-t" + }, + "untagged_vlan": null, + "vdcs": [], + "vrf": null, + "wireless_lans": [], + "wireless_link": null, + "wwn": null + }, + { + "_occupied": false, + "bridge": null, + "cable": null, + "cable_end": "", + "connected_endpoints": null, + "connected_endpoints_reachable": null, + "connected_endpoints_type": null, + "count_fhrp_groups": 0, + "count_ipaddresses": 0, + "custom_fields": {}, + "description": "", + "device": { + "description": "", + "display": "Test Nexus One", + "id": 4, + "name": "Test Nexus One" + }, + "display": "wlink1", + "display_url": "http://localhost:32768/dcim/interfaces/6/", + "duplex": null, + "enabled": true, + "id": 6, + "ip_addresses": [], + "l2vpn_termination": null, + "label": "", + "lag": null, + "link_peers": [], + "link_peers_type": null, + "mac_address": null, + "mark_connected": false, + "mgmt_only": false, + "mode": null, + "module": null, + "mtu": null, + "name": "wlink1", + "parent": null, + "poe_mode": null, + "poe_type": null, + "rf_channel": null, + "rf_channel_frequency": null, + "rf_channel_width": null, + "rf_role": null, + "speed": null, + "tagged_vlans": [], + "tags": [], + "tx_power": null, + "type": { + "label": "IEEE 802.11a", + "value": "ieee802.11a" + }, + "untagged_vlan": null, + "vdcs": [], + "vrf": null, + "wireless_lans": [], + "wireless_link": null, + "wwn": null + } + ], + "is_virtual": false, + "locations": [ + "test-rack-group", + "parent-rack-group" + ], + "manufacturer": "cisco", + "primary_ip4": "172.16.180.12", + "regions": [ + "test-region", + "parent-region" + ], + "role": "core-switch", + "serial": "", + "services": [ + { + "comments": "", + "custom_fields": {}, + "description": "", + "device": { + "description": "", + "display": "Test Nexus One", + "id": 4, + "name": "Test Nexus One" + }, + "display": "telnet (TCP/23)", + "display_url": "http://localhost:32768/ipam/services/3/", + "id": 3, + "ipaddresses": [], + "name": "telnet", + "ports": [ + 23 + ], + "protocol": { + "label": "TCP", + "value": "tcp" + }, + "tags": [], + "virtual_machine": null + } + ], + "site": "test-site", + "site_groups": [], + "status": { + "label": "Active", + "value": "active" + }, + "tags": [] + }, + "Test VM With Spaces": { + "cluster": "Test Cluster 2", + "cluster_type": "test-cluster-type", + "interfaces": [ + { + "bridge": null, + "count_fhrp_groups": 0, + "count_ipaddresses": 0, + "custom_fields": {}, + "description": "", + "display": "Eth0", + "display_url": "http://localhost:32768/virtualization/interfaces/11/", + "enabled": true, + "id": 11, + "ip_addresses": [], + "l2vpn_termination": null, + "mac_address": null, + "mode": null, + "mtu": null, + "name": "Eth0", + "parent": null, + "tagged_vlans": [], + "tags": [], + "untagged_vlan": null, + "virtual_machine": { + "description": "", + "display": "Test VM With Spaces", + "id": 6, + "name": "Test VM With Spaces" + }, + "vrf": null + }, + { + "bridge": null, + "count_fhrp_groups": 0, + "count_ipaddresses": 0, + "custom_fields": {}, + "description": "", + "display": "Eth1", + "display_url": "http://localhost:32768/virtualization/interfaces/12/", + "enabled": true, + "id": 12, + "ip_addresses": [], + "l2vpn_termination": null, + "mac_address": null, + "mode": null, + "mtu": null, + "name": "Eth1", + "parent": null, + "tagged_vlans": [], + "tags": [], + "untagged_vlan": null, + "virtual_machine": { + "description": "", + "display": "Test VM With Spaces", + "id": 6, + "name": "Test VM With Spaces" + }, + "vrf": null + } + ], + "is_virtual": true, + "locations": [], + "regions": [], + "serial": "", + "services": [ + { + "comments": "", + "custom_fields": {}, + "description": "", + "device": null, + "display": "ssh (TCP/22)", + "display_url": "http://localhost:32768/ipam/services/4/", + "id": 4, + "ipaddresses": [], + "name": "ssh", + "ports": [ + 22 + ], + "protocol": { + "label": "TCP", + "value": "tcp" + }, + "tags": [], + "virtual_machine": { + "description": "", + "display": "Test VM With Spaces", + "id": 6, + "name": "Test VM With Spaces" + } + } + ], + "site_groups": [], + "status": { + "label": "Active", + "value": "active" + }, + "tags": [] + }, + "TestDeviceR1": { + "device_type": "cisco-test", + "interfaces": [], + "is_virtual": false, + "locations": [ + "test-rack-group", + "parent-rack-group" + ], + "manufacturer": "cisco", + "rack": "Test Rack", + "regions": [ + "test-region", + "parent-region" + ], + "role": "core-switch", + "serial": "FAB12345678", + "services": [], + "site": "test-site", + "site_groups": [], + "status": { + "label": "Active", + "value": "active" + }, + "tags": [] + }, + "test100": { + "asset_tag": "123456789", + "device_type": "cisco-test", + "interfaces": [ + { + "_occupied": false, + "bridge": null, + "cable": null, + "cable_end": "", + "connected_endpoints": null, + "connected_endpoints_reachable": null, + "connected_endpoints_type": null, + "count_fhrp_groups": 0, + "count_ipaddresses": 1, + "custom_fields": {}, + "description": "", + "device": { + "description": "", + "display": "test100 (123456789)", + "id": 1, + "name": "test100" + }, + "display": "GigabitEthernet1", + "display_url": "http://localhost:32768/dcim/interfaces/3/", + "duplex": null, + "enabled": true, + "id": 3, + "ip_addresses": [ + { + "address": "172.16.180.1/24", + "comments": "", + "custom_fields": {}, + "description": "", + "display": "172.16.180.1/24", + "display_url": "http://localhost:32768/ipam/ip-addresses/1/", + "dns_name": "", + "family": { + "label": "IPv4", + "value": 4 + }, + "id": 1, + "nat_inside": null, + "nat_outside": [], + "role": null, + "status": { + "label": "Active", + "value": "active" + }, + "tags": [], + "tenant": null, + "vrf": null + } + ], + "l2vpn_termination": null, + "label": "", + "lag": null, + "link_peers": [], + "link_peers_type": null, + "mac_address": null, + "mark_connected": false, + "mgmt_only": false, + "mode": null, + "module": null, + "mtu": null, + "name": "GigabitEthernet1", + "parent": null, + "poe_mode": null, + "poe_type": null, + "rf_channel": null, + "rf_channel_frequency": null, + "rf_channel_width": null, + "rf_role": null, + "speed": null, + "tagged_vlans": [], + "tags": [], + "tx_power": null, + "type": { + "label": "1000BASE-T (1GE)", + "value": "1000base-t" + }, + "untagged_vlan": null, + "vdcs": [], + "vrf": null, + "wireless_lans": [], + "wireless_link": null, + "wwn": null + }, + { + "_occupied": false, + "bridge": null, + "cable": null, + "cable_end": "", + "connected_endpoints": null, + "connected_endpoints_reachable": null, + "connected_endpoints_type": null, + "count_fhrp_groups": 0, + "count_ipaddresses": 1, + "custom_fields": {}, + "description": "", + "device": { + "description": "", + "display": "test100 (123456789)", + "id": 1, + "name": "test100" + }, + "display": "GigabitEthernet2", + "display_url": "http://localhost:32768/dcim/interfaces/4/", + "duplex": null, + "enabled": true, + "id": 4, + "ip_addresses": [ + { + "address": "2001::1:1/64", + "comments": "", + "custom_fields": {}, + "description": "", + "display": "2001::1:1/64", + "display_url": "http://localhost:32768/ipam/ip-addresses/2/", + "dns_name": "", + "family": { + "label": "IPv6", + "value": 6 + }, + "id": 2, + "nat_inside": null, + "nat_outside": [], + "role": null, + "status": { + "label": "Active", + "value": "active" + }, + "tags": [], + "tenant": null, + "vrf": null + } + ], + "l2vpn_termination": null, + "label": "", + "lag": null, + "link_peers": [], + "link_peers_type": null, + "mac_address": null, + "mark_connected": false, + "mgmt_only": false, + "mode": null, + "module": null, + "mtu": null, + "name": "GigabitEthernet2", + "parent": null, + "poe_mode": null, + "poe_type": null, + "rf_channel": null, + "rf_channel_frequency": null, + "rf_channel_width": null, + "rf_role": null, + "speed": null, + "tagged_vlans": [], + "tags": [], + "tx_power": null, + "type": { + "label": "1000BASE-T (1GE)", + "value": "1000base-t" + }, + "untagged_vlan": null, + "vdcs": [], + "vrf": null, + "wireless_lans": [], + "wireless_link": null, + "wwn": null + }, + { + "_occupied": false, + "bridge": null, + "cable": null, + "cable_end": "", + "connected_endpoints": null, + "connected_endpoints_reachable": null, + "connected_endpoints_type": null, + "count_fhrp_groups": 0, + "count_ipaddresses": 0, + "custom_fields": {}, + "description": "", + "device": { + "description": "", + "display": "test100 (123456789)", + "id": 1, + "name": "test100" + }, + "display": "wlink1", + "display_url": "http://localhost:32768/dcim/interfaces/5/", + "duplex": null, + "enabled": true, + "id": 5, + "ip_addresses": [], + "l2vpn_termination": null, + "label": "", + "lag": null, + "link_peers": [], + "link_peers_type": null, + "mac_address": null, + "mark_connected": false, + "mgmt_only": false, + "mode": null, + "module": null, + "mtu": null, + "name": "wlink1", + "parent": null, + "poe_mode": null, + "poe_type": null, + "rf_channel": null, + "rf_channel_frequency": null, + "rf_channel_width": null, + "rf_role": null, + "speed": null, + "tagged_vlans": [], + "tags": [], + "tx_power": null, + "type": { + "label": "IEEE 802.11a", + "value": "ieee802.11a" + }, + "untagged_vlan": null, + "vdcs": [], + "vrf": null, + "wireless_lans": [], + "wireless_link": null, + "wwn": null + } + ], + "is_virtual": false, + "locations": [ + "test-rack-group", + "parent-rack-group" + ], + "manufacturer": "cisco", + "ntp_servers": [ + "pool.ntp.org" + ], + "regions": [ + "test-region", + "parent-region" + ], + "role": "core-switch", + "serial": "FAB01234567", + "services": [ + { + "comments": "", + "custom_fields": {}, + "description": "", + "device": { + "description": "", + "display": "test100 (123456789)", + "id": 1, + "name": "test100" + }, + "display": "ssh (TCP/22)", + "display_url": "http://localhost:32768/ipam/services/1/", + "id": 1, + "ipaddresses": [], + "name": "ssh", + "ports": [ + 22 + ], + "protocol": { + "label": "TCP", + "value": "tcp" + }, + "tags": [], + "virtual_machine": null + }, + { + "comments": "", + "custom_fields": {}, + "description": "", + "device": { + "description": "", + "display": "test100 (123456789)", + "id": 1, + "name": "test100" + }, + "display": "http (TCP/80)", + "display_url": "http://localhost:32768/ipam/services/2/", + "id": 2, + "ipaddresses": [ + { + "address": "172.16.180.1/24", + "description": "", + "display": "172.16.180.1/24", + "family": { + "label": "IPv4", + "value": 4 + }, + "id": 1 + }, + { + "address": "2001::1:1/64", + "description": "", + "display": "2001::1:1/64", + "family": { + "label": "IPv6", + "value": 6 + }, + "id": 2 + } + ], + "name": "http", + "ports": [ + 80 + ], + "protocol": { + "label": "TCP", + "value": "tcp" + }, + "tags": [], + "virtual_machine": null + } + ], + "site": "test-site", + "site_groups": [], + "status": { + "label": "Active", + "value": "active" + }, + "tags": [] + }, + "test100-vm": { + "cluster": "Test Cluster", + "cluster_group": "test-cluster-group", + "cluster_type": "test-cluster-type", + "disk": 170, + "interfaces": [ + { + "bridge": null, + "count_fhrp_groups": 0, + "count_ipaddresses": 0, + "custom_fields": {}, + "description": "", + "display": "Eth0", + "display_url": "http://localhost:32768/virtualization/interfaces/1/", + "enabled": true, + "id": 1, + "ip_addresses": [], + "l2vpn_termination": null, + "mac_address": null, + "mode": null, + "mtu": null, + "name": "Eth0", + "parent": null, + "tagged_vlans": [], + "tags": [], + "untagged_vlan": null, + "virtual_machine": { + "description": "", + "display": "test100-vm", + "id": 1, + "name": "test100-vm" + }, + "vrf": null + }, + { + "bridge": null, + "count_fhrp_groups": 0, + "count_ipaddresses": 0, + "custom_fields": {}, + "description": "", + "display": "Eth1", + "display_url": "http://localhost:32768/virtualization/interfaces/2/", + "enabled": true, + "id": 2, + "ip_addresses": [], + "l2vpn_termination": null, + "mac_address": null, + "mode": null, + "mtu": null, + "name": "Eth1", + "parent": null, + "tagged_vlans": [], + "tags": [], + "untagged_vlan": null, + "virtual_machine": { + "description": "", + "display": "test100-vm", + "id": 1, + "name": "test100-vm" + }, + "vrf": null + }, + { + "bridge": null, + "count_fhrp_groups": 0, + "count_ipaddresses": 0, + "custom_fields": {}, + "description": "", + "display": "Eth2", + "display_url": "http://localhost:32768/virtualization/interfaces/3/", + "enabled": true, + "id": 3, + "ip_addresses": [], + "l2vpn_termination": null, + "mac_address": null, + "mode": null, + "mtu": null, + "name": "Eth2", + "parent": null, + "tagged_vlans": [], + "tags": [], + "untagged_vlan": null, + "virtual_machine": { + "description": "", + "display": "test100-vm", + "id": 1, + "name": "test100-vm" + }, + "vrf": null + }, + { + "bridge": null, + "count_fhrp_groups": 0, + "count_ipaddresses": 0, + "custom_fields": {}, + "description": "", + "display": "Eth3", + "display_url": "http://localhost:32768/virtualization/interfaces/4/", + "enabled": true, + "id": 4, + "ip_addresses": [], + "l2vpn_termination": null, + "mac_address": null, + "mode": null, + "mtu": null, + "name": "Eth3", + "parent": null, + "tagged_vlans": [], + "tags": [], + "untagged_vlan": null, + "virtual_machine": { + "description": "", + "display": "test100-vm", + "id": 1, + "name": "test100-vm" + }, + "vrf": null + }, + { + "bridge": null, + "count_fhrp_groups": 0, + "count_ipaddresses": 0, + "custom_fields": {}, + "description": "", + "display": "Eth4", + "display_url": "http://localhost:32768/virtualization/interfaces/5/", + "enabled": true, + "id": 5, + "ip_addresses": [], + "l2vpn_termination": null, + "mac_address": null, + "mode": null, + "mtu": null, + "name": "Eth4", + "parent": null, + "tagged_vlans": [], + "tags": [], + "untagged_vlan": null, + "virtual_machine": { + "description": "", + "display": "test100-vm", + "id": 1, + "name": "test100-vm" + }, + "vrf": null + } + ], + "is_virtual": true, + "locations": [], + "regions": [ + "test-region", + "parent-region" + ], + "serial": "", + "services": [], + "site": "test-site", + "site_groups": [], + "status": { + "label": "Active", + "value": "active" + }, + "tags": [] + }, + "test101-vm": { + "cluster": "Test Cluster", + "cluster_group": "test-cluster-group", + "cluster_type": "test-cluster-type", + "interfaces": [ + { + "bridge": null, + "count_fhrp_groups": 0, + "count_ipaddresses": 0, + "custom_fields": {}, + "description": "", + "display": "Eth0", + "display_url": "http://localhost:32768/virtualization/interfaces/6/", + "enabled": true, + "id": 6, + "ip_addresses": [], + "l2vpn_termination": null, + "mac_address": null, + "mode": null, + "mtu": null, + "name": "Eth0", + "parent": null, + "tagged_vlans": [], + "tags": [], + "untagged_vlan": null, + "virtual_machine": { + "description": "", + "display": "test101-vm", + "id": 2, + "name": "test101-vm" + }, + "vrf": null + }, + { + "bridge": null, + "count_fhrp_groups": 0, + "count_ipaddresses": 0, + "custom_fields": {}, + "description": "", + "display": "Eth1", + "display_url": "http://localhost:32768/virtualization/interfaces/7/", + "enabled": true, + "id": 7, + "ip_addresses": [], + "l2vpn_termination": null, + "mac_address": null, + "mode": null, + "mtu": null, + "name": "Eth1", + "parent": null, + "tagged_vlans": [], + "tags": [], + "untagged_vlan": null, + "virtual_machine": { + "description": "", + "display": "test101-vm", + "id": 2, + "name": "test101-vm" + }, + "vrf": null + }, + { + "bridge": null, + "count_fhrp_groups": 0, + "count_ipaddresses": 0, + "custom_fields": {}, + "description": "", + "display": "Eth2", + "display_url": "http://localhost:32768/virtualization/interfaces/8/", + "enabled": true, + "id": 8, + "ip_addresses": [], + "l2vpn_termination": null, + "mac_address": null, + "mode": null, + "mtu": null, + "name": "Eth2", + "parent": null, + "tagged_vlans": [], + "tags": [], + "untagged_vlan": null, + "virtual_machine": { + "description": "", + "display": "test101-vm", + "id": 2, + "name": "test101-vm" + }, + "vrf": null + }, + { + "bridge": null, + "count_fhrp_groups": 0, + "count_ipaddresses": 0, + "custom_fields": {}, + "description": "", + "display": "Eth3", + "display_url": "http://localhost:32768/virtualization/interfaces/9/", + "enabled": true, + "id": 9, + "ip_addresses": [], + "l2vpn_termination": null, + "mac_address": null, + "mode": null, + "mtu": null, + "name": "Eth3", + "parent": null, + "tagged_vlans": [], + "tags": [], + "untagged_vlan": null, + "virtual_machine": { + "description": "", + "display": "test101-vm", + "id": 2, + "name": "test101-vm" + }, + "vrf": null + }, + { + "bridge": null, + "count_fhrp_groups": 0, + "count_ipaddresses": 0, + "custom_fields": {}, + "description": "", + "display": "Eth4", + "display_url": "http://localhost:32768/virtualization/interfaces/10/", + "enabled": true, + "id": 10, + "ip_addresses": [], + "l2vpn_termination": null, + "mac_address": null, + "mode": null, + "mtu": null, + "name": "Eth4", + "parent": null, + "tagged_vlans": [], + "tags": [], + "untagged_vlan": null, + "virtual_machine": { + "description": "", + "display": "test101-vm", + "id": 2, + "name": "test101-vm" + }, + "vrf": null + } + ], + "is_virtual": true, + "locations": [], + "regions": [ + "test-region", + "parent-region" + ], + "serial": "", + "services": [], + "site": "test-site", + "site_groups": [], + "status": { + "label": "Active", + "value": "active" + }, + "tags": [] + }, + "test102-vm": { + "cluster": "Test Cluster", + "cluster_group": "test-cluster-group", + "cluster_type": "test-cluster-type", + "interfaces": [], + "is_virtual": true, + "locations": [], + "regions": [ + "test-region", + "parent-region" + ], + "serial": "", + "services": [], + "site": "test-site", + "site_groups": [], + "status": { + "label": "Active", + "value": "active" + }, + "tags": [] + }, + "test103-vm": { + "cluster": "Test Cluster", + "cluster_group": "test-cluster-group", + "cluster_type": "test-cluster-type", + "interfaces": [], + "is_virtual": true, + "locations": [], + "regions": [ + "test-region", + "parent-region" + ], + "serial": "", + "services": [], + "site": "test-site", + "site_groups": [], + "status": { + "label": "Active", + "value": "active" + }, + "tags": [] + }, + "test104-vm": { + "cluster": "Test Cluster 2", + "cluster_type": "test-cluster-type", + "interfaces": [], + "is_virtual": true, + "locations": [], + "regions": [], + "serial": "", + "services": [], + "site_groups": [], + "status": { + "label": "Active", + "value": "active" + }, + "tags": [] + } + } + }, + "active": { + "hosts": [ + "R1-Device", + "Test Nexus One", + "TestDeviceR1", + "test100", + "Test VM With Spaces", + "test100-vm", + "test101-vm", + "test102-vm", + "test103-vm", + "test104-vm" + ] + }, + "all": { + "children": [ + "ungrouped", + "test_site2", + "other_region", + "parent_region", + "other_site_group", + "parent_site_group", + "Test_Rack_Site_2", + "test_rack_role", + "core_switch", + "cisco_test", + "cisco", + "active", + "nexus_parent", + "Test_Rack", + "Test_Cluster_2", + "test_cluster_type", + "is_virtual", + "Test_Cluster", + "test_cluster_group" + ] + }, + "cisco": { + "hosts": [ + "R1-Device", + "Test Nexus One", + "TestDeviceR1", + "test100" + ] + }, + "cisco_test": { + "hosts": [ + "R1-Device", + "TestDeviceR1", + "test100" + ] + }, + "core_switch": { + "hosts": [ + "R1-Device", + "Test Nexus One", + "TestDeviceR1", + "test100" + ] + }, + "is_virtual": { + "hosts": [ + "Test VM With Spaces", + "test100-vm", + "test101-vm", + "test102-vm", + "test103-vm", + "test104-vm" + ] + }, + "nexus_parent": { + "hosts": [ + "Test Nexus One" + ] + }, + "parent_rack_group": { + "children": [ + "test_rack_group" + ] + }, + "parent_region": { + "children": [ + "test_region" + ] + }, + "parent_site_group": { + "children": [ + "test_site_group" + ] + }, + "test_cluster_group": { + "hosts": [ + "test100-vm", + "test101-vm", + "test102-vm", + "test103-vm" + ] + }, + "test_cluster_type": { + "hosts": [ + "Test VM With Spaces", + "test100-vm", + "test101-vm", + "test102-vm", + "test103-vm", + "test104-vm" + ] + }, + "test_rack_group": { + "hosts": [ + "Test Nexus One", + "TestDeviceR1", + "test100" + ] + }, + "test_rack_role": { + "hosts": [ + "R1-Device" + ] + }, + "test_region": { + "children": [ + "test_site" + ] + }, + "test_site": { + "children": [ + "parent_rack_group" + ], + "hosts": [ + "test100-vm", + "test101-vm", + "test102-vm", + "test103-vm" + ] + }, + "test_site2": { + "hosts": [ + "R1-Device" + ] + } +} \ No newline at end of file diff --git a/tests/integration/targets/inventory-v4.3/files/test-inventory-options-flatten.yml b/tests/integration/targets/inventory-v4.3/files/test-inventory-options-flatten.yml new file mode 100644 index 000000000..73d6beec9 --- /dev/null +++ b/tests/integration/targets/inventory-v4.3/files/test-inventory-options-flatten.yml @@ -0,0 +1,41 @@ +--- +plugin: netbox.netbox.nb_inventory +api_endpoint: http://localhost:32768 +token: "0123456789abcdef0123456789abcdef01234567" +validate_certs: false + +# Use cache on this test to make sure interfaces is tested via the cache +cache: true +cache_timeout: 3600 +cache_plugin: jsonfile +cache_connection: /tmp/inventory_netbox + +config_context: true +flatten_config_context: true +flatten_custom_fields: true +flatten_local_context_data: true +plurals: false +interfaces: true +services: true +fetch_all: false +max_uri_length: 0 +group_names_raw: true + +group_by: + - site + - tenant + - rack + - location + - rack_role + - tag + - role + - device_type + - manufacturer + - platform + - region + - site_group + - cluster + - cluster_group + - cluster_type + - is_virtual + - status diff --git a/tests/integration/targets/inventory-v4.3/files/test-inventory-options.json b/tests/integration/targets/inventory-v4.3/files/test-inventory-options.json new file mode 100644 index 000000000..0542ee506 --- /dev/null +++ b/tests/integration/targets/inventory-v4.3/files/test-inventory-options.json @@ -0,0 +1,390 @@ +{ + "Test_Cluster": { + "hosts": [ + "test100-vm", + "test101-vm", + "test102-vm", + "test103-vm" + ] + }, + "Test_Cluster_2": { + "hosts": [ + "Test VM With Spaces", + "test104-vm" + ] + }, + "Test_Rack": { + "hosts": [ + "TestDeviceR1" + ] + }, + "Test_Rack_Site_2": { + "hosts": [ + "R1-Device" + ] + }, + "_meta": { + "hostvars": { + "R1-Device": { + "asset_tag": "345678901", + "custom_fields": {}, + "device_type": "cisco-test", + "is_virtual": false, + "locations": [], + "manufacturer": "cisco", + "rack": "Test Rack Site 2", + "rack_id": "1", + "rack_role": "test-rack-role", + "regions": [], + "role": "core-switch", + "serial": "", + "site": "test-site2", + "site_groups": [], + "status": { + "label": "Active", + "value": "active" + }, + "tags": [] + }, + "Test VM With Spaces": { + "cluster": "Test Cluster 2", + "cluster_type": "test-cluster-type", + "custom_fields": {}, + "is_virtual": true, + "locations": [], + "regions": [], + "serial": "", + "site_groups": [], + "status": { + "label": "Active", + "value": "active" + }, + "tags": [] + }, + "TestDeviceR1": { + "custom_fields": {}, + "device_type": "cisco-test", + "is_virtual": false, + "locations": [ + "test-rack-group", + "parent-rack-group" + ], + "manufacturer": "cisco", + "rack": "Test Rack", + "rack_id": "2", + "regions": [ + "test-region", + "parent-region" + ], + "role": "core-switch", + "serial": "FAB12345678", + "site": "test-site", + "site_groups": [], + "status": { + "label": "Active", + "value": "active" + }, + "tags": [] + }, + "VC1": { + "ansible_host": "nexus.example.com", + "custom_fields": {}, + "device_type": "nexus-parent", + "dns_name": "nexus.example.com", + "is_virtual": false, + "locations": [ + "test-rack-group", + "parent-rack-group" + ], + "manufacturer": "cisco", + "primary_ip4": "172.16.180.12", + "regions": [ + "test-region", + "parent-region" + ], + "role": "core-switch", + "serial": "", + "site": "test-site", + "site_groups": [], + "status": { + "label": "Active", + "value": "active" + }, + "tags": [] + }, + "test100": { + "asset_tag": "123456789", + "custom_fields": {}, + "device_type": "cisco-test", + "is_virtual": false, + "local_context_data": { + "ntp_servers": [ + "pool.ntp.org" + ] + }, + "locations": [ + "test-rack-group", + "parent-rack-group" + ], + "manufacturer": "cisco", + "regions": [ + "test-region", + "parent-region" + ], + "role": "core-switch", + "serial": "FAB01234567", + "site": "test-site", + "site_groups": [], + "status": { + "label": "Active", + "value": "active" + }, + "tags": [] + }, + "test100-vm": { + "cluster": "Test Cluster", + "cluster_group": "test-cluster-group", + "cluster_type": "test-cluster-type", + "custom_fields": {}, + "disk": 170, + "is_virtual": true, + "locations": [], + "regions": [ + "test-region", + "parent-region" + ], + "serial": "", + "site": "test-site", + "site_groups": [], + "status": { + "label": "Active", + "value": "active" + }, + "tags": [] + }, + "test101-vm": { + "cluster": "Test Cluster", + "cluster_group": "test-cluster-group", + "cluster_type": "test-cluster-type", + "custom_fields": {}, + "is_virtual": true, + "locations": [], + "regions": [ + "test-region", + "parent-region" + ], + "serial": "", + "site": "test-site", + "site_groups": [], + "status": { + "label": "Active", + "value": "active" + }, + "tags": [] + }, + "test102-vm": { + "cluster": "Test Cluster", + "cluster_group": "test-cluster-group", + "cluster_type": "test-cluster-type", + "custom_fields": {}, + "is_virtual": true, + "locations": [], + "regions": [ + "test-region", + "parent-region" + ], + "serial": "", + "site": "test-site", + "site_groups": [], + "status": { + "label": "Active", + "value": "active" + }, + "tags": [] + }, + "test103-vm": { + "cluster": "Test Cluster", + "cluster_group": "test-cluster-group", + "cluster_type": "test-cluster-type", + "custom_fields": {}, + "is_virtual": true, + "locations": [], + "regions": [ + "test-region", + "parent-region" + ], + "serial": "", + "site": "test-site", + "site_groups": [], + "status": { + "label": "Active", + "value": "active" + }, + "tags": [] + }, + "test104-vm": { + "cluster": "Test Cluster 2", + "cluster_type": "test-cluster-type", + "custom_fields": {}, + "is_virtual": true, + "locations": [], + "regions": [], + "serial": "", + "site_groups": [], + "status": { + "label": "Active", + "value": "active" + }, + "tags": [] + } + } + }, + "active": { + "hosts": [ + "R1-Device", + "VC1", + "TestDeviceR1", + "test100", + "Test VM With Spaces", + "test100-vm", + "test101-vm", + "test102-vm", + "test103-vm", + "test104-vm" + ] + }, + "all": { + "children": [ + "ungrouped", + "test_site2", + "other_region", + "parent_region", + "other_site_group", + "parent_site_group", + "Test_Rack_Site_2", + "test_rack_role", + "core_switch", + "cisco_test", + "cisco", + "active", + "nexus_parent", + "jinja_test_group", + "Test_Rack", + "Test_Cluster_2", + "test_cluster_type", + "is_virtual", + "Test_Cluster", + "test_cluster_group" + ] + }, + "cisco": { + "hosts": [ + "R1-Device", + "VC1", + "TestDeviceR1", + "test100" + ] + }, + "cisco_test": { + "hosts": [ + "R1-Device", + "TestDeviceR1", + "test100" + ] + }, + "core_switch": { + "hosts": [ + "R1-Device", + "VC1", + "TestDeviceR1", + "test100" + ] + }, + "is_virtual": { + "hosts": [ + "Test VM With Spaces", + "test100-vm", + "test101-vm", + "test102-vm", + "test103-vm", + "test104-vm" + ] + }, + "jinja_test_group": { + "hosts": [ + "TestDeviceR1", + "Test VM With Spaces" + ] + }, + "nexus_parent": { + "hosts": [ + "VC1" + ] + }, + "parent_rack_group": { + "children": [ + "test_rack_group" + ] + }, + "parent_region": { + "children": [ + "test_region" + ] + }, + "parent_site_group": { + "children": [ + "test_site_group" + ] + }, + "test_cluster_group": { + "hosts": [ + "test100-vm", + "test101-vm", + "test102-vm", + "test103-vm" + ] + }, + "test_cluster_type": { + "hosts": [ + "Test VM With Spaces", + "test100-vm", + "test101-vm", + "test102-vm", + "test103-vm", + "test104-vm" + ] + }, + "test_rack_group": { + "hosts": [ + "VC1", + "TestDeviceR1", + "test100" + ] + }, + "test_rack_role": { + "hosts": [ + "R1-Device" + ] + }, + "test_region": { + "children": [ + "test_site" + ] + }, + "test_site": { + "children": [ + "parent_rack_group" + ], + "hosts": [ + "test100-vm", + "test101-vm", + "test102-vm", + "test103-vm" + ] + }, + "test_site2": { + "hosts": [ + "R1-Device" + ] + } +} \ No newline at end of file diff --git a/tests/integration/targets/inventory-v4.3/files/test-inventory-options.yml b/tests/integration/targets/inventory-v4.3/files/test-inventory-options.yml new file mode 100644 index 000000000..f6597c661 --- /dev/null +++ b/tests/integration/targets/inventory-v4.3/files/test-inventory-options.yml @@ -0,0 +1,62 @@ +--- +plugin: netbox.netbox.nb_inventory +api_endpoint: http://localhost:32768 +token: "0123456789abcdef0123456789abcdef01234567" +validate_certs: false + +# Cache is not for performance of tests, but to test the caching option works +# Also set on test-inventory-plurals.yml so that we actually hit the cache on one of these runs +cache: true +cache_timeout: 3600 +cache_plugin: jsonfile +cache_connection: /tmp/inventory_netbox + +config_context: false +plurals: false +interfaces: false +services: false +group_names_raw: true +virtual_chassis_name: true +dns_name: true +ansible_host_dns_name: true + +group_by: + - site + - tenant + - rack + - location + - rack_role + - tag + - role + - device_type + - manufacturer + - platform + - region + - site_group + - cluster + - cluster_group + - cluster_type + - is_virtual + - status + +query_filters: "" + +device_query_filters: + - role: core-switch + +vm_query_filters: + - cluster_type: test-cluster-type + +# See Constructed for details +# https://docs.ansible.com/ansible/latest/plugins/inventory/constructed.html + +compose: + rack_id: rack.id + ntp_servers: config_context.ntp_servers + +keyed_groups: + - prefix: rack + key: rack.name + +groups: + jinja_test_group: inventory_hostname.startswith('Test') diff --git a/tests/integration/targets/inventory-v4.3/files/test-inventory-plurals-flatten.json b/tests/integration/targets/inventory-v4.3/files/test-inventory-plurals-flatten.json new file mode 100644 index 000000000..4bad3dca5 --- /dev/null +++ b/tests/integration/targets/inventory-v4.3/files/test-inventory-plurals-flatten.json @@ -0,0 +1,446 @@ +{ + "Test_Cluster": { + "hosts": [ + "test100-vm", + "test101-vm", + "test102-vm", + "test103-vm" + ] + }, + "Test_Cluster_2": { + "hosts": [ + "Test VM With Spaces", + "test104-vm" + ] + }, + "Test_Rack": { + "hosts": [ + "TestDeviceR1" + ] + }, + "Test_Rack_Site_2": { + "hosts": [ + "R1-Device" + ] + }, + "_meta": { + "hostvars": { + "R1-Device": { + "asset_tag": "345678901", + "device_roles": [ + "core-switch" + ], + "device_types": [ + "cisco-test" + ], + "is_virtual": false, + "local_context_data": [ + null + ], + "locations": [], + "manufacturers": [ + "cisco" + ], + "rack_role": "test-rack-role", + "racks": [ + "Test Rack Site 2" + ], + "regions": [], + "serial": "", + "site_groups": [], + "sites": [ + "test-site2" + ], + "status": { + "label": "Active", + "value": "active" + }, + "tags": [] + }, + "Test Nexus One": { + "ansible_host": "172.16.180.12", + "device_roles": [ + "core-switch" + ], + "device_types": [ + "nexus-parent" + ], + "is_virtual": false, + "local_context_data": [ + null + ], + "locations": [ + "test-rack-group", + "parent-rack-group" + ], + "manufacturers": [ + "cisco" + ], + "primary_ip4": "172.16.180.12", + "regions": [ + "test-region", + "parent-region" + ], + "serial": "", + "site_groups": [], + "sites": [ + "test-site" + ], + "status": { + "label": "Active", + "value": "active" + }, + "tags": [] + }, + "Test VM With Spaces": { + "cluster": "Test Cluster 2", + "cluster_type": "test-cluster-type", + "is_virtual": true, + "local_context_data": [ + null + ], + "locations": [], + "regions": [], + "serial": "", + "site_groups": [], + "status": { + "label": "Active", + "value": "active" + }, + "tags": [] + }, + "TestDeviceR1": { + "device_roles": [ + "core-switch" + ], + "device_types": [ + "cisco-test" + ], + "is_virtual": false, + "local_context_data": [ + null + ], + "locations": [ + "test-rack-group", + "parent-rack-group" + ], + "manufacturers": [ + "cisco" + ], + "racks": [ + "Test Rack" + ], + "regions": [ + "test-region", + "parent-region" + ], + "serial": "FAB12345678", + "site_groups": [], + "sites": [ + "test-site" + ], + "status": { + "label": "Active", + "value": "active" + }, + "tags": [] + }, + "test100": { + "asset_tag": "123456789", + "device_roles": [ + "core-switch" + ], + "device_types": [ + "cisco-test" + ], + "is_virtual": false, + "local_context_data": [ + { + "ntp_servers": [ + "pool.ntp.org" + ] + } + ], + "locations": [ + "test-rack-group", + "parent-rack-group" + ], + "manufacturers": [ + "cisco" + ], + "ntp_servers": [ + "pool.ntp.org" + ], + "regions": [ + "test-region", + "parent-region" + ], + "serial": "FAB01234567", + "site_groups": [], + "sites": [ + "test-site" + ], + "status": { + "label": "Active", + "value": "active" + }, + "tags": [] + }, + "test100-vm": { + "cluster": "Test Cluster", + "cluster_group": "test-cluster-group", + "cluster_type": "test-cluster-type", + "disk": 170, + "is_virtual": true, + "local_context_data": [ + null + ], + "locations": [], + "regions": [ + "test-region", + "parent-region" + ], + "serial": "", + "site_groups": [], + "sites": [ + "test-site" + ], + "status": { + "label": "Active", + "value": "active" + }, + "tags": [] + }, + "test101-vm": { + "cluster": "Test Cluster", + "cluster_group": "test-cluster-group", + "cluster_type": "test-cluster-type", + "is_virtual": true, + "local_context_data": [ + null + ], + "locations": [], + "regions": [ + "test-region", + "parent-region" + ], + "serial": "", + "site_groups": [], + "sites": [ + "test-site" + ], + "status": { + "label": "Active", + "value": "active" + }, + "tags": [] + }, + "test102-vm": { + "cluster": "Test Cluster", + "cluster_group": "test-cluster-group", + "cluster_type": "test-cluster-type", + "is_virtual": true, + "local_context_data": [ + null + ], + "locations": [], + "regions": [ + "test-region", + "parent-region" + ], + "serial": "", + "site_groups": [], + "sites": [ + "test-site" + ], + "status": { + "label": "Active", + "value": "active" + }, + "tags": [] + }, + "test103-vm": { + "cluster": "Test Cluster", + "cluster_group": "test-cluster-group", + "cluster_type": "test-cluster-type", + "is_virtual": true, + "local_context_data": [ + null + ], + "locations": [], + "regions": [ + "test-region", + "parent-region" + ], + "serial": "", + "site_groups": [], + "sites": [ + "test-site" + ], + "status": { + "label": "Active", + "value": "active" + }, + "tags": [] + }, + "test104-vm": { + "cluster": "Test Cluster 2", + "cluster_type": "test-cluster-type", + "is_virtual": true, + "local_context_data": [ + null + ], + "locations": [], + "regions": [], + "serial": "", + "site_groups": [], + "status": { + "label": "Active", + "value": "active" + }, + "tags": [] + } + } + }, + "active": { + "hosts": [ + "R1-Device", + "Test Nexus One", + "TestDeviceR1", + "test100", + "Test VM With Spaces", + "test100-vm", + "test101-vm", + "test102-vm", + "test103-vm", + "test104-vm" + ] + }, + "all": { + "children": [ + "ungrouped", + "test_site2", + "other_region", + "parent_region", + "other_site_group", + "parent_site_group", + "Test_Rack_Site_2", + "test_rack_role", + "core_switch", + "cisco_test", + "cisco", + "active", + "nexus_parent", + "Test_Rack", + "Test_Cluster_2", + "test_cluster_type", + "is_virtual", + "Test_Cluster", + "test_cluster_group" + ] + }, + "cisco": { + "hosts": [ + "R1-Device", + "Test Nexus One", + "TestDeviceR1", + "test100" + ] + }, + "cisco_test": { + "hosts": [ + "R1-Device", + "TestDeviceR1", + "test100" + ] + }, + "core_switch": { + "hosts": [ + "R1-Device", + "Test Nexus One", + "TestDeviceR1", + "test100" + ] + }, + "is_virtual": { + "hosts": [ + "Test VM With Spaces", + "test100-vm", + "test101-vm", + "test102-vm", + "test103-vm", + "test104-vm" + ] + }, + "nexus_parent": { + "hosts": [ + "Test Nexus One" + ] + }, + "parent_rack_group": { + "children": [ + "test_rack_group" + ] + }, + "parent_region": { + "children": [ + "test_region" + ] + }, + "parent_site_group": { + "children": [ + "test_site_group" + ] + }, + "test_cluster_group": { + "hosts": [ + "test100-vm", + "test101-vm", + "test102-vm", + "test103-vm" + ] + }, + "test_cluster_type": { + "hosts": [ + "Test VM With Spaces", + "test100-vm", + "test101-vm", + "test102-vm", + "test103-vm", + "test104-vm" + ] + }, + "test_rack_group": { + "hosts": [ + "Test Nexus One", + "TestDeviceR1", + "test100" + ] + }, + "test_rack_role": { + "hosts": [ + "R1-Device" + ] + }, + "test_region": { + "children": [ + "test_site" + ] + }, + "test_site": { + "children": [ + "parent_rack_group" + ], + "hosts": [ + "test100-vm", + "test101-vm", + "test102-vm", + "test103-vm" + ] + }, + "test_site2": { + "hosts": [ + "R1-Device" + ] + } +} \ No newline at end of file diff --git a/tests/integration/targets/inventory-v4.3/files/test-inventory-plurals-flatten.yml b/tests/integration/targets/inventory-v4.3/files/test-inventory-plurals-flatten.yml new file mode 100644 index 000000000..33213ff5c --- /dev/null +++ b/tests/integration/targets/inventory-v4.3/files/test-inventory-plurals-flatten.yml @@ -0,0 +1,33 @@ +--- +plugin: netbox.netbox.nb_inventory +api_endpoint: http://localhost:32768 +token: "0123456789abcdef0123456789abcdef01234567" +validate_certs: false + +config_context: true +flatten_config_context: true +flatten_custom_fields: true +plurals: true +interfaces: false +services: false +fetch_all: true +group_names_raw: true + +group_by: + - sites + - tenants + - racks + - location + - rack_role + - tags + - device_roles + - device_types + - manufacturers + - platforms + - region + - site_group + - cluster + - cluster_group + - cluster_type + - is_virtual + - status diff --git a/tests/integration/targets/inventory-v4.3/files/test-inventory-plurals.json b/tests/integration/targets/inventory-v4.3/files/test-inventory-plurals.json new file mode 100644 index 000000000..fb34d7fa2 --- /dev/null +++ b/tests/integration/targets/inventory-v4.3/files/test-inventory-plurals.json @@ -0,0 +1,1421 @@ +{ + "_meta": { + "hostvars": { + "R1-Device": { + "asset_tag": "345678901", + "config_context": [ + {} + ], + "custom_fields": {}, + "device_roles": [ + "core-switch" + ], + "device_types": [ + "cisco-test" + ], + "interfaces": [], + "is_virtual": false, + "local_context_data": [ + null + ], + "locations": [], + "manufacturers": [ + "cisco" + ], + "rack_role": "test-rack-role", + "racks": [ + "Test Rack Site 2" + ], + "regions": [], + "serial": "", + "services": [], + "site_groups": [], + "sites": [ + "test-site2" + ], + "status": { + "label": "Active", + "value": "active" + }, + "tags": [] + }, + "Test Nexus One": { + "ansible_host": "172.16.180.12", + "config_context": [ + {} + ], + "custom_fields": {}, + "device_roles": [ + "core-switch" + ], + "device_types": [ + "nexus-parent" + ], + "dns_name": "nexus.example.com", + "interfaces": [ + { + "_occupied": false, + "bridge": null, + "cable": null, + "cable_end": "", + "connected_endpoints": null, + "connected_endpoints_reachable": null, + "connected_endpoints_type": null, + "count_fhrp_groups": 0, + "count_ipaddresses": 1, + "custom_fields": {}, + "description": "", + "device": { + "description": "", + "display": "Test Nexus One", + "id": 4, + "name": "Test Nexus One" + }, + "display": "Ethernet1/1", + "display_url": "http://localhost:32768/dcim/interfaces/1/", + "duplex": null, + "enabled": true, + "id": 1, + "ip_addresses": [ + { + "address": "172.16.180.11/24", + "comments": "", + "custom_fields": {}, + "description": "", + "display": "172.16.180.11/24", + "display_url": "http://localhost:32768/ipam/ip-addresses/3/", + "dns_name": "", + "family": { + "label": "IPv4", + "value": 4 + }, + "id": 3, + "nat_inside": null, + "nat_outside": [], + "role": null, + "status": { + "label": "Active", + "value": "active" + }, + "tags": [], + "tenant": null, + "vrf": null + } + ], + "l2vpn_termination": null, + "label": "", + "lag": null, + "link_peers": [], + "link_peers_type": null, + "mac_address": null, + "mark_connected": false, + "mgmt_only": false, + "mode": null, + "module": null, + "mtu": null, + "name": "Ethernet1/1", + "parent": null, + "poe_mode": null, + "poe_type": null, + "rf_channel": null, + "rf_channel_frequency": null, + "rf_channel_width": null, + "rf_role": null, + "speed": null, + "tagged_vlans": [], + "tags": [], + "tx_power": null, + "type": { + "label": "1000BASE-T (1GE)", + "value": "1000base-t" + }, + "untagged_vlan": null, + "vdcs": [], + "vrf": null, + "wireless_lans": [], + "wireless_link": null, + "wwn": null + }, + { + "_occupied": false, + "bridge": null, + "cable": null, + "cable_end": "", + "connected_endpoints": null, + "connected_endpoints_reachable": null, + "connected_endpoints_type": null, + "count_fhrp_groups": 0, + "count_ipaddresses": 1, + "custom_fields": {}, + "description": "", + "device": { + "description": "", + "display": "Test Nexus Child One", + "id": 5, + "name": "Test Nexus Child One" + }, + "display": "Ethernet2/1", + "display_url": "http://localhost:32768/dcim/interfaces/2/", + "duplex": null, + "enabled": true, + "id": 2, + "ip_addresses": [ + { + "address": "172.16.180.12/24", + "comments": "", + "custom_fields": {}, + "description": "", + "display": "172.16.180.12/24", + "display_url": "http://localhost:32768/ipam/ip-addresses/4/", + "dns_name": "nexus.example.com", + "family": { + "label": "IPv4", + "value": 4 + }, + "id": 4, + "nat_inside": null, + "nat_outside": [], + "role": null, + "status": { + "label": "Active", + "value": "active" + }, + "tags": [], + "tenant": null, + "vrf": null + } + ], + "l2vpn_termination": null, + "label": "", + "lag": null, + "link_peers": [], + "link_peers_type": null, + "mac_address": null, + "mark_connected": false, + "mgmt_only": false, + "mode": null, + "module": null, + "mtu": null, + "name": "Ethernet2/1", + "parent": null, + "poe_mode": null, + "poe_type": null, + "rf_channel": null, + "rf_channel_frequency": null, + "rf_channel_width": null, + "rf_role": null, + "speed": null, + "tagged_vlans": [], + "tags": [], + "tx_power": null, + "type": { + "label": "1000BASE-T (1GE)", + "value": "1000base-t" + }, + "untagged_vlan": null, + "vdcs": [], + "vrf": null, + "wireless_lans": [], + "wireless_link": null, + "wwn": null + }, + { + "_occupied": false, + "bridge": null, + "cable": null, + "cable_end": "", + "connected_endpoints": null, + "connected_endpoints_reachable": null, + "connected_endpoints_type": null, + "count_fhrp_groups": 0, + "count_ipaddresses": 0, + "custom_fields": {}, + "description": "", + "device": { + "description": "", + "display": "Test Nexus One", + "id": 4, + "name": "Test Nexus One" + }, + "display": "wlink1", + "display_url": "http://localhost:32768/dcim/interfaces/6/", + "duplex": null, + "enabled": true, + "id": 6, + "ip_addresses": [], + "l2vpn_termination": null, + "label": "", + "lag": null, + "link_peers": [], + "link_peers_type": null, + "mac_address": null, + "mark_connected": false, + "mgmt_only": false, + "mode": null, + "module": null, + "mtu": null, + "name": "wlink1", + "parent": null, + "poe_mode": null, + "poe_type": null, + "rf_channel": null, + "rf_channel_frequency": null, + "rf_channel_width": null, + "rf_role": null, + "speed": null, + "tagged_vlans": [], + "tags": [], + "tx_power": null, + "type": { + "label": "IEEE 802.11a", + "value": "ieee802.11a" + }, + "untagged_vlan": null, + "vdcs": [], + "vrf": null, + "wireless_lans": [], + "wireless_link": null, + "wwn": null + } + ], + "is_virtual": false, + "local_context_data": [ + null + ], + "locations": [ + "test-rack-group", + "parent-rack-group" + ], + "manufacturers": [ + "cisco" + ], + "primary_ip4": "172.16.180.12", + "regions": [ + "test-region", + "parent-region" + ], + "serial": "", + "services": [ + { + "comments": "", + "custom_fields": {}, + "description": "", + "device": { + "description": "", + "display": "Test Nexus One", + "id": 4, + "name": "Test Nexus One" + }, + "display": "telnet (TCP/23)", + "display_url": "http://localhost:32768/ipam/services/3/", + "id": 3, + "ipaddresses": [], + "name": "telnet", + "ports": [ + 23 + ], + "protocol": { + "label": "TCP", + "value": "tcp" + }, + "tags": [], + "virtual_machine": null + } + ], + "site_groups": [], + "sites": [ + "test-site" + ], + "status": { + "label": "Active", + "value": "active" + }, + "tags": [] + }, + "Test VM With Spaces": { + "cluster": "Test Cluster 2", + "cluster_type": "test-cluster-type", + "config_context": [ + {} + ], + "custom_fields": {}, + "interfaces": [ + { + "bridge": null, + "count_fhrp_groups": 0, + "count_ipaddresses": 0, + "custom_fields": {}, + "description": "", + "display": "Eth0", + "display_url": "http://localhost:32768/virtualization/interfaces/11/", + "enabled": true, + "id": 11, + "ip_addresses": [], + "l2vpn_termination": null, + "mac_address": null, + "mode": null, + "mtu": null, + "name": "Eth0", + "parent": null, + "tagged_vlans": [], + "tags": [], + "untagged_vlan": null, + "virtual_machine": { + "description": "", + "display": "Test VM With Spaces", + "id": 6, + "name": "Test VM With Spaces" + }, + "vrf": null + }, + { + "bridge": null, + "count_fhrp_groups": 0, + "count_ipaddresses": 0, + "custom_fields": {}, + "description": "", + "display": "Eth1", + "display_url": "http://localhost:32768/virtualization/interfaces/12/", + "enabled": true, + "id": 12, + "ip_addresses": [], + "l2vpn_termination": null, + "mac_address": null, + "mode": null, + "mtu": null, + "name": "Eth1", + "parent": null, + "tagged_vlans": [], + "tags": [], + "untagged_vlan": null, + "virtual_machine": { + "description": "", + "display": "Test VM With Spaces", + "id": 6, + "name": "Test VM With Spaces" + }, + "vrf": null + } + ], + "is_virtual": true, + "local_context_data": [ + null + ], + "locations": [], + "regions": [], + "serial": "", + "services": [ + { + "comments": "", + "custom_fields": {}, + "description": "", + "device": null, + "display": "ssh (TCP/22)", + "display_url": "http://localhost:32768/ipam/services/4/", + "id": 4, + "ipaddresses": [], + "name": "ssh", + "ports": [ + 22 + ], + "protocol": { + "label": "TCP", + "value": "tcp" + }, + "tags": [], + "virtual_machine": { + "description": "", + "display": "Test VM With Spaces", + "id": 6, + "name": "Test VM With Spaces" + } + } + ], + "site_groups": [], + "status": { + "label": "Active", + "value": "active" + }, + "tags": [] + }, + "TestDeviceR1": { + "config_context": [ + {} + ], + "custom_fields": {}, + "device_roles": [ + "core-switch" + ], + "device_types": [ + "cisco-test" + ], + "interfaces": [], + "is_virtual": false, + "local_context_data": [ + null + ], + "locations": [ + "test-rack-group", + "parent-rack-group" + ], + "manufacturers": [ + "cisco" + ], + "racks": [ + "Test Rack" + ], + "regions": [ + "test-region", + "parent-region" + ], + "serial": "FAB12345678", + "services": [], + "site_groups": [], + "sites": [ + "test-site" + ], + "status": { + "label": "Active", + "value": "active" + }, + "tags": [] + }, + "test100": { + "asset_tag": "123456789", + "config_context": [ + { + "ntp_servers": [ + "pool.ntp.org" + ] + } + ], + "custom_fields": {}, + "device_roles": [ + "core-switch" + ], + "device_types": [ + "cisco-test" + ], + "interfaces": [ + { + "_occupied": false, + "bridge": null, + "cable": null, + "cable_end": "", + "connected_endpoints": null, + "connected_endpoints_reachable": null, + "connected_endpoints_type": null, + "count_fhrp_groups": 0, + "count_ipaddresses": 1, + "custom_fields": {}, + "description": "", + "device": { + "description": "", + "display": "test100 (123456789)", + "id": 1, + "name": "test100" + }, + "display": "GigabitEthernet1", + "display_url": "http://localhost:32768/dcim/interfaces/3/", + "duplex": null, + "enabled": true, + "id": 3, + "ip_addresses": [ + { + "address": "172.16.180.1/24", + "comments": "", + "custom_fields": {}, + "description": "", + "display": "172.16.180.1/24", + "display_url": "http://localhost:32768/ipam/ip-addresses/1/", + "dns_name": "", + "family": { + "label": "IPv4", + "value": 4 + }, + "id": 1, + "nat_inside": null, + "nat_outside": [], + "role": null, + "status": { + "label": "Active", + "value": "active" + }, + "tags": [], + "tenant": null, + "vrf": null + } + ], + "l2vpn_termination": null, + "label": "", + "lag": null, + "link_peers": [], + "link_peers_type": null, + "mac_address": null, + "mark_connected": false, + "mgmt_only": false, + "mode": null, + "module": null, + "mtu": null, + "name": "GigabitEthernet1", + "parent": null, + "poe_mode": null, + "poe_type": null, + "rf_channel": null, + "rf_channel_frequency": null, + "rf_channel_width": null, + "rf_role": null, + "speed": null, + "tagged_vlans": [], + "tags": [], + "tx_power": null, + "type": { + "label": "1000BASE-T (1GE)", + "value": "1000base-t" + }, + "untagged_vlan": null, + "vdcs": [], + "vrf": null, + "wireless_lans": [], + "wireless_link": null, + "wwn": null + }, + { + "_occupied": false, + "bridge": null, + "cable": null, + "cable_end": "", + "connected_endpoints": null, + "connected_endpoints_reachable": null, + "connected_endpoints_type": null, + "count_fhrp_groups": 0, + "count_ipaddresses": 1, + "custom_fields": {}, + "description": "", + "device": { + "description": "", + "display": "test100 (123456789)", + "id": 1, + "name": "test100" + }, + "display": "GigabitEthernet2", + "display_url": "http://localhost:32768/dcim/interfaces/4/", + "duplex": null, + "enabled": true, + "id": 4, + "ip_addresses": [ + { + "address": "2001::1:1/64", + "comments": "", + "custom_fields": {}, + "description": "", + "display": "2001::1:1/64", + "display_url": "http://localhost:32768/ipam/ip-addresses/2/", + "dns_name": "", + "family": { + "label": "IPv6", + "value": 6 + }, + "id": 2, + "nat_inside": null, + "nat_outside": [], + "role": null, + "status": { + "label": "Active", + "value": "active" + }, + "tags": [], + "tenant": null, + "vrf": null + } + ], + "l2vpn_termination": null, + "label": "", + "lag": null, + "link_peers": [], + "link_peers_type": null, + "mac_address": null, + "mark_connected": false, + "mgmt_only": false, + "mode": null, + "module": null, + "mtu": null, + "name": "GigabitEthernet2", + "parent": null, + "poe_mode": null, + "poe_type": null, + "rf_channel": null, + "rf_channel_frequency": null, + "rf_channel_width": null, + "rf_role": null, + "speed": null, + "tagged_vlans": [], + "tags": [], + "tx_power": null, + "type": { + "label": "1000BASE-T (1GE)", + "value": "1000base-t" + }, + "untagged_vlan": null, + "vdcs": [], + "vrf": null, + "wireless_lans": [], + "wireless_link": null, + "wwn": null + }, + { + "_occupied": false, + "bridge": null, + "cable": null, + "cable_end": "", + "connected_endpoints": null, + "connected_endpoints_reachable": null, + "connected_endpoints_type": null, + "count_fhrp_groups": 0, + "count_ipaddresses": 0, + "custom_fields": {}, + "description": "", + "device": { + "description": "", + "display": "test100 (123456789)", + "id": 1, + "name": "test100" + }, + "display": "wlink1", + "display_url": "http://localhost:32768/dcim/interfaces/5/", + "duplex": null, + "enabled": true, + "id": 5, + "ip_addresses": [], + "l2vpn_termination": null, + "label": "", + "lag": null, + "link_peers": [], + "link_peers_type": null, + "mac_address": null, + "mark_connected": false, + "mgmt_only": false, + "mode": null, + "module": null, + "mtu": null, + "name": "wlink1", + "parent": null, + "poe_mode": null, + "poe_type": null, + "rf_channel": null, + "rf_channel_frequency": null, + "rf_channel_width": null, + "rf_role": null, + "speed": null, + "tagged_vlans": [], + "tags": [], + "tx_power": null, + "type": { + "label": "IEEE 802.11a", + "value": "ieee802.11a" + }, + "untagged_vlan": null, + "vdcs": [], + "vrf": null, + "wireless_lans": [], + "wireless_link": null, + "wwn": null + } + ], + "is_virtual": false, + "local_context_data": [ + { + "ntp_servers": [ + "pool.ntp.org" + ] + } + ], + "locations": [ + "test-rack-group", + "parent-rack-group" + ], + "manufacturers": [ + "cisco" + ], + "regions": [ + "test-region", + "parent-region" + ], + "serial": "FAB01234567", + "services": [ + { + "comments": "", + "custom_fields": {}, + "description": "", + "device": { + "description": "", + "display": "test100 (123456789)", + "id": 1, + "name": "test100" + }, + "display": "ssh (TCP/22)", + "display_url": "http://localhost:32768/ipam/services/1/", + "id": 1, + "ipaddresses": [], + "name": "ssh", + "ports": [ + 22 + ], + "protocol": { + "label": "TCP", + "value": "tcp" + }, + "tags": [], + "virtual_machine": null + }, + { + "comments": "", + "custom_fields": {}, + "description": "", + "device": { + "description": "", + "display": "test100 (123456789)", + "id": 1, + "name": "test100" + }, + "display": "http (TCP/80)", + "display_url": "http://localhost:32768/ipam/services/2/", + "id": 2, + "ipaddresses": [ + { + "address": "172.16.180.1/24", + "description": "", + "display": "172.16.180.1/24", + "family": { + "label": "IPv4", + "value": 4 + }, + "id": 1 + }, + { + "address": "2001::1:1/64", + "description": "", + "display": "2001::1:1/64", + "family": { + "label": "IPv6", + "value": 6 + }, + "id": 2 + } + ], + "name": "http", + "ports": [ + 80 + ], + "protocol": { + "label": "TCP", + "value": "tcp" + }, + "tags": [], + "virtual_machine": null + } + ], + "site_groups": [], + "sites": [ + "test-site" + ], + "status": { + "label": "Active", + "value": "active" + }, + "tags": [] + }, + "test100-vm": { + "cluster": "Test Cluster", + "cluster_group": "test-cluster-group", + "cluster_type": "test-cluster-type", + "config_context": [ + {} + ], + "custom_fields": {}, + "disk": 170, + "interfaces": [ + { + "bridge": null, + "count_fhrp_groups": 0, + "count_ipaddresses": 0, + "custom_fields": {}, + "description": "", + "display": "Eth0", + "display_url": "http://localhost:32768/virtualization/interfaces/1/", + "enabled": true, + "id": 1, + "ip_addresses": [], + "l2vpn_termination": null, + "mac_address": null, + "mode": null, + "mtu": null, + "name": "Eth0", + "parent": null, + "tagged_vlans": [], + "tags": [], + "untagged_vlan": null, + "virtual_machine": { + "description": "", + "display": "test100-vm", + "id": 1, + "name": "test100-vm" + }, + "vrf": null + }, + { + "bridge": null, + "count_fhrp_groups": 0, + "count_ipaddresses": 0, + "custom_fields": {}, + "description": "", + "display": "Eth1", + "display_url": "http://localhost:32768/virtualization/interfaces/2/", + "enabled": true, + "id": 2, + "ip_addresses": [], + "l2vpn_termination": null, + "mac_address": null, + "mode": null, + "mtu": null, + "name": "Eth1", + "parent": null, + "tagged_vlans": [], + "tags": [], + "untagged_vlan": null, + "virtual_machine": { + "description": "", + "display": "test100-vm", + "id": 1, + "name": "test100-vm" + }, + "vrf": null + }, + { + "bridge": null, + "count_fhrp_groups": 0, + "count_ipaddresses": 0, + "custom_fields": {}, + "description": "", + "display": "Eth2", + "display_url": "http://localhost:32768/virtualization/interfaces/3/", + "enabled": true, + "id": 3, + "ip_addresses": [], + "l2vpn_termination": null, + "mac_address": null, + "mode": null, + "mtu": null, + "name": "Eth2", + "parent": null, + "tagged_vlans": [], + "tags": [], + "untagged_vlan": null, + "virtual_machine": { + "description": "", + "display": "test100-vm", + "id": 1, + "name": "test100-vm" + }, + "vrf": null + }, + { + "bridge": null, + "count_fhrp_groups": 0, + "count_ipaddresses": 0, + "custom_fields": {}, + "description": "", + "display": "Eth3", + "display_url": "http://localhost:32768/virtualization/interfaces/4/", + "enabled": true, + "id": 4, + "ip_addresses": [], + "l2vpn_termination": null, + "mac_address": null, + "mode": null, + "mtu": null, + "name": "Eth3", + "parent": null, + "tagged_vlans": [], + "tags": [], + "untagged_vlan": null, + "virtual_machine": { + "description": "", + "display": "test100-vm", + "id": 1, + "name": "test100-vm" + }, + "vrf": null + }, + { + "bridge": null, + "count_fhrp_groups": 0, + "count_ipaddresses": 0, + "custom_fields": {}, + "description": "", + "display": "Eth4", + "display_url": "http://localhost:32768/virtualization/interfaces/5/", + "enabled": true, + "id": 5, + "ip_addresses": [], + "l2vpn_termination": null, + "mac_address": null, + "mode": null, + "mtu": null, + "name": "Eth4", + "parent": null, + "tagged_vlans": [], + "tags": [], + "untagged_vlan": null, + "virtual_machine": { + "description": "", + "display": "test100-vm", + "id": 1, + "name": "test100-vm" + }, + "vrf": null + } + ], + "is_virtual": true, + "local_context_data": [ + null + ], + "locations": [], + "regions": [ + "test-region", + "parent-region" + ], + "serial": "", + "services": [], + "site_groups": [], + "sites": [ + "test-site" + ], + "status": { + "label": "Active", + "value": "active" + }, + "tags": [] + }, + "test101-vm": { + "cluster": "Test Cluster", + "cluster_group": "test-cluster-group", + "cluster_type": "test-cluster-type", + "config_context": [ + {} + ], + "custom_fields": {}, + "interfaces": [ + { + "bridge": null, + "count_fhrp_groups": 0, + "count_ipaddresses": 0, + "custom_fields": {}, + "description": "", + "display": "Eth0", + "display_url": "http://localhost:32768/virtualization/interfaces/6/", + "enabled": true, + "id": 6, + "ip_addresses": [], + "l2vpn_termination": null, + "mac_address": null, + "mode": null, + "mtu": null, + "name": "Eth0", + "parent": null, + "tagged_vlans": [], + "tags": [], + "untagged_vlan": null, + "virtual_machine": { + "description": "", + "display": "test101-vm", + "id": 2, + "name": "test101-vm" + }, + "vrf": null + }, + { + "bridge": null, + "count_fhrp_groups": 0, + "count_ipaddresses": 0, + "custom_fields": {}, + "description": "", + "display": "Eth1", + "display_url": "http://localhost:32768/virtualization/interfaces/7/", + "enabled": true, + "id": 7, + "ip_addresses": [], + "l2vpn_termination": null, + "mac_address": null, + "mode": null, + "mtu": null, + "name": "Eth1", + "parent": null, + "tagged_vlans": [], + "tags": [], + "untagged_vlan": null, + "virtual_machine": { + "description": "", + "display": "test101-vm", + "id": 2, + "name": "test101-vm" + }, + "vrf": null + }, + { + "bridge": null, + "count_fhrp_groups": 0, + "count_ipaddresses": 0, + "custom_fields": {}, + "description": "", + "display": "Eth2", + "display_url": "http://localhost:32768/virtualization/interfaces/8/", + "enabled": true, + "id": 8, + "ip_addresses": [], + "l2vpn_termination": null, + "mac_address": null, + "mode": null, + "mtu": null, + "name": "Eth2", + "parent": null, + "tagged_vlans": [], + "tags": [], + "untagged_vlan": null, + "virtual_machine": { + "description": "", + "display": "test101-vm", + "id": 2, + "name": "test101-vm" + }, + "vrf": null + }, + { + "bridge": null, + "count_fhrp_groups": 0, + "count_ipaddresses": 0, + "custom_fields": {}, + "description": "", + "display": "Eth3", + "display_url": "http://localhost:32768/virtualization/interfaces/9/", + "enabled": true, + "id": 9, + "ip_addresses": [], + "l2vpn_termination": null, + "mac_address": null, + "mode": null, + "mtu": null, + "name": "Eth3", + "parent": null, + "tagged_vlans": [], + "tags": [], + "untagged_vlan": null, + "virtual_machine": { + "description": "", + "display": "test101-vm", + "id": 2, + "name": "test101-vm" + }, + "vrf": null + }, + { + "bridge": null, + "count_fhrp_groups": 0, + "count_ipaddresses": 0, + "custom_fields": {}, + "description": "", + "display": "Eth4", + "display_url": "http://localhost:32768/virtualization/interfaces/10/", + "enabled": true, + "id": 10, + "ip_addresses": [], + "l2vpn_termination": null, + "mac_address": null, + "mode": null, + "mtu": null, + "name": "Eth4", + "parent": null, + "tagged_vlans": [], + "tags": [], + "untagged_vlan": null, + "virtual_machine": { + "description": "", + "display": "test101-vm", + "id": 2, + "name": "test101-vm" + }, + "vrf": null + } + ], + "is_virtual": true, + "local_context_data": [ + null + ], + "locations": [], + "regions": [ + "test-region", + "parent-region" + ], + "serial": "", + "services": [], + "site_groups": [], + "sites": [ + "test-site" + ], + "status": { + "label": "Active", + "value": "active" + }, + "tags": [] + }, + "test102-vm": { + "cluster": "Test Cluster", + "cluster_group": "test-cluster-group", + "cluster_type": "test-cluster-type", + "config_context": [ + {} + ], + "custom_fields": {}, + "interfaces": [], + "is_virtual": true, + "local_context_data": [ + null + ], + "locations": [], + "regions": [ + "test-region", + "parent-region" + ], + "serial": "", + "services": [], + "site_groups": [], + "sites": [ + "test-site" + ], + "status": { + "label": "Active", + "value": "active" + }, + "tags": [] + }, + "test103-vm": { + "cluster": "Test Cluster", + "cluster_group": "test-cluster-group", + "cluster_type": "test-cluster-type", + "config_context": [ + {} + ], + "custom_fields": {}, + "interfaces": [], + "is_virtual": true, + "local_context_data": [ + null + ], + "locations": [], + "regions": [ + "test-region", + "parent-region" + ], + "serial": "", + "services": [], + "site_groups": [], + "sites": [ + "test-site" + ], + "status": { + "label": "Active", + "value": "active" + }, + "tags": [] + }, + "test104-vm": { + "cluster": "Test Cluster 2", + "cluster_type": "test-cluster-type", + "config_context": [ + {} + ], + "custom_fields": {}, + "interfaces": [], + "is_virtual": true, + "local_context_data": [ + null + ], + "locations": [], + "regions": [], + "serial": "", + "services": [], + "site_groups": [], + "status": { + "label": "Active", + "value": "active" + }, + "tags": [] + } + } + }, + "all": { + "children": [ + "ungrouped", + "sites_test_site2", + "region_other_region", + "region_parent_region", + "site_group_other_site_group", + "site_group_parent_site_group", + "racks_Test_Rack_Site_2", + "rack_role_test_rack_role", + "device_roles_core_switch", + "device_types_cisco_test", + "manufacturers_cisco", + "status_active", + "device_types_nexus_parent", + "racks_Test_Rack", + "cluster_Test_Cluster_2", + "cluster_type_test_cluster_type", + "is_virtual", + "cluster_Test_Cluster", + "cluster_group_test_cluster_group" + ] + }, + "cluster_Test_Cluster": { + "hosts": [ + "test100-vm", + "test101-vm", + "test102-vm", + "test103-vm" + ] + }, + "cluster_Test_Cluster_2": { + "hosts": [ + "Test VM With Spaces", + "test104-vm" + ] + }, + "cluster_group_test_cluster_group": { + "hosts": [ + "test100-vm", + "test101-vm", + "test102-vm", + "test103-vm" + ] + }, + "cluster_type_test_cluster_type": { + "hosts": [ + "Test VM With Spaces", + "test100-vm", + "test101-vm", + "test102-vm", + "test103-vm", + "test104-vm" + ] + }, + "device_roles_core_switch": { + "hosts": [ + "R1-Device", + "Test Nexus One", + "TestDeviceR1", + "test100" + ] + }, + "device_types_cisco_test": { + "hosts": [ + "R1-Device", + "TestDeviceR1", + "test100" + ] + }, + "device_types_nexus_parent": { + "hosts": [ + "Test Nexus One" + ] + }, + "is_virtual": { + "hosts": [ + "Test VM With Spaces", + "test100-vm", + "test101-vm", + "test102-vm", + "test103-vm", + "test104-vm" + ] + }, + "location_parent_rack_group": { + "children": [ + "location_test_rack_group" + ] + }, + "location_test_rack_group": { + "hosts": [ + "Test Nexus One", + "TestDeviceR1", + "test100" + ] + }, + "manufacturers_cisco": { + "hosts": [ + "R1-Device", + "Test Nexus One", + "TestDeviceR1", + "test100" + ] + }, + "rack_role_test_rack_role": { + "hosts": [ + "R1-Device" + ] + }, + "racks_Test_Rack": { + "hosts": [ + "TestDeviceR1" + ] + }, + "racks_Test_Rack_Site_2": { + "hosts": [ + "R1-Device" + ] + }, + "region_parent_region": { + "children": [ + "region_test_region" + ] + }, + "region_test_region": { + "children": [ + "sites_test_site" + ] + }, + "site_group_parent_site_group": { + "children": [ + "site_group_test_site_group" + ] + }, + "sites_test_site": { + "children": [ + "location_parent_rack_group" + ], + "hosts": [ + "test100-vm", + "test101-vm", + "test102-vm", + "test103-vm" + ] + }, + "sites_test_site2": { + "hosts": [ + "R1-Device" + ] + }, + "status_active": { + "hosts": [ + "R1-Device", + "Test Nexus One", + "TestDeviceR1", + "test100", + "Test VM With Spaces", + "test100-vm", + "test101-vm", + "test102-vm", + "test103-vm", + "test104-vm" + ] + } +} \ No newline at end of file diff --git a/tests/integration/targets/inventory-v4.3/files/test-inventory-plurals.yml b/tests/integration/targets/inventory-v4.3/files/test-inventory-plurals.yml new file mode 100644 index 000000000..1e53fd0bf --- /dev/null +++ b/tests/integration/targets/inventory-v4.3/files/test-inventory-plurals.yml @@ -0,0 +1,38 @@ +--- +plugin: netbox.netbox.nb_inventory +api_endpoint: http://localhost:32768 +token: "0123456789abcdef0123456789abcdef01234567" +validate_certs: false + +cache: true +cache_timeout: 3600 +cache_plugin: jsonfile +cache_connection: /tmp/inventory_netbox + +config_context: true +plurals: true +interfaces: true +services: true + +# Enough to fit only 2 devices, so tests chunking logic +max_uri_length: 80 +fetch_all: false + +group_by: + - sites + - tenants + - racks + - location + - rack_role + - tags + - device_roles + - device_types + - manufacturers + - platforms + - region + - site_group + - cluster + - cluster_group + - cluster_type + - is_virtual + - status diff --git a/tests/integration/targets/inventory-v4.3/files/test-inventory.json b/tests/integration/targets/inventory-v4.3/files/test-inventory.json new file mode 100644 index 000000000..b7e51862b --- /dev/null +++ b/tests/integration/targets/inventory-v4.3/files/test-inventory.json @@ -0,0 +1,1423 @@ +{ + "_meta": { + "hostvars": { + "R1-Device": { + "asset_tag": "345678901", + "config_context": {}, + "custom_fields": {}, + "device_type": "cisco-test", + "interfaces": [], + "is_virtual": false, + "locations": [], + "manufacturer": "cisco", + "rack": "Test Rack Site 2", + "rack_role": "test-rack-role", + "regions": [], + "role": "core-switch", + "serial": "", + "services": [], + "site": "test-site2", + "site_groups": [], + "status": { + "label": "Active", + "value": "active" + }, + "tags": [], + "virtual_disks": [] + }, + "Test Nexus One": { + "ansible_host": "172.16.180.12", + "config_context": {}, + "custom_fields": {}, + "device_type": "nexus-parent", + "dns_name": "nexus.example.com", + "interfaces": [ + { + "_occupied": false, + "bridge": null, + "cable": null, + "cable_end": "", + "connected_endpoints": null, + "connected_endpoints_reachable": null, + "connected_endpoints_type": null, + "count_fhrp_groups": 0, + "count_ipaddresses": 1, + "custom_fields": {}, + "description": "", + "device": { + "description": "", + "display": "Test Nexus One", + "id": 4, + "name": "Test Nexus One" + }, + "display": "Ethernet1/1", + "display_url": "http://localhost:32768/dcim/interfaces/1/", + "duplex": null, + "enabled": true, + "id": 1, + "ip_addresses": [ + { + "address": "172.16.180.11/24", + "comments": "", + "custom_fields": {}, + "description": "", + "display": "172.16.180.11/24", + "display_url": "http://localhost:32768/ipam/ip-addresses/3/", + "dns_name": "", + "family": { + "label": "IPv4", + "value": 4 + }, + "id": 3, + "nat_inside": null, + "nat_outside": [], + "role": null, + "status": { + "label": "Active", + "value": "active" + }, + "tags": [], + "tenant": null, + "vrf": null + } + ], + "l2vpn_termination": null, + "label": "", + "lag": null, + "link_peers": [], + "link_peers_type": null, + "mac_address": null, + "mark_connected": false, + "mgmt_only": false, + "mode": null, + "module": null, + "mtu": null, + "name": "Ethernet1/1", + "parent": null, + "poe_mode": null, + "poe_type": null, + "rf_channel": null, + "rf_channel_frequency": null, + "rf_channel_width": null, + "rf_role": null, + "speed": null, + "tagged_vlans": [], + "tags": [], + "tx_power": null, + "type": { + "label": "1000BASE-T (1GE)", + "value": "1000base-t" + }, + "untagged_vlan": null, + "vdcs": [], + "vrf": null, + "wireless_lans": [], + "wireless_link": null, + "wwn": null + }, + { + "_occupied": false, + "bridge": null, + "cable": null, + "cable_end": "", + "connected_endpoints": null, + "connected_endpoints_reachable": null, + "connected_endpoints_type": null, + "count_fhrp_groups": 0, + "count_ipaddresses": 1, + "custom_fields": {}, + "description": "", + "device": { + "description": "", + "display": "Test Nexus Child One", + "id": 5, + "name": "Test Nexus Child One" + }, + "display": "Ethernet2/1", + "display_url": "http://localhost:32768/dcim/interfaces/2/", + "duplex": null, + "enabled": true, + "id": 2, + "ip_addresses": [ + { + "address": "172.16.180.12/24", + "comments": "", + "custom_fields": {}, + "description": "", + "display": "172.16.180.12/24", + "display_url": "http://localhost:32768/ipam/ip-addresses/4/", + "dns_name": "nexus.example.com", + "family": { + "label": "IPv4", + "value": 4 + }, + "id": 4, + "nat_inside": null, + "nat_outside": [], + "role": null, + "status": { + "label": "Active", + "value": "active" + }, + "tags": [], + "tenant": null, + "vrf": null + } + ], + "l2vpn_termination": null, + "label": "", + "lag": null, + "link_peers": [], + "link_peers_type": null, + "mac_address": null, + "mark_connected": false, + "mgmt_only": false, + "mode": null, + "module": null, + "mtu": null, + "name": "Ethernet2/1", + "parent": null, + "poe_mode": null, + "poe_type": null, + "rf_channel": null, + "rf_channel_frequency": null, + "rf_channel_width": null, + "rf_role": null, + "speed": null, + "tagged_vlans": [], + "tags": [], + "tx_power": null, + "type": { + "label": "1000BASE-T (1GE)", + "value": "1000base-t" + }, + "untagged_vlan": null, + "vdcs": [], + "vrf": null, + "wireless_lans": [], + "wireless_link": null, + "wwn": null + }, + { + "_occupied": false, + "bridge": null, + "cable": null, + "cable_end": "", + "connected_endpoints": null, + "connected_endpoints_reachable": null, + "connected_endpoints_type": null, + "count_fhrp_groups": 0, + "count_ipaddresses": 0, + "custom_fields": {}, + "description": "", + "device": { + "description": "", + "display": "Test Nexus One", + "id": 4, + "name": "Test Nexus One" + }, + "display": "wlink1", + "display_url": "http://localhost:32768/dcim/interfaces/6/", + "duplex": null, + "enabled": true, + "id": 6, + "ip_addresses": [], + "l2vpn_termination": null, + "label": "", + "lag": null, + "link_peers": [], + "link_peers_type": null, + "mac_address": null, + "mark_connected": false, + "mgmt_only": false, + "mode": null, + "module": null, + "mtu": null, + "name": "wlink1", + "parent": null, + "poe_mode": null, + "poe_type": null, + "rf_channel": null, + "rf_channel_frequency": null, + "rf_channel_width": null, + "rf_role": null, + "speed": null, + "tagged_vlans": [], + "tags": [], + "tx_power": null, + "type": { + "label": "IEEE 802.11a", + "value": "ieee802.11a" + }, + "untagged_vlan": null, + "vdcs": [], + "vrf": null, + "wireless_lans": [], + "wireless_link": null, + "wwn": null + } + ], + "is_virtual": false, + "locations": [ + "test-rack-group", + "parent-rack-group" + ], + "manufacturer": "cisco", + "primary_ip4": "172.16.180.12", + "regions": [ + "test-region", + "parent-region" + ], + "role": "core-switch", + "serial": "", + "services": [ + { + "comments": "", + "custom_fields": {}, + "description": "", + "device": { + "description": "", + "display": "Test Nexus One", + "id": 4, + "name": "Test Nexus One" + }, + "display": "telnet (TCP/23)", + "display_url": "http://localhost:32768/ipam/services/3/", + "id": 3, + "ipaddresses": [], + "name": "telnet", + "ports": [ + 23 + ], + "protocol": { + "label": "TCP", + "value": "tcp" + }, + "tags": [], + "virtual_machine": null + } + ], + "site": "test-site", + "site_groups": [], + "status": { + "label": "Active", + "value": "active" + }, + "tags": [], + "virtual_disks": [] + }, + "Test VM With Spaces": { + "cluster": "Test Cluster 2", + "cluster_type": "test-cluster-type", + "config_context": {}, + "custom_fields": {}, + "interfaces": [ + { + "bridge": null, + "count_fhrp_groups": 0, + "count_ipaddresses": 0, + "custom_fields": {}, + "description": "", + "display": "Eth0", + "display_url": "http://localhost:32768/virtualization/interfaces/11/", + "enabled": true, + "id": 11, + "ip_addresses": [], + "l2vpn_termination": null, + "mac_address": null, + "mode": null, + "mtu": null, + "name": "Eth0", + "parent": null, + "tagged_vlans": [], + "tags": [], + "untagged_vlan": null, + "virtual_machine": { + "description": "", + "display": "Test VM With Spaces", + "id": 6, + "name": "Test VM With Spaces" + }, + "vrf": null + }, + { + "bridge": null, + "count_fhrp_groups": 0, + "count_ipaddresses": 0, + "custom_fields": {}, + "description": "", + "display": "Eth1", + "display_url": "http://localhost:32768/virtualization/interfaces/12/", + "enabled": true, + "id": 12, + "ip_addresses": [], + "l2vpn_termination": null, + "mac_address": null, + "mode": null, + "mtu": null, + "name": "Eth1", + "parent": null, + "tagged_vlans": [], + "tags": [], + "untagged_vlan": null, + "virtual_machine": { + "description": "", + "display": "Test VM With Spaces", + "id": 6, + "name": "Test VM With Spaces" + }, + "vrf": null + } + ], + "is_virtual": true, + "locations": [], + "regions": [], + "serial": "", + "services": [ + { + "comments": "", + "custom_fields": {}, + "description": "", + "device": null, + "display": "ssh (TCP/22)", + "display_url": "http://localhost:32768/ipam/services/4/", + "id": 4, + "ipaddresses": [], + "name": "ssh", + "ports": [ + 22 + ], + "protocol": { + "label": "TCP", + "value": "tcp" + }, + "tags": [], + "virtual_machine": { + "description": "", + "display": "Test VM With Spaces", + "id": 6, + "name": "Test VM With Spaces" + } + } + ], + "site_groups": [], + "status": { + "label": "Active", + "value": "active" + }, + "tags": [], + "virtual_disks": [] + }, + "TestDeviceR1": { + "config_context": {}, + "custom_fields": {}, + "device_type": "cisco-test", + "interfaces": [], + "is_virtual": false, + "locations": [ + "test-rack-group", + "parent-rack-group" + ], + "manufacturer": "cisco", + "rack": "Test Rack", + "regions": [ + "test-region", + "parent-region" + ], + "role": "core-switch", + "serial": "FAB12345678", + "services": [], + "site": "test-site", + "site_groups": [], + "status": { + "label": "Active", + "value": "active" + }, + "tags": [], + "virtual_disks": [] + }, + "test100": { + "asset_tag": "123456789", + "config_context": { + "ntp_servers": [ + "pool.ntp.org" + ] + }, + "custom_fields": {}, + "device_type": "cisco-test", + "interfaces": [ + { + "_occupied": false, + "bridge": null, + "cable": null, + "cable_end": "", + "connected_endpoints": null, + "connected_endpoints_reachable": null, + "connected_endpoints_type": null, + "count_fhrp_groups": 0, + "count_ipaddresses": 1, + "custom_fields": {}, + "description": "", + "device": { + "description": "", + "display": "test100 (123456789)", + "id": 1, + "name": "test100" + }, + "display": "GigabitEthernet1", + "display_url": "http://localhost:32768/dcim/interfaces/3/", + "duplex": null, + "enabled": true, + "id": 3, + "ip_addresses": [ + { + "address": "172.16.180.1/24", + "comments": "", + "custom_fields": {}, + "description": "", + "display": "172.16.180.1/24", + "display_url": "http://localhost:32768/ipam/ip-addresses/1/", + "dns_name": "", + "family": { + "label": "IPv4", + "value": 4 + }, + "id": 1, + "nat_inside": null, + "nat_outside": [], + "role": null, + "status": { + "label": "Active", + "value": "active" + }, + "tags": [], + "tenant": null, + "vrf": null + } + ], + "l2vpn_termination": null, + "label": "", + "lag": null, + "link_peers": [], + "link_peers_type": null, + "mac_address": null, + "mark_connected": false, + "mgmt_only": false, + "mode": null, + "module": null, + "mtu": null, + "name": "GigabitEthernet1", + "parent": null, + "poe_mode": null, + "poe_type": null, + "rf_channel": null, + "rf_channel_frequency": null, + "rf_channel_width": null, + "rf_role": null, + "speed": null, + "tagged_vlans": [], + "tags": [], + "tx_power": null, + "type": { + "label": "1000BASE-T (1GE)", + "value": "1000base-t" + }, + "untagged_vlan": null, + "vdcs": [], + "vrf": null, + "wireless_lans": [], + "wireless_link": null, + "wwn": null + }, + { + "_occupied": false, + "bridge": null, + "cable": null, + "cable_end": "", + "connected_endpoints": null, + "connected_endpoints_reachable": null, + "connected_endpoints_type": null, + "count_fhrp_groups": 0, + "count_ipaddresses": 1, + "custom_fields": {}, + "description": "", + "device": { + "description": "", + "display": "test100 (123456789)", + "id": 1, + "name": "test100" + }, + "display": "GigabitEthernet2", + "display_url": "http://localhost:32768/dcim/interfaces/4/", + "duplex": null, + "enabled": true, + "id": 4, + "ip_addresses": [ + { + "address": "2001::1:1/64", + "comments": "", + "custom_fields": {}, + "description": "", + "display": "2001::1:1/64", + "display_url": "http://localhost:32768/ipam/ip-addresses/2/", + "dns_name": "", + "family": { + "label": "IPv6", + "value": 6 + }, + "id": 2, + "nat_inside": null, + "nat_outside": [], + "role": null, + "status": { + "label": "Active", + "value": "active" + }, + "tags": [], + "tenant": null, + "vrf": null + } + ], + "l2vpn_termination": null, + "label": "", + "lag": null, + "link_peers": [], + "link_peers_type": null, + "mac_address": null, + "mark_connected": false, + "mgmt_only": false, + "mode": null, + "module": null, + "mtu": null, + "name": "GigabitEthernet2", + "parent": null, + "poe_mode": null, + "poe_type": null, + "rf_channel": null, + "rf_channel_frequency": null, + "rf_channel_width": null, + "rf_role": null, + "speed": null, + "tagged_vlans": [], + "tags": [], + "tx_power": null, + "type": { + "label": "1000BASE-T (1GE)", + "value": "1000base-t" + }, + "untagged_vlan": null, + "vdcs": [], + "vrf": null, + "wireless_lans": [], + "wireless_link": null, + "wwn": null + }, + { + "_occupied": false, + "bridge": null, + "cable": null, + "cable_end": "", + "connected_endpoints": null, + "connected_endpoints_reachable": null, + "connected_endpoints_type": null, + "count_fhrp_groups": 0, + "count_ipaddresses": 0, + "custom_fields": {}, + "description": "", + "device": { + "description": "", + "display": "test100 (123456789)", + "id": 1, + "name": "test100" + }, + "display": "wlink1", + "display_url": "http://localhost:32768/dcim/interfaces/5/", + "duplex": null, + "enabled": true, + "id": 5, + "ip_addresses": [], + "l2vpn_termination": null, + "label": "", + "lag": null, + "link_peers": [], + "link_peers_type": null, + "mac_address": null, + "mark_connected": false, + "mgmt_only": false, + "mode": null, + "module": null, + "mtu": null, + "name": "wlink1", + "parent": null, + "poe_mode": null, + "poe_type": null, + "rf_channel": null, + "rf_channel_frequency": null, + "rf_channel_width": null, + "rf_role": null, + "speed": null, + "tagged_vlans": [], + "tags": [], + "tx_power": null, + "type": { + "label": "IEEE 802.11a", + "value": "ieee802.11a" + }, + "untagged_vlan": null, + "vdcs": [], + "vrf": null, + "wireless_lans": [], + "wireless_link": null, + "wwn": null + } + ], + "is_virtual": false, + "local_context_data": { + "ntp_servers": [ + "pool.ntp.org" + ] + }, + "locations": [ + "test-rack-group", + "parent-rack-group" + ], + "manufacturer": "cisco", + "regions": [ + "test-region", + "parent-region" + ], + "role": "core-switch", + "serial": "FAB01234567", + "services": [ + { + "comments": "", + "custom_fields": {}, + "description": "", + "device": { + "description": "", + "display": "test100 (123456789)", + "id": 1, + "name": "test100" + }, + "display": "ssh (TCP/22)", + "display_url": "http://localhost:32768/ipam/services/1/", + "id": 1, + "ipaddresses": [], + "name": "ssh", + "ports": [ + 22 + ], + "protocol": { + "label": "TCP", + "value": "tcp" + }, + "tags": [], + "virtual_machine": null + }, + { + "comments": "", + "custom_fields": {}, + "description": "", + "device": { + "description": "", + "display": "test100 (123456789)", + "id": 1, + "name": "test100" + }, + "display": "http (TCP/80)", + "display_url": "http://localhost:32768/ipam/services/2/", + "id": 2, + "ipaddresses": [ + { + "address": "172.16.180.1/24", + "description": "", + "display": "172.16.180.1/24", + "family": { + "label": "IPv4", + "value": 4 + }, + "id": 1 + }, + { + "address": "2001::1:1/64", + "description": "", + "display": "2001::1:1/64", + "family": { + "label": "IPv6", + "value": 6 + }, + "id": 2 + } + ], + "name": "http", + "ports": [ + 80 + ], + "protocol": { + "label": "TCP", + "value": "tcp" + }, + "tags": [], + "virtual_machine": null + } + ], + "site": "test-site", + "site_groups": [], + "status": { + "label": "Active", + "value": "active" + }, + "tags": [], + "virtual_disks": [ + { + "custom_fields": {}, + "description": "", + "display": "disk1", + "display_url": "http://localhost:32768/virtualization/virtual-disks/1/", + "id": 1, + "name": "disk1", + "size": 60, + "tags": [], + "virtual_machine": { + "description": "", + "display": "test100-vm", + "id": 1, + "name": "test100-vm" + } + }, + { + "custom_fields": {}, + "description": "", + "display": "disk2", + "display_url": "http://localhost:32768/virtualization/virtual-disks/2/", + "id": 2, + "name": "disk2", + "size": 110, + "tags": [], + "virtual_machine": { + "description": "", + "display": "test100-vm", + "id": 1, + "name": "test100-vm" + } + } + ] + }, + "test100-vm": { + "cluster": "Test Cluster", + "cluster_group": "test-cluster-group", + "cluster_type": "test-cluster-type", + "config_context": {}, + "custom_fields": {}, + "disk": 170, + "interfaces": [ + { + "bridge": null, + "count_fhrp_groups": 0, + "count_ipaddresses": 0, + "custom_fields": {}, + "description": "", + "display": "Eth0", + "display_url": "http://localhost:32768/virtualization/interfaces/1/", + "enabled": true, + "id": 1, + "ip_addresses": [], + "l2vpn_termination": null, + "mac_address": null, + "mode": null, + "mtu": null, + "name": "Eth0", + "parent": null, + "tagged_vlans": [], + "tags": [], + "untagged_vlan": null, + "virtual_machine": { + "description": "", + "display": "test100-vm", + "id": 1, + "name": "test100-vm" + }, + "vrf": null + }, + { + "bridge": null, + "count_fhrp_groups": 0, + "count_ipaddresses": 0, + "custom_fields": {}, + "description": "", + "display": "Eth1", + "display_url": "http://localhost:32768/virtualization/interfaces/2/", + "enabled": true, + "id": 2, + "ip_addresses": [], + "l2vpn_termination": null, + "mac_address": null, + "mode": null, + "mtu": null, + "name": "Eth1", + "parent": null, + "tagged_vlans": [], + "tags": [], + "untagged_vlan": null, + "virtual_machine": { + "description": "", + "display": "test100-vm", + "id": 1, + "name": "test100-vm" + }, + "vrf": null + }, + { + "bridge": null, + "count_fhrp_groups": 0, + "count_ipaddresses": 0, + "custom_fields": {}, + "description": "", + "display": "Eth2", + "display_url": "http://localhost:32768/virtualization/interfaces/3/", + "enabled": true, + "id": 3, + "ip_addresses": [], + "l2vpn_termination": null, + "mac_address": null, + "mode": null, + "mtu": null, + "name": "Eth2", + "parent": null, + "tagged_vlans": [], + "tags": [], + "untagged_vlan": null, + "virtual_machine": { + "description": "", + "display": "test100-vm", + "id": 1, + "name": "test100-vm" + }, + "vrf": null + }, + { + "bridge": null, + "count_fhrp_groups": 0, + "count_ipaddresses": 0, + "custom_fields": {}, + "description": "", + "display": "Eth3", + "display_url": "http://localhost:32768/virtualization/interfaces/4/", + "enabled": true, + "id": 4, + "ip_addresses": [], + "l2vpn_termination": null, + "mac_address": null, + "mode": null, + "mtu": null, + "name": "Eth3", + "parent": null, + "tagged_vlans": [], + "tags": [], + "untagged_vlan": null, + "virtual_machine": { + "description": "", + "display": "test100-vm", + "id": 1, + "name": "test100-vm" + }, + "vrf": null + }, + { + "bridge": null, + "count_fhrp_groups": 0, + "count_ipaddresses": 0, + "custom_fields": {}, + "description": "", + "display": "Eth4", + "display_url": "http://localhost:32768/virtualization/interfaces/5/", + "enabled": true, + "id": 5, + "ip_addresses": [], + "l2vpn_termination": null, + "mac_address": null, + "mode": null, + "mtu": null, + "name": "Eth4", + "parent": null, + "tagged_vlans": [], + "tags": [], + "untagged_vlan": null, + "virtual_machine": { + "description": "", + "display": "test100-vm", + "id": 1, + "name": "test100-vm" + }, + "vrf": null + } + ], + "is_virtual": true, + "locations": [], + "regions": [ + "test-region", + "parent-region" + ], + "serial": "", + "services": [], + "site": "test-site", + "site_groups": [], + "status": { + "label": "Active", + "value": "active" + }, + "tags": [], + "virtual_disks": [ + { + "custom_fields": {}, + "description": "", + "display": "disk1", + "display_url": "http://localhost:32768/virtualization/virtual-disks/1/", + "id": 1, + "name": "disk1", + "size": 60, + "tags": [], + "virtual_machine": { + "description": "", + "display": "test100-vm", + "id": 1, + "name": "test100-vm" + } + }, + { + "custom_fields": {}, + "description": "", + "display": "disk2", + "display_url": "http://localhost:32768/virtualization/virtual-disks/2/", + "id": 2, + "name": "disk2", + "size": 110, + "tags": [], + "virtual_machine": { + "description": "", + "display": "test100-vm", + "id": 1, + "name": "test100-vm" + } + } + ] + }, + "test101-vm": { + "cluster": "Test Cluster", + "cluster_group": "test-cluster-group", + "cluster_type": "test-cluster-type", + "config_context": {}, + "custom_fields": {}, + "interfaces": [ + { + "bridge": null, + "count_fhrp_groups": 0, + "count_ipaddresses": 0, + "custom_fields": {}, + "description": "", + "display": "Eth0", + "display_url": "http://localhost:32768/virtualization/interfaces/6/", + "enabled": true, + "id": 6, + "ip_addresses": [], + "l2vpn_termination": null, + "mac_address": null, + "mode": null, + "mtu": null, + "name": "Eth0", + "parent": null, + "tagged_vlans": [], + "tags": [], + "untagged_vlan": null, + "virtual_machine": { + "description": "", + "display": "test101-vm", + "id": 2, + "name": "test101-vm" + }, + "vrf": null + }, + { + "bridge": null, + "count_fhrp_groups": 0, + "count_ipaddresses": 0, + "custom_fields": {}, + "description": "", + "display": "Eth1", + "display_url": "http://localhost:32768/virtualization/interfaces/7/", + "enabled": true, + "id": 7, + "ip_addresses": [], + "l2vpn_termination": null, + "mac_address": null, + "mode": null, + "mtu": null, + "name": "Eth1", + "parent": null, + "tagged_vlans": [], + "tags": [], + "untagged_vlan": null, + "virtual_machine": { + "description": "", + "display": "test101-vm", + "id": 2, + "name": "test101-vm" + }, + "vrf": null + }, + { + "bridge": null, + "count_fhrp_groups": 0, + "count_ipaddresses": 0, + "custom_fields": {}, + "description": "", + "display": "Eth2", + "display_url": "http://localhost:32768/virtualization/interfaces/8/", + "enabled": true, + "id": 8, + "ip_addresses": [], + "l2vpn_termination": null, + "mac_address": null, + "mode": null, + "mtu": null, + "name": "Eth2", + "parent": null, + "tagged_vlans": [], + "tags": [], + "untagged_vlan": null, + "virtual_machine": { + "description": "", + "display": "test101-vm", + "id": 2, + "name": "test101-vm" + }, + "vrf": null + }, + { + "bridge": null, + "count_fhrp_groups": 0, + "count_ipaddresses": 0, + "custom_fields": {}, + "description": "", + "display": "Eth3", + "display_url": "http://localhost:32768/virtualization/interfaces/9/", + "enabled": true, + "id": 9, + "ip_addresses": [], + "l2vpn_termination": null, + "mac_address": null, + "mode": null, + "mtu": null, + "name": "Eth3", + "parent": null, + "tagged_vlans": [], + "tags": [], + "untagged_vlan": null, + "virtual_machine": { + "description": "", + "display": "test101-vm", + "id": 2, + "name": "test101-vm" + }, + "vrf": null + }, + { + "bridge": null, + "count_fhrp_groups": 0, + "count_ipaddresses": 0, + "custom_fields": {}, + "description": "", + "display": "Eth4", + "display_url": "http://localhost:32768/virtualization/interfaces/10/", + "enabled": true, + "id": 10, + "ip_addresses": [], + "l2vpn_termination": null, + "mac_address": null, + "mode": null, + "mtu": null, + "name": "Eth4", + "parent": null, + "tagged_vlans": [], + "tags": [], + "untagged_vlan": null, + "virtual_machine": { + "description": "", + "display": "test101-vm", + "id": 2, + "name": "test101-vm" + }, + "vrf": null + } + ], + "is_virtual": true, + "locations": [], + "regions": [ + "test-region", + "parent-region" + ], + "serial": "", + "services": [], + "site": "test-site", + "site_groups": [], + "status": { + "label": "Active", + "value": "active" + }, + "tags": [], + "virtual_disks": [] + }, + "test102-vm": { + "cluster": "Test Cluster", + "cluster_group": "test-cluster-group", + "cluster_type": "test-cluster-type", + "config_context": {}, + "custom_fields": {}, + "interfaces": [], + "is_virtual": true, + "locations": [], + "regions": [ + "test-region", + "parent-region" + ], + "serial": "", + "services": [], + "site": "test-site", + "site_groups": [], + "status": { + "label": "Active", + "value": "active" + }, + "tags": [], + "virtual_disks": [] + }, + "test103-vm": { + "cluster": "Test Cluster", + "cluster_group": "test-cluster-group", + "cluster_type": "test-cluster-type", + "config_context": {}, + "custom_fields": {}, + "interfaces": [], + "is_virtual": true, + "locations": [], + "regions": [ + "test-region", + "parent-region" + ], + "serial": "", + "services": [], + "site": "test-site", + "site_groups": [], + "status": { + "label": "Active", + "value": "active" + }, + "tags": [], + "virtual_disks": [] + }, + "test104-vm": { + "cluster": "Test Cluster 2", + "cluster_type": "test-cluster-type", + "config_context": {}, + "custom_fields": {}, + "interfaces": [], + "is_virtual": true, + "locations": [], + "regions": [], + "serial": "", + "services": [], + "site_groups": [], + "status": { + "label": "Active", + "value": "active" + }, + "tags": [], + "virtual_disks": [] + } + } + }, + "all": { + "children": [ + "ungrouped", + "site_test_site2", + "region_other_region", + "region_parent_region", + "site_group_other_site_group", + "site_group_parent_site_group", + "rack_Test_Rack_Site_2", + "rack_role_test_rack_role", + "role_core_switch", + "device_type_cisco_test", + "manufacturer_cisco", + "status_active", + "device_type_nexus_parent", + "service_telnet", + "rack_Test_Rack", + "service_ssh", + "service_http", + "cluster_Test_Cluster_2", + "cluster_type_test_cluster_type", + "is_virtual", + "cluster_Test_Cluster", + "cluster_group_test_cluster_group" + ] + }, + "cluster_Test_Cluster": { + "hosts": [ + "test100-vm", + "test101-vm", + "test102-vm", + "test103-vm" + ] + }, + "cluster_Test_Cluster_2": { + "hosts": [ + "Test VM With Spaces", + "test104-vm" + ] + }, + "cluster_group_test_cluster_group": { + "hosts": [ + "test100-vm", + "test101-vm", + "test102-vm", + "test103-vm" + ] + }, + "cluster_type_test_cluster_type": { + "hosts": [ + "Test VM With Spaces", + "test100-vm", + "test101-vm", + "test102-vm", + "test103-vm", + "test104-vm" + ] + }, + "device_type_cisco_test": { + "hosts": [ + "R1-Device", + "TestDeviceR1", + "test100" + ] + }, + "device_type_nexus_parent": { + "hosts": [ + "Test Nexus One" + ] + }, + "is_virtual": { + "hosts": [ + "Test VM With Spaces", + "test100-vm", + "test101-vm", + "test102-vm", + "test103-vm", + "test104-vm" + ] + }, + "location_parent_rack_group": { + "children": [ + "location_test_rack_group" + ] + }, + "location_test_rack_group": { + "hosts": [ + "Test Nexus One", + "TestDeviceR1", + "test100" + ] + }, + "manufacturer_cisco": { + "hosts": [ + "R1-Device", + "Test Nexus One", + "TestDeviceR1", + "test100" + ] + }, + "rack_Test_Rack": { + "hosts": [ + "TestDeviceR1" + ] + }, + "rack_Test_Rack_Site_2": { + "hosts": [ + "R1-Device" + ] + }, + "rack_role_test_rack_role": { + "hosts": [ + "R1-Device" + ] + }, + "region_parent_region": { + "children": [ + "region_test_region" + ] + }, + "region_test_region": { + "children": [ + "site_test_site" + ] + }, + "role_core_switch": { + "hosts": [ + "R1-Device", + "Test Nexus One", + "TestDeviceR1", + "test100" + ] + }, + "service_http": { + "hosts": [ + "test100" + ] + }, + "service_ssh": { + "hosts": [ + "test100", + "Test VM With Spaces" + ] + }, + "service_telnet": { + "hosts": [ + "Test Nexus One" + ] + }, + "site_group_parent_site_group": { + "children": [ + "site_group_test_site_group" + ] + }, + "site_test_site": { + "children": [ + "location_parent_rack_group" + ], + "hosts": [ + "test100-vm", + "test101-vm", + "test102-vm", + "test103-vm" + ] + }, + "site_test_site2": { + "hosts": [ + "R1-Device" + ] + }, + "status_active": { + "hosts": [ + "R1-Device", + "Test Nexus One", + "TestDeviceR1", + "test100", + "Test VM With Spaces", + "test100-vm", + "test101-vm", + "test102-vm", + "test103-vm", + "test104-vm" + ] + } +} \ No newline at end of file diff --git a/tests/integration/targets/inventory-v4.3/files/test-inventory.yml b/tests/integration/targets/inventory-v4.3/files/test-inventory.yml new file mode 100644 index 000000000..a24cd7bbb --- /dev/null +++ b/tests/integration/targets/inventory-v4.3/files/test-inventory.yml @@ -0,0 +1,31 @@ +--- +plugin: netbox.netbox.nb_inventory +api_endpoint: http://localhost:32768 +token: "0123456789abcdef0123456789abcdef01234567" +validate_certs: false + +config_context: true +plurals: false +interfaces: true +virtual_disks: true +services: true + +group_by: + - site + - tenant + - rack + - location + - rack_role + - tag + - role + - device_type + - manufacturer + - platform + - region + - site_group + - cluster + - cluster_group + - cluster_type + - is_virtual + - services + - status diff --git a/tests/integration/targets/inventory-v4.3/runme.sh b/tests/integration/targets/inventory-v4.3/runme.sh new file mode 100755 index 000000000..f0ea70d04 --- /dev/null +++ b/tests/integration/targets/inventory-v4.3/runme.sh @@ -0,0 +1,72 @@ +#!/usr/bin/env bash + +set -o xtrace # Print commands as they're run +set -o errexit # abort on nonzero exitstatus +set -o nounset # abort on unbound variable +set -o pipefail # don't hide errors within pipes + +# Directory of this script +SCRIPT_DIR="$( dirname "${BASH_SOURCE[0]}" )" +RUNME_CONFIG="$SCRIPT_DIR/runme_config" +INVENTORIES_DIR="$SCRIPT_DIR/files" + +# Load runme_config, if exists - the only way to pass environment when run through ansible-test +if [[ -f "$RUNME_CONFIG" ]] +then + source "$RUNME_CONFIG" +fi + +declare -a COMPARE_OPTIONS # empty array + +# Check if NETBOX_VERSION has been set by runme_config, and if so, pass to compare_inventory_json.py +if [[ "${NETBOX_VERSION:-}" == "v4.1" ]] +then + COMPARE_OPTIONS+=(--netbox-version "${NETBOX_VERSION}") +fi + +# OUTPUT_DIR is set by ansible-test +# OUTPUT_INVENTORY_JSON is only set if running hacking/update_test_inventories.sh to update the test diff data +if [[ -n "${OUTPUT_INVENTORY_JSON:-}" ]] +then + OUTPUT_DIR="$OUTPUT_INVENTORY_JSON" + + # Clean up JSON fields we don't want to store and compare against in tests (creation times, etc.) + COMPARE_OPTIONS+=(--write) +fi + +echo OUTPUT_DIR="$OUTPUT_DIR" + +inventory () { + if [[ -n "${OUTPUT_INVENTORY_JSON:-}" ]] + then + # Running for the purpose of updating test data + ansible-inventory "$@" + else + # Running inside ansible-test + # Run through python.py just to make sure we've definitely got the coverage environment set up + # Just running ansible-inventory directly may not actually find the right one in PATH + python.py "$(command -v ansible-inventory)" "$@" + fi +} + + +RESULT=0 + +for INVENTORY in "$INVENTORIES_DIR"/*.yml +do + NAME="$(basename "$INVENTORY")" + NAME_WITHOUT_EXTENSION="${NAME%.yml}" + + OUTPUT_JSON="$OUTPUT_DIR/$NAME_WITHOUT_EXTENSION.json" + inventory -vvvv --list --inventory "$INVENTORY" --output="$OUTPUT_JSON" + + # Compare the output + if ! "$SCRIPT_DIR/compare_inventory_json.py" "${COMPARE_OPTIONS[@]}" "$INVENTORIES_DIR/$NAME_WITHOUT_EXTENSION.json" "$OUTPUT_JSON" + then + # Returned non-zero status + RESULT=1 + fi + +done + +exit $RESULT diff --git a/tests/integration/targets/inventory-v4.3/runme_config.template b/tests/integration/targets/inventory-v4.3/runme_config.template new file mode 100644 index 000000000..80b42a326 --- /dev/null +++ b/tests/integration/targets/inventory-v4.3/runme_config.template @@ -0,0 +1,6 @@ +# runme_config is source'd by runme.sh to set environment variables used to modify the test against different versions of NetBox. +# .travis.yml uses render_config.sh to generate it from runme_config.template +# There is no other way to pass environment variables to a runme.sh integration test. +# (integration_config.yml files are only helpful to ansible yaml-based tests) + +export NETBOX_VERSION=${VERSION} diff --git a/tests/integration/targets/regression-v4.2/tasks/main.yml b/tests/integration/targets/regression-v4.2/tasks/main.yml index 5bc0bd708..9e64019df 100644 --- a/tests/integration/targets/regression-v4.2/tasks/main.yml +++ b/tests/integration/targets/regression-v4.2/tasks/main.yml @@ -282,3 +282,20 @@ ansible.builtin.assert: that: - test_results.results.0.location.id != test_results.results.1.location.id + +- name: "Issue #1413 - Update interface primary MAC by ID" + netbox.netbox.netbox_device_interface: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + device: test100 + name: GigabitEthernet2 + primary_mac_address: + id: 3 + state: present + register: test_results + +- name: "ASSERT Issue #1413" + ansible.builtin.assert: + that: + - test_results['interface']['primary_mac_address'] == 3 diff --git a/tests/integration/targets/regression-v4.3/tasks/main.yml b/tests/integration/targets/regression-v4.3/tasks/main.yml new file mode 100644 index 000000000..9e64019df --- /dev/null +++ b/tests/integration/targets/regression-v4.3/tasks/main.yml @@ -0,0 +1,301 @@ +--- +## +## +### TEST NETBOX CONNECTION FAILURE +## +## +- name: TEST NETBOX CONNECTION FAILURE + connection: local + block: + - name: 1 - Device with required information + netbox.netbox.netbox_device: + netbox_url: http://some-random-invalid-URL + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: R1 + device_type: Cisco Test + device_role: Core Switch + site: Test Site + status: Staged + state: present + register: test_one + ignore_errors: true + + - name: 1 - ASSERT + ansible.builtin.assert: + that: + - test_one is failed + - test_one['msg'] == "Failed to establish connection to NetBox API" + + - name: 2 - Check to see if netbox_prefix with parent defined will pass via check-mode + netbox.netbox.netbox_prefix: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + parent: 10.10.0.0/16 + prefix_length: 24 + first_available: true + state: present + register: test_two + check_mode: true + + - name: 2 - ASSERT + ansible.builtin.assert: + that: + - test_two is changed + - test_two['msg'] == "New prefix created within 10.10.0.0/16" + + - name: "3 - Add device with tags - Setup device to test #242" + netbox.netbox.netbox_device: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: issue-242 + device_type: Cisco Test + device_role: Core Switch + site: Test Site + status: Staged + tags: + - slug: first + - slug: second + + - name: "4 - Add device with tags out of order - shouldn't change - Tests #242 is fixed" + netbox.netbox.netbox_device: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: issue-242 + device_type: Cisco Test + device_role: Core Switch + site: Test Site + status: Staged + tags: + - slug: second + - slug: first + register: test_four + diff: true + + - name: "4 - Assert not changed - Tests #242 is fixed" + ansible.builtin.assert: + that: + - not test_four["changed"] + + - name: "5 - Add device with extra tag - Tests #242 is fixed" + netbox.netbox.netbox_device: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: issue-242 + device_type: Cisco Test + device_role: Core Switch + site: Test Site + status: Staged + asset_tag: "1234" + tags: + - slug: second + - slug: third + - slug: first + register: test_five + diff: true + + - name: "5 - Assert added tag - Tests #242 is fixed" + ansible.builtin.assert: + that: + - test_five is changed + - test_five["diff"]["after"]["tags"] is defined + - test_five["device"]["tags"] is defined + + - name: "6 - Loop through and add interface templates to different device interface templates - Fixes #282" + netbox.netbox.netbox_device_interface_template: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: SFP+ (10GE) + type: SFP+ (10GE) + device_type: "{{ item }}" + register: test_six + loop: + - Cisco Test + - Arista Test + - Nexus Child + - Nexus Parent + + - name: "6 - Assert device type is correct - Fixes #282" + ansible.builtin.assert: + that: + - test_six.results[0]["diff"]["before"]["state"] == "absent" + - test_six.results[0]["diff"]["after"]["state"] == "present" + - test_six.results[0]["interface_template"]["device_type"] == 1 + - test_six.results[1]["diff"]["before"]["state"] == "absent" + - test_six.results[1]["diff"]["after"]["state"] == "present" + - test_six.results[1]["interface_template"]["device_type"] == 2 + - test_six.results[2]["diff"]["before"]["state"] == "absent" + - test_six.results[2]["diff"]["after"]["state"] == "present" + - test_six.results[2]["interface_template"]["device_type"] == 4 + - test_six.results[3]["diff"]["before"]["state"] == "absent" + - test_six.results[3]["diff"]["after"]["state"] == "present" + - test_six.results[3]["interface_template"]["device_type"] == 3 + + - name: 7 - Don't prevent updates to other params if tags are specified + netbox.netbox.netbox_device: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: issue-242 + device_type: Cisco Test + device_role: Core Switch + site: Test Site + status: Staged + asset_tag: "Null" + tags: + # Changed these for issue #407 to be IDs + - 2 + - 3 + - 1 + register: test_seven + + - name: "5 - Assert added tag - Tests #242 is fixed" + ansible.builtin.assert: + that: + - test_seven is changed + - test_seven["diff"]["after"]["asset_tag"] == "Null" + - test_seven["device"]["asset_tag"] == "Null" + + - name: Add ip address to netbox and don't assign it to a device (Issue 372) + netbox.netbox.netbox_ip_address: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + address: 10.255.255.1/24 + query_params: + - address + - vrf + state: present + + - name: Update same ip address to attach to a device interface (Issue 372) + netbox.netbox.netbox_ip_address: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + address: 10.255.255.1/24 + assigned_object: + device: test100 + name: GigabitEthernet1 + query_params: + - address + - vrf + state: present + register: query_params_372 + + - name: Assert ip address was updated and added to device interface + ansible.builtin.assert: + that: + - query_params_372 is changed + - query_params_372['msg'] == 'ip_address 10.255.255.1/24 updated' + - query_params_372['diff']['after']['assigned_object'] == 3 + - query_params_372['diff']['after']['assigned_object_id'] == 3 + - query_params_372['diff']['after']['assigned_object_type'] == 'dcim.interface' + + - name: Validate failure due to invalid child params provided by user + netbox.netbox.netbox_cable: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + termination_a_type: dcim.interface + termination_a: + device: test100 + name: GigabitEthernet1 + termination_b_type: circuits.circuittermination + termination_b: + name: XYZ987 + ignore_errors: true + register: test_results + + - name: "Issue #415 - Assert failure message shows the allowed params and what the user provided" + ansible.builtin.assert: + that: + - test_results is failed + - 'test_results["msg"] == "One or more of the kwargs provided are invalid for circuits.circuittermination, provided kwargs: name. Acceptable kwargs: circuit, + term_side"' + + - name: "Issue #432 - Make sure same IPs get assigned to different device interfaces" + netbox.netbox.netbox_ip_address: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: "{{ item }}" + loop: "{{ data }}" + register: test_results + vars: + data: + - address: 121.121.121.121/32 + assigned_object: + device: Test Nexus One + name: Ethernet1/1 + description: ansible-netbox-1.2.1 + dns_name: ansible-netbox-1.2.1 + role: HSRP + status: Active + - address: 121.121.121.121/32 + assigned_object: + device: Test Nexus Child One + name: Ethernet2/1 + description: ansible-netbox-1.2.1 + dns_name: ansible-netbox-1.2.1 + role: HSRP + status: Active + - address: 1.121.121.121/32 + assigned_object: + device: Test Nexus One + name: Ethernet1/1 + description: ansible-netbox-1.2.1 + dns_name: ansible-netbox-1.2.1 + role: HSRP + status: Active + - address: 1.121.121.121/32 + assigned_object: + device: Test Nexus Child One + name: Ethernet2/1 + description: ansible-netbox-1.2.1 + dns_name: ansible-netbox-1.2.1 + role: HSRP + status: Active + + - name: "ASSERT Issue #432 changes reflect correct device" + ansible.builtin.assert: + that: + - test_results | community.general.json_query('results[?ip_address.address==`1.121.121.121/32`]') | length == 2 + - test_results | community.general.json_query('results[?ip_address.address==`121.121.121.121/32`]') | length == 2 + + - name: "Issue #958 - Make sure we can add same location with different sites" + netbox.netbox.netbox_location: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Office Building + site: "{{ item }}" + loop: + - Test Site + - Test Site2 + register: test_results + + - name: "ASSERT ISSUE #957 - Location has different IDs" + ansible.builtin.assert: + that: + - test_results.results.0.location.id != test_results.results.1.location.id + +- name: "Issue #1413 - Update interface primary MAC by ID" + netbox.netbox.netbox_device_interface: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + device: test100 + name: GigabitEthernet2 + primary_mac_address: + id: 3 + state: present + register: test_results + +- name: "ASSERT Issue #1413" + ansible.builtin.assert: + that: + - test_results['interface']['primary_mac_address'] == 3 diff --git a/tests/integration/targets/v4.0/tasks/main.yml b/tests/integration/targets/v4.0/tasks/main.yml index f229a24a9..d4f5664ba 100644 --- a/tests/integration/targets/v4.0/tasks/main.yml +++ b/tests/integration/targets/v4.0/tasks/main.yml @@ -23,6 +23,15 @@ - name: NETBOX_CONTACT TESTS ansible.builtin.include_tasks: netbox_contact.yml +- name: NETBOX_CONTACT_GROUP TESTS + ansible.builtin.include_tasks: + file: netbox_contact_group.yml + apply: + tags: + - netbox_contact_group + tags: + - netbox_contact_group + - name: NETBOX_CONTACT_ROLE TESTS ansible.builtin.include_tasks: netbox_contact_role.yml diff --git a/tests/integration/targets/v4.0/tasks/netbox_contact.yml b/tests/integration/targets/v4.0/tasks/netbox_contact.yml index f5ede9c1a..6403e808a 100644 --- a/tests/integration/targets/v4.0/tasks/netbox_contact.yml +++ b/tests/integration/targets/v4.0/tasks/netbox_contact.yml @@ -98,3 +98,46 @@ - test_five['contact']['phone'] == "12345678" - test_five['contact']['tags'] | length == 3 - test_five['msg'] == "contact Contact ABC created" + +- name: 6 Setup - Create contact group + netbox.netbox.netbox_contact_group: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Contact Group With Contacts + register: test_group + +- name: 6 - Create contact with contact group + netbox.netbox.netbox_contact: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Grouped Contact 1 + contact_group: Contact Group With Contacts + register: test_six + +- name: 6 - ASSERT + ansible.builtin.assert: + that: + - test_six is changed + - test_six['diff']['before']['state'] == "absent" + - test_six['diff']['after']['state'] == "present" + - test_six['contact']['name'] == "Grouped Contact 1" + - test_six['contact']['group'] == test_group['contact_group']['id'] + - test_six['msg'] == "contact Grouped Contact 1 created" + +- name: 7 - Try to create contact using contact_groups + netbox.netbox.netbox_contact: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Grouped Contact 2 + contact_groups: + - Contact Group With Contacts + register: test_seven + ignore_errors: true + +- name: 7 - ASSERT + ansible.builtin.assert: + that: + - "'contact_groups is not available in Netbox 4.0. Use contact_group instead, or upgrade to Netbox 4.3 or greater.' in test_seven['module_stderr']" diff --git a/tests/integration/targets/v4.0/tasks/netbox_contact_group.yml b/tests/integration/targets/v4.0/tasks/netbox_contact_group.yml new file mode 100644 index 000000000..090d880a0 --- /dev/null +++ b/tests/integration/targets/v4.0/tasks/netbox_contact_group.yml @@ -0,0 +1,119 @@ +--- +## +## +### NETBOX_CONTACT_GROUP +## +## +- name: 1 - Test contact group creation + netbox.netbox.netbox_contact_group: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Contact Group 1 + register: test_one + +- name: 1 - ASSERT + ansible.builtin.assert: + that: + - test_one is changed + - test_one['diff']['before']['state'] == "absent" + - test_one['diff']['after']['state'] == "present" + - test_one['contact_group']['name'] == "Contact Group 1" + - test_one['msg'] == "contact_group Contact Group 1 created" + +- name: Test duplicate contact group + netbox.netbox.netbox_contact_group: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Contact Group 1 + register: test_two + +- name: 2 - ASSERT + ansible.builtin.assert: + that: + - not test_two['changed'] + - test_two['contact_group']['name'] == "Contact Group 1" + - test_two['msg'] == "contact_group Contact Group 1 already exists" + +- name: 3 - Test update + netbox.netbox.netbox_contact_group: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Contact Group 1 + description: The first contact group + register: test_three + +- name: 3 - ASSERT + ansible.builtin.assert: + that: + - test_three is changed + - test_three['diff']['after']['description'] == "The first contact group" + - test_three['contact_group']['name'] == "Contact Group 1" + - test_three['contact_group']['description'] == "The first contact group" + - test_three['msg'] == "contact_group Contact Group 1 updated" + +- name: 4 - Test delete + netbox.netbox.netbox_contact_group: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Contact Group 1 + state: absent + register: test_four + +- name: 4 - ASSERT + ansible.builtin.assert: + that: + - test_four is changed + - test_four['diff']['before']['state'] == "present" + - test_four['diff']['after']['state'] == "absent" + - test_four['msg'] == "contact_group Contact Group 1 deleted" + +- name: 5 - Create contact group with all parameters + netbox.netbox.netbox_contact_group: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Contact Group Parent + slug: the-parent-contact-group + description: The parent contact group + tags: + - tagA + - tagB + - tagC + state: present + register: test_five + +- name: 5 - ASSERT + ansible.builtin.assert: + that: + - test_five is changed + - test_five['diff']['before']['state'] == "absent" + - test_five['diff']['after']['state'] == "present" + - test_five['contact_group']['name'] == "Contact Group Parent" + - test_five['contact_group']['slug'] == "the-parent-contact-group" + - test_five['contact_group']['description'] == "The parent contact group" + - test_five['contact_group']['tags'] | length == 3 + - test_five['msg'] == "contact_group Contact Group Parent created" + +- name: 6 - Create contact group with parent contact group + netbox.netbox.netbox_contact_group: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Contact Group Child + parent_contact_group: Contact Group Parent + state: present + register: test_six + +- name: 6 - ASSERT + ansible.builtin.assert: + that: + - test_six is changed + - test_six['diff']['before']['state'] == "absent" + - test_six['diff']['after']['state'] == "present" + - test_six['contact_group']['name'] == "Contact Group Child" + - test_six['contact_group']['parent'] == test_five['contact_group']['id'] + - test_six['msg'] == "contact_group Contact Group Child created" diff --git a/tests/integration/targets/v4.0/tasks/netbox_permission.yml b/tests/integration/targets/v4.0/tasks/netbox_permission.yml index fdc459332..4a785ce60 100644 --- a/tests/integration/targets/v4.0/tasks/netbox_permission.yml +++ b/tests/integration/targets/v4.0/tasks/netbox_permission.yml @@ -115,7 +115,7 @@ ansible.builtin.assert: that: - test_five is changed - - test_five['user_group']['permissions'] == [1] + - test_five['user_group']['permissions'] == [test_one['permission']['id']] - name: "PERMISSION 6: Add permission to user" netbox.netbox.netbox_user: @@ -123,7 +123,7 @@ netbox_token: "0123456789abcdef0123456789abcdef01234567" data: username: TestUser - password: TestPassword + password: TestPassword6 permissions: - Test Permission 2 state: present @@ -133,7 +133,7 @@ ansible.builtin.assert: that: - test_six is changed - - test_six['user']['permissions'] == [2] + - test_six['user']['permissions'] == [test_four['permission']['id']] - name: "PERMISSION 7: Delete" netbox.netbox.netbox_permission: @@ -167,3 +167,48 @@ - not test_eight['changed'] - test_eight['permission'] == None - test_eight['msg'] == "permission Test Permission already absent" + +- name: "PERMISSION 9: Necessary permission" + netbox.netbox.netbox_permission: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test Permission + description: The test permission + enabled: true + actions: + - view + - add + - change + - delete + - extreme_administration + object_types: + - vpn.tunneltermination + - wireless.wirelesslan + state: present + +- name: "PERMISSION 9: Re-create permission with lists in wrong order" + netbox.netbox.netbox_permission: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test Permission + description: The test permission + enabled: true + actions: + - extreme_administration + - delete + - change + - add + - view + object_types: + - wireless.wirelesslan + - vpn.tunneltermination + state: present + register: test_nine + +- name: "PERMISSION 9: ASSERT - The same lists in a new order do not update the permission" + ansible.builtin.assert: + that: + - not test_nine['changed'] + # actions and object_types seem to be ordered randomly so we cannot test them here diff --git a/tests/integration/targets/v4.0/tasks/netbox_token.yml b/tests/integration/targets/v4.0/tasks/netbox_token.yml index f149ef9c0..abfe53e79 100644 --- a/tests/integration/targets/v4.0/tasks/netbox_token.yml +++ b/tests/integration/targets/v4.0/tasks/netbox_token.yml @@ -10,8 +10,9 @@ netbox_token: "0123456789abcdef0123456789abcdef01234567" data: username: TestUser - password: TestPassword + password: TestPassword1 state: present + register: test_user - name: "TOKEN 1: Necessary info creation" netbox.netbox.netbox_token: @@ -29,7 +30,7 @@ - test_one is changed - test_one['diff']['before']['state'] == "absent" - test_one['diff']['after']['state'] == "present" - - test_one['token']['user'] == 3 + - test_one['token']['user'] == test_user['user']['id'] - test_one['msg'] == "token ******** created" - name: "TOKEN 2: Create duplicate" diff --git a/tests/integration/targets/v4.0/tasks/netbox_user.yml b/tests/integration/targets/v4.0/tasks/netbox_user.yml index a95e93234..62b35e563 100644 --- a/tests/integration/targets/v4.0/tasks/netbox_user.yml +++ b/tests/integration/targets/v4.0/tasks/netbox_user.yml @@ -10,11 +10,11 @@ netbox_token: "0123456789abcdef0123456789abcdef01234567" data: username: TestUser - password: TestPassword + password: TestPassword1 state: present register: test_one -- name: "USESR 1: ASSERT - Necessary info creation" +- name: "USER 1: ASSERT - Necessary info creation" ansible.builtin.assert: that: - test_one is changed @@ -48,7 +48,7 @@ netbox_token: "0123456789abcdef0123456789abcdef01234567" data: username: TestUser - password: TestPassword + password: TestPassword3 email: test@user.com first_name: Test last_name: User @@ -88,7 +88,7 @@ - test_four['diff']['after']['state'] == "absent" - test_four['msg'] == "user TestUser deleted" -- name: "USER 5: ASSERT - Delete non existing" +- name: "USER 5: Delete non existing" netbox.netbox.netbox_user: netbox_url: http://localhost:32768 netbox_token: "0123456789abcdef0123456789abcdef01234567" @@ -103,3 +103,100 @@ - not test_five['changed'] - test_five['user'] == None - test_five['msg'] == "user TestUser already absent" + +- name: "USER 6: Necessary group 1" + netbox.netbox.netbox_user_group: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test User Group Alpha + state: present + register: user_group_alpha + +- name: "USER 6: Necessary group 2" + netbox.netbox.netbox_user_group: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test User Group Beta + state: present + register: user_group_beta + +- name: "User 6: Necessary permission 1" + netbox.netbox.netbox_permission: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test Permission Foo + actions: + - view + object_types: [] + state: present + register: permission_foo + +- name: "User 6: Necessary permission 2" + netbox.netbox.netbox_permission: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test Permission Bar + actions: + - view + object_types: [] + state: present + register: permission_bar + +- name: "User 6: Necessary permission 3" + netbox.netbox.netbox_permission: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test Permission Baz + actions: + - view + object_types: [] + state: present + register: permission_baz + +- name: "USER 6: Set up user with multiple groups and permissions" + netbox.netbox.netbox_user: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + username: TestUser2 + password: TestPassword2 + permissions: + - Test Permission Foo + - Test Permission Bar + - Test Permission Baz + groups: + - Test User Group Alpha + - Test User Group Beta + state: present + +- name: "USER 6: Re-create user with lists in wrong order" + netbox.netbox.netbox_user: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + username: TestUser2 + permissions: + - Test Permission Bar + - Test Permission Baz + - Test Permission Foo + groups: + - Test User Group Beta + - Test User Group Alpha + state: present + register: test_six + +- name: "USER 6: ASSERT - The same lists in a new order do not update the user" + ansible.builtin.assert: + that: + - not test_six['changed'] + - test_six['msg'] == "user TestUser2 already exists" + - test_six['user']['groups'][0] == user_group_alpha['user_group']['id'] + - test_six['user']['groups'][1] == user_group_beta['user_group']['id'] + - test_six['user']['permissions'][0] == permission_foo['permission']['id'] + - test_six['user']['permissions'][1] == permission_bar['permission']['id'] + - test_six['user']['permissions'][2] == permission_baz['permission']['id'] diff --git a/tests/integration/targets/v4.0/tasks/netbox_user_group.yml b/tests/integration/targets/v4.0/tasks/netbox_user_group.yml index b6f87059f..0bedc95fb 100644 --- a/tests/integration/targets/v4.0/tasks/netbox_user_group.yml +++ b/tests/integration/targets/v4.0/tasks/netbox_user_group.yml @@ -81,7 +81,7 @@ netbox_token: "0123456789abcdef0123456789abcdef01234567" data: username: TestUser - password: TestPassword + password: TestPassword5 groups: - Test User Group state: present @@ -91,7 +91,7 @@ ansible.builtin.assert: that: - test_five is changed - - test_five['user']['groups'] == [1] + - test_five['user']['groups'] == [test_one['user_group']['id']] - name: "USER_GROUP 6: Delete" netbox.netbox.netbox_user_group: @@ -125,3 +125,57 @@ - not test_seven['changed'] - test_seven['user_group'] == None - test_seven['msg'] == "user_group Test User Group already absent" + +- name: "USER_GROUP 8: Necessary permission 1" + netbox.netbox.netbox_permission: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test Permission Foo + actions: + - view + object_types: [] + state: present + register: permission_foo + +- name: "USER_GROUP 8: Necessary permission 2" + netbox.netbox.netbox_permission: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test Permission Bar + actions: + - view + object_types: [] + state: present + register: permission_bar + +- name: "USER_GROUP 8: Necessary info creation" + netbox.netbox.netbox_user_group: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test User Group + permissions: + - Test Permission Foo + - Test Permission Bar + state: present + +- name: "USER_GROUP 8: Re-create user group with permissions in wrong order" + netbox.netbox.netbox_user_group: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test User Group + permissions: + - Test Permission Bar + - Test Permission Foo + state: present + register: test_eight + +- name: "USER_GROUP 8: ASSERT - The same permissions in a new order do not update the group" + ansible.builtin.assert: + that: + - not test_eight is changed + - test_eight['user_group']['permissions'][0] == permission_foo['permission']['id'] + - test_eight['user_group']['permissions'][1] == permission_bar['permission']['id'] diff --git a/tests/integration/targets/v4.1/tasks/main.yml b/tests/integration/targets/v4.1/tasks/main.yml index 1d56afb98..4914837a3 100644 --- a/tests/integration/targets/v4.1/tasks/main.yml +++ b/tests/integration/targets/v4.1/tasks/main.yml @@ -23,6 +23,15 @@ - name: NETBOX_CONTACT TESTS ansible.builtin.include_tasks: netbox_contact.yml +- name: NETBOX_CONTACT_GROUP TESTS + ansible.builtin.include_tasks: + file: netbox_contact_group.yml + apply: + tags: + - netbox_contact_group + tags: + - netbox_contact_group + - name: NETBOX_CONTACT_ROLE TESTS ansible.builtin.include_tasks: netbox_contact_role.yml diff --git a/tests/integration/targets/v4.1/tasks/netbox_contact.yml b/tests/integration/targets/v4.1/tasks/netbox_contact.yml index f5ede9c1a..291bd6f04 100644 --- a/tests/integration/targets/v4.1/tasks/netbox_contact.yml +++ b/tests/integration/targets/v4.1/tasks/netbox_contact.yml @@ -98,3 +98,46 @@ - test_five['contact']['phone'] == "12345678" - test_five['contact']['tags'] | length == 3 - test_five['msg'] == "contact Contact ABC created" + +- name: 6 Setup - Create contact group + netbox.netbox.netbox_contact_group: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Contact Group With Contacts + register: test_group + +- name: 6 - Create contact with contact group + netbox.netbox.netbox_contact: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Grouped Contact 1 + contact_group: Contact Group With Contacts + register: test_six + +- name: 6 - ASSERT + ansible.builtin.assert: + that: + - test_six is changed + - test_six['diff']['before']['state'] == "absent" + - test_six['diff']['after']['state'] == "present" + - test_six['contact']['name'] == "Grouped Contact 1" + - test_six['contact']['group'] == test_group['contact_group']['id'] + - test_six['msg'] == "contact Grouped Contact 1 created" + +- name: 7 - Try to create contact using contact_groups + netbox.netbox.netbox_contact: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Grouped Contact 2 + contact_groups: + - Contact Group With Contacts + register: test_seven + ignore_errors: true + +- name: 7 - ASSERT + ansible.builtin.assert: + that: + - "'contact_groups is not available in Netbox 4.1. Use contact_group instead, or upgrade to Netbox 4.3 or greater.' in test_seven['module_stderr']" diff --git a/tests/integration/targets/v4.1/tasks/netbox_contact_group.yml b/tests/integration/targets/v4.1/tasks/netbox_contact_group.yml new file mode 100644 index 000000000..090d880a0 --- /dev/null +++ b/tests/integration/targets/v4.1/tasks/netbox_contact_group.yml @@ -0,0 +1,119 @@ +--- +## +## +### NETBOX_CONTACT_GROUP +## +## +- name: 1 - Test contact group creation + netbox.netbox.netbox_contact_group: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Contact Group 1 + register: test_one + +- name: 1 - ASSERT + ansible.builtin.assert: + that: + - test_one is changed + - test_one['diff']['before']['state'] == "absent" + - test_one['diff']['after']['state'] == "present" + - test_one['contact_group']['name'] == "Contact Group 1" + - test_one['msg'] == "contact_group Contact Group 1 created" + +- name: Test duplicate contact group + netbox.netbox.netbox_contact_group: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Contact Group 1 + register: test_two + +- name: 2 - ASSERT + ansible.builtin.assert: + that: + - not test_two['changed'] + - test_two['contact_group']['name'] == "Contact Group 1" + - test_two['msg'] == "contact_group Contact Group 1 already exists" + +- name: 3 - Test update + netbox.netbox.netbox_contact_group: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Contact Group 1 + description: The first contact group + register: test_three + +- name: 3 - ASSERT + ansible.builtin.assert: + that: + - test_three is changed + - test_three['diff']['after']['description'] == "The first contact group" + - test_three['contact_group']['name'] == "Contact Group 1" + - test_three['contact_group']['description'] == "The first contact group" + - test_three['msg'] == "contact_group Contact Group 1 updated" + +- name: 4 - Test delete + netbox.netbox.netbox_contact_group: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Contact Group 1 + state: absent + register: test_four + +- name: 4 - ASSERT + ansible.builtin.assert: + that: + - test_four is changed + - test_four['diff']['before']['state'] == "present" + - test_four['diff']['after']['state'] == "absent" + - test_four['msg'] == "contact_group Contact Group 1 deleted" + +- name: 5 - Create contact group with all parameters + netbox.netbox.netbox_contact_group: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Contact Group Parent + slug: the-parent-contact-group + description: The parent contact group + tags: + - tagA + - tagB + - tagC + state: present + register: test_five + +- name: 5 - ASSERT + ansible.builtin.assert: + that: + - test_five is changed + - test_five['diff']['before']['state'] == "absent" + - test_five['diff']['after']['state'] == "present" + - test_five['contact_group']['name'] == "Contact Group Parent" + - test_five['contact_group']['slug'] == "the-parent-contact-group" + - test_five['contact_group']['description'] == "The parent contact group" + - test_five['contact_group']['tags'] | length == 3 + - test_five['msg'] == "contact_group Contact Group Parent created" + +- name: 6 - Create contact group with parent contact group + netbox.netbox.netbox_contact_group: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Contact Group Child + parent_contact_group: Contact Group Parent + state: present + register: test_six + +- name: 6 - ASSERT + ansible.builtin.assert: + that: + - test_six is changed + - test_six['diff']['before']['state'] == "absent" + - test_six['diff']['after']['state'] == "present" + - test_six['contact_group']['name'] == "Contact Group Child" + - test_six['contact_group']['parent'] == test_five['contact_group']['id'] + - test_six['msg'] == "contact_group Contact Group Child created" diff --git a/tests/integration/targets/v4.1/tasks/netbox_permission.yml b/tests/integration/targets/v4.1/tasks/netbox_permission.yml index 865991142..4a785ce60 100644 --- a/tests/integration/targets/v4.1/tasks/netbox_permission.yml +++ b/tests/integration/targets/v4.1/tasks/netbox_permission.yml @@ -115,7 +115,7 @@ ansible.builtin.assert: that: - test_five is changed - - test_five['user_group']['permissions'] == [1] + - test_five['user_group']['permissions'] == [test_one['permission']['id']] - name: "PERMISSION 6: Add permission to user" netbox.netbox.netbox_user: @@ -123,7 +123,7 @@ netbox_token: "0123456789abcdef0123456789abcdef01234567" data: username: TestUser - password: TestPassword2 + password: TestPassword6 permissions: - Test Permission 2 state: present @@ -133,7 +133,7 @@ ansible.builtin.assert: that: - test_six is changed - - test_six['user']['permissions'] == [2] + - test_six['user']['permissions'] == [test_four['permission']['id']] - name: "PERMISSION 7: Delete" netbox.netbox.netbox_permission: @@ -167,3 +167,48 @@ - not test_eight['changed'] - test_eight['permission'] == None - test_eight['msg'] == "permission Test Permission already absent" + +- name: "PERMISSION 9: Necessary permission" + netbox.netbox.netbox_permission: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test Permission + description: The test permission + enabled: true + actions: + - view + - add + - change + - delete + - extreme_administration + object_types: + - vpn.tunneltermination + - wireless.wirelesslan + state: present + +- name: "PERMISSION 9: Re-create permission with lists in wrong order" + netbox.netbox.netbox_permission: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test Permission + description: The test permission + enabled: true + actions: + - extreme_administration + - delete + - change + - add + - view + object_types: + - wireless.wirelesslan + - vpn.tunneltermination + state: present + register: test_nine + +- name: "PERMISSION 9: ASSERT - The same lists in a new order do not update the permission" + ansible.builtin.assert: + that: + - not test_nine['changed'] + # actions and object_types seem to be ordered randomly so we cannot test them here diff --git a/tests/integration/targets/v4.1/tasks/netbox_token.yml b/tests/integration/targets/v4.1/tasks/netbox_token.yml index a602883fe..e8b2aa165 100644 --- a/tests/integration/targets/v4.1/tasks/netbox_token.yml +++ b/tests/integration/targets/v4.1/tasks/netbox_token.yml @@ -12,6 +12,7 @@ username: TestUser password: TestPassword2 state: present + register: test_user - name: "TOKEN 1: Necessary info creation" netbox.netbox.netbox_token: @@ -29,7 +30,7 @@ - test_one is changed - test_one['diff']['before']['state'] == "absent" - test_one['diff']['after']['state'] == "present" - - test_one['token']['user'] == 3 + - test_one['token']['user'] == test_user['user']['id'] - test_one['msg'] == "token ******** created" - name: "TOKEN 2: Create duplicate" diff --git a/tests/integration/targets/v4.1/tasks/netbox_user.yml b/tests/integration/targets/v4.1/tasks/netbox_user.yml index 360ba6c31..62b35e563 100644 --- a/tests/integration/targets/v4.1/tasks/netbox_user.yml +++ b/tests/integration/targets/v4.1/tasks/netbox_user.yml @@ -14,7 +14,7 @@ state: present register: test_one -- name: "USESR 1: ASSERT - Necessary info creation" +- name: "USER 1: ASSERT - Necessary info creation" ansible.builtin.assert: that: - test_one is changed @@ -48,7 +48,7 @@ netbox_token: "0123456789abcdef0123456789abcdef01234567" data: username: TestUser - password: TestPassword1 + password: TestPassword3 email: test@user.com first_name: Test last_name: User @@ -88,7 +88,7 @@ - test_four['diff']['after']['state'] == "absent" - test_four['msg'] == "user TestUser deleted" -- name: "USER 5: ASSERT - Delete non existing" +- name: "USER 5: Delete non existing" netbox.netbox.netbox_user: netbox_url: http://localhost:32768 netbox_token: "0123456789abcdef0123456789abcdef01234567" @@ -103,3 +103,100 @@ - not test_five['changed'] - test_five['user'] == None - test_five['msg'] == "user TestUser already absent" + +- name: "USER 6: Necessary group 1" + netbox.netbox.netbox_user_group: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test User Group Alpha + state: present + register: user_group_alpha + +- name: "USER 6: Necessary group 2" + netbox.netbox.netbox_user_group: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test User Group Beta + state: present + register: user_group_beta + +- name: "User 6: Necessary permission 1" + netbox.netbox.netbox_permission: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test Permission Foo + actions: + - view + object_types: [] + state: present + register: permission_foo + +- name: "User 6: Necessary permission 2" + netbox.netbox.netbox_permission: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test Permission Bar + actions: + - view + object_types: [] + state: present + register: permission_bar + +- name: "User 6: Necessary permission 3" + netbox.netbox.netbox_permission: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test Permission Baz + actions: + - view + object_types: [] + state: present + register: permission_baz + +- name: "USER 6: Set up user with multiple groups and permissions" + netbox.netbox.netbox_user: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + username: TestUser2 + password: TestPassword2 + permissions: + - Test Permission Foo + - Test Permission Bar + - Test Permission Baz + groups: + - Test User Group Alpha + - Test User Group Beta + state: present + +- name: "USER 6: Re-create user with lists in wrong order" + netbox.netbox.netbox_user: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + username: TestUser2 + permissions: + - Test Permission Bar + - Test Permission Baz + - Test Permission Foo + groups: + - Test User Group Beta + - Test User Group Alpha + state: present + register: test_six + +- name: "USER 6: ASSERT - The same lists in a new order do not update the user" + ansible.builtin.assert: + that: + - not test_six['changed'] + - test_six['msg'] == "user TestUser2 already exists" + - test_six['user']['groups'][0] == user_group_alpha['user_group']['id'] + - test_six['user']['groups'][1] == user_group_beta['user_group']['id'] + - test_six['user']['permissions'][0] == permission_foo['permission']['id'] + - test_six['user']['permissions'][1] == permission_bar['permission']['id'] + - test_six['user']['permissions'][2] == permission_baz['permission']['id'] diff --git a/tests/integration/targets/v4.1/tasks/netbox_user_group.yml b/tests/integration/targets/v4.1/tasks/netbox_user_group.yml index 03dfbe5e0..0bedc95fb 100644 --- a/tests/integration/targets/v4.1/tasks/netbox_user_group.yml +++ b/tests/integration/targets/v4.1/tasks/netbox_user_group.yml @@ -81,7 +81,7 @@ netbox_token: "0123456789abcdef0123456789abcdef01234567" data: username: TestUser - password: TestPassword2 + password: TestPassword5 groups: - Test User Group state: present @@ -91,7 +91,7 @@ ansible.builtin.assert: that: - test_five is changed - - test_five['user']['groups'] == [1] + - test_five['user']['groups'] == [test_one['user_group']['id']] - name: "USER_GROUP 6: Delete" netbox.netbox.netbox_user_group: @@ -125,3 +125,57 @@ - not test_seven['changed'] - test_seven['user_group'] == None - test_seven['msg'] == "user_group Test User Group already absent" + +- name: "USER_GROUP 8: Necessary permission 1" + netbox.netbox.netbox_permission: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test Permission Foo + actions: + - view + object_types: [] + state: present + register: permission_foo + +- name: "USER_GROUP 8: Necessary permission 2" + netbox.netbox.netbox_permission: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test Permission Bar + actions: + - view + object_types: [] + state: present + register: permission_bar + +- name: "USER_GROUP 8: Necessary info creation" + netbox.netbox.netbox_user_group: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test User Group + permissions: + - Test Permission Foo + - Test Permission Bar + state: present + +- name: "USER_GROUP 8: Re-create user group with permissions in wrong order" + netbox.netbox.netbox_user_group: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test User Group + permissions: + - Test Permission Bar + - Test Permission Foo + state: present + register: test_eight + +- name: "USER_GROUP 8: ASSERT - The same permissions in a new order do not update the group" + ansible.builtin.assert: + that: + - not test_eight is changed + - test_eight['user_group']['permissions'][0] == permission_foo['permission']['id'] + - test_eight['user_group']['permissions'][1] == permission_bar['permission']['id'] diff --git a/tests/integration/targets/v4.2/tasks/main.yml b/tests/integration/targets/v4.2/tasks/main.yml index 33ce77bcf..c37909af6 100644 --- a/tests/integration/targets/v4.2/tasks/main.yml +++ b/tests/integration/targets/v4.2/tasks/main.yml @@ -71,6 +71,15 @@ tags: - netbox_contact +- name: NETBOX_CONTACT_GROUP TESTS + ansible.builtin.include_tasks: + file: netbox_contact_group.yml + apply: + tags: + - netbox_contact_group + tags: + - netbox_contact_group + - name: NETBOX_CONTACT_ROLE TESTS ansible.builtin.include_tasks: file: netbox_contact_role.yml diff --git a/tests/integration/targets/v4.2/tasks/netbox_circuit_termination.yml b/tests/integration/targets/v4.2/tasks/netbox_circuit_termination.yml index cbc749f63..953905f16 100644 --- a/tests/integration/targets/v4.2/tasks/netbox_circuit_termination.yml +++ b/tests/integration/targets/v4.2/tasks/netbox_circuit_termination.yml @@ -4,6 +4,25 @@ ### NETBOX_CIRCUIT_TERMINATION ## ## +- name: "NETBOX_CIRCUIT_TERMINATION 0: Create provider network within NetBox with only required information" + netbox.netbox.netbox_provider_network: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + provider: Test Provider + name: Test Provider Network One + state: present + register: test_one + +- name: "NETBOX_CIRCUIT_TERMINATION 0: ASSERT - Necessary info creation" + ansible.builtin.assert: + that: + - test_one is changed + - test_one['diff']['before']['state'] == "absent" + - test_one['diff']['after']['state'] == "present" + - test_one['provider_network']['name'] == "Test Provider Network One" + - test_one['msg'] == "provider_network Test Provider Network One created" + - name: "NETBOX_CIRCUIT_TERMINATION 1: Create provider within NetBox with only required information" netbox.netbox.netbox_circuit_termination: netbox_url: http://localhost:32768 @@ -11,7 +30,8 @@ data: circuit: Test Circuit term_side: A - site: Test Site + termination_id: 2 + termination_type: circuits.providernetwork port_speed: 10000 state: present register: test_one @@ -22,9 +42,10 @@ - test_one is changed - test_one['diff']['before']['state'] == "absent" - test_one['diff']['after']['state'] == "present" + - test_one['circuit_termination']['termination_type'] == "circuits.providernetwork" + - test_one['circuit_termination']['termination_id'] == 2 - test_one['circuit_termination']['circuit'] == 1 - test_one['circuit_termination']['term_side'] == "A" - - test_one['circuit_termination']['site'] == 1 - test_one['circuit_termination']['port_speed'] == 10000 - test_one['msg'] == "circuit_termination test_circuit_a created" @@ -42,9 +63,10 @@ ansible.builtin.assert: that: - not test_two['changed'] + - test_one['circuit_termination']['termination_type'] == "circuits.providernetwork" + - test_one['circuit_termination']['termination_id'] == 2 - test_two['circuit_termination']['circuit'] == 1 - test_two['circuit_termination']['term_side'] == "A" - - test_two['circuit_termination']['site'] == 1 - test_two['circuit_termination']['port_speed'] == 10000 - test_two['msg'] == "circuit_termination test_circuit_a already exists" @@ -66,13 +88,14 @@ ansible.builtin.assert: that: - test_three is changed + - test_one['circuit_termination']['termination_type'] == "circuits.providernetwork" + - test_one['circuit_termination']['termination_id'] == 2 - test_three['diff']['after']['upstream_speed'] == 1000 - test_three['diff']['after']['xconnect_id'] == "10X100" - test_three['diff']['after']['pp_info'] == "PP10-24" - test_three['diff']['after']['description'] == "Test description" - test_three['circuit_termination']['circuit'] == 1 - test_three['circuit_termination']['term_side'] == "A" - - test_three['circuit_termination']['site'] == 1 - test_three['circuit_termination']['port_speed'] == 10000 - test_three['circuit_termination']['upstream_speed'] == 1000 - test_three['circuit_termination']['xconnect_id'] == "10X100" @@ -87,7 +110,8 @@ data: circuit: Test Circuit term_side: Z - site: Test Site + termination_id: 2 + termination_type: circuits.providernetwork port_speed: 10000 state: present register: test_four @@ -98,9 +122,10 @@ - test_four is changed - test_four['diff']['before']['state'] == "absent" - test_four['diff']['after']['state'] == "present" + - test_one['circuit_termination']['termination_type'] == "circuits.providernetwork" + - test_one['circuit_termination']['termination_id'] == 2 - test_four['circuit_termination']['circuit'] == 1 - test_four['circuit_termination']['term_side'] == "Z" - - test_four['circuit_termination']['site'] == 1 - test_four['circuit_termination']['port_speed'] == 10000 - test_four['msg'] == "circuit_termination test_circuit_z created" @@ -120,10 +145,11 @@ - test_five is changed - test_five['circuit_termination']['circuit'] == 1 - test_five['circuit_termination']['term_side'] == "A" - - test_five['circuit_termination']['site'] == 1 - test_five['circuit_termination']['port_speed'] == 10000 - test_five['circuit_termination']['upstream_speed'] == 1000 - test_five['circuit_termination']['xconnect_id'] == "10X100" - test_five['circuit_termination']['pp_info'] == "PP10-24" - test_five['circuit_termination']['description'] == "Test description" + - test_one['circuit_termination']['termination_type'] == "circuits.providernetwork" + - test_one['circuit_termination']['termination_id'] == 2 - test_five['msg'] == "circuit_termination test_circuit_a deleted" diff --git a/tests/integration/targets/v4.2/tasks/netbox_contact.yml b/tests/integration/targets/v4.2/tasks/netbox_contact.yml index f5ede9c1a..75f5f1719 100644 --- a/tests/integration/targets/v4.2/tasks/netbox_contact.yml +++ b/tests/integration/targets/v4.2/tasks/netbox_contact.yml @@ -98,3 +98,46 @@ - test_five['contact']['phone'] == "12345678" - test_five['contact']['tags'] | length == 3 - test_five['msg'] == "contact Contact ABC created" + +- name: 6 Setup - Create contact group + netbox.netbox.netbox_contact_group: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Contact Group With Contacts + register: test_group + +- name: 6 - Create contact with contact group + netbox.netbox.netbox_contact: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Grouped Contact 1 + contact_group: Contact Group With Contacts + register: test_six + +- name: 6 - ASSERT + ansible.builtin.assert: + that: + - test_six is changed + - test_six['diff']['before']['state'] == "absent" + - test_six['diff']['after']['state'] == "present" + - test_six['contact']['name'] == "Grouped Contact 1" + - test_six['contact']['group'] == test_group['contact_group']['id'] + - test_six['msg'] == "contact Grouped Contact 1 created" + +- name: 7 - Try to create contact using contact_groups + netbox.netbox.netbox_contact: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Grouped Contact 2 + contact_groups: + - Contact Group With Contacts + register: test_seven + ignore_errors: true + +- name: 7 - ASSERT + ansible.builtin.assert: + that: + - "'contact_groups is not available in Netbox 4.2. Use contact_group instead, or upgrade to Netbox 4.3 or greater.' in test_seven['module_stderr']" diff --git a/tests/integration/targets/v4.2/tasks/netbox_contact_group.yml b/tests/integration/targets/v4.2/tasks/netbox_contact_group.yml new file mode 100644 index 000000000..090d880a0 --- /dev/null +++ b/tests/integration/targets/v4.2/tasks/netbox_contact_group.yml @@ -0,0 +1,119 @@ +--- +## +## +### NETBOX_CONTACT_GROUP +## +## +- name: 1 - Test contact group creation + netbox.netbox.netbox_contact_group: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Contact Group 1 + register: test_one + +- name: 1 - ASSERT + ansible.builtin.assert: + that: + - test_one is changed + - test_one['diff']['before']['state'] == "absent" + - test_one['diff']['after']['state'] == "present" + - test_one['contact_group']['name'] == "Contact Group 1" + - test_one['msg'] == "contact_group Contact Group 1 created" + +- name: Test duplicate contact group + netbox.netbox.netbox_contact_group: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Contact Group 1 + register: test_two + +- name: 2 - ASSERT + ansible.builtin.assert: + that: + - not test_two['changed'] + - test_two['contact_group']['name'] == "Contact Group 1" + - test_two['msg'] == "contact_group Contact Group 1 already exists" + +- name: 3 - Test update + netbox.netbox.netbox_contact_group: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Contact Group 1 + description: The first contact group + register: test_three + +- name: 3 - ASSERT + ansible.builtin.assert: + that: + - test_three is changed + - test_three['diff']['after']['description'] == "The first contact group" + - test_three['contact_group']['name'] == "Contact Group 1" + - test_three['contact_group']['description'] == "The first contact group" + - test_three['msg'] == "contact_group Contact Group 1 updated" + +- name: 4 - Test delete + netbox.netbox.netbox_contact_group: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Contact Group 1 + state: absent + register: test_four + +- name: 4 - ASSERT + ansible.builtin.assert: + that: + - test_four is changed + - test_four['diff']['before']['state'] == "present" + - test_four['diff']['after']['state'] == "absent" + - test_four['msg'] == "contact_group Contact Group 1 deleted" + +- name: 5 - Create contact group with all parameters + netbox.netbox.netbox_contact_group: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Contact Group Parent + slug: the-parent-contact-group + description: The parent contact group + tags: + - tagA + - tagB + - tagC + state: present + register: test_five + +- name: 5 - ASSERT + ansible.builtin.assert: + that: + - test_five is changed + - test_five['diff']['before']['state'] == "absent" + - test_five['diff']['after']['state'] == "present" + - test_five['contact_group']['name'] == "Contact Group Parent" + - test_five['contact_group']['slug'] == "the-parent-contact-group" + - test_five['contact_group']['description'] == "The parent contact group" + - test_five['contact_group']['tags'] | length == 3 + - test_five['msg'] == "contact_group Contact Group Parent created" + +- name: 6 - Create contact group with parent contact group + netbox.netbox.netbox_contact_group: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Contact Group Child + parent_contact_group: Contact Group Parent + state: present + register: test_six + +- name: 6 - ASSERT + ansible.builtin.assert: + that: + - test_six is changed + - test_six['diff']['before']['state'] == "absent" + - test_six['diff']['after']['state'] == "present" + - test_six['contact_group']['name'] == "Contact Group Child" + - test_six['contact_group']['parent'] == test_five['contact_group']['id'] + - test_six['msg'] == "contact_group Contact Group Child created" diff --git a/tests/integration/targets/v4.2/tasks/netbox_permission.yml b/tests/integration/targets/v4.2/tasks/netbox_permission.yml index 865991142..4a785ce60 100644 --- a/tests/integration/targets/v4.2/tasks/netbox_permission.yml +++ b/tests/integration/targets/v4.2/tasks/netbox_permission.yml @@ -115,7 +115,7 @@ ansible.builtin.assert: that: - test_five is changed - - test_five['user_group']['permissions'] == [1] + - test_five['user_group']['permissions'] == [test_one['permission']['id']] - name: "PERMISSION 6: Add permission to user" netbox.netbox.netbox_user: @@ -123,7 +123,7 @@ netbox_token: "0123456789abcdef0123456789abcdef01234567" data: username: TestUser - password: TestPassword2 + password: TestPassword6 permissions: - Test Permission 2 state: present @@ -133,7 +133,7 @@ ansible.builtin.assert: that: - test_six is changed - - test_six['user']['permissions'] == [2] + - test_six['user']['permissions'] == [test_four['permission']['id']] - name: "PERMISSION 7: Delete" netbox.netbox.netbox_permission: @@ -167,3 +167,48 @@ - not test_eight['changed'] - test_eight['permission'] == None - test_eight['msg'] == "permission Test Permission already absent" + +- name: "PERMISSION 9: Necessary permission" + netbox.netbox.netbox_permission: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test Permission + description: The test permission + enabled: true + actions: + - view + - add + - change + - delete + - extreme_administration + object_types: + - vpn.tunneltermination + - wireless.wirelesslan + state: present + +- name: "PERMISSION 9: Re-create permission with lists in wrong order" + netbox.netbox.netbox_permission: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test Permission + description: The test permission + enabled: true + actions: + - extreme_administration + - delete + - change + - add + - view + object_types: + - wireless.wirelesslan + - vpn.tunneltermination + state: present + register: test_nine + +- name: "PERMISSION 9: ASSERT - The same lists in a new order do not update the permission" + ansible.builtin.assert: + that: + - not test_nine['changed'] + # actions and object_types seem to be ordered randomly so we cannot test them here diff --git a/tests/integration/targets/v4.2/tasks/netbox_service.yml b/tests/integration/targets/v4.2/tasks/netbox_service.yml index d937e50a6..fb6ab5fb7 100644 --- a/tests/integration/targets/v4.2/tasks/netbox_service.yml +++ b/tests/integration/targets/v4.2/tasks/netbox_service.yml @@ -178,7 +178,7 @@ netbox_token: "0123456789abcdef0123456789abcdef01234567" data: virtual_machine: test100-vm - name: node-exporter + name: node-exporter-vm port: 9100 protocol: TCP state: present @@ -188,9 +188,9 @@ ansible.builtin.assert: that: - test_service_create_vm is changed - - test_service_create_vm['services']['name'] == "node-exporter" + - test_service_create_vm['services']['name'] == "node-exporter-vm" - test_service_create_vm['services']['ports'] == [9100] - test_service_create_vm['services']['protocol'] == "tcp" - test_service_create_vm['diff']['after']['state'] == "present" - test_service_create_vm['diff']['before']['state'] == "absent" - - test_service_create_vm['msg'] == "services node-exporter created" + - test_service_create_vm['msg'] == "services node-exporter-vm created" diff --git a/tests/integration/targets/v4.2/tasks/netbox_tag.yml b/tests/integration/targets/v4.2/tasks/netbox_tag.yml index f3fcbac39..636d163e1 100644 --- a/tests/integration/targets/v4.2/tasks/netbox_tag.yml +++ b/tests/integration/targets/v4.2/tasks/netbox_tag.yml @@ -12,6 +12,8 @@ name: Test Tag 1 description: Tag 1 test color: "0000ff" + object_types: + - ipam.prefix state: present register: test_one @@ -25,6 +27,7 @@ - test_one['tags']['description'] == "Tag 1 test" - test_one['tags']['name'] == "Test Tag 1" - test_one['tags']['slug'] == "test-tag-1" + - test_one['tags']['object_types'][0] == "ipam.prefix" - test_one['msg'] == "tags Test Tag 1 created" - name: "TAG 2: Create duplicate" @@ -53,6 +56,8 @@ name: Test Tag 1 description: Tag 1 update test color: "00ff00" + object_types: + - ipam.asn state: present register: test_three @@ -65,6 +70,7 @@ - test_three['tags']['name'] == "Test Tag 1" - test_three['tags']['description'] == "Tag 1 update test" - test_three['tags']['color'] == "00ff00" + - test_three['tags']['object_types'][0] == "ipam.asn" - test_three['msg'] == "tags Test Tag 1 updated" - name: "TAG 4: ASSERT - Delete" diff --git a/tests/integration/targets/v4.2/tasks/netbox_token.yml b/tests/integration/targets/v4.2/tasks/netbox_token.yml index a602883fe..e8b2aa165 100644 --- a/tests/integration/targets/v4.2/tasks/netbox_token.yml +++ b/tests/integration/targets/v4.2/tasks/netbox_token.yml @@ -12,6 +12,7 @@ username: TestUser password: TestPassword2 state: present + register: test_user - name: "TOKEN 1: Necessary info creation" netbox.netbox.netbox_token: @@ -29,7 +30,7 @@ - test_one is changed - test_one['diff']['before']['state'] == "absent" - test_one['diff']['after']['state'] == "present" - - test_one['token']['user'] == 3 + - test_one['token']['user'] == test_user['user']['id'] - test_one['msg'] == "token ******** created" - name: "TOKEN 2: Create duplicate" diff --git a/tests/integration/targets/v4.2/tasks/netbox_user.yml b/tests/integration/targets/v4.2/tasks/netbox_user.yml index 360ba6c31..62b35e563 100644 --- a/tests/integration/targets/v4.2/tasks/netbox_user.yml +++ b/tests/integration/targets/v4.2/tasks/netbox_user.yml @@ -14,7 +14,7 @@ state: present register: test_one -- name: "USESR 1: ASSERT - Necessary info creation" +- name: "USER 1: ASSERT - Necessary info creation" ansible.builtin.assert: that: - test_one is changed @@ -48,7 +48,7 @@ netbox_token: "0123456789abcdef0123456789abcdef01234567" data: username: TestUser - password: TestPassword1 + password: TestPassword3 email: test@user.com first_name: Test last_name: User @@ -88,7 +88,7 @@ - test_four['diff']['after']['state'] == "absent" - test_four['msg'] == "user TestUser deleted" -- name: "USER 5: ASSERT - Delete non existing" +- name: "USER 5: Delete non existing" netbox.netbox.netbox_user: netbox_url: http://localhost:32768 netbox_token: "0123456789abcdef0123456789abcdef01234567" @@ -103,3 +103,100 @@ - not test_five['changed'] - test_five['user'] == None - test_five['msg'] == "user TestUser already absent" + +- name: "USER 6: Necessary group 1" + netbox.netbox.netbox_user_group: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test User Group Alpha + state: present + register: user_group_alpha + +- name: "USER 6: Necessary group 2" + netbox.netbox.netbox_user_group: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test User Group Beta + state: present + register: user_group_beta + +- name: "User 6: Necessary permission 1" + netbox.netbox.netbox_permission: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test Permission Foo + actions: + - view + object_types: [] + state: present + register: permission_foo + +- name: "User 6: Necessary permission 2" + netbox.netbox.netbox_permission: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test Permission Bar + actions: + - view + object_types: [] + state: present + register: permission_bar + +- name: "User 6: Necessary permission 3" + netbox.netbox.netbox_permission: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test Permission Baz + actions: + - view + object_types: [] + state: present + register: permission_baz + +- name: "USER 6: Set up user with multiple groups and permissions" + netbox.netbox.netbox_user: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + username: TestUser2 + password: TestPassword2 + permissions: + - Test Permission Foo + - Test Permission Bar + - Test Permission Baz + groups: + - Test User Group Alpha + - Test User Group Beta + state: present + +- name: "USER 6: Re-create user with lists in wrong order" + netbox.netbox.netbox_user: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + username: TestUser2 + permissions: + - Test Permission Bar + - Test Permission Baz + - Test Permission Foo + groups: + - Test User Group Beta + - Test User Group Alpha + state: present + register: test_six + +- name: "USER 6: ASSERT - The same lists in a new order do not update the user" + ansible.builtin.assert: + that: + - not test_six['changed'] + - test_six['msg'] == "user TestUser2 already exists" + - test_six['user']['groups'][0] == user_group_alpha['user_group']['id'] + - test_six['user']['groups'][1] == user_group_beta['user_group']['id'] + - test_six['user']['permissions'][0] == permission_foo['permission']['id'] + - test_six['user']['permissions'][1] == permission_bar['permission']['id'] + - test_six['user']['permissions'][2] == permission_baz['permission']['id'] diff --git a/tests/integration/targets/v4.2/tasks/netbox_user_group.yml b/tests/integration/targets/v4.2/tasks/netbox_user_group.yml index 03dfbe5e0..0bedc95fb 100644 --- a/tests/integration/targets/v4.2/tasks/netbox_user_group.yml +++ b/tests/integration/targets/v4.2/tasks/netbox_user_group.yml @@ -81,7 +81,7 @@ netbox_token: "0123456789abcdef0123456789abcdef01234567" data: username: TestUser - password: TestPassword2 + password: TestPassword5 groups: - Test User Group state: present @@ -91,7 +91,7 @@ ansible.builtin.assert: that: - test_five is changed - - test_five['user']['groups'] == [1] + - test_five['user']['groups'] == [test_one['user_group']['id']] - name: "USER_GROUP 6: Delete" netbox.netbox.netbox_user_group: @@ -125,3 +125,57 @@ - not test_seven['changed'] - test_seven['user_group'] == None - test_seven['msg'] == "user_group Test User Group already absent" + +- name: "USER_GROUP 8: Necessary permission 1" + netbox.netbox.netbox_permission: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test Permission Foo + actions: + - view + object_types: [] + state: present + register: permission_foo + +- name: "USER_GROUP 8: Necessary permission 2" + netbox.netbox.netbox_permission: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test Permission Bar + actions: + - view + object_types: [] + state: present + register: permission_bar + +- name: "USER_GROUP 8: Necessary info creation" + netbox.netbox.netbox_user_group: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test User Group + permissions: + - Test Permission Foo + - Test Permission Bar + state: present + +- name: "USER_GROUP 8: Re-create user group with permissions in wrong order" + netbox.netbox.netbox_user_group: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test User Group + permissions: + - Test Permission Bar + - Test Permission Foo + state: present + register: test_eight + +- name: "USER_GROUP 8: ASSERT - The same permissions in a new order do not update the group" + ansible.builtin.assert: + that: + - not test_eight is changed + - test_eight['user_group']['permissions'][0] == permission_foo['permission']['id'] + - test_eight['user_group']['permissions'][1] == permission_bar['permission']['id'] diff --git a/tests/integration/targets/v4.3/tasks/main.yml b/tests/integration/targets/v4.3/tasks/main.yml new file mode 100644 index 000000000..ed0745caa --- /dev/null +++ b/tests/integration/targets/v4.3/tasks/main.yml @@ -0,0 +1,770 @@ +--- +- name: NETBOX_DEVICE TESTS + ansible.builtin.include_tasks: + file: netbox_device.yml + apply: + tags: + - netbox_device + tags: + - netbox_device + +- name: NETBOX_DEVICE_INTERFACE TESTS + 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: + 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: + file: netbox_ip_address.yml + apply: + tags: + - netbox_ip_address + tags: + - netbox_ip_address + +- name: NETBOX_PREFIX TESTS + ansible.builtin.include_tasks: + file: netbox_prefix.yml + apply: + tags: + - netbox_prefix + tags: + - netbox_prefix + +- name: NETBOX_SITE TESTS + ansible.builtin.include_tasks: + file: netbox_site.yml + apply: + tags: + - netbox_site + tags: + - netbox_site + +- name: NETBOX_SITE_GROUP TESTS + 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: + file: netbox_contact.yml + apply: + tags: + - netbox_contact + tags: + - netbox_contact + +- name: NETBOX_CONTACT_ASSIGNMENT TESTS + ansible.builtin.include_tasks: + file: netbox_contact_assignment.yml + apply: + tags: + - netbox_contact_assignment + tags: + - netbox_contact_assignment + +- name: NETBOX_CONTACT_GROUP TESTS + ansible.builtin.include_tasks: + file: netbox_contact_group.yml + apply: + tags: + - netbox_contact_group + tags: + - netbox_contact_group + +- name: NETBOX_CONTACT_ROLE TESTS + 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: + file: netbox_tenant.yml + apply: + tags: + - netbox_tenant + tags: + - netbox_tenant + +- name: NETBOX_TENTANT_GROUP TESTS + 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: + file: netbox_rack.yml + apply: + tags: + - netbox_rack + tags: + - netbox_rack + +- name: NETBOX_RACK_ROLE TESTS + 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: + file: netbox_location.yml + apply: + tags: + - netbox_location + tags: + - netbox_location + +- name: NETBOX_MANUFACTURER TESTS + ansible.builtin.include_tasks: + file: netbox_manufacturer.yml + apply: + tags: + - netbox_manufacturer + tags: + - netbox_manufacturer + +- name: NETBOX_PLATFORM TESTS + ansible.builtin.include_tasks: + file: netbox_platform.yml + apply: + tags: + - netbox_platform + tags: + - netbox_platform + +- name: NETBOX_DEVICE_TYPE TESTS + 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: + file: netbox_device_role.yml + apply: + tags: + - netbox_device_role + tags: + - netbox_device_role + +- name: NETBOX_IPAM_ROLE TESTS + 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: + file: netbox_vlan_group.yml + apply: + tags: + - netbox_vlan_group + tags: + - netbox_vlan_group + +- name: NETBOX_VLAN TESTS + ansible.builtin.include_tasks: + file: netbox_vlan.yml + apply: + tags: + - netbox_vlan + tags: + - netbox_vlan + +- name: NETBOX_VRF TESTS + ansible.builtin.include_tasks: + file: netbox_vrf.yml + apply: + tags: + - netbox_vrf + tags: + - netbox_vrf + +- name: NETBOX_RIR TESTS + ansible.builtin.include_tasks: + file: netbox_rir.yml + apply: + tags: + - netbox_rir + tags: + - netbox_rir + +- name: NETBOX_AGGREGATE TESTS + ansible.builtin.include_tasks: + file: netbox_aggregate.yml + apply: + tags: + - netbox_aggregate + tags: + - netbox_aggregate + +- name: NETBOX_REGION TESTS + ansible.builtin.include_tasks: + file: netbox_region.yml + apply: + tags: + - netbox_region + tags: + - netbox_region + +- name: NETBOX_DEVICE_BAY TESTS + 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: + 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: + file: netbox_inventory_item.yml + apply: + tags: + - netbox_inventory_item + tags: + - netbox_inventory_item + +- name: NETBOX_VIRTUAL_MACHINE TESTS + ansible.builtin.include_tasks: + file: netbox_virtual_machine.yml + apply: + tags: + - netbox_virtual_machine + tags: + - netbox_virtual_machine + +- name: NETBOX_CLUSTER TESTS + ansible.builtin.include_tasks: + file: netbox_cluster.yml + apply: + tags: + - netbox_cluster + tags: + - netbox_cluster + +- name: NETBOX_CLUSTER_GROUP TESTS + 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: + file: netbox_cluster_type.yml + apply: + tags: + - netbox_cluster_type + tags: + - netbox_cluster_type + +- name: NETBOX_VM_INTERFACE TESTS + 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: + file: netbox_provider.yml + apply: + tags: + - netbox_provider + tags: + - netbox_provider + +- name: NETBOX_PROVIDER_NETWORK TESTS + 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: + file: netbox_circuit_type.yml + apply: + tags: + - netbox_circuit_type + tags: + - netbox_circuit_type + +- name: NETBOX_CIRCUIT TESTS + ansible.builtin.include_tasks: + file: netbox_circuit.yml + apply: + tags: + - netbox_circuit + tags: + - netbox_circuit + +- name: NETBOX_REAR_PORT TESTS + 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: + 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: + file: netbox_front_port.yml + apply: + tags: + - netbox_front_port + tags: + - netbox_front_port + +- name: NETBOX_FRONT_PORT_TEMPLATE TESTS + 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: + file: netbox_console_port.yml + apply: + tags: + - netbox_console_port + tags: + - netbox_console_port + +- name: NETBOX_CONSOLE_PORT_TEMPLATE TESTS + 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: + 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: + 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: + file: netbox_power_panel.yml + apply: + tags: + - netbox_power_panel + tags: + - netbox_power_panel + +- name: NETBOX_POWER_FEED TESTS + 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: + file: netbox_power_port.yml + apply: + tags: + - netbox_power_port + tags: + - netbox_power_port + +- name: NETBOX_POWER_PORT_TEMPLATE TESTS + 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: + file: netbox_power_outlet.yml + apply: + tags: + - netbox_power_outlet + tags: + - netbox_power_outlet + +- name: NETBOX_POWER_OUTLET_TEMPLATE TESTS + 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: + file: netbox_virtual_chassis.yml + apply: + tags: + - netbox_virtual_chassis + tags: + - netbox_virtual_chassis + +- name: NETBOX_USER_TESTS + ansible.builtin.include_tasks: + file: netbox_user.yml + apply: + tags: + - netbox_user + tags: + - netbox_user + +- name: NETBOX_USER_GROUP_TESTS + ansible.builtin.include_tasks: + file: netbox_user_group.yml + apply: + tags: + - netbox_user_group + tags: + - netbox_user_group + +- name: NETBOX_PERMISSION TESTS + ansible.builtin.include_tasks: + file: netbox_permission.yml + apply: + tags: + - netbox_permission + tags: + - netbox_permission + +- name: NETBOX_TOKEN_TESTS + ansible.builtin.include_tasks: + file: netbox_token.yml + apply: + tags: + - netbox_token + tags: + - netbox_token + +# Module has to be updated for 3.3 +# - name: "NETBOX_CABLE TESTS" +# include_tasks: "netbox_cable.yml" + +- name: NETBOX_SERVICE TESTS + ansible.builtin.include_tasks: + file: netbox_service.yml + apply: + tags: + - netbox_service + tags: + - netbox_service + +- name: NETBOX_LOOKUP TESTS + ansible.builtin.include_tasks: + file: netbox_lookup.yml + apply: + tags: + - netbox_lookup + tags: + - netbox_lookup + +- name: NETBOX_TAG_TESTS + ansible.builtin.include_tasks: + file: netbox_tag.yml + apply: + tags: + - netbox_tag + tags: + - netbox_tag + +- name: NETBOX_ROUTE_TARGET_TESTS + ansible.builtin.include_tasks: + file: netbox_route_target.yml + apply: + tags: + - netbox_route_target + tags: + - netbox_route_target + +- name: NETBOX_WIRELESS_LAN TESTS + ansible.builtin.include_tasks: + file: netbox_wireless_lan.yml + apply: + tags: + - netbox_wireless_lan + tags: + - netbox_wireless_lan + +- name: NETBOX_WIRELESS_LAN_GROUP TESTS + ansible.builtin.include_tasks: + file: netbox_wireless_lan_group.yml + apply: + tags: + - netbox_wireless_lan_group + tags: + - netbox_wireless_lan_group + +- name: NETBOX_WIRELESS_LINK TESTS + ansible.builtin.include_tasks: + file: netbox_wireless_link.yml + apply: + tags: + - netbox_wireless_link + tags: + - netbox_wireless_link + +- name: NETBOX_CUSTOM_FIELD TESTS + ansible.builtin.include_tasks: + file: netbox_custom_field.yml + apply: + tags: + - netbox_custom_field + tags: + - netbox_custom_field + +- name: NETBOX_CUSTOM_LINK TESTS + ansible.builtin.include_tasks: + file: netbox_custom_link.yml + apply: + tags: + - netbox_custom_link + tags: + - netbox_custom_link + +- name: NETBOX_EXPORT_TEMPLATE TESTS + ansible.builtin.include_tasks: + file: netbox_export_template.yml + apply: + tags: + - netbox_export_template + tags: + - netbox_export_template + +# Must update for 3.7 +# - name: "NETBOX_WEBHOOK TESTS" +# include_tasks: +# file: "netbox_webhook.yml" +# apply: +# tags: +# - netbox_webhook +# tags: +# - netbox_webhook + +# - name: "NETBOX_L2VPN TESTS" +# include_tasks: +# file: "netbox_l2vpn.yml" +# apply: +# tags: +# - netbox_l2vpn +# tags: +# - netbox_l2vpn + +# - name: "NETBOX_L2VPN_TERMINATION TESTS" +# include_tasks: +# file: "netbox_l2vpn_termination.yml" +# apply: +# tags: +# - netbox_l2vpn_termination +# tags: +# - netbox_l2vpn_termination + +- name: NETBOX_INVENTORY_ITEM_ROLE TESTS + ansible.builtin.include_tasks: + file: netbox_inventory_item_role.yml + apply: + tags: + - netbox_inventory_item_role + tags: + - netbox_inventory_item_role + +- name: NETBOX_MODULE_TYPE TESTS + ansible.builtin.include_tasks: + file: netbox_module_type.yml + apply: + tags: + - netbox_module_type + tags: + - netbox_module_type + +- name: NETBOX_SERVICE_TEMPLATE TESTS + ansible.builtin.include_tasks: + file: netbox_service_template.yml + apply: + tags: + - netbox_service_template + tags: + - netbox_service_template + +- name: NETBOX_ASN TESTS + ansible.builtin.include_tasks: + file: netbox_asn.yml + apply: + tags: + - netbox_asn + tags: + - netbox_asn + +- name: NETBOX_FHRP_GROUP TESTS + 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: + file: netbox_journal_entry.yml + apply: + tags: + - netbox_journal_entry + tags: + - netbox_journal_entry + +- name: NETBOX_FHRP_GROUP_ASSIGNMENT TESTS + ansible.builtin.include_tasks: + file: netbox_fhrp_group_assignment.yml + apply: + tags: + - netbox_fhrp_group_assignmen + tags: + - netbox_fhrp_group_assignmen + +- name: NETBOX_CONFIG_TEMPLATE + ansible.builtin.include_tasks: + file: netbox_config_template.yml + apply: + tags: + - netbox_config_template + tags: + - netbox_config_template + +- name: NETBOX_VIRTUAL_DISK + ansible.builtin.include_tasks: + file: netbox_virtual_disk.yml + apply: + tags: + - netbox_virtual_disk + tags: + - netbox_virtual_disk + +- name: NETBOX_TUNNEL TESTS + ansible.builtin.include_tasks: + file: netbox_tunnel.yml + apply: + tags: + - netbox_tunnel + tags: + - netbox_tunnel + +- name: NETBOX_TUNNEL GROUP TESTS + ansible.builtin.include_tasks: + file: netbox_tunnel_group.yml + apply: + tags: + - netbox_tunnel_group + tags: + - netbox_tunnel_group + +- name: NETBOX_MAC_ADDRESS TESTS + ansible.builtin.include_tasks: + file: netbox_mac_address.yml + apply: + tags: + - netbox_mac_address + tags: + - netbox_mac_address + +- name: NETBOX_CIRCUIT_TERMINATION TESTS + ansible.builtin.include_tasks: + file: netbox_circuit_termination.yml + apply: + tags: + - netbox_circuit_termination + tags: + - netbox_circuit_termination + +- name: NETBOX_DATA_SOURCE TESTS + ansible.builtin.include_tasks: + file: netbox_data_source.yml + apply: + tags: + - netbox_data_source + tags: + - netbox_data_source diff --git a/tests/integration/targets/v4.3/tasks/netbox_aggregate.yml b/tests/integration/targets/v4.3/tasks/netbox_aggregate.yml new file mode 100644 index 000000000..d45b9c835 --- /dev/null +++ b/tests/integration/targets/v4.3/tasks/netbox_aggregate.yml @@ -0,0 +1,115 @@ +--- +## +## +### NETBOX_AGGEGATE +## +## +- name: "AGGREGATE 1: Necessary info creation" + netbox.netbox.netbox_aggregate: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + prefix: 10.0.0.0/8 + rir: Example RIR + state: present + register: test_one + +- name: "AGGREGATE 1: ASSERT - Necessary info creation" + ansible.builtin.assert: + that: + - test_one is changed + - test_one['diff']['before']['state'] == "absent" + - test_one['diff']['after']['state'] == "present" + - test_one['aggregate']['prefix'] == "10.0.0.0/8" + # - test_one['aggregate']['family'] == 4 + - test_one['aggregate']['rir'] == 1 + - test_one['msg'] == "aggregate 10.0.0.0/8 created" + +- name: "AGGREGATE 2: Create duplicate" + netbox.netbox.netbox_aggregate: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + prefix: 10.0.0.0/8 + state: present + register: test_two + +- name: "AGGREGATE 2: ASSERT - Create duplicate" + ansible.builtin.assert: + that: + - not test_two['changed'] + - test_two['aggregate']['prefix'] == "10.0.0.0/8" + - test_two['aggregate']['family'] == 4 + - test_two['aggregate']['rir'] == 1 + - test_two['msg'] == "aggregate 10.0.0.0/8 already exists" + +- name: "AGGREGATE 3: ASSERT - Update" + netbox.netbox.netbox_aggregate: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + prefix: 10.0.0.0/8 + rir: Example RIR + date_added: "1989-01-18" + description: Test Description + tags: + - Schnozzberry + state: present + register: test_three + +- name: "AGGREGATE 3: ASSERT - Updated" + ansible.builtin.assert: + that: + - test_three is changed + - test_three['diff']['after']['date_added'] == "1989-01-18" + - test_three['diff']['after']['description'] == "Test Description" + - test_three['diff']['after']['tags'][0] == 4 + - test_three['aggregate']['prefix'] == "10.0.0.0/8" + - test_three['aggregate']['family'] == 4 + - test_three['aggregate']['rir'] == 1 + - test_three['aggregate']['date_added'] == "1989-01-18" + - test_three['aggregate']['description'] == "Test Description" + - test_three['aggregate']['tags'][0] == 4 + - test_three['msg'] == "aggregate 10.0.0.0/8 updated" + +- name: "AGGREGATE 4: ASSERT - Delete" + netbox.netbox.netbox_aggregate: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + prefix: 10.0.0.0/8 + state: absent + register: test_four + +- name: "AGGREGATE 4: ASSERT - Delete" + ansible.builtin.assert: + that: + - test_four is changed + - test_four['aggregate']['prefix'] == "10.0.0.0/8" + - test_four['aggregate']['family'] == 4 + - test_four['aggregate']['rir'] == 1 + - test_four['aggregate']['date_added'] == "1989-01-18" + - test_four['aggregate']['description'] == "Test Description" + - test_four['aggregate']['tags'][0] == 4 + - test_four['msg'] == "aggregate 10.0.0.0/8 deleted" + +- name: "AGGREGATE 5: Necessary info creation" + netbox.netbox.netbox_aggregate: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + prefix: 2001::/32 + rir: Example RIR + state: present + register: test_five + +- name: "AGGREGATE 5: ASSERT - Necessary info creation" + ansible.builtin.assert: + that: + - test_five is changed + - test_five['diff']['before']['state'] == "absent" + - test_five['diff']['after']['state'] == "present" + - test_five['aggregate']['prefix'] == "2001::/32" + # - test_five['aggregate']['family'] == 6 + - test_five['aggregate']['rir'] == 1 + - test_five['msg'] == "aggregate 2001::/32 created" diff --git a/tests/integration/targets/v4.3/tasks/netbox_asn.yml b/tests/integration/targets/v4.3/tasks/netbox_asn.yml new file mode 100644 index 000000000..fab4270a9 --- /dev/null +++ b/tests/integration/targets/v4.3/tasks/netbox_asn.yml @@ -0,0 +1,88 @@ +--- +## +## +### NETBOX_ASN +## +## +- name: "ASN 1: Test ASN creation" + netbox.netbox.netbox_asn: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + asn: 1111111111 + rir: Example RIR + state: present + register: test_one + +- name: "ASN 1: ASSERT - Necessary info creation" + ansible.builtin.assert: + that: + - test_one is changed + - test_one['diff']['before']['state'] == "absent" + - test_one['diff']['after']['state'] == "present" + - test_one['asn']['asn'] == 1111111111 + - test_one['asn']['rir'] == 1 + - test_one['msg'] == "asn 1111111111 created" + +- name: "ASN 2: Create duplicate" + netbox.netbox.netbox_asn: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + asn: 1111111111 + rir: Example RIR + state: present + register: test_two + +- name: "ASN 2: ASSERT - Create duplicate" + ansible.builtin.assert: + that: + - not test_two['changed'] + - test_two['asn']['asn'] == 1111111111 + - test_two['asn']['rir'] == 1 + - test_two['msg'] == "asn 1111111111 already exists" + +- name: "ASN 3: Update ASN with other fields" + netbox.netbox.netbox_asn: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + asn: 1111111111 + rir: Example RIR + tenant: Test Tenant + description: Test description + tags: + - Schnozzberry + state: present + register: test_three + +- name: "ASN 3: ASSERT - Update ASN with other fields" + ansible.builtin.assert: + that: + - test_three is changed + - test_three['diff']['after']['tenant'] == 1 + - test_three['diff']['after']['description'] == "Test description" + - test_three['diff']['after']['tags'][0] == 4 + - test_three['asn']['asn'] == 1111111111 + - test_three['asn']['rir'] == 1 + - test_three['asn']['tenant'] == 1 + - test_three['asn']['description'] == "Test description" + - test_three['asn']['tags'][0] == 4 + - test_three['msg'] == "asn 1111111111 updated" + +- name: "ASN 4: ASSERT - Delete" + netbox.netbox.netbox_asn: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + asn: 1111111111 + state: absent + register: test_four + +- name: "ASN 4: ASSERT - Delete" + ansible.builtin.assert: + that: + - test_four is changed + - test_four['diff']['before']['state'] == "present" + - test_four['diff']['after']['state'] == "absent" + - test_four['msg'] == "asn 1111111111 deleted" diff --git a/tests/integration/targets/v4.3/tasks/netbox_cable.yml b/tests/integration/targets/v4.3/tasks/netbox_cable.yml new file mode 100644 index 000000000..d6f0ab02e --- /dev/null +++ b/tests/integration/targets/v4.3/tasks/netbox_cable.yml @@ -0,0 +1,193 @@ +--- +# © 2020 Nokia +# Licensed under the GNU General Public License v3.0 only +# SPDX-License-Identifier: GPL-3.0-only +## +## +### NETBOX_CABLE +## +## +- name: "CABLE 1: Necessary info creation" + netbox.netbox.netbox_cable: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + termination_a_type: dcim.interface + termination_a: + device: Test Nexus Child One + name: Ethernet2/2 + termination_b_type: dcim.interface + termination_b: + device: Test Nexus Child One + name: Ethernet2/1 + state: present + register: test_one + +- name: "CABLE 1: ASSERT - Necessary info creation" + ansible.builtin.assert: + that: + - test_one is changed + - test_one['diff']['before']['state'] == "absent" + - test_one['diff']['after']['state'] == "present" + - test_one['cable']['termination_a_type'] == "dcim.interface" + - test_one['cable']['termination_a_id'] == 15 + - test_one['cable']['termination_b_type'] == "dcim.interface" + - test_one['cable']['termination_b_id'] == 2 + - test_one['msg'] == "cable dcim.interface Ethernet2/2 <> dcim.interface Ethernet2/1 created" + +- name: "CABLE 2: Create duplicate" + netbox.netbox.netbox_cable: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + termination_a_type: dcim.interface + termination_a: + device: Test Nexus Child One + name: Ethernet2/2 + termination_b_type: dcim.interface + termination_b: + device: Test Nexus Child One + name: Ethernet2/1 + state: present + register: test_two + +- name: "CABLE 2: ASSERT - Create duplicate" + ansible.builtin.assert: + that: + - not test_two['changed'] + - test_two['cable']['termination_a_type'] == "dcim.interface" + - test_two['cable']['termination_a_id'] == 15 + - test_two['cable']['termination_b_type'] == "dcim.interface" + - test_two['cable']['termination_b_id'] == 2 + - test_two['msg'] == "cable dcim.interface Ethernet2/2 <> dcim.interface Ethernet2/1 already exists" + +- name: "CABLE 3: Update Cable with other fields" + netbox.netbox.netbox_cable: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + termination_a_type: dcim.interface + termination_a: + device: Test Nexus Child One + name: Ethernet2/2 + termination_b_type: dcim.interface + termination_b: + device: Test Nexus Child One + name: Ethernet2/1 + type: mmf-om4 + status: planned + label: label123 + color: abcdef + length: 30 + length_unit: m + tags: + - Schnozzberry + tenant: Test Tenant + state: present + register: test_three + +- name: "CABLE 3: ASSERT - Update Cable with other fields" + ansible.builtin.assert: + that: + - test_three is changed + - test_three['diff']['after']['type'] == "mmf-om4" + - test_three['diff']['after']['status'] == "planned" + - test_three['diff']['after']['label'] == "label123" + - test_three['diff']['after']['color'] == "abcdef" + - test_three['diff']['after']['length'] == 30 + - test_three['diff']['after']['length_unit'] == "m" + - test_three['diff']['after']['tags'][0] == 4 + - test_three['diff']['after']['tenant'] == 1 + - test_three['cable']['termination_a_type'] == "dcim.interface" + - test_three['cable']['termination_a_id'] == 15 + - test_three['cable']['termination_b_type'] == "dcim.interface" + - test_three['cable']['termination_b_id'] == 2 + - test_three['cable']['type'] == "mmf-om4" + - test_three['cable']['status'] == "planned" + - test_three['cable']['label'] == "label123" + - test_three['cable']['color'] == "abcdef" + - test_three['cable']['length'] == 30 + - test_three['cable']['length_unit'] == "m" + - test_three['cable']['tags'][0] == 4 + - test_three['cable']['tenant'] == 1 + - test_three['msg'] == "cable dcim.interface Ethernet2/2 <> dcim.interface Ethernet2/1 updated" + +- name: "CABLE 4: ASSERT - Delete" + netbox.netbox.netbox_cable: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + termination_a_type: dcim.interface + termination_a: + device: Test Nexus Child One + name: Ethernet2/2 + termination_b_type: dcim.interface + termination_b: + device: Test Nexus Child One + name: Ethernet2/1 + state: absent + register: test_four + +- name: "CABLE 4: ASSERT - Delete" + ansible.builtin.assert: + that: + - test_four is changed + - test_four['diff']['before']['state'] == "present" + - test_four['diff']['after']['state'] == "absent" + - test_four['msg'] == "cable dcim.interface Ethernet2/2 <> dcim.interface Ethernet2/1 deleted" + +- name: "CABLE 5: Connect Console Port and Console Server Port" + netbox.netbox.netbox_cable: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + termination_a_type: dcim.consoleserverport + termination_a: + name: Console Server Port + device: test100 + termination_b_type: dcim.consoleport + termination_b: + name: Console Port + device: test100 + state: present + register: test_five + +- name: "CABLE 5: ASSERT - Connect Console Port and Console Server Port" + ansible.builtin.assert: + that: + - test_five is changed + - test_five['diff']['before']['state'] == "absent" + - test_five['diff']['after']['state'] == "present" + - test_five['cable']['termination_a_type'] == "dcim.consoleserverport" + - test_five['cable']['termination_a_id'] == 1 + - test_five['cable']['termination_b_type'] == "dcim.consoleport" + - test_five['cable']['termination_b_id'] == 1 + - test_five['msg'] == "cable dcim.consoleserverport Console Server Port <> dcim.consoleport Console Port created" + +- name: "CABLE 6: Circuits Termination as side A" + netbox.netbox.netbox_cable: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + termination_a_type: circuits.circuittermination + termination_a: + circuit: Test Circuit Two + term_side: A + termination_b_type: dcim.interface + termination_b: + device: test100 + name: GigabitEthernet2 + state: present + register: test_six + +- name: "CABLE 6: ASSERT - Circuits Termination as side A" + ansible.builtin.assert: + that: + - test_six is changed + - test_six['diff']['before']['state'] == "absent" + - test_six['diff']['after']['state'] == "present" + - test_six['cable']['termination_a_type'] == "circuits.circuittermination" + - test_six['cable']['termination_a_id'] == 1 + - test_six['cable']['termination_b_type'] == "dcim.interface" + - test_six['cable']['termination_b_id'] == 4 + - test_six['msg'] == "cable circuits.circuittermination 1 <> dcim.interface GigabitEthernet2 created" diff --git a/tests/integration/targets/v4.3/tasks/netbox_circuit.yml b/tests/integration/targets/v4.3/tasks/netbox_circuit.yml new file mode 100644 index 000000000..8bfd265ac --- /dev/null +++ b/tests/integration/targets/v4.3/tasks/netbox_circuit.yml @@ -0,0 +1,109 @@ +--- +## +## +### NETBOX_CIRCUIT +## +## +- name: "NETBOX_CIRCUIT 1: Create provider within NetBox with only required information" + netbox.netbox.netbox_circuit: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + cid: Test Circuit One + provider: Test Provider + circuit_type: Test Circuit Type + state: present + register: test_one + +- name: "NETBOX_CIRCUIT 1: ASSERT - Necessary info creation" + ansible.builtin.assert: + that: + - test_one is changed + - test_one['diff']['before']['state'] == "absent" + - test_one['diff']['after']['state'] == "present" + - test_one['circuit']['cid'] == "Test Circuit One" + - test_one['circuit']['provider'] == 1 + - test_one['circuit']['type'] == 1 + - test_one['msg'] == "circuit Test Circuit One created" + +- name: "NETBOX_CIRCUIT 2: Duplicate" + netbox.netbox.netbox_circuit: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + cid: Test Circuit One + provider: Test Provider + circuit_type: Test Circuit Type + state: present + register: test_two + +- name: "NETBOX_CIRCUIT 2: ASSERT - Create duplicate" + ansible.builtin.assert: + that: + - not test_two['changed'] + - test_two['circuit']['cid'] == "Test Circuit One" + - test_two['circuit']['provider'] == 1 + - test_two['circuit']['type'] == 1 + - test_two['msg'] == "circuit Test Circuit One already exists" + +- name: "NETBOX_CIRCUIT 3: Update provider with other fields" + netbox.netbox.netbox_circuit: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + cid: Test Circuit One + provider: Test Provider + circuit_type: Test Circuit Type + status: Planned + tenant: Test Tenant + install_date: "2018-12-25" + commit_rate: 10000 + description: "Test circuit " + comments: FAST CIRCUIT + state: present + register: test_three + +- name: "NETBOX_CIRCUIT 3: ASSERT - Updated" + ansible.builtin.assert: + that: + - test_three is changed + - test_three['diff']['after']['status'] == "planned" + - test_three['diff']['after']['tenant'] == 1 + - test_three['diff']['after']['install_date'] == "2018-12-25" + - test_three['diff']['after']['commit_rate'] == 10000 + - test_three['diff']['after']['description'] == "Test circuit" + - test_three['diff']['after']['comments'] == "FAST CIRCUIT" + - test_three['circuit']['cid'] == "Test Circuit One" + - test_three['circuit']['provider'] == 1 + - test_three['circuit']['type'] == 1 + - test_three['circuit']['status'] == "planned" + - test_three['circuit']['tenant'] == 1 + - test_three['circuit']['install_date'] == "2018-12-25" + - test_three['circuit']['commit_rate'] == 10000 + - test_three['circuit']['description'] == "Test circuit" + - test_three['circuit']['comments'] == "FAST CIRCUIT" + - test_three['msg'] == "circuit Test Circuit One updated" + +- name: "NETBOX_CIRCUIT 4: Delete provider within netbox" + netbox.netbox.netbox_circuit: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + cid: Test Circuit One + state: absent + register: test_four + +- name: "NETBOX_CIRCUIT 4 : ASSERT - Delete" + ansible.builtin.assert: + that: + - test_four is changed + - test_four['circuit']['cid'] == "Test Circuit One" + - test_four['circuit']['provider'] == 1 + - test_four['circuit']['type'] == 1 + - test_four['circuit']['status'] == "planned" + - test_four['circuit']['tenant'] == 1 + - test_four['circuit']['install_date'] == "2018-12-25" + - test_four['circuit']['commit_rate'] == 10000 + - test_four['circuit']['description'] == "Test circuit" + - test_four['circuit']['comments'] == "FAST CIRCUIT" + - test_four['msg'] == "circuit Test Circuit One deleted" diff --git a/tests/integration/targets/v4.3/tasks/netbox_circuit_termination.yml b/tests/integration/targets/v4.3/tasks/netbox_circuit_termination.yml new file mode 100644 index 000000000..953905f16 --- /dev/null +++ b/tests/integration/targets/v4.3/tasks/netbox_circuit_termination.yml @@ -0,0 +1,155 @@ +--- +## +## +### NETBOX_CIRCUIT_TERMINATION +## +## +- name: "NETBOX_CIRCUIT_TERMINATION 0: Create provider network within NetBox with only required information" + netbox.netbox.netbox_provider_network: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + provider: Test Provider + name: Test Provider Network One + state: present + register: test_one + +- name: "NETBOX_CIRCUIT_TERMINATION 0: ASSERT - Necessary info creation" + ansible.builtin.assert: + that: + - test_one is changed + - test_one['diff']['before']['state'] == "absent" + - test_one['diff']['after']['state'] == "present" + - test_one['provider_network']['name'] == "Test Provider Network One" + - test_one['msg'] == "provider_network Test Provider Network One created" + +- name: "NETBOX_CIRCUIT_TERMINATION 1: Create provider within NetBox with only required information" + netbox.netbox.netbox_circuit_termination: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + circuit: Test Circuit + term_side: A + termination_id: 2 + termination_type: circuits.providernetwork + port_speed: 10000 + state: present + register: test_one + +- name: "NETBOX_CIRCUIT_TERMINATION 1: ASSERT - Necessary info creation" + ansible.builtin.assert: + that: + - test_one is changed + - test_one['diff']['before']['state'] == "absent" + - test_one['diff']['after']['state'] == "present" + - test_one['circuit_termination']['termination_type'] == "circuits.providernetwork" + - test_one['circuit_termination']['termination_id'] == 2 + - test_one['circuit_termination']['circuit'] == 1 + - test_one['circuit_termination']['term_side'] == "A" + - test_one['circuit_termination']['port_speed'] == 10000 + - test_one['msg'] == "circuit_termination test_circuit_a created" + +- name: "NETBOX_CIRCUIT_TERMINATION 2: Duplicate" + netbox.netbox.netbox_circuit_termination: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + circuit: Test Circuit + term_side: A + state: present + register: test_two + +- name: "NETBOX_CIRCUIT_TERMINATION 2: ASSERT - Create duplicate" + ansible.builtin.assert: + that: + - not test_two['changed'] + - test_one['circuit_termination']['termination_type'] == "circuits.providernetwork" + - test_one['circuit_termination']['termination_id'] == 2 + - test_two['circuit_termination']['circuit'] == 1 + - test_two['circuit_termination']['term_side'] == "A" + - test_two['circuit_termination']['port_speed'] == 10000 + - test_two['msg'] == "circuit_termination test_circuit_a already exists" + +- name: "NETBOX_CIRCUIT_TERMINATION 3: Update provider with other fields" + netbox.netbox.netbox_circuit_termination: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + circuit: Test Circuit + term_side: A + upstream_speed: 1000 + xconnect_id: 10X100 + pp_info: PP10-24 + description: Test description + state: present + register: test_three + +- name: "NETBOX_CIRCUIT_TERMINATION 3: ASSERT - Updated" + ansible.builtin.assert: + that: + - test_three is changed + - test_one['circuit_termination']['termination_type'] == "circuits.providernetwork" + - test_one['circuit_termination']['termination_id'] == 2 + - test_three['diff']['after']['upstream_speed'] == 1000 + - test_three['diff']['after']['xconnect_id'] == "10X100" + - test_three['diff']['after']['pp_info'] == "PP10-24" + - test_three['diff']['after']['description'] == "Test description" + - test_three['circuit_termination']['circuit'] == 1 + - test_three['circuit_termination']['term_side'] == "A" + - test_three['circuit_termination']['port_speed'] == 10000 + - test_three['circuit_termination']['upstream_speed'] == 1000 + - test_three['circuit_termination']['xconnect_id'] == "10X100" + - test_three['circuit_termination']['pp_info'] == "PP10-24" + - test_three['circuit_termination']['description'] == "Test description" + - test_three['msg'] == "circuit_termination test_circuit_a updated" + +- name: "NETBOX_CIRCUIT_TERMINATION 4: Create Z Side" + netbox.netbox.netbox_circuit_termination: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + circuit: Test Circuit + term_side: Z + termination_id: 2 + termination_type: circuits.providernetwork + port_speed: 10000 + state: present + register: test_four + +- name: "NETBOX_CIRCUIT_TERMINATION 4: ASSERT - Create Z Side" + ansible.builtin.assert: + that: + - test_four is changed + - test_four['diff']['before']['state'] == "absent" + - test_four['diff']['after']['state'] == "present" + - test_one['circuit_termination']['termination_type'] == "circuits.providernetwork" + - test_one['circuit_termination']['termination_id'] == 2 + - test_four['circuit_termination']['circuit'] == 1 + - test_four['circuit_termination']['term_side'] == "Z" + - test_four['circuit_termination']['port_speed'] == 10000 + - test_four['msg'] == "circuit_termination test_circuit_z created" + +- name: "NETBOX_CIRCUIT_TERMINATION 5: Delete provider within netbox" + netbox.netbox.netbox_circuit_termination: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + circuit: Test Circuit + term_side: A + state: absent + register: test_five + +- name: "NETBOX_CIRCUIT_TERMINATION 5: ASSERT - Delete" + ansible.builtin.assert: + that: + - test_five is changed + - test_five['circuit_termination']['circuit'] == 1 + - test_five['circuit_termination']['term_side'] == "A" + - test_five['circuit_termination']['port_speed'] == 10000 + - test_five['circuit_termination']['upstream_speed'] == 1000 + - test_five['circuit_termination']['xconnect_id'] == "10X100" + - test_five['circuit_termination']['pp_info'] == "PP10-24" + - test_five['circuit_termination']['description'] == "Test description" + - test_one['circuit_termination']['termination_type'] == "circuits.providernetwork" + - test_one['circuit_termination']['termination_id'] == 2 + - test_five['msg'] == "circuit_termination test_circuit_a deleted" diff --git a/tests/integration/targets/v4.3/tasks/netbox_circuit_type.yml b/tests/integration/targets/v4.3/tasks/netbox_circuit_type.yml new file mode 100644 index 000000000..08dc67985 --- /dev/null +++ b/tests/integration/targets/v4.3/tasks/netbox_circuit_type.yml @@ -0,0 +1,96 @@ +--- +## +## +### NETBOX_CIRCUIT_TYPE +## +## +- name: "CIRCUIT_TYPE 1: Necessary info creation" + netbox.netbox.netbox_circuit_type: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test Circuit Type One + state: present + register: test_one + +- name: "CIRCUIT_TYPE 1: ASSERT - Necessary info creation" + ansible.builtin.assert: + that: + - test_one is changed + - test_one['diff']['before']['state'] == "absent" + - test_one['diff']['after']['state'] == "present" + - test_one['circuit_type']['name'] == "Test Circuit Type One" + - test_one['circuit_type']['slug'] == "test-circuit-type-one" + - test_one['msg'] == "circuit_type Test Circuit Type One created" + +- name: "CIRCUIT_TYPE 2: Create duplicate" + netbox.netbox.netbox_circuit_type: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test Circuit Type One + state: present + register: test_two + +- name: "CIRCUIT_TYPE 2: ASSERT - Create duplicate" + ansible.builtin.assert: + that: + - not test_two['changed'] + - test_two['circuit_type']['name'] == "Test Circuit Type One" + - test_two['circuit_type']['slug'] == "test-circuit-type-one" + - test_two['msg'] == "circuit_type Test Circuit Type One already exists" + +- name: "CIRCUIT_TYPE 3: User specified slug" + netbox.netbox.netbox_circuit_type: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test Circuit Type Two + slug: test-circuit-type-2 + state: present + register: test_three + +- name: "CIRCUIT_TYPE 3: ASSERT - User specified slug" + ansible.builtin.assert: + that: + - test_three is changed + - test_three['diff']['before']['state'] == "absent" + - test_three['diff']['after']['state'] == "present" + - test_three['circuit_type']['name'] == "Test Circuit Type Two" + - test_three['circuit_type']['slug'] == "test-circuit-type-2" + - test_three['msg'] == "circuit_type Test Circuit Type Two created" + +- name: "CIRCUIT_TYPE 4: ASSERT - Delete" + netbox.netbox.netbox_circuit_type: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test Circuit Type One + state: absent + register: test_four + +- name: "CIRCUIT_TYPE 4: ASSERT - Delete" + ansible.builtin.assert: + that: + - test_four is changed + - test_four['circuit_type']['name'] == "Test Circuit Type One" + - test_four['circuit_type']['slug'] == "test-circuit-type-one" + - test_four['msg'] == "circuit_type Test Circuit Type One deleted" + +- name: "CIRCUIT_TYPE 5: ASSERT - Delete" + netbox.netbox.netbox_circuit_type: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test Circuit Type Two + slug: test-circuit-type-2 + state: absent + register: test_five + +- name: "CIRCUIT_TYPE 5: ASSERT - Delete" + ansible.builtin.assert: + that: + - test_five is changed + - test_five['circuit_type']['name'] == "Test Circuit Type Two" + - test_five['circuit_type']['slug'] == "test-circuit-type-2" + - test_five['msg'] == "circuit_type Test Circuit Type Two deleted" diff --git a/tests/integration/targets/v4.3/tasks/netbox_cluster.yml b/tests/integration/targets/v4.3/tasks/netbox_cluster.yml new file mode 100644 index 000000000..54047f6dd --- /dev/null +++ b/tests/integration/targets/v4.3/tasks/netbox_cluster.yml @@ -0,0 +1,102 @@ +--- +## +## +### NETBOX_CLUSTER +## +## +- name: "CLUSTER 1: Necessary info creation" + netbox.netbox.netbox_cluster: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test Cluster One + cluster_type: Test Cluster Type + state: present + register: test_one + +- name: "CLUSTER 1: ASSERT - Necessary info creation" + ansible.builtin.assert: + that: + - test_one is changed + - test_one['diff']['before']['state'] == "absent" + - test_one['diff']['after']['state'] == "present" + - test_one['cluster']['name'] == "Test Cluster One" + - test_one['cluster']['type'] == 1 + - test_one['msg'] == "cluster Test Cluster One created" + +- name: "CLUSTER 2: Create duplicate" + netbox.netbox.netbox_cluster: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test Cluster One + cluster_type: Test Cluster Type + state: present + register: test_two + +- name: "CLUSTER 2: ASSERT - Create duplicate" + ansible.builtin.assert: + that: + - not test_two['changed'] + - test_two['cluster']['name'] == "Test Cluster One" + - test_two['cluster']['type'] == 1 + - test_two['msg'] == "cluster Test Cluster One already exists" + +- name: "CLUSTER 3: Update" + netbox.netbox.netbox_cluster: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test Cluster One + cluster_type: Test Cluster Type + cluster_group: Test Cluster Group + scope_type: "dcim.site" + scope: Test Site + comments: Updated cluster + tenant: Test Tenant + tags: + - Schnozzberry + state: present + register: test_three + +- name: "CLUSTER 3: ASSERT - Updated" + ansible.builtin.assert: + that: + - test_three is changed + - test_three['diff']['after']['group'] == 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']['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: Delete" + netbox.netbox.netbox_cluster: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test Cluster One + state: absent + register: test_four + +- name: "CLUSTER 4: ASSERT - Delete" + ansible.builtin.assert: + that: + - test_four is changed + - test_four['cluster']['name'] == "Test Cluster One" + - test_four['cluster']['type'] == 1 + - test_four['cluster']['group'] == 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.3/tasks/netbox_cluster_group.yml b/tests/integration/targets/v4.3/tasks/netbox_cluster_group.yml new file mode 100644 index 000000000..64dda6c44 --- /dev/null +++ b/tests/integration/targets/v4.3/tasks/netbox_cluster_group.yml @@ -0,0 +1,96 @@ +--- +## +## +### NETBOX_CLUSTER_GROUP +## +## +- name: "CLUSTER_GROUP 1: Necessary info creation" + netbox.netbox.netbox_cluster_group: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test Cluster Group One + state: present + register: test_one + +- name: "CLUSTER_GROUP 1: ASSERT - Necessary info creation" + ansible.builtin.assert: + that: + - test_one is changed + - test_one['diff']['before']['state'] == "absent" + - test_one['diff']['after']['state'] == "present" + - test_one['cluster_group']['name'] == "Test Cluster Group One" + - test_one['cluster_group']['slug'] == "test-cluster-group-one" + - test_one['msg'] == "cluster_group Test Cluster Group One created" + +- name: "CLUSTER_GROUP 2: Create duplicate" + netbox.netbox.netbox_cluster_group: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test Cluster Group One + state: present + register: test_two + +- name: "CLUSTER_GROUP 2: ASSERT - Create duplicate" + ansible.builtin.assert: + that: + - not test_two['changed'] + - test_two['cluster_group']['name'] == "Test Cluster Group One" + - test_two['cluster_group']['slug'] == "test-cluster-group-one" + - test_two['msg'] == "cluster_group Test Cluster Group One already exists" + +- name: "CLUSTER_GROUP 3: User specified slug" + netbox.netbox.netbox_cluster_group: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test Cluster Group Two + slug: test-cluster-group-2 + state: present + register: test_three + +- name: "CLUSTER_GROUP 3: ASSERT - User specified slug" + ansible.builtin.assert: + that: + - test_three is changed + - test_three['diff']['before']['state'] == "absent" + - test_three['diff']['after']['state'] == "present" + - test_three['cluster_group']['name'] == "Test Cluster Group Two" + - test_three['cluster_group']['slug'] == "test-cluster-group-2" + - test_three['msg'] == "cluster_group Test Cluster Group Two created" + +- name: "CLUSTER_GROUP 4: ASSERT - Delete" + netbox.netbox.netbox_cluster_group: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test Cluster Group One + state: absent + register: test_four + +- name: "CLUSTER_GROUP 4: ASSERT - Delete" + ansible.builtin.assert: + that: + - test_four is changed + - test_four['cluster_group']['name'] == "Test Cluster Group One" + - test_four['cluster_group']['slug'] == "test-cluster-group-one" + - test_four['msg'] == "cluster_group Test Cluster Group One deleted" + +- name: "CLUSTER_GROUP 5: ASSERT - Delete" + netbox.netbox.netbox_cluster_group: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test Cluster Group Two + slug: test-cluster-group-2 + state: absent + register: test_five + +- name: "CLUSTER_GROUP 5: ASSERT - Delete" + ansible.builtin.assert: + that: + - test_five is changed + - test_five['cluster_group']['name'] == "Test Cluster Group Two" + - test_five['cluster_group']['slug'] == "test-cluster-group-2" + - test_five['msg'] == "cluster_group Test Cluster Group Two deleted" diff --git a/tests/integration/targets/v4.3/tasks/netbox_cluster_type.yml b/tests/integration/targets/v4.3/tasks/netbox_cluster_type.yml new file mode 100644 index 000000000..bc09ac8a6 --- /dev/null +++ b/tests/integration/targets/v4.3/tasks/netbox_cluster_type.yml @@ -0,0 +1,96 @@ +--- +## +## +### NETBOX_CLUSTER_TYPE +## +## +- name: "CLUSTER_TYPE 1: Necessary info creation" + netbox.netbox.netbox_cluster_type: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test Cluster Type One + state: present + register: test_one + +- name: "CLUSTER_TYPE 1: ASSERT - Necessary info creation" + ansible.builtin.assert: + that: + - test_one is changed + - test_one['diff']['before']['state'] == "absent" + - test_one['diff']['after']['state'] == "present" + - test_one['cluster_type']['name'] == "Test Cluster Type One" + - test_one['cluster_type']['slug'] == "test-cluster-type-one" + - test_one['msg'] == "cluster_type Test Cluster Type One created" + +- name: "CLUSTER_TYPE 2: Create duplicate" + netbox.netbox.netbox_cluster_type: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test Cluster Type One + state: present + register: test_two + +- name: "CLUSTER_TYPE 2: ASSERT - Create duplicate" + ansible.builtin.assert: + that: + - not test_two['changed'] + - test_two['cluster_type']['name'] == "Test Cluster Type One" + - test_two['cluster_type']['slug'] == "test-cluster-type-one" + - test_two['msg'] == "cluster_type Test Cluster Type One already exists" + +- name: "CLUSTER_TYPE 3: User specified slug" + netbox.netbox.netbox_cluster_type: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test Cluster Type Two + slug: test-cluster-type-2 + state: present + register: test_three + +- name: "CLUSTER_TYPE 3: ASSERT - User specified slug" + ansible.builtin.assert: + that: + - test_three is changed + - test_three['diff']['before']['state'] == "absent" + - test_three['diff']['after']['state'] == "present" + - test_three['cluster_type']['name'] == "Test Cluster Type Two" + - test_three['cluster_type']['slug'] == "test-cluster-type-2" + - test_three['msg'] == "cluster_type Test Cluster Type Two created" + +- name: "CLUSTER_TYPE 4: ASSERT - Delete" + netbox.netbox.netbox_cluster_type: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test Cluster Type One + state: absent + register: test_four + +- name: "CLUSTER_TYPE 4: ASSERT - Delete" + ansible.builtin.assert: + that: + - test_four is changed + - test_four['cluster_type']['name'] == "Test Cluster Type One" + - test_four['cluster_type']['slug'] == "test-cluster-type-one" + - test_four['msg'] == "cluster_type Test Cluster Type One deleted" + +- name: "CLUSTER_TYPE 5: ASSERT - Delete" + netbox.netbox.netbox_cluster_type: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test Cluster Type Two + slug: test-cluster-type-2 + state: absent + register: test_five + +- name: "CLUSTER_TYPE 5: ASSERT - Delete" + ansible.builtin.assert: + that: + - test_five is changed + - test_five['cluster_type']['name'] == "Test Cluster Type Two" + - test_five['cluster_type']['slug'] == "test-cluster-type-2" + - test_five['msg'] == "cluster_type Test Cluster Type Two deleted" diff --git a/tests/integration/targets/v4.3/tasks/netbox_config_context.yml b/tests/integration/targets/v4.3/tasks/netbox_config_context.yml new file mode 100644 index 000000000..910ec82ca --- /dev/null +++ b/tests/integration/targets/v4.3/tasks/netbox_config_context.yml @@ -0,0 +1,107 @@ +--- +## +## +### NETBOX_CONFIG_CONTEXTS +## +## +- name: "CONFIG_CONTEXT 1: Necessary info creation" + netbox.netbox.netbox_config_context: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: test_context + description: Test context + data: '{ "testkey": { "testsubkey": [ "testvaule" ] } }' + state: present + register: test_one + +- name: "CONFIG_CONTEXT 1: ASSERT - Necessary info creation" + ansible.builtin.assert: + that: + - test_one is changed + - test_one['diff']['before']['state'] == "absent" + - test_one['diff']['after']['state'] == "present" + - test_one['config_context']['name'] == "test_context" + - test_one['config_context']['description'] == "Test context" + - test_one['config_context']['is_active'] == true + - test_one['config_context']['weight'] == 1000 + - test_one['config_context']['data'].testkey.testsubkey[0] == "testvaule" + - test_one['msg'] == "config_context test_context created" + +- name: "CONFIG_CONTEXT 2: Create duplicate" + netbox.netbox.netbox_config_context: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: test_context + description: Test context + data: '{ "testkey": { "testsubkey": [ "testvaule" ] } }' + state: present + register: test_two + +- name: "CONFIG_CONTEXT 2: ASSERT - Create duplicate" + ansible.builtin.assert: + that: + - not test_two['changed'] + - test_two['config_context']['name'] == "test_context" + - test_two['msg'] == "config_context test_context already exists" + +- name: "CONFIG_CONTEXT 3: Update data and attach to site" + netbox.netbox.netbox_config_context: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: test_context + description: Updated test context + data: '{ "testkey": { "testsubkey": [ "updatedvaule" ] } }' + weight: 100 + sites: [test-site] + state: present + register: test_three + +- name: "CONFIG_CONTEXT 3: ASSERT - Updated" + ansible.builtin.assert: + that: + - test_three is changed + - test_three['diff']['after']['data'].testkey.testsubkey[0] == "updatedvaule" + - test_three['diff']['after']['description'] == "Updated test context" + - test_three['diff']['after']['weight'] == 100 + - test_three['diff']['after']['sites'][0] == 1 + - test_three['config_context']['name'] == "test_context" + - test_three['msg'] == "config_context test_context updated" + +- name: "CONFIG_CONTEXT 4: Detach from site" + netbox.netbox.netbox_config_context: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: test_context + data: '{ "testkey": { "testsubkey": [ "updatedvaule" ] } }' + sites: [] + state: present + register: test_four + +- name: "CONFIG_CONTEXT 4: ASSERT - Detached" + ansible.builtin.assert: + that: + - test_four is changed + - test_four['diff']['after']['sites']|length == 0 + - test_four['config_context']['name'] == "test_context" + - test_four['msg'] == "config_context test_context updated" + +- name: "CONFIG_CONTEXT 5: Delete" + netbox.netbox.netbox_config_context: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: test_context + state: absent + register: test_five + +- name: "CONFIG_CONTEXT 5: ASSERT - Deleted" + ansible.builtin.assert: + that: + - test_five is changed + - test_five['diff']['after']['state'] == "absent" + - test_five['config_context']['name'] == "test_context" + - test_five['msg'] == "config_context test_context deleted" diff --git a/tests/integration/targets/v4.3/tasks/netbox_config_template.yml b/tests/integration/targets/v4.3/tasks/netbox_config_template.yml new file mode 100644 index 000000000..af6cfb471 --- /dev/null +++ b/tests/integration/targets/v4.3/tasks/netbox_config_template.yml @@ -0,0 +1,82 @@ +--- +## +## +### NETBOX_CONFIG_TEMPLATES +## +## +- name: "CONFIG_TEMPLATES 1: Necessary info creation" + netbox.netbox.netbox_config_template: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: test_template + description: Test template + template_code: test template + state: present + register: test_one + +- name: "CONFIG_TEMPLATES 1: ASSERT - Necessary info creation" + ansible.builtin.assert: + that: + - test_one is changed + - test_one['diff']['before']['state'] == "absent" + - test_one['diff']['after']['state'] == "present" + - test_one['config_template']['name'] == "test_template" + - test_one['config_template']['description'] == "Test template" + - test_one['config_template']['template_code'] == "test template" + - test_one['msg'] == "config_template test_template created" + +- name: "CONFIG_TEMPLATES 2: Create duplicate" + netbox.netbox.netbox_config_template: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: test_template + description: Test template + template_code: test template + state: present + register: test_two + +- name: "CONFIG_TEMPLATES 2: ASSERT - Create duplicate" + ansible.builtin.assert: + that: + - not test_two['changed'] + - test_two['config_template']['name'] == "test_template" + - test_two['msg'] == "config_template test_template already exists" + +- name: "CONFIG_TEMPLATES 3: Update data" + netbox.netbox.netbox_config_template: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: test_template + description: Updated test template + template_code: updated test template + state: present + register: test_three + +- name: "CONFIG_TEMPLATES 3: ASSERT - Updated" + ansible.builtin.assert: + that: + - test_three is changed + - test_three['diff']['after']['template_code'] == "updated test template" + - test_three['diff']['after']['description'] == "Updated test template" + - test_three['config_template']['name'] == "test_template" + - test_three['msg'] == "config_template test_template updated" + +- name: "CONFIG_TEMPLATES 4: Delete" + netbox.netbox.netbox_config_template: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: test_template + state: absent + register: test_four + +- name: "CONFIG_TEMPLATES 4: ASSERT - Deleted" + ansible.builtin.assert: + that: + - test_four is changed + - test_four['diff']['after']['state'] == "absent" + - test_four['config_template']['name'] == "test_template" + - test_four['msg'] == "config_template test_template deleted" diff --git a/tests/integration/targets/v4.3/tasks/netbox_console_port.yml b/tests/integration/targets/v4.3/tasks/netbox_console_port.yml new file mode 100644 index 000000000..6be028bec --- /dev/null +++ b/tests/integration/targets/v4.3/tasks/netbox_console_port.yml @@ -0,0 +1,108 @@ +--- +# © 2020 Nokia +# Licensed under the GNU General Public License v3.0 only +# SPDX-License-Identifier: GPL-3.0-only +## +## +### NETBOX_CONSOLE_PORT +## +## +- name: "CONSOLE_PORT 1: Necessary info creation" + netbox.netbox.netbox_console_port: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Console Port + device: test100 + state: present + register: test_one + +- name: "CONSOLE_PORT 1: ASSERT - Necessary info creation" + ansible.builtin.assert: + that: + - test_one is changed + - test_one['diff']['before']['state'] == "absent" + - test_one['diff']['after']['state'] == "present" + - test_one['console_port']['name'] == "Console Port" + - test_one['console_port']['device'] == 1 + - test_one['msg'] == "console_port Console Port created" + +- name: "CONSOLE_PORT 2: Create duplicate" + netbox.netbox.netbox_console_port: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Console Port + device: test100 + state: present + register: test_two + +- name: "CONSOLE_PORT 2: ASSERT - Create duplicate" + ansible.builtin.assert: + that: + - not test_two['changed'] + - test_two['console_port']['name'] == "Console Port" + - test_two['console_port']['device'] == 1 + - test_two['msg'] == "console_port Console Port already exists" + +- name: "CONSOLE_PORT 3: Update Console Port with other fields" + netbox.netbox.netbox_console_port: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Console Port + device: test100 + type: usb-a + description: test description + state: present + register: test_three + +- name: "CONSOLE_PORT 3: ASSERT - Update Console Port with other fields" + ansible.builtin.assert: + that: + - test_three is changed + - test_three['diff']['after']['type'] == "usb-a" + - test_three['diff']['after']['description'] == "test description" + - test_three['console_port']['name'] == "Console Port" + - test_three['console_port']['device'] == 1 + - test_three['console_port']['type'] == "usb-a" + - test_three['console_port']['description'] == "test description" + - test_three['msg'] == "console_port Console Port updated" + +- name: "CONSOLE_PORT 4: Create Console Port for Delete Test" + netbox.netbox.netbox_console_port: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Console Port 2 + device: test100 + state: present + register: test_four + +- name: "CONSOLE_PORT 4: ASSERT - Create Console Port for Delete Test" + ansible.builtin.assert: + that: + - test_four is changed + - test_four['diff']['before']['state'] == "absent" + - test_four['diff']['after']['state'] == "present" + - test_four['console_port']['name'] == "Console Port 2" + - test_four['console_port']['device'] == 1 + - test_four['msg'] == "console_port Console Port 2 created" + +- name: "CONSOLE_PORT 5: Delete Console Port" + netbox.netbox.netbox_console_port: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Console Port 2 + device: test100 + state: absent + register: test_five + +- name: "CONSOLE_PORT 5: ASSERT - Delete Console Port" + ansible.builtin.assert: + that: + - test_five is changed + - test_five['diff']['before']['state'] == "present" + - test_five['diff']['after']['state'] == "absent" + - test_five['msg'] == "console_port Console Port 2 deleted" diff --git a/tests/integration/targets/v4.3/tasks/netbox_console_port_template.yml b/tests/integration/targets/v4.3/tasks/netbox_console_port_template.yml new file mode 100644 index 000000000..ef6149214 --- /dev/null +++ b/tests/integration/targets/v4.3/tasks/netbox_console_port_template.yml @@ -0,0 +1,105 @@ +--- +# © 2020 Nokia +# Licensed under the GNU General Public License v3.0 only +# SPDX-License-Identifier: GPL-3.0-only +## +## +### NETBOX_CONSOLE_PORT_TEMPLATE +## +## +- name: "CONSOLE_PORT_TEMPLATE 1: Necessary info creation" + netbox.netbox.netbox_console_port_template: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Console Port Template + device_type: Cisco Test + state: present + register: test_one + +- name: "CONSOLE_PORT_TEMPLATE 1: ASSERT - Necessary info creation" + ansible.builtin.assert: + that: + - test_one is changed + - test_one['diff']['before']['state'] == "absent" + - test_one['diff']['after']['state'] == "present" + - test_one['console_port_template']['name'] == "Console Port Template" + - test_one['console_port_template']['device_type'] == 1 + - test_one['msg'] == "console_port_template Console Port Template created" + +- name: "CONSOLE_PORT_TEMPLATE 2: Create duplicate" + netbox.netbox.netbox_console_port_template: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Console Port Template + device_type: Cisco Test + state: present + register: test_two + +- name: "CONSOLE_PORT_TEMPLATE 2: ASSERT - Create duplicate" + ansible.builtin.assert: + that: + - not test_two['changed'] + - test_two['console_port_template']['name'] == "Console Port Template" + - test_two['console_port_template']['device_type'] == 1 + - test_two['msg'] == "console_port_template Console Port Template already exists" + +- name: "CONSOLE_PORT_TEMPLATE 3: Update Console Port Template with other fields" + netbox.netbox.netbox_console_port_template: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Console Port Template + device_type: Cisco Test + type: usb-a + state: present + register: test_three + +- name: "CONSOLE_PORT_TEMPLATE 3: ASSERT - Update Console Port Template with other fields" + ansible.builtin.assert: + that: + - test_three is changed + - test_three['diff']['after']['type'] == "usb-a" + - test_three['console_port_template']['name'] == "Console Port Template" + - test_three['console_port_template']['device_type'] == 1 + - test_three['console_port_template']['type'] == "usb-a" + - test_three['msg'] == "console_port_template Console Port Template updated" + +- name: "CONSOLE_PORT_TEMPLATE 4: Create Console Port Template for Delete Test" + netbox.netbox.netbox_console_port_template: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Console Port Template 2 + device_type: Cisco Test + state: present + register: test_four + +- name: "CONSOLE_PORT_TEMPLATE 4: ASSERT - Create Console Port Template for Delete Test" + ansible.builtin.assert: + that: + - test_four is changed + - test_four['diff']['before']['state'] == "absent" + - test_four['diff']['after']['state'] == "present" + - test_four['console_port_template']['name'] == "Console Port Template 2" + - test_four['console_port_template']['device_type'] == 1 + - test_four['msg'] == "console_port_template Console Port Template 2 created" + +- name: "CONSOLE_PORT_TEMPLATE 5: Delete Console Port Template" + netbox.netbox.netbox_console_port_template: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Console Port Template 2 + device_type: Cisco Test + state: absent + register: test_five + +- name: "CONSOLE_PORT_TEMPLATE 5: ASSERT - Delete Console Port Template" + ansible.builtin.assert: + that: + - test_five is changed + - test_five['diff']['before']['state'] == "present" + - test_five['diff']['after']['state'] == "absent" + - test_five['msg'] == "console_port_template Console Port Template 2 deleted" diff --git a/tests/integration/targets/v4.3/tasks/netbox_console_server_port.yml b/tests/integration/targets/v4.3/tasks/netbox_console_server_port.yml new file mode 100644 index 000000000..0ac7b65d0 --- /dev/null +++ b/tests/integration/targets/v4.3/tasks/netbox_console_server_port.yml @@ -0,0 +1,108 @@ +--- +# © 2020 Nokia +# Licensed under the GNU General Public License v3.0 only +# SPDX-License-Identifier: GPL-3.0-only +## +## +### NETBOX_CONSOLE_SERVER_PORT +## +## +- name: "CONSOLE_SERVER_PORT 1: Necessary info creation" + netbox.netbox.netbox_console_server_port: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Console Server Port + device: test100 + state: present + register: test_one + +- name: "CONSOLE_SERVER_PORT 1: ASSERT - Necessary info creation" + ansible.builtin.assert: + that: + - test_one is changed + - test_one['diff']['before']['state'] == "absent" + - test_one['diff']['after']['state'] == "present" + - test_one['console_server_port']['name'] == "Console Server Port" + - test_one['console_server_port']['device'] == 1 + - test_one['msg'] == "console_server_port Console Server Port created" + +- name: "CONSOLE_SERVER_PORT 2: Create duplicate" + netbox.netbox.netbox_console_server_port: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Console Server Port + device: test100 + state: present + register: test_two + +- name: "CONSOLE_SERVER_PORT 2: ASSERT - Create duplicate" + ansible.builtin.assert: + that: + - not test_two['changed'] + - test_two['console_server_port']['name'] == "Console Server Port" + - test_two['console_server_port']['device'] == 1 + - test_two['msg'] == "console_server_port Console Server Port already exists" + +- name: "CONSOLE_SERVER_PORT 3: Update Console Server Port with other fields" + netbox.netbox.netbox_console_server_port: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Console Server Port + device: test100 + type: usb-a + description: test description + state: present + register: test_three + +- name: "CONSOLE_SERVER_PORT 3: ASSERT - Update Console Server Port with other fields" + ansible.builtin.assert: + that: + - test_three is changed + - test_three['diff']['after']['type'] == "usb-a" + - test_three['diff']['after']['description'] == "test description" + - test_three['console_server_port']['name'] == "Console Server Port" + - test_three['console_server_port']['device'] == 1 + - test_three['console_server_port']['type'] == "usb-a" + - test_three['console_server_port']['description'] == "test description" + - test_three['msg'] == "console_server_port Console Server Port updated" + +- name: "CONSOLE_SERVER_PORT 4: Create Console Server Port for Delete Test" + netbox.netbox.netbox_console_server_port: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Console Server Port 2 + device: test100 + state: present + register: test_four + +- name: "CONSOLE_SERVER_PORT 4: ASSERT - Create Console Server Port for Delete Test" + ansible.builtin.assert: + that: + - test_four is changed + - test_four['diff']['before']['state'] == "absent" + - test_four['diff']['after']['state'] == "present" + - test_four['console_server_port']['name'] == "Console Server Port 2" + - test_four['console_server_port']['device'] == 1 + - test_four['msg'] == "console_server_port Console Server Port 2 created" + +- name: "CONSOLE_SERVER_PORT 5: Delete Console Server Port" + netbox.netbox.netbox_console_server_port: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Console Server Port 2 + device: test100 + state: absent + register: test_five + +- name: "CONSOLE_SERVER_PORT 5: ASSERT - Delete Console Server Port" + ansible.builtin.assert: + that: + - test_five is changed + - test_five['diff']['before']['state'] == "present" + - test_five['diff']['after']['state'] == "absent" + - test_five['msg'] == "console_server_port Console Server Port 2 deleted" diff --git a/tests/integration/targets/v4.3/tasks/netbox_console_server_port_template.yml b/tests/integration/targets/v4.3/tasks/netbox_console_server_port_template.yml new file mode 100644 index 000000000..4c7dfc846 --- /dev/null +++ b/tests/integration/targets/v4.3/tasks/netbox_console_server_port_template.yml @@ -0,0 +1,105 @@ +--- +# © 2020 Nokia +# Licensed under the GNU General Public License v3.0 only +# SPDX-License-Identifier: GPL-3.0-only +## +## +### NETBOX_CONSOLE_SERVER_PORT_TEMPLATE +## +## +- name: "CONSOLE_SERVER_PORT_TEMPLATE 1: Necessary info creation" + netbox.netbox.netbox_console_server_port_template: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Console Server Port Template + device_type: Cisco Test + state: present + register: test_one + +- name: "CONSOLE_SERVER_PORT_TEMPLATE 1: ASSERT - Necessary info creation" + ansible.builtin.assert: + that: + - test_one is changed + - test_one['diff']['before']['state'] == "absent" + - test_one['diff']['after']['state'] == "present" + - test_one['console_server_port_template']['name'] == "Console Server Port Template" + - test_one['console_server_port_template']['device_type'] == 1 + - test_one['msg'] == "console_server_port_template Console Server Port Template created" + +- name: "CONSOLE_SERVER_PORT_TEMPLATE 2: Create duplicate" + netbox.netbox.netbox_console_server_port_template: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Console Server Port Template + device_type: Cisco Test + state: present + register: test_two + +- name: "CONSOLE_SERVER_PORT_TEMPLATE 2: ASSERT - Create duplicate" + ansible.builtin.assert: + that: + - not test_two['changed'] + - test_two['console_server_port_template']['name'] == "Console Server Port Template" + - test_two['console_server_port_template']['device_type'] == 1 + - test_two['msg'] == "console_server_port_template Console Server Port Template already exists" + +- name: "CONSOLE_SERVER_PORT_TEMPLATE 3: Update Console Server Port Template with other fields" + netbox.netbox.netbox_console_server_port_template: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Console Server Port Template + device_type: Cisco Test + type: usb-a + state: present + register: test_three + +- name: "CONSOLE_SERVER_PORT_TEMPLATE 3: ASSERT - Update Console Server Port Template with other fields" + ansible.builtin.assert: + that: + - test_three is changed + - test_three['diff']['after']['type'] == "usb-a" + - test_three['console_server_port_template']['name'] == "Console Server Port Template" + - test_three['console_server_port_template']['device_type'] == 1 + - test_three['console_server_port_template']['type'] == "usb-a" + - test_three['msg'] == "console_server_port_template Console Server Port Template updated" + +- name: "CONSOLE_SERVER_PORT_TEMPLATE 4: Create Console Server Port Template for Delete Test" + netbox.netbox.netbox_console_server_port_template: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Console Server Port Template 2 + device_type: Cisco Test + state: present + register: test_four + +- name: "CONSOLE_SERVER_PORT_TEMPLATE 4: ASSERT - Create Console Server Port Template for Delete Test" + ansible.builtin.assert: + that: + - test_four is changed + - test_four['diff']['before']['state'] == "absent" + - test_four['diff']['after']['state'] == "present" + - test_four['console_server_port_template']['name'] == "Console Server Port Template 2" + - test_four['console_server_port_template']['device_type'] == 1 + - test_four['msg'] == "console_server_port_template Console Server Port Template 2 created" + +- name: "CONSOLE_SERVER_PORT_TEMPLATE 5: Delete Console Server Port Template" + netbox.netbox.netbox_console_server_port_template: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Console Server Port Template 2 + device_type: Cisco Test + state: absent + register: test_five + +- name: "CONSOLE_SERVER_PORT_TEMPLATE 5: ASSERT - Delete Console Server Port Template" + ansible.builtin.assert: + that: + - test_five is changed + - test_five['diff']['before']['state'] == "present" + - test_five['diff']['after']['state'] == "absent" + - test_five['msg'] == "console_server_port_template Console Server Port Template 2 deleted" diff --git a/tests/integration/targets/v4.3/tasks/netbox_contact.yml b/tests/integration/targets/v4.3/tasks/netbox_contact.yml new file mode 100644 index 000000000..e62635607 --- /dev/null +++ b/tests/integration/targets/v4.3/tasks/netbox_contact.yml @@ -0,0 +1,143 @@ +--- +## +## +### NETBOX_CONTACT +## +## +- name: 1 - Test contact creation + netbox.netbox.netbox_contact: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Contact ABC + register: test_one + +- name: 1 - ASSERT + ansible.builtin.assert: + that: + - test_one is changed + - test_one['diff']['before']['state'] == "absent" + - test_one['diff']['after']['state'] == "present" + - test_one['contact']['name'] == "Contact ABC" + - test_one['msg'] == "contact Contact ABC created" + +- name: Test duplicate contact + netbox.netbox.netbox_contact: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Contact ABC + register: test_two + +- name: 2 - ASSERT + ansible.builtin.assert: + that: + - not test_two['changed'] + - test_two['contact']['name'] == "Contact ABC" + - test_two['msg'] == "contact Contact ABC already exists" + +- name: 3 - Test update + netbox.netbox.netbox_contact: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Contact ABC + title: New Title + register: test_three + +- name: 3 - ASSERT + ansible.builtin.assert: + that: + - test_three is changed + - test_three['diff']['after']['title'] == "New Title" + - test_three['contact']['name'] == "Contact ABC" + - test_three['contact']['title'] == "New Title" + - test_three['msg'] == "contact Contact ABC updated" + +- name: 4 - Test delete + netbox.netbox.netbox_contact: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Contact ABC + state: absent + register: test_four + +- name: 4 - ASSERT + ansible.builtin.assert: + that: + - test_four is changed + - test_four['diff']['before']['state'] == "present" + - test_four['diff']['after']['state'] == "absent" + - test_four['msg'] == "contact Contact ABC deleted" + +- name: 5 - Create contact with all parameters + netbox.netbox.netbox_contact: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Contact ABC + title: Fancy title + phone: "12345678" + email: contact@contact.com + tags: + - tagA + - tagB + - tagC + state: present + register: test_five + +- name: 5 - ASSERT + ansible.builtin.assert: + that: + - test_five is changed + - test_five['diff']['before']['state'] == "absent" + - test_five['diff']['after']['state'] == "present" + - test_five['contact']['name'] == "Contact ABC" + - test_five['contact']['title'] == "Fancy title" + - test_five['contact']['phone'] == "12345678" + - test_five['contact']['tags'] | length == 3 + - test_five['msg'] == "contact Contact ABC created" + +- name: 6 Setup - Create contact group + netbox.netbox.netbox_contact_group: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Contact Group With Contacts + register: test_group + +- name: 6 - Create contact with contact group + netbox.netbox.netbox_contact: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Grouped Contact 1 + contact_groups: + - Contact Group With Contacts + register: test_six + +- name: 6 - ASSERT + ansible.builtin.assert: + that: + - test_six is changed + - test_six['diff']['before']['state'] == "absent" + - test_six['diff']['after']['state'] == "present" + - test_six['contact']['name'] == "Grouped Contact 1" + - test_six['contact']['groups'] == [test_group['contact_group']['id']] + - test_six['msg'] == "contact Grouped Contact 1 created" + +- name: 7 - Try to create contact using contact_group + netbox.netbox.netbox_contact: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Grouped Contact 2 + contact_group: Contact Group With Contacts + register: test_seven + ignore_errors: true + +- name: 7 - ASSERT + ansible.builtin.assert: + that: + - "'contact_group is not available in Netbox 4.3. Use contact_groups instead.' in test_seven['module_stderr']" diff --git a/tests/integration/targets/v4.3/tasks/netbox_contact_assignment.yml b/tests/integration/targets/v4.3/tasks/netbox_contact_assignment.yml new file mode 100644 index 000000000..6928b8f83 --- /dev/null +++ b/tests/integration/targets/v4.3/tasks/netbox_contact_assignment.yml @@ -0,0 +1,503 @@ +--- +## +## +### NETBOX_CONTACT_ASSIGNMENT +## +## +- name: Setup - Create contact for assignment + netbox.netbox.netbox_contact: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Contact For Assignment + state: present + +- name: Setup - Create contact role for assignment + netbox.netbox.netbox_contact_role: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Role For Assignment + state: present + +- name: 1 - Setup - Create tenant to assign contact to + netbox.netbox.netbox_tenant: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Tenant With Contact + state: present + +- name: 1 - Assign contact to tenant + netbox.netbox.netbox_contact_assignment: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + object_type: tenant + object_name: Tenant With Contact + contact: Contact For Assignment + role: Role For Assignment + state: present + register: test_one + +- name: 1 - ASSERT + ansible.builtin.assert: + that: + - test_one is changed + - test_one['diff']['before']['state'] == "absent" + - test_one['diff']['after']['state'] == "present" + - test_one['contact_assignment']['display'] == "Contact For Assignment -> Tenant With Contact" + - test_one['msg'] == "contact_assignment Contact For Assignment -> Tenant With Contact created" + +- name: Test duplicate contact + netbox.netbox.netbox_contact_assignment: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + object_type: tenant + object_name: Tenant With Contact + contact: Contact For Assignment + role: Role For Assignment + state: present + register: test_two + +- name: 2 - ASSERT + ansible.builtin.assert: + that: + - not test_two['changed'] + - test_two['msg'] == "contact_assignment Contact For Assignment -> Tenant With Contact already exists" + +- name: 3 - Test update + netbox.netbox.netbox_contact_assignment: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + object_type: tenant + object_name: Tenant With Contact + contact: Contact For Assignment + role: Role For Assignment + priority: tertiary + tags: + - tagA + - tagB + register: test_three + +- name: 3 - ASSERT + ansible.builtin.assert: + that: + - test_three is changed + - test_three['diff']['before']['priority'] == None + - test_three['diff']['after']['priority'] == "tertiary" + - test_three['diff']['before']['tags'] == [] + - test_three['diff']['after']['tags'] != [] + - test_three['msg'] == "contact_assignment Contact For Assignment -> Tenant With Contact updated" + +- name: 4 - Test delete + netbox.netbox.netbox_contact_assignment: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + object_type: tenant + object_name: Tenant With Contact + contact: Contact For Assignment + role: Role For Assignment + state: absent + register: test_four + +- name: 4 - ASSERT + ansible.builtin.assert: + that: + - test_four is changed + - test_four['diff']['before']['state'] == "present" + - test_four['diff']['after']['state'] == "absent" + - test_four['msg'] == "contact_assignment Contact For Assignment -> Tenant With Contact deleted" + +- name: 5 - Setup - Create circuit to assign contact to + netbox.netbox.netbox_circuit: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + cid: Circuit With Contact + provider: Test Provider + circuit_type: Test Circuit Type + state: present + +- name: 5 - Assign contact to circuit + netbox.netbox.netbox_contact_assignment: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + object_type: circuit + object_name: Circuit With Contact + contact: Contact For Assignment + role: Role For Assignment + state: present + register: test_five + +- name: 5 - ASSERT + ansible.builtin.assert: + that: + - test_five is changed + - test_five['diff']['before']['state'] == "absent" + - test_five['diff']['after']['state'] == "present" + - test_five['contact_assignment']['display'] == "Contact For Assignment -> Circuit With Contact" + - test_five['msg'] == "contact_assignment Contact For Assignment -> Circuit With Contact created" + +- name: 6 - Setup - Create provider to assign contact to + netbox.netbox.netbox_provider: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Provider With Contact + state: present + +- name: 6 - Assign contact to provider + netbox.netbox.netbox_contact_assignment: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + object_type: provider + object_name: Provider With Contact + contact: Contact For Assignment + role: Role For Assignment + state: present + register: test_six + +- name: 6 - ASSERT + ansible.builtin.assert: + that: + - test_six is changed + - test_six['diff']['before']['state'] == "absent" + - test_six['diff']['after']['state'] == "present" + - test_six['contact_assignment']['display'] == "Contact For Assignment -> Provider With Contact" + - test_six['msg'] == "contact_assignment Contact For Assignment -> Provider With Contact created" + +- name: 7 - Setup - Create device to assign contact to + netbox.netbox.netbox_device: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Device With Contact + device_type: + id: "1" + device_role: Core Switch + site: Test Site + status: Staged + state: present + +- name: 7 - Assign contact to device + netbox.netbox.netbox_contact_assignment: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + object_type: device + object_name: Device With Contact + contact: Contact For Assignment + role: Role For Assignment + state: present + register: test_seven + +- name: 7 - ASSERT + ansible.builtin.assert: + that: + - test_seven is changed + - test_seven['diff']['before']['state'] == "absent" + - test_seven['diff']['after']['state'] == "present" + - test_seven['contact_assignment']['display'] == "Contact For Assignment -> Device With Contact" + - test_seven['msg'] == "contact_assignment Contact For Assignment -> Device With Contact created" + +- name: 8 - Setup - Create location to assign contact to + netbox.netbox.netbox_location: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Location With Contact + site: Test Site + state: present + +- name: 8 - Assign contact to location + netbox.netbox.netbox_contact_assignment: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + object_type: location + object_name: Location With Contact + contact: Contact For Assignment + role: Role For Assignment + state: present + register: test_eight + +- name: 8 - ASSERT + ansible.builtin.assert: + that: + - test_eight is changed + - test_eight['diff']['before']['state'] == "absent" + - test_eight['diff']['after']['state'] == "present" + - test_eight['contact_assignment']['display'] == "Contact For Assignment -> Location With Contact" + - test_eight['msg'] == "contact_assignment Contact For Assignment -> Location With Contact created" + +- name: 9 - Setup - Create manufacturer to assign contact to + netbox.netbox.netbox_manufacturer: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Manufacturer With Contact + state: present + +- name: 9 - Assign contact to manufacturer + netbox.netbox.netbox_contact_assignment: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + object_type: manufacturer + object_name: Manufacturer With Contact + contact: Contact For Assignment + role: Role For Assignment + state: present + register: test_nine + +- name: 9 - ASSERT + ansible.builtin.assert: + that: + - test_nine is changed + - test_nine['diff']['before']['state'] == "absent" + - test_nine['diff']['after']['state'] == "present" + - test_nine['contact_assignment']['display'] == "Contact For Assignment -> Manufacturer With Contact" + - test_nine['msg'] == "contact_assignment Contact For Assignment -> Manufacturer With Contact created" + +- name: 10 - Setup - Create power panel to assign contact to + netbox.netbox.netbox_power_panel: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Power Panel With Contact + site: Test Site + state: present + +- name: 10 - Assign contact to power panel + netbox.netbox.netbox_contact_assignment: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + object_type: power_panel + object_name: Power Panel With Contact + contact: Contact For Assignment + role: Role For Assignment + state: present + register: test_ten + +- name: 10 - ASSERT + ansible.builtin.assert: + that: + - test_ten is changed + - test_ten['diff']['before']['state'] == "absent" + - test_ten['diff']['after']['state'] == "present" + - test_ten['contact_assignment']['display'] == "Contact For Assignment -> Power Panel With Contact" + - test_ten['msg'] == "contact_assignment Contact For Assignment -> Power Panel With Contact created" + +- name: 11 - Setup - Create rack to assign contact to + netbox.netbox.netbox_rack: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Rack With Contact + site: Test Site + location: Test Rack Group + state: present + +- name: 11 - Assign contact to rack + netbox.netbox.netbox_contact_assignment: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + object_type: rack + object_name: Rack With Contact + contact: Contact For Assignment + role: Role For Assignment + state: present + register: test_eleven + +- name: 11 - ASSERT + ansible.builtin.assert: + that: + - test_eleven is changed + - test_eleven['diff']['before']['state'] == "absent" + - test_eleven['diff']['after']['state'] == "present" + - test_eleven['contact_assignment']['display'] == "Contact For Assignment -> Rack With Contact" + - test_eleven['msg'] == "contact_assignment Contact For Assignment -> Rack With Contact created" + +- name: 12 - Setup - Create region to assign contact to + netbox.netbox.netbox_region: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Region With Contact + state: present + +- name: 12 - Assign contact to region + netbox.netbox.netbox_contact_assignment: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + object_type: region + object_name: Region With Contact + contact: Contact For Assignment + role: Role For Assignment + state: present + register: test_twelve + +- name: 12 - ASSERT + ansible.builtin.assert: + that: + - test_twelve is changed + - test_twelve['diff']['before']['state'] == "absent" + - test_twelve['diff']['after']['state'] == "present" + - test_twelve['contact_assignment']['display'] == "Contact For Assignment -> Region With Contact" + - test_twelve['msg'] == "contact_assignment Contact For Assignment -> Region With Contact created" + +- name: 13 - Setup - Create site to assign contact to + netbox.netbox.netbox_site: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Site With Contact + state: present + +- name: 13 - Assign contact to site + netbox.netbox.netbox_contact_assignment: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + object_type: site + object_name: Site With Contact + contact: Contact For Assignment + role: Role For Assignment + state: present + register: test_thirteen + +- name: 13 - ASSERT + ansible.builtin.assert: + that: + - test_thirteen is changed + - test_thirteen['diff']['before']['state'] == "absent" + - test_thirteen['diff']['after']['state'] == "present" + - test_thirteen['contact_assignment']['display'] == "Contact For Assignment -> Site With Contact" + - test_thirteen['msg'] == "contact_assignment Contact For Assignment -> Site With Contact created" + +- name: 14 - Setup - Create site group to assign contact to + netbox.netbox.netbox_site_group: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Site Group With Contact + state: present + +- name: 14 - Assign contact to site group + netbox.netbox.netbox_contact_assignment: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + object_type: site_group + object_name: Site Group With Contact + contact: Contact For Assignment + role: Role For Assignment + state: present + register: test_fourteen + +- name: 14 - ASSERT + ansible.builtin.assert: + that: + - test_fourteen is changed + - test_fourteen['diff']['before']['state'] == "absent" + - test_fourteen['diff']['after']['state'] == "present" + - test_fourteen['contact_assignment']['display'] == "Contact For Assignment -> Site Group With Contact" + - test_fourteen['msg'] == "contact_assignment Contact For Assignment -> Site Group With Contact created" + +- name: 15 - Setup - Create cluster to assign contact to + netbox.netbox.netbox_cluster: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Cluster With Contact + cluster_type: Test Cluster Type + state: present + +- name: 15 - Assign contact to cluster + netbox.netbox.netbox_contact_assignment: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + object_type: cluster + object_name: Cluster With Contact + contact: Contact For Assignment + role: Role For Assignment + state: present + register: test_fifteen + +- name: 15 - ASSERT + ansible.builtin.assert: + that: + - test_fifteen is changed + - test_fifteen['diff']['before']['state'] == "absent" + - test_fifteen['diff']['after']['state'] == "present" + - test_fifteen['contact_assignment']['display'] == "Contact For Assignment -> Cluster With Contact" + - test_fifteen['msg'] == "contact_assignment Contact For Assignment -> Cluster With Contact created" + +- name: 16 - Setup - Create cluster group to assign contact to + netbox.netbox.netbox_cluster_group: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Cluster Group With Contact + state: present + +- name: 16 - Assign contact to cluster group + netbox.netbox.netbox_contact_assignment: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + object_type: cluster_group + object_name: Cluster Group With Contact + contact: Contact For Assignment + role: Role For Assignment + state: present + register: test_sixteen + +- name: 16 - ASSERT + ansible.builtin.assert: + that: + - test_sixteen is changed + - test_sixteen['diff']['before']['state'] == "absent" + - test_sixteen['diff']['after']['state'] == "present" + - test_sixteen['contact_assignment']['display'] == "Contact For Assignment -> Cluster Group With Contact" + - test_sixteen['msg'] == "contact_assignment Contact For Assignment -> Cluster Group With Contact created" + +- name: 17 - Setup - Create virtual machine to assign contact to + netbox.netbox.netbox_virtual_machine: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Virtual Machine With Contact + cluster: Test Cluster + state: present + +- name: 17 - Assign contact to virtual machine + netbox.netbox.netbox_contact_assignment: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + object_type: virtual_machine + object_name: Virtual Machine With Contact + contact: Contact For Assignment + role: Role For Assignment + state: present + 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['contact_assignment']['display'] == "Contact For Assignment -> Virtual Machine With Contact" + - test_seventeen['msg'] == "contact_assignment Contact For Assignment -> Virtual Machine With Contact created" diff --git a/tests/integration/targets/v4.3/tasks/netbox_contact_group.yml b/tests/integration/targets/v4.3/tasks/netbox_contact_group.yml new file mode 100644 index 000000000..090d880a0 --- /dev/null +++ b/tests/integration/targets/v4.3/tasks/netbox_contact_group.yml @@ -0,0 +1,119 @@ +--- +## +## +### NETBOX_CONTACT_GROUP +## +## +- name: 1 - Test contact group creation + netbox.netbox.netbox_contact_group: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Contact Group 1 + register: test_one + +- name: 1 - ASSERT + ansible.builtin.assert: + that: + - test_one is changed + - test_one['diff']['before']['state'] == "absent" + - test_one['diff']['after']['state'] == "present" + - test_one['contact_group']['name'] == "Contact Group 1" + - test_one['msg'] == "contact_group Contact Group 1 created" + +- name: Test duplicate contact group + netbox.netbox.netbox_contact_group: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Contact Group 1 + register: test_two + +- name: 2 - ASSERT + ansible.builtin.assert: + that: + - not test_two['changed'] + - test_two['contact_group']['name'] == "Contact Group 1" + - test_two['msg'] == "contact_group Contact Group 1 already exists" + +- name: 3 - Test update + netbox.netbox.netbox_contact_group: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Contact Group 1 + description: The first contact group + register: test_three + +- name: 3 - ASSERT + ansible.builtin.assert: + that: + - test_three is changed + - test_three['diff']['after']['description'] == "The first contact group" + - test_three['contact_group']['name'] == "Contact Group 1" + - test_three['contact_group']['description'] == "The first contact group" + - test_three['msg'] == "contact_group Contact Group 1 updated" + +- name: 4 - Test delete + netbox.netbox.netbox_contact_group: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Contact Group 1 + state: absent + register: test_four + +- name: 4 - ASSERT + ansible.builtin.assert: + that: + - test_four is changed + - test_four['diff']['before']['state'] == "present" + - test_four['diff']['after']['state'] == "absent" + - test_four['msg'] == "contact_group Contact Group 1 deleted" + +- name: 5 - Create contact group with all parameters + netbox.netbox.netbox_contact_group: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Contact Group Parent + slug: the-parent-contact-group + description: The parent contact group + tags: + - tagA + - tagB + - tagC + state: present + register: test_five + +- name: 5 - ASSERT + ansible.builtin.assert: + that: + - test_five is changed + - test_five['diff']['before']['state'] == "absent" + - test_five['diff']['after']['state'] == "present" + - test_five['contact_group']['name'] == "Contact Group Parent" + - test_five['contact_group']['slug'] == "the-parent-contact-group" + - test_five['contact_group']['description'] == "The parent contact group" + - test_five['contact_group']['tags'] | length == 3 + - test_five['msg'] == "contact_group Contact Group Parent created" + +- name: 6 - Create contact group with parent contact group + netbox.netbox.netbox_contact_group: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Contact Group Child + parent_contact_group: Contact Group Parent + state: present + register: test_six + +- name: 6 - ASSERT + ansible.builtin.assert: + that: + - test_six is changed + - test_six['diff']['before']['state'] == "absent" + - test_six['diff']['after']['state'] == "present" + - test_six['contact_group']['name'] == "Contact Group Child" + - test_six['contact_group']['parent'] == test_five['contact_group']['id'] + - test_six['msg'] == "contact_group Contact Group Child created" diff --git a/tests/integration/targets/v4.3/tasks/netbox_contact_role.yml b/tests/integration/targets/v4.3/tasks/netbox_contact_role.yml new file mode 100644 index 000000000..c84703da9 --- /dev/null +++ b/tests/integration/targets/v4.3/tasks/netbox_contact_role.yml @@ -0,0 +1,94 @@ +--- +## +## +### NETBOX_CONTACT_ROLE +## +## +- name: "CONTACT_ROLE 1: Necessary info creation" + netbox.netbox.netbox_contact_role: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test Contact Role + state: present + register: test_one + +- name: "CONTACT_ROLE 1: ASSERT - Necessary info creation" + ansible.builtin.assert: + that: + - test_one is changed + - test_one['diff']['before']['state'] == "absent" + - test_one['diff']['after']['state'] == "present" + - test_one['contact_role']['name'] == "Test Contact Role" + - test_one['contact_role']['slug'] == "test-contact-role" + - test_one['msg'] == "contact_role Test Contact Role created" + +- name: "CONTACT_ROLE 2: Create duplicate" + netbox.netbox.netbox_contact_role: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test Contact Role + state: present + register: test_two + +- name: "CONTACT ROLE 2: ASSERT - Create duplicate" + ansible.builtin.assert: + that: + - not test_two['changed'] + - test_two['contact_role']['name'] == "Test Contact Role" + - test_two['contact_role']['slug'] == "test-contact-role" + - test_two['msg'] == "contact_role Test Contact Role already exists" + +- name: "CONTACT_ROLE 3: ASSERT - Update" + netbox.netbox.netbox_contact_role: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test Contact Role + description: Update description + state: present + register: test_three + +- name: "IPAM_ROLE 3: ASSERT - Update" + ansible.builtin.assert: + that: + - test_three is changed + - test_three['diff']['after']['description'] == "Update description" + - test_three['contact_role']['name'] == "Test Contact Role" + - test_three['contact_role']['slug'] == "test-contact-role" + - test_three['contact_role']['description'] == "Update description" + - test_three['msg'] == "contact_role Test Contact Role updated" + +- name: "CONTACT_ROLE 4: ASSERT - Delete" + netbox.netbox.netbox_contact_role: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test Contact Role + state: absent + register: test_four + +- name: "CONTACT_ROLE 4: ASSERT - Delete" + ansible.builtin.assert: + that: + - test_four is changed + - test_four['diff']['before']['state'] == "present" + - test_four['diff']['after']['state'] == "absent" + - test_four['msg'] == "contact_role Test Contact Role deleted" + +- name: "CONTACT_ROLE 5: ASSERT - Delete non existing" + netbox.netbox.netbox_contact_role: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test Contact Role + state: absent + register: test_five + +- name: "CONTACT_ROLE 5: ASSERT - Delete non existing`" + ansible.builtin.assert: + that: + - not test_five['changed'] + - test_five['contact_role'] == None + - test_five['msg'] == "contact_role Test Contact Role already absent" diff --git a/tests/integration/targets/v4.3/tasks/netbox_custom_field.yml b/tests/integration/targets/v4.3/tasks/netbox_custom_field.yml new file mode 100644 index 000000000..a4aba8608 --- /dev/null +++ b/tests/integration/targets/v4.3/tasks/netbox_custom_field.yml @@ -0,0 +1,129 @@ +--- +## +## +### NETBOX_CUSTOM_FIELD +## +## +- name: "CUSTOM_FIELD 1: Necessary info creation" + netbox.netbox.netbox_custom_field: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + object_types: + - dcim.device + name: A_CustomField + type: text + state: present + register: test_one + +- name: "CUSTOM_FIELD 1: ASSERT - Necessary info creation" + ansible.builtin.assert: + that: + - test_one is changed + - test_one['diff']['before']['state'] == "absent" + - test_one['diff']['after']['state'] == "present" + - test_one['custom_field']['name'] == "A_CustomField" + - test_one['custom_field']['required'] == false + - test_one['custom_field']['object_types'] == ["dcim.device"] + - test_one['custom_field']['type'] == "text" + - test_one['custom_field']['weight'] == 100 + - test_one['msg'] == "custom_field A_CustomField created" + +- name: "CUSTOM_FIELD 2: Create duplicate" + netbox.netbox.netbox_custom_field: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + object_types: + - dcim.device + name: A_CustomField + state: present + register: test_two + +- name: "CUSTOM_FIELD 2: ASSERT - Create duplicate" + ansible.builtin.assert: + that: + - not test_two['changed'] + - test_two['custom_field']['name'] == "A_CustomField" + - test_two['msg'] == "custom_field A_CustomField already exists" + +- name: "CUSTOM_FIELD 3: Update data and make it required" + netbox.netbox.netbox_custom_field: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + object_types: + - dcim.device + name: A_CustomField + description: Added a description + required: true + state: present + register: test_three + +- name: "CUSTOM_FIELD 3: ASSERT - Updated" + ansible.builtin.assert: + that: + - test_three is changed + - test_three['diff']['after']['description'] == "Added a description" + - test_three['diff']['after']['required'] == true + - test_three['custom_field']['name'] == "A_CustomField" + - test_three['msg'] == "custom_field A_CustomField updated" + +- name: "CUSTOM_FIELD 4: Change content type" + netbox.netbox.netbox_custom_field: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + object_types: + - virtualization.virtualmachine + name: A_CustomField + description: Added a description + required: true + state: present + register: test_four + +- name: "CUSTOM_FIELD 4: ASSERT - Change content type" + ansible.builtin.assert: + that: + - test_four is changed + - test_four['diff']['after']['object_types'] == ["virtualization.virtualmachine"] + - test_four['custom_field']['name'] == "A_CustomField" + - test_four['msg'] == "custom_field A_CustomField updated" + +- name: "CUSTOM_FIELD 5: Delete" + netbox.netbox.netbox_custom_field: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: A_CustomField + state: absent + register: test_five + +- name: "CUSTOM_FIELD 5: ASSERT - Deleted" + ansible.builtin.assert: + that: + - test_five is changed + - test_five['diff']['after']['state'] == "absent" + - test_five['custom_field']['name'] == "A_CustomField" + - test_five['msg'] == "custom_field A_CustomField deleted" + +# Change in NetBox 3.7 +# - name: "CUSTOM_FIELD 6: UI Visibility (hidden-ifunset)" +# netbox.netbox.netbox_custom_field: +# netbox_url: http://localhost:32768 +# netbox_token: 0123456789abcdef0123456789abcdef01234567 +# data: +# object_types: +# - "dcim.device" +# name: A_CustomField +# type: text +# ui_visibility: hidden-ifunset +# state: present +# register: test_six + +# - name: "CUSTOM_FIELD 6: UI Visibility (hidden-ifunset)" +# assert: +# that: +# - test_six is changed +# - test_six['custom_field']['name'] == "A_CustomField" +# - test_six['custom_field']['ui_visibility'] == "hidden-ifunset" diff --git a/tests/integration/targets/v4.3/tasks/netbox_custom_link.yml b/tests/integration/targets/v4.3/tasks/netbox_custom_link.yml new file mode 100644 index 000000000..3aa29d958 --- /dev/null +++ b/tests/integration/targets/v4.3/tasks/netbox_custom_link.yml @@ -0,0 +1,113 @@ +--- +## +## +### NETBOX_CUSTOM_LINK +## +## +- name: "CUSTOM_LINK 1: Necessary info creation" + netbox.netbox.netbox_custom_link: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + object_types: + - dcim.device + name: Custom Link + link_text: Open Web management + link_url: !unsafe https://{{ obj.name }}.domain.local/ + state: present + register: test_one + +- name: "CUSTOM_LINK 1: ASSERT - Necessary info creation" + ansible.builtin.assert: + that: + - test_one is changed + - test_one['diff']['before']['state'] == "absent" + - test_one['diff']['after']['state'] == "present" + - test_one['custom_link']['name'] == "Custom Link" + - test_one['custom_link']['object_types'] == ["dcim.device"] + - test_one['custom_link']['link_text'] == "Open Web management" + - test_one['msg'] == "custom_link Custom Link created" + +- name: "CUSTOM_LINK 2: Create duplicate" + netbox.netbox.netbox_custom_link: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + object_types: + - dcim.device + name: Custom Link + link_text: Open Web management + link_url: !unsafe https://{{ obj.name }}.domain.local/ + state: present + register: test_two + +- name: "CUSTOM_LINK 2: ASSERT - Create duplicate" + ansible.builtin.assert: + that: + - not test_two['changed'] + - test_two['custom_link']['name'] == "Custom Link" + - test_two['msg'] == "custom_link Custom Link already exists" + +- name: "CUSTOM_FIELD 3: Update data and add weight" + netbox.netbox.netbox_custom_link: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + object_types: + - dcim.device + name: Custom Link + link_text: Open Web management + link_url: !unsafe https://{{ obj.name }}.domain.local/ + weight: 50 + state: present + register: test_three + +- name: "CUSTOM_FIELD 3: ASSERT - Updated" + ansible.builtin.assert: + that: + - test_three is changed + - test_three['diff']['after']['weight'] == 50 + - test_three['custom_link']['name'] == "Custom Link" + - test_three['msg'] == "custom_link Custom Link updated" + +- name: "CUSTOM_LINK 4: Change content type" + netbox.netbox.netbox_custom_link: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + object_types: + - virtualization.virtualmachine + name: Custom Link + link_text: Open Web management + link_url: !unsafe https://{{ obj.name }}.domain.local/ + state: present + register: test_four + +- name: "CUSTOM_LINK 4: ASSERT - Change content type" + ansible.builtin.assert: + that: + - test_four is changed + - test_four['diff']['after']['object_types'] == ["virtualization.virtualmachine"] + - test_four['custom_link']['name'] == "Custom Link" + - test_four['msg'] == "custom_link Custom Link updated" + +- name: "CUSTOM_LINK 5: Delete" + netbox.netbox.netbox_custom_link: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + object_types: + - virtualization.virtualmachine + name: Custom Link + link_text: Open Web management + link_url: !unsafe https://{{ obj.name }}.domain.local/ + state: absent + register: test_five + +- name: "CUSTOM_LINK 5: ASSERT - Deleted" + ansible.builtin.assert: + that: + - test_five is changed + - test_five['diff']['after']['state'] == "absent" + - test_five['custom_link']['name'] == "Custom Link" + - test_five['msg'] == "custom_link Custom Link deleted" diff --git a/tests/integration/targets/v4.3/tasks/netbox_data_source.yml b/tests/integration/targets/v4.3/tasks/netbox_data_source.yml new file mode 100644 index 000000000..9fd954cba --- /dev/null +++ b/tests/integration/targets/v4.3/tasks/netbox_data_source.yml @@ -0,0 +1,75 @@ +--- +## +## +### NETBOX_DATA_SOURCE +## +## +- name: "DATA SOURCE 1: Create" + netbox.netbox.netbox_data_source: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: "Data Source 1" + type: "local" + source_url: "/tmp/data-source.txt" + enabled: true + state: present + register: test_one + +- name: "DATA SOURCE 1: Assert - Create" + ansible.builtin.assert: + that: + - test_one is changed + - test_one['diff']['before']['state'] == "absent" + - test_one['diff']['after']['state'] == "present" + - test_one['data_source']['name'] == "Data Source 1" + - test_one['data_source']['type'] == "local" + - test_one['data_source']['source_url'] == "/tmp/data-source.txt" + - test_one['data_source']['enabled'] == true + - test_one['msg'] == "data_source Data Source 1 created" + +- name: "DATA SOURCE 2: Update" + netbox.netbox.netbox_data_source: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: "Data Source 1" + type: "amazon-s3" + source_url: "path/to/bucket" + enabled: false + description: "My first data source" + ignore_rules: ".*\nfoo.txt\n*.yml" + sync_interval: 1440 + comments: "Some commentary on this data source" + state: present + register: test_two + +- name: "DATA SOURCE 2: Assert - Update" + ansible.builtin.assert: + that: + - test_two is changed + - test_two['data_source']['name'] == "Data Source 1" + - test_two['data_source']['type'] == "amazon-s3" + - test_two['data_source']['source_url'] == "path/to/bucket" + - test_two['data_source']['enabled'] == false + - test_two['data_source']['description'] == "My first data source" + - test_two['data_source']['ignore_rules'] == ".*\nfoo.txt\n*.yml" + - test_two['data_source']['sync_interval'] == 1440 + - test_two['data_source']['comments'] == "Some commentary on this data source" + - test_two['msg'] == "data_source Data Source 1 updated" + +- name: "DATA SOURCE 3: Delete" + netbox.netbox.netbox_data_source: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: "Data Source 1" + state: absent + register: test_three + +- name: "DATA SOURCE 3: Assert - Delete" + ansible.builtin.assert: + that: + - test_three is changed + - test_three['diff']['before']['state'] == "present" + - test_three['diff']['after']['state'] == "absent" diff --git a/tests/integration/targets/v4.3/tasks/netbox_device.yml b/tests/integration/targets/v4.3/tasks/netbox_device.yml new file mode 100644 index 000000000..4d42e6e71 --- /dev/null +++ b/tests/integration/targets/v4.3/tasks/netbox_device.yml @@ -0,0 +1,243 @@ +--- +## +## +### NETBOX_DEVICE +## +## +- name: 1 - Device with required information + netbox.netbox.netbox_device: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: R1 + device_type: + id: "1" + device_role: Core Switch + site: Test Site + status: Staged + state: present + register: test_one + +- name: 1 - ASSERT + ansible.builtin.assert: + that: + - test_one is changed + - test_one['diff']['before']['state'] == 'absent' + - test_one['diff']['after']['state'] == 'present' + - test_one['device']['name'] == "R1" + - test_one['device']['role'] == 1 + - test_one['device']['device_type'] == 1 + - test_one['device']['site'] == 1 + - test_one['device']['status'] == "staged" + - test_one['device']['name'] == "R1" + - test_one['msg'] == "device R1 created" + +- name: 2 - Duplicate device + netbox.netbox.netbox_device: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: R1 + device_type: Cisco Test + device_role: Core Switch + site: Test Site + status: Staged + state: present + register: test_two + +- name: 2 - ASSERT + ansible.builtin.assert: + that: + - not test_two['changed'] + - test_two['device']['name'] == "R1" + - test_two['device']['role'] == 1 + - test_two['device']['device_type'] == 1 + - test_two['device']['site'] == 1 + - test_two['device']['status'] == "staged" + - test_two['msg'] == "device R1 already exists" + +- name: 3 - Update device + netbox.netbox.netbox_device: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: R1 + serial: FXS1001 + local_context_data: + bgp_as: "65412" + virtual_chassis: VC1 + vc_position: 3 + vc_priority: 15 + location: Test Rack Group + state: present + register: test_three + +- name: 3 - ASSERT + ansible.builtin.assert: + that: + - test_three is changed + - test_three['diff']['after']['serial'] == "FXS1001" + - test_three['diff']['after']['local_context_data']["bgp_as"] == "65412" + - test_three['diff']['after']['virtual_chassis'] == 1 + - test_three['diff']['after']['vc_position'] == 3 + - test_three['diff']['after']['vc_priority'] == 15 + - test_three['device']['name'] == "R1" + - test_three['device']['role'] == 1 + - test_three['device']['device_type'] == 1 + - test_three['device']['site'] == 1 + - test_three['device']['status'] == "staged" + - test_three['device']['serial'] == "FXS1001" + - test_three['device']['local_context_data']["bgp_as"] == "65412" + - test_three['device']['virtual_chassis'] == 1 + - test_three['device']['vc_position'] == 3 + - test_three['device']['vc_priority'] == 15 + - test_three['device']['location'] == 1 + - test_three['msg'] == "device R1 updated" + +- name: 3.1 - Update device name using query_params + netbox.netbox.netbox_device: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: R1-changed-name + serial: FXS1001 + query_params: + - serial + state: present + register: test_three_dot_one + +- name: 3.1 - ASSERT + ansible.builtin.assert: + that: + - test_three_dot_one is changed + - test_three_dot_one['diff']['after']['name'] == "R1-changed-name" + - test_three_dot_one['device']['role'] == 1 + - test_three_dot_one['device']['device_type'] == 1 + - test_three_dot_one['device']['site'] == 1 + - test_three_dot_one['device']['status'] == "staged" + - test_three_dot_one['device']['serial'] == "FXS1001" + - test_three_dot_one['device']['local_context_data']["bgp_as"] == "65412" + - test_three_dot_one['msg'] == "device R1-changed-name updated" + +- name: 4 - Create device with tags and assign to rack + netbox.netbox.netbox_device: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: TestR1 + device_type: "1841" + device_role: Core Switch + site: Test Site2 + rack: Test Rack Site 2 + position: 35.5 + face: Front + tags: + - schnozzberry + tenant: Test Tenant + asset_tag: "1234" + state: present + register: test_four + +- name: 4 - ASSERT + ansible.builtin.assert: + that: + - test_four is changed + - test_four['diff']['before']['state'] == "absent" + - test_four['diff']['after']['state'] == "present" + - test_four['device']['name'] == "TestR1" + - test_four['device']['role'] == 1 + - test_four['device']['device_type'] == 5 + - test_four['device']['site'] == 2 + - test_four['device']['status'] == "active" + - test_four['device']['rack'] == 1 + - test_four['device']['tags'][0] == 4 + - test_four['device']['tenant'] == 1 + - test_four['device']['asset_tag'] == '1234' + - test_four['msg'] == "device TestR1 created" + +- name: 5 - Delete previous device + netbox.netbox.netbox_device: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: TestR1 + state: absent + register: test_five + +- name: 5 - ASSERT + ansible.builtin.assert: + that: + - test_five is changed + - test_five['diff']['before']['state'] == "present" + - test_five['diff']['after']['state'] == "absent" + - test_five['msg'] == "device TestR1 deleted" + +- name: 6 - Delete R1 + netbox.netbox.netbox_device: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: R1-changed-name + state: absent + register: test_six + +- name: 6 - ASSERT + ansible.builtin.assert: + that: + - test_six is changed + - test_six['diff']['before']['state'] == "present" + - test_six['diff']['after']['state'] == "absent" + - test_six['msg'] == "device R1-changed-name deleted" + +- name: 7 - Add primary_ip4/6 to test100 + netbox.netbox.netbox_device: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: test100 + primary_ip4: 172.16.180.1/24 + primary_ip6: 2001::1:1/64 + state: present + register: test_seven + +- name: 7 - ASSERT + ansible.builtin.assert: + that: + - test_seven is changed + - test_seven['diff']['after']['primary_ip4'] == 1 + - test_seven['diff']['after']['primary_ip6'] == 2 + - test_seven['device']['name'] == "test100" + - test_seven['device']['role'] == 1 + - test_seven['device']['device_type'] == 1 + - test_seven['device']['site'] == 1 + - test_seven['device']['status'] == "active" + - test_seven['device']['primary_ip4'] == 1 + - test_seven['device']['primary_ip6'] == 2 + - test_seven['msg'] == "device test100 updated" + +- name: 8 - Device with empty string name + netbox.netbox.netbox_device: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: "" + device_type: + id: 1 + device_role: Core Switch + site: Test Site + status: Staged + state: present + register: test_eight + +- name: 8 - ASSERT + ansible.builtin.assert: + that: + - test_eight is changed + - test_eight['diff']['before']['state'] == 'absent' + - test_eight['diff']['after']['state'] == 'present' + - test_eight['device']['role'] == 1 + - test_eight['device']['device_type'] == 1 + - test_eight['device']['site'] == 1 + - test_eight['device']['status'] == "staged" + - "'-' in test_eight['device']['name']" + - test_eight['device']['name'] | length == 36 diff --git a/tests/integration/targets/v4.3/tasks/netbox_device_bay.yml b/tests/integration/targets/v4.3/tasks/netbox_device_bay.yml new file mode 100644 index 000000000..b892d2160 --- /dev/null +++ b/tests/integration/targets/v4.3/tasks/netbox_device_bay.yml @@ -0,0 +1,87 @@ +--- +## +## +### NETBOX_DEVICE_BAY +## +## +- name: "DEVICE_BAY 1: Necessary info creation" + netbox.netbox.netbox_device_bay: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + device: Test Nexus One + name: Device Bay One + state: present + register: test_one + +- name: "DEVICE_BAY 1: ASSERT - Necessary info creation" + ansible.builtin.assert: + that: + - test_one is changed + - test_one['diff']['before']['state'] == "absent" + - test_one['diff']['after']['state'] == "present" + - test_one['device_bay']['name'] == "Device Bay One" + - test_one['device_bay']['device'] == 4 + - test_one['msg'] == "device_bay Device Bay One created" + +- name: "DEVICE_BAY 2: Create duplicate" + netbox.netbox.netbox_device_bay: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + device: Test Nexus One + name: Device Bay One + state: present + register: test_two + +- name: "DEVICE_BAY 2: ASSERT - Create duplicate" + ansible.builtin.assert: + that: + - not test_two['changed'] + - test_two['device_bay']['name'] == "Device Bay One" + - test_two['device_bay']['device'] == 4 + - test_two['msg'] == "device_bay Device Bay One already exists" + +- name: "DEVICE_BAY 3: ASSERT - Update" + netbox.netbox.netbox_device_bay: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + device: Test Nexus One + name: Device Bay One + installed_device: Test Nexus Child One + tags: + - Schnozzberry + state: present + register: test_three + +- name: "DEVICE_BAY 3: ASSERT - Updated" + ansible.builtin.assert: + that: + - test_three is changed + - test_three['diff']['after']['installed_device'] == 5 + - test_three['diff']['after']['tags'][0] == 4 + - test_three['device_bay']['name'] == "Device Bay One" + - test_three['device_bay']['device'] == 4 + - test_three['device_bay']['installed_device'] == 5 + - test_three['device_bay']['tags'][0] == 4 + - test_three['msg'] == "device_bay Device Bay One updated" + +- name: "DEVICE_BAY 4: ASSERT - Delete" + netbox.netbox.netbox_device_bay: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Device Bay One + state: absent + register: test_four + +- name: "DEVICE_BAY 4: ASSERT - Delete" + ansible.builtin.assert: + that: + - test_four is changed + - test_four['device_bay']['name'] == "Device Bay One" + - test_four['device_bay']['device'] == 4 + - test_four['device_bay']['installed_device'] == 5 + - test_four['device_bay']['tags'][0] == 4 + - test_four['msg'] == "device_bay Device Bay One deleted" diff --git a/tests/integration/targets/v4.3/tasks/netbox_device_bay_template.yml b/tests/integration/targets/v4.3/tasks/netbox_device_bay_template.yml new file mode 100644 index 000000000..c2ba1e32c --- /dev/null +++ b/tests/integration/targets/v4.3/tasks/netbox_device_bay_template.yml @@ -0,0 +1,81 @@ +--- +## +## +### NETBOX_DEVICE_BAY_TEMPLATE +## +## +- name: "DEVICE_BAY_TEMPLATE 1: Necessary info creation" + netbox.netbox.netbox_device_bay_template: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + device_type: WS Test 3850 + name: Device Bay Template One + state: present + register: test_one + +- name: "DEVICE_BAY_TEMPLATE 1: ASSERT - Necessary info creation" + ansible.builtin.assert: + that: + - test_one is changed + - test_one['diff']['before']['state'] == "absent" + - test_one['diff']['after']['state'] == "present" + - test_one['device_bay_template']['name'] == "Device Bay Template One" + - test_one['device_bay_template']['device_type'] == 7 + - test_one['msg'] == "device_bay_template Device Bay Template One created" + +- name: "DEVICE_BAY_TEMPLATE 2: Create duplicate" + netbox.netbox.netbox_device_bay_template: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + device_type: WS Test 3850 + name: Device Bay Template One + state: present + register: test_two + +- name: "DEVICE_BAY_TEMPLATE 2: ASSERT - Create duplicate" + ansible.builtin.assert: + that: + - not test_two['changed'] + - test_two['device_bay_template']['name'] == "Device Bay Template One" + - test_two['device_bay_template']['device_type'] == 7 + - test_two['msg'] == "device_bay_template Device Bay Template One already exists" + +- name: "DEVICE_BAY_TEMPLATE 3: ASSERT - Create Device Bay Template for Delete Test" + netbox.netbox.netbox_device_bay_template: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + device_type: WS Test 3850 + name: Device Bay Template Two + state: present + register: test_three + +- name: "DEVICE_BAY_TEMPLATE 3: ASSERT - Updated" + ansible.builtin.assert: + that: + - test_three is changed + - test_three['diff']['before']['state'] == "absent" + - test_three['diff']['after']['state'] == "present" + - test_three['device_bay_template']['name'] == "Device Bay Template Two" + - test_three['device_bay_template']['device_type'] == 7 + - test_three['msg'] == "device_bay_template Device Bay Template Two created" + +- name: "DEVICE_BAY_TEMPLATE 4: ASSERT - Delete" + netbox.netbox.netbox_device_bay_template: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Device Bay Template Two + device_type: WS Test 3850 + state: absent + register: test_four + +- name: "DEVICE_BAY_TEMPLATE 4: ASSERT - Delete" + ansible.builtin.assert: + that: + - test_four is changed + - test_four['device_bay_template']['name'] == "Device Bay Template Two" + - test_four['device_bay_template']['device_type'] == 7 + - test_four['msg'] == "device_bay_template Device Bay Template Two deleted" diff --git a/tests/integration/targets/v4.3/tasks/netbox_device_interface.yml b/tests/integration/targets/v4.3/tasks/netbox_device_interface.yml new file mode 100644 index 000000000..5013b6edc --- /dev/null +++ b/tests/integration/targets/v4.3/tasks/netbox_device_interface.yml @@ -0,0 +1,332 @@ +--- +# NETBOX_DEVICE_INTERFACE + +- name: 1 - Interface with required information + netbox.netbox.netbox_device_interface: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + device: test100 + name: GigabitEthernet3 + type: 1000Base-T (1GE) + register: test_one + +- name: 1 - ASSERT + ansible.builtin.assert: + that: + - test_one is changed + - test_one['msg'] == "interface GigabitEthernet3 created" + - test_one['diff']['before']['state'] == 'absent' + - test_one['diff']['after']['state'] == 'present' + - test_one['interface']['name'] == "GigabitEthernet3" + - test_one['interface']['device'] == 1 + +- name: 2 - Update test100 - GigabitEthernet3 + netbox.netbox.netbox_device_interface: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + device: test100 + name: GigabitEthernet3 + mtu: 1600 + enabled: false + register: test_two + +- name: 2 - ASSERT + ansible.builtin.assert: + that: + - test_two is changed + - test_two['msg'] == "interface GigabitEthernet3 updated" + - test_two['diff']['after']['enabled'] == false + - test_two['diff']['after']['mtu'] == 1600 + - test_two['interface']['name'] == "GigabitEthernet3" + - test_two['interface']['device'] == 1 + - test_two['interface']['enabled'] == false + - test_two['interface']['mtu'] == 1600 + +- name: 3 - Delete interface test100 - GigabitEthernet3 + netbox.netbox.netbox_device_interface: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + device: test100 + name: GigabitEthernet3 + state: absent + register: test_three + +- name: 3 - ASSERT + ansible.builtin.assert: + that: + - test_three is changed + - test_three['msg'] == "interface GigabitEthernet3 deleted" + - test_three['diff']['before']['state'] == "present" + - test_three['diff']['after']['state'] == "absent" + +- name: 4 - Create LAG with several specified options + netbox.netbox.netbox_device_interface: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + device: test100 + name: port-channel1 + type: Link Aggregation Group (LAG) + mtu: 1600 + mgmt_only: false + mode: Access + state: present + register: test_four + +- name: 4 - ASSERT + ansible.builtin.assert: + that: + - test_four is changed + - test_four['msg'] == "interface port-channel1 created" + - test_four['diff']['before']['state'] == 'absent' + - test_four['diff']['after']['state'] == 'present' + - test_four['interface']['name'] == "port-channel1" + - test_four['interface']['device'] == 1 + - test_four['interface']['enabled'] == true + - test_four['interface']['type'] == "lag" + - test_four['interface']['mgmt_only'] == false + - test_four['interface']['mode'] == "access" + - test_four['interface']['mtu'] == 1600 + +- name: 5 - Create interface and assign it to parent LAG + netbox.netbox.netbox_device_interface: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + device: test100 + name: GigabitEthernet3 + enabled: false + type: 1000Base-T (1GE) + lag: + name: port-channel1 + mtu: 1600 + mgmt_only: false + mode: Access + state: present + register: test_five + +- name: 5 - ASSERT + ansible.builtin.assert: + that: + - test_five is changed + - test_five['msg'] == "interface GigabitEthernet3 created" + - test_five['diff']['before']['state'] == 'absent' + - test_five['diff']['after']['state'] == 'present' + - test_five['interface']['name'] == "GigabitEthernet3" + - test_five['interface']['device'] == 1 + - test_five['interface']['enabled'] == false + - test_five['interface']['type'] == "1000base-t" + - test_five['interface']['mgmt_only'] == false + - test_five['interface']['lag'] == test_four["interface"]["id"] + - test_five['interface']['mode'] == "access" + - test_five['interface']['mtu'] == 1600 + +- name: 6 - Create interface as trunk port + netbox.netbox.netbox_device_interface: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + device: test100 + name: GigabitEthernet21 + enabled: false + type: 1000Base-T (1GE) + untagged_vlan: + name: Wireless + site: Test Site + tagged_vlans: + - name: Data + site: Test Site + - name: VoIP + site: Test Site + mtu: 1600 + mgmt_only: true + mode: Tagged + state: present + register: test_six + +- name: 6 - ASSERT + ansible.builtin.assert: + that: + - test_six is changed + - test_six['msg'] == "interface GigabitEthernet21 created" + - test_six['diff']['before']['state'] == 'absent' + - test_six['diff']['after']['state'] == 'present' + - test_six['interface']['name'] == "GigabitEthernet21" + - test_six['interface']['device'] == 1 + - test_six['interface']['enabled'] == false + - test_six['interface']['type'] == "1000base-t" + - test_six['interface']['mgmt_only'] == true + - test_six['interface']['mode'] == "tagged" + - test_six['interface']['mtu'] == 1600 + - test_six['interface']['tagged_vlans'] == [2, 3] + - test_six['interface']['untagged_vlan'] == 1 + +- name: 7 - Duplicate Interface + netbox.netbox.netbox_device_interface: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + device: test100 + name: GigabitEthernet1 + register: test_seven + +- name: 7 - ASSERT + ansible.builtin.assert: + that: + - not test_seven['changed'] + - test_seven['msg'] == "interface GigabitEthernet1 already exists" + - test_seven['interface']['name'] == "GigabitEthernet1" + - test_seven['interface']['device'] == 1 + +- name: Add port-channel1 to R1 to test finding proper port-channel1 + netbox.netbox.netbox_device_interface: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + device: R1-Device + name: port-channel1 + type: Link Aggregation Group (LAG) + +- name: 8 - Create interface and assign it to parent LAG - non dict + netbox.netbox.netbox_device_interface: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + device: test100 + name: GigabitEthernet4 + enabled: false + type: 1000Base-T (1GE) + lag: port-channel1 + mtu: 1600 + mgmt_only: false + mode: Access + state: present + register: test_eight + +- name: 8 - ASSERT + ansible.builtin.assert: + that: + - test_eight is changed + - test_eight['msg'] == "interface GigabitEthernet4 created" + - test_eight['diff']['before']['state'] == 'absent' + - test_eight['diff']['after']['state'] == 'present' + - test_eight['interface']['name'] == "GigabitEthernet4" + - test_eight['interface']['device'] == 1 + - test_eight['interface']['enabled'] == false + - test_eight['interface']['type'] == "1000base-t" + - test_eight['interface']['mgmt_only'] == false + - test_eight['interface']['lag'] == 10 + - test_eight['interface']['mode'] == "access" + - test_eight['interface']['mtu'] == 1600 + +- name: 9 - Create interface on VC child + netbox.netbox.netbox_device_interface: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + device: Test Nexus Child One + name: Ethernet2/2 + type: 1000Base-T (1GE) + state: present + register: test_nine + +- name: 9 - ASSERT + ansible.builtin.assert: + that: + - test_nine is changed + - test_nine['msg'] == "interface Ethernet2/2 created" + - test_nine['diff']['before']['state'] == 'absent' + - test_nine['diff']['after']['state'] == 'present' + - test_nine['interface']['name'] == "Ethernet2/2" + - test_nine['interface']['device'] == 5 + - test_nine['interface']['enabled'] == true + - test_nine['interface']['type'] == "1000base-t" + +- name: 10 - Update interface on VC child + netbox.netbox.netbox_device_interface: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + device: Test Nexus One + name: Ethernet2/2 + description: Updated child interface from parent device + type: 1000Base-T (1GE) + update_vc_child: true + state: present + register: test_ten + +- name: 10 - ASSERT + ansible.builtin.assert: + that: + - test_ten is changed + - test_ten['msg'] == "interface Ethernet2/2 updated" + - test_ten['diff']['after']['description'] == 'Updated child interface from parent device' + - test_ten['interface']['name'] == "Ethernet2/2" + - test_ten['interface']['device'] == 5 + - test_ten['interface']['enabled'] == true + - test_ten['interface']['type'] == "1000base-t" + - test_ten['interface']['description'] == 'Updated child interface from parent device' + +- name: 11 - Update interface on VC child w/o update_vc_child + netbox.netbox.netbox_device_interface: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + device: Test Nexus One + name: Ethernet2/2 + description: Updated child interface from parent device - test + type: 1000Base-T (1GE) + state: present + ignore_errors: true + register: test_eleven + +- name: 11 - ASSERT + ansible.builtin.assert: + that: + - test_eleven is failed + - test_eleven['msg'] == "Must set update_vc_child to True to allow child device interface modification" + +- name: 12 - Create interface and mark it as connected + netbox.netbox.netbox_device_interface: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + device: test100 + name: GigabitEthernet5 + type: 1000Base-T (1GE) + mark_connected: true + register: test_twelve + +- name: 12- ASSERT + ansible.builtin.assert: + that: + - test_twelve is changed + - test_twelve['msg'] == "interface GigabitEthernet5 created" + - test_twelve['diff']['before']['state'] == 'absent' + - test_twelve['diff']['after']['state'] == 'present' + - test_twelve['interface']['name'] == "GigabitEthernet5" + - test_twelve['interface']['device'] == 1 + - test_twelve['interface']['mark_connected'] == true + +- name: "13 - Update interface primary MAC address" + netbox.netbox.netbox_device_interface: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + device: test100 + name: GigabitEthernet2 + primary_mac_address: "AA:AB:CC:DD:EE:FF" + state: present + register: test_thirteen + +- name: "13 - ASSERT" + ansible.builtin.assert: + that: + - test_thirteen is changed + - test_thirteen['msg'] == "interface GigabitEthernet2 updated" + - test_thirteen['interface']['name'] == "GigabitEthernet2" + - test_thirteen['interface']['device'] == 1 + - test_thirteen['interface']['primary_mac_address'] == 2 diff --git a/tests/integration/targets/v4.3/tasks/netbox_device_interface_template.yml b/tests/integration/targets/v4.3/tasks/netbox_device_interface_template.yml new file mode 100644 index 000000000..abe8f3405 --- /dev/null +++ b/tests/integration/targets/v4.3/tasks/netbox_device_interface_template.yml @@ -0,0 +1,109 @@ +--- +## +## +### NETBOX_DEVICE_INTERFACE_TEMPLATE +## +## +- name: 1 - Interface with required information + netbox.netbox.netbox_device_interface_template: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + device_type: Arista Test + name: 10GBASE-T (10GE) + type: 10gbase-t + register: test_one + +- name: 1 - ASSERT + ansible.builtin.assert: + that: + - test_one is changed + - test_one['msg'] == "interface_template 10GBASE-T (10GE) created" + - test_one['diff']['before']['state'] == 'absent' + - test_one['diff']['after']['state'] == 'present' + - test_one['interface_template']['name'] == "10GBASE-T (10GE)" + - test_one['interface_template']['device_type'] == 2 + - test_one['interface_template']['type'] == '10gbase-t' + +- name: 2 - Update 10GBASE-T (10GE) + netbox.netbox.netbox_device_interface_template: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + device_type: Arista Test + name: 10GBASE-T (10GE) + type: 10gbase-t + mgmt_only: true + register: test_two + +- name: 2 - ASSERT + ansible.builtin.assert: + that: + - test_two is changed + - test_two['msg'] == "interface_template 10GBASE-T (10GE) updated" + - test_two['diff']['after']['mgmt_only'] == true + - test_two['interface_template']['name'] == "10GBASE-T (10GE)" + - test_two['interface_template']['device_type'] == 2 + - test_two['interface_template']['mgmt_only'] == true + +- name: 3 - Delete interface template 10GBASE-T (10GE) + netbox.netbox.netbox_device_interface_template: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + device_type: Arista Test + name: 10GBASE-T (10GE) + type: 10gbase-t + state: absent + register: test_three + +- name: 3 - ASSERT + ansible.builtin.assert: + that: + - test_three is changed + - test_three['msg'] == "interface_template 10GBASE-T (10GE) deleted" + - test_three['diff']['before']['state'] == "present" + - test_three['diff']['after']['state'] == "absent" + +- name: 4 - Create LAG with several specified options + netbox.netbox.netbox_device_interface_template: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + device_type: Arista Test + name: port channel template + type: lag + mgmt_only: false + state: present + register: test_four + +- name: 4 - ASSERT + ansible.builtin.assert: + that: + - test_four is changed + - test_four['msg'] == "interface_template port channel template created" + - test_four['diff']['before']['state'] == 'absent' + - test_four['diff']['after']['state'] == 'present' + - test_four['interface_template']['name'] == "port channel template" + - test_four['interface_template']['device_type'] == 2 + - test_four['interface_template']['type'] == "lag" + - test_four['interface_template']['mgmt_only'] == false + +- name: 5 - Duplicate Interface Template port channel template + netbox.netbox.netbox_device_interface_template: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + device_type: Arista Test + name: port channel template + type: lag + register: test_five + +- name: 5 - ASSERT + ansible.builtin.assert: + that: + - not test_five['changed'] + - test_five['msg'] == "interface_template port channel template already exists" + - test_five['interface_template']['name'] == "port channel template" + - test_five['interface_template']['device_type'] == 2 + - test_five['interface_template']['type'] == "lag" diff --git a/tests/integration/targets/v4.3/tasks/netbox_device_role.yml b/tests/integration/targets/v4.3/tasks/netbox_device_role.yml new file mode 100644 index 000000000..b85ee2c86 --- /dev/null +++ b/tests/integration/targets/v4.3/tasks/netbox_device_role.yml @@ -0,0 +1,101 @@ +--- +## +## +### NETBOX_DEVICE_ROLE +## +## +- name: "DEVICE_ROLE 1: Necessary info creation" + netbox.netbox.netbox_device_role: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test Device Role + color: FFFFFF + state: present + register: test_one + +- name: "DEVICE_ROLE 1: ASSERT - Necessary info creation" + ansible.builtin.assert: + that: + - test_one is changed + - test_one['diff']['before']['state'] == "absent" + - test_one['diff']['after']['state'] == "present" + - test_one['device_role']['name'] == "Test Device Role" + - test_one['device_role']['slug'] == "test-device-role" + - test_one['device_role']['color'] == "ffffff" + - test_one['msg'] == "device_role Test Device Role created" + +- name: "DEVICE_ROLE 2: Create duplicate" + netbox.netbox.netbox_device_role: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test Device Role + color: FFFFFF + state: present + register: test_two + +- name: "DEVICE_ROLE 2: ASSERT - Create duplicate" + ansible.builtin.assert: + that: + - not test_two['changed'] + - test_two['device_role']['name'] == "Test Device Role" + - test_two['device_role']['slug'] == "test-device-role" + - test_two['device_role']['color'] == "ffffff" + - test_two['msg'] == "device_role Test Device Role already exists" + +- name: "DEVICE_ROLE 3: ASSERT - Update" + netbox.netbox.netbox_device_role: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test Device Role + color: "003EFF" + vm_role: false + state: present + register: test_three + +- name: "DEVICE_ROLE 3: ASSERT - Update" + ansible.builtin.assert: + that: + - test_three is changed + - test_three['diff']['after']['color'] == "003eff" + - test_three['diff']['after']['vm_role'] == false + - test_three['device_role']['name'] == "Test Device Role" + - test_three['device_role']['slug'] == "test-device-role" + - test_three['device_role']['color'] == "003eff" + - test_three['device_role']['vm_role'] == false + - test_three['msg'] == "device_role Test Device Role updated" + +- name: "DEVICE_ROLE 4: ASSERT - Delete" + netbox.netbox.netbox_device_role: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test Device Role + state: absent + register: test_four + +- name: "DEVICE_ROLE 4: ASSERT - Delete" + ansible.builtin.assert: + that: + - test_four is changed + - test_four['diff']['before']['state'] == "present" + - test_four['diff']['after']['state'] == "absent" + - test_four['msg'] == "device_role Test Device Role deleted" + +- name: "DEVICE_ROLE 5: ASSERT - Delete non existing" + netbox.netbox.netbox_device_role: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test Device Role + state: absent + register: test_five + +- name: "DEVICE_ROLE 5: ASSERT - Delete non existing`" + ansible.builtin.assert: + that: + - not test_five['changed'] + - test_five['device_role'] == None + - test_five['msg'] == "device_role Test Device Role already absent" diff --git a/tests/integration/targets/v4.3/tasks/netbox_device_type.yml b/tests/integration/targets/v4.3/tasks/netbox_device_type.yml new file mode 100644 index 000000000..3027f6fd1 --- /dev/null +++ b/tests/integration/targets/v4.3/tasks/netbox_device_type.yml @@ -0,0 +1,132 @@ +--- +## +## +### NETBOX_DEVICE_TYPE +## +## +- name: "DEVICE_TYPE 1: Necessary info creation" + netbox.netbox.netbox_device_type: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + slug: test-device-type + model: ws-test-3750 + manufacturer: Test Manufacturer + state: present + register: test_one + +- name: "DEVICE_TYPE 1: ASSERT - Necessary info creation" + ansible.builtin.assert: + that: + - test_one is changed + - test_one['diff']['before']['state'] == "absent" + - test_one['diff']['after']['state'] == "present" + - test_one['device_type']['slug'] == "test-device-type" + - test_one['device_type']['model'] == "ws-test-3750" + - test_one['device_type']['manufacturer'] == 3 + - test_one['msg'] == "device_type test-device-type created" + +- name: "DEVICE_TYPE 2: Create duplicate" + netbox.netbox.netbox_device_type: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + slug: test-device-type + model: ws-test-3750 + manufacturer: Test Manufacturer + state: present + register: test_two + +- name: "DEVICE_TYPE 2: ASSERT - Create duplicate" + ansible.builtin.assert: + that: + - not test_two['changed'] + - test_one['device_type']['slug'] == "test-device-type" + - test_one['device_type']['model'] == "ws-test-3750" + - test_one['device_type']['manufacturer'] == 3 + - test_two['msg'] == "device_type test-device-type already exists" + +- name: "DEVICE_TYPE 3: ASSERT - Update" + netbox.netbox.netbox_device_type: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + slug: test-device-type + model: ws-test-3750 + manufacturer: Test Manufacturer + part_number: ws-3750g-v2 + u_height: 1.5 + is_full_depth: false + subdevice_role: parent + state: present + register: test_three + +- name: "DEVICE_TYPE 3: ASSERT - Update" + ansible.builtin.assert: + that: + - test_three is changed + - test_three['diff']['after']['is_full_depth'] == false + - test_three['diff']['after']['part_number'] == "ws-3750g-v2" + - test_three['diff']['after']['subdevice_role'] == "parent" + - test_three['device_type']['slug'] == "test-device-type" + - test_three['device_type']['model'] == "ws-test-3750" + - test_three['device_type']['manufacturer'] == 3 + - test_three['device_type']['is_full_depth'] == false + - test_three['device_type']['part_number'] == "ws-3750g-v2" + - test_three['device_type']['subdevice_role'] == "parent" + - test_three['msg'] == "device_type test-device-type updated" + +- name: "DEVICE_TYPE 4: ASSERT - Delete" + netbox.netbox.netbox_device_type: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + model: test-device-type + state: absent + register: test_four + +- name: "DEVICE_TYPE 4: ASSERT - Delete" + ansible.builtin.assert: + that: + - test_four is changed + - test_four['diff']['before']['state'] == "present" + - test_four['diff']['after']['state'] == "absent" + - test_four['msg'] == "device_type test-device-type deleted" + +- name: "DEVICE_TYPE 5: ASSERT - Delete non existing" + netbox.netbox.netbox_device_type: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + model: Test Device Type + state: absent + register: test_five + +- name: "DEVICE_TYPE 5: ASSERT - Delete non existing`" + ansible.builtin.assert: + that: + - not test_five['changed'] + - test_five['device_type'] == None + - test_five['msg'] == "device_type Test Device Type already absent" + +- name: "DEVICE_TYPE 6: Without Slug" + netbox.netbox.netbox_device_type: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + model: WS Test 3850 + manufacturer: Test Manufacturer + subdevice_role: parent + state: present + register: test_six + +- name: "DEVICE_TYPE 6: ASSERT - Without Slug" + ansible.builtin.assert: + that: + - test_six is changed + - test_six['diff']['before']['state'] == "absent" + - test_six['diff']['after']['state'] == "present" + - test_six['device_type']['slug'] == "ws-test-3850" + - test_six['device_type']['model'] == "WS Test 3850" + - test_six['device_type']['manufacturer'] == 3 + - test_six['msg'] == "device_type WS Test 3850 created" diff --git a/tests/integration/targets/v4.3/tasks/netbox_export_template.yml b/tests/integration/targets/v4.3/tasks/netbox_export_template.yml new file mode 100644 index 000000000..1e7535c08 --- /dev/null +++ b/tests/integration/targets/v4.3/tasks/netbox_export_template.yml @@ -0,0 +1,118 @@ +--- +## +## +### NETBOX_EXPORT_TEMPLATE +## +## +- name: "EXPORT_TEMPLATE 1: Necessary info creation" + netbox.netbox.netbox_export_template: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + object_types: + - dcim.device + name: Example Export Template + description: Export Devices + template_code: !unsafe >- + {% for obj in queryset %}{{ obj.name }}{% endfor %} + state: present + register: test_one + +- name: "EXPORT_TEMPLATE 1: ASSERT - Necessary info creation" + ansible.builtin.assert: + that: + - test_one is changed + - test_one['diff']['before']['state'] == "absent" + - test_one['diff']['after']['state'] == "present" + - test_one['export_template']['name'] == "Example Export Template" + - test_one['export_template']['object_types'] == ["dcim.device"] + - test_one['export_template']['description'] == "Export Devices" + - test_one['msg'] == "export_template Example Export Template created" + +- name: "EXPORT_TEMPLATE 2: Create duplicate" + netbox.netbox.netbox_export_template: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + object_types: + - dcim.device + name: Example Export Template + description: Export Devices + template_code: !unsafe >- + {% for obj in queryset %}{{ obj.name }}{% endfor %} + state: present + register: test_two + +- name: "EXPORT_TEMPLATE 2: ASSERT - Create duplicate" + ansible.builtin.assert: + that: + - not test_two['changed'] + - test_two['export_template']['name'] == "Example Export Template" + - test_two['msg'] == "export_template Example Export Template already exists" + +- name: "EXPORT_TEMPLATE 3: Update data and remove as_attachment" + netbox.netbox.netbox_export_template: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + object_types: + - dcim.device + name: Example Export Template + description: Export Devices + template_code: !unsafe >- + {% for obj in queryset %}{{ obj.name }}{% endfor %} + as_attachment: false + state: present + register: test_three + +- name: "EXPORT_TEMPLATE 3: ASSERT - Updated" + ansible.builtin.assert: + that: + - test_three is changed + - test_three['diff']['after']['as_attachment'] == false + - test_three['export_template']['name'] == "Example Export Template" + - test_three['msg'] == "export_template Example Export Template updated" + +- name: "EXPORT_TEMPLATE 4: Change content type" + netbox.netbox.netbox_export_template: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + object_types: + - virtualization.virtualmachine + name: Example Export Template + description: Export Devices + template_code: !unsafe >- + {% for obj in queryset %}{{ obj.name }}{% endfor %} + state: present + register: test_four + +- name: "EXPORT_TEMPLATE 4: ASSERT - Change content type" + ansible.builtin.assert: + that: + - test_four is changed + - test_four['diff']['after']['object_types'] == ["virtualization.virtualmachine"] + - test_four['export_template']['name'] == "Example Export Template" + - test_four['msg'] == "export_template Example Export Template updated" + +- name: "EXPORT_TEMPLATE 5: Delete" + netbox.netbox.netbox_export_template: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + object_types: + - virtualization.virtualmachine + name: Example Export Template + description: Export Devices + template_code: !unsafe >- + {% for obj in queryset %}{{ obj.name }}{% endfor %} + state: absent + register: test_five + +- name: "EXPORT_TEMPLATE 5: ASSERT - Deleted" + ansible.builtin.assert: + that: + - test_five is changed + - test_five['diff']['after']['state'] == "absent" + - test_five['export_template']['name'] == "Example Export Template" + - test_five['msg'] == "export_template Example Export Template deleted" diff --git a/tests/integration/targets/v4.3/tasks/netbox_fhrp_group.yml b/tests/integration/targets/v4.3/tasks/netbox_fhrp_group.yml new file mode 100644 index 000000000..eed3f2f88 --- /dev/null +++ b/tests/integration/targets/v4.3/tasks/netbox_fhrp_group.yml @@ -0,0 +1,91 @@ +--- +## +## +### NETBOX_FHRP_GROUP +## +## +- name: "FHRP group 1: Test FHRP group creation" + netbox.netbox.netbox_fhrp_group: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + protocol: glbp + group_id: 111 + state: present + register: test_one + +- name: "FHRP group: ASSERT - Necessary info creation" + ansible.builtin.assert: + that: + - test_one is changed + - test_one['diff']['before']['state'] == "absent" + - test_one['diff']['after']['state'] == "present" + - test_one['fhrp_group']['group_id'] == 111 + - test_one['fhrp_group']['protocol'] == "glbp" + - test_one['msg'] == "fhrp_group 111 created" + +- name: "FHRP group 2: Create duplicate" + netbox.netbox.netbox_fhrp_group: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + protocol: glbp + group_id: 111 + state: present + register: test_two + +- name: "FHRP group 2: ASSERT - Create duplicate" + ansible.builtin.assert: + that: + - not test_two['changed'] + - test_two['fhrp_group']['group_id'] == 111 + - test_two['fhrp_group']['protocol'] == "glbp" + - test_two['msg'] == "fhrp_group 111 already exists" + +- name: "FHRP group 3: Update FHRP group with other fields" + netbox.netbox.netbox_fhrp_group: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + protocol: glbp + group_id: 111 + auth_type: md5 + auth_key: 11111 + description: Test description + tags: + - Schnozzberry + state: present + register: test_three + +- name: "FHRP group 3: ASSERT - Update FHRP group with other fields" + ansible.builtin.assert: + that: + - test_three is changed + - test_three['diff']['after']['auth_type'] == "md5" + - test_three['diff']['after']['auth_key'] == "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER" + - test_three['diff']['after']['description'] == "Test description" + - test_three['diff']['after']['tags'][0] == 4 + - test_three['fhrp_group']['group_id'] == 111 + - test_three['fhrp_group']['protocol'] == "glbp" + - test_three['fhrp_group']['auth_type'] == "md5" + - test_three['fhrp_group']['auth_key'] == "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER" + - test_three['fhrp_group']['description'] == "Test description" + - test_three['fhrp_group']['tags'][0] == 4 + - test_three['msg'] == "fhrp_group 111 updated" + +- name: "FHRP group 4: ASSERT - Delete" + netbox.netbox.netbox_fhrp_group: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + group_id: 111 + state: absent + register: test_four + +- name: "FHRP group 4: ASSERT - Delete" + ansible.builtin.assert: + that: + - test_four is changed + - test_four['diff']['before']['state'] == "present" + - test_four['diff']['after']['state'] == "absent" + - test_four['msg'] == "fhrp_group 111 deleted" diff --git a/tests/integration/targets/v4.3/tasks/netbox_fhrp_group_assignment.yml b/tests/integration/targets/v4.3/tasks/netbox_fhrp_group_assignment.yml new file mode 100644 index 000000000..2dd2f6d61 --- /dev/null +++ b/tests/integration/targets/v4.3/tasks/netbox_fhrp_group_assignment.yml @@ -0,0 +1,92 @@ +--- +## +## +### NETBOX_FHRP_GROUP_ASSIGNMENT +## +## +- name: "FHRP group assignment 1: Test FHRP group assignment creation" + netbox.netbox.netbox_fhrp_group_assignment: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + fhrp_group: 1 + interface_type: dcim.interface + interface_id: 1 + priority: 1 + state: present + register: test_one + +- name: "FHRP group assignment: ASSERT - Necessary info creation" + ansible.builtin.assert: + that: + - test_one is changed + - test_one['diff']['before']['state'] == "absent" + - test_one['diff']['after']['state'] == "present" + - test_one['fhrp_group_assignment']['group'] == 1 + - test_one['fhrp_group_assignment']['interface_type'] == "dcim.interface" + - test_one['fhrp_group_assignment']['interface_id'] == 1 + - test_one['fhrp_group_assignment']['priority'] == 1 + - test_one['msg'] == "fhrp_group_assignment fhrp_group 1 > dcim.interface 1 created" + +- name: "FHRP group assignment 2: Create duplicate" + netbox.netbox.netbox_fhrp_group_assignment: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + fhrp_group: 1 + interface_type: dcim.interface + interface_id: 1 + priority: 1 + state: present + register: test_two + +- name: "FHRP group assignment 2: ASSERT - Create duplicate" + ansible.builtin.assert: + that: + - not test_two['changed'] + - test_two['fhrp_group_assignment']['group'] == 1 + - test_two['fhrp_group_assignment']['interface_type'] == "dcim.interface" + - test_two['fhrp_group_assignment']['interface_id'] == 1 + - test_two['fhrp_group_assignment']['priority'] == 1 + - test_two['msg'] == "fhrp_group_assignment fhrp_group 1 > dcim.interface 1 already exists" + +- name: "FHRP group assignment 3: Update FHRP group assignment" + netbox.netbox.netbox_fhrp_group_assignment: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + fhrp_group: 1 + interface_type: dcim.interface + interface_id: 1 + priority: 2 + state: present + register: test_three + +- name: "FHRP group assignment 3: ASSERT - Update FHRP group assignment" + ansible.builtin.assert: + that: + - test_three is changed + - test_three['fhrp_group_assignment']['group'] == 1 + - test_three['fhrp_group_assignment']['interface_type'] == "dcim.interface" + - test_three['fhrp_group_assignment']['interface_id'] == 1 + - test_three['fhrp_group_assignment']['priority'] == 2 + - test_three['msg'] == "fhrp_group_assignment fhrp_group 1 > dcim.interface 1 updated" + +- name: "FHRP group assignment 4: Delete FHRP group assignment" + netbox.netbox.netbox_fhrp_group_assignment: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + fhrp_group: 1 + interface_type: dcim.interface + interface_id: 1 + state: absent + register: test_four + +- name: "FHRP group assignment 3: ASSERT - Delete FHRP group assignment" + ansible.builtin.assert: + that: + - test_four is changed + - test_four['diff']['before']['state'] == "present" + - test_four['diff']['after']['state'] == "absent" + - test_four['msg'] == "fhrp_group_assignment fhrp_group 1 > dcim.interface 1 deleted" diff --git a/tests/integration/targets/v4.3/tasks/netbox_front_port.yml b/tests/integration/targets/v4.3/tasks/netbox_front_port.yml new file mode 100644 index 000000000..7088bbeef --- /dev/null +++ b/tests/integration/targets/v4.3/tasks/netbox_front_port.yml @@ -0,0 +1,150 @@ +--- +# © 2020 Nokia +# Licensed under the GNU General Public License v3.0 only +# SPDX-License-Identifier: GPL-3.0-only +## +## +### NETBOX_FRONT_PORT +## +## +- name: "FRONT_PORT 1: Necessary info creation" + netbox.netbox.netbox_front_port: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Front Port + device: test100 + type: bnc + rear_port: Rear Port + state: present + register: test_one + +- name: "FRONT_PORT 1: ASSERT - Necessary info creation" + ansible.builtin.assert: + that: + - test_one is changed + - test_one['diff']['before']['state'] == "absent" + - test_one['diff']['after']['state'] == "present" + - test_one['front_port']['name'] == "Front Port" + - test_one['front_port']['device'] == 1 + - test_one['front_port']['type'] == "bnc" + - test_one['front_port']['rear_port'] == 1 + - test_one['msg'] == "front_port Front Port created" + +- name: "FRONT_PORT 2: Create duplicate" + netbox.netbox.netbox_front_port: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Front Port + device: test100 + type: bnc + rear_port: Rear Port + state: present + register: test_two + +- name: "FRONT_PORT 2: ASSERT - Create duplicate" + ansible.builtin.assert: + that: + - not test_two['changed'] + - test_two['front_port']['name'] == "Front Port" + - test_two['front_port']['device'] == 1 + - test_two['front_port']['type'] == "bnc" + - test_two['front_port']['rear_port'] == 1 + - test_two['msg'] == "front_port Front Port already exists" + +- name: "FRONT_PORT 3: Update Front Port with other fields" + netbox.netbox.netbox_front_port: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Front Port + device: test100 + type: bnc + rear_port: Rear Port + rear_port_position: 5 + description: test description + state: present + register: test_three + +- name: "FRONT_PORT 3: ASSERT - Update Front Port with other fields" + ansible.builtin.assert: + that: + - test_three is changed + - test_three['diff']['after']['rear_port_position'] == 5 + - test_three['diff']['after']['description'] == "test description" + - test_three['front_port']['name'] == "Front Port" + - test_three['front_port']['device'] == 1 + - test_three['front_port']['type'] == "bnc" + - test_three['front_port']['rear_port'] == 1 + - test_three['front_port']['rear_port_position'] == 5 + - test_three['front_port']['description'] == "test description" + - test_three['msg'] == "front_port Front Port updated" + +- name: "FRONT_PORT 4: Create Front Port for Delete Test" + netbox.netbox.netbox_front_port: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Front Port 2 + device: test100 + type: bnc + rear_port: Rear Port + state: present + register: test_four + +- name: "FRONT_PORT 4: ASSERT - Create Front Port for Delete Test" + ansible.builtin.assert: + that: + - test_four is changed + - test_four['diff']['before']['state'] == "absent" + - test_four['diff']['after']['state'] == "present" + - test_four['front_port']['name'] == "Front Port 2" + - test_four['front_port']['device'] == 1 + - test_four['front_port']['type'] == "bnc" + - test_four['front_port']['rear_port'] == 1 + - test_four['msg'] == "front_port Front Port 2 created" + +- name: "FRONT_PORT 5: Delete Front Port" + netbox.netbox.netbox_front_port: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Front Port 2 + device: test100 + type: bnc + rear_port: Rear Port + state: absent + register: test_five + +- name: "FRONT_PORT 5: ASSERT - Delete Front Port" + ansible.builtin.assert: + that: + - test_five is changed + - test_five['diff']['before']['state'] == "present" + - test_five['diff']['after']['state'] == "absent" + - test_five['msg'] == "front_port Front Port 2 deleted" + +- name: "FRONT_PORT 6: Create duplicate with rear_port dictionary" + netbox.netbox.netbox_front_port: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Front Port + device: test100 + type: bnc + rear_port: + device: test100 + name: Rear Port + state: present + register: test_six + +- name: "FRONT_PORT 6: ASSERT - Create duplicate with rear_port dictionary" + ansible.builtin.assert: + that: + - not test_six['changed'] + - test_six['front_port']['name'] == "Front Port" + - test_six['front_port']['device'] == 1 + - test_six['front_port']['type'] == "bnc" + - test_six['front_port']['rear_port'] == 1 + - test_six['msg'] == "front_port Front Port already exists" diff --git a/tests/integration/targets/v4.3/tasks/netbox_front_port_template.yml b/tests/integration/targets/v4.3/tasks/netbox_front_port_template.yml new file mode 100644 index 000000000..966279fa8 --- /dev/null +++ b/tests/integration/targets/v4.3/tasks/netbox_front_port_template.yml @@ -0,0 +1,147 @@ +--- +# © 2020 Nokia +# Licensed under the GNU General Public License v3.0 only +# SPDX-License-Identifier: GPL-3.0-only +## +## +### NETBOX_FRONT_PORT_TEMPLATE +## +## +- name: "FRONT_PORT_TEMPLATE 1: Necessary info creation" + netbox.netbox.netbox_front_port_template: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Front Port Template + device_type: Cisco Test + type: bnc + rear_port_template: Rear Port Template + state: present + register: test_one + +- name: "FRONT_PORT_TEMPLATE 1: ASSERT - Necessary info creation" + ansible.builtin.assert: + that: + - test_one is changed + - test_one['diff']['before']['state'] == "absent" + - test_one['diff']['after']['state'] == "present" + - test_one['front_port_template']['name'] == "Front Port Template" + - test_one['front_port_template']['device_type'] == 1 + - test_one['front_port_template']['type'] == "bnc" + - test_one['front_port_template']['rear_port'] == 1 + - test_one['msg'] == "front_port_template Front Port Template created" + +- name: "FRONT_PORT_TEMPLATE 2: Create duplicate" + netbox.netbox.netbox_front_port_template: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Front Port Template + device_type: Cisco Test + type: bnc + rear_port_template: Rear Port Template + state: present + register: test_two + +- name: "FRONT_PORT_TEMPLATE 2: ASSERT - Create duplicate" + ansible.builtin.assert: + that: + - not test_two['changed'] + - test_two['front_port_template']['name'] == "Front Port Template" + - test_two['front_port_template']['device_type'] == 1 + - test_two['front_port_template']['type'] == "bnc" + - test_two['front_port_template']['rear_port'] == 1 + - test_two['msg'] == "front_port_template Front Port Template already exists" + +- name: "FRONT_PORT_TEMPLATE 3: Update Front Port Template with other fields" + netbox.netbox.netbox_front_port_template: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Front Port Template + device_type: Cisco Test + type: bnc + rear_port_template: Rear Port Template + rear_port_template_position: 5 + state: present + register: test_three + +- name: "FRONT_PORT_TEMPLATE 3: ASSERT - Update Front Port Template with other fields" + ansible.builtin.assert: + that: + - test_three is changed + - test_three['diff']['after']['rear_port_position'] == 5 + - test_three['front_port_template']['name'] == "Front Port Template" + - test_three['front_port_template']['device_type'] == 1 + - test_three['front_port_template']['type'] == "bnc" + - test_three['front_port_template']['rear_port_position'] == 5 + - test_three['front_port_template']['rear_port'] == 1 + - test_three['msg'] == "front_port_template Front Port Template updated" + +- name: "FRONT_PORT_TEMPLATE 4: Create Front Port Template for Delete Test" + netbox.netbox.netbox_front_port_template: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Front Port Template 2 + device_type: Cisco Test + type: bnc + rear_port_template: Rear Port Template + state: present + register: test_four + +- name: "FRONT_PORT_TEMPLATE 4: ASSERT - Create Front Port Template for Delete Test" + ansible.builtin.assert: + that: + - test_four is changed + - test_four['diff']['before']['state'] == "absent" + - test_four['diff']['after']['state'] == "present" + - test_four['front_port_template']['name'] == "Front Port Template 2" + - test_four['front_port_template']['device_type'] == 1 + - test_four['front_port_template']['type'] == "bnc" + - test_four['front_port_template']['rear_port'] == 1 + - test_four['msg'] == "front_port_template Front Port Template 2 created" + +- name: "FRONT_PORT_TEMPLATE 5: Delete Front Port Template" + netbox.netbox.netbox_front_port_template: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Front Port Template 2 + device_type: Cisco Test + type: bnc + rear_port_template: Rear Port Template + state: absent + register: test_five + +- name: "FRONT_PORT_TEMPLATE 5: ASSERT - Delete Front Port Template" + ansible.builtin.assert: + that: + - test_five is changed + - test_five['diff']['before']['state'] == "present" + - test_five['diff']['after']['state'] == "absent" + - test_five['msg'] == "front_port_template Front Port Template 2 deleted" + +- name: "FRONT_PORT 6: Create duplicate with rear_port_template dictionary" + netbox.netbox.netbox_front_port_template: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Front Port Template + device_type: Cisco Test + type: bnc + rear_port_template: + device: Cisco Test + name: Rear Port Template + state: present + register: test_six + +- name: "FRONT_PORT 6: ASSERT - Create duplicate with rear_port_template dictionary" + ansible.builtin.assert: + that: + - not test_six['changed'] + - test_six['front_port_template']['name'] == "Front Port Template" + - test_six['front_port_template']['device_type'] == 1 + - test_six['front_port_template']['type'] == "bnc" + - test_six['front_port_template']['rear_port'] == 1 + - test_six['msg'] == "front_port_template Front Port Template already exists" diff --git a/tests/integration/targets/v4.3/tasks/netbox_inventory_item.yml b/tests/integration/targets/v4.3/tasks/netbox_inventory_item.yml new file mode 100644 index 000000000..5b330c3a5 --- /dev/null +++ b/tests/integration/targets/v4.3/tasks/netbox_inventory_item.yml @@ -0,0 +1,203 @@ +--- +## +## +### NETBOX_INVENTORY_ITEM +## +## +- name: "INVENTORY_ITEM 1: Necessary info creation" + netbox.netbox.netbox_inventory_item: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + device: test100 + name: 10G-SFP+ + state: present + register: test_one + +- name: "INVENTORY_ITEM 1: ASSERT - Necessary info creation" + ansible.builtin.assert: + that: + - test_one is changed + - test_one.diff.before.state == "absent" + - test_one.diff.after.state == "present" + - test_one.inventory_item.name == "10G-SFP+" + - test_one.inventory_item.device == 1 + - test_one.msg == "inventory_item 10G-SFP+ created" + +- name: "INVENTORY_ITEM 2: Create duplicate" + netbox.netbox.netbox_inventory_item: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + device: test100 + name: 10G-SFP+ + state: present + register: test_two + +- name: "INVENTORY_ITEM 2: ASSERT - Create duplicate" + ansible.builtin.assert: + that: + - not test_two.changed + - test_two.inventory_item.name == "10G-SFP+" + - test_two.inventory_item.device == 1 + - test_two.msg == "inventory_item 10G-SFP+ already exists" + +- name: "INVENTORY_ITEM 3: Update properties" + netbox.netbox.netbox_inventory_item: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + device: test100 + name: 10G-SFP+ + manufacturer: Cisco + part_id: 10G-SFP+ + serial: "1234" + asset_tag: "1234" + description: New SFP + discovered: true + tags: + - Schnozzberry + state: present + register: test_three + +- name: "INVENTORY_ITEM 3: ASSERT - Updated" + ansible.builtin.assert: + that: + - test_three is changed + - test_three.diff.after.asset_tag == "1234" + - test_three.diff.after.serial == "1234" + - test_three.diff.after.description == "New SFP" + - test_three.diff.after.manufacturer == 1 + - test_three.diff.after.part_id == "10G-SFP+" + - test_three.diff.after.tags[0] == 4 + - test_three.diff.after.discovered == True + - test_three.inventory_item.name == "10G-SFP+" + - test_three.inventory_item.device == 1 + - test_three.inventory_item.asset_tag == "1234" + - test_three.inventory_item.serial == "1234" + - test_three.inventory_item.description == "New SFP" + - test_three.inventory_item.manufacturer == 1 + - test_three.inventory_item.part_id == "10G-SFP+" + - test_three.inventory_item.tags[0] == 4 + - test_three.inventory_item.discovered == True + - test_three.msg == "inventory_item 10G-SFP+ updated" + +- name: "INVENTORY_ITEM 4: Delete inventory item" + netbox.netbox.netbox_inventory_item: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + device: test100 + name: 10G-SFP+ + state: absent + register: test_four + +- name: "INVENTORY_ITEM 4: ASSERT - Delete" + ansible.builtin.assert: + that: + - test_four is changed + - test_four.inventory_item.name == "10G-SFP+" + - test_four.inventory_item.device == 1 + - test_four.inventory_item.asset_tag == "1234" + - test_four.inventory_item.serial == "1234" + - test_four.inventory_item.description == "New SFP" + - test_four.inventory_item.manufacturer == 1 + - test_four.inventory_item.part_id == "10G-SFP+" + - test_four.inventory_item.tags[0] == 4 + - test_four.msg == "inventory_item 10G-SFP+ deleted" + +- name: "INVENTORY_ITEM 5: PREWORK - Create inventory item role" + netbox.netbox.netbox_inventory_item_role: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Processor + color: FFFFFF + state: present + register: test_five_prework + +- name: "INVENTORY_ITEM 5: Create inventory item with role" + netbox.netbox.netbox_inventory_item: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + device: test100 + name: test_processor + inventory_item_role: Processor + state: present + register: test_five + +- name: "INVENTORY_ITEM 5: ASSERT - Inventory item creation with role" + ansible.builtin.assert: + that: + - test_five is changed + - test_five.diff.before.state == "absent" + - test_five.diff.after.state == "present" + - test_five.inventory_item.name == "test_processor" + - test_five.inventory_item.role == test_five_prework.inventory_item_role.id + - test_five.inventory_item.device == 1 + - test_five.msg == "inventory_item test_processor created" + +- name: "INVENTORY_ITEM 6: Create inventory item with missing role" + netbox.netbox.netbox_inventory_item: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + device: test100 + name: test_processor + inventory_item_role: Foo + state: present + ignore_errors: true + register: test_six + +- name: "INVENTORY_ITEM 6: ASSERT - Inventory item creation with missing role" + ansible.builtin.assert: + that: + - test_six.failed + - test_six.msg == "Could not resolve id of inventory_item_role: Foo" + +- name: "INVENTORY_ITEM 7: Create inventory item with component" + netbox.netbox.netbox_inventory_item: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + device: test100 + name: test_component + component_type: dcim.interface + component: + name: GigabitEthernet2 + device: test100 + state: present + register: test_seven + +- name: "INVENTORY_ITEM 7: ASSERT - Inventory item creation with component" + ansible.builtin.assert: + that: + - test_seven is changed + - test_seven.diff.before.state == "absent" + - test_seven.diff.after.state == "present" + - test_seven.inventory_item.name == "test_component" + - test_seven.inventory_item.component_type == "dcim.interface" + - test_seven.inventory_item.component_id == 4 + - test_seven.inventory_item.device == 1 + - test_seven.msg == "inventory_item test_component created" + +- name: "INVENTORY_ITEM 8: Create inventory item with missing component_type" + netbox.netbox.netbox_inventory_item: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + device: test100 + name: test_component + component: + name: GigabitEthernet2 + device: test100 + state: present + ignore_errors: true + register: test_eight + +- name: "INVENTORY_ITEM 8: ASSERT - Inventory item creation with missing component_type" + ansible.builtin.assert: + that: + - test_eight.failed + - test_eight.msg == "parameters are required together: component_type, component" diff --git a/tests/integration/targets/v4.3/tasks/netbox_inventory_item_role.yml b/tests/integration/targets/v4.3/tasks/netbox_inventory_item_role.yml new file mode 100644 index 000000000..71d86d747 --- /dev/null +++ b/tests/integration/targets/v4.3/tasks/netbox_inventory_item_role.yml @@ -0,0 +1,98 @@ +--- +## +## +### NETBOX_INVENTORY_ITEM_ROLE +## +## +- name: "INVENTORY_ITEM_ROLE 1: Necessary info creation" + netbox.netbox.netbox_inventory_item_role: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test Inventory Item Role + color: FFFFFF + state: present + register: test_one + +- name: "INVENTORY_ITEM_ROLE 1: ASSERT - Necessary info creation" + ansible.builtin.assert: + that: + - test_one is changed + - test_one['diff']['before']['state'] == "absent" + - test_one['diff']['after']['state'] == "present" + - test_one['inventory_item_role']['name'] == "Test Inventory Item Role" + - test_one['inventory_item_role']['slug'] == "test-inventory-item-role" + - test_one['inventory_item_role']['color'] == "ffffff" + - test_one['msg'] == "inventory_item_role Test Inventory Item Role created" + +- name: "INVENTORY_ITEM_ROLE 2: Create duplicate" + netbox.netbox.netbox_inventory_item_role: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test Inventory Item Role + color: FFFFFF + state: present + register: test_two + +- name: "INVENTORY_ITEM_ROLE 2: ASSERT - Create duplicate" + ansible.builtin.assert: + that: + - not test_two['changed'] + - test_two['inventory_item_role']['name'] == "Test Inventory Item Role" + - test_two['inventory_item_role']['slug'] == "test-inventory-item-role" + - test_two['inventory_item_role']['color'] == "ffffff" + - test_two['msg'] == "inventory_item_role Test Inventory Item Role already exists" + +- name: "INVENTORY_ITEM_ROLE 3: ASSERT - Update" + netbox.netbox.netbox_inventory_item_role: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test Inventory Item Role + color: "003EFF" + state: present + register: test_three + +- name: "INVENTORY_ITEM_ROLE 3: ASSERT - Update" + ansible.builtin.assert: + that: + - test_three is changed + - test_three['diff']['after']['color'] == "003eff" + - test_three['inventory_item_role']['name'] == "Test Inventory Item Role" + - test_three['inventory_item_role']['slug'] == "test-inventory-item-role" + - test_three['inventory_item_role']['color'] == "003eff" + - test_three['msg'] == "inventory_item_role Test Inventory Item Role updated" + +- name: "INVENTORY_ITEM_ROLE 4: ASSERT - Delete" + netbox.netbox.netbox_inventory_item_role: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test Inventory Item Role + state: absent + register: test_four + +- name: "INVENTORY_ITEM_ROLE 4: ASSERT - Delete" + ansible.builtin.assert: + that: + - test_four is changed + - test_four['diff']['before']['state'] == "present" + - test_four['diff']['after']['state'] == "absent" + - test_four['msg'] == "inventory_item_role Test Inventory Item Role deleted" + +- name: "INVENTORY_ITEM_ROLE 5: ASSERT - Delete non existing" + netbox.netbox.netbox_inventory_item_role: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test Inventory Item Role + state: absent + register: test_five + +- name: "INVENTORY_ITEM_ROLE 5: ASSERT - Delete non existing`" + ansible.builtin.assert: + that: + - not test_five['changed'] + - test_five['inventory_item_role'] == None + - test_five['msg'] == "inventory_item_role Test Inventory Item Role already absent" diff --git a/tests/integration/targets/v4.3/tasks/netbox_ip_address.yml b/tests/integration/targets/v4.3/tasks/netbox_ip_address.yml new file mode 100644 index 000000000..328cdfc35 --- /dev/null +++ b/tests/integration/targets/v4.3/tasks/netbox_ip_address.yml @@ -0,0 +1,401 @@ +--- +## +## +### NETBOX_IP_ADDRESS +## +## +- name: "1 - Create IP address within NetBox with only required information - State: Present" + netbox.netbox.netbox_ip_address: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + address: 192.168.1.10/30 + state: present + register: test_one + +- name: 1 - ASSERT + ansible.builtin.assert: + that: + - test_one is changed + - test_one['diff']['before']['state'] == "absent" + - test_one['diff']['after']['state'] == "present" + - test_one['msg'] == "ip_address 192.168.1.10/30 created" + - test_one['ip_address']['address'] == "192.168.1.10/30" + +- name: 2 - Update 192.168.1.10/30 + netbox.netbox.netbox_ip_address: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + address: 192.168.1.10/30 + description: Updated ip address + tags: + - Updated + state: present + register: test_two + +- name: 2 - ASSERT + ansible.builtin.assert: + that: + - test_two is changed + - test_two['diff']['after']['description'] == "Updated ip address" + - test_two['diff']['after']['tags'][0] == 10 + - test_two['msg'] == "ip_address 192.168.1.10/30 updated" + - test_two['ip_address']['address'] == "192.168.1.10/30" + - test_two['ip_address']['tags'][0] == 10 + - test_two['ip_address']['description'] == "Updated ip address" + +- name: "3 - Delete IP - 192.168.1.10 - State: Absent" + netbox.netbox.netbox_ip_address: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + address: 192.168.1.10/30 + state: absent + register: test_three + +- name: 3 - ASSERT + ansible.builtin.assert: + that: + - test_three is changed + - test_three['diff']['before']['state'] == "present" + - test_three['diff']['after']['state'] == "absent" + - test_three['msg'] == "ip_address 192.168.1.10/30 deleted" + +- name: "4 - Create IP in global VRF - 192.168.1.20/30 - State: Present" + netbox.netbox.netbox_ip_address: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + address: 192.168.1.20/30 + state: present + register: test_four + +- name: 4 - ASSERT + ansible.builtin.assert: + that: + - test_four is changed + - test_four['diff']['before']['state'] == "absent" + - test_four['diff']['after']['state'] == "present" + - test_four['msg'] == "ip_address 192.168.1.20/30 created" + - test_four['ip_address']['address'] == "192.168.1.20/30" + +# Enforce uniqueness in NetBox 3.7 +# - name: "5 - Create IP in global VRF - 192.168.1.20/30 - State: New" +# netbox.netbox.netbox_ip_address: +# netbox_url: http://localhost:32768 +# netbox_token: 0123456789abcdef0123456789abcdef01234567 +# data: +# address: 192.168.1.20/30 +# state: new +# register: test_five + +# - name: "5 - ASSERT" +# assert: +# that: +# - test_five is changed +# - test_five['diff']['before']['state'] == "absent" +# - test_five['diff']['after']['state'] == "present" +# - test_five['msg'] == "ip_address 192.168.1.20/30 created" +# - test_five['ip_address']['address'] == "192.168.1.20/30" + +- name: "6 - Create new address with only prefix specified - State: new" + netbox.netbox.netbox_ip_address: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + prefix: 192.168.100.0/24 + state: new + register: test_six + +- name: 6 - ASSERT + ansible.builtin.assert: + that: + - test_six is changed + - test_six['diff']['before']['state'] == "absent" + - test_six['diff']['after']['state'] == "present" + - test_six['msg'] == "ip_address 192.168.100.1/24 created" + - test_six['ip_address']['address'] == "192.168.100.1/24" + +- name: 7 - Create IP address with several specified + netbox.netbox.netbox_ip_address: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + family: 4 + address: 172.16.1.20/24 + vrf: Test VRF + tenant: Test Tenant + status: Reserved + role: Loopback + description: Test description + tags: + - Schnozzberry + state: present + register: test_seven + +- name: 7 - ASSERT + ansible.builtin.assert: + that: + - test_seven is changed + - test_seven['diff']['before']['state'] == "absent" + - test_seven['diff']['after']['state'] == "present" + - test_seven['msg'] == "ip_address 172.16.1.20/24 created" + - test_seven['ip_address']['address'] == "172.16.1.20/24" + - test_seven['ip_address']['description'] == "Test description" + - test_seven['ip_address']['family'] == 4 + - test_seven['ip_address']['role'] == "loopback" + - test_seven['ip_address']['status'] == "reserved" + - test_seven['ip_address']['tags'][0] == 4 + - test_seven['ip_address']['tenant'] == 1 + - test_seven['ip_address']['vrf'] == 1 + +- name: 8 - Create IP address and assign a nat_inside IP + netbox.netbox.netbox_ip_address: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + family: 4 + address: 10.10.1.30/16 + vrf: Test VRF + nat_inside: + address: 172.16.1.20 + vrf: Test VRF + register: test_eight + +- name: 8 - ASSERT + ansible.builtin.assert: + that: + - test_eight is changed + - test_eight['diff']['before']['state'] == "absent" + - test_eight['diff']['after']['state'] == "present" + - test_eight['msg'] == "ip_address 10.10.1.30/16 created" + - test_eight['ip_address']['address'] == "10.10.1.30/16" + - test_eight['ip_address']['family'] == 4 + - test_eight['ip_address'].get('nat_inside') + - test_eight['ip_address']['vrf'] == 1 + +- name: "9 - Create IP address on GigabitEthernet2 - 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 + assigned_object: + name: GigabitEthernet2 + device: test100 + register: test_nine + +- name: 9 - 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: "10 - Create IP address on GigabitEthernet2 - test100 - State: new" + netbox.netbox.netbox_ip_address: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + family: 4 + prefix: 10.10.0.0/16 + assigned_object: + name: GigabitEthernet2 + device: test100 + state: new + register: test_ten + +- name: 10 - 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: "11 - Create IP address on GigabitEthernet2 - test100 - State: present" + netbox.netbox.netbox_ip_address: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + family: 4 + prefix: 192.168.100.0/24 + assigned_object: + name: GigabitEthernet2 + device: test100 + state: present + register: test_eleven + +- name: 11 - 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: 12 - Duplicate - 192.168.100.2/24 on interface + netbox.netbox.netbox_ip_address: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + address: 192.168.100.2/24 + assigned_object: + name: GigabitEthernet2 + device: test100 + state: present + register: test_twelve + +- name: 12 - 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 + +- name: 13 - Duplicate - 192.168.100.2/24 + netbox.netbox.netbox_ip_address: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + address: 192.168.100.2/24 + state: present + register: test_thirteen + +- name: 13 - ASSERT + ansible.builtin.assert: + that: + - not test_thirteen['changed'] + - test_thirteen['msg'] == "ip_address 192.168.100.2/24 already exists" + - test_thirteen['ip_address']['address'] == "192.168.100.2/24" + +- name: "14 - Create IP address on Eth0 - test100-vm - State: present" + netbox.netbox.netbox_ip_address: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + family: 4 + address: 10.188.1.100/24 + assigned_object: + name: Eth0 + virtual_machine: test100-vm + register: test_fourteen + +- name: 14 - ASSERT + ansible.builtin.assert: + that: + - test_fourteen is changed + - test_fourteen['diff']['before']['state'] == "absent" + - test_fourteen['diff']['after']['state'] == "present" + - test_fourteen['msg'] == "ip_address 10.188.1.100/24 created" + - test_fourteen['ip_address']['address'] == "10.188.1.100/24" + - test_fourteen['ip_address']['family'] == 4 + - test_fourteen['ip_address']['assigned_object_type'] == "virtualization.vminterface" + - test_fourteen['ip_address']['assigned_object_id'] == 1 + +# Enforce uniqueness in NetBox 3.7 +# - name: "15 - Create same IP address on Eth0 - test101-vm - State: present" +# netbox.netbox.netbox_ip_address: +# netbox_url: http://localhost:32768 +# netbox_token: 0123456789abcdef0123456789abcdef01234567 +# data: +# family: 4 +# address: 10.188.1.100/24 +# assigned_object: +# name: Eth0 +# virtual_machine: test101-vm +# state: "present" +# register: test_fifteen + +# - name: "15 - ASSERT" +# assert: +# that: +# - test_fifteen is changed +# - test_fifteen['diff']['before']['state'] == "absent" +# - test_fifteen['diff']['after']['state'] == "present" +# - test_fifteen['msg'] == "ip_address 10.188.1.100/24 created" +# - test_fifteen['ip_address']['address'] == "10.188.1.100/24" +# - test_fifteen['ip_address']['family'] == 4 +# - test_fifteen['ip_address']['assigned_object_type'] == "virtualization.vminterface" +# - test_fifteen['ip_address']['assigned_object_id'] == 6 + +- name: "16 - Create IP address with no mask - State: Present" + netbox.netbox.netbox_ip_address: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + address: 10.120.10.1 + state: present + register: test_sixteen + +- name: 16 - ASSERT + ansible.builtin.assert: + that: + - test_sixteen is changed + - test_sixteen['diff']['before']['state'] == "absent" + - 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.3/tasks/netbox_ipam_role.yml b/tests/integration/targets/v4.3/tasks/netbox_ipam_role.yml new file mode 100644 index 000000000..9f376c2ed --- /dev/null +++ b/tests/integration/targets/v4.3/tasks/netbox_ipam_role.yml @@ -0,0 +1,94 @@ +--- +## +## +### NETBOX_IPAM_ROLE +## +## +- name: "IPAM_ROLE 1: Necessary info creation" + netbox.netbox.netbox_ipam_role: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test IPAM Role + state: present + register: test_one + +- name: "IPAM_ROLE 1: ASSERT - Necessary info creation" + ansible.builtin.assert: + that: + - test_one is changed + - test_one['diff']['before']['state'] == "absent" + - test_one['diff']['after']['state'] == "present" + - test_one['role']['name'] == "Test IPAM Role" + - test_one['role']['slug'] == "test-ipam-role" + - test_one['msg'] == "role Test IPAM Role created" + +- name: "IPAM_ROLE 2: Create duplicate" + netbox.netbox.netbox_ipam_role: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test IPAM Role + state: present + register: test_two + +- name: "IPAM_ROLE 2: ASSERT - Create duplicate" + ansible.builtin.assert: + that: + - not test_two['changed'] + - test_two['role']['name'] == "Test IPAM Role" + - test_two['role']['slug'] == "test-ipam-role" + - test_two['msg'] == "role Test IPAM Role already exists" + +- name: "IPAM_ROLE 3: ASSERT - Update" + netbox.netbox.netbox_ipam_role: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test IPAM Role + weight: 4096 + state: present + register: test_three + +- name: "IPAM_ROLE 3: ASSERT - Update" + ansible.builtin.assert: + that: + - test_three is changed + - test_three['diff']['after']['weight'] == 4096 + - test_three['role']['name'] == "Test IPAM Role" + - test_three['role']['slug'] == "test-ipam-role" + - test_three['role']['weight'] == 4096 + - test_three['msg'] == "role Test IPAM Role updated" + +- name: "IPAM_ROLE 4: ASSERT - Delete" + netbox.netbox.netbox_ipam_role: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test IPAM Role + state: absent + register: test_four + +- name: "IPAM_ROLE 4: ASSERT - Delete" + ansible.builtin.assert: + that: + - test_four is changed + - test_four['diff']['before']['state'] == "present" + - test_four['diff']['after']['state'] == "absent" + - test_four['msg'] == "role Test IPAM Role deleted" + +- name: "IPAM_ROLE 5: ASSERT - Delete non existing" + netbox.netbox.netbox_ipam_role: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test IPAM Role + state: absent + register: test_five + +- name: "IPAM_ROLE 5: ASSERT - Delete non existing`" + ansible.builtin.assert: + that: + - not test_five['changed'] + - test_five['role'] == None + - test_five['msg'] == "role Test IPAM Role already absent" diff --git a/tests/integration/targets/v4.3/tasks/netbox_journal_entry.yml b/tests/integration/targets/v4.3/tasks/netbox_journal_entry.yml new file mode 100644 index 000000000..7eead8db1 --- /dev/null +++ b/tests/integration/targets/v4.3/tasks/netbox_journal_entry.yml @@ -0,0 +1,26 @@ +--- +## +## +### NETBOX_JOURNAL_ENTRY +## +## +- name: "JOURNAL ENTRY 1: Creation" + netbox.netbox.netbox_journal_entry: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + assigned_object_type: dcim.device + assigned_object_id: 1 + comments: | + Comment on device + state: new + register: test_one + +- name: "JOURNAL_ENTRY 1: ASSERT - Creation" + ansible.builtin.assert: + that: + - test_one is changed + - test_one['diff']['before']['state'] == "absent" + - test_one['diff']['after']['state'] == "present" + - test_one['journal_entry']['kind'] == "info" + - test_one['msg'] == "journal_entry created" diff --git a/tests/integration/targets/v4.3/tasks/netbox_l2vpn.yml b/tests/integration/targets/v4.3/tasks/netbox_l2vpn.yml new file mode 100644 index 000000000..655be9455 --- /dev/null +++ b/tests/integration/targets/v4.3/tasks/netbox_l2vpn.yml @@ -0,0 +1,99 @@ +--- +## +## +### NETBOX_L2VPN +## +## +- name: "L2VPN 1: Necessary info creation" + netbox.netbox.netbox_l2vpn: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test L2VPN + type: vxlan + state: present + register: test_one + +- name: "L2VPN 1: ASSERT - Necessary info creation" + ansible.builtin.assert: + that: + - test_one is changed + - test_one['diff']['before']['state'] == "absent" + - test_one['diff']['after']['state'] == "present" + - test_one['l2vpn']['name'] == "Test L2VPN" + - test_one['l2vpn']['type'] == "vxlan" + - test_one['msg'] == "l2vpn Test L2VPN created" + +- name: "L2VPN 2: Create duplicate" + netbox.netbox.netbox_l2vpn: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test L2VPN + type: vxlan + state: present + register: test_two + +- name: "L2VPN 2: ASSERT - Create duplicate" + ansible.builtin.assert: + that: + - not test_two['changed'] + - test_two['l2vpn']['name'] == "Test L2VPN" + - test_two['l2vpn']['type'] == "vxlan" + - test_two['msg'] == "l2vpn Test L2VPN already exists" + +- name: "L2VPN 4: ASSERT - Update" + netbox.netbox.netbox_l2vpn: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test L2VPN + type: vxlan + tenant: Test Tenant + description: Updated description + import_targets: + - 4000:4000 + - 5000:5000 + export_targets: + - 6000:6000 + tags: + - Schnozzberry + state: present + register: test_four + +- name: "L2VPN: ASSERT - Updated" + ansible.builtin.assert: + that: + - test_four is changed + - test_four['diff']['after']['description'] == "Updated description" + - test_four['diff']['after']['import_targets'] == [1, 2] + - test_four['diff']['after']['export_targets'] == [3] + - test_four['diff']['after']['tags'][0] == 4 + - test_four['l2vpn']['name'] == "Test L2VPN" + - test_four['l2vpn']['tenant'] == 1 + - test_four['l2vpn']['import_targets'] == [1, 2] + - test_four['l2vpn']['export_targets'] == [3] + - test_four['l2vpn']['description'] == "Updated description" + - test_four['l2vpn']['tags'][0] == 4 + - test_four['msg'] == "l2vpn Test L2VPN updated" + +- name: "L2VPN: ASSERT - Delete" + netbox.netbox.netbox_l2vpn: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test L2VPN + type: vxlan + state: absent + register: test_six + +- name: "L2VPN 6: ASSERT - Delete" + ansible.builtin.assert: + that: + - test_six is changed + - test_six['l2vpn']['name'] == "Test L2VPN" + - test_six['l2vpn']['tenant'] == 1 + - test_six['l2vpn']['type'] == "vxlan" + - test_six['l2vpn']['description'] == "Updated description" + - test_six['l2vpn']['tags'][0] == 4 + - test_six['msg'] == "l2vpn Test L2VPN deleted" diff --git a/tests/integration/targets/v4.3/tasks/netbox_l2vpn_termination.yml b/tests/integration/targets/v4.3/tasks/netbox_l2vpn_termination.yml new file mode 100644 index 000000000..0dd539943 --- /dev/null +++ b/tests/integration/targets/v4.3/tasks/netbox_l2vpn_termination.yml @@ -0,0 +1,94 @@ +--- +## +## +### NETBOX_L2VPN_TERMINATION +## +## +- name: "L2VPN_TERMINATION 1: Necessary info creation" + netbox.netbox.netbox_l2vpn_termination: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + l2vpn: 1 + assigned_object_type: dcim.interface + assigned_object_id: 1 + state: present + register: test_one + +- name: "L2VPN_TERMINATION 1: ASSERT - Necessary info creation" + ansible.builtin.assert: + that: + - test_one is changed + - test_one['diff']['before']['state'] == "absent" + - test_one['diff']['after']['state'] == "present" + - test_one['l2vpn_termination']['l2vpn'] == 1 + - test_one['l2vpn_termination']['assigned_object_type'] == "dcim.interface" + - test_one['l2vpn_termination']['assigned_object_id'] == 1 + - test_one['msg'] == "l2vpn_termination l2vpn 1 <> dcim.interface 1 created" + +- name: "L2VPN_TERMINATION 2: Create duplicate" + netbox.netbox.netbox_l2vpn_termination: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + l2vpn: 1 + assigned_object_type: dcim.interface + assigned_object_id: 1 + state: present + register: test_two + +- name: "L2VPN_TERMINATION 2: ASSERT - Create duplicate" + ansible.builtin.assert: + that: + - not test_two['changed'] + - test_two['l2vpn_termination']['l2vpn'] == 1 + - test_two['l2vpn_termination']['assigned_object_type'] == "dcim.interface" + - test_two['l2vpn_termination']['assigned_object_id'] == 1 + - test_two['msg'] == "l2vpn_termination l2vpn 1 <> dcim.interface 1 already exists" + +- name: "L2VPN_TERMINATION 3: Update" + netbox.netbox.netbox_l2vpn_termination: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + l2vpn: 1 + assigned_object_type: dcim.interface + assigned_object_id: 1 + tags: + - Schnozzberry + state: present + register: test_three + +- name: "L2VPN_TERMINATION 3: ASSERT - Updated" + ansible.builtin.assert: + that: + - test_three is changed + - test_three['diff']['after']['tags'][0] == 4 + - test_three['l2vpn_termination']['l2vpn'] == 1 + - test_three['l2vpn_termination']['assigned_object_type'] == "dcim.interface" + - test_three['l2vpn_termination']['assigned_object_id'] == 1 + - test_three['l2vpn_termination']['tags'][0] == 4 + - test_three['msg'] == "l2vpn_termination l2vpn 1 <> dcim.interface 1 updated" + +- name: "L2VPN_TERMINATION 4: Delete" + netbox.netbox.netbox_l2vpn_termination: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + l2vpn: 1 + assigned_object_type: dcim.interface + assigned_object_id: 1 + state: absent + register: test_four + +- name: "L2VPN_TERMINATION 4: ASSERT - Delete" + ansible.builtin.assert: + that: + - test_four is changed + - test_four['diff']['before']['state'] == "present" + - test_four['diff']['after']['state'] == "absent" + - test_four['l2vpn_termination']['l2vpn'] == 1 + - test_four['l2vpn_termination']['assigned_object_type'] == "dcim.interface" + - test_four['l2vpn_termination']['assigned_object_id'] == 1 + - test_four['l2vpn_termination']['tags'][0] == 4 + - test_four['msg'] == "l2vpn_termination l2vpn 1 <> dcim.interface 1 deleted" diff --git a/tests/integration/targets/v4.3/tasks/netbox_location.yml b/tests/integration/targets/v4.3/tasks/netbox_location.yml new file mode 100644 index 000000000..2e37c7682 --- /dev/null +++ b/tests/integration/targets/v4.3/tasks/netbox_location.yml @@ -0,0 +1,85 @@ +--- +## +## +### NETBOX_LOCATION +## +## +- name: "LOCATION 1: Necessary info creation" + netbox.netbox.netbox_location: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Location + site: Test Site + state: present + register: test_one + +- name: "LOCATION 1: ASSERT - Necessary info creation" + ansible.builtin.assert: + that: + - test_one is changed + - test_one['diff']['before']['state'] == "absent" + - test_one['diff']['after']['state'] == "present" + - test_one['location']['name'] == "Location" + - test_one['location']['slug'] == "location" + - test_one['location']['site'] == 1 + - test_one['msg'] == "location Location created" + +- name: "LOCATION 2: Create duplicate" + netbox.netbox.netbox_location: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Location + site: Test Site + state: present + register: test_two + +- name: "LOCATION 2: ASSERT - Create duplicate" + ansible.builtin.assert: + that: + - not test_two['changed'] + - test_two['location']['name'] == "Location" + - test_two['location']['slug'] == "location" + - test_two['location']['site'] == 1 + - test_two['msg'] == "location Location already exists" + +- name: "LOCATION 3: Update" + netbox.netbox.netbox_location: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Location + parent_location: Parent Rack Group + description: This is a location + state: present + register: test_three + +- name: "LOCATION 3: ASSERT - Update" + ansible.builtin.assert: + that: + - test_three is changed + - test_three['diff']['after']['parent'] == 2 + - test_three['diff']['after']['description'] == "This is a location" + - test_three['location']['name'] == "Location" + - test_three['location']['slug'] == "location" + - test_three['location']['parent'] == 2 + - test_three['location']['description'] == "This is a location" + - test_three['msg'] == "location Location updated" + +- name: "LOCATION 4: Delete" + netbox.netbox.netbox_location: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Location + state: absent + register: test_four + +- name: "LOCATION 4: ASSERT - Delete" + ansible.builtin.assert: + that: + - test_four is changed + - test_four['diff']['before']['state'] == "present" + - test_four['diff']['after']['state'] == "absent" + - test_four['msg'] == "location Location deleted" diff --git a/tests/integration/targets/v4.3/tasks/netbox_lookup.yml b/tests/integration/targets/v4.3/tasks/netbox_lookup.yml new file mode 100644 index 000000000..3d5ef9efa --- /dev/null +++ b/tests/integration/targets/v4.3/tasks/netbox_lookup.yml @@ -0,0 +1,105 @@ +--- +## +## +### NETBOX_LOOKUP +## +## +- name: "NETBOX_LOOKUP 1: Lookup returns exactly four sites" + ansible.builtin.assert: + that: query_result == "4" + vars: + query_result: "{{ query('netbox.netbox.nb_lookup', 'sites', api_endpoint='http://localhost:32768', token='0123456789abcdef0123456789abcdef01234567') | count }}" + +- name: "NETBOX_LOOKUP 2: Query doesn't return Wibble (sanity check json_query)" + ansible.builtin.assert: + that: query_result == "0" + vars: + query_result: "{{ query('netbox.netbox.nb_lookup', 'devices', api_endpoint='http://localhost:32768', token='0123456789abcdef0123456789abcdef01234567') | community.general.json_query('[?value.display==`Wibble`]') + | count }}" + +- name: "NETBOX_LOOKUP 3: Device query returns exactly one TestDeviceR1" + ansible.builtin.assert: + that: query_result == "1" + vars: + query_result: "{{ query('netbox.netbox.nb_lookup', 'devices', api_endpoint='http://localhost:32768', token='0123456789abcdef0123456789abcdef01234567') | community.general.json_query('[?value.display==`TestDeviceR1`]') + | count }}" + +- name: "NETBOX_LOOKUP 4: VLAN ID 400 can be queried and is named 'Test VLAN'" + ansible.builtin.assert: + that: query_result == 'Test VLAN' + vars: + query_result: "{{ (query('netbox.netbox.nb_lookup', 'vlans', api_endpoint='http://localhost:32768', token='0123456789abcdef0123456789abcdef01234567') | community.general.json_query('[?value.vid==`400`].value.name'))[0] + }}" + +- name: "NETBOX_LOOKUP 5: Add one of two devices for lookup filter test." + netbox.netbox.netbox_device: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: L1 + device_type: Cisco Test + device_role: Core Switch + site: Test Site + status: Staged + tags: + - nolookup + state: present + +- name: "NETBOX_LOOKUP 6: Add two of two devices for lookup filter test." + netbox.netbox.netbox_device: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: L2 + device_type: Cisco Test + device_role: Core Switch + site: Test Site2 + status: Staged + tags: + - lookup + state: present + +- name: "NETBOX_LOOKUP 7: Device query returns exactly the L2 device" + ansible.builtin.assert: + that: query_result == "1" + vars: + query_result: "{{ query('netbox.netbox.nb_lookup', 'devices', api_filter='role=core-switch tag=lookup', api_endpoint='http://localhost:32768', token='0123456789abcdef0123456789abcdef01234567') + | community.general.json_query('[?value.display==`L2`]') | count }}" + +- name: "NETBOX_LOOKUP 8: Device query specifying raw data returns payload without key/value dict" + ansible.builtin.assert: + that: query_result == "1" + vars: + query_result: "{{ query('netbox.netbox.nb_lookup', 'devices', api_filter='role=core-switch tag=lookup', api_endpoint='http://localhost:32768', token='0123456789abcdef0123456789abcdef01234567', + raw_data=True) | community.general.json_query('[?display==`L2`]') | count }}" + +- name: "NETBOX_LOOKUP 9: Device query specifying multiple sites, Make sure L1 and L2 are in the results" + ansible.builtin.assert: + that: + - "'L1' in query_result" + - "'L2' in query_result" + vars: + query_result: "{{ query('netbox.netbox.nb_lookup', 'devices', api_filter='role=core-switch site=test-site site=test-site2', api_endpoint='http://localhost:32768', + token='0123456789abcdef0123456789abcdef01234567', raw_data=True) | community.general.json_query('[*].display') }}" + +- name: "NETBOX_LOOKUP 10: Device query by ID" + ansible.builtin.assert: + that: query_result + vars: + query_result: "{{ query('netbox.netbox.nb_lookup', 'devices', api_filter='id=1', api_endpoint='http://localhost:32768', token='0123456789abcdef0123456789abcdef01234567') + }}" + +- name: "NETBOX_LOOKUP 11: Device query by ansible variable" + ansible.builtin.set_fact: + hostname: "L2" + +- name: "NETBOX LOOKUP 11.1: Obtain details of a single device from NetBox" + ansible.builtin.debug: + msg: > + "Device {{item.0.value.display}} (ID: {{item.0.key}}) was + manufactured by {{ item.0.value.device_type.manufacturer.name }}" + loop: + - '{{ query("netbox.netbox.nb_lookup", "devices", + api_filter="name=" ~hostname, + api_endpoint="http://localhost:32768", + token="0123456789abcdef0123456789abcdef01234567") }}' diff --git a/tests/integration/targets/v4.3/tasks/netbox_mac_address.yml b/tests/integration/targets/v4.3/tasks/netbox_mac_address.yml new file mode 100644 index 000000000..88192d197 --- /dev/null +++ b/tests/integration/targets/v4.3/tasks/netbox_mac_address.yml @@ -0,0 +1,70 @@ +--- +## +## +### NETBOX_MAC_ADDRESS +## +## +- name: "MAC 1: Create MAC address with required parameters" + netbox.netbox.netbox_mac_address: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + mac_address: "00:11:22:33:44:55" + state: present + register: test_one + +- name: "MAC 1: ASSERT - Create MAC address" + ansible.builtin.assert: + that: + - test_one is changed + - test_one['diff']['before']['state'] == "absent" + - test_one['diff']['after']['state'] == "present" + - test_one['mac_address']['mac_address'] == "00:11:22:33:44:55" + - test_one['msg'] == "mac_address 00:11:22:33:44:55 created" + +- name: "MAC 2: Create MAC address with all parameters" + netbox.netbox.netbox_mac_address: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + mac_address: "AA:BB:CC:DD:EE:F0" + assigned_object: + device: Test Nexus One + name: Ethernet1/1 + description: "Test MAC address" + comments: "Test MAC address comment" + tags: + - Schnozzberry + state: present + register: test_two + +- name: "MAC 2: ASSERT - Create MAC address with all parameters" + ansible.builtin.assert: + that: + - test_two is changed + - test_two['diff']['before']['state'] == "absent" + - test_two['diff']['after']['state'] == "present" + - test_two['mac_address']['mac_address'] == "AA:BB:CC:DD:EE:F0" + - test_two['mac_address']['assigned_object_type'] == "dcim.interface" + - test_two['mac_address']['assigned_object_id'] == 1 + - test_two['mac_address']['description'] == "Test MAC address" + - test_two['mac_address']['comments'] == "Test MAC address comment" + - test_two['mac_address']['tags'][0] == 4 + - test_two['msg'] == "mac_address AA:BB:CC:DD:EE:F0 created" + +- name: "MAC 3: Delete MAC address" + netbox.netbox.netbox_mac_address: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + mac_address: "00:11:22:33:44:55" + state: absent + register: test_three + +- name: "MAC 3: ASSERT - Delete MAC address" + ansible.builtin.assert: + that: + - test_three is changed + - test_three['diff']['before']['state'] == "present" + - test_three['diff']['after']['state'] == "absent" + - test_three['msg'] == "mac_address 00:11:22:33:44:55 deleted" diff --git a/tests/integration/targets/v4.3/tasks/netbox_manufacturer.yml b/tests/integration/targets/v4.3/tasks/netbox_manufacturer.yml new file mode 100644 index 000000000..39804659b --- /dev/null +++ b/tests/integration/targets/v4.3/tasks/netbox_manufacturer.yml @@ -0,0 +1,91 @@ +--- +## +## +### NETBOX_MANUFACTURER +## +## +- name: "MANUFACTURER 1: Necessary info creation" + netbox.netbox.netbox_manufacturer: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test Manufacturer Two + state: present + register: test_one + +- name: "MANUFACTURER 1: ASSERT - Necessary info creation" + ansible.builtin.assert: + that: + - test_one is changed + - test_one['diff']['before']['state'] == "absent" + - test_one['diff']['after']['state'] == "present" + - test_one['manufacturer']['name'] == "Test Manufacturer Two" + - test_one['manufacturer']['slug'] == "test-manufacturer-two" + - test_one['msg'] == "manufacturer Test Manufacturer Two created" + +- name: "MANUFACTURER 2: Create duplicate" + netbox.netbox.netbox_manufacturer: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test Manufacturer Two + state: present + register: test_two + +- name: "MANUFACTURER 2: ASSERT - Create duplicate" + ansible.builtin.assert: + that: + - not test_two['changed'] + - test_two['manufacturer']['name'] == "Test Manufacturer Two" + - test_two['manufacturer']['slug'] == "test-manufacturer-two" + - test_two['msg'] == "manufacturer Test Manufacturer Two already exists" + +- name: "MANUFACTURER 3: Update" + netbox.netbox.netbox_manufacturer: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: test manufacturer two + state: present + register: test_three + +- name: "MANUFACTURER 3: ASSERT - Update" + ansible.builtin.assert: + that: + - test_three['changed'] + - test_three['manufacturer']['name'] == "test manufacturer two" + - test_three['manufacturer']['slug'] == "test-manufacturer-two" + - test_three['msg'] == "manufacturer test manufacturer two updated" + +- name: "MANUFACTURER 4: ASSERT - Delete" + netbox.netbox.netbox_manufacturer: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: test manufacturer two + state: absent + register: test_four + +- name: "MANUFACTURER 3: ASSERT - Delete" + ansible.builtin.assert: + that: + - test_four is changed + - test_four['diff']['before']['state'] == "present" + - test_four['diff']['after']['state'] == "absent" + - test_four['msg'] == "manufacturer test manufacturer two deleted" + +- name: "MANUFACTURER 5: ASSERT - Delete non existing" + netbox.netbox.netbox_manufacturer: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test Manufacturer Two + state: absent + register: test_five + +- name: "MANUFACTURER 5: ASSERT - Delete non existing" + ansible.builtin.assert: + that: + - not test_five['changed'] + - test_five['manufacturer'] == None + - test_five['msg'] == "manufacturer Test Manufacturer Two already absent" diff --git a/tests/integration/targets/v4.3/tasks/netbox_module.yml b/tests/integration/targets/v4.3/tasks/netbox_module.yml new file mode 100644 index 000000000..0a18f3894 --- /dev/null +++ b/tests/integration/targets/v4.3/tasks/netbox_module.yml @@ -0,0 +1,107 @@ +--- +## +## +### NETBOX_MODULE +## +## +- name: "MODULE 1: Necessary info creation" + netbox.netbox.netbox_module: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + device: C9300-DEMO + module_bay: Network Module + module_type: C9300-NM-8X + state: present + register: test_one + +- name: "MODULE 1: ASSERT - Necessary info creation" + ansible.builtin.assert: + that: + - test_one is changed + - test_one['diff']['before']['state'] == "absent" + - test_one['diff']['after']['state'] == "present" + - test_one['module']['device'] == "C9300-DEMO" + - test_one['module']['module_bay'] == "Network Module" + - test_one['module']['module_type'] == "C9300-NM-8X" + - test_one['msg'] == "module ws-test-3750 created" + +- name: "MODULE 2: Create duplicate" + netbox.netbox.netbox_module: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + device: C9300-DEMO + module_bay: Network Module + module_type: C9300-NM-8X + state: present + register: test_two + +- name: "MODULE 2: ASSERT - Create duplicate" + ansible.builtin.assert: + that: + - not test_two['changed'] + - test_two['module']['device'] == "C9300-DEMO" + - test_two['module']['module_bay'] == "Network Module" + - test_two['module']['module_type'] == "C9300-NM-8X" + - test_two['msg'] == "module C9300-NM-8X already exists in slot Network Module of C9300-DEMO" + +- name: "MODULE 3: ASSERT - Update" + netbox.netbox.netbox_module: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + device: C9300-DEMO + module_bay: Network Module + module_type: C9300-NM-8X + serial: XXXNNNNXXXX + state: present + register: test_three + +- name: "MODULE 3: ASSERT - Update" + ansible.builtin.assert: + that: + - test_three is changed + - test_three['diff']['after']['serial'] == "XXXNNNNXXXX" + - test_three['module']['device'] == "C9300-DEMO" + - test_three['module']['module_bay'] == "Network Module" + - test_three['module']['module_type'] == "C9300-NM-8X" + - test_three['module']['serial'] == "XXXNNNNXXXX" + - test_three['msg'] == "module C9300-DEMO - Network Module - C9300-NM-8X updated" + +- name: "MODULE 4: ASSERT - Delete" + netbox.netbox.netbox_module: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + device: C9300-DEMO + module_bay: Network Module + module_type: C9300-NM-8X + state: absent + register: test_four + +- name: "MODULE 4: ASSERT - Delete" + ansible.builtin.assert: + that: + - test_four is changed + - test_four['diff']['before']['state'] == "present" + - test_four['diff']['after']['state'] == "absent" + - test_four['msg'] == "module C9300-NM-8X deleted in slot Network Module of C9300-DEMO" + +- name: "MODULE 5: ASSERT - Delete non existing" + netbox.netbox.netbox_module: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + device: C9300-DEMO + module_bay: Network Module + module_type: C9300-NM-2Y + state: absent + register: test_five + +- name: "MODULE 5: ASSERT - Delete non existing`" + ansible.builtin.assert: + that: + - not test_five['changed'] + - test_five['module'] == None + - test_five['msg'] == "module Test Module Type already absent" diff --git a/tests/integration/targets/v4.3/tasks/netbox_module_bay.yml b/tests/integration/targets/v4.3/tasks/netbox_module_bay.yml new file mode 100644 index 000000000..843a4767e --- /dev/null +++ b/tests/integration/targets/v4.3/tasks/netbox_module_bay.yml @@ -0,0 +1,105 @@ +--- +## +## +### NETBOX_MODULE_BAY +## +## +- name: "MODULE 1: Necessary info creation" + netbox.netbox.netbox_module_bay: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + device: C9300-DEMO + name: Network Module + position: 0 + state: present + register: test_one + +- name: "MODULE BAY 1: ASSERT - Necessary info creation" + ansible.builtin.assert: + that: + - test_one is changed + - test_one['diff']['before']['state'] == "absent" + - test_one['diff']['after']['state'] == "present" + - test_one['module_bay']['device'] == "C9300-DEMO" + - test_one['module_bay']['name'] == "Network Module" + - test_one['module_bay']['position'] == "0" + - test_one['msg'] == "module_bay Network Module in C9300-DEMO position 0 created" + +- name: "MODULE BAY 2: Create duplicate" + netbox.netbox.netbox_module_bay: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + device: C9300-DEMO + name: Network Module + position: 0 + state: present + register: test_two + +- name: "MODULE BAY 2: ASSERT - Create duplicate" + ansible.builtin.assert: + that: + - not test_two['changed'] + - test_two['module_bay']['device'] == "C9300-DEMO" + - test_two['module_bay']['name'] == "Network Module" + - test_two['module_bay']['position'] == "0" + - test_two['msg'] == "module_bay Network Module in C9300-DEMO position 0 already exists" + +- name: "MODULE BAY 3: ASSERT - Update" + netbox.netbox.netbox_module_bay: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + device: C9300-DEMO + name: Network Module + position: 0 + label: TEST + state: present + register: test_three + +- name: "MODULE BAY 3: ASSERT - Update" + ansible.builtin.assert: + that: + - test_three is changed + - test_three['diff']['after']['label'] == "TEST" + - test_three['module_bay']['device'] == "C9300-DEMO" + - test_three['module_bay']['name'] == "Network Module" + - test_three['module_bay']['position'] == "0" + - test_three['module_bay']['label'] == "TEST" + - test_three['msg'] == "module_bay Network Module in C9300-DEMO position 0 updated with label TEST" + +- name: "MODULE BAY 4: ASSERT - Delete" + netbox.netbox.netbox_module_bay: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + device: C9300-DEMO + name: Network Module + state: absent + register: test_four + +- name: "MODULE BAY 4: ASSERT - Delete" + ansible.builtin.assert: + that: + - test_four is changed + - test_four['diff']['before']['state'] == "present" + - test_four['diff']['after']['state'] == "absent" + - test_four['msg'] == "module_bay Network Module in C9300-DEMO position 0 deleted" + +- name: "MODULE BAY 5: ASSERT - Delete non existing" + netbox.netbox.netbox_module_bay: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + device: C9300-DEMO + name: Network Module + state: absent + register: test_five + +- name: "MODULE BAY 5: ASSERT - Delete non existing`" + ansible.builtin.assert: + that: + - not test_five['changed'] + - test_five['module_bay'] == None + - test_five['msg'] == "module_bay Network Module already absent" diff --git a/tests/integration/targets/v4.3/tasks/netbox_module_type.yml b/tests/integration/targets/v4.3/tasks/netbox_module_type.yml new file mode 100644 index 000000000..8ab077803 --- /dev/null +++ b/tests/integration/targets/v4.3/tasks/netbox_module_type.yml @@ -0,0 +1,97 @@ +--- +## +## +### NETBOX_MODULE_TYPE +## +## +- name: "MODULE_TYPE 1: Necessary info creation" + netbox.netbox.netbox_module_type: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + model: ws-test-3750 + manufacturer: Test Manufacturer + state: present + register: test_one + +- name: "MODULE_TYPE 1: ASSERT - Necessary info creation" + ansible.builtin.assert: + that: + - test_one is changed + - test_one['diff']['before']['state'] == "absent" + - test_one['diff']['after']['state'] == "present" + - test_one['module_type']['model'] == "ws-test-3750" + - test_one['module_type']['manufacturer'] == 3 + - test_one['msg'] == "module_type ws-test-3750 created" + +- name: "MODULE_TYPE 2: Create duplicate" + netbox.netbox.netbox_module_type: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + model: ws-test-3750 + manufacturer: Test Manufacturer + state: present + register: test_two + +- name: "MODULE_TYPE 2: ASSERT - Create duplicate" + ansible.builtin.assert: + that: + - not test_two['changed'] + - test_one['module_type']['model'] == "ws-test-3750" + - test_one['module_type']['manufacturer'] == 3 + - test_two['msg'] == "module_type ws-test-3750 already exists" + +- name: "MODULE_TYPE 3: ASSERT - Update" + netbox.netbox.netbox_module_type: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + model: ws-test-3750 + manufacturer: Test Manufacturer + part_number: ws-3750g-v2 + state: present + register: test_three + +- name: "MODULE_TYPE 3: ASSERT - Update" + ansible.builtin.assert: + that: + - test_three is changed + - test_three['diff']['after']['part_number'] == "ws-3750g-v2" + - test_three['module_type']['model'] == "ws-test-3750" + - test_three['module_type']['manufacturer'] == 3 + - test_three['module_type']['part_number'] == "ws-3750g-v2" + - test_three['msg'] == "module_type ws-test-3750 updated" + +- name: "MODULE_TYPE 4: ASSERT - Delete" + netbox.netbox.netbox_module_type: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + model: ws-test-3750 + state: absent + register: test_four + +- name: "MODULE_TYPE 4: ASSERT - Delete" + ansible.builtin.assert: + that: + - test_four is changed + - test_four['diff']['before']['state'] == "present" + - test_four['diff']['after']['state'] == "absent" + - test_four['msg'] == "module_type ws-test-3750 deleted" + +- name: "MODULE_TYPE 5: ASSERT - Delete non existing" + netbox.netbox.netbox_module_type: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + model: Test Module Type + state: absent + register: test_five + +- name: "MODULE_TYPE 5: ASSERT - Delete non existing`" + ansible.builtin.assert: + that: + - not test_five['changed'] + - test_five['module_type'] == None + - test_five['msg'] == "module_type Test Module Type already absent" diff --git a/tests/integration/targets/v4.3/tasks/netbox_permission.yml b/tests/integration/targets/v4.3/tasks/netbox_permission.yml new file mode 100644 index 000000000..4a785ce60 --- /dev/null +++ b/tests/integration/targets/v4.3/tasks/netbox_permission.yml @@ -0,0 +1,214 @@ +--- +## +## +### NETBOX_PERMISSION +## +## +- name: "PERMISSION 1: Necessary info creation" + netbox.netbox.netbox_permission: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test Permission + actions: + - view + object_types: [] + state: present + register: test_one + +- name: "PERMISSION 1: ASSERT - Necessary info creation" + ansible.builtin.assert: + that: + - test_one is changed + - test_one['diff']['before']['state'] == "absent" + - test_one['diff']['after']['state'] == "present" + - test_one['permission']['name'] == "Test Permission" + - test_one['msg'] == "permission Test Permission created" + +- name: "PERMISSION 2: Create duplicate" + netbox.netbox.netbox_permission: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test Permission + actions: + - view + object_types: [] + state: present + register: test_two + +- name: "PERMISSION 2: ASSERT - Create duplicate" + ansible.builtin.assert: + that: + - not test_two['changed'] + - test_two['permission']['name'] == "Test Permission" + - test_two['msg'] == "permission Test Permission already exists" + +- name: "PERMISSION 3: Update" + netbox.netbox.netbox_permission: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test Permission + description: The test permission + enabled: false + actions: + - view + - add + - change + - delete + - extreme_administration + object_types: + - vpn.tunneltermination + - wireless.wirelesslan + constraints: + name: Foo + state: present + register: test_three + +- name: "PERMISSION 3: ASSERT - Update" + ansible.builtin.assert: + that: + - test_three is changed + - test_three['diff']['after']['description'] == "The test permission" + - test_three['permission']['name'] == "Test Permission" + - test_three['permission']['description'] == "The test permission" + - test_three['permission']['enabled'] == False + - test_three['permission']['actions'] == ["view", "add", "change", "delete", "extreme_administration"] + - test_three['permission']['object_types'] == ["vpn.tunneltermination", "wireless.wirelesslan"] + - test_three['permission']['constraints']["name"] == "Foo" + - test_three['msg'] == "permission Test Permission updated" + +- name: "PERMISSION 4: Create second permission" + netbox.netbox.netbox_permission: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test Permission 2 + actions: + - view + object_types: [] + state: present + register: test_four + +- name: "PERMISSION 4: Create second permission" + ansible.builtin.assert: + that: + - test_four is changed + - test_four['diff']['before']['state'] == "absent" + - test_four['diff']['after']['state'] == "present" + - test_four['permission']['name'] == "Test Permission 2" + - test_four['msg'] == "permission Test Permission 2 created" + +- name: "PERMISSION 5: Add permission to group" + netbox.netbox.netbox_user_group: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test User Group + permissions: + - Test Permission + state: present + register: test_five + +- name: "PERMISSION 5: ASSERT - Add permission to group" + ansible.builtin.assert: + that: + - test_five is changed + - test_five['user_group']['permissions'] == [test_one['permission']['id']] + +- name: "PERMISSION 6: Add permission to user" + netbox.netbox.netbox_user: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + username: TestUser + password: TestPassword6 + permissions: + - Test Permission 2 + state: present + register: test_six + +- name: "PERMISSION 6: ASSERT - Add permission to user" + ansible.builtin.assert: + that: + - test_six is changed + - test_six['user']['permissions'] == [test_four['permission']['id']] + +- name: "PERMISSION 7: Delete" + netbox.netbox.netbox_permission: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test Permission + state: absent + register: test_seven + +- name: "PERMISSION 7: ASSERT - Delete" + ansible.builtin.assert: + that: + - test_seven is changed + - test_seven['diff']['before']['state'] == "present" + - test_seven['diff']['after']['state'] == "absent" + - test_seven['msg'] == "permission Test Permission deleted" + +- name: "PERMISSION 8: Delete non existing" + netbox.netbox.netbox_permission: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test Permission + state: absent + register: test_eight + +- name: "PERMISSION 8: ASSERT - Delete non existing`" + ansible.builtin.assert: + that: + - not test_eight['changed'] + - test_eight['permission'] == None + - test_eight['msg'] == "permission Test Permission already absent" + +- name: "PERMISSION 9: Necessary permission" + netbox.netbox.netbox_permission: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test Permission + description: The test permission + enabled: true + actions: + - view + - add + - change + - delete + - extreme_administration + object_types: + - vpn.tunneltermination + - wireless.wirelesslan + state: present + +- name: "PERMISSION 9: Re-create permission with lists in wrong order" + netbox.netbox.netbox_permission: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test Permission + description: The test permission + enabled: true + actions: + - extreme_administration + - delete + - change + - add + - view + object_types: + - wireless.wirelesslan + - vpn.tunneltermination + state: present + register: test_nine + +- name: "PERMISSION 9: ASSERT - The same lists in a new order do not update the permission" + ansible.builtin.assert: + that: + - not test_nine['changed'] + # actions and object_types seem to be ordered randomly so we cannot test them here diff --git a/tests/integration/targets/v4.3/tasks/netbox_platform.yml b/tests/integration/targets/v4.3/tasks/netbox_platform.yml new file mode 100644 index 000000000..8a36ef2c1 --- /dev/null +++ b/tests/integration/targets/v4.3/tasks/netbox_platform.yml @@ -0,0 +1,92 @@ +--- +## +## +### NETBOX_PLATFORM +## +## +- name: "PLATFORM 1: Necessary info creation" + netbox.netbox.netbox_platform: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test Platform + state: present + register: test_one + +- name: "PLATFORM 1: ASSERT - Necessary info creation" + ansible.builtin.assert: + that: + - test_one is changed + - test_one['diff']['before']['state'] == "absent" + - test_one['diff']['after']['state'] == "present" + - test_one['platform']['name'] == "Test Platform" + - test_one['platform']['slug'] == "test-platform" + - test_one['msg'] == "platform Test Platform created" + +- name: "PLATFORM 2: Create duplicate" + netbox.netbox.netbox_platform: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test Platform + state: present + register: test_two + +- name: "PLATFORM 2: ASSERT - Create duplicate" + ansible.builtin.assert: + that: + - not test_two['changed'] + - test_two['platform']['name'] == "Test Platform" + - test_two['platform']['slug'] == "test-platform" + - test_two['msg'] == "platform Test Platform already exists" + +- name: "PLATFORM 3: ASSERT - Update" + netbox.netbox.netbox_platform: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test Platform + manufacturer: Test Manufacturer + state: present + register: test_three + +- name: "PLATFORM 3: ASSERT - Update" + ansible.builtin.assert: + that: + - test_three is changed + - test_three['diff']['after']['manufacturer'] == 3 + - test_three['platform']['manufacturer'] == 3 + - test_three['msg'] == "platform Test Platform updated" + +- name: "PLATFORM 4: ASSERT - Delete" + netbox.netbox.netbox_platform: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test Platform + state: absent + register: test_four + +- name: "PLATFORM 4: ASSERT - Delete" + ansible.builtin.assert: + that: + - test_four is changed + - test_four['diff']['before']['state'] == "present" + - test_four['diff']['after']['state'] == "absent" + - test_four['msg'] == "platform Test Platform deleted" + +- name: "PLATFORM 5: ASSERT - Delete non existing" + netbox.netbox.netbox_platform: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test Platform + state: absent + register: test_five + +- name: "PLATFORM 5: ASSERT - Delete non existing`" + ansible.builtin.assert: + that: + - not test_five['changed'] + - test_five['platform'] == None + - test_five['msg'] == "platform Test Platform already absent" diff --git a/tests/integration/targets/v4.3/tasks/netbox_power_feed.yml b/tests/integration/targets/v4.3/tasks/netbox_power_feed.yml new file mode 100644 index 000000000..233e0fa4c --- /dev/null +++ b/tests/integration/targets/v4.3/tasks/netbox_power_feed.yml @@ -0,0 +1,125 @@ +--- +# © 2020 Nokia +# Licensed under the GNU General Public License v3.0 only +# SPDX-License-Identifier: GPL-3.0-only +## +## +### NETBOX_POWER_FEED +## +## +- name: "POWER_FEED 1: Necessary info creation" + netbox.netbox.netbox_power_feed: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Power Feed + power_panel: Power Panel + state: present + register: test_one + +- name: "POWER_FEED 1: ASSERT - Necessary info creation" + ansible.builtin.assert: + that: + - test_one is changed + - test_one['diff']['before']['state'] == "absent" + - test_one['diff']['after']['state'] == "present" + - test_one['power_feed']['name'] == "Power Feed" + - test_one['msg'] == "power_feed Power Feed created" + +- name: "POWER_FEED 2: Create duplicate" + netbox.netbox.netbox_power_feed: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Power Feed + power_panel: Power Panel + state: present + register: test_two + +- name: "POWER_FEED 2: ASSERT - Create duplicate" + ansible.builtin.assert: + that: + - not test_two['changed'] + - test_two['power_feed']['name'] == "Power Feed" + - test_two['power_feed']['power_panel'] == test_one['power_feed']['power_panel'] + - test_two['msg'] == "power_feed Power Feed already exists" + +- name: "POWER_FEED 3: Update power_feed with other fields" + netbox.netbox.netbox_power_feed: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Power Feed + power_panel: Power Panel + status: offline + type: redundant + supply: dc + phase: three-phase + voltage: 400 + amperage: 32 + max_utilization: 25 + comments: totally normal power feed + state: present + register: test_three + +- name: "POWER_FEED 3: ASSERT - Update power_feed with other fields" + ansible.builtin.assert: + that: + - test_three is changed + - test_three['diff']['after']['status'] == "offline" + - test_three['diff']['after']['type'] == "redundant" + - test_three['diff']['after']['supply'] == "dc" + - test_three['diff']['after']['phase'] == "three-phase" + - test_three['diff']['after']['voltage'] == 400 + - test_three['diff']['after']['amperage'] == 32 + - test_three['diff']['after']['max_utilization'] == 25 + - test_three['diff']['after']['comments'] == "totally normal power feed" + - test_three['power_feed']['name'] == "Power Feed" + - test_three['power_feed']['power_panel'] == test_one['power_feed']['power_panel'] + - test_three['power_feed']['status'] == "offline" + - test_three['power_feed']['type'] == "redundant" + - test_three['power_feed']['supply'] == "dc" + - test_three['power_feed']['phase'] == "three-phase" + - test_three['power_feed']['voltage'] == 400 + - test_three['power_feed']['amperage'] == 32 + - test_three['power_feed']['max_utilization'] == 25 + - test_three['power_feed']['comments'] == "totally normal power feed" + - test_three['msg'] == "power_feed Power Feed updated" + +- name: "POWER_FEED 4: Create Power Feed for Delete Test" + netbox.netbox.netbox_power_feed: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Power Feed 2 + power_panel: Power Panel + state: present + register: test_four + +- name: "POWER_FEED 4: ASSERT - Create Power Feed for Delete Test" + ansible.builtin.assert: + that: + - test_four is changed + - test_four['diff']['before']['state'] == "absent" + - test_four['diff']['after']['state'] == "present" + - test_four['power_feed']['name'] == "Power Feed 2" + - test_four['power_feed']['power_panel'] == test_one['power_feed']['power_panel'] + - test_four['msg'] == "power_feed Power Feed 2 created" + +- name: "POWER_FEED 5: Delete Power Feed" + netbox.netbox.netbox_power_feed: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Power Feed 2 + power_panel: Power Panel + state: absent + register: test_five + +- name: "POWER_FEED 5: ASSERT - Delete Power Feed" + ansible.builtin.assert: + that: + - test_five is changed + - test_five['diff']['before']['state'] == "present" + - test_five['diff']['after']['state'] == "absent" + - test_five['msg'] == "power_feed Power Feed 2 deleted" diff --git a/tests/integration/targets/v4.3/tasks/netbox_power_outlet.yml b/tests/integration/targets/v4.3/tasks/netbox_power_outlet.yml new file mode 100644 index 000000000..e38a8650a --- /dev/null +++ b/tests/integration/targets/v4.3/tasks/netbox_power_outlet.yml @@ -0,0 +1,113 @@ +--- +# © 2020 Nokia +# Licensed under the GNU General Public License v3.0 only +# SPDX-License-Identifier: GPL-3.0-only +## +## +### NETBOX_POWER_OUTLET +## +## +- name: "POWER_OUTLET 1: Necessary info creation" + netbox.netbox.netbox_power_outlet: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Power Outlet + device: Device Power Tests + state: present + register: test_one + +- name: "POWER_OUTLET 1: ASSERT - Necessary info creation" + ansible.builtin.assert: + that: + - test_one is changed + - test_one['diff']['before']['state'] == "absent" + - test_one['diff']['after']['state'] == "present" + - test_one['power_outlet']['name'] == "Power Outlet" + - test_one['msg'] == "power_outlet Power Outlet created" + +- name: "POWER_OUTLET 2: Create duplicate" + netbox.netbox.netbox_power_outlet: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Power Outlet + device: Device Power Tests + state: present + register: test_two + +- name: "POWER_OUTLET 2: ASSERT - Create duplicate" + ansible.builtin.assert: + that: + - not test_two['changed'] + - test_two['power_outlet']['name'] == "Power Outlet" + - test_two['power_outlet']['device'] == test_one['power_outlet']['device'] + - test_two['msg'] == "power_outlet Power Outlet already exists" + +- name: "POWER_OUTLET 3: Update power_outlet with other fields" + netbox.netbox.netbox_power_outlet: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Power Outlet + device: Device Power Tests + type: ita-e + power_port: Power Port + feed_leg: B + description: test description + state: present + register: test_three + +- name: "POWER_OUTLET 3: ASSERT - Update power_outlet with other fields" + ansible.builtin.assert: + that: + - test_three is changed + - test_three['diff']['after']['type'] == "ita-e" + - test_three['diff']['after']['power_port'] == 1 + - test_three['diff']['after']['feed_leg'] == "B" + - test_three['diff']['after']['description'] == "test description" + - test_three['power_outlet']['name'] == "Power Outlet" + - test_three['power_outlet']['device'] == test_one['power_outlet']['device'] + - test_three['power_outlet']['type'] == "ita-e" + - test_three['power_outlet']['power_port'] == 1 + - test_three['power_outlet']['feed_leg'] == "B" + - test_three['power_outlet']['description'] == "test description" + - test_three['msg'] == "power_outlet Power Outlet updated" + +- name: "POWER_OUTLET 4: Create Power Outlet for Delete Test" + netbox.netbox.netbox_power_outlet: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Power Outlet 2 + device: Device Power Tests + state: present + register: test_four + +- name: "POWER_OUTLET 4: ASSERT - Create Power Outlet for Delete Test" + ansible.builtin.assert: + that: + - test_four is changed + - test_four['diff']['before']['state'] == "absent" + - test_four['diff']['after']['state'] == "present" + - test_four['power_outlet']['name'] == "Power Outlet 2" + - test_four['power_outlet']['device'] == test_one['power_outlet']['device'] + - test_four['msg'] == "power_outlet Power Outlet 2 created" + +- name: "POWER_OUTLET 5: Delete Power Outlet" + netbox.netbox.netbox_power_outlet: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Power Outlet 2 + device: Device Power Tests + state: absent + register: test_five + +- name: "POWER_OUTLET 5: ASSERT - Delete Power Outlet" + ansible.builtin.assert: + that: + - test_five is changed + - test_five['diff']['before']['state'] == "present" + - test_five['diff']['after']['state'] == "absent" + - test_five['msg'] == "power_outlet Power Outlet 2 deleted" diff --git a/tests/integration/targets/v4.3/tasks/netbox_power_outlet_template.yml b/tests/integration/targets/v4.3/tasks/netbox_power_outlet_template.yml new file mode 100644 index 000000000..14ff49d0c --- /dev/null +++ b/tests/integration/targets/v4.3/tasks/netbox_power_outlet_template.yml @@ -0,0 +1,111 @@ +--- +# © 2020 Nokia +# Licensed under the GNU General Public License v3.0 only +# SPDX-License-Identifier: GPL-3.0-only +## +## +### NETBOX_POWER_OUTLET_TEMPLATE +## +## +- name: "POWER_OUTLET_TEMPLATE 1: Necessary info creation" + netbox.netbox.netbox_power_outlet_template: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Power Outlet Template + device_type: Device Type Power Tests + state: present + register: test_one + +- name: "POWER_OUTLET_TEMPLATE 1: ASSERT - Necessary info creation" + ansible.builtin.assert: + that: + - test_one is changed + - test_one['diff']['before']['state'] == "absent" + - test_one['diff']['after']['state'] == "present" + - test_one['power_outlet_template']['name'] == "Power Outlet Template" + - test_one['power_outlet_template']['device_type'] == 8 + - test_one['msg'] == "power_outlet_template Power Outlet Template created" + +- name: "POWER_OUTLET_TEMPLATE 2: Create duplicate" + netbox.netbox.netbox_power_outlet_template: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Power Outlet Template + device_type: Device Type Power Tests + state: present + register: test_two + +- name: "POWER_OUTLET_TEMPLATE 2: ASSERT - Create duplicate" + ansible.builtin.assert: + that: + - not test_two['changed'] + - test_two['power_outlet_template']['name'] == "Power Outlet Template" + - test_two['power_outlet_template']['device_type'] == 8 + - test_two['msg'] == "power_outlet_template Power Outlet Template already exists" + +- name: "POWER_OUTLET_TEMPLATE 3: Update power_outlet_template with other fields" + netbox.netbox.netbox_power_outlet_template: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Power Outlet Template + device_type: Device Type Power Tests + type: ita-e + power_port_template: Power Port Template + feed_leg: B + state: present + register: test_three + +- name: "POWER_OUTLET_TEMPLATE 3: ASSERT - Update power_outlet_template with other fields" + ansible.builtin.assert: + that: + - test_three is changed + - test_three['diff']['after']['type'] == "ita-e" + - test_three['diff']['after']['power_port'] == 1 + - test_three['diff']['after']['feed_leg'] == "B" + - test_three['power_outlet_template']['name'] == "Power Outlet Template" + - test_three['power_outlet_template']['device_type'] == 8 + - test_three['power_outlet_template']['type'] == "ita-e" + - test_three['power_outlet_template']['power_port'] == 1 + - test_three['power_outlet_template']['feed_leg'] == "B" + - test_three['msg'] == "power_outlet_template Power Outlet Template updated" + +- name: "POWER_OUTLET_TEMPLATE 4: Create Power Outlet Template for Delete Test" + netbox.netbox.netbox_power_outlet_template: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Power Outlet Template 2 + device_type: Device Type Power Tests + state: present + register: test_four + +- name: "POWER_OUTLET_TEMPLATE 4: ASSERT - Create Power Outlet Template for Delete Test" + ansible.builtin.assert: + that: + - test_four is changed + - test_four['diff']['before']['state'] == "absent" + - test_four['diff']['after']['state'] == "present" + - test_four['power_outlet_template']['name'] == "Power Outlet Template 2" + - test_four['power_outlet_template']['device_type'] == 8 + - test_four['msg'] == "power_outlet_template Power Outlet Template 2 created" + +- name: "POWER_OUTLET_TEMPLATE 5: Delete Power Outlet Template" + netbox.netbox.netbox_power_outlet_template: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Power Outlet Template 2 + device_type: Device Type Power Tests + state: absent + register: test_five + +- name: "POWER_OUTLET_TEMPLATE 5: ASSERT - Delete Power Outlet Template" + ansible.builtin.assert: + that: + - test_five is changed + - test_five['diff']['before']['state'] == "present" + - test_five['diff']['after']['state'] == "absent" + - test_five['msg'] == "power_outlet_template Power Outlet Template 2 deleted" diff --git a/tests/integration/targets/v4.3/tasks/netbox_power_panel.yml b/tests/integration/targets/v4.3/tasks/netbox_power_panel.yml new file mode 100644 index 000000000..e568a75f4 --- /dev/null +++ b/tests/integration/targets/v4.3/tasks/netbox_power_panel.yml @@ -0,0 +1,105 @@ +--- +# © 2020 Nokia +# Licensed under the GNU General Public License v3.0 only +# SPDX-License-Identifier: GPL-3.0-only +## +## +### NETBOX_POWER_PANEL +## +## +- name: "POWER_PANEL 1: Necessary info creation" + netbox.netbox.netbox_power_panel: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Power Panel + site: Test Site + state: present + register: test_one + +- name: "POWER_PANEL 1: ASSERT - Necessary info creation" + ansible.builtin.assert: + that: + - test_one is changed + - test_one['diff']['before']['state'] == "absent" + - test_one['diff']['after']['state'] == "present" + - test_one['power_panel']['name'] == "Power Panel" + - test_one['power_panel']['site'] == 1 + - test_one['msg'] == "power_panel Power Panel created" + +- name: "POWER_PANEL 2: Create duplicate" + netbox.netbox.netbox_power_panel: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Power Panel + site: Test Site + state: present + register: test_two + +- name: "POWER_PANEL 2: ASSERT - Create duplicate" + ansible.builtin.assert: + that: + - not test_two['changed'] + - test_two['power_panel']['name'] == "Power Panel" + - test_two['power_panel']['site'] == 1 + - test_two['msg'] == "power_panel Power Panel already exists" + +- name: "POWER_PANEL 3: Update power_panel with other fields" + netbox.netbox.netbox_power_panel: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Power Panel + site: Test Site + location: Test Rack Group + state: present + register: test_three + +- name: "POWER_PANEL 3: ASSERT - Update power_panel with other fields" + ansible.builtin.assert: + that: + - test_three is changed + - test_three['diff']['after']['location'] == 1 + - test_three['power_panel']['name'] == "Power Panel" + - test_three['power_panel']['site'] == 1 + - test_three['power_panel']['location'] == 1 + - test_three['msg'] == "power_panel Power Panel updated" + +- name: "POWER_PANEL 4: Create Power Panel for Delete Test" + netbox.netbox.netbox_power_panel: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Power Panel 2 + site: Test Site + state: present + register: test_four + +- name: "POWER_PANEL 4: ASSERT - Create Power Panel for Delete Test" + ansible.builtin.assert: + that: + - test_four is changed + - test_four['diff']['before']['state'] == "absent" + - test_four['diff']['after']['state'] == "present" + - test_four['power_panel']['name'] == "Power Panel 2" + - test_four['power_panel']['site'] == 1 + - test_four['msg'] == "power_panel Power Panel 2 created" + +- name: "POWER_PANEL 5: Delete Power Panel" + netbox.netbox.netbox_power_panel: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Power Panel 2 + site: Test Site + state: absent + register: test_five + +- name: "POWER_PANEL 5: ASSERT - Delete Power Panel" + ansible.builtin.assert: + that: + - test_five is changed + - test_five['diff']['before']['state'] == "present" + - test_five['diff']['after']['state'] == "absent" + - test_five['msg'] == "power_panel Power Panel 2 deleted" diff --git a/tests/integration/targets/v4.3/tasks/netbox_power_port.yml b/tests/integration/targets/v4.3/tasks/netbox_power_port.yml new file mode 100644 index 000000000..7b0a7d50d --- /dev/null +++ b/tests/integration/targets/v4.3/tasks/netbox_power_port.yml @@ -0,0 +1,124 @@ +--- +# © 2020 Nokia +# Licensed under the GNU General Public License v3.0 only +# SPDX-License-Identifier: GPL-3.0-only +## +## +### NETBOX_POWER_PORT +## +## +- name: "POWER_PORT 0: Create device for testing power ports" + netbox.netbox.netbox_device: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Device Power Tests + device_type: Cisco Test + device_role: Core Switch + site: Test Site + state: present + +- name: "POWER_PORT 1: Necessary info creation" + netbox.netbox.netbox_power_port: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Power Port + device: Device Power Tests + state: present + register: test_one + +- name: "POWER_PORT 1: ASSERT - Necessary info creation" + ansible.builtin.assert: + that: + - test_one is changed + - test_one['diff']['before']['state'] == "absent" + - test_one['diff']['after']['state'] == "present" + - test_one['power_port']['name'] == "Power Port" + - test_one['msg'] == "power_port Power Port created" + +- name: "POWER_PORT 2: Create duplicate" + netbox.netbox.netbox_power_port: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Power Port + device: Device Power Tests + state: present + register: test_two + +- name: "POWER_PORT 2: ASSERT - Create duplicate" + ansible.builtin.assert: + that: + - not test_two['changed'] + - test_two['power_port']['name'] == "Power Port" + - test_two['power_port']['device'] == test_one['power_port']['device'] + - test_two['msg'] == "power_port Power Port already exists" + +- name: "POWER_FEED 3: Update power_port with other fields" + netbox.netbox.netbox_power_port: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Power Port + device: Device Power Tests + type: ita-e + allocated_draw: 10 + maximum_draw: 20 + description: test description + state: present + register: test_three + +- name: "POWER_FEED 3: ASSERT - Update power_port with other fields" + ansible.builtin.assert: + that: + - test_three is changed + - test_three['diff']['after']['type'] == "ita-e" + - test_three['diff']['after']['allocated_draw'] == 10 + - test_three['diff']['after']['maximum_draw'] == 20 + - test_three['diff']['after']['description'] == "test description" + - test_three['power_port']['name'] == "Power Port" + - test_three['power_port']['device'] == test_one['power_port']['device'] + - test_three['power_port']['type'] == "ita-e" + - test_three['power_port']['allocated_draw'] == 10 + - test_three['power_port']['maximum_draw'] == 20 + - test_three['power_port']['description'] == "test description" + - test_three['msg'] == "power_port Power Port updated" + +- name: "POWER_PORT 4: Create Power Port for Delete Test" + netbox.netbox.netbox_power_port: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Power Port 2 + device: Device Power Tests + state: present + register: test_four + +- name: "POWER_PORT 4: ASSERT - Create Power Port for Delete Test" + ansible.builtin.assert: + that: + - test_four is changed + - test_four['diff']['before']['state'] == "absent" + - test_four['diff']['after']['state'] == "present" + - test_four['power_port']['name'] == "Power Port 2" + - test_four['power_port']['device'] == test_one['power_port']['device'] + - test_four['msg'] == "power_port Power Port 2 created" + +- name: "POWER_PORT 5: Delete Power Port" + netbox.netbox.netbox_power_port: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Power Port 2 + device: Device Power Tests + state: absent + register: test_five + +- name: "POWER_PORT 5: ASSERT - Delete Power Port" + ansible.builtin.assert: + that: + - test_five is changed + - test_five['diff']['before']['state'] == "present" + - test_five['diff']['after']['state'] == "absent" + - test_five['msg'] == "power_port Power Port 2 deleted" diff --git a/tests/integration/targets/v4.3/tasks/netbox_power_port_template.yml b/tests/integration/targets/v4.3/tasks/netbox_power_port_template.yml new file mode 100644 index 000000000..b413c29ce --- /dev/null +++ b/tests/integration/targets/v4.3/tasks/netbox_power_port_template.yml @@ -0,0 +1,212 @@ +--- +# © 2020 Nokia +# Licensed under the GNU General Public License v3.0 only +# SPDX-License-Identifier: GPL-3.0-only +## +## +### NETBOX_POWER_PORT_TEMPLATE +## +## +- name: "POWER_PORT_TEMPLATE 0.1: Create device type for testing power ports on device types" + netbox.netbox.netbox_device_type: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + model: Device Type Power Tests + manufacturer: Test Manufacturer + state: present + +- name: "POWER_PORT_TEMPLATE 0.2: Create module type for testing power ports on module types" + netbox.netbox.netbox_module_type: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + model: Module Type Power Tests + manufacturer: Test Manufacturer + state: present + +- name: "POWER_PORT_TEMPLATE 1: Necessary info creation" + netbox.netbox.netbox_power_port_template: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Power Port Template + device_type: Device Type Power Tests + state: present + register: test_one + +- name: "POWER_PORT_TEMPLATE 1: ASSERT - Necessary info creation" + ansible.builtin.assert: + that: + - test_one is changed + - test_one['diff']['before']['state'] == "absent" + - test_one['diff']['after']['state'] == "present" + - test_one['power_port_template']['name'] == "Power Port Template" + - test_one['power_port_template']['device_type'] == 8 + - test_one['msg'] == "power_port_template Power Port Template created" + +- name: "POWER_PORT_TEMPLATE 2: Create duplicate" + netbox.netbox.netbox_power_port_template: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Power Port Template + device_type: Device Type Power Tests + state: present + register: test_two + +- name: "POWER_PORT_TEMPLATE 2: ASSERT - Create duplicate" + ansible.builtin.assert: + that: + - not test_two['changed'] + - test_two['power_port_template']['name'] == "Power Port Template" + - test_two['power_port_template']['device_type'] == 8 + - test_two['msg'] == "power_port_template Power Port Template already exists" + +- name: "POWER_PORT_TEMPLATE 3: Update power_port_template with other fields" + netbox.netbox.netbox_power_port_template: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Power Port Template + device_type: Device Type Power Tests + type: ita-e + allocated_draw: 10 + maximum_draw: 20 + state: present + register: test_three + +- name: "POWER_PORT_TEMPLATE 3: ASSERT - Update power_port_template with other fields" + ansible.builtin.assert: + that: + - test_three is changed + - test_three['diff']['after']['type'] == "ita-e" + - test_three['diff']['after']['allocated_draw'] == 10 + - test_three['diff']['after']['maximum_draw'] == 20 + - test_three['power_port_template']['name'] == "Power Port Template" + - test_three['power_port_template']['device_type'] == 8 + - test_three['power_port_template']['type'] == "ita-e" + - test_three['power_port_template']['allocated_draw'] == 10 + - test_three['power_port_template']['maximum_draw'] == 20 + - test_three['msg'] == "power_port_template Power Port Template updated" + +- name: "POWER_PORT_TEMPLATE 4: Create Power Port Template for Delete Test" + netbox.netbox.netbox_power_port_template: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Power Port Template 2 + device_type: Device Type Power Tests + state: present + register: test_four + +- name: "POWER_PORT_TEMPLATE 4: ASSERT - Create Power Port Template for Delete Test" + ansible.builtin.assert: + that: + - test_four is changed + - test_four['diff']['before']['state'] == "absent" + - test_four['diff']['after']['state'] == "present" + - test_four['power_port_template']['name'] == "Power Port Template 2" + - test_four['power_port_template']['device_type'] == 8 + - test_four['msg'] == "power_port_template Power Port Template 2 created" + +- name: "POWER_PORT_TEMPLATE 5: Delete Power Port Template" + netbox.netbox.netbox_power_port_template: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Power Port Template 2 + device_type: Device Type Power Tests + state: absent + register: test_five + +- name: "POWER_PORT_TEMPLATE 5: ASSERT - Delete Power Port Template" + ansible.builtin.assert: + that: + - test_five is changed + - test_five['diff']['before']['state'] == "present" + - test_five['diff']['after']['state'] == "absent" + - test_five['msg'] == "power_port_template Power Port Template 2 deleted" + +- name: "POWER_PORT_TEMPLATE 6: Necessary info creation" + netbox.netbox.netbox_power_port_template: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Module Power Port Template + module_type: Module Type Power Tests + state: present + register: test_six + +- name: "POWER_PORT_TEMPLATE 6: ASSERT - Necessary info creation" + ansible.builtin.assert: + that: + - test_six is changed + - test_six['diff']['before']['state'] == "absent" + - test_six['diff']['after']['state'] == "present" + - test_six['power_port_template']['name'] == "Module Power Port Template" + - test_six['power_port_template']['module_type'] == 1 + - test_six['msg'] == "power_port_template Module Power Port Template created" + +- name: "POWER_PORT_TEMPLATE 7: Create duplicate" + netbox.netbox.netbox_power_port_template: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Module Power Port Template + module_type: Module Type Power Tests + state: present + register: test_seven + +- name: "POWER_PORT_TEMPLATE 7: ASSERT - Create duplicate" + ansible.builtin.assert: + that: + - not test_seven['changed'] + - test_seven['power_port_template']['name'] == "Module Power Port Template" + - test_seven['power_port_template']['module_type'] == 1 + - test_seven['msg'] == "power_port_template Module Power Port Template already exists" + +- name: "POWER_PORT_TEMPLATE 8: Update power_port_template with other fields" + netbox.netbox.netbox_power_port_template: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Module Power Port Template + module_type: Module Type Power Tests + type: ita-e + allocated_draw: 10 + maximum_draw: 20 + state: present + register: test_eight + +- name: "POWER_PORT_TEMPLATE 8: ASSERT - Update power_port_template with other fields" + ansible.builtin.assert: + that: + - test_eight is changed + - test_eight['diff']['after']['type'] == "ita-e" + - test_eight['diff']['after']['allocated_draw'] == 10 + - test_eight['diff']['after']['maximum_draw'] == 20 + - test_eight['power_port_template']['name'] == "Module Power Port Template" + - test_eight['power_port_template']['module_type'] == 1 + - test_eight['power_port_template']['type'] == "ita-e" + - test_eight['power_port_template']['allocated_draw'] == 10 + - test_eight['power_port_template']['maximum_draw'] == 20 + - test_eight['msg'] == "power_port_template Module Power Port Template updated" + +- name: "POWER_PORT_TEMPLATE 9: Delete Power Port Template" + netbox.netbox.netbox_power_port_template: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Module Power Port Template + module_type: Module Type Power Tests + state: absent + register: test_nine + +- name: "POWER_PORT_TEMPLATE 9: ASSERT - Delete Power Port Template" + ansible.builtin.assert: + that: + - test_nine is changed + - test_nine['diff']['before']['state'] == "present" + - test_nine['diff']['after']['state'] == "absent" + - test_nine['msg'] == "power_port_template Module Power Port Template deleted" diff --git a/tests/integration/targets/v4.3/tasks/netbox_prefix.yml b/tests/integration/targets/v4.3/tasks/netbox_prefix.yml new file mode 100644 index 000000000..4b42d748e --- /dev/null +++ b/tests/integration/targets/v4.3/tasks/netbox_prefix.yml @@ -0,0 +1,254 @@ +--- +## +## +### NETBOX_PREFIX +## +## +- name: 1 - Create prefix within NetBox with only required information + netbox.netbox.netbox_prefix: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + prefix: 10.156.0.0/19 + state: present + register: test_one + +- name: 1 - ASSERT + ansible.builtin.assert: + that: + - test_one is changed + - test_one['diff']['before']['state'] == "absent" + - test_one['diff']['after']['state'] == "present" + - test_one['msg'] == "prefix 10.156.0.0/19 created" + - test_one['prefix']['prefix'] == "10.156.0.0/19" + +- name: 2 - Duplicate + netbox.netbox.netbox_prefix: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + prefix: 10.156.0.0/19 + state: present + register: test_two + +- name: 2 - ASSERT + ansible.builtin.assert: + that: + - not test_two['changed'] + - test_two['msg'] == "prefix 10.156.0.0/19 already exists" + - test_two['prefix']['prefix'] == "10.156.0.0/19" + +- name: 3 - Update 10.156.0.0/19 + netbox.netbox.netbox_prefix: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + prefix: 10.156.0.0/19 + scope_type: "dcim.site" + scope: Test Site + status: Reserved + description: This prefix has been updated + state: present + register: test_three + +- name: 3 - ASSERT + ansible.builtin.assert: + that: + - test_three is changed + - 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']['scope'] == 1 + - test_three['prefix']['scope_type'] == "dcim.site" + - test_three['prefix']['status'] == "reserved" + - test_three['prefix']['description'] == "This prefix has been updated" + +- name: 4 - Delete prefix within netbox + netbox.netbox.netbox_prefix: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + prefix: 10.156.0.0/19 + state: absent + register: test_four + +- name: 4 - ASSERT + ansible.builtin.assert: + that: + - test_four is changed + - test_four['diff']['before']['state'] == "present" + - test_four['diff']['after']['state'] == "absent" + - test_four['msg'] == "prefix 10.156.0.0/19 deleted" + +- name: 5 - Create prefix with several specified options + netbox.netbox.netbox_prefix: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + family: 4 + prefix: 10.156.32.0/19 + scope_type: "dcim.site" + scope: Test Site + vrf: Test VRF + tenant: Test Tenant + vlan: + name: Test VLAN + site: Test Site + tenant: Test Tenant + vlan_group: Test Vlan Group + status: Reserved + prefix_role: Network of care + description: Test description + is_pool: true + tags: + - Schnozzberry + state: present + register: test_five + +- name: 5 - ASSERT + ansible.builtin.assert: + that: + - test_five is changed + - test_five['diff']['before']['state'] == "absent" + - test_five['diff']['after']['state'] == "present" + - 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']['scope'] == 1 + - test_five['prefix']['scope_type'] == "dcim.site" + - test_five['prefix']['vrf'] == 1 + - test_five['prefix']['tenant'] == 1 + - test_five['prefix']['vlan'] == 4 + - test_five['prefix']['status'] == "reserved" + - test_five['prefix']['role'] == 1 + - test_five['prefix']['description'] == "Test description" + - test_five['prefix']['is_pool'] == true + - test_five['prefix']['tags'][0] == 4 + +- name: 6 - Get a new /24 inside 10.156.0.0/19 within NetBox - Parent doesn't exist + netbox.netbox.netbox_prefix: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + parent: 10.156.0.0/19 + prefix_length: 24 + state: present + first_available: true + register: test_six + +- name: 6 - ASSERT + ansible.builtin.assert: + that: + - not test_six['changed'] + - test_six['msg'] == "Parent prefix does not exist - 10.156.0.0/19" + +- name: 7 - Create prefix within NetBox with only required information + netbox.netbox.netbox_prefix: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + prefix: 10.156.0.0/19 + state: present + register: test_seven + +- name: 7 - ASSERT + ansible.builtin.assert: + that: + - test_seven is changed + - test_seven['diff']['before']['state'] == "absent" + - test_seven['diff']['after']['state'] == "present" + - test_seven['msg'] == "prefix 10.156.0.0/19 created" + - test_seven['prefix']['prefix'] == "10.156.0.0/19" + +- name: 8 - Get a new /24 inside 10.156.0.0/19 within NetBox + netbox.netbox.netbox_prefix: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + parent: 10.156.0.0/19 + prefix_length: 24 + state: present + first_available: true + register: test_eight + +- name: 8 - ASSERT + ansible.builtin.assert: + that: + - test_eight is changed + - test_eight['diff']['before']['state'] == "absent" + - test_eight['diff']['after']['state'] == "present" + - test_eight['msg'] == "prefix 10.156.0.0/24 created" + - test_eight['prefix']['prefix'] == "10.156.0.0/24" + +- name: 9 - Create 10.157.0.0/19 + netbox.netbox.netbox_prefix: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + prefix: 10.157.0.0/19 + vrf: Test VRF + scope_type: "dcim.site" + scope: Test Site + state: present + register: test_nine + +- name: 9 - ASSERT + ansible.builtin.assert: + that: + - test_nine is changed + - test_nine['diff']['before']['state'] == "absent" + - 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']['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 + netbox.netbox.netbox_prefix: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + parent: 10.157.0.0/19 + prefix_length: 24 + vrf: Test VRF + scope_type: "dcim.site" + scope: Test Site + state: present + first_available: true + register: test_ten + +- name: 10 - ASSERT + ansible.builtin.assert: + that: + - test_ten is changed + - test_ten['diff']['before']['state'] == "absent" + - 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']['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 + netbox.netbox.netbox_prefix: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + parent: 10.156.0.0/19 + prefix_length: 24 + state: present + first_available: true + register: test_eleven + +- name: 11 - ASSERT + ansible.builtin.assert: + that: + - test_eleven is changed + - test_eleven['diff']['before']['state'] == "absent" + - test_eleven['diff']['after']['state'] == "present" + - test_eleven['msg'] == "prefix 10.156.1.0/24 created" + - test_eleven['prefix']['prefix'] == "10.156.1.0/24" diff --git a/tests/integration/targets/v4.3/tasks/netbox_provider.yml b/tests/integration/targets/v4.3/tasks/netbox_provider.yml new file mode 100644 index 000000000..ec7b2c30a --- /dev/null +++ b/tests/integration/targets/v4.3/tasks/netbox_provider.yml @@ -0,0 +1,79 @@ +--- +## +## +### NETBOX_PROVIDER +## +## +- name: "NETBOX_PROVIDER 1: Create provider within NetBox with only required information" + netbox.netbox.netbox_provider: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test Provider One + state: present + register: test_one + +- name: "NETBOX_PROVIDER 1: ASSERT - Necessary info creation" + ansible.builtin.assert: + that: + - test_one is changed + - test_one['diff']['before']['state'] == "absent" + - test_one['diff']['after']['state'] == "present" + - test_one['provider']['name'] == "Test Provider One" + - test_one['provider']['slug'] == "test-provider-one" + - test_one['msg'] == "provider Test Provider One created" + +- name: "NETBOX_PROVIDER 2: Duplicate" + netbox.netbox.netbox_provider: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test Provider One + state: present + register: test_two + +- name: "NETBOX_PROVIDER 2: ASSERT - Create duplicate" + ansible.builtin.assert: + that: + - not test_two['changed'] + - test_two['provider']['name'] == "Test Provider One" + - test_two['provider']['slug'] == "test-provider-one" + - test_two['msg'] == "provider Test Provider One already exists" + +- name: "NETBOX_PROVIDER 3: Update provider with other fields" + netbox.netbox.netbox_provider: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test Provider One + comments: BAD PROVIDER + state: present + register: test_three + +- name: "NETBOX_PROVIDER 3: ASSERT - Updated" + ansible.builtin.assert: + that: + - test_three is changed + - test_three['diff']['after']['comments'] == "BAD PROVIDER" + - test_three['provider']['name'] == "Test Provider One" + - test_three['provider']['slug'] == "test-provider-one" + - test_three['provider']['comments'] == "BAD PROVIDER" + - test_three['msg'] == "provider Test Provider One updated" + +- name: "NETBOX_PROVIDER 4: Delete provider within netbox" + netbox.netbox.netbox_provider: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test Provider One + state: absent + register: test_four + +- name: "NETBOX_PROVIDER 4 : ASSERT - Delete" + ansible.builtin.assert: + that: + - test_four is changed + - test_four['provider']['name'] == "Test Provider One" + - test_four['provider']['slug'] == "test-provider-one" + - test_four['provider']['comments'] == "BAD PROVIDER" + - test_four['msg'] == "provider Test Provider One deleted" diff --git a/tests/integration/targets/v4.3/tasks/netbox_provider_network.yml b/tests/integration/targets/v4.3/tasks/netbox_provider_network.yml new file mode 100644 index 000000000..6f8b2b331 --- /dev/null +++ b/tests/integration/targets/v4.3/tasks/netbox_provider_network.yml @@ -0,0 +1,83 @@ +--- +## +## +### NETBOX_PROVIDER +## +## +- name: "NETBOX_PROVIDER_NETWORK 1: Create provider network within NetBox with only required information" + netbox.netbox.netbox_provider_network: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + provider: Test Provider + name: Test Provider Network One + state: present + register: test_one + +- name: "NETBOX_PROVIDER_NETWORK 1: ASSERT - Necessary info creation" + ansible.builtin.assert: + that: + - test_one is changed + - test_one['diff']['before']['state'] == "absent" + - test_one['diff']['after']['state'] == "present" + - test_one['provider_network']['name'] == "Test Provider Network One" + - test_one['msg'] == "provider_network Test Provider Network One created" + +- name: "NETBOX_PROVIDER_NETWORK 2: Duplicate" + netbox.netbox.netbox_provider_network: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + provider: Test Provider + name: Test Provider Network One + state: present + register: test_two + +- name: "NETBOX_PROVIDER_NETWORK 2: ASSERT - Create duplicate" + ansible.builtin.assert: + that: + - not test_two['changed'] + - test_two['provider_network']['name'] == "Test Provider Network One" + - test_two['msg'] == "provider_network Test Provider Network One already exists" + +- name: "NETBOX_PROVIDER_NETWORK 3: Update provider network with other fields" + netbox.netbox.netbox_provider_network: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + provider: Test Provider + name: Test Provider Network One + description: Describe a Provider Network + comments: A provider network + state: present + register: test_three + +- name: "NETBOX_PROVIDER_NETWORK 3: ASSERT - Updated" + ansible.builtin.assert: + that: + - test_three is changed + - test_three['diff']['after']['comments'] == "A provider network" + - test_three['diff']['after']['description'] == "Describe a Provider Network" + - test_three['provider_network']['name'] == "Test Provider Network One" + - test_three['provider_network']['comments'] == "A provider network" + - test_three['provider_network']['description'] == "Describe a Provider Network" + - test_three['msg'] == "provider_network Test Provider Network One updated" + +- name: "NETBOX_PROVIDER_NETWORK 4: Delete provider within netbox" + netbox.netbox.netbox_provider_network: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + provider: Test Provider + name: Test Provider Network One + state: absent + register: test_four + +- name: "NETBOX_PROVIDER_NETWORK 4 : ASSERT - Delete" + ansible.builtin.assert: + that: + - test_four is changed + - test_four['provider_network']['name'] == "Test Provider Network One" + - test_four['provider_network']['comments'] == "A provider network" + - test_four['provider_network']['description'] == "Describe a Provider Network" + - test_four['msg'] == "provider_network Test Provider Network One deleted" diff --git a/tests/integration/targets/v4.3/tasks/netbox_rack.yml b/tests/integration/targets/v4.3/tasks/netbox_rack.yml new file mode 100644 index 000000000..59d97fa52 --- /dev/null +++ b/tests/integration/targets/v4.3/tasks/netbox_rack.yml @@ -0,0 +1,226 @@ +--- +## +## +### NETBOX_RACK +## +## +- name: 1 - Test rack creation + netbox.netbox.netbox_rack: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test rack one + site: Test Site + location: Test Rack Group + register: test_one + +- name: 1 - ASSERT + ansible.builtin.assert: + that: + - test_one is changed + - test_one['diff']['before']['state'] == "absent" + - test_one['diff']['after']['state'] == "present" + - test_one['rack']['name'] == "Test rack one" + - test_one['rack']['site'] == 1 + +- name: Test duplicate rack + netbox.netbox.netbox_rack: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test rack one + register: test_two + +- name: 2 - ASSERT + ansible.builtin.assert: + that: + - not test_two['changed'] + - test_two['rack']['name'] == "Test rack one" + - test_two['rack']['site'] == 1 + - test_two['msg'] == "rack Test rack one already exists" + +- name: 3 - Create new rack with similar name + netbox.netbox.netbox_rack: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test rack - Test Site + site: Test Site + state: present + register: test_three + +- name: 3 - ASSERT + ansible.builtin.assert: + that: + - test_three is changed + - test_three['diff']['before']['state'] == "absent" + - test_three['diff']['after']['state'] == "present" + - test_three['rack']['name'] == "Test rack - Test Site" + - test_three['rack']['site'] == 1 + - test_three['msg'] == "rack Test rack - Test Site created" + +- name: 4 - Attempt to create Test rack one again + netbox.netbox.netbox_rack: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test rack one + site: Test Site + location: Test Rack Group + state: present + register: test_four + +- name: 4 - ASSERT + ansible.builtin.assert: + that: + - not test_four['changed'] + - test_four['rack']['name'] == "Test rack one" + - test_four['rack']['site'] == 1 + - test_four['msg'] == "rack Test rack one already exists" + +- name: 5 - Update Test rack one with more options + netbox.netbox.netbox_rack: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test rack one + site: Test Site + rack_role: Test Rack Role + location: Test Rack Group + facility_id: EQUI10291 + tenant: Test Tenant + status: Available + serial: FXS10001 + asset_tag: "1234" + width: 23 + u_height: 48 + type: 2-post frame + outer_width: 32 + outer_depth: 24 + outer_unit: Inches + comments: Just testing rack module + tags: + - Schnozzberry + state: present + register: test_five + +- name: 5 - ASSERT + ansible.builtin.assert: + that: + - test_five is changed + - test_five['diff']['after']['asset_tag'] == "1234" + - test_five['diff']['after']['comments'] == "Just testing rack module" + - test_five['diff']['after']['facility_id'] == "EQUI10291" + - test_five['diff']['after']['outer_depth'] == 24 + - test_five['diff']['after']['outer_unit'] == "in" + - test_five['diff']['after']['outer_width'] == 32 + - test_five['diff']['after']['role'] == 1 + - test_five['diff']['after']['serial'] == "FXS10001" + - test_five['diff']['after']['status'] == "available" + - test_five['diff']['after']['tenant'] == 1 + - test_five['diff']['after']['tags'][0] == 4 + - test_five['diff']['after']['form_factor'] == "2-post-frame" + - test_five['diff']['after']['u_height'] == 48 + - test_five['diff']['after']['width'] == 23 + - test_five['rack']['name'] == "Test rack one" + - test_five['rack']['site'] == 1 + - test_five['rack']['asset_tag'] == "1234" + - test_five['rack']['comments'] == "Just testing rack module" + - test_five['rack']['facility_id'] == "EQUI10291" + - test_five['rack']['location'] == 1 + - test_five['rack']['outer_depth'] == 24 + - test_five['rack']['outer_unit'] == "in" + - test_five['rack']['outer_width'] == 32 + - test_five['rack']['role'] == 1 + - test_five['rack']['serial'] == "FXS10001" + - test_five['rack']['status'] == "available" + - test_five['rack']['tenant'] == 1 + - test_five['rack']['tags'][0] == 4 + - test_five['rack']['form_factor'] == "2-post-frame" + - test_five['rack']['u_height'] == 48 + - test_five['rack']['width'] == 23 + - test_five['msg'] == "rack Test rack one updated" + +- name: 6 - Update Test rack one with same options + netbox.netbox.netbox_rack: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test rack one + site: Test Site + rack_role: Test Rack Role + location: Test Rack Group + facility_id: EQUI10291 + tenant: Test Tenant + status: Available + serial: FXS10001 + asset_tag: "1234" + width: 23 + u_height: 48 + type: 2-post frame + outer_width: 32 + outer_depth: 24 + outer_unit: Inches + comments: Just testing rack module + tags: + - Schnozzberry + state: present + register: test_six + +- name: 6 - ASSERT + ansible.builtin.assert: + that: + - test_six is not changed + - test_six['rack']['name'] == "Test rack one" + - test_six['rack']['site'] == 1 + - test_six['rack']['asset_tag'] == "1234" + - test_six['rack']['comments'] == "Just testing rack module" + - test_six['rack']['facility_id'] == "EQUI10291" + - test_six['rack']['location'] == 1 + - test_six['rack']['outer_depth'] == 24 + - test_six['rack']['outer_unit'] == "in" + - test_six['rack']['outer_width'] == 32 + - test_six['rack']['role'] == 1 + - test_six['rack']['serial'] == "FXS10001" + - test_six['rack']['status'] == "available" + - test_six['rack']['tenant'] == 1 + - test_six['rack']['tags'][0] == 4 + - test_six['rack']['form_factor'] == "2-post-frame" + - test_six['rack']['u_height'] == 48 + - test_six['rack']['width'] == 23 + +- name: 7 - Create rack with same asset tag and serial number + netbox.netbox.netbox_rack: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test rack two + site: Test Site + serial: FXS10001 + asset_tag: "1234" + state: present + ignore_errors: true + register: test_seven + +- name: 7 - ASSERT + ansible.builtin.assert: + that: + - test_seven is failed + - "'asset tag already exists' in test_seven['msg']" + +- name: 8 - Test delete + netbox.netbox.netbox_rack: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test rack one + state: absent + register: test_eight + +- name: 8 - ASSERT + ansible.builtin.assert: + that: + - test_eight is changed + - test_eight['diff']['before']['state'] == "present" + - test_eight['diff']['after']['state'] == "absent" + - test_eight['msg'] == "rack Test rack one deleted" diff --git a/tests/integration/targets/v4.3/tasks/netbox_rack_group.yml b/tests/integration/targets/v4.3/tasks/netbox_rack_group.yml new file mode 100644 index 000000000..40dba8408 --- /dev/null +++ b/tests/integration/targets/v4.3/tasks/netbox_rack_group.yml @@ -0,0 +1,62 @@ +--- +## +## +### NETBOX_RACK_GROUP +## +## +- name: "RACK_GROUP 1: Necessary info creation" + netbox.netbox.netbox_rack_group: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Rack Group + site: Test Site + state: present + register: test_one + +- name: "RACK_GROUP 1: ASSERT - Necessary info creation" + ansible.builtin.assert: + that: + - test_one is changed + - test_one['diff']['before']['state'] == "absent" + - test_one['diff']['after']['state'] == "present" + - test_one['rack_group']['name'] == "Rack Group" + - test_one['rack_group']['slug'] == "rack-group" + - test_one['rack_group']['site'] == 1 + - test_one['msg'] == "rack_group Rack Group created" + +- name: "RACK_GROUP 2: Create duplicate" + netbox.netbox.netbox_rack_group: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Rack Group + site: Test Site + state: present + register: test_two + +- name: "RACK_GROUP 2: ASSERT - Create duplicate" + ansible.builtin.assert: + that: + - not test_two['changed'] + - test_two['rack_group']['name'] == "Rack Group" + - test_two['rack_group']['slug'] == "rack-group" + - test_two['rack_group']['site'] == 1 + - test_two['msg'] == "rack_group Rack Group already exists" + +- name: "RACK_GROUP 3: ASSERT - Delete" + netbox.netbox.netbox_rack_group: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Rack Group + state: absent + register: test_three + +- name: "RACK_GROUP 3: ASSERT - Update" + ansible.builtin.assert: + that: + - test_three is changed + - test_three['diff']['before']['state'] == "present" + - test_three['diff']['after']['state'] == "absent" + - test_three['msg'] == "rack_group Rack Group deleted" diff --git a/tests/integration/targets/v4.3/tasks/netbox_rack_role.yml b/tests/integration/targets/v4.3/tasks/netbox_rack_role.yml new file mode 100644 index 000000000..ff0d6b4da --- /dev/null +++ b/tests/integration/targets/v4.3/tasks/netbox_rack_role.yml @@ -0,0 +1,81 @@ +--- +## +## +### NETBOX_RACK_ROLE +## +## +- name: "RACK_ROLE 1: Necessary info creation" + netbox.netbox.netbox_rack_role: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Rack Role + color: ffffff + state: present + register: test_one + +- name: "RACK_ROLE 1: ASSERT - Necessary info creation" + ansible.builtin.assert: + that: + - test_one is changed + - test_one['diff']['before']['state'] == "absent" + - test_one['diff']['after']['state'] == "present" + - test_one['rack_role']['name'] == "Rack Role" + - test_one['rack_role']['slug'] == "rack-role" + - test_one['rack_role']['color'] == "ffffff" + - test_one['msg'] == "rack_role Rack Role created" + +- name: "RACK_ROLE 2: Create duplicate" + netbox.netbox.netbox_rack_role: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Rack Role + state: present + register: test_two + +- name: "RACK_ROLE 1: ASSERT - Create duplicate" + ansible.builtin.assert: + that: + - not test_two['changed'] + - test_two['rack_role']['name'] == "Rack Role" + - test_two['rack_role']['slug'] == "rack-role" + - test_two['rack_role']['color'] == "ffffff" + - test_two['msg'] == "rack_role Rack Role already exists" + +- name: "RACK_ROLE 3: Update" + netbox.netbox.netbox_rack_role: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Rack Role + color: "003EFF" + state: present + register: test_three + +- name: "RACK_ROLE 3: ASSERT - Update" + ansible.builtin.assert: + that: + - test_three is changed + - test_three['diff']['after']['color'] == "003eff" + - test_three['rack_role']['name'] == "Rack Role" + - test_three['rack_role']['slug'] == "rack-role" + - test_three['rack_role']['color'] == "003eff" + - test_three['msg'] == "rack_role Rack Role updated" + +- name: "RACK_ROLE 4: Delete" + netbox.netbox.netbox_rack_role: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Rack Role + state: absent + register: test_four + +- name: "RACK_ROLE 4: ASSERT - Update" + ansible.builtin.assert: + that: + - test_four is changed + - test_four['diff']['before']['state'] == "present" + - test_four['diff']['after']['state'] == "absent" + - test_four['msg'] == "rack_role Rack Role deleted" diff --git a/tests/integration/targets/v4.3/tasks/netbox_rear_port.yml b/tests/integration/targets/v4.3/tasks/netbox_rear_port.yml new file mode 100644 index 000000000..d186233be --- /dev/null +++ b/tests/integration/targets/v4.3/tasks/netbox_rear_port.yml @@ -0,0 +1,139 @@ +--- +# © 2020 Nokia +# Licensed under the GNU General Public License v3.0 only +# SPDX-License-Identifier: GPL-3.0-only +## +## +### NETBOX_REAR_PORT +## +## +- name: "REAR_PORT 1: Necessary info creation" + netbox.netbox.netbox_rear_port: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Rear Port + device: test100 + type: bnc + state: present + register: test_one + +- name: "REAR_PORT 1: ASSERT - Necessary info creation" + ansible.builtin.assert: + that: + - test_one is changed + - test_one['diff']['before']['state'] == "absent" + - test_one['diff']['after']['state'] == "present" + - test_one['rear_port']['name'] == "Rear Port" + - test_one['rear_port']['device'] == 1 + - test_one['rear_port']['type'] == "bnc" + - test_one['msg'] == "rear_port Rear Port created" + +- name: "REAR_PORT 2: Create duplicate" + netbox.netbox.netbox_rear_port: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Rear Port + device: test100 + type: bnc + state: present + register: test_two + +- name: "REAR_PORT 2: ASSERT - Create duplicate" + ansible.builtin.assert: + that: + - not test_two['changed'] + - test_two['rear_port']['name'] == "Rear Port" + - test_two['rear_port']['device'] == 1 + - test_two['rear_port']['type'] == "bnc" + - test_two['msg'] == "rear_port Rear Port already exists" + +- name: "REAR_PORT 3: Update Rear Port with other fields" + netbox.netbox.netbox_rear_port: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Rear Port + device: test100 + type: bnc + positions: 5 + description: test description + state: present + register: test_three + +- name: "REAR_PORT 3: ASSERT - Update Rear Port with other fields" + ansible.builtin.assert: + that: + - test_three is changed + - test_three['diff']['after']['positions'] == 5 + - test_three['diff']['after']['description'] == "test description" + - test_three['rear_port']['name'] == "Rear Port" + - test_three['rear_port']['device'] == 1 + - test_three['rear_port']['type'] == "bnc" + - test_three['rear_port']['positions'] == 5 + - test_three['rear_port']['description'] == "test description" + - test_three['msg'] == "rear_port Rear Port updated" + +- name: "REAR_PORT 4: Create Rear Port for Delete Test" + netbox.netbox.netbox_rear_port: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Rear Port 2 + device: test100 + type: bnc + state: present + register: test_four + +- name: "REAR_PORT 4: ASSERT - Create Rear Port for Delete Test" + ansible.builtin.assert: + that: + - test_four is changed + - test_four['diff']['before']['state'] == "absent" + - test_four['diff']['after']['state'] == "present" + - test_four['rear_port']['name'] == "Rear Port 2" + - test_four['rear_port']['device'] == 1 + - test_four['rear_port']['type'] == "bnc" + - test_four['msg'] == "rear_port Rear Port 2 created" + +- name: "REAR_PORT 5: Delete Rear Port" + netbox.netbox.netbox_rear_port: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Rear Port 2 + device: test100 + type: bnc + state: absent + register: test_five + +- name: "REAR_PORT 5: ASSERT - Delete Rear Port" + ansible.builtin.assert: + that: + - test_five is changed + - test_five['diff']['before']['state'] == "present" + - test_five['diff']['after']['state'] == "absent" + - test_five['msg'] == "rear_port Rear Port 2 deleted" + +- name: "REAR_PORT 6: Create second Rear Port" + netbox.netbox.netbox_rear_port: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Rear Port + device: Test Nexus One + type: bnc + state: present + register: test_six + +- name: "REAR_PORT 6: ASSERT - Create second Rear Port" + ansible.builtin.assert: + that: + - test_six is changed + - test_six['diff']['before']['state'] == "absent" + - test_six['diff']['after']['state'] == "present" + - test_six['rear_port']['name'] == "Rear Port" + - test_six['rear_port']['device'] == 4 + - test_six['rear_port']['type'] == "bnc" + - test_six['msg'] == "rear_port Rear Port created" diff --git a/tests/integration/targets/v4.3/tasks/netbox_rear_port_template.yml b/tests/integration/targets/v4.3/tasks/netbox_rear_port_template.yml new file mode 100644 index 000000000..5342627d0 --- /dev/null +++ b/tests/integration/targets/v4.3/tasks/netbox_rear_port_template.yml @@ -0,0 +1,136 @@ +--- +# © 2020 Nokia +# Licensed under the GNU General Public License v3.0 only +# SPDX-License-Identifier: GPL-3.0-only +## +## +### NETBOX_REAR_PORT_TEMPLATE +## +## +- name: "REAR_PORT_TEMPLATE 1: Necessary info creation" + netbox.netbox.netbox_rear_port_template: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Rear Port Template + device_type: Cisco Test + type: bnc + state: present + register: test_one + +- name: "REAR_PORT_TEMPLATE 1: ASSERT - Necessary info creation" + ansible.builtin.assert: + that: + - test_one is changed + - test_one['diff']['before']['state'] == "absent" + - test_one['diff']['after']['state'] == "present" + - test_one['rear_port_template']['name'] == "Rear Port Template" + - test_one['rear_port_template']['device_type'] == 1 + - test_one['rear_port_template']['type'] == "bnc" + - test_one['msg'] == "rear_port_template Rear Port Template created" + +- name: "REAR_PORT_TEMPLATE 2: Create duplicate" + netbox.netbox.netbox_rear_port_template: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Rear Port Template + device_type: Cisco Test + type: bnc + state: present + register: test_two + +- name: "REAR_PORT_TEMPLATE 2: ASSERT - Create duplicate" + ansible.builtin.assert: + that: + - not test_two['changed'] + - test_two['rear_port_template']['name'] == "Rear Port Template" + - test_two['rear_port_template']['device_type'] == 1 + - test_two['rear_port_template']['type'] == "bnc" + - test_two['msg'] == "rear_port_template Rear Port Template already exists" + +- name: "REAR_PORT_TEMPLATE 3: Update Rear Port Template with other fields" + netbox.netbox.netbox_rear_port_template: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Rear Port Template + device_type: Cisco Test + type: bnc + positions: 5 + state: present + register: test_three + +- name: "REAR_PORT_TEMPLATE 3: ASSERT - Update Rear Port Template with other fields" + ansible.builtin.assert: + that: + - test_three is changed + - test_three['diff']['after']['positions'] == 5 + - test_three['rear_port_template']['name'] == "Rear Port Template" + - test_three['rear_port_template']['device_type'] == 1 + - test_three['rear_port_template']['type'] == "bnc" + - test_three['rear_port_template']['positions'] == 5 + - test_three['msg'] == "rear_port_template Rear Port Template updated" + +- name: "REAR_PORT_TEMPLATE 4: Create Rear Port Template for Delete Test" + netbox.netbox.netbox_rear_port_template: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Rear Port Template 2 + device_type: Cisco Test + type: bnc + state: present + register: test_four + +- name: "REAR_PORT_TEMPLATE 4: ASSERT - Create Rear Port Template for Delete Test" + ansible.builtin.assert: + that: + - test_four is changed + - test_four['diff']['before']['state'] == "absent" + - test_four['diff']['after']['state'] == "present" + - test_four['rear_port_template']['name'] == "Rear Port Template 2" + - test_four['rear_port_template']['device_type'] == 1 + - test_four['rear_port_template']['type'] == "bnc" + - test_four['msg'] == "rear_port_template Rear Port Template 2 created" + +- name: "REAR_PORT_TEMPLATE 5: Delete Rear Port Template" + netbox.netbox.netbox_rear_port_template: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Rear Port Template 2 + device_type: Cisco Test + type: bnc + state: absent + register: test_five + +- name: "REAR_PORT_TEMPLATE 5: ASSERT - Delete Rear Port Template" + ansible.builtin.assert: + that: + - test_five is changed + - test_five['diff']['before']['state'] == "present" + - test_five['diff']['after']['state'] == "absent" + - test_five['msg'] == "rear_port_template Rear Port Template 2 deleted" + +- name: "REAR_PORT_TEMPLATE 6: Create second Rear Port Template" + netbox.netbox.netbox_rear_port_template: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Rear Port Template 2 + device_type: Arista Test + type: bnc + state: present + register: test_six + +- name: "REAR_PORT_TEMPLATE 6: ASSERT - Create second Rear Port Template" + ansible.builtin.assert: + that: + - test_six is changed + - test_six['diff']['before']['state'] == "absent" + - test_six['diff']['after']['state'] == "present" + - test_six['rear_port_template']['name'] == "Rear Port Template 2" + - test_six['rear_port_template']['device_type'] == 2 + - test_six['rear_port_template']['type'] == "bnc" + - test_six['msg'] == "rear_port_template Rear Port Template 2 created" diff --git a/tests/integration/targets/v4.3/tasks/netbox_region.yml b/tests/integration/targets/v4.3/tasks/netbox_region.yml new file mode 100644 index 000000000..0395db435 --- /dev/null +++ b/tests/integration/targets/v4.3/tasks/netbox_region.yml @@ -0,0 +1,79 @@ +--- +## +## +### NETBOX_REGION +## +## +- name: "REGION 1: Necessary info creation" + netbox.netbox.netbox_region: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test Region One + state: present + register: test_one + +- name: "REGION 1: ASSERT - Necessary info creation" + ansible.builtin.assert: + that: + - test_one is changed + - test_one['diff']['before']['state'] == "absent" + - test_one['diff']['after']['state'] == "present" + - test_one['region']['name'] == "Test Region One" + - test_one['region']['slug'] == "test-region-one" + - test_one['msg'] == "region Test Region One created" + +- name: "REGION 2: Create duplicate" + netbox.netbox.netbox_region: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test Region One + state: present + register: test_two + +- name: "REGION 2: ASSERT - Create duplicate" + ansible.builtin.assert: + that: + - not test_two['changed'] + - test_two['region']['name'] == "Test Region One" + - test_two['region']['slug'] == "test-region-one" + - test_two['msg'] == "region Test Region One already exists" + +- name: "REGION 3: ASSERT - Update" + netbox.netbox.netbox_region: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test Region One + parent_region: Test Region + state: present + register: test_three + +- name: "REGION 3: ASSERT - Updated" + ansible.builtin.assert: + that: + - test_three is changed + - test_three['diff']['after']['parent'] == 1 + - test_three['region']['name'] == "Test Region One" + - test_three['region']['slug'] == "test-region-one" + - test_three['region']['parent'] == 1 + - test_three['msg'] == "region Test Region One updated" + +- name: "REGION 4: ASSERT - Delete" + netbox.netbox.netbox_region: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test Region One + state: absent + register: test_four + +- name: "REGION 4: ASSERT - Delete" + ansible.builtin.assert: + that: + - test_four is changed + - test_four['region']['name'] == "Test Region One" + - test_four['region']['slug'] == "test-region-one" + - test_four['region']['parent'] == 1 + - test_four['msg'] == "region Test Region One deleted" diff --git a/tests/integration/targets/v4.3/tasks/netbox_rir.yml b/tests/integration/targets/v4.3/tasks/netbox_rir.yml new file mode 100644 index 000000000..3a7bf79fa --- /dev/null +++ b/tests/integration/targets/v4.3/tasks/netbox_rir.yml @@ -0,0 +1,79 @@ +--- +## +## +### NETBOX_RIR +## +## +- name: "RIR 1: Necessary info creation" + netbox.netbox.netbox_rir: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test RIR One + state: present + register: test_one + +- name: "RIR 1: ASSERT - Necessary info creation" + ansible.builtin.assert: + that: + - test_one is changed + - test_one['diff']['before']['state'] == "absent" + - test_one['diff']['after']['state'] == "present" + - test_one['rir']['name'] == "Test RIR One" + - test_one['rir']['slug'] == "test-rir-one" + - test_one['msg'] == "rir Test RIR One created" + +- name: "RIR 2: Create duplicate" + netbox.netbox.netbox_rir: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test RIR One + state: present + register: test_two + +- name: "RIR 2: ASSERT - Create duplicate" + ansible.builtin.assert: + that: + - not test_two['changed'] + - test_two['rir']['name'] == "Test RIR One" + - test_two['rir']['slug'] == "test-rir-one" + - test_two['msg'] == "rir Test RIR One already exists" + +- name: "RIR 3: ASSERT - Update" + netbox.netbox.netbox_rir: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test RIR One + is_private: true + state: present + register: test_three + +- name: "RIR 3: ASSERT - Updated" + ansible.builtin.assert: + that: + - test_three is changed + - test_three['diff']['after']['is_private'] == true + - test_three['rir']['name'] == "Test RIR One" + - test_three['rir']['slug'] == "test-rir-one" + - test_three['rir']['is_private'] == true + - test_three['msg'] == "rir Test RIR One updated" + +- name: "RIR 4: ASSERT - Delete" + netbox.netbox.netbox_rir: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test RIR One + state: absent + register: test_four + +- name: "RIR 4: ASSERT - Delete" + ansible.builtin.assert: + that: + - test_four is changed + - test_four['rir']['name'] == "Test RIR One" + - test_four['rir']['slug'] == "test-rir-one" + - test_four['rir']['is_private'] == true + - test_four['msg'] == "rir Test RIR One deleted" diff --git a/tests/integration/targets/v4.3/tasks/netbox_route_target.yml b/tests/integration/targets/v4.3/tasks/netbox_route_target.yml new file mode 100644 index 000000000..c2576c4cc --- /dev/null +++ b/tests/integration/targets/v4.3/tasks/netbox_route_target.yml @@ -0,0 +1,204 @@ +--- +# +# ADD (CHECK MODE) +- name: "NETBOX_ROUTE_TARGET_ADD: Check Mode - Add all fields except description" + netbox.netbox.netbox_route_target: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: 65000:65001 + tenant: Test Tenant + tags: + - first + - second + check_mode: true + register: test_results + +- name: "NETBOX_ROUTE_TARGET_ADD: (ASSERT) Check Mode - Add all fields except description" + ansible.builtin.assert: + that: + - test_results is changed + - test_results['route_target']['name'] == "65000:65001" + - test_results['route_target']['tenant'] == 1 + - test_results['route_target']['tags'] | length == 2 + - test_results['diff']['after']['state'] == "present" + - test_results['diff']['before']['state'] == "absent" + - test_results['msg'] == "route_target 65000:65001 created" + +# ADD +- name: "NETBOX_ROUTE_TARGET_ADD: Add all fields except description" + netbox.netbox.netbox_route_target: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: 65000:65001 + tenant: Test Tenant + tags: + - first + - second + register: test_results + +- name: "NETBOX_ROUTE_TARGET_ADD: (ASSERT) Add all fields except description" + ansible.builtin.assert: + that: + - test_results is changed + - test_results['route_target']['name'] == "65000:65001" + - test_results['route_target']['tenant'] == 1 + - test_results['route_target']['tags'] | length == 2 + - test_results['diff']['after']['state'] == "present" + - test_results['diff']['before']['state'] == "absent" + - test_results['msg'] == "route_target 65000:65001 created" + +# ADD (IDEMPOTENT) +- name: "NETBOX_ROUTE_TARGET_ADD_IDEM: (IDEMPOTENT) Add all fields except description" + netbox.netbox.netbox_route_target: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: 65000:65001 + tenant: Test Tenant + tags: + - first + - second + register: test_results + +- name: "NETBOX_ROUTE_TARGET_ADD_IDEM: (IDEMPOTENT) Add all fields except description" + ansible.builtin.assert: + that: + - test_results is not changed + - test_results['route_target']['name'] == "65000:65001" + - test_results['route_target']['tenant'] == 1 + - test_results['route_target']['tags'] | length == 2 + - test_results['msg'] == "route_target 65000:65001 already exists" + +# +# UPDATE (CHECK MODE) +- name: "NETBOX_ROUTE_TARGET_UPDATE: Check Mode - Update description" + netbox.netbox.netbox_route_target: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: 65000:65001 + description: NEW DESCRIPTION + tenant: Test Tenant + tags: + - first + - second + check_mode: true + register: test_results + +- name: "NETBOX_ROUTE_TARGET_UPDATE: (ASSERT) Check Mode - Update description" + ansible.builtin.assert: + that: + - test_results is changed + - test_results['route_target']['name'] == "65000:65001" + - test_results['route_target']['tenant'] == 1 + - test_results['route_target']['tags'] | length == 2 + - test_results['route_target']['description'] == "NEW DESCRIPTION" + - test_results['diff']['after']['description'] == "NEW DESCRIPTION" + - test_results['diff']['before']['description'] == "" + - test_results['msg'] == "route_target 65000:65001 updated" + +# UPDATE +- name: "NETBOX_ROUTE_TARGET_UPDATE: Update description" + netbox.netbox.netbox_route_target: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: 65000:65001 + tenant: Test Tenant + description: NEW DESCRIPTION + tags: + - first + - second + register: test_results + +- name: "NETBOX_ROUTE_TARGET_UPDATE: (ASSERT) Update description" + ansible.builtin.assert: + that: + - test_results is changed + - test_results['route_target']['name'] == "65000:65001" + - test_results['route_target']['tenant'] == 1 + - test_results['route_target']['tags'] | length == 2 + - test_results['route_target']['description'] == "NEW DESCRIPTION" + - test_results['diff']['after']['description'] == "NEW DESCRIPTION" + - test_results['diff']['before']['description'] == "" + - test_results['msg'] == "route_target 65000:65001 updated" + +# UPDATE (IDEMPOTENT) +- name: "NETBOX_ROUTE_TARGET_UPDATE_IDEM: (IDEMPOTENT) Update description" + netbox.netbox.netbox_route_target: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: 65000:65001 + tenant: Test Tenant + description: NEW DESCRIPTION + tags: + - first + - second + register: test_results + +- name: "NETBOX_ROUTE_TARGET_UPDATE_IDEM: (IDEMPOTENT) Update description" + ansible.builtin.assert: + that: + - test_results is not changed + - test_results['route_target']['name'] == "65000:65001" + - test_results['route_target']['tenant'] == 1 + - test_results['route_target']['tags'] | length == 2 + - test_results['route_target']['description'] == "NEW DESCRIPTION" + - test_results['msg'] == "route_target 65000:65001 already exists" + +# +# DELETE (CHECK MODE) +- name: "NETBOX_ROUTE_TARGET_DELETE: Check Mode - Delete route target" + netbox.netbox.netbox_route_target: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: 65000:65001 + state: absent + check_mode: true + register: test_results + +- name: "NETBOX_ROUTE_TARGET_DELETE: (ASSERT) Check Mode - Delete route target" + ansible.builtin.assert: + that: + - test_results is changed + - test_results['diff']['after']['state'] == "absent" + - test_results['diff']['before']['state'] == "present" + - test_results['msg'] == "route_target 65000:65001 deleted" + +# DELETE +- name: "NETBOX_ROUTE_TARGET_DELETE: Delete route target" + netbox.netbox.netbox_route_target: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: 65000:65001 + state: absent + register: test_results + +- name: "NETBOX_ROUTE_TARGET_DELETE: (ASSERT) Delete route target" + ansible.builtin.assert: + that: + - test_results is changed + - test_results['diff']['after']['state'] == "absent" + - test_results['diff']['before']['state'] == "present" + - test_results['msg'] == "route_target 65000:65001 deleted" + +# DELETE (IDEMPOTENT) +- name: "NETBOX_ROUTE_TARGET_DELETE_IDEM: (IDEMPOTENT) Delete route target" + netbox.netbox.netbox_route_target: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: 65000:65001 + state: absent + register: test_results + +- name: "NETBOX_ROUTE_TARGET_DELETE_IDEM: (IDEMPOTENT) Delete route target" + ansible.builtin.assert: + that: + - test_results is not changed + - test_results['msg'] == "route_target 65000:65001 already absent" diff --git a/tests/integration/targets/v4.3/tasks/netbox_service.yml b/tests/integration/targets/v4.3/tasks/netbox_service.yml new file mode 100644 index 000000000..fb6ab5fb7 --- /dev/null +++ b/tests/integration/targets/v4.3/tasks/netbox_service.yml @@ -0,0 +1,196 @@ +--- +## +## +### NETBOX_SERVICE +## +## +- name: 1 - Device with required information needs to add new service + netbox.netbox.netbox_device: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: FOR_SERVICE + device_type: Cisco Test + device_role: Core Switch + site: Test Site + status: Staged + state: present + +- name: "NETBOX_SERVICE: Create new service" + netbox.netbox.netbox_service: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + device: FOR_SERVICE + name: node-exporter + port: 9100 + protocol: TCP + state: present + register: test_service_create + +- name: NETBOX_SERVICE ASSERT - Create + ansible.builtin.assert: + that: + - test_service_create is changed + - test_service_create['services']['name'] == "node-exporter" + - test_service_create['services']['ports'] == [9100] + - test_service_create['services']['protocol'] == "tcp" + - test_service_create['diff']['after']['state'] == "present" + - test_service_create['diff']['before']['state'] == "absent" + - test_service_create['msg'] == "services node-exporter created" + +- name: "NETBOX_SERVICE: Test idempotence" + netbox.netbox.netbox_service: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + device: FOR_SERVICE + name: node-exporter + port: 9100 + protocol: TCP + state: present + register: test_service_idempotence + +- name: NETBOX_SERVICE ASSERT - Not changed + ansible.builtin.assert: + that: + - test_service_idempotence['services']['name'] == "node-exporter" + - test_service_idempotence['services']['ports'] == [9100] + - test_service_idempotence['services']['protocol'] == "tcp" + - test_service_idempotence['msg'] == "services node-exporter already exists" + +- name: "NETBOX_SERVICE: Test update" + netbox.netbox.netbox_service: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + device: FOR_SERVICE + name: node-exporter + ports: + - 9100 + - 9200 + protocol: TCP + tags: + - Schnozzberry + state: present + register: test_service_update + +- name: NETBOX_SERVICE ASSERT - Service has been updated + ansible.builtin.assert: + that: + - test_service_update is changed + - test_service_update['diff']['after']['tags'][0] == 4 + - test_service_update['diff']['after']['ports'] == [9100, 9200] + - test_service_update['msg'] == "services node-exporter updated" + +- name: "NETBOX_SERVICE: Test same details, but different protocol - Create" + netbox.netbox.netbox_service: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + device: FOR_SERVICE + name: node-exporter + port: 9100 + protocol: UDP + state: present + register: test_service_protocol + +- name: NETBOX_SERVICE ASSERT - Different protocol - Create + ansible.builtin.assert: + that: + - test_service_protocol is changed + - test_service_protocol['diff']['after']['state'] == "present" + - test_service_protocol['diff']['before']['state'] == "absent" + - test_service_protocol['services']['name'] == "node-exporter" + - test_service_protocol['services']['ports'] == [9100] + - test_service_protocol['services']['protocol'] == "udp" + - test_service_protocol['msg'] == "services node-exporter created" + +- name: "NETBOX_SERVICE: Test service deletion" + netbox.netbox.netbox_service: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + device: FOR_SERVICE + name: node-exporter + port: 9100 + protocol: UDP + state: absent + register: test_service_delete + +- name: NETBOX_SERVICE ASSERT - Service has been deleted + ansible.builtin.assert: + that: + - test_service_delete is changed + - test_service_delete['diff']['after']['state'] == "absent" + - test_service_delete['diff']['before']['state'] == "present" + - test_service_delete['msg'] == "services node-exporter deleted" + +- name: "NETBOX_SERVICE: Test service IP addresses" + netbox.netbox.netbox_service: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + device: test100 + name: node-exporter + port: 9100 + protocol: UDP + ipaddresses: + - address: 172.16.180.1/24 + state: present + register: test_service_ip_addresses + +- name: NETBOX_SERVICE ASSERT - Service has been created with IP address + ansible.builtin.assert: + that: + - test_service_ip_addresses is changed + - test_service_ip_addresses['diff']['after']['state'] == "present" + - test_service_ip_addresses['diff']['before']['state'] == "absent" + - test_service_ip_addresses['services']['name'] == "node-exporter" + - test_service_ip_addresses['services']['ports'] == [9100] + - test_service_ip_addresses['services']['protocol'] == "udp" + - test_service_ip_addresses['services']['ipaddresses'] is defined + - test_service_ip_addresses['msg'] == "services node-exporter created" + +- name: "NETBOX_SERVICE: Missing both device & virtual_machine options - Tests required_one_of" + netbox.netbox.netbox_service: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: node-exporter + port: 9100 + protocol: UDP + ipaddresses: + - address: 172.16.180.1/24 + state: present + ignore_errors: true + register: test_service_required_one_of + +- name: NETBOX_SERVICE ASSERT - Failed due to missing arguments + ansible.builtin.assert: + that: + - test_service_required_one_of is failed + - 'test_service_required_one_of["msg"] == "one of the following is required: device, virtual_machine"' + +- name: "NETBOX_SERVICE: Create new service on virtual_machine" + netbox.netbox.netbox_service: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + virtual_machine: test100-vm + name: node-exporter-vm + port: 9100 + protocol: TCP + state: present + register: test_service_create_vm + +- name: NETBOX_SERVICE ASSERT - Create + ansible.builtin.assert: + that: + - test_service_create_vm is changed + - test_service_create_vm['services']['name'] == "node-exporter-vm" + - test_service_create_vm['services']['ports'] == [9100] + - test_service_create_vm['services']['protocol'] == "tcp" + - test_service_create_vm['diff']['after']['state'] == "present" + - test_service_create_vm['diff']['before']['state'] == "absent" + - test_service_create_vm['msg'] == "services node-exporter-vm created" diff --git a/tests/integration/targets/v4.3/tasks/netbox_service_template.yml b/tests/integration/targets/v4.3/tasks/netbox_service_template.yml new file mode 100644 index 000000000..507a566a4 --- /dev/null +++ b/tests/integration/targets/v4.3/tasks/netbox_service_template.yml @@ -0,0 +1,115 @@ +--- +## +## +### NETBOX_SERVICE_TEMPLATE +## +## +- name: "SERVICE_TEMPLATE 1: Necessary info creation" + netbox.netbox.netbox_service_template: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Service Template for SSH + ports: + - 22 + protocol: tcp + state: present + register: test_one + +- name: "SERVICE_TEMPLATE 1: ASSERT - Necessary info creation" + ansible.builtin.assert: + that: + - test_one is changed + - test_one['diff']['before']['state'] == "absent" + - test_one['diff']['after']['state'] == "present" + - test_one['service_template']['name'] == "Service Template for SSH" + - test_one['service_template']['ports'] == [22] + - test_one['service_template']['protocol'] == "tcp" + - test_one['msg'] == "service_template Service Template for SSH created" + +- name: "SERVICE_TEMPLATE 2: Create duplicate" + netbox.netbox.netbox_service_template: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Service Template for SSH + ports: + - 22 + protocol: tcp + state: present + register: test_two + +- name: "SERVICE_TEMPLATE 2: ASSERT - Create duplicate" + ansible.builtin.assert: + that: + - not test_two['changed'] + - test_two['service_template']['name'] == "Service Template for SSH" + - test_two['service_template']['ports'] == [22] + - test_two['service_template']['protocol'] == "tcp" + - test_two['msg'] == "service_template Service Template for SSH already exists" + +- name: "SERVICE_TEMPLATE 3: Update Service Template with other fields" + netbox.netbox.netbox_service_template: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Service Template for SSH + ports: + - 22 + protocol: tcp + comments: For SSH service + state: present + register: test_three + +- name: "SERVICE_TEMPLATE 3: ASSERT - Update Service Template with other fields" + ansible.builtin.assert: + that: + - test_three is changed + - test_three['diff']['after']['comments'] == "For SSH service" + - test_three['service_template']['name'] == "Service Template for SSH" + - test_three['service_template']['ports'] == [22] + - test_three['service_template']['protocol'] == "tcp" + - test_three['service_template']['comments'] == "For SSH service" + - test_three['msg'] == "service_template Service Template for SSH updated" + +- name: "SERVICE_TEMPLATE 4: Create Service Template for Delete Test" + netbox.netbox.netbox_service_template: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Service Template for DNS + ports: + - 53 + protocol: udp + comments: Domain Name System + state: present + register: test_four + +- name: "SERVICE_TEMPLATE 4: ASSERT - Create Service Template for Delete Test" + ansible.builtin.assert: + that: + - test_four is changed + - test_four['diff']['before']['state'] == "absent" + - test_four['diff']['after']['state'] == "present" + - test_four['service_template']['name'] == "Service Template for DNS" + - test_four['service_template']['ports'] == [53] + - test_four['service_template']['protocol'] == "udp" + - test_four['service_template']['comments'] == "Domain Name System" + - test_four['msg'] == "service_template Service Template for DNS created" + +- name: "SERVICE_TEMPLATE 5: Delete Service Template" + netbox.netbox.netbox_service_template: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Service Template for DNS + state: absent + register: test_five + +- name: "SERVICE_TEMPLATE 5: ASSERT - Delete Service Template" + ansible.builtin.assert: + that: + - test_five is changed + - test_five['diff']['before']['state'] == "present" + - test_five['diff']['after']['state'] == "absent" + - test_five['msg'] == "service_template Service Template for DNS deleted" diff --git a/tests/integration/targets/v4.3/tasks/netbox_site.yml b/tests/integration/targets/v4.3/tasks/netbox_site.yml new file mode 100644 index 000000000..a5861522e --- /dev/null +++ b/tests/integration/targets/v4.3/tasks/netbox_site.yml @@ -0,0 +1,165 @@ +--- +## +## +### NETBOX_SITE +## +## +- name: 1 - Create site within NetBox with only required information + netbox.netbox.netbox_site: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test - Colorado + state: present + register: test_one + +- name: 1 - ASSERT + ansible.builtin.assert: + that: + - test_one is changed + - test_one['diff']['before']['state'] == "absent" + - test_one['diff']['after']['state'] == "present" + - test_one['site']['name'] == "Test - Colorado" + - test_one['msg'] == "site Test - Colorado created" + +- name: 2 - Duplicate + netbox.netbox.netbox_site: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test - Colorado + state: present + register: test_two + +- name: 2 - ASSERT + ansible.builtin.assert: + that: + - not test_two['changed'] + - test_two['msg'] == "site Test - Colorado already exists" + - test_two['site']['name'] == "Test - Colorado" + +- name: 3 - Update Test - Colorado + netbox.netbox.netbox_site: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test - Colorado + status: Planned + region: Test Region + state: present + register: test_three + +- name: 3 - ASSERT + ansible.builtin.assert: + that: + - test_three is changed + - test_three['diff']['after']['status'] == "planned" + - test_three['diff']['after']['region'] == 1 + - test_three['msg'] == "site Test - Colorado updated" + - test_three['site']['name'] == "Test - Colorado" + - test_three['site']['status'] == "planned" + - test_three['site']['region'] == 1 + +- name: 4 - Create site with all parameters + netbox.netbox.netbox_site: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test - California + status: Planned + region: Test Region + site_group: Test Site Group + tenant: Test Tenant + facility: EquinoxCA7 + time_zone: America/Los Angeles + description: This is a test description + physical_address: Hollywood, CA, 90210 + shipping_address: Hollywood, CA, 90210 + latitude: "22.169141" + longitude: "-100.994041" + comments: "### Placeholder" + slug: test_california + state: present + register: test_four + +- name: 4 - ASSERT + ansible.builtin.assert: + that: + - test_four is changed + - test_four['diff']['before']['state'] == "absent" + - test_four['diff']['after']['state'] == "present" + - test_four['site']['name'] == "Test - California" + - test_four['msg'] == "site Test - California created" + - test_four['site']['status'] == "planned" + - test_four['site']['region'] == 1 + - test_four['site']['group'] == 4 + - test_four['site']['tenant'] == 1 + - test_four['site']['facility'] == "EquinoxCA7" + - test_four['site']['time_zone'] == "America/Los_Angeles" + - test_four['site']['description'] == "This is a test description" + - test_four['site']['physical_address'] == "Hollywood, CA, 90210" + - test_four['site']['shipping_address'] == "Hollywood, CA, 90210" + - test_four['site']['latitude'] == 22.169141 + - test_four['site']['longitude'] == -100.994041 + - test_four['site']['comments'] == "### Placeholder" + - test_four['site']['slug'] == "test_california" + +- name: "NETBOX_SITE_IDEM: Idempotency - Create duplicate site with all parameters" + netbox.netbox.netbox_site: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test - California + status: Planned + region: Test Region + site_group: Test Site Group + tenant: Test Tenant + facility: EquinoxCA7 + time_zone: America/Los Angeles + description: This is a test description + physical_address: Hollywood, CA, 90210 + shipping_address: Hollywood, CA, 90210 + latitude: "22.169141" + longitude: "-100.994041" + comments: "### Placeholder" + slug: test_california + state: present + register: test_results + +- name: "NETBOX_SITE_IDEM: (ASSERT) Idempotency - Duplicate device site with all parameters" + ansible.builtin.assert: + that: + - test_results is not changed + - test_results['site']['name'] == "Test - California" + - test_results['msg'] == "site Test - California already exists" + - test_results['site']['status'] == "planned" + - test_results['site']['region'] == 1 + - test_results['site']['group'] == 4 + - test_results['site']['tenant'] == 1 + - test_results['site']['facility'] == "EquinoxCA7" + - test_results['site']['time_zone'] == "America/Los_Angeles" + - test_results['site']['description'] == "This is a test description" + - test_results['site']['physical_address'] == "Hollywood, CA, 90210" + - test_results['site']['shipping_address'] == "Hollywood, CA, 90210" + - test_results['site']['latitude'] == 22.169141 + - test_results['site']['longitude'] == -100.994041 + - test_results['site']['comments'] == "### Placeholder" + - test_results['site']['slug'] == "test_california" + +- name: 5 - Delete site within netbox + netbox.netbox.netbox_site: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test - Colorado + state: absent + register: test_five + +- name: 5 - ASSERT + ansible.builtin.assert: + that: + - test_five is changed + - test_five['diff']['before']['state'] == "present" + - test_five['diff']['after']['state'] == "absent" + - test_five['site']['name'] == "Test - Colorado" + - test_five['msg'] == "site Test - Colorado deleted" diff --git a/tests/integration/targets/v4.3/tasks/netbox_site_group.yml b/tests/integration/targets/v4.3/tasks/netbox_site_group.yml new file mode 100644 index 000000000..11b9cbb24 --- /dev/null +++ b/tests/integration/targets/v4.3/tasks/netbox_site_group.yml @@ -0,0 +1,81 @@ +--- +## +## +### NETBOX_SITE_GROUP +## +## +- name: "SITE_GROUP 1: Necessary info creation" + netbox.netbox.netbox_site_group: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Site Group + state: present + register: test_one + +- name: "SITE_GROUP 1: ASSERT - Necessary info creation" + ansible.builtin.assert: + that: + - test_one is changed + - test_one['diff']['before']['state'] == "absent" + - test_one['diff']['after']['state'] == "present" + - test_one['site_group']['name'] == "Site Group" + - test_one['site_group']['slug'] == "site-group" + - test_one['msg'] == "site_group Site Group created" + +- name: "SITE_GROUP 2: Create duplicate" + netbox.netbox.netbox_site_group: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Site Group + state: present + register: test_two + +- name: "SITE_GROUP 2: ASSERT - Create duplicate" + ansible.builtin.assert: + that: + - not test_two['changed'] + - test_two['site_group']['name'] == "Site Group" + - test_two['site_group']['slug'] == "site-group" + - test_two['msg'] == "site_group Site Group already exists" + +- name: "SITE_GROUP 3: Update" + netbox.netbox.netbox_site_group: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Site Group + parent_site_group: Test Site Group + description: This is a site group + state: present + register: test_three + +- name: "SITE_GROUP 3: ASSERT - Update" + ansible.builtin.assert: + that: + - test_three is changed + - test_three['diff']['after']['parent'] == 4 + - test_three['diff']['after']['description'] == "This is a site group" + - test_three['site_group']['name'] == "Site Group" + - test_three['site_group']['slug'] == "site-group" + - test_three['site_group']['parent'] == 4 + - test_three['site_group']['description'] == "This is a site group" + - test_three['msg'] == "site_group Site Group updated" + +- name: "SITE_GROUP 4: Delete" + netbox.netbox.netbox_site_group: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Site Group + state: absent + register: test_four + +- name: "SITE_GROUP 4: ASSERT - Delete" + ansible.builtin.assert: + that: + - test_four is changed + - test_four['diff']['before']['state'] == "present" + - test_four['diff']['after']['state'] == "absent" + - test_four['msg'] == "site_group Site Group deleted" diff --git a/tests/integration/targets/v4.3/tasks/netbox_tag.yml b/tests/integration/targets/v4.3/tasks/netbox_tag.yml new file mode 100644 index 000000000..f3fcbac39 --- /dev/null +++ b/tests/integration/targets/v4.3/tasks/netbox_tag.yml @@ -0,0 +1,110 @@ +--- +## +## +### NETBOX_TAGS +## +## +- name: "TAG 1: ASSERT - Necessary info creation" + netbox.netbox.netbox_tag: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test Tag 1 + description: Tag 1 test + color: "0000ff" + state: present + register: test_one + +- name: "TAG 1: ASSERT - Necessary info creation" + ansible.builtin.assert: + that: + - test_one is changed + - test_one['diff']['before']['state'] == "absent" + - test_one['diff']['after']['state'] == "present" + - test_one['tags']['color'] == "0000ff" + - test_one['tags']['description'] == "Tag 1 test" + - test_one['tags']['name'] == "Test Tag 1" + - test_one['tags']['slug'] == "test-tag-1" + - test_one['msg'] == "tags Test Tag 1 created" + +- name: "TAG 2: Create duplicate" + netbox.netbox.netbox_tag: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test Tag 1 + description: Tag 1 test + color: "0000ff" + state: present + register: test_two + +- name: "TAG 2: ASSERT - Create duplicate" + ansible.builtin.assert: + that: + - not test_two['changed'] + - test_two['tags']['name'] == "Test Tag 1" + - test_two['msg'] == "tags Test Tag 1 already exists" + +- name: "TAG 3: ASSERT - Update" + netbox.netbox.netbox_tag: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test Tag 1 + description: Tag 1 update test + color: "00ff00" + state: present + register: test_three + +- name: "TAG 3: ASSERT - Updated" + ansible.builtin.assert: + that: + - test_three is changed + - test_three['diff']['after']['color'] == "00ff00" + - test_three['diff']['after']['description'] == "Tag 1 update test" + - test_three['tags']['name'] == "Test Tag 1" + - test_three['tags']['description'] == "Tag 1 update test" + - test_three['tags']['color'] == "00ff00" + - test_three['msg'] == "tags Test Tag 1 updated" + +- name: "TAG 4: ASSERT - Delete" + netbox.netbox.netbox_tag: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test Tag 1 + state: absent + register: test_four + +- name: "TAG 4: ASSERT - Delete" + ansible.builtin.assert: + that: + - test_four is changed + - test_four['diff']['after']['state'] == "absent" + - test_four['tags']['name'] == "Test Tag 1" + - test_four['tags']['slug'] == "test-tag-1" + - test_four['msg'] == "tags Test Tag 1 deleted" + +- name: "TAG 5: ASSERT - Necessary info creation" + netbox.netbox.netbox_tag: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test Tag 5 + slug: test-tag-five + description: Tag 5 test + color: "0000ff" + state: present + register: test_five + +- name: "TAG 5: ASSERT - Necessary info creation" + ansible.builtin.assert: + that: + - test_five is changed + - test_five['diff']['before']['state'] == "absent" + - test_five['diff']['after']['state'] == "present" + - test_five['tags']['color'] == "0000ff" + - test_five['tags']['description'] == "Tag 5 test" + - test_five['tags']['name'] == "Test Tag 5" + - test_five['tags']['slug'] == "test-tag-five" + - test_five['msg'] == "tags Test Tag 5 created" diff --git a/tests/integration/targets/v4.3/tasks/netbox_tenant.yml b/tests/integration/targets/v4.3/tasks/netbox_tenant.yml new file mode 100644 index 000000000..0731e0268 --- /dev/null +++ b/tests/integration/targets/v4.3/tasks/netbox_tenant.yml @@ -0,0 +1,106 @@ +--- +## +## +### NETBOX_TENANT +## +## +- name: 1 - Test tenant creation + netbox.netbox.netbox_tenant: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Tenant ABC + register: test_one + +- name: 1 - ASSERT + ansible.builtin.assert: + that: + - test_one is changed + - test_one['diff']['before']['state'] == "absent" + - test_one['diff']['after']['state'] == "present" + - test_one['tenant']['name'] == "Tenant ABC" + - test_one['tenant']['slug'] == "tenant-abc" + - test_one['msg'] == "tenant Tenant ABC created" + +- name: Test duplicate tenant + netbox.netbox.netbox_tenant: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Tenant ABC + register: test_two + +- name: 2 - ASSERT + ansible.builtin.assert: + that: + - not test_two['changed'] + - test_two['tenant']['name'] == "Tenant ABC" + - test_two['tenant']['slug'] == "tenant-abc" + - test_two['msg'] == "tenant Tenant ABC already exists" + +- name: 3 - Test update + netbox.netbox.netbox_tenant: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Tenant ABC + description: Updated description + register: test_three + +- name: 3 - ASSERT + ansible.builtin.assert: + that: + - test_three is changed + - test_three['diff']['after']['description'] == "Updated description" + - test_three['tenant']['name'] == "Tenant ABC" + - test_three['tenant']['slug'] == "tenant-abc" + - test_three['tenant']['description'] == "Updated description" + - test_three['msg'] == "tenant Tenant ABC updated" + +- name: 4 - Test delete + netbox.netbox.netbox_tenant: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Tenant ABC + state: absent + register: test_four + +- name: 4 - ASSERT + ansible.builtin.assert: + that: + - test_four is changed + - test_four['diff']['before']['state'] == "present" + - test_four['diff']['after']['state'] == "absent" + - test_four['msg'] == "tenant Tenant ABC deleted" + +- name: 5 - Create tenant with all parameters + netbox.netbox.netbox_tenant: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Tenant ABC + description: ABC Incorporated + comments: "### This tenant is super cool" + tenant_group: Test Tenant Group + slug: tenant_abc + tags: + - tagA + - tagB + - tagC + state: present + register: test_five + +- name: 5 - ASSERT + ansible.builtin.assert: + that: + - test_five is changed + - test_five['diff']['before']['state'] == "absent" + - test_five['diff']['after']['state'] == "present" + - test_five['tenant']['name'] == "Tenant ABC" + - test_five['tenant']['slug'] == "tenant_abc" + - test_five['tenant']['description'] == "ABC Incorporated" + - test_five['tenant']['comments'] == "### This tenant is super cool" + - test_five['tenant']['group'] == 1 + - test_five['tenant']['tags'] | length == 3 + - test_five['msg'] == "tenant Tenant ABC created" diff --git a/tests/integration/targets/v4.3/tasks/netbox_tenant_group.yml b/tests/integration/targets/v4.3/tasks/netbox_tenant_group.yml new file mode 100644 index 000000000..f7f57f3c2 --- /dev/null +++ b/tests/integration/targets/v4.3/tasks/netbox_tenant_group.yml @@ -0,0 +1,129 @@ +--- +## +## +### NETBOX_TENANT_GROUP +## +## +- name: 1 - Test tenant group creation + netbox.netbox.netbox_tenant_group: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test Tenant Group Two + register: test_one + +- name: 1 - ASSERT + ansible.builtin.assert: + that: + - test_one is changed + - test_one['diff']['before']['state'] == "absent" + - test_one['diff']['after']['state'] == "present" + - test_one['tenant_group']['name'] == "Test Tenant Group Two" + - test_one['tenant_group']['slug'] == "test-tenant-group-two" + - test_one['msg'] == "tenant_group Test Tenant Group Two created" + +- name: Test duplicate tenant group + netbox.netbox.netbox_tenant_group: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test Tenant Group Two + register: test_two + +- name: 2 - ASSERT + ansible.builtin.assert: + that: + - not test_two['changed'] + - test_two['tenant_group']['name'] == "Test Tenant Group Two" + - test_two['tenant_group']['slug'] == "test-tenant-group-two" + - test_two['msg'] == "tenant_group Test Tenant Group Two already exists" + +- name: 3 - Test delete + netbox.netbox.netbox_tenant_group: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test Tenant Group Two + state: absent + register: test_three + +- name: 3 - ASSERT + ansible.builtin.assert: + that: + - test_three is changed + - test_three['diff']['before']['state'] == "present" + - test_three['diff']['after']['state'] == "absent" + - test_three['msg'] == "tenant_group Test Tenant Group Two deleted" + +- name: 4 - Test tenant group creation with custom slug + netbox.netbox.netbox_tenant_group: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test Tenant Group ABC + slug: test_tenant_group_four + register: test_four + +- name: 4 - ASSERT + ansible.builtin.assert: + that: + - test_four is changed + - test_four['diff']['before']['state'] == "absent" + - test_four['diff']['after']['state'] == "present" + - test_four['tenant_group']['name'] == "Test Tenant Group ABC" + - test_four['tenant_group']['slug'] == "test_tenant_group_four" + - test_four['msg'] == "tenant_group Test Tenant Group ABC created" + +- name: 5 - Test child tenant group creation + netbox.netbox.netbox_tenant_group: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Child Test Tenant Group + parent_tenant_group: "{{ test_four.tenant_group.slug }}" + register: test_five + +- name: 5 - ASSERT + ansible.builtin.assert: + that: + - test_five is changed + - test_five['diff']['before']['state'] == "absent" + - test_five['diff']['after']['state'] == "present" + - test_five['tenant_group']['name'] == "Child Test Tenant Group" + - test_five['tenant_group']['parent'] == test_four.tenant_group.id + - test_five['msg'] == "tenant_group Child Test Tenant Group created" + +- name: 6 - Test child tenant group deletion + netbox.netbox.netbox_tenant_group: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Child Test Tenant Group + state: absent + register: test_six + +- name: 6 - ASSERT + ansible.builtin.assert: + that: + - test_six is changed + - test_six['diff']['before']['state'] == "present" + - test_six['diff']['after']['state'] == "absent" + - test_six['msg'] == "tenant_group Child Test Tenant Group deleted" + +- name: 7 - Test deletion of the tenant group with custom slug + netbox.netbox.netbox_tenant_group: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test Tenant Group ABC + slug: test_tenant_group_four + state: absent + register: test_seven + +- name: 7 - ASSERT + ansible.builtin.assert: + that: + - test_seven is changed + - test_seven['diff']['before']['state'] == "present" + - test_seven['diff']['after']['state'] == "absent" + - test_seven['msg'] == "tenant_group Test Tenant Group ABC deleted" diff --git a/tests/integration/targets/v4.3/tasks/netbox_token.yml b/tests/integration/targets/v4.3/tasks/netbox_token.yml new file mode 100644 index 000000000..e8b2aa165 --- /dev/null +++ b/tests/integration/targets/v4.3/tasks/netbox_token.yml @@ -0,0 +1,105 @@ +--- +## +## +### NETBOX_PERMISSION +## +## +- name: "TOKEN: Set up user" + netbox.netbox.netbox_user: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + username: TestUser + password: TestPassword2 + state: present + register: test_user + +- name: "TOKEN 1: Necessary info creation" + netbox.netbox.netbox_token: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + user: TestUser + key: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + state: present + register: test_one + +- name: "TOKEN 1: ASSERT - Necessary info creation" + ansible.builtin.assert: + that: + - test_one is changed + - test_one['diff']['before']['state'] == "absent" + - test_one['diff']['after']['state'] == "present" + - test_one['token']['user'] == test_user['user']['id'] + - test_one['msg'] == "token ******** created" + +- name: "TOKEN 2: Create duplicate" + netbox.netbox.netbox_token: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + user: TestUser + key: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + state: present + register: test_two + +- name: "TOKEN 2: ASSERT - Create duplicate" + ansible.builtin.assert: + that: + - not test_two['changed'] + - test_two['msg'] == "token ******** already exists" + +- name: "TOKEN 3: Update" + netbox.netbox.netbox_token: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + user: TestUser + key: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + description: The test token + write_enabled: false + expires: 2024-08-26T14:49:01.345000+00:00 + state: present + register: test_three + +- name: "TOKEN 3: ASSERT - Update" + ansible.builtin.assert: + that: + - test_three is changed + - test_three['token']['description'] == "The test token" + - test_three['token']['write_enabled'] == false + - test_three['token']['expires'] == "2024-08-26T14:49:01.345000+00:00" + - test_three['msg'] == "token ******** updated" + +- name: "TOKEN 4: Delete" + netbox.netbox.netbox_token: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + key: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + state: absent + register: test_four + +- name: "TOKEN 4: ASSERT - Delete" + ansible.builtin.assert: + that: + - test_four is changed + - test_four['diff']['before']['state'] == "present" + - test_four['diff']['after']['state'] == "absent" + - test_four['msg'] == "token ******** deleted" + +- name: "TOKEN 5: ASSERT - Delete non existing" + netbox.netbox.netbox_token: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + key: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + state: absent + register: test_five + +- name: "TOKEN 5: ASSERT - Delete non existing" + ansible.builtin.assert: + that: + - not test_five['changed'] + - test_five['token'] == None + - test_five['msg'] == "token ******** already absent" diff --git a/tests/integration/targets/v4.3/tasks/netbox_tunnel.yml b/tests/integration/targets/v4.3/tasks/netbox_tunnel.yml new file mode 100644 index 000000000..71e98d81a --- /dev/null +++ b/tests/integration/targets/v4.3/tasks/netbox_tunnel.yml @@ -0,0 +1,96 @@ +--- +## +## +### NETBOX_TUNNEL +## +## +- name: "TUNNEL 1: Necessary info creation" + netbox.netbox.netbox_tunnel: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test Tunnel + status: active + encapsulation: ipsec-tunnel + state: present + register: test_one + +- name: "TUNNEL 1: ASSERT - Necessary info creation" + ansible.builtin.assert: + that: + - test_one is changed + - test_one['diff']['before']['state'] == "absent" + - test_one['diff']['after']['state'] == "present" + - test_one['tunnel']['name'] == "Test Tunnel" + - test_one['tunnel']['status'] == "active" + - test_one['tunnel']['encapsulation'] == "ipsec-tunnel" + - test_one['msg'] == "tunnel Test Tunnel created" + +- name: "TUNNEL 2: Create duplicate" + netbox.netbox.netbox_tunnel: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test Tunnel + status: active + encapsulation: ipsec-tunnel + state: present + register: test_two + +- name: "TUNNEL 2: ASSERT - Create duplicate" + ansible.builtin.assert: + that: + - not test_two['changed'] + - test_two['tunnel']['name'] == "Test Tunnel" + - test_two['tunnel']['status'] == "active" + - test_two['tunnel']['encapsulation'] == "ipsec-tunnel" + - test_two['msg'] == "tunnel Test Tunnel already exists" + +- name: "TUNNEL 3: Update Existing" + netbox.netbox.netbox_tunnel: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test Tunnel + encapsulation: ipsec-tunnel + description: Test Description + tenant: Test Tenant + tunnel_id: 200 + tags: + - Schnozzberry + state: present + register: test_three + +- name: "TUNNEL: ASSERT - Updated" + ansible.builtin.assert: + that: + - test_three is changed + - test_three['diff']['after']['description'] == "Test Description" + - test_three['diff']['after']['tenant'] == 1 + - test_three['diff']['after']['tunnel_id'] == 200 + - test_three['diff']['after']['tags'][0] == 4 + - test_three['tunnel']['name'] == "Test Tunnel" + - test_three['tunnel']['tenant'] == 1 + - test_three['tunnel']['tunnel_id'] == 200 + - test_three['tunnel']['description'] == "Test Description" + - test_three['tunnel']['tags'][0] == 4 + - test_three['tunnel']['encapsulation'] == "ipsec-tunnel" + - test_three['msg'] == "tunnel Test Tunnel updated" + +- name: "TUNNEL 4: Delete" + netbox.netbox.netbox_tunnel: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test Tunnel + encapsulation: ipsec-tunnel + state: absent + register: test_four + +- name: "TUNNEL 4: ASSERT - Delete" + ansible.builtin.assert: + that: + - test_four is changed + - test_four['diff']['before']['state'] == "present" + - test_four['diff']['after']['state'] == "absent" + - test_four['msg'] == "tunnel Test Tunnel deleted" diff --git a/tests/integration/targets/v4.3/tasks/netbox_tunnel_group.yml b/tests/integration/targets/v4.3/tasks/netbox_tunnel_group.yml new file mode 100644 index 000000000..918147341 --- /dev/null +++ b/tests/integration/targets/v4.3/tasks/netbox_tunnel_group.yml @@ -0,0 +1,81 @@ +--- +## +## +### NETBOX_TUNNEL GROUP +## +## +- name: "TUNNEL_GROUP 1: Necessary info creation" + netbox.netbox.netbox_tunnel_group: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test Tunnel Group + state: present + register: test_one + +- name: "TUNNEL_GROUP 1: ASSERT - Necessary info creation" + ansible.builtin.assert: + that: + - test_one is changed + - test_one['diff']['before']['state'] == "absent" + - test_one['diff']['after']['state'] == "present" + - test_one['tunnel_group']['name'] == "Test Tunnel Group" + - test_one['tunnel_group']['slug'] == "test-tunnel-group" + - test_one['msg'] == "tunnel_group Test Tunnel Group created" + +- name: "TUNNEL_GROUP 2: Create duplicate" + netbox.netbox.netbox_tunnel_group: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test Tunnel Group + state: present + register: test_two + +- name: "TUNNEL_GROUP 2: ASSERT - Create duplicate" + ansible.builtin.assert: + that: + - not test_two['changed'] + - test_two['tunnel_group']['name'] == "Test Tunnel Group" + - test_two['tunnel_group']['slug'] == "test-tunnel-group" + - test_two['msg'] == "tunnel_group Test Tunnel Group already exists" + +- name: "TUNNEL_GROUP 3: Update Existing" + netbox.netbox.netbox_tunnel_group: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test Tunnel Group + description: Test Description + tags: + - Schnozzberry + state: present + register: test_three + +- name: "TUNNEL_GROUP 3: ASSERT - Updated" + ansible.builtin.assert: + that: + - test_three is changed + - test_three['diff']['after']['description'] == "Test Description" + - test_three['diff']['after']['tags'][0] == 4 + - test_three['tunnel_group']['name'] == "Test Tunnel Group" + - test_three['tunnel_group']['description'] == "Test Description" + - test_three['tunnel_group']['tags'][0] == 4 + - test_three['msg'] == "tunnel_group Test Tunnel Group updated" + +- name: "TUNNEL_GROUP 4: Delete" + netbox.netbox.netbox_tunnel_group: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test Tunnel Group + state: absent + register: test_four + +- name: "TUNNEL_GROUP 4: ASSERT - Delete" + ansible.builtin.assert: + that: + - test_four is changed + - test_four['diff']['before']['state'] == "present" + - test_four['diff']['after']['state'] == "absent" + - test_four['msg'] == "tunnel_group Test Tunnel Group deleted" diff --git a/tests/integration/targets/v4.3/tasks/netbox_user.yml b/tests/integration/targets/v4.3/tasks/netbox_user.yml new file mode 100644 index 000000000..62b35e563 --- /dev/null +++ b/tests/integration/targets/v4.3/tasks/netbox_user.yml @@ -0,0 +1,202 @@ +--- +## +## +### NETBOX_USER +## +## +- name: "USER 1: Necessary info creation" + netbox.netbox.netbox_user: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + username: TestUser + password: TestPassword1 + state: present + register: test_one + +- name: "USER 1: ASSERT - Necessary info creation" + ansible.builtin.assert: + that: + - test_one is changed + - test_one['diff']['before']['state'] == "absent" + - test_one['diff']['after']['state'] == "present" + - test_one['user']['username'] == "TestUser" + - test_one['user']['display'] == "TestUser" + - test_one['msg'] == "user TestUser created" + +- name: "USER 2: Update password" + netbox.netbox.netbox_user: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + username: TestUser + password: TestPassword2 + email: my@user.com + state: present + register: test_two + +- name: "USER 2: ASSERT - Update password" + ansible.builtin.assert: + that: + - test_two['changed'] + - test_two['user']['username'] == "TestUser" + - test_two['msg'] == "user TestUser updated" + +- name: "USER 3: Update" + netbox.netbox.netbox_user: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + username: TestUser + password: TestPassword3 + email: test@user.com + first_name: Test + last_name: User + is_active: false + is_staff: true + state: present + register: test_three + +- name: "USER 3: ASSERT - Update" + ansible.builtin.assert: + that: + - test_three is changed + - test_three['diff']['after']['first_name'] == "Test" + - test_three['diff']['after']['last_name'] == "User" + - test_three['user']['username'] == "TestUser" + - test_three['user']['email'] == "test@user.com" + - test_three['user']['first_name'] == "Test" + - test_three['user']['last_name'] == "User" + - test_three['user']['is_active'] == False + - test_three['user']['is_staff'] == True + - test_three['msg'] == "user TestUser updated" + +- name: "USER 4: Delete" + netbox.netbox.netbox_user: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + username: TestUser + state: absent + register: test_four + +- name: "USER 4: ASSERT - Delete" + ansible.builtin.assert: + that: + - test_four is changed + - test_four['diff']['before']['state'] == "present" + - test_four['diff']['after']['state'] == "absent" + - test_four['msg'] == "user TestUser deleted" + +- name: "USER 5: Delete non existing" + netbox.netbox.netbox_user: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + username: TestUser + state: absent + register: test_five + +- name: "USER 5: ASSERT - Delete non existing`" + ansible.builtin.assert: + that: + - not test_five['changed'] + - test_five['user'] == None + - test_five['msg'] == "user TestUser already absent" + +- name: "USER 6: Necessary group 1" + netbox.netbox.netbox_user_group: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test User Group Alpha + state: present + register: user_group_alpha + +- name: "USER 6: Necessary group 2" + netbox.netbox.netbox_user_group: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test User Group Beta + state: present + register: user_group_beta + +- name: "User 6: Necessary permission 1" + netbox.netbox.netbox_permission: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test Permission Foo + actions: + - view + object_types: [] + state: present + register: permission_foo + +- name: "User 6: Necessary permission 2" + netbox.netbox.netbox_permission: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test Permission Bar + actions: + - view + object_types: [] + state: present + register: permission_bar + +- name: "User 6: Necessary permission 3" + netbox.netbox.netbox_permission: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test Permission Baz + actions: + - view + object_types: [] + state: present + register: permission_baz + +- name: "USER 6: Set up user with multiple groups and permissions" + netbox.netbox.netbox_user: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + username: TestUser2 + password: TestPassword2 + permissions: + - Test Permission Foo + - Test Permission Bar + - Test Permission Baz + groups: + - Test User Group Alpha + - Test User Group Beta + state: present + +- name: "USER 6: Re-create user with lists in wrong order" + netbox.netbox.netbox_user: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + username: TestUser2 + permissions: + - Test Permission Bar + - Test Permission Baz + - Test Permission Foo + groups: + - Test User Group Beta + - Test User Group Alpha + state: present + register: test_six + +- name: "USER 6: ASSERT - The same lists in a new order do not update the user" + ansible.builtin.assert: + that: + - not test_six['changed'] + - test_six['msg'] == "user TestUser2 already exists" + - test_six['user']['groups'][0] == user_group_alpha['user_group']['id'] + - test_six['user']['groups'][1] == user_group_beta['user_group']['id'] + - test_six['user']['permissions'][0] == permission_foo['permission']['id'] + - test_six['user']['permissions'][1] == permission_bar['permission']['id'] + - test_six['user']['permissions'][2] == permission_baz['permission']['id'] diff --git a/tests/integration/targets/v4.3/tasks/netbox_user_group.yml b/tests/integration/targets/v4.3/tasks/netbox_user_group.yml new file mode 100644 index 000000000..0bedc95fb --- /dev/null +++ b/tests/integration/targets/v4.3/tasks/netbox_user_group.yml @@ -0,0 +1,181 @@ +--- +## +## +### NETBOX_USER_GROUP +## +## +- name: "USER_GROUP 1: Necessary info creation" + netbox.netbox.netbox_user_group: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test User Group + state: present + register: test_one + +- name: "USER_GROUP 1: ASSERT - Necessary info creation" + ansible.builtin.assert: + that: + - test_one is changed + - test_one['diff']['before']['state'] == "absent" + - test_one['diff']['after']['state'] == "present" + - test_one['user_group']['name'] == "Test User Group" + - test_one['msg'] == "user_group Test User Group created" + +- name: "USER_GROUP 2: Create duplicate" + netbox.netbox.netbox_user_group: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test User Group + state: present + register: test_two + +- name: "USER_GROUP 2: ASSERT - Create duplicate" + ansible.builtin.assert: + that: + - not test_two['changed'] + - test_two['user_group']['name'] == "Test User Group" + - test_two['msg'] == "user_group Test User Group already exists" + +- name: "USER_GROUP 3: Update" + netbox.netbox.netbox_user_group: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test User Group + description: The test group + state: present + register: test_three + +- name: "USER_GROUP 3: ASSERT - Update" + ansible.builtin.assert: + that: + - test_three is changed + - test_three['diff']['after']['description'] == "The test group" + - test_three['user_group']['name'] == "Test User Group" + - test_three['user_group']['description'] == "The test group" + - test_three['msg'] == "user_group Test User Group updated" + +- name: "USER_GROUP 4: Create second group" + netbox.netbox.netbox_user_group: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test User Group 2 + state: present + register: test_four + +- name: "USER_GROUP 4: ASSERT - Necessary info creation" + ansible.builtin.assert: + that: + - test_four is changed + - test_four['diff']['before']['state'] == "absent" + - test_four['diff']['after']['state'] == "present" + - test_four['user_group']['name'] == "Test User Group 2" + - test_four['msg'] == "user_group Test User Group 2 created" + +- name: "USER_GROUP 5: Add user to group" + netbox.netbox.netbox_user: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + username: TestUser + password: TestPassword5 + groups: + - Test User Group + state: present + register: test_five + +- name: "USER_GROUP 5: ASSERT - Add user to group" + ansible.builtin.assert: + that: + - test_five is changed + - test_five['user']['groups'] == [test_one['user_group']['id']] + +- name: "USER_GROUP 6: Delete" + netbox.netbox.netbox_user_group: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test User Group + state: absent + register: test_six + +- name: "USER_GROUP 6: ASSERT - Delete" + ansible.builtin.assert: + that: + - test_six is changed + - test_six['diff']['before']['state'] == "present" + - test_six['diff']['after']['state'] == "absent" + - test_six['msg'] == "user_group Test User Group deleted" + +- name: "USER_GROUP 6: ASSERT - Delete non existing" + netbox.netbox.netbox_user_group: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test User Group + state: absent + register: test_seven + +- name: "USER_GROUP 7: ASSERT - Delete non existing`" + ansible.builtin.assert: + that: + - not test_seven['changed'] + - test_seven['user_group'] == None + - test_seven['msg'] == "user_group Test User Group already absent" + +- name: "USER_GROUP 8: Necessary permission 1" + netbox.netbox.netbox_permission: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test Permission Foo + actions: + - view + object_types: [] + state: present + register: permission_foo + +- name: "USER_GROUP 8: Necessary permission 2" + netbox.netbox.netbox_permission: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test Permission Bar + actions: + - view + object_types: [] + state: present + register: permission_bar + +- name: "USER_GROUP 8: Necessary info creation" + netbox.netbox.netbox_user_group: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test User Group + permissions: + - Test Permission Foo + - Test Permission Bar + state: present + +- name: "USER_GROUP 8: Re-create user group with permissions in wrong order" + netbox.netbox.netbox_user_group: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test User Group + permissions: + - Test Permission Bar + - Test Permission Foo + state: present + register: test_eight + +- name: "USER_GROUP 8: ASSERT - The same permissions in a new order do not update the group" + ansible.builtin.assert: + that: + - not test_eight is changed + - test_eight['user_group']['permissions'][0] == permission_foo['permission']['id'] + - test_eight['user_group']['permissions'][1] == permission_bar['permission']['id'] diff --git a/tests/integration/targets/v4.3/tasks/netbox_virtual_chassis.yml b/tests/integration/targets/v4.3/tasks/netbox_virtual_chassis.yml new file mode 100644 index 000000000..6eae6de19 --- /dev/null +++ b/tests/integration/targets/v4.3/tasks/netbox_virtual_chassis.yml @@ -0,0 +1,130 @@ +--- +# © 2020 Nokia +# Licensed under the GNU General Public License v3.0 only +# SPDX-License-Identifier: GPL-3.0-only +## +## +### NETBOX_VIRTUAL_CHASSIS +## +## +- name: "VIRTUAL_CHASSIS 0: Create device for testing virtual chassis" + netbox.netbox.netbox_device: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Device Virtual Chassis Tests + device_type: Cisco Test + device_role: Core Switch + site: Test Site + vc_position: 1 + vc_priority: 1 + state: present + +- name: "VIRTUAL_CHASSIS 1: Necessary info creation" + netbox.netbox.netbox_virtual_chassis: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: First VC + master: Device Virtual Chassis Tests + state: present + register: test_one + +- name: "VIRTUAL_CHASSIS 1: ASSERT - Necessary info creation" + ansible.builtin.assert: + that: + - test_one is changed + - test_one['diff']['before']['state'] == "absent" + - test_one['diff']['after']['state'] == "present" + - test_one['virtual_chassis']['name'] == "First VC" + - test_one['msg'] == "virtual_chassis First VC created" + +- name: "VIRTUAL_CHASSIS 2: Create duplicate" + netbox.netbox.netbox_virtual_chassis: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: First VC + master: Device Virtual Chassis Tests + state: present + register: test_two + +- name: "VIRTUAL_CHASSIS 2: ASSERT - Create duplicate" + ansible.builtin.assert: + that: + - not test_two['changed'] + - test_two['virtual_chassis']['master'] == test_one['virtual_chassis']['master'] + - test_two['virtual_chassis']['name'] == "First VC" + - test_two['msg'] == "virtual_chassis First VC already exists" + +- name: "POWER_FEED 3: Update virtual_chassis with other fields" + netbox.netbox.netbox_virtual_chassis: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: First VC + master: Device Virtual Chassis Tests + domain: Domain Text + state: present + register: test_three + +- name: "POWER_FEED 3: ASSERT - Update virtual_chassis with other fields" + ansible.builtin.assert: + that: + - test_three is changed + - test_three['diff']['after']['domain'] == "Domain Text" + - test_three['virtual_chassis']['master'] == test_one['virtual_chassis']['master'] + - test_three['virtual_chassis']['domain'] == "Domain Text" + - test_three['virtual_chassis']['name'] == "First VC" + - test_three['msg'] == "virtual_chassis First VC updated" + +- name: "VIRTUAL_CHASSIS 4: Create device for testing virtual chassis deletion" + netbox.netbox.netbox_device: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Device Virtual Chassis Tests 2 + device_type: Cisco Test + device_role: Core Switch + site: Test Site + vc_position: 1 + vc_priority: 15 + state: present + +- name: "VIRTUAL_CHASSIS 4: Create Virtual Chassis for Delete Test" + netbox.netbox.netbox_virtual_chassis: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Second VC + master: Device Virtual Chassis Tests 2 + state: present + register: test_four + +- name: "VIRTUAL_CHASSIS 4: ASSERT - Create Virtual Chassis for Delete Test" + ansible.builtin.assert: + that: + - test_four is changed + - test_four['diff']['before']['state'] == "absent" + - test_four['diff']['after']['state'] == "present" + - test_four['virtual_chassis']['master'] != test_one['virtual_chassis']['master'] + - test_four['virtual_chassis']['name'] == "Second VC" + - test_four['msg'] == "virtual_chassis Second VC created" + +- name: "VIRTUAL_CHASSIS 5: Delete Virtual Chassis" + netbox.netbox.netbox_virtual_chassis: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Second VC + master: Device Virtual Chassis Tests 2 + state: absent + register: test_five + +- name: "VIRTUAL_CHASSIS 5: ASSERT - Delete Virtual Chassis" + ansible.builtin.assert: + that: + - test_five is changed + - test_five['diff']['before']['state'] == "present" + - test_five['diff']['after']['state'] == "absent" + - test_five['msg'] == "virtual_chassis Second VC deleted" diff --git a/tests/integration/targets/v4.3/tasks/netbox_virtual_disk.yml b/tests/integration/targets/v4.3/tasks/netbox_virtual_disk.yml new file mode 100644 index 000000000..5b17eaddf --- /dev/null +++ b/tests/integration/targets/v4.3/tasks/netbox_virtual_disk.yml @@ -0,0 +1,87 @@ +--- +## +## +### NETBOX_VIRTUAL_DISK +## +## +- name: "NETBOX_VIRTUAL_DISK 1: Necessary info creation" + netbox.netbox.netbox_virtual_disk: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + virtual_machine: test100-vm + name: disk0 + size: 50 + state: present + register: test_one + +- name: "NETBOX_VIRTUAL_DISK 1: ASSERT - Necessary info creation" + ansible.builtin.assert: + that: + - test_one is changed + - test_one['diff']['before']['state'] == "absent" + - test_one['diff']['after']['state'] == "present" + - test_one['virtual_disk']['name'] == "disk0" + - test_one['virtual_disk']['virtual_machine'] == 1 + - test_one['msg'] == "virtual_disk disk0 created" + +- name: "NETBOX_VIRTUAL_DISK 2: Create duplicate" + netbox.netbox.netbox_virtual_disk: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + virtual_machine: test100-vm + name: disk0 + size: 50 + state: present + register: test_two + +- name: "NETBOX_VIRTUAL_DISK 2: ASSERT - Create duplicate" + ansible.builtin.assert: + that: + - not test_two['changed'] + - test_two['virtual_disk']['name'] == "disk0" + - test_two['virtual_disk']['virtual_machine'] == 1 + - test_two['msg'] == "virtual_disk disk0 already exists" + +- name: "NETBOX_VIRTUAL_DISK 3: Update" + netbox.netbox.netbox_virtual_disk: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + virtual_machine: test100-vm + name: disk0 + size: 60 + tags: + - Schnozzberry + state: present + register: test_three + +- name: "NETBOX_VIRTUAL_DISK 4: ASSERT - Updated" + ansible.builtin.assert: + that: + - test_three is changed + - test_three['diff']['after']['size'] == 60 + - test_three['virtual_disk']['name'] == "disk0" + - test_three['virtual_disk']['virtual_machine'] == 1 + - test_three['virtual_disk']['size'] == 60 + - test_three['virtual_disk']['tags'][0] == 4 + - test_three['msg'] == "virtual_disk disk0 updated" + +- name: "NETBOX_VIRTUAL_DISK 4: ASSERT - Delete" + netbox.netbox.netbox_virtual_disk: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: disk0 + virtual_machine: test100-vm + state: absent + register: test_four + +- name: "NETBOX_VIRTUAL_DISK 4: ASSERT - Delete" + ansible.builtin.assert: + that: + - test_four is changed + - test_four['virtual_disk']['name'] == "disk0" + - test_four['virtual_disk']['virtual_machine'] == 1 + - test_four['msg'] == "virtual_disk disk0 deleted" diff --git a/tests/integration/targets/v4.3/tasks/netbox_virtual_machine.yml b/tests/integration/targets/v4.3/tasks/netbox_virtual_machine.yml new file mode 100644 index 000000000..6ef7f1f47 --- /dev/null +++ b/tests/integration/targets/v4.3/tasks/netbox_virtual_machine.yml @@ -0,0 +1,131 @@ +--- +## +## +### NETBOX_VIRTUAL_MACHINES +## +## +- name: "VIRTUAL_MACHINE 1: Necessary info creation" + netbox.netbox.netbox_virtual_machine: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test VM One + cluster: Test Cluster + state: present + register: test_one + +- name: "VIRTUAL_MACHINE 1: ASSERT - Necessary info creation" + ansible.builtin.assert: + that: + - test_one is changed + - test_one['diff']['before']['state'] == "absent" + - test_one['diff']['after']['state'] == "present" + - test_one['virtual_machine']['name'] == "Test VM One" + - test_one['virtual_machine']['cluster'] == 1 + - test_one['msg'] == "virtual_machine Test VM One created" + +- name: "VIRTUAL_MACHINE 2: Create duplicate" + netbox.netbox.netbox_virtual_machine: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test VM One + cluster: Test Cluster + state: present + register: test_two + +- name: "VIRTUAL_MACHINE 2: ASSERT - Create duplicate" + ansible.builtin.assert: + that: + - not test_two['changed'] + - test_two['virtual_machine']['name'] == "Test VM One" + - test_two['virtual_machine']['cluster'] == 1 + - test_two['msg'] == "virtual_machine Test VM One already exists" + +- name: "VIRTUAL_MACHINE 3: Update" + netbox.netbox.netbox_virtual_machine: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test VM One + cluster: Test Cluster + serial: 12345678 + vcpus: 8.5 + memory: 8 + status: Planned + virtual_machine_role: Test VM Role + tags: + - Schnozzberry + state: present + register: test_three + +- name: "VIRTUAL_MACHINE 3: ASSERT - Updated" + ansible.builtin.assert: + that: + - test_three is changed + - test_three['diff']['after']['vcpus'] == 8.5 + - test_three['diff']['after']['memory'] == 8 + - test_three['diff']['after']['status'] == "planned" + - test_three['diff']['after']['role'] == 2 + - test_three['diff']['after']['serial'] == "12345678" + - test_three['diff']['after']['tags'][0] == 4 + - test_three['virtual_machine']['name'] == "Test VM One" + - test_three['virtual_machine']['cluster'] == 1 + - test_three['virtual_machine']['vcpus'] == 8.5 + - test_three['virtual_machine']['memory'] == 8 + - test_three['virtual_machine']['status'] == "planned" + - test_three['virtual_machine']['role'] == 2 + - test_three['virtual_machine']['serial'] == "12345678" + - test_three['virtual_machine']['tags'][0] == 4 + - test_three['msg'] == "virtual_machine Test VM One updated" + +- name: "VIRTUAL_MACHINE 4: Test idempotence" + netbox.netbox.netbox_virtual_machine: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test VM One + cluster: Test Cluster + vcpus: 8.5 + memory: 8 + status: Planned + virtual_machine_role: Test VM Role + tags: + - Schnozzberry + state: present + register: test_four_idempotence + +- name: "VIRTUAL_MACHINE 4: ASSERT - Not changed" + ansible.builtin.assert: + that: + - test_four_idempotence is not changed + - test_four_idempotence['virtual_machine']['name'] == "Test VM One" + - test_four_idempotence['virtual_machine']['cluster'] == 1 + - test_four_idempotence['virtual_machine']['vcpus'] == 8.5 + - test_four_idempotence['virtual_machine']['memory'] == 8 + - test_four_idempotence['virtual_machine']['status'] == "planned" + - test_four_idempotence['virtual_machine']['role'] == 2 + - test_four_idempotence['virtual_machine']['tags'][0] == 4 + - test_four_idempotence['msg'] == "virtual_machine Test VM One already exists" + +- name: "VIRTUAL_MACHINE 5: Delete" + netbox.netbox.netbox_virtual_machine: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test VM One + state: absent + register: test_five + +- name: "VIRTUAL_MACHINE 5: ASSERT - Delete" + ansible.builtin.assert: + that: + - test_five is changed + - test_five['virtual_machine']['name'] == "Test VM One" + - test_five['virtual_machine']['cluster'] == 1 + - test_five['virtual_machine']['vcpus'] == 8.5 + - test_five['virtual_machine']['memory'] == 8 + - test_five['virtual_machine']['status'] == "planned" + - test_five['virtual_machine']['role'] == 2 + - test_five['virtual_machine']['tags'][0] == 4 + - test_five['msg'] == "virtual_machine Test VM One deleted" diff --git a/tests/integration/targets/v4.3/tasks/netbox_vlan.yml b/tests/integration/targets/v4.3/tasks/netbox_vlan.yml new file mode 100644 index 000000000..463873ca5 --- /dev/null +++ b/tests/integration/targets/v4.3/tasks/netbox_vlan.yml @@ -0,0 +1,193 @@ +--- +## +## +### NETBOX_VLAN +## +## +- name: "VLAN 1: Necessary info creation" + netbox.netbox.netbox_vlan: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test VLAN 500 + vid: 500 + state: present + register: test_one + +- name: "VLAN 1: ASSERT - Necessary info creation" + ansible.builtin.assert: + that: + - test_one is changed + - test_one['diff']['before']['state'] == "absent" + - test_one['diff']['after']['state'] == "present" + - test_one['vlan']['name'] == "Test VLAN 500" + - test_one['vlan']['vid'] == 500 + - test_one['msg'] == "vlan Test VLAN 500 created" + +- name: "VLAN 2: Create duplicate" + netbox.netbox.netbox_vlan: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test VLAN 500 + vid: 500 + state: present + register: test_two + +- name: "VLAN 2: ASSERT - Create duplicate" + ansible.builtin.assert: + that: + - not test_two['changed'] + - test_two['vlan']['name'] == "Test VLAN 500" + - test_two['vlan']['vid'] == 500 + - test_two['msg'] == "vlan Test VLAN 500 already exists" + +- name: "VLAN 3: Create VLAN with same name, but different site" + netbox.netbox.netbox_vlan: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test VLAN 500 + vid: 500 + site: Test Site + tenant: Test Tenant + vlan_group: Test VLAN Group + state: present + register: test_three + +- name: "VLAN 3: ASSERT - Create VLAN with same name, but different site" + ansible.builtin.assert: + that: + - test_three is changed + - test_three['diff']['before']['state'] == "absent" + - test_three['diff']['after']['state'] == "present" + - test_three['vlan']['name'] == "Test VLAN 500" + - test_three['vlan']['vid'] == 500 + - test_three['vlan']['site'] == 1 + - test_three['vlan']['group'] == 1 + - test_three['msg'] == "vlan Test VLAN 500 created" + +- name: "VLAN 4: ASSERT - Update" + netbox.netbox.netbox_vlan: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test VLAN 500 + vid: 500 + tenant: Test Tenant + vlan_group: Test VLAN Group + status: Reserved + vlan_role: Network of care + description: Updated description + site: Test Site + tags: + - Schnozzberry + state: present + register: test_four + +- name: "VLAN 4: ASSERT - Updated" + ansible.builtin.assert: + that: + - test_four is changed + - test_four['diff']['after']['status'] == "reserved" + - test_four['diff']['after']['role'] == 1 + - test_four['diff']['after']['description'] == "Updated description" + - test_four['diff']['after']['tags'][0] == 4 + - test_four['vlan']['name'] == "Test VLAN 500" + - test_four['vlan']['tenant'] == 1 + - test_four['vlan']['site'] == 1 + - test_four['vlan']['group'] == 1 + - test_four['vlan']['status'] == "reserved" + - test_four['vlan']['role'] == 1 + - test_four['vlan']['description'] == "Updated description" + - test_four['vlan']['tags'][0] == 4 + - test_four['msg'] == "vlan Test VLAN 500 updated" + +- name: "VLAN: ASSERT - IDEMPOTENT WITH VLAN_GROUP" + netbox.netbox.netbox_vlan: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test VLAN 500 + vid: 500 + tenant: Test Tenant + vlan_group: Test VLAN Group + status: Reserved + vlan_role: Network of care + description: Updated description + site: Test Site + tags: + - Schnozzberry + state: present + register: idempotent_vlan_group + +- name: "VLAN: ASSERT - IDEMPOTENT WITH VLAN_GROUP" + ansible.builtin.assert: + that: + - idempotent_vlan_group is not changed + +- name: "VLAN: Create VLAN with same name, but different vlan_group" + netbox.netbox.netbox_vlan: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test VLAN 500 + vid: 500 + site: Test Site + tenant: Test Tenant + vlan_group: Test VLAN Group 2 + state: present + register: new_vlan_group + +- name: "VLAN: ASSERT - Create VLAN with same name, but different vlan_group" + ansible.builtin.assert: + that: + - new_vlan_group is changed + - new_vlan_group['diff']['before']['state'] == "absent" + - new_vlan_group['diff']['after']['state'] == "present" + - new_vlan_group['vlan']['name'] == "Test VLAN 500" + - new_vlan_group['vlan']['vid'] == 500 + - new_vlan_group['vlan']['site'] == 1 + - new_vlan_group['vlan']['group'] == 2 + - new_vlan_group['msg'] == "vlan Test VLAN 500 created" + +- name: "VLAN 5: ASSERT - Delete more than one result" + netbox.netbox.netbox_vlan: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test VLAN 500 + state: absent + ignore_errors: true + register: test_five + +- name: "VLAN 5: ASSERT - Delete more than one result" + ansible.builtin.assert: + that: + - test_five is failed + - test_five['msg'] == "More than one result returned for Test VLAN 500" + +- name: "VLAN 6: ASSERT - Delete" + netbox.netbox.netbox_vlan: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test VLAN 500 + site: Test Site + vlan_group: Test VLAN Group + state: absent + register: test_six + +- name: "VLAN 6: ASSERT - Delete" + ansible.builtin.assert: + that: + - test_six is changed + - test_six['vlan']['name'] == "Test VLAN 500" + - test_six['vlan']['tenant'] == 1 + - test_six['vlan']['site'] == 1 + - test_six['vlan']['group'] == 1 + - test_six['vlan']['status'] == "reserved" + - test_six['vlan']['role'] == 1 + - test_six['vlan']['description'] == "Updated description" + - test_six['vlan']['tags'][0] == 4 + - test_six['msg'] == "vlan Test VLAN 500 deleted" diff --git a/tests/integration/targets/v4.3/tasks/netbox_vlan_group.yml b/tests/integration/targets/v4.3/tasks/netbox_vlan_group.yml new file mode 100644 index 000000000..9dd4d1789 --- /dev/null +++ b/tests/integration/targets/v4.3/tasks/netbox_vlan_group.yml @@ -0,0 +1,314 @@ +--- +## +## +### NETBOX_VLAN_GROUP +## +## +- name: "VLAN_GROUP 1: Necessary info creation" + netbox.netbox.netbox_vlan_group: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: VLAN Group One + scope_type: dcim.site + scope: Test Site + state: present + register: results + +- name: "VLAN_GROUP 1: ASSERT - Necessary info creation" + ansible.builtin.assert: + that: + - results is changed + - results['diff']['before']['state'] == "absent" + - results['diff']['after']['state'] == "present" + - results['vlan_group']['name'] == "VLAN Group One" + - results['vlan_group']['slug'] == "vlan-group-one" + - results['vlan_group']['scope_type'] == "dcim.site" + - results['vlan_group']['scope_id'] == 1 + - results['msg'] == "vlan_group VLAN Group One created" + +- name: "VLAN_GROUP 2: Create duplicate" + netbox.netbox.netbox_vlan_group: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: VLAN Group One + scope_type: dcim.site + scope: Test Site + state: present + register: results + +- name: "VLAN_GROUP 2: ASSERT - Create duplicate" + ansible.builtin.assert: + that: + - not results['changed'] + - results['vlan_group']['name'] == "VLAN Group One" + - results['vlan_group']['slug'] == "vlan-group-one" + - results['vlan_group']['scope_type'] == "dcim.site" + - results['vlan_group']['scope_id'] == 1 + - results['msg'] == "vlan_group VLAN Group One already exists" + +- name: "VLAN_GROUP 3: ASSERT - Create with same name, different site" + netbox.netbox.netbox_vlan_group: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: VLAN Group One + scope_type: dcim.site + scope: Test Site2 + state: present + register: results + +- name: "VLAN_GROUP 3: ASSERT - Create with same name, different site" + ansible.builtin.assert: + that: + - results is changed + - results['vlan_group']['name'] == "VLAN Group One" + - results['vlan_group']['slug'] == "vlan-group-one" + - results['vlan_group']['scope_type'] == "dcim.site" + - results['vlan_group']['scope_id'] == 2 + - results['msg'] == "vlan_group VLAN Group One created" + +- name: "VLAN_GROUP 4: ASSERT - Create vlan group, no site" + netbox.netbox.netbox_vlan_group: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: VLAN Group One + state: present + ignore_errors: true + register: results + +- name: "VLAN_GROUP 4: ASSERT - Create with same name, different site" + ansible.builtin.assert: + that: + - results is failed + - results['msg'] == "More than one result returned for VLAN Group One" + +- name: "VLAN_GROUP 5: ASSERT - Delete" + netbox.netbox.netbox_vlan_group: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: VLAN Group One + scope_type: dcim.site + scope: Test Site2 + state: absent + register: results + +- name: "VLAN_GROUP 5: ASSERT - Delete" + ansible.builtin.assert: + that: + - results is changed + - results['diff']['before']['state'] == "present" + - results['diff']['after']['state'] == "absent" + - results['vlan_group']['name'] == "VLAN Group One" + - results['vlan_group']['slug'] == "vlan-group-one" + - results['vlan_group']['scope_type'] == "dcim.site" + - results['vlan_group']['scope_id'] == 2 + - results['msg'] == "vlan_group VLAN Group One deleted" + +- name: "VLAN_GROUP 6: ASSERT - Delete non existing" + netbox.netbox.netbox_vlan_group: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: VLAN Group One + scope_type: dcim.site + scope: Test Site2 + state: absent + register: results + +- name: "VLAN_GROUP 6: ASSERT - Delete non existing`" + ansible.builtin.assert: + that: + - not results['changed'] + - results['vlan_group'] == None + - results['msg'] == "vlan_group VLAN Group One already absent" + +- name: "VLAN_GROUP 7: Necessary info creation - scope_type: dcim.location" + netbox.netbox.netbox_vlan_group: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: VLAN Group Location + scope_type: dcim.location + scope: Test Rack Group + state: present + register: results + +- name: "VLAN_GROUP 7: ASSERT - Necessary info creation - scope_type: dcim.location" + ansible.builtin.assert: + that: + - results is changed + - results['diff']['before']['state'] == "absent" + - results['diff']['after']['state'] == "present" + - results['vlan_group']['name'] == "VLAN Group Location" + - results['vlan_group']['slug'] == "vlan-group-location" + - results['vlan_group']['scope_type'] == "dcim.location" + - results['vlan_group']['scope_id'] == 1 + - results['msg'] == "vlan_group VLAN Group Location created" + +- name: "VLAN_GROUP 8: Necessary info creation - scope_type: dcim.rack" + netbox.netbox.netbox_vlan_group: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: VLAN Group Rack + scope_type: dcim.rack + scope: Test Rack + state: present + register: results + +- name: "VLAN_GROUP 8: ASSERT - Necessary info creation - scope_type: dcim.rack" + ansible.builtin.assert: + that: + - results is changed + - results['diff']['before']['state'] == "absent" + - results['diff']['after']['state'] == "present" + - results['vlan_group']['name'] == "VLAN Group Rack" + - results['vlan_group']['slug'] == "vlan-group-rack" + - results['vlan_group']['scope_type'] == "dcim.rack" + - results['vlan_group']['scope_id'] == 2 + - results['msg'] == "vlan_group VLAN Group Rack created" + +- name: "VLAN_GROUP 9: Necessary info creation - scope_type: dcim.region" + netbox.netbox.netbox_vlan_group: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: VLAN Group Region + scope_type: dcim.region + scope: Test Region + state: present + register: results + +- name: "VLAN_GROUP 9: ASSERT - Necessary info creation - scope_type: dcim.region" + ansible.builtin.assert: + that: + - results is changed + - results['diff']['before']['state'] == "absent" + - results['diff']['after']['state'] == "present" + - results['vlan_group']['name'] == "VLAN Group Region" + - results['vlan_group']['slug'] == "vlan-group-region" + - results['vlan_group']['scope_type'] == "dcim.region" + - results['vlan_group']['scope_id'] == 1 + - results['msg'] == "vlan_group VLAN Group Region created" + +- name: "VLAN_GROUP 10: Necessary info creation - scope_type: dcim.sitegroup" + netbox.netbox.netbox_vlan_group: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: VLAN Group Site Group + scope_type: dcim.sitegroup + scope: Test Site Group + state: present + register: results + +- name: "VLAN_GROUP 10: ASSERT - Necessary info creation - scope_type: dcim.sitegroup" + ansible.builtin.assert: + that: + - results is changed + - results['diff']['before']['state'] == "absent" + - results['diff']['after']['state'] == "present" + - results['vlan_group']['name'] == "VLAN Group Site Group" + - results['vlan_group']['slug'] == "vlan-group-site-group" + - results['vlan_group']['scope_type'] == "dcim.sitegroup" + - results['vlan_group']['scope_id'] == 4 + - results['msg'] == "vlan_group VLAN Group Site Group created" + +# Commented out due to invalid content type being reported back by API +# - name: "VLAN_GROUP 11: Necessary info creation - scope_type: virtualization.cluster" +# netbox.netbox.netbox_vlan_group: +# netbox_url: http://localhost:32768 +# netbox_token: 0123456789abcdef0123456789abcdef01234567 +# data: +# name: "VLAN Group Cluster" +# scope_type: "virtualization.cluster" +# scope: Test Cluster +# state: present +# register: results + +# - name: "VLAN_GROUP 11: ASSERT - Necessary info creation - scope_type: virtualization.cluster" +# assert: +# that: +# - results is changed +# - results['diff']['before']['state'] == "absent" +# - results['diff']['after']['state'] == "present" +# - results['vlan_group']['name'] == "VLAN Group Cluster" +# - results['vlan_group']['slug'] == "vlan-group-cluster" +# - results['vlan_group']['scope_type'] == "virtualization.cluster" +# - results['vlan_group']['scope_id'] == 1 +# - results['msg'] == "vlan_group VLAN Group Cluster created" + +# - name: "VLAN_GROUP 12: Necessary info creation - scope_type: virtualization.clustergroup" +# netbox.netbox.netbox_vlan_group: +# netbox_url: http://localhost:32768 +# netbox_token: 0123456789abcdef0123456789abcdef01234567 +# data: +# name: "VLAN Group Cluster Group" +# scope_type: "virtualization.clustergroup" +# scope: Test Cluster Group +# state: present +# register: results + +# - name: "VLAN_GROUP 12: ASSERT - Necessary info creation - scope_type: virtualization.clustergroup" +# assert: +# that: +# - results is changed +# - results['diff']['before']['state'] == "absent" +# - results['diff']['after']['state'] == "present" +# - results['vlan_group']['name'] == "VLAN Group Cluster Group" +# - results['vlan_group']['slug'] == "vlan-group-cluster-group" +# - results['vlan_group']['scope_type'] == "virtualization.clustergroup" +# - results['vlan_group']['scope_id'] == 1 +# - results['msg'] == "vlan_group VLAN Group Cluster Group created" + +- name: "VLAN_GROUP 12: Update Description - scope_type: dcim.location" + netbox.netbox.netbox_vlan_group: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: VLAN Group Location + scope_type: dcim.location + scope: Test Rack Group + description: Ansible updated description + state: present + register: results + +- name: "VLAN_GROUP 12: ASSERT - Update Description - scope_type: dcim.location" + ansible.builtin.assert: + that: + - results is changed + - results['diff']['before']['description'] == "" + - results['diff']['after']['description'] == "Ansible updated description" + - results['vlan_group']['name'] == "VLAN Group Location" + - results['vlan_group']['slug'] == "vlan-group-location" + - results['vlan_group']['scope_type'] == "dcim.location" + - results['vlan_group']['scope_id'] == 1 + - results['vlan_group']['description'] == "Ansible updated description" + - results['msg'] == "vlan_group VLAN Group Location updated" + +- name: "VLAN_GROUP 12: Update Description (IDEM) - scope_type: dcim.location" + netbox.netbox.netbox_vlan_group: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: VLAN Group Location + scope_type: dcim.location + scope: Test Rack Group + description: Ansible updated description + state: present + register: results + +- name: "VLAN_GROUP 12: ASSERT - Update Description (IDEM) - scope_type: dcim.location" + ansible.builtin.assert: + that: + - results is not changed + - results['vlan_group']['name'] == "VLAN Group Location" + - results['vlan_group']['slug'] == "vlan-group-location" + - results['vlan_group']['scope_type'] == "dcim.location" + - results['vlan_group']['scope_id'] == 1 + - results['vlan_group']['description'] == "Ansible updated description" + - results['msg'] == "vlan_group VLAN Group Location already exists" diff --git a/tests/integration/targets/v4.3/tasks/netbox_vm_interface.yml b/tests/integration/targets/v4.3/tasks/netbox_vm_interface.yml new file mode 100644 index 000000000..6ca36e1e5 --- /dev/null +++ b/tests/integration/targets/v4.3/tasks/netbox_vm_interface.yml @@ -0,0 +1,159 @@ +--- +## +## +### NETBOX_VM_INTERFACE +## +## +- name: "NETBOX_VM_INTERFACE 1: Necessary info creation" + netbox.netbox.netbox_vm_interface: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + virtual_machine: test100-vm + name: Eth10 + state: present + register: test_one + +- name: "NETBOX_VM_INTERFACE 1: ASSERT - Necessary info creation" + ansible.builtin.assert: + that: + - test_one is changed + - test_one['diff']['before']['state'] == "absent" + - test_one['diff']['after']['state'] == "present" + - test_one['interface']['name'] == "Eth10" + - test_one['interface']['virtual_machine'] == 1 + - test_one['msg'] == "interface Eth10 created" + +- name: "NETBOX_VM_INTERFACE 2: Create duplicate" + netbox.netbox.netbox_vm_interface: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + virtual_machine: test100-vm + name: Eth10 + state: present + register: test_two + +- name: "NETBOX_VM_INTERFACE 2: ASSERT - Create duplicate" + ansible.builtin.assert: + that: + - not test_two['changed'] + - test_two['interface']['name'] == "Eth10" + - test_two['interface']['virtual_machine'] == 1 + - test_two['msg'] == "interface Eth10 already exists" + +- name: "NETBOX_VM_INTERFACE 3: Updated" + netbox.netbox.netbox_vm_interface: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + virtual_machine: test100-vm + name: Eth10 + enabled: false + mtu: 9000 + mac_address: "00:00:00:AA:AA:01" + description: Updated test100-vm + mode: Tagged + # untagged_vlan: + # name: Wireless + # site: Test Site + # tagged_vlans: + # - name: Data + # site: Test Site + # - name: VoIP + # site: Test Site + tags: + - Schnozzberry + state: present + register: test_three + +- name: "NETBOX_VM_INTERFACE 4: ASSERT - Updated" + ansible.builtin.assert: + that: + - test_three is changed + - test_three['diff']['after']['enabled'] == false + - test_three['diff']['after']['mtu'] == 9000 + - test_three['diff']['after']['mac_address'] == "00:00:00:AA:AA:01" + - test_three['diff']['after']['description'] == "Updated test100-vm" + - test_three['diff']['after']['mode'] == "tagged" + # - test_three['diff']['after']['untagged_vlan'] == 1 + # - test_three['diff']['after']['tagged_vlans'] == [2, 3] + - test_three['diff']['after']['tags'][0] == 4 + - test_three['interface']['name'] == "Eth10" + - test_three['interface']['virtual_machine'] == 1 + - test_three['interface']['enabled'] == false + - test_three['interface']['mtu'] == 9000 + - test_three['interface']['mac_address'] == "00:00:00:AA:AA:01" + - test_three['interface']['description'] == "Updated test100-vm" + - test_three['interface']['mode'] == "tagged" + # - test_three['interface']['untagged_vlan'] == 1 + # - test_three['interface']['tagged_vlans'] == [2, 3] + - test_three['interface']['tags'][0] == 4 + - test_three['msg'] == "interface Eth10 updated" + +- name: "NETBOX_VM_INTERFACE 4: ASSERT - Delete" + netbox.netbox.netbox_vm_interface: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Eth10 + virtual_machine: test100-vm + state: absent + register: test_four + +- name: "NETBOX_VM_INTERFACE 4: ASSERT - Delete" + ansible.builtin.assert: + that: + - test_four is changed + - test_four['interface']['name'] == "Eth10" + - test_four['interface']['virtual_machine'] == 1 + - test_four['msg'] == "interface Eth10 deleted" + +- name: "NETBOX_VM_INTERFACE 5: Attempt to update interface with same name on other VMs" + netbox.netbox.netbox_vm_interface: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + virtual_machine: test100-vm + name: Eth0 + enabled: false + mtu: 9000 + mac_address: "00:00:00:AA:AA:01" + description: Updated test100-vm Eth0 intf + mode: Tagged + # untagged_vlan: + # name: Wireless + # site: Test Site + # tagged_vlans: + # - name: Data + # site: Test Site + # - name: VoIP + # site: Test Site + tags: + - Schnozzberry + state: present + register: test_five + +- name: "NETBOX_VM_INTERFACE 5: ASSERT - Updated" + ansible.builtin.assert: + that: + - test_five is changed + - test_five['diff']['after']['enabled'] == false + - test_five['diff']['after']['mtu'] == 9000 + - test_five['diff']['after']['mac_address'] == "00:00:00:AA:AA:01" + - test_five['diff']['after']['description'] == "Updated test100-vm Eth0 intf" + - test_five['diff']['after']['mode'] == "tagged" + # - test_five['diff']['after']['untagged_vlan'] == 1 + # - test_five['diff']['after']['tagged_vlans'] == [2, 3] + - test_five['diff']['after']['tags'][0] == 4 + - test_five['interface']['name'] == "Eth0" + - test_five['interface']['virtual_machine'] == 1 + - test_five['interface']['enabled'] == false + - test_five['interface']['mtu'] == 9000 + - test_five['interface']['mac_address'] == "00:00:00:AA:AA:01" + - test_five['interface']['description'] == "Updated test100-vm Eth0 intf" + - test_five['interface']['mode'] == "tagged" + # - test_five['interface']['untagged_vlan'] == 1 + # - test_five['interface']['tagged_vlans'] == [2, 3] + - test_five['interface']['tags'][0] == 4 + - test_five['msg'] == "interface Eth0 updated" diff --git a/tests/integration/targets/v4.3/tasks/netbox_vrf.yml b/tests/integration/targets/v4.3/tasks/netbox_vrf.yml new file mode 100644 index 000000000..1da7ae382 --- /dev/null +++ b/tests/integration/targets/v4.3/tasks/netbox_vrf.yml @@ -0,0 +1,137 @@ +--- +## +## +### NETBOX_VRF +## +## +- name: "VRF 1: Necessary info creation" + netbox.netbox.netbox_vrf: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test VRF One + state: present + register: test_one + +- name: "VRF 1: ASSERT - Necessary info creation" + ansible.builtin.assert: + that: + - test_one is changed + - test_one['diff']['before']['state'] == "absent" + - test_one['diff']['after']['state'] == "present" + - test_one['vrf']['name'] == "Test VRF One" + - test_one['msg'] == "vrf Test VRF One created" + +- name: "VRF 2: Create duplicate" + netbox.netbox.netbox_vrf: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test VRF One + state: present + register: test_two + +- name: "VRF 2: ASSERT - Create duplicate" + ansible.builtin.assert: + that: + - not test_two['changed'] + - test_two['vrf']['name'] == "Test VRF One" + - test_two['msg'] == "vrf Test VRF One already exists" + +- name: "VRF 3: Create VRF with same name, but different tenant" + netbox.netbox.netbox_vrf: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test VRF One + tenant: Test Tenant + state: present + register: test_three + +- name: "VRF 3: ASSERT - Create VRF with same name, but different site" + ansible.builtin.assert: + that: + - test_three is changed + - test_three['diff']['before']['state'] == "absent" + - test_three['diff']['after']['state'] == "present" + - test_three['vrf']['name'] == "Test VRF One" + - test_three['vrf']['tenant'] == 1 + - test_three['msg'] == "vrf Test VRF One created" + +- name: "VRF 4: ASSERT - Update" + netbox.netbox.netbox_vrf: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test VRF One + rd: "65001:1" + enforce_unique: false + tenant: Test Tenant + description: Updated description + import_targets: + - 4000:4000 + - 5000:5000 + export_targets: + - 5000:5000 + tags: + - Schnozzberry + state: present + register: test_four + +- name: "VRF 4: ASSERT - Updated" + ansible.builtin.assert: + that: + - test_four is changed + - test_four['diff']['after']['rd'] == "65001:1" + - test_four['diff']['after']['enforce_unique'] == false + - test_four['diff']['after']['description'] == "Updated description" + - test_four['diff']['after']['tags'][0] == 4 + - test_four['diff']['after']['import_targets'] | length == 2 + - test_four['diff']['after']['export_targets'] | length == 1 + - test_four['vrf']['name'] == "Test VRF One" + - test_four['vrf']['tenant'] == 1 + - test_four['vrf']['rd'] == "65001:1" + - test_four['vrf']['enforce_unique'] == false + - test_four['vrf']['description'] == "Updated description" + - test_four['vrf']['tags'][0] == 4 + - test_four['vrf']['import_targets'] | length == 2 + - test_four['vrf']['export_targets'] | length == 1 + - test_four['msg'] == "vrf Test VRF One updated" + +- name: "VRF 5: ASSERT - Delete more than one result" + netbox.netbox.netbox_vrf: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test VRF One + state: absent + ignore_errors: true + register: test_five + +- name: "VRF 5: ASSERT - Delete more than one result" + ansible.builtin.assert: + that: + - test_five is failed + - test_five['msg'] == "More than one result returned for Test VRF One" + +- name: "VRF 6: ASSERT - Delete" + netbox.netbox.netbox_vrf: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Test VRF One + tenant: Test Tenant + state: absent + register: test_six + +- name: "VRF 6: ASSERT - Delete" + ansible.builtin.assert: + that: + - test_six is changed + - test_six['vrf']['name'] == "Test VRF One" + - test_six['vrf']['tenant'] == 1 + - test_six['vrf']['rd'] == "65001:1" + - test_six['vrf']['enforce_unique'] == false + - test_six['vrf']['description'] == "Updated description" + - test_six['vrf']['tags'][0] == 4 + - test_six['msg'] == "vrf Test VRF One deleted" diff --git a/tests/integration/targets/v4.3/tasks/netbox_webhook.yml b/tests/integration/targets/v4.3/tasks/netbox_webhook.yml new file mode 100644 index 000000000..a3d5a3825 --- /dev/null +++ b/tests/integration/targets/v4.3/tasks/netbox_webhook.yml @@ -0,0 +1,121 @@ +--- +## +## +### NETBOX_WEBHOOK +## +## +- name: "WEBHOOK 1: Necessary info creation" + netbox.netbox.netbox_webhook: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + content_types: + - dcim.device + name: Example Webhook + type_create: true + payload_url: https://payload.url + body_template: !unsafe >- + {{ data }} + state: present + register: test_one + +- name: "WEBHOOK 1: ASSERT - Necessary info creation" + ansible.builtin.assert: + that: + - test_one is changed + - test_one['diff']['before']['state'] == "absent" + - test_one['diff']['after']['state'] == "present" + - test_one['webhook']['name'] == "Example Webhook" + - test_one['webhook']['type_create'] == True + - test_one['webhook']['payload_url'] == "https://payload.url" + - test_one['webhook']['content_types'] == ["dcim.device"] + - test_one['msg'] == "webhook Example Webhook created" + +- name: "WEBHOOK 2: Create duplicate" + netbox.netbox.netbox_webhook: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + content_types: + - dcim.device + name: Example Webhook + type_create: true + payload_url: https://payload.url + body_template: !unsafe >- + {{ data }} + state: present + register: test_two + +- name: "WEBHOOK 2: ASSERT - Create duplicate" + ansible.builtin.assert: + that: + - not test_two['changed'] + - test_two['webhook']['name'] == "Example Webhook" + - test_two['msg'] == "webhook Example Webhook already exists" + +- name: "WEBHOOK 3: Update data and add on delete" + netbox.netbox.netbox_webhook: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + content_types: + - dcim.device + type_create: true + type_delete: true + name: Example Webhook + payload_url: https://payload.url + body_template: !unsafe >- + {{ data }} + state: present + register: test_three + +- name: "WEBHOOK 3: ASSERT - Updated" + ansible.builtin.assert: + that: + - test_three is changed + - test_three['webhook']['name'] == "Example Webhook" + - test_three['msg'] == "webhook Example Webhook updated" + +- name: "WEBHOOK 4: Change content type" + netbox.netbox.netbox_webhook: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + content_types: + - virtualization.virtualmachine + name: Example Webhook + payload_url: https://payload.url + body_template: !unsafe >- + {{ data }} + state: present + register: test_four + +- name: "WEBHOOK 4: ASSERT - Change content type" + ansible.builtin.assert: + that: + - test_four is changed + - test_four['diff']['after']['content_types'] == ["virtualization.virtualmachine"] + - test_four['webhook']['name'] == "Example Webhook" + - test_four['msg'] == "webhook Example Webhook updated" + +- name: "WEBHOOK 5: Delete" + netbox.netbox.netbox_webhook: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + content_types: + - virtualization.virtualmachine + name: Example Webhook + payload_url: https://payload.url + body_template: !unsafe >- + {{ data }} + state: absent + register: test_five + +- name: "WEBHOOK 5: ASSERT - Deleted" + ansible.builtin.assert: + that: + - test_five is changed + - test_five['diff']['after']['state'] == "absent" + - test_five['webhook']['name'] == "Example Webhook" + - test_five['msg'] == "webhook Example Webhook deleted" diff --git a/tests/integration/targets/v4.3/tasks/netbox_wireless_lan.yml b/tests/integration/targets/v4.3/tasks/netbox_wireless_lan.yml new file mode 100644 index 000000000..e70fd3e59 --- /dev/null +++ b/tests/integration/targets/v4.3/tasks/netbox_wireless_lan.yml @@ -0,0 +1,103 @@ +--- +## +## +### NETBOX_WIRELESS_LAN +## +## +- name: 1 - Test wireless LAN creation + netbox.netbox.netbox_wireless_lan: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + ssid: Wireless LAN One + register: test_one + +- name: 1 - ASSERT + ansible.builtin.assert: + that: + - test_one is changed + - test_one['diff']['before']['state'] == "absent" + - test_one['diff']['after']['state'] == "present" + - test_one['wireless_lan']['ssid'] == "Wireless LAN One" + - test_one['msg'] == "wireless_lan Wireless LAN One created" + +- name: Test duplicate wireless LAN + netbox.netbox.netbox_wireless_lan: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + ssid: Wireless LAN One + register: test_two + +- name: 2 - ASSERT + ansible.builtin.assert: + that: + - not test_two['changed'] + - test_two['wireless_lan']['ssid'] == "Wireless LAN One" + - test_two['msg'] == "wireless_lan Wireless LAN One already exists" + +- name: 3 - Test update + netbox.netbox.netbox_wireless_lan: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + ssid: Wireless LAN One + description: New Description + register: test_three + +- name: 3 - ASSERT + ansible.builtin.assert: + that: + - test_three is changed + - test_three['diff']['after']['description'] == "New Description" + - test_three['wireless_lan']['ssid'] == "Wireless LAN One" + - test_three['wireless_lan']['description'] == "New Description" + - test_three['msg'] == "wireless_lan Wireless LAN One updated" + +- name: 4 - Test delete + netbox.netbox.netbox_wireless_lan: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + ssid: Wireless LAN One + state: absent + register: test_four + +- name: 4 - ASSERT + ansible.builtin.assert: + that: + - test_four is changed + - test_four['diff']['before']['state'] == "present" + - test_four['diff']['after']['state'] == "absent" + - test_four['msg'] == "wireless_lan Wireless LAN One deleted" + +- name: 5 - Create wireless LAN with all parameters + netbox.netbox.netbox_wireless_lan: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + ssid: Wireless Network One + description: Cool Wireless Network + auth_type: wpa-enterprise + auth_cipher: aes + auth_psk: psk123456 + tags: + - tagA + - tagB + - tagC + state: present + register: test_five + +- name: 5 - ASSERT + ansible.builtin.assert: + that: + - test_five is changed + - test_five['diff']['before']['state'] == "absent" + - test_five['diff']['after']['state'] == "present" + - test_five['wireless_lan']['ssid'] == "Wireless Network One" + - test_five['wireless_lan']['description'] == "Cool Wireless Network" + - test_five['wireless_lan']['auth_type'] == "wpa-enterprise" + - test_five['wireless_lan']['auth_cipher'] == "aes" + - test_five['wireless_lan']['auth_psk'] == "psk123456" + # - test_five['wireless_lan']['tags'] | length == 3 + - test_five['msg'] == "wireless_lan Wireless Network One created" diff --git a/tests/integration/targets/v4.3/tasks/netbox_wireless_lan_group.yml b/tests/integration/targets/v4.3/tasks/netbox_wireless_lan_group.yml new file mode 100644 index 000000000..57daaf62c --- /dev/null +++ b/tests/integration/targets/v4.3/tasks/netbox_wireless_lan_group.yml @@ -0,0 +1,97 @@ +--- +## +## +### NETBOX_WIRELESS_LAN_GROUP +## +## +- name: 1 - Test wireless LAN group creation + netbox.netbox.netbox_wireless_lan_group: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Wireless LAN Group One + register: test_one + +- name: 1 - ASSERT + ansible.builtin.assert: + that: + - test_one is changed + - test_one['diff']['before']['state'] == "absent" + - test_one['diff']['after']['state'] == "present" + - test_one['wireless_lan_group']['name'] == "Wireless LAN Group One" + - test_one['msg'] == "wireless_lan_group Wireless LAN Group One created" + +- name: Test duplicate wireless LAN group + netbox.netbox.netbox_wireless_lan_group: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Wireless LAN Group One + register: test_two + +- name: 2 - ASSERT + ansible.builtin.assert: + that: + - not test_two['changed'] + - test_two['wireless_lan_group']['name'] == "Wireless LAN Group One" + - test_two['msg'] == "wireless_lan_group Wireless LAN Group One already exists" + +- name: 3 - Test update + netbox.netbox.netbox_wireless_lan_group: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Wireless LAN Group One + description: New Description + register: test_three + +- name: 3 - ASSERT + ansible.builtin.assert: + that: + - test_three is changed + - test_three['diff']['after']['description'] == "New Description" + - test_three['wireless_lan_group']['name'] == "Wireless LAN Group One" + - test_three['wireless_lan_group']['description'] == "New Description" + - test_three['msg'] == "wireless_lan_group Wireless LAN Group One updated" + +- name: 4 - Test delete + netbox.netbox.netbox_wireless_lan_group: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Wireless LAN Group One + state: absent + register: test_four + +- name: 4 - ASSERT + ansible.builtin.assert: + that: + - test_four is changed + - test_four['diff']['before']['state'] == "present" + - test_four['diff']['after']['state'] == "absent" + - test_four['msg'] == "wireless_lan_group Wireless LAN Group One deleted" + +- name: 5 - Create wireless LAN group with all parameters + netbox.netbox.netbox_wireless_lan_group: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + name: Wireless LAN Group One + description: Cool Wireless LAN Group + tags: + - tagA + - tagB + - tagC + state: present + register: test_five + +- name: 5 - ASSERT + ansible.builtin.assert: + that: + - test_five is changed + - test_five['diff']['before']['state'] == "absent" + - test_five['diff']['after']['state'] == "present" + - test_five['wireless_lan_group']['name'] == "Wireless LAN Group One" + - test_five['wireless_lan_group']['description'] == "Cool Wireless LAN Group" + - test_five['wireless_lan_group']['tags'] | length == 3 + - test_five['msg'] == "wireless_lan_group Wireless LAN Group One created" diff --git a/tests/integration/targets/v4.3/tasks/netbox_wireless_link.yml b/tests/integration/targets/v4.3/tasks/netbox_wireless_link.yml new file mode 100644 index 000000000..b026db81e --- /dev/null +++ b/tests/integration/targets/v4.3/tasks/netbox_wireless_link.yml @@ -0,0 +1,130 @@ +--- +## +## +### NETBOX_WIRELESS_LINK +## +## +- name: 1 - Test wireless link creation + netbox.netbox.netbox_wireless_link: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + interface_a: + device: Test Nexus One + name: wlink1 + interface_b: + device: test100 + name: wlink1 + register: test_one + +- name: 1 - ASSERT + ansible.builtin.assert: + that: + - test_one is changed + - test_one['diff']['before']['state'] == "absent" + - test_one['diff']['after']['state'] == "present" + - test_one['wireless_link']['interface_a'] == 6 + - test_one['wireless_link']['interface_b'] == 5 + - test_one['msg'] == "wireless_link Test Nexus One wlink1 <> test100 wlink1 created" + +- name: Test duplicate wireless link + netbox.netbox.netbox_wireless_link: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + interface_a: + device: Test Nexus One + name: wlink1 + interface_b: + device: test100 + name: wlink1 + register: test_two + +- name: 2 - ASSERT + ansible.builtin.assert: + that: + - not test_two['changed'] + - test_two['msg'] == "wireless_link Test Nexus One wlink1 <> test100 wlink1 already exists" + +- name: 3 - Test update + netbox.netbox.netbox_wireless_link: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + interface_a: + device: Test Nexus One + name: wlink1 + interface_b: + device: test100 + name: wlink1 + status: planned + register: test_three + +- name: 3 - ASSERT + ansible.builtin.assert: + that: + - test_three is changed + - test_three['diff']['after']['status'] == "planned" + - test_three['wireless_link']['status'] == "planned" + - test_three['msg'] == "wireless_link Test Nexus One wlink1 <> test100 wlink1 updated" + +- name: 4 - Test delete + netbox.netbox.netbox_wireless_link: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + interface_a: + device: Test Nexus One + name: wlink1 + interface_b: + device: test100 + name: wlink1 + state: absent + register: test_four + +- name: 4 - ASSERT + ansible.builtin.assert: + that: + - test_four is changed + - test_four['diff']['before']['state'] == "present" + - test_four['diff']['after']['state'] == "absent" + - test_four['msg'] == "wireless_link Test Nexus One wlink1 <> test100 wlink1 deleted" + +- name: 5 - Create wireless link with all parameters + netbox.netbox.netbox_wireless_link: + netbox_url: http://localhost:32768 + netbox_token: "0123456789abcdef0123456789abcdef01234567" + data: + interface_a: + device: Test Nexus One + name: wlink1 + interface_b: + device: test100 + name: wlink1 + ssid: Wireless Network One + description: Cool Wireless Network + auth_type: wpa-enterprise + auth_cipher: aes + auth_psk: psk123456 + tags: + - tagA + - tagB + - tagC + state: present + register: test_five + +- name: 5 - ASSERT + ansible.builtin.assert: + that: + - test_five is changed + - test_five['diff']['before']['state'] == "absent" + - test_five['diff']['after']['state'] == "present" + - test_five['wireless_link']['ssid'] == "Wireless Network One" + - test_five['wireless_link']['description'] == "Cool Wireless Network" + - test_five['wireless_link']['interface_a'] == 6 + - test_five['wireless_link']['interface_b'] == 5 + - test_five['wireless_link']['auth_type'] == "wpa-enterprise" + - test_five['wireless_link']['auth_cipher'] == "aes" + - test_five['wireless_link']['auth_psk'] == "psk123456" + # - test_five['wireless_link']['tags'] | length == 3 + - test_five['msg'] == "wireless_link Test Nexus One wlink1 <> test100 wlink1 created" diff --git a/tests/netbox-docker/v4.3/docker-compose.override.yml b/tests/netbox-docker/v4.3/docker-compose.override.yml new file mode 100644 index 000000000..1b3d14807 --- /dev/null +++ b/tests/netbox-docker/v4.3/docker-compose.override.yml @@ -0,0 +1,25 @@ +--- +version: "3.4" +services: + netbox-worker: &netbox-override + image: netboxcommunity/netbox:v4.3 + healthcheck: + start_period: 300s + timeout: 3s + interval: 15s + test: ps -aux | grep -v grep | grep -q rqworker || exit 1 + netbox: + <<: *netbox-override + ports: + - 32768:8080 + healthcheck: + start_period: 300s + timeout: 3s + interval: 15s + test: curl -f http://localhost:8080/login/ || exit 1 + environment: + SKIP_SUPERUSER: "false" + SUPERUSER_API_TOKEN: "0123456789abcdef0123456789abcdef01234567" + SUPERUSER_EMAIL: admin@localhost.com + SUPERUSER_NAME: admin + SUPERUSER_PASSWORD: admin diff --git a/tests/test_data.py b/tests/test_data.py deleted file mode 100644 index e1cc73e99..000000000 --- a/tests/test_data.py +++ /dev/null @@ -1,21 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright: (c) 2019, Bruno Inec (@sweenu) -# Copyright: (c) 2019, Mikhail Yohman (@FragmentedPacket) -# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) - -from __future__ import absolute_import, division, print_function - -__metaclass__ = type - -import json - - -# Load test data from a json file, for a pytest parametrize -def load_test_data(path, test_path): - with open(f"{path}/test_data/{test_path}/data.json", "r") as f: - data = json.loads(f.read()) - tests = [] - for test in data: - tuple_data = tuple(test.values()) - tests.append(tuple_data) - return tests diff --git a/tests/unit/helpers/load_data.py b/tests/unit/helpers/load_data.py new file mode 100644 index 000000000..5849cb554 --- /dev/null +++ b/tests/unit/helpers/load_data.py @@ -0,0 +1,63 @@ +# -*- coding: utf-8 -*- +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +""" +Helper functions for loading structured test data for unit tests. + +Provides functions to locate JSON test_data files based on the +location of the test script in tests/unit/ and to return the data +as lists of tuples for use in pytest parameterization. +""" + +import json +from pathlib import Path + +CURRENT_FILE = Path(__file__).resolve() # Current file abs path +UNIT_TESTS_DIR = CURRENT_FILE.parents[1] # project_root/tests/unit +# Relative path from project root to unit tests dir - tests/unit +ROOT_TO_UNIT_TESTS = CURRENT_FILE.parents[1].relative_to(CURRENT_FILE.parents[3]) + + +def load_test_data(script_dir: Path, file_name: str, use_subfold: bool = True) -> list: + """ + Load structured test data for a test file. + + The directory structure is derived from: + tests/unit///... + + Args: + test_script_dir: Directory containing the test file. + file_name: Name of the test_data folder to load. + use_sub: Dive into same subfolders as script_dir in test_data + + Returns: + List of tuples extracted from the JSON file. + """ + try: + # Normal environments: script_dir is resolved under same path tests/unit + units_to_test_file: list = script_dir.relative_to(UNIT_TESTS_DIR).parts + except ValueError: + # Fallback for tox/CI virtual environments where path tests/unit differ + # Find the path fragment "tests/unit" and slice from there + parts = list(script_dir.parts) + try: + idx = parts.index(UNIT_TESTS_DIR.parts[-1]) # project/tests/unit/... + units_to_test_file: list = parts[idx + 1 :] + except ValueError: + # Last-resort fallback: treat as having no subfolder + units_to_test_file = () + + unit_test_dir: str = units_to_test_file[0] if len(units_to_test_file) > 0 else "" + subfolder = Path(*units_to_test_file[1:]) if len(units_to_test_file) > 1 else None + + # Build data.json path + base = ROOT_TO_UNIT_TESTS / unit_test_dir / "test_data" + if subfolder and use_subfold: + base /= subfolder + + data_file = base / f"{file_name}.json" + + with data_file.open("r", encoding="utf-8") as f: + data = json.load(f) + + return [tuple(item.values()) for item in data] diff --git a/tests/unit/inventory/test_data/data.json b/tests/unit/inventory/test_data/data.json deleted file mode 100644 index 41726270e..000000000 --- a/tests/unit/inventory/test_data/data.json +++ /dev/null @@ -1,12 +0,0 @@ -[ - { - "name": "disk1", - "vm_name": "test100-vm", - "size_gb": 100 - }, - { - "name": "disk2", - "vm_name": "test100-vm", - "size_gb": 200 - } -] diff --git a/tests/unit/inventory/test_data/extract_custom_fields/data.json b/tests/unit/inventory/test_data/extract_custom_fields.json similarity index 100% rename from tests/unit/inventory/test_data/extract_custom_fields/data.json rename to tests/unit/inventory/test_data/extract_custom_fields.json diff --git a/tests/unit/inventory/test_data/filter_query_parameters/data.json b/tests/unit/inventory/test_data/filter_query_parameters.json similarity index 100% rename from tests/unit/inventory/test_data/filter_query_parameters/data.json rename to tests/unit/inventory/test_data/filter_query_parameters.json diff --git a/tests/unit/inventory/test_data/get_resource_list_chunked/data.json b/tests/unit/inventory/test_data/get_resource_list_chunked.json similarity index 100% rename from tests/unit/inventory/test_data/get_resource_list_chunked/data.json rename to tests/unit/inventory/test_data/get_resource_list_chunked.json diff --git a/tests/unit/inventory/test_data/group_extractors/data.json b/tests/unit/inventory/test_data/group_extractors.json similarity index 100% rename from tests/unit/inventory/test_data/group_extractors/data.json rename to tests/unit/inventory/test_data/group_extractors.json diff --git a/tests/unit/inventory/test_data/refresh_url/data.json b/tests/unit/inventory/test_data/refresh_url.json similarity index 100% rename from tests/unit/inventory/test_data/refresh_url/data.json rename to tests/unit/inventory/test_data/refresh_url.json diff --git a/tests/unit/inventory/test_data/validate_query_parameter/data.json b/tests/unit/inventory/test_data/validate_query_parameter.json similarity index 100% rename from tests/unit/inventory/test_data/validate_query_parameter/data.json rename to tests/unit/inventory/test_data/validate_query_parameter.json diff --git a/tests/unit/inventory/test_nb_inventory.py b/tests/unit/inventory/test_nb_inventory.py index 93a59217f..6dbaca8d2 100644 --- a/tests/unit/inventory/test_nb_inventory.py +++ b/tests/unit/inventory/test_nb_inventory.py @@ -6,8 +6,8 @@ __metaclass__ = type -import os from functools import partial +from pathlib import Path from unittest.mock import Mock, call, mock_open, patch import pytest @@ -17,7 +17,9 @@ from ansible_collections.netbox.netbox.plugins.inventory.nb_inventory import ( InventoryModule, ) - from ansible_collections.netbox.netbox.tests.test_data import load_test_data + from ansible_collections.netbox.netbox.tests.unit.helpers.load_data import ( + load_test_data, + ) except ImportError: import sys @@ -27,15 +29,12 @@ sys.path.append("plugins/inventory") sys.path.append("tests") - from test_data import load_test_data + from tests.unit.helpers.load_data import load_test_data -load_relative_test_data = partial( - load_test_data, os.path.dirname(os.path.abspath(__file__)) -) +load_relative_test_data = partial(load_test_data, Path(__file__).resolve().parent) class MockInventory: - def __init__(self): self.variables = {} diff --git a/tests/unit/module_utils/fixtures/choices/circuits.json b/tests/unit/module_utils/fixtures/choices/circuits.json deleted file mode 100644 index e7f112b72..000000000 --- a/tests/unit/module_utils/fixtures/choices/circuits.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "status": [ - { - "value": "planned", - "display_name": "Planned" - }, - { - "value": "provisioning", - "display_name": "Provisioning" - }, - { - "value": "active", - "display_name": "Active" - }, - { - "value": "offline", - "display_name": "Offline" - }, - { - "value": "deprovisioning", - "display_name": "Deprovisioning" - }, - { - "value": "decommissioned", - "display_name": "Decommissioned" - } - ] -} \ No newline at end of file diff --git a/tests/unit/module_utils/fixtures/choices/device_types.json b/tests/unit/module_utils/fixtures/choices/device_types.json deleted file mode 100644 index e82964eef..000000000 --- a/tests/unit/module_utils/fixtures/choices/device_types.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "subdevice_role": [ - { - "value": "parent", - "display_name": "Parent" - }, - { - "value": "child", - "display_name": "Child" - } - ] -} \ No newline at end of file diff --git a/tests/unit/module_utils/fixtures/choices/devices.json b/tests/unit/module_utils/fixtures/choices/devices.json deleted file mode 100644 index 5bf1f2f39..000000000 --- a/tests/unit/module_utils/fixtures/choices/devices.json +++ /dev/null @@ -1,42 +0,0 @@ -{ - "face": [ - { - "value": "front", - "display_name": "Front" - }, - { - "value": "rear", - "display_name": "Rear" - } - ], - "status": [ - { - "value": "offline", - "display_name": "Offline" - }, - { - "value": "active", - "display_name": "Active" - }, - { - "value": "planned", - "display_name": "Planned" - }, - { - "value": "staged", - "display_name": "Staged" - }, - { - "value": "failed", - "display_name": "Failed" - }, - { - "value": "inventory", - "display_name": "Inventory" - }, - { - "value": "decommissioning", - "display_name": "Decommissioning" - } - ] -} \ No newline at end of file diff --git a/tests/unit/module_utils/fixtures/choices/interfaces.json b/tests/unit/module_utils/fixtures/choices/interfaces.json deleted file mode 100644 index 2bda690ff..000000000 --- a/tests/unit/module_utils/fixtures/choices/interfaces.json +++ /dev/null @@ -1,306 +0,0 @@ -{ - "type": [ - { - "value": "virtual", - "display_name": "Virtual" - }, - { - "value": "lag", - "display_name": "Link Aggregation Group (LAG)" - }, - { - "value": "100base-tx", - "display_name": "100BASE-TX (10/100ME)" - }, - { - "value": "1000base-t", - "display_name": "1000BASE-T (1GE)" - }, - { - "value": "2.5gbase-t", - "display_name": "2.5GBASE-T (2.5GE)" - }, - { - "value": "5gbase-t", - "display_name": "5GBASE-T (5GE)" - }, - { - "value": "10gbase-t", - "display_name": "10GBASE-T (10GE)" - }, - { - "value": "10gbase-cx4", - "display_name": "10GBASE-CX4 (10GE)" - }, - { - "value": "1000base-x-gbic", - "display_name": "GBIC (1GE)" - }, - { - "value": "1000base-x-sfp", - "display_name": "SFP (1GE)" - }, - { - "value": "10gbase-x-sfpp", - "display_name": "SFP+ (10GE)" - }, - { - "value": "10gbase-x-xfp", - "display_name": "XFP (10GE)" - }, - { - "value": "10gbase-x-xenpak", - "display_name": "XENPAK (10GE)" - }, - { - "value": "10gbase-x-x2", - "display_name": "X2 (10GE)" - }, - { - "value": "25gbase-x-sfp28", - "display_name": "SFP28 (25GE)" - }, - { - "value": "40gbase-x-qsfpp", - "display_name": "QSFP+ (40GE)" - }, - { - "value": "50gbase-x-sfp28", - "display_name": "QSFP28 (50GE)" - }, - { - "value": "100gbase-x-cfp", - "display_name": "CFP (100GE)" - }, - { - "value": "100gbase-x-cfp2", - "display_name": "CFP2 (100GE)" - }, - { - "value": "200gbase-x-cfp2", - "display_name": "CFP2 (200GE)" - }, - { - "value": "100gbase-x-cfp4", - "display_name": "CFP4 (100GE)" - }, - { - "value": "100gbase-x-cpak", - "display_name": "Cisco CPAK (100GE)" - }, - { - "value": "100gbase-x-qsfp28", - "display_name": "QSFP28 (100GE)" - }, - { - "value": "200gbase-x-qsfp56", - "display_name": "QSFP56 (200GE)" - }, - { - "value": "400gbase-x-qsfpdd", - "display_name": "QSFP-DD (400GE)" - }, - { - "value": "400gbase-x-osfp", - "display_name": "OSFP (400GE)" - }, - { - "value": "ieee802.11a", - "display_name": "IEEE 802.11a" - }, - { - "value": "ieee802.11g", - "display_name": "IEEE 802.11b/g" - }, - { - "value": "ieee802.11n", - "display_name": "IEEE 802.11n" - }, - { - "value": "ieee802.11ac", - "display_name": "IEEE 802.11ac" - }, - { - "value": "ieee802.11ad", - "display_name": "IEEE 802.11ad" - }, - { - "value": "ieee802.11ax", - "display_name": "IEEE 802.11ax" - }, - { - "value": "gsm", - "display_name": "GSM" - }, - { - "value": "cdma", - "display_name": "CDMA" - }, - { - "value": "lte", - "display_name": "LTE" - }, - { - "value": "sonet-oc3", - "display_name": "OC-3/STM-1" - }, - { - "value": "sonet-oc12", - "display_name": "OC-12/STM-4" - }, - { - "value": "sonet-oc48", - "display_name": "OC-48/STM-16" - }, - { - "value": "sonet-oc192", - "display_name": "OC-192/STM-64" - }, - { - "value": "sonet-oc768", - "display_name": "OC-768/STM-256" - }, - { - "value": "sonet-oc1920", - "display_name": "OC-1920/STM-640" - }, - { - "value": "sonet-oc3840", - "display_name": "OC-3840/STM-1234" - }, - { - "value": "1gfc-sfp", - "display_name": "SFP (1GFC)" - }, - { - "value": "2gfc-sfp", - "display_name": "SFP (2GFC)" - }, - { - "value": "4gfc-sfp", - "display_name": "SFP (4GFC)" - }, - { - "value": "8gfc-sfpp", - "display_name": "SFP+ (8GFC)" - }, - { - "value": "16gfc-sfpp", - "display_name": "SFP+ (16GFC)" - }, - { - "value": "32gfc-sfp28", - "display_name": "SFP28 (32GFC)" - }, - { - "value": "128gfc-sfp28", - "display_name": "QSFP28 (128GFC)" - }, - { - "value": "inifiband-sdr", - "display_name": "SDR (2 Gbps)" - }, - { - "value": "inifiband-ddr", - "display_name": "DDR (4 Gbps)" - }, - { - "value": "inifiband-qdr", - "display_name": "QDR (8 Gbps)" - }, - { - "value": "inifiband-fdr10", - "display_name": "FDR10 (10 Gbps)" - }, - { - "value": "inifiband-fdr", - "display_name": "FDR (13.5 Gbps)" - }, - { - "value": "inifiband-edr", - "display_name": "EDR (25 Gbps)" - }, - { - "value": "inifiband-hdr", - "display_name": "HDR (50 Gbps)" - }, - { - "value": "inifiband-ndr", - "display_name": "NDR (100 Gbps)" - }, - { - "value": "inifiband-xdr", - "display_name": "XDR (250 Gbps)" - }, - { - "value": "t1", - "display_name": "T1 (1.544 Mbps)" - }, - { - "value": "e1", - "display_name": "E1 (2.048 Mbps)" - }, - { - "value": "t3", - "display_name": "T3 (45 Mbps)" - }, - { - "value": "e3", - "display_name": "E3 (34 Mbps)" - }, - { - "value": "cisco-stackwise", - "display_name": "Cisco StackWise" - }, - { - "value": "cisco-stackwise-plus", - "display_name": "Cisco StackWise Plus" - }, - { - "value": "cisco-flexstack", - "display_name": "Cisco FlexStack" - }, - { - "value": "cisco-flexstack-plus", - "display_name": "Cisco FlexStack Plus" - }, - { - "value": "juniper-vcp", - "display_name": "Juniper VCP" - }, - { - "value": "extreme-summitstack", - "display_name": "Extreme SummitStack" - }, - { - "value": "extreme-summitstack-128", - "display_name": "Extreme SummitStack-128" - }, - { - "value": "extreme-summitstack-256", - "display_name": "Extreme SummitStack-256" - }, - { - "value": "extreme-summitstack-512", - "display_name": "Extreme SummitStack-512" - }, - { - "value": "other", - "display_name": "Other" - } - ], - "mode": [ - { - "value": "access", - "display_name": "Access" - }, - { - "value": "tagged", - "display_name": "Tagged" - }, - { - "value": "tagged-all", - "display_name": "Tagged (All)" - } - ] -} \ No newline at end of file diff --git a/tests/unit/module_utils/fixtures/choices/prefixes.json b/tests/unit/module_utils/fixtures/choices/prefixes.json deleted file mode 100644 index 135ce2bba..000000000 --- a/tests/unit/module_utils/fixtures/choices/prefixes.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "status": [ - { - "value": "container", - "display_name": "Container" - }, - { - "value": "active", - "display_name": "Active" - }, - { - "value": "reserved", - "display_name": "Reserved" - }, - { - "value": "deprecated", - "display_name": "Deprecated" - } - ] -} \ No newline at end of file diff --git a/tests/unit/module_utils/fixtures/choices/racks.json b/tests/unit/module_utils/fixtures/choices/racks.json deleted file mode 100644 index 3068db3da..000000000 --- a/tests/unit/module_utils/fixtures/choices/racks.json +++ /dev/null @@ -1,66 +0,0 @@ -{ - "status": [ - { - "value": "reserved", - "display_name": "Reserved" - }, - { - "value": "available", - "display_name": "Available" - }, - { - "value": "planned", - "display_name": "Planned" - }, - { - "value": "active", - "display_name": "Active" - }, - { - "value": "deprecated", - "display_name": "Deprecated" - } - ], - "type": [ - { - "value": "2-post-frame", - "display_name": "2-post frame" - }, - { - "value": "4-post-frame", - "display_name": "4-post frame" - }, - { - "value": "4-post-cabinet", - "display_name": "4-post cabinet" - }, - { - "value": "wall-frame", - "display_name": "Wall-mounted frame" - }, - { - "value": "wall-cabinet", - "display_name": "Wall-mounted cabinet" - } - ], - "width": [ - { - "value": 19, - "display_name": "19 inches" - }, - { - "value": 23, - "display_name": "23 inches" - } - ], - "outer_unit": [ - { - "value": "mm", - "display_name": "Millimeters" - }, - { - "value": "in", - "display_name": "Inches" - } - ] -} \ No newline at end of file diff --git a/tests/unit/module_utils/fixtures/choices/services.json b/tests/unit/module_utils/fixtures/choices/services.json deleted file mode 100644 index e14147a55..000000000 --- a/tests/unit/module_utils/fixtures/choices/services.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "protocol": [ - { - "value": "tcp", - "display_name": "TCP" - }, - { - "value": "udp", - "display_name": "UDP" - } - ] -} \ No newline at end of file diff --git a/tests/unit/module_utils/fixtures/choices/sites.json b/tests/unit/module_utils/fixtures/choices/sites.json deleted file mode 100644 index 636289373..000000000 --- a/tests/unit/module_utils/fixtures/choices/sites.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "status": [ - { - "value": "active", - "display_name": "Active" - }, - { - "value": "planned", - "display_name": "Planned" - }, - { - "value": "retired", - "display_name": "Retired" - } - ] -} \ No newline at end of file diff --git a/tests/unit/module_utils/fixtures/choices/virtual_machines.json b/tests/unit/module_utils/fixtures/choices/virtual_machines.json deleted file mode 100644 index d4e781e8c..000000000 --- a/tests/unit/module_utils/fixtures/choices/virtual_machines.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "status": [ - { - "value": "active", - "display_name": "Active" - }, - { - "value": "offline", - "display_name": "Offline" - }, - { - "value": "staged", - "display_name": "Staged" - } - ] -} \ No newline at end of file diff --git a/tests/unit/module_utils/fixtures/choices/vlans.json b/tests/unit/module_utils/fixtures/choices/vlans.json deleted file mode 100644 index 1f0e6765f..000000000 --- a/tests/unit/module_utils/fixtures/choices/vlans.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "status": [ - { - "value": "active", - "display_name": "Active" - }, - { - "value": "reserved", - "display_name": "Reserved" - }, - { - "value": "deprecated", - "display_name": "Deprecated" - } - ] -} \ No newline at end of file diff --git a/tests/unit/module_utils/test_netbox_base_class.py b/tests/unit/module_utils/netbox_utils/test_netbox_module.py similarity index 86% rename from tests/unit/module_utils/test_netbox_base_class.py rename to tests/unit/module_utils/netbox_utils/test_netbox_module.py index 40bbadaa7..da73b5c7a 100644 --- a/tests/unit/module_utils/test_netbox_base_class.py +++ b/tests/unit/module_utils/netbox_utils/test_netbox_module.py @@ -7,10 +7,10 @@ __metaclass__ = type -import os +import re from functools import partial +from pathlib import Path from unittest.mock import MagicMock - import pytest try: @@ -20,7 +20,9 @@ from ansible_collections.netbox.netbox.plugins.module_utils.netbox_utils import ( NetboxModule, ) - from ansible_collections.netbox.netbox.tests.test_data import load_test_data + from ansible_collections.netbox.netbox.tests.unit.helpers.load_data import ( + load_test_data, + ) MOCKER_PATCH_PATH = "ansible_collections.netbox.netbox.plugins.module_utils.netbox_utils.NetboxModule" except ImportError: @@ -33,13 +35,11 @@ sys.path.append("tests") from netbox_dcim import NB_DEVICES from netbox_utils import NetboxModule - from test_data import load_test_data + from tests.unit.helpers.load_data import load_test_data MOCKER_PATCH_PATH = "netbox_utils.NetboxModule" -load_relative_test_data = partial( - load_test_data, os.path.dirname(os.path.abspath(__file__)) -) +load_relative_test_data = partial(load_test_data, Path(__file__).resolve().parent) @pytest.fixture @@ -63,6 +63,7 @@ def fixture_arg_spec(): "state": "present", "validate_certs": False, "cert": None, + "headers": None, } @@ -373,24 +374,29 @@ def test_update_netbox_object_with_changes_check_mode_true( assert diff == on_update_diff -@pytest.mark.parametrize("version", ["2.9", "2.8", "2.7"]) +@pytest.mark.parametrize("version", ["2.13", "2.12", "2.11", "2.10.8", "2.10"]) def test_version_check_greater_true(mock_netbox_module, nb_obj_mock, version): mock_netbox_module.nb_object = nb_obj_mock - assert mock_netbox_module._version_check_greater("2.10", version) + assert mock_netbox_module._version_check_greater(version, "2.9") + assert mock_netbox_module._version_check_greater(version, "2.9.11") -@pytest.mark.parametrize("version", ["2.13", "2.12", "2.11", "2.10"]) +@pytest.mark.parametrize("version", ["2.9", "2.8", "2.7.12", "2.7"]) def test_version_check_greater_false(mock_netbox_module, nb_obj_mock, version): mock_netbox_module.nb_object = nb_obj_mock - assert not mock_netbox_module._version_check_greater("2.10", version) + assert not mock_netbox_module._version_check_greater(version, "2.10") + assert not mock_netbox_module._version_check_greater(version, "2.10.8") -@pytest.mark.parametrize("version", ["2.9", "2.8", "2.7"]) +@pytest.mark.parametrize("version", ["2.9", "2.8", "2.7.5", "2.7"]) def test_version_check_greater_equal_to_true(mock_netbox_module, nb_obj_mock, version): mock_netbox_module.nb_object = nb_obj_mock assert mock_netbox_module._version_check_greater( version, "2.7", greater_or_equal=True ) + assert mock_netbox_module._version_check_greater( + version, "2.6.12", greater_or_equal=True + ) @pytest.mark.parametrize("version", ["2.6", "2.5", "2.4"]) @@ -399,3 +405,34 @@ def test_version_check_greater_equal_to_false(mock_netbox_module, nb_obj_mock, v assert not mock_netbox_module._version_check_greater( version, "2.7", greater_or_equal=True ) + assert not mock_netbox_module._version_check_greater( + version, "2.7.7", greater_or_equal=True + ) + + +@pytest.mark.parametrize( + "raw_value,expected", + [ + ("2.6", "2.6"), + ("2.6.", "2.6"), + ("4.2-dev", "4.2"), + ("4", "4"), + ("4-dev", "4"), + ("4.-dev", "4"), + ("4.2.9-Docker-3.2.1", "4.2.9"), + ("3.1.0-extra-info", "3.1.0"), + ("10.20.30foobar", "10.20.30"), + ], +) +def test_version_sanitize_to_true(mock_netbox_module, nb_obj_mock, raw_value, expected): + mock_netbox_module.nb_object = nb_obj_mock + sanitized = mock_netbox_module._version_sanitize(raw_value) + assert sanitized == expected + assert re.match(r"^\d+(\.\d+)*$", sanitized) + + +@pytest.mark.parametrize("version", [None, [], {}, "", "aa-dev", "-4", ".4", "dev-4"]) +def test_version_sanitize_value_error(mock_netbox_module, nb_obj_mock, version): + mock_netbox_module.nb_object = nb_obj_mock + with pytest.raises(ValueError): + mock_netbox_module._version_sanitize(version) diff --git a/tests/unit/module_utils/test_data/arg_spec_default/data.json b/tests/unit/module_utils/test_data/netbox_utils/arg_spec_default.json similarity index 100% rename from tests/unit/module_utils/test_data/arg_spec_default/data.json rename to tests/unit/module_utils/test_data/netbox_utils/arg_spec_default.json diff --git a/tests/unit/module_utils/test_data/build_query_params_child/data.json b/tests/unit/module_utils/test_data/netbox_utils/build_query_params_child.json similarity index 100% rename from tests/unit/module_utils/test_data/build_query_params_child/data.json rename to tests/unit/module_utils/test_data/netbox_utils/build_query_params_child.json diff --git a/tests/unit/module_utils/test_data/build_query_params_no_child/data.json b/tests/unit/module_utils/test_data/netbox_utils/build_query_params_no_child.json similarity index 100% rename from tests/unit/module_utils/test_data/build_query_params_no_child/data.json rename to tests/unit/module_utils/test_data/netbox_utils/build_query_params_no_child.json diff --git a/tests/unit/module_utils/test_data/build_query_params_user_query_params/data.json b/tests/unit/module_utils/test_data/netbox_utils/build_query_params_user_query_params.json similarity index 100% rename from tests/unit/module_utils/test_data/build_query_params_user_query_params/data.json rename to tests/unit/module_utils/test_data/netbox_utils/build_query_params_user_query_params.json diff --git a/tests/unit/module_utils/test_data/choices_id/data.json b/tests/unit/module_utils/test_data/netbox_utils/choices_id.json similarity index 100% rename from tests/unit/module_utils/test_data/choices_id/data.json rename to tests/unit/module_utils/test_data/netbox_utils/choices_id.json diff --git a/tests/unit/module_utils/test_data/find_app/data.json b/tests/unit/module_utils/test_data/netbox_utils/find_app.json similarity index 100% rename from tests/unit/module_utils/test_data/find_app/data.json rename to tests/unit/module_utils/test_data/netbox_utils/find_app.json diff --git a/tests/unit/module_utils/test_data/normalize_data/data.json b/tests/unit/module_utils/test_data/netbox_utils/normalize_data.json similarity index 100% rename from tests/unit/module_utils/test_data/normalize_data/data.json rename to tests/unit/module_utils/test_data/netbox_utils/normalize_data.json diff --git a/tests/unit/module_utils/test_data/slug/data.json b/tests/unit/module_utils/test_data/netbox_utils/slug.json similarity index 100% rename from tests/unit/module_utils/test_data/slug/data.json rename to tests/unit/module_utils/test_data/netbox_utils/slug.json