diff --git a/.gitignore b/.gitignore index ce4cdd28b..aac02bbee 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,8 @@ __pycache__/ *.pyc tests/output/* +venv/ +.vscode/ + +# https://github.com/ansible/ansible/issues/68499 +# ansible_collections/ diff --git a/.travis.yml b/.travis.yml index d65566e5c..0198ea335 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,7 +18,7 @@ jobs: # Previous release of Netbox, latest release of Ansible - name: "Python 3.6 - Netbox 2.6 - Latest PyPi Ansible" python: 3.6 - env: PYTHON_VER=3.6 VERSION=v2.6 + env: PYTHON_VER=3.6 VERSION=v2.6 INTEGRATION_TESTS=v2.6 install: - cd .. # Setup netbox container for integration testing @@ -27,15 +27,16 @@ jobs: - docker-compose pull - docker-compose up -d - cd .. - - pip install -U pip + # setuptools <46.1.3 has issues with ansible-test executables https://github.com/ansible/ansible/issues/68963 + - pip install -U pip "setuptools>=46.1.3" # coverage 5.0 is not compatible with ansible-test https://github.com/ansible/ansible/issues/65907 - pip install pytest==4.6.5 pytest-mock pytest-xdist jinja2 PyYAML black==19.10b0 "coverage<5" - - pip install pynetbox cryptography codecov jmespath ansible + - pip install pynetbox cryptography codecov jmespath jsondiff ansible - # Latest release of Netbox and Ansible - name: "Python 3.6 - Netbox 2.7 - Latest PyPi Ansible" python: 3.6 - env: PYTHON_VER=3.6 VERSION=v2.7 + env: + - PYTHON_VER=3.6 VERSION=v2.7 INTEGRATION_TESTS=latest install: - cd .. # Setup netbox container for integration testing @@ -44,16 +45,35 @@ jobs: - docker-compose pull - docker-compose up -d - cd .. - - pip install -U pip + - pip install -U pip "setuptools>=46.1.3" - pip install pytest==4.6.5 pytest-mock pytest-xdist jinja2 PyYAML black==19.10b0 "coverage<5" - - pip install pynetbox cryptography codecov jmespath ansible + - pip install pynetbox cryptography codecov jmespath jsondiff ansible + + # Stick to python 3.7 instead of 3.8, as ansible-test sanity is not compatible with 3.7 + # https://github.com/ansible/ansible/issues/67118 + + - name: "Python 3.7 - Netbox 2.8 - Latest PyPi Ansible" + python: 3.7 + env: + - PYTHON_VER=3.7 VERSION=v2.8 INTEGRATION_TESTS=latest + install: + - cd .. + # Setup netbox container for integration testing + - git clone https://github.com/netbox-community/netbox-docker.git + - cd netbox-docker + - docker-compose pull + - docker-compose up -d + - cd .. + - pip install -U pip "setuptools>=46.1.3" + - pip install pytest==4.6.5 pytest-mock pytest-xdist jinja2 PyYAML black==19.10b0 "coverage<5" + - pip install pynetbox cryptography codecov jmespath jsondiff ansible # Latest development versions of Netbox and Ansible, newest Python # This may be broken sometimes by changes in the netbox & ansible projects # Failures will be allowed in this build - - name: "Python 3.8 - Netbox develop-2.8 - Ansible Devel" + - name: "Python 3.8 - Netbox develop branch (snapshot) - Ansible Devel" python: 3.8 - env: PYTHON_VER=3.8 VERSION=develop-2.8 + env: PYTHON_VER=3.8 VERSION=snapshot INTEGRATION_TESTS=latest install: - cd .. # Setup netbox container for integration testing @@ -62,16 +82,16 @@ jobs: - docker-compose pull - docker-compose up -d - cd .. - - pip install -U pip + - pip install -U pip "setuptools>=46.1.3" - pip install pytest==4.6.5 pytest-mock pytest-xdist jinja2 PyYAML black==19.10b0 "coverage<5" - - pip install pynetbox cryptography jmespath + - pip install pynetbox cryptography jmespath jsondiff - git clone https://github.com/ansible/ansible.git - cd ansible - source hacking/env-setup - cd .. allow_failures: # When testing against dev netbox and dev ansible, allow failures - - env: PYTHON_VER=3.8 VERSION=develop-2.8 + - env: PYTHON_VER=3.8 VERSION=snapshot INTEGRATION_TESTS=latest before_script: - mkdir -p ~/ansible_collections/$COLLECTION_NAMESPACE @@ -80,31 +100,47 @@ before_script: - ansible-galaxy collection build . - ansible-galaxy collection install $COLLECTION_NAMESPACE-$COLLECTION_NAME-$COLLECTION_VERSION.tar.gz -p /home/travis/.ansible/collections + # Run all further tests from within the installed directory + # Required to resolve imports of other collections + - cd /home/travis/.ansible/collections/ansible_collections/$COLLECTION_NAMESPACE/$COLLECTION_NAME + + # Set runme.sh execute permissions stripped by ansible-galaxy. Should be fixed in Ansible 2.10 + # https://github.com/ansible/ansible/issues/68415 + - chmod +x tests/integration/targets/inventory/runme.sh + - chmod +x tests/integration/targets/inventory/compare_inventory_json.py + script: - # Perform unit tests on collection from within the installed directory, not the source directory - # Required for imports of other collections (ie. ansible.netcommon) to work correctly - - (cd /home/travis/.ansible/collections/ansible_collections/$COLLECTION_NAMESPACE/$COLLECTION_NAME && ansible-test units --coverage --python $PYTHON_VER -v) # Check python syntax - black . --check --diff + # Sanity tests + # --requirements - install pip packages as necessary + # Skip pep8 as we use black instead + # Skip validate-modules until the issues can be resolved #180 + - ansible-test sanity -v --requirements --python $PYTHON_VER --skip-test pep8 --skip-test validate-modules + + # Unit tests, with code coverage + - ansible-test units -v --coverage --python $PYTHON_VER + # Wait for Netbox containers to be running - timeout 300 bash -c 'while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' localhost:32768)" != "200" ]]; do echo "waiting for Netbox"; sleep 5; done' || false # Prepare data in Netbox - - python tests/integration/netbox-deploy.py + - ./tests/integration/netbox-deploy.py # Run regression and integration tests - - ansible-playbook tests/integration/regression-tests.yml -vvvv - - ansible-playbook tests/integration/$VERSION/main.yml -vvvv - - ansible-inventory -i tests/integration/test-inventory.yml --list + # Run the inventory test first, in case any of the other tests modify the data. + - ansible-test integration -v --coverage --python $PYTHON_VER inventory + - ansible-test integration -v --coverage --python $PYTHON_VER regression + - ansible-test integration -v --coverage --python $PYTHON_VER $INTEGRATION_TESTS # Report code coverage - - (cd /home/travis/.ansible/collections/ansible_collections/$COLLECTION_NAMESPACE/$COLLECTION_NAME && ansible-test coverage report) + - ansible-test coverage report --all --omit "tests/*,hacking/*" --show-missing deploy: provider: script skip_cleanup: true - script: ansible-galaxy collection publish $COLLECTION_NAMESPACE-$COLLECTION_NAME-$COLLECTION_VERSION.tar.gz --api-key="$GALAXY_API_TOKEN" + script: ansible-galaxy collection publish ~/ansible_collections/$COLLECTION_NAMESPACE/$COLLECTION_NAME/$COLLECTION_NAMESPACE-$COLLECTION_NAME-$COLLECTION_VERSION.tar.gz --api-key="$GALAXY_API_TOKEN" on: tags: true diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 28493d8ba..3943742df 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,5 +1,7 @@ # Contributing +## Modules + The structure of the Netbox modules attempts to follow the layout of the Netbox API by having a module_util for each application (`dcim, ipam, tenancy, etc`) that inherits from a base module (`NetboxModule - netbox_utils.py`) and then implements the specific endpoints within the correct application module. e.g. Add logic for adding devices under netbox_dcim.py or ip addresses under netbox_ipam.py @@ -257,7 +259,7 @@ Copying an existing module that has close to the same options is typically the p - Change the author: `Copyright: (c) 2018, Mikhail Yohman (@FragmentedPacket) ` - Update the **DOCUMENTATION**/**EXAMPLES**/**RETURN** string with the necessary information - Main things are module, descriptions, author, version and the sub options under data - - The **RETURN** should return the singluar of the endpoint name (done dynamically, but needs to be documented correctly) + - The **RETURN** should return the singular of the endpoint name (done dynamically, but needs to be documented correctly) - Update the module_util, module, and endpoint variable for the endpoint ```python @@ -296,3 +298,50 @@ Copying an existing module that has close to the same options is typically the p - Run `black .` within the base directory for black formatting as it's required for tests to pass - Run `ansible-lint integration-tests.yml` it's required for tests to pass - Check necessary dependencies defined within `.travis.yml` for now if you're wanting to test locally + + +## Inventory + +Integration tests are run by comparing `ansible-inventory --list` against known output, for a few different inventory files with different options. + +When the inventory plugin is updated in a way that changes this output (or `netbox-deploy.py` is changed), the test data used for comparison will need to be updated. There is a script `./hacking/update_test_inventories.sh` to do this. + +Run from the root project working directory, and make sure you have a clean test instance of Netbox set up with test data loaded into it from `./tests/integration/netbox-deploy.py` + +``` +./hacking/update_test_inventories.sh +``` + +After running the script, to prevent introducing a regression you'll need to manually read through the diff to verify it looks correct. + + +# Setting up a local dev/test environment + +You can see the specific details of what happens in CI in `.travis.yml`. An overview of what you need to do is: + +* Run a test instance of Netbox on port 32768. The `netbox-docker` project makes this easy. + +``` +git clone git@github.com:netbox-community/netbox-docker.git +cd netbox-docker +export VERSION=snapshot +docker-compose pull +docker-compose up -d +``` + +* Check out this repo to a directory named `netbox` in a directory tree `ansible_collections/netbox/netbox` - running some `ansible-test` commands will complain if there's no `ansible_collections` in the current directory path, so you'd have to build/install the collection every time you want to run tests. + +``` +git clone git@github.com:netbox-community/ansible_modules.git ansible_collections/netbox/netbox +``` + +* Recommended - set up a Python virtualenv, in a directory above the collection. If you create a virtualenv inside the `ansible_modules` working directory `ansible-galaxy collection build` will include it as part of the build (until Ansible 2.10 where `build_ignore` is supported) + +``` +cd ../../.. +python3 -m venv venv +source venv/bin/activate +cd ansible_collections/netbox/netbox +``` + +* Install required python packages - see `.travis.yml` for the latest `pip install` list in different environments. diff --git a/ansible.cfg b/ansible.cfg index cececd096..4501b1d8b 100644 --- a/ansible.cfg +++ b/ansible.cfg @@ -1,2 +1,5 @@ +[defaults] +force_valid_group_names = always + [inventory] -enable_plugins = netbox.netbox.nb_inventory, auto, host_list, yaml, ini, toml, script +enable_plugins = netbox.netbox.nb_inventory, auto, host_list, yaml, ini, toml, script diff --git a/galaxy.yml b/galaxy.yml index 8967e0422..1174cf65c 100644 --- a/galaxy.yml +++ b/galaxy.yml @@ -46,8 +46,12 @@ tags: # L(specifiers,https://python-semanticversion.readthedocs.io/en/latest/#requirement-specification). Multiple version # range specifiers can be set and are separated by ',' dependencies: + # Required for ipaddress python library ansible.netcommon: "*" + # Required for json_query used in lookup plugin integration tests + community.general: "*" + # The URL of the originating SCM repository repository: https://github.com/netbox-community/ansible_modules @@ -59,3 +63,13 @@ homepage: # The URL to the collection issue tracker issues: https://github.com/netbox-community/ansible_modules/issues + +# Files to ignore when building collection. Only supported when building with Ansible 2.10 +# https://github.com/ansible/ansible/issues/67543 +# https://docs.ansible.com/ansible/devel/dev_guide/developing_collections.html#ignoring-files-and-folders +build_ignore: +- venv +- ansible_collections +- tests/output +- .pytest_cache +- .vscode diff --git a/hacking/black.sh b/hacking/black.sh new file mode 100755 index 000000000..e095f9116 --- /dev/null +++ b/hacking/black.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash + +# Usage: ./hacking/black.sh + +# Run black to reformat all python code +black . --exclude "ansible_collections|venv" diff --git a/hacking/build.sh b/hacking/build.sh new file mode 100755 index 000000000..c77c7a243 --- /dev/null +++ b/hacking/build.sh @@ -0,0 +1,20 @@ +#!/usr/bin/env bash + +# Usage: ./hacking/build.sh + +# galaxy.yml build_ignore is not implemented in Ansible 2.9, so we have to delete files we don't want + +# Remove previous test installs +rm -r ansible_collections + +# Remove old built versions +rm netbox-netbox-*.tar.gz + +# Remove test output +rm -r tests/output +rm -r .pytest_cache + +ansible-galaxy collection build --force --verbose . + +# To verify what files have been included in the build: +# tar --gunzip --list --file netbox-netbox-*.tar.gz diff --git a/scripts/get_inventory_query_parameters.py b/hacking/get_inventory_query_parameters.py similarity index 81% rename from scripts/get_inventory_query_parameters.py rename to hacking/get_inventory_query_parameters.py index d54421c82..91c38c571 100755 --- a/scripts/get_inventory_query_parameters.py +++ b/hacking/get_inventory_query_parameters.py @@ -1,10 +1,15 @@ -#!/usr/bin/env python3 +#!/usr/bin/env python # Usage: ./get_inventory_query_filters.py https://netbox/api/docs/?format=openapi +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + import sys import json import urllib.request +from ansible.module_utils.urls import open_url def get_parameters(data, path): @@ -23,7 +28,7 @@ def get_parameters(data, path): print("Getting from %s" % url, file=sys.stderr) -response = urllib.request.urlopen(url) +response = open_url(url) data = json.load(response) print("ALLOWED_DEVICE_QUERY_PARAMETERS = (") diff --git a/hacking/local-test.sh b/hacking/local-test.sh new file mode 100755 index 000000000..325f51d05 --- /dev/null +++ b/hacking/local-test.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash + +# Usage: ./hacking/local-test.sh + +# Run build, which will remove previously installed versions +./hacking/build.sh + +# Install new built version +ansible-galaxy collection install netbox-netbox-*.tar.gz -p . + +# You can now cd into the installed version and run tests +(cd ansible_collections/netbox/netbox/ && ansible-test units -v --python 3.6) diff --git a/hacking/update_test_inventories.sh b/hacking/update_test_inventories.sh new file mode 100755 index 000000000..74f95cf42 --- /dev/null +++ b/hacking/update_test_inventories.sh @@ -0,0 +1,20 @@ +#!/usr/bin/env bash + +# Stop on failure - if unit tests fail the inventory will not be updated +set -e + +# Usage overview (see Contributing.md for more detail): +# - Run netbox with the netbox-docker project +# - Fill with test data, run ./tests/integration/netbox-deploy.py +# - Run ./hacking/update_test_inventories.sh +# - Manually verify the diff of new JSON is correct, to prevent introducing a regression. + +# Install locally +export ANSIBLE_COLLECTIONS_PATHS=. +export OUTPUT_INVENTORY_JSON=tests/integration/targets/inventory/files + +# Clean and install the built collection +./hacking/local-test.sh + +# Run the same script used by integration tests, but save the results +./tests/integration/targets/inventory/runme.sh diff --git a/plugins/inventory/nb_inventory.py b/plugins/inventory/nb_inventory.py index c7f10c364..c67c7a3b4 100644 --- a/plugins/inventory/nb_inventory.py +++ b/plugins/inventory/nb_inventory.py @@ -50,6 +50,12 @@ # in order of precedence - name: NETBOX_TOKEN - name: NETBOX_API_KEY + plurals: + description: + - If True, all host vars are contained inside single-element arrays for legacy compatibility. Group names will be plural (ie. "sites_mysite" instead of "site_mysite") + default: True + type: boolean + version_added: "0.2.1" interfaces: description: - If True, it adds the device or virtual machine interface information in host vars. @@ -63,17 +69,26 @@ type: boolean version_added: "0.2.0" group_by: - description: Keys used to create groups. + description: Keys used to create groups. The 'plurals' option controls which of these are valid. type: list choices: - sites + - site - tenants + - tenant - racks + - rack - tags + - tag - device_roles + - role - device_types + - device_type - manufacturers + - manufacturer - platforms + - platform + - region default: [] group_names_raw: description: Will not add the group_by choice name to the group names @@ -160,7 +175,7 @@ ) # List of parameters fetched from /api/docs/?format=openapi -# Use scripts/get_inventory_query_parameters.py to update this +# Use hacking/get_inventory_query_parameters.py to update this ALLOWED_DEVICE_QUERY_PARAMETERS = ( "asset_tag", @@ -461,23 +476,54 @@ def get_resource_list(self, api_url): @property def group_extractors(self): - return { - "sites": self.extract_site, - "tenants": self.extract_tenant, - "racks": self.extract_rack, - "tags": self.extract_tags, - "disk": self.extract_disk, - "memory": self.extract_memory, - "vcpus": self.extract_vcpus, - "device_roles": self.extract_device_role, - "platforms": self.extract_platform, - "device_types": self.extract_device_type, - "services": self.extract_services, - "config_context": self.extract_config_context, - "manufacturers": self.extract_manufacturer, - "interfaces": self.extract_interfaces, - "custom_fields": self.extract_custom_fields, - } + + # List of group_by options and hostvars to extract + # Keys are different depending on plurals option + if self.plurals: + return { + "sites": self.extract_site, + "tenants": self.extract_tenant, + "racks": self.extract_rack, + "tags": self.extract_tags, + "disk": self.extract_disk, + "memory": self.extract_memory, + "vcpus": self.extract_vcpus, + "device_roles": self.extract_device_role, + "platforms": self.extract_platform, + "device_types": self.extract_device_type, + "services": self.extract_services, + "config_context": self.extract_config_context, + "manufacturers": self.extract_manufacturer, + "interfaces": self.extract_interfaces, + "custom_fields": self.extract_custom_fields, + "region": self.extract_regions, + } + else: + return { + "site": self.extract_site, + "tenant": self.extract_tenant, + "rack": self.extract_rack, + "tag": self.extract_tags, + "disk": self.extract_disk, + "memory": self.extract_memory, + "vcpus": self.extract_vcpus, + "role": self.extract_device_role, + "platform": self.extract_platform, + "device_type": self.extract_device_type, + "services": self.extract_services, + "config_context": self.extract_config_context, + "manufacturer": self.extract_manufacturer, + "interfaces": self.extract_interfaces, + "custom_fields": self.extract_custom_fields, + "region": self.extract_regions, + } + + def _pluralize(self, extracted_value): + # If plurals is enabled, wrap in a single-element list for backwards compatibility + if self.plurals: + return [extracted_value] + else: + return extracted_value def extract_disk(self, host): return host.get("disk") @@ -490,7 +536,7 @@ def extract_memory(self, host): def extract_platform(self, host): try: - return [self.platforms_lookup[host["platform"]["id"]]] + return self._pluralize(self.platforms_lookup[host["platform"]["id"]]) except Exception: return @@ -509,48 +555,50 @@ def extract_services(self, host): def extract_device_type(self, host): try: - return [self.device_types_lookup[host["device_type"]["id"]]] + return self._pluralize(self.device_types_lookup[host["device_type"]["id"]]) except Exception: return def extract_rack(self, host): try: - return [self.racks_lookup[host["rack"]["id"]]] + return self._pluralize(self.racks_lookup[host["rack"]["id"]]) except Exception: return def extract_site(self, host): try: - return [self.sites_lookup[host["site"]["id"]]] + return self._pluralize(self.sites_lookup[host["site"]["id"]]) except Exception: return def extract_tenant(self, host): try: - return [self.tenants_lookup[host["tenant"]["id"]]] + return self._pluralize(self.tenants_lookup[host["tenant"]["id"]]) except Exception: return def extract_device_role(self, host): try: if "device_role" in host: - return [self.device_roles_lookup[host["device_role"]["id"]]] + return self._pluralize( + self.device_roles_lookup[host["device_role"]["id"]] + ) elif "role" in host: - return [self.device_roles_lookup[host["role"]["id"]]] + return self._pluralize(self.device_roles_lookup[host["role"]["id"]]) except Exception: return def extract_config_context(self, host): try: - return [host["config_context"]] + return self._pluralize(host["config_context"]) except Exception: return def extract_manufacturer(self, host): try: - return [ + return self._pluralize( self.manufacturers_lookup[host["device_type"]["manufacturer"]["id"]] - ] + ) except Exception: return @@ -638,6 +686,39 @@ def extract_custom_fields(self, host): except Exception: return + def extract_regions(self, host): + # A host may have a site. A site may have a region. A region may have a parent region. + # Produce a list of regions: + # - it will be empty if the device has no site, or the site has no region set + # - it will have 1 element if the site's region has no parent + # - it will have multiple elements if the site's region has a parent region + + site = host.get("site", None) + if not isinstance(site, dict): + # Device has no site + return [] + + site_id = site.get("id", None) + if site_id is None: + # Device has no site + return [] + + regions = [] + region_id = self.sites_region_lookup[site_id] + + # Keep looping until the region has no parent + while region_id is not None: + region_slug = self.regions_lookup[region_id] + if region_slug in regions: + # Won't ever happen - defensively guard against infinite loop + break + regions.append(region_slug) + + # Get the parent of this region + region_id = self.regions_parent_lookup[region_id] + + return regions + def refresh_platforms_lookup(self): url = self.api_endpoint + "/api/dcim/platforms/?limit=0" platforms = self.get_resource_list(api_url=url) @@ -650,11 +731,35 @@ def refresh_sites_lookup(self): sites = self.get_resource_list(api_url=url) self.sites_lookup = dict((site["id"], site["slug"]) for site in sites) + def get_region_for_site(site): + # Will fail if site does not have a region defined in Netbox + try: + return (site["id"], site["region"]["id"]) + except Exception: + return (site["id"], None) + + # Dictionary of site id to region id + self.sites_region_lookup = dict( + filter(lambda x: x is not None, map(get_region_for_site, sites)) + ) + def refresh_regions_lookup(self): url = self.api_endpoint + "/api/dcim/regions/?limit=0" regions = self.get_resource_list(api_url=url) self.regions_lookup = dict((region["id"], region["slug"]) for region in regions) + def get_region_parent(region): + # Will fail if region does not have a parent region + try: + return (region["id"], region["parent"]["id"]) + except Exception: + return (region["id"], None) + + # Dictionary of region id to parent region id + self.regions_parent_lookup = dict( + filter(lambda x: x is not None, map(get_region_parent, regions)) + ) + def refresh_tenants_lookup(self): url = self.api_endpoint + "/api/tenancy/tenants/?limit=0" tenants = self.get_resource_list(api_url=url) @@ -820,42 +925,131 @@ def extract_name(self, host): # We default to an UUID for hostname in case the name is not set in NetBox return host["name"] or str(uuid.uuid4()) + def generate_group_name(self, grouping, group): + if self.group_names_raw: + return group + else: + return "_".join([grouping, group]) + def add_host_to_groups(self, host, hostname): - for group in self.group_by: - sub_groups = self.group_extractors[group](host) - if not sub_groups: + # If we're grouping by regions, hosts are not added to region groups + # - the site groups are added as sub-groups of regions + # So, we need to make sure we're also grouping by sites if regions are enabled + + if "region" in self.group_by: + # Make sure "site" or "sites" grouping also exists, depending on plurals options + if self.plurals and "sites" not in self.group_by: + self.group_by.append("sites") + elif not self.plurals and "site" not in self.group_by: + self.group_by.append("site") + + for grouping in self.group_by: + + # Don't handle regions here - that will happen in main() + if grouping == "region": continue - for sub_group in sub_groups: - if self.group_names_raw: - group_name = sub_group - else: - group_name = "_".join([group, sub_group]) - self.inventory.add_group(group=group_name) - self.inventory.add_host(group=group_name, host=hostname) + if grouping not in self.group_extractors: + raise AnsibleError( + 'group_by option "%s" is not valid. (Maybe check the plurals option? It can determine what group_by options are valid)' + % grouping + ) - def _fill_host_variables(self, host, hostname): - for attribute, extractor in self.group_extractors.items(): - if not extractor(host): + groups_for_host = self.group_extractors[grouping](host) + + if not groups_for_host: continue - self.inventory.set_variable(hostname, attribute, extractor(host)) - if self.extract_primary_ip(host): - self.inventory.set_variable( - hostname, "ansible_host", self.extract_primary_ip(host=host) + # Make groups_for_host a list if it isn't already + if not isinstance(groups_for_host, list): + groups_for_host = [groups_for_host] + + for group_for_host in groups_for_host: + group_name = self.generate_group_name(grouping, group_for_host) + + # Group names may be transformed by the ansible TRANSFORM_INVALID_GROUP_CHARS setting + # add_group returns the actual group name used + transformed_group_name = self.inventory.add_group(group=group_name) + self.inventory.add_host(group=transformed_group_name, host=hostname) + + def _add_region_groups(self): + + # Mapping of region id to group name + region_transformed_group_names = dict() + + # Create groups for each region + for region_id in self.regions_lookup: + region_group_name = self.generate_group_name( + "region", self.regions_lookup[region_id] ) + region_transformed_group_names[region_id] = self.inventory.add_group( + group=region_group_name + ) + + # Now that all region groups exist, add relationships between them + for region_id in self.regions_lookup: + region_group_name = region_transformed_group_names[region_id] + parent_region_id = self.regions_parent_lookup.get(region_id, None) + if ( + parent_region_id is not None + and parent_region_id in region_transformed_group_names + ): + parent_region_name = region_transformed_group_names[parent_region_id] + self.inventory.add_child(parent_region_name, region_group_name) + + # Add site groups as children of region groups + for site_id in self.sites_lookup: + region_id = self.sites_region_lookup.get(site_id, None) + if region_id is None: + continue - if self.extract_primary_ip4(host): - self.inventory.set_variable( - hostname, "primary_ip4", self.extract_primary_ip4(host=host) + region_transformed_group_name = region_transformed_group_names[region_id] + + site_name = self.sites_lookup[site_id] + site_group_name = self.generate_group_name( + "sites" if self.plurals else "site", site_name + ) + # Add the site group to get its transformed name + # Will already be created by add_host_to_groups - it's ok to call add_group again just to get its name + site_transformed_group_name = self.inventory.add_group( + group=site_group_name ) - if self.extract_primary_ip6(host): - self.inventory.set_variable( - hostname, "primary_ip6", self.extract_primary_ip6(host=host) + self.inventory.add_child( + region_transformed_group_name, site_transformed_group_name ) + def _fill_host_variables(self, host, hostname): + for attribute, extractor in self.group_extractors.items(): + extracted_value = extractor(host) + + # Compare with None, not just check for a truth comparison - allow empty arrays, etc to be host vars + if extracted_value is None: + continue + + # Special case - all group_by options are single strings, but tag is a list of tags + # Keep the groups named singular "tag_sometag", but host attribute should be "tags":["sometag", "someothertag"] + if attribute == "tag": + attribute = "tags" + + if attribute == "region": + attribute = "regions" + + self.inventory.set_variable(hostname, attribute, extracted_value) + + extracted_primary_ip = self.extract_primary_ip(host=host) + if extracted_primary_ip: + self.inventory.set_variable(hostname, "ansible_host", extracted_primary_ip) + + extracted_primary_ip4 = self.extract_primary_ip4(host=host) + if extracted_primary_ip4: + self.inventory.set_variable(hostname, "primary_ip4", extracted_primary_ip4) + + extracted_primary_ip6 = self.extract_primary_ip6(host=host) + if extracted_primary_ip6: + self.inventory.set_variable(hostname, "primary_ip6", extracted_primary_ip6) + def main(self): self.refresh_lookups() hosts_list = self.fetch_hosts() @@ -883,6 +1077,10 @@ def main(self): ) self.add_host_to_groups(host=host, hostname=hostname) + # Create groups for regions, containing the site groups + if "region" in self.group_by: + self._add_region_groups() + def parse(self, inventory, loader, path, cache=True): super(InventoryModule, self).parse(inventory, loader, path) self._read_config_data(path=path) @@ -895,6 +1093,7 @@ def parse(self, inventory, loader, path, cache=True): self.timeout = self.get_option("timeout") self.validate_certs = self.get_option("validate_certs") self.config_context = self.get_option("config_context") + self.plurals = self.get_option("plurals") self.interfaces = self.get_option("interfaces") self.services = self.get_option("services") self.headers = { diff --git a/plugins/lookup/nb_lookup.py b/plugins/lookup/nb_lookup.py index be67d7aa0..456e4b138 100644 --- a/plugins/lookup/nb_lookup.py +++ b/plugins/lookup/nb_lookup.py @@ -73,7 +73,7 @@ api_endpoint='http://localhost/', token='') }}" -This example uses an API Filter +# This example uses an API Filter tasks: # query a list of devices diff --git a/plugins/module_utils/netbox_ipam.py b/plugins/module_utils/netbox_ipam.py index ddfd921d7..49aed7db2 100644 --- a/plugins/module_utils/netbox_ipam.py +++ b/plugins/module_utils/netbox_ipam.py @@ -7,7 +7,7 @@ # Import necessary packages import traceback -from ansible.module_utils.compat import ipaddress +from ansible_collections.ansible.netcommon.plugins.module_utils.compat import ipaddress from ansible.module_utils._text import to_text from ansible.module_utils.basic import missing_required_lib diff --git a/plugins/module_utils/netbox_utils.py b/plugins/module_utils/netbox_utils.py index fbd432648..66a1384fa 100644 --- a/plugins/module_utils/netbox_utils.py +++ b/plugins/module_utils/netbox_utils.py @@ -3,6 +3,8 @@ # Copyright: (c) 2018, David Gomez (@amb1s1) # 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 necessary packages diff --git a/plugins/modules/netbox_aggregate.py b/plugins/modules/netbox_aggregate.py index ffce1bf5a..8236ad66a 100644 --- a/plugins/modules/netbox_aggregate.py +++ b/plugins/modules/netbox_aggregate.py @@ -47,7 +47,7 @@ rir: description: - The RIR the aggregate will be assigned to - required:true + required: true date_added: description: - Date added, format: YYYY-MM-DD @@ -164,5 +164,5 @@ def main(): netbox_aggregate.run() -if __name__ == "__main__": +if __name__ == "__main__": # pragma: no cover main() diff --git a/plugins/modules/netbox_circuit.py b/plugins/modules/netbox_circuit.py index 7bdea311c..cef2c8526 100644 --- a/plugins/modules/netbox_circuit.py +++ b/plugins/modules/netbox_circuit.py @@ -206,5 +206,5 @@ def main(): netbox_circuit.run() -if __name__ == "__main__": +if __name__ == "__main__": # pragma: no cover main() diff --git a/plugins/modules/netbox_circuit_termination.py b/plugins/modules/netbox_circuit_termination.py index afcf21bea..b1ec09f72 100644 --- a/plugins/modules/netbox_circuit_termination.py +++ b/plugins/modules/netbox_circuit_termination.py @@ -182,5 +182,5 @@ def main(): netbox_circuit_termination.run() -if __name__ == "__main__": +if __name__ == "__main__": # pragma: no cover main() diff --git a/plugins/modules/netbox_circuit_type.py b/plugins/modules/netbox_circuit_type.py index c0df861c3..dce387177 100644 --- a/plugins/modules/netbox_circuit_type.py +++ b/plugins/modules/netbox_circuit_type.py @@ -129,5 +129,5 @@ def main(): netbox_circuit_type.run() -if __name__ == "__main__": +if __name__ == "__main__": # pragma: no cover main() diff --git a/plugins/modules/netbox_cluster.py b/plugins/modules/netbox_cluster.py index 94e34e0b3..bf3ac8d0c 100644 --- a/plugins/modules/netbox_cluster.py +++ b/plugins/modules/netbox_cluster.py @@ -177,5 +177,5 @@ def main(): netbox_cluster.run() -if __name__ == "__main__": +if __name__ == "__main__": # pragma: no cover main() diff --git a/plugins/modules/netbox_cluster_group.py b/plugins/modules/netbox_cluster_group.py index e9c24d504..5a807e812 100644 --- a/plugins/modules/netbox_cluster_group.py +++ b/plugins/modules/netbox_cluster_group.py @@ -129,5 +129,5 @@ def main(): netbox_cluster_group.run() -if __name__ == "__main__": +if __name__ == "__main__": # pragma: no cover main() diff --git a/plugins/modules/netbox_cluster_type.py b/plugins/modules/netbox_cluster_type.py index 3d7f56c65..6a91645d8 100644 --- a/plugins/modules/netbox_cluster_type.py +++ b/plugins/modules/netbox_cluster_type.py @@ -129,5 +129,5 @@ def main(): netbox_cluster_type.run() -if __name__ == "__main__": +if __name__ == "__main__": # pragma: no cover main() diff --git a/plugins/modules/netbox_device.py b/plugins/modules/netbox_device.py index cb18dfe95..0e046f7a2 100644 --- a/plugins/modules/netbox_device.py +++ b/plugins/modules/netbox_device.py @@ -263,5 +263,5 @@ def main(): netbox_device.run() -if __name__ == "__main__": +if __name__ == "__main__": # pragma: no cover main() diff --git a/plugins/modules/netbox_device_bay.py b/plugins/modules/netbox_device_bay.py index a80c8b042..b4bed6c37 100644 --- a/plugins/modules/netbox_device_bay.py +++ b/plugins/modules/netbox_device_bay.py @@ -159,5 +159,5 @@ def main(): netbox_device_bay.run() -if __name__ == "__main__": +if __name__ == "__main__": # pragma: no cover main() diff --git a/plugins/modules/netbox_device_interface.py b/plugins/modules/netbox_device_interface.py index fe5f63dea..937bea3f2 100644 --- a/plugins/modules/netbox_device_interface.py +++ b/plugins/modules/netbox_device_interface.py @@ -273,5 +273,5 @@ def main(): netbox_device_interface.run() -if __name__ == "__main__": +if __name__ == "__main__": # pragma: no cover main() diff --git a/plugins/modules/netbox_device_role.py b/plugins/modules/netbox_device_role.py index bbd875417..8bfde0cdb 100644 --- a/plugins/modules/netbox_device_role.py +++ b/plugins/modules/netbox_device_role.py @@ -87,7 +87,7 @@ netbox_url: http://netbox.local netbox_token: thisIsMyToken data: - name: Test Rack role + name: Test Rack role state: absent """ @@ -141,5 +141,5 @@ def main(): netbox_device_role.run() -if __name__ == "__main__": +if __name__ == "__main__": # pragma: no cover main() diff --git a/plugins/modules/netbox_device_type.py b/plugins/modules/netbox_device_type.py index 5f03912ed..b12e37d25 100644 --- a/plugins/modules/netbox_device_type.py +++ b/plugins/modules/netbox_device_type.py @@ -191,5 +191,5 @@ def main(): netbox_device_type.run() -if __name__ == "__main__": +if __name__ == "__main__": # pragma: no cover main() diff --git a/plugins/modules/netbox_interface.py b/plugins/modules/netbox_interface.py index 552841235..5c5dddfb6 100644 --- a/plugins/modules/netbox_interface.py +++ b/plugins/modules/netbox_interface.py @@ -358,5 +358,5 @@ def ensure_interface_absent(nb, nb_endpoint, data): return result -if __name__ == "__main__": +if __name__ == "__main__": # pragma: no cover main() diff --git a/plugins/modules/netbox_inventory_item.py b/plugins/modules/netbox_inventory_item.py index 617cfe234..b4e38c092 100644 --- a/plugins/modules/netbox_inventory_item.py +++ b/plugins/modules/netbox_inventory_item.py @@ -183,5 +183,5 @@ def main(): netbox_inventory_item.run() -if __name__ == "__main__": +if __name__ == "__main__": # pragma: no cover main() diff --git a/plugins/modules/netbox_ip_address.py b/plugins/modules/netbox_ip_address.py index e06e7714c..0d413c632 100644 --- a/plugins/modules/netbox_ip_address.py +++ b/plugins/modules/netbox_ip_address.py @@ -301,5 +301,5 @@ def main(): netbox_ip_address.run() -if __name__ == "__main__": +if __name__ == "__main__": # pragma: no cover main() diff --git a/plugins/modules/netbox_ipam_role.py b/plugins/modules/netbox_ipam_role.py index 7dd17a572..0b26f7a1c 100644 --- a/plugins/modules/netbox_ipam_role.py +++ b/plugins/modules/netbox_ipam_role.py @@ -79,7 +79,7 @@ netbox_url: http://netbox.local netbox_token: thisIsMyToken data: - name: Test IPAM Role + name: Test IPAM Role state: present - name: Delete ipam role within netbox @@ -141,5 +141,5 @@ def main(): netbox_ipam_role.run() -if __name__ == "__main__": +if __name__ == "__main__": # pragma: no cover main() diff --git a/plugins/modules/netbox_manufacturer.py b/plugins/modules/netbox_manufacturer.py index 5acca2da9..79b43c1a7 100644 --- a/plugins/modules/netbox_manufacturer.py +++ b/plugins/modules/netbox_manufacturer.py @@ -129,5 +129,5 @@ def main(): netbox_manufacturer.run() -if __name__ == "__main__": +if __name__ == "__main__": # pragma: no cover main() diff --git a/plugins/modules/netbox_platform.py b/plugins/modules/netbox_platform.py index 5e3795d3d..d246def1b 100644 --- a/plugins/modules/netbox_platform.py +++ b/plugins/modules/netbox_platform.py @@ -154,5 +154,5 @@ def main(): netbox_platform.run() -if __name__ == "__main__": +if __name__ == "__main__": # pragma: no cover main() diff --git a/plugins/modules/netbox_prefix.py b/plugins/modules/netbox_prefix.py index 16bcd5ac2..3a109c37b 100644 --- a/plugins/modules/netbox_prefix.py +++ b/plugins/modules/netbox_prefix.py @@ -291,5 +291,5 @@ def main(): netbox_prefix.run() -if __name__ == "__main__": +if __name__ == "__main__": # pragma: no cover main() diff --git a/plugins/modules/netbox_provider.py b/plugins/modules/netbox_provider.py index 0ce148bbe..3277a9553 100644 --- a/plugins/modules/netbox_provider.py +++ b/plugins/modules/netbox_provider.py @@ -160,5 +160,5 @@ def main(): netbox_provider.run() -if __name__ == "__main__": +if __name__ == "__main__": # pragma: no cover main() diff --git a/plugins/modules/netbox_rack.py b/plugins/modules/netbox_rack.py index 7187d4815..9dfd91f59 100644 --- a/plugins/modules/netbox_rack.py +++ b/plugins/modules/netbox_rack.py @@ -152,7 +152,7 @@ netbox_url: http://netbox.local netbox_token: thisIsMyToken data: - name: Test Rack + name: Test Rack state: absent """ @@ -246,5 +246,5 @@ def main(): netbox_rack.run() -if __name__ == "__main__": +if __name__ == "__main__": # pragma: no cover main() diff --git a/plugins/modules/netbox_rack_group.py b/plugins/modules/netbox_rack_group.py index b9fd0d094..427cb07e9 100644 --- a/plugins/modules/netbox_rack_group.py +++ b/plugins/modules/netbox_rack_group.py @@ -81,7 +81,7 @@ netbox_url: http://netbox.local netbox_token: thisIsMyToken data: - name: Test Rack group + name: Test Rack group site: Test Site state: absent """ @@ -136,5 +136,5 @@ def main(): netbox_rack_group.run() -if __name__ == "__main__": +if __name__ == "__main__": # pragma: no cover main() diff --git a/plugins/modules/netbox_rack_role.py b/plugins/modules/netbox_rack_role.py index 301811526..37b98e119 100644 --- a/plugins/modules/netbox_rack_role.py +++ b/plugins/modules/netbox_rack_role.py @@ -82,7 +82,7 @@ netbox_url: http://netbox.local netbox_token: thisIsMyToken data: - name: Test Rack role + name: Test Rack role state: absent """ @@ -136,5 +136,5 @@ def main(): netbox_rack_role.run() -if __name__ == "__main__": +if __name__ == "__main__": # pragma: no cover main() diff --git a/plugins/modules/netbox_region.py b/plugins/modules/netbox_region.py index 5d39d652c..55c52a2fc 100644 --- a/plugins/modules/netbox_region.py +++ b/plugins/modules/netbox_region.py @@ -86,7 +86,7 @@ netbox_url: http://netbox.local netbox_token: thisIsMyToken data: - name: Tenant Group ABC + name: Tenant Group ABC state: absent """ @@ -140,5 +140,5 @@ def main(): netbox_region.run() -if __name__ == "__main__": +if __name__ == "__main__": # pragma: no cover main() diff --git a/plugins/modules/netbox_rir.py b/plugins/modules/netbox_rir.py index ade5c0992..c31be3bdb 100644 --- a/plugins/modules/netbox_rir.py +++ b/plugins/modules/netbox_rir.py @@ -144,5 +144,5 @@ def main(): netbox_rir.run() -if __name__ == "__main__": +if __name__ == "__main__": # pragma: no cover main() diff --git a/plugins/modules/netbox_service.py b/plugins/modules/netbox_service.py index 765e987ef..f57057996 100644 --- a/plugins/modules/netbox_service.py +++ b/plugins/modules/netbox_service.py @@ -69,7 +69,7 @@ type: str tags: description: - - What tags to add/update + - What tags to add/update custom_fields: description: - Must exist in Netbox and in key/value format @@ -117,7 +117,7 @@ tasks: - name: Delete service netbox_service: - netbox_url: netbox_url + netbox_url: netbox_url netbox_token: netbox_token data: device: Test666 @@ -172,5 +172,5 @@ def main(): netbox_service.run() -if __name__ == "__main__": +if __name__ == "__main__": # pragma: no cover main() diff --git a/plugins/modules/netbox_site.py b/plugins/modules/netbox_site.py index b9f51c3f9..4c0b205e2 100644 --- a/plugins/modules/netbox_site.py +++ b/plugins/modules/netbox_site.py @@ -258,5 +258,5 @@ def main(): netbox_site.run() -if __name__ == "__main__": +if __name__ == "__main__": # pragma: no cover main() diff --git a/plugins/modules/netbox_tenant.py b/plugins/modules/netbox_tenant.py index 9847b3f73..96c984735 100644 --- a/plugins/modules/netbox_tenant.py +++ b/plugins/modules/netbox_tenant.py @@ -181,5 +181,5 @@ def main(): netbox_tenant.run() -if __name__ == "__main__": +if __name__ == "__main__": # pragma: no cover main() diff --git a/plugins/modules/netbox_tenant_group.py b/plugins/modules/netbox_tenant_group.py index d3e8b72c9..d9e0e301a 100644 --- a/plugins/modules/netbox_tenant_group.py +++ b/plugins/modules/netbox_tenant_group.py @@ -142,5 +142,5 @@ def main(): netbox_tenant_group.run() -if __name__ == "__main__": +if __name__ == "__main__": # pragma: no cover main() diff --git a/plugins/modules/netbox_virtual_machine.py b/plugins/modules/netbox_virtual_machine.py index 99ea29a35..0c54469a2 100644 --- a/plugins/modules/netbox_virtual_machine.py +++ b/plugins/modules/netbox_virtual_machine.py @@ -215,5 +215,5 @@ def main(): netbox_virtual_machine.run() -if __name__ == "__main__": +if __name__ == "__main__": # pragma: no cover main() diff --git a/plugins/modules/netbox_vlan.py b/plugins/modules/netbox_vlan.py index ccf7a6f27..fc0e5dd89 100644 --- a/plugins/modules/netbox_vlan.py +++ b/plugins/modules/netbox_vlan.py @@ -195,5 +195,5 @@ def main(): netbox_vlan.run() -if __name__ == "__main__": +if __name__ == "__main__": # pragma: no cover main() diff --git a/plugins/modules/netbox_vlan_group.py b/plugins/modules/netbox_vlan_group.py index 36ea3b12a..8fbc75fc3 100644 --- a/plugins/modules/netbox_vlan_group.py +++ b/plugins/modules/netbox_vlan_group.py @@ -81,7 +81,7 @@ netbox_url: http://netbox.local netbox_token: thisIsMyToken data: - name: Test vlan group + name: Test vlan group state: absent """ @@ -135,5 +135,5 @@ def main(): netbox_vlan_group.run() -if __name__ == "__main__": +if __name__ == "__main__": # pragma: no cover main() diff --git a/plugins/modules/netbox_vm_interface.py b/plugins/modules/netbox_vm_interface.py index 2f63db847..93a13d2c9 100644 --- a/plugins/modules/netbox_vm_interface.py +++ b/plugins/modules/netbox_vm_interface.py @@ -210,5 +210,5 @@ def main(): netbox_vm_interface.run() -if __name__ == "__main__": +if __name__ == "__main__": # pragma: no cover main() diff --git a/plugins/modules/netbox_vrf.py b/plugins/modules/netbox_vrf.py index 5827e56bd..6872db837 100644 --- a/plugins/modules/netbox_vrf.py +++ b/plugins/modules/netbox_vrf.py @@ -169,5 +169,5 @@ def main(): netbox_vrf.run() -if __name__ == "__main__": +if __name__ == "__main__": # pragma: no cover main() diff --git a/tests/integration/integration-tests.yml b/tests/integration/integration-tests.yml deleted file mode 100644 index 5179df4c9..000000000 --- a/tests/integration/integration-tests.yml +++ /dev/null @@ -1,4507 +0,0 @@ ---- -## -## -### NETBOX_DEVICE -## -## -- name: "TEST NETBOX_DEVICE" - hosts: localhost - connection: local - gather_facts: no - collections: - - netbox.netbox - - tasks: - - name: "1 - Device with required information" - 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_one - - - name: "1 - ASSERT" - 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']['device_role'] == 1 - - test_one['device']['device_type'] == 1 - - test_one['device']['site'] == 1 - - test_one['device']['status'] == 3 - - test_one['device']['name'] == "R1" - - test_one['msg'] == "device R1 created" - - - name: "2 - Duplicate device" - 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" - assert: - that: - - not test_two['changed'] - - test_two['device']['name'] == "R1" - - test_two['device']['device_role'] == 1 - - test_two['device']['device_type'] == 1 - - test_two['device']['site'] == 1 - - test_two['device']['status'] == 3 - - test_two['msg'] == "device R1 already exists" - - - name: "3 - Update device" - netbox_device: - netbox_url: "http://localhost:32768" - netbox_token: "0123456789abcdef0123456789abcdef01234567" - data: - name: "R1" - serial: "FXS1001" - state: present - register: test_three - - - name: "3 - ASSERT" - assert: - that: - - test_three is changed - - test_three['diff']['after']['serial'] == "FXS1001" - - test_three['device']['name'] == "R1" - - test_three['device']['device_role'] == 1 - - test_three['device']['device_type'] == 1 - - test_three['device']['site'] == 1 - - test_three['device']['status'] == 3 - - test_three['device']['serial'] == "FXS1001" - - test_three['msg'] == "device R1 updated" - - - name: "4 - Create device with tags and assign to rack" - netbox_device: - netbox_url: "http://localhost:32768" - netbox_token: "0123456789abcdef0123456789abcdef01234567" - data: - name: "TestR1" - device_type: "Arista Test" - device_role: "Core Switch" - site: "Test Site2" - rack: "Test Rack" - position: 35 - face: "Front" - tags: - - "Schnozzberry" - tenant: "Test Tenant" - asset_tag: "1234" - state: present - register: test_four - - - name: "4 - ASSERT" - 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']['device_role'] == 1 - - test_four['device']['device_type'] == 2 - - test_four['device']['site'] == 2 - - test_four['device']['status'] == 1 - - test_four['device']['rack'] == 1 - - test_four['device']['tags'][0] == 'Schnozzberry' - - test_four['device']['tenant'] == 1 - - test_four['device']['asset_tag'] == '1234' - - test_four['msg'] == "device TestR1 created" - - - name: "5 - Delete previous device" - netbox_device: - netbox_url: "http://localhost:32768" - netbox_token: "0123456789abcdef0123456789abcdef01234567" - data: - name: "TestR1" - state: absent - register: test_five - - - name: "5 - ASSERT" - 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_device: - netbox_url: "http://localhost:32768" - netbox_token: "0123456789abcdef0123456789abcdef01234567" - data: - name: "R1" - state: absent - register: test_six - - - name: "6 - ASSERT" - assert: - that: - - test_six is changed - - test_six['diff']['before']['state'] == "present" - - test_six['diff']['after']['state'] == "absent" - - test_six['msg'] == "device R1 deleted" - - - name: "7 - Add primary_ip4/6 to test100" - 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" - 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']['device_role'] == 1 - - test_seven['device']['device_type'] == 1 - - test_seven['device']['site'] == 1 - - test_seven['device']['status'] == 1 - - 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_device: - netbox_url: "http://localhost:32768" - netbox_token: "0123456789abcdef0123456789abcdef01234567" - data: - name: "" - device_type: "Cisco Test" - device_role: "Core Switch" - site: "Test Site" - status: "Staged" - state: present - register: test_eight - - - name: "8 - ASSERT" - assert: - that: - - test_eight is changed - - test_eight['diff']['before']['state'] == 'absent' - - test_eight['diff']['after']['state'] == 'present' - - test_eight['device']['device_role'] == 1 - - test_eight['device']['device_type'] == 1 - - test_eight['device']['site'] == 1 - - test_eight['device']['status'] == 3 - - "'-' in test_eight['device']['name']" - - "test_eight['device']['name'] | length == 36" - -## -## -### NETBOX_DEVICE_INTERFACE -## -## -- name: "TEST NETBOX_DEVICE_INTERFACE" - hosts: localhost - connection: local - gather_facts: no - collections: - - netbox.netbox - - tasks: - - name: "1 - Interface with required information" - netbox_device_interface: - netbox_url: "http://localhost:32768" - netbox_token: "0123456789abcdef0123456789abcdef01234567" - data: - device: test100 - name: GigabitEthernet3 - register: test_one - - - name: "1 - ASSERT" - 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_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" - 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_device_interface: - netbox_url: "http://localhost:32768" - netbox_token: "0123456789abcdef0123456789abcdef01234567" - data: - device: test100 - name: GigabitEthernet3 - state: absent - register: test_three - - - name: "3 - ASSERT" - 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_device_interface: - netbox_url: "http://localhost:32768" - netbox_token: "0123456789abcdef0123456789abcdef01234567" - data: - device: test100 - name: port-channel1 - form_factor: Link Aggregation Group (LAG) - mtu: 1600 - mgmt_only: false - mode: Access - state: present - register: test_four - - - name: "4 - ASSERT" - 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']['form_factor'] == 200 - - test_four['interface']['mgmt_only'] == false - - test_four['interface']['mode'] == 100 - - test_four['interface']['mtu'] == 1600 - - - name: "5 - Create interface and assign it to parent LAG" - netbox_device_interface: - netbox_url: "http://localhost:32768" - netbox_token: "0123456789abcdef0123456789abcdef01234567" - data: - device: test100 - name: GigabitEthernet3 - enabled: false - form_factor: 1000Base-T (1GE) - lag: - name: port-channel1 - mtu: 1600 - mgmt_only: false - mode: Access - state: present - register: test_five - - - name: "5 - ASSERT" - 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']['form_factor'] == 1000 - - test_five['interface']['mgmt_only'] == false - - test_five['interface']['lag'] == 15 - - test_five['interface']['mode'] == 100 - - test_five['interface']['mtu'] == 1600 - - - name: "6 - Create interface as trunk port" - netbox_device_interface: - netbox_url: "http://localhost:32768" - netbox_token: "0123456789abcdef0123456789abcdef01234567" - data: - device: test100 - name: GigabitEthernet21 - enabled: false - form_factor: 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" - 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']['form_factor'] == 1000 - - test_six['interface']['mgmt_only'] == true - - test_six['interface']['mode'] == 200 - - test_six['interface']['mtu'] == 1600 - - test_six['interface']['tagged_vlans'] == [2, 3] - - test_six['interface']['untagged_vlan'] == 1 - - - name: "7 - Duplicate Interface" - netbox_device_interface: - netbox_url: "http://localhost:32768" - netbox_token: "0123456789abcdef0123456789abcdef01234567" - data: - device: test100 - name: GigabitEthernet1 - register: test_seven - - - name: "7 - ASSERT" - assert: - that: - - not test_seven['changed'] - - test_seven['msg'] == "interface GigabitEthernet1 already exists" - - test_seven['interface']['name'] == "GigabitEthernet1" - - test_seven['interface']['device'] == 1 - - - name: "8 - Create interface and assign it to parent LAG - non dict" - netbox_device_interface: - netbox_url: "http://localhost:32768" - netbox_token: "0123456789abcdef0123456789abcdef01234567" - data: - device: test100 - name: GigabitEthernet4 - enabled: false - form_factor: 1000Base-T (1GE) - lag: "port-channel1" - mtu: 1600 - mgmt_only: false - mode: Access - state: present - register: test_eight - - - name: "8 - ASSERT" - 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']['form_factor'] == 1000 - - test_eight['interface']['mgmt_only'] == false - - test_eight['interface']['lag'] == 15 - - test_eight['interface']['mode'] == 100 - - test_eight['interface']['mtu'] == 1600 - - - name: "9 - Create interface on VC child" - netbox_device_interface: - netbox_url: "http://localhost:32768" - netbox_token: "0123456789abcdef0123456789abcdef01234567" - data: - device: Test Nexus Child One - name: Ethernet2/1 - form_factor: 1000Base-T (1GE) - state: present - register: test_nine - - - name: "9 - ASSERT" - assert: - that: - - test_nine is changed - - test_nine['msg'] == "interface Ethernet2/1 created" - - test_nine['diff']['before']['state'] == 'absent' - - test_nine['diff']['after']['state'] == 'present' - - test_nine['interface']['name'] == "Ethernet2/1" - - test_nine['interface']['device'] == 5 - - test_nine['interface']['enabled'] == true - - test_nine['interface']['form_factor'] == 1000 - - - name: "10 - Update interface on VC child" - netbox_device_interface: - netbox_url: "http://localhost:32768" - netbox_token: "0123456789abcdef0123456789abcdef01234567" - data: - device: Test Nexus One - name: Ethernet2/1 - description: "Updated child interface from parent device" - update_vc_child: True - state: present - register: test_ten - - - name: "10 - ASSERT" - assert: - that: - - test_ten is changed - - test_ten['msg'] == "interface Ethernet2/1 updated" - - test_ten['diff']['after']['description'] == 'Updated child interface from parent device' - - test_ten['interface']['name'] == "Ethernet2/1" - - test_ten['interface']['device'] == 5 - - test_ten['interface']['enabled'] == true - - test_ten['interface']['form_factor'] == 1000 - - test_ten['interface']['description'] == 'Updated child interface from parent device' - - - name: "11 - Update interface on VC child w/o update_vc_child" - netbox_device_interface: - netbox_url: "http://localhost:32768" - netbox_token: "0123456789abcdef0123456789abcdef01234567" - data: - device: Test Nexus One - name: Ethernet2/1 - description: "Updated child interface from parent device - test" - state: present - ignore_errors: yes - register: test_eleven - - - name: "11 - ASSERT" - assert: - that: - - test_eleven is failed - - test_eleven['msg'] == "Must set update_vc_child to True to allow child device interface modification" - -## -## -### NETBOX_IP_ADDRESS -## -## -- name: "TEST NETBOX_IP_ADDRESS" - connection: local - hosts: localhost - gather_facts: False - collections: - - netbox.netbox - - tasks: - - name: "1 - Create IP address within Netbox with only required information - State: Present" - netbox_ip_address: - netbox_url: http://localhost.org:32768 - netbox_token: 0123456789abcdef0123456789abcdef01234567 - data: - address: 192.168.1.10/30 - state: present - register: test_one - - - name: "1 - ASSERT" - 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_ip_address: - netbox_url: http://localhost.org: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" - assert: - that: - - test_two is changed - - test_two['diff']['after']['description'] == "Updated ip address" - - test_two['diff']['after']['tags'][0] == "Updated" - - 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] == "Updated" - - test_two['ip_address']['description'] == "Updated ip address" - - - name: "3 - Delete IP - 192.168.1.10 - State: Absent" - netbox_ip_address: - netbox_url: http://localhost.org:32768 - netbox_token: 0123456789abcdef0123456789abcdef01234567 - data: - address: 192.168.1.10/30 - state: absent - register: test_three - - - name: "3 - ASSERT" - 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_ip_address: - netbox_url: http://localhost.org:32768 - netbox_token: 0123456789abcdef0123456789abcdef01234567 - data: - address: 192.168.1.20/30 - state: present - register: test_four - - - name: "4 - ASSERT" - 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" - - - name: "5 - Create IP in global VRF - 192.168.1.20/30 - State: New" - netbox_ip_address: - netbox_url: http://localhost.org: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_ip_address: - netbox_url: http://localhost.org:32768 - netbox_token: 0123456789abcdef0123456789abcdef01234567 - data: - prefix: 192.168.100.0/24 - state: new - register: test_six - - - name: "6 - ASSERT" - 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_ip_address: - netbox_url: http://localhost.org: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" - 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'] == 10 - - test_seven['ip_address']['status'] == 2 - - test_seven['ip_address']['tags'][0] == "Schnozzberry" - - test_seven['ip_address']['tenant'] == 1 - - test_seven['ip_address']['vrf'] == 1 - - - name: "8 - Create IP address and assign a nat_inside IP" - netbox_ip_address: - netbox_url: http://localhost.org: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 - interface: - name: GigabitEthernet1 - device: test100 - register: test_eight - - - name: "8 - ASSERT" - 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']['interface'] == 2 - - test_eight['ip_address']['nat_inside'] == 7 - - test_eight['ip_address']['vrf'] == 1 - - - name: "9 - Create IP address on GigabitEthernet2 - test100 - State: present" - netbox_ip_address: - netbox_url: http://localhost.org:32768 - netbox_token: 0123456789abcdef0123456789abcdef01234567 - data: - family: 4 - address: 10.10.200.30/16 - interface: - name: GigabitEthernet2 - device: test100 - register: test_nine - - - name: "9 - ASSERT" - 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']['interface'] == 3 - - - name: "10 - Create IP address on GigabitEthernet2 - test100 - State: new" - netbox_ip_address: - netbox_url: http://localhost.org:32768 - netbox_token: 0123456789abcdef0123456789abcdef01234567 - data: - family: 4 - prefix: 10.10.0.0/16 - interface: - name: GigabitEthernet2 - device: test100 - state: new - register: test_ten - - - name: "10 - ASSERT" - 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']['value'] == 4 - - test_ten['ip_address']['interface']['id'] == 3 - - - name: "11 - Create IP address on GigabitEthernet2 - test100 - State: present" - netbox_ip_address: - netbox_url: http://localhost.org:32768 - netbox_token: 0123456789abcdef0123456789abcdef01234567 - data: - family: 4 - prefix: 192.168.100.0/24 - interface: - name: GigabitEthernet2 - device: test100 - state: present - register: test_eleven - - - name: "11 - ASSERT" - 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_ip_address: - netbox_url: http://localhost.org:32768 - netbox_token: 0123456789abcdef0123456789abcdef01234567 - data: - address: 192.168.100.2/24 - interface: - name: GigabitEthernet2 - device: test100 - state: present - register: test_twelve - - - name: "12 - ASSERT" - 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']['interface'] == 3 - - - name: "13 - Duplicate - 192.168.100.2/24" - netbox_ip_address: - netbox_url: http://localhost.org:32768 - netbox_token: 0123456789abcdef0123456789abcdef01234567 - data: - address: 192.168.100.2/24 - state: present - register: test_thirteen - - - name: "13 - ASSERT" - 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_ip_address: - netbox_url: http://localhost.org:32768 - netbox_token: 0123456789abcdef0123456789abcdef01234567 - data: - family: 4 - address: 10.188.1.100/24 - interface: - name: Eth0 - virtual_machine: test100-vm - register: test_fourteen - - - name: "14 - ASSERT" - 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']['interface'] == 4 - - - name: "15 - Create IP address with no mask - State: Present" - netbox_ip_address: - netbox_url: http://localhost.org:32768 - netbox_token: 0123456789abcdef0123456789abcdef01234567 - data: - address: 10.120.10.1 - 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.120.10.1/32 created" - - test_fifteen['ip_address']['address'] == "10.120.10.1/32" - -## -## -### NETBOX_PREFIX -## -## -- name: "TEST NETBOX_PREFIX" - connection: local - hosts: localhost - gather_facts: False - collections: - - netbox.netbox - - tasks: - - name: "1 - Create prefix within Netbox with only required information" - 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" - 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_prefix: - netbox_url: http://localhost:32768 - netbox_token: 0123456789abcdef0123456789abcdef01234567 - data: - prefix: 10.156.0.0/19 - state: present - register: test_two - - - name: "2 - ASSERT" - 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_prefix: - netbox_url: http://localhost:32768 - netbox_token: 0123456789abcdef0123456789abcdef01234567 - data: - prefix: 10.156.0.0/19 - site: Test Site - status: Reserved - description: "This prefix has been updated" - state: present - register: test_three - - - name: "3 - ASSERT" - assert: - that: - - test_three is changed - - test_three['diff']['after']['site'] == 1 - - test_three['diff']['after']['status'] == 2 - - test_three['diff']['after']['description'] == "This prefix has been updated" - - test_three['msg'] == "prefix 10.156.0.0/19 updated" - - test_three['prefix']['prefix'] == "10.156.0.0/19" - - test_three['prefix']['site'] == 1 - - test_three['prefix']['status'] == 2 - - test_three['prefix']['description'] == "This prefix has been updated" - - - name: "4 - Delete prefix within 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" - 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_prefix: - netbox_url: http://localhost:32768 - netbox_token: 0123456789abcdef0123456789abcdef01234567 - data: - family: 4 - prefix: 10.156.32.0/19 - site: 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" - 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']['site'] == 1 - - test_five['prefix']['vrf'] == 1 - - test_five['prefix']['tenant'] == 1 - - test_five['prefix']['vlan'] == 4 - - test_five['prefix']['status'] == 2 - - test_five['prefix']['role'] == 1 - - test_five['prefix']['description'] == "Test description" - - test_five['prefix']['is_pool'] == true - - test_five['prefix']['tags'][0] == "Schnozzberry" - - - name: "6 - Get a new /24 inside 10.156.0.0/19 within Netbox - Parent doesn't exist" - netbox_prefix: - netbox_url: http://localhost:32768 - netbox_token: 0123456789abcdef0123456789abcdef01234567 - data: - parent: 10.156.0.0/19 - prefix_length: 24 - state: present - first_available: yes - register: test_six - - - name: "6 - ASSERT" - 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_prefix: - netbox_url: http://localhost:32768 - netbox_token: 0123456789abcdef0123456789abcdef01234567 - data: - prefix: 10.156.0.0/19 - state: present - register: test_seven - - - name: "7 - ASSERT" - 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_prefix: - netbox_url: http://localhost:32768 - netbox_token: 0123456789abcdef0123456789abcdef01234567 - data: - parent: 10.156.0.0/19 - prefix_length: 24 - state: present - first_available: yes - register: test_eight - - - name: "8 - ASSERT" - 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_prefix: - netbox_url: http://localhost:32768 - netbox_token: 0123456789abcdef0123456789abcdef01234567 - data: - prefix: 10.157.0.0/19 - vrf: Test VRF - site: Test Site - state: present - register: test_nine - - - name: "9 - ASSERT" - 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']['site'] == 1 - - test_nine['prefix']['vrf'] == 1 - - - name: "10 - Get a new /24 inside 10.157.0.0/19 within Netbox with additional values" - netbox_prefix: - netbox_url: http://localhost:32768 - netbox_token: 0123456789abcdef0123456789abcdef01234567 - data: - parent: 10.157.0.0/19 - prefix_length: 24 - vrf: Test VRF - site: Test Site - state: present - first_available: yes - register: test_ten - - - name: "10 - ASSERT" - 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']['site']['id'] == 1 - - test_ten['prefix']['vrf']['id'] == 1 - - - name: "11 - Get a new /24 inside 10.156.0.0/19 within 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: yes - register: test_eleven - - - name: "11 - ASSERT" - 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" - -## -## -### NETBOX_SITE -## -## -- name: "TEST NETBOX_SITE" - connection: local - hosts: localhost - gather_facts: False - collections: - - netbox.netbox - - tasks: - - name: "1 - Create site within Netbox with only required information" - netbox_site: - netbox_url: http://localhost:32768 - netbox_token: 0123456789abcdef0123456789abcdef01234567 - data: - name: Test - Colorado - state: present - register: test_one - - - name: "1 - ASSERT" - 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_site: - netbox_url: http://localhost:32768 - netbox_token: 0123456789abcdef0123456789abcdef01234567 - data: - name: Test - Colorado - state: present - register: test_two - - - name: "2 - ASSERT" - 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_site: - netbox_url: http://localhost:32768 - netbox_token: 0123456789abcdef0123456789abcdef01234567 - data: - name: Test - Colorado - status: Planned - region: Test Region - contact_name: Mikhail - state: present - register: test_three - - - name: "3 - ASSERT" - assert: - that: - - test_three is changed - - test_three['diff']['after']['status'] == 2 - - test_three['diff']['after']['contact_name'] == "Mikhail" - - test_three['diff']['after']['region'] == 1 - - test_three['msg'] == "site Test - Colorado updated" - - test_three['site']['name'] == "Test - Colorado" - - test_three['site']['status'] == 2 - - test_three['site']['contact_name'] == "Mikhail" - - test_three['site']['region'] == 1 - - - name: "4 - Create site with all parameters" - netbox_site: - netbox_url: http://localhost:32768 - netbox_token: 0123456789abcdef0123456789abcdef01234567 - data: - name: Test - California - status: Planned - region: Test Region - tenant: Test Tenant - facility: EquinoxCA7 - asn: 65001 - time_zone: America/Los Angeles - description: This is a test description - physical_address: Hollywood, CA, 90210 - shipping_address: Hollywood, CA, 90210 - latitude: 10.1 - longitude: 12.2 - contact_name: Jenny - contact_phone: 867-5309 - contact_email: jenny@changednumber.com - comments: "### Placeholder" - slug: "test_california" - state: present - register: test_four - - - name: "4 - ASSERT" - 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'] == 2 - - test_four['site']['region'] == 1 - - test_four['site']['tenant'] == 1 - - test_four['site']['facility'] == "EquinoxCA7" - - test_four['site']['asn'] == 65001 - - 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'] == "10.100000" - - test_four['site']['longitude'] == "12.200000" - - test_four['site']['contact_name'] == "Jenny" - - test_four['site']['contact_phone'] == "867-5309" - - test_four['site']['contact_email'] == "jenny@changednumber.com" - - test_four['site']['comments'] == "### Placeholder" - - test_four['site']['slug'] == "test_california" - - - name: "5 - Delete site within netbox" - netbox_site: - netbox_url: http://localhost:32768 - netbox_token: 0123456789abcdef0123456789abcdef01234567 - data: - name: Test - Colorado - state: absent - register: test_five - - - name: "5 - ASSERT" - 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" - -## -## -### NETBOX_TENANT -## -## -- name: "TEST NETBOX_TENANT" - hosts: localhost - connection: local - gather_facts: no - collections: - - netbox.netbox - - tasks: - - name: "1 - Test tenant creation" - netbox_tenant: - netbox_url: http://localhost:32768 - netbox_token: 0123456789abcdef0123456789abcdef01234567 - data: - name: "Tenant ABC" - register: test_one - - - name: "1 - ASSERT" - 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_tenant: - netbox_url: http://localhost:32768 - netbox_token: 0123456789abcdef0123456789abcdef01234567 - data: - name: "Tenant ABC" - register: test_two - - - name: "2 - ASSERT" - 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_tenant: - netbox_url: http://localhost:32768 - netbox_token: 0123456789abcdef0123456789abcdef01234567 - data: - name: "Tenant ABC" - description: "Updated description" - register: test_three - - - name: "3 - ASSERT" - 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_tenant: - netbox_url: http://localhost:32768 - netbox_token: 0123456789abcdef0123456789abcdef01234567 - data: - name: "Tenant ABC" - state: "absent" - register: test_four - - - name: "4 - ASSERT" - 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_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" - 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" - -## -## -### NETBOX_TENANT_GROUP -## -## -- name: "TEST NETBOX_TENANT_GROUP" - hosts: localhost - connection: local - gather_facts: no - collections: - - netbox.netbox - - tasks: - - name: "1 - Test tenant group creation" - netbox_tenant_group: - netbox_url: http://localhost:32768 - netbox_token: 0123456789abcdef0123456789abcdef01234567 - data: - name: "Test Tenant Group Two" - register: test_one - - - name: "1 - ASSERT" - 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_tenant_group: - netbox_url: http://localhost:32768 - netbox_token: 0123456789abcdef0123456789abcdef01234567 - data: - name: "Test Tenant Group Two" - register: test_two - - - name: "2 - ASSERT" - 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_tenant_group: - netbox_url: http://localhost:32768 - netbox_token: 0123456789abcdef0123456789abcdef01234567 - data: - name: "Test Tenant Group Two" - state: "absent" - register: test_three - - - name: "3 - ASSERT" - 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 another tenant group creation" - 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" - 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" - -## -## -### NETBOX_RACK -## -## -- name: "TEST NETBOX_RACK" - hosts: localhost - connection: local - gather_facts: no - collections: - - netbox.netbox - - tasks: - - name: "1 - Test rack creation" - netbox_rack: - netbox_url: http://localhost:32768 - netbox_token: 0123456789abcdef0123456789abcdef01234567 - data: - name: "Test rack one" - site: "Test Site" - register: test_one - - - name: "1 - ASSERT" - 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_rack: - netbox_url: http://localhost:32768 - netbox_token: 0123456789abcdef0123456789abcdef01234567 - data: - name: "Test rack one" - register: test_two - - - name: "2 - ASSERT" - 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_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" - 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_rack: - netbox_url: http://localhost:32768 - netbox_token: 0123456789abcdef0123456789abcdef01234567 - data: - name: Test rack one - site: Test Site - state: present - register: test_four - - - name: "4 - ASSERT" - 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_rack: - netbox_url: http://localhost:32768 - netbox_token: 0123456789abcdef0123456789abcdef01234567 - data: - name: Test rack one - site: Test Site - rack_role: "Test Rack Role" - rack_group: "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" - 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']['group'] == 1 - - test_five['diff']['after']['outer_depth'] == 24 - - test_five['diff']['after']['outer_unit'] == 2000 - - test_five['diff']['after']['outer_width'] == 32 - - test_five['diff']['after']['role'] == 1 - - test_five['diff']['after']['serial'] == "FXS10001" - - test_five['diff']['after']['status'] == 1 - - test_five['diff']['after']['tenant'] == 1 - - test_five['diff']['after']['tags'][0] == "Schnozzberry" - - test_five['diff']['after']['type'] == 100 - - 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']['group'] == 1 - - test_five['rack']['outer_depth'] == 24 - - test_five['rack']['outer_unit'] == 2000 - - test_five['rack']['outer_width'] == 32 - - test_five['rack']['role'] == 1 - - test_five['rack']['serial'] == "FXS10001" - - test_five['rack']['status'] == 1 - - test_five['rack']['tenant'] == 1 - - test_five['rack']['tags'][0] == "Schnozzberry" - - test_five['rack']['type'] == 100 - - 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_rack: - netbox_url: http://localhost:32768 - netbox_token: 0123456789abcdef0123456789abcdef01234567 - data: - name: Test rack one - site: Test Site - rack_role: "Test Rack Role" - rack_group: "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" - 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']['group'] == 1 - - test_six['rack']['outer_depth'] == 24 - - test_six['rack']['outer_unit'] == 2000 - - test_six['rack']['outer_width'] == 32 - - test_six['rack']['role'] == 1 - - test_six['rack']['serial'] == "FXS10001" - - test_six['rack']['status'] == 1 - - test_six['rack']['tenant'] == 1 - - test_six['rack']['tags'][0] == "Schnozzberry" - - test_six['rack']['type'] == 100 - - test_six['rack']['u_height'] == 48 - - test_six['rack']['width'] == 23 - - - name: "7 - Create rack with same asset tag and serial number" - 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: yes - register: test_seven - - - name: "7 - ASSERT" - assert: - that: - - test_seven is failed - - "'Asset tag already exists' in test_seven['msg']" - - - name: "8 - Test delete" - netbox_rack: - netbox_url: http://localhost:32768 - netbox_token: 0123456789abcdef0123456789abcdef01234567 - data: - name: "Test rack one" - state: "absent" - register: test_eight - - - name: "8 - ASSERT" - 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" - -## -## -### NETBOX_RACK_ROLE -## -## -- name: "TEST NETBOX_RACK_ROLE" - connection: local - hosts: localhost - gather_facts: False - collections: - - netbox.netbox - - tasks: - - name: "RACK_ROLE 1: Necessary info creation" - 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" - 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_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" - 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_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" - 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_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" - 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" - -## -## -### NETBOX_RACK_GROUP -## -## -- name: "TEST NETBOX_RACK_GROUP" - connection: local - hosts: localhost - gather_facts: False - collections: - - netbox.netbox - - tasks: - - name: "RACK_GROUP 1: Necessary info creation" - 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" - 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_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" - 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_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" - 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" - -## -## -### NETBOX_MANUFACTURER -## -## -- name: "TEST NETBOX_MANUFACTURER" - connection: local - hosts: localhost - gather_facts: False - collections: - - netbox.netbox - - tasks: - - name: "MANUFACTURER 1: Necessary info creation" - 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" - 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_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" - 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_manufacturer: - netbox_url: http://localhost:32768 - netbox_token: 0123456789abcdef0123456789abcdef01234567 - data: - name: test manufacturer two - state: present - register: test_three - - - name: "MANUFACTURER 3: ASSERT - Update" - 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_manufacturer: - netbox_url: http://localhost:32768 - netbox_token: 0123456789abcdef0123456789abcdef01234567 - data: - name: test manufacturer two - state: absent - register: test_four - - - name: "MANUFACTURER 3: ASSERT - Delete" - 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_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" - assert: - that: - - not test_five['changed'] - - test_five['manufacturer'] == None - - test_five['msg'] == "manufacturer Test Manufacturer Two already absent" - -## -## -### NETBOX_PLATFORM -## -## -- name: "TEST NETBOX_PLATFORM" - connection: local - hosts: localhost - gather_facts: False - collections: - - netbox.netbox - - tasks: - - name: "PLATFORM 1: Necessary info creation" - 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" - 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_platform: - netbox_url: http://localhost:32768 - netbox_token: 0123456789abcdef0123456789abcdef01234567 - data: - name: Test Platform - state: present - register: test_two - - - name: "PLATFORM 2: ASSERT - Create duplicate" - 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_platform: - netbox_url: http://localhost:32768 - netbox_token: 0123456789abcdef0123456789abcdef01234567 - data: - name: Test Platform - manufacturer: Test Manufacturer - napalm_driver: ios - napalm_args: - global_delay_factor: 2 - state: present - register: test_three - - - name: "PLATFORM 3: ASSERT - Update" - assert: - that: - - test_three is changed - - test_three['diff']['after']['manufacturer'] == 3 - - test_three['diff']['after']['napalm_args']['global_delay_factor'] == 2 - - test_three['diff']['after']['napalm_driver'] == "ios" - - test_three['platform']['manufacturer'] == 3 - - test_three['platform']['napalm_args']['global_delay_factor'] == 2 - - test_three['platform']['napalm_driver'] == "ios" - - test_three['msg'] == "platform Test Platform updated" - - - name: "PLATFORM 4: ASSERT - Delete" - netbox_platform: - netbox_url: http://localhost:32768 - netbox_token: 0123456789abcdef0123456789abcdef01234567 - data: - name: Test Platform - state: absent - register: test_four - - - name: "PLATFORM 4: ASSERT - Delete" - 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_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`" - assert: - that: - - not test_five['changed'] - - test_five['platform'] == None - - test_five['msg'] == "platform Test Platform already absent" - -## -## -### NETBOX_DEVICE_TYPE -## -## -- name: "TEST NETBOX_DEVICE_TYPE" - connection: local - hosts: localhost - gather_facts: False - collections: - - netbox.netbox - - tasks: - - name: "DEVICE_TYPE 1: Necessary info creation" - 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" - 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_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" - 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_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 - is_full_depth: false - subdevice_role: parent - state: present - register: test_three - - - name: "DEVICE_TYPE 3: ASSERT - Update" - 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'] == true - - 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'] == true - - test_three['msg'] == "device_type test-device-type updated" - - - name: "DEVICE_TYPE 4: ASSERT - Delete" - 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" - 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_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`" - 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_device_type: - netbox_url: http://localhost:32768 - netbox_token: 0123456789abcdef0123456789abcdef01234567 - data: - model: "WS Test 3850" - manufacturer: Test Manufacturer - state: present - register: test_six - - - name: "DEVICE_TYPE 6: ASSERT - Without Slug" - 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" - -## -## -### NETBOX_DEVICE_ROLE -## -## -- name: "TEST NETBOX_DEVICE_ROLE" - connection: local - hosts: localhost - gather_facts: False - collections: - - netbox.netbox - - tasks: - - name: "DEVICE_ROLE 1: Necessary info creation" - 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" - 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_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" - 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_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" - 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_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" - 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_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`" - assert: - that: - - not test_five['changed'] - - test_five['device_role'] == None - - test_five['msg'] == "device_role Test Device Role already absent" - -## -## -### NETBOX_IPAM_ROLE -## -## -- name: "TEST NETBOX_IPAM_ROLE" - connection: local - hosts: localhost - gather_facts: False - collections: - - netbox.netbox - - tasks: - - name: "IPAM_ROLE 1: Necessary info creation" - 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" - 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_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" - 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_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" - 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_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" - 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_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`" - assert: - that: - - not test_five['changed'] - - test_five['role'] == None - - test_five['msg'] == "role Test IPAM Role already absent" - -## -## -### NETBOX_VLAN_GROUP -## -## -- name: "TEST NETBOX_VLAN_GROUP" - connection: local - hosts: localhost - gather_facts: False - collections: - - netbox.netbox - - tasks: - - name: "VLAN_GROUP 1: Necessary info creation" - netbox_vlan_group: - netbox_url: http://localhost:32768 - netbox_token: 0123456789abcdef0123456789abcdef01234567 - data: - name: "VLAN Group One" - site: Test Site - state: present - register: test_one - - - name: "VLAN_GROUP 1: ASSERT - Necessary info creation" - assert: - that: - - test_one is changed - - test_one['diff']['before']['state'] == "absent" - - test_one['diff']['after']['state'] == "present" - - test_one['vlan_group']['name'] == "VLAN Group One" - - test_one['vlan_group']['slug'] == "vlan-group-one" - - test_one['vlan_group']['site'] == 1 - - test_one['msg'] == "vlan_group VLAN Group One created" - - - name: "VLAN_GROUP 2: Create duplicate" - netbox_vlan_group: - netbox_url: http://localhost:32768 - netbox_token: 0123456789abcdef0123456789abcdef01234567 - data: - name: "VLAN Group One" - site: Test Site - state: present - register: test_two - - - name: "VLAN_GROUP 2: ASSERT - Create duplicate" - assert: - that: - - not test_two['changed'] - - test_two['vlan_group']['name'] == "VLAN Group One" - - test_two['vlan_group']['slug'] == "vlan-group-one" - - test_two['vlan_group']['site'] == 1 - - test_two['msg'] == "vlan_group VLAN Group One already exists" - - - name: "VLAN_GROUP 3: ASSERT - Create with same name, different site" - netbox_vlan_group: - netbox_url: http://localhost:32768 - netbox_token: 0123456789abcdef0123456789abcdef01234567 - data: - name: "VLAN Group One" - site: "Test Site2" - state: present - register: test_three - - - name: "VLAN_GROUP 3: ASSERT - Create with same name, different site" - assert: - that: - - test_three is changed - - test_three['vlan_group']['name'] == "VLAN Group One" - - test_three['vlan_group']['slug'] == "vlan-group-one" - - test_three['vlan_group']['site'] == 2 - - test_three['msg'] == "vlan_group VLAN Group One created" - - - name: "VLAN_GROUP 4: ASSERT - Create vlan group, no site" - netbox_vlan_group: - netbox_url: http://localhost:32768 - netbox_token: 0123456789abcdef0123456789abcdef01234567 - data: - name: "VLAN Group One" - state: present - ignore_errors: yes - register: test_four - - - name: "VLAN_GROUP 4: ASSERT - Create with same name, different site" - assert: - that: - - test_four is failed - - test_four['msg'] == "More than one result returned for VLAN Group One" - - - name: "VLAN_GROUP 5: ASSERT - Delete" - netbox_vlan_group: - netbox_url: http://localhost:32768 - netbox_token: 0123456789abcdef0123456789abcdef01234567 - data: - name: VLAN Group One - site: Test Site2 - state: absent - register: test_five - - - name: "VLAN_GROUP 5: ASSERT - Delete" - assert: - that: - - test_five is changed - - test_five['diff']['before']['state'] == "present" - - test_five['diff']['after']['state'] == "absent" - - test_five['vlan_group']['name'] == "VLAN Group One" - - test_five['vlan_group']['slug'] == "vlan-group-one" - - test_five['vlan_group']['site'] == 2 - - test_five['msg'] == "vlan_group VLAN Group One deleted" - - - name: "VLAN_GROUP 6: ASSERT - Delete non existing" - netbox_vlan_group: - netbox_url: http://localhost:32768 - netbox_token: 0123456789abcdef0123456789abcdef01234567 - data: - name: VLAN Group One - site: Test Site2 - state: absent - register: test_six - - - name: "VLAN_GROUP 6: ASSERT - Delete non existing`" - assert: - that: - - not test_six['changed'] - - test_six['vlan_group'] == None - - test_six['msg'] == "vlan_group VLAN Group One already absent" - -## -## -### NETBOX_VLAN -## -## -- name: "TEST NETBOX_VLAN" - connection: local - hosts: localhost - gather_facts: False - collections: - - netbox.netbox - - tasks: - - name: "VLAN 1: Necessary info creation" - 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" - 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_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" - 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_vlan: - netbox_url: http://localhost:32768 - netbox_token: 0123456789abcdef0123456789abcdef01234567 - data: - name: Test VLAN 500 - vid: 500 - site: Test Site - tenant: Test Tenant - state: present - register: test_three - - - name: "VLAN 3: ASSERT - Create VLAN with same name, but different site" - 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['msg'] == "vlan Test VLAN 500 created" - - - name: "VLAN 4: ASSERT - Update" - 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" - assert: - that: - - test_four is changed - - test_four['diff']['after']['group'] == 1 - - test_four['diff']['after']['status'] == 2 - - test_four['diff']['after']['role'] == 1 - - test_four['diff']['after']['description'] == "Updated description" - - test_four['diff']['after']['tags'][0] == "Schnozzberry" - - 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'] == 2 - - test_four['vlan']['role'] == 1 - - test_four['vlan']['description'] == "Updated description" - - test_four['vlan']['tags'][0] == "Schnozzberry" - - test_four['msg'] == "vlan Test VLAN 500 updated" - - - name: "VLAN 5: ASSERT - Delete more than one result" - netbox_vlan: - netbox_url: http://localhost:32768 - netbox_token: 0123456789abcdef0123456789abcdef01234567 - data: - name: "Test VLAN 500" - state: absent - ignore_errors: yes - register: test_five - - - name: "VLAN 5: ASSERT - Delete more than one result" - assert: - that: - - test_five is failed - - test_five['msg'] == "More than one result returned for Test VLAN 500" - - - name: "VLAN 6: ASSERT - Delete" - netbox_vlan: - netbox_url: http://localhost:32768 - netbox_token: 0123456789abcdef0123456789abcdef01234567 - data: - name: "Test VLAN 500" - site: Test Site - state: absent - register: test_six - - - name: "VLAN 6: ASSERT - Delete" - 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'] == 2 - - test_six['vlan']['role'] == 1 - - test_six['vlan']['description'] == "Updated description" - - test_six['vlan']['tags'][0] == "Schnozzberry" - - test_six['msg'] == "vlan Test VLAN 500 deleted" - -## -## -### NETBOX_VRF -## -## -- name: "TEST NETBOX_VRF" - connection: local - hosts: localhost - gather_facts: False - collections: - - netbox.netbox - - tasks: - - name: "VRF 1: Necessary info creation" - 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" - 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_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" - 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_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" - 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_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 - tags: - - Schnozzberry - state: present - register: test_four - - - name: "VRF 4: ASSERT - Updated" - 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] == "Schnozzberry" - - 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] == "Schnozzberry" - - test_four['msg'] == "vrf Test VRF One updated" - - - name: "VRF 5: ASSERT - Delete more than one result" - netbox_vrf: - netbox_url: http://localhost:32768 - netbox_token: 0123456789abcdef0123456789abcdef01234567 - data: - name: "Test VRF One" - state: absent - ignore_errors: yes - register: test_five - - - name: "VRF 5: ASSERT - Delete more than one result" - assert: - that: - - test_five is failed - - test_five['msg'] == "More than one result returned for Test VRF One" - - - name: "VRF 6: ASSERT - Delete" - 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" - 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] == "Schnozzberry" - - test_six['msg'] == "vrf Test VRF One deleted" - -## -## -### NETBOX_RIR -## -## -- name: "TEST NETBOX_RIR" - connection: local - hosts: localhost - gather_facts: False - collections: - - netbox.netbox - - tasks: - - name: "RIR 1: Necessary info creation" - 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" - 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_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" - 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_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" - 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_rir: - netbox_url: http://localhost:32768 - netbox_token: 0123456789abcdef0123456789abcdef01234567 - data: - name: "Test RIR One" - state: absent - register: test_four - - - name: "RIR 4: ASSERT - Delete" - 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" - -## -## -### NETBOX_AGGEGATE -## -## -- name: "TEST NETBOX_AGGREGATE" - connection: local - hosts: localhost - gather_facts: False - collections: - - netbox.netbox - - tasks: - - name: "AGGREGATE 1: Necessary info creation" - 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" - 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_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" - 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_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" - 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] == "Schnozzberry" - - 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] == "Schnozzberry" - - test_three['msg'] == "aggregate 10.0.0.0/8 updated" - - - name: "AGGREGATE 4: ASSERT - Delete" - 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" - 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] == "Schnozzberry" - - test_four['msg'] == "aggregate 10.0.0.0/8 deleted" - - - name: "AGGREGATE 5: Necessary info creation" - 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" - 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" - -## -## -### NETBOX_REGION -## -## -- name: "TEST NETBOX_REGION" - connection: local - hosts: localhost - gather_facts: False - collections: - - netbox.netbox - - tasks: - - name: "REGION 1: Necessary info creation" - 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" - 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_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" - 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_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" - 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_region: - netbox_url: http://localhost:32768 - netbox_token: 0123456789abcdef0123456789abcdef01234567 - data: - name: "Test Region One" - state: absent - register: test_four - - - name: "REGION 4: ASSERT - Delete" - 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" - -## -## -### NETBOX_DEVICE_BAY -## -## -- name: "TEST NETBOX_DEVICE_BAY" - connection: local - hosts: localhost - gather_facts: False - collections: - - netbox.netbox - - tasks: - - name: "DEVICE_BAY 1: Necessary info creation" - 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" - 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_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" - 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_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" - assert: - that: - - test_three is changed - - test_three['diff']['after']['installed_device'] == 5 - - test_three['diff']['after']['tags'][0] == "Schnozzberry" - - 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] == "Schnozzberry" - - test_three['msg'] == "device_bay Device Bay One updated" - - - name: "DEVICE_BAY 4: ASSERT - Delete" - 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" - 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] == "Schnozzberry" - - test_four['msg'] == "device_bay Device Bay One deleted" - -## -## -### NETBOX_INVENTORY_ITEM -## -## -- name: "TEST NETBOX_INVENTORY_ITEM" - connection: local - hosts: localhost - gather_facts: False - collections: - - netbox.netbox - - tasks: - - name: "INVENTORY_ITEM 1: Necessary info creation" - 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" - 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_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" - 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: ASSERT - Update" - 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" - tags: - - Schnozzberry - state: present - register: test_three - - - name: "INVENTORY_ITEM 3: ASSERT - Updated" - 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] == "Schnozzberry" - - 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] == "Schnozzberry" - - test_three['msg'] == "inventory_item 10G-SFP+ updated" - - - name: "INVENTORY_ITEM 4: ASSERT - Delete" - 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" - 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] == "Schnozzberry" - - test_four['msg'] == "inventory_item 10G-SFP+ deleted" - -## -## -### NETBOX_VIRTUAL_MACHINES -## -## -- name: "TEST NETBOX_VIRTUAL_MACHINES" - connection: local - hosts: localhost - gather_facts: False - collections: - - netbox.netbox - - tasks: - - name: "VIRTUAL_MACHINE 1: Necessary info creation" - 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" - 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_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" - 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_virtual_machine: - netbox_url: http://localhost:32768 - netbox_token: 0123456789abcdef0123456789abcdef01234567 - data: - name: "Test VM One" - cluster: "Test Cluster" - vcpus: 8 - memory: 8 - status: 0 - virtual_machine_role: "Test VM Role" - tags: - - Schnozzberry - state: present - register: test_three - - - name: "VIRTUAL_MACHINE 3: ASSERT - Updated" - assert: - that: - - test_three is changed - - test_three['diff']['after']['vcpus'] == 8 - - test_three['diff']['after']['memory'] == 8 - - test_three['diff']['after']['status'] == 0 - - test_three['diff']['after']['role'] == 2 - - test_three['diff']['after']['tags'][0] == "Schnozzberry" - - test_three['virtual_machine']['name'] == "Test VM One" - - test_three['virtual_machine']['cluster'] == 1 - - test_three['virtual_machine']['vcpus'] == 8 - - test_three['virtual_machine']['memory'] == 8 - - test_three['virtual_machine']['status'] == 0 - - test_three['virtual_machine']['role'] == 2 - - test_three['virtual_machine']['tags'][0] == "Schnozzberry" - - test_three['msg'] == "virtual_machine Test VM One updated" - - - name: "VIRTUAL_MACHINE 4: ASSERT - Delete" - netbox_virtual_machine: - netbox_url: http://localhost:32768 - netbox_token: 0123456789abcdef0123456789abcdef01234567 - data: - name: "Test VM One" - state: absent - register: test_four - - - name: "VIRTUAL_MACHINE 4: ASSERT - Delete" - assert: - that: - - test_four is changed - - test_four['virtual_machine']['name'] == "Test VM One" - - test_four['virtual_machine']['cluster'] == 1 - - test_four['virtual_machine']['vcpus'] == 8 - - test_four['virtual_machine']['memory'] == 8 - - test_four['virtual_machine']['status'] == 0 - - test_four['virtual_machine']['role'] == 2 - - test_four['virtual_machine']['tags'][0] == "Schnozzberry" - - test_four['msg'] == "virtual_machine Test VM One deleted" - -## -## -### NETBOX_CLUSTER -## -## -- name: "TEST NETBOX_CLUSTER" - connection: local - hosts: localhost - gather_facts: False - collections: - - netbox.netbox - - tasks: - - name: "CLUSTER 1: Necessary info creation" - 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" - 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_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" - 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_cluster: - netbox_url: http://localhost:32768 - netbox_token: 0123456789abcdef0123456789abcdef01234567 - data: - name: "Test Cluster One" - cluster_type: "Test Cluster Type" - cluster_group: "Test Cluster Group" - site: "Test Site" - comments: "Updated cluster" - tags: - - Schnozzberry - state: present - register: test_three - - - name: "CLUSTER 3: ASSERT - Updated" - assert: - that: - - test_three is changed - - test_three['diff']['after']['group'] == 1 - - test_three['diff']['after']['site'] == 1 - - test_three['diff']['after']['comments'] == "Updated cluster" - - test_three['diff']['after']['tags'][0] == "Schnozzberry" - - test_three['cluster']['name'] == "Test Cluster One" - - test_three['cluster']['type'] == 1 - - test_three['cluster']['group'] == 1 - - test_three['cluster']['site'] == 1 - - test_three['cluster']['comments'] == "Updated cluster" - - test_three['cluster']['tags'][0] == "Schnozzberry" - - test_three['msg'] == "cluster Test Cluster One updated" - - - name: "CLUSTER 4: ASSERT - Delete" - 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" - 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']['site'] == 1 - - test_four['cluster']['comments'] == "Updated cluster" - - test_four['cluster']['tags'][0] == "Schnozzberry" - - test_four['msg'] == "cluster Test Cluster One deleted" - -## -## -### NETBOX_CLUSTER_GROUP -## -## -- name: "TEST NETBOX_CLUSTER_GROUP" - connection: local - hosts: localhost - gather_facts: False - collections: - - netbox.netbox - - tasks: - - name: "CLUSTER_GROUP 1: Necessary info creation" - 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" - 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_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" - 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_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" - 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_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" - 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_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" - 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" - -## -## -### NETBOX_CLUSTER_TYPE -## -## -- name: "TEST NETBOX_CLUSTER_TYPE" - connection: local - hosts: localhost - gather_facts: False - collections: - - netbox.netbox - - tasks: - - name: "CLUSTER_TYPE 1: Necessary info creation" - 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" - 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_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" - 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_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" - 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_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" - 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_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" - 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" - -## -## -### NETBOX_VM_INTERFACE -## -## -- name: "TEST NETBOX_VM_INTERFACE" - connection: local - hosts: localhost - gather_facts: False - collections: - - netbox.netbox - - tasks: - - name: "NETBOX_VM_INTERFACE 1: Necessary info creation" - 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" - 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_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" - 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_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" - 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'] == 200 - - test_three['diff']['after']['untagged_vlan'] == 1 - - test_three['diff']['after']['tagged_vlans'] == [2, 3] - - test_three['diff']['after']['tags'][0] == "Schnozzberry" - - 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'] == 200 - - test_three['interface']['untagged_vlan'] == 1 - - test_three['interface']['tagged_vlans'] == [2, 3] - - test_three['interface']['tags'][0] == "Schnozzberry" - - test_three['msg'] == "interface Eth10 updated" - - - name: "NETBOX_VM_INTERFACE 4: ASSERT - Delete" - 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" - 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_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" - 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'] == 200 - - test_five['diff']['after']['untagged_vlan'] == 1 - - test_five['diff']['after']['tagged_vlans'] == [2, 3] - - test_five['diff']['after']['tags'][0] == "Schnozzberry" - - 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'] == 200 - - test_five['interface']['untagged_vlan'] == 1 - - test_five['interface']['tagged_vlans'] == [2, 3] - - test_five['interface']['tags'][0] == "Schnozzberry" - - test_five['msg'] == "interface Eth0 updated" -## -## -### NETBOX_PROVIDER -## -## -- name: "TEST NETBOX_PROVIDER" - connection: local - hosts: localhost - gather_facts: False - collections: - - netbox.netbox - - tasks: - - name: "NETBOX_PROVIDER 1: Create provider within Netbox with only required information" - 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" - 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_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" - 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_provider: - netbox_url: http://localhost:32768 - netbox_token: 0123456789abcdef0123456789abcdef01234567 - data: - name: Test Provider One - asn: 65001 - account: "200129104" - portal_url: http://provider.net - noc_contact: noc@provider.net - admin_contact: admin@provider.net - comments: "BAD PROVIDER" - state: present - register: test_three - - - name: "NETBOX_PROVIDER 3: ASSERT - Updated" - assert: - that: - - test_three is changed - - test_three['diff']['after']['asn'] == 65001 - - test_three['diff']['after']['account'] == "200129104" - - test_three['diff']['after']['portal_url'] == "http://provider.net" - - test_three['diff']['after']['noc_contact'] == "noc@provider.net" - - test_three['diff']['after']['admin_contact'] == "admin@provider.net" - - test_three['diff']['after']['comments'] == "BAD PROVIDER" - - test_three['provider']['name'] == "Test Provider One" - - test_three['provider']['slug'] == "test-provider-one" - - test_three['provider']['asn'] == 65001 - - test_three['provider']['account'] == "200129104" - - test_three['provider']['portal_url'] == "http://provider.net" - - test_three['provider']['noc_contact'] == "noc@provider.net" - - test_three['provider']['admin_contact'] == "admin@provider.net" - - test_three['provider']['comments'] == "BAD PROVIDER" - - test_three['msg'] == "provider Test Provider One updated" - - - name: "NETBOX_PROVIDER 4: Delete provider within 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" - assert: - that: - - test_four is changed - - test_four['provider']['name'] == "Test Provider One" - - test_four['provider']['slug'] == "test-provider-one" - - test_four['provider']['asn'] == 65001 - - test_four['provider']['account'] == "200129104" - - test_four['provider']['portal_url'] == "http://provider.net" - - test_four['provider']['noc_contact'] == "noc@provider.net" - - test_four['provider']['admin_contact'] == "admin@provider.net" - - test_four['provider']['comments'] == "BAD PROVIDER" - - test_four['msg'] == "provider Test Provider One deleted" -## -## -### NETBOX_CIRCUIT_TYPE -## -## -- name: "TEST NETBOX_CIRCUIT_TYPE" - connection: local - hosts: localhost - gather_facts: False - collections: - - netbox.netbox - - tasks: - - name: "CIRCUIT_TYPE 1: Necessary info creation" - 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" - 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_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" - 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_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" - 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_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" - 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_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" - 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" -## -## -### NETBOX_CIRCUIT -## -## -- name: "TEST NETBOX_CIRCUIT" - connection: local - hosts: localhost - gather_facts: False - collections: - - netbox.netbox - - tasks: - - name: "NETBOX_CIRCUIT 1: Create provider within Netbox with only required information" - 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" - 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_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" - 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_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" - assert: - that: - - test_three is changed - - test_three['diff']['after']['status'] == 2 - - 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'] == 2 - - 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_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" - 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'] == 2 - - 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" -## -## -### NETBOX_CIRCUIT_TERMINATION -## -## -- name: "TEST NETBOX_CIRCUIT_TERMINATION" - connection: local - hosts: localhost - gather_facts: False - collections: - - netbox.netbox - - tasks: - - name: "NETBOX_CIRCUIT_TERMINATION 1: Create provider within Netbox with only required information" - netbox_circuit_termination: - netbox_url: http://localhost:32768 - netbox_token: 0123456789abcdef0123456789abcdef01234567 - data: - circuit: Test Circuit - term_side: A - site: "Test Site" - port_speed: 10000 - state: present - register: test_one - - - name: "NETBOX_CIRCUIT_TERMINATION 1: ASSERT - Necessary info creation" - assert: - that: - - test_one is changed - - test_one['diff']['before']['state'] == "absent" - - test_one['diff']['after']['state'] == "present" - - 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" - - - name: "NETBOX_CIRCUIT_TERMINATION 2: Duplicate" - 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" - assert: - that: - - not test_two['changed'] - - 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" - - - name: "NETBOX_CIRCUIT_TERMINATION 3: Update provider with other fields" - 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" - assert: - that: - - test_three is changed - - 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" - - 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_circuit_termination: - netbox_url: http://localhost:32768 - netbox_token: 0123456789abcdef0123456789abcdef01234567 - data: - circuit: Test Circuit - term_side: Z - site: "Test Site" - port_speed: 10000 - state: present - register: test_four - - - name: "NETBOX_CIRCUIT_TERMINATION 4: ASSERT - Create Z Side" - assert: - that: - - test_four is changed - - test_four['diff']['before']['state'] == "absent" - - test_four['diff']['after']['state'] == "present" - - 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" - - - name: "NETBOX_CIRCUIT_TERMINATION 5: Delete provider within 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" - assert: - that: - - 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_five['msg'] == "circuit_termination test_circuit_a deleted" - - - - ## - ## - ### NETBOX_SERVICE - ## - ## - - name: "1 - Device with required information needs to add new service" - 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_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" - assert: - that: - - test_service_create is changed - - test_service_create['services']['name'] == "node-exporter" - - test_service_create['services']['port'] == 9100 - - test_service_create['services']['protocol'] == 6 - - 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_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" - assert: - that: - - test_service_idempotence['services']['name'] == "node-exporter" - - test_service_idempotence['services']['port'] == 9100 - - test_service_idempotence['services']['protocol'] == 6 - - test_service_idempotence['msg'] == "services node-exporter already exists" - - name: "NETBOX_SERVICE: Test update" - 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_update - - - name: "NETBOX_SERVICE ASSERT - Service has been updated" - assert: - that: - - test_service_update is changed - - test_service_update['diff']['before']['protocol'] == 6 - - test_service_update['diff']['after']['protocol'] == 17 - - test_service_update['msg'] == "services node-exporter updated" - - - name: "NETBOX_SERVICE: Test service deletion" - 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" - 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" - -## -## -### NETBOX_LOOKUP -## -## -- name: "TEST NETBOX_LOOKUP" - connection: local - hosts: localhost - gather_facts: False - - tasks: - - name: "NETBOX_LOOKUP 1: Lookup returns exactly two sites" - assert: - that: "{{ query_result|count }} == 3" - vars: - query_result: "{{ query('netbox.netbox.nb_lookup', 'sites', api_endpoint='http://localhost:32768', token='0123456789abcdef0123456789abcdef01234567') }}" - - - name: "NETBOX_LOOKUP 2: Query doesn't return Wibble (sanity check json_query)" - assert: - that: "{{ query_result|json_query('[?value.display_name==`Wibble`]')|count }} == 0" - vars: - query_result: "{{ query('netbox.netbox.nb_lookup', 'devices', api_endpoint='http://localhost:32768', token='0123456789abcdef0123456789abcdef01234567') }}" - - - name: "NETBOX_LOOKUP 3: Device query returns exactly one TestDeviceR1" - assert: - that: "{{ query_result|json_query('[?value.display_name==`TestDeviceR1`]')|count }} == 1" - vars: - query_result: "{{ query('netbox.netbox.nb_lookup', 'devices', api_endpoint='http://localhost:32768', token='0123456789abcdef0123456789abcdef01234567') }}" - - - name: "NETBOX_LOOKUP 4: VLAN ID 400 can be queried and is named 'Test VLAN'" - assert: - that: "{{ (query_result|json_query('[?value.vid==`400`].value.name'))[0] == 'Test VLAN' }}" - vars: - query_result: "{{ query('netbox.netbox.nb_lookup', 'vlans', api_endpoint='http://localhost:32768', token='0123456789abcdef0123456789abcdef01234567') }}" - - - name: "NETBOX_LOOKUP 5: Add one of two devices for lookup filter test." - 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_device: - netbox_url: "http://localhost:32768" - netbox_token: "0123456789abcdef0123456789abcdef01234567" - data: - name: "L2" - device_type: "Cisco Test" - device_role: "Core Switch" - site: "Test Site" - status: "Staged" - tags: - - "lookup" - state: present - - - name: "NETBOX_LOOKUP 7: Device query returns exactly the L2 device" - assert: - that: "{{ query_result|json_query('[?value.display_name==`L2`]')|count }} == 1" - vars: - query_result: "{{ query('netbox.netbox.nb_lookup', 'devices', api_filter='role=core-switch tag=lookup', api_endpoint='http://localhost:32768', token='0123456789abcdef0123456789abcdef01234567') }}" - - - name: "NETBOX_LOOKUP 8: Device query specifying raw data returns payload without key/value dict" - assert: - that: "{{ query_result|json_query('[?display_name==`L2`]')|count }} == 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) }}" diff --git a/tests/integration/integration.cfg b/tests/integration/integration.cfg new file mode 100644 index 000000000..4501b1d8b --- /dev/null +++ b/tests/integration/integration.cfg @@ -0,0 +1,5 @@ +[defaults] +force_valid_group_names = always + +[inventory] +enable_plugins = netbox.netbox.nb_inventory, auto, host_list, yaml, ini, toml, script diff --git a/tests/integration/netbox-deploy.py b/tests/integration/netbox-deploy.py old mode 100644 new mode 100755 index 8b669e8fe..c526412b5 --- a/tests/integration/netbox-deploy.py +++ b/tests/integration/netbox-deploy.py @@ -1,3 +1,9 @@ +#!/usr/bin/env python + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + import pynetbox # Set nb variable to connec to Netbox and use the veriable in future calls @@ -18,9 +24,30 @@ created_tenant_groups = nb.tenancy.tenant_groups.create(tenant_groups) +## Create Regions +regions = [ + {"name": "Test Region", "slug": "test-region"}, + {"name": "Parent Region", "slug": "parent-region"}, + {"name": "Other Region", "slug": "other-region"}, +] +created_regions = nb.dcim.regions.create(regions) +### Region variables to be used later on +parent_region = nb.dcim.regions.get(slug="parent-region") +test_region = nb.dcim.regions.get(slug="test-region") + +### Create relationship between regions +test_region.parent = parent_region +test_region.save() + + ## Create SITES and register variables sites = [ - {"name": "Test Site", "slug": "test-site", "tenant": test_tenant.id}, + { + "name": "Test Site", + "slug": "test-site", + "tenant": test_tenant.id, + "region": test_region.id, + }, {"name": "Test Site2", "slug": "test-site2"}, ] created_sites = nb.dcim.sites.create(sites) @@ -42,11 +69,6 @@ created_prefixes = nb.ipam.prefixes.create(prefixes) -## Create Regions -regions = [{"name": "Test Region", "slug": "test-region"}] -created_regions = nb.dcim.regions.create(regions) - - ## Create VLAN GROUPS vlan_groups = [ { @@ -138,6 +160,7 @@ ## Create Racks racks = [{"name": "Test Rack", "slug": "test-rack", "site": test_site2.id}] created_racks = nb.dcim.racks.create(racks) +test_rack = nb.dcim.racks.get(slug="test-rack") ## Create Rack Groups @@ -159,6 +182,7 @@ "device_type": cisco_test.id, "device_role": core_switch.id, "site": test_site.id, + "local_context_data": {"ntp_servers": ["pool.ntp.org"]}, }, { "name": "TestDeviceR1", @@ -170,7 +194,8 @@ "name": "R1-Device", "device_type": cisco_test.id, "device_role": core_switch.id, - "site": test_site.id, + "site": test_site2.id, + "rack": test_rack.id, }, { "name": "Test Nexus One", diff --git a/tests/integration/targets/inventory/aliases b/tests/integration/targets/inventory/aliases new file mode 100644 index 000000000..a3a2089b9 --- /dev/null +++ b/tests/integration/targets/inventory/aliases @@ -0,0 +1 @@ +# https://docs.ansible.com/ansible/devel/dev_guide/testing/sanity/integration-aliases.html diff --git a/tests/integration/targets/inventory/compare_inventory_json.py b/tests/integration/targets/inventory/compare_inventory_json.py new file mode 100755 index 000000000..c224a5c31 --- /dev/null +++ b/tests/integration/targets/inventory/compare_inventory_json.py @@ -0,0 +1,75 @@ +#!/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 sys +import json +from jsondiff import diff +from typing import Iterable + +# Netbox includes created and last_updated times on objects. +# These end up in the interfaces objects that are included verbatim from the Netbox API. +# Ignore these when performing diffs as they will be different for each test run +ignored_keys = set(["created", "last_updated", "form_factor", "type", "status"]) +# interface "form_factor", "type" and ip_addresses "status" are differnt in Netbox 2.6 vs 2.7 APIs + + +# Assume the object will not be recursive, as it originally came from JSON +def remove_ignored_keys(obj): + + if isinstance(obj, dict): + keys_to_remove = ignored_keys.intersection(obj.keys()) + for key in keys_to_remove: + del obj[key] + + for (key, value) in obj.items(): + remove_ignored_keys(value) + + elif isinstance(obj, list): + for item in obj: + remove_ignored_keys(item) + + +def main(): + if len(sys.argv) != 3: + print( + "Error: Must have exactly 2 file to compare passed as arguments. Received %i." + % (len(sys.argv) - 1), + file=sys.stderr, + ) + sys.exit(2) + + a = sys.argv[1] + b = sys.argv[2] + + with open(a, "r") as f: + adata = json.loads(f.read()) + with open(b, "r") as f: + bdata = json.loads(f.read()) + + # Remove keys that we don't want to diff + # ie. times that will change on each run of tests + remove_ignored_keys(adata) + remove_ignored_keys(bdata) + + # Perform the diff + # syntax='symmetric' will produce output that prints both the before and after as "$insert" and "$delete" + # marshal=True removes any special types, allowing to be dumped as json + result = diff(adata, bdata, marshal=True, syntax="symmetric") + + if result: + # Dictionary is not empty - print differences + print(json.dumps(result, sort_keys=True, indent=4)) + sys.exit(1) + else: + # Success, no differences + sys.exit(0) + + +if __name__ == "__main__": + main() diff --git a/tests/integration/targets/inventory/files/test-inventory-legacy.json b/tests/integration/targets/inventory/files/test-inventory-legacy.json new file mode 100644 index 000000000..3c5c1ec8d --- /dev/null +++ b/tests/integration/targets/inventory/files/test-inventory-legacy.json @@ -0,0 +1,183 @@ +{ + "_meta": { + "hostvars": { + "R1-Device": { + "custom_fields": {}, + "device_roles": [ + "core-switch" + ], + "device_types": [ + "cisco-test" + ], + "manufacturers": [ + "cisco" + ], + "racks": [ + "Test Rack" + ], + "regions": [], + "services": [], + "sites": [ + "test-site2" + ], + "tags": [] + }, + "Test Nexus Child One": { + "custom_fields": {}, + "device_roles": [ + "core-switch" + ], + "device_types": [ + "nexus-child" + ], + "manufacturers": [ + "cisco" + ], + "regions": [ + "test-region", + "parent-region" + ], + "sites": [ + "test-site" + ], + "tags": [] + }, + "Test Nexus One": { + "custom_fields": {}, + "device_roles": [ + "core-switch" + ], + "device_types": [ + "nexus-parent" + ], + "manufacturers": [ + "cisco" + ], + "regions": [ + "test-region", + "parent-region" + ], + "sites": [ + "test-site" + ], + "tags": [] + }, + "TestDeviceR1": { + "custom_fields": {}, + "device_roles": [ + "core-switch" + ], + "device_types": [ + "cisco-test" + ], + "manufacturers": [ + "cisco" + ], + "regions": [ + "test-region", + "parent-region" + ], + "services": [], + "sites": [ + "test-site" + ], + "tags": [] + }, + "test100": { + "custom_fields": {}, + "device_roles": [ + "core-switch" + ], + "device_types": [ + "cisco-test" + ], + "manufacturers": [ + "cisco" + ], + "regions": [ + "test-region", + "parent-region" + ], + "services": [], + "sites": [ + "test-site" + ], + "tags": [] + }, + "test100-vm": { + "custom_fields": {}, + "regions": [ + "test-region", + "parent-region" + ], + "sites": [ + "test-site" + ], + "tags": [] + }, + "test101-vm": { + "custom_fields": {}, + "regions": [ + "test-region", + "parent-region" + ], + "sites": [ + "test-site" + ], + "tags": [] + }, + "test102-vm": { + "custom_fields": {}, + "regions": [ + "test-region", + "parent-region" + ], + "sites": [ + "test-site" + ], + "tags": [] + }, + "test103-vm": { + "custom_fields": {}, + "regions": [ + "test-region", + "parent-region" + ], + "sites": [ + "test-site" + ], + "tags": [] + }, + "test104-vm": { + "custom_fields": {}, + "regions": [ + "test-region", + "parent-region" + ], + "sites": [ + "test-site" + ], + "tags": [] + } + } + }, + "all": { + "children": [ + "ungrouped" + ] + }, + "ungrouped": { + "hosts": [ + "R1-Device", + "Test Nexus Child One", + "Test Nexus One", + "TestDeviceR1", + "test100", + "test100-vm", + "test101-vm", + "test102-vm", + "test103-vm", + "test104-vm" + ] + } +} \ No newline at end of file diff --git a/tests/integration/targets/inventory/files/test-inventory-legacy.yml b/tests/integration/targets/inventory/files/test-inventory-legacy.yml new file mode 100644 index 000000000..9aafebf87 --- /dev/null +++ b/tests/integration/targets/inventory/files/test-inventory-legacy.yml @@ -0,0 +1,9 @@ +# 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/files/test-inventory-options.json b/tests/integration/targets/inventory/files/test-inventory-options.json new file mode 100644 index 000000000..374a9cb1b --- /dev/null +++ b/tests/integration/targets/inventory/files/test-inventory-options.json @@ -0,0 +1,205 @@ +{ + "Test_Rack": { + "hosts": [ + "R1-Device" + ] + }, + "_meta": { + "hostvars": { + "R1-Device": { + "custom_fields": {}, + "device_type": "cisco-test", + "display": "R1-Device", + "manufacturer": "cisco", + "rack": "Test Rack", + "rack_id": "1", + "regions": [], + "role": "core-switch", + "site": "test-site2", + "tags": [] + }, + "Test Nexus Child One": { + "custom_fields": {}, + "device_type": "nexus-child", + "display": "Test Nexus Child One", + "manufacturer": "cisco", + "regions": [ + "test-region", + "parent-region" + ], + "role": "core-switch", + "site": "test-site", + "tags": [] + }, + "Test Nexus One": { + "custom_fields": {}, + "device_type": "nexus-parent", + "display": "Test Nexus One", + "manufacturer": "cisco", + "regions": [ + "test-region", + "parent-region" + ], + "role": "core-switch", + "site": "test-site", + "tags": [] + }, + "TestDeviceR1": { + "custom_fields": {}, + "device_type": "cisco-test", + "display": "TestDeviceR1", + "manufacturer": "cisco", + "regions": [ + "test-region", + "parent-region" + ], + "role": "core-switch", + "site": "test-site", + "tags": [] + }, + "test100": { + "custom_fields": {}, + "device_type": "cisco-test", + "display": "test100", + "manufacturer": "cisco", + "regions": [ + "test-region", + "parent-region" + ], + "role": "core-switch", + "site": "test-site", + "tags": [] + }, + "test100-vm": { + "custom_fields": {}, + "regions": [ + "test-region", + "parent-region" + ], + "site": "test-site", + "tags": [] + }, + "test101-vm": { + "custom_fields": {}, + "regions": [ + "test-region", + "parent-region" + ], + "site": "test-site", + "tags": [] + }, + "test102-vm": { + "custom_fields": {}, + "regions": [ + "test-region", + "parent-region" + ], + "site": "test-site", + "tags": [] + }, + "test103-vm": { + "custom_fields": {}, + "regions": [ + "test-region", + "parent-region" + ], + "site": "test-site", + "tags": [] + }, + "test104-vm": { + "custom_fields": {}, + "regions": [ + "test-region", + "parent-region" + ], + "site": "test-site", + "tags": [] + } + } + }, + "all": { + "children": [ + "Test_Rack", + "cisco", + "cisco_test", + "core_switch", + "jinja_test_group", + "nexus_child", + "nexus_parent", + "other_region", + "parent_region", + "test_site2", + "ungrouped" + ] + }, + "cisco": { + "hosts": [ + "R1-Device", + "Test Nexus Child One", + "Test Nexus One", + "TestDeviceR1", + "test100" + ] + }, + "cisco_test": { + "hosts": [ + "R1-Device", + "TestDeviceR1", + "test100" + ] + }, + "core_switch": { + "hosts": [ + "R1-Device", + "Test Nexus Child One", + "Test Nexus One", + "TestDeviceR1", + "test100" + ] + }, + "jinja_test_group": { + "hosts": [ + "Test Nexus Child One", + "Test Nexus One", + "TestDeviceR1" + ] + }, + "nexus_child": { + "hosts": [ + "Test Nexus Child One" + ] + }, + "nexus_parent": { + "hosts": [ + "Test Nexus One" + ] + }, + "parent_region": { + "children": [ + "test_region" + ] + }, + "test_region": { + "children": [ + "test_site" + ] + }, + "test_site": { + "hosts": [ + "Test Nexus Child One", + "Test Nexus One", + "TestDeviceR1", + "test100", + "test100-vm", + "test101-vm", + "test102-vm", + "test103-vm", + "test104-vm" + ] + }, + "test_site2": { + "hosts": [ + "R1-Device" + ] + } +} \ No newline at end of file diff --git a/tests/integration/targets/inventory/files/test-inventory-options.yml b/tests/integration/targets/inventory/files/test-inventory-options.yml new file mode 100644 index 000000000..a365c96a1 --- /dev/null +++ b/tests/integration/targets/inventory/files/test-inventory-options.yml @@ -0,0 +1,51 @@ +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 + +group_by: + - site + - tenant + - rack + - tag + - role + - device_type + - manufacturer + - platform + - region + +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: + display: display_name + 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/files/test-inventory-plurals.json b/tests/integration/targets/inventory/files/test-inventory-plurals.json new file mode 100644 index 000000000..0a6eeeb88 --- /dev/null +++ b/tests/integration/targets/inventory/files/test-inventory-plurals.json @@ -0,0 +1,681 @@ +{ + "_meta": { + "hostvars": { + "R1-Device": { + "config_context": [ + {} + ], + "custom_fields": {}, + "device_roles": [ + "core-switch" + ], + "device_types": [ + "cisco-test" + ], + "interfaces": [], + "manufacturers": [ + "cisco" + ], + "racks": [ + "Test Rack" + ], + "regions": [], + "services": [], + "sites": [ + "test-site2" + ], + "tags": [] + }, + "Test Nexus Child One": { + "config_context": [ + {} + ], + "custom_fields": {}, + "device_roles": [ + "core-switch" + ], + "device_types": [ + "nexus-child" + ], + "interfaces": [], + "manufacturers": [ + "cisco" + ], + "regions": [ + "test-region", + "parent-region" + ], + "sites": [ + "test-site" + ], + "tags": [] + }, + "Test Nexus One": { + "config_context": [ + {} + ], + "custom_fields": {}, + "device_roles": [ + "core-switch" + ], + "device_types": [ + "nexus-parent" + ], + "interfaces": [ + { + "cable": null, + "connected_endpoint": null, + "connected_endpoint_type": null, + "connection_status": null, + "count_ipaddresses": 0, + "description": "", + "device": { + "display_name": "Test Nexus One", + "id": 4, + "name": "Test Nexus One", + "url": "http://localhost:32768/api/dcim/devices/4/" + }, + "enabled": true, + "id": 1, + "ip_addresses": [], + "lag": null, + "mac_address": null, + "mgmt_only": false, + "mode": null, + "mtu": null, + "name": "Ethernet1/1", + "tagged_vlans": [], + "tags": [], + "type": { + "id": 1000, + "label": "1000BASE-T (1GE)", + "value": "1000base-t" + }, + "untagged_vlan": null + } + ], + "manufacturers": [ + "cisco" + ], + "regions": [ + "test-region", + "parent-region" + ], + "sites": [ + "test-site" + ], + "tags": [] + }, + "TestDeviceR1": { + "config_context": [ + {} + ], + "custom_fields": {}, + "device_roles": [ + "core-switch" + ], + "device_types": [ + "cisco-test" + ], + "interfaces": [], + "manufacturers": [ + "cisco" + ], + "regions": [ + "test-region", + "parent-region" + ], + "services": [], + "sites": [ + "test-site" + ], + "tags": [] + }, + "test100": { + "config_context": [ + { + "ntp_servers": [ + "pool.ntp.org" + ] + } + ], + "custom_fields": {}, + "device_roles": [ + "core-switch" + ], + "device_types": [ + "cisco-test" + ], + "interfaces": [ + { + "cable": null, + "connected_endpoint": null, + "connected_endpoint_type": null, + "connection_status": null, + "count_ipaddresses": 1, + "description": "", + "device": { + "display_name": "test100", + "id": 1, + "name": "test100", + "url": "http://localhost:32768/api/dcim/devices/1/" + }, + "enabled": true, + "id": 2, + "ip_addresses": [ + { + "address": "172.16.180.1/24", + "created": "2020-04-21", + "custom_fields": {}, + "description": "", + "dns_name": "", + "family": { + "label": "IPv4", + "value": 4 + }, + "id": 1, + "interface": { + "device": { + "display_name": "test100", + "id": 1, + "name": "test100", + "url": "http://localhost:32768/api/dcim/devices/1/" + }, + "id": 2, + "name": "GigabitEthernet1", + "url": "http://localhost:32768/api/dcim/interfaces/2/", + "virtual_machine": null + }, + "last_updated": "2020-04-21T14:01:20.151503Z", + "nat_inside": null, + "nat_outside": null, + "role": null, + "status": { + "id": 1, + "label": "Active", + "value": "active" + }, + "tags": [], + "tenant": null, + "vrf": null + } + ], + "lag": null, + "mac_address": null, + "mgmt_only": false, + "mode": null, + "mtu": null, + "name": "GigabitEthernet1", + "tagged_vlans": [], + "tags": [], + "type": { + "id": 1000, + "label": "1000BASE-T (1GE)", + "value": "1000base-t" + }, + "untagged_vlan": null + }, + { + "cable": null, + "connected_endpoint": null, + "connected_endpoint_type": null, + "connection_status": null, + "count_ipaddresses": 1, + "description": "", + "device": { + "display_name": "test100", + "id": 1, + "name": "test100", + "url": "http://localhost:32768/api/dcim/devices/1/" + }, + "enabled": true, + "id": 3, + "ip_addresses": [ + { + "address": "2001::1:1/64", + "created": "2020-04-21", + "custom_fields": {}, + "description": "", + "dns_name": "", + "family": { + "label": "IPv6", + "value": 6 + }, + "id": 2, + "interface": { + "device": { + "display_name": "test100", + "id": 1, + "name": "test100", + "url": "http://localhost:32768/api/dcim/devices/1/" + }, + "id": 3, + "name": "GigabitEthernet2", + "url": "http://localhost:32768/api/dcim/interfaces/3/", + "virtual_machine": null + }, + "last_updated": "2020-04-21T14:01:20.156802Z", + "nat_inside": null, + "nat_outside": null, + "role": null, + "status": { + "id": 1, + "label": "Active", + "value": "active" + }, + "tags": [], + "tenant": null, + "vrf": null + } + ], + "lag": null, + "mac_address": null, + "mgmt_only": false, + "mode": null, + "mtu": null, + "name": "GigabitEthernet2", + "tagged_vlans": [], + "tags": [], + "type": { + "id": 1000, + "label": "1000BASE-T (1GE)", + "value": "1000base-t" + }, + "untagged_vlan": null + } + ], + "manufacturers": [ + "cisco" + ], + "regions": [ + "test-region", + "parent-region" + ], + "services": [], + "sites": [ + "test-site" + ], + "tags": [] + }, + "test100-vm": { + "config_context": [ + {} + ], + "custom_fields": {}, + "interfaces": [ + { + "description": "", + "enabled": true, + "id": 4, + "ip_addresses": [], + "mac_address": null, + "mode": null, + "mtu": null, + "name": "Eth0", + "tagged_vlans": [], + "tags": [], + "type": { + "label": "Virtual", + "value": "virtual" + }, + "untagged_vlan": null, + "virtual_machine": { + "id": 1, + "name": "test100-vm", + "url": "http://localhost:32768/api/virtualization/virtual-machines/1/" + } + }, + { + "description": "", + "enabled": true, + "id": 5, + "ip_addresses": [], + "mac_address": null, + "mode": null, + "mtu": null, + "name": "Eth1", + "tagged_vlans": [], + "tags": [], + "type": { + "label": "Virtual", + "value": "virtual" + }, + "untagged_vlan": null, + "virtual_machine": { + "id": 1, + "name": "test100-vm", + "url": "http://localhost:32768/api/virtualization/virtual-machines/1/" + } + }, + { + "description": "", + "enabled": true, + "id": 6, + "ip_addresses": [], + "mac_address": null, + "mode": null, + "mtu": null, + "name": "Eth2", + "tagged_vlans": [], + "tags": [], + "type": { + "label": "Virtual", + "value": "virtual" + }, + "untagged_vlan": null, + "virtual_machine": { + "id": 1, + "name": "test100-vm", + "url": "http://localhost:32768/api/virtualization/virtual-machines/1/" + } + }, + { + "description": "", + "enabled": true, + "id": 7, + "ip_addresses": [], + "mac_address": null, + "mode": null, + "mtu": null, + "name": "Eth3", + "tagged_vlans": [], + "tags": [], + "type": { + "label": "Virtual", + "value": "virtual" + }, + "untagged_vlan": null, + "virtual_machine": { + "id": 1, + "name": "test100-vm", + "url": "http://localhost:32768/api/virtualization/virtual-machines/1/" + } + }, + { + "description": "", + "enabled": true, + "id": 8, + "ip_addresses": [], + "mac_address": null, + "mode": null, + "mtu": null, + "name": "Eth4", + "tagged_vlans": [], + "tags": [], + "type": { + "label": "Virtual", + "value": "virtual" + }, + "untagged_vlan": null, + "virtual_machine": { + "id": 1, + "name": "test100-vm", + "url": "http://localhost:32768/api/virtualization/virtual-machines/1/" + } + } + ], + "regions": [ + "test-region", + "parent-region" + ], + "sites": [ + "test-site" + ], + "tags": [] + }, + "test101-vm": { + "config_context": [ + {} + ], + "custom_fields": {}, + "interfaces": [ + { + "description": "", + "enabled": true, + "id": 9, + "ip_addresses": [], + "mac_address": null, + "mode": null, + "mtu": null, + "name": "Eth0", + "tagged_vlans": [], + "tags": [], + "type": { + "label": "Virtual", + "value": "virtual" + }, + "untagged_vlan": null, + "virtual_machine": { + "id": 2, + "name": "test101-vm", + "url": "http://localhost:32768/api/virtualization/virtual-machines/2/" + } + }, + { + "description": "", + "enabled": true, + "id": 10, + "ip_addresses": [], + "mac_address": null, + "mode": null, + "mtu": null, + "name": "Eth1", + "tagged_vlans": [], + "tags": [], + "type": { + "label": "Virtual", + "value": "virtual" + }, + "untagged_vlan": null, + "virtual_machine": { + "id": 2, + "name": "test101-vm", + "url": "http://localhost:32768/api/virtualization/virtual-machines/2/" + } + }, + { + "description": "", + "enabled": true, + "id": 11, + "ip_addresses": [], + "mac_address": null, + "mode": null, + "mtu": null, + "name": "Eth2", + "tagged_vlans": [], + "tags": [], + "type": { + "label": "Virtual", + "value": "virtual" + }, + "untagged_vlan": null, + "virtual_machine": { + "id": 2, + "name": "test101-vm", + "url": "http://localhost:32768/api/virtualization/virtual-machines/2/" + } + }, + { + "description": "", + "enabled": true, + "id": 12, + "ip_addresses": [], + "mac_address": null, + "mode": null, + "mtu": null, + "name": "Eth3", + "tagged_vlans": [], + "tags": [], + "type": { + "label": "Virtual", + "value": "virtual" + }, + "untagged_vlan": null, + "virtual_machine": { + "id": 2, + "name": "test101-vm", + "url": "http://localhost:32768/api/virtualization/virtual-machines/2/" + } + }, + { + "description": "", + "enabled": true, + "id": 13, + "ip_addresses": [], + "mac_address": null, + "mode": null, + "mtu": null, + "name": "Eth4", + "tagged_vlans": [], + "tags": [], + "type": { + "label": "Virtual", + "value": "virtual" + }, + "untagged_vlan": null, + "virtual_machine": { + "id": 2, + "name": "test101-vm", + "url": "http://localhost:32768/api/virtualization/virtual-machines/2/" + } + } + ], + "regions": [ + "test-region", + "parent-region" + ], + "sites": [ + "test-site" + ], + "tags": [] + }, + "test102-vm": { + "config_context": [ + {} + ], + "custom_fields": {}, + "interfaces": [], + "regions": [ + "test-region", + "parent-region" + ], + "sites": [ + "test-site" + ], + "tags": [] + }, + "test103-vm": { + "config_context": [ + {} + ], + "custom_fields": {}, + "interfaces": [], + "regions": [ + "test-region", + "parent-region" + ], + "sites": [ + "test-site" + ], + "tags": [] + }, + "test104-vm": { + "config_context": [ + {} + ], + "custom_fields": {}, + "interfaces": [], + "regions": [ + "test-region", + "parent-region" + ], + "sites": [ + "test-site" + ], + "tags": [] + } + } + }, + "all": { + "children": [ + "device_roles_core_switch", + "device_types_cisco_test", + "device_types_nexus_child", + "device_types_nexus_parent", + "manufacturers_cisco", + "racks_Test_Rack", + "region_other_region", + "region_parent_region", + "sites_test_site2", + "ungrouped" + ] + }, + "device_roles_core_switch": { + "hosts": [ + "R1-Device", + "Test Nexus Child One", + "Test Nexus One", + "TestDeviceR1", + "test100" + ] + }, + "device_types_cisco_test": { + "hosts": [ + "R1-Device", + "TestDeviceR1", + "test100" + ] + }, + "device_types_nexus_child": { + "hosts": [ + "Test Nexus Child One" + ] + }, + "device_types_nexus_parent": { + "hosts": [ + "Test Nexus One" + ] + }, + "manufacturers_cisco": { + "hosts": [ + "R1-Device", + "Test Nexus Child One", + "Test Nexus One", + "TestDeviceR1", + "test100" + ] + }, + "racks_Test_Rack": { + "hosts": [ + "R1-Device" + ] + }, + "region_parent_region": { + "children": [ + "region_test_region" + ] + }, + "region_test_region": { + "children": [ + "sites_test_site" + ] + }, + "sites_test_site": { + "hosts": [ + "Test Nexus Child One", + "Test Nexus One", + "TestDeviceR1", + "test100", + "test100-vm", + "test101-vm", + "test102-vm", + "test103-vm", + "test104-vm" + ] + }, + "sites_test_site2": { + "hosts": [ + "R1-Device" + ] + } +} diff --git a/tests/integration/targets/inventory/files/test-inventory-plurals.yml b/tests/integration/targets/inventory/files/test-inventory-plurals.yml new file mode 100644 index 000000000..545c64048 --- /dev/null +++ b/tests/integration/targets/inventory/files/test-inventory-plurals.yml @@ -0,0 +1,25 @@ +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 + +group_by: + - sites + - tenants + - racks + - tags + - device_roles + - device_types + - manufacturers + - platforms + - region diff --git a/tests/integration/targets/inventory/files/test-inventory.json b/tests/integration/targets/inventory/files/test-inventory.json new file mode 100644 index 000000000..381e11146 --- /dev/null +++ b/tests/integration/targets/inventory/files/test-inventory.json @@ -0,0 +1,609 @@ +{ + "_meta": { + "hostvars": { + "R1-Device": { + "config_context": {}, + "custom_fields": {}, + "device_type": "cisco-test", + "interfaces": [], + "manufacturer": "cisco", + "rack": "Test Rack", + "regions": [], + "role": "core-switch", + "services": [], + "site": "test-site2", + "tags": [] + }, + "Test Nexus Child One": { + "config_context": {}, + "custom_fields": {}, + "device_type": "nexus-child", + "interfaces": [], + "manufacturer": "cisco", + "regions": [ + "test-region", + "parent-region" + ], + "role": "core-switch", + "site": "test-site", + "tags": [] + }, + "Test Nexus One": { + "config_context": {}, + "custom_fields": {}, + "device_type": "nexus-parent", + "interfaces": [ + { + "cable": null, + "connected_endpoint": null, + "connected_endpoint_type": null, + "connection_status": null, + "count_ipaddresses": 0, + "description": "", + "device": { + "display_name": "Test Nexus One", + "id": 4, + "name": "Test Nexus One", + "url": "http://localhost:32768/api/dcim/devices/4/" + }, + "enabled": true, + "id": 1, + "ip_addresses": [], + "lag": null, + "mac_address": null, + "mgmt_only": false, + "mode": null, + "mtu": null, + "name": "Ethernet1/1", + "tagged_vlans": [], + "tags": [], + "type": { + "id": 1000, + "label": "1000BASE-T (1GE)", + "value": "1000base-t" + }, + "untagged_vlan": null + } + ], + "manufacturer": "cisco", + "regions": [ + "test-region", + "parent-region" + ], + "role": "core-switch", + "site": "test-site", + "tags": [] + }, + "TestDeviceR1": { + "config_context": {}, + "custom_fields": {}, + "device_type": "cisco-test", + "interfaces": [], + "manufacturer": "cisco", + "regions": [ + "test-region", + "parent-region" + ], + "role": "core-switch", + "services": [], + "site": "test-site", + "tags": [] + }, + "test100": { + "config_context": { + "ntp_servers": [ + "pool.ntp.org" + ] + }, + "custom_fields": {}, + "device_type": "cisco-test", + "interfaces": [ + { + "cable": null, + "connected_endpoint": null, + "connected_endpoint_type": null, + "connection_status": null, + "count_ipaddresses": 1, + "description": "", + "device": { + "display_name": "test100", + "id": 1, + "name": "test100", + "url": "http://localhost:32768/api/dcim/devices/1/" + }, + "enabled": true, + "id": 2, + "ip_addresses": [ + { + "address": "172.16.180.1/24", + "created": "2020-04-21", + "custom_fields": {}, + "description": "", + "dns_name": "", + "family": { + "label": "IPv4", + "value": 4 + }, + "id": 1, + "interface": { + "device": { + "display_name": "test100", + "id": 1, + "name": "test100", + "url": "http://localhost:32768/api/dcim/devices/1/" + }, + "id": 2, + "name": "GigabitEthernet1", + "url": "http://localhost:32768/api/dcim/interfaces/2/", + "virtual_machine": null + }, + "last_updated": "2020-04-21T14:01:20.151503Z", + "nat_inside": null, + "nat_outside": null, + "role": null, + "status": { + "id": 1, + "label": "Active", + "value": "active" + }, + "tags": [], + "tenant": null, + "vrf": null + } + ], + "lag": null, + "mac_address": null, + "mgmt_only": false, + "mode": null, + "mtu": null, + "name": "GigabitEthernet1", + "tagged_vlans": [], + "tags": [], + "type": { + "id": 1000, + "label": "1000BASE-T (1GE)", + "value": "1000base-t" + }, + "untagged_vlan": null + }, + { + "cable": null, + "connected_endpoint": null, + "connected_endpoint_type": null, + "connection_status": null, + "count_ipaddresses": 1, + "description": "", + "device": { + "display_name": "test100", + "id": 1, + "name": "test100", + "url": "http://localhost:32768/api/dcim/devices/1/" + }, + "enabled": true, + "id": 3, + "ip_addresses": [ + { + "address": "2001::1:1/64", + "created": "2020-04-21", + "custom_fields": {}, + "description": "", + "dns_name": "", + "family": { + "label": "IPv6", + "value": 6 + }, + "id": 2, + "interface": { + "device": { + "display_name": "test100", + "id": 1, + "name": "test100", + "url": "http://localhost:32768/api/dcim/devices/1/" + }, + "id": 3, + "name": "GigabitEthernet2", + "url": "http://localhost:32768/api/dcim/interfaces/3/", + "virtual_machine": null + }, + "last_updated": "2020-04-21T14:01:20.156802Z", + "nat_inside": null, + "nat_outside": null, + "role": null, + "status": { + "id": 1, + "label": "Active", + "value": "active" + }, + "tags": [], + "tenant": null, + "vrf": null + } + ], + "lag": null, + "mac_address": null, + "mgmt_only": false, + "mode": null, + "mtu": null, + "name": "GigabitEthernet2", + "tagged_vlans": [], + "tags": [], + "type": { + "id": 1000, + "label": "1000BASE-T (1GE)", + "value": "1000base-t" + }, + "untagged_vlan": null + } + ], + "manufacturer": "cisco", + "regions": [ + "test-region", + "parent-region" + ], + "role": "core-switch", + "services": [], + "site": "test-site", + "tags": [] + }, + "test100-vm": { + "config_context": {}, + "custom_fields": {}, + "interfaces": [ + { + "description": "", + "enabled": true, + "id": 4, + "ip_addresses": [], + "mac_address": null, + "mode": null, + "mtu": null, + "name": "Eth0", + "tagged_vlans": [], + "tags": [], + "type": { + "label": "Virtual", + "value": "virtual" + }, + "untagged_vlan": null, + "virtual_machine": { + "id": 1, + "name": "test100-vm", + "url": "http://localhost:32768/api/virtualization/virtual-machines/1/" + } + }, + { + "description": "", + "enabled": true, + "id": 5, + "ip_addresses": [], + "mac_address": null, + "mode": null, + "mtu": null, + "name": "Eth1", + "tagged_vlans": [], + "tags": [], + "type": { + "label": "Virtual", + "value": "virtual" + }, + "untagged_vlan": null, + "virtual_machine": { + "id": 1, + "name": "test100-vm", + "url": "http://localhost:32768/api/virtualization/virtual-machines/1/" + } + }, + { + "description": "", + "enabled": true, + "id": 6, + "ip_addresses": [], + "mac_address": null, + "mode": null, + "mtu": null, + "name": "Eth2", + "tagged_vlans": [], + "tags": [], + "type": { + "label": "Virtual", + "value": "virtual" + }, + "untagged_vlan": null, + "virtual_machine": { + "id": 1, + "name": "test100-vm", + "url": "http://localhost:32768/api/virtualization/virtual-machines/1/" + } + }, + { + "description": "", + "enabled": true, + "id": 7, + "ip_addresses": [], + "mac_address": null, + "mode": null, + "mtu": null, + "name": "Eth3", + "tagged_vlans": [], + "tags": [], + "type": { + "label": "Virtual", + "value": "virtual" + }, + "untagged_vlan": null, + "virtual_machine": { + "id": 1, + "name": "test100-vm", + "url": "http://localhost:32768/api/virtualization/virtual-machines/1/" + } + }, + { + "description": "", + "enabled": true, + "id": 8, + "ip_addresses": [], + "mac_address": null, + "mode": null, + "mtu": null, + "name": "Eth4", + "tagged_vlans": [], + "tags": [], + "type": { + "label": "Virtual", + "value": "virtual" + }, + "untagged_vlan": null, + "virtual_machine": { + "id": 1, + "name": "test100-vm", + "url": "http://localhost:32768/api/virtualization/virtual-machines/1/" + } + } + ], + "regions": [ + "test-region", + "parent-region" + ], + "site": "test-site", + "tags": [] + }, + "test101-vm": { + "config_context": {}, + "custom_fields": {}, + "interfaces": [ + { + "description": "", + "enabled": true, + "id": 9, + "ip_addresses": [], + "mac_address": null, + "mode": null, + "mtu": null, + "name": "Eth0", + "tagged_vlans": [], + "tags": [], + "type": { + "label": "Virtual", + "value": "virtual" + }, + "untagged_vlan": null, + "virtual_machine": { + "id": 2, + "name": "test101-vm", + "url": "http://localhost:32768/api/virtualization/virtual-machines/2/" + } + }, + { + "description": "", + "enabled": true, + "id": 10, + "ip_addresses": [], + "mac_address": null, + "mode": null, + "mtu": null, + "name": "Eth1", + "tagged_vlans": [], + "tags": [], + "type": { + "label": "Virtual", + "value": "virtual" + }, + "untagged_vlan": null, + "virtual_machine": { + "id": 2, + "name": "test101-vm", + "url": "http://localhost:32768/api/virtualization/virtual-machines/2/" + } + }, + { + "description": "", + "enabled": true, + "id": 11, + "ip_addresses": [], + "mac_address": null, + "mode": null, + "mtu": null, + "name": "Eth2", + "tagged_vlans": [], + "tags": [], + "type": { + "label": "Virtual", + "value": "virtual" + }, + "untagged_vlan": null, + "virtual_machine": { + "id": 2, + "name": "test101-vm", + "url": "http://localhost:32768/api/virtualization/virtual-machines/2/" + } + }, + { + "description": "", + "enabled": true, + "id": 12, + "ip_addresses": [], + "mac_address": null, + "mode": null, + "mtu": null, + "name": "Eth3", + "tagged_vlans": [], + "tags": [], + "type": { + "label": "Virtual", + "value": "virtual" + }, + "untagged_vlan": null, + "virtual_machine": { + "id": 2, + "name": "test101-vm", + "url": "http://localhost:32768/api/virtualization/virtual-machines/2/" + } + }, + { + "description": "", + "enabled": true, + "id": 13, + "ip_addresses": [], + "mac_address": null, + "mode": null, + "mtu": null, + "name": "Eth4", + "tagged_vlans": [], + "tags": [], + "type": { + "label": "Virtual", + "value": "virtual" + }, + "untagged_vlan": null, + "virtual_machine": { + "id": 2, + "name": "test101-vm", + "url": "http://localhost:32768/api/virtualization/virtual-machines/2/" + } + } + ], + "regions": [ + "test-region", + "parent-region" + ], + "site": "test-site", + "tags": [] + }, + "test102-vm": { + "config_context": {}, + "custom_fields": {}, + "interfaces": [], + "regions": [ + "test-region", + "parent-region" + ], + "site": "test-site", + "tags": [] + }, + "test103-vm": { + "config_context": {}, + "custom_fields": {}, + "interfaces": [], + "regions": [ + "test-region", + "parent-region" + ], + "site": "test-site", + "tags": [] + }, + "test104-vm": { + "config_context": {}, + "custom_fields": {}, + "interfaces": [], + "regions": [ + "test-region", + "parent-region" + ], + "site": "test-site", + "tags": [] + } + } + }, + "all": { + "children": [ + "device_type_cisco_test", + "device_type_nexus_child", + "device_type_nexus_parent", + "manufacturer_cisco", + "rack_Test_Rack", + "region_other_region", + "region_parent_region", + "role_core_switch", + "site_test_site2", + "ungrouped" + ] + }, + "device_type_cisco_test": { + "hosts": [ + "R1-Device", + "TestDeviceR1", + "test100" + ] + }, + "device_type_nexus_child": { + "hosts": [ + "Test Nexus Child One" + ] + }, + "device_type_nexus_parent": { + "hosts": [ + "Test Nexus One" + ] + }, + "manufacturer_cisco": { + "hosts": [ + "R1-Device", + "Test Nexus Child One", + "Test Nexus One", + "TestDeviceR1", + "test100" + ] + }, + "rack_Test_Rack": { + "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 Child One", + "Test Nexus One", + "TestDeviceR1", + "test100" + ] + }, + "site_test_site": { + "hosts": [ + "Test Nexus Child One", + "Test Nexus One", + "TestDeviceR1", + "test100", + "test100-vm", + "test101-vm", + "test102-vm", + "test103-vm", + "test104-vm" + ] + }, + "site_test_site2": { + "hosts": [ + "R1-Device" + ] + } +} diff --git a/tests/integration/targets/inventory/files/test-inventory.yml b/tests/integration/targets/inventory/files/test-inventory.yml new file mode 100644 index 000000000..efd12ede0 --- /dev/null +++ b/tests/integration/targets/inventory/files/test-inventory.yml @@ -0,0 +1,20 @@ +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 + - tag + - role + - device_type + - manufacturer + - platform + - region diff --git a/tests/integration/targets/inventory/runme.sh b/tests/integration/targets/inventory/runme.sh new file mode 100755 index 000000000..c871db9ed --- /dev/null +++ b/tests/integration/targets/inventory/runme.sh @@ -0,0 +1,53 @@ +#!/usr/bin/env bash + +# Print commands as they're run +set -x + +# Directory of this script +SCRIPT_DIR="$( dirname "${BASH_SOURCE[0]}" )" + +INVENTORIES_DIR="$SCRIPT_DIR/files" + +# 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" +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 + python.py "$(command -v ansible-inventory)" "$@" + fi +} + + +RESULT=0 + +for INVENTORY in "$INVENTORIES_DIR"/*.yml +do + NAME="$(basename "$INVENTORY")" + NAME_WITHOUT_EXTENSION="${NAME%.yml}" + + # 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 + 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" "$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/latest/tasks/main.yml b/tests/integration/targets/latest/tasks/main.yml new file mode 100644 index 000000000..34547fd9f --- /dev/null +++ b/tests/integration/targets/latest/tasks/main.yml @@ -0,0 +1,102 @@ +--- +- name: "NETBOX_DEVICE TESTS" + include_tasks: "netbox_device.yml" + +- name: "NETBOX_DEVICE_INTERFACE TESTS" + include_tasks: "netbox_device_interface.yml" + +- name: "NETBOX_IP_ADDRESS TESTS" + include_tasks: "netbox_ip_address.yml" + +- name: "NETBOX_PREFIX TESTS" + include_tasks: "netbox_prefix.yml" + +- name: "NETBOX_SITE TESTS" + include_tasks: "netbox_site.yml" + +- name: "NETBOX_TENTANT TESTS" + include_tasks: "netbox_tenant.yml" + +- name: "NETBOX_TENTANT_GROUP TESTS" + include_tasks: "netbox_tenant_group.yml" + +- name: "NETBOX_RACK TESTS" + include_tasks: "netbox_rack.yml" + +- name: "NETBOX_RACK_ROLE TESTS" + include_tasks: "netbox_rack_role.yml" + +- name: "NETBOX_RACK_GROUP TESTS" + include_tasks: "netbox_rack_group.yml" + +- name: "NETBOX_MANUFACTURER TESTS" + include_tasks: "netbox_manufacturer.yml" + +- name: "NETBOX_PLATFORM TESTS" + include_tasks: "netbox_platform.yml" + +- name: "NETBOX_DEVICE_TYPE TESTS" + include_tasks: "netbox_device_type.yml" + +- name: "NETBOX_DEVICE_ROLE TESTS" + include_tasks: "netbox_device_role.yml" + +- name: "NETBOX_IPAM_ROLE TESTS" + include_tasks: "netbox_ipam_role.yml" + +- name: "NETBOX_VLAN_GROUP TESTS" + include_tasks: "netbox_vlan_group.yml" + +- name: "NETBOX_VLAN TESTS" + include_tasks: "netbox_vlan.yml" + +- name: "NETBOX_VRF TESTS" + include_tasks: "netbox_vrf.yml" + +- name: "NETBOX_RIR TESTS" + include_tasks: "netbox_rir.yml" + +- name: "NETBOX_AGGREGATE TESTS" + include_tasks: "netbox_aggregate.yml" + +- name: "NETBOX_REGION TESTS" + include_tasks: "netbox_region.yml" + +- name: "NETBOX_DEVICE_BAY TESTS" + include_tasks: "netbox_device_bay.yml" + +- name: "NETBOX_INVENTORY_ITEM TESTS" + include_tasks: "netbox_inventory_item.yml" + +- name: "NETBOX_VIRTUAL_MACHINE TESTS" + include_tasks: "netbox_virtual_machine.yml" + +- name: "NETBOX_CLUSTER TESTS" + include_tasks: "netbox_cluster.yml" + +- name: "NETBOX_CLUSTER_GROUP TESTS" + include_tasks: "netbox_cluster_group.yml" + +- name: "NETBOX_CLUSTER_TYPE TESTS" + include_tasks: "netbox_cluster_type.yml" + +- name: "NETBOX_VM_INTERFACE TESTS" + include_tasks: "netbox_vm_interface.yml" + +- name: "NETBOX_PROVIDER TESTS" + include_tasks: "netbox_provider.yml" + +- name: "NETBOX_CIRCUIT_TYPE TESTS" + include_tasks: "netbox_circuit_type.yml" + +- name: "NETBOX_CIRCUIT TESTS" + include_tasks: "netbox_circuit.yml" + +- name: "NETBOX_CIRCUIT_TERMINATION TESTS" + include_tasks: "netbox_circuit_termination.yml" + +- name: "NETBOX_SERVICE TESTS" + include_tasks: "netbox_service.yml" + +- name: "NETBOX_LOOKUP TESTS" + include_tasks: "netbox_lookup.yml" diff --git a/tests/integration/v2.6/tasks/netbox_aggregate.yml b/tests/integration/targets/latest/tasks/netbox_aggregate.yml similarity index 95% rename from tests/integration/v2.6/tasks/netbox_aggregate.yml rename to tests/integration/targets/latest/tasks/netbox_aggregate.yml index c9e2cffef..3c3e66ec9 100644 --- a/tests/integration/v2.6/tasks/netbox_aggregate.yml +++ b/tests/integration/targets/latest/tasks/netbox_aggregate.yml @@ -5,7 +5,7 @@ ## ## - name: "AGGREGATE 1: Necessary info creation" - netbox_aggregate: + netbox.netbox.netbox_aggregate: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -26,7 +26,7 @@ - test_one['msg'] == "aggregate 10.0.0.0/8 created" - name: "AGGREGATE 2: Create duplicate" - netbox_aggregate: + netbox.netbox.netbox_aggregate: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -44,7 +44,7 @@ - test_two['msg'] == "aggregate 10.0.0.0/8 already exists" - name: "AGGREGATE 3: ASSERT - Update" - netbox_aggregate: + netbox.netbox.netbox_aggregate: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -73,7 +73,7 @@ - test_three['msg'] == "aggregate 10.0.0.0/8 updated" - name: "AGGREGATE 4: ASSERT - Delete" - netbox_aggregate: + netbox.netbox.netbox_aggregate: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -94,7 +94,7 @@ - test_four['msg'] == "aggregate 10.0.0.0/8 deleted" - name: "AGGREGATE 5: Necessary info creation" - netbox_aggregate: + netbox.netbox.netbox_aggregate: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: diff --git a/tests/integration/v2.8/tasks/netbox_circuit.yml b/tests/integration/targets/latest/tasks/netbox_circuit.yml similarity index 96% rename from tests/integration/v2.8/tasks/netbox_circuit.yml rename to tests/integration/targets/latest/tasks/netbox_circuit.yml index 1ea3474de..692cfa4ca 100644 --- a/tests/integration/v2.8/tasks/netbox_circuit.yml +++ b/tests/integration/targets/latest/tasks/netbox_circuit.yml @@ -5,7 +5,7 @@ ## ## - name: "NETBOX_CIRCUIT 1: Create provider within Netbox with only required information" - netbox_circuit: + netbox.netbox.netbox_circuit: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -27,7 +27,7 @@ - test_one['msg'] == "circuit Test Circuit One created" - name: "NETBOX_CIRCUIT 2: Duplicate" - netbox_circuit: + netbox.netbox.netbox_circuit: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -47,7 +47,7 @@ - test_two['msg'] == "circuit Test Circuit One already exists" - name: "NETBOX_CIRCUIT 3: Update provider with other fields" - netbox_circuit: + netbox.netbox.netbox_circuit: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -85,7 +85,7 @@ - test_three['msg'] == "circuit Test Circuit One updated" - name: "NETBOX_CIRCUIT 4: Delete provider within netbox" - netbox_circuit: + netbox.netbox.netbox_circuit: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: diff --git a/tests/integration/v2.7/tasks/netbox_circuit_termination.yml b/tests/integration/targets/latest/tasks/netbox_circuit_termination.yml similarity index 95% rename from tests/integration/v2.7/tasks/netbox_circuit_termination.yml rename to tests/integration/targets/latest/tasks/netbox_circuit_termination.yml index 6e79a3d34..6851b5105 100644 --- a/tests/integration/v2.7/tasks/netbox_circuit_termination.yml +++ b/tests/integration/targets/latest/tasks/netbox_circuit_termination.yml @@ -5,7 +5,7 @@ ## ## - name: "NETBOX_CIRCUIT_TERMINATION 1: Create provider within Netbox with only required information" - netbox_circuit_termination: + netbox.netbox.netbox_circuit_termination: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -29,7 +29,7 @@ - test_one['msg'] == "circuit_termination test_circuit_a created" - name: "NETBOX_CIRCUIT_TERMINATION 2: Duplicate" - netbox_circuit_termination: + netbox.netbox.netbox_circuit_termination: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -49,7 +49,7 @@ - test_two['msg'] == "circuit_termination test_circuit_a already exists" - name: "NETBOX_CIRCUIT_TERMINATION 3: Update provider with other fields" - netbox_circuit_termination: + netbox.netbox.netbox_circuit_termination: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -81,7 +81,7 @@ - test_three['msg'] == "circuit_termination test_circuit_a updated" - name: "NETBOX_CIRCUIT_TERMINATION 4: Create Z Side" - netbox_circuit_termination: + netbox.netbox.netbox_circuit_termination: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -105,7 +105,7 @@ - test_four['msg'] == "circuit_termination test_circuit_z created" - name: "NETBOX_CIRCUIT_TERMINATION 5: Delete provider within netbox" - netbox_circuit_termination: + netbox.netbox.netbox_circuit_termination: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: diff --git a/tests/integration/v2.7/tasks/netbox_circuit_type.yml b/tests/integration/targets/latest/tasks/netbox_circuit_type.yml similarity index 94% rename from tests/integration/v2.7/tasks/netbox_circuit_type.yml rename to tests/integration/targets/latest/tasks/netbox_circuit_type.yml index c7685e524..45f956e34 100644 --- a/tests/integration/v2.7/tasks/netbox_circuit_type.yml +++ b/tests/integration/targets/latest/tasks/netbox_circuit_type.yml @@ -5,7 +5,7 @@ ## ## - name: "CIRCUIT_TYPE 1: Necessary info creation" - netbox_circuit_type: + netbox.netbox.netbox_circuit_type: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -24,7 +24,7 @@ - test_one['msg'] == "circuit_type Test Circuit Type One created" - name: "CIRCUIT_TYPE 2: Create duplicate" - netbox_circuit_type: + netbox.netbox.netbox_circuit_type: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -41,7 +41,7 @@ - test_two['msg'] == "circuit_type Test Circuit Type One already exists" - name: "CIRCUIT_TYPE 3: User specified slug" - netbox_circuit_type: + netbox.netbox.netbox_circuit_type: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -61,7 +61,7 @@ - test_three['msg'] == "circuit_type Test Circuit Type Two created" - name: "CIRCUIT_TYPE 4: ASSERT - Delete" - netbox_circuit_type: + netbox.netbox.netbox_circuit_type: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -78,7 +78,7 @@ - test_four['msg'] == "circuit_type Test Circuit Type One deleted" - name: "CIRCUIT_TYPE 5: ASSERT - Delete" - netbox_circuit_type: + netbox.netbox.netbox_circuit_type: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: diff --git a/tests/integration/v2.8/tasks/netbox_cluster.yml b/tests/integration/targets/latest/tasks/netbox_cluster.yml similarity index 95% rename from tests/integration/v2.8/tasks/netbox_cluster.yml rename to tests/integration/targets/latest/tasks/netbox_cluster.yml index fdda9a69e..e80a034ba 100644 --- a/tests/integration/v2.8/tasks/netbox_cluster.yml +++ b/tests/integration/targets/latest/tasks/netbox_cluster.yml @@ -5,7 +5,7 @@ ## ## - name: "CLUSTER 1: Necessary info creation" - netbox_cluster: + netbox.netbox.netbox_cluster: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -25,7 +25,7 @@ - test_one['msg'] == "cluster Test Cluster One created" - name: "CLUSTER 2: Create duplicate" - netbox_cluster: + netbox.netbox.netbox_cluster: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -43,7 +43,7 @@ - test_two['msg'] == "cluster Test Cluster One already exists" - name: "CLUSTER 3: Update" - netbox_cluster: + netbox.netbox.netbox_cluster: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -74,7 +74,7 @@ - test_three['msg'] == "cluster Test Cluster One updated" - name: "CLUSTER 4: ASSERT - Delete" - netbox_cluster: + netbox.netbox.netbox_cluster: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: diff --git a/tests/integration/v2.8/tasks/netbox_cluster_group.yml b/tests/integration/targets/latest/tasks/netbox_cluster_group.yml similarity index 94% rename from tests/integration/v2.8/tasks/netbox_cluster_group.yml rename to tests/integration/targets/latest/tasks/netbox_cluster_group.yml index 27ebb73e6..9f84518ce 100644 --- a/tests/integration/v2.8/tasks/netbox_cluster_group.yml +++ b/tests/integration/targets/latest/tasks/netbox_cluster_group.yml @@ -5,7 +5,7 @@ ## ## - name: "CLUSTER_GROUP 1: Necessary info creation" - netbox_cluster_group: + netbox.netbox.netbox_cluster_group: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -24,7 +24,7 @@ - test_one['msg'] == "cluster_group Test Cluster Group One created" - name: "CLUSTER_GROUP 2: Create duplicate" - netbox_cluster_group: + netbox.netbox.netbox_cluster_group: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -41,7 +41,7 @@ - test_two['msg'] == "cluster_group Test Cluster Group One already exists" - name: "CLUSTER_GROUP 3: User specified slug" - netbox_cluster_group: + netbox.netbox.netbox_cluster_group: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -61,7 +61,7 @@ - test_three['msg'] == "cluster_group Test Cluster Group Two created" - name: "CLUSTER_GROUP 4: ASSERT - Delete" - netbox_cluster_group: + netbox.netbox.netbox_cluster_group: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -78,7 +78,7 @@ - test_four['msg'] == "cluster_group Test Cluster Group One deleted" - name: "CLUSTER_GROUP 5: ASSERT - Delete" - netbox_cluster_group: + netbox.netbox.netbox_cluster_group: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: diff --git a/tests/integration/v2.8/tasks/netbox_cluster_type.yml b/tests/integration/targets/latest/tasks/netbox_cluster_type.yml similarity index 94% rename from tests/integration/v2.8/tasks/netbox_cluster_type.yml rename to tests/integration/targets/latest/tasks/netbox_cluster_type.yml index cd4a111e0..abcaed091 100644 --- a/tests/integration/v2.8/tasks/netbox_cluster_type.yml +++ b/tests/integration/targets/latest/tasks/netbox_cluster_type.yml @@ -4,7 +4,7 @@ ## ## - name: "CLUSTER_TYPE 1: Necessary info creation" - netbox_cluster_type: + netbox.netbox.netbox_cluster_type: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -23,7 +23,7 @@ - test_one['msg'] == "cluster_type Test Cluster Type One created" - name: "CLUSTER_TYPE 2: Create duplicate" - netbox_cluster_type: + netbox.netbox.netbox_cluster_type: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -40,7 +40,7 @@ - test_two['msg'] == "cluster_type Test Cluster Type One already exists" - name: "CLUSTER_TYPE 3: User specified slug" - netbox_cluster_type: + netbox.netbox.netbox_cluster_type: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -60,7 +60,7 @@ - test_three['msg'] == "cluster_type Test Cluster Type Two created" - name: "CLUSTER_TYPE 4: ASSERT - Delete" - netbox_cluster_type: + netbox.netbox.netbox_cluster_type: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -77,7 +77,7 @@ - test_four['msg'] == "cluster_type Test Cluster Type One deleted" - name: "CLUSTER_TYPE 5: ASSERT - Delete" - netbox_cluster_type: + netbox.netbox.netbox_cluster_type: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: diff --git a/tests/integration/v2.8/tasks/netbox_device.yml b/tests/integration/targets/latest/tasks/netbox_device.yml similarity index 95% rename from tests/integration/v2.8/tasks/netbox_device.yml rename to tests/integration/targets/latest/tasks/netbox_device.yml index d0816e161..9957d8f19 100644 --- a/tests/integration/v2.8/tasks/netbox_device.yml +++ b/tests/integration/targets/latest/tasks/netbox_device.yml @@ -5,7 +5,7 @@ ## ## - name: "1 - Device with required information" - netbox_device: + netbox.netbox.netbox_device: netbox_url: "http://localhost:32768" netbox_token: "0123456789abcdef0123456789abcdef01234567" data: @@ -32,7 +32,7 @@ - test_one['msg'] == "device R1 created" - name: "2 - Duplicate device" - netbox_device: + netbox.netbox.netbox_device: netbox_url: "http://localhost:32768" netbox_token: "0123456789abcdef0123456789abcdef01234567" data: @@ -56,7 +56,7 @@ - test_two['msg'] == "device R1 already exists" - name: "3 - Update device" - netbox_device: + netbox.netbox.netbox_device: netbox_url: "http://localhost:32768" netbox_token: "0123456789abcdef0123456789abcdef01234567" data: @@ -79,7 +79,7 @@ - test_three['msg'] == "device R1 updated" - name: "4 - Create device with tags and assign to rack" - netbox_device: + netbox.netbox.netbox_device: netbox_url: "http://localhost:32768" netbox_token: "0123456789abcdef0123456789abcdef01234567" data: @@ -115,7 +115,7 @@ - test_four['msg'] == "device TestR1 created" - name: "5 - Delete previous device" - netbox_device: + netbox.netbox.netbox_device: netbox_url: "http://localhost:32768" netbox_token: "0123456789abcdef0123456789abcdef01234567" data: @@ -132,7 +132,7 @@ - test_five['msg'] == "device TestR1 deleted" - name: "6 - Delete R1" - netbox_device: + netbox.netbox.netbox_device: netbox_url: "http://localhost:32768" netbox_token: "0123456789abcdef0123456789abcdef01234567" data: @@ -149,7 +149,7 @@ - test_six['msg'] == "device R1 deleted" - name: "7 - Add primary_ip4/6 to test100" - netbox_device: + netbox.netbox.netbox_device: netbox_url: "http://localhost:32768" netbox_token: "0123456789abcdef0123456789abcdef01234567" data: @@ -175,7 +175,7 @@ - test_seven['msg'] == "device test100 updated" - name: "8 - Device with empty string name" - netbox_device: + netbox.netbox.netbox_device: netbox_url: "http://localhost:32768" netbox_token: "0123456789abcdef0123456789abcdef01234567" data: @@ -198,4 +198,4 @@ - test_eight['device']['site'] == 1 - test_eight['device']['status'] == "staged" - "'-' in test_eight['device']['name']" - - "test_eight['device']['name'] | length == 36" \ No newline at end of file + - "test_eight['device']['name'] | length == 36" diff --git a/tests/integration/v2.7/tasks/netbox_device_bay.yml b/tests/integration/targets/latest/tasks/netbox_device_bay.yml similarity index 94% rename from tests/integration/v2.7/tasks/netbox_device_bay.yml rename to tests/integration/targets/latest/tasks/netbox_device_bay.yml index 62f0436b9..f8e27820e 100644 --- a/tests/integration/v2.7/tasks/netbox_device_bay.yml +++ b/tests/integration/targets/latest/tasks/netbox_device_bay.yml @@ -5,7 +5,7 @@ ## ## - name: "DEVICE_BAY 1: Necessary info creation" - netbox_device_bay: + netbox.netbox.netbox_device_bay: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -25,7 +25,7 @@ - test_one['msg'] == "device_bay Device Bay One created" - name: "DEVICE_BAY 2: Create duplicate" - netbox_device_bay: + netbox.netbox.netbox_device_bay: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -43,7 +43,7 @@ - test_two['msg'] == "device_bay Device Bay One already exists" - name: "DEVICE_BAY 3: ASSERT - Update" - netbox_device_bay: + netbox.netbox.netbox_device_bay: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -68,7 +68,7 @@ - test_three['msg'] == "device_bay Device Bay One updated" - name: "DEVICE_BAY 4: ASSERT - Delete" - netbox_device_bay: + netbox.netbox.netbox_device_bay: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: diff --git a/tests/integration/v2.8/tasks/netbox_device_interface.yml b/tests/integration/targets/latest/tasks/netbox_device_interface.yml similarity index 94% rename from tests/integration/v2.8/tasks/netbox_device_interface.yml rename to tests/integration/targets/latest/tasks/netbox_device_interface.yml index baedb9d11..254d6aef8 100644 --- a/tests/integration/v2.8/tasks/netbox_device_interface.yml +++ b/tests/integration/targets/latest/tasks/netbox_device_interface.yml @@ -5,7 +5,7 @@ ## ## - name: "1 - Interface with required information" - netbox_device_interface: + netbox.netbox.netbox_device_interface: netbox_url: "http://localhost:32768" netbox_token: "0123456789abcdef0123456789abcdef01234567" data: @@ -25,7 +25,7 @@ - test_one['interface']['device'] == 1 - name: "2 - Update test100 - GigabitEthernet3" - netbox_device_interface: + netbox.netbox.netbox_device_interface: netbox_url: "http://localhost:32768" netbox_token: "0123456789abcdef0123456789abcdef01234567" data: @@ -48,7 +48,7 @@ - test_two['interface']['mtu'] == 1600 - name: "3 - Delete interface test100 - GigabitEthernet3" - netbox_device_interface: + netbox.netbox.netbox_device_interface: netbox_url: "http://localhost:32768" netbox_token: "0123456789abcdef0123456789abcdef01234567" data: @@ -66,7 +66,7 @@ - test_three['diff']['after']['state'] == "absent" - name: "4 - Create LAG with several specified options" - netbox_device_interface: + netbox.netbox.netbox_device_interface: netbox_url: "http://localhost:32768" netbox_token: "0123456789abcdef0123456789abcdef01234567" data: @@ -95,7 +95,7 @@ - test_four['interface']['mtu'] == 1600 - name: "5 - Create interface and assign it to parent LAG" - netbox_device_interface: + netbox.netbox.netbox_device_interface: netbox_url: "http://localhost:32768" netbox_token: "0123456789abcdef0123456789abcdef01234567" data: @@ -128,7 +128,7 @@ - test_five['interface']['mtu'] == 1600 - name: "6 - Create interface as trunk port" - netbox_device_interface: + netbox.netbox.netbox_device_interface: netbox_url: "http://localhost:32768" netbox_token: "0123456789abcdef0123456789abcdef01234567" data: @@ -168,7 +168,7 @@ - test_six['interface']['untagged_vlan'] == 1 - name: "7 - Duplicate Interface" - netbox_device_interface: + netbox.netbox.netbox_device_interface: netbox_url: "http://localhost:32768" netbox_token: "0123456789abcdef0123456789abcdef01234567" data: @@ -185,7 +185,7 @@ - test_seven['interface']['device'] == 1 - name: "Add port-channel1 to R1 to test finding proper port-channel1" - netbox_device_interface: + netbox.netbox.netbox_device_interface: netbox_url: "http://localhost:32768" netbox_token: "0123456789abcdef0123456789abcdef01234567" data: @@ -194,7 +194,7 @@ form_factor: "Link Aggregation Group (LAG)" - name: "8 - Create interface and assign it to parent LAG - non dict" - netbox_device_interface: + netbox.netbox.netbox_device_interface: netbox_url: "http://localhost:32768" netbox_token: "0123456789abcdef0123456789abcdef01234567" data: @@ -226,7 +226,7 @@ - test_eight['interface']['mtu'] == 1600 - name: "9 - Create interface on VC child" - netbox_device_interface: + netbox.netbox.netbox_device_interface: netbox_url: "http://localhost:32768" netbox_token: "0123456789abcdef0123456789abcdef01234567" data: @@ -249,7 +249,7 @@ - test_nine['interface']['type'] == "1000base-t" - name: "10 - Update interface on VC child" - netbox_device_interface: + netbox.netbox.netbox_device_interface: netbox_url: "http://localhost:32768" netbox_token: "0123456789abcdef0123456789abcdef01234567" data: @@ -273,7 +273,7 @@ - test_ten['interface']['description'] == 'Updated child interface from parent device' - name: "11 - Update interface on VC child w/o update_vc_child" - netbox_device_interface: + netbox.netbox.netbox_device_interface: netbox_url: "http://localhost:32768" netbox_token: "0123456789abcdef0123456789abcdef01234567" data: @@ -288,4 +288,4 @@ assert: that: - test_eleven is failed - - test_eleven['msg'] == "Must set update_vc_child to True to allow child device interface modification" \ No newline at end of file + - test_eleven['msg'] == "Must set update_vc_child to True to allow child device interface modification" diff --git a/tests/integration/v2.6/tasks/netbox_device_role.yml b/tests/integration/targets/latest/tasks/netbox_device_role.yml similarity index 94% rename from tests/integration/v2.6/tasks/netbox_device_role.yml rename to tests/integration/targets/latest/tasks/netbox_device_role.yml index 9d0d9477c..64ec9840f 100644 --- a/tests/integration/v2.6/tasks/netbox_device_role.yml +++ b/tests/integration/targets/latest/tasks/netbox_device_role.yml @@ -5,7 +5,7 @@ ## ## - name: "DEVICE_ROLE 1: Necessary info creation" - netbox_device_role: + netbox.netbox.netbox_device_role: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -26,7 +26,7 @@ - test_one['msg'] == "device_role Test Device Role created" - name: "DEVICE_ROLE 2: Create duplicate" - netbox_device_role: + netbox.netbox.netbox_device_role: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -45,7 +45,7 @@ - test_two['msg'] == "device_role Test Device Role already exists" - name: "DEVICE_ROLE 3: ASSERT - Update" - netbox_device_role: + netbox.netbox.netbox_device_role: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -68,7 +68,7 @@ - test_three['msg'] == "device_role Test Device Role updated" - name: "DEVICE_ROLE 4: ASSERT - Delete" - netbox_device_role: + netbox.netbox.netbox_device_role: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -85,7 +85,7 @@ - test_four['msg'] == "device_role Test Device Role deleted" - name: "DEVICE_ROLE 5: ASSERT - Delete non existing" - netbox_device_role: + netbox.netbox.netbox_device_role: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: diff --git a/tests/integration/v2.7/tasks/netbox_device_type.yml b/tests/integration/targets/latest/tasks/netbox_device_type.yml similarity index 95% rename from tests/integration/v2.7/tasks/netbox_device_type.yml rename to tests/integration/targets/latest/tasks/netbox_device_type.yml index 868e378b4..6fd2c36a2 100644 --- a/tests/integration/v2.7/tasks/netbox_device_type.yml +++ b/tests/integration/targets/latest/tasks/netbox_device_type.yml @@ -5,7 +5,7 @@ ## ## - name: "DEVICE_TYPE 1: Necessary info creation" - netbox_device_type: + netbox.netbox.netbox_device_type: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -27,7 +27,7 @@ - test_one['msg'] == "device_type test-device-type created" - name: "DEVICE_TYPE 2: Create duplicate" - netbox_device_type: + netbox.netbox.netbox_device_type: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -47,7 +47,7 @@ - test_two['msg'] == "device_type test-device-type already exists" - name: "DEVICE_TYPE 3: ASSERT - Update" - netbox_device_type: + netbox.netbox.netbox_device_type: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -77,7 +77,7 @@ - test_three['msg'] == "device_type test-device-type updated" - name: "DEVICE_TYPE 4: ASSERT - Delete" - netbox_device_type: + netbox.netbox.netbox_device_type: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -94,7 +94,7 @@ - test_four['msg'] == "device_type test-device-type deleted" - name: "DEVICE_TYPE 5: ASSERT - Delete non existing" - netbox_device_type: + netbox.netbox.netbox_device_type: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -110,7 +110,7 @@ - test_five['msg'] == "device_type Test Device Type already absent" - name: "DEVICE_TYPE 6: Without Slug" - netbox_device_type: + netbox.netbox.netbox_device_type: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: diff --git a/tests/integration/v2.8/tasks/netbox_inventory_item.yml b/tests/integration/targets/latest/tasks/netbox_inventory_item.yml similarity index 95% rename from tests/integration/v2.8/tasks/netbox_inventory_item.yml rename to tests/integration/targets/latest/tasks/netbox_inventory_item.yml index a3e953e24..5d4eb603a 100644 --- a/tests/integration/v2.8/tasks/netbox_inventory_item.yml +++ b/tests/integration/targets/latest/tasks/netbox_inventory_item.yml @@ -5,7 +5,7 @@ ## ## - name: "INVENTORY_ITEM 1: Necessary info creation" - netbox_inventory_item: + netbox.netbox.netbox_inventory_item: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -25,7 +25,7 @@ - test_one['msg'] == "inventory_item 10G-SFP+ created" - name: "INVENTORY_ITEM 2: Create duplicate" - netbox_inventory_item: + netbox.netbox.netbox_inventory_item: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -43,7 +43,7 @@ - test_two['msg'] == "inventory_item 10G-SFP+ already exists" - name: "INVENTORY_ITEM 3: ASSERT - Update" - netbox_inventory_item: + netbox.netbox.netbox_inventory_item: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -80,7 +80,7 @@ - test_three['msg'] == "inventory_item 10G-SFP+ updated" - name: "INVENTORY_ITEM 4: ASSERT - Delete" - netbox_inventory_item: + netbox.netbox.netbox_inventory_item: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: diff --git a/tests/integration/v2.8/tasks/netbox_ip_address.yml b/tests/integration/targets/latest/tasks/netbox_ip_address.yml similarity index 95% rename from tests/integration/v2.8/tasks/netbox_ip_address.yml rename to tests/integration/targets/latest/tasks/netbox_ip_address.yml index 0bd530e86..5d41c5233 100644 --- a/tests/integration/v2.8/tasks/netbox_ip_address.yml +++ b/tests/integration/targets/latest/tasks/netbox_ip_address.yml @@ -5,7 +5,7 @@ ## ## - name: "1 - Create IP address within Netbox with only required information - State: Present" - netbox_ip_address: + netbox.netbox.netbox_ip_address: netbox_url: http://localhost.org:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -23,7 +23,7 @@ - test_one['ip_address']['address'] == "192.168.1.10/30" - name: "2 - Update 192.168.1.10/30" - netbox_ip_address: + netbox.netbox.netbox_ip_address: netbox_url: http://localhost.org:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -46,7 +46,7 @@ - test_two['ip_address']['description'] == "Updated ip address" - name: "3 - Delete IP - 192.168.1.10 - State: Absent" - netbox_ip_address: + netbox.netbox.netbox_ip_address: netbox_url: http://localhost.org:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -63,7 +63,7 @@ - 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_ip_address: + netbox.netbox.netbox_ip_address: netbox_url: http://localhost.org:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -81,7 +81,7 @@ - test_four['ip_address']['address'] == "192.168.1.20/30" - name: "5 - Create IP in global VRF - 192.168.1.20/30 - State: New" - netbox_ip_address: + netbox.netbox.netbox_ip_address: netbox_url: http://localhost.org:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -99,7 +99,7 @@ - test_five['ip_address']['address'] == "192.168.1.20/30" - name: "6 - Create new address with only prefix specified - State: new" - netbox_ip_address: + netbox.netbox.netbox_ip_address: netbox_url: http://localhost.org:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -117,7 +117,7 @@ - test_six['ip_address']['address'] == "192.168.100.1/24" - name: "7 - Create IP address with several specified" - netbox_ip_address: + netbox.netbox.netbox_ip_address: netbox_url: http://localhost.org:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -150,7 +150,7 @@ - test_seven['ip_address']['vrf'] == 1 - name: "8 - Create IP address and assign a nat_inside IP" - netbox_ip_address: + netbox.netbox.netbox_ip_address: netbox_url: http://localhost.org:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -179,7 +179,7 @@ - test_eight['ip_address']['vrf'] == 1 - name: "9 - Create IP address on GigabitEthernet2 - test100 - State: present" - netbox_ip_address: + netbox.netbox.netbox_ip_address: netbox_url: http://localhost.org:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -202,7 +202,7 @@ - test_nine['ip_address']['interface'] == 3 - name: "10 - Create IP address on GigabitEthernet2 - test100 - State: new" - netbox_ip_address: + netbox.netbox.netbox_ip_address: netbox_url: http://localhost.org:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -226,7 +226,7 @@ - test_ten['ip_address']['interface']['id'] == 3 - name: "11 - Create IP address on GigabitEthernet2 - test100 - State: present" - netbox_ip_address: + netbox.netbox.netbox_ip_address: netbox_url: http://localhost.org:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -248,7 +248,7 @@ - test_eleven['ip_address']['address'] == "192.168.100.2/24" - name: "12 - Duplicate - 192.168.100.2/24 on interface" - netbox_ip_address: + netbox.netbox.netbox_ip_address: netbox_url: http://localhost.org:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -268,7 +268,7 @@ - test_twelve['ip_address']['interface'] == 3 - name: "13 - Duplicate - 192.168.100.2/24" - netbox_ip_address: + netbox.netbox.netbox_ip_address: netbox_url: http://localhost.org:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -284,7 +284,7 @@ - test_thirteen['ip_address']['address'] == "192.168.100.2/24" - name: "14 - Create IP address on Eth0 - test100-vm - State: present" - netbox_ip_address: + netbox.netbox.netbox_ip_address: netbox_url: http://localhost.org:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -307,7 +307,7 @@ - test_fourteen['ip_address']['interface'] == 4 - name: "15 - Create IP address with no mask - State: Present" - netbox_ip_address: + netbox.netbox.netbox_ip_address: netbox_url: http://localhost.org:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: diff --git a/tests/integration/v2.8/tasks/netbox_ipam_role.yml b/tests/integration/targets/latest/tasks/netbox_ipam_role.yml similarity index 93% rename from tests/integration/v2.8/tasks/netbox_ipam_role.yml rename to tests/integration/targets/latest/tasks/netbox_ipam_role.yml index 240f57b62..1f1ff0f36 100644 --- a/tests/integration/v2.8/tasks/netbox_ipam_role.yml +++ b/tests/integration/targets/latest/tasks/netbox_ipam_role.yml @@ -5,7 +5,7 @@ ## ## - name: "IPAM_ROLE 1: Necessary info creation" - netbox_ipam_role: + netbox.netbox.netbox_ipam_role: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -24,7 +24,7 @@ - test_one['msg'] == "role Test IPAM Role created" - name: "IPAM_ROLE 2: Create duplicate" - netbox_ipam_role: + netbox.netbox.netbox_ipam_role: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -41,7 +41,7 @@ - test_two['msg'] == "role Test IPAM Role already exists" - name: "IPAM_ROLE 3: ASSERT - Update" - netbox_ipam_role: + netbox.netbox.netbox_ipam_role: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -61,7 +61,7 @@ - test_three['msg'] == "role Test IPAM Role updated" - name: "IPAM_ROLE 4: ASSERT - Delete" - netbox_ipam_role: + netbox.netbox.netbox_ipam_role: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -78,7 +78,7 @@ - test_four['msg'] == "role Test IPAM Role deleted" - name: "IPAM_ROLE 5: ASSERT - Delete non existing" - netbox_ipam_role: + netbox.netbox.netbox_ipam_role: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: diff --git a/tests/integration/v2.7/tasks/netbox_lookup.yml b/tests/integration/targets/latest/tasks/netbox_lookup.yml similarity index 97% rename from tests/integration/v2.7/tasks/netbox_lookup.yml rename to tests/integration/targets/latest/tasks/netbox_lookup.yml index a2d534b8a..076837b2d 100644 --- a/tests/integration/v2.7/tasks/netbox_lookup.yml +++ b/tests/integration/targets/latest/tasks/netbox_lookup.yml @@ -29,7 +29,7 @@ query_result: "{{ query('netbox.netbox.nb_lookup', 'vlans', api_endpoint='http://localhost:32768', token='0123456789abcdef0123456789abcdef01234567') }}" - name: "NETBOX_LOOKUP 5: Add one of two devices for lookup filter test." - netbox_device: + netbox.netbox.netbox_device: netbox_url: "http://localhost:32768" netbox_token: "0123456789abcdef0123456789abcdef01234567" data: @@ -43,7 +43,7 @@ state: present - name: "NETBOX_LOOKUP 6: Add two of two devices for lookup filter test." - netbox_device: + netbox.netbox.netbox_device: netbox_url: "http://localhost:32768" netbox_token: "0123456789abcdef0123456789abcdef01234567" data: diff --git a/tests/integration/v2.6/tasks/netbox_manufacturer.yml b/tests/integration/targets/latest/tasks/netbox_manufacturer.yml similarity index 93% rename from tests/integration/v2.6/tasks/netbox_manufacturer.yml rename to tests/integration/targets/latest/tasks/netbox_manufacturer.yml index 52486c081..4dd1907eb 100644 --- a/tests/integration/v2.6/tasks/netbox_manufacturer.yml +++ b/tests/integration/targets/latest/tasks/netbox_manufacturer.yml @@ -5,7 +5,7 @@ ## ## - name: "MANUFACTURER 1: Necessary info creation" - netbox_manufacturer: + netbox.netbox.netbox_manufacturer: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -24,7 +24,7 @@ - test_one['msg'] == "manufacturer Test Manufacturer Two created" - name: "MANUFACTURER 2: Create duplicate" - netbox_manufacturer: + netbox.netbox.netbox_manufacturer: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -41,7 +41,7 @@ - test_two['msg'] == "manufacturer Test Manufacturer Two already exists" - name: "MANUFACTURER 3: Update" - netbox_manufacturer: + netbox.netbox.netbox_manufacturer: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -58,7 +58,7 @@ - test_three['msg'] == "manufacturer test manufacturer two updated" - name: "MANUFACTURER 4: ASSERT - Delete" - netbox_manufacturer: + netbox.netbox.netbox_manufacturer: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -75,7 +75,7 @@ - test_four['msg'] == "manufacturer test manufacturer two deleted" - name: "MANUFACTURER 5: ASSERT - Delete non existing" - netbox_manufacturer: + netbox.netbox.netbox_manufacturer: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: diff --git a/tests/integration/v2.7/tasks/netbox_platform.yml b/tests/integration/targets/latest/tasks/netbox_platform.yml similarity index 94% rename from tests/integration/v2.7/tasks/netbox_platform.yml rename to tests/integration/targets/latest/tasks/netbox_platform.yml index 2bc1f9de7..95ccdb4cf 100644 --- a/tests/integration/v2.7/tasks/netbox_platform.yml +++ b/tests/integration/targets/latest/tasks/netbox_platform.yml @@ -5,7 +5,7 @@ ## ## - name: "PLATFORM 1: Necessary info creation" - netbox_platform: + netbox.netbox.netbox_platform: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -24,7 +24,7 @@ - test_one['msg'] == "platform Test Platform created" - name: "PLATFORM 2: Create duplicate" - netbox_platform: + netbox.netbox.netbox_platform: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -41,7 +41,7 @@ - test_two['msg'] == "platform Test Platform already exists" - name: "PLATFORM 3: ASSERT - Update" - netbox_platform: + netbox.netbox.netbox_platform: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -66,7 +66,7 @@ - test_three['msg'] == "platform Test Platform updated" - name: "PLATFORM 4: ASSERT - Delete" - netbox_platform: + netbox.netbox.netbox_platform: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -83,7 +83,7 @@ - test_four['msg'] == "platform Test Platform deleted" - name: "PLATFORM 5: ASSERT - Delete non existing" - netbox_platform: + netbox.netbox.netbox_platform: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: diff --git a/tests/integration/v2.8/tasks/netbox_prefix.yml b/tests/integration/targets/latest/tasks/netbox_prefix.yml similarity index 95% rename from tests/integration/v2.8/tasks/netbox_prefix.yml rename to tests/integration/targets/latest/tasks/netbox_prefix.yml index a50585fad..f247ec31b 100644 --- a/tests/integration/v2.8/tasks/netbox_prefix.yml +++ b/tests/integration/targets/latest/tasks/netbox_prefix.yml @@ -5,7 +5,7 @@ ## ## - name: "1 - Create prefix within Netbox with only required information" - netbox_prefix: + netbox.netbox.netbox_prefix: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -23,7 +23,7 @@ - test_one['prefix']['prefix'] == "10.156.0.0/19" - name: "2 - Duplicate" - netbox_prefix: + netbox.netbox.netbox_prefix: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -39,7 +39,7 @@ - test_two['prefix']['prefix'] == "10.156.0.0/19" - name: "3 - Update 10.156.0.0/19" - netbox_prefix: + netbox.netbox.netbox_prefix: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -64,7 +64,7 @@ - test_three['prefix']['description'] == "This prefix has been updated" - name: "4 - Delete prefix within netbox" - netbox_prefix: + netbox.netbox.netbox_prefix: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -81,7 +81,7 @@ - test_four['msg'] == "prefix 10.156.0.0/19 deleted" - name: "5 - Create prefix with several specified options" - netbox_prefix: + netbox.netbox.netbox_prefix: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -124,7 +124,7 @@ - test_five['prefix']['tags'][0] == "Schnozzberry" - name: "6 - Get a new /24 inside 10.156.0.0/19 within Netbox - Parent doesn't exist" - netbox_prefix: + netbox.netbox.netbox_prefix: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -141,7 +141,7 @@ - test_six['msg'] == "Parent prefix does not exist - 10.156.0.0/19" - name: "7 - Create prefix within Netbox with only required information" - netbox_prefix: + netbox.netbox.netbox_prefix: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -159,7 +159,7 @@ - test_seven['prefix']['prefix'] == "10.156.0.0/19" - name: "8 - Get a new /24 inside 10.156.0.0/19 within Netbox" - netbox_prefix: + netbox.netbox.netbox_prefix: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -179,7 +179,7 @@ - test_eight['prefix']['prefix'] == "10.156.0.0/24" - name: "9 - Create 10.157.0.0/19" - netbox_prefix: + netbox.netbox.netbox_prefix: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -201,7 +201,7 @@ - test_nine['prefix']['vrf'] == 1 - name: "10 - Get a new /24 inside 10.157.0.0/19 within Netbox with additional values" - netbox_prefix: + netbox.netbox.netbox_prefix: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -225,7 +225,7 @@ - test_ten['prefix']['vrf']['id'] == 1 - name: "11 - Get a new /24 inside 10.156.0.0/19 within Netbox" - netbox_prefix: + netbox.netbox.netbox_prefix: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: diff --git a/tests/integration/v2.8/tasks/netbox_provider.yml b/tests/integration/targets/latest/tasks/netbox_provider.yml similarity index 96% rename from tests/integration/v2.8/tasks/netbox_provider.yml rename to tests/integration/targets/latest/tasks/netbox_provider.yml index 7e4b54053..782df16f8 100644 --- a/tests/integration/v2.8/tasks/netbox_provider.yml +++ b/tests/integration/targets/latest/tasks/netbox_provider.yml @@ -5,7 +5,7 @@ ## ## - name: "NETBOX_PROVIDER 1: Create provider within Netbox with only required information" - netbox_provider: + netbox.netbox.netbox_provider: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -24,7 +24,7 @@ - test_one['msg'] == "provider Test Provider One created" - name: "NETBOX_PROVIDER 2: Duplicate" - netbox_provider: + netbox.netbox.netbox_provider: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -41,7 +41,7 @@ - test_two['msg'] == "provider Test Provider One already exists" - name: "NETBOX_PROVIDER 3: Update provider with other fields" - netbox_provider: + netbox.netbox.netbox_provider: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -76,7 +76,7 @@ - test_three['msg'] == "provider Test Provider One updated" - name: "NETBOX_PROVIDER 4: Delete provider within netbox" - netbox_provider: + netbox.netbox.netbox_provider: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: diff --git a/tests/integration/v2.7/tasks/netbox_rack.yml b/tests/integration/targets/latest/tasks/netbox_rack.yml similarity index 96% rename from tests/integration/v2.7/tasks/netbox_rack.yml rename to tests/integration/targets/latest/tasks/netbox_rack.yml index 6ba18f733..5e01b5e2c 100644 --- a/tests/integration/v2.7/tasks/netbox_rack.yml +++ b/tests/integration/targets/latest/tasks/netbox_rack.yml @@ -5,7 +5,7 @@ ## ## - name: "1 - Test rack creation" - netbox_rack: + netbox.netbox.netbox_rack: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -23,7 +23,7 @@ - test_one['rack']['site'] == 1 - name: "Test duplicate rack" - netbox_rack: + netbox.netbox.netbox_rack: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -39,7 +39,7 @@ - test_two['msg'] == "rack Test rack one already exists" - name: "3 - Create new rack with similar name" - netbox_rack: + netbox.netbox.netbox_rack: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -59,7 +59,7 @@ - test_three['msg'] == "rack Test rack - Test Site created" - name: "4 - Attempt to create Test rack one again" - netbox_rack: + netbox.netbox.netbox_rack: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -77,7 +77,7 @@ - test_four['msg'] == "rack Test rack one already exists" - name: "5 - Update Test rack one with more options" - netbox_rack: + netbox.netbox.netbox_rack: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -141,7 +141,7 @@ - test_five['msg'] == "rack Test rack one updated" - name: "6 - Update Test rack one with same options" - netbox_rack: + netbox.netbox.netbox_rack: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -189,7 +189,7 @@ - test_six['rack']['width'] == 23 - name: "7 - Create rack with same asset tag and serial number" - netbox_rack: + netbox.netbox.netbox_rack: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -208,7 +208,7 @@ - "'Asset tag already exists' in test_seven['msg']" - name: "8 - Test delete" - netbox_rack: + netbox.netbox.netbox_rack: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: diff --git a/tests/integration/v2.8/tasks/netbox_rack_group.yml b/tests/integration/targets/latest/tasks/netbox_rack_group.yml similarity index 94% rename from tests/integration/v2.8/tasks/netbox_rack_group.yml rename to tests/integration/targets/latest/tasks/netbox_rack_group.yml index b2ae0c65e..6a10cbf94 100644 --- a/tests/integration/v2.8/tasks/netbox_rack_group.yml +++ b/tests/integration/targets/latest/tasks/netbox_rack_group.yml @@ -5,7 +5,7 @@ ## ## - name: "RACK_GROUP 1: Necessary info creation" - netbox_rack_group: + netbox.netbox.netbox_rack_group: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -26,7 +26,7 @@ - test_one['msg'] == "rack_group Rack Group created" - name: "RACK_GROUP 2: Create duplicate" - netbox_rack_group: + netbox.netbox.netbox_rack_group: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -45,7 +45,7 @@ - test_two['msg'] == "rack_group Rack Group already exists" - name: "RACK_GROUP 3: ASSERT - Delete" - netbox_rack_group: + netbox.netbox.netbox_rack_group: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: diff --git a/tests/integration/v2.8/tasks/netbox_rack_role.yml b/tests/integration/targets/latest/tasks/netbox_rack_role.yml similarity index 94% rename from tests/integration/v2.8/tasks/netbox_rack_role.yml rename to tests/integration/targets/latest/tasks/netbox_rack_role.yml index 847c73d96..5ca9e44eb 100644 --- a/tests/integration/v2.8/tasks/netbox_rack_role.yml +++ b/tests/integration/targets/latest/tasks/netbox_rack_role.yml @@ -5,7 +5,7 @@ ## ## - name: "RACK_ROLE 1: Necessary info creation" - netbox_rack_role: + netbox.netbox.netbox_rack_role: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -26,7 +26,7 @@ - test_one['msg'] == "rack_role Rack Role created" - name: "RACK_ROLE 2: Create duplicate" - netbox_rack_role: + netbox.netbox.netbox_rack_role: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -44,7 +44,7 @@ - test_two['msg'] == "rack_role Rack Role already exists" - name: "RACK_ROLE 3: Update" - netbox_rack_role: + netbox.netbox.netbox_rack_role: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -64,7 +64,7 @@ - test_three['msg'] == "rack_role Rack Role updated" - name: "RACK_ROLE 4: Delete" - netbox_rack_role: + netbox.netbox.netbox_rack_role: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: diff --git a/tests/integration/v2.7/tasks/netbox_region.yml b/tests/integration/targets/latest/tasks/netbox_region.yml similarity index 94% rename from tests/integration/v2.7/tasks/netbox_region.yml rename to tests/integration/targets/latest/tasks/netbox_region.yml index f6f8e7654..1359598af 100644 --- a/tests/integration/v2.7/tasks/netbox_region.yml +++ b/tests/integration/targets/latest/tasks/netbox_region.yml @@ -5,7 +5,7 @@ ## ## - name: "REGION 1: Necessary info creation" - netbox_region: + netbox.netbox.netbox_region: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -24,7 +24,7 @@ - test_one['msg'] == "region Test Region One created" - name: "REGION 2: Create duplicate" - netbox_region: + netbox.netbox.netbox_region: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -41,7 +41,7 @@ - test_two['msg'] == "region Test Region One already exists" - name: "REGION 3: ASSERT - Update" - netbox_region: + netbox.netbox.netbox_region: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -61,7 +61,7 @@ - test_three['msg'] == "region Test Region One updated" - name: "REGION 4: ASSERT - Delete" - netbox_region: + netbox.netbox.netbox_region: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: diff --git a/tests/integration/v2.6/tasks/netbox_rir.yml b/tests/integration/targets/latest/tasks/netbox_rir.yml similarity index 95% rename from tests/integration/v2.6/tasks/netbox_rir.yml rename to tests/integration/targets/latest/tasks/netbox_rir.yml index 821b3e280..cc4935938 100644 --- a/tests/integration/v2.6/tasks/netbox_rir.yml +++ b/tests/integration/targets/latest/tasks/netbox_rir.yml @@ -5,7 +5,7 @@ ## ## - name: "RIR 1: Necessary info creation" - netbox_rir: + netbox.netbox.netbox_rir: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -24,7 +24,7 @@ - test_one['msg'] == "rir Test RIR One created" - name: "RIR 2: Create duplicate" - netbox_rir: + netbox.netbox.netbox_rir: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -41,7 +41,7 @@ - test_two['msg'] == "rir Test RIR One already exists" - name: "RIR 3: ASSERT - Update" - netbox_rir: + netbox.netbox.netbox_rir: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -61,7 +61,7 @@ - test_three['msg'] == "rir Test RIR One updated" - name: "RIR 4: ASSERT - Delete" - netbox_rir: + netbox.netbox.netbox_rir: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: diff --git a/tests/integration/v2.8/tasks/netbox_service.yml b/tests/integration/targets/latest/tasks/netbox_service.yml similarity index 95% rename from tests/integration/v2.8/tasks/netbox_service.yml rename to tests/integration/targets/latest/tasks/netbox_service.yml index 7ec656963..cf70109a0 100644 --- a/tests/integration/v2.8/tasks/netbox_service.yml +++ b/tests/integration/targets/latest/tasks/netbox_service.yml @@ -5,7 +5,7 @@ ## ## - name: "1 - Device with required information needs to add new service" - netbox_device: + netbox.netbox.netbox_device: netbox_url: "http://localhost:32768" netbox_token: "0123456789abcdef0123456789abcdef01234567" data: @@ -17,7 +17,7 @@ state: present - name: "NETBOX_SERVICE: Create new service" - netbox_service: + netbox.netbox.netbox_service: netbox_url: "http://localhost:32768" netbox_token: "0123456789abcdef0123456789abcdef01234567" data: @@ -40,7 +40,7 @@ - test_service_create['msg'] == "services node-exporter created" - name: "NETBOX_SERVICE: Test idempotence" - netbox_service: + netbox.netbox.netbox_service: netbox_url: "http://localhost:32768" netbox_token: "0123456789abcdef0123456789abcdef01234567" data: @@ -60,7 +60,7 @@ - test_service_idempotence['msg'] == "services node-exporter already exists" - name: "NETBOX_SERVICE: Test update" - netbox_service: + netbox.netbox.netbox_service: netbox_url: "http://localhost:32768" netbox_token: "0123456789abcdef0123456789abcdef01234567" data: @@ -81,7 +81,7 @@ - test_service_update['msg'] == "services node-exporter updated" - name: "NETBOX_SERVICE: Test same details, but different protocol - Create" - netbox_service: + netbox.netbox.netbox_service: netbox_url: "http://localhost:32768" netbox_token: "0123456789abcdef0123456789abcdef01234567" data: @@ -104,7 +104,7 @@ - test_service_protocol['msg'] == "services node-exporter created" - name: "NETBOX_SERVICE: Test service deletion" - netbox_service: + netbox.netbox.netbox_service: netbox_url: "http://localhost:32768" netbox_token: "0123456789abcdef0123456789abcdef01234567" data: @@ -124,7 +124,7 @@ - test_service_delete['msg'] == "services node-exporter deleted" - name: "NETBOX_SERVICE: Test service IP addresses" - netbox_service: + netbox.netbox.netbox_service: netbox_url: "http://localhost:32768" netbox_token: "0123456789abcdef0123456789abcdef01234567" data: diff --git a/tests/integration/v2.7/tasks/netbox_site.yml b/tests/integration/targets/latest/tasks/netbox_site.yml similarity index 96% rename from tests/integration/v2.7/tasks/netbox_site.yml rename to tests/integration/targets/latest/tasks/netbox_site.yml index b1aa04ebd..dd7f9ffc5 100644 --- a/tests/integration/v2.7/tasks/netbox_site.yml +++ b/tests/integration/targets/latest/tasks/netbox_site.yml @@ -5,7 +5,7 @@ ## ## - name: "1 - Create site within Netbox with only required information" - netbox_site: + netbox.netbox.netbox_site: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -23,7 +23,7 @@ - test_one['msg'] == "site Test - Colorado created" - name: "2 - Duplicate" - netbox_site: + netbox.netbox.netbox_site: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -39,7 +39,7 @@ - test_two['site']['name'] == "Test - Colorado" - name: "3 - Update Test - Colorado" - netbox_site: + netbox.netbox.netbox_site: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -64,7 +64,7 @@ - test_three['site']['region'] == 1 - name: "4 - Create site with all parameters" - netbox_site: + netbox.netbox.netbox_site: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -114,7 +114,7 @@ - test_four['site']['slug'] == "test_california" - name: "5 - Delete site within netbox" - netbox_site: + netbox.netbox.netbox_site: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: diff --git a/tests/integration/v2.8/tasks/netbox_tenant.yml b/tests/integration/targets/latest/tasks/netbox_tenant.yml similarity index 95% rename from tests/integration/v2.8/tasks/netbox_tenant.yml rename to tests/integration/targets/latest/tasks/netbox_tenant.yml index c6b95e807..420cb22e3 100644 --- a/tests/integration/v2.8/tasks/netbox_tenant.yml +++ b/tests/integration/targets/latest/tasks/netbox_tenant.yml @@ -5,7 +5,7 @@ ## ## - name: "1 - Test tenant creation" - netbox_tenant: + netbox.netbox.netbox_tenant: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -23,7 +23,7 @@ - test_one['msg'] == "tenant Tenant ABC created" - name: "Test duplicate tenant" - netbox_tenant: + netbox.netbox.netbox_tenant: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -39,7 +39,7 @@ - test_two['msg'] == "tenant Tenant ABC already exists" - name: "3 - Test update" - netbox_tenant: + netbox.netbox.netbox_tenant: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -58,7 +58,7 @@ - test_three['msg'] == "tenant Tenant ABC updated" - name: "4 - Test delete" - netbox_tenant: + netbox.netbox.netbox_tenant: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -75,7 +75,7 @@ - test_four['msg'] == "tenant Tenant ABC deleted" - name: "5 - Create tenant with all parameters" - netbox_tenant: + netbox.netbox.netbox_tenant: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: diff --git a/tests/integration/v2.7/tasks/netbox_tenant_group.yml b/tests/integration/targets/latest/tasks/netbox_tenant_group.yml similarity index 93% rename from tests/integration/v2.7/tasks/netbox_tenant_group.yml rename to tests/integration/targets/latest/tasks/netbox_tenant_group.yml index d35fd194f..2ee814646 100644 --- a/tests/integration/v2.7/tasks/netbox_tenant_group.yml +++ b/tests/integration/targets/latest/tasks/netbox_tenant_group.yml @@ -5,7 +5,7 @@ ## ## - name: "1 - Test tenant group creation" - netbox_tenant_group: + netbox.netbox.netbox_tenant_group: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -23,7 +23,7 @@ - test_one['msg'] == "tenant_group Test Tenant Group Two created" - name: "Test duplicate tenant group" - netbox_tenant_group: + netbox.netbox.netbox_tenant_group: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -39,7 +39,7 @@ - test_two['msg'] == "tenant_group Test Tenant Group Two already exists" - name: "3 - Test delete" - netbox_tenant_group: + netbox.netbox.netbox_tenant_group: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -56,7 +56,7 @@ - test_three['msg'] == "tenant_group Test Tenant Group Two deleted" - name: "4 - Test another tenant group creation" - netbox_tenant_group: + netbox.netbox.netbox_tenant_group: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: diff --git a/tests/integration/v2.8/tasks/netbox_virtual_machine.yml b/tests/integration/targets/latest/tasks/netbox_virtual_machine.yml similarity index 95% rename from tests/integration/v2.8/tasks/netbox_virtual_machine.yml rename to tests/integration/targets/latest/tasks/netbox_virtual_machine.yml index aa025465b..b1e5e2478 100644 --- a/tests/integration/v2.8/tasks/netbox_virtual_machine.yml +++ b/tests/integration/targets/latest/tasks/netbox_virtual_machine.yml @@ -5,7 +5,7 @@ ## ## - name: "VIRTUAL_MACHINE 1: Necessary info creation" - netbox_virtual_machine: + netbox.netbox.netbox_virtual_machine: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -25,7 +25,7 @@ - test_one['msg'] == "virtual_machine Test VM One created" - name: "VIRTUAL_MACHINE 2: Create duplicate" - netbox_virtual_machine: + netbox.netbox.netbox_virtual_machine: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -43,7 +43,7 @@ - test_two['msg'] == "virtual_machine Test VM One already exists" - name: "VIRTUAL_MACHINE 3: Update" - netbox_virtual_machine: + netbox.netbox.netbox_virtual_machine: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -77,7 +77,7 @@ - test_three['msg'] == "virtual_machine Test VM One updated" - name: "VIRTUAL_MACHINE 4: ASSERT - Delete" - netbox_virtual_machine: + netbox.netbox.netbox_virtual_machine: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: diff --git a/tests/integration/v2.7/tasks/netbox_vlan.yml b/tests/integration/targets/latest/tasks/netbox_vlan.yml similarity index 96% rename from tests/integration/v2.7/tasks/netbox_vlan.yml rename to tests/integration/targets/latest/tasks/netbox_vlan.yml index 5903b4793..51a9608c4 100644 --- a/tests/integration/v2.7/tasks/netbox_vlan.yml +++ b/tests/integration/targets/latest/tasks/netbox_vlan.yml @@ -5,7 +5,7 @@ ## ## - name: "VLAN 1: Necessary info creation" - netbox_vlan: + netbox.netbox.netbox_vlan: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -25,7 +25,7 @@ - test_one['msg'] == "vlan Test VLAN 500 created" - name: "VLAN 2: Create duplicate" - netbox_vlan: + netbox.netbox.netbox_vlan: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -43,7 +43,7 @@ - test_two['msg'] == "vlan Test VLAN 500 already exists" - name: "VLAN 3: Create VLAN with same name, but different site" - netbox_vlan: + netbox.netbox.netbox_vlan: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -66,7 +66,7 @@ - test_three['msg'] == "vlan Test VLAN 500 created" - name: "VLAN 4: ASSERT - Update" - netbox_vlan: + netbox.netbox.netbox_vlan: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -103,7 +103,7 @@ - test_four['msg'] == "vlan Test VLAN 500 updated" - name: "VLAN 5: ASSERT - Delete more than one result" - netbox_vlan: + netbox.netbox.netbox_vlan: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -119,7 +119,7 @@ - test_five['msg'] == "More than one result returned for Test VLAN 500" - name: "VLAN 6: ASSERT - Delete" - netbox_vlan: + netbox.netbox.netbox_vlan: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: diff --git a/tests/integration/v2.7/tasks/netbox_vlan_group.yml b/tests/integration/targets/latest/tasks/netbox_vlan_group.yml similarity index 94% rename from tests/integration/v2.7/tasks/netbox_vlan_group.yml rename to tests/integration/targets/latest/tasks/netbox_vlan_group.yml index 063c91c42..df59a1699 100644 --- a/tests/integration/v2.7/tasks/netbox_vlan_group.yml +++ b/tests/integration/targets/latest/tasks/netbox_vlan_group.yml @@ -5,7 +5,7 @@ ## ## - name: "VLAN_GROUP 1: Necessary info creation" - netbox_vlan_group: + netbox.netbox.netbox_vlan_group: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -26,7 +26,7 @@ - test_one['msg'] == "vlan_group VLAN Group One created" - name: "VLAN_GROUP 2: Create duplicate" - netbox_vlan_group: + netbox.netbox.netbox_vlan_group: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -45,7 +45,7 @@ - test_two['msg'] == "vlan_group VLAN Group One already exists" - name: "VLAN_GROUP 3: ASSERT - Create with same name, different site" - netbox_vlan_group: + netbox.netbox.netbox_vlan_group: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -64,7 +64,7 @@ - test_three['msg'] == "vlan_group VLAN Group One created" - name: "VLAN_GROUP 4: ASSERT - Create vlan group, no site" - netbox_vlan_group: + netbox.netbox.netbox_vlan_group: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -80,7 +80,7 @@ - test_four['msg'] == "More than one result returned for VLAN Group One" - name: "VLAN_GROUP 5: ASSERT - Delete" - netbox_vlan_group: + netbox.netbox.netbox_vlan_group: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -101,7 +101,7 @@ - test_five['msg'] == "vlan_group VLAN Group One deleted" - name: "VLAN_GROUP 6: ASSERT - Delete non existing" - netbox_vlan_group: + netbox.netbox.netbox_vlan_group: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: diff --git a/tests/integration/v2.8/tasks/netbox_vm_interface.yml b/tests/integration/targets/latest/tasks/netbox_vm_interface.yml similarity index 96% rename from tests/integration/v2.8/tasks/netbox_vm_interface.yml rename to tests/integration/targets/latest/tasks/netbox_vm_interface.yml index 08ea21e20..28b20344c 100644 --- a/tests/integration/v2.8/tasks/netbox_vm_interface.yml +++ b/tests/integration/targets/latest/tasks/netbox_vm_interface.yml @@ -5,7 +5,7 @@ ## ## - name: "NETBOX_VM_INTERFACE 1: Necessary info creation" - netbox_vm_interface: + netbox.netbox.netbox_vm_interface: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -25,7 +25,7 @@ - test_one['msg'] == "interface Eth10 created" - name: "NETBOX_VM_INTERFACE 2: Create duplicate" - netbox_vm_interface: + netbox.netbox.netbox_vm_interface: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -43,7 +43,7 @@ - test_two['msg'] == "interface Eth10 already exists" - name: "NETBOX_VM_INTERFACE 3: Updated" - netbox_vm_interface: + netbox.netbox.netbox_vm_interface: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -92,7 +92,7 @@ - test_three['msg'] == "interface Eth10 updated" - name: "NETBOX_VM_INTERFACE 4: ASSERT - Delete" - netbox_vm_interface: + netbox.netbox.netbox_vm_interface: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -110,7 +110,7 @@ - test_four['msg'] == "interface Eth10 deleted" - name: "NETBOX_VM_INTERFACE 5: Attempt to update interface with same name on other VMs" - netbox_vm_interface: + netbox.netbox.netbox_vm_interface: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: diff --git a/tests/integration/v2.6/tasks/netbox_vrf.yml b/tests/integration/targets/latest/tasks/netbox_vrf.yml similarity index 95% rename from tests/integration/v2.6/tasks/netbox_vrf.yml rename to tests/integration/targets/latest/tasks/netbox_vrf.yml index cf75d08be..dc3d428d5 100644 --- a/tests/integration/v2.6/tasks/netbox_vrf.yml +++ b/tests/integration/targets/latest/tasks/netbox_vrf.yml @@ -5,7 +5,7 @@ ## ## - name: "VRF 1: Necessary info creation" - netbox_vrf: + netbox.netbox.netbox_vrf: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -23,7 +23,7 @@ - test_one['msg'] == "vrf Test VRF One created" - name: "VRF 2: Create duplicate" - netbox_vrf: + netbox.netbox.netbox_vrf: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -39,7 +39,7 @@ - test_two['msg'] == "vrf Test VRF One already exists" - name: "VRF 3: Create VRF with same name, but different tenant" - netbox_vrf: + netbox.netbox.netbox_vrf: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -59,7 +59,7 @@ - test_three['msg'] == "vrf Test VRF One created" - name: "VRF 4: ASSERT - Update" - netbox_vrf: + netbox.netbox.netbox_vrf: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -90,7 +90,7 @@ - test_four['msg'] == "vrf Test VRF One updated" - name: "VRF 5: ASSERT - Delete more than one result" - netbox_vrf: + netbox.netbox.netbox_vrf: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -106,7 +106,7 @@ - test_five['msg'] == "More than one result returned for Test VRF One" - name: "VRF 6: ASSERT - Delete" - netbox_vrf: + netbox.netbox.netbox_vrf: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: diff --git a/tests/integration/regression-tests.yml b/tests/integration/targets/regression/tasks/main.yml similarity index 77% rename from tests/integration/regression-tests.yml rename to tests/integration/targets/regression/tasks/main.yml index 065fb072c..fac9e3d07 100644 --- a/tests/integration/regression-tests.yml +++ b/tests/integration/targets/regression/tasks/main.yml @@ -5,18 +5,11 @@ ## ## - name: "TEST NETBOX CONNECTION FAILURE" - hosts: localhost connection: local - gather_facts: no - collections: - - netbox.netbox - vars: - netbox_url: "http://localhost:32768" - - tasks: + block: - name: "1 - Device with required information" - netbox_device: - netbox_url: netbox_url + netbox.netbox.netbox_device: + netbox_url: "http://some-random-invalid-URL" netbox_token: "0123456789abcdef0123456789abcdef01234567" data: name: "R1" diff --git a/tests/integration/targets/v2.6/tasks/main.yml b/tests/integration/targets/v2.6/tasks/main.yml new file mode 100644 index 000000000..34547fd9f --- /dev/null +++ b/tests/integration/targets/v2.6/tasks/main.yml @@ -0,0 +1,102 @@ +--- +- name: "NETBOX_DEVICE TESTS" + include_tasks: "netbox_device.yml" + +- name: "NETBOX_DEVICE_INTERFACE TESTS" + include_tasks: "netbox_device_interface.yml" + +- name: "NETBOX_IP_ADDRESS TESTS" + include_tasks: "netbox_ip_address.yml" + +- name: "NETBOX_PREFIX TESTS" + include_tasks: "netbox_prefix.yml" + +- name: "NETBOX_SITE TESTS" + include_tasks: "netbox_site.yml" + +- name: "NETBOX_TENTANT TESTS" + include_tasks: "netbox_tenant.yml" + +- name: "NETBOX_TENTANT_GROUP TESTS" + include_tasks: "netbox_tenant_group.yml" + +- name: "NETBOX_RACK TESTS" + include_tasks: "netbox_rack.yml" + +- name: "NETBOX_RACK_ROLE TESTS" + include_tasks: "netbox_rack_role.yml" + +- name: "NETBOX_RACK_GROUP TESTS" + include_tasks: "netbox_rack_group.yml" + +- name: "NETBOX_MANUFACTURER TESTS" + include_tasks: "netbox_manufacturer.yml" + +- name: "NETBOX_PLATFORM TESTS" + include_tasks: "netbox_platform.yml" + +- name: "NETBOX_DEVICE_TYPE TESTS" + include_tasks: "netbox_device_type.yml" + +- name: "NETBOX_DEVICE_ROLE TESTS" + include_tasks: "netbox_device_role.yml" + +- name: "NETBOX_IPAM_ROLE TESTS" + include_tasks: "netbox_ipam_role.yml" + +- name: "NETBOX_VLAN_GROUP TESTS" + include_tasks: "netbox_vlan_group.yml" + +- name: "NETBOX_VLAN TESTS" + include_tasks: "netbox_vlan.yml" + +- name: "NETBOX_VRF TESTS" + include_tasks: "netbox_vrf.yml" + +- name: "NETBOX_RIR TESTS" + include_tasks: "netbox_rir.yml" + +- name: "NETBOX_AGGREGATE TESTS" + include_tasks: "netbox_aggregate.yml" + +- name: "NETBOX_REGION TESTS" + include_tasks: "netbox_region.yml" + +- name: "NETBOX_DEVICE_BAY TESTS" + include_tasks: "netbox_device_bay.yml" + +- name: "NETBOX_INVENTORY_ITEM TESTS" + include_tasks: "netbox_inventory_item.yml" + +- name: "NETBOX_VIRTUAL_MACHINE TESTS" + include_tasks: "netbox_virtual_machine.yml" + +- name: "NETBOX_CLUSTER TESTS" + include_tasks: "netbox_cluster.yml" + +- name: "NETBOX_CLUSTER_GROUP TESTS" + include_tasks: "netbox_cluster_group.yml" + +- name: "NETBOX_CLUSTER_TYPE TESTS" + include_tasks: "netbox_cluster_type.yml" + +- name: "NETBOX_VM_INTERFACE TESTS" + include_tasks: "netbox_vm_interface.yml" + +- name: "NETBOX_PROVIDER TESTS" + include_tasks: "netbox_provider.yml" + +- name: "NETBOX_CIRCUIT_TYPE TESTS" + include_tasks: "netbox_circuit_type.yml" + +- name: "NETBOX_CIRCUIT TESTS" + include_tasks: "netbox_circuit.yml" + +- name: "NETBOX_CIRCUIT_TERMINATION TESTS" + include_tasks: "netbox_circuit_termination.yml" + +- name: "NETBOX_SERVICE TESTS" + include_tasks: "netbox_service.yml" + +- name: "NETBOX_LOOKUP TESTS" + include_tasks: "netbox_lookup.yml" diff --git a/tests/integration/v2.8/tasks/netbox_aggregate.yml b/tests/integration/targets/v2.6/tasks/netbox_aggregate.yml similarity index 95% rename from tests/integration/v2.8/tasks/netbox_aggregate.yml rename to tests/integration/targets/v2.6/tasks/netbox_aggregate.yml index c9e2cffef..3c3e66ec9 100644 --- a/tests/integration/v2.8/tasks/netbox_aggregate.yml +++ b/tests/integration/targets/v2.6/tasks/netbox_aggregate.yml @@ -5,7 +5,7 @@ ## ## - name: "AGGREGATE 1: Necessary info creation" - netbox_aggregate: + netbox.netbox.netbox_aggregate: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -26,7 +26,7 @@ - test_one['msg'] == "aggregate 10.0.0.0/8 created" - name: "AGGREGATE 2: Create duplicate" - netbox_aggregate: + netbox.netbox.netbox_aggregate: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -44,7 +44,7 @@ - test_two['msg'] == "aggregate 10.0.0.0/8 already exists" - name: "AGGREGATE 3: ASSERT - Update" - netbox_aggregate: + netbox.netbox.netbox_aggregate: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -73,7 +73,7 @@ - test_three['msg'] == "aggregate 10.0.0.0/8 updated" - name: "AGGREGATE 4: ASSERT - Delete" - netbox_aggregate: + netbox.netbox.netbox_aggregate: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -94,7 +94,7 @@ - test_four['msg'] == "aggregate 10.0.0.0/8 deleted" - name: "AGGREGATE 5: Necessary info creation" - netbox_aggregate: + netbox.netbox.netbox_aggregate: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: diff --git a/tests/integration/v2.6/tasks/netbox_circuit.yml b/tests/integration/targets/v2.6/tasks/netbox_circuit.yml similarity index 96% rename from tests/integration/v2.6/tasks/netbox_circuit.yml rename to tests/integration/targets/v2.6/tasks/netbox_circuit.yml index 98ffe9d59..e61c7c690 100644 --- a/tests/integration/v2.6/tasks/netbox_circuit.yml +++ b/tests/integration/targets/v2.6/tasks/netbox_circuit.yml @@ -5,7 +5,7 @@ ## ## - name: "NETBOX_CIRCUIT 1: Create provider within Netbox with only required information" - netbox_circuit: + netbox.netbox.netbox_circuit: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -27,7 +27,7 @@ - test_one['msg'] == "circuit Test Circuit One created" - name: "NETBOX_CIRCUIT 2: Duplicate" - netbox_circuit: + netbox.netbox.netbox_circuit: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -47,7 +47,7 @@ - test_two['msg'] == "circuit Test Circuit One already exists" - name: "NETBOX_CIRCUIT 3: Update provider with other fields" - netbox_circuit: + netbox.netbox.netbox_circuit: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -85,7 +85,7 @@ - test_three['msg'] == "circuit Test Circuit One updated" - name: "NETBOX_CIRCUIT 4: Delete provider within netbox" - netbox_circuit: + netbox.netbox.netbox_circuit: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: diff --git a/tests/integration/v2.8/tasks/netbox_circuit_termination.yml b/tests/integration/targets/v2.6/tasks/netbox_circuit_termination.yml similarity index 95% rename from tests/integration/v2.8/tasks/netbox_circuit_termination.yml rename to tests/integration/targets/v2.6/tasks/netbox_circuit_termination.yml index 6e79a3d34..6851b5105 100644 --- a/tests/integration/v2.8/tasks/netbox_circuit_termination.yml +++ b/tests/integration/targets/v2.6/tasks/netbox_circuit_termination.yml @@ -5,7 +5,7 @@ ## ## - name: "NETBOX_CIRCUIT_TERMINATION 1: Create provider within Netbox with only required information" - netbox_circuit_termination: + netbox.netbox.netbox_circuit_termination: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -29,7 +29,7 @@ - test_one['msg'] == "circuit_termination test_circuit_a created" - name: "NETBOX_CIRCUIT_TERMINATION 2: Duplicate" - netbox_circuit_termination: + netbox.netbox.netbox_circuit_termination: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -49,7 +49,7 @@ - test_two['msg'] == "circuit_termination test_circuit_a already exists" - name: "NETBOX_CIRCUIT_TERMINATION 3: Update provider with other fields" - netbox_circuit_termination: + netbox.netbox.netbox_circuit_termination: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -81,7 +81,7 @@ - test_three['msg'] == "circuit_termination test_circuit_a updated" - name: "NETBOX_CIRCUIT_TERMINATION 4: Create Z Side" - netbox_circuit_termination: + netbox.netbox.netbox_circuit_termination: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -105,7 +105,7 @@ - test_four['msg'] == "circuit_termination test_circuit_z created" - name: "NETBOX_CIRCUIT_TERMINATION 5: Delete provider within netbox" - netbox_circuit_termination: + netbox.netbox.netbox_circuit_termination: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: diff --git a/tests/integration/v2.8/tasks/netbox_circuit_type.yml b/tests/integration/targets/v2.6/tasks/netbox_circuit_type.yml similarity index 94% rename from tests/integration/v2.8/tasks/netbox_circuit_type.yml rename to tests/integration/targets/v2.6/tasks/netbox_circuit_type.yml index c7685e524..45f956e34 100644 --- a/tests/integration/v2.8/tasks/netbox_circuit_type.yml +++ b/tests/integration/targets/v2.6/tasks/netbox_circuit_type.yml @@ -5,7 +5,7 @@ ## ## - name: "CIRCUIT_TYPE 1: Necessary info creation" - netbox_circuit_type: + netbox.netbox.netbox_circuit_type: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -24,7 +24,7 @@ - test_one['msg'] == "circuit_type Test Circuit Type One created" - name: "CIRCUIT_TYPE 2: Create duplicate" - netbox_circuit_type: + netbox.netbox.netbox_circuit_type: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -41,7 +41,7 @@ - test_two['msg'] == "circuit_type Test Circuit Type One already exists" - name: "CIRCUIT_TYPE 3: User specified slug" - netbox_circuit_type: + netbox.netbox.netbox_circuit_type: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -61,7 +61,7 @@ - test_three['msg'] == "circuit_type Test Circuit Type Two created" - name: "CIRCUIT_TYPE 4: ASSERT - Delete" - netbox_circuit_type: + netbox.netbox.netbox_circuit_type: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -78,7 +78,7 @@ - test_four['msg'] == "circuit_type Test Circuit Type One deleted" - name: "CIRCUIT_TYPE 5: ASSERT - Delete" - netbox_circuit_type: + netbox.netbox.netbox_circuit_type: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: diff --git a/tests/integration/v2.6/tasks/netbox_cluster.yml b/tests/integration/targets/v2.6/tasks/netbox_cluster.yml similarity index 95% rename from tests/integration/v2.6/tasks/netbox_cluster.yml rename to tests/integration/targets/v2.6/tasks/netbox_cluster.yml index fdda9a69e..e80a034ba 100644 --- a/tests/integration/v2.6/tasks/netbox_cluster.yml +++ b/tests/integration/targets/v2.6/tasks/netbox_cluster.yml @@ -5,7 +5,7 @@ ## ## - name: "CLUSTER 1: Necessary info creation" - netbox_cluster: + netbox.netbox.netbox_cluster: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -25,7 +25,7 @@ - test_one['msg'] == "cluster Test Cluster One created" - name: "CLUSTER 2: Create duplicate" - netbox_cluster: + netbox.netbox.netbox_cluster: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -43,7 +43,7 @@ - test_two['msg'] == "cluster Test Cluster One already exists" - name: "CLUSTER 3: Update" - netbox_cluster: + netbox.netbox.netbox_cluster: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -74,7 +74,7 @@ - test_three['msg'] == "cluster Test Cluster One updated" - name: "CLUSTER 4: ASSERT - Delete" - netbox_cluster: + netbox.netbox.netbox_cluster: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: diff --git a/tests/integration/v2.6/tasks/netbox_cluster_group.yml b/tests/integration/targets/v2.6/tasks/netbox_cluster_group.yml similarity index 94% rename from tests/integration/v2.6/tasks/netbox_cluster_group.yml rename to tests/integration/targets/v2.6/tasks/netbox_cluster_group.yml index 27ebb73e6..9f84518ce 100644 --- a/tests/integration/v2.6/tasks/netbox_cluster_group.yml +++ b/tests/integration/targets/v2.6/tasks/netbox_cluster_group.yml @@ -5,7 +5,7 @@ ## ## - name: "CLUSTER_GROUP 1: Necessary info creation" - netbox_cluster_group: + netbox.netbox.netbox_cluster_group: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -24,7 +24,7 @@ - test_one['msg'] == "cluster_group Test Cluster Group One created" - name: "CLUSTER_GROUP 2: Create duplicate" - netbox_cluster_group: + netbox.netbox.netbox_cluster_group: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -41,7 +41,7 @@ - test_two['msg'] == "cluster_group Test Cluster Group One already exists" - name: "CLUSTER_GROUP 3: User specified slug" - netbox_cluster_group: + netbox.netbox.netbox_cluster_group: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -61,7 +61,7 @@ - test_three['msg'] == "cluster_group Test Cluster Group Two created" - name: "CLUSTER_GROUP 4: ASSERT - Delete" - netbox_cluster_group: + netbox.netbox.netbox_cluster_group: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -78,7 +78,7 @@ - test_four['msg'] == "cluster_group Test Cluster Group One deleted" - name: "CLUSTER_GROUP 5: ASSERT - Delete" - netbox_cluster_group: + netbox.netbox.netbox_cluster_group: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: diff --git a/tests/integration/v2.7/tasks/netbox_cluster_type.yml b/tests/integration/targets/v2.6/tasks/netbox_cluster_type.yml similarity index 94% rename from tests/integration/v2.7/tasks/netbox_cluster_type.yml rename to tests/integration/targets/v2.6/tasks/netbox_cluster_type.yml index cd4a111e0..abcaed091 100644 --- a/tests/integration/v2.7/tasks/netbox_cluster_type.yml +++ b/tests/integration/targets/v2.6/tasks/netbox_cluster_type.yml @@ -4,7 +4,7 @@ ## ## - name: "CLUSTER_TYPE 1: Necessary info creation" - netbox_cluster_type: + netbox.netbox.netbox_cluster_type: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -23,7 +23,7 @@ - test_one['msg'] == "cluster_type Test Cluster Type One created" - name: "CLUSTER_TYPE 2: Create duplicate" - netbox_cluster_type: + netbox.netbox.netbox_cluster_type: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -40,7 +40,7 @@ - test_two['msg'] == "cluster_type Test Cluster Type One already exists" - name: "CLUSTER_TYPE 3: User specified slug" - netbox_cluster_type: + netbox.netbox.netbox_cluster_type: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -60,7 +60,7 @@ - test_three['msg'] == "cluster_type Test Cluster Type Two created" - name: "CLUSTER_TYPE 4: ASSERT - Delete" - netbox_cluster_type: + netbox.netbox.netbox_cluster_type: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -77,7 +77,7 @@ - test_four['msg'] == "cluster_type Test Cluster Type One deleted" - name: "CLUSTER_TYPE 5: ASSERT - Delete" - netbox_cluster_type: + netbox.netbox.netbox_cluster_type: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: diff --git a/tests/integration/v2.6/tasks/netbox_device.yml b/tests/integration/targets/v2.6/tasks/netbox_device.yml similarity index 95% rename from tests/integration/v2.6/tasks/netbox_device.yml rename to tests/integration/targets/v2.6/tasks/netbox_device.yml index 9732e67c7..6ea19cbb5 100644 --- a/tests/integration/v2.6/tasks/netbox_device.yml +++ b/tests/integration/targets/v2.6/tasks/netbox_device.yml @@ -5,7 +5,7 @@ ## ## - name: "1 - Device with required information" - netbox_device: + netbox.netbox.netbox_device: netbox_url: "http://localhost:32768" netbox_token: "0123456789abcdef0123456789abcdef01234567" data: @@ -32,7 +32,7 @@ - test_one['msg'] == "device R1 created" - name: "2 - Duplicate device" - netbox_device: + netbox.netbox.netbox_device: netbox_url: "http://localhost:32768" netbox_token: "0123456789abcdef0123456789abcdef01234567" data: @@ -56,7 +56,7 @@ - test_two['msg'] == "device R1 already exists" - name: "3 - Update device" - netbox_device: + netbox.netbox.netbox_device: netbox_url: "http://localhost:32768" netbox_token: "0123456789abcdef0123456789abcdef01234567" data: @@ -79,7 +79,7 @@ - test_three['msg'] == "device R1 updated" - name: "4 - Create device with tags and assign to rack" - netbox_device: + netbox.netbox.netbox_device: netbox_url: "http://localhost:32768" netbox_token: "0123456789abcdef0123456789abcdef01234567" data: @@ -115,7 +115,7 @@ - test_four['msg'] == "device TestR1 created" - name: "5 - Delete previous device" - netbox_device: + netbox.netbox.netbox_device: netbox_url: "http://localhost:32768" netbox_token: "0123456789abcdef0123456789abcdef01234567" data: @@ -132,7 +132,7 @@ - test_five['msg'] == "device TestR1 deleted" - name: "6 - Delete R1" - netbox_device: + netbox.netbox.netbox_device: netbox_url: "http://localhost:32768" netbox_token: "0123456789abcdef0123456789abcdef01234567" data: @@ -149,7 +149,7 @@ - test_six['msg'] == "device R1 deleted" - name: "7 - Add primary_ip4/6 to test100" - netbox_device: + netbox.netbox.netbox_device: netbox_url: "http://localhost:32768" netbox_token: "0123456789abcdef0123456789abcdef01234567" data: @@ -175,7 +175,7 @@ - test_seven['msg'] == "device test100 updated" - name: "8 - Device with empty string name" - netbox_device: + netbox.netbox.netbox_device: netbox_url: "http://localhost:32768" netbox_token: "0123456789abcdef0123456789abcdef01234567" data: @@ -198,4 +198,4 @@ - test_eight['device']['site'] == 1 - test_eight['device']['status'] == 3 - "'-' in test_eight['device']['name']" - - "test_eight['device']['name'] | length == 36" \ No newline at end of file + - "test_eight['device']['name'] | length == 36" diff --git a/tests/integration/v2.6/tasks/netbox_device_bay.yml b/tests/integration/targets/v2.6/tasks/netbox_device_bay.yml similarity index 94% rename from tests/integration/v2.6/tasks/netbox_device_bay.yml rename to tests/integration/targets/v2.6/tasks/netbox_device_bay.yml index 62f0436b9..f8e27820e 100644 --- a/tests/integration/v2.6/tasks/netbox_device_bay.yml +++ b/tests/integration/targets/v2.6/tasks/netbox_device_bay.yml @@ -5,7 +5,7 @@ ## ## - name: "DEVICE_BAY 1: Necessary info creation" - netbox_device_bay: + netbox.netbox.netbox_device_bay: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -25,7 +25,7 @@ - test_one['msg'] == "device_bay Device Bay One created" - name: "DEVICE_BAY 2: Create duplicate" - netbox_device_bay: + netbox.netbox.netbox_device_bay: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -43,7 +43,7 @@ - test_two['msg'] == "device_bay Device Bay One already exists" - name: "DEVICE_BAY 3: ASSERT - Update" - netbox_device_bay: + netbox.netbox.netbox_device_bay: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -68,7 +68,7 @@ - test_three['msg'] == "device_bay Device Bay One updated" - name: "DEVICE_BAY 4: ASSERT - Delete" - netbox_device_bay: + netbox.netbox.netbox_device_bay: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: diff --git a/tests/integration/v2.6/tasks/netbox_device_interface.yml b/tests/integration/targets/v2.6/tasks/netbox_device_interface.yml similarity index 94% rename from tests/integration/v2.6/tasks/netbox_device_interface.yml rename to tests/integration/targets/v2.6/tasks/netbox_device_interface.yml index dc643fb51..8e4f39729 100644 --- a/tests/integration/v2.6/tasks/netbox_device_interface.yml +++ b/tests/integration/targets/v2.6/tasks/netbox_device_interface.yml @@ -5,7 +5,7 @@ ## ## - name: "1 - Interface with required information" - netbox_device_interface: + netbox.netbox.netbox_device_interface: netbox_url: "http://localhost:32768" netbox_token: "0123456789abcdef0123456789abcdef01234567" data: @@ -24,7 +24,7 @@ - test_one['interface']['device'] == 1 - name: "2 - Update test100 - GigabitEthernet3" - netbox_device_interface: + netbox.netbox.netbox_device_interface: netbox_url: "http://localhost:32768" netbox_token: "0123456789abcdef0123456789abcdef01234567" data: @@ -47,7 +47,7 @@ - test_two['interface']['mtu'] == 1600 - name: "3 - Delete interface test100 - GigabitEthernet3" - netbox_device_interface: + netbox.netbox.netbox_device_interface: netbox_url: "http://localhost:32768" netbox_token: "0123456789abcdef0123456789abcdef01234567" data: @@ -65,7 +65,7 @@ - test_three['diff']['after']['state'] == "absent" - name: "4 - Create LAG with several specified options" - netbox_device_interface: + netbox.netbox.netbox_device_interface: netbox_url: "http://localhost:32768" netbox_token: "0123456789abcdef0123456789abcdef01234567" data: @@ -94,7 +94,7 @@ - test_four['interface']['mtu'] == 1600 - name: "5 - Create interface and assign it to parent LAG" - netbox_device_interface: + netbox.netbox.netbox_device_interface: netbox_url: "http://localhost:32768" netbox_token: "0123456789abcdef0123456789abcdef01234567" data: @@ -127,7 +127,7 @@ - test_five['interface']['mtu'] == 1600 - name: "6 - Create interface as trunk port" - netbox_device_interface: + netbox.netbox.netbox_device_interface: netbox_url: "http://localhost:32768" netbox_token: "0123456789abcdef0123456789abcdef01234567" data: @@ -167,7 +167,7 @@ - test_six['interface']['untagged_vlan'] == 1 - name: "7 - Duplicate Interface" - netbox_device_interface: + netbox.netbox.netbox_device_interface: netbox_url: "http://localhost:32768" netbox_token: "0123456789abcdef0123456789abcdef01234567" data: @@ -184,7 +184,7 @@ - test_seven['interface']['device'] == 1 - name: "Add port-channel1 to R1 to test finding proper port-channel1" - netbox_device_interface: + netbox.netbox.netbox_device_interface: netbox_url: "http://localhost:32768" netbox_token: "0123456789abcdef0123456789abcdef01234567" data: @@ -193,7 +193,7 @@ form_factor: "Link Aggregation Group (LAG)" - name: "8 - Create interface and assign it to parent LAG - non dict" - netbox_device_interface: + netbox.netbox.netbox_device_interface: netbox_url: "http://localhost:32768" netbox_token: "0123456789abcdef0123456789abcdef01234567" data: @@ -225,7 +225,7 @@ - test_eight['interface']['mtu'] == 1600 - name: "9 - Create interface on VC child" - netbox_device_interface: + netbox.netbox.netbox_device_interface: netbox_url: "http://localhost:32768" netbox_token: "0123456789abcdef0123456789abcdef01234567" data: @@ -248,7 +248,7 @@ - test_nine['interface']['form_factor'] == 1000 - name: "10 - Update interface on VC child" - netbox_device_interface: + netbox.netbox.netbox_device_interface: netbox_url: "http://localhost:32768" netbox_token: "0123456789abcdef0123456789abcdef01234567" data: @@ -272,7 +272,7 @@ - test_ten['interface']['description'] == 'Updated child interface from parent device' - name: "11 - Update interface on VC child w/o update_vc_child" - netbox_device_interface: + netbox.netbox.netbox_device_interface: netbox_url: "http://localhost:32768" netbox_token: "0123456789abcdef0123456789abcdef01234567" data: @@ -287,4 +287,4 @@ assert: that: - test_eleven is failed - - test_eleven['msg'] == "Must set update_vc_child to True to allow child device interface modification" \ No newline at end of file + - test_eleven['msg'] == "Must set update_vc_child to True to allow child device interface modification" diff --git a/tests/integration/v2.7/tasks/netbox_device_role.yml b/tests/integration/targets/v2.6/tasks/netbox_device_role.yml similarity index 94% rename from tests/integration/v2.7/tasks/netbox_device_role.yml rename to tests/integration/targets/v2.6/tasks/netbox_device_role.yml index 9d0d9477c..64ec9840f 100644 --- a/tests/integration/v2.7/tasks/netbox_device_role.yml +++ b/tests/integration/targets/v2.6/tasks/netbox_device_role.yml @@ -5,7 +5,7 @@ ## ## - name: "DEVICE_ROLE 1: Necessary info creation" - netbox_device_role: + netbox.netbox.netbox_device_role: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -26,7 +26,7 @@ - test_one['msg'] == "device_role Test Device Role created" - name: "DEVICE_ROLE 2: Create duplicate" - netbox_device_role: + netbox.netbox.netbox_device_role: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -45,7 +45,7 @@ - test_two['msg'] == "device_role Test Device Role already exists" - name: "DEVICE_ROLE 3: ASSERT - Update" - netbox_device_role: + netbox.netbox.netbox_device_role: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -68,7 +68,7 @@ - test_three['msg'] == "device_role Test Device Role updated" - name: "DEVICE_ROLE 4: ASSERT - Delete" - netbox_device_role: + netbox.netbox.netbox_device_role: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -85,7 +85,7 @@ - test_four['msg'] == "device_role Test Device Role deleted" - name: "DEVICE_ROLE 5: ASSERT - Delete non existing" - netbox_device_role: + netbox.netbox.netbox_device_role: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: diff --git a/tests/integration/v2.6/tasks/netbox_device_type.yml b/tests/integration/targets/v2.6/tasks/netbox_device_type.yml similarity index 95% rename from tests/integration/v2.6/tasks/netbox_device_type.yml rename to tests/integration/targets/v2.6/tasks/netbox_device_type.yml index b0178f01f..1e5437277 100644 --- a/tests/integration/v2.6/tasks/netbox_device_type.yml +++ b/tests/integration/targets/v2.6/tasks/netbox_device_type.yml @@ -5,7 +5,7 @@ ## ## - name: "DEVICE_TYPE 1: Necessary info creation" - netbox_device_type: + netbox.netbox.netbox_device_type: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -27,7 +27,7 @@ - test_one['msg'] == "device_type test-device-type created" - name: "DEVICE_TYPE 2: Create duplicate" - netbox_device_type: + netbox.netbox.netbox_device_type: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -47,7 +47,7 @@ - test_two['msg'] == "device_type test-device-type already exists" - name: "DEVICE_TYPE 3: ASSERT - Update" - netbox_device_type: + netbox.netbox.netbox_device_type: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -77,7 +77,7 @@ - test_three['msg'] == "device_type test-device-type updated" - name: "DEVICE_TYPE 4: ASSERT - Delete" - netbox_device_type: + netbox.netbox.netbox_device_type: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -94,7 +94,7 @@ - test_four['msg'] == "device_type test-device-type deleted" - name: "DEVICE_TYPE 5: ASSERT - Delete non existing" - netbox_device_type: + netbox.netbox.netbox_device_type: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -110,7 +110,7 @@ - test_five['msg'] == "device_type Test Device Type already absent" - name: "DEVICE_TYPE 6: Without Slug" - netbox_device_type: + netbox.netbox.netbox_device_type: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: diff --git a/tests/integration/v2.7/tasks/netbox_inventory_item.yml b/tests/integration/targets/v2.6/tasks/netbox_inventory_item.yml similarity index 95% rename from tests/integration/v2.7/tasks/netbox_inventory_item.yml rename to tests/integration/targets/v2.6/tasks/netbox_inventory_item.yml index a3e953e24..5d4eb603a 100644 --- a/tests/integration/v2.7/tasks/netbox_inventory_item.yml +++ b/tests/integration/targets/v2.6/tasks/netbox_inventory_item.yml @@ -5,7 +5,7 @@ ## ## - name: "INVENTORY_ITEM 1: Necessary info creation" - netbox_inventory_item: + netbox.netbox.netbox_inventory_item: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -25,7 +25,7 @@ - test_one['msg'] == "inventory_item 10G-SFP+ created" - name: "INVENTORY_ITEM 2: Create duplicate" - netbox_inventory_item: + netbox.netbox.netbox_inventory_item: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -43,7 +43,7 @@ - test_two['msg'] == "inventory_item 10G-SFP+ already exists" - name: "INVENTORY_ITEM 3: ASSERT - Update" - netbox_inventory_item: + netbox.netbox.netbox_inventory_item: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -80,7 +80,7 @@ - test_three['msg'] == "inventory_item 10G-SFP+ updated" - name: "INVENTORY_ITEM 4: ASSERT - Delete" - netbox_inventory_item: + netbox.netbox.netbox_inventory_item: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: diff --git a/tests/integration/v2.6/tasks/netbox_ip_address.yml b/tests/integration/targets/v2.6/tasks/netbox_ip_address.yml similarity index 95% rename from tests/integration/v2.6/tasks/netbox_ip_address.yml rename to tests/integration/targets/v2.6/tasks/netbox_ip_address.yml index 4a0c28d43..c0ca9a7e9 100644 --- a/tests/integration/v2.6/tasks/netbox_ip_address.yml +++ b/tests/integration/targets/v2.6/tasks/netbox_ip_address.yml @@ -5,7 +5,7 @@ ## ## - name: "1 - Create IP address within Netbox with only required information - State: Present" - netbox_ip_address: + netbox.netbox.netbox_ip_address: netbox_url: http://localhost.org:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -23,7 +23,7 @@ - test_one['ip_address']['address'] == "192.168.1.10/30" - name: "2 - Update 192.168.1.10/30" - netbox_ip_address: + netbox.netbox.netbox_ip_address: netbox_url: http://localhost.org:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -46,7 +46,7 @@ - test_two['ip_address']['description'] == "Updated ip address" - name: "3 - Delete IP - 192.168.1.10 - State: Absent" - netbox_ip_address: + netbox.netbox.netbox_ip_address: netbox_url: http://localhost.org:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -63,7 +63,7 @@ - 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_ip_address: + netbox.netbox.netbox_ip_address: netbox_url: http://localhost.org:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -81,7 +81,7 @@ - test_four['ip_address']['address'] == "192.168.1.20/30" - name: "5 - Create IP in global VRF - 192.168.1.20/30 - State: New" - netbox_ip_address: + netbox.netbox.netbox_ip_address: netbox_url: http://localhost.org:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -99,7 +99,7 @@ - test_five['ip_address']['address'] == "192.168.1.20/30" - name: "6 - Create new address with only prefix specified - State: new" - netbox_ip_address: + netbox.netbox.netbox_ip_address: netbox_url: http://localhost.org:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -117,7 +117,7 @@ - test_six['ip_address']['address'] == "192.168.100.1/24" - name: "7 - Create IP address with several specified" - netbox_ip_address: + netbox.netbox.netbox_ip_address: netbox_url: http://localhost.org:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -150,7 +150,7 @@ - test_seven['ip_address']['vrf'] == 1 - name: "8 - Create IP address and assign a nat_inside IP" - netbox_ip_address: + netbox.netbox.netbox_ip_address: netbox_url: http://localhost.org:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -179,7 +179,7 @@ - test_eight['ip_address']['vrf'] == 1 - name: "9 - Create IP address on GigabitEthernet2 - test100 - State: present" - netbox_ip_address: + netbox.netbox.netbox_ip_address: netbox_url: http://localhost.org:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -202,7 +202,7 @@ - test_nine['ip_address']['interface'] == 3 - name: "10 - Create IP address on GigabitEthernet2 - test100 - State: new" - netbox_ip_address: + netbox.netbox.netbox_ip_address: netbox_url: http://localhost.org:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -226,7 +226,7 @@ - test_ten['ip_address']['interface']['id'] == 3 - name: "11 - Create IP address on GigabitEthernet2 - test100 - State: present" - netbox_ip_address: + netbox.netbox.netbox_ip_address: netbox_url: http://localhost.org:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -248,7 +248,7 @@ - test_eleven['ip_address']['address'] == "192.168.100.2/24" - name: "12 - Duplicate - 192.168.100.2/24 on interface" - netbox_ip_address: + netbox.netbox.netbox_ip_address: netbox_url: http://localhost.org:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -268,7 +268,7 @@ - test_twelve['ip_address']['interface'] == 3 - name: "13 - Duplicate - 192.168.100.2/24" - netbox_ip_address: + netbox.netbox.netbox_ip_address: netbox_url: http://localhost.org:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -284,7 +284,7 @@ - test_thirteen['ip_address']['address'] == "192.168.100.2/24" - name: "14 - Create IP address on Eth0 - test100-vm - State: present" - netbox_ip_address: + netbox.netbox.netbox_ip_address: netbox_url: http://localhost.org:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -307,7 +307,7 @@ - test_fourteen['ip_address']['interface'] == 4 - name: "15 - Create IP address with no mask - State: Present" - netbox_ip_address: + netbox.netbox.netbox_ip_address: netbox_url: http://localhost.org:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: diff --git a/tests/integration/v2.6/tasks/netbox_ipam_role.yml b/tests/integration/targets/v2.6/tasks/netbox_ipam_role.yml similarity index 93% rename from tests/integration/v2.6/tasks/netbox_ipam_role.yml rename to tests/integration/targets/v2.6/tasks/netbox_ipam_role.yml index 240f57b62..1f1ff0f36 100644 --- a/tests/integration/v2.6/tasks/netbox_ipam_role.yml +++ b/tests/integration/targets/v2.6/tasks/netbox_ipam_role.yml @@ -5,7 +5,7 @@ ## ## - name: "IPAM_ROLE 1: Necessary info creation" - netbox_ipam_role: + netbox.netbox.netbox_ipam_role: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -24,7 +24,7 @@ - test_one['msg'] == "role Test IPAM Role created" - name: "IPAM_ROLE 2: Create duplicate" - netbox_ipam_role: + netbox.netbox.netbox_ipam_role: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -41,7 +41,7 @@ - test_two['msg'] == "role Test IPAM Role already exists" - name: "IPAM_ROLE 3: ASSERT - Update" - netbox_ipam_role: + netbox.netbox.netbox_ipam_role: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -61,7 +61,7 @@ - test_three['msg'] == "role Test IPAM Role updated" - name: "IPAM_ROLE 4: ASSERT - Delete" - netbox_ipam_role: + netbox.netbox.netbox_ipam_role: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -78,7 +78,7 @@ - test_four['msg'] == "role Test IPAM Role deleted" - name: "IPAM_ROLE 5: ASSERT - Delete non existing" - netbox_ipam_role: + netbox.netbox.netbox_ipam_role: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: diff --git a/tests/integration/v2.8/tasks/netbox_lookup.yml b/tests/integration/targets/v2.6/tasks/netbox_lookup.yml similarity index 97% rename from tests/integration/v2.8/tasks/netbox_lookup.yml rename to tests/integration/targets/v2.6/tasks/netbox_lookup.yml index a2d534b8a..076837b2d 100644 --- a/tests/integration/v2.8/tasks/netbox_lookup.yml +++ b/tests/integration/targets/v2.6/tasks/netbox_lookup.yml @@ -29,7 +29,7 @@ query_result: "{{ query('netbox.netbox.nb_lookup', 'vlans', api_endpoint='http://localhost:32768', token='0123456789abcdef0123456789abcdef01234567') }}" - name: "NETBOX_LOOKUP 5: Add one of two devices for lookup filter test." - netbox_device: + netbox.netbox.netbox_device: netbox_url: "http://localhost:32768" netbox_token: "0123456789abcdef0123456789abcdef01234567" data: @@ -43,7 +43,7 @@ state: present - name: "NETBOX_LOOKUP 6: Add two of two devices for lookup filter test." - netbox_device: + netbox.netbox.netbox_device: netbox_url: "http://localhost:32768" netbox_token: "0123456789abcdef0123456789abcdef01234567" data: diff --git a/tests/integration/v2.8/tasks/netbox_manufacturer.yml b/tests/integration/targets/v2.6/tasks/netbox_manufacturer.yml similarity index 93% rename from tests/integration/v2.8/tasks/netbox_manufacturer.yml rename to tests/integration/targets/v2.6/tasks/netbox_manufacturer.yml index 52486c081..4dd1907eb 100644 --- a/tests/integration/v2.8/tasks/netbox_manufacturer.yml +++ b/tests/integration/targets/v2.6/tasks/netbox_manufacturer.yml @@ -5,7 +5,7 @@ ## ## - name: "MANUFACTURER 1: Necessary info creation" - netbox_manufacturer: + netbox.netbox.netbox_manufacturer: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -24,7 +24,7 @@ - test_one['msg'] == "manufacturer Test Manufacturer Two created" - name: "MANUFACTURER 2: Create duplicate" - netbox_manufacturer: + netbox.netbox.netbox_manufacturer: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -41,7 +41,7 @@ - test_two['msg'] == "manufacturer Test Manufacturer Two already exists" - name: "MANUFACTURER 3: Update" - netbox_manufacturer: + netbox.netbox.netbox_manufacturer: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -58,7 +58,7 @@ - test_three['msg'] == "manufacturer test manufacturer two updated" - name: "MANUFACTURER 4: ASSERT - Delete" - netbox_manufacturer: + netbox.netbox.netbox_manufacturer: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -75,7 +75,7 @@ - test_four['msg'] == "manufacturer test manufacturer two deleted" - name: "MANUFACTURER 5: ASSERT - Delete non existing" - netbox_manufacturer: + netbox.netbox.netbox_manufacturer: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: diff --git a/tests/integration/v2.8/tasks/netbox_platform.yml b/tests/integration/targets/v2.6/tasks/netbox_platform.yml similarity index 94% rename from tests/integration/v2.8/tasks/netbox_platform.yml rename to tests/integration/targets/v2.6/tasks/netbox_platform.yml index 2bc1f9de7..95ccdb4cf 100644 --- a/tests/integration/v2.8/tasks/netbox_platform.yml +++ b/tests/integration/targets/v2.6/tasks/netbox_platform.yml @@ -5,7 +5,7 @@ ## ## - name: "PLATFORM 1: Necessary info creation" - netbox_platform: + netbox.netbox.netbox_platform: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -24,7 +24,7 @@ - test_one['msg'] == "platform Test Platform created" - name: "PLATFORM 2: Create duplicate" - netbox_platform: + netbox.netbox.netbox_platform: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -41,7 +41,7 @@ - test_two['msg'] == "platform Test Platform already exists" - name: "PLATFORM 3: ASSERT - Update" - netbox_platform: + netbox.netbox.netbox_platform: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -66,7 +66,7 @@ - test_three['msg'] == "platform Test Platform updated" - name: "PLATFORM 4: ASSERT - Delete" - netbox_platform: + netbox.netbox.netbox_platform: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -83,7 +83,7 @@ - test_four['msg'] == "platform Test Platform deleted" - name: "PLATFORM 5: ASSERT - Delete non existing" - netbox_platform: + netbox.netbox.netbox_platform: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: diff --git a/tests/integration/v2.6/tasks/netbox_prefix.yml b/tests/integration/targets/v2.6/tasks/netbox_prefix.yml similarity index 95% rename from tests/integration/v2.6/tasks/netbox_prefix.yml rename to tests/integration/targets/v2.6/tasks/netbox_prefix.yml index 9cf04512f..96eb1de47 100644 --- a/tests/integration/v2.6/tasks/netbox_prefix.yml +++ b/tests/integration/targets/v2.6/tasks/netbox_prefix.yml @@ -5,7 +5,7 @@ ## ## - name: "1 - Create prefix within Netbox with only required information" - netbox_prefix: + netbox.netbox.netbox_prefix: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -23,7 +23,7 @@ - test_one['prefix']['prefix'] == "10.156.0.0/19" - name: "2 - Duplicate" - netbox_prefix: + netbox.netbox.netbox_prefix: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -39,7 +39,7 @@ - test_two['prefix']['prefix'] == "10.156.0.0/19" - name: "3 - Update 10.156.0.0/19" - netbox_prefix: + netbox.netbox.netbox_prefix: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -64,7 +64,7 @@ - test_three['prefix']['description'] == "This prefix has been updated" - name: "4 - Delete prefix within netbox" - netbox_prefix: + netbox.netbox.netbox_prefix: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -81,7 +81,7 @@ - test_four['msg'] == "prefix 10.156.0.0/19 deleted" - name: "5 - Create prefix with several specified options" - netbox_prefix: + netbox.netbox.netbox_prefix: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -124,7 +124,7 @@ - test_five['prefix']['tags'][0] == "Schnozzberry" - name: "6 - Get a new /24 inside 10.156.0.0/19 within Netbox - Parent doesn't exist" - netbox_prefix: + netbox.netbox.netbox_prefix: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -141,7 +141,7 @@ - test_six['msg'] == "Parent prefix does not exist - 10.156.0.0/19" - name: "7 - Create prefix within Netbox with only required information" - netbox_prefix: + netbox.netbox.netbox_prefix: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -159,7 +159,7 @@ - test_seven['prefix']['prefix'] == "10.156.0.0/19" - name: "8 - Get a new /24 inside 10.156.0.0/19 within Netbox" - netbox_prefix: + netbox.netbox.netbox_prefix: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -179,7 +179,7 @@ - test_eight['prefix']['prefix'] == "10.156.0.0/24" - name: "9 - Create 10.157.0.0/19" - netbox_prefix: + netbox.netbox.netbox_prefix: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -201,7 +201,7 @@ - test_nine['prefix']['vrf'] == 1 - name: "10 - Get a new /24 inside 10.157.0.0/19 within Netbox with additional values" - netbox_prefix: + netbox.netbox.netbox_prefix: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -225,7 +225,7 @@ - test_ten['prefix']['vrf']['id'] == 1 - name: "11 - Get a new /24 inside 10.156.0.0/19 within Netbox" - netbox_prefix: + netbox.netbox.netbox_prefix: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: diff --git a/tests/integration/v2.7/tasks/netbox_provider.yml b/tests/integration/targets/v2.6/tasks/netbox_provider.yml similarity index 96% rename from tests/integration/v2.7/tasks/netbox_provider.yml rename to tests/integration/targets/v2.6/tasks/netbox_provider.yml index 7e4b54053..782df16f8 100644 --- a/tests/integration/v2.7/tasks/netbox_provider.yml +++ b/tests/integration/targets/v2.6/tasks/netbox_provider.yml @@ -5,7 +5,7 @@ ## ## - name: "NETBOX_PROVIDER 1: Create provider within Netbox with only required information" - netbox_provider: + netbox.netbox.netbox_provider: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -24,7 +24,7 @@ - test_one['msg'] == "provider Test Provider One created" - name: "NETBOX_PROVIDER 2: Duplicate" - netbox_provider: + netbox.netbox.netbox_provider: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -41,7 +41,7 @@ - test_two['msg'] == "provider Test Provider One already exists" - name: "NETBOX_PROVIDER 3: Update provider with other fields" - netbox_provider: + netbox.netbox.netbox_provider: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -76,7 +76,7 @@ - test_three['msg'] == "provider Test Provider One updated" - name: "NETBOX_PROVIDER 4: Delete provider within netbox" - netbox_provider: + netbox.netbox.netbox_provider: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: diff --git a/tests/integration/v2.6/tasks/netbox_rack.yml b/tests/integration/targets/v2.6/tasks/netbox_rack.yml similarity index 96% rename from tests/integration/v2.6/tasks/netbox_rack.yml rename to tests/integration/targets/v2.6/tasks/netbox_rack.yml index b1ba617d1..d0bbbd31b 100644 --- a/tests/integration/v2.6/tasks/netbox_rack.yml +++ b/tests/integration/targets/v2.6/tasks/netbox_rack.yml @@ -5,7 +5,7 @@ ## ## - name: "1 - Test rack creation" - netbox_rack: + netbox.netbox.netbox_rack: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -23,7 +23,7 @@ - test_one['rack']['site'] == 1 - name: "Test duplicate rack" - netbox_rack: + netbox.netbox.netbox_rack: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -39,7 +39,7 @@ - test_two['msg'] == "rack Test rack one already exists" - name: "3 - Create new rack with similar name" - netbox_rack: + netbox.netbox.netbox_rack: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -59,7 +59,7 @@ - test_three['msg'] == "rack Test rack - Test Site created" - name: "4 - Attempt to create Test rack one again" - netbox_rack: + netbox.netbox.netbox_rack: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -77,7 +77,7 @@ - test_four['msg'] == "rack Test rack one already exists" - name: "5 - Update Test rack one with more options" - netbox_rack: + netbox.netbox.netbox_rack: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -141,7 +141,7 @@ - test_five['msg'] == "rack Test rack one updated" - name: "6 - Update Test rack one with same options" - netbox_rack: + netbox.netbox.netbox_rack: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -189,7 +189,7 @@ - test_six['rack']['width'] == 23 - name: "7 - Create rack with same asset tag and serial number" - netbox_rack: + netbox.netbox.netbox_rack: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -208,7 +208,7 @@ - "'Asset tag already exists' in test_seven['msg']" - name: "8 - Test delete" - netbox_rack: + netbox.netbox.netbox_rack: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: diff --git a/tests/integration/v2.6/tasks/netbox_rack_group.yml b/tests/integration/targets/v2.6/tasks/netbox_rack_group.yml similarity index 94% rename from tests/integration/v2.6/tasks/netbox_rack_group.yml rename to tests/integration/targets/v2.6/tasks/netbox_rack_group.yml index b2ae0c65e..6a10cbf94 100644 --- a/tests/integration/v2.6/tasks/netbox_rack_group.yml +++ b/tests/integration/targets/v2.6/tasks/netbox_rack_group.yml @@ -5,7 +5,7 @@ ## ## - name: "RACK_GROUP 1: Necessary info creation" - netbox_rack_group: + netbox.netbox.netbox_rack_group: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -26,7 +26,7 @@ - test_one['msg'] == "rack_group Rack Group created" - name: "RACK_GROUP 2: Create duplicate" - netbox_rack_group: + netbox.netbox.netbox_rack_group: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -45,7 +45,7 @@ - test_two['msg'] == "rack_group Rack Group already exists" - name: "RACK_GROUP 3: ASSERT - Delete" - netbox_rack_group: + netbox.netbox.netbox_rack_group: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: diff --git a/tests/integration/v2.6/tasks/netbox_rack_role.yml b/tests/integration/targets/v2.6/tasks/netbox_rack_role.yml similarity index 94% rename from tests/integration/v2.6/tasks/netbox_rack_role.yml rename to tests/integration/targets/v2.6/tasks/netbox_rack_role.yml index 847c73d96..5ca9e44eb 100644 --- a/tests/integration/v2.6/tasks/netbox_rack_role.yml +++ b/tests/integration/targets/v2.6/tasks/netbox_rack_role.yml @@ -5,7 +5,7 @@ ## ## - name: "RACK_ROLE 1: Necessary info creation" - netbox_rack_role: + netbox.netbox.netbox_rack_role: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -26,7 +26,7 @@ - test_one['msg'] == "rack_role Rack Role created" - name: "RACK_ROLE 2: Create duplicate" - netbox_rack_role: + netbox.netbox.netbox_rack_role: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -44,7 +44,7 @@ - test_two['msg'] == "rack_role Rack Role already exists" - name: "RACK_ROLE 3: Update" - netbox_rack_role: + netbox.netbox.netbox_rack_role: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -64,7 +64,7 @@ - test_three['msg'] == "rack_role Rack Role updated" - name: "RACK_ROLE 4: Delete" - netbox_rack_role: + netbox.netbox.netbox_rack_role: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: diff --git a/tests/integration/v2.8/tasks/netbox_region.yml b/tests/integration/targets/v2.6/tasks/netbox_region.yml similarity index 94% rename from tests/integration/v2.8/tasks/netbox_region.yml rename to tests/integration/targets/v2.6/tasks/netbox_region.yml index f6f8e7654..1359598af 100644 --- a/tests/integration/v2.8/tasks/netbox_region.yml +++ b/tests/integration/targets/v2.6/tasks/netbox_region.yml @@ -5,7 +5,7 @@ ## ## - name: "REGION 1: Necessary info creation" - netbox_region: + netbox.netbox.netbox_region: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -24,7 +24,7 @@ - test_one['msg'] == "region Test Region One created" - name: "REGION 2: Create duplicate" - netbox_region: + netbox.netbox.netbox_region: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -41,7 +41,7 @@ - test_two['msg'] == "region Test Region One already exists" - name: "REGION 3: ASSERT - Update" - netbox_region: + netbox.netbox.netbox_region: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -61,7 +61,7 @@ - test_three['msg'] == "region Test Region One updated" - name: "REGION 4: ASSERT - Delete" - netbox_region: + netbox.netbox.netbox_region: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: diff --git a/tests/integration/v2.8/tasks/netbox_rir.yml b/tests/integration/targets/v2.6/tasks/netbox_rir.yml similarity index 95% rename from tests/integration/v2.8/tasks/netbox_rir.yml rename to tests/integration/targets/v2.6/tasks/netbox_rir.yml index 821b3e280..cc4935938 100644 --- a/tests/integration/v2.8/tasks/netbox_rir.yml +++ b/tests/integration/targets/v2.6/tasks/netbox_rir.yml @@ -5,7 +5,7 @@ ## ## - name: "RIR 1: Necessary info creation" - netbox_rir: + netbox.netbox.netbox_rir: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -24,7 +24,7 @@ - test_one['msg'] == "rir Test RIR One created" - name: "RIR 2: Create duplicate" - netbox_rir: + netbox.netbox.netbox_rir: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -41,7 +41,7 @@ - test_two['msg'] == "rir Test RIR One already exists" - name: "RIR 3: ASSERT - Update" - netbox_rir: + netbox.netbox.netbox_rir: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -61,7 +61,7 @@ - test_three['msg'] == "rir Test RIR One updated" - name: "RIR 4: ASSERT - Delete" - netbox_rir: + netbox.netbox.netbox_rir: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: diff --git a/tests/integration/v2.6/tasks/netbox_service.yml b/tests/integration/targets/v2.6/tasks/netbox_service.yml similarity index 95% rename from tests/integration/v2.6/tasks/netbox_service.yml rename to tests/integration/targets/v2.6/tasks/netbox_service.yml index 5a3ae97cc..9ce9eeab6 100644 --- a/tests/integration/v2.6/tasks/netbox_service.yml +++ b/tests/integration/targets/v2.6/tasks/netbox_service.yml @@ -5,7 +5,7 @@ ## ## - name: "1 - Device with required information needs to add new service" - netbox_device: + netbox.netbox.netbox_device: netbox_url: "http://localhost:32768" netbox_token: "0123456789abcdef0123456789abcdef01234567" data: @@ -17,7 +17,7 @@ state: present - name: "NETBOX_SERVICE: Create new service" - netbox_service: + netbox.netbox.netbox_service: netbox_url: "http://localhost:32768" netbox_token: "0123456789abcdef0123456789abcdef01234567" data: @@ -40,7 +40,7 @@ - test_service_create['msg'] == "services node-exporter created" - name: "NETBOX_SERVICE: Test idempotence" - netbox_service: + netbox.netbox.netbox_service: netbox_url: "http://localhost:32768" netbox_token: "0123456789abcdef0123456789abcdef01234567" data: @@ -60,7 +60,7 @@ - test_service_idempotence['msg'] == "services node-exporter already exists" - name: "NETBOX_SERVICE: Test update" - netbox_service: + netbox.netbox.netbox_service: netbox_url: "http://localhost:32768" netbox_token: "0123456789abcdef0123456789abcdef01234567" data: @@ -80,7 +80,7 @@ - test_service_update['msg'] == "services node-exporter updated" - name: "NETBOX_SERVICE: Test same details, but different protocol - Create" - netbox_service: + netbox.netbox.netbox_service: netbox_url: "http://localhost:32768" netbox_token: "0123456789abcdef0123456789abcdef01234567" data: @@ -103,7 +103,7 @@ - test_service_protocol['msg'] == "services node-exporter created" - name: "NETBOX_SERVICE: Test service deletion" - netbox_service: + netbox.netbox.netbox_service: netbox_url: "http://localhost:32768" netbox_token: "0123456789abcdef0123456789abcdef01234567" data: diff --git a/tests/integration/v2.6/tasks/netbox_site.yml b/tests/integration/targets/v2.6/tasks/netbox_site.yml similarity index 96% rename from tests/integration/v2.6/tasks/netbox_site.yml rename to tests/integration/targets/v2.6/tasks/netbox_site.yml index 2eebee2e0..70642cf92 100644 --- a/tests/integration/v2.6/tasks/netbox_site.yml +++ b/tests/integration/targets/v2.6/tasks/netbox_site.yml @@ -5,7 +5,7 @@ ## ## - name: "1 - Create site within Netbox with only required information" - netbox_site: + netbox.netbox.netbox_site: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -23,7 +23,7 @@ - test_one['msg'] == "site Test - Colorado created" - name: "2 - Duplicate" - netbox_site: + netbox.netbox.netbox_site: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -39,7 +39,7 @@ - test_two['site']['name'] == "Test - Colorado" - name: "3 - Update Test - Colorado" - netbox_site: + netbox.netbox.netbox_site: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -64,7 +64,7 @@ - test_three['site']['region'] == 1 - name: "4 - Create site with all parameters" - netbox_site: + netbox.netbox.netbox_site: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -114,7 +114,7 @@ - test_four['site']['slug'] == "test_california" - name: "5 - Delete site within netbox" - netbox_site: + netbox.netbox.netbox_site: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: diff --git a/tests/integration/v2.6/tasks/netbox_tenant.yml b/tests/integration/targets/v2.6/tasks/netbox_tenant.yml similarity index 95% rename from tests/integration/v2.6/tasks/netbox_tenant.yml rename to tests/integration/targets/v2.6/tasks/netbox_tenant.yml index c6b95e807..420cb22e3 100644 --- a/tests/integration/v2.6/tasks/netbox_tenant.yml +++ b/tests/integration/targets/v2.6/tasks/netbox_tenant.yml @@ -5,7 +5,7 @@ ## ## - name: "1 - Test tenant creation" - netbox_tenant: + netbox.netbox.netbox_tenant: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -23,7 +23,7 @@ - test_one['msg'] == "tenant Tenant ABC created" - name: "Test duplicate tenant" - netbox_tenant: + netbox.netbox.netbox_tenant: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -39,7 +39,7 @@ - test_two['msg'] == "tenant Tenant ABC already exists" - name: "3 - Test update" - netbox_tenant: + netbox.netbox.netbox_tenant: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -58,7 +58,7 @@ - test_three['msg'] == "tenant Tenant ABC updated" - name: "4 - Test delete" - netbox_tenant: + netbox.netbox.netbox_tenant: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -75,7 +75,7 @@ - test_four['msg'] == "tenant Tenant ABC deleted" - name: "5 - Create tenant with all parameters" - netbox_tenant: + netbox.netbox.netbox_tenant: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: diff --git a/tests/integration/v2.8/tasks/netbox_tenant_group.yml b/tests/integration/targets/v2.6/tasks/netbox_tenant_group.yml similarity index 93% rename from tests/integration/v2.8/tasks/netbox_tenant_group.yml rename to tests/integration/targets/v2.6/tasks/netbox_tenant_group.yml index d35fd194f..2ee814646 100644 --- a/tests/integration/v2.8/tasks/netbox_tenant_group.yml +++ b/tests/integration/targets/v2.6/tasks/netbox_tenant_group.yml @@ -5,7 +5,7 @@ ## ## - name: "1 - Test tenant group creation" - netbox_tenant_group: + netbox.netbox.netbox_tenant_group: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -23,7 +23,7 @@ - test_one['msg'] == "tenant_group Test Tenant Group Two created" - name: "Test duplicate tenant group" - netbox_tenant_group: + netbox.netbox.netbox_tenant_group: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -39,7 +39,7 @@ - test_two['msg'] == "tenant_group Test Tenant Group Two already exists" - name: "3 - Test delete" - netbox_tenant_group: + netbox.netbox.netbox_tenant_group: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -56,7 +56,7 @@ - test_three['msg'] == "tenant_group Test Tenant Group Two deleted" - name: "4 - Test another tenant group creation" - netbox_tenant_group: + netbox.netbox.netbox_tenant_group: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: diff --git a/tests/integration/v2.6/tasks/netbox_virtual_machine.yml b/tests/integration/targets/v2.6/tasks/netbox_virtual_machine.yml similarity index 95% rename from tests/integration/v2.6/tasks/netbox_virtual_machine.yml rename to tests/integration/targets/v2.6/tasks/netbox_virtual_machine.yml index dc527458b..56379f412 100644 --- a/tests/integration/v2.6/tasks/netbox_virtual_machine.yml +++ b/tests/integration/targets/v2.6/tasks/netbox_virtual_machine.yml @@ -5,7 +5,7 @@ ## ## - name: "VIRTUAL_MACHINE 1: Necessary info creation" - netbox_virtual_machine: + netbox.netbox.netbox_virtual_machine: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -25,7 +25,7 @@ - test_one['msg'] == "virtual_machine Test VM One created" - name: "VIRTUAL_MACHINE 2: Create duplicate" - netbox_virtual_machine: + netbox.netbox.netbox_virtual_machine: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -43,7 +43,7 @@ - test_two['msg'] == "virtual_machine Test VM One already exists" - name: "VIRTUAL_MACHINE 3: Update" - netbox_virtual_machine: + netbox.netbox.netbox_virtual_machine: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -77,7 +77,7 @@ - test_three['msg'] == "virtual_machine Test VM One updated" - name: "VIRTUAL_MACHINE 4: ASSERT - Delete" - netbox_virtual_machine: + netbox.netbox.netbox_virtual_machine: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: diff --git a/tests/integration/v2.6/tasks/netbox_vlan.yml b/tests/integration/targets/v2.6/tasks/netbox_vlan.yml similarity index 96% rename from tests/integration/v2.6/tasks/netbox_vlan.yml rename to tests/integration/targets/v2.6/tasks/netbox_vlan.yml index 002c06abd..4719f9a46 100644 --- a/tests/integration/v2.6/tasks/netbox_vlan.yml +++ b/tests/integration/targets/v2.6/tasks/netbox_vlan.yml @@ -5,7 +5,7 @@ ## ## - name: "VLAN 1: Necessary info creation" - netbox_vlan: + netbox.netbox.netbox_vlan: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -25,7 +25,7 @@ - test_one['msg'] == "vlan Test VLAN 500 created" - name: "VLAN 2: Create duplicate" - netbox_vlan: + netbox.netbox.netbox_vlan: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -43,7 +43,7 @@ - test_two['msg'] == "vlan Test VLAN 500 already exists" - name: "VLAN 3: Create VLAN with same name, but different site" - netbox_vlan: + netbox.netbox.netbox_vlan: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -66,7 +66,7 @@ - test_three['msg'] == "vlan Test VLAN 500 created" - name: "VLAN 4: ASSERT - Update" - netbox_vlan: + netbox.netbox.netbox_vlan: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -103,7 +103,7 @@ - test_four['msg'] == "vlan Test VLAN 500 updated" - name: "VLAN 5: ASSERT - Delete more than one result" - netbox_vlan: + netbox.netbox.netbox_vlan: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -119,7 +119,7 @@ - test_five['msg'] == "More than one result returned for Test VLAN 500" - name: "VLAN 6: ASSERT - Delete" - netbox_vlan: + netbox.netbox.netbox_vlan: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: diff --git a/tests/integration/v2.6/tasks/netbox_vlan_group.yml b/tests/integration/targets/v2.6/tasks/netbox_vlan_group.yml similarity index 94% rename from tests/integration/v2.6/tasks/netbox_vlan_group.yml rename to tests/integration/targets/v2.6/tasks/netbox_vlan_group.yml index 063c91c42..df59a1699 100644 --- a/tests/integration/v2.6/tasks/netbox_vlan_group.yml +++ b/tests/integration/targets/v2.6/tasks/netbox_vlan_group.yml @@ -5,7 +5,7 @@ ## ## - name: "VLAN_GROUP 1: Necessary info creation" - netbox_vlan_group: + netbox.netbox.netbox_vlan_group: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -26,7 +26,7 @@ - test_one['msg'] == "vlan_group VLAN Group One created" - name: "VLAN_GROUP 2: Create duplicate" - netbox_vlan_group: + netbox.netbox.netbox_vlan_group: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -45,7 +45,7 @@ - test_two['msg'] == "vlan_group VLAN Group One already exists" - name: "VLAN_GROUP 3: ASSERT - Create with same name, different site" - netbox_vlan_group: + netbox.netbox.netbox_vlan_group: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -64,7 +64,7 @@ - test_three['msg'] == "vlan_group VLAN Group One created" - name: "VLAN_GROUP 4: ASSERT - Create vlan group, no site" - netbox_vlan_group: + netbox.netbox.netbox_vlan_group: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -80,7 +80,7 @@ - test_four['msg'] == "More than one result returned for VLAN Group One" - name: "VLAN_GROUP 5: ASSERT - Delete" - netbox_vlan_group: + netbox.netbox.netbox_vlan_group: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -101,7 +101,7 @@ - test_five['msg'] == "vlan_group VLAN Group One deleted" - name: "VLAN_GROUP 6: ASSERT - Delete non existing" - netbox_vlan_group: + netbox.netbox.netbox_vlan_group: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: diff --git a/tests/integration/v2.6/tasks/netbox_vm_interface.yml b/tests/integration/targets/v2.6/tasks/netbox_vm_interface.yml similarity index 96% rename from tests/integration/v2.6/tasks/netbox_vm_interface.yml rename to tests/integration/targets/v2.6/tasks/netbox_vm_interface.yml index e047dcfbb..a69faddcd 100644 --- a/tests/integration/v2.6/tasks/netbox_vm_interface.yml +++ b/tests/integration/targets/v2.6/tasks/netbox_vm_interface.yml @@ -5,7 +5,7 @@ ## ## - name: "NETBOX_VM_INTERFACE 1: Necessary info creation" - netbox_vm_interface: + netbox.netbox.netbox_vm_interface: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -25,7 +25,7 @@ - test_one['msg'] == "interface Eth10 created" - name: "NETBOX_VM_INTERFACE 2: Create duplicate" - netbox_vm_interface: + netbox.netbox.netbox_vm_interface: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -43,7 +43,7 @@ - test_two['msg'] == "interface Eth10 already exists" - name: "NETBOX_VM_INTERFACE 3: Updated" - netbox_vm_interface: + netbox.netbox.netbox_vm_interface: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -92,7 +92,7 @@ - test_three['msg'] == "interface Eth10 updated" - name: "NETBOX_VM_INTERFACE 4: ASSERT - Delete" - netbox_vm_interface: + netbox.netbox.netbox_vm_interface: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -110,7 +110,7 @@ - test_four['msg'] == "interface Eth10 deleted" - name: "NETBOX_VM_INTERFACE 5: Attempt to update interface with same name on other VMs" - netbox_vm_interface: + netbox.netbox.netbox_vm_interface: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: diff --git a/tests/integration/v2.7/tasks/netbox_vrf.yml b/tests/integration/targets/v2.6/tasks/netbox_vrf.yml similarity index 95% rename from tests/integration/v2.7/tasks/netbox_vrf.yml rename to tests/integration/targets/v2.6/tasks/netbox_vrf.yml index cf75d08be..dc3d428d5 100644 --- a/tests/integration/v2.7/tasks/netbox_vrf.yml +++ b/tests/integration/targets/v2.6/tasks/netbox_vrf.yml @@ -5,7 +5,7 @@ ## ## - name: "VRF 1: Necessary info creation" - netbox_vrf: + netbox.netbox.netbox_vrf: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -23,7 +23,7 @@ - test_one['msg'] == "vrf Test VRF One created" - name: "VRF 2: Create duplicate" - netbox_vrf: + netbox.netbox.netbox_vrf: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -39,7 +39,7 @@ - test_two['msg'] == "vrf Test VRF One already exists" - name: "VRF 3: Create VRF with same name, but different tenant" - netbox_vrf: + netbox.netbox.netbox_vrf: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -59,7 +59,7 @@ - test_three['msg'] == "vrf Test VRF One created" - name: "VRF 4: ASSERT - Update" - netbox_vrf: + netbox.netbox.netbox_vrf: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -90,7 +90,7 @@ - test_four['msg'] == "vrf Test VRF One updated" - name: "VRF 5: ASSERT - Delete more than one result" - netbox_vrf: + netbox.netbox.netbox_vrf: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: @@ -106,7 +106,7 @@ - test_five['msg'] == "More than one result returned for Test VRF One" - name: "VRF 6: ASSERT - Delete" - netbox_vrf: + netbox.netbox.netbox_vrf: netbox_url: http://localhost:32768 netbox_token: 0123456789abcdef0123456789abcdef01234567 data: diff --git a/tests/integration/test-inventory.yml b/tests/integration/test-inventory.yml deleted file mode 100644 index 178bd3a52..000000000 --- a/tests/integration/test-inventory.yml +++ /dev/null @@ -1,4 +0,0 @@ -plugin: netbox.netbox.nb_inventory -api_endpoint: "http://localhost:32768" -token: "0123456789abcdef0123456789abcdef01234567" -validate_certs: false diff --git a/tests/integration/v2.6/main.yml b/tests/integration/v2.6/main.yml deleted file mode 100644 index 6278480b5..000000000 --- a/tests/integration/v2.6/main.yml +++ /dev/null @@ -1,109 +0,0 @@ ---- -- hosts: localhost - connection: local - gather_facts: no - collections: - - netbox.netbox - - tasks: - - name: "NETBOX_DEVICE TESTS" - include_tasks: "tasks/netbox_device.yml" - - - name: "NETBOX_DEVICE_INTERFACE TESTS" - include_tasks: "tasks/netbox_device_interface.yml" - - - name: "NETBOX_IP_ADDRESS TESTS" - include_tasks: "tasks/netbox_ip_address.yml" - - - name: "NETBOX_PREFIX TESTS" - include_tasks: "tasks/netbox_prefix.yml" - - - name: "NETBOX_SITE TESTS" - include_tasks: "tasks/netbox_site.yml" - - - name: "NETBOX_TENTANT TESTS" - include_tasks: "tasks/netbox_tenant.yml" - - - name: "NETBOX_TENTANT_GROUP TESTS" - include_tasks: "tasks/netbox_tenant_group.yml" - - - name: "NETBOX_RACK TESTS" - include_tasks: "tasks/netbox_rack.yml" - - - name: "NETBOX_RACK_ROLE TESTS" - include_tasks: "tasks/netbox_rack_role.yml" - - - name: "NETBOX_RACK_GROUP TESTS" - include_tasks: "tasks/netbox_rack_group.yml" - - - name: "NETBOX_MANUFACTURER TESTS" - include_tasks: "tasks/netbox_manufacturer.yml" - - - name: "NETBOX_PLATFORM TESTS" - include_tasks: "tasks/netbox_platform.yml" - - - name: "NETBOX_DEVICE_TYPE TESTS" - include_tasks: "tasks/netbox_device_type.yml" - - - name: "NETBOX_DEVICE_ROLE TESTS" - include_tasks: "tasks/netbox_device_role.yml" - - - name: "NETBOX_IPAM_ROLE TESTS" - include_tasks: "tasks/netbox_ipam_role.yml" - - - name: "NETBOX_VLAN_GROUP TESTS" - include_tasks: "tasks/netbox_vlan_group.yml" - - - name: "NETBOX_VLAN TESTS" - include_tasks: "tasks/netbox_vlan.yml" - - - name: "NETBOX_VRF TESTS" - include_tasks: "tasks/netbox_vrf.yml" - - - name: "NETBOX_RIR TESTS" - include_tasks: "tasks/netbox_rir.yml" - - - name: "NETBOX_AGGREGATE TESTS" - include_tasks: "tasks/netbox_aggregate.yml" - - - name: "NETBOX_REGION TESTS" - include_tasks: "tasks/netbox_region.yml" - - - name: "NETBOX_DEVICE_BAY TESTS" - include_tasks: "tasks/netbox_device_bay.yml" - - - name: "NETBOX_INVENTORY_ITEM TESTS" - include_tasks: "tasks/netbox_inventory_item.yml" - - - name: "NETBOX_VIRTUAL_MACHINE TESTS" - include_tasks: "tasks/netbox_virtual_machine.yml" - - - name: "NETBOX_CLUSTER TESTS" - include_tasks: "tasks/netbox_cluster.yml" - - - name: "NETBOX_CLUSTER_GROUP TESTS" - include_tasks: "tasks/netbox_cluster_group.yml" - - - name: "NETBOX_CLUSTER_TYPE TESTS" - include_tasks: "tasks/netbox_cluster_type.yml" - - - name: "NETBOX_VM_INTERFACE TESTS" - include_tasks: "tasks/netbox_vm_interface.yml" - - - name: "NETBOX_PROVIDER TESTS" - include_tasks: "tasks/netbox_provider.yml" - - - name: "NETBOX_CIRCUIT_TYPE TESTS" - include_tasks: "tasks/netbox_circuit_type.yml" - - - name: "NETBOX_CIRCUIT TESTS" - include_tasks: "tasks/netbox_circuit.yml" - - - name: "NETBOX_CIRCUIT_TERMINATION TESTS" - include_tasks: "tasks/netbox_circuit_termination.yml" - - - name: "NETBOX_SERVICE TESTS" - include_tasks: "tasks/netbox_service.yml" - - - name: "NETBOX_LOOKUP TESTS" - include_tasks: "tasks/netbox_lookup.yml" diff --git a/tests/integration/v2.6/tasks/netbox_circuit_termination.yml b/tests/integration/v2.6/tasks/netbox_circuit_termination.yml deleted file mode 100644 index 6e79a3d34..000000000 --- a/tests/integration/v2.6/tasks/netbox_circuit_termination.yml +++ /dev/null @@ -1,129 +0,0 @@ ---- -## -## -### NETBOX_CIRCUIT_TERMINATION -## -## -- name: "NETBOX_CIRCUIT_TERMINATION 1: Create provider within Netbox with only required information" - netbox_circuit_termination: - netbox_url: http://localhost:32768 - netbox_token: 0123456789abcdef0123456789abcdef01234567 - data: - circuit: Test Circuit - term_side: A - site: "Test Site" - port_speed: 10000 - state: present - register: test_one - -- name: "NETBOX_CIRCUIT_TERMINATION 1: ASSERT - Necessary info creation" - assert: - that: - - test_one is changed - - test_one['diff']['before']['state'] == "absent" - - test_one['diff']['after']['state'] == "present" - - 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" - -- name: "NETBOX_CIRCUIT_TERMINATION 2: Duplicate" - 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" - assert: - that: - - not test_two['changed'] - - 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" - -- name: "NETBOX_CIRCUIT_TERMINATION 3: Update provider with other fields" - 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" - assert: - that: - - test_three is changed - - 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" - - 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_circuit_termination: - netbox_url: http://localhost:32768 - netbox_token: 0123456789abcdef0123456789abcdef01234567 - data: - circuit: Test Circuit - term_side: Z - site: "Test Site" - port_speed: 10000 - state: present - register: test_four - -- name: "NETBOX_CIRCUIT_TERMINATION 4: ASSERT - Create Z Side" - assert: - that: - - test_four is changed - - test_four['diff']['before']['state'] == "absent" - - test_four['diff']['after']['state'] == "present" - - 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" - -- name: "NETBOX_CIRCUIT_TERMINATION 5: Delete provider within 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" - assert: - that: - - 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_five['msg'] == "circuit_termination test_circuit_a deleted" diff --git a/tests/integration/v2.6/tasks/netbox_circuit_type.yml b/tests/integration/v2.6/tasks/netbox_circuit_type.yml deleted file mode 100644 index c7685e524..000000000 --- a/tests/integration/v2.6/tasks/netbox_circuit_type.yml +++ /dev/null @@ -1,96 +0,0 @@ ---- -## -## -### NETBOX_CIRCUIT_TYPE -## -## -- name: "CIRCUIT_TYPE 1: Necessary info creation" - 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" - 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_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" - 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_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" - 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_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" - 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_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" - 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/v2.6/tasks/netbox_cluster_type.yml b/tests/integration/v2.6/tasks/netbox_cluster_type.yml deleted file mode 100644 index cd4a111e0..000000000 --- a/tests/integration/v2.6/tasks/netbox_cluster_type.yml +++ /dev/null @@ -1,95 +0,0 @@ -## -## -### NETBOX_CLUSTER_TYPE -## -## -- name: "CLUSTER_TYPE 1: Necessary info creation" - 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" - 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_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" - 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_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" - 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_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" - 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_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" - 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/v2.6/tasks/netbox_inventory_item.yml b/tests/integration/v2.6/tasks/netbox_inventory_item.yml deleted file mode 100644 index a3e953e24..000000000 --- a/tests/integration/v2.6/tasks/netbox_inventory_item.yml +++ /dev/null @@ -1,104 +0,0 @@ ---- -## -## -### NETBOX_INVENTORY_ITEM -## -## -- name: "INVENTORY_ITEM 1: Necessary info creation" - 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" - 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_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" - 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: ASSERT - Update" - 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" - tags: - - Schnozzberry - state: present - register: test_three - -- name: "INVENTORY_ITEM 3: ASSERT - Updated" - 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] == "Schnozzberry" - - 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] == "Schnozzberry" - - test_three['msg'] == "inventory_item 10G-SFP+ updated" - -- name: "INVENTORY_ITEM 4: ASSERT - Delete" - 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" - 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] == "Schnozzberry" - - test_four['msg'] == "inventory_item 10G-SFP+ deleted" diff --git a/tests/integration/v2.6/tasks/netbox_lookup.yml b/tests/integration/v2.6/tasks/netbox_lookup.yml deleted file mode 100644 index a2d534b8a..000000000 --- a/tests/integration/v2.6/tasks/netbox_lookup.yml +++ /dev/null @@ -1,69 +0,0 @@ ---- -## -## -### NETBOX_LOOKUP -## -## -- name: "NETBOX_LOOKUP 1: Lookup returns exactly two sites" - assert: - that: "{{ query_result|count }} == 3" - vars: - query_result: "{{ query('netbox.netbox.nb_lookup', 'sites', api_endpoint='http://localhost:32768', token='0123456789abcdef0123456789abcdef01234567') }}" - -- name: "NETBOX_LOOKUP 2: Query doesn't return Wibble (sanity check json_query)" - assert: - that: "{{ query_result|json_query('[?value.display_name==`Wibble`]')|count }} == 0" - vars: - query_result: "{{ query('netbox.netbox.nb_lookup', 'devices', api_endpoint='http://localhost:32768', token='0123456789abcdef0123456789abcdef01234567') }}" - -- name: "NETBOX_LOOKUP 3: Device query returns exactly one TestDeviceR1" - assert: - that: "{{ query_result|json_query('[?value.display_name==`TestDeviceR1`]')|count }} == 1" - vars: - query_result: "{{ query('netbox.netbox.nb_lookup', 'devices', api_endpoint='http://localhost:32768', token='0123456789abcdef0123456789abcdef01234567') }}" - -- name: "NETBOX_LOOKUP 4: VLAN ID 400 can be queried and is named 'Test VLAN'" - assert: - that: "{{ (query_result|json_query('[?value.vid==`400`].value.name'))[0] == 'Test VLAN' }}" - vars: - query_result: "{{ query('netbox.netbox.nb_lookup', 'vlans', api_endpoint='http://localhost:32768', token='0123456789abcdef0123456789abcdef01234567') }}" - -- name: "NETBOX_LOOKUP 5: Add one of two devices for lookup filter test." - 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_device: - netbox_url: "http://localhost:32768" - netbox_token: "0123456789abcdef0123456789abcdef01234567" - data: - name: "L2" - device_type: "Cisco Test" - device_role: "Core Switch" - site: "Test Site" - status: "Staged" - tags: - - "lookup" - state: present - -- name: "NETBOX_LOOKUP 7: Device query returns exactly the L2 device" - assert: - that: "{{ query_result|json_query('[?value.display_name==`L2`]')|count }} == 1" - vars: - query_result: "{{ query('netbox.netbox.nb_lookup', 'devices', api_filter='role=core-switch tag=lookup', api_endpoint='http://localhost:32768', token='0123456789abcdef0123456789abcdef01234567') }}" - -- name: "NETBOX_LOOKUP 8: Device query specifying raw data returns payload without key/value dict" - assert: - that: "{{ query_result|json_query('[?display_name==`L2`]')|count }} == 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) }}" diff --git a/tests/integration/v2.6/tasks/netbox_platform.yml b/tests/integration/v2.6/tasks/netbox_platform.yml deleted file mode 100644 index 2bc1f9de7..000000000 --- a/tests/integration/v2.6/tasks/netbox_platform.yml +++ /dev/null @@ -1,99 +0,0 @@ ---- -## -## -### NETBOX_PLATFORM -## -## -- name: "PLATFORM 1: Necessary info creation" - 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" - 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_platform: - netbox_url: http://localhost:32768 - netbox_token: 0123456789abcdef0123456789abcdef01234567 - data: - name: Test Platform - state: present - register: test_two - -- name: "PLATFORM 2: ASSERT - Create duplicate" - 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_platform: - netbox_url: http://localhost:32768 - netbox_token: 0123456789abcdef0123456789abcdef01234567 - data: - name: Test Platform - manufacturer: Test Manufacturer - napalm_driver: ios - napalm_args: - global_delay_factor: 2 - state: present - register: test_three - -- name: "PLATFORM 3: ASSERT - Update" - assert: - that: - - test_three is changed - - test_three['diff']['after']['manufacturer'] == 3 - - test_three['diff']['after']['napalm_args']['global_delay_factor'] == 2 - - test_three['diff']['after']['napalm_driver'] == "ios" - - test_three['platform']['manufacturer'] == 3 - - test_three['platform']['napalm_args']['global_delay_factor'] == 2 - - test_three['platform']['napalm_driver'] == "ios" - - test_three['msg'] == "platform Test Platform updated" - -- name: "PLATFORM 4: ASSERT - Delete" - netbox_platform: - netbox_url: http://localhost:32768 - netbox_token: 0123456789abcdef0123456789abcdef01234567 - data: - name: Test Platform - state: absent - register: test_four - -- name: "PLATFORM 4: ASSERT - Delete" - 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_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`" - assert: - that: - - not test_five['changed'] - - test_five['platform'] == None - - test_five['msg'] == "platform Test Platform already absent" diff --git a/tests/integration/v2.6/tasks/netbox_provider.yml b/tests/integration/v2.6/tasks/netbox_provider.yml deleted file mode 100644 index 7e4b54053..000000000 --- a/tests/integration/v2.6/tasks/netbox_provider.yml +++ /dev/null @@ -1,99 +0,0 @@ ---- -## -## -### NETBOX_PROVIDER -## -## -- name: "NETBOX_PROVIDER 1: Create provider within Netbox with only required information" - 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" - 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_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" - 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_provider: - netbox_url: http://localhost:32768 - netbox_token: 0123456789abcdef0123456789abcdef01234567 - data: - name: Test Provider One - asn: 65001 - account: "200129104" - portal_url: http://provider.net - noc_contact: noc@provider.net - admin_contact: admin@provider.net - comments: "BAD PROVIDER" - state: present - register: test_three - -- name: "NETBOX_PROVIDER 3: ASSERT - Updated" - assert: - that: - - test_three is changed - - test_three['diff']['after']['asn'] == 65001 - - test_three['diff']['after']['account'] == "200129104" - - test_three['diff']['after']['portal_url'] == "http://provider.net" - - test_three['diff']['after']['noc_contact'] == "noc@provider.net" - - test_three['diff']['after']['admin_contact'] == "admin@provider.net" - - test_three['diff']['after']['comments'] == "BAD PROVIDER" - - test_three['provider']['name'] == "Test Provider One" - - test_three['provider']['slug'] == "test-provider-one" - - test_three['provider']['asn'] == 65001 - - test_three['provider']['account'] == "200129104" - - test_three['provider']['portal_url'] == "http://provider.net" - - test_three['provider']['noc_contact'] == "noc@provider.net" - - test_three['provider']['admin_contact'] == "admin@provider.net" - - test_three['provider']['comments'] == "BAD PROVIDER" - - test_three['msg'] == "provider Test Provider One updated" - -- name: "NETBOX_PROVIDER 4: Delete provider within 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" - assert: - that: - - test_four is changed - - test_four['provider']['name'] == "Test Provider One" - - test_four['provider']['slug'] == "test-provider-one" - - test_four['provider']['asn'] == 65001 - - test_four['provider']['account'] == "200129104" - - test_four['provider']['portal_url'] == "http://provider.net" - - test_four['provider']['noc_contact'] == "noc@provider.net" - - test_four['provider']['admin_contact'] == "admin@provider.net" - - test_four['provider']['comments'] == "BAD PROVIDER" - - test_four['msg'] == "provider Test Provider One deleted" diff --git a/tests/integration/v2.6/tasks/netbox_region.yml b/tests/integration/v2.6/tasks/netbox_region.yml deleted file mode 100644 index f6f8e7654..000000000 --- a/tests/integration/v2.6/tasks/netbox_region.yml +++ /dev/null @@ -1,79 +0,0 @@ ---- -## -## -### NETBOX_REGION -## -## -- name: "REGION 1: Necessary info creation" - 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" - 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_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" - 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_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" - 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_region: - netbox_url: http://localhost:32768 - netbox_token: 0123456789abcdef0123456789abcdef01234567 - data: - name: "Test Region One" - state: absent - register: test_four - -- name: "REGION 4: ASSERT - Delete" - 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/v2.6/tasks/netbox_tenant_group.yml b/tests/integration/v2.6/tasks/netbox_tenant_group.yml deleted file mode 100644 index d35fd194f..000000000 --- a/tests/integration/v2.6/tasks/netbox_tenant_group.yml +++ /dev/null @@ -1,75 +0,0 @@ ---- -## -## -### NETBOX_TENANT_GROUP -## -## -- name: "1 - Test tenant group creation" - netbox_tenant_group: - netbox_url: http://localhost:32768 - netbox_token: 0123456789abcdef0123456789abcdef01234567 - data: - name: "Test Tenant Group Two" - register: test_one - -- name: "1 - ASSERT" - 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_tenant_group: - netbox_url: http://localhost:32768 - netbox_token: 0123456789abcdef0123456789abcdef01234567 - data: - name: "Test Tenant Group Two" - register: test_two - -- name: "2 - ASSERT" - 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_tenant_group: - netbox_url: http://localhost:32768 - netbox_token: 0123456789abcdef0123456789abcdef01234567 - data: - name: "Test Tenant Group Two" - state: "absent" - register: test_three - -- name: "3 - ASSERT" - 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 another tenant group creation" - 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" - 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" diff --git a/tests/integration/v2.7/main.yml b/tests/integration/v2.7/main.yml deleted file mode 100644 index 6278480b5..000000000 --- a/tests/integration/v2.7/main.yml +++ /dev/null @@ -1,109 +0,0 @@ ---- -- hosts: localhost - connection: local - gather_facts: no - collections: - - netbox.netbox - - tasks: - - name: "NETBOX_DEVICE TESTS" - include_tasks: "tasks/netbox_device.yml" - - - name: "NETBOX_DEVICE_INTERFACE TESTS" - include_tasks: "tasks/netbox_device_interface.yml" - - - name: "NETBOX_IP_ADDRESS TESTS" - include_tasks: "tasks/netbox_ip_address.yml" - - - name: "NETBOX_PREFIX TESTS" - include_tasks: "tasks/netbox_prefix.yml" - - - name: "NETBOX_SITE TESTS" - include_tasks: "tasks/netbox_site.yml" - - - name: "NETBOX_TENTANT TESTS" - include_tasks: "tasks/netbox_tenant.yml" - - - name: "NETBOX_TENTANT_GROUP TESTS" - include_tasks: "tasks/netbox_tenant_group.yml" - - - name: "NETBOX_RACK TESTS" - include_tasks: "tasks/netbox_rack.yml" - - - name: "NETBOX_RACK_ROLE TESTS" - include_tasks: "tasks/netbox_rack_role.yml" - - - name: "NETBOX_RACK_GROUP TESTS" - include_tasks: "tasks/netbox_rack_group.yml" - - - name: "NETBOX_MANUFACTURER TESTS" - include_tasks: "tasks/netbox_manufacturer.yml" - - - name: "NETBOX_PLATFORM TESTS" - include_tasks: "tasks/netbox_platform.yml" - - - name: "NETBOX_DEVICE_TYPE TESTS" - include_tasks: "tasks/netbox_device_type.yml" - - - name: "NETBOX_DEVICE_ROLE TESTS" - include_tasks: "tasks/netbox_device_role.yml" - - - name: "NETBOX_IPAM_ROLE TESTS" - include_tasks: "tasks/netbox_ipam_role.yml" - - - name: "NETBOX_VLAN_GROUP TESTS" - include_tasks: "tasks/netbox_vlan_group.yml" - - - name: "NETBOX_VLAN TESTS" - include_tasks: "tasks/netbox_vlan.yml" - - - name: "NETBOX_VRF TESTS" - include_tasks: "tasks/netbox_vrf.yml" - - - name: "NETBOX_RIR TESTS" - include_tasks: "tasks/netbox_rir.yml" - - - name: "NETBOX_AGGREGATE TESTS" - include_tasks: "tasks/netbox_aggregate.yml" - - - name: "NETBOX_REGION TESTS" - include_tasks: "tasks/netbox_region.yml" - - - name: "NETBOX_DEVICE_BAY TESTS" - include_tasks: "tasks/netbox_device_bay.yml" - - - name: "NETBOX_INVENTORY_ITEM TESTS" - include_tasks: "tasks/netbox_inventory_item.yml" - - - name: "NETBOX_VIRTUAL_MACHINE TESTS" - include_tasks: "tasks/netbox_virtual_machine.yml" - - - name: "NETBOX_CLUSTER TESTS" - include_tasks: "tasks/netbox_cluster.yml" - - - name: "NETBOX_CLUSTER_GROUP TESTS" - include_tasks: "tasks/netbox_cluster_group.yml" - - - name: "NETBOX_CLUSTER_TYPE TESTS" - include_tasks: "tasks/netbox_cluster_type.yml" - - - name: "NETBOX_VM_INTERFACE TESTS" - include_tasks: "tasks/netbox_vm_interface.yml" - - - name: "NETBOX_PROVIDER TESTS" - include_tasks: "tasks/netbox_provider.yml" - - - name: "NETBOX_CIRCUIT_TYPE TESTS" - include_tasks: "tasks/netbox_circuit_type.yml" - - - name: "NETBOX_CIRCUIT TESTS" - include_tasks: "tasks/netbox_circuit.yml" - - - name: "NETBOX_CIRCUIT_TERMINATION TESTS" - include_tasks: "tasks/netbox_circuit_termination.yml" - - - name: "NETBOX_SERVICE TESTS" - include_tasks: "tasks/netbox_service.yml" - - - name: "NETBOX_LOOKUP TESTS" - include_tasks: "tasks/netbox_lookup.yml" diff --git a/tests/integration/v2.7/tasks/netbox_aggregate.yml b/tests/integration/v2.7/tasks/netbox_aggregate.yml deleted file mode 100644 index c9e2cffef..000000000 --- a/tests/integration/v2.7/tasks/netbox_aggregate.yml +++ /dev/null @@ -1,115 +0,0 @@ ---- -## -## -### NETBOX_AGGEGATE -## -## -- name: "AGGREGATE 1: Necessary info creation" - 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" - 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_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" - 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_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" - 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] == "Schnozzberry" - - 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] == "Schnozzberry" - - test_three['msg'] == "aggregate 10.0.0.0/8 updated" - -- name: "AGGREGATE 4: ASSERT - Delete" - 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" - 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] == "Schnozzberry" - - test_four['msg'] == "aggregate 10.0.0.0/8 deleted" - -- name: "AGGREGATE 5: Necessary info creation" - 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" - 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/v2.7/tasks/netbox_circuit.yml b/tests/integration/v2.7/tasks/netbox_circuit.yml deleted file mode 100644 index 1ea3474de..000000000 --- a/tests/integration/v2.7/tasks/netbox_circuit.yml +++ /dev/null @@ -1,109 +0,0 @@ ---- -## -## -### NETBOX_CIRCUIT -## -## -- name: "NETBOX_CIRCUIT 1: Create provider within Netbox with only required information" - 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" - 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_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" - 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_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" - 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_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" - 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/v2.7/tasks/netbox_cluster.yml b/tests/integration/v2.7/tasks/netbox_cluster.yml deleted file mode 100644 index fdda9a69e..000000000 --- a/tests/integration/v2.7/tasks/netbox_cluster.yml +++ /dev/null @@ -1,95 +0,0 @@ ---- -## -## -### NETBOX_CLUSTER -## -## -- name: "CLUSTER 1: Necessary info creation" - 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" - 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_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" - 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_cluster: - netbox_url: http://localhost:32768 - netbox_token: 0123456789abcdef0123456789abcdef01234567 - data: - name: "Test Cluster One" - cluster_type: "Test Cluster Type" - cluster_group: "Test Cluster Group" - site: "Test Site" - comments: "Updated cluster" - tags: - - Schnozzberry - state: present - register: test_three - -- name: "CLUSTER 3: ASSERT - Updated" - assert: - that: - - test_three is changed - - test_three['diff']['after']['group'] == 1 - - test_three['diff']['after']['site'] == 1 - - test_three['diff']['after']['comments'] == "Updated cluster" - - test_three['diff']['after']['tags'][0] == "Schnozzberry" - - test_three['cluster']['name'] == "Test Cluster One" - - test_three['cluster']['type'] == 1 - - test_three['cluster']['group'] == 1 - - test_three['cluster']['site'] == 1 - - test_three['cluster']['comments'] == "Updated cluster" - - test_three['cluster']['tags'][0] == "Schnozzberry" - - test_three['msg'] == "cluster Test Cluster One updated" - -- name: "CLUSTER 4: ASSERT - Delete" - 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" - 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']['site'] == 1 - - test_four['cluster']['comments'] == "Updated cluster" - - test_four['cluster']['tags'][0] == "Schnozzberry" - - test_four['msg'] == "cluster Test Cluster One deleted" diff --git a/tests/integration/v2.7/tasks/netbox_cluster_group.yml b/tests/integration/v2.7/tasks/netbox_cluster_group.yml deleted file mode 100644 index 27ebb73e6..000000000 --- a/tests/integration/v2.7/tasks/netbox_cluster_group.yml +++ /dev/null @@ -1,96 +0,0 @@ ---- -## -## -### NETBOX_CLUSTER_GROUP -## -## -- name: "CLUSTER_GROUP 1: Necessary info creation" - 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" - 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_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" - 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_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" - 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_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" - 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_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" - 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/v2.7/tasks/netbox_device.yml b/tests/integration/v2.7/tasks/netbox_device.yml deleted file mode 100644 index d0816e161..000000000 --- a/tests/integration/v2.7/tasks/netbox_device.yml +++ /dev/null @@ -1,201 +0,0 @@ ---- -## -## -### NETBOX_DEVICE -## -## -- name: "1 - Device with required information" - 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_one - -- name: "1 - ASSERT" - 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']['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_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" - assert: - that: - - not test_two['changed'] - - test_two['device']['name'] == "R1" - - test_two['device']['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_device: - netbox_url: "http://localhost:32768" - netbox_token: "0123456789abcdef0123456789abcdef01234567" - data: - name: "R1" - serial: "FXS1001" - state: present - register: test_three - -- name: "3 - ASSERT" - assert: - that: - - test_three is changed - - test_three['diff']['after']['serial'] == "FXS1001" - - test_three['device']['name'] == "R1" - - test_three['device']['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['msg'] == "device R1 updated" - -- name: "4 - Create device with tags and assign to rack" - netbox_device: - netbox_url: "http://localhost:32768" - netbox_token: "0123456789abcdef0123456789abcdef01234567" - data: - name: "TestR1" - device_type: "Arista Test" - device_role: "Core Switch" - site: "Test Site2" - rack: "Test Rack" - position: 35 - face: "Front" - tags: - - "Schnozzberry" - tenant: "Test Tenant" - asset_tag: "1234" - state: present - register: test_four - -- name: "4 - ASSERT" - 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']['device_role'] == 1 - - test_four['device']['device_type'] == 2 - - test_four['device']['site'] == 2 - - test_four['device']['status'] == "active" - - test_four['device']['rack'] == 1 - - test_four['device']['tags'][0] == 'Schnozzberry' - - test_four['device']['tenant'] == 1 - - test_four['device']['asset_tag'] == '1234' - - test_four['msg'] == "device TestR1 created" - -- name: "5 - Delete previous device" - netbox_device: - netbox_url: "http://localhost:32768" - netbox_token: "0123456789abcdef0123456789abcdef01234567" - data: - name: "TestR1" - state: absent - register: test_five - -- name: "5 - ASSERT" - 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_device: - netbox_url: "http://localhost:32768" - netbox_token: "0123456789abcdef0123456789abcdef01234567" - data: - name: "R1" - state: absent - register: test_six - -- name: "6 - ASSERT" - assert: - that: - - test_six is changed - - test_six['diff']['before']['state'] == "present" - - test_six['diff']['after']['state'] == "absent" - - test_six['msg'] == "device R1 deleted" - -- name: "7 - Add primary_ip4/6 to test100" - 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" - 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']['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_device: - netbox_url: "http://localhost:32768" - netbox_token: "0123456789abcdef0123456789abcdef01234567" - data: - name: "" - device_type: "Cisco Test" - device_role: "Core Switch" - site: "Test Site" - status: "Staged" - state: present - register: test_eight - -- name: "8 - ASSERT" - assert: - that: - - test_eight is changed - - test_eight['diff']['before']['state'] == 'absent' - - test_eight['diff']['after']['state'] == 'present' - - test_eight['device']['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" \ No newline at end of file diff --git a/tests/integration/v2.7/tasks/netbox_device_interface.yml b/tests/integration/v2.7/tasks/netbox_device_interface.yml deleted file mode 100644 index baedb9d11..000000000 --- a/tests/integration/v2.7/tasks/netbox_device_interface.yml +++ /dev/null @@ -1,291 +0,0 @@ ---- -## -## -### NETBOX_DEVICE_INTERFACE -## -## -- name: "1 - Interface with required information" - netbox_device_interface: - netbox_url: "http://localhost:32768" - netbox_token: "0123456789abcdef0123456789abcdef01234567" - data: - device: test100 - name: GigabitEthernet3 - form_factor: "1000Base-T (1GE)" - register: test_one - -- name: "1 - ASSERT" - 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_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" - 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_device_interface: - netbox_url: "http://localhost:32768" - netbox_token: "0123456789abcdef0123456789abcdef01234567" - data: - device: test100 - name: GigabitEthernet3 - state: absent - register: test_three - -- name: "3 - ASSERT" - 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_device_interface: - netbox_url: "http://localhost:32768" - netbox_token: "0123456789abcdef0123456789abcdef01234567" - data: - device: test100 - name: port-channel1 - form_factor: Link Aggregation Group (LAG) - mtu: 1600 - mgmt_only: false - mode: Access - state: present - register: test_four - -- name: "4 - ASSERT" - 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_device_interface: - netbox_url: "http://localhost:32768" - netbox_token: "0123456789abcdef0123456789abcdef01234567" - data: - device: test100 - name: GigabitEthernet3 - enabled: false - form_factor: 1000Base-T (1GE) - lag: - name: port-channel1 - mtu: 1600 - mgmt_only: false - mode: Access - state: present - register: test_five - -- name: "5 - ASSERT" - 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'] == 15 - - test_five['interface']['mode'] == "access" - - test_five['interface']['mtu'] == 1600 - -- name: "6 - Create interface as trunk port" - netbox_device_interface: - netbox_url: "http://localhost:32768" - netbox_token: "0123456789abcdef0123456789abcdef01234567" - data: - device: test100 - name: GigabitEthernet21 - enabled: false - form_factor: 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" - 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_device_interface: - netbox_url: "http://localhost:32768" - netbox_token: "0123456789abcdef0123456789abcdef01234567" - data: - device: test100 - name: GigabitEthernet1 - register: test_seven - -- name: "7 - ASSERT" - 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_device_interface: - netbox_url: "http://localhost:32768" - netbox_token: "0123456789abcdef0123456789abcdef01234567" - data: - device: "R1-Device" - name: "port-channel1" - form_factor: "Link Aggregation Group (LAG)" - -- name: "8 - Create interface and assign it to parent LAG - non dict" - netbox_device_interface: - netbox_url: "http://localhost:32768" - netbox_token: "0123456789abcdef0123456789abcdef01234567" - data: - device: test100 - name: GigabitEthernet4 - enabled: false - form_factor: 1000Base-T (1GE) - lag: "port-channel1" - mtu: 1600 - mgmt_only: false - mode: Access - state: present - register: test_eight - -- name: "8 - ASSERT" - 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'] == 15 - - test_eight['interface']['mode'] == "access" - - test_eight['interface']['mtu'] == 1600 - -- name: "9 - Create interface on VC child" - netbox_device_interface: - netbox_url: "http://localhost:32768" - netbox_token: "0123456789abcdef0123456789abcdef01234567" - data: - device: Test Nexus Child One - name: Ethernet2/1 - form_factor: 1000Base-T (1GE) - state: present - register: test_nine - -- name: "9 - ASSERT" - assert: - that: - - test_nine is changed - - test_nine['msg'] == "interface Ethernet2/1 created" - - test_nine['diff']['before']['state'] == 'absent' - - test_nine['diff']['after']['state'] == 'present' - - test_nine['interface']['name'] == "Ethernet2/1" - - test_nine['interface']['device'] == 5 - - test_nine['interface']['enabled'] == true - - test_nine['interface']['type'] == "1000base-t" - -- name: "10 - Update interface on VC child" - netbox_device_interface: - netbox_url: "http://localhost:32768" - netbox_token: "0123456789abcdef0123456789abcdef01234567" - data: - device: Test Nexus One - name: Ethernet2/1 - description: "Updated child interface from parent device" - update_vc_child: True - state: present - register: test_ten - -- name: "10 - ASSERT" - assert: - that: - - test_ten is changed - - test_ten['msg'] == "interface Ethernet2/1 updated" - - test_ten['diff']['after']['description'] == 'Updated child interface from parent device' - - test_ten['interface']['name'] == "Ethernet2/1" - - 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_device_interface: - netbox_url: "http://localhost:32768" - netbox_token: "0123456789abcdef0123456789abcdef01234567" - data: - device: Test Nexus One - name: Ethernet2/1 - description: "Updated child interface from parent device - test" - state: present - ignore_errors: yes - register: test_eleven - -- name: "11 - ASSERT" - assert: - that: - - test_eleven is failed - - test_eleven['msg'] == "Must set update_vc_child to True to allow child device interface modification" \ No newline at end of file diff --git a/tests/integration/v2.7/tasks/netbox_ip_address.yml b/tests/integration/v2.7/tasks/netbox_ip_address.yml deleted file mode 100644 index 0bd530e86..000000000 --- a/tests/integration/v2.7/tasks/netbox_ip_address.yml +++ /dev/null @@ -1,325 +0,0 @@ ---- -## -## -### NETBOX_IP_ADDRESS -## -## -- name: "1 - Create IP address within Netbox with only required information - State: Present" - netbox_ip_address: - netbox_url: http://localhost.org:32768 - netbox_token: 0123456789abcdef0123456789abcdef01234567 - data: - address: 192.168.1.10/30 - state: present - register: test_one - -- name: "1 - ASSERT" - 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_ip_address: - netbox_url: http://localhost.org: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" - assert: - that: - - test_two is changed - - test_two['diff']['after']['description'] == "Updated ip address" - - test_two['diff']['after']['tags'][0] == "Updated" - - 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] == "Updated" - - test_two['ip_address']['description'] == "Updated ip address" - -- name: "3 - Delete IP - 192.168.1.10 - State: Absent" - netbox_ip_address: - netbox_url: http://localhost.org:32768 - netbox_token: 0123456789abcdef0123456789abcdef01234567 - data: - address: 192.168.1.10/30 - state: absent - register: test_three - -- name: "3 - ASSERT" - 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_ip_address: - netbox_url: http://localhost.org:32768 - netbox_token: 0123456789abcdef0123456789abcdef01234567 - data: - address: 192.168.1.20/30 - state: present - register: test_four - -- name: "4 - ASSERT" - 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" - -- name: "5 - Create IP in global VRF - 192.168.1.20/30 - State: New" - netbox_ip_address: - netbox_url: http://localhost.org: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_ip_address: - netbox_url: http://localhost.org:32768 - netbox_token: 0123456789abcdef0123456789abcdef01234567 - data: - prefix: 192.168.100.0/24 - state: new - register: test_six - -- name: "6 - ASSERT" - 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_ip_address: - netbox_url: http://localhost.org: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" - 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] == "Schnozzberry" - - test_seven['ip_address']['tenant'] == 1 - - test_seven['ip_address']['vrf'] == 1 - -- name: "8 - Create IP address and assign a nat_inside IP" - netbox_ip_address: - netbox_url: http://localhost.org: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 - interface: - name: GigabitEthernet1 - device: test100 - register: test_eight - -- name: "8 - ASSERT" - 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']['interface'] == 2 - - test_eight['ip_address']['nat_inside'] == 7 - - test_eight['ip_address']['vrf'] == 1 - -- name: "9 - Create IP address on GigabitEthernet2 - test100 - State: present" - netbox_ip_address: - netbox_url: http://localhost.org:32768 - netbox_token: 0123456789abcdef0123456789abcdef01234567 - data: - family: 4 - address: 10.10.200.30/16 - interface: - name: GigabitEthernet2 - device: test100 - register: test_nine - -- name: "9 - ASSERT" - 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']['interface'] == 3 - -- name: "10 - Create IP address on GigabitEthernet2 - test100 - State: new" - netbox_ip_address: - netbox_url: http://localhost.org:32768 - netbox_token: 0123456789abcdef0123456789abcdef01234567 - data: - family: 4 - prefix: 10.10.0.0/16 - interface: - name: GigabitEthernet2 - device: test100 - state: new - register: test_ten - -- name: "10 - ASSERT" - 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']['value'] == 4 - - test_ten['ip_address']['interface']['id'] == 3 - -- name: "11 - Create IP address on GigabitEthernet2 - test100 - State: present" - netbox_ip_address: - netbox_url: http://localhost.org:32768 - netbox_token: 0123456789abcdef0123456789abcdef01234567 - data: - family: 4 - prefix: 192.168.100.0/24 - interface: - name: GigabitEthernet2 - device: test100 - state: present - register: test_eleven - -- name: "11 - ASSERT" - 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_ip_address: - netbox_url: http://localhost.org:32768 - netbox_token: 0123456789abcdef0123456789abcdef01234567 - data: - address: 192.168.100.2/24 - interface: - name: GigabitEthernet2 - device: test100 - state: present - register: test_twelve - -- name: "12 - ASSERT" - 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']['interface'] == 3 - -- name: "13 - Duplicate - 192.168.100.2/24" - netbox_ip_address: - netbox_url: http://localhost.org:32768 - netbox_token: 0123456789abcdef0123456789abcdef01234567 - data: - address: 192.168.100.2/24 - state: present - register: test_thirteen - -- name: "13 - ASSERT" - 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_ip_address: - netbox_url: http://localhost.org:32768 - netbox_token: 0123456789abcdef0123456789abcdef01234567 - data: - family: 4 - address: 10.188.1.100/24 - interface: - name: Eth0 - virtual_machine: test100-vm - register: test_fourteen - -- name: "14 - ASSERT" - 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']['interface'] == 4 - -- name: "15 - Create IP address with no mask - State: Present" - netbox_ip_address: - netbox_url: http://localhost.org:32768 - netbox_token: 0123456789abcdef0123456789abcdef01234567 - data: - address: 10.120.10.1 - 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.120.10.1/32 created" - - test_fifteen['ip_address']['address'] == "10.120.10.1/32" diff --git a/tests/integration/v2.7/tasks/netbox_ipam_role.yml b/tests/integration/v2.7/tasks/netbox_ipam_role.yml deleted file mode 100644 index 240f57b62..000000000 --- a/tests/integration/v2.7/tasks/netbox_ipam_role.yml +++ /dev/null @@ -1,94 +0,0 @@ ---- -## -## -### NETBOX_IPAM_ROLE -## -## -- name: "IPAM_ROLE 1: Necessary info creation" - 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" - 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_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" - 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_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" - 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_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" - 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_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`" - assert: - that: - - not test_five['changed'] - - test_five['role'] == None - - test_five['msg'] == "role Test IPAM Role already absent" diff --git a/tests/integration/v2.7/tasks/netbox_manufacturer.yml b/tests/integration/v2.7/tasks/netbox_manufacturer.yml deleted file mode 100644 index 52486c081..000000000 --- a/tests/integration/v2.7/tasks/netbox_manufacturer.yml +++ /dev/null @@ -1,91 +0,0 @@ ---- -## -## -### NETBOX_MANUFACTURER -## -## -- name: "MANUFACTURER 1: Necessary info creation" - 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" - 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_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" - 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_manufacturer: - netbox_url: http://localhost:32768 - netbox_token: 0123456789abcdef0123456789abcdef01234567 - data: - name: test manufacturer two - state: present - register: test_three - -- name: "MANUFACTURER 3: ASSERT - Update" - 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_manufacturer: - netbox_url: http://localhost:32768 - netbox_token: 0123456789abcdef0123456789abcdef01234567 - data: - name: test manufacturer two - state: absent - register: test_four - -- name: "MANUFACTURER 3: ASSERT - Delete" - 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_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" - assert: - that: - - not test_five['changed'] - - test_five['manufacturer'] == None - - test_five['msg'] == "manufacturer Test Manufacturer Two already absent" diff --git a/tests/integration/v2.7/tasks/netbox_prefix.yml b/tests/integration/v2.7/tasks/netbox_prefix.yml deleted file mode 100644 index a50585fad..000000000 --- a/tests/integration/v2.7/tasks/netbox_prefix.yml +++ /dev/null @@ -1,245 +0,0 @@ ---- -## -## -### NETBOX_PREFIX -## -## -- name: "1 - Create prefix within Netbox with only required information" - 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" - 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_prefix: - netbox_url: http://localhost:32768 - netbox_token: 0123456789abcdef0123456789abcdef01234567 - data: - prefix: 10.156.0.0/19 - state: present - register: test_two - -- name: "2 - ASSERT" - 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_prefix: - netbox_url: http://localhost:32768 - netbox_token: 0123456789abcdef0123456789abcdef01234567 - data: - prefix: 10.156.0.0/19 - site: Test Site - status: Reserved - description: "This prefix has been updated" - state: present - register: test_three - -- name: "3 - ASSERT" - assert: - that: - - test_three is changed - - test_three['diff']['after']['site'] == 1 - - test_three['diff']['after']['status'] == "reserved" - - test_three['diff']['after']['description'] == "This prefix has been updated" - - test_three['msg'] == "prefix 10.156.0.0/19 updated" - - test_three['prefix']['prefix'] == "10.156.0.0/19" - - test_three['prefix']['site'] == 1 - - test_three['prefix']['status'] == "reserved" - - test_three['prefix']['description'] == "This prefix has been updated" - -- name: "4 - Delete prefix within 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" - 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_prefix: - netbox_url: http://localhost:32768 - netbox_token: 0123456789abcdef0123456789abcdef01234567 - data: - family: 4 - prefix: 10.156.32.0/19 - site: 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" - 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']['site'] == 1 - - 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] == "Schnozzberry" - -- name: "6 - Get a new /24 inside 10.156.0.0/19 within Netbox - Parent doesn't exist" - netbox_prefix: - netbox_url: http://localhost:32768 - netbox_token: 0123456789abcdef0123456789abcdef01234567 - data: - parent: 10.156.0.0/19 - prefix_length: 24 - state: present - first_available: yes - register: test_six - -- name: "6 - ASSERT" - 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_prefix: - netbox_url: http://localhost:32768 - netbox_token: 0123456789abcdef0123456789abcdef01234567 - data: - prefix: 10.156.0.0/19 - state: present - register: test_seven - -- name: "7 - ASSERT" - 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_prefix: - netbox_url: http://localhost:32768 - netbox_token: 0123456789abcdef0123456789abcdef01234567 - data: - parent: 10.156.0.0/19 - prefix_length: 24 - state: present - first_available: yes - register: test_eight - -- name: "8 - ASSERT" - 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_prefix: - netbox_url: http://localhost:32768 - netbox_token: 0123456789abcdef0123456789abcdef01234567 - data: - prefix: 10.157.0.0/19 - vrf: Test VRF - site: Test Site - state: present - register: test_nine - -- name: "9 - ASSERT" - 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']['site'] == 1 - - test_nine['prefix']['vrf'] == 1 - -- name: "10 - Get a new /24 inside 10.157.0.0/19 within Netbox with additional values" - netbox_prefix: - netbox_url: http://localhost:32768 - netbox_token: 0123456789abcdef0123456789abcdef01234567 - data: - parent: 10.157.0.0/19 - prefix_length: 24 - vrf: Test VRF - site: Test Site - state: present - first_available: yes - register: test_ten - -- name: "10 - ASSERT" - 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']['site']['id'] == 1 - - test_ten['prefix']['vrf']['id'] == 1 - -- name: "11 - Get a new /24 inside 10.156.0.0/19 within 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: yes - register: test_eleven - -- name: "11 - ASSERT" - 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/v2.7/tasks/netbox_rack_group.yml b/tests/integration/v2.7/tasks/netbox_rack_group.yml deleted file mode 100644 index b2ae0c65e..000000000 --- a/tests/integration/v2.7/tasks/netbox_rack_group.yml +++ /dev/null @@ -1,62 +0,0 @@ ---- -## -## -### NETBOX_RACK_GROUP -## -## -- name: "RACK_GROUP 1: Necessary info creation" - 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" - 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_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" - 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_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" - 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/v2.7/tasks/netbox_rack_role.yml b/tests/integration/v2.7/tasks/netbox_rack_role.yml deleted file mode 100644 index 847c73d96..000000000 --- a/tests/integration/v2.7/tasks/netbox_rack_role.yml +++ /dev/null @@ -1,81 +0,0 @@ ---- -## -## -### NETBOX_RACK_ROLE -## -## -- name: "RACK_ROLE 1: Necessary info creation" - 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" - 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_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" - 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_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" - 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_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" - 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/v2.7/tasks/netbox_rir.yml b/tests/integration/v2.7/tasks/netbox_rir.yml deleted file mode 100644 index 821b3e280..000000000 --- a/tests/integration/v2.7/tasks/netbox_rir.yml +++ /dev/null @@ -1,79 +0,0 @@ ---- -## -## -### NETBOX_RIR -## -## -- name: "RIR 1: Necessary info creation" - 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" - 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_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" - 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_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" - 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_rir: - netbox_url: http://localhost:32768 - netbox_token: 0123456789abcdef0123456789abcdef01234567 - data: - name: "Test RIR One" - state: absent - register: test_four - -- name: "RIR 4: ASSERT - Delete" - 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/v2.7/tasks/netbox_service.yml b/tests/integration/v2.7/tasks/netbox_service.yml deleted file mode 100644 index 7ec656963..000000000 --- a/tests/integration/v2.7/tasks/netbox_service.yml +++ /dev/null @@ -1,150 +0,0 @@ ---- -## -## -### NETBOX_SERVICE -## -## -- name: "1 - Device with required information needs to add new service" - 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_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" - assert: - that: - - test_service_create is changed - - test_service_create['services']['name'] == "node-exporter" - - test_service_create['services']['port'] == 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_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" - assert: - that: - - test_service_idempotence['services']['name'] == "node-exporter" - - test_service_idempotence['services']['port'] == 9100 - - test_service_idempotence['services']['protocol'] == "tcp" - - test_service_idempotence['msg'] == "services node-exporter already exists" - -- name: "NETBOX_SERVICE: Test update" - netbox_service: - netbox_url: "http://localhost:32768" - netbox_token: "0123456789abcdef0123456789abcdef01234567" - data: - device: "FOR_SERVICE" - name: "node-exporter" - port: 9100 - protocol: TCP - tags: - - "Schnozzberry" - state: present - register: test_service_update - -- name: "NETBOX_SERVICE ASSERT - Service has been updated" - assert: - that: - - test_service_update is changed - - test_service_update['diff']['after']['tags'][0] == "Schnozzberry" - - test_service_update['msg'] == "services node-exporter updated" - -- name: "NETBOX_SERVICE: Test same details, but different protocol - Create" - 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" - 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']['port'] == 9100 - - test_service_protocol['services']['protocol'] == "udp" - - test_service_protocol['msg'] == "services node-exporter created" - -- name: "NETBOX_SERVICE: Test service deletion" - 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" - 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_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" - 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']['port'] == 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" diff --git a/tests/integration/v2.7/tasks/netbox_tenant.yml b/tests/integration/v2.7/tasks/netbox_tenant.yml deleted file mode 100644 index c6b95e807..000000000 --- a/tests/integration/v2.7/tasks/netbox_tenant.yml +++ /dev/null @@ -1,106 +0,0 @@ ---- -## -## -### NETBOX_TENANT -## -## -- name: "1 - Test tenant creation" - netbox_tenant: - netbox_url: http://localhost:32768 - netbox_token: 0123456789abcdef0123456789abcdef01234567 - data: - name: "Tenant ABC" - register: test_one - -- name: "1 - ASSERT" - 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_tenant: - netbox_url: http://localhost:32768 - netbox_token: 0123456789abcdef0123456789abcdef01234567 - data: - name: "Tenant ABC" - register: test_two - -- name: "2 - ASSERT" - 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_tenant: - netbox_url: http://localhost:32768 - netbox_token: 0123456789abcdef0123456789abcdef01234567 - data: - name: "Tenant ABC" - description: "Updated description" - register: test_three - -- name: "3 - ASSERT" - 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_tenant: - netbox_url: http://localhost:32768 - netbox_token: 0123456789abcdef0123456789abcdef01234567 - data: - name: "Tenant ABC" - state: "absent" - register: test_four - -- name: "4 - ASSERT" - 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_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" - 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/v2.7/tasks/netbox_virtual_machine.yml b/tests/integration/v2.7/tasks/netbox_virtual_machine.yml deleted file mode 100644 index aa025465b..000000000 --- a/tests/integration/v2.7/tasks/netbox_virtual_machine.yml +++ /dev/null @@ -1,99 +0,0 @@ ---- -## -## -### NETBOX_VIRTUAL_MACHINES -## -## -- name: "VIRTUAL_MACHINE 1: Necessary info creation" - 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" - 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_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" - 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_virtual_machine: - netbox_url: http://localhost:32768 - netbox_token: 0123456789abcdef0123456789abcdef01234567 - data: - name: "Test VM One" - cluster: "Test Cluster" - vcpus: 8 - memory: 8 - status: "Planned" - virtual_machine_role: "Test VM Role" - tags: - - Schnozzberry - state: present - register: test_three - -- name: "VIRTUAL_MACHINE 3: ASSERT - Updated" - assert: - that: - - test_three is changed - - test_three['diff']['after']['vcpus'] == 8 - - test_three['diff']['after']['memory'] == 8 - - test_three['diff']['after']['status'] == "planned" - - test_three['diff']['after']['role'] == 2 - - test_three['diff']['after']['tags'][0] == "Schnozzberry" - - test_three['virtual_machine']['name'] == "Test VM One" - - test_three['virtual_machine']['cluster'] == 1 - - test_three['virtual_machine']['vcpus'] == 8 - - test_three['virtual_machine']['memory'] == 8 - - test_three['virtual_machine']['status'] == "planned" - - test_three['virtual_machine']['role'] == 2 - - test_three['virtual_machine']['tags'][0] == "Schnozzberry" - - test_three['msg'] == "virtual_machine Test VM One updated" - -- name: "VIRTUAL_MACHINE 4: ASSERT - Delete" - netbox_virtual_machine: - netbox_url: http://localhost:32768 - netbox_token: 0123456789abcdef0123456789abcdef01234567 - data: - name: "Test VM One" - state: absent - register: test_four - -- name: "VIRTUAL_MACHINE 4: ASSERT - Delete" - assert: - that: - - test_four is changed - - test_four['virtual_machine']['name'] == "Test VM One" - - test_four['virtual_machine']['cluster'] == 1 - - test_four['virtual_machine']['vcpus'] == 8 - - test_four['virtual_machine']['memory'] == 8 - - test_four['virtual_machine']['status'] == "planned" - - test_four['virtual_machine']['role'] == 2 - - test_four['virtual_machine']['tags'][0] == "Schnozzberry" - - test_four['msg'] == "virtual_machine Test VM One deleted" diff --git a/tests/integration/v2.7/tasks/netbox_vm_interface.yml b/tests/integration/v2.7/tasks/netbox_vm_interface.yml deleted file mode 100644 index 08ea21e20..000000000 --- a/tests/integration/v2.7/tasks/netbox_vm_interface.yml +++ /dev/null @@ -1,159 +0,0 @@ ---- -## -## -### NETBOX_VM_INTERFACE -## -## -- name: "NETBOX_VM_INTERFACE 1: Necessary info creation" - 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" - 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_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" - 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_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" - 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] == "Schnozzberry" - - 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] == "Schnozzberry" - - test_three['msg'] == "interface Eth10 updated" - -- name: "NETBOX_VM_INTERFACE 4: ASSERT - Delete" - 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" - 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_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" - 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] == "Schnozzberry" - - 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] == "Schnozzberry" - - test_five['msg'] == "interface Eth0 updated" diff --git a/tests/integration/v2.8/main.yml b/tests/integration/v2.8/main.yml deleted file mode 100644 index 6278480b5..000000000 --- a/tests/integration/v2.8/main.yml +++ /dev/null @@ -1,109 +0,0 @@ ---- -- hosts: localhost - connection: local - gather_facts: no - collections: - - netbox.netbox - - tasks: - - name: "NETBOX_DEVICE TESTS" - include_tasks: "tasks/netbox_device.yml" - - - name: "NETBOX_DEVICE_INTERFACE TESTS" - include_tasks: "tasks/netbox_device_interface.yml" - - - name: "NETBOX_IP_ADDRESS TESTS" - include_tasks: "tasks/netbox_ip_address.yml" - - - name: "NETBOX_PREFIX TESTS" - include_tasks: "tasks/netbox_prefix.yml" - - - name: "NETBOX_SITE TESTS" - include_tasks: "tasks/netbox_site.yml" - - - name: "NETBOX_TENTANT TESTS" - include_tasks: "tasks/netbox_tenant.yml" - - - name: "NETBOX_TENTANT_GROUP TESTS" - include_tasks: "tasks/netbox_tenant_group.yml" - - - name: "NETBOX_RACK TESTS" - include_tasks: "tasks/netbox_rack.yml" - - - name: "NETBOX_RACK_ROLE TESTS" - include_tasks: "tasks/netbox_rack_role.yml" - - - name: "NETBOX_RACK_GROUP TESTS" - include_tasks: "tasks/netbox_rack_group.yml" - - - name: "NETBOX_MANUFACTURER TESTS" - include_tasks: "tasks/netbox_manufacturer.yml" - - - name: "NETBOX_PLATFORM TESTS" - include_tasks: "tasks/netbox_platform.yml" - - - name: "NETBOX_DEVICE_TYPE TESTS" - include_tasks: "tasks/netbox_device_type.yml" - - - name: "NETBOX_DEVICE_ROLE TESTS" - include_tasks: "tasks/netbox_device_role.yml" - - - name: "NETBOX_IPAM_ROLE TESTS" - include_tasks: "tasks/netbox_ipam_role.yml" - - - name: "NETBOX_VLAN_GROUP TESTS" - include_tasks: "tasks/netbox_vlan_group.yml" - - - name: "NETBOX_VLAN TESTS" - include_tasks: "tasks/netbox_vlan.yml" - - - name: "NETBOX_VRF TESTS" - include_tasks: "tasks/netbox_vrf.yml" - - - name: "NETBOX_RIR TESTS" - include_tasks: "tasks/netbox_rir.yml" - - - name: "NETBOX_AGGREGATE TESTS" - include_tasks: "tasks/netbox_aggregate.yml" - - - name: "NETBOX_REGION TESTS" - include_tasks: "tasks/netbox_region.yml" - - - name: "NETBOX_DEVICE_BAY TESTS" - include_tasks: "tasks/netbox_device_bay.yml" - - - name: "NETBOX_INVENTORY_ITEM TESTS" - include_tasks: "tasks/netbox_inventory_item.yml" - - - name: "NETBOX_VIRTUAL_MACHINE TESTS" - include_tasks: "tasks/netbox_virtual_machine.yml" - - - name: "NETBOX_CLUSTER TESTS" - include_tasks: "tasks/netbox_cluster.yml" - - - name: "NETBOX_CLUSTER_GROUP TESTS" - include_tasks: "tasks/netbox_cluster_group.yml" - - - name: "NETBOX_CLUSTER_TYPE TESTS" - include_tasks: "tasks/netbox_cluster_type.yml" - - - name: "NETBOX_VM_INTERFACE TESTS" - include_tasks: "tasks/netbox_vm_interface.yml" - - - name: "NETBOX_PROVIDER TESTS" - include_tasks: "tasks/netbox_provider.yml" - - - name: "NETBOX_CIRCUIT_TYPE TESTS" - include_tasks: "tasks/netbox_circuit_type.yml" - - - name: "NETBOX_CIRCUIT TESTS" - include_tasks: "tasks/netbox_circuit.yml" - - - name: "NETBOX_CIRCUIT_TERMINATION TESTS" - include_tasks: "tasks/netbox_circuit_termination.yml" - - - name: "NETBOX_SERVICE TESTS" - include_tasks: "tasks/netbox_service.yml" - - - name: "NETBOX_LOOKUP TESTS" - include_tasks: "tasks/netbox_lookup.yml" diff --git a/tests/integration/v2.8/tasks/netbox_device_bay.yml b/tests/integration/v2.8/tasks/netbox_device_bay.yml deleted file mode 100644 index 62f0436b9..000000000 --- a/tests/integration/v2.8/tasks/netbox_device_bay.yml +++ /dev/null @@ -1,87 +0,0 @@ ---- -## -## -### NETBOX_DEVICE_BAY -## -## -- name: "DEVICE_BAY 1: Necessary info creation" - 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" - 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_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" - 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_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" - assert: - that: - - test_three is changed - - test_three['diff']['after']['installed_device'] == 5 - - test_three['diff']['after']['tags'][0] == "Schnozzberry" - - 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] == "Schnozzberry" - - test_three['msg'] == "device_bay Device Bay One updated" - -- name: "DEVICE_BAY 4: ASSERT - Delete" - 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" - 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] == "Schnozzberry" - - test_four['msg'] == "device_bay Device Bay One deleted" diff --git a/tests/integration/v2.8/tasks/netbox_device_role.yml b/tests/integration/v2.8/tasks/netbox_device_role.yml deleted file mode 100644 index 9d0d9477c..000000000 --- a/tests/integration/v2.8/tasks/netbox_device_role.yml +++ /dev/null @@ -1,101 +0,0 @@ ---- -## -## -### NETBOX_DEVICE_ROLE -## -## -- name: "DEVICE_ROLE 1: Necessary info creation" - 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" - 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_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" - 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_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" - 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_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" - 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_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`" - 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/v2.8/tasks/netbox_device_type.yml b/tests/integration/v2.8/tasks/netbox_device_type.yml deleted file mode 100644 index 868e378b4..000000000 --- a/tests/integration/v2.8/tasks/netbox_device_type.yml +++ /dev/null @@ -1,131 +0,0 @@ ---- -## -## -### NETBOX_DEVICE_TYPE -## -## -- name: "DEVICE_TYPE 1: Necessary info creation" - 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" - 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_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" - 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_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 - is_full_depth: false - subdevice_role: parent - state: present - register: test_three - -- name: "DEVICE_TYPE 3: ASSERT - Update" - 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_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" - 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_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`" - 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_device_type: - netbox_url: http://localhost:32768 - netbox_token: 0123456789abcdef0123456789abcdef01234567 - data: - model: "WS Test 3850" - manufacturer: Test Manufacturer - state: present - register: test_six - -- name: "DEVICE_TYPE 6: ASSERT - Without Slug" - 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/v2.8/tasks/netbox_rack.yml b/tests/integration/v2.8/tasks/netbox_rack.yml deleted file mode 100644 index 948c550f7..000000000 --- a/tests/integration/v2.8/tasks/netbox_rack.yml +++ /dev/null @@ -1,177 +0,0 @@ ---- -## -## -### NETBOX_RACK -## -## -- name: "1 - Test rack creation" - netbox_rack: - netbox_url: http://localhost:32768 - netbox_token: 0123456789abcdef0123456789abcdef01234567 - data: - name: "Test rack one" - site: "Test Site" - register: test_one - -- name: "1 - ASSERT" - 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_rack: - netbox_url: http://localhost:32768 - netbox_token: 0123456789abcdef0123456789abcdef01234567 - data: - name: "Test rack one" - register: test_two - -- name: "2 - ASSERT" - 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_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" - 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_rack: - netbox_url: http://localhost:32768 - netbox_token: 0123456789abcdef0123456789abcdef01234567 - data: - name: Test rack one - site: Test Site - state: present - register: test_four - -- name: "4 - ASSERT" - 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_rack: - netbox_url: http://localhost:32768 - netbox_token: 0123456789abcdef0123456789abcdef01234567 - data: - name: Test rack one - site: Test Site - rack_role: "Test Rack Role" - rack_group: "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" - 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']['group'] == 1 - - 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] == "Schnozzberry" - - test_five['diff']['after']['type'] == "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']['group'] == 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] == "Schnozzberry" - - test_five['rack']['type'] == "2-post-frame" - - test_five['rack']['u_height'] == 48 - - test_five['rack']['width'] == "23" - - test_five['msg'] == "rack Test rack one updated" - -- name: "6 - Create rack with same asset tag and serial number" - 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: yes - register: test_six - -- name: "6 - ASSERT" - assert: - that: - - test_six is failed - - "'Asset tag already exists' in test_six['msg']" - -- name: "7 - Test delete" - netbox_rack: - netbox_url: http://localhost:32768 - netbox_token: 0123456789abcdef0123456789abcdef01234567 - data: - name: "Test rack one" - state: "absent" - register: test_seven - -- name: "7 - ASSERT" - assert: - that: - - test_seven is changed - - test_seven['diff']['before']['state'] == "present" - - test_seven['diff']['after']['state'] == "absent" - - test_seven['msg'] == "rack Test rack one deleted" diff --git a/tests/integration/v2.8/tasks/netbox_site.yml b/tests/integration/v2.8/tasks/netbox_site.yml deleted file mode 100644 index b1aa04ebd..000000000 --- a/tests/integration/v2.8/tasks/netbox_site.yml +++ /dev/null @@ -1,132 +0,0 @@ ---- -## -## -### NETBOX_SITE -## -## -- name: "1 - Create site within Netbox with only required information" - netbox_site: - netbox_url: http://localhost:32768 - netbox_token: 0123456789abcdef0123456789abcdef01234567 - data: - name: Test - Colorado - state: present - register: test_one - -- name: "1 - ASSERT" - 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_site: - netbox_url: http://localhost:32768 - netbox_token: 0123456789abcdef0123456789abcdef01234567 - data: - name: Test - Colorado - state: present - register: test_two - -- name: "2 - ASSERT" - 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_site: - netbox_url: http://localhost:32768 - netbox_token: 0123456789abcdef0123456789abcdef01234567 - data: - name: Test - Colorado - status: Planned - region: Test Region - contact_name: Mikhail - state: present - register: test_three - -- name: "3 - ASSERT" - assert: - that: - - test_three is changed - - test_three['diff']['after']['status'] == "planned" - - test_three['diff']['after']['contact_name'] == "Mikhail" - - 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']['contact_name'] == "Mikhail" - - test_three['site']['region'] == 1 - -- name: "4 - Create site with all parameters" - netbox_site: - netbox_url: http://localhost:32768 - netbox_token: 0123456789abcdef0123456789abcdef01234567 - data: - name: Test - California - status: Planned - region: Test Region - tenant: Test Tenant - facility: EquinoxCA7 - asn: 65001 - time_zone: America/Los Angeles - description: This is a test description - physical_address: Hollywood, CA, 90210 - shipping_address: Hollywood, CA, 90210 - latitude: 10.1 - longitude: 12.2 - contact_name: Jenny - contact_phone: 867-5309 - contact_email: jenny@changednumber.com - comments: "### Placeholder" - slug: "test_california" - state: present - register: test_four - -- name: "4 - ASSERT" - 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']['tenant'] == 1 - - test_four['site']['facility'] == "EquinoxCA7" - - test_four['site']['asn'] == 65001 - - 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'] == "10.100000" - - test_four['site']['longitude'] == "12.200000" - - test_four['site']['contact_name'] == "Jenny" - - test_four['site']['contact_phone'] == "867-5309" - - test_four['site']['contact_email'] == "jenny@changednumber.com" - - test_four['site']['comments'] == "### Placeholder" - - test_four['site']['slug'] == "test_california" - -- name: "5 - Delete site within netbox" - netbox_site: - netbox_url: http://localhost:32768 - netbox_token: 0123456789abcdef0123456789abcdef01234567 - data: - name: Test - Colorado - state: absent - register: test_five - -- name: "5 - ASSERT" - 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/v2.8/tasks/netbox_vlan.yml b/tests/integration/v2.8/tasks/netbox_vlan.yml deleted file mode 100644 index 5903b4793..000000000 --- a/tests/integration/v2.8/tasks/netbox_vlan.yml +++ /dev/null @@ -1,143 +0,0 @@ ---- -## -## -### NETBOX_VLAN -## -## -- name: "VLAN 1: Necessary info creation" - 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" - 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_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" - 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_vlan: - netbox_url: http://localhost:32768 - netbox_token: 0123456789abcdef0123456789abcdef01234567 - data: - name: Test VLAN 500 - vid: 500 - site: Test Site - tenant: Test Tenant - state: present - register: test_three - -- name: "VLAN 3: ASSERT - Create VLAN with same name, but different site" - 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['msg'] == "vlan Test VLAN 500 created" - -- name: "VLAN 4: ASSERT - Update" - 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" - assert: - that: - - test_four is changed - - test_four['diff']['after']['group'] == 1 - - 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] == "Schnozzberry" - - 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] == "Schnozzberry" - - test_four['msg'] == "vlan Test VLAN 500 updated" - -- name: "VLAN 5: ASSERT - Delete more than one result" - netbox_vlan: - netbox_url: http://localhost:32768 - netbox_token: 0123456789abcdef0123456789abcdef01234567 - data: - name: "Test VLAN 500" - state: absent - ignore_errors: yes - register: test_five - -- name: "VLAN 5: ASSERT - Delete more than one result" - assert: - that: - - test_five is failed - - test_five['msg'] == "More than one result returned for Test VLAN 500" - -- name: "VLAN 6: ASSERT - Delete" - netbox_vlan: - netbox_url: http://localhost:32768 - netbox_token: 0123456789abcdef0123456789abcdef01234567 - data: - name: "Test VLAN 500" - site: Test Site - state: absent - register: test_six - -- name: "VLAN 6: ASSERT - Delete" - 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] == "Schnozzberry" - - test_six['msg'] == "vlan Test VLAN 500 deleted" diff --git a/tests/integration/v2.8/tasks/netbox_vlan_group.yml b/tests/integration/v2.8/tasks/netbox_vlan_group.yml deleted file mode 100644 index 063c91c42..000000000 --- a/tests/integration/v2.8/tasks/netbox_vlan_group.yml +++ /dev/null @@ -1,118 +0,0 @@ ---- -## -## -### NETBOX_VLAN_GROUP -## -## -- name: "VLAN_GROUP 1: Necessary info creation" - netbox_vlan_group: - netbox_url: http://localhost:32768 - netbox_token: 0123456789abcdef0123456789abcdef01234567 - data: - name: "VLAN Group One" - site: Test Site - state: present - register: test_one - -- name: "VLAN_GROUP 1: ASSERT - Necessary info creation" - assert: - that: - - test_one is changed - - test_one['diff']['before']['state'] == "absent" - - test_one['diff']['after']['state'] == "present" - - test_one['vlan_group']['name'] == "VLAN Group One" - - test_one['vlan_group']['slug'] == "vlan-group-one" - - test_one['vlan_group']['site'] == 1 - - test_one['msg'] == "vlan_group VLAN Group One created" - -- name: "VLAN_GROUP 2: Create duplicate" - netbox_vlan_group: - netbox_url: http://localhost:32768 - netbox_token: 0123456789abcdef0123456789abcdef01234567 - data: - name: "VLAN Group One" - site: Test Site - state: present - register: test_two - -- name: "VLAN_GROUP 2: ASSERT - Create duplicate" - assert: - that: - - not test_two['changed'] - - test_two['vlan_group']['name'] == "VLAN Group One" - - test_two['vlan_group']['slug'] == "vlan-group-one" - - test_two['vlan_group']['site'] == 1 - - test_two['msg'] == "vlan_group VLAN Group One already exists" - -- name: "VLAN_GROUP 3: ASSERT - Create with same name, different site" - netbox_vlan_group: - netbox_url: http://localhost:32768 - netbox_token: 0123456789abcdef0123456789abcdef01234567 - data: - name: "VLAN Group One" - site: "Test Site2" - state: present - register: test_three - -- name: "VLAN_GROUP 3: ASSERT - Create with same name, different site" - assert: - that: - - test_three is changed - - test_three['vlan_group']['name'] == "VLAN Group One" - - test_three['vlan_group']['slug'] == "vlan-group-one" - - test_three['vlan_group']['site'] == 2 - - test_three['msg'] == "vlan_group VLAN Group One created" - -- name: "VLAN_GROUP 4: ASSERT - Create vlan group, no site" - netbox_vlan_group: - netbox_url: http://localhost:32768 - netbox_token: 0123456789abcdef0123456789abcdef01234567 - data: - name: "VLAN Group One" - state: present - ignore_errors: yes - register: test_four - -- name: "VLAN_GROUP 4: ASSERT - Create with same name, different site" - assert: - that: - - test_four is failed - - test_four['msg'] == "More than one result returned for VLAN Group One" - -- name: "VLAN_GROUP 5: ASSERT - Delete" - netbox_vlan_group: - netbox_url: http://localhost:32768 - netbox_token: 0123456789abcdef0123456789abcdef01234567 - data: - name: VLAN Group One - site: Test Site2 - state: absent - register: test_five - -- name: "VLAN_GROUP 5: ASSERT - Delete" - assert: - that: - - test_five is changed - - test_five['diff']['before']['state'] == "present" - - test_five['diff']['after']['state'] == "absent" - - test_five['vlan_group']['name'] == "VLAN Group One" - - test_five['vlan_group']['slug'] == "vlan-group-one" - - test_five['vlan_group']['site'] == 2 - - test_five['msg'] == "vlan_group VLAN Group One deleted" - -- name: "VLAN_GROUP 6: ASSERT - Delete non existing" - netbox_vlan_group: - netbox_url: http://localhost:32768 - netbox_token: 0123456789abcdef0123456789abcdef01234567 - data: - name: VLAN Group One - site: Test Site2 - state: absent - register: test_six - -- name: "VLAN_GROUP 6: ASSERT - Delete non existing`" - assert: - that: - - not test_six['changed'] - - test_six['vlan_group'] == None - - test_six['msg'] == "vlan_group VLAN Group One already absent" diff --git a/tests/integration/v2.8/tasks/netbox_vrf.yml b/tests/integration/v2.8/tasks/netbox_vrf.yml deleted file mode 100644 index cf75d08be..000000000 --- a/tests/integration/v2.8/tasks/netbox_vrf.yml +++ /dev/null @@ -1,128 +0,0 @@ ---- -## -## -### NETBOX_VRF -## -## -- name: "VRF 1: Necessary info creation" - 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" - 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_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" - 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_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" - 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_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 - tags: - - Schnozzberry - state: present - register: test_four - -- name: "VRF 4: ASSERT - Updated" - 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] == "Schnozzberry" - - 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] == "Schnozzberry" - - test_four['msg'] == "vrf Test VRF One updated" - -- name: "VRF 5: ASSERT - Delete more than one result" - netbox_vrf: - netbox_url: http://localhost:32768 - netbox_token: 0123456789abcdef0123456789abcdef01234567 - data: - name: "Test VRF One" - state: absent - ignore_errors: yes - register: test_five - -- name: "VRF 5: ASSERT - Delete more than one result" - assert: - that: - - test_five is failed - - test_five['msg'] == "More than one result returned for Test VRF One" - -- name: "VRF 6: ASSERT - Delete" - 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" - 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] == "Schnozzberry" - - test_six['msg'] == "vrf Test VRF One deleted" diff --git a/tests/sanity/ignore-2.10.txt b/tests/sanity/ignore-2.10.txt new file mode 100644 index 000000000..16a4c9863 --- /dev/null +++ b/tests/sanity/ignore-2.10.txt @@ -0,0 +1,2 @@ +plugins/modules/netbox_interface.py import-3.8!skip # Module is deprecated, so will not be updated for 2.10 compatibility +plugins/modules/netbox_interface.py validate-modules!skip diff --git a/tests/test_data.py b/tests/test_data.py index 4d082e217..95e6dd34d 100644 --- a/tests/test_data.py +++ b/tests/test_data.py @@ -3,6 +3,10 @@ # 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 diff --git a/tests/unit/inventory/test_nb_inventory.py b/tests/unit/inventory/test_nb_inventory.py index 417585d1b..0009cf385 100644 --- a/tests/unit/inventory/test_nb_inventory.py +++ b/tests/unit/inventory/test_nb_inventory.py @@ -2,6 +2,10 @@ # Copyright: (c) 2020, Hillsong, Douglas Heriot (@DouglasHeriot) # 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 pytest import os from functools import partial diff --git a/tests/unit/module_utils/test_netbox_base_class.py b/tests/unit/module_utils/test_netbox_base_class.py index 3408e06d3..e7dcd3533 100644 --- a/tests/unit/module_utils/test_netbox_base_class.py +++ b/tests/unit/module_utils/test_netbox_base_class.py @@ -3,6 +3,10 @@ # 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 pytest import os from functools import partial