diff options
Diffstat (limited to 'ansible_collections/cisco/mso')
162 files changed, 12973 insertions, 5681 deletions
diff --git a/ansible_collections/cisco/mso/.github/workflows/ansible-test.yml b/ansible_collections/cisco/mso/.github/workflows/ansible-test.yml index 08ed31bba..0696792f8 100644 --- a/ansible_collections/cisco/mso/.github/workflows/ansible-test.yml +++ b/ansible_collections/cisco/mso/.github/workflows/ansible-test.yml @@ -7,7 +7,7 @@ on: # * is a special character in YAML so you have to quote this string - cron: '0 7 * * *' env: - python_version: 3.9 + python_version: '3.10' jobs: build: name: Build collection @@ -15,7 +15,7 @@ jobs: strategy: fail-fast: false matrix: - ansible: [v2.9.27, v2.10.17, v2.11.12, v2.12.10, stable-2.13, stable-2.14] + ansible: [v2.14.13, v2.15.8, v2.16.2, stable-2.16] steps: - name: Check out code uses: actions/checkout@v3 @@ -65,8 +65,8 @@ jobs: with: python-version: ${{ env.python_version }} - - name: Install ansible-base (stable-2.14) - run: pip install https://github.com/ansible/ansible/archive/stable-2.14.tar.gz --disable-pip-version-check + - name: Install ansible-base (v2.15.8) + run: pip install https://github.com/ansible/ansible/archive/v2.15.8.tar.gz --disable-pip-version-check - name: Download migrated collection artifacts uses: actions/download-artifact@v3 @@ -107,7 +107,7 @@ jobs: strategy: fail-fast: false matrix: - ansible: [v2.9.27, v2.10.17, v2.11.12, v2.12.10, stable-2.13, stable-2.14] + ansible: [v2.14.13, v2.15.8, v2.16.2, stable-2.16] steps: - name: Set up Python ${{ env.python_version }} uses: actions/setup-python@v4 @@ -129,6 +129,9 @@ jobs: - name: Install the collection tarball run: ansible-galaxy collection install .cache/collection-tarballs/*.tar.gz + - name: Install the ND collection (NDO dependency) + run: ansible-galaxy collection install cisco.nd + - name: Run sanity tests run: ansible-test sanity --docker -v --color --truncate 0 --coverage working-directory: /home/runner/.ansible/collections/ansible_collections/cisco/mso @@ -149,11 +152,8 @@ jobs: strategy: fail-fast: false matrix: - ansible: [v2.10.17, v2.11.12, v2.12.10, stable-2.13, stable-2.14] - python-version: [3.9] - include: - - ansible: v2.9.27 - python-version: 3.8 + ansible: [v2.14.13, v2.15.8, v2.16.2, stable-2.16] + python-version: ['3.10'] steps: - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v4 @@ -198,8 +198,8 @@ jobs: with: python-version: ${{ env.python_version }} - - name: Install ansible-base (stable-2.13) - run: pip install https://github.com/ansible/ansible/archive/stable-2.13.tar.gz --disable-pip-version-check + - name: Install ansible-base (v2.15.8) + run: pip install https://github.com/ansible/ansible/archive/v2.15.8.tar.gz --disable-pip-version-check - name: Install coverage (v4.5.4) run: pip install coverage==4.5.4 diff --git a/ansible_collections/cisco/mso/.github/workflows/galaxy-importer.cfg b/ansible_collections/cisco/mso/.github/workflows/galaxy-importer.cfg index 631359cf4..7208e7c1e 100644 --- a/ansible_collections/cisco/mso/.github/workflows/galaxy-importer.cfg +++ b/ansible_collections/cisco/mso/.github/workflows/galaxy-importer.cfg @@ -1,6 +1,6 @@ [galaxy-importer] LOG_LEVEL_MAIN = INFO -RUN_FLAKE8 = True +RUN_FLAKE8 = False RUN_ANSIBLE_DOC = True RUN_ANSIBLE_LINT = True RUN_ANSIBLE_TEST = False diff --git a/ansible_collections/cisco/mso/CHANGELOG.rst b/ansible_collections/cisco/mso/CHANGELOG.rst index 56fdfe5ee..689f7dba9 100644 --- a/ansible_collections/cisco/mso/CHANGELOG.rst +++ b/ansible_collections/cisco/mso/CHANGELOG.rst @@ -6,6 +6,37 @@ Cisco MSO Ansible Collection Release Notes This changelog describes changes after version 0.0.4. +v2.6.0 +====== + +Release Summary +--------------- + +Release v2.6.0 of the ``ansible-mso`` collection on 2024-04-06. +This changelog describes all changes made to the modules and plugins included in this collection since v2.5.0. + + +Minor Changes +------------- + +- Add Azure Cloud site support to mso_schema_site_contract_service_graph +- Add Azure Cloud site support to mso_schema_site_service_graph +- Add functionality to resolve same name in remote and local user. +- Add l3out_template and l3out_schema arguments to mso_schema_site_external_epg (#394) +- Add mso_schema_site_contract_service_graph module to manage site contract service graph +- Add mso_schema_site_contract_service_graph_listener module to manage Azure site contract service graph listeners and update other modules +- Add new parameter remote_user to add multiple remote users associated with multiple login domains +- Add support for replacing all existing contracts with new provided contracts in a single operation with one request and adding/removing multiple contracts in multiple operations with a single request in mso_schema_template_anp_epg_contract module +- Add support for replacing all existing static ports with new provided static ports in a single operation with one request and adding/removing multiple static ports in multiple operations with a single request in mso_schema_template_anp_epg_staticport module +- Add support for required attributes introduced in NDO 4.2 for mso_schema_site_anp_epg_domain +- Support for creation of schemas without templates with the mso_schema module + +Bugfixes +-------- + +- Fix TypeError for iteration on NoneType in mso_schema_template +- Fixed the useg_subnet logic in mso_schema_template_anp_epg_useg_attribute + v2.5.0 ====== diff --git a/ansible_collections/cisco/mso/FILES.json b/ansible_collections/cisco/mso/FILES.json index b721a6242..e842a93b4 100644 --- a/ansible_collections/cisco/mso/FILES.json +++ b/ansible_collections/cisco/mso/FILES.json @@ -88,21 +88,21 @@ "name": "plugins/module_utils/mso.py", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "365ed0c9e88643e9282f6ed37ecb70438c0a8a8bca6140c23d394c57e40cd8e9", + "chksum_sha256": "efdfdb481900e55e4e343ebc46d9959b307d188bc7331bbe2f5ffc34f334314b", "format": 1 }, { "name": "plugins/module_utils/constants.py", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "2f1ef5582a8aadb1f63c9764a1569c37f35c4f3771362645e2c1d37893ad0b58", + "chksum_sha256": "b17782b7585f2093de4cd7bed8ce8ecc0ece53418ac229eec7bdf9e6133fa903", "format": 1 }, { "name": "plugins/module_utils/schema.py", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "666a8b807cc281fb6b20571e8181356150b540b310538dae977fb34c98b065f2", + "chksum_sha256": "e28a7319c7a1620ab5d49b24399439b2e5925fd5676b382214d1ef36f4d80637", "format": 1 }, { @@ -116,476 +116,490 @@ "name": "plugins/modules/mso_schema_template_contract_filter.py", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "6f1cd0ad89ea16105dedec1ee73865c3039c0d440f51835c01bea909088200e1", + "chksum_sha256": "529de4ee2f32adab3f4de2228c79c6ebaf555d2f37e4e6fb2373afb50369c583", "format": 1 }, { "name": "plugins/modules/mso_schema_template_anp_epg_useg_attribute.py", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "8ed6ceddad626de74e9a017e479c2a9668c8e460c705611958b0e810ea03654f", + "chksum_sha256": "b072d717a7c11f9144338428cc6b0298a62eb25d5204c3997c0021ff6156661d", "format": 1 }, { "name": "plugins/modules/mso_schema_site_anp_epg_staticport.py", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "24c0bbb68eddf4b2dbd1920ad0dbb8f487318ed2897467c4b357878ba4a27313", + "chksum_sha256": "d426b1f4358a4a15936cdae01a5642a24471b0c352dbc36c0e5d2ae517620bc8", "format": 1 }, { "name": "plugins/modules/mso_schema_site_anp.py", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "53b683bfe3797188a7114b2f7fd32c80f20c82ab75af2cbb52c65ef86ab34b6c", + "chksum_sha256": "c84cdd70071fb6d1b9fcc031ea40d0123acc96e317f65e240b02d747b169ac14", "format": 1 }, { "name": "plugins/modules/mso_dhcp_option_policy_option.py", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "1d2486a946afc26f3bb7b7a8797670747848c844b9109f1782564a2ded687a1a", + "chksum_sha256": "eda5f9f0fc62e4bd96240718661c418432d06c8779b7beeabe2c08e91f4682c8", "format": 1 }, { "name": "plugins/modules/mso_schema_site_vrf_region_hub_network.py", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "7a43523bd0dc4cfffe22440d971b3f89e85d2d9e0a50aeb39389c3c2830c4bd9", + "chksum_sha256": "0e46ba971fc360ce3aac486f5052d9114b370550a9696789e4abf8490db597d9", "format": 1 }, { "name": "plugins/modules/mso_schema_template_clone.py", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "467bbd942d0e26497d51bb70c33338eb07079e4743700c1c256e7e2e4c5aa4ca", + "chksum_sha256": "fd6f1dd1edaf676366762f1d11c8d9d12cd3135f2175c28ebe126c1c815195ee", "format": 1 }, { "name": "plugins/modules/mso_schema_site_external_epg_selector.py", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "4363f0f76203e827914ee92e71976ddd77281b00a132e0ac3ead2b92afd00674", + "chksum_sha256": "710a8ea56534dfc6543988d277d0437a440fb2a941fd0d4c5f74ab08ae95be61", "format": 1 }, { "name": "plugins/modules/mso_schema_site_anp_epg.py", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "5b0ee7e4bcb554da6cd227ebb70187b63d1bcccd68b1dcd7bc7e18c785b942b5", + "chksum_sha256": "f6d7cc46a952c866b799726f06715fa28636628c6d30c7f257cca90e3d7a413a", "format": 1 }, { "name": "plugins/modules/mso_schema_site_bd_subnet.py", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "548b14f399f547ccfefc18346676a0e24cce3a7826557e8988d6a392813b138f", + "chksum_sha256": "c188f403fd34b45bc3fa87a4f52454f5c363b9e9e421549fa39c5c90d7666109", "format": 1 }, { "name": "plugins/modules/mso_schema_template_anp.py", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "563af9420bd43908af689c4f8931a4ea5ce461008e08d45ac0ba1578d398388a", + "chksum_sha256": "b879cf3ed34dfdf45150bae5b96f94bd93846cc8ca414433c88b4e34503ba817", "format": 1 }, { "name": "plugins/modules/mso_schema_template_bd_subnet.py", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "a57db7b1e169ac4cd985f8c754ccf15df5654b7527cc5234b3980fcd83ab3ec9", + "chksum_sha256": "f47b8cf5a99acd4c7d3db34263795304c160dc7afa7f537b02cdad0b2e1653ec", "format": 1 }, { "name": "plugins/modules/mso_schema_site_service_graph.py", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "f61b1039f2822f8e5bc0d520e429821f67b220847a66553d7a2424680ff89c7e", + "chksum_sha256": "ec3b6d065bdd34f47f246bdd40edbebe1769f1115582bb85c637119d70fcc22a", "format": 1 }, { "name": "plugins/modules/mso_schema_template_deploy.py", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "4675f4f2242f139b0198e240e39bc0033d7807dcde46b4e5fe5cce4ab00f7a43", + "chksum_sha256": "9c30233ef80f83701478bfd2eab63858b92b27e24266428b2cc32b82fd7a515b", "format": 1 }, { "name": "plugins/modules/mso_tenant.py", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "f6cfabf979e75755aba9b5de7485a55512bb02d1083d7c0afa97aadf6bfde44b", + "chksum_sha256": "ddfd5dcc9a0e553e02dc97a7aedd16c990354064af942483064c8edd76ca9eb8", "format": 1 }, { "name": "plugins/modules/mso_schema_site_vrf_region_cidr_subnet.py", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "bb9d0be9896f46fa894f4ee2242683cba38141c1ad826aa7fc9720b4a752143b", + "chksum_sha256": "99317cd35700317aa573606354f2e76e980ee1a68c02cd890ee539c19e849e18", "format": 1 }, { "name": "plugins/modules/mso_schema_site_vrf.py", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "cfc09a18b5f1ddb2598e9bb69241f35b4c3a967f84f529266ce8b610400f3939", + "chksum_sha256": "8ba10a75ea0fe7dfad2666a8a2fe33e61c8a66a6164245d480be99d38cebeeec", "format": 1 }, { "name": "plugins/modules/mso_schema_site_anp_epg_staticleaf.py", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "517fe0774f3853668ba3fa20a27db581974292e6a068eeaeba266fd13e7a2130", + "chksum_sha256": "c13a222b63c1b22f2347e563a79462d484746ea729649fb826b5c9cdb66e95fa", "format": 1 }, { "name": "plugins/modules/mso_schema_template_contract_service_graph.py", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "d5f117924e42571f83fb0fd7e3006938d6c7a03535c2b9b1d0e8fef1187e9d43", + "chksum_sha256": "bd18ce347bdc3b3b6f50be09b814515fcd954d3b604e06e1a6e6da0dbf15d835", "format": 1 }, { "name": "plugins/modules/mso_schema_template_external_epg_contract.py", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "1f977a4e86c0133551d4885a8f2e738be26ff169f84bf6e75eda627e2237e8ef", + "chksum_sha256": "0f114737538989c09d92a90a7fa080e9132b03510b0cb3c54b011208dd7005ac", "format": 1 }, { "name": "plugins/modules/mso_schema_template_external_epg.py", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "cca13445dac9275a27359ba8f7904208056934c22019553342a5bd81a5927541", + "chksum_sha256": "1bf80882445fbc6d3831bca7dcb7932f36bc228d96a1f07fe137a7fb816bc4a5", "format": 1 }, { "name": "plugins/modules/mso_schema_template_bd_dhcp_policy.py", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "ccc7584c47937ca7a2759f4bd83766d0589d5ecbf83fa2beb75683719e739458", + "chksum_sha256": "a345743ad69de49554b9d0b3d615a2f77818e666e6305196b54a1c08c937d8d5", "format": 1 }, { "name": "plugins/modules/mso_schema_site_vrf_region_cidr.py", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "537ea2679378ebab08599813a7e89de4866baed013c8816499f081b440b80c8b", + "chksum_sha256": "57dc635bc10d4adc1060b779b7bc0f754f43119e78479049f455f12f56c8d4dd", "format": 1 }, { "name": "plugins/modules/mso_schema_template_anp_epg.py", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "fbd12de54e5336dc265f43bf76c59215d9583c8e09d590ccfd63acd5e346f543", + "chksum_sha256": "d6af8d36a24da44c06da51d5e425733dd27908bcf35fc19184578f2301a50015", "format": 1 }, { "name": "plugins/modules/mso_schema_template_anp_epg_contract.py", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "dac857729a99d0a1d6d778c94565ac54def3c1a548d949643288f3ae0d7ff047", + "chksum_sha256": "36b5e8d57b9c7cb39227a38b15f3ff28efe3219376d088571fc35c838f39989d", "format": 1 }, { "name": "plugins/modules/mso_dhcp_relay_policy_provider.py", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "39748852f207b8d1a2f0572c8204326bc70c16799e6d414c44d70562781d76f1", + "chksum_sha256": "ac154937e7da1fe34cf9d6b455a71fab03007cd90138b0a58b04bdcdca32a04d", "format": 1 }, { "name": "plugins/modules/mso_tenant_site.py", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "30b1ce3e3c94d3b6fb9c8de815b1b02eef9d2ef1b2add0d26057802a5d211f64", + "chksum_sha256": "4b05c8f8d0708d4df336e35ee21538426502acaa0c1ae5e06c9353864cd39462", "format": 1 }, { "name": "plugins/modules/mso_backup.py", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "023cdd8db111487656d214b5664691b2524b93b8792f6833cd6e44ff24d33775", + "chksum_sha256": "1f95a32e7b4b2ae490378510c0b54404b73eee95de3f91781f22e91a543c357b", "format": 1 }, { "name": "plugins/modules/mso_site.py", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "2dc848085c68033f3b8ef93d4c82e7a4791074736507c69b5b7e630108e1494e", + "chksum_sha256": "9d4f94940cf21a0b359e4f4911fcadfa94effe6bfa076f50dd18a5f4d153d49d", "format": 1 }, { "name": "plugins/modules/mso_remote_location.py", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "fbc21ccb26b9b6a4a206b218c24d05996917ad200160195ac5a3bd23ce2b10fa", + "chksum_sha256": "926198de94a92a491d433fb8fd784e6a23f7c879e93bd87dbaa9a550be358ddc", "format": 1 }, { "name": "plugins/modules/mso_schema_site_anp_epg_selector.py", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "f759e142e699d3013a1a625563a0bf561ac7b1a78e6a0fb511ac952a68ef7ce0", + "chksum_sha256": "894a28da428a3556e45cc21a2a485a9c64707a3dd4783ae3acc1620f9942101a", "format": 1 }, { "name": "plugins/modules/mso_schema_template_vrf.py", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "92bf0092c6f6e72ef1d5748b2316c368b99839ab172caea71668fa44ea2a08c8", + "chksum_sha256": "6869be92ec1ca7893432bf677004c4260290ac34105fe610f959ca95b48f0abd", "format": 1 }, { "name": "plugins/modules/mso_schema_clone.py", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "d72660f2a0bb86fd807259b2f4046ea75bc7775abd2659a1ad4301bbce3b5de4", + "chksum_sha256": "a530da97206a358b2413103b42a7a6cd39e84a3b1c2e40368b6d13f4bd276ab2", "format": 1 }, { "name": "plugins/modules/mso_schema_site_anp_epg_useg_attribute.py", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "e6cd229643ea78515528641359ee0dea24bbff6a6a7f76fe23f81c9abc02c430", + "chksum_sha256": "7130a3af0e55ab119c7312de18a10bbd519105f36e4861fdb84cc6ad657e6bf1", "format": 1 }, { "name": "plugins/modules/mso_schema_site_external_epg.py", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "1c42b50d3217281fab3bdbdb63831973ffa0abb7b427059338b24ec9ead91111", + "chksum_sha256": "4bfc2da7b937871cdae2e7e5eda88651f1e67d4a3d4b69bb18b1158a3b3608aa", "format": 1 }, { "name": "plugins/modules/mso_schema_site_anp_epg_bulk_staticport.py", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "7fa1e1ba14119d99731281f5edb1c29e9a00ce8e9e68dc885c14f057e8611a5a", + "chksum_sha256": "45fda87759808362dfb03728aff531cf4f028762e7d92c67db48e4722d552c37", "format": 1 }, { "name": "plugins/modules/mso_schema.py", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "eb277796d3882cd5af04d61252d31d73bd6bcbbe37bd378169fb7e9b9ca17a1d", + "chksum_sha256": "1a8188eb77d54445999a9aaa8d7a7e1eebb6292f8343f0087c11fd0b2d8cc25a", "format": 1 }, { "name": "plugins/modules/mso_service_node_type.py", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "f8b2c340e2a19be2b2a3993555500a8a07254a4fd6bbd424f787c59e50ddadd3", + "chksum_sha256": "b4b4e9dfd8a3cd89b293a58b2ce9de07ab8c65697b78e629167b4a41b521f513", "format": 1 }, { "name": "plugins/modules/mso_schema_site_bd_l3out.py", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "a673bd1f3b2be1b8e290b0aca6b71b784ee6dcbc3b7c83e6688a69b374ac3859", + "chksum_sha256": "0d35a6caae8642331852296992e6ed56d20e7928b3413734b305b2eb2d166ba9", "format": 1 }, { "name": "plugins/modules/mso_schema_site_anp_epg_domain.py", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "eea4baa850dee443f4763f8821171b7a9018ad32863fcc9419c711b794cbaeaf", + "chksum_sha256": "833dbacd5ea2b4222042ce18026a3b9e9e4cc2cbc68dd264686a9c9059211ab3", "format": 1 }, { "name": "plugins/modules/mso_role.py", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "676bb9102ab59c395bc74b1e7ae88188ec2d759d243b563dc6f7c40e7954fcc5", + "chksum_sha256": "358b270cd1c7990681926fc112f315c8bc8720ce0c3a26a5d24b70eeac3ed4bb", "format": 1 }, { "name": "plugins/modules/mso_schema_template_externalepg.py", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "cca13445dac9275a27359ba8f7904208056934c22019553342a5bd81a5927541", + "chksum_sha256": "1bf80882445fbc6d3831bca7dcb7932f36bc228d96a1f07fe137a7fb816bc4a5", "format": 1 }, { "name": "plugins/modules/mso_schema_template_external_epg_subnet.py", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "ce326dbc4882ff9fb12721721c84184dfee85c35a31f88eed7ea4f1ee15ce95f", + "chksum_sha256": "284f870b6411c6b74636ebc207c04fa11ef1e5b969436dd006634a72befeaca2", "format": 1 }, { "name": "plugins/modules/mso_schema_template_filter_entry.py", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "0bcd5ec3532d03574c2116dd8235fb60fa23aa60212a8f2d1d8fb8cf54ae66f1", + "chksum_sha256": "7b0ac723395463cad198f322ab087095e4cafec8b1d3e7ccf32e58713b6527f6", "format": 1 }, { "name": "plugins/modules/mso_schema_template_service_graph.py", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "1758c7b2153df304380c61c29c5861e83e6dbabc447bb738c474755128bc4c78", + "chksum_sha256": "e220243eb8c8e40767439e1e2bb003ecc36ccdafa2d4b2d73d43600c4ffa10fc", "format": 1 }, { "name": "plugins/modules/mso_schema_site_bd.py", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "efa09b8140a5e1deb8ad7ee81e32d610b75475bdb510d3118cac7928443b7700", + "chksum_sha256": "a51c3e49422be56b26dc10e6a0c509470f60e5a35c9132674d40e384488082c0", "format": 1 }, { "name": "plugins/modules/mso_schema_site_anp_epg_subnet.py", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "9a255127f9740b65860e5106edb61c5265c31e841d104328324bffb109116450", + "chksum_sha256": "f9d6358f5afebbbfa87cbc90a3dfadc95086a46107b05dc6d7498d0a8d7d6188", "format": 1 }, { "name": "plugins/modules/mso_rest.py", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "716c55c4720e7717076cd4c94d6fd14696ff7bbc95f8e4638be9b6cd43eacf94", + "chksum_sha256": "a82ada771919fc6f779c93c58a1e2db2b25f057b9b2a6c9e89a7668125298c83", "format": 1 }, { "name": "plugins/modules/mso_schema_template_vrf_contract.py", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "c4c30b7dbc29b7b17217bab52b48d9f2763266ee64f059dc91a193b7f713fb24", + "chksum_sha256": "40dfe9ede10d01034136f30593fb9a9cc53cd1a8cbbf00860e3ef628f2e1a45f", + "format": 1 + }, + { + "name": "plugins/modules/mso_schema_site_contract_service_graph.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "8a2ba79b3a21a299b96b1b10a68b8e0644f9da23a630133ab7296b800003d705", "format": 1 }, { "name": "plugins/modules/mso_schema_validate.py", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "b09b020a522340cefe979ae6d7dde26c16d57723f9c4d98568791d1bbd1009e1", + "chksum_sha256": "e0cf62641c2bfbbb6c145d2de5ab5bd25aae9452c54ccb403596d5a8b3dbbc65", "format": 1 }, { "name": "plugins/modules/mso_label.py", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "91f3e18abb64d487e24698602aa2c8122275077b76f7ce3e44c9c72615769a6b", + "chksum_sha256": "081146778e14fd64b318da7304dc6ecfe8c5c6c4bfc796c66d46cdd616ba3a0b", "format": 1 }, { "name": "plugins/modules/mso_schema_site_vrf_region.py", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "9d1d6ac938b724f90bee0389ba5449bd39009470c2470b491cbb9c6fa9476f7e", + "chksum_sha256": "8835271f837f8d881da42f73d0626f172aec10307cc162edb2c4521cc8a0bd89", "format": 1 }, { "name": "plugins/modules/ndo_schema_template_deploy.py", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "245a3f6f5127f6bce09cf8be06aa8705c70f03b9cc09d9a068053a34a9ffae36", + "chksum_sha256": "a01d099cb2fb19db139901feff0c1e163bb2c95743fec2cef73472e7bdccc1b0", "format": 1 }, { "name": "plugins/modules/mso_schema_template_external_epg_selector.py", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "c3c4b25e653b0ffe17b3855a110ff5183b45a7c131deeb720e37bf0e3999512d", + "chksum_sha256": "816002cb3c41dadf1f71ef97e1a7e1184898411ff6e1e070ebafda0e2e55ad33", "format": 1 }, { "name": "plugins/modules/mso_schema_template_migrate.py", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "1e02912efe8eb9f53827a2843d0ab91aecfc57d5d11fb2b2b535d593fc0b1874", + "chksum_sha256": "bb665ec1b8c18427bd32d42739a1895e0587a57e23ff3bc5e3702b2ab80d5fe3", "format": 1 }, { "name": "plugins/modules/mso_version.py", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "1a91a748dc001172e3a0c485848fa0fdd41831b79a0f0862a55625c9c6d78133", + "chksum_sha256": "31a5b738343e42b1b01cabad5eaebbed9c59a34b6bd0da4eb861c156b7ecd301", "format": 1 }, { "name": "plugins/modules/mso_schema_template_l3out.py", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "4e0bb66ebb85fd043104a8cbd14338e3014d16ba49a349eb39a4eacf6319ea21", + "chksum_sha256": "d558b5f03388d5aed0a27029cac2ed3c8e47677e42ba8c62704b591df139ebf8", "format": 1 }, { "name": "plugins/modules/mso_dhcp_relay_policy.py", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "3eb53debf9a3c8ee3bfed778e538a73e03dac02371f77ad8046e9be200f04806", + "chksum_sha256": "f32a44b801b801120b948cb00b7217ae8ca055f79b319a595d8e98d76060dbfd", + "format": 1 + }, + { + "name": "plugins/modules/mso_schema_site_contract_service_graph_listener.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "44a8c1c8db5aef031e9d37135b3812c5228ed36d0da87f2b596481f3f5aa878e", "format": 1 }, { "name": "plugins/modules/mso_schema_template_anp_epg_subnet.py", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "6d3eb9cfffe291d742bd95c98e2222696b47b9532de5960d405390823f4195c6", + "chksum_sha256": "3015e6e746164b203532a58eeaf68ea796b78d5c270799d36a2c4ed595a8bccc", "format": 1 }, { "name": "plugins/modules/mso_schema_template_deploy_status.py", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "c9017bda8f5590b60047f9654db54e4608064f97abf2cbae45ce455e2cde815f", + "chksum_sha256": "0c19b16a14e60c56623b5601791545b34e603446ac6479a228ea6736fbf9c332", "format": 1 }, { "name": "plugins/modules/mso_dhcp_option_policy.py", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "80d5de0dec0b967c33be6f0a882ed477d774e38823f082ed928bd99acbda77e0", + "chksum_sha256": "ae6db0609d70bf161d7d480cea09d938657cd6be9cb66a39a3fc01e012002dd0", "format": 1 }, { "name": "plugins/modules/mso_schema_template_anp_epg_selector.py", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "3fd399a8567a0f217d09cd52bc98233bc66d8f95198cce9d3dca1d3c9605e2d3", + "chksum_sha256": "983751917e08ec653d1432d701e90decdced6948c419cbb72d9720dfdc2bca9d", "format": 1 }, { "name": "plugins/modules/mso_user.py", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "5a1253f212aaef3c7f1f0a6f0d782db05d56b5943a71a3ef22f170d2b180436a", + "chksum_sha256": "c02cdf0bf73ef68f147964c0cbe229691cab43ff7a99004efb731ee44b540b30", "format": 1 }, { "name": "plugins/modules/mso_backup_schedule.py", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "ffcb686b57665f77ba98e5c9da90371bd375651ee14a872946a6ef410795d028", + "chksum_sha256": "e55a6680185af141d01540448fb0ecfac8f231a0620fa15ff22a6171eae8215b", "format": 1 }, { "name": "plugins/modules/mso_schema_template_bd.py", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "bea197a237bc35514301873858b1b089474b68859e73755c97fbeef8bd9cf022", + "chksum_sha256": "8325e223822e77be1ff4ecf1e76cf25651e34d8564fce45ccc0378b48d64b1dc", "format": 1 }, { "name": "plugins/modules/mso_schema_site_l3out.py", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "640901827b0efe076fc738afbb8909d60bfbbfd23ee11116f397a80ef2567e1a", + "chksum_sha256": "f4d248f321c95e99f1628c74264e7a254da2d4fb3d1a1a034f67f38d57c8de02", "format": 1 }, { "name": "plugins/modules/mso_schema_site.py", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "a06f86812347eaddbc5b39836e8cc96703e4207a327673876883550b8109277a", + "chksum_sha256": "f8faf0cb27c969b2b01207ac10f42b229074b1182877b85e3c36aba061a412ba", "format": 1 }, { "name": "plugins/modules/mso_schema_template.py", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "fd7d0b52e775c6607e2c2da18e655f9ae5f760b616f51629f3dda9dcc95bebb5", + "chksum_sha256": "5e2519bfffae43c962927493346ee03efa3871319d3efa75d404e1e0545a9ec9", "format": 1 }, { @@ -634,7 +648,7 @@ "name": "tests/integration/targets/mso_dhcp_relay_policy/tasks/main.yaml", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "d9ef7c98101c518cc0689cd0c3052c7a965924473d468d9f28cf94616035f9f3", + "chksum_sha256": "85f785b8f6b63231054901880ced3d8ec969fdb7ff72b7d64ff211b206da9946", "format": 1 }, { @@ -662,7 +676,14 @@ "name": "tests/integration/targets/mso_schema_site_service_graph/tasks/main.yml", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "827c0652a8363fa1585bc3087517cdcc9622f62d6937cc8e4325162c8d1f977b", + "chksum_sha256": "41cd65e6f3afec3bc923411ee09e65cae143297e40031fd69231c850424600d4", + "format": 1 + }, + { + "name": "tests/integration/targets/mso_schema_site_service_graph/tasks/l4_l7_devices.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "65f5132f51c9db35a1eacf4882ef937b3876178ac3b8786d6d689e8b8cb9f2a7", "format": 1 }, { @@ -690,7 +711,7 @@ "name": "tests/integration/targets/mso_schema_template_deploy/tasks/main.yml", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "0c70364503504b44437583c853a4dd70dfb8ed09c3dcb60d254790cefbb0a6c5", + "chksum_sha256": "789b506894b3bfe0a2131f1d1ae4420732087cf71faf8c9d04a5ce395fc297d8", "format": 1 }, { @@ -729,6 +750,55 @@ "format": 1 }, { + "name": "tests/integration/targets/mso_schema_site_contract_service_graph_listener", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/mso_schema_site_contract_service_graph_listener/tasks", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/mso_schema_site_contract_service_graph_listener/tasks/main.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "1a65f7665e110ee1ec5eb08742616c82786dd4ac28772447af9498c3b38d3259", + "format": 1 + }, + { + "name": "tests/integration/targets/mso_schema_site_contract_service_graph_listener/tasks/l4_l7_devices.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "71472aecc4c6421c5cd7411003f4859eac5cbcd1922c55be179f7b55f4356723", + "format": 1 + }, + { + "name": "tests/integration/targets/mso_schema_site_contract_service_graph_listener/tasks/pki", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/mso_schema_site_contract_service_graph_listener/tasks/pki/admin.crt", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "9d690f11eea29ff905c65d4457fcff73fe9eda30f733af7ae91a6ec545e2239d", + "format": 1 + }, + { + "name": "tests/integration/targets/mso_schema_site_contract_service_graph_listener/aliases", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "4e674607496d01ce032bfdbcc3e77ecdcde02f3e9d57080a95682a0cdff6809a", + "format": 1 + }, + { "name": "tests/integration/targets/mso_schema_site_vrf_region_cidr_subnet", "ftype": "dir", "chksum_type": null, @@ -746,7 +816,7 @@ "name": "tests/integration/targets/mso_schema_site_vrf_region_cidr_subnet/tasks/main.yml", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "95b8ad80d173f5a830b41a0b4c6cdb523a89dadc12413e4d4f4f956a82244c04", + "chksum_sha256": "9e5f21f4b103f0c9e1dd0bbf9dc99e6f54ad6f565e01fdc87f49b27f365dceb9", "format": 1 }, { @@ -774,7 +844,7 @@ "name": "tests/integration/targets/mso_schema_template/tasks/main.yml", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "69e1eb1e15a1af3fe9e08e301c4173e32f26592337ec169896a202e914747440", + "chksum_sha256": "c829d6782b2a3b5be8cfff70e8833555bf79c199026c342966df5c9986f7692c", "format": 1 }, { @@ -802,7 +872,7 @@ "name": "tests/integration/targets/mso_rest/tasks/json_template.yml", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "8cc983a7d84493d9f41cbe38b197727174afec4426f78c376bce540a4b4a4fec", + "chksum_sha256": "fdb29819b5ad2c704e3f93c1f6939f2fd4031932eaa71803e441179eae80accc", "format": 1 }, { @@ -816,42 +886,42 @@ "name": "tests/integration/targets/mso_rest/tasks/json_inline.yml", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "79a502e927c89c5968a435bf2c2418ab416cfa47a6b41d48079eef0c36149f29", + "chksum_sha256": "32591469bda7ecedac44b748673e3fa362cd092db6320500e69f033d83d0e763", "format": 1 }, { "name": "tests/integration/targets/mso_rest/tasks/json_string.yml", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "db213807aee3f02d301fea223f60d9e54dff6ad8ea8bdf787d20c03bf7ca98c9", + "chksum_sha256": "a91f997e0bda9a22e4c7f48c86534e75d1a4d339660506cca21d7aebbeecc66b", "format": 1 }, { "name": "tests/integration/targets/mso_rest/tasks/yaml_inline.yml", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "d3b9e0b8414481027b4b3fc2ac7b06002e835bd1af89a05a2d7800007b12af87", + "chksum_sha256": "fb74400224c7afb47ead1d5d9c50c0d120274c1a4a8d5dda57eb9ac7e018c227", "format": 1 }, { "name": "tests/integration/targets/mso_rest/tasks/yaml_string.yml", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "de348a80485987b8ccd22ced6deb28150d79e81947929908a395fd8019fab605", + "chksum_sha256": "e95a64f1d09d5456b7ddecc958654473ed9ae2fa6a336a692d82474c385ec554", "format": 1 }, { "name": "tests/integration/targets/mso_rest/tasks/main.yml", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "52f1fb7f60fafa3735b17352ca4e1da195810b0edf3f2680738092e4d52fb1b1", + "chksum_sha256": "744643738a57bf2c1a361be092101d1566c91dba7e936168f98731fa4c33abd6", "format": 1 }, { "name": "tests/integration/targets/mso_rest/tasks/error_handling.yml", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "833535c5837bd384a895d6741629bae58d64af7b2b8f5af78d288ca9ad601947", + "chksum_sha256": "ba05804b3cc1a2444507235a47be5397f079fc4c9f600aec06d60e22c7df29d8", "format": 1 }, { @@ -879,7 +949,7 @@ "name": "tests/integration/targets/mso_remote_location/tasks/main.yml", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "38221f3e70c4a94b31aa03a33e8da81ad05164ba82afbf2ecdb6c3e77fd3977f", + "chksum_sha256": "498c8d1960ddb796e2db681e180bcbbee04f0742c7c70e860de659f6979a959c", "format": 1 }, { @@ -942,7 +1012,7 @@ "name": "tests/integration/targets/mso_schema_template_external_epg_subnet/tasks/main.yml", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "5836b610052cfbdc33f4603cac14419dd92c3c64f3c56f17d557f89198055ccb", + "chksum_sha256": "1bc14f5f921716518b103f4580b5ebe0cd56f2e450e7ef4cd439be5872d813e0", "format": 1 }, { @@ -970,7 +1040,7 @@ "name": "tests/integration/targets/mso_schema_site/tasks/main.yml", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "fe21b23b905888b210fb78e8102768cdb990ab083ff7de03e6c6ef519e947c59", + "chksum_sha256": "8580f8a7b0ac76035d2bbce994214a23cbeb7c1eca01e0a22c226f0e09764622", "format": 1 }, { @@ -998,7 +1068,7 @@ "name": "tests/integration/targets/mso_schema/tasks/main.yml", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "c1312bf7a3945d1864d7a94e5a5224ebdfcad2076570a76f32a211f351aae11f", + "chksum_sha256": "09c5abd625918899f197862d96e7ef2bc4b0fcdf56cd12520be3628979d883e4", "format": 1 }, { @@ -1026,7 +1096,7 @@ "name": "tests/integration/targets/mso_schema_template_migrate/tasks/main.yml", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "071adadb5df6a35002c55292ca8c7435e5893be90318e66f3defe6b124345cde", + "chksum_sha256": "8fbbd33d4126f435b1acf37ea292e7b6a2100e1d50e9cf148363b438a550176c", "format": 1 }, { @@ -1054,7 +1124,7 @@ "name": "tests/integration/targets/mso_schema_template_l3out/tasks/main.yml", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "c254fa26dea680790cff05b10a996729ab1d4ae6d58a22f9e0870ded774c0ad1", + "chksum_sha256": "7b95b029ed47a194421d7e15e1acbcd410c94a4e49024d9c66ef024a3bc72d81", "format": 1 }, { @@ -1082,7 +1152,7 @@ "name": "tests/integration/targets/mso_schema_template_anp/tasks/main.yml", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "39d7a4e61d89fcf18b1dc760e208d6f2e7293987033a87432f380c7497dcc92a", + "chksum_sha256": "6123445aaf9ec2240832d300da52c1c7d659653b8677a3f77b96cc6a21b3ceb9", "format": 1 }, { @@ -1110,7 +1180,7 @@ "name": "tests/integration/targets/ndo_schema_template_deploy/tasks/main.yml", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "d9dc44d7e2603c394f4d0d28305b233bc2b00b0f3bc6d21f79d8f59914acc053", + "chksum_sha256": "cc3b4c4a0d5025a1876562002fcda8790a15797dfb6a350f8afd68371215160b", "format": 1 }, { @@ -1138,7 +1208,7 @@ "name": "tests/integration/targets/mso_schema_site_anp_epg_selector/tasks/main.yml", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "8eaa3bd0ba02460cf49baad9c987294915aeb9dd70086caf5a5d742ef2e450f0", + "chksum_sha256": "2cea815660e1466bd00c33b4cf7a936f2ac0cb086c589d43e32b1ee68efd9d44", "format": 1 }, { @@ -1166,7 +1236,7 @@ "name": "tests/integration/targets/mso_schema_template_external_epg_selector/tasks/main.yml", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "2270c9de7e7ccae07b323d7f4fa7779faa468a8bdabcf7318746dd8966a67e0e", + "chksum_sha256": "9e63408ec28fee5139cfc92e95275057e97544c1456a2e5eb04c097a8143dedb", "format": 1 }, { @@ -1194,7 +1264,7 @@ "name": "tests/integration/targets/mso_schema_clone/tasks/main.yml", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "514d4e40cfb3e4dcff5bbfb105cefd20fbaeb0ea0620450eff89ac48311486d7", + "chksum_sha256": "8776594057c0d09a20c4767d406a00fb93ca52a7e6892b7d75c93cd479b56683", "format": 1 }, { @@ -1222,7 +1292,7 @@ "name": "tests/integration/targets/mso_schema_template_contract_service_graph/tasks/main.yml", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "578c3318a14ef60ec71adaadcb725f767b60ab223d177aa19965ed1421b08799", + "chksum_sha256": "500b0a0044fbf00e9037396d503576a0b83a709c761ae3a731bb4d11ac6c826d", "format": 1 }, { @@ -1250,7 +1320,7 @@ "name": "tests/integration/targets/mso_schema_template_external_epg_contract/tasks/main.yml", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "82a0285141349272dba64176a122887414245415ba23ce9e7edb68f2f24a5768", + "chksum_sha256": "b1c38ed9c13368747f30aff25ebc6cad40aefc7d7566598b60ff1b8283c99bfd", "format": 1 }, { @@ -1278,7 +1348,7 @@ "name": "tests/integration/targets/mso_schema_site_vrf_region/tasks/main.yml", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "77efce495c27cf34aee29ad0d23857ee75862a8285cf28c7d2e36b1f7d5a21e5", + "chksum_sha256": "38ab5a7886ac80a23976f9628b0f969e8fa466492b14425015fcca62690fb543", "format": 1 }, { @@ -1306,7 +1376,7 @@ "name": "tests/integration/targets/mso_schema_template_contract_filter/tasks/main.yml", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "3f2ee3ce9770c0a1e82f0359641f889c34e21f1a1a357256818762ff7c34baf4", + "chksum_sha256": "22decfbc1454f009b51756faf9c3f40f1a7cd91cb679cfc627d9e216d5435da6", "format": 1 }, { @@ -1334,7 +1404,7 @@ "name": "tests/integration/targets/mso_dhcp_option_policy_option/tasks/main.yaml", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "51f135acdfc12bd620051460c18d84c139adeca91bcfbf53e44ed5c1a3879213", + "chksum_sha256": "dc327b7dadc2b48ade2464c00cf84e699ad01706fc05ce8a8d49bf199fe985de", "format": 1 }, { @@ -1362,7 +1432,7 @@ "name": "tests/integration/targets/mso_schema_site_external_epg_selector/tasks/main.yml", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "e493d7a02b30e3933cdde6112452b3d8848718fd7cdbad91c02cf9ead974824c", + "chksum_sha256": "6916e1c25af21ecbb1cfef365adc46bd67e003bc2a12784192e8525e7d46c3bc", "format": 1 }, { @@ -1390,7 +1460,7 @@ "name": "tests/integration/targets/mso_backup_schedule/tasks/main.yml", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "07a0e9ba07f2daa25c9fba4c9ea0ddf30f8a7c8742d23db43c606d418502fcdd", + "chksum_sha256": "66b6797b624c845d57b58a072c4f2136c074dcde22f963fc45ef886ea4abea19", "format": 1 }, { @@ -1418,7 +1488,7 @@ "name": "tests/integration/targets/mso_schema_site_anp_epg/tasks/main.yml", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "9d33506200b0c453f2d6d810772e4d4df6f4bf2cafa60728196bf2e0f69e6229", + "chksum_sha256": "2152f5760e632679d7f3950ac0d0c08087d54e97789882a6c9eaaf79c98fb966", "format": 1 }, { @@ -1446,7 +1516,7 @@ "name": "tests/integration/targets/mso_schema_template_bd/tasks/main.yml", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "333679f0f0e047c4923b582594ef248ade0ea86781386548e12fecbb3abe071c", + "chksum_sha256": "3e2a080b664193f72346098ac18120d6ca516241f9cb69b1c1015e3c9053332d", "format": 1 }, { @@ -1474,7 +1544,7 @@ "name": "tests/integration/targets/mso_schema_site_bd/tasks/main.yml", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "6901d10171226d330516388d635afe119a679289eef9ef4035ac4de6353c3b94", + "chksum_sha256": "b6d924f071e652f1e06ffad8ca581d87b16fab76f92f7e0a554f921fe0f86405", "format": 1 }, { @@ -1502,7 +1572,7 @@ "name": "tests/integration/targets/mso_schema_template_external_epg/tasks/main.yml", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "ff9797ef3ae1245f5f8c22f8b690f2da40ee624029286bec15391a83ca808574", + "chksum_sha256": "ae944971b202fbcbbb4a1bbfb7322ee1e8d73f113d7e60b88da8da604ce2b8c1", "format": 1 }, { @@ -1537,7 +1607,7 @@ "name": "tests/integration/targets/mso_site/tasks/main.yml", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "b1069b4a82af6ab3a3f5c48a3e1ccd7934914ce4a01986527c8abd1b9644f60f", + "chksum_sha256": "78e7c19bb659638812ed34f2cc4c4a6f0d3946c7eec28e54d05a2dd04001ae6e", "format": 1 }, { @@ -1565,7 +1635,7 @@ "name": "tests/integration/targets/mso_backup/tasks/main.yml", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "18d20201dae1300b207fb2a4aca24df285f859edb393c5f86f773bb8df08e7eb", + "chksum_sha256": "cfd643748dcd4bb01db6c8a5f8f93cef5c74f455187c4331eeb587a8d3fbd132", "format": 1 }, { @@ -1593,7 +1663,7 @@ "name": "tests/integration/targets/mso_schema_validate/tasks/main.yml", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "1af77eaab77c5a6b06eda3a60b2bd918b84dfa5750f6288aaad1d002d069bc6b", + "chksum_sha256": "8531c2bc69d731cc659e88a40e74d4172321240e00844f839e35d26891d83975", "format": 1 }, { @@ -1621,7 +1691,7 @@ "name": "tests/integration/targets/mso_schema_site_external_epg/tasks/main.yml", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "6bdfe858336ec0d8a3fb0d5d09142ef1c2a4a0cbd99fcc389e6784ac8ddd2b41", + "chksum_sha256": "e054e4ebc87f0526ae3c5dd7748dc32871338deb0236d72687240382c56a47d4", "format": 1 }, { @@ -1649,7 +1719,7 @@ "name": "tests/integration/targets/mso_schema_site_bd_l3out/tasks/main.yml", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "7b158c1ec848377082954461ef32fb48016b0986ac9d9a7e8b5be178410df282", + "chksum_sha256": "7b1dd7407d125187f7110c266063d8e98f3e03feeeadab3707fb71ed742b7850", "format": 1 }, { @@ -1660,6 +1730,41 @@ "format": 1 }, { + "name": "tests/integration/targets/mso_schema_site_contract_service_graph", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/mso_schema_site_contract_service_graph/tasks", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/mso_schema_site_contract_service_graph/tasks/main.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "2a29449d81e24e4858042f74b100beadb2a56264cb03c1e0cf3e9f151a09884b", + "format": 1 + }, + { + "name": "tests/integration/targets/mso_schema_site_contract_service_graph/tasks/l4_l7_devices.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "7951548c601b5038570a069c96db81056ff81e7c40f3693a0538ee8a3aec36bc", + "format": 1 + }, + { + "name": "tests/integration/targets/mso_schema_site_contract_service_graph/aliases", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "4e674607496d01ce032bfdbcc3e77ecdcde02f3e9d57080a95682a0cdff6809a", + "format": 1 + }, + { "name": "tests/integration/targets/mso_schema_template_vrf", "ftype": "dir", "chksum_type": null, @@ -1677,7 +1782,7 @@ "name": "tests/integration/targets/mso_schema_template_vrf/tasks/main.yml", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "1c7674afec5735c25d6728fe1ad92d3c18fbeb86285c8ab671d0feca2f2f1c16", + "chksum_sha256": "19cc140ef2b984829c7f751c6a41cbb1f58d00a1eb6d4b6259154ea72ee3bd3f", "format": 1 }, { @@ -1705,7 +1810,7 @@ "name": "tests/integration/targets/mso_dhcp_relay_policy_provider/tasks/main.yaml", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "5d51e2b02f8d1e76e11de62f429d8ef56d434d5b2cdb69ad0b919889ff2f5936", + "chksum_sha256": "d0a9a51f78de0a35485537afb420626cb33bd7769a96b4227c89457307a1d1c3", "format": 1 }, { @@ -1740,7 +1845,7 @@ "name": "tests/integration/targets/mso_version/tasks/main.yml", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "e12f785897861f1ddb8774ca5decd418c4cfb07cea9d3f7d17b82e702c90c6e9", + "chksum_sha256": "33e95584610880663096db1a8f392693f224951d0929f54517b35823aacd426e", "format": 1 }, { @@ -1768,7 +1873,7 @@ "name": "tests/integration/targets/mso_dhcp_option_policy/tasks/main.yaml", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "c8a3d5702a82e14a426180a493c3479435a0e19d46bd02c8493b035296d958c0", + "chksum_sha256": "7a264b8ac34b2a4d38201316246494316674d9d469ffc279deac501bea902745", "format": 1 }, { @@ -1796,7 +1901,7 @@ "name": "tests/integration/targets/mso_schema_site_anp/tasks/main.yml", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "418ff7da34a7ad01685d47cc802cedff5ba29cbe769c954ee9083f682dad7ae1", + "chksum_sha256": "282ba92eb7c1498f5c0c1ef3159415e7e4d12f314cdaf8872b43bf536d407624", "format": 1 }, { @@ -1824,14 +1929,14 @@ "name": "tests/integration/targets/mso_schema_site_vrf_region_hub_network/tasks/hub_network.yml", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "e1a5fd0bbf1f1adf0d4da159ccfe96f57b5c10f4e8fa48c6c76da8339b10c530", + "chksum_sha256": "2deeeb9bfe3db63602a8fa5bc68c733967f577f68eecdca9bae9ca4e183922c3", "format": 1 }, { "name": "tests/integration/targets/mso_schema_site_vrf_region_hub_network/tasks/main.yml", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "ffa9f5e1ba49276fbf6d6cb24151327d6901a5a778d57e4ddb1c8ac0c722487e", + "chksum_sha256": "40853a8fa344161fddff84ac11064eeddf7dd2c02e79c9a50c33b81187535b18", "format": 1 }, { @@ -1859,7 +1964,7 @@ "name": "tests/integration/targets/mso_schema_site_anp_epg_staticport/tasks/main.yml", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "f4cd4ae7386ed895636f750b632a5001c004d8a8805c21de5059cfbbad3c04c4", + "chksum_sha256": "a56038abe8b876cf73a846293694e57e7d66a056f38b8671fa258d3efead62b1", "format": 1 }, { @@ -1887,7 +1992,7 @@ "name": "tests/integration/targets/mso_schema_site_vrf_region_cidr/tasks/main.yml", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "b28d23e8386bd853d29a9544995258c438bec534f7abd563642f0c08de3d9784", + "chksum_sha256": "2d778fc51d376d9b55c16782080fb33791d574f8b0ecd9e4578544f549a574ee", "format": 1 }, { @@ -1915,7 +2020,7 @@ "name": "tests/integration/targets/mso_schema_template_clone/tasks/main.yml", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "d844a496be851967b5ad5b12b7e87c97cfeb43fb9aea9a017fe1ff5eef8872c4", + "chksum_sha256": "bcef426421ffeff530e23ba152f73347ec7f3659a8ef27ae66e896ba8af1c072", "format": 1 }, { @@ -1943,7 +2048,7 @@ "name": "tests/integration/targets/mso_schema_template_bd_dhcp_policy/tasks/main.yml", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "78b2e112fa8a4f86ae598358e9230f87e97032cac5c42cce6e2225b2d214684e", + "chksum_sha256": "bdfbb261c651a8b266d174ad8ca3fef7bab7e439c54403ca3a6da98a781e48c8", "format": 1 }, { @@ -1971,7 +2076,7 @@ "name": "tests/integration/targets/mso_schema_site_bd_subnet/tasks/main.yml", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "13b1b2addac18340cc8e491f123f1bfd6eb036b1bc9436ab49e95fb723bb652c", + "chksum_sha256": "20f6a89566a58b145d17e54a97f6a63740165596f8375bc8cc953cd43932fd77", "format": 1 }, { @@ -1999,7 +2104,7 @@ "name": "tests/integration/targets/mso_schema_template_service_graph/tasks/main.yml", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "484c7ee52533c8a3945e0895aea08fc8ce43f4cbeb214f09382da2b94f8be366", + "chksum_sha256": "1bccf60d8d142999c6f91c1d7643877b2463f0f1bcf7816b4df16d1a53ea9e36", "format": 1 }, { @@ -2027,7 +2132,7 @@ "name": "tests/integration/targets/mso_tenant_site/tasks/main.yml", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "47f6b866deb362cc0f408b86ce5c35d130b2020d1a9c1b417619e72e5a53eaf7", + "chksum_sha256": "b71bdd7e10f0354fd474ca739438281103671cbc627d2818457ac6d5ae0600cc", "format": 1 }, { @@ -2055,7 +2160,7 @@ "name": "tests/integration/targets/mso_schema_template_bd_subnet/tasks/main.yml", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "7ff362dc5f1bc93ef2020db1ec557092607256e917d8ddd430c323d6f5d8ec5f", + "chksum_sha256": "8b7650a13616eb890800a7cfdaf473476df824e2d5a14e537c2f757eca5bac9f", "format": 1 }, { @@ -2083,7 +2188,7 @@ "name": "tests/integration/targets/mso_schema_template_filter_entry/tasks/main.yml", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "fa3311bf4f0a496d1f4fb2ced7e15eba2fc91f94dc9d3ff03fcc90d914edfef6", + "chksum_sha256": "02d72c0b14dff84ed6b8a9a88a1e4a805314099f462954b400d7f47b1901d392", "format": 1 }, { @@ -2111,7 +2216,7 @@ "name": "tests/integration/targets/mso_schema_site_anp_epg_bulk_staticport/tasks/main.yml", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "54fb49cc6419f67dbbad1d40262ad3b5d51c4397a4051dc1bf1517b9a0cc2649", + "chksum_sha256": "ef18b8d1183244545df0e30359f4970b019b5617634337b22a950f55e5b81c5c", "format": 1 }, { @@ -2139,7 +2244,7 @@ "name": "tests/integration/targets/mso_tenant/tasks/main.yml", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "947a71a53705d001c273db32700e5068456b9c4485e965ce74f6f7a1b9deac21", + "chksum_sha256": "ddf2bf7c2a0c51332f5e567f5be3f42210128b1fc09fb3231658f10f45c24b62", "format": 1 }, { @@ -2167,7 +2272,7 @@ "name": "tests/integration/targets/mso_user/tasks/main.yml", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "4da63f32ce74b3890e7ee8d4c3c075036bbf41c12a05993ae0149e200802a69f", + "chksum_sha256": "ffde6cae7d1c5ea2177b965831f0398fd92f6005f9753b3ed3f5a3facf794f83", "format": 1 }, { @@ -2195,7 +2300,7 @@ "name": "tests/integration/targets/mso_label/tasks/main.yml", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "480fe2aaf7ae221186ad81b486471d176476c07347e005255d0a399ac14c2086", + "chksum_sha256": "0c3d8b89ce467783f71f5f2dbe4001ef36ebc75589826490e8209164f6bf0c50", "format": 1 }, { @@ -2223,7 +2328,7 @@ "name": "tests/integration/targets/mso_schema_site_anp_epg_useg_attribute/tasks/main.yml", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "37ede5ad61f45ac3ade6efa497636f6a60d3c53c84a018acd8381455d8bb62f0", + "chksum_sha256": "10619550bc02fc49ab081aae29a45c4f107e9495a5fc687403f02d59afcedd9f", "format": 1 }, { @@ -2251,7 +2356,7 @@ "name": "tests/integration/targets/mso_schema_template_anp_epg_contract/tasks/main.yml", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "1c4ffb17ea697e5f4084e51af650ea8926d15db223e0e0ae010a7954def3c6ff", + "chksum_sha256": "050d7f9e940a19588c94277bbc0b10df53261c2d50120c73d13185f1838eaa89", "format": 1 }, { @@ -2279,7 +2384,7 @@ "name": "tests/integration/targets/mso_schema_template_anp_epg_selector/tasks/main.yml", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "b076386dec1bbce7c25deeb36f6c674d6ba271e2d22d87241db43dd8fbf60913", + "chksum_sha256": "c34c10fda893cd1747d5444b2b839381fbe1c409c1f41a8188bc02f2953ceb71", "format": 1 }, { @@ -2307,7 +2412,7 @@ "name": "tests/integration/targets/mso_schema_template_anp_epg/tasks/main.yml", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "4745d027cba442156d8f6c5c441695cf796bd7a3dc2f3db5addffcff340c1268", + "chksum_sha256": "ea515cc4a21172eae0223fb1dfa976170dd532d1169c98e9b42dedb49fecbfc3", "format": 1 }, { @@ -2335,7 +2440,7 @@ "name": "tests/integration/targets/mso_schema_site_anp_epg_domain/tasks/main.yml", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "ee1fb2b9a12e1cf8279a729d0e1931f8428bd9ebba10437d919b33e5c68bc7ea", + "chksum_sha256": "ff484522430e64fe87c59447052f70c597798923f81506207534863fa313743c", "format": 1 }, { @@ -2363,7 +2468,7 @@ "name": "tests/integration/targets/mso_schema_template_vrf_contract/tasks/main.yml", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "c1639c0d1bda672778a81703b34dfde366b560c7e075fc78abfd42b0aadae844", + "chksum_sha256": "fcea17ca3703a45b1f8bd76fe56c173df8f1ac189f669488b75af72a54868449", "format": 1 }, { @@ -2391,21 +2496,21 @@ "name": "tests/integration/targets/mso_role/tasks/role-ro.yml", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "e6bd02045da50a15d5637fa33f5fd81cf2be74a7169ad5f3d3bb3f8bb5ddbf04", + "chksum_sha256": "b202d850f019300dded56caa6fe2b3191de2c0b40a6237e8dec65d98d6a10f2a", "format": 1 }, { "name": "tests/integration/targets/mso_role/tasks/role-rw.yml", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "71801c0349fceb078b940dd5fcec5cdf2009698f1217dffd56742ac102d21f8f", + "chksum_sha256": "b6afc1669d06eefe9ea8e5eb04a08909ace49d5061d31e167b6f58df20d37498", "format": 1 }, { "name": "tests/integration/targets/mso_role/tasks/main.yml", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "65a2f97fa530d35fa0f1c647b8b3052d42d2dee2d6a9e6ea766e9eae531ff177", + "chksum_sha256": "9b55740c252269b29fe741e31bff2bd8552600048e321700cfee4177d20fda8c", "format": 1 }, { @@ -2433,7 +2538,7 @@ "name": "tests/integration/targets/mso_schema_template_anp_epg_useg_attribute/tasks/main.yml", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "366babbe8a312685256b3034cb45e56c0bb3fb31347df60f368dd8d704b5ef16", + "chksum_sha256": "3b937b0e5e31c12044a2c595f9ade15f63310f8cd08bc759466d417b8800c6a9", "format": 1 }, { @@ -2461,7 +2566,7 @@ "name": "tests/integration/targets/mso_service_node_type/tasks/main.yml", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "0f1f0fc9edff212a859e9a1a92cabdc157a25b5458d9dd9f429cc3e867ebfaa3", + "chksum_sha256": "b5b140bd4b575119c42f82ab18b8c33bf3c1cf4c941e4429a3d9241c05402be4", "format": 1 }, { @@ -2489,7 +2594,7 @@ "name": "tests/integration/targets/mso_schema_template_deploy_status/tasks/main.yml", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "eb8bc653c1850980ecdef451053e466effa70eec2482c9b62d997ed7a131a036", + "chksum_sha256": "a3f58eda151d16e67a38f2374854342959d9470b32530b36ebe82e9aad41d4a5", "format": 1 }, { @@ -2517,7 +2622,7 @@ "name": "tests/integration/inventory.networking", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "d3f3ffdd2f2ba13a4c77372a057605170c0480c7766a1b7ee626cdac9a11bbd5", + "chksum_sha256": "7c41c75da3834ca94b3741249d23d91a6176740d787cb30e7205975d6954b384", "format": 1 }, { @@ -2552,7 +2657,7 @@ "name": "meta/runtime.yml", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "205a2ae640e2768827a4bf733001d5294da4301f3413b1aac640fbb2a6155d03", + "chksum_sha256": "fba10f5ea19bbbe13b0a56de28ceb30e61d401148ab2a6d5d9d35ef88844ba68", "format": 1 }, { @@ -2587,21 +2692,21 @@ "name": "changelogs/.plugin-cache.yaml", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "0e39bdaa5b1012ce06db1c6e59c9c3a09bb9ea6956647d966c93d2792de5819a", + "chksum_sha256": "e92e2ea06f1ace11275a3e3db7de2352e2f378ff8bc8416fba2c360ec14f3164", "format": 1 }, { "name": "changelogs/changelog.yaml", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "aaefd32a4575f9258e66e377433698ba78c07d641a54c47092e1064edd676036", + "chksum_sha256": "38ca5840b834c074ca4a92cd74bb3255a3429102b9a98f86901251de3e816bb7", "format": 1 }, { "name": "README.md", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "613db67fc4c860791ee0bc02b1e0ace99d9a0daae54db9cc8309fdfbf061d239", + "chksum_sha256": "eb8b8d99cba3d16e1d3e4341d3e9a369bc22c189514497be4453f10326816240", "format": 1 }, { @@ -2636,7 +2741,7 @@ "name": ".github/workflows/galaxy-importer.cfg", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "edc6f2746e7b8c7b94dea479036ba246953cf69234974b89c069c10d614dcaad", + "chksum_sha256": "495797aee3d8a36d013c51e137187e94b639b998c59e84b64574584c826846a8", "format": 1 }, { @@ -2650,7 +2755,7 @@ "name": ".github/workflows/ansible-test.yml", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "55a01eb1c79e977744677bca59563ff6dfbb3f12b0932130d4cc7a46d49deb04", + "chksum_sha256": "072437507f49a0e8a0a016fb40285086d18266453378f1cfbed42ede55c2b006", "format": 1 }, { @@ -2692,7 +2797,7 @@ "name": "CHANGELOG.rst", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "e4747ba584163f6422760b76eed3d11156df1c5ccf6ca6d18417140bcc214c16", + "chksum_sha256": "7ea304c736eb95b9526593261392b48d14fef496e5da625f9f71d3ce64ac7aea", "format": 1 }, { diff --git a/ansible_collections/cisco/mso/MANIFEST.json b/ansible_collections/cisco/mso/MANIFEST.json index 72c5f44d9..9d55dcb55 100644 --- a/ansible_collections/cisco/mso/MANIFEST.json +++ b/ansible_collections/cisco/mso/MANIFEST.json @@ -2,7 +2,7 @@ "collection_info": { "namespace": "cisco", "name": "mso", - "version": "2.5.0", + "version": "2.6.0", "authors": [ "Dag Wieers (@dagwieers)", "Nirav Katarmal (@nkatarmal-crest)", @@ -36,7 +36,7 @@ "name": "FILES.json", "ftype": "file", "chksum_type": "sha256", - "chksum_sha256": "52400ead13bbe6a4f9a3ae26b7702c3406c1463f794330adcc7bfa8aba2fca77", + "chksum_sha256": "d15ff3f0354f6d6736439deb843e42f7ad91602d4e2224135b7a1f52cc739efc", "format": 1 }, "format": 1 diff --git a/ansible_collections/cisco/mso/README.md b/ansible_collections/cisco/mso/README.md index d83eb5297..f6d08f6f9 100644 --- a/ansible_collections/cisco/mso/README.md +++ b/ansible_collections/cisco/mso/README.md @@ -10,7 +10,7 @@ Modules supporting new features introduced in MSO API in specific MSO versions m *Note: The Nexus Dashboard (ND) HTTPAPI connection plugin should be used when Cisco ACI Multi-Site is installed on Nexus Dashboard (v3.2+) or when using this collection with Nexus Dashboard Orchestrator (v3.6+).* ## Requirements -- Ansible v2.9 or newer +- Ansible v2.14 or newer ## Install Ansible must be installed @@ -46,7 +46,6 @@ Once the collection is installed, you can use it in a playbook by specifying the anp: ANP1 epg: EPG1 state: present - delegate_to: localhost ``` You can also use the MSO HTTPAPI connection plugin by setting the following variables in your inventory file (cisco.mso collection v1.2+). diff --git a/ansible_collections/cisco/mso/changelogs/.plugin-cache.yaml b/ansible_collections/cisco/mso/changelogs/.plugin-cache.yaml index 48e4fe51b..e6bda9878 100644 --- a/ansible_collections/cisco/mso/changelogs/.plugin-cache.yaml +++ b/ansible_collections/cisco/mso/changelogs/.plugin-cache.yaml @@ -141,8 +141,20 @@ plugins: name: mso_schema_site_bd_subnet namespace: '' version_added: null + mso_schema_site_contract_service_graph: + description: Manage the service graph association with a contract in schema + sites + name: mso_schema_site_contract_service_graph + namespace: '' + version_added: null + mso_schema_site_contract_service_graph_listener: + description: Manage the listener for Azure site contract service graph in schema + sites + name: mso_schema_site_contract_service_graph_listener + namespace: '' + version_added: null mso_schema_site_external_epg: - description: Manage External EPG in schema of sites + description: Manage External EPG in schema of sites. name: mso_schema_site_external_epg namespace: '' version_added: null @@ -357,4 +369,4 @@ plugins: strategy: {} test: {} vars: {} -version: 2.5.0 +version: 2.6.0 diff --git a/ansible_collections/cisco/mso/changelogs/changelog.yaml b/ansible_collections/cisco/mso/changelogs/changelog.yaml index 18ae8b912..f7767c577 100644 --- a/ansible_collections/cisco/mso/changelogs/changelog.yaml +++ b/ansible_collections/cisco/mso/changelogs/changelog.yaml @@ -3,332 +3,325 @@ releases: 0.0.5: changes: release_summary: New release v0.0.5 - release_date: "2020-04-07" + release_date: '2020-04-07' 0.0.6: changes: bugfixes: - - Add aliases for backward support of permissions in role module. - - Add integration test for mso_schema_template_db and fix un-needed push to - API found by integration test. - - Consistent object output on domain_associations - - Fix EPG / External EPG Contract issue and create test for mso_schema_template_anp_epg_contract - and mso_schema_template_external_epg_contract - - Fix contract filter issue and add contract-filter test file - - Fix duplicate user, add admin user to associated user list and update tenant - test file - - Fix intersite_multicast_source attribute issue in mso_schema_template_anp_epg - and add the proxy_arp argument. - - Fix mso_schema_template_anp_epg idempotancy for both EPG and EPG with contracts - - Remove label with test domain before create it - - Send context instead of vrf when vrf parameter is used - - Update mso_schema_template_bd.py example for BD in another schema + - Add aliases for backward support of permissions in role module. + - Add integration test for mso_schema_template_db and fix un-needed push to + API found by integration test. + - Consistent object output on domain_associations + - Fix EPG / External EPG Contract issue and create test for mso_schema_template_anp_epg_contract + and mso_schema_template_external_epg_contract + - Fix contract filter issue and add contract-filter test file + - Fix duplicate user, add admin user to associated user list and update tenant + test file + - Fix intersite_multicast_source attribute issue in mso_schema_template_anp_epg + and add the proxy_arp argument. + - Fix mso_schema_template_anp_epg idempotancy for both EPG and EPG with contracts + - Remove label with test domain before create it + - Send context instead of vrf when vrf parameter is used + - Update mso_schema_template_bd.py example for BD in another schema minor_changes: - - ACI/MSO - Use get() dict lookups (https://github.com/ansible/ansible/pull/63074) - - Add EPG and ANP at site level when needed - - Add github action CI pipeline with test coverage - - Add login domain support for authentication in all modules - - Add support for DHCP querier to all subnet objects. Add partial test in mso_schema_template_bd - integration test. - - Add support for clean output if needed for debuging - - Add test file for mso_schema_template_anp_epg - - Added DHCP relay options and scope options to MSO schema template bd - - Added ability to bind epg to static fex port - - Added module to manage contracts for external EPG in Cisco MSO (https://github.com/ansible/ansible/pull/63550) - - Added module to manage template external epg subnet for Cisco MSO (https://github.com/ansible/ansible/pull/63542) - - Disabling tests for the role modules as API is not supported after 2.2.3i - until further notice - - Increased test coverage for existing module integration tests. - - Modified fail messages for site and updated documentation - - Moving test to Ansible v2.9.9 and increasing timelimit for mutex to 30+ min - - Update authors. - - Update mso_schema_site_anp.py (https://github.com/ansible/ansible/pull/67099) - - Updated Test File Covering all conditions - - mso_schema_site_anp_epg_staticport - Add VPC support (https://github.com/ansible/ansible/pull/62803) + - ACI/MSO - Use get() dict lookups (https://github.com/ansible/ansible/pull/63074) + - Add EPG and ANP at site level when needed + - Add github action CI pipeline with test coverage + - Add login domain support for authentication in all modules + - Add support for DHCP querier to all subnet objects. Add partial test in mso_schema_template_bd + integration test. + - Add support for clean output if needed for debuging + - Add test file for mso_schema_template_anp_epg + - Added DHCP relay options and scope options to MSO schema template bd + - Added ability to bind epg to static fex port + - Added module to manage contracts for external EPG in Cisco MSO (https://github.com/ansible/ansible/pull/63550) + - Added module to manage template external epg subnet for Cisco MSO (https://github.com/ansible/ansible/pull/63542) + - Disabling tests for the role modules as API is not supported after 2.2.3i + until further notice + - Increased test coverage for existing module integration tests. + - Modified fail messages for site and updated documentation + - Moving test to Ansible v2.9.9 and increasing timelimit for mutex to 30+ min + - Update authors. + - Update mso_schema_site_anp.py (https://github.com/ansible/ansible/pull/67099) + - Updated Test File Covering all conditions + - mso_schema_site_anp_epg_staticport - Add VPC support (https://github.com/ansible/ansible/pull/62803) release_summary: New release v0.0.6 - release_date: "2020-06-13" + release_date: '2020-06-13' 0.0.7: changes: bugfixes: - - Fix mso_schema_site_vrf_region_cidr to automatically create VRF and Region - if not present at site level - - Fix query condition when VRF or Region do not exist at site level - - Remove unused regions attribute from mso_schema_template_vrf + - Fix mso_schema_site_vrf_region_cidr to automatically create VRF and Region + if not present at site level + - Fix query condition when VRF or Region do not exist at site level + - Remove unused regions attribute from mso_schema_template_vrf minor_changes: - - Add l3out, preferred_group and test file for mso_schema_template_externalepg - - Add mso_schema_template_vrf_contract module and test file - - Add new attribute choice "policy_compression" to mso_Schema_template_contract_filter - - Add new functionality - Direct Port Channel (dpc), micro-seg-vlan and default - values - - Add new module for anp-epg-selector in site level - - Add new module mso_schema_template_anp_epg_selector and its test file - - Add new module mso_schema_vrf_contract - - Add new module mso_tenant_site to support cloud and non-cloud sites association - with a tenant and test file (https://github.com/CiscoDevNet/ansible-mso/pull/62) - - Add new mso_site_external_epg_selector module and test file - - Add site external epg and contract filter test - - Add support for VGW attribute in mso_schema_site_vrf_region_cidr_subnet - - Add support to set account as inactive using account_status attribute in mso_user - - Add test for mso_schema_site_vrf_region_cidr module - - Add test for mso_schema_site_vrf_region_cidr_subnet module - - Add vzAny attribute in mso_schema_template_vrf - - Automatically add ANP and EPG at site level and new test file for mso_schema_site_anp_epg_staticport - (https://github.com/CiscoDevNet/ansible-mso/pull/55) - - Modified External EPG module and addition of new Selector module + - Add l3out, preferred_group and test file for mso_schema_template_externalepg + - Add mso_schema_template_vrf_contract module and test file + - Add new attribute choice "policy_compression" to mso_Schema_template_contract_filter + - Add new functionality - Direct Port Channel (dpc), micro-seg-vlan and default + values + - Add new module for anp-epg-selector in site level + - Add new module mso_schema_template_anp_epg_selector and its test file + - Add new module mso_schema_vrf_contract + - Add new module mso_tenant_site to support cloud and non-cloud sites association + with a tenant and test file (https://github.com/CiscoDevNet/ansible-mso/pull/62) + - Add new mso_site_external_epg_selector module and test file + - Add site external epg and contract filter test + - Add support for VGW attribute in mso_schema_site_vrf_region_cidr_subnet + - Add support to set account as inactive using account_status attribute in mso_user + - Add test for mso_schema_site_vrf_region_cidr module + - Add test for mso_schema_site_vrf_region_cidr_subnet module + - Add vzAny attribute in mso_schema_template_vrf + - Automatically add ANP and EPG at site level and new test file for mso_schema_site_anp_epg_staticport + (https://github.com/CiscoDevNet/ansible-mso/pull/55) + - Modified External EPG module and addition of new Selector module release_summary: New release v0.0.7 - release_date: "2020-07-08" + release_date: '2020-07-08' 0.0.8: changes: bugfixes: - - Add login_domain to existing test. - - Add missing tests for VRF settings and changing those settings. - - Add test for specifying read-only roles and increase overall test coverage - of mso_user (https://github.com/CiscoDevNet/ansible-mso/pull/77) - - Add test to mso_schema_template_vrf, mso_schema_template_external_epg and - mso_schema_template_anp_epg to check for API error when pushing changes to - object with existing contract. - - Cleanup unused imports, unused variables and branches and change a variable - from ambiguous name to reduce warnings at Ansible Galaxy import - - Fix API error when pushing EPG with existing contracts - - Fix role tests to work with pre/post 2.2.4 and re-enable them - - Fix site issue if no site present and fix test issues with MSO v3.0 - - Fixing External EPG renaming for 2.9 and later - - Fixing L3MCast test to pass on 2.2.4 - - Fixing wrong removal of schemas - - Test hub network module after creating region manually - - Updating Azure site IP in inventory and add second MSO version to inventory + - Add login_domain to existing test. + - Add missing tests for VRF settings and changing those settings. + - Add test for specifying read-only roles and increase overall test coverage + of mso_user (https://github.com/CiscoDevNet/ansible-mso/pull/77) + - Add test to mso_schema_template_vrf, mso_schema_template_external_epg and + mso_schema_template_anp_epg to check for API error when pushing changes to + object with existing contract. + - Cleanup unused imports, unused variables and branches and change a variable + from ambiguous name to reduce warnings at Ansible Galaxy import + - Fix API error when pushing EPG with existing contracts + - Fix role tests to work with pre/post 2.2.4 and re-enable them + - Fix site issue if no site present and fix test issues with MSO v3.0 + - Fixing External EPG renaming for 2.9 and later + - Fixing L3MCast test to pass on 2.2.4 + - Fixing wrong removal of schemas + - Test hub network module after creating region manually + - Updating Azure site IP in inventory and add second MSO version to inventory minor_changes: - - Add Login Domain support to mso_site - - Add aliases file for contract_filter module - - Add contract information in current and previous part - - Add new module and test file to query MSO version - - New backup module and test file (https://github.com/CiscoDevNet/ansible-mso/pull/80) - - Renaming mso_schema_template_externalepg module to mso_schema_template_external_epg - while keeping both working. - - Update cidr module, udpate attributes in hub network module and its test file - - Use a function to reuuse duplicate part + - Add Login Domain support to mso_site + - Add aliases file for contract_filter module + - Add contract information in current and previous part + - Add new module and test file to query MSO version + - New backup module and test file (https://github.com/CiscoDevNet/ansible-mso/pull/80) + - Renaming mso_schema_template_externalepg module to mso_schema_template_external_epg + while keeping both working. + - Update cidr module, udpate attributes in hub network module and its test file + - Use a function to reuuse duplicate part release_summary: New release v0.0.8 - release_date: "2020-07-21" + release_date: '2020-07-21' 1.0.0: changes: bugfixes: - - Fix sanity issues to support 2.10.0 + - Fix sanity issues to support 2.10.0 minor_changes: - - Add changelog - - Fix M() and module to use FQCN - - Update Ansible version in CI and add 2.10.0 to sanity in CI. - - Update Readme with supported versions - release_summary: - "This is the first official release of the ``cisco.mso`` collection + - Add changelog + - Fix M() and module to use FQCN + - Update Ansible version in CI and add 2.10.0 to sanity in CI. + - Update Readme with supported versions + release_summary: 'This is the first official release of the ``cisco.mso`` collection on 2020-08-18. This changelog describes all changes made to the modules and plugins included in this collection since Ansible 2.9.0. - " - release_date: "2020-08-18" + ' + release_date: '2020-08-18' 1.0.1: changes: bugfixes: - - Fix default value for l2Stretch in mso_schema_template_bd module - - Fix deletion of schema when wrong template is provided in single template - schema - - Fix examples in documentation for mso_schema_template_l3out and mso_user - - Fix naming issue in deploy module - - Remove author emails due to length restriction - - Remove dead code branch in mso_schema_template + - Fix default value for l2Stretch in mso_schema_template_bd module + - Fix deletion of schema when wrong template is provided in single template + schema + - Fix examples in documentation for mso_schema_template_l3out and mso_user + - Fix naming issue in deploy module + - Remove author emails due to length restriction + - Remove dead code branch in mso_schema_template minor_changes: - - Add delete capability to mso_schema_site - - Add env_fallback for mso_argument_spec params - - Add non existing template deletion test - - Add test file for mso_schema_template - - Add test file for site_bd_subnet - - Bump module to v1.0.1 - - Extent mso_tenant test case coverage - release_summary: - "Release v1.0.1 of the ``cisco.mso`` collection on 2020-10-30. + - Add delete capability to mso_schema_site + - Add env_fallback for mso_argument_spec params + - Add non existing template deletion test + - Add test file for mso_schema_template + - Add test file for site_bd_subnet + - Bump module to v1.0.1 + - Extent mso_tenant test case coverage + release_summary: 'Release v1.0.1 of the ``cisco.mso`` collection on 2020-10-30. This changelog describes all changes made to the modules and plugins included in this collection since v1.0.0. - " - release_date: "2020-10-30" + ' + release_date: '2020-10-30' 1.1.0: changes: bugfixes: - - Fix anp idempotency issue - - Fix crash issue when using irrelevant site-template - - Fix default value for mso_schema state parameter - - Fix examples for mso_schema - - Fix galaxy-importer check warnings - - Fix issue on mso_schema_site_vrf_region_cidr_subnet to allow an AWS subnet - to be used for a TGW Attachment (Hub Network) - - Fix module name in example of mso_schema_site_vrf_region - - Fix mso_backup upload issue - - Fix sanity test error mso_schema_site_bd - - Fix some coding standard and improvements to contributed mso_dhcp_relay modules - and test files - - Fix space in asssertion - - Fix space in site_anp_epg_domain - - Fix space in test file - - Remove space from template name in all modules - - Remove space in template name + - Fix anp idempotency issue + - Fix crash issue when using irrelevant site-template + - Fix default value for mso_schema state parameter + - Fix examples for mso_schema + - Fix galaxy-importer check warnings + - Fix issue on mso_schema_site_vrf_region_cidr_subnet to allow an AWS subnet + to be used for a TGW Attachment (Hub Network) + - Fix module name in example of mso_schema_site_vrf_region + - Fix mso_backup upload issue + - Fix sanity test error mso_schema_site_bd + - Fix some coding standard and improvements to contributed mso_dhcp_relay modules + and test files + - Fix space in asssertion + - Fix space in site_anp_epg_domain + - Fix space in test file + - Remove space from template name in all modules + - Remove space in template name minor_changes: - - Add DHCP Policy Operations - - Add SVI MAC Addreess option in mso_schema_site_bd - - Add additional test file to add tenant from templated payload file - - Add attribute virtual_ip to mso_schema_site_bd_subnet - - Add capability for restore and download backup - - Add capability to upload backup - - Add check for undeploy under MSO version - - Add error handeling test file - - Add error message to display when yaml has failed to load - - Add galaxy-importer check - - Add galaxy-importer config - - Add mso_dhcp_option_policy and mso_dhcp_option_policy_option and test files - - Add new module mso_rest and test case files to support GET api method - - Add new options to template bd and updated test file - - Add notes to use region_cidr module to create region - - Add task to undeploy the template from the site - - Add tasks in test file to remove templates for mso_schema_template_migrate - - Add test case for schema removing - - Add test cases to verify GET, PUT, POST and DELETE API methods for sites in - mso_rest.py - - Add test file for mso_schema - - Add test file for mso_schema_template_anp - - Add test file for region module - - Add test files yaml_inline and yaml_string to support YAML - - Add userAssociations to tenants to resolve CI issues - - Addition of cloud setting for ext epg - - Changes made to payload of mso_schema_template_external_epg - - Changes to options in template bd - - Check warning - - Documentation Corrected - - Force arp flood to be true when l2unkwunicast is flood - - Make changes to display correct status code - - Modify mso library and updated test file - - Modify mso_rest test files to make PATCH available, and test other methods - against schemas - - Move options for subnet from mso to the template_bd_subnet module - - Python lint corrected - - Redirect log to both stdout and log.txt file & Check warnings and errors - - Remove creation example in document of mso_schema_site_vrf_region - - Remove present state from mso_schema module - - Removed unused variable in mso_schema_site_vrf_region_hub_network - - Test DHCP Policy Provider added - - Test file for mso_dhcp_relay_policy added - - Test file for template_bd_subnet and new option foe module - release_summary: - "Release v1.1.0 of the ``cisco.mso`` collection on 2021-01-20. + - Add DHCP Policy Operations + - Add SVI MAC Addreess option in mso_schema_site_bd + - Add additional test file to add tenant from templated payload file + - Add attribute virtual_ip to mso_schema_site_bd_subnet + - Add capability for restore and download backup + - Add capability to upload backup + - Add check for undeploy under MSO version + - Add error handeling test file + - Add error message to display when yaml has failed to load + - Add galaxy-importer check + - Add galaxy-importer config + - Add mso_dhcp_option_policy and mso_dhcp_option_policy_option and test files + - Add new module mso_rest and test case files to support GET api method + - Add new options to template bd and updated test file + - Add notes to use region_cidr module to create region + - Add task to undeploy the template from the site + - Add tasks in test file to remove templates for mso_schema_template_migrate + - Add test case for schema removing + - Add test cases to verify GET, PUT, POST and DELETE API methods for sites in + mso_rest.py + - Add test file for mso_schema + - Add test file for mso_schema_template_anp + - Add test file for region module + - Add test files yaml_inline and yaml_string to support YAML + - Add userAssociations to tenants to resolve CI issues + - Addition of cloud setting for ext epg + - Changes made to payload of mso_schema_template_external_epg + - Changes to options in template bd + - Check warning + - Documentation Corrected + - Force arp flood to be true when l2unkwunicast is flood + - Make changes to display correct status code + - Modify mso library and updated test file + - Modify mso_rest test files to make PATCH available, and test other methods + against schemas + - Move options for subnet from mso to the template_bd_subnet module + - Python lint corrected + - Redirect log to both stdout and log.txt file & Check warnings and errors + - Remove creation example in document of mso_schema_site_vrf_region + - Remove present state from mso_schema module + - Removed unused variable in mso_schema_site_vrf_region_hub_network + - Test DHCP Policy Provider added + - Test file for mso_dhcp_relay_policy added + - Test file for template_bd_subnet and new option foe module + release_summary: 'Release v1.1.0 of the ``cisco.mso`` collection on 2021-01-20. This changelog describes all changes made to the modules and plugins included in this collection since v1.0.1. - " - release_date: "2021-01-20" + ' + release_date: '2021-01-20' 1.2.0: changes: bugfixes: - - Add test case and small fixes to mso_schema_site_bd_l3out module - - Fix documentation issues accross modules - - Fix fail_json usage accross module_utils/mso.py - - Fix mso_rest to support HTTPAPI plugin and tests to support ND platform - - Fix mso_user to due to error in v1 API in MSO 3.2 - - Fix path issue in mso_schema_template_migrate - - Fixes for site level external epgs and site level L3Outs - - Fixes to support MSO 3.3 - - Remove query of all schemas to get schema ID and only query schema ID indentity - list API + - Add test case and small fixes to mso_schema_site_bd_l3out module + - Fix documentation issues accross modules + - Fix fail_json usage accross module_utils/mso.py + - Fix mso_rest to support HTTPAPI plugin and tests to support ND platform + - Fix mso_user to due to error in v1 API in MSO 3.2 + - Fix path issue in mso_schema_template_migrate + - Fixes for site level external epgs and site level L3Outs + - Fixes to support MSO 3.3 + - Remove query of all schemas to get schema ID and only query schema ID indentity + list API minor_changes: - - Add Ansible common HTTPAPI dependancy in galaxy.yml - - Add HTTPAPI connection plugin support and HTTPAPI MSO connection plugin - - Add primary and unicast_routing attributes to mso_schema_template_bd - - Add requirements.txt for Ansible Environment support - - Add schema and template cloning modules mso_schema_clone and mso_schema_template_clone - - Add support cisco.nd.nd connection plugin - - Add support for multiple DCHP policies in a BD and new module mso_schema_template_bd_dhcp_policy - - Upgrade CI to latest Ansible version and Python 3.8 - release_summary: - "Release v1.2.0 of the ``cisco.mso`` collection on 2021-06-02. + - Add Ansible common HTTPAPI dependancy in galaxy.yml + - Add HTTPAPI connection plugin support and HTTPAPI MSO connection plugin + - Add primary and unicast_routing attributes to mso_schema_template_bd + - Add requirements.txt for Ansible Environment support + - Add schema and template cloning modules mso_schema_clone and mso_schema_template_clone + - Add support cisco.nd.nd connection plugin + - Add support for multiple DCHP policies in a BD and new module mso_schema_template_bd_dhcp_policy + - Upgrade CI to latest Ansible version and Python 3.8 + release_summary: 'Release v1.2.0 of the ``cisco.mso`` collection on 2021-06-02. This changelog describes all changes made to the modules and plugins included in this collection since v1.1.0. - " + ' plugins: httpapi: - - description: MSO Ansible HTTPAPI Plugin. - name: mso - namespace: null - release_date: "2021-06-02" + - description: MSO Ansible HTTPAPI Plugin. + name: mso + namespace: null + release_date: '2021-06-02' 1.3.0: changes: bugfixes: - - Add no_log to aws_access_key and secret_key in mso_tenant_site - - Fix MSO HTTP API to work without host, user and password module attribute - - Fix issue with unicast_routing idemptotency in mso_schema_template_bd - - Fix mso_schema_site_anp and mso_schema_site_anp_epg idempotency issue - - Remove sanity ignore files and fix sanity issues that were previously ignored + - Add no_log to aws_access_key and secret_key in mso_tenant_site + - Fix MSO HTTP API to work without host, user and password module attribute + - Fix issue with unicast_routing idemptotency in mso_schema_template_bd + - Fix mso_schema_site_anp and mso_schema_site_anp_epg idempotency issue + - Remove sanity ignore files and fix sanity issues that were previously ignored minor_changes: - - Add container_overlay and underlay_context_profile support to mso_schema_site_vrf_region - - Add description support to various modules - - Add hosted_vrf support to mso_schema_site_vrf_region_cidr_subnet - - Add module mso_schema_validate to check schema validations - - Add private_link_label support to mso_schema_site_anp_epg and mso_schema_site_vrf_region_cidr_subnet - - Add qos_level and Service EPG support to mso_schema_template_anp_epg - - Add qos_level, action and priority support to mso_schema_template_contract_filter - - Add schema and template description support to mso_schema_template - - Add subnet as primary support to mso_schema_template_bd_subnet - - Add support for automatically creating anp structure at site level when using - mso_schema_site_anp_epg - - Add support for encap-flood as multi_destination_flooding in mso_schema_template_bd - - Add test file for mso_schema_site_anp, mso_schema_site_anp_epg, mso_schema_template_external_epg_subnet - mso_schema_template_filter_entry - - Improve scope attribute documentation in mso_schema_template_external_epg_subnet - - Update Ansible version used in automated testing to v2.9.27, v2.10.16 and - addition of v2.11.7 and v2.12.1 - release_summary: - "Release v1.3.0 of the ``cisco.mso`` collection on 2021-12-18. + - Add container_overlay and underlay_context_profile support to mso_schema_site_vrf_region + - Add description support to various modules + - Add hosted_vrf support to mso_schema_site_vrf_region_cidr_subnet + - Add module mso_schema_validate to check schema validations + - Add private_link_label support to mso_schema_site_anp_epg and mso_schema_site_vrf_region_cidr_subnet + - Add qos_level and Service EPG support to mso_schema_template_anp_epg + - Add qos_level, action and priority support to mso_schema_template_contract_filter + - Add schema and template description support to mso_schema_template + - Add subnet as primary support to mso_schema_template_bd_subnet + - Add support for automatically creating anp structure at site level when using + mso_schema_site_anp_epg + - Add support for encap-flood as multi_destination_flooding in mso_schema_template_bd + - Add test file for mso_schema_site_anp, mso_schema_site_anp_epg, mso_schema_template_external_epg_subnet + mso_schema_template_filter_entry + - Improve scope attribute documentation in mso_schema_template_external_epg_subnet + - Update Ansible version used in automated testing to v2.9.27, v2.10.16 and + addition of v2.11.7 and v2.12.1 + release_summary: 'Release v1.3.0 of the ``cisco.mso`` collection on 2021-12-18. This changelog describes all changes made to the modules and plugins included in this collection since v1.2.0. - " - release_date: "2021-12-18" + ' + release_date: '2021-12-18' 1.4.0: changes: bugfixes: - - Fix arp_entry value issue in mso_schema_template_filter_entry - - Fix mso_schema_site_anp idempotency when children exists - - Fix use_ssl documentation to explain usage when used with HTTPAPI connection - plugin + - Fix arp_entry value issue in mso_schema_template_filter_entry + - Fix mso_schema_site_anp idempotency when children exists + - Fix use_ssl documentation to explain usage when used with HTTPAPI connection + plugin minor_changes: - - Update mso_schema_template_clone to use new method from NDO and unrestrict - it to earlier version - release_summary: - "Release v1.4.0 of the ``ansible-mso`` collection on 2022-03-15. + - Update mso_schema_template_clone to use new method from NDO and unrestrict + it to earlier version + release_summary: 'Release v1.4.0 of the ``ansible-mso`` collection on 2022-03-15. This changelog describes all changes made to the modules and plugins included in this collection since v1.3.0. - " - release_date: "2022-03-15" + ' + release_date: '2022-03-15' 2.1.0: changes: bugfixes: - - Fix time issue when host running ansible is in a different timezone then NDO - - Remove mso_guide from notes + - Fix time issue when host running ansible is in a different timezone then NDO + - Remove mso_guide from notes deprecated_features: - - The mso_schema_template_contract_filter contract_filter_type attribute is - deprecated. The value is now deduced from filter_type. + - The mso_schema_template_contract_filter contract_filter_type attribute is + deprecated. The value is now deduced from filter_type. minor_changes: - - Add aci_remote_location module (#259) - - Add mso_backup_schedule module (#250) - - Add mso_chema_template_contract_service_graph module (#257) - - Add mso_schema_template_service_graph, mso_schema_site_service_graph and mso_service_node_type - modules (#243) - - Add primary attribute to mso_schema_site_bd_subnet (#254) - release_summary: - "Release v2.1.0 of the ``ansible-mso`` collection on 2022-10-14. + - Add aci_remote_location module (#259) + - Add mso_backup_schedule module (#250) + - Add mso_chema_template_contract_service_graph module (#257) + - Add mso_schema_template_service_graph, mso_schema_site_service_graph and mso_service_node_type + modules (#243) + - Add primary attribute to mso_schema_site_bd_subnet (#254) + release_summary: 'Release v2.1.0 of the ``ansible-mso`` collection on 2022-10-14. This changelog describes all changes made to the modules and plugins included in this collection since v1.4.0. @@ -336,97 +329,126 @@ releases: The version was bumped directly to 2.1.0 due to a previous collection upload issue on galaxy. - " - release_date: "2022-10-14" + ' + release_date: '2022-10-14' 2.2.0: changes: bugfixes: - - Fix MSO HTTPAPI plugin login domain issue (#317) - - Fix deploymentImmediacy key inconsistency in the API used by mso_schema_site_anp - and mso_schema_site_anp_epg (#283) - - Fix mso_schema_template_bd issue when created with unicast_routing as false - (#278) - - Fix to be able to add multiple filter and filters with "-" in their names - (#306) + - Fix MSO HTTPAPI plugin login domain issue (#317) + - Fix deploymentImmediacy key inconsistency in the API used by mso_schema_site_anp + and mso_schema_site_anp_epg (#283) + - Fix mso_schema_template_bd issue when created with unicast_routing as false + (#278) + - Fix to be able to add multiple filter and filters with "-" in their names + (#306) minor_changes: - - Add automatic creation of site bd when not existing in mso_schema_site_bd_subnet - module (#263) - - Add automatic schema validation functionality to mso_schema_template_deploy - and ndo_schema_template_deploy (#318) - - Add ndo_schema_template_deploy to support NDO 4+ deploy functionality (#305) - - Add support for l3out from different template or schema in mso_schema_site_bd_l3out - (#304) - - Add support for orchestrator_only attribute for mso_tenant with state absent - (#268) - release_summary: - "Release v2.2.0 of the ``ansible-mso`` collection on 2023-01-29. + - Add automatic creation of site bd when not existing in mso_schema_site_bd_subnet + module (#263) + - Add automatic schema validation functionality to mso_schema_template_deploy + and ndo_schema_template_deploy (#318) + - Add ndo_schema_template_deploy to support NDO 4+ deploy functionality (#305) + - Add support for l3out from different template or schema in mso_schema_site_bd_l3out + (#304) + - Add support for orchestrator_only attribute for mso_tenant with state absent + (#268) + release_summary: 'Release v2.2.0 of the ``ansible-mso`` collection on 2023-01-29. This changelog describes all changes made to the modules and plugins included in this collection since v2.1.0. - " - release_date: "2023-01-29" + ' + release_date: '2023-01-29' 2.2.1: changes: bugfixes: - - Fix datetime support for python2.7 in mso_backup_schedule (#323) - release_summary: - "Release v2.2.1 of the ``ansible-mso`` collection on 2023-01-31. + - Fix datetime support for python2.7 in mso_backup_schedule (#323) + release_summary: 'Release v2.2.1 of the ``ansible-mso`` collection on 2023-01-31. This changelog describes all changes made to the modules and plugins included in this collection since v2.2.0. - " - release_date: "2023-01-31" + ' + release_date: '2023-01-31' 2.3.0: changes: bugfixes: - - Fix idempotency for mso_schema_site_bd_l3out + - Fix idempotency for mso_schema_site_bd_l3out minor_changes: - - Add module mso_schema_site_anp_epg_bulk_staticport (#330) - - Add route_reachability attribute to mso_schema_site_external_epg module (#335) - release_summary: - "Release v2.3.0 of the ``ansible-mso`` collection on 2023-03-30. + - Add module mso_schema_site_anp_epg_bulk_staticport (#330) + - Add route_reachability attribute to mso_schema_site_external_epg module (#335) + release_summary: 'Release v2.3.0 of the ``ansible-mso`` collection on 2023-03-30. This changelog describes all changes made to the modules and plugins included in this collection since v2.2.1. - " - release_date: "2023-03-30" + ' + release_date: '2023-03-30' 2.4.0: changes: bugfixes: - - Add attributes to payload for changed schema behaviour of deploymentImmediacy - (deployImmediacy) and vmmDomainProperties (properties at domain level in payload) - (#362) - - Fix mso_backup for NDO and ND-based MSO v3.2+ (#333) - - Fix validation condition for path in mso_schema_site_anp_epg_bulk_staticport - module (#360) + - Add attributes to payload for changed schema behaviour of deploymentImmediacy + (deployImmediacy) and vmmDomainProperties (properties at domain level in payload) + (#362) + - Fix mso_backup for NDO and ND-based MSO v3.2+ (#333) + - Fix validation condition for path in mso_schema_site_anp_epg_bulk_staticport + module (#360) minor_changes: - - Add ip_data_plane_learning and preferred_group arguments to mso_schema_template_vrf - module (#358) - release_summary: - "Release v2.4.0 of the ``ansible-mso`` collection on 2023-04-19. + - Add ip_data_plane_learning and preferred_group arguments to mso_schema_template_vrf + module (#358) + release_summary: 'Release v2.4.0 of the ``ansible-mso`` collection on 2023-04-19. This changelog describes all changes made to the modules and plugins included in this collection since v2.3.0. - " - release_date: "2023-04-19" + ' + release_date: '2023-04-19' 2.5.0: changes: bugfixes: - - Fix mso_tenant_site "site not found" issue on absent (#368) + - Fix mso_tenant_site "site not found" issue on absent (#368) minor_changes: - - Add login domain attribute to mso httpapi connection plugin with restructure - of connection parameter handling - - Add mso_schema_template_anp_epg_useg_attribute and mso_schema_site_anp_epg_useg_attribute - modules to manage EPG uSeg attributes (#370) - release_summary: - "Release v2.5.0 of the ``ansible-mso`` collection on 2023-08-04. + - Add login domain attribute to mso httpapi connection plugin with restructure + of connection parameter handling + - Add mso_schema_template_anp_epg_useg_attribute and mso_schema_site_anp_epg_useg_attribute + modules to manage EPG uSeg attributes (#370) + release_summary: 'Release v2.5.0 of the ``ansible-mso`` collection on 2023-08-04. This changelog describes all changes made to the modules and plugins included in this collection since v2.4.0. - " - release_date: "2023-08-04" + ' + release_date: '2023-08-04' + 2.6.0: + changes: + bugfixes: + - Fix TypeError for iteration on NoneType in mso_schema_template + - Fixed the useg_subnet logic in mso_schema_template_anp_epg_useg_attribute + minor_changes: + - Add Azure Cloud site support to mso_schema_site_contract_service_graph + - Add Azure Cloud site support to mso_schema_site_service_graph + - Add functionality to resolve same name in remote and local user. + - Add l3out_template and l3out_schema arguments to mso_schema_site_external_epg + (#394) + - Add mso_schema_site_contract_service_graph module to manage site contract + service graph + - Add mso_schema_site_contract_service_graph_listener module to manage Azure + site contract service graph listeners and update other modules + - Add new parameter remote_user to add multiple remote users associated with + multiple login domains + - Add support for replacing all existing contracts with new provided contracts + in a single operation with one request and adding/removing multiple contracts + in multiple operations with a single request in mso_schema_template_anp_epg_contract + module + - Add support for replacing all existing static ports with new provided static + ports in a single operation with one request and adding/removing multiple + static ports in multiple operations with a single request in mso_schema_template_anp_epg_staticport + module + - Add support for required attributes introduced in NDO 4.2 for mso_schema_site_anp_epg_domain + - Support for creation of schemas without templates with the mso_schema module + release_summary: 'Release v2.6.0 of the ``ansible-mso`` collection on 2024-04-06. + + This changelog describes all changes made to the modules and plugins included + in this collection since v2.5.0. + + ' + release_date: '2024-04-06' diff --git a/ansible_collections/cisco/mso/meta/runtime.yml b/ansible_collections/cisco/mso/meta/runtime.yml index 9aeca0a48..9e42ab404 100644 --- a/ansible_collections/cisco/mso/meta/runtime.yml +++ b/ansible_collections/cisco/mso/meta/runtime.yml @@ -1,9 +1,14 @@ --- -requires_ansible: '>=2.9.10' +requires_ansible: '>=2.14.0' plugin_routing: modules: mso_schema_template_externalepg: redirect: cisco.mso.mso_schema_template_external_epg + mso_schema_site_anp_epg_bulk_staticport: + deprecation: + removal_version: 3.0.0 + warning_text: Use M(cisco.mso.mso_schema_site_anp_epg_staticport) with O(force_replace=true) + instead. action_groups: mso: - mso_backup @@ -31,6 +36,8 @@ action_groups: - mso_schema_site_bd - mso_schema_site_bd_l3out - mso_schema_site_bd_subnet + - mso_schema_site_contract_service_graph + - mso_schema_site_contract_service_graph_listener - mso_schema_site_external_epg - mso_schema_site_external_epg_selector - mso_schema_site_l3out @@ -101,6 +108,8 @@ action_groups: - mso_schema_site_bd - mso_schema_site_bd_l3out - mso_schema_site_bd_subnet + - mso_schema_site_contract_service_graph + - mso_schema_site_contract_service_graph_listener - mso_schema_site_external_epg - mso_schema_site_external_epg_selector - mso_schema_site_l3out diff --git a/ansible_collections/cisco/mso/plugins/module_utils/constants.py b/ansible_collections/cisco/mso/plugins/module_utils/constants.py index 2f3e0d472..ff08019df 100644 --- a/ansible_collections/cisco/mso/plugins/module_utils/constants.py +++ b/ansible_collections/cisco/mso/plugins/module_utils/constants.py @@ -16,7 +16,7 @@ SERVICE_NODE_CONNECTOR_MAP = { # 'external_epg': {'id': 'externalEpg', 'connector_type': 'route-peering'} } -YES_OR_NO_TO_BOOL_STRING_MAP = {"yes": "true", "no": "false"} +YES_OR_NO_TO_BOOL_STRING_MAP = {"yes": "true", "no": "false", True: "yes", False: "no"} NDO_4_UNIQUE_IDENTIFIERS = ["templateID", "autoRouteTargetImport", "autoRouteTargetExport"] @@ -38,3 +38,40 @@ EPG_U_SEG_ATTR_TYPE_MAP = { } EPG_U_SEG_ATTR_OPERATOR_LIST = ["equals", "contains", "starts_with", "ends_with"] + +AZURE_L4L7_CONNECTOR_TYPE_MAP = { + "none": "none", + "redirect": "redir", + "source_nat": "snat", + "destination_nat": "dnat", + "source_and_destination_nat": "snat_dnat", +} + +LISTENER_PROTOCOLS = ["http", "https", "tcp", "udp", "tls", "inherit"] + +LISTENER_SECURITY_POLICY_MAP = { + "default": "default", + "elb_sec_2016_18": "eLBSecurityPolicy-2016-08", + "elb_sec_fs_2018_06": "eLBSecurityPolicy-FS-2018-06", + "elb_sec_tls_1_2_2017_01": "eLBSecurityPolicy-TLS-1-2-2017-01", + "elb_sec_tls_1_2_ext_2018_06": "eLBSecurityPolicy-TLS-1-2-Ext-2018-06", + "elb_sec_tls_1_1_2017_01": "eLBSecurityPolicy-TLS-1-1-2017-01", + "elb_sec_2015_05": "eLBSecurityPolicy-2015-05", + "elb_sec_tls_1_0_2015_04": "eLBSecurityPolicy-TLS-1-0-2015-04", + "app_gw_ssl_default": "AppGwSslPolicyDefault", + "app_gw_ssl_2015_501": "AppGwSslPolicy20150501", + "app_gw_ssl_2017_401": "AppGwSslPolicy20170401", + "app_gw_ssl_2017_401s": "AppGwSslPolicy20170401S", +} + +LISTENER_ACTION_TYPE_MAP = {"fixed_response": "fixedResponse", "forward": "forward", "redirect": "redirect", "ha_port": "haPort"} + +LISTENER_CONTENT_TYPE_MAP = {"text_plain": "textPlain", "text_css": "textCSS", "text_html": "textHtml", "app_js": "appJS", "app_json": "appJson"} + +LISTENER_REDIRECT_CODE_MAP = { + "unknown": "unknown", + "permanently_moved": "permMoved", + "found": "found", + "see_other": "seeOther", + "temporary_redirect": "temporary", +} diff --git a/ansible_collections/cisco/mso/plugins/module_utils/mso.py b/ansible_collections/cisco/mso/plugins/module_utils/mso.py index 4bc9053ef..0f346d79b 100644 --- a/ansible_collections/cisco/mso/plugins/module_utils/mso.py +++ b/ansible_collections/cisco/mso/plugins/module_utils/mso.py @@ -22,7 +22,16 @@ from ansible.module_utils.six.moves.urllib.parse import urlencode, urljoin from ansible.module_utils.urls import fetch_url from ansible.module_utils._text import to_native, to_text from ansible.module_utils.connection import Connection -from ansible_collections.cisco.mso.plugins.module_utils.constants import NDO_API_VERSION_PATH_FORMAT +from ansible_collections.cisco.mso.plugins.module_utils.constants import ( + NDO_API_VERSION_PATH_FORMAT, + AZURE_L4L7_CONNECTOR_TYPE_MAP, + LISTENER_REDIRECT_CODE_MAP, + LISTENER_CONTENT_TYPE_MAP, + LISTENER_ACTION_TYPE_MAP, + LISTENER_PROTOCOLS, +) +from ansible_collections.cisco.nd.plugins.module_utils.nd import NDModule + try: from requests_toolbelt.multipart.encoder import MultipartEncoder @@ -50,7 +59,7 @@ def issubset(subset, superset): return True # Both objects have a different type - if type(subset) != type(superset): + if type(subset) is not type(superset): return False for key, value in subset.items(): @@ -205,7 +214,11 @@ def mso_service_graph_node_spec(): def mso_service_graph_node_device_spec(): return dict( - name=dict(type="str", required=True), + device_name=dict(type="str", aliases=["name"], required=True), + provider_connector_type=dict(type="str", choices=list(AZURE_L4L7_CONNECTOR_TYPE_MAP.keys())), + provider_interface=dict(type="str"), + consumer_connector_type=dict(type="str", choices=["none", "redirect"]), + consumer_interface=dict(type="str"), ) @@ -239,6 +252,13 @@ def mso_site_anp_epg_bulk_staticport_spec(): ) +def ndo_remote_user_spec(): + return dict( + name=dict(type="str", required=True), + login_domain=dict(type="str", required=True), + ) + + # Copied from ansible's module uri.py (url): https://github.com/ansible/ansible/blob/cdf62edc65f564fff6b7e575e084026fa7faa409/lib/ansible/modules/uri.py def write_file(module, url, dest, content, resp, tmpsrc=None): # create a tempfile with some test content @@ -321,6 +341,8 @@ class MSOModule(object): self.status = None self.url = None self.httpapi_logs = list() + self.site_type = None # on-premise or cloud + self.cloud_provider_type = None # aws or azure or gcp if self.module._debug: self.module.warn("Enable debug output because ANSIBLE_DEBUG was set.") @@ -845,6 +867,13 @@ class MSOModule(object): ids.append(dict(roleId=r.get("id"), accessType=access_type)) return ids + def lookup_site_type(self, site_data): + """Get site type(AWS, AZURE or physical)""" + site_type = site_data.get("platform") + if site_type == "cloud": + self.cloud_provider_type = site_data.get("cloudProviders")[0] + self.site_type = site_type + def lookup_site(self, site, ignore_not_found_error=False): """Look up a site and return its id""" if site is None: @@ -858,6 +887,8 @@ class MSOModule(object): return None if "id" not in s: self.fail_json(msg="Site lookup failed for site '{0}': {1}".format(site, s)) + + self.lookup_site_type(s) return s.get("id") def lookup_sites(self, sites, ignore_not_found_error=False): @@ -916,26 +947,65 @@ class MSOModule(object): users.append("admin") ids = [] + if self.platform == "nd": + nd = NDModule(self.module) + remote_users = nd.request("/nexus/infra/api/aaa/v4/remoteusers", method="GET") + local_users = nd.request("/nexus/infra/api/aaa/v4/localusers", method="GET") + for user in users: + user_dict = dict() if self.platform == "nd": - u = self.get_obj("users", loginID=user, api_version="v2") + user_dict = self.get_user_from_list_of_users(user, local_users) + if user_dict is None: + user_dict = self.get_user_from_list_of_users(user, remote_users) else: - u = self.get_obj("users", username=user) - if not u and not ignore_not_found_error: + user_dict = self.get_obj("users", username=user) + if not user_dict and not ignore_not_found_error: self.fail_json(msg="User '{0}' is not a valid user name.".format(user)) - elif (not u or "id" not in u) and ignore_not_found_error: + elif (not user_dict or "id" not in user_dict) and ignore_not_found_error: self.module.warn("User '{0}' is not a valid user name.".format(user)) return ids - if "id" not in u: - if "userID" not in u: - self.fail_json(msg="User lookup failed for user '{0}': {1}".format(user, u)) - id = dict(userId=u.get("userID")) + if "id" not in user_dict: + if "userID" not in user_dict: + self.fail_json(msg="User lookup failed for user '{0}': {1}".format(user, user_dict)) + id = dict(userId=user_dict.get("userID")) else: - id = dict(userId=u.get("id")) + id = dict(userId=user_dict.get("id")) if id in ids: self.fail_json(msg="User '{0}' is duplicate.".format(user)) ids.append(id) + return ids + def get_user_from_list_of_users(self, user_name, list_of_users, login_domain=""): + """Get user from list of users""" + for user in list_of_users.get("items"): + if user.get("spec").get("loginID") == user_name and (login_domain == "" or user.get("spec").get("loginDomain") == login_domain): + return user.get("spec") + return None + + def lookup_remote_users(self, remote_users, ignore_not_found_error=False): + ids = [] + if self.platform == "nd": + nd = NDModule(self.module) + remote_users_data = nd.request("/nexus/infra/api/aaa/v4/remoteusers", method="GET") + for remote_user in remote_users: + user_dict = dict() + if self.platform == "nd": + user_dict = self.get_user_from_list_of_users(remote_user.get("name"), remote_users_data, remote_user.get("login_domain")) + if not user_dict and not ignore_not_found_error: + self.fail_json(msg="User '{0}' is not a valid user name.".format(remote_user.get("name"))) + elif (not user_dict or "id" not in user_dict) and ignore_not_found_error: + self.module.warn("User '{0}' is not a valid user name.".format(remote_user.get("name"))) + return ids + if "id" not in user_dict: + if "userID" not in user_dict: + self.fail_json(msg="User lookup failed for user '{0}': {1}".format(remote_user.get("name"), user_dict)) + id = dict(userId=user_dict.get("userID")) + else: + id = dict(userId=user_dict.get("id")) + if id in ids: + self.fail_json(msg="User '{0}' is duplicate.".format(remote_user.get("name"))) + ids.append(id) return ids def create_label(self, label, label_type): @@ -1112,7 +1182,7 @@ class MSOModule(object): """Create a DHCP policy from input""" if data is None: return None - if type(data) == list: + if isinstance(data, list): dhcps = [] for dhcp in data: if "dhcp_option_policy" in dhcp: @@ -1330,6 +1400,9 @@ class MSOModule(object): return node_objs def lookup_service_node_device(self, site_id, tenant, device_name=None, service_node_type=None, ignore_not_found_error=False): + if self.site_type == "cloud": + tenant = "{0}/{1}".format(tenant, self.site_type) + if service_node_type is None: node_devices = self.query_objs("sites/{0}/aci/tenants/{1}/devices".format(site_id, tenant), key="devices") else: @@ -1393,3 +1466,121 @@ class MSOModule(object): def validate_schema(self, schema_id): return self.request("schemas/{id}/validate".format(id=schema_id), method="GET") + + def input_validation(self, attr_name, attr_value, required_attributes, target_object, object_position=None, object_name=None): + if attr_name in (None, "") or attr_value in (None, ""): + self.module.fail_json(msg="The attribute and value must be set") + + empty_attributes = [attribute for attribute in required_attributes if target_object.get(attribute) in (None, "", [], {}, 0)] + + if object_position is not None and object_name is not None and empty_attributes: + self.module.fail_json( + msg="When the '{0}' is '{1}', the {2} attributes must be set at the object position: {3} and the object name: {4}".format( + attr_name, attr_value, empty_attributes, object_position, object_name + ) + ) + elif object_position is not None and object_name is None and empty_attributes: + self.module.fail_json( + msg="When the '{0}' is '{1}', the {2} attributes must be set at the object position: {3}".format( + attr_name, attr_value, empty_attributes, object_position + ) + ) + elif object_position is None and object_name is not None and empty_attributes: + self.module.fail_json( + msg="When the '{0}' is '{1}', the {2} attributes must be set and the object name: {3}".format( + attr_name, attr_value, empty_attributes, object_name + ) + ) + elif empty_attributes: + self.module.fail_json(msg="When the '{0}' is '{1}', the {2} attributes must be set".format(attr_name, attr_value, empty_attributes)) + + +def service_node_ref_str_to_dict(serviceNodeRefStr): + serviceNodeRefTokens = serviceNodeRefStr.split("/") + return dict( + schemaId=serviceNodeRefTokens[2], + serviceGraphName=serviceNodeRefTokens[6], + serviceNodeName=serviceNodeRefTokens[8], + templateName=serviceNodeRefTokens[4], + ) + + +def mso_schema_site_contract_service_graph_spec(): + return dict( + cluster_interface_device=dict(type="str", required=True, aliases=["cluster_device", "device", "device_name"]), + provider_connector_cluster_interface=dict( + type="str", required=True, aliases=["provider_cluster_interface", "provider_interface", "provider_interface_name"] + ), + provider_connector_redirect_policy_tenant=dict(type="str", aliases=["provider_redirect_policy_tenant", "provider_tenant"]), + provider_connector_redirect_policy=dict(type="str", aliases=["provider_redirect_policy", "provider_policy"]), + consumer_connector_cluster_interface=dict( + type="str", required=True, aliases=["consumer_cluster_interface", "consumer_interface", "consumer_interface_name"] + ), + consumer_connector_redirect_policy_tenant=dict(type="str", aliases=["consumer_redirect_policy_tenant", "consumer_tenant"]), + consumer_connector_redirect_policy=dict(type="str", aliases=["consumer_redirect_policy", "consumer_policy"]), + consumer_subnet_ips=dict(type="list", elements="str"), + ) + + +def listener_ssl_certificates_spec(): + return dict( + name=dict(type="str", required=True), + certificate_store=dict(type="str", choices=["default", "iam", "acm"], required=True), + ) + + +def listener_rules_provider_epg_ref_spec(): + return dict( + schema=dict(type="str"), + template=dict(type="str"), + anp_name=dict(type="str", required=True, aliases=["anp"]), + epg_name=dict(type="str", required=True, aliases=["epg"]), + ) + + +def listener_rules_health_check_spec(): + return dict( + port=dict(type="int"), + protocol=dict(type="str", choices=LISTENER_PROTOCOLS), + path=dict(type="str"), + interval=dict(type="int"), + timeout=dict(type="int"), + unhealthy_threshold=dict(type="int"), + use_host_from_rule=dict(type="bool"), + success_code=dict(type="str"), + host=dict(type="str"), + ) + + +def listener_rules_spec(): + return dict( + name=dict(type="str", required=True), + floating_ip=dict(type="str"), + priority=dict(type="int", required=True), + host=dict(type="str"), + path=dict(type="str"), + action=dict(type="str"), + action_type=dict(type="str", required=True, choices=list(LISTENER_ACTION_TYPE_MAP)), + content_type=dict(type="str", choices=list(LISTENER_CONTENT_TYPE_MAP)), + port=dict(type="int"), + protocol=dict(type="str", choices=LISTENER_PROTOCOLS), + provider_epg=dict( + type="dict", + options=listener_rules_provider_epg_ref_spec(), + ), + url_type=dict(type="str", choices=["original", "custom"]), + custom_url=dict(type="str"), + redirect_host_name=dict(type="str"), + redirect_path=dict(type="str"), + redirect_query=dict(type="str"), + response_code=dict(type="str"), + response_body=dict(type="str"), + redirect_protocol=dict(type="str", choices=LISTENER_PROTOCOLS), + redirect_port=dict(type="int"), + redirect_code=dict(type="str", choices=list(LISTENER_REDIRECT_CODE_MAP)), + health_check=dict( + type="dict", + options=listener_rules_health_check_spec(), + ), + target_ip_type=dict(type="str", choices=["unspecified", "primary", "secondary"]), + ) diff --git a/ansible_collections/cisco/mso/plugins/module_utils/schema.py b/ansible_collections/cisco/mso/plugins/module_utils/schema.py index ce1bd36c7..75da0d1de 100644 --- a/ansible_collections/cisco/mso/plugins/module_utils/schema.py +++ b/ansible_collections/cisco/mso/plugins/module_utils/schema.py @@ -112,6 +112,24 @@ class MSOSchema: self.mso.fail_json(msg=msg) self.schema_objects["template_anp_epg"] = match + def set_template_anp_epg_contract(self, contract_ref, relation_type, fail_module=True): + """ + Get template endpoint group contract item that matches the reference and type of an contract. + :param contract_ref: Reference of the contract to match. -> Str + :param relation_type: Relation_type of the contract to match. -> Str + :param fail_module: When match is not found fail the ansible module. -> Bool + :return: Template epg item. -> Item(Int, Dict) | None + """ + self.validate_schema_objects_present(["template_anp_epg"]) + kv_list = [KVPair("contractRef", contract_ref), KVPair("relationshipType", relation_type)] + match, existing = self.get_object_from_list(self.schema_objects["template_anp_epg"].details.get("contractRelationships"), kv_list) + if not match and fail_module: + msg = "Provided Contract Reference '{0}' with type '{1}' not matching existing contacts(s): {2}".format( + contract_ref, relation_type, ", ".join(existing) + ) + self.mso.fail_json(msg=msg) + self.schema_objects["template_anp_epg_contract"] = match + def set_template_anp_epg_useg_attr(self, useg_attr, fail_module=True): """ Get template endpoint group item that matches the name of an EPG uSeg Attribute. @@ -237,3 +255,60 @@ class MSOSchema: msg = "Provided Site uSeg Attribute '{0}' does not match the existing Site uSeg Attribute(s): {1}".format(useg_attr, ", ".join(existing)) self.mso.fail_json(msg=msg) self.schema_objects["site_anp_epg_useg_attribute"] = match + + def set_site_contract(self, contract_name, fail_module=True): + """ + Get site contract item that matches the name of a contract. + :param contract_name: Name of the contract to match. -> Str + :param fail_module: When match is not found fail the ansible module. -> Bool + :return: Site contract item. -> Item(Int, Dict) | None + """ + self.validate_schema_objects_present(["template", "site"]) + kv_list = [ + KVPair( + "contractRef", self.mso.contract_ref(schema_id=self.id, template=self.schema_objects["template"].details.get("name"), contract=contract_name) + ) + ] + match, existing = self.get_object_from_list(self.schema_objects["site"].details.get("contracts"), kv_list) + if not match and fail_module: + msg = "Provided Contract '{0}' not matching existing site contract(s): {1}".format(contract_name, ", ".join(existing)) + self.mso.fail_json(msg=msg) + self.schema_objects["site_contract"] = match + + def set_site_service_graph(self, site_service_graph, fail_module=True): + """ + Get site item that matches the name of a service graph. + :param service_graph: Name of the service graph to match. -> Str + :param fail_module: When match is not found fail the ansible module. -> Bool + :return: Site service graph item. -> Item(Int, Dict) | None + """ + self.validate_schema_objects_present(["template", "site"]) + + kv_list = [ + KVPair( + "serviceGraphRef", + self.mso.service_graph_ref(schema_id=self.id, template=self.schema_objects["template"].details.get("name"), service_graph=site_service_graph), + ) + ] + + site_service_graph = self.schema_objects["site"].details.get("serviceGraphs") + match, existing = self.get_object_from_list(site_service_graph, kv_list) + if not match and fail_module: + msg = "Provided Site Service Graph '{0}' not matching existing site service graph(s): {1}".format(site_service_graph, ", ".join(existing)) + self.mso.fail_json(msg=msg) + self.schema_objects["site_service_graph"] = match + + def set_site_anp_epg_static_port(self, path, fail_module=True): + """ + Get site anp epg static port path item that matches the path of Static Port. + :param path: Path of the Static Port to match. -> Str + :param fail_module: When match is not found fail the ansible module. -> Bool + :return: Site anp epg item. -> Item(Int, Dict) | None + """ + self.validate_schema_objects_present(["site_anp_epg"]) + kv_list = [KVPair("path", path)] + match, existing = self.get_object_from_list(self.schema_objects["site_anp_epg"].details.get("staticPorts"), kv_list) + if not match and fail_module: + msg = "Provided Static Port Path '{0}' not matching existing static port path(s): {1}".format(path, ", ".join(existing)) + self.mso.fail_json(msg=msg) + self.schema_objects["site_anp_epg_static_port"] = match diff --git a/ansible_collections/cisco/mso/plugins/modules/mso_backup.py b/ansible_collections/cisco/mso/plugins/modules/mso_backup.py index fc2564b82..d7ceab4fb 100644 --- a/ansible_collections/cisco/mso/plugins/modules/mso_backup.py +++ b/ansible_collections/cisco/mso/plugins/modules/mso_backup.py @@ -83,7 +83,6 @@ EXAMPLES = r""" description: via Ansible location_type: local state: present - delegate_to: localhost - name: Create a new remote backup cisco.mso.mso_backup: @@ -95,7 +94,6 @@ EXAMPLES = r""" location_type: remote remote_location: ansible_test state: present - delegate_to: localhost - name: Move backup to remote location cisco.mso.mso_backup: @@ -106,7 +104,6 @@ EXAMPLES = r""" remote_location: ansible_test remote_path: test state: move - delegate_to: localhost - name: Download a backup cisco.mso.mso_backup: @@ -116,7 +113,6 @@ EXAMPLES = r""" backup: Backup destination: ./ state: download - delegate_to: localhost - name: Upload a backup cisco.mso.mso_backup: @@ -125,7 +121,6 @@ EXAMPLES = r""" password: SomeSecretPassword backup: ./Backup state: upload - delegate_to: localhost - name: Restore a backup cisco.mso.mso_backup: @@ -134,7 +129,6 @@ EXAMPLES = r""" password: SomeSecretPassword backup: Backup state: restore - delegate_to: localhost - name: Remove a Backup cisco.mso.mso_backup: @@ -143,7 +137,6 @@ EXAMPLES = r""" password: SomeSecretPassword backup: Backup state: absent - delegate_to: localhost - name: Query a backup cisco.mso.mso_backup: @@ -152,7 +145,6 @@ EXAMPLES = r""" password: SomeSecretPassword backup: Backup state: query - delegate_to: localhost register: query_result - name: Query a backup with its complete name @@ -162,7 +154,6 @@ EXAMPLES = r""" password: SomeSecretPassword backup: Backup_20200721220043 state: query - delegate_to: localhost register: query_result - name: Query all backups @@ -171,7 +162,6 @@ EXAMPLES = r""" username: admin password: SomeSecretPassword state: query - delegate_to: localhost register: query_result """ diff --git a/ansible_collections/cisco/mso/plugins/modules/mso_backup_schedule.py b/ansible_collections/cisco/mso/plugins/modules/mso_backup_schedule.py index e97b59b2e..a96c1da97 100644 --- a/ansible_collections/cisco/mso/plugins/modules/mso_backup_schedule.py +++ b/ansible_collections/cisco/mso/plugins/modules/mso_backup_schedule.py @@ -65,7 +65,7 @@ EXAMPLES = r""" username: admin password: SomeSecretPassword state: query - delegate_to: localhost + register: query_result - name: Set backup schedule cisco.mso.mso_backup_schedule: @@ -76,7 +76,6 @@ EXAMPLES = r""" frequency_length: 7 remote_location: ansible_test state: present - delegate_to: localhost - name: Set backup schedule with date and time cisco.mso.mso_backup_schedule: @@ -90,7 +89,6 @@ EXAMPLES = r""" start_time: 20:57:36 start_date: 2023-04-09 state: present - delegate_to: localhost - name: Delete backup schedule cisco.mso.mso_backup_schedule: @@ -98,7 +96,6 @@ EXAMPLES = r""" username: admin password: SomeSecretPassword state: absent - delegate_to: localhost """ RETURN = r""" diff --git a/ansible_collections/cisco/mso/plugins/modules/mso_dhcp_option_policy.py b/ansible_collections/cisco/mso/plugins/modules/mso_dhcp_option_policy.py index e9b7f23d3..7568c4704 100644 --- a/ansible_collections/cisco/mso/plugins/modules/mso_dhcp_option_policy.py +++ b/ansible_collections/cisco/mso/plugins/modules/mso_dhcp_option_policy.py @@ -56,7 +56,6 @@ EXAMPLES = r""" description: "My Test DHCP Policy" tenant: ansible_test state: present - delegate_to: localhost - name: Remove DHCP Option Policy cisco.mso.mso_dhcp_option_policy: @@ -65,7 +64,6 @@ EXAMPLES = r""" password: SomeSecretPassword dhcp_option_policy: my_test_dhcp_policy state: absent - delegate_to: localhost - name: Query a DHCP Option Policy cisco.mso.mso_dhcp_option_policy: @@ -74,7 +72,7 @@ EXAMPLES = r""" password: SomeSecretPassword dhcp_option_policy: my_test_dhcp_policy state: query - delegate_to: localhost + register: query_result - name: Query all DHCP Option Policies cisco.mso.mso_dhcp_option_policy: @@ -82,7 +80,7 @@ EXAMPLES = r""" username: admin password: SomeSecretPassword state: query - delegate_to: localhost + register: query_result """ RETURN = r""" diff --git a/ansible_collections/cisco/mso/plugins/modules/mso_dhcp_option_policy_option.py b/ansible_collections/cisco/mso/plugins/modules/mso_dhcp_option_policy_option.py index f4c397c24..4d5edd14f 100644 --- a/ansible_collections/cisco/mso/plugins/modules/mso_dhcp_option_policy_option.py +++ b/ansible_collections/cisco/mso/plugins/modules/mso_dhcp_option_policy_option.py @@ -63,7 +63,6 @@ EXAMPLES = r""" id: 1 data: Data stored in the option state: present - delegate_to: localhost - name: Remove a option to a DHCP Option Policy cisco.mso.mso_dhcp_option_policy_option: @@ -73,7 +72,6 @@ EXAMPLES = r""" dhcp_option_policy: my_test_dhcp_policy name: ansible_test state: absent - delegate_to: localhost - name: Query a option to a DHCP Option Policy cisco.mso.mso_dhcp_option_policy_option: @@ -83,7 +81,7 @@ EXAMPLES = r""" dhcp_option_policy: my_test_dhcp_policy name: ansible_test state: query - delegate_to: localhost + register: query_result - name: Query all option of a DHCP Option Policy cisco.mso.mso_dhcp_option_policy_option: @@ -92,7 +90,7 @@ EXAMPLES = r""" password: SomeSecretPassword dhcp_option_policy: my_test_dhcp_policy state: query - delegate_to: localhost + register: query_result """ RETURN = r""" diff --git a/ansible_collections/cisco/mso/plugins/modules/mso_dhcp_relay_policy.py b/ansible_collections/cisco/mso/plugins/modules/mso_dhcp_relay_policy.py index 394825feb..59fdf4db7 100644 --- a/ansible_collections/cisco/mso/plugins/modules/mso_dhcp_relay_policy.py +++ b/ansible_collections/cisco/mso/plugins/modules/mso_dhcp_relay_policy.py @@ -55,7 +55,6 @@ EXAMPLES = r""" description: "My Test DHCP Policy" tenant: ansible_test state: present - delegate_to: localhost - name: Remove DHCP Relay Policy cisco.mso.mso_dhcp_relay_policy: @@ -64,7 +63,6 @@ EXAMPLES = r""" password: SomeSecretPassword dhcp_relay_policy: my_test_dhcp_policy state: absent - delegate_to: localhost - name: Query a DHCP Relay Policy cisco.mso.mso_dhcp_relay_policy: @@ -73,7 +71,7 @@ EXAMPLES = r""" password: SomeSecretPassword dhcp_relay_policy: my_test_dhcp_policy state: query - delegate_to: localhost + register: query_result - name: Query all DHCP Relay Policies cisco.mso.mso_dhcp_relay_policy: @@ -81,7 +79,7 @@ EXAMPLES = r""" username: admin password: SomeSecretPassword state: query - delegate_to: localhost + register: query_result """ RETURN = r""" diff --git a/ansible_collections/cisco/mso/plugins/modules/mso_dhcp_relay_policy_provider.py b/ansible_collections/cisco/mso/plugins/modules/mso_dhcp_relay_policy_provider.py index 760d90430..e17ee92bc 100644 --- a/ansible_collections/cisco/mso/plugins/modules/mso_dhcp_relay_policy_provider.py +++ b/ansible_collections/cisco/mso/plugins/modules/mso_dhcp_relay_policy_provider.py @@ -82,7 +82,6 @@ EXAMPLES = r""" application_profile: ansible_test endpoint_group: ansible_test state: present - delegate_to: localhost - name: Remove a provider to a DHCP Relay Policy cisco.mso.mso_dhcp_relay_policy_provider: @@ -96,7 +95,6 @@ EXAMPLES = r""" application_profile: ansible_test endpoint_group: ansible_test state: absent - delegate_to: localhost - name: Query a provider to a DHCP Relay Policy cisco.mso.mso_dhcp_relay_policy_provider: @@ -110,7 +108,7 @@ EXAMPLES = r""" application_profile: ansible_test endpoint_group: ansible_test state: query - delegate_to: localhost + register: query_result - name: Query all provider of a DHCP Relay Policy cisco.mso.mso_dhcp_relay_policy_provider: @@ -119,7 +117,7 @@ EXAMPLES = r""" password: SomeSecretPassword dhcp_relay_policy: my_test_dhcp_policy state: query - delegate_to: localhost + register: query_result """ RETURN = r""" diff --git a/ansible_collections/cisco/mso/plugins/modules/mso_label.py b/ansible_collections/cisco/mso/plugins/modules/mso_label.py index f4f05f7de..2b65de521 100644 --- a/ansible_collections/cisco/mso/plugins/modules/mso_label.py +++ b/ansible_collections/cisco/mso/plugins/modules/mso_label.py @@ -49,7 +49,6 @@ EXAMPLES = r""" label: Belgium type: site state: present - delegate_to: localhost - name: Remove a label cisco.mso.mso_label: @@ -58,7 +57,6 @@ EXAMPLES = r""" password: SomeSecretPassword label: Belgium state: absent - delegate_to: localhost - name: Query a label cisco.mso.mso_label: @@ -67,7 +65,6 @@ EXAMPLES = r""" password: SomeSecretPassword label: Belgium state: query - delegate_to: localhost register: query_result - name: Query all labels @@ -76,7 +73,6 @@ EXAMPLES = r""" username: admin password: SomeSecretPassword state: query - delegate_to: localhost register: query_result """ diff --git a/ansible_collections/cisco/mso/plugins/modules/mso_remote_location.py b/ansible_collections/cisco/mso/plugins/modules/mso_remote_location.py index 10546563f..b3ec5e405 100644 --- a/ansible_collections/cisco/mso/plugins/modules/mso_remote_location.py +++ b/ansible_collections/cisco/mso/plugins/modules/mso_remote_location.py @@ -89,7 +89,6 @@ EXAMPLES = r""" username: admin password: SomeSecretPassword state: query - delegate_to: localhost register: backups - name: Query a remote location @@ -99,7 +98,7 @@ EXAMPLES = r""" password: SomeSecretPassword remote_location: ansible_test state: query - delegate_to: localhost + register: query_result - name: Configure a remote location cisco.mso.mso_remote_location: @@ -114,7 +113,6 @@ EXAMPLES = r""" remote_username: username remote_password: password state: present - delegate_to: localhost - name: Delete a remote location cisco.mso.mso_remote_location: @@ -123,7 +121,6 @@ EXAMPLES = r""" password: SomeSecretPassword remote_location: ansible_test state: absent - delegate_to: localhost """ RETURN = r""" diff --git a/ansible_collections/cisco/mso/plugins/modules/mso_rest.py b/ansible_collections/cisco/mso/plugins/modules/mso_rest.py index ae05b093b..04387c505 100644 --- a/ansible_collections/cisco/mso/plugins/modules/mso_rest.py +++ b/ansible_collections/cisco/mso/plugins/modules/mso_rest.py @@ -83,7 +83,6 @@ EXAMPLES = r""" "sites": [], "_updateVersion": 0 } - delegate_to: localhost - name: Query schema cisco.mso.mso_rest: @@ -92,7 +91,7 @@ EXAMPLES = r""" password: SomeSecretPassword path: /mso/api/v1/schemas method: get - delegate_to: localhost + register: query_result - name: Patch schema (YAML) cisco.mso.mso_rest: @@ -109,7 +108,6 @@ EXAMPLES = r""" displayName: AP2 epgs: [] _updateVersion: 0 - delegate_to: localhost - name: Add a tenant from a templated payload file from templates cisco.mso.mso_rest: @@ -119,7 +117,6 @@ EXAMPLES = r""" method: post path: /api/v1/tenants content: "{{ lookup('template', 'mso/tenant.json.j2') }}" - delegate_to: localhost """ RETURN = r""" diff --git a/ansible_collections/cisco/mso/plugins/modules/mso_role.py b/ansible_collections/cisco/mso/plugins/modules/mso_role.py index cfa4483b0..a99df655a 100644 --- a/ansible_collections/cisco/mso/plugins/modules/mso_role.py +++ b/ansible_collections/cisco/mso/plugins/modules/mso_role.py @@ -115,7 +115,6 @@ EXAMPLES = r""" - manage-tenant-schemas - manage-users state: present - delegate_to: localhost - name: Remove a role cisco.mso.mso_role: @@ -124,7 +123,6 @@ EXAMPLES = r""" password: SomeSecretPassword role: readOnly state: absent - delegate_to: localhost - name: Query a role cisco.mso.mso_role: @@ -133,7 +131,6 @@ EXAMPLES = r""" password: SomeSecretPassword role: readOnly state: query - delegate_to: localhost register: query_result - name: Query all roles @@ -142,7 +139,6 @@ EXAMPLES = r""" username: admin password: SomeSecretPassword state: query - delegate_to: localhost register: query_result """ diff --git a/ansible_collections/cisco/mso/plugins/modules/mso_schema.py b/ansible_collections/cisco/mso/plugins/modules/mso_schema.py index 2eba13ac9..7ba2df609 100644 --- a/ansible_collections/cisco/mso/plugins/modules/mso_schema.py +++ b/ansible_collections/cisco/mso/plugins/modules/mso_schema.py @@ -2,6 +2,8 @@ # -*- coding: utf-8 -*- # Copyright: (c) 2018, Dag Wieers (@dagwieers) <dag@wieers.com> +# Copyright: (c) 2023, Akini Ross (@akinross) <akinross@cisco.com> + # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) from __future__ import absolute_import, division, print_function @@ -18,21 +20,32 @@ description: - Manage schemas on Cisco ACI Multi-Site. author: - Dag Wieers (@dagwieers) +- Akini Ross (@akinross) options: schema: description: - The name of the schema. type: str aliases: [ name ] + id: + description: + - The id of the schema. + - This parameter is required when the C(schema) needs to be updated. + type: str + description: + description: + - The description of the schema. + type: str state: description: - Use C(absent) for removing. - Use C(query) for listing an object or multiple objects. + - Use C(present) for creating or updating. Only supported on versions of MSO that are 4.1 or greater. type: str - choices: [ absent, query ] + choices: [ absent, query, present ] default: query notes: -- Due to restrictions of the MSO REST API this module cannot create empty schemas (i.e. schemas without templates). +- Due to restrictions of the MSO REST API this module can only create empty schemas (i.e. schemas without templates) on versions of MSO that are 4.1 or greater. Use the M(cisco.mso.mso_schema_template) to automatically create schemas with templates. seealso: - module: cisco.mso.mso_schema_site @@ -41,6 +54,15 @@ extends_documentation_fragment: cisco.mso.modules """ EXAMPLES = r""" +- name: Create schema + cisco.mso.mso_schema: + host: mso_host + username: admin + password: SomeSecretPassword + schema: Schema 1 + state: present + delegate_to: localhost + - name: Remove schemas cisco.mso.mso_schema: host: mso_host @@ -48,7 +70,6 @@ EXAMPLES = r""" password: SomeSecretPassword schema: Schema 1 state: absent - delegate_to: localhost - name: Query a schema cisco.mso.mso_schema: @@ -57,7 +78,6 @@ EXAMPLES = r""" password: SomeSecretPassword schema: Schema 1 state: query - delegate_to: localhost register: query_result - name: Query all schemas @@ -66,7 +86,6 @@ EXAMPLES = r""" username: admin password: SomeSecretPassword state: query - delegate_to: localhost register: query_result """ @@ -81,12 +100,9 @@ def main(): argument_spec = mso_argument_spec() argument_spec.update( schema=dict(type="str", aliases=["name"]), - # messages=dict(type='dict'), - # associations=dict(type='list'), - # health_faults=dict(type='list'), - # references=dict(type='dict'), - # policy_states=dict(type='list'), - state=dict(type="str", default="query", choices=["absent", "query"]), + id=dict(type="str"), + description=dict(type="str"), + state=dict(type="str", default="query", choices=["absent", "query", "present"]), ) module = AnsibleModule( @@ -94,28 +110,48 @@ def main(): supports_check_mode=True, required_if=[ ["state", "absent", ["schema"]], + ["state", "present", ["schema"]], ], ) schema = module.params.get("schema") + schema_id = module.params.get("id") + description = module.params.get("description") state = module.params.get("state") mso = MSOModule(module) - - schema_id = None path = "schemas" # Query for existing object(s) if schema: - mso.existing = mso.get_obj(path, displayName=schema) + if schema_id: + mso.existing = mso.get_obj(path, id=schema_id) + else: + mso.existing = mso.get_obj(path, displayName=schema) + if mso.existing: - schema_id = mso.existing.get("id") + if not schema_id: + schema_id = mso.existing.get("id") path = "schemas/{id}".format(id=schema_id) else: mso.existing = mso.query_objs(path) - if state == "query": - pass + mso.previous = mso.existing + if state == "present": + mso.sanitize(dict(displayName=schema, id=schema_id, description=description), collate=True) + if mso.existing: + ops = [] + if mso.existing.get("displayName") != schema: + ops.append(dict(op="replace", path="/displayName", value=schema)) + if mso.existing.get("description") != description and description is not None: + ops.append(dict(op="replace", path="/description", value=description)) + + if not module.check_mode: + mso.request(path, method="PATCH", data=ops) + else: + if not module.check_mode: + mso.request(path, method="POST", data=dict(displayName=schema, description=description)) + mso.existing = mso.proposed elif state == "absent": mso.previous = mso.existing diff --git a/ansible_collections/cisco/mso/plugins/modules/mso_schema_clone.py b/ansible_collections/cisco/mso/plugins/modules/mso_schema_clone.py index 840fb12ca..f02322f9e 100644 --- a/ansible_collections/cisco/mso/plugins/modules/mso_schema_clone.py +++ b/ansible_collections/cisco/mso/plugins/modules/mso_schema_clone.py @@ -49,7 +49,6 @@ EXAMPLES = r""" source_schema: Source_Schema destination_schema: Destination_Schema state: clone - delegate_to: localhost """ RETURN = r""" diff --git a/ansible_collections/cisco/mso/plugins/modules/mso_schema_site.py b/ansible_collections/cisco/mso/plugins/modules/mso_schema_site.py index 83a5213a2..b8e1a7cda 100644 --- a/ansible_collections/cisco/mso/plugins/modules/mso_schema_site.py +++ b/ansible_collections/cisco/mso/plugins/modules/mso_schema_site.py @@ -58,7 +58,6 @@ EXAMPLES = r""" site: Site1 template: Template 1 state: present - delegate_to: localhost - name: Remove a site from a schema cisco.mso.mso_schema_site: @@ -69,7 +68,6 @@ EXAMPLES = r""" site: Site1 template: Template 1 state: absent - delegate_to: localhost - name: Query a schema site cisco.mso.mso_schema_site: @@ -80,7 +78,6 @@ EXAMPLES = r""" site: Site1 template: Template 1 state: query - delegate_to: localhost register: query_result - name: Query all schema sites @@ -90,7 +87,6 @@ EXAMPLES = r""" password: SomeSecretPassword schema: Schema 1 state: query - delegate_to: localhost register: query_result """ diff --git a/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_anp.py b/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_anp.py index 0552b6a31..39c5225cd 100644 --- a/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_anp.py +++ b/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_anp.py @@ -64,7 +64,6 @@ EXAMPLES = r""" template: Template1 anp: ANP1 state: present - delegate_to: localhost - name: Remove a site ANP cisco.mso.mso_schema_site_anp: @@ -76,7 +75,6 @@ EXAMPLES = r""" template: Template1 anp: ANP1 state: absent - delegate_to: localhost - name: Query a specific site ANP cisco.mso.mso_schema_site_anp: @@ -88,7 +86,6 @@ EXAMPLES = r""" template: Template1 anp: ANP1 state: query - delegate_to: localhost register: query_result - name: Query all site ANPs @@ -100,7 +97,6 @@ EXAMPLES = r""" site: Site1 template: Template1 state: query - delegate_to: localhost register: query_result """ diff --git a/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_anp_epg.py b/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_anp_epg.py index 1c2ad6433..6c23a0ca0 100644 --- a/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_anp_epg.py +++ b/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_anp_epg.py @@ -75,7 +75,6 @@ EXAMPLES = r""" anp: ANP1 epg: EPG1 state: present - delegate_to: localhost - name: Remove a site EPG cisco.mso.mso_schema_site_anp_epg: @@ -88,7 +87,6 @@ EXAMPLES = r""" anp: ANP1 epg: EPG1 state: absent - delegate_to: localhost - name: Query a specific site EPGs cisco.mso.mso_schema_site_anp_epg: @@ -101,7 +99,6 @@ EXAMPLES = r""" anp: ANP1 epg: EPG1 state: query - delegate_to: localhost register: query_result - name: Query all site EPGs @@ -114,7 +111,6 @@ EXAMPLES = r""" template: Template1 anp: ANP1 state: query - delegate_to: localhost register: query_result """ diff --git a/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_anp_epg_bulk_staticport.py b/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_anp_epg_bulk_staticport.py index eda60cfd1..aa302a991 100644 --- a/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_anp_epg_bulk_staticport.py +++ b/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_anp_epg_bulk_staticport.py @@ -164,6 +164,10 @@ notes: seealso: - module: cisco.mso.mso_schema_site_anp_epg - module: cisco.mso.mso_schema_template_anp_epg +deprecated: + removed_in: 3.0.0 + alternative: Use M(cisco.mso.mso_schema_site_anp_epg_staticport) with option `force_replace=true` instead. + why: The module has been merged to centralise all static port functionality into M(cisco.mso.mso_schema_site_anp_epg_staticport). extends_documentation_fragment: cisco.mso.modules """ @@ -190,7 +194,6 @@ EXAMPLES = r""" - path: eth1/3 vlan: 124 state: present - delegate_to: localhost - name: Add a new static fex port to a site EPG cisco.mso.mso_schema_site_anp_epg_bulk_staticport: @@ -215,7 +218,6 @@ EXAMPLES = r""" vlan: 124 - fex: 151 state: present - delegate_to: localhost - name: Add a new static VPC to a site EPG cisco.mso.mso_schema_site_anp_epg_bulk_staticport: @@ -245,7 +247,6 @@ EXAMPLES = r""" mode: untagged deployment_immediacy: lazy state: present - delegate_to: localhost - name: Remove static ports from a site EPG cisco.mso.mso_schema_site_anp_epg_bulk_staticport: @@ -258,7 +259,6 @@ EXAMPLES = r""" anp: ANP1 epg: EPG1 state: absent - delegate_to: localhost - name: Query all site EPG static ports cisco.mso.mso_schema_site_anp_epg_bulk_staticport: @@ -270,7 +270,6 @@ EXAMPLES = r""" template: Template1 anp: ANP1 state: query - delegate_to: localhost register: query_result """ diff --git a/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_anp_epg_domain.py b/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_anp_epg_domain.py index c684a27be..4e6097f7f 100644 --- a/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_anp_epg_domain.py +++ b/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_anp_epg_domain.py @@ -2,6 +2,8 @@ # -*- coding: utf-8 -*- # Copyright: (c) 2019, Nirav Katarmal (@nkatarmal-crest) <nirav.katarmal@crestdatasys.com> +# Copyright: (c) 2023, Mabille Florent (@fmabille09) <florent.mabille@smals.be> +# Copyright: (c) 2024, Akini Ross (@akinross) <akinross@cisco.com> # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) from __future__ import absolute_import, division, print_function @@ -18,6 +20,8 @@ description: - Manage site-local EPG domains in schema template on Cisco ACI Multi-Site. author: - Nirav Katarmal (@nkatarmal-crest) +- Mabille Florent (@fmabille09) +- Akini Ross (@akinross) options: schema: description: @@ -68,46 +72,95 @@ options: choices: [ immediate, lazy, pre-provision ] micro_seg_vlan_type: description: - - Virtual LAN type for microsegmentation. This attribute can only be used with vmmDomain domain association. - - vlan is currently the only accepted value. + - Virtual LAN type for microsegmentation. This attribute can only be used with VMM domain association. type: str + choices: [ vlan ] micro_seg_vlan: description: - - Virtual LAN for microsegmentation. This attribute can only be used with vmmDomain domain association. + - Virtual LAN for microsegmentation. This attribute can only be used with VMM domain association. type: int port_encap_vlan_type: description: - - Virtual LAN type for port encap. This attribute can only be used with vmmDomain domain association. - - vlan is currently the only accepted value. + - Virtual LAN type for port encap. This attribute can only be used with VMM domain association. type: str + choices: [ vlan ] port_encap_vlan: description: - - Virtual LAN type for port encap. This attribute can only be used with vmmDomain domain association. + - Virtual LAN type for port encap. This attribute can only be used with VMM domain association. type: int vlan_encap_mode: description: - - Which VLAN enacap mode to use. This attribute can only be used with vmmDomain domain association. + - Which VLAN enacap mode to use. This attribute can only be used with VMM domain association. type: str choices: [ static, dynamic ] allow_micro_segmentation: description: - - Specifies microsegmentation is enabled or not. This attribute can only be used with vmmDomain domain association. + - Specifies microsegmentation is enabled or not. This attribute can only be used with VMM domain association. type: bool switch_type: description: - - Which switch type to use with this domain association. This attribute can only be used with vmmDomain domain association. + - Which switch type to use with this domain association. This attribute can only be used with VMM domain association. type: str switching_mode: description: - - Which switching mode to use with this domain association. This attribute can only be used with vmmDomain domain association. + - Which switching mode to use with this domain association. This attribute can only be used with VMM domain association. type: str enhanced_lagpolicy_name: description: - - EPG enhanced lagpolicy name. This attribute can only be used with vmmDomain domain association. + - EPG enhanced lagpolicy name. This attribute can only be used with VMM domain association. type: str enhanced_lagpolicy_dn: description: - - Distinguished name of EPG lagpolicy. This attribute can only be used with vmmDomain domain association. + - Distinguished name of EPG lagpolicy. This attribute can only be used with VMM domain association. + type: str + delimiter: + description: + - Which delimiter to use with this domain association. This attribute can only be used with VMM domain association. + type: str + choices: [ '+', '|', '~', '!', '@', '^', '=' ] + binding_type: + description: + - Which binding_type to use with this domain association. This attribute can only be used with VMM domain association. + type: str + default: none + choices: [ static, dynamic, none, ephemeral ] + num_ports: + description: + - Number of ports for the binding type. This attribute can only be used with VMM domain association. + type: int + port_allocation: + description: + - Port allocation for the binding type. This attribute can only be used with VMM domain association and binding type in static. + - Required when O(binding_type=static). + type: str + choices: [ elastic, fixed ] + netflow_pref: + description: + - The netflow preference state of the domain association. This attribute can only be used with VMM domain association. + type: str + default: disabled + choices: [ enabled, disabled ] + allow_promiscuous: + description: + - The allow promiscuous state of the domain association. This attribute can only be used with VMM domain association. + type: str + default: reject + choices: [ accept, reject ] + forged_transmits: + description: + - The forged transmits state of the domain association. This attribute can only be used with VMM domain association. + type: str + default: reject + choices: [ accept, reject ] + mac_changes: + description: + - The mac changes state of the domain association. This attribute can only be used with VMM domain association. + type: str + default: reject + choices: [ accept, reject ] + custom_epg_name: + description: + - Which custom_epg_name to use with this domain association. This attribute can only be used with VMM domain association. type: str state: description: @@ -142,9 +195,8 @@ EXAMPLES = r""" deployment_immediacy: lazy resolution_immediacy: pre-provision state: present - delegate_to: localhost -- name: Remove a domain from a site EPG +- name: Add a new domain to a site EPG with all possible attributes set cisco.mso.mso_schema_site_anp_epg_domain: host: mso_host username: admin @@ -156,10 +208,28 @@ EXAMPLES = r""" epg: EPG1 domain_association_type: vmmDomain domain_profile: 'VMware-VMM' - deployment_immediacy: lazy - resolution_immediacy: pre-provision - state: absent - delegate_to: localhost + deployment_immediacy: immediate + resolution_immediacy: immediate + micro_seg_vlan_type: vlan + micro_seg_vlan: 100 + port_encap_vlan_type: vlan + port_encap_vlan: 100 + vlan_encap_mode: static + allow_micro_segmentation: true + switch_type: default + switching_mode: native + enhanced_lagpolicy_name: ansible_lag_name + enhanced_lagpolicy_dn: ansible_lag_dn + delimiter: '|' + binding_type: static + num_ports: 2 + port_allocation: elastic + netflow_pref: enabled + allow_promiscuous: accept + forged_transmits: accept + mac_changes: accept + custom_epg_name: ansible_custom_epg + state: present - name: Query a domain associated with a specific site EPG cisco.mso.mso_schema_site_anp_epg_domain: @@ -174,7 +244,6 @@ EXAMPLES = r""" domain_association_type: vmmDomain domain_profile: 'VMware-VMM' state: query - delegate_to: localhost register: query_result - name: Query all domains associated with a site EPG @@ -188,8 +257,23 @@ EXAMPLES = r""" anp: ANP1 epg: EPG1 state: query - delegate_to: localhost register: query_result + +- name: Remove a domain from a site EPG + cisco.mso.mso_schema_site_anp_epg_domain: + host: mso_host + username: admin + password: SomeSecretPassword + schema: Schema1 + site: Site1 + template: Template1 + anp: ANP1 + epg: EPG1 + domain_association_type: vmmDomain + domain_profile: 'VMware-VMM' + deployment_immediacy: lazy + resolution_immediacy: pre-provision + state: absent """ RETURN = r""" @@ -212,9 +296,9 @@ def main(): deployment_immediacy=dict(type="str", choices=["immediate", "lazy"]), resolution_immediacy=dict(type="str", choices=["immediate", "lazy", "pre-provision"]), state=dict(type="str", default="present", choices=["absent", "present", "query"]), - micro_seg_vlan_type=dict(type="str"), + micro_seg_vlan_type=dict(type="str", choices=["vlan"]), micro_seg_vlan=dict(type="int"), - port_encap_vlan_type=dict(type="str"), + port_encap_vlan_type=dict(type="str", choices=["vlan"]), port_encap_vlan=dict(type="int"), vlan_encap_mode=dict(type="str", choices=["static", "dynamic"]), allow_micro_segmentation=dict(type="bool"), @@ -222,6 +306,15 @@ def main(): switching_mode=dict(type="str"), enhanced_lagpolicy_name=dict(type="str"), enhanced_lagpolicy_dn=dict(type="str"), + binding_type=dict(type="str", default="none", choices=["dynamic", "ephemeral", "none", "static"]), + port_allocation=dict(type="str", choices=["elastic", "fixed"]), + num_ports=dict(type="int"), + netflow_pref=dict(type="str", default="disabled", choices=["enabled", "disabled"]), + allow_promiscuous=dict(type="str", default="reject", choices=["accept", "reject"]), + forged_transmits=dict(type="str", default="reject", choices=["accept", "reject"]), + mac_changes=dict(type="str", default="reject", choices=["accept", "reject"]), + delimiter=dict(type="str", choices=["+", "|", "~", "!", "@", "^", "="]), + custom_epg_name=dict(type="str"), ) module = AnsibleModule( @@ -230,6 +323,12 @@ def main(): required_if=[ ["state", "absent", ["domain_association_type", "domain_profile", "deployment_immediacy", "resolution_immediacy"]], ["state", "present", ["domain_association_type", "domain_profile", "deployment_immediacy", "resolution_immediacy"]], + ["binding_type", "static", ["port_allocation"]], + ], + required_together=[ + ("micro_seg_vlan_type", "micro_seg_vlan"), + ("port_encap_vlan_type", "port_encap_vlan"), + ("enhanced_lagpolicy_name", "enhanced_lagpolicy_dn"), ], ) @@ -253,6 +352,15 @@ def main(): switching_mode = module.params.get("switching_mode") enhanced_lagpolicy_name = module.params.get("enhanced_lagpolicy_name") enhanced_lagpolicy_dn = module.params.get("enhanced_lagpolicy_dn") + binding_type = module.params.get("binding_type") + port_allocation = module.params.get("port_allocation") + num_ports = module.params.get("num_ports") + netflow_pref = module.params.get("netflow_pref") + allow_promiscuous = module.params.get("allow_promiscuous") + forged_transmits = module.params.get("forged_transmits") + mac_changes = module.params.get("mac_changes") + delimiter = module.params.get("delimiter") + custom_epg_name = module.params.get("custom_epg_name") mso = MSOModule(module) @@ -397,46 +505,54 @@ def main(): if domain_association_type == "vmmDomain": vmmDomainProperties = {} if micro_seg_vlan_type and micro_seg_vlan: - microSegVlan = dict(vlanType=micro_seg_vlan_type, vlan=micro_seg_vlan) - vmmDomainProperties["microSegVlan"] = microSegVlan - elif not micro_seg_vlan_type and micro_seg_vlan: - mso.fail_json(msg="micro_seg_vlan_type is required when micro_seg_vlan is provided.") - elif micro_seg_vlan_type and not micro_seg_vlan: - mso.fail_json(msg="micro_seg_vlan is required when micro_seg_vlan_type is provided.") + vmmDomainProperties["microSegVlan"] = dict(vlanType=micro_seg_vlan_type, vlan=micro_seg_vlan) if port_encap_vlan_type and port_encap_vlan: - portEncapVlan = dict(vlanType=port_encap_vlan_type, vlan=port_encap_vlan) - vmmDomainProperties["portEncapVlan"] = portEncapVlan - elif not port_encap_vlan_type and port_encap_vlan: - mso.fail_json(msg="port_encap_vlan_type is required when port_encap_vlan is provided.") - elif port_encap_vlan_type and not port_encap_vlan: - mso.fail_json(msg="port_encap_vlan is required when port_encap_vlan_type is provided.") + vmmDomainProperties["portEncapVlan"] = dict(vlanType=port_encap_vlan_type, vlan=port_encap_vlan) if vlan_encap_mode: vmmDomainProperties["vlanEncapMode"] = vlan_encap_mode - if allow_micro_segmentation: + if allow_micro_segmentation is not None: vmmDomainProperties["allowMicroSegmentation"] = allow_micro_segmentation + if switch_type: vmmDomainProperties["switchType"] = switch_type + if switching_mode: vmmDomainProperties["switchingMode"] = switching_mode if enhanced_lagpolicy_name and enhanced_lagpolicy_dn: - enhancedLagPol = dict(name=enhanced_lagpolicy_name, dn=enhanced_lagpolicy_dn) - epgLagPol = dict(enhancedLagPol=enhancedLagPol) - vmmDomainProperties["epgLagPol"] = epgLagPol - elif not enhanced_lagpolicy_name and enhanced_lagpolicy_dn: - mso.fail_json(msg="enhanced_lagpolicy_name is required when enhanced_lagpolicy_dn is provided.") - elif enhanced_lagpolicy_name and not enhanced_lagpolicy_dn: - mso.fail_json(msg="enhanced_lagpolicy_dn is required when enhanced_lagpolicy_name is provided.") + vmmDomainProperties["epgLagPol"] = dict(enhancedLagPol=dict(name=enhanced_lagpolicy_name, dn=enhanced_lagpolicy_dn)) + + if delimiter: + vmmDomainProperties["delimiter"] = delimiter + + if binding_type: + vmmDomainProperties["bindingType"] = binding_type + vmmDomainProperties["numPorts"] = num_ports + + if port_allocation: + vmmDomainProperties["portAllocation"] = port_allocation + + if netflow_pref: + vmmDomainProperties["netflowPref"] = netflow_pref + + if allow_promiscuous: + vmmDomainProperties["allowPromiscuous"] = allow_promiscuous + + if forged_transmits: + vmmDomainProperties["forgedTransmits"] = forged_transmits + + if mac_changes: + vmmDomainProperties["macChanges"] = mac_changes + + if custom_epg_name: + vmmDomainProperties["customEpgName"] = custom_epg_name if vmmDomainProperties: new_domain["vmmDomainProperties"] = vmmDomainProperties - properties = ["allowMicroSegmentation", "epgLagPol", "switchType", "switchingMode", "vlanEncapMode", "portEncapVlan", "microSegVlan"] - for property in properties: - if property in vmmDomainProperties: - new_domain[property] = vmmDomainProperties[property] + new_domain.update(vmmDomainProperties) # If payload is empty, anp and EPG already exist at site level if not payload: diff --git a/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_anp_epg_selector.py b/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_anp_epg_selector.py index ffd3c682e..54780ceed 100644 --- a/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_anp_epg_selector.py +++ b/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_anp_epg_selector.py @@ -103,7 +103,6 @@ EXAMPLES = r""" operator: in value: test state: present - delegate_to: localhost - name: Remove a Selector from a site EPG cisco.mso.mso_schema_site_anp_epg_selector: @@ -117,7 +116,6 @@ EXAMPLES = r""" epg: EPG 1 selector: selector_1 state: absent - delegate_to: localhost - name: Query a specific Selector cisco.mso.mso_schema_site_anp_epg_selector: @@ -131,7 +129,6 @@ EXAMPLES = r""" epg: EPG 1 selector: selector_1 state: query - delegate_to: localhost register: query_result - name: Query all Selectors @@ -145,7 +142,6 @@ EXAMPLES = r""" anp: ANP 1 epg: EPG 1 state: query - delegate_to: localhost register: query_result """ diff --git a/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_anp_epg_staticleaf.py b/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_anp_epg_staticleaf.py index 01e2ac386..64a2bcddb 100644 --- a/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_anp_epg_staticleaf.py +++ b/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_anp_epg_staticleaf.py @@ -88,7 +88,6 @@ EXAMPLES = r""" leaf: Leaf1 vlan: 123 state: present - delegate_to: localhost - name: Remove a static leaf from a site EPG cisco.mso.mso_schema_site_anp_epg_staticleaf: @@ -102,7 +101,6 @@ EXAMPLES = r""" epg: EPG1 leaf: Leaf1 state: absent - delegate_to: localhost - name: Query a specific site EPG static leaf cisco.mso.mso_schema_site_anp_epg_staticleaf: @@ -116,7 +114,6 @@ EXAMPLES = r""" epg: EPG1 leaf: Leaf1 state: query - delegate_to: localhost register: query_result - name: Query all site EPG static leafs @@ -129,7 +126,6 @@ EXAMPLES = r""" template: Template1 anp: ANP1 state: query - delegate_to: localhost register: query_result """ diff --git a/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_anp_epg_staticport.py b/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_anp_epg_staticport.py index d05336c52..d22ae1fcf 100644 --- a/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_anp_epg_staticport.py +++ b/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_anp_epg_staticport.py @@ -2,6 +2,7 @@ # -*- coding: utf-8 -*- # Copyright: (c) 2019, Dag Wieers (@dagwieers) <dag@wieers.com> +# Copyright: (c) 2024, Akini Ross (@akinross) <akinross@cisco.com> # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) from __future__ import absolute_import, division, print_function @@ -18,6 +19,7 @@ description: - Manage site-local EPG static ports in schema template on Cisco ACI Multi-Site. author: - Dag Wieers (@dagwieers) +- Akini Ross (@akinross) options: schema: description: @@ -47,9 +49,9 @@ options: type: description: - The path type of the static port - - vpc is used for a Virtual Port Channel - - dpc is used for a Direct Port Channel - - port is used for a single interface + - C(vpc) is used for a Virtual Port Channel + - C(dpc) is used for a Direct Port Channel + - C(port) is used for a single interface type: str choices: [ port, vpc, dpc ] default: port @@ -94,6 +96,75 @@ options: description: - Primary micro-seg VLAN of static port. type: int + force_replace: + description: + - Replaces all the configured static port(s) with the provided static port(s). + - This option can only be used in combination with the O(static_ports) option. + - In combination with the O(state=absent) and without any static port configuration all configured static port(s) will be removed. + type: bool + static_ports: + description: + - A list of Static Ports associated to this EPG. + - All configured Static Ports will be replaced with the provided Static Ports when used with O(force_replace=true). + - Only the provided Static Ports will be added, updated or removed when used with O(force_replace=false). + - In combination with the O(state=query) all provided Static Ports must be found else the task will fail. + - When I(static_ports) attributes are not provided the module attributes will be used. + - For each Static Ports provided in the list, the following attributes must be resolved + - I(static_ports.type) + - I(static_ports.pod) + - I(static_ports.leaf) + - I(static_ports.path) + - I(static_ports.vlan) + type: list + elements: dict + suboptions: + type: + description: + - The path type of the static port + - C(vpc) is used for a Virtual Port Channel + - C(dpc) is used for a Direct Port Channel + - C(port) is used for a single interface + type: str + choices: [ port, vpc, dpc ] + pod: + description: + - The pod of the static port. + type: str + leaf: + description: + - The leaf of the static port. + type: str + fex: + description: + - The fex id of the static port. + type: str + path: + description: + - The path of the static port. + type: str + vlan: + description: + - The port encapsulation VLAN id of the static port. + type: int + deployment_immediacy: + description: + - The deployment immediacy of the static port. + - C(immediate) means B(Deploy immediate). + - C(lazy) means B(Deploy on demand). + type: str + choices: [ immediate, lazy ] + mode: + description: + - The mode of the static port. + - C(native) means B(Access (802.1p)). + - C(regular) means B(Trunk). + - C(untagged) means B(Access (untagged)). + type: str + choices: [ native, regular, untagged ] + primary_micro_segment_vlan: + description: + - Primary micro-seg VLAN of static port. + type: int state: description: - Use C(present) or C(absent) for adding or removing. @@ -129,7 +200,6 @@ EXAMPLES = r""" vlan: 126 deployment_immediacy: immediate state: present - delegate_to: localhost - name: Add a new static fex port to a site EPG mso_schema_site_anp_epg_staticport: @@ -149,7 +219,6 @@ EXAMPLES = r""" vlan: 126 deployment_immediacy: lazy state: present - delegate_to: localhost - name: Add a new static VPC to a site EPG mso_schema_site_anp_epg_staticport: @@ -169,9 +238,8 @@ EXAMPLES = r""" mode: untagged deployment_immediacy: lazy state: present - delegate_to: localhost -- name: Remove a static port from a site EPG +- name: Add two new static port to a site EPG cisco.mso.mso_schema_site_anp_epg_staticport: host: mso_host username: admin @@ -181,12 +249,40 @@ EXAMPLES = r""" template: Template1 anp: ANP1 epg: EPG1 - type: port - pod: pod-1 - leaf: 101 - path: eth1/1 - state: absent - delegate_to: localhost + static_ports: + - pod: pod-1 + leaf: 101 + path: eth1/1 + vlan: 126 + - pod: pod-2 + leaf: 101 + path: eth2/1 + vlan: 128 + deployment_immediacy: immediate + state: present + +- name: Replace all existing static pors on a site EPG with 2 new static ports + cisco.mso.mso_schema_site_anp_epg_staticport: + host: mso_host + username: admin + password: SomeSecretPassword + schema: Schema1 + site: Site1 + template: Template1 + anp: ANP1 + epg: EPG1 + force_replace: true + static_ports: + - pod: pod-1 + leaf: 101 + path: eth1/1 + vlan: 126 + - pod: pod-2 + leaf: 101 + path: eth2/1 + vlan: 128 + deployment_immediacy: immediate + state: present - name: Query a specific site EPG static port cisco.mso.mso_schema_site_anp_epg_staticport: @@ -203,7 +299,28 @@ EXAMPLES = r""" leaf: 101 path: eth1/1 state: query - delegate_to: localhost + register: query_result + +- name: Query a list of static ports + cisco.mso.mso_schema_site_anp_epg_staticport: + host: mso_host + username: admin + password: SomeSecretPassword + schema: Schema1 + site: Site1 + template: Template1 + anp: ANP1 + epg: EPG1 + static_ports: + - pod: pod-1 + leaf: 101 + path: eth1/1 + vlan: 126 + - pod: pod-2 + leaf: 101 + path: eth2/1 + vlan: 128 + state: query register: query_result - name: Query all site EPG static ports @@ -216,15 +333,66 @@ EXAMPLES = r""" template: Template1 anp: ANP1 state: query - delegate_to: localhost register: query_result + +- name: Remove a static port from a site EPG + cisco.mso.mso_schema_site_anp_epg_staticport: + host: mso_host + username: admin + password: SomeSecretPassword + schema: Schema1 + site: Site1 + template: Template1 + anp: ANP1 + epg: EPG1 + type: port + pod: pod-1 + leaf: 101 + path: eth1/1 + state: absent + +- name: Remove two static ports from a site EPG + cisco.mso.mso_schema_site_anp_epg_staticport: + host: mso_host + username: admin + password: SomeSecretPassword + schema: Schema1 + site: Site1 + template: Template1 + anp: ANP1 + epg: EPG1 + static_ports: + - pod: pod-1 + leaf: 101 + path: eth1/1 + vlan: 126 + - pod: pod-2 + leaf: 101 + path: eth2/1 + vlan: 128 + deployment_immediacy: immediate + state: absent + +- name: Remove all existing static pors from a site EPG + cisco.mso.mso_schema_site_anp_epg_staticport: + host: mso_host + username: admin + password: SomeSecretPassword + schema: Schema1 + site: Site1 + template: Template1 + anp: ANP1 + epg: EPG1 + force_replace: true + state: absent """ RETURN = r""" """ from ansible.module_utils.basic import AnsibleModule -from ansible_collections.cisco.mso.plugins.module_utils.mso import MSOModule, mso_argument_spec +from ansible_collections.cisco.mso.plugins.module_utils.mso import MSOModule, mso_argument_spec, mso_site_anp_epg_bulk_staticport_spec +from ansible_collections.cisco.mso.plugins.module_utils.schema import MSOSchema def main(): @@ -235,25 +403,23 @@ def main(): template=dict(type="str", required=True), anp=dict(type="str", required=True), epg=dict(type="str", required=True), + force_replace=dict(type="bool"), type=dict(type="str", default="port", choices=["port", "vpc", "dpc"]), - pod=dict(type="str"), # This parameter is not required for querying all objects - leaf=dict(type="str"), # This parameter is not required for querying all objects - fex=dict(type="str"), # This parameter is not required for querying all objects - path=dict(type="str"), # This parameter is not required for querying all objects - vlan=dict(type="int"), # This parameter is not required for querying all objects - primary_micro_segment_vlan=dict(type="int"), # This parameter is not required for querying all objects + pod=dict(type="str"), + leaf=dict(type="str"), + fex=dict(type="str"), + path=dict(type="str"), + vlan=dict(type="int"), + primary_micro_segment_vlan=dict(type="int"), deployment_immediacy=dict(type="str", default="lazy", choices=["immediate", "lazy"]), mode=dict(type="str", default="untagged", choices=["native", "regular", "untagged"]), + static_ports=dict(type="list", elements="dict", options=mso_site_anp_epg_bulk_staticport_spec()), state=dict(type="str", default="present", choices=["absent", "present", "query"]), ) module = AnsibleModule( argument_spec=argument_spec, supports_check_mode=True, - required_if=[ - ["state", "absent", ["type", "pod", "leaf", "path", "vlan"]], - ["state", "present", ["type", "pod", "leaf", "path", "vlan"]], - ], ) schema = module.params.get("schema") @@ -270,174 +436,247 @@ def main(): primary_micro_segment_vlan = module.params.get("primary_micro_segment_vlan") deployment_immediacy = module.params.get("deployment_immediacy") mode = module.params.get("mode") + force_replace = module.params.get("force_replace") + static_ports = module.params.get("static_ports") state = module.params.get("state") - if path_type == "port" and fex is not None: - # Select port path for fex if fex param is used - portpath = "topology/{0}/paths-{1}/extpaths-{2}/pathep-[{3}]".format(pod, leaf, fex, path) - elif path_type == "vpc": - portpath = "topology/{0}/protpaths-{1}/pathep-[{2}]".format(pod, leaf, path) - else: - portpath = "topology/{0}/paths-{1}/pathep-[{2}]".format(pod, leaf, path) + if not static_ports and state in ["present", "absent"]: + key_list = ["pod", "leaf", "path", "vlan"] + required_missing = [key for key in key_list if module.params.get(key)] + if len(required_missing) != 4 and not (len(required_missing) == 0 and state == "absent" and force_replace): + module.fail_json( + msg="state is present or absent but all of the following are missing: {0}.".format( + ", ".join([key for key in key_list if not module.params.get(key)]), + ) + ) mso = MSOModule(module) - # Get schema objects - schema_id, schema_path, schema_obj = mso.query_schema(schema) - - # Get template - templates = [t.get("name") for t in schema_obj.get("templates")] - if template not in templates: - mso.fail_json(msg="Provided template '{0}' does not exist. Existing templates: {1}".format(template, ", ".join(templates))) - template_idx = templates.index(template) - - # Get site - site_id = mso.lookup_site(site) - - # Get site_idx - if not schema_obj.get("sites"): - mso.fail_json(msg="No site associated with template '{0}'. Associate the site with the template using mso_schema_site.".format(template)) - sites = [(s.get("siteId"), s.get("templateName")) for s in schema_obj.get("sites")] - sites_list = [s.get("siteId") + "/" + s.get("templateName") for s in schema_obj.get("sites")] - if (site_id, template) not in sites: - mso.fail_json( - msg="Provided site/siteId/template '{0}/{1}/{2}' does not exist. " - "Existing siteIds/templates: {3}".format(site, site_id, template, ", ".join(sites_list)) - ) - - # Schema-access uses indexes - site_idx = sites.index((site_id, template)) - # Path-based access uses site_id-template - site_template = "{0}-{1}".format(site_id, template) + mso_schema = MSOSchema(mso, schema, template, site) + mso_schema.set_template_anp(anp) + mso_schema.set_template_anp_epg(epg) + mso_schema.set_site_anp(anp, False) + mso_schema.set_site_anp_epg(epg, False) - payload = dict() ops = [] - op_path = "" - - # Get ANP - anp_ref = mso.anp_ref(schema_id=schema_id, template=template, anp=anp) - anps = [a.get("anpRef") for a in schema_obj["sites"][site_idx]["anps"]] - anps_in_temp = [a.get("name") for a in schema_obj["templates"][template_idx]["anps"]] - if anp not in anps_in_temp: - mso.fail_json(msg="Provided anp '{0}' does not exist. Existing anps: {1}".format(anp, ", ".join(anps))) - else: - # Update anp index at template level - template_anp_idx = anps_in_temp.index(anp) - - # If anp not at site level but exists at template level - if anp_ref not in anps: - op_path = "/sites/{0}/anps/-".format(site_template) - payload.update( - anpRef=dict( - schemaId=schema_id, - templateName=template, - anpName=anp, - ), - ) - else: - # Update anp index at site level - anp_idx = anps.index(anp_ref) + # Create missing site anp and site epg if not present + # Logic is only needed for NDO version below 4.x when validate false flag was still available + # This did not trigger the auto creation of site anp and site epg during template anp and epg creation or ataching site to template + # Coverage misses this two conditionals when testing on 4.x and above + if state == "present" and not mso_schema.schema_objects.get("site_anp"): + ops.append( + dict( + op="add", + path="/sites/{0}-{1}/anps/-".format(mso_schema.schema_objects.get("site").details.get("siteId"), template), + value=dict(epgRef=dict(schemaId=mso_schema.id, templateName=template, anpName=anp, epgName=epg)), + ) + ) - # Get EPG - epg_ref = mso.epg_ref(schema_id=schema_id, template=template, anp=anp, epg=epg) + if state == "present" and not mso_schema.schema_objects.get("site_anp_epg"): + ops.append( + dict( + op="add", + path="/sites/{0}-{1}/anps/{2}/epgs/-".format(mso_schema.schema_objects.get("site").details.get("siteId"), template, anp), + value=dict(anpRef=dict(schemaId=mso_schema.id, templateName=template, anpName=anp)), + ) + ) - # If anp exists at site level - if "anpRef" not in payload: - epgs = [e.get("epgRef") for e in schema_obj["sites"][site_idx]["anps"][anp_idx]["epgs"]] + static_ports_path = "/sites/{0}-{1}/anps/{2}/epgs/{3}/staticPorts".format( + mso_schema.schema_objects.get("site").details.get("siteId"), + template, + anp, + epg, + ) + static_port_path = "{0}/-".format(static_ports_path) + + full_paths = [] + if static_ports: + found_static_ports = [] + found_full_paths = [] + set_existing_static_ports(mso, mso_schema, full_paths) + for static_port in static_ports: + overwrite_static_path_unprovided_attributes( + mso, static_port, path_type, pod, leaf, fex, path, vlan, primary_micro_segment_vlan, deployment_immediacy, mode + ) + full_path = get_full_static_path( + static_port.get("type"), static_port.get("pod"), static_port.get("leaf"), static_port.get("fex"), static_port.get("path") + ) + mso_schema.set_site_anp_epg_static_port(full_path, False) + if mso_schema.schema_objects.get("site_anp_epg_static_port") is not None: + found_static_ports.append(mso_schema.schema_objects["site_anp_epg_static_port"].details) + found_full_paths.append(full_path) + + elif path_type and pod and leaf and path and vlan: + full_path = get_full_static_path(path_type, pod, leaf, fex, path) + mso_schema.set_site_anp_epg_static_port(full_path, False) + if mso_schema.schema_objects.get("site_anp_epg_static_port") is not None: + mso.existing = mso_schema.schema_objects["site_anp_epg_static_port"].details + static_port_path = "{0}/{1}".format(static_ports_path, mso_schema.schema_objects["site_anp_epg_static_port"].index) + else: + set_existing_static_ports(mso, mso_schema, full_paths) - # If anp already at site level AND if epg not at site level (or) anp not at site level - if ("anpRef" not in payload and epg_ref not in epgs) or "anpRef" in payload: - epgs_in_temp = [e.get("name") for e in schema_obj["templates"][template_idx]["anps"][template_anp_idx]["epgs"]] + if state == "query": + if static_ports: + if len(found_static_ports) == len(static_ports): + mso.existing = found_static_ports + else: + not_found_static_ports = [ + "Provided Static Port Path '{0}' not found".format(full_paths[index]) + for index, static_port in enumerate(static_ports) + if full_paths[index] not in found_full_paths + ] + mso.fail_json(msg=not_found_static_ports) + elif not mso.existing and full_path: + mso.fail_json(msg="Provided Static Port Path '{0}' not found".format(full_path)) + mso.exit_json() - # If EPG not at template level - Fail - if epg not in epgs_in_temp: - mso.fail_json(msg="Provided EPG '{0}' does not exist. Existing EPGs: {1} epgref {2}".format(epg, ", ".join(epgs_in_temp), epg_ref)) + mso.previous = mso.existing - # EPG at template level but not at site level. Create payload at site level for EPG + if state == "absent" and mso.existing: + if static_ports and not force_replace: + mso.proposed = mso.existing.copy() + remove_index = [] + for found_full_path in found_full_paths: + if found_full_path in full_paths: + index = full_paths.index(found_full_path) + remove_index.append(index) + # The list index should not shift when removing static ports from the list + # By sorting the indexes found in reverse order, we assure that the highest index is removed first by the NDO backend + # This logic is to avoid removing the wrong static ports + for index in reversed(sorted(remove_index)): + mso.proposed.pop(index) + ops.append(dict(op="remove", path="{0}/{1}".format(static_ports_path, index))) + mso.sent = mso.proposed + elif not force_replace: + mso.sent = mso.existing = {} + ops.append(dict(op="remove", path=static_port_path)) else: - new_epg = dict( - epgRef=dict( - schemaId=schema_id, - templateName=template, - anpName=anp, - epgName=epg, - ) - ) + mso.sent = mso.proposed = mso.existing = [] + ops.append(dict(op="remove", path=static_ports_path)) - # If anp not in payload then, anp already exists at site level. New payload will only have new EPG payload - if "anpRef" not in payload: - op_path = "/sites/{0}/anps/{1}/epgs/-".format(site_template, anp) - payload = new_epg + elif state == "present": + if static_ports and force_replace: + mso.sent = mso.proposed = [ + get_static_port_payload( + get_full_static_path( + static_port.get("type"), + static_port.get("pod"), + static_port.get("leaf"), + static_port.get("fex"), + static_port.get("path"), + ), + static_port.get("deployment_immediacy"), + static_port.get("mode"), + static_port.get("vlan"), + static_port.get("type"), + static_port.get("primary_micro_segment_vlan"), + ) + for static_port in static_ports + ] + if mso.existing: + ops.append(dict(op="replace", path=static_ports_path, value=mso.sent)) + else: + ops.append(dict(op="add", path=static_ports_path, value=mso.sent)) + elif static_ports: + mso.sent = mso.proposed = mso.existing.copy() + for static_port in static_ports: + full_path = get_full_static_path( + static_port.get("type"), static_port.get("pod"), static_port.get("leaf"), static_port.get("fex"), static_port.get("path") + ) + payload = get_static_port_payload( + full_path, + static_port.get("deployment_immediacy"), + static_port.get("mode"), + static_port.get("vlan"), + static_port.get("type"), + static_port.get("primary_micro_segment_vlan"), + ) + if full_path not in found_full_paths: + ops.append(dict(op="add", path=static_port_path, value=payload)) + mso.proposed.append(payload) + else: + index = found_full_paths.index(full_path) + mso.proposed[index] = payload + ops.append(dict(op="replace", path="{0}/{1}".format(static_ports_path, index), value=payload)) + else: + payload = get_static_port_payload(full_path, deployment_immediacy, mode, vlan, path_type, primary_micro_segment_vlan) + mso.sanitize(payload, collate=True) + if mso.existing: + ops.append(dict(op="replace", path=static_port_path, value=mso.sent)) else: - # If anp in payload, anp exists at site level. Update payload with EPG payload - payload["epgs"] = [new_epg] + ops.append(dict(op="add", path=static_port_path, value=mso.sent)) + mso.existing = payload - # Update index of EPG at site level - else: - epg_idx = epgs.index(epg_ref) + mso.existing = mso.proposed - # Get Leaf - # If anp at site level and epg is at site level - if "anpRef" not in payload and "epgRef" not in payload: - portpaths = [p.get("path") for p in schema_obj.get("sites")[site_idx]["anps"][anp_idx]["epgs"][epg_idx]["staticPorts"]] - if portpath in portpaths: - portpath_idx = portpaths.index(portpath) - port_path = "/sites/{0}/anps/{1}/epgs/{2}/staticPorts/{3}".format(site_template, anp, epg, portpath_idx) - mso.existing = schema_obj.get("sites")[site_idx]["anps"][anp_idx]["epgs"][epg_idx]["staticPorts"][portpath_idx] + if not module.check_mode and mso.proposed != mso.previous: + mso.request(mso_schema.path, method="PATCH", data=ops) - if state == "query": - if leaf is None or vlan is None: - mso.existing = schema_obj.get("sites")[site_idx]["anps"][anp_idx]["epgs"][epg_idx]["staticPorts"] - elif not mso.existing: - mso.fail_json(msg="Static port '{portpath}' not found".format(portpath=portpath)) - mso.exit_json() + mso.exit_json() - ports_path = "/sites/{0}/anps/{1}/epgs/{2}/staticPorts".format(site_template, anp, epg) - ops = [] - new_leaf = dict( + +def set_existing_static_ports(mso, mso_schema, full_paths): + mso.existing = [] + if mso_schema.schema_objects.get("site_anp_epg"): + for existing_static_port in mso_schema.schema_objects["site_anp_epg"].details.get("staticPorts"): + full_paths.append(existing_static_port.get("path")) + mso.existing.append(existing_static_port) + + +def get_static_port_payload(full_path, deployment_immediacy, mode, vlan, path_type, primary_micro_segment_vlan): + payload = dict( deploymentImmediacy=deployment_immediacy, mode=mode, - path=portpath, + path=full_path, portEncapVlan=vlan, type=path_type, ) if primary_micro_segment_vlan: - new_leaf.update(microSegVlan=primary_micro_segment_vlan) + payload.update(microSegVlan=primary_micro_segment_vlan) + return payload - # If payload is empty, anp and EPG already exist at site level - if not payload: - op_path = ports_path + "/-" - payload = new_leaf - # If payload exists +def get_full_static_path(path_type, pod, leaf, fex, path): + if path_type == "port" and fex is not None: + return "topology/{0}/paths-{1}/extpaths-{2}/pathep-[{3}]".format(pod, leaf, fex, path) + elif path_type == "vpc": + return "topology/{0}/protpaths-{1}/pathep-[{2}]".format(pod, leaf, path) else: - # If anp already exists at site level - if "anpRef" not in payload: - payload["staticPorts"] = [new_leaf] - else: - payload["epgs"][0]["staticPorts"] = [new_leaf] - - mso.previous = mso.existing - if state == "absent": - if mso.existing: - mso.sent = mso.existing = {} - ops.append(dict(op="remove", path=port_path)) - - elif state == "present": - mso.sanitize(payload, collate=True) - - if mso.existing: - ops.append(dict(op="replace", path=port_path, value=mso.sent)) - else: - ops.append(dict(op="add", path=op_path, value=mso.sent)) - - mso.existing = new_leaf - - if not module.check_mode: - mso.request(schema_path, method="PATCH", data=ops) - - mso.exit_json() + return "topology/{0}/paths-{1}/pathep-[{2}]".format(pod, leaf, path) + + +def overwrite_static_path_unprovided_attributes(mso, static_path, path_type, pod, leaf, fex, path, vlan, micro_vlan, deployment_immediacy, mode): + required_overwrites = [] + if not static_path.get("type"): + static_path["type"] = path_type + if not static_path.get("pod"): + static_path["pod"] = pod + if not pod: + required_overwrites.append("pod") + if not static_path.get("leaf"): + static_path["leaf"] = leaf + if not leaf: + required_overwrites.append("leaf") + if not static_path.get("fex"): + static_path["fex"] = fex + if not static_path.get("path"): + static_path["path"] = path + if not path: + required_overwrites.append("path") + if not static_path.get("vlan"): + static_path["vlan"] = vlan + if not vlan: + required_overwrites.append("vlan") + if not static_path.get("primary_micro_segment_vlan"): + static_path["primary_micro_segment_vlan"] = micro_vlan + if not static_path.get("deployment_immediacy"): + static_path["deployment_immediacy"] = deployment_immediacy + if not static_path.get("mode"): + static_path["mode"] = mode + + if required_overwrites: + mso.fail_json(msg="state is present but all of the following are missing: {0}.".format(", ".join(required_overwrites))) if __name__ == "__main__": diff --git a/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_anp_epg_subnet.py b/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_anp_epg_subnet.py index e5aaeba37..ba55e7c07 100644 --- a/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_anp_epg_subnet.py +++ b/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_anp_epg_subnet.py @@ -100,7 +100,6 @@ EXAMPLES = r""" epg: EPG1 subnet: 10.0.0.0/24 state: present - delegate_to: localhost - name: Remove a subnet from a site EPG cisco.mso.mso_schema_site_anp_epg_subnet: @@ -114,7 +113,6 @@ EXAMPLES = r""" epg: EPG1 subnet: 10.0.0.0/24 state: absent - delegate_to: localhost - name: Query a specific site EPG subnet cisco.mso.mso_schema_site_anp_epg_subnet: @@ -128,7 +126,6 @@ EXAMPLES = r""" epg: EPG1 subnet: 10.0.0.0/24 state: query - delegate_to: localhost register: query_result - name: Query all site EPG subnets @@ -141,7 +138,6 @@ EXAMPLES = r""" template: Template1 anp: ANP1 state: query - delegate_to: localhost register: query_result """ diff --git a/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_anp_epg_useg_attribute.py b/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_anp_epg_useg_attribute.py index 3030852f5..7e69f5481 100644 --- a/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_anp_epg_useg_attribute.py +++ b/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_anp_epg_useg_attribute.py @@ -74,7 +74,7 @@ options: description: - The uSeg Subnet can only be used when the I(attribute_type) is IP. - Use C(false) to set the custom uSeg Subnet IP address to the uSeg Attribute. - - Use C(true) to set the uSeg Subnet IP address to 0.0.0.0. + - Use C(true) to set the default uSeg Subnet IP address 0.0.0.0. type: bool state: description: @@ -104,7 +104,6 @@ EXAMPLES = r""" useg_subnet: false value: 10.0.0.0/24 state: present - delegate_to: localhost - name: Query a specific EPG uSeg attr with name cisco.mso.mso_schema_site_anp_epg_useg_attribute: @@ -118,7 +117,7 @@ EXAMPLES = r""" name: useg_attr_ip site: ansible_test state: query - delegate_to: localhost + register: query_result - name: Query all EPG uSeg attrs cisco.mso.mso_schema_site_anp_epg_useg_attribute: @@ -131,7 +130,7 @@ EXAMPLES = r""" epg: EPG 1 site: ansible_test state: query - delegate_to: localhost + register: query_result - name: Remove a uSeg attr from an EPG with name cisco.mso.mso_schema_site_anp_epg_useg_attribute: @@ -145,7 +144,6 @@ EXAMPLES = r""" site: ansible_test name: useg_attr_ip state: absent - delegate_to: localhost """ RETURN = r""" @@ -251,11 +249,13 @@ def main(): payload = dict(name=name, displayName=name, description=description, type=EPG_U_SEG_ATTR_TYPE_MAP[attribute_type], value=value) if attribute_type == "ip": - if useg_subnet is False: - payload["fvSubnet"] = True - else: - payload["fvSubnet"] = False + if useg_subnet: + if value != "" and value != "0.0.0.0" and value is not None: + mso.fail_json(msg="The value of uSeg subnet IP should be an empty string or 0.0.0.0, when the useg_subnet is set to true.") + payload["fvSubnet"] = useg_subnet payload["value"] = "0.0.0.0" + else: + payload["fvSubnet"] = useg_subnet mso.sanitize(payload, collate=True) diff --git a/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_bd.py b/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_bd.py index 35c352fb6..64a798b1a 100644 --- a/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_bd.py +++ b/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_bd.py @@ -73,7 +73,6 @@ EXAMPLES = r""" template: Template1 bd: BD1 state: present - delegate_to: localhost - name: Remove a site BD cisco.mso.mso_schema_site_bd: @@ -85,7 +84,6 @@ EXAMPLES = r""" template: Template1 bd: BD1 state: absent - delegate_to: localhost - name: Query a specific site BD cisco.mso.mso_schema_site_bd: @@ -97,7 +95,6 @@ EXAMPLES = r""" template: Template1 bd: BD1 state: query - delegate_to: localhost register: query_result - name: Query all site BDs @@ -109,7 +106,6 @@ EXAMPLES = r""" site: Site1 template: Template1 state: query - delegate_to: localhost register: query_result """ diff --git a/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_bd_l3out.py b/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_bd_l3out.py index 8f9581294..2f562a684 100644 --- a/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_bd_l3out.py +++ b/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_bd_l3out.py @@ -94,7 +94,6 @@ EXAMPLES = r""" l3out: name: L3out1 state: present - delegate_to: localhost - name: Add a new site BD l3out with different schema and template cisco.mso.mso_schema_site_bd_l3out: @@ -110,7 +109,6 @@ EXAMPLES = r""" schema: Schema2 template: Template2 state: present - delegate_to: localhost - name: Remove a site BD l3out cisco.mso.mso_schema_site_bd_l3out: @@ -124,7 +122,6 @@ EXAMPLES = r""" l3out: name: L3out1 state: absent - delegate_to: localhost - name: Query a specific site BD l3out cisco.mso.mso_schema_site_bd_l3out: @@ -138,7 +135,6 @@ EXAMPLES = r""" l3out: name: L3out1 state: query - delegate_to: localhost register: query_result - name: Query all site BD l3outs @@ -151,7 +147,6 @@ EXAMPLES = r""" template: Template1 bd: BD1 state: query - delegate_to: localhost register: query_result """ diff --git a/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_bd_subnet.py b/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_bd_subnet.py index c4ab52eec..9bce8c2da 100644 --- a/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_bd_subnet.py +++ b/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_bd_subnet.py @@ -111,7 +111,6 @@ EXAMPLES = r""" bd: BD1 subnet: 11.11.11.0/24 state: present - delegate_to: localhost - name: Remove a site BD subnet cisco.mso.mso_schema_site_bd_subnet: @@ -124,7 +123,6 @@ EXAMPLES = r""" bd: BD1 subnet: 11.11.11.0/24 state: absent - delegate_to: localhost - name: Query a specific site BD subnet cisco.mso.mso_schema_site_bd_subnet: @@ -137,7 +135,6 @@ EXAMPLES = r""" bd: BD1 subnet: 11.11.11.0/24 state: query - delegate_to: localhost register: query_result - name: Query all site BD subnets @@ -150,7 +147,6 @@ EXAMPLES = r""" template: Template1 bd: BD1 state: query - delegate_to: localhost register: query_result """ diff --git a/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_contract_service_graph.py b/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_contract_service_graph.py new file mode 100644 index 000000000..231ee4284 --- /dev/null +++ b/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_contract_service_graph.py @@ -0,0 +1,376 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright: (c) 2024, Sabari Jaganathan (@sajagana) <sajagana@cisco.com> +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +ANSIBLE_METADATA = {"metadata_version": "1.1", "status": ["preview"], "supported_by": "community"} + + +DOCUMENTATION = r""" +--- +module: mso_schema_site_contract_service_graph +short_description: Manage the service graph association with a contract in schema sites +description: +- Manage the service graph association with a contract in schema sites on Cisco ACI Multi-Site. +- This module is only compatible with NDO versions 3.7 and 4.2+. NDO versions 4.0 and 4.1 are not supported. +author: +- Sabari Jaganathan (@sajagana) +options: + tenant: + description: + - The name of the tenant. + type: str + schema: + description: + - The name of the schema. + type: str + required: true + template: + description: + - The name of the template. + type: str + required: true + contract: + description: + - The name of the contract. + type: str + site: + description: + - The name of the site. + type: str + required: true + service_graph_schema: + description: + - The name of the schema in which the service graph is located. + type: str + service_graph_template: + description: + - The name of the template in which the service graph is located. + type: str + service_graph: + description: + - The name of the service graph to associate with the site contract. + type: str + node_relationship: + description: + - A list of nodes and their connector details associated with the Service Graph. + type: list + elements: dict + suboptions: + cluster_interface_device: + description: + - The name of the cluster interface device. + type: str + required: true + aliases: [ cluster_device, device, device_name ] + provider_connector_cluster_interface: + description: + - The name of the cluster interface for the provider connector. + type: str + required: true + aliases: [ provider_cluster_interface, provider_interface, provider_interface_name ] + provider_connector_redirect_policy_tenant: + description: + - The name of the tenant for the provider connector redirect policy. + type: str + aliases: [ provider_redirect_policy_tenant, provider_tenant ] + provider_connector_redirect_policy: + description: + - The name of the redirect policy for the provider connector. + type: str + aliases: [ provider_redirect_policy, provider_policy ] + consumer_connector_cluster_interface: + description: + - The name of the cluster interface for the consumer connector. + type: str + required: true + aliases: [ consumer_cluster_interface, consumer_interface, consumer_interface_name ] + consumer_connector_redirect_policy_tenant: + description: + - The name of the tenant for the consumer connector redirect policy. + type: str + aliases: [ consumer_redirect_policy_tenant, consumer_tenant ] + consumer_connector_redirect_policy: + description: + - The name of the redirect policy for the consumer connector. + type: str + aliases: [ consumer_redirect_policy, consumer_policy ] + consumer_subnet_ips: + description: + - The list of subnet IPs for the consumer connector. + - The subnet IPs option is only available for the load balancer devices. + type: list + elements: str + state: + description: + - Use C(present) or C(absent) for adding or removing. + - Use C(query) for listing an object or multiple objects. + type: str + choices: [ absent, present, query ] + default: present +seealso: +- module: cisco.mso.mso_schema_template_contract_service_graph +extends_documentation_fragment: cisco.mso.modules +""" + + +EXAMPLES = r""" +- name: Associate a service graph with a site contract + cisco.mso.mso_schema_site_contract_service_graph: + host: mso_host + username: admin + password: SomeSecretPassword + tenant: ansible_tenant + schema: ansible_schema + template: ansible_template1 + site: ansible_test + contract: Contract1 + service_graph_schema: ansible_schema + service_graph_template: ansible_template1 + service_graph: sg + node_relationship: + - cluster_interface_device: ansible_tenant_firewall1 + provider_connector_cluster_interface: clu_if1 + provider_connector_redirect_policy: redirect_policy1 + consumer_connector_cluster_interface: clu_if1 + consumer_connector_redirect_policy: redirect_policy1 + - cluster_interface_device: ansible_tenant_adc + provider_connector_cluster_interface: clu_if3 + provider_connector_redirect_policy: redirect_policy1 + consumer_connector_cluster_interface: clu_if3 + consumer_connector_redirect_policy: redirect_policy1 + consumer_subnet_ips: ["1.1.1.1/24", "4.4.4.4/24"] + - cluster_interface_device: ansible_tenant_other + provider_connector_cluster_interface: clu_if4 + provider_connector_redirect_policy: redirect_policy1 + consumer_connector_cluster_interface: clu_if4 + consumer_connector_redirect_policy: redirect_policy1 + state: present + +- name: Associate a service graph with a cloud site contract + cisco.mso.mso_schema_site_contract_service_graph: + host: mso_host + username: admin + password: SomeSecretPassword + tenant: ansible_tenant + schema: ansible_schema + template: ansible_template1 + site: ansible_test + contract: Contract1 + service_graph_schema: ansible_schema + service_graph_template: ansible_template1 + service_graph: sg + state: present + +- name: Query a site contract service graph with contract name + cisco.mso.mso_schema_site_contract_service_graph: + host: mso_host + username: admin + password: SomeSecretPassword + schema: ansible_schema + template: ansible_template1 + contract: Contract1 + site: ansible_test + state: query + register: query_result + +- name: Query all site contract service graphs associated with a site template + cisco.mso.mso_schema_site_contract_service_graph: + host: mso_host + username: admin + password: SomeSecretPassword + schema: ansible_schema + template: ansible_template1 + site: ansible_test + state: query + register: query_result + +- name: Remove a site contract service graph with contract name + cisco.mso.mso_schema_site_contract_service_graph: + host: mso_host + username: admin + password: SomeSecretPassword + schema: ansible_schema + template: ansible_template1 + site: ansible_test + contract: Contract1 + state: absent +""" + +RETURN = r""" +""" + + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.cisco.mso.plugins.module_utils.schema import MSOSchema +from ansible_collections.cisco.mso.plugins.module_utils.mso import MSOModule, mso_argument_spec, mso_schema_site_contract_service_graph_spec + + +def main(): + argument_spec = mso_argument_spec() + argument_spec.update( + tenant=dict(type="str"), + schema=dict(type="str", required=True), + template=dict(type="str", required=True), + contract=dict(type="str"), + site=dict(type="str", required=True), + service_graph_schema=dict(type="str"), + service_graph_template=dict(type="str"), + service_graph=dict(type="str"), + node_relationship=dict(type="list", elements="dict", options=mso_schema_site_contract_service_graph_spec()), + state=dict(type="str", default="present", choices=["absent", "present", "query"]), + ) + + module = AnsibleModule( + argument_spec=argument_spec, + supports_check_mode=True, + required_if=[ + ["state", "absent", ["contract"]], + ["state", "present", ["contract", "service_graph"]], + ], + ) + + tenant = module.params.get("tenant") + schema = module.params.get("schema") + template = module.params.get("template").replace(" ", "") + contract = module.params.get("contract") + site = module.params.get("site") + service_graph_schema = module.params.get("service_graph_schema") + service_graph_template = module.params.get("service_graph_template") + service_graph = module.params.get("service_graph") + node_relationship = module.params.get("node_relationship") + state = module.params.get("state") + + mso = MSOModule(module) + + mso_schema = MSOSchema(mso, schema, template) + mso_schema.set_template(template) + + service_graph_schema_id = schema_id = mso.lookup_schema(schema, True) + service_graph_reference_schema = service_graph_schema or schema + + # Get service graph reference schema id if the service graph schema is not matching with the schema + if service_graph_reference_schema != schema: + service_graph_schema_id = mso.lookup_schema(service_graph_reference_schema, True) + if service_graph_schema_id is None: + mso.fail_json(msg="Provided service_graph_schema: '{0}' does not exist.".format(service_graph_schema)) + + service_graph_reference_schema_id = service_graph_schema_id or schema_id + service_graph_reference_template = service_graph_template or template + + # Get site id + site_id = mso.lookup_site(site) + mso_schema.set_site(template, site) + mso_schema.set_site_contract(contract, False) + + if mso.site_type == "on-premise" and state == "present": + # When site type is on-premise, both node_relationship and tenant are required + if node_relationship is None and tenant is None: + mso.fail_json(msg="The node_relationship and tenant attributes are required when state is present and site type is on-premise.") + elif node_relationship is None: + mso.fail_json(msg="The node_relationship attribute is required when state is present and site type is on-premise.") + elif tenant is None: + mso.fail_json(msg="The tenant attribute is required when state is present and site type is on-premise.") + + if contract and mso_schema.schema_objects["site_contract"] is not None: + site_contract_service_graph = mso_schema.schema_objects["site_contract"].details.get("serviceGraphRelationship") + if site_contract_service_graph and service_graph: + site_contract_service_graph_name = site_contract_service_graph.get("serviceGraphRef").split("/")[-1] + if site_contract_service_graph_name == service_graph: + mso.existing = site_contract_service_graph + else: + mso.fail_json(msg="The service graph: {0} does not associated with the site contract: {1}.".format(service_graph, contract)) + elif site_contract_service_graph and service_graph is None: + mso.existing = site_contract_service_graph + elif contract is not None and mso_schema.schema_objects["site_contract"] is None: + mso.fail_json(msg="The site contract: {0} does not exist.".format(contract)) + elif contract is None and mso_schema.schema_objects["site"].details.get("contracts"): + mso.existing = [ + contract.get("serviceGraphRelationship") + for contract in mso_schema.schema_objects["site"].details.get("contracts") + if contract.get("serviceGraphRelationship") + ] + + if state == "query": + mso.exit_json() + + site_contract_service_graph_path = "/sites/{0}-{1}/contracts/{2}/serviceGraphRelationship".format(site_id, service_graph_reference_template, contract) + + ops = [] + mso.previous = mso.existing + + if state == "absent": + mso.existing = {} + ops.append(dict(op="remove", path=site_contract_service_graph_path)) + elif state == "present": + service_graph_ref = dict(schemaId=service_graph_reference_schema_id, serviceGraphName=service_graph, templateName=service_graph_reference_template) + service_node_relationship = [] + if mso.site_type == "on-premise" and node_relationship: + for node_index, node in enumerate(node_relationship, 1): + service_node_ref = dict( + schemaId=service_graph_reference_schema_id, + serviceGraphName=service_graph, + serviceNodeName="node{0}".format(node_index), + templateName=service_graph_reference_template, + ) + + consumer_subnet_ips_list = [dict(ip=subnet) for subnet in node.get("consumer_subnet_ips")] if node.get("consumer_subnet_ips") else [] + consumer_connector = dict( + clusterInterface=dict( + dn="uni/tn-{0}/lDevVip-{1}/lIf-{2}".format( + tenant, node.get("cluster_interface_device"), node.get("consumer_connector_cluster_interface") + ) + ), + redirectPolicy=dict( + dn="uni/tn-{0}/svcCont/svcRedirectPol-{1}".format( + node.get("consumer_connector_redirect_policy_tenant") or tenant, node.get("consumer_connector_redirect_policy") + ) + ), + subnets=consumer_subnet_ips_list, + ) + provider_connector = dict( + clusterInterface=dict( + dn="uni/tn-{0}/lDevVip-{1}/lIf-{2}".format( + tenant, node.get("cluster_interface_device"), node.get("provider_connector_cluster_interface") + ) + ), + redirectPolicy=dict( + dn="uni/tn-{0}/svcCont/svcRedirectPol-{1}".format( + node.get("provider_connector_redirect_policy_tenant") or tenant, node.get("provider_connector_redirect_policy") + ) + ), + ) + service_node_relationship.append( + dict(consumerConnector=consumer_connector, providerConnector=provider_connector, serviceNodeRef=service_node_ref) + ) + + payload = dict(serviceGraphRef=service_graph_ref, serviceNodesRelationship=service_node_relationship) + elif mso.cloud_provider_type == "azure": + mso_schema.set_site_service_graph(service_graph) + service_nodes = mso_schema.schema_objects["site_service_graph"].details.get("serviceNodes", []) + payload = dict( + serviceGraphRef=service_graph_ref, serviceNodesRelationship=[dict(serviceNodeRef=sg_node.get("serviceNodeRef")) for sg_node in service_nodes] + ) + + mso.sanitize(payload, collate=True) + + if mso.existing: + ops.append(dict(op="replace", path=site_contract_service_graph_path, value=mso.sent)) + else: + ops.append(dict(op="add", path=site_contract_service_graph_path, value=mso.sent)) + + mso.existing = mso.proposed + + if not module.check_mode: + mso.request(mso_schema.path, method="PATCH", data=ops) + + mso.exit_json() + + +if __name__ == "__main__": + main() diff --git a/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_contract_service_graph_listener.py b/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_contract_service_graph_listener.py new file mode 100644 index 000000000..b854f0404 --- /dev/null +++ b/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_contract_service_graph_listener.py @@ -0,0 +1,739 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright: (c) 2024, Sabari Jaganathan (@sajagana) <sajagana@cisco.com> +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +ANSIBLE_METADATA = {"metadata_version": "1.1", "status": ["preview"], "supported_by": "community"} + + +DOCUMENTATION = r""" +--- +module: mso_schema_site_contract_service_graph_listener +short_description: Manage the listener for Azure site contract service graph in schema sites +description: +- Manage the listener for Azure site contract service graph in schema sites on Cisco ACI Multi-Site. +- This module is only compatible with NDO versions 3.7 and 4.2+. NDO versions 4.0 and 4.1 are not supported. +author: +- Sabari Jaganathan (@sajagana) +options: + tenant: + description: + - The name of the tenant. + type: str + device: + description: + - The name of the device. + type: str + aliases: [ device_name ] + schema: + description: + - The name of the schema. + type: str + required: true + template: + description: + - The name of the template. + type: str + required: true + contract: + description: + - The name of the contract. + type: str + required: true + site: + description: + - The name of the site. + type: str + required: true + service_node_index: + description: + - The index of the service node in the site contract service graph. The value starts from 0. + type: int + listener: + description: + - The name of the listener. + type: str + aliases: [ name, listener_name ] + listener_protocol: + description: + - The protocol of the listener. + type: str + choices: [ http, https, tcp, udp, tls, inherit ] + listener_port: + description: + - The port of the listener. + type: int + security_policy: + description: + - The security policy of the listener. + type: str + choices: [ + default, + elb_sec_2016_18, + elb_sec_fs_2018_06, + elb_sec_tls_1_2_2017_01, + elb_sec_tls_1_2_ext_2018_06, + elb_sec_tls_1_1_2017_01, + elb_sec_2015_05, + elb_sec_tls_1_0_2015_04, + app_gw_ssl_default, + app_gw_ssl_2015_501, + app_gw_ssl_2017_401, + app_gw_ssl_2017_401s + ] + ssl_certificates: + description: + - The ssl certificates of the listener. + type: list + elements: dict + suboptions: + name: + description: + - The name of the ssl certificate. + type: str + required: true + certificate_store: + description: + - The certificate store of the ssl certificate. + type: str + required: true + choices: [ default, iam, acm ] + frontend_ip: + description: + - The frontend ip of the listener. Only supported for Network load balancers. + type: str + rules: + description: + - The rules of the listener. + type: list + elements: dict + suboptions: + name: + description: + - The name of the rule. + type: str + required: true + floating_ip: + description: + - The floating ip of the rule. + type: str + priority: + description: + - The priority of the rule. + type: int + required: true + host: + description: + - The host of the rule. + type: str + path: + description: + - The path of the rule. + type: str + action: + description: + - The action of the rule. + type: str + action_type: + description: + - The action type of the rule. + type: str + required: true + choices: [ fixed_response, forward, redirect, ha_port ] + content_type: + description: + - The content type of the rule. + type: str + choices: [ text_plain, text_css, text_html, app_js, app_json ] + port: + description: + - The port of the rule. + type: int + protocol: + description: + - The protocol of the rule. + type: str + choices: [ http, https, tcp, udp, tls, inherit ] + provider_epg: + description: + - The provider epg of the rule. + type: dict + suboptions: + schema: + description: + - The schema name of the provider epg reference. + type: str + template: + description: + - The template name of the provider epg reference. + type: str + anp_name: + description: + - The application profile name of the provider epg reference. + type: str + required: true + aliases: [ anp ] + epg_name: + description: + - The epg (Endpoint Group) name of the provider epg reference. + type: str + required: true + aliases: [ epg ] + url_type: + description: + - The url type of the rule. + type: str + choices: [ original, custom ] + custom_url: + description: + - The custom url of the rule. + type: str + redirect_host_name: + description: + - The redirect host name of the rule. + type: str + redirect_path: + description: + - The redirect path of the rule. + type: str + redirect_query: + description: + - The redirect query of the rule. + type: str + response_code: + description: + - The response code of the rule. + type: str + response_body: + description: + - The response body of the rule. + type: str + redirect_protocol: + description: + - The redirect protocol of the rule. + type: str + choices: [ http, https, tcp, udp, tls, inherit ] + redirect_port: + description: + - The redirect port of the rule. + type: int + redirect_code: + description: + - The redirect code of the rule. + type: str + choices: [ unknown, permanently_moved, found, see_other, temporary_redirect ] + health_check: + description: + - The health check of the rule. + type: dict + suboptions: + port: + description: + - The port of the health check. + type: int + protocol: + description: + - The protocol of the health check. + type: str + choices: [ http, https, tcp, udp, tls, inherit ] + path: + description: + - The path of the health check. + type: str + interval: + description: + - The interval of the health check. + type: int + timeout: + description: + - The timeout of the health check. + type: int + unhealthy_threshold: + description: + - The unhealthy threshold of the health check. + type: int + use_host_from_rule: + description: + - The use host from rule of the health check. + type: bool + host: + description: + - The host of the health check. The host attribute will be enabled when the I(use_host_from_rule) is false. + type: str + success_code: + description: + - The success code of the health check. + type: str + target_ip_type: + description: + - The target ip type of the rule. + type: str + choices: [ unspecified, primary, secondary ] + state: + description: + - Use C(present) or C(absent) for adding or removing. + - Use C(query) for listing an object or multiple objects. + type: str + choices: [ absent, present, query ] + default: present +seealso: +- module: cisco.mso.mso_schema_template_contract_service_graph +extends_documentation_fragment: cisco.mso.modules +""" + + +EXAMPLES = r""" +- name: Add a listener for Network Load-Balancer + cisco.mso.mso_schema_site_contract_service_graph_listener: + host: mso_host + username: admin + password: SomeSecretPassword + contract: "Contract2" + schema: mso_schema + template: ansible_template1 + site: mso_site + service_node_index: 0 + listener: nlb_li_tcp + listener_port: 80 + listener_protocol: tcp + tenant: mso_tenant + frontend_ip: "10.10.10.10" + device: ans_test_nlb + security_policy: default + rules: + - name: rule1 + priority: 1 + action_type: forward + port: 80 + protocol: tcp + health_check: + port: 80 + protocol: tcp + interval: 5 + unhealthy_threshold: 2 + success_code: 200-399 + +- name: Add a listener for Application Load-Balancer + cisco.mso.mso_schema_site_contract_service_graph_listener: + host: mso_host + username: admin + password: SomeSecretPassword + contract: "Contract2" + schema: mso_schema + template: ansible_template1 + site: mso_site + service_node_index: 1 + listener: aplb_li_https + tenant: mso_tenant + device: ans_test_aplb + listener_port: 443 + listener_protocol: https + security_policy: default + ssl_certificates: + - name: ans_test_keyring + certificate_store: default + rules: + - name: rule1 + priority: 1 + action_type: forward + port: 80 + protocol: http + provider_epg: + anp_name: AP1 + epg_name: EPG1 + health_check: + port: 80 + protocol: http + path: "health_check_path" + interval: 30 + timeout: 30 + unhealthy_threshold: 3 + use_host_from_rule: true + success_code: "200" + target_ip_type: unspecified + +- name: Query all listeners + cisco.mso.mso_schema_site_contract_service_graph_listener: + host: mso_host + username: admin + password: SomeSecretPassword + contract: "Contract2" + schema: mso_schema + template: ansible_template1 + site: mso_site + state: query + register: query_all_listeners + +- name: Query all listeners with name ans_li_common + cisco.mso.mso_schema_site_contract_service_graph_listener: + host: mso_host + username: admin + password: SomeSecretPassword + contract: "Contract2" + schema: mso_schema + template: ansible_template1 + site: mso_site + listener: ans_li_common + state: query + register: query_all_ans_li_common + +- name: Query a listener with name - aplb_li_https + cisco.mso.mso_schema_site_contract_service_graph_listener: + host: mso_host + username: admin + password: SomeSecretPassword + contract: "Contract2" + schema: mso_schema + template: ansible_template1 + site: mso_site + service_node_index: 1 + listener: aplb_li_https + state: query + register: query_aplb_li_https + +- name: Remove an existing listener - ans_li_common + cisco.mso.mso_schema_site_contract_service_graph_listener: + host: mso_host + username: admin + password: SomeSecretPassword + contract: "Contract2" + schema: mso_schema + template: ansible_template1 + site: mso_site + service_node_index: 1 + listener: aplb_li_https + state: absent +""" + +RETURN = r""" +""" + + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.cisco.mso.plugins.module_utils.schema import MSOSchema +from ansible_collections.cisco.mso.plugins.module_utils.mso import ( + MSOModule, + mso_argument_spec, + listener_ssl_certificates_spec, + listener_rules_spec, +) +from ansible_collections.cisco.mso.plugins.module_utils.constants import ( + LISTENER_REDIRECT_CODE_MAP, + LISTENER_CONTENT_TYPE_MAP, + LISTENER_ACTION_TYPE_MAP, + LISTENER_SECURITY_POLICY_MAP, + LISTENER_PROTOCOLS, + YES_OR_NO_TO_BOOL_STRING_MAP, +) + + +def main(): + argument_spec = mso_argument_spec() + argument_spec.update( + tenant=dict(type="str"), + device=dict(type="str", aliases=["device_name"]), + schema=dict(type="str", required=True), + template=dict(type="str", required=True), + contract=dict(type="str", required=True), + site=dict(type="str", required=True), + service_node_index=dict(type="int"), + listener=dict(type="str", aliases=["name", "listener_name"]), + listener_protocol=dict(type="str", choices=LISTENER_PROTOCOLS), + listener_port=dict(type="int"), + security_policy=dict(type="str", choices=list(LISTENER_SECURITY_POLICY_MAP)), + ssl_certificates=dict(type="list", elements="dict", options=listener_ssl_certificates_spec()), + frontend_ip=dict(type="str"), + rules=dict(type="list", elements="dict", options=listener_rules_spec()), + state=dict(type="str", default="present", choices=["absent", "present", "query"]), + ) + + module = AnsibleModule( + argument_spec=argument_spec, + supports_check_mode=True, + required_if=[ + ["state", "absent", ["listener"]], + ["state", "present", ["listener", "listener_protocol", "listener_port", "rules"]], + ], + ) + + mso = MSOModule(module) + site = module.params.get("site") + + # Get site id + site_id = mso.lookup_site(site) + + if mso.site_type == "on-premise" or mso.cloud_provider_type != "azure": + mso.fail_json(msg="The Site Contract Service Graph Listener is not supported for the site: {0}.".format(site)) + + schema = module.params.get("schema") + template = module.params.get("template") + contract = module.params.get("contract") + service_node_index = module.params.get("service_node_index") + listener = module.params.get("listener") + tenant = module.params.get("tenant") + device = module.params.get("device") + listener_protocol = module.params.get("listener_protocol") + listener_port = module.params.get("listener_port") + security_policy = LISTENER_SECURITY_POLICY_MAP.get(module.params.get("security_policy")) + ssl_certificates = module.params.get("ssl_certificates") + frontend_ip = module.params.get("frontend_ip") + rules = module.params.get("rules") + state = module.params.get("state") + + if listener_protocol == "https": + mso.input_validation("listener_protocol", "https", ["security_policy", "ssl_certificates"], module.params, None, object_name=listener) + + mso_schema = MSOSchema(mso, schema, template) + mso_schema.set_template(template) + schema_id = mso.lookup_schema(schema, True) + mso_schema.set_site(template, site) + mso_schema.set_site_contract(contract, False) + + service_graph_ref = mso_schema.schema_objects["site_contract"].details.get("serviceGraphRelationship", {}).get("serviceGraphRef") + service_nodes = mso_schema.schema_objects["site_contract"].details.get("serviceGraphRelationship", {}).get("serviceNodesRelationship", []) + + parent_present = False + + if service_graph_ref is None: + mso.fail_json(msg="The site contract: {0} is not associated with a service graph.".format(contract)) + # Parent object present check + else: + if service_node_index is not None and service_node_index >= 0: + if len(service_nodes) > 0 and len(service_nodes) > service_node_index: + service_node = service_nodes[service_node_index] + # Query all listeners under a contract service node + # The below condition was never false if the service graph was created properly, but condition is required to avoid error + if service_node.get("serviceNodeRef") and service_node.get("serviceNodeRef").split("/")[-1] == "node{0}".format(service_node_index + 1): + listeners = service_node.get("deviceConfiguration", {}).get("cloudLoadBalancer", {}).get("listeners", []) + if listeners: + parent_present = True + if listener: + for listener_data in listeners: + if listener_data.get("name") == listener: + mso.existing = listener_data + break + else: + mso.existing = listeners + else: + mso.fail_json( + msg="The service_node_index: {0} is not matching with the service node reference: {1}.".format( + service_node_index, service_node.get("serviceNodeRef") + ) + ) + else: + mso.fail_json(msg="The service_node_index: {0} is out of range.".format(service_node_index)) + + # Query all listeners under a contract does not require service_node_index, so the below condition is required + elif state == "query": + # Query all listeners under a contract + for service_node in service_nodes: + listeners = service_node.get("deviceConfiguration", {}).get("cloudLoadBalancer", {}).get("listeners", []) + if listener: + for listener_data in listeners: + # Query a listener under a contract service node + if listener_data.get("name") == listener: + mso.existing = ([listener_data] + mso.existing) if mso.existing else [listener_data] + break + else: + mso.existing = (listeners + mso.existing) if mso.existing else listeners + + else: + mso.fail_json(msg="The service_node_index: {0} is not valid.".format(service_node_index)) + + if state == "query": + mso.exit_json() + + ops = [] + mso.previous = mso.existing + + parent_object = {} + + if state == "present": + # Parent object creation logic begins + if device is None and parent_present is False: + mso.fail_json(msg="The 'device' name is required to initialize the parent object.") + + elif device is not None and parent_present is False: + query_device_data = mso.lookup_service_node_device(site_id, tenant, device_name=device) + + if query_device_data.get("deviceVendorType") == "NATIVELB" and ( + query_device_data.get("devType") == "application" or query_device_data.get("devType") == "network" + ): + mso_schema.set_site_service_graph(service_graph_ref.split("/")[-1]) + + for sg in mso_schema.schema_objects["site_service_graph"].details.get("serviceNodes", []): + if device == sg.get("device").get("dn").split("/")[-1].split("-")[-1]: + parent_object = dict(deviceConfiguration=dict(cloudLoadBalancer=dict(listeners=[])), serviceNodeRef=sg.get("serviceNodeRef")) + break + else: + mso.fail_json( + msg="Listener is not supported for the 'service_node_index': {0} is associated with the Third-Party {1} device.".format( + service_node_index, "Load Balancer" if query_device_data.get("deviceVendorType") == "ADC" else "Firewall" + ) + ) + # Parent object creation logic ends + + # Listener object creation logic begins + listener_object = dict( + name=listener, + protocol=listener_protocol, + port=listener_port, + secPolicy=security_policy, + ) + + if frontend_ip: + mso.input_validation("frontend_ip", frontend_ip, ["tenant", "device"], module.params, None, object_name=listener) + listener_object["nlbDevIp"] = dict(name=frontend_ip, dn="uni/tn-{0}/clb-{1}/vip-{2}".format(tenant, device, frontend_ip)) + + if ssl_certificates: + listener_object["certificates"] = [ + { + "name": ssl_certificate.get("name"), + "tDn": "uni/tn-{0}/certstore".format(tenant), + "default": True, + "store": ssl_certificate.get("certificate_store"), + } + for ssl_certificate in ssl_certificates + ] + + # Rules object creation logic + rules_data = [] + + for position, rule in enumerate(rules, 0): + if (listener_protocol == "http" and rule.get("protocol") == "http") or (listener_protocol == "https" and rule.get("protocol") == "https"): + mso.fail_json(msg="When the 'listener_protocol' is '{0}', the rule 'protocol' must be '{1}'".format(listener_protocol, rule.get("protocol"))) + + if rule.get("action_type") == "redirect": + mso.input_validation( + "action_type", "redirect", ["redirect_protocol", "redirect_port", "url_type", "redirect_code"], rule, position, rule.get("name") + ) + elif rule.get("action_type") == "forward": + mso.input_validation("action_type", "forward", ["protocol", "port", "health_check"], rule, position, rule.get("name")) + + if rule.get("url_type") == "custom": + mso.input_validation( + "url_type", "custom", ["redirect_host_name", "redirect_path", "redirect_query", "response_code"], rule, position, rule.get("name") + ) + + rule_data = dict( + name=rule.get("name"), + floatingIp=rule.get("floating_ip"), + index=rule.get("priority"), + host=rule.get("host"), + path=rule.get("path"), + action=rule.get("action"), + actionType=LISTENER_ACTION_TYPE_MAP.get(rule.get("action_type")), + contentType=LISTENER_CONTENT_TYPE_MAP.get(rule.get("content_type")), + port=rule.get("port"), + protocol=rule.get("protocol"), + urlType=rule.get("url_type"), + customURL=rule.get("custom_url"), + redirectHostName=rule.get("redirect_host_name"), + redirectPath=rule.get("redirect_path"), + redirectQuery=rule.get("redirect_query"), + responseCode=rule.get("response_code"), + responseBody=rule.get("response_body"), + redirectProtocol=rule.get("redirect_protocol"), + redirectPort=rule.get("redirect_port"), + redirectCode=LISTENER_REDIRECT_CODE_MAP.get(rule.get("redirect_code")), + targetIpType=rule.get("target_ip_type"), + ) + + if listener_protocol in ["tcp", "udp"]: + mso.input_validation("listener_protocol", "tcp/udp", ["health_check"], rule) + + provider_epg = rule.get("provider_epg") + if provider_epg: + rule_data["providerEpgRef"] = "/schemas/{0}/templates/{1}/anps/{2}/epgs/{3}".format( + provider_epg.get("schema") or schema_id, + provider_epg.get("template_name") or template, + provider_epg.get("anp_name"), + provider_epg.get("epg_name"), + ) + + health_check = rule.get("health_check") + if health_check: + if listener_protocol in ["tcp", "udp"]: + if health_check.get("protocol") == "tcp": + mso.input_validation("health_check - 'protocol'", "tcp", ["port", "unhealthy_threshold", "interval"], health_check) + elif health_check.get("protocol") in ["http", "https"]: + mso.input_validation("health_check - 'protocol'", "http/https", ["port", "path", "unhealthy_threshold", "interval"], health_check) + elif (listener_protocol == "http" and health_check.get("protocol") == "https") or ( + listener_protocol == "https" and health_check.get("protocol") == "http" + ): + mso.input_validation( + "health_check - 'protocol'", "http/https", ["port", "path", "unhealthy_threshold", "timeout", "interval"], health_check + ) + else: + mso.fail_json( + msg=( + "The 'listener_protocol': {0} and the health_check protocol: {1} " + + "is not a valid configuration at the object position: {2} and the object name: {3}" + ).format(listener_protocol, health_check.get("protocol"), position, rule.get("name")) + ) + + health_check_data = dict( + port=health_check.get("port"), + protocol=health_check.get("protocol"), + path=health_check.get("path"), + interval=health_check.get("interval"), + timeout=health_check.get("timeout"), + unhealthyThreshold=health_check.get("unhealthy_threshold"), + successCode=health_check.get("success_code"), + useHostFromRule=YES_OR_NO_TO_BOOL_STRING_MAP.get(health_check.get("use_host_from_rule")), + host=health_check.get("host"), + ) + + rule_data["healthCheck"] = health_check_data + + rules_data.append(rule_data) + + listener_object["rules"] = rules_data + + if parent_present: + # Update an existing listener + if mso.existing: + listener_path = ( + "/sites/{0}-{1}/contracts/{2}/serviceGraphRelationship/serviceNodesRelationship/{3}/deviceConfiguration/cloudLoadBalancer/listeners/{4}" + ).format(site_id, template, contract, service_node_index, listener) + op = "replace" + else: + # Create a new listener + listener_path = ( + "/sites/{0}-{1}/contracts/{2}/serviceGraphRelationship/serviceNodesRelationship/{3}/deviceConfiguration/cloudLoadBalancer/listeners/-" + ).format(site_id, template, contract, service_node_index) + op = "add" + parent_object = listener_object + else: + # Create a new listener with parent object + listener_path = "/sites/{0}-{1}/contracts/{2}/serviceGraphRelationship/serviceNodesRelationship/{3}".format( + site_id, template, contract, service_node_index + ) + op = "replace" + parent_object["deviceConfiguration"]["cloudLoadBalancer"]["listeners"].append(listener_object) + + mso.sanitize(parent_object, collate=True) + ops.append(dict(op=op, path=listener_path, value=mso.sent)) + + elif state == "absent": + if mso.existing: + listener_path = ( + "/sites/{0}-{1}/contracts/{2}/serviceGraphRelationship/serviceNodesRelationship/{3}/deviceConfiguration/cloudLoadBalancer/listeners/{4}" + ).format(site_id, template, contract, service_node_index, listener) + ops.append(dict(op="remove", path=listener_path)) + + mso.existing = mso.proposed + + if not module.check_mode: + mso.request(mso_schema.path, method="PATCH", data=ops) + + mso.exit_json() + + +if __name__ == "__main__": + main() diff --git a/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_external_epg.py b/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_external_epg.py index dff4cf152..ee48df378 100644 --- a/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_external_epg.py +++ b/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_external_epg.py @@ -1,7 +1,7 @@ #!/usr/bin/python # -*- coding: utf-8 -*- -# Copyright: (c) 2021, Anvitha Jain (@anvitha-jain) <anvjain@cisco.com> +# Copyright: (c) 2021, 2023, Anvitha Jain (@anvitha-jain) <anvjain@cisco.com> # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) from __future__ import absolute_import, division, print_function @@ -13,7 +13,7 @@ ANSIBLE_METADATA = {"metadata_version": "1.1", "status": ["preview"], "supported DOCUMENTATION = r""" --- module: mso_schema_site_external_epg -short_description: Manage External EPG in schema of sites +short_description: Manage External EPG in schema of sites. description: - Manage External EPG in schema of sites on Cisco ACI Multi-Site. - This module can only be used on versions of MSO that are 3.3 or greater. @@ -34,6 +34,19 @@ options: description: - The L3Out associated with the external epg. - Required when site is of type on-premise. + - In NDO versions over 4.2, the parameter is accessible only when an external EPG is + - linked to the current schema-template's VRF. + type: str + aliases: [ l3out_name ] + l3out_schema: + description: + - The schema that defines the referenced L3Out. + - If this parameter is unspecified, it defaults to the current schema. + type: str + l3out_template: + description: + - The template that defines the referenced L3Out. + - If this parameter is unspecified, it defaults to the current template. type: str external_epg: description: @@ -75,7 +88,6 @@ EXAMPLES = r""" external_epg: External EPG 1 l3out: L3out1 state: present - delegate_to: localhost - name: Remove a Site External EPG cisco.mso.mso_schema_site_external_epg: @@ -87,7 +99,6 @@ EXAMPLES = r""" external_epg: External EPG 1 l3out: L3out1 state: absent - delegate_to: localhost - name: Query a Site External EPG cisco.mso.mso_schema_site_external_epg: @@ -99,7 +110,7 @@ EXAMPLES = r""" external_epg: External EPG 1 l3out: L3out1 state: query - delegate_to: localhost + register: query_result - name: Query all Site External EPGs cisco.mso.mso_schema_site_external_epg: @@ -109,7 +120,7 @@ EXAMPLES = r""" schema: Schema 1 template: Template 1 state: query - delegate_to: localhost + register: query_result """ RETURN = r""" @@ -126,7 +137,9 @@ def main(): schema=dict(type="str", required=True), template=dict(type="str", required=True), site=dict(type="str", required=True), - l3out=dict(type="str"), + l3out=dict(type="str", aliases=["l3out_name"]), + l3out_schema=dict(type="str"), + l3out_template=dict(type="str"), external_epg=dict(type="str", aliases=["name"]), route_reachability=dict(type="str", default="internet", choices=["internet", "site-ext"]), state=dict(type="str", default="present", choices=["absent", "present", "query"]), @@ -142,15 +155,21 @@ def main(): ) schema = module.params.get("schema") - template = module.params.get("template") + template = module.params.get("template").replace(" ", "") site = module.params.get("site") external_epg = module.params.get("external_epg") l3out = module.params.get("l3out") + l3out_schema = module.params.get("l3out_schema") + l3out_template = module.params.get("l3out_template") route_reachability = module.params.get("route_reachability") state = module.params.get("state") mso = MSOModule(module) + l3out_template = template if l3out_template is None else l3out_template.replace(" ", "") + l3out_schema = schema if l3out_schema is None else l3out_schema + l3out_schema_id = mso.lookup_schema(l3out_schema) + mso_schema = MSOSchema(mso, schema, template, site) mso_objects = mso_schema.schema_objects @@ -175,7 +194,6 @@ def main(): ops = [] l3out_dn = "" - if state == "query": if external_epg is None: mso.existing = mso_objects.get("site").details.get("externalEpgs") @@ -208,8 +226,8 @@ def main(): ), l3outDn=l3out_dn, l3outRef=dict( - schemaId=mso_schema.id, - templateName=template, + schemaId=l3out_schema_id, + templateName=l3out_template, l3outName=l3out, ), routeReachabilityInternetType=route_reachability, diff --git a/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_external_epg_selector.py b/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_external_epg_selector.py index 001ebf2b5..e4081cebe 100644 --- a/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_external_epg_selector.py +++ b/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_external_epg_selector.py @@ -94,7 +94,6 @@ EXAMPLES = r""" operator: equals value: 10.0.0.0 state: present - delegate_to: localhost - name: Remove a Selector cisco.mso.mso_schema_site_external_epg_selector: @@ -107,7 +106,6 @@ EXAMPLES = r""" external_epg: ext1 selector: test state: absent - delegate_to: localhost - name: Query a specific Selector cisco.mso.mso_schema_site_external_epg_selector: @@ -120,7 +118,6 @@ EXAMPLES = r""" external_epg: ext1 selector: selector_1 state: query - delegate_to: localhost register: query_result - name: Query all Selectors @@ -133,7 +130,6 @@ EXAMPLES = r""" site: azure_ansible_test external_epg: ext1 state: query - delegate_to: localhost register: query_result """ diff --git a/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_l3out.py b/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_l3out.py index 4741e4bd7..4293d7253 100644 --- a/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_l3out.py +++ b/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_l3out.py @@ -89,7 +89,6 @@ EXAMPLES = r""" template: TemplateName schema: schemaName state: present - delegate_to: localhost - name: Remove a site L3Out cisco.mso.mso_schema_site_l3out: @@ -101,7 +100,6 @@ EXAMPLES = r""" template: Template1 l3out: L3out1 state: absent - delegate_to: localhost - name: Query a specific site L3Out cisco.mso.mso_schema_site_l3out: @@ -113,7 +111,6 @@ EXAMPLES = r""" template: Template1 l3out: L3out1 state: query - delegate_to: localhost register: query_result - name: Query all site l3outs @@ -125,7 +122,6 @@ EXAMPLES = r""" site: Site1 template: Template1 state: query - delegate_to: localhost register: query_result """ diff --git a/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_service_graph.py b/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_service_graph.py index 9495a501d..29919152d 100644 --- a/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_service_graph.py +++ b/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_service_graph.py @@ -50,11 +50,32 @@ options: type: list elements: dict suboptions: - name: + device_name: description: - The name of the device required: true type: str + aliases: [ name ] + provider_interface: + description: + - The name of the provider interface for the Azure CNC L4-L7 device. + type: str + provider_connector_type: + description: + - The provider connector type for the Azure CNC site service graph. + - Defaults to C(none) when unset during creation. + type: str + choices: [ none, redirect, source_nat, destination_nat, source_and_destination_nat ] + consumer_interface: + description: + - The name of the consumer interface for the Azure CNC L4-L7 device. + type: str + consumer_connector_type: + description: + - The consumer connector type for the Azure CNC site service graph. + - Defaults to C(none) when unset during creation. + type: str + choices: [ none, redirect ] state: description: - Use C(present) or C(absent) for adding or removing. @@ -81,7 +102,28 @@ EXAMPLES = r""" - name: ansible_test_adc - name: ansible_test_other state: present - delegate_to: localhost + +- name: Add a Site service graph for the Azure cloud CNC + cisco.mso.mso_schema_site_service_graph: + host: mso_host + username: admin + password: SomeSecretPassword + schema: Schema1 + template: Template1 + service_graph: SG1 + site: site1 + tenant: tenant1 + devices: + - name: ans_tnt_firewall1 + provider_connector_type: source_nat + provider_interface: TP_FW_Inf1 + consumer_connector_type: redirect + consumer_interface: TP_FW_Inf1 + - name: ans_tnt_app_lb + - name: ans_tnt_other + provider_connector_type: destination_nat + consumer_connector_type: redirect + state: present - name: Remove a Service Graph cisco.mso.mso_schema_site_service_graph_node: @@ -93,7 +135,6 @@ EXAMPLES = r""" service_graph: SG1 site: site1 state: absent - delegate_to: localhost - name: Query a specific Service Graph cisco.mso.mso_schema_site_service_graph_node: @@ -105,7 +146,7 @@ EXAMPLES = r""" service_graph: SG1 site: site1 state: query - delegate_to: localhost + register: query_result - name: Query all Service Graphs cisco.mso.mso_schema_site_service_graph_node: @@ -116,14 +157,21 @@ EXAMPLES = r""" template: Template1 site: site1 state: query - delegate_to: localhost + register: query_result """ RETURN = r""" """ + from ansible.module_utils.basic import AnsibleModule -from ansible_collections.cisco.mso.plugins.module_utils.mso import MSOModule, mso_argument_spec, mso_service_graph_node_device_spec +from ansible_collections.cisco.mso.plugins.module_utils.mso import ( + MSOModule, + mso_argument_spec, + mso_service_graph_node_device_spec, + service_node_ref_str_to_dict, +) +from ansible_collections.cisco.mso.plugins.module_utils.constants import AZURE_L4L7_CONNECTOR_TYPE_MAP def main(): @@ -206,17 +254,25 @@ def main(): ops = [] mso.previous = mso.existing + if mso.previous.get("serviceNodes") is not None and len(mso.previous.get("serviceNodes")) > 0: + for node in mso.previous.get("serviceNodes"): + node["serviceNodeRef"] = service_node_ref_str_to_dict(node.get("serviceNodeRef")) + + devices_payload = [] + if state == "absent": if mso.existing: mso.sent = mso.existing = {} ops.append(dict(op="remove", path=service_graph_path)) elif state == "present": - devices_payload = [] service_graphs = templates[template_idx]["serviceGraphs"] + service_node_types_from_template = [] for graph in service_graphs: if graph.get("name") == service_graph: service_node_types_from_template = graph["serviceNodes"] + break + user_number_devices = len(devices) number_of_nodes_in_template = len(service_node_types_from_template) if user_number_devices != number_of_nodes_in_template: @@ -227,29 +283,77 @@ def main(): ) if devices is not None: - service_node_type_names_from_template = [type.get("name") for type in service_node_types_from_template] + query_device_data = mso.lookup_service_node_device(site_id, tenant, device_name=None, service_node_type=None) for index, device in enumerate(devices): - template_node_type = service_node_type_names_from_template[index] - apic_type = "OTHERS" - if template_node_type == "firewall": - apic_type = "FW" - elif template_node_type == "load-balancer": - apic_type = "ADC" - query_device_data = mso.lookup_service_node_device(site_id, tenant, device.get("name"), apic_type) - devices_payload.append( - dict( - device=dict( - dn=query_device_data.get("dn"), - funcTyp=query_device_data.get("funcType"), - ), - serviceNodeRef=dict( - serviceNodeName=template_node_type, - serviceGraphName=service_graph, - templateName=template, - schemaId=schema_id, - ), - ), - ) + if query_device_data: + for device_data in query_device_data: + if device.get("device_name") == device_data.get("dn").split("/")[-1].split("-")[-1]: + device_payload = dict() + device_payload["device"] = dict( + dn=device_data.get("dn"), + funcType=device_data.get("funcType"), + ) + device_payload["serviceNodeRef"] = dict( + serviceNodeName="node{0}".format(index + 1), + serviceGraphName=service_graph, + templateName=template, + schemaId=schema_id, + ) + + if mso.cloud_provider_type == "azure": + consumer_interface = device.get("consumer_interface") + provider_interface = device.get("provider_interface") + provider_connector_type = device.get("provider_connector_type") + consumer_connector_type = device.get("consumer_connector_type") + + if ( + device_data.get("deviceVendorType") == "NATIVELB" + and device_data.get("devType") == "application" + and ( + consumer_interface is not None + or provider_interface is not None + or provider_connector_type is not None + or consumer_connector_type is not None + ) + ): + # Application Load Balancer - Consumer Interface, Consumer Connector Type, + # Provider Interface, Provider Connector Type - not supported + mso.fail_json( + msg="Unsupported attributes: provider_connector_type, provider_interface, " + + "consumer_connector_type, consumer_interface should be 'None' for the " + + "Application Load Balancer device." + ) + elif ( + device_data.get("deviceVendorType") == "NATIVELB" + and device_data.get("devType") == "network" + and (consumer_interface is not None or provider_interface is not None) + ): + # Network Load Balancer - Consumer Interface, Provider Interface - not supported + mso.fail_json( + msg="Unsupported attributes: provider_interface and consumer_interface should " + + "be 'None' for the Network Load Balancer device." + ) + elif ( + device_data.get("deviceVendorType") == "ADC" + and device_data.get("devType") == "CLOUD" + and (provider_connector_type is not None or consumer_connector_type is not None) + ): + # Third-Party Load Balancer - Consumer Connector Type, + # Provider Connector Type - not supported + mso.fail_json( + msg="Unsupported attributes: provider_connector_type and " + + "consumer_connector_type should be 'None' for the " + + "Third-Party Load Balancer." + ) + + # (FW) Third-Party Firewall - Consumer Interface, Consumer Connector Type, + # Provider Interface, Provider Connector Type - supported + device_payload["consumerInterface"] = consumer_interface + device_payload["providerInterface"] = provider_interface + device_payload["providerConnectorType"] = AZURE_L4L7_CONNECTOR_TYPE_MAP.get(provider_connector_type) + device_payload["consumerConnectorType"] = AZURE_L4L7_CONNECTOR_TYPE_MAP.get(consumer_connector_type) + + devices_payload.append(device_payload) payload = dict( serviceGraphRef=dict( @@ -263,6 +367,8 @@ def main(): mso.sanitize(payload, collate=True) if not mso.existing: + # The site service graph reference will be added automatically when the site is associated with the template + # So the add(create) part will not be used for the NDO v4.2 ops.append(dict(op="add", path=service_graphs_path, value=payload)) else: ops.append(dict(op="replace", path=service_graph_path, value=mso.sent)) diff --git a/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_vrf.py b/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_vrf.py index a0b864a8b..42de06ab7 100644 --- a/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_vrf.py +++ b/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_vrf.py @@ -63,7 +63,6 @@ EXAMPLES = r""" template: Template1 vrf: VRF1 state: present - delegate_to: localhost - name: Remove a site VRF cisco.mso.mso_schema_site_vrf: @@ -75,7 +74,6 @@ EXAMPLES = r""" template: Template1 vrf: VRF1 state: absent - delegate_to: localhost - name: Query a specific site VRF cisco.mso.mso_schema_site_vrf: @@ -87,7 +85,6 @@ EXAMPLES = r""" template: Template1 vrf: VRF1 state: query - delegate_to: localhost register: query_result - name: Query all site VRFs @@ -99,7 +96,6 @@ EXAMPLES = r""" site: Site1 template: Template1 state: query - delegate_to: localhost register: query_result """ diff --git a/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_vrf_region.py b/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_vrf_region.py index 5ac5804e6..6863426ad 100644 --- a/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_vrf_region.py +++ b/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_vrf_region.py @@ -101,7 +101,6 @@ EXAMPLES = r""" region: us-west-1 vpn_gateway_router: false state: present - delegate_to: localhost - name: Remove a site VRF region cisco.mso.mso_schema_site_vrf_region: @@ -114,7 +113,6 @@ EXAMPLES = r""" vrf: VRF1 region: us-west-1 state: absent - delegate_to: localhost - name: Query a specific site VRF region cisco.mso.mso_schema_site_vrf_region: @@ -127,7 +125,6 @@ EXAMPLES = r""" vrf: VRF1 region: us-west-1 state: query - delegate_to: localhost register: query_result - name: Query all site VRF regions @@ -140,7 +137,6 @@ EXAMPLES = r""" template: Template1 vrf: VRF1 state: query - delegate_to: localhost register: query_result """ diff --git a/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_vrf_region_cidr.py b/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_vrf_region_cidr.py index ef409f710..b2a8e4f33 100644 --- a/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_vrf_region_cidr.py +++ b/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_vrf_region_cidr.py @@ -87,7 +87,6 @@ EXAMPLES = r""" region: us-west-1 cidr: 14.14.14.1/24 state: present - delegate_to: localhost - name: Remove a site VRF region CIDR cisco.mso.mso_schema_site_vrf_region_cidr: @@ -101,7 +100,6 @@ EXAMPLES = r""" region: us-west-1 cidr: 14.14.14.1/24 state: absent - delegate_to: localhost - name: Query a specific site VRF region CIDR cisco.mso.mso_schema_site_vrf_region_cidr: @@ -115,7 +113,6 @@ EXAMPLES = r""" region: us-west-1 cidr: 14.14.14.1/24 state: query - delegate_to: localhost register: query_result - name: Query all site VRF region CIDR @@ -129,7 +126,6 @@ EXAMPLES = r""" vrf: VRF1 region: us-west-1 state: query - delegate_to: localhost register: query_result """ diff --git a/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_vrf_region_cidr_subnet.py b/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_vrf_region_cidr_subnet.py index 85a00ea9c..a8cd42ca5 100644 --- a/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_vrf_region_cidr_subnet.py +++ b/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_vrf_region_cidr_subnet.py @@ -113,7 +113,6 @@ EXAMPLES = r""" subnet: 14.14.14.2/24 zone: us-west-1a state: present - delegate_to: localhost - name: Remove a site VRF region CIDR subnet cisco.mso.mso_schema_site_vrf_region_cidr_subnet: @@ -128,7 +127,6 @@ EXAMPLES = r""" cidr: 14.14.14.1/24 subnet: 14.14.14.2/24 state: absent - delegate_to: localhost - name: Query a specific site VRF region CIDR subnet cisco.mso.mso_schema_site_vrf_region_cidr_subnet: @@ -143,7 +141,6 @@ EXAMPLES = r""" cidr: 14.14.14.1/24 subnet: 14.14.14.2/24 state: query - delegate_to: localhost register: query_result - name: Query all site VRF region CIDR subnet @@ -158,7 +155,6 @@ EXAMPLES = r""" region: us-west-1 cidr: 14.14.14.1/24 state: query - delegate_to: localhost register: query_result """ diff --git a/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_vrf_region_hub_network.py b/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_vrf_region_hub_network.py index 9df7bab4f..3d0cf4f3c 100644 --- a/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_vrf_region_hub_network.py +++ b/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_vrf_region_hub_network.py @@ -93,7 +93,6 @@ EXAMPLES = r""" name: hub-default tenant: infra state: present - delegate_to: localhost - name: Remove a site VRF region hub network cisco.mso.mso_schema_site_vrf_region_hub_network: @@ -105,7 +104,6 @@ EXAMPLES = r""" template: Template1 vrf: VRF1 state: absent - delegate_to: localhost - name: Query site VRF region hub network cisco.mso.mso_schema_site_vrf_region_hub_network: @@ -118,7 +116,6 @@ EXAMPLES = r""" vrf: VRF1 region: us-west-1 state: query - delegate_to: localhost register: query_result """ diff --git a/ansible_collections/cisco/mso/plugins/modules/mso_schema_template.py b/ansible_collections/cisco/mso/plugins/modules/mso_schema_template.py index 6f4ece9ca..bd0fa8fef 100644 --- a/ansible_collections/cisco/mso/plugins/modules/mso_schema_template.py +++ b/ansible_collections/cisco/mso/plugins/modules/mso_schema_template.py @@ -2,6 +2,8 @@ # -*- coding: utf-8 -*- # Copyright: (c) 2018, Dag Wieers (@dagwieers) <dag@wieers.com> +# Copyright: (c) 2023, Akini Ross (@akinross) <akinross@cisco.com> + # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) from __future__ import absolute_import, division, print_function @@ -18,12 +20,12 @@ description: - Manage templates on Cisco ACI Multi-Site. author: - Dag Wieers (@dagwieers) +- Akini Ross (@akinross) options: tenant: description: - The tenant used for this template. type: str - required: true schema: description: - The name of the schema. @@ -50,6 +52,7 @@ options: description: - Use C(present) or C(absent) for adding or removing. - Use C(query) for listing an object or multiple objects. + - Using C(present) on empty schemas M(cisco.mso.mso_schema) is supported on versions of MSO that are 4.2 or greater. type: str choices: [ absent, present, query ] default: present @@ -71,7 +74,6 @@ EXAMPLES = r""" schema: Schema 1 template: Template 1 state: present - delegate_to: localhost - name: Remove a template from a schema cisco.mso.mso_schema_template: @@ -82,7 +84,6 @@ EXAMPLES = r""" schema: Schema 1 template: Template 1 state: absent - delegate_to: localhost - name: Query a template cisco.mso.mso_schema_template: @@ -93,7 +94,6 @@ EXAMPLES = r""" schema: Schema 1 template: Template 1 state: query - delegate_to: localhost register: query_result - name: Query all templates @@ -104,7 +104,6 @@ EXAMPLES = r""" tenant: Tenant 1 schema: Schema 1 state: query - delegate_to: localhost register: query_result """ @@ -118,7 +117,7 @@ from ansible_collections.cisco.mso.plugins.module_utils.mso import MSOModule, ms def main(): argument_spec = mso_argument_spec() argument_spec.update( - tenant=dict(type="str", required=True), + tenant=dict(type="str"), schema=dict(type="str", required=True), schema_description=dict(type="str"), template_description=dict(type="str"), @@ -132,7 +131,7 @@ def main(): supports_check_mode=True, required_if=[ ["state", "absent", ["template"]], - ["state", "present", ["template"]], + ["state", "present", ["template", "tenant"]], ], ) @@ -157,13 +156,11 @@ def main(): schema_path = "schemas/{id}".format(**schema_obj) # Get template - templates = [t.get("name") for t in schema_obj.get("templates")] + templates = schema_obj.get("templates") if schema_obj.get("templates") is not None else [] if template: - if template in templates: - template_idx = templates.index(template) - mso.existing = schema_obj.get("templates")[template_idx] + mso.existing = next((item for item in templates if item.get("name") == template), {}) else: - mso.existing = schema_obj.get("templates") + mso.existing = templates else: schema_path = "schemas" diff --git a/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_anp.py b/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_anp.py index 9922750f8..f37b95237 100644 --- a/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_anp.py +++ b/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_anp.py @@ -65,7 +65,6 @@ EXAMPLES = r""" template: Template 1 anp: ANP 1 state: present - delegate_to: localhost - name: Remove an ANP cisco.mso.mso_schema_template_anp: @@ -76,7 +75,6 @@ EXAMPLES = r""" template: Template 1 anp: ANP 1 state: absent - delegate_to: localhost - name: Query a specific ANPs cisco.mso.mso_schema_template_anp: @@ -86,7 +84,6 @@ EXAMPLES = r""" schema: Schema 1 template: Template 1 state: query - delegate_to: localhost register: query_result - name: Query all ANPs @@ -97,7 +94,6 @@ EXAMPLES = r""" schema: Schema 1 template: Template 1 state: query - delegate_to: localhost register: query_result """ diff --git a/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_anp_epg.py b/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_anp_epg.py index 6c021e7f7..b5a26f31c 100644 --- a/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_anp_epg.py +++ b/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_anp_epg.py @@ -212,7 +212,6 @@ EXAMPLES = r""" vrf: name: vrf1 state: present - delegate_to: localhost - name: Add a new EPG with preferred group. cisco.mso.mso_schema_template_anp_epg: @@ -225,7 +224,6 @@ EXAMPLES = r""" epg: EPG 1 state: present preferred_group: true - delegate_to: localhost - name: Remove an EPG cisco.mso.mso_schema_template_anp_epg: @@ -241,7 +239,6 @@ EXAMPLES = r""" vrf: name: vrf1 state: absent - delegate_to: localhost - name: Query a specific EPG cisco.mso.mso_schema_template_anp_epg: @@ -257,7 +254,6 @@ EXAMPLES = r""" vrf: name: vrf1 state: query - delegate_to: localhost register: query_result - name: Query all EPGs @@ -274,7 +270,6 @@ EXAMPLES = r""" vrf: name: vrf1 state: query - delegate_to: localhost register: query_result """ diff --git a/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_anp_epg_contract.py b/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_anp_epg_contract.py index d8c881d5d..3563e78f9 100644 --- a/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_anp_epg_contract.py +++ b/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_anp_epg_contract.py @@ -2,6 +2,7 @@ # -*- coding: utf-8 -*- # Copyright: (c) 2018, Dag Wieers (@dagwieers) <dag@wieers.com> +# Copyright: (c) 2024, Akini Ross (@akinross) <akinross@cisco.com> # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) from __future__ import absolute_import, division, print_function @@ -18,15 +19,16 @@ description: - Manage EPG contracts in schema templates on Cisco ACI Multi-Site. author: - Dag Wieers (@dagwieers) +- Akini Ross (@akinross) options: schema: description: - - The name of the schema. + - The name of the Schema. type: str required: true template: description: - - The name of the template to change. + - The name of the Template. type: str required: true anp: @@ -36,31 +38,70 @@ options: required: true epg: description: - - The name of the EPG to manage. + - The name of the EPG. type: str required: true + force_replace: + description: + - Replaces all the configured contract(s) with the provided contract(s). + - This option can only be used in combination with the O(contracts) option. + - In combination with the O(state=absent) and without any contract configuration all configured static port(s) will be removed. + type: bool contract: description: - - A contract associated to this EPG. + - The Contract associated to this EPG. + - This option can not be used in combination with the I(contracts) option. type: dict suboptions: name: description: - - The name of the Contract to associate with. + - The name of the Contract. + required: true + type: str + schema: + description: + - The name of the Schema that defines the referenced Contract. + - If this parameter is unspecified, it defaults to the current schema. + type: str + template: + description: + - The name of the Template that defines the referenced Contract. + - If this parameter is unspecified, it defaults to the current schema. + type: str + type: + description: + - The type of the Contract. + type: str + required: true + choices: [ consumer, provider ] + contracts: + description: + - A list of Contracts associated to this EPG. + - This option can not be used in combination with the O(contract) option. + - All configured contract(s) will be replaced with the provided contract(s) when used with O(force_replace=true). + - Only the provided contract(s) will be added, updated or removed when used with O(force_replace=false). + - In combination with the O(state=query) all provided contract(s) must be found else the task will fail. + type: list + elements: dict + suboptions: + name: + description: + - The name of the Contract. required: true type: str schema: description: - - The schema that defines the referenced BD. + - The name of the Schema that defines the referenced Contract. - If this parameter is unspecified, it defaults to the current schema. type: str template: description: - - The template that defines the referenced BD. + - The name of the Template that defines the referenced Contract. + - If this parameter is unspecified, it defaults to the current schema. type: str type: description: - - The type of contract. + - The type of the Contract. type: str required: true choices: [ consumer, provider ] @@ -91,9 +132,8 @@ EXAMPLES = r""" name: Contract 1 type: consumer state: present - delegate_to: localhost -- name: Remove a Contract +- name: Add 2 contracts to an EPG cisco.mso.mso_schema_template_anp_epg_contract: host: mso_host username: admin @@ -102,10 +142,29 @@ EXAMPLES = r""" template: Template 1 anp: ANP 1 epg: EPG 1 - contract: - name: Contract 1 - state: absent - delegate_to: localhost + contracts: + - name: Contract 1 + type: provider + - name: Contract 1 + type: consumer + state: present + +- name: Replace all existing contracts on an EPG with 2 new contracts + cisco.mso.mso_schema_template_anp_epg_contract: + host: mso_host + username: admin + password: SomeSecretPassword + schema: Schema 1 + template: Template 1 + anp: ANP 1 + epg: EPG 1 + force_replace: true + contracts: + - name: Contract 2 + type: provider + - name: Contract 2 + type: consumer + state: present - name: Query a specific Contract cisco.mso.mso_schema_template_anp_epg_contract: @@ -118,8 +177,25 @@ EXAMPLES = r""" epg: EPG 1 contract: name: Contract 1 + type: consumer + state: query + register: query_result + +- name: Query a list of Contracts + cisco.mso.mso_schema_template_anp_epg_contract: + host: mso_host + username: admin + password: SomeSecretPassword + schema: Schema 1 + template: Template 1 + anp: ANP 1 + epg: EPG 1 + contracts: + - name: Contract 2 + type: provider + - name: Contract 2 + type: consumer state: query - delegate_to: localhost register: query_result - name: Query all Contracts @@ -131,8 +207,48 @@ EXAMPLES = r""" template: Template 1 anp: ANP 1 state: query - delegate_to: localhost register: query_result + +- name: Remove a Contract + cisco.mso.mso_schema_template_anp_epg_contract: + host: mso_host + username: admin + password: SomeSecretPassword + schema: Schema 1 + template: Template 1 + anp: ANP 1 + epg: EPG 1 + contract: + name: Contract 1 + state: absent + +- name: Remove 2 contracts to an EPG + cisco.mso.mso_schema_template_anp_epg_contract: + host: mso_host + username: admin + password: SomeSecretPassword + schema: Schema 1 + template: Template 1 + anp: ANP 1 + epg: EPG 1 + contracts: + - name: Contract 1 + type: provider + - name: Contract 1 + type: consumer + state: absent + +- name: Remove all existing contracts from an EPG + cisco.mso.mso_schema_template_anp_epg_contract: + host: mso_host + username: admin + password: SomeSecretPassword + schema: Schema 1 + template: Template 1 + anp: ANP 1 + epg: EPG 1 + force_replace: true + state: absent """ RETURN = r""" @@ -140,6 +256,7 @@ RETURN = r""" from ansible.module_utils.basic import AnsibleModule from ansible_collections.cisco.mso.plugins.module_utils.mso import MSOModule, mso_argument_spec, mso_contractref_spec +from ansible_collections.cisco.mso.plugins.module_utils.schema import MSOSchema def main(): @@ -149,7 +266,9 @@ def main(): template=dict(type="str", required=True), anp=dict(type="str", required=True), epg=dict(type="str", required=True), + force_replace=dict(type="bool"), contract=dict(type="dict", options=mso_contractref_spec()), + contracts=dict(type="list", elements="dict", options=mso_contractref_spec()), state=dict(type="str", default="present", choices=["absent", "present", "query"]), ) @@ -157,8 +276,12 @@ def main(): argument_spec=argument_spec, supports_check_mode=True, required_if=[ - ["state", "absent", ["contract"]], - ["state", "present", ["contract"]], + ["state", "absent", ["contract", "contracts", "force_replace"], True], + ["state", "present", ["contract", "contracts"], True], + ], + mutually_exclusive=[ + ["contract", "contracts"], + ["contract", "force_replace"], ], ) @@ -166,97 +289,160 @@ def main(): template = module.params.get("template").replace(" ", "") anp = module.params.get("anp") epg = module.params.get("epg") + force_replace = module.params.get("force_replace") contract = module.params.get("contract") - if contract is not None and contract.get("template") is not None: - contract["template"] = contract.get("template").replace(" ", "") + contracts = module.params.get("contracts") state = module.params.get("state") mso = MSOModule(module) + mso_schema = MSOSchema(mso, schema, template) + mso_schema.set_template(template) + mso_schema.set_template_anp(anp) + mso_schema.set_template_anp_epg(epg) + + # Schema dict is used as a cache store for schema id lookups + # This is done to limit the amount of schema id lookups when schema is not specified for multiple contracts + schema_cache = {mso_schema.schema_name: mso_schema.id} if contract: - if contract.get("schema") is None: - contract["schema"] = schema - contract["schema_id"] = mso.lookup_schema(contract.get("schema")) - if contract.get("template") is None: - contract["template"] = template - - # Get schema - schema_id, schema_path, schema_obj = mso.query_schema(schema) - - # Get template - templates = [t.get("name") for t in schema_obj.get("templates")] - if template not in templates: - mso.fail_json(msg="Provided template '{0}' does not exist. Existing templates: {1}".format(template, ", ".join(templates))) - template_idx = templates.index(template) - - # Get ANP - anps = [a.get("name") for a in schema_obj.get("templates")[template_idx]["anps"]] - if anp not in anps: - mso.fail_json(msg="Provided anp '{0}' does not exist. Existing anps: {1}".format(anp, ", ".join(anps))) - anp_idx = anps.index(anp) - - # Get EPG - epgs = [e.get("name") for e in schema_obj.get("templates")[template_idx]["anps"][anp_idx]["epgs"]] - if epg not in epgs: - mso.fail_json(msg="Provided epg '{epg}' does not exist. Existing epgs: {epgs}".format(epg=epg, epgs=", ".join(epgs))) - epg_idx = epgs.index(epg) - - # Get Contract + overwrite_contract_schema_and_template(mso, contract, schema, schema_cache, template) + elif contracts: + for contract_dict in contracts: + overwrite_contract_schema_and_template(mso, contract_dict, schema, schema_cache, template) + + contracts_path = "/templates/{0}/anps/{1}/epgs/{2}/contractRelationships".format(template, anp, epg) + contract_path = "{0}/-".format(contracts_path) + ops = [] + if contract: - contracts = [ - (c.get("contractRef"), c.get("relationshipType")) - for c in schema_obj.get("templates")[template_idx]["anps"][anp_idx]["epgs"][epg_idx]["contractRelationships"] - ] contract_ref = mso.contract_ref(**contract) - if (contract_ref, contract.get("type")) in contracts: - contract_idx = contracts.index((contract_ref, contract.get("type"))) - contract_path = "/templates/{0}/anps/{1}/epgs/{2}/contractRelationships/{3}".format(template, anp, epg, contract_idx) - mso.existing = schema_obj.get("templates")[template_idx]["anps"][anp_idx]["epgs"][epg_idx]["contractRelationships"][contract_idx] + mso_schema.set_template_anp_epg_contract(contract_ref, contract.get("type"), False) + if mso_schema.schema_objects.get("template_anp_epg_contract") is not None: + mso.existing = get_contract_payload_from_schema(mso, mso_schema) + contract_path = "{0}/{1}".format(contracts_path, mso_schema.schema_objects["template_anp_epg_contract"].index) + else: + found_contracts = [] + set_existing_contracts(mso, mso_schema) + if contracts: + for contract_details in contracts: + contract_ref = mso.contract_ref(**contract_details) + mso_schema.set_template_anp_epg_contract(contract_ref, contract_details.get("type"), False) + if mso_schema.schema_objects.get("template_anp_epg_contract") is not None: + found_contracts.append(get_contract_payload_from_schema(mso, mso_schema)) if state == "query": - if not contract: - mso.existing = schema_obj.get("templates")[template_idx]["anps"][anp_idx]["epgs"][epg_idx]["contractRelationships"] + if contracts: + if len(found_contracts) == len(contracts): + mso.existing = found_contracts + else: + not_found_contracts = [ + "Contract with Reference '{0}' and type '{1}' not found".format(mso.contract_ref(**contract), contract.get("type")) + for contract in contracts + if contract not in found_contracts + ] + mso.fail_json(msg=not_found_contracts) elif not mso.existing: - mso.fail_json(msg="Contract '{0}' not found".format(contract_ref)) - - if "contractRef" in mso.existing: - mso.existing["contractRef"] = mso.dict_from_ref(mso.existing.get("contractRef")) + mso.fail_json(msg="Contract with Reference '{0}' and type '{1}' not found".format(contract_ref, contract.get("type"))) mso.exit_json() - contracts_path = "/templates/{0}/anps/{1}/epgs/{2}/contractRelationships".format(template, anp, epg) - ops = [] - mso.previous = mso.existing - if state == "absent": - if mso.existing: - mso.sent = mso.existing = {} + + if state == "absent" and mso.existing: + if contract: + mso.sent = mso.proposed = {} ops.append(dict(op="remove", path=contract_path)) + elif force_replace: + mso.sent = mso.proposed = [] + ops.append(dict(op="remove", path=contracts_path)) + else: + mso.proposed = mso.existing.copy() + remove_index = [] + for contract in contracts: + payload = get_contract_payload(contract) + if any(True if payload == found_contract else False for found_contract in found_contracts): + mso.proposed.remove(payload) + remove_index.append(mso.existing.index(payload)) + # The list index should not shift when removing contracts from the list + # By sorting the indexes found in reverse order, we assure that the highest index is removed first by the NDO backend + # This logic is to avoid removing the wrong contract + for index in reversed(sorted(remove_index)): + ops.append(dict(op="remove", path="{0}/{1}".format(contracts_path, index))) + mso.sent = mso.proposed elif state == "present": - payload = dict( - relationshipType=contract.get("type"), - contractRef=dict( - contractName=contract.get("name"), - templateName=contract.get("template"), - schemaId=contract.get("schema_id"), - ), + if contract: + mso.sanitize(get_contract_payload(contract), collate=True) + if not mso.existing: + ops.append(dict(op="add", path=contract_path, value=mso.sent)) + elif force_replace: + mso.sent = mso.proposed = [get_contract_payload(contract) for contract in contracts] + if mso.existing: + ops.append(dict(op="replace", path=contracts_path, value=mso.sent)) + else: + ops.append(dict(op="add", path=contracts_path, value=mso.sent)) + else: + mso.sent = [] + mso.proposed = mso.existing.copy() + for contract in contracts: + payload = get_contract_payload(contract) + if payload not in mso.existing: + mso.proposed.append(payload) + # Only add the operation list if the contract is not already present + # This is to avoid adding the same contract multiple times + # Replace operation is not required because there are no attributes that can be changed except the contract itself + if not force_replace and not any(True if payload == found_contract else False for found_contract in found_contracts): + ops.append(dict(op="add", path=contract_path, value=payload)) + mso.sent.append(payload) + + mso.existing = mso.proposed + + if not module.check_mode and mso.proposed != mso.previous: + mso.request(mso_schema.path, method="PATCH", data=ops) + + mso.exit_json() + + +def set_existing_contracts(mso, mso_schema): + mso.existing = [] + for existing_contract in mso_schema.schema_objects["template_anp_epg"].details.get("contractRelationships"): + mso.existing.append( + dict( + relationshipType=existing_contract.get("relationshipType"), + contractRef=mso.dict_from_ref(existing_contract.get("contractRef")), + ) ) - mso.sanitize(payload, collate=True) - if mso.existing: - ops.append(dict(op="replace", path=contract_path, value=mso.sent)) - else: - ops.append(dict(op="add", path=contracts_path + "/-", value=mso.sent)) +def get_contract_payload_from_schema(mso, mso_schema): + return dict( + relationshipType=mso_schema.schema_objects["template_anp_epg_contract"].details.get("relationshipType"), + contractRef=mso.dict_from_ref(mso_schema.schema_objects["template_anp_epg_contract"].details.get("contractRef")), + ) - mso.existing = mso.proposed - if "contractRef" in mso.previous: - mso.previous["contractRef"] = mso.dict_from_ref(mso.previous.get("contractRef")) - if not module.check_mode and mso.proposed != mso.previous: - mso.request(schema_path, method="PATCH", data=ops) +def get_contract_payload(contract): + return dict( + relationshipType=contract.get("type"), + contractRef=dict( + contractName=contract.get("name"), + templateName=contract.get("template"), + schemaId=contract.get("schema_id"), + ), + ) - mso.exit_json() + +def overwrite_contract_schema_and_template(mso, contract, epg_schema_name, schema_cache, epg_template_name): + if contract.get("schema") is None: + contract["schema"] = epg_schema_name + contract["schema_id"] = schema_cache.get(epg_schema_name) + else: + schema_id = schema_cache.get(contract.get("schema")) + contract["schema_id"] = schema_id if schema_id else mso.lookup_schema(contract.get("schema")) + + if contract.get("template") is None: + contract["template"] = epg_template_name + else: + contract["template"] = contract.get("template").replace(" ", "") if __name__ == "__main__": diff --git a/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_anp_epg_selector.py b/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_anp_epg_selector.py index bd98fc321..f479fe807 100644 --- a/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_anp_epg_selector.py +++ b/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_anp_epg_selector.py @@ -94,7 +94,6 @@ EXAMPLES = r""" operator: in value: test state: present - delegate_to: localhost - name: Remove a Selector cisco.mso.mso_schema_template_anp_epg_selector: @@ -107,7 +106,6 @@ EXAMPLES = r""" epg: EPG 1 selector: selector_1 state: absent - delegate_to: localhost - name: Query a specific Selector cisco.mso.mso_schema_template_anp_epg_selector: @@ -120,7 +118,6 @@ EXAMPLES = r""" epg: EPG 1 selector: selector_1 state: query - delegate_to: localhost register: query_result - name: Query all Selectors @@ -133,7 +130,6 @@ EXAMPLES = r""" anp: ANP 1 epg: EPG 1 state: query - delegate_to: localhost register: query_result """ diff --git a/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_anp_epg_subnet.py b/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_anp_epg_subnet.py index b060ddd5e..2a88803b3 100644 --- a/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_anp_epg_subnet.py +++ b/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_anp_epg_subnet.py @@ -89,7 +89,6 @@ EXAMPLES = r""" epg: EPG 1 subnet: 10.0.0.0/24 state: present - delegate_to: localhost - name: Remove a subnet from an EPG cisco.mso.mso_schema_template_anp_epg_subnet: @@ -102,7 +101,6 @@ EXAMPLES = r""" epg: EPG 1 subnet: 10.0.0.0/24 state: absent - delegate_to: localhost - name: Query a specific EPG subnet cisco.mso.mso_schema_template_anp_epg_subnet: @@ -115,7 +113,6 @@ EXAMPLES = r""" epg: EPG 1 subnet: 10.0.0.0/24 state: query - delegate_to: localhost register: query_result - name: Query all EPGs subnets @@ -127,7 +124,6 @@ EXAMPLES = r""" template: Template 1 anp: ANP 1 state: query - delegate_to: localhost register: query_result """ diff --git a/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_anp_epg_useg_attribute.py b/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_anp_epg_useg_attribute.py index 1f61e95de..0e9b8178e 100644 --- a/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_anp_epg_useg_attribute.py +++ b/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_anp_epg_useg_attribute.py @@ -69,7 +69,7 @@ options: description: - The uSeg Subnet can only be used when the I(attribute_type) is IP. - Use C(false) to set the custom uSeg Subnet IP address to the uSeg Attribute. - - Use C(true) to set the uSeg Subnet IP address to 0.0.0.0. + - Use C(true) to set the default uSeg Subnet IP address 0.0.0.0. type: bool state: description: @@ -98,7 +98,6 @@ EXAMPLES = r""" useg_subnet: false value: 10.0.0.0/24 state: present - delegate_to: localhost - name: Query a specific EPG uSeg attr with name cisco.mso.mso_schema_template_anp_epg_useg_attribute: @@ -111,7 +110,6 @@ EXAMPLES = r""" epg: EPG 1 name: useg_attr_ip state: query - delegate_to: localhost register: query_result - name: Query all EPG uSeg attrs @@ -124,7 +122,6 @@ EXAMPLES = r""" anp: ANP 1 epg: EPG 1 state: query - delegate_to: localhost register: query_result - name: Remove a uSeg attr from an EPG with name @@ -138,7 +135,6 @@ EXAMPLES = r""" epg: EPG 1 name: useg_attr_ip state: absent - delegate_to: localhost """ RETURN = r""" @@ -233,11 +229,13 @@ def main(): payload = dict(name=name, displayName=name, description=description, type=EPG_U_SEG_ATTR_TYPE_MAP[attribute_type], value=value) if attribute_type == "ip": - if useg_subnet is False: - payload["fvSubnet"] = True - else: - payload["fvSubnet"] = False + if useg_subnet: + if value != "" and value != "0.0.0.0" and value is not None: + mso.fail_json(msg="The value of uSeg subnet IP should be an empty string or 0.0.0.0, when the useg_subnet is set to true.") + payload["fvSubnet"] = useg_subnet payload["value"] = "0.0.0.0" + else: + payload["fvSubnet"] = useg_subnet mso.sanitize(payload, collate=True) diff --git a/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_bd.py b/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_bd.py index 0793e844d..ca2f9445d 100644 --- a/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_bd.py +++ b/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_bd.py @@ -250,7 +250,6 @@ EXAMPLES = r""" vrf: name: VRF1 state: present - delegate_to: localhost - name: Add a new BD from another Schema mso_schema_template_bd: @@ -265,7 +264,6 @@ EXAMPLES = r""" schema: Schema Origin template: Template Origin state: present - delegate_to: localhost - name: Add bd with options available on version 3.1 mso_schema_template_bd: @@ -357,7 +355,6 @@ EXAMPLES = r""" name: ansible_test_option version: 1 state: present - delegate_to: localhost - name: Remove a BD cisco.mso.mso_schema_template_bd: @@ -368,7 +365,6 @@ EXAMPLES = r""" template: Template 1 bd: BD1 state: absent - delegate_to: localhost - name: Query a specific BD cisco.mso.mso_schema_template_bd: @@ -379,7 +375,6 @@ EXAMPLES = r""" template: Template 1 bd: BD1 state: query - delegate_to: localhost register: query_result - name: Query all BDs @@ -390,7 +385,6 @@ EXAMPLES = r""" schema: Schema 1 template: Template 1 state: query - delegate_to: localhost register: query_result """ diff --git a/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_bd_dhcp_policy.py b/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_bd_dhcp_policy.py index 64fe360ea..095e5b668 100644 --- a/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_bd_dhcp_policy.py +++ b/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_bd_dhcp_policy.py @@ -85,7 +85,6 @@ EXAMPLES = r""" name: ansible_test_option version: 1 state: present - delegate_to: localhost - name: Remove a DHCP policy from a BD cisco.mso.mso_schema_template_bd_dhcp_policy: @@ -98,7 +97,6 @@ EXAMPLES = r""" name: ansible_test version: 1 state: absent - delegate_to: localhost - name: Query a specific BD DHCP Policy cisco.mso.mso_schema_template_bd_dhcp_policy: @@ -110,7 +108,6 @@ EXAMPLES = r""" bd: BD 1 name: ansible_test state: query - delegate_to: localhost register: query_result - name: Query all BD DHCP Policies @@ -122,7 +119,6 @@ EXAMPLES = r""" template: Template 1 bd: BD 1 state: query - delegate_to: localhost register: query_result """ diff --git a/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_bd_subnet.py b/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_bd_subnet.py index cc55eea7b..e4ae628e4 100644 --- a/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_bd_subnet.py +++ b/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_bd_subnet.py @@ -98,7 +98,6 @@ EXAMPLES = r""" bd: BD 1 subnet: 10.0.0.0/24 state: present - delegate_to: localhost - name: Remove a subset from a BD cisco.mso.mso_schema_template_bd_subnet: @@ -110,7 +109,6 @@ EXAMPLES = r""" bd: BD 1 subnet: 10.0.0.0/24 state: absent - delegate_to: localhost - name: Query a specific BD subnet cisco.mso.mso_schema_template_bd_subnet: @@ -122,7 +120,6 @@ EXAMPLES = r""" bd: BD 1 subnet: 10.0.0.0/24 state: query - delegate_to: localhost register: query_result - name: Query all BD subnets @@ -134,7 +131,6 @@ EXAMPLES = r""" template: Template 1 bd: BD 1 state: query - delegate_to: localhost register: query_result """ diff --git a/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_clone.py b/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_clone.py index 0cd41779f..dd1d1e067 100644 --- a/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_clone.py +++ b/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_clone.py @@ -69,7 +69,6 @@ EXAMPLES = r""" destination_template_name: Template1_clone destination_template_display_name: Template1_clone state: clone - delegate_to: localhost - name: Clone template to different schema cisco.mso.mso_schema_template_clone: @@ -83,7 +82,6 @@ EXAMPLES = r""" destination_template_name: Cloned_template_1 destination_template_display_name: Cloned_template_1 state: clone - delegate_to: localhost - name: Clone template in the same schema but different tenant attached cisco.mso.mso_schema_template_clone: @@ -96,7 +94,6 @@ EXAMPLES = r""" source_template_name: Template1_clone destination_template_name: Template1_clone_2 state: clone - delegate_to: localhost """ RETURN = r""" diff --git a/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_contract_filter.py b/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_contract_filter.py index 11bf08731..cb2ac1b0d 100644 --- a/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_contract_filter.py +++ b/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_contract_filter.py @@ -128,7 +128,6 @@ EXAMPLES = r""" contract_scope: global filter: Filter 1 state: present - delegate_to: localhost - name: Remove a contract filter cisco.mso.mso_schema_template_contract_filter: @@ -140,7 +139,6 @@ EXAMPLES = r""" contract: Contract 1 filter: Filter 1 state: absent - delegate_to: localhost - name: Query a specific contract filter cisco.mso.mso_schema_template_contract_filter: @@ -152,7 +150,6 @@ EXAMPLES = r""" contract: Contract 1 filter: Filter 1 state: query - delegate_to: localhost register: query_result - name: Query all contract filters @@ -164,7 +161,6 @@ EXAMPLES = r""" template: Template 1 contract: Contract 1 state: query - delegate_to: localhost register: query_result """ diff --git a/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_contract_service_graph.py b/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_contract_service_graph.py index 0e398843b..deaa82e18 100644 --- a/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_contract_service_graph.py +++ b/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_contract_service_graph.py @@ -113,7 +113,6 @@ EXAMPLES = r""" consumer: b2 filter: Filter 1 state: present - delegate_to: localhost - name: Remove a contract service graph cisco.mso.mso_schema_template_contract_service_graph: @@ -125,7 +124,6 @@ EXAMPLES = r""" contract: Contract 1 service_graph: SG1 state: absent - delegate_to: localhost - name: Query a contract service graph cisco.mso.mso_schema_template_contract_service_graph: @@ -136,7 +134,6 @@ EXAMPLES = r""" template: Template 1 contract: Contract 1 state: query - delegate_to: localhost register: query_result """ diff --git a/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_deploy.py b/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_deploy.py index 49df465c5..d3714d184 100644 --- a/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_deploy.py +++ b/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_deploy.py @@ -60,7 +60,6 @@ EXAMPLES = r""" schema: Schema 1 template: Template 1 state: deploy - delegate_to: localhost - name: Undeploy a schema template cisco.mso.mso_schema_template_deploy: @@ -71,7 +70,6 @@ EXAMPLES = r""" template: Template 1 site: Site 1 state: undeploy - delegate_to: localhost - name: Get deployment status cisco.mso.mso_schema: @@ -81,7 +79,6 @@ EXAMPLES = r""" schema: Schema 1 template: Template 1 state: status - delegate_to: localhost register: status_result """ diff --git a/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_deploy_status.py b/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_deploy_status.py index 707ad7320..768694905 100644 --- a/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_deploy_status.py +++ b/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_deploy_status.py @@ -51,7 +51,6 @@ EXAMPLES = r""" schema: Schema 1 template: Template 1 state: query - delegate_to: localhost register: query_result - name: Query status of objects using site @@ -62,7 +61,6 @@ EXAMPLES = r""" schema: Schema 1 site: ansible_test state: query - delegate_to: localhost register: query_result - name: Query status of objects in a template associated with a site @@ -74,7 +72,6 @@ EXAMPLES = r""" template: Template 1 site: ansible_test state: query - delegate_to: localhost register: query_result - name: Query status of objects in all templates @@ -84,7 +81,6 @@ EXAMPLES = r""" password: SomeSecretPassword schema: Schema 1 state: query - delegate_to: localhost register: query_result """ diff --git a/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_external_epg.py b/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_external_epg.py index ce201913f..3da65c7f5 100644 --- a/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_external_epg.py +++ b/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_external_epg.py @@ -138,7 +138,6 @@ EXAMPLES = r""" schema: Schema 1 template: Template 1 state: present - delegate_to: localhost - name: Add a new external EPG with external epg in cloud cisco.mso.mso_schema_template_external_epg: @@ -158,7 +157,6 @@ EXAMPLES = r""" schema: Schema 1 template: Template 1 state: present - delegate_to: localhost - name: Remove an external EPG cisco.mso.mso_schema_template_external_epg: @@ -169,7 +167,6 @@ EXAMPLES = r""" template: Template 1 external_epg: external EPG1 state: absent - delegate_to: localhost - name: Query a specific external EPGs cisco.mso.mso_schema_template_external_epg: @@ -180,7 +177,6 @@ EXAMPLES = r""" template: Template 1 external_epg: external EPG1 state: query - delegate_to: localhost register: query_result - name: Query all external EPGs @@ -191,7 +187,6 @@ EXAMPLES = r""" schema: Schema 1 template: Template 1 state: query - delegate_to: localhost register: query_result """ diff --git a/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_external_epg_contract.py b/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_external_epg_contract.py index 4029175bc..3b13c8020 100644 --- a/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_external_epg_contract.py +++ b/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_external_epg_contract.py @@ -85,7 +85,6 @@ EXAMPLES = r""" name: Contract 1 type: consumer state: present - delegate_to: localhost - name: Remove a Contract cisco.mso.mso_schema_template_external_epg_contract: @@ -98,7 +97,6 @@ EXAMPLES = r""" contract: name: Contract 1 state: absent - delegate_to: localhost - name: Query a specific Contract cisco.mso.mso_schema_template_external_epg_contract: @@ -111,7 +109,6 @@ EXAMPLES = r""" contract: name: Contract 1 state: query - delegate_to: localhost register: query_result - name: Query all Contracts @@ -122,7 +119,6 @@ EXAMPLES = r""" schema: Schema 1 template: Template 1 state: query - delegate_to: localhost register: query_result """ diff --git a/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_external_epg_selector.py b/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_external_epg_selector.py index 7d4b93b27..679c4ee27 100644 --- a/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_external_epg_selector.py +++ b/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_external_epg_selector.py @@ -90,7 +90,6 @@ EXAMPLES = r""" operator: equals value: 10.0.0.0 state: present - delegate_to: localhost - name: Remove a Selector cisco.mso.mso_schema_template_external_epg_selector: @@ -102,7 +101,6 @@ EXAMPLES = r""" external_epg: extEPG 1 selector: selector_1 state: absent - delegate_to: localhost - name: Query a specific Selector cisco.mso.mso_schema_template_external_epg_selector: @@ -114,7 +112,6 @@ EXAMPLES = r""" external_epg: extEPG 1 selector: selector_1 state: query - delegate_to: localhost register: query_result - name: Query all Selectors @@ -126,7 +123,6 @@ EXAMPLES = r""" template: Template 1 external_epg: extEPG 1 state: query - delegate_to: localhost register: query_result """ diff --git a/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_external_epg_subnet.py b/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_external_epg_subnet.py index c7512c2ee..7339312a0 100644 --- a/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_external_epg_subnet.py +++ b/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_external_epg_subnet.py @@ -50,6 +50,7 @@ options: - The C(shared-security) for Shared Security Import can only be used when External Subnets for External EPG is present type: list elements: str + default: [] aggregate: description: - The aggregate option aggregates shared routes for the subnet. @@ -57,6 +58,7 @@ options: - The C(shared-rtctrl) option can only be used when scope parameter Shared Route Control in the Route Control section is selected. type: list elements: str + default: [] state: description: - Use C(present) or C(absent) for adding or removing. @@ -80,7 +82,6 @@ EXAMPLES = r""" external_epg: EPG 1 subnet: 10.0.0.0/24 state: present - delegate_to: localhost - name: Remove a subnet from an External EPG cisco.mso.mso_schema_template_external_epg_subnet: @@ -92,7 +93,6 @@ EXAMPLES = r""" external_epg: EPG 1 subnet: 10.0.0.0/24 state: absent - delegate_to: localhost - name: Query a specific External EPG subnet cisco.mso.mso_schema_template_external_epg_subnet: @@ -104,7 +104,6 @@ EXAMPLES = r""" external_epg: EPG 1 subnet: 10.0.0.0/24 state: query - delegate_to: localhost register: query_result - name: Query all External EPGs subnets @@ -115,7 +114,6 @@ EXAMPLES = r""" schema: Schema 1 template: Template 1 state: query - delegate_to: localhost register: query_result """ diff --git a/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_externalepg.py b/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_externalepg.py index ce201913f..3da65c7f5 100644 --- a/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_externalepg.py +++ b/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_externalepg.py @@ -138,7 +138,6 @@ EXAMPLES = r""" schema: Schema 1 template: Template 1 state: present - delegate_to: localhost - name: Add a new external EPG with external epg in cloud cisco.mso.mso_schema_template_external_epg: @@ -158,7 +157,6 @@ EXAMPLES = r""" schema: Schema 1 template: Template 1 state: present - delegate_to: localhost - name: Remove an external EPG cisco.mso.mso_schema_template_external_epg: @@ -169,7 +167,6 @@ EXAMPLES = r""" template: Template 1 external_epg: external EPG1 state: absent - delegate_to: localhost - name: Query a specific external EPGs cisco.mso.mso_schema_template_external_epg: @@ -180,7 +177,6 @@ EXAMPLES = r""" template: Template 1 external_epg: external EPG1 state: query - delegate_to: localhost register: query_result - name: Query all external EPGs @@ -191,7 +187,6 @@ EXAMPLES = r""" schema: Schema 1 template: Template 1 state: query - delegate_to: localhost register: query_result """ diff --git a/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_filter_entry.py b/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_filter_entry.py index c0ab485a4..5bf69bde1 100644 --- a/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_filter_entry.py +++ b/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_filter_entry.py @@ -132,7 +132,6 @@ EXAMPLES = r""" template: Template 1 filter: Filter 1 state: present - delegate_to: localhost - name: Remove a filter entry cisco.mso.mso_schema_template_filter_entry: @@ -143,7 +142,6 @@ EXAMPLES = r""" template: Template 1 filter: Filter 1 state: absent - delegate_to: localhost - name: Query a specific filter entry cisco.mso.mso_schema_template_filter_entry: @@ -154,7 +152,6 @@ EXAMPLES = r""" template: Template 1 filter: Filter 1 state: query - delegate_to: localhost register: query_result - name: Query all filter entries @@ -165,7 +162,6 @@ EXAMPLES = r""" schema: Schema 1 template: Template 1 state: query - delegate_to: localhost register: query_result """ diff --git a/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_l3out.py b/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_l3out.py index 4b8c1b66d..eb7857df8 100644 --- a/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_l3out.py +++ b/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_l3out.py @@ -87,7 +87,6 @@ EXAMPLES = r""" schema: vrfSchema template: vrfTemplate state: present - delegate_to: localhost - name: Remove an L3out cisco.mso.mso_schema_template_l3out: @@ -98,7 +97,6 @@ EXAMPLES = r""" template: Template 1 l3out: L3out 1 state: absent - delegate_to: localhost - name: Query a specific L3outs cisco.mso.mso_schema_template_l3out: @@ -110,7 +108,6 @@ EXAMPLES = r""" template: Template 1 l3out: L3out 1 state: query - delegate_to: localhost register: query_result - name: Query all L3outs @@ -122,7 +119,6 @@ EXAMPLES = r""" schema: Schema 1 template: Template 1 state: query - delegate_to: localhost register: query_result """ diff --git a/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_migrate.py b/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_migrate.py index d0e15b8d0..35fa0d205 100644 --- a/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_migrate.py +++ b/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_migrate.py @@ -84,7 +84,6 @@ EXAMPLES = r""" - epg: EPG1 anp: ANP state: present - delegate_to: localhost - name: Migration of objects between templates of different schema mso_schema_template_migrate: @@ -101,7 +100,6 @@ EXAMPLES = r""" - epg: EPG1 anp: ANP state: present - delegate_to: localhost - name: Migration of BD object between templates of same schema mso_schema_template_migrate: @@ -116,7 +114,6 @@ EXAMPLES = r""" - BD - BD1 state: present - delegate_to: localhost - name: Migration of BD object between templates of different schema mso_schema_template_migrate: @@ -131,7 +128,6 @@ EXAMPLES = r""" - BD - BD1 state: present - delegate_to: localhost - name: Migration of EPG objects between templates of same schema mso_schema_template_migrate: @@ -148,7 +144,6 @@ EXAMPLES = r""" - epg: EPG2 anp: ANP2 state: present - delegate_to: localhost - name: Migration of EPG objects between templates of different schema mso_schema_template_migrate: @@ -165,7 +160,6 @@ EXAMPLES = r""" - epg: EPG2 anp: ANP2 state: present - delegate_to: localhost """ RETURN = r""" diff --git a/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_service_graph.py b/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_service_graph.py index 70fadd804..d304673dc 100644 --- a/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_service_graph.py +++ b/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_service_graph.py @@ -83,7 +83,6 @@ EXAMPLES = r""" - type: other - type: load-balancer state: present - delegate_to: localhost - name: Remove a Service Graph cisco.mso.mso_schema_template_service_graph: @@ -94,7 +93,6 @@ EXAMPLES = r""" template: Template1 service_graph: graph1 state: absent - delegate_to: localhost - name: Query a specific Service Graph cisco.mso.mso_schema_template_service_graph: @@ -105,7 +103,7 @@ EXAMPLES = r""" template: Template1 service_graph: graph1 state: query - delegate_to: localhost + register: query_result - name: Query all Service Graphs cisco.mso.mso_schema_template_service_graph: @@ -115,7 +113,7 @@ EXAMPLES = r""" schema: Schema1 template: Template1 state: query - delegate_to: localhost + register: query_result """ RETURN = r""" @@ -215,14 +213,15 @@ def main(): node_name = node.get("type") if node_name in service_node_types: service_node_index = service_node_index + 1 + service_node_name = "node{0}".format(service_node_index) for node_data in query_node_data: if node_data["name"] == node_name: payload = dict( - name=node_name, + name=service_node_name, serviceNodeTypeId=node_data.get("id"), index=service_node_index, serviceNodeRef=dict( - serviceNodeName=node_name, + serviceNodeName=service_node_name, serviceGraphName=service_graph, templateName=template, schemaId=schema_id, diff --git a/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_vrf.py b/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_vrf.py index efafd2387..84464c312 100644 --- a/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_vrf.py +++ b/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_vrf.py @@ -79,7 +79,6 @@ EXAMPLES = r""" template: Template 1 vrf: VRF 1 state: present - delegate_to: localhost - name: Remove an VRF cisco.mso.mso_schema_template_vrf: @@ -90,7 +89,6 @@ EXAMPLES = r""" template: Template 1 vrf: VRF1 state: absent - delegate_to: localhost - name: Query a specific VRFs cisco.mso.mso_schema_template_vrf: @@ -101,7 +99,6 @@ EXAMPLES = r""" template: Template 1 vrf: VRF1 state: query - delegate_to: localhost register: query_result - name: Query all VRFs @@ -112,7 +109,6 @@ EXAMPLES = r""" schema: Schema 1 template: Template 1 state: query - delegate_to: localhost register: query_result """ diff --git a/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_vrf_contract.py b/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_vrf_contract.py index eaef8235c..fbfb96352 100644 --- a/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_vrf_contract.py +++ b/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_vrf_contract.py @@ -84,7 +84,6 @@ EXAMPLES = r""" name: Contract 1 type: consumer state: present - delegate_to: localhost - name: Remove a Contract cisco.mso.mso_schema_template_vrf_contract: @@ -98,7 +97,6 @@ EXAMPLES = r""" name: Contract 1 type: consumer state: absent - delegate_to: localhost - name: Query a specific Contract cisco.mso.mso_schema_template_vrf_contract: @@ -112,7 +110,6 @@ EXAMPLES = r""" name: Contract 1 type: consumer state: query - delegate_to: localhost register: query_result - name: Query all Contracts @@ -124,7 +121,6 @@ EXAMPLES = r""" template: Template 1 vrf: VRF 1 state: query - delegate_to: localhost register: query_result """ diff --git a/ansible_collections/cisco/mso/plugins/modules/mso_schema_validate.py b/ansible_collections/cisco/mso/plugins/modules/mso_schema_validate.py index a4a4f6cd0..35b082618 100644 --- a/ansible_collections/cisco/mso/plugins/modules/mso_schema_validate.py +++ b/ansible_collections/cisco/mso/plugins/modules/mso_schema_validate.py @@ -35,11 +35,19 @@ options: default: query choices: [ query ] seealso: -- module: cisco.mso.mso_schema_template_external_epg +- module: cisco.mso.mso_schema extends_documentation_fragment: cisco.mso.modules """ EXAMPLES = r""" + - name: Get Validation status + mso_schema_validate: + host: mso_host + username: admin + password: SomeSecretPassword + schema: Schema 1 + state: query + register: query_validate """ RETURN = r""" diff --git a/ansible_collections/cisco/mso/plugins/modules/mso_service_node_type.py b/ansible_collections/cisco/mso/plugins/modules/mso_service_node_type.py index b8319256b..eace7bd26 100644 --- a/ansible_collections/cisco/mso/plugins/modules/mso_service_node_type.py +++ b/ansible_collections/cisco/mso/plugins/modules/mso_service_node_type.py @@ -46,7 +46,6 @@ EXAMPLES = r""" name: ips display_name: ips state: present - delegate_to: localhost - name: Remove a Service Node Type cisco.mso.mso_schema_service_node: @@ -55,7 +54,6 @@ EXAMPLES = r""" password: SomeSecretPassword name: ips state: absent - delegate_to: localhost - name: Query a specific Service Node Type cisco.mso.mso_schema_service_node: @@ -64,7 +62,7 @@ EXAMPLES = r""" password: SomeSecretPassword name: ips state: query - delegate_to: localhost + register: query_result - name: Query all Service Node Types cisco.mso.mso_schema_service_node: @@ -72,7 +70,7 @@ EXAMPLES = r""" username: admin password: SomeSecretPassword state: query - delegate_to: localhost + register: query_result """ RETURN = r""" diff --git a/ansible_collections/cisco/mso/plugins/modules/mso_site.py b/ansible_collections/cisco/mso/plugins/modules/mso_site.py index a3778d28a..d12f935bc 100644 --- a/ansible_collections/cisco/mso/plugins/modules/mso_site.py +++ b/ansible_collections/cisco/mso/plugins/modules/mso_site.py @@ -110,7 +110,6 @@ EXAMPLES = r""" latitude: 50.887318 longitude: 4.447084 state: present - delegate_to: localhost - name: Remove a site cisco.mso.mso_site: @@ -119,7 +118,6 @@ EXAMPLES = r""" password: SomeSecretPassword site: north_europe state: absent - delegate_to: localhost - name: Query a site cisco.mso.mso_site: @@ -128,7 +126,6 @@ EXAMPLES = r""" password: SomeSecretPassword site: north_europe state: query - delegate_to: localhost register: query_result - name: Query all sites @@ -137,7 +134,6 @@ EXAMPLES = r""" username: admin password: SomeSecretPassword state: query - delegate_to: localhost register: query_result """ diff --git a/ansible_collections/cisco/mso/plugins/modules/mso_tenant.py b/ansible_collections/cisco/mso/plugins/modules/mso_tenant.py index 17aa457e3..b1caf3cbe 100644 --- a/ansible_collections/cisco/mso/plugins/modules/mso_tenant.py +++ b/ansible_collections/cisco/mso/plugins/modules/mso_tenant.py @@ -3,6 +3,7 @@ # Copyright: (c) 2018, Dag Wieers (@dagwieers) <dag@wieers.com> # Copyright: (c) 2020, Cindy Zhao (@cizhao) <cizhao@cisco.com> +# Copyright: (c) 2023, Anvitha Jain (@anvjain) <anvjain@cisco.com> # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) from __future__ import absolute_import, division, print_function @@ -40,6 +41,22 @@ options: - Admin user is always added to the associated user list irrespective of this parameter being used. type: list elements: str + remote_users: + description: + - A list of associated remote users for this tenant. + type: list + elements: dict + suboptions: + name: + description: + - The name of the associated remote user for this tenant. + required: true + type: str + login_domain: + description: + - Domain name of the associated remote user for this tenant. + required: true + type: str sites: description: - A list of associated sites for this tenant. @@ -73,7 +90,6 @@ EXAMPLES = r""" display_name: North European Datacenter description: This tenant manages the NEDC environment. state: present - delegate_to: localhost - name: Remove a tenant from MSO and Site/APIC cisco.mso.mso_tenant: @@ -83,7 +99,6 @@ EXAMPLES = r""" tenant: north_europe orchestrator_only: no state: absent - delegate_to: localhost - name: Remove a tenant from MSO only cisco.mso.mso_tenant: @@ -93,7 +108,6 @@ EXAMPLES = r""" tenant: north_europe orchestrator_only: yes state: absent - delegate_to: localhost - name: Query a tenant cisco.mso.mso_tenant: @@ -102,7 +116,6 @@ EXAMPLES = r""" password: SomeSecretPassword tenant: north_europe state: query - delegate_to: localhost register: query_result - name: Query all tenants @@ -111,7 +124,6 @@ EXAMPLES = r""" username: admin password: SomeSecretPassword state: query - delegate_to: localhost register: query_result """ @@ -119,7 +131,7 @@ RETURN = r""" """ from ansible.module_utils.basic import AnsibleModule -from ansible_collections.cisco.mso.plugins.module_utils.mso import MSOModule, mso_argument_spec +from ansible_collections.cisco.mso.plugins.module_utils.mso import MSOModule, mso_argument_spec, ndo_remote_user_spec from ansible_collections.cisco.mso.plugins.module_utils.constants import YES_OR_NO_TO_BOOL_STRING_MAP @@ -130,6 +142,7 @@ def main(): display_name=dict(type="str"), tenant=dict(type="str", aliases=["name"]), users=dict(type="list", elements="str"), + remote_users=dict(type="list", elements="dict", options=ndo_remote_user_spec()), sites=dict(type="list", elements="str"), orchestrator_only=dict(type="str", default="yes", choices=["yes", "no"]), state=dict(type="str", default="present", choices=["absent", "present", "query"]), @@ -149,13 +162,10 @@ def main(): tenant = module.params.get("tenant") orchestrator_only = module.params.get("orchestrator_only") state = module.params.get("state") + remote_users = module.params.get("remote_users") mso = MSOModule(module) - # Convert sites and users - sites = mso.lookup_sites(module.params.get("sites")) - users = mso.lookup_users(module.params.get("users")) - tenant_id = None path = "tenants" @@ -182,6 +192,12 @@ def main(): mso.existing = mso.request(path, method="DELETE") elif state == "present": + # Convert sites and users + sites = mso.lookup_sites(module.params.get("sites")) + users = mso.lookup_users(module.params.get("users")) + if remote_users is not None: + users += mso.lookup_remote_users(remote_users) + mso.previous = mso.existing payload = dict( diff --git a/ansible_collections/cisco/mso/plugins/modules/mso_tenant_site.py b/ansible_collections/cisco/mso/plugins/modules/mso_tenant_site.py index 4b9c2af56..895403e12 100644 --- a/ansible_collections/cisco/mso/plugins/modules/mso_tenant_site.py +++ b/ansible_collections/cisco/mso/plugins/modules/mso_tenant_site.py @@ -114,7 +114,6 @@ EXAMPLES = r""" tenant: tenant_name site: site_name state: present - delegate_to: localhost - name: Associate AWS site with a tenant, with aws_trusted set to true cisco.mso.mso_tenant_site: @@ -126,7 +125,6 @@ EXAMPLES = r""" cloud_account: '000000000000' aws_trusted: true state: present - delegate_to: localhost - name: Associate AWS site with a tenant, with aws_trusted set to false cisco.mso.mso_tenant_site: @@ -141,7 +139,6 @@ EXAMPLES = r""" secret_key: '0' aws_account_org: false state: present - delegate_to: localhost - name: Associate Azure site in managed mode mso.cisco.mso_tenant_site: @@ -155,7 +152,6 @@ EXAMPLES = r""" azure_subscription_id: '9' azure_application_id: '100' state: present - delegate_to: localhost - name: Associate Azure site in unmanaged mode mso.cisco.mso_tenant_site: @@ -173,7 +169,6 @@ EXAMPLES = r""" azure_active_directory_id: '32' azure_active_directory_name: CiscoINSBUAd state: present - delegate_to: localhost - name: Dissociate a site cisco.mso.mso_tenant_site: @@ -183,7 +178,6 @@ EXAMPLES = r""" tenant: tenant_name site: site_name state: absent - delegate_to: localhost - name: Query a site cisco.mso.mso_tenant_site: @@ -193,7 +187,7 @@ EXAMPLES = r""" tenant: tenant_name site: site_name state: query - delegate_to: localhost + register: query_result - name: Query all sites of a tenant cisco.mso.mso_tenant_site: @@ -202,7 +196,6 @@ EXAMPLES = r""" password: SomeSecretPassword tenant: tenant_name state: query - delegate_to: localhost register: query_result """ diff --git a/ansible_collections/cisco/mso/plugins/modules/mso_user.py b/ansible_collections/cisco/mso/plugins/modules/mso_user.py index 37127a7f1..d74088206 100644 --- a/ansible_collections/cisco/mso/plugins/modules/mso_user.py +++ b/ansible_collections/cisco/mso/plugins/modules/mso_user.py @@ -87,7 +87,6 @@ EXAMPLES = r""" user: admin user_password: newPassword state: present - delegate_to: localhost - name: Add a new user cisco.mso.mso_user: @@ -107,7 +106,6 @@ EXAMPLES = r""" - name: schemaManager access_type: read state: present - delegate_to: localhost - name: Add a new user cisco.mso.mso_user: @@ -122,7 +120,6 @@ EXAMPLES = r""" phone: +32 478 436 299 roles: - powerUser - delegate_to: localhost - name: Remove a user cisco.mso.mso_user: @@ -132,7 +129,6 @@ EXAMPLES = r""" validate_certs: false user: dag state: absent - delegate_to: localhost - name: Query a user cisco.mso.mso_user: @@ -142,7 +138,6 @@ EXAMPLES = r""" validate_certs: false user: dag state: query - delegate_to: localhost register: query_result - name: Query all users @@ -152,7 +147,6 @@ EXAMPLES = r""" password: SomeSecretPassword validate_certs: false state: query - delegate_to: localhost register: query_result """ diff --git a/ansible_collections/cisco/mso/plugins/modules/mso_version.py b/ansible_collections/cisco/mso/plugins/modules/mso_version.py index 19668afb4..f2c0ce8a1 100644 --- a/ansible_collections/cisco/mso/plugins/modules/mso_version.py +++ b/ansible_collections/cisco/mso/plugins/modules/mso_version.py @@ -35,7 +35,6 @@ EXAMPLES = r""" username: admin password: SomeSecretPassword state: query - delegate_to: localhost register: query_result """ diff --git a/ansible_collections/cisco/mso/plugins/modules/ndo_schema_template_deploy.py b/ansible_collections/cisco/mso/plugins/modules/ndo_schema_template_deploy.py index b8bdb63ae..f1971280e 100644 --- a/ansible_collections/cisco/mso/plugins/modules/ndo_schema_template_deploy.py +++ b/ansible_collections/cisco/mso/plugins/modules/ndo_schema_template_deploy.py @@ -61,7 +61,6 @@ EXAMPLES = r""" schema: Schema 1 template: Template 1 state: deploy - delegate_to: localhost - name: Redeploy a schema template cisco.mso.ndo_schema_template_deploy: @@ -71,7 +70,6 @@ EXAMPLES = r""" schema: Schema 1 template: Template 1 state: redeploy - delegate_to: localhost - name: Undeploy a schema template cisco.mso.ndo_schema_template_deploy: @@ -82,7 +80,6 @@ EXAMPLES = r""" template: Template 1 sites: [ Site1, Site2 ] state: undeploy - delegate_to: localhost - name: Query a schema template deploy status cisco.mso.ndo_schema_template_deploy: @@ -92,7 +89,7 @@ EXAMPLES = r""" schema: Schema 1 template: Template 1 state: query - delegate_to: localhost + register: query_result """ RETURN = r""" diff --git a/ansible_collections/cisco/mso/tests/integration/inventory.networking b/ansible_collections/cisco/mso/tests/integration/inventory.networking index 590ee6685..b4a333570 100644 --- a/ansible_collections/cisco/mso/tests/integration/inventory.networking +++ b/ansible_collections/cisco/mso/tests/integration/inventory.networking @@ -6,8 +6,8 @@ lh-dmz1-pod1-mso-v311 ansible_host=173.36.219.11 ansible_connection=local mso_ho ndo [ndo] -lh-dmz1-pod1-ndo-v371 ansible_host=173.36.219.30 ansible_connection=ansible.netcommon.httpapi ansible_network_os=cisco.nd.nd mso_hostname=173.36.219.30 -lh-dmz1-pod1-ndo-v411 ansible_host=173.36.219.32 ansible_connection=ansible.netcommon.httpapi ansible_network_os=cisco.nd.nd mso_hostname=173.36.219.32 +lh-dmz1-pod1-ndo-v421 ansible_host=173.36.219.30 ansible_connection=ansible.netcommon.httpapi ansible_network_os=cisco.nd.nd mso_hostname=173.36.219.30 +lh-dmz1-pod1-ndo-v412 ansible_host=173.36.219.32 ansible_connection=ansible.netcommon.httpapi ansible_network_os=cisco.nd.nd mso_hostname=173.36.219.32 [all:vars] mso_username=ansible_github_ci diff --git a/ansible_collections/cisco/mso/tests/integration/targets/mso_backup/tasks/main.yml b/ansible_collections/cisco/mso/tests/integration/targets/mso_backup/tasks/main.yml index 9fe4d1a9a..c266ff1a6 100644 --- a/ansible_collections/cisco/mso/tests/integration/targets/mso_backup/tasks/main.yml +++ b/ansible_collections/cisco/mso/tests/integration/targets/mso_backup/tasks/main.yml @@ -5,13 +5,13 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI MultiSite host, username and password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: mso_hostname, mso_username and mso_password.' when: mso_hostname is not defined or mso_username is not defined or mso_password is not defined # CLEAN ENVIRONMENT - name: Set vars - set_fact: + ansible.builtin.set_fact: mso_info: &mso_info host: '{{ mso_hostname }}' username: '{{ mso_username }}' @@ -22,13 +22,13 @@ output_level: '{{ mso_output_level | default("info") }}' - name: Query MSO version - mso_version: + cisco.mso.mso_version: <<: *mso_info state: query register: version - name: Clear tenant - mso_tenant: &tenant1_absent + cisco.mso.mso_tenant: &tenant1_absent <<: *mso_info tenant: Tenant1 display_name: Test_Tenant @@ -53,13 +53,13 @@ state: present - name: Query all backups - mso_backup: &query_all_backups + cisco.mso.mso_backup: &query_all_backups <<: *mso_info state: query register: query_ansibleBackup_for_delete - name: Remove all backups - mso_backup: + cisco.mso.mso_backup: <<: *mso_info backup_id: '{{ item.id }}' state: absent @@ -70,7 +70,7 @@ when: version.current.version is version('3.2', '<') block: - name: Create local ansibleBackup1 in check mode - mso_backup: + cisco.mso.mso_backup: <<: *mso_info backup: ansibleBackup1 description: via Ansible @@ -80,12 +80,12 @@ check_mode: true - name: Verify local cm_add_ansibleBackup1 - assert: + ansible.builtin.assert: that: - cm_add_ansibleBackup1 is changed - name: Create local ansibleBackup1 in normal mode - mso_backup: + cisco.mso.mso_backup: <<: *mso_info backup: ansibleBackup1 description: via Ansible @@ -94,7 +94,7 @@ register: nm_add_ansibleBackup1 - name: Query ansibleBackup1 to check if it exists - mso_backup: + cisco.mso.mso_backup: <<: *mso_info backup: ansibleBackup1 state: query @@ -107,13 +107,13 @@ delay: 10 - name: Verify nm_add_ansibleBackup1 - assert: + ansible.builtin.assert: that: - nm_add_ansibleBackup1 is changed - check_ansibleBackup1.current[0].backupEntry.metadata.name is match("ansibleBackup1_[0-9a-zA-Z]*") - name: Create local ansibleBackup3 in normal mode - mso_backup: + cisco.mso.mso_backup: <<: *mso_info backup: ansibleBackup3 description: via Ansible @@ -122,7 +122,7 @@ register: nm_add_ansibleBackup3 - name: Query ansibleBackup3 to check if it exists - mso_backup: + cisco.mso.mso_backup: <<: *mso_info backup: ansibleBackup3 state: query @@ -136,7 +136,7 @@ delay: 10 - name: Assertions check for create local ansibleBackup3 in normal mode - assert: + ansible.builtin.assert: that: - query_ansibleBackup3 is not changed - query_ansibleBackup3.current.0.status.statusType == "success" @@ -145,7 +145,7 @@ # Creating duplicate backups with the name of ansibleBackup3 - to validate "Multiple backups with same name found" error message - name: Create local ansibleBackup3 in normal mode again - mso_backup: + cisco.mso.mso_backup: <<: *mso_info backup: ansibleBackup3 description: via Ansible @@ -154,7 +154,7 @@ register: nm_add_ansibleBackup3_again - name: Query duplicate ansibleBackup3 to check if it exists - mso_backup: + cisco.mso.mso_backup: <<: *mso_info backup: ansibleBackup3 state: query @@ -168,7 +168,7 @@ delay: 10 - name: Assertions check for create local ansibleBackup3 in normal mode again - assert: + ansible.builtin.assert: that: - query_ansibleBackup3_again is not changed - query_ansibleBackup3_again.current.1.status.statusType == "success" @@ -180,7 +180,7 @@ when: version.current.version is version('3.2', '<') block: - name: Move ansibleBackup1 from local to remote location in check mode - mso_backup: &move_ab1_cm + cisco.mso.mso_backup: &move_ab1_cm <<: *mso_info remote_location: ansible_test remote_path: "" @@ -191,12 +191,12 @@ register: move_ab1_cm - name: Move ansibleBackup1 from local to remote location in normal mode - mso_backup: + cisco.mso.mso_backup: <<: *move_ab1_cm register: move_ab1_nm - name: Move a non existent backup from local location to remote - mso_backup: + cisco.mso.mso_backup: <<: *mso_info backup: non_existent_backup remote_location: ansible_test @@ -206,7 +206,7 @@ ignore_errors: true - name: Move a ansibleBackup3 from local location to remote - check mode - mso_backup: + cisco.mso.mso_backup: <<: *mso_info backup: ansibleBackup3 remote_location: ansible_test @@ -216,7 +216,7 @@ ignore_errors: true - name: Move a ansibleBackup3 from local location to remote - normal mode - mso_backup: + cisco.mso.mso_backup: <<: *mso_info backup: ansibleBackup3 remote_location: ansible_test @@ -226,7 +226,7 @@ ignore_errors: true - name: Assertions check for move a backup from local location to remote location - assert: + ansible.builtin.assert: that: - move_ab1_cm is changed - move_ab1_nm is changed @@ -236,7 +236,7 @@ # Create Remote backup - For all version - name: Create ansibleBackupRemote1 in check mode - mso_backup: + cisco.mso.mso_backup: <<: *mso_info backup: ansibleBackupRemote1 description: Remote via Ansible @@ -248,7 +248,7 @@ register: cm_add_ansibleBackupRemote1 - name: Create ansibleBackupRemote1 in normal mode - mso_backup: + cisco.mso.mso_backup: <<: *mso_info backup: ansibleBackupRemote1 description: Remote via Ansible @@ -259,7 +259,7 @@ register: nm_add_ansibleBackupRemote1 - name: Query ansibleBackupRemote1 to check if it exists - mso_backup: + cisco.mso.mso_backup: <<: *mso_info backup: ansibleBackupRemote1 state: query @@ -272,7 +272,7 @@ delay: 10 - name: Assertions check for the backups present on the remote location - assert: + ansible.builtin.assert: that: - cm_add_ansibleBackupRemote1 is changed - nm_add_ansibleBackupRemote1 is changed @@ -280,13 +280,13 @@ # Remove additional backups - to handle "Multiple backups with same name" during the download - name: Query all backups to handle "Multiple backups with same name" during the download - mso_backup: + cisco.mso.mso_backup: <<: *mso_info state: query register: query_ansibleBackup_for_delete - name: Delete all backups except for one to handle "Multiple backups with same name" during the download - mso_backup: + cisco.mso.mso_backup: <<: *mso_info backup_id: '{{ item.id }}' state: absent @@ -301,7 +301,7 @@ mode: '0755' - name: Download non existent backup - mso_backup: + cisco.mso.mso_backup: <<: *mso_info backup: non_existent_backup destination: './{{mso_hostname}}' @@ -310,7 +310,7 @@ register: download_non_existent_backup - name: Download ansibleBackupRemote1 in check mode - mso_backup: &download_ab1_cm + cisco.mso.mso_backup: &download_ab1_cm <<: *mso_info backup: ansibleBackupRemote1 destination: './{{mso_hostname}}' @@ -319,12 +319,12 @@ register: download_ab1_cm - name: Download ansibleBackupRemote1 in normal mode - mso_backup: + cisco.mso.mso_backup: <<: *download_ab1_cm register: download_ab1_nm - name: Assertions check for download a backup form MSO/NDO - assert: + ansible.builtin.assert: that: - download_ab1_cm is changed - download_ab1_nm is changed @@ -332,7 +332,7 @@ # Find Backup - name: Find backup - find: + ansible.builtin.find: paths: './{{mso_hostname}}' patterns: "*.tar.gz" register: backup_match @@ -342,7 +342,7 @@ when: version.current.version is version('3.2', '<') block: - name: Upload a backup from local machine to local location in check mode - mso_backup: &upload_backup_to_local_cm + cisco.mso.mso_backup: &upload_backup_to_local_cm <<: *mso_info backup: "{{ backup_match.files[0].path }}" state: upload @@ -350,12 +350,12 @@ check_mode: true - name: Upload a backup from local machine to local location in normal mode - mso_backup: + cisco.mso.mso_backup: <<: *upload_backup_to_local_cm register: upload_backup_to_local_nm - name: Upload a non existent backup from local machine to local location - mso_backup: + cisco.mso.mso_backup: <<: *mso_info backup: non_existent_backup state: upload @@ -363,7 +363,7 @@ ignore_errors: true - name: Assertions check for the upload a backup form local machine to local location - assert: + ansible.builtin.assert: that: - upload_backup_to_local_cm is changed - upload_backup_to_local_nm is changed @@ -372,12 +372,12 @@ # Upload backup to remote location for all platforms # To Support NDO Backup upload - name: Check present working directory with Shell command - shell: + ansible.builtin.shell: "pwd" register: present_working_directory - name: Upload an existing backup from local machine to remote location - check mode - mso_backup: &upload_backup_cm + cisco.mso.mso_backup: &upload_backup_cm <<: *mso_info backup: "{{present_working_directory.stdout}}/{{ backup_match.files[0].path }}" location_type: remote @@ -388,7 +388,7 @@ register: upload_backup_cm - name: Upload an existing backup from local machine to remote location - normal mode - mso_backup: + cisco.mso.mso_backup: <<: *upload_backup_cm register: upload_backup_nm ignore_errors: true @@ -400,25 +400,25 @@ - upload_backup_nm.current == [] block: - name: Query all backups - clear existing backups before uploading - to handle "Backup already existing issue" - mso_backup: + cisco.mso.mso_backup: <<: *mso_info state: query register: query_ansibleBackup_for_delete - name: Delete all backups from MSO/NDO before uploading the backup form local machine - mso_backup: + cisco.mso.mso_backup: <<: *mso_info backup_id: '{{ item.id }}' state: absent loop: '{{ query_ansibleBackup_for_delete.current | list | sort(attribute="name", reverse=True) }}' - name: Upload an existing backup from local machine to remote location - normal mode - after removing existing backups - mso_backup: + cisco.mso.mso_backup: <<: *upload_backup_cm register: upload_backup_nm - name: Upload a non existent backup from local location - mso_backup: + cisco.mso.mso_backup: <<: *mso_info backup: non_existent_backup location_type: remote @@ -429,7 +429,7 @@ ignore_errors: true - name: Assertions check for the upload a backup form local machine to remote location - assert: + ansible.builtin.assert: that: - upload_non_existent_backup is not changed - "{{ 'Upload failed due to' in upload_non_existent_backup.msg }}" @@ -442,21 +442,21 @@ when: - version.current.version is version('2.2.4e', '!=') - version.current.version is version('3.2', '<') - set_fact: + ansible.builtin.set_fact: uploaded_backup_name: '{{ upload_backup_nm.current.backupEntry.metadata.name.split("_") | first }}' - name: Set Uploaded Backup Name for NDO when: - version.current.version is version('2.2.4e', '!=') - version.current.version is version('3.2', '>=') - set_fact: + ansible.builtin.set_fact: uploaded_backup_name: '{{ upload_backup_nm.current.body.backupEntry.metadata.name.split("_") | first }}' - name: Restore backup check when: version.current.version is version('2.2.4e', '!=') block: - name: Restore non existent backup - mso_backup: + cisco.mso.mso_backup: <<: *mso_info backup: non_existent_backup state: restore @@ -465,13 +465,13 @@ register: restore_non_existent_backup - name: Add a new tenant - mso_tenant: + cisco.mso.mso_tenant: <<: *tenant1_absent state: present register: tenant1_present - name: Restore {{ uploaded_backup_name }} in check mode - mso_backup: &restore_backup_cm + cisco.mso.mso_backup: &restore_backup_cm <<: *mso_info backup: '{{ uploaded_backup_name }}' state: restore @@ -480,23 +480,23 @@ register: restore_backup_cm - name: Restore {{ uploaded_backup_name }} in normal mode - mso_backup: + cisco.mso.mso_backup: <<: *restore_backup_cm register: restore_backup_nm - name: Query Tenant1 after restoring the backup - mso_tenant: + cisco.mso.mso_tenant: <<: *tenant1_absent state: query register: query_tenant1 - name: Restore {{ uploaded_backup_name }} in normal mode - idempotency check - mso_backup: + cisco.mso.mso_backup: <<: *restore_backup_cm register: idm_restore_backup_nm - name: Assertions check for the backup restore - assert: + ansible.builtin.assert: that: - restore_non_existent_backup.msg is match ("Backup 'non_existent_backup' does not exist") - restore_backup_cm is changed @@ -509,25 +509,25 @@ # Cleaning part # Remove all other backups - name: Query all backups before deleting - mso_backup: + cisco.mso.mso_backup: <<: *query_all_backups state: query register: query_all_backups_bf_delete - name: Ensure backups does not exists - mso_backup: + cisco.mso.mso_backup: <<: *mso_info backup_id: '{{ item.id }}' state: absent loop: '{{ query_all_backups_bf_delete.current | list | sort(attribute="name", reverse=True) }}' - name: Query all backups after deleting - to ensure all are absent - mso_backup: + cisco.mso.mso_backup: <<: *query_all_backups register: query_all_backups_af_delete - name: Assertions check for the query and remove all backups - assert: + ansible.builtin.assert: that: - query_all_backups_bf_delete is not changed - query_all_backups_af_delete is not changed @@ -541,6 +541,6 @@ # Remove Tenant1 - name: Ensure Tenant1 is absent - mso_tenant: + cisco.mso.mso_tenant: <<: *tenant1_absent state: absent diff --git a/ansible_collections/cisco/mso/tests/integration/targets/mso_backup_schedule/tasks/main.yml b/ansible_collections/cisco/mso/tests/integration/targets/mso_backup_schedule/tasks/main.yml index 1a50284f8..02f6885aa 100644 --- a/ansible_collections/cisco/mso/tests/integration/targets/mso_backup_schedule/tasks/main.yml +++ b/ansible_collections/cisco/mso/tests/integration/targets/mso_backup_schedule/tasks/main.yml @@ -4,14 +4,14 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI MultiSite host, username and password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: mso_hostname, mso_username and mso_password.' when: mso_hostname is not defined or mso_username is not defined or mso_password is not defined # CLEAN ENVIRONMENT - name: Set vars - set_fact: + ansible.builtin.set_fact: mso_info: &mso_info host: '{{ mso_hostname }}' username: '{{ mso_username }}' @@ -25,7 +25,6 @@ cisco.mso.mso_backup_schedule: <<: *mso_info state: absent - delegate_to: localhost - name: Ensure remote location is present cisco.mso.mso_remote_location: @@ -45,11 +44,10 @@ cisco.mso.mso_backup_schedule: <<: *mso_info state: query - delegate_to: localhost register: no_schedule - name: Verify empty backup schedule - assert: + ansible.builtin.assert: that: - no_schedule is not changed - no_schedule.current == {} @@ -62,7 +60,6 @@ remote_location: ansible_test state: present check_mode: true - delegate_to: localhost register: cm_schedule_create - name: Set backup schedule (normal mode) @@ -72,12 +69,11 @@ frequency_length: 7 remote_location: ansible_test state: present - delegate_to: localhost register: nm_schedule_create # add date tests - name: Verify success set backup schedule - assert: + ansible.builtin.assert: that: - cm_schedule_create is changed - cm_schedule_create.current.intervalLength == 7 @@ -97,7 +93,6 @@ remote_location: ansible_test state: present check_mode: true - delegate_to: localhost register: cm_schedule_adjust - name: Adjust backup schedule (normal mode) @@ -107,11 +102,10 @@ frequency_length: 1 remote_location: ansible_test state: present - delegate_to: localhost register: nm_schedule_adjust - name: Verify success set backup schedule - assert: + ansible.builtin.assert: that: - cm_schedule_adjust is changed - cm_schedule_adjust.current.intervalLength == 1 @@ -126,11 +120,10 @@ cisco.mso.mso_backup_schedule: <<: *mso_info state: query - delegate_to: localhost register: schedule - name: Verify success get backup schedule - assert: + ansible.builtin.assert: that: - schedule is not changed - nm_schedule_adjust.current.timeInterval.length == 1 @@ -142,23 +135,20 @@ <<: *mso_info state: absent check_mode: true - delegate_to: localhost - name: Delete backup schedule (normal mode) cisco.mso.mso_backup_schedule: <<: *mso_info state: absent - delegate_to: localhost - name: Get empty backup schedule cisco.mso.mso_backup_schedule: <<: *mso_info state: query - delegate_to: localhost register: no_schedule - name: Verify empty backup schedule - assert: + ansible.builtin.assert: that: - no_schedule is not changed - no_schedule.current == {} @@ -171,7 +161,6 @@ frequency_length: 7 remote_location: ansible_test state: present - delegate_to: localhost register: nm_schedule_incorrect_time ignore_errors: true @@ -183,7 +172,6 @@ frequency_length: 7 remote_location: ansible_test state: present - delegate_to: localhost register: nm_schedule_incorrect_date ignore_errors: true @@ -195,7 +183,6 @@ frequency_length: 7 remote_location: ansible_test state: present - delegate_to: localhost register: nm_schedule_incorrect_date_from_start_date ignore_errors: true @@ -207,12 +194,11 @@ frequency_length: 7 remote_location: ansible_test state: present - delegate_to: localhost register: nm_schedule_incorrect_time_from_start_time ignore_errors: true - name: Verify error messages - assert: + ansible.builtin.assert: that: - nm_schedule_incorrect_time is failed - nm_schedule_incorrect_time.msg.startswith("Failed to parse time format") @@ -233,11 +219,10 @@ remote_location: ansible_test remote_path: remote_add state: present - delegate_to: localhost register: nm_schedule_full - name: Verify success set backup schedule - assert: + ansible.builtin.assert: that: - nm_schedule_full is changed - nm_schedule_full.current.timeInterval.length == 1 @@ -250,17 +235,15 @@ cisco.mso.mso_backup_schedule: <<: *mso_info state: absent - delegate_to: localhost - name: Get empty backup schedule cisco.mso.mso_backup_schedule: <<: *mso_info state: query - delegate_to: localhost register: no_schedule - name: Verify empty backup schedule - assert: + ansible.builtin.assert: that: - no_schedule is not changed - - no_schedule.current == {}
\ No newline at end of file + - no_schedule.current == {} diff --git a/ansible_collections/cisco/mso/tests/integration/targets/mso_dhcp_option_policy/tasks/main.yaml b/ansible_collections/cisco/mso/tests/integration/targets/mso_dhcp_option_policy/tasks/main.yaml index b24749eb6..5d8225553 100644 --- a/ansible_collections/cisco/mso/tests/integration/targets/mso_dhcp_option_policy/tasks/main.yaml +++ b/ansible_collections/cisco/mso/tests/integration/targets/mso_dhcp_option_policy/tasks/main.yaml @@ -5,13 +5,13 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI MultiSite host, username and password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: mso_hostname, mso_username and mso_password.' when: mso_hostname is not defined or mso_username is not defined or mso_password is not defined #CLEAN ENVIRONMENT - name: Set vars - set_fact: + ansible.builtin.set_fact: mso_info: &mso_info host: '{{ mso_hostname }}' username: '{{ mso_username }}' @@ -22,7 +22,7 @@ output_level: '{{ mso_output_level | default("info") }}' - name: Query MSO version - mso_version: + cisco.mso.mso_version: <<: *mso_info state: query register: version @@ -31,7 +31,7 @@ when: version.current.version is version('4.0', '<') block: - name: Ensure tenant ansible_test exist - mso_tenant: + cisco.mso.mso_tenant: <<: *mso_info tenant: ansible_test users: @@ -40,7 +40,7 @@ register: ansible_tenant - name: Stop consuming DHCP Policy CLIENT_BD - mso_schema_template_bd: + cisco.mso.mso_schema_template_bd: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -51,7 +51,7 @@ ignore_errors: true - name: Stop consuming DHCP Policy ansible_test_2 - mso_schema_template_bd: + cisco.mso.mso_schema_template_bd: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 2 @@ -60,7 +60,7 @@ ignore_errors: true - name: Stop consuming DHCP Policy ansible_test_multiple_dhcp - mso_schema_template_bd: + cisco.mso.mso_schema_template_bd: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -69,7 +69,7 @@ ignore_errors: true - name: Stop consuming DHCP Policy ansible_test_5 - mso_schema_template_bd: + cisco.mso.mso_schema_template_bd: <<: *mso_info schema: '{{ mso_schema | default("ansible_test_2") }}' template: Template 5 @@ -78,7 +78,7 @@ ignore_errors: true - name: Remove DHCP Option Policies - mso_dhcp_option_policy: + cisco.mso.mso_dhcp_option_policy: <<: *mso_info dhcp_option_policy: '{{ item }}' state: absent @@ -91,7 +91,7 @@ # ADD DHCP Policy - name: Add a new DHCP Option Policy 1 (check mode) - mso_dhcp_option_policy: &create_dhcp + cisco.mso.mso_dhcp_option_policy: &create_dhcp <<: *mso_info dhcp_option_policy: ansible_dhcp_option_1 description: "My Test DHCP Policy 1" @@ -101,12 +101,12 @@ register: dhcp_pol1_cm - name: Add a new DHCP Option Policy 1 (normal mode) - mso_dhcp_option_policy: + cisco.mso.mso_dhcp_option_policy: <<: *create_dhcp register: dhcp_pol1_nm - name: Verify dhcp_pol1_cm and dhcp_pol1_nm - assert: + ansible.builtin.assert: that: - dhcp_pol1_cm is changed - dhcp_pol1_nm is changed @@ -117,18 +117,18 @@ - dhcp_pol1_cm.current.tenantId == dhcp_pol1_nm.current.tenantId == ansible_tenant.current.id - name: Add a new DHCP Option Policy 1 again (check mode) - mso_dhcp_option_policy: + cisco.mso.mso_dhcp_option_policy: <<: *create_dhcp check_mode: true register: dhcp_pol1_again_cm - name: Add a new DHCP Option Policy 1 again (normal mode) - mso_dhcp_option_policy: + cisco.mso.mso_dhcp_option_policy: <<: *create_dhcp register: dhcp_pol1_again_nm - name: Verify dhcp_pol1_again_cm and dhcp_pol1_again_nm - assert: + ansible.builtin.assert: that: - dhcp_pol1_again_cm is not changed - dhcp_pol1_again_nm is not changed @@ -139,25 +139,25 @@ - dhcp_pol1_again_cm.current.tenantId == dhcp_pol1_again_nm.current.tenantId == ansible_tenant.current.id - name: Add a new DHCP Option Policy 2 (normal mode) - mso_dhcp_option_policy: + cisco.mso.mso_dhcp_option_policy: <<: *create_dhcp dhcp_option_policy: ansible_dhcp_option_2 - name: Change DHCP Option Policy 1 description (check mode) - mso_dhcp_option_policy: + cisco.mso.mso_dhcp_option_policy: <<: *create_dhcp description: "My Changed Test DHCP Policy 1" check_mode: true register: change_dhcp_pol1_cm - name: Change DHCP Option Policy 1 description (normal mode) - mso_dhcp_option_policy: + cisco.mso.mso_dhcp_option_policy: <<: *create_dhcp description: "My Changed Test DHCP Policy 1" register: change_dhcp_pol1_nm - name: Verify change_dhcp_pol1_cm and change_dhcp_pol1_nm - assert: + ansible.builtin.assert: that: - change_dhcp_pol1_cm is changed - change_dhcp_pol1_nm is changed @@ -169,7 +169,7 @@ # QUERY A DHCP OPTION POLICY - name: Query DHCP Option Policy 1 (check mode) - mso_dhcp_option_policy: &query_dhcp + cisco.mso.mso_dhcp_option_policy: &query_dhcp <<: *mso_info dhcp_option_policy: ansible_dhcp_option_1 state: query @@ -177,12 +177,12 @@ register: dhcp_pol1_query_cm - name: Query DHCP Option Policy 1 (normal mode) - mso_dhcp_option_policy: + cisco.mso.mso_dhcp_option_policy: <<: *query_dhcp register: dhcp_pol1_query_nm - name: Verify dhcp_pol1_query - assert: + ansible.builtin.assert: that: - dhcp_pol1_query_cm is not changed - dhcp_pol1_query_nm is not changed @@ -193,33 +193,33 @@ # QUERY A NON-EXISTING DHCP OPTION POLICY - name: Query non-existing DHCP Option Policy (normal mode) - mso_dhcp_option_policy: + cisco.mso.mso_dhcp_option_policy: <<: *mso_info dhcp_option_policy: non_existing state: query register: quey_non_dhcp_pol - name: Verify quey_non_dhcp_pol - assert: + ansible.builtin.assert: that: - quey_non_dhcp_pol is not changed # QUERY ALL DHCP OPTION POLICIES - name: Query all DHCP Option Policies (normal mode) - mso_dhcp_option_policy: + cisco.mso.mso_dhcp_option_policy: <<: *mso_info state: query register: dhcp_policies_query - name: Verify dhcp_policies_query - assert: + ansible.builtin.assert: that: - dhcp_policies_query is not changed - dhcp_policies_query.current | length == 2 # REMOVE DHCP POLICY - name: Remove DHCP Option Policy 1 (check mode) - mso_dhcp_option_policy: &remove_dhcp + cisco.mso.mso_dhcp_option_policy: &remove_dhcp <<: *mso_info dhcp_option_policy: ansible_dhcp_option_1 state: absent @@ -227,12 +227,12 @@ register: dhcp_pol1_removed_cm - name: Remove DHCP Option Policy 1 (normal mode) - mso_dhcp_option_policy: + cisco.mso.mso_dhcp_option_policy: <<: *remove_dhcp register: dhcp_pol1_removed_nm - name: Verify dhcp_policies_removed - assert: + ansible.builtin.assert: that: - dhcp_pol1_removed_cm is changed - dhcp_pol1_removed_nm is changed @@ -240,18 +240,18 @@ # REMOVE DHCP POLICY AGAIN - name: Remove DHCP Option Policy 1 again (check mode) - mso_dhcp_option_policy: + cisco.mso.mso_dhcp_option_policy: <<: *remove_dhcp check_mode: true register: dhcp_pol1_removed_again_cm - name: Remove DHCP Option Policy 1 again (normal mode) - mso_dhcp_option_policy: + cisco.mso.mso_dhcp_option_policy: <<: *remove_dhcp register: dhcp_pol1_removed_again_nm - name: Verify dhcp_pol1_removed_again - assert: + ansible.builtin.assert: that: - dhcp_pol1_removed_again_cm is not changed - dhcp_pol1_removed_again_nm is not changed @@ -261,7 +261,7 @@ # USE A NON-EXISTING TENANT - name: Non Existing Tenant for DHCP Option Policy 3 (normal mode) - mso_dhcp_option_policy: + cisco.mso.mso_dhcp_option_policy: <<: *mso_info dhcp_option_policy: ansible_dhcp_option_3 description: "My Test DHCP Policy 3" @@ -271,14 +271,14 @@ register: nm_non_existing_tenant - name: Verify nm_non_existing_tenant - assert: + ansible.builtin.assert: that: - nm_non_existing_tenant is not changed - nm_non_existing_tenant.msg == "Tenant 'non_existing' is not valid tenant name." # CLEAN UP - name: Stop consuming DHCP Policy - mso_schema_template_bd: + cisco.mso.mso_schema_template_bd: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -289,7 +289,7 @@ ignore_errors: true - name: Remove DHCP Option Policies - mso_dhcp_option_policy: + cisco.mso.mso_dhcp_option_policy: <<: *mso_info dhcp_option_policy: '{{ item }}' state: absent diff --git a/ansible_collections/cisco/mso/tests/integration/targets/mso_dhcp_option_policy_option/tasks/main.yaml b/ansible_collections/cisco/mso/tests/integration/targets/mso_dhcp_option_policy_option/tasks/main.yaml index f6a79204f..b7c5cd66f 100644 --- a/ansible_collections/cisco/mso/tests/integration/targets/mso_dhcp_option_policy_option/tasks/main.yaml +++ b/ansible_collections/cisco/mso/tests/integration/targets/mso_dhcp_option_policy_option/tasks/main.yaml @@ -5,13 +5,13 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI MultiSite host, username and password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: mso_hostname, mso_username and mso_password.' when: mso_hostname is not defined or mso_username is not defined or mso_password is not defined #CLEAN ENVIRONMENT - name: Set vars - set_fact: + ansible.builtin.set_fact: mso_info: &mso_info host: '{{ mso_hostname }}' username: '{{ mso_username }}' @@ -22,7 +22,7 @@ output_level: '{{ mso_output_level | default("info") }}' - name: Query MSO version - mso_version: + cisco.mso.mso_version: <<: *mso_info state: query register: version @@ -31,7 +31,7 @@ when: version.current.version is version('4.0', '<') block: - name: Remove options from DHCP Option Policy - mso_dhcp_option_policy_option: + cisco.mso.mso_dhcp_option_policy_option: <<: *mso_info dhcp_option_policy: ansible_dhcp_option_1 name: "{{ item }}" @@ -42,7 +42,7 @@ ignore_errors: true - name: Stop consuming DHCP Policy - mso_schema_template_bd: + cisco.mso.mso_schema_template_bd: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -53,7 +53,7 @@ ignore_errors: true - name: Remove DHCP Relay Policy 1 - mso_dhcp_relay_policy: + cisco.mso.mso_dhcp_relay_policy: <<: *mso_info dhcp_relay_policy: '{{ item }}' state: absent @@ -62,7 +62,7 @@ - ansible_dhcp_relay_2 - name: Remove DHCP Option Policies - mso_dhcp_option_policy: + cisco.mso.mso_dhcp_option_policy: <<: *mso_info dhcp_option_policy: '{{ item }}' state: absent @@ -72,7 +72,7 @@ - ansible_dhcp_option_2 - name: Undeploy sites in schema 1 template 1 - mso_schema_template_deploy: + cisco.mso.mso_schema_template_deploy: <<: *mso_info template: Template 1 schema: '{{ mso_schema | default("ansible_test") }}' @@ -86,7 +86,7 @@ - 'azure_{{ mso_site | default("ansible_test") }}' - name: Undeploy sites in schema 1 template 2 - mso_schema_template_deploy: + cisco.mso.mso_schema_template_deploy: <<: *mso_info template: Template 2 schema: '{{ mso_schema | default("ansible_test") }}' @@ -100,7 +100,7 @@ - 'azure_{{ mso_site | default("ansible_test") }}' - name: Remove schemas - mso_schema: + cisco.mso.mso_schema: <<: *mso_info schema: '{{ item }}' state: absent @@ -109,7 +109,7 @@ - '{{ mso_schema | default("ansible_test") }}' - name: Ensure tenant ansible_test exist - mso_tenant: + cisco.mso.mso_tenant: <<: *mso_info tenant: ansible_test users: @@ -118,7 +118,7 @@ register: tenant_ansible - name: Ensure schema 1 with Template 1 exist - mso_schema_template: + cisco.mso.mso_schema_template: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' tenant: ansible_test @@ -126,7 +126,7 @@ state: present - name: Add a new VRF - mso_schema_template_vrf: + cisco.mso.mso_schema_template_vrf: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -134,7 +134,7 @@ state: present - name: Add BD - mso_schema_template_bd: + cisco.mso.mso_schema_template_bd: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -145,7 +145,7 @@ # ADD DHCP RELAY AND OPTION POLICY - name: Add a new DHCP Option Policy 1 (Normal mode) - mso_dhcp_option_policy: + cisco.mso.mso_dhcp_option_policy: <<: *mso_info dhcp_option_policy: ansible_dhcp_option_1 description: "My Test DHCP Policy 1" @@ -153,7 +153,7 @@ state: present - name: Add a new DHCP Relay Policy 1 (Normal mode) - mso_dhcp_relay_policy: + cisco.mso.mso_dhcp_relay_policy: <<: *mso_info dhcp_relay_policy: ansible_dhcp_relay_1 description: "My Test DHCP Policy 1" @@ -162,7 +162,7 @@ # ADD OPTION TO DHCP OPTION POLICY - name: Add Option to DHCP Option Policy (check mode) - mso_dhcp_option_policy_option: &create_option + cisco.mso.mso_dhcp_option_policy_option: &create_option <<: *mso_info dhcp_option_policy: ansible_dhcp_option_1 name: ansibletest @@ -173,12 +173,12 @@ register: dhcp_pol1_opt1_cm - name: Add Option to DHCP Option Policy (normal mode) - mso_dhcp_option_policy_option: + cisco.mso.mso_dhcp_option_policy_option: <<: *create_option register: dhcp_pol1_opt1_nm - name: Verify dhcp_pol1_opt1 - assert: + ansible.builtin.assert: that: - dhcp_pol1_opt1_cm is changed - dhcp_pol1_opt1_nm is changed @@ -187,18 +187,18 @@ - dhcp_pol1_opt1_cm.current.data == dhcp_pol1_opt1_nm.current.data == 'DHCP Data' - name: Add Option to DHCP Option Policy again (check mode) - mso_dhcp_option_policy_option: + cisco.mso.mso_dhcp_option_policy_option: <<: *create_option check_mode: true register: dhcp_pol1_opt1_again_cm - name: Add Option to DHCP Option Policy again (normal mode) - mso_dhcp_option_policy_option: + cisco.mso.mso_dhcp_option_policy_option: <<: *create_option register: dhcp_pol1_opt1_again_nm - name: Verify dhcp_pol1_opt1_again - assert: + ansible.builtin.assert: that: - dhcp_pol1_opt1_again_cm is not changed - dhcp_pol1_opt1_again_nm is not changed @@ -207,20 +207,20 @@ - dhcp_pol1_opt1_again_cm.current.data == dhcp_pol1_opt1_again_nm.current.data == 'DHCP Data' - name: Change Option IP to DHCP Option Policy (check mode) - mso_dhcp_option_policy_option: + cisco.mso.mso_dhcp_option_policy_option: <<: *create_option data: Changed DHCP Data check_mode: true register: dhcp_pol1_opt1_change_cm - name: Change Option IP to DHCP Option Policy (normal mode) - mso_dhcp_option_policy_option: + cisco.mso.mso_dhcp_option_policy_option: <<: *create_option data: Changed DHCP Data register: dhcp_pol1_opt1_change_nm - name: Verify dhcp_pol1_opt1_change - assert: + ansible.builtin.assert: that: - dhcp_pol1_opt1_change_cm is changed - dhcp_pol1_opt1_change_nm is changed @@ -229,20 +229,20 @@ - dhcp_pol1_opt1_change_cm.current.data == dhcp_pol1_opt1_change_nm.current.data == 'Changed DHCP Data' - name: Add 2nd Option to DHCP Option Policy (check mode) - mso_dhcp_option_policy_option: + cisco.mso.mso_dhcp_option_policy_option: <<: *create_option name: ansibletest2 check_mode: true register: dhcp_pol1_opt2_cm - name: Add 2nd Option to DHCP Option Policy (normal mode) - mso_dhcp_option_policy_option: + cisco.mso.mso_dhcp_option_policy_option: <<: *create_option name: ansibletest2 register: dhcp_pol1_opt2_nm - name: Verify dhcp_pol1_opt2 - assert: + ansible.builtin.assert: that: - dhcp_pol1_opt2_cm is changed - dhcp_pol1_opt2_nm is changed @@ -252,7 +252,7 @@ # QUERY OPTION FROM DHCP OPTION POLICY - name: Query Option from DHCP Option Policy (check mode) - mso_dhcp_option_policy_option: &query_option + cisco.mso.mso_dhcp_option_policy_option: &query_option <<: *mso_info dhcp_option_policy: ansible_dhcp_option_1 name: ansibletest @@ -260,26 +260,26 @@ register: dhcp_pol1_opt1_query_cm - name: Query Option from DHCP Option Policy (normal mode) - mso_dhcp_option_policy_option: + cisco.mso.mso_dhcp_option_policy_option: <<: *query_option register: dhcp_pol1_opt1_query_nm - name: Query nonexisting Option from DHCP Option Policy - mso_dhcp_option_policy_option: + cisco.mso.mso_dhcp_option_policy_option: <<: *query_option name: nonexisting state: query register: dhcp_pol1_opt1_query_non_existing - name: Query all Options from a DHCP Option Policy - mso_dhcp_option_policy_option: + cisco.mso.mso_dhcp_option_policy_option: <<: *mso_info dhcp_option_policy: ansible_dhcp_option_1 state: query register: dhcp_pol1_query_all - name: Verify all query variables - assert: + ansible.builtin.assert: that: - dhcp_pol1_opt1_query_cm is not changed - dhcp_pol1_opt1_query_nm is not changed @@ -293,7 +293,7 @@ # REMOVE OPTION FROM DHCP OPTION POLICY - name: Remove Option from DHCP Option Policy (check mode) - mso_dhcp_option_policy_option: &delete_option + cisco.mso.mso_dhcp_option_policy_option: &delete_option <<: *mso_info dhcp_option_policy: ansible_dhcp_option_1 name: ansibletest @@ -302,64 +302,64 @@ register: dhcp_pol1_opt1_del_cm - name: Remove Option from DHCP Option Policy (normal mode) - mso_dhcp_option_policy_option: + cisco.mso.mso_dhcp_option_policy_option: <<: *delete_option register: dhcp_pol1_opt1_del_nm - name: Verify dhcp_pol1_opt1_del - assert: + ansible.builtin.assert: that: - dhcp_pol1_opt1_del_cm is changed - dhcp_pol1_opt1_del_nm is changed - dhcp_pol1_opt1_del_cm.current == dhcp_pol1_opt1_del_nm.current == {} - name: Remove Option from DHCP Option Policy again (check mode) - mso_dhcp_option_policy_option: + cisco.mso.mso_dhcp_option_policy_option: <<: *delete_option check_mode: true register: dhcp_pol1_opt1_del_again_cm - name: Remove Option from DHCP Option Policy again (normal mode) - mso_dhcp_option_policy_option: + cisco.mso.mso_dhcp_option_policy_option: <<: *delete_option register: dhcp_pol1_opt1_del_again_nm - name: Verify dhcp_pol1_opt1_again_del - assert: + ansible.builtin.assert: that: - dhcp_pol1_opt1_del_again_cm is not changed - dhcp_pol1_opt1_del_again_nm is not changed - dhcp_pol1_opt1_del_again_cm.current == dhcp_pol1_opt1_del_again_nm.current == {} - name: Remove Non-Existing Option - mso_dhcp_option_policy_option: + cisco.mso.mso_dhcp_option_policy_option: <<: *delete_option name: nonexisting register: dhcp_pol1_opt1_del_nm_non_existing - name: Verify dhcp_pol1_opt1_del_nm_non_existing - assert: + ansible.builtin.assert: that: - dhcp_pol1_opt1_del_nm_non_existing is not changed - dhcp_pol1_opt1_del_nm_non_existing.current == {} # CONSUME DHCP POLICIES - name: Get DHCP Relay Policy version - mso_dhcp_relay_policy: + cisco.mso.mso_dhcp_relay_policy: <<: *mso_info dhcp_relay_policy: ansible_dhcp_relay_1 state: query register: dhcp_relay_policy_version - name: Get DHCP Option Policy version - mso_dhcp_option_policy: + cisco.mso.mso_dhcp_option_policy: <<: *mso_info dhcp_option_policy: ansible_dhcp_option_1 state: query register: dhcp_option_policy_version - name: Consume DHCP Policy - mso_schema_template_bd: + cisco.mso.mso_schema_template_bd: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -376,7 +376,7 @@ register: bd_dhcp_policy - name: Stop consuming DHCP Policy - mso_schema_template_bd: + cisco.mso.mso_schema_template_bd: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -388,7 +388,7 @@ # QUERY OPTION FROM non_existing DHCP OPTION POLICY - name: Query Option from DHCP Option Policy (check mode) - mso_dhcp_option_policy_option: + cisco.mso.mso_dhcp_option_policy_option: <<: *mso_info dhcp_option_policy: nonexisting state: query @@ -396,14 +396,14 @@ register: dhcp_non_existing - name: Verify dhcp_non_existing - assert: + ansible.builtin.assert: that: - dhcp_non_existing is not changed - dhcp_non_existing.msg == "DHCP Option Policy 'nonexisting' is not a valid DHCP Option Policy name." # CLEAN UP - name: Remove options from DHCP Option Policy - mso_dhcp_option_policy_option: + cisco.mso.mso_dhcp_option_policy_option: <<: *mso_info dhcp_option_policy: ansible_dhcp_option_1 name: "{{ item }}" @@ -414,7 +414,7 @@ ignore_errors: true - name: Stop consuming DHCP Policy - mso_schema_template_bd: + cisco.mso.mso_schema_template_bd: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -425,7 +425,7 @@ ignore_errors: true - name: Remove DHCP Relay Policy 1 - mso_dhcp_relay_policy: + cisco.mso.mso_dhcp_relay_policy: <<: *mso_info dhcp_relay_policy: '{{ item }}' state: absent @@ -434,7 +434,7 @@ - ansible_dhcp_relay_2 - name: Remove DHCP Option Policies - mso_dhcp_option_policy: + cisco.mso.mso_dhcp_option_policy: <<: *mso_info dhcp_option_policy: '{{ item }}' state: absent diff --git a/ansible_collections/cisco/mso/tests/integration/targets/mso_dhcp_relay_policy/tasks/main.yaml b/ansible_collections/cisco/mso/tests/integration/targets/mso_dhcp_relay_policy/tasks/main.yaml index 4a7db2dca..a500c12f9 100644 --- a/ansible_collections/cisco/mso/tests/integration/targets/mso_dhcp_relay_policy/tasks/main.yaml +++ b/ansible_collections/cisco/mso/tests/integration/targets/mso_dhcp_relay_policy/tasks/main.yaml @@ -4,13 +4,13 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI MultiSite host, username and password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: mso_hostname, mso_username and mso_password.' when: mso_hostname is not defined or mso_username is not defined or mso_password is not defined #CLEAN ENVIRONMENT - name: Set vars - set_fact: + ansible.builtin.set_fact: mso_info: &mso_info host: '{{ mso_hostname }}' username: '{{ mso_username }}' @@ -21,7 +21,7 @@ output_level: '{{ mso_output_level | default("info") }}' - name: Query MSO version - mso_version: + cisco.mso.mso_version: <<: *mso_info state: query register: version @@ -30,7 +30,7 @@ when: version.current.version is version('4.0', '<') block: - name: Ensure tenant ansible_test exist - mso_tenant: + cisco.mso.mso_tenant: <<: *mso_info tenant: ansible_test users: @@ -39,7 +39,7 @@ register: ansible_tenant - name: Stop consuming DHCP Policy - mso_schema_template_bd: + cisco.mso.mso_schema_template_bd: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -50,7 +50,7 @@ ignore_errors: true - name: Remove DHCP Relay Policy 1 - mso_dhcp_relay_policy: + cisco.mso.mso_dhcp_relay_policy: <<: *mso_info dhcp_relay_policy: '{{ item }}' state: absent @@ -63,7 +63,7 @@ # ADD DHCP Policy - name: Add a new DHCP Relay Policy 1 (check mode) - mso_dhcp_relay_policy: &create_dhcp + cisco.mso.mso_dhcp_relay_policy: &create_dhcp <<: *mso_info dhcp_relay_policy: ansible_dhcp_relay_1 description: "My Test DHCP Policy 1" @@ -73,12 +73,12 @@ register: dhcp_pol1_cm - name: Add a new DHCP Relay Policy 1 (normal mode) - mso_dhcp_relay_policy: + cisco.mso.mso_dhcp_relay_policy: <<: *create_dhcp register: dhcp_pol1_nm - name: Verify dhcp_pol1_cm and dhcp_pol1_nm - assert: + ansible.builtin.assert: that: - dhcp_pol1_cm is changed - dhcp_pol1_nm is changed @@ -89,18 +89,18 @@ - dhcp_pol1_cm.current.tenantId == dhcp_pol1_nm.current.tenantId == ansible_tenant.current.id - name: Add a new DHCP Relay Policy 1 again (check mode) - mso_dhcp_relay_policy: + cisco.mso.mso_dhcp_relay_policy: <<: *create_dhcp check_mode: true register: dhcp_pol1_again_cm - name: Add a new DHCP Relay Policy 1 again (normal mode) - mso_dhcp_relay_policy: + cisco.mso.mso_dhcp_relay_policy: <<: *create_dhcp register: dhcp_pol1_again_nm - name: Verify dhcp_pol1_again_cm and dhcp_pol1_again_nm - assert: + ansible.builtin.assert: that: - dhcp_pol1_again_cm is not changed - dhcp_pol1_again_nm is not changed @@ -111,25 +111,25 @@ - dhcp_pol1_again_cm.current.tenantId == dhcp_pol1_again_nm.current.tenantId == ansible_tenant.current.id - name: Add a new DHCP Relay Policy 2 (normal mode) - mso_dhcp_relay_policy: + cisco.mso.mso_dhcp_relay_policy: <<: *create_dhcp dhcp_relay_policy: ansible_dhcp_relay_2 - name: Change DHCP Relay Policy 1 description (check mode) - mso_dhcp_relay_policy: + cisco.mso.mso_dhcp_relay_policy: <<: *create_dhcp description: "My Changed Test DHCP Policy 1" check_mode: true register: change_dhcp_pol1_cm - name: Change DHCP Relay Policy 1 description (normal mode) - mso_dhcp_relay_policy: + cisco.mso.mso_dhcp_relay_policy: <<: *create_dhcp description: "My Changed Test DHCP Policy 1" register: change_dhcp_pol1_nm - name: Verify change_dhcp_pol1_cm and change_dhcp_pol1_nm - assert: + ansible.builtin.assert: that: - change_dhcp_pol1_cm is changed - change_dhcp_pol1_nm is changed @@ -141,7 +141,7 @@ # QUERY A DHCP RELAY POLICY - name: Query DHCP Relay Policy 1 (check mode) - mso_dhcp_relay_policy: &query_dhcp + cisco.mso.mso_dhcp_relay_policy: &query_dhcp <<: *mso_info dhcp_relay_policy: ansible_dhcp_relay_1 state: query @@ -149,12 +149,12 @@ register: dhcp_pol1_query_cm - name: Query DHCP Relay Policy 1 (normal mode) - mso_dhcp_relay_policy: + cisco.mso.mso_dhcp_relay_policy: <<: *query_dhcp register: dhcp_pol1_query_nm - name: Verify dhcp_pol1_query - assert: + ansible.builtin.assert: that: - dhcp_pol1_query_cm is not changed - dhcp_pol1_query_nm is not changed @@ -165,33 +165,33 @@ # QUERY A NON-EXISTING DHCP RELAY POLICY - name: Query non-existing DHCP Relay Policy (normal mode) - mso_dhcp_relay_policy: + cisco.mso.mso_dhcp_relay_policy: <<: *mso_info dhcp_relay_policy: non_existing state: query register: quey_non_dhcp_pol - name: Verify quey_non_dhcp_pol - assert: + ansible.builtin.assert: that: - quey_non_dhcp_pol is not changed # QUERY ALL DHCP RELAY POLICIES - name: Query all DHCP Relay Policies (normal mode) - mso_dhcp_relay_policy: + cisco.mso.mso_dhcp_relay_policy: <<: *mso_info state: query register: dhcp_policies_query - name: Verify dhcp_policies_query - assert: + ansible.builtin.assert: that: - dhcp_policies_query is not changed - dhcp_policies_query.current | length == 2 # REMOVE DHCP POLICY - name: Remove DHCP Relay Policy 1 (check mode) - mso_dhcp_relay_policy: &remove_dhcp + cisco.mso.mso_dhcp_relay_policy: &remove_dhcp <<: *mso_info dhcp_relay_policy: ansible_dhcp_relay_1 state: absent @@ -199,12 +199,12 @@ register: dhcp_pol1_removed_cm - name: Remove DHCP Relay Policy 1 (normal mode) - mso_dhcp_relay_policy: + cisco.mso.mso_dhcp_relay_policy: <<: *remove_dhcp register: dhcp_pol1_removed_nm - name: Verify dhcp_policies_removed - assert: + ansible.builtin.assert: that: - dhcp_pol1_removed_cm is changed - dhcp_pol1_removed_nm is changed @@ -212,18 +212,18 @@ # REMOVE DHCP POLICY AGAIN - name: Remove DHCP Relay Policy 1 again (check mode) - mso_dhcp_relay_policy: + cisco.mso.mso_dhcp_relay_policy: <<: *remove_dhcp check_mode: true register: dhcp_pol1_removed_again_cm - name: Remove DHCP Relay Policy 1 again (normal mode) - mso_dhcp_relay_policy: + cisco.mso.mso_dhcp_relay_policy: <<: *remove_dhcp register: dhcp_pol1_removed_again_nm - name: Verify dhcp_pol1_removed_again - assert: + ansible.builtin.assert: that: - dhcp_pol1_removed_again_cm is not changed - dhcp_pol1_removed_again_nm is not changed @@ -233,7 +233,7 @@ # USE A NON-EXISTING TENANT - name: Non Existing Tenant for DHCP Relay Policy 3 (normal mode) - mso_dhcp_relay_policy: + cisco.mso.mso_dhcp_relay_policy: <<: *mso_info dhcp_relay_policy: ansible_dhcp_relay_3 description: "My Test DHCP Policy 3" @@ -243,14 +243,14 @@ register: nm_non_existing_tenant - name: Verify nm_non_existing_tenant - assert: + ansible.builtin.assert: that: - nm_non_existing_tenant is not changed - nm_non_existing_tenant.msg == "Tenant 'non_existing' is not valid tenant name." # CLEAN UP DHCP POLICIES - name: Stop consuming DHCP Policy - mso_schema_template_bd: + cisco.mso.mso_schema_template_bd: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -261,7 +261,7 @@ ignore_errors: true - name: Remove DHCP Relay Policy 1 - mso_dhcp_relay_policy: + cisco.mso.mso_dhcp_relay_policy: <<: *mso_info dhcp_relay_policy: '{{ item }}' state: absent diff --git a/ansible_collections/cisco/mso/tests/integration/targets/mso_dhcp_relay_policy_provider/tasks/main.yaml b/ansible_collections/cisco/mso/tests/integration/targets/mso_dhcp_relay_policy_provider/tasks/main.yaml index 828a34424..a3506099c 100644 --- a/ansible_collections/cisco/mso/tests/integration/targets/mso_dhcp_relay_policy_provider/tasks/main.yaml +++ b/ansible_collections/cisco/mso/tests/integration/targets/mso_dhcp_relay_policy_provider/tasks/main.yaml @@ -4,13 +4,13 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI MultiSite host, username and password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: mso_hostname, mso_username and mso_password.' when: mso_hostname is not defined or mso_username is not defined or mso_password is not defined #CLEAN ENVIRONMENT - name: Set vars - set_fact: + ansible.builtin.set_fact: mso_info: &mso_info host: '{{ mso_hostname }}' username: '{{ mso_username }}' @@ -21,7 +21,7 @@ output_level: '{{ mso_output_level | default("info") }}' - name: Query MSO version - mso_version: + cisco.mso.mso_version: <<: *mso_info state: query register: version @@ -30,7 +30,7 @@ when: version.current.version is version('4.0', '<') block: - name: Remove EXT_EPGs Providers from DHCP Relay Policy - mso_dhcp_relay_policy_provider: + cisco.mso.mso_dhcp_relay_policy_provider: <<: *mso_info dhcp_relay_policy: ansible_dhcp_relay_1 tenant: ansible_test @@ -44,7 +44,7 @@ - EXT_EPG_2 - name: Remove EXT_EPGs Providers from DHCP Relay Policy - mso_dhcp_relay_policy_provider: + cisco.mso.mso_dhcp_relay_policy_provider: <<: *mso_info dhcp_relay_policy: ansible_dhcp_relay_1 tenant: ansible_test @@ -59,7 +59,7 @@ - EPG_2 - name: Stop consuming DHCP Policy - mso_schema_template_bd: + cisco.mso.mso_schema_template_bd: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -70,7 +70,7 @@ ignore_errors: true - name: Remove DHCP Relay Policies - mso_dhcp_relay_policy: + cisco.mso.mso_dhcp_relay_policy: <<: *mso_info dhcp_relay_policy: '{{ item }}' state: absent @@ -80,7 +80,7 @@ - ansible_dhcp_relay_2 - name: Undeploy sites in schema 1 template 1 - mso_schema_template_deploy: + cisco.mso.mso_schema_template_deploy: <<: *mso_info template: Template 1 schema: '{{ mso_schema | default("ansible_test") }}' @@ -94,7 +94,7 @@ - 'azure_{{ mso_site | default("ansible_test") }}' - name: Undeploy sites in schema 1 template 2 - mso_schema_template_deploy: + cisco.mso.mso_schema_template_deploy: <<: *mso_info template: Template 2 schema: '{{ mso_schema | default("ansible_test") }}' @@ -108,7 +108,7 @@ - 'azure_{{ mso_site | default("ansible_test") }}' - name: Remove schemas - mso_schema: + cisco.mso.mso_schema: <<: *mso_info schema: '{{ item }}' state: absent @@ -117,7 +117,7 @@ - '{{ mso_schema | default("ansible_test") }}' - name: Ensure tenant ansible_test exist - mso_tenant: + cisco.mso.mso_tenant: <<: *mso_info tenant: ansible_test users: @@ -126,7 +126,7 @@ register: tenant_ansible - name: Ensure schema 1 with Template 1 exist - mso_schema_template: + cisco.mso.mso_schema_template: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' tenant: ansible_test @@ -135,7 +135,7 @@ # CREATE EPG PROVIDER - name: Add a new VRF - mso_schema_template_vrf: + cisco.mso.mso_schema_template_vrf: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -143,7 +143,7 @@ state: present - name: Add a new BD - mso_schema_template_bd: + cisco.mso.mso_schema_template_bd: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -153,7 +153,7 @@ state: present - name: Add 2nd BD - mso_schema_template_bd: + cisco.mso.mso_schema_template_bd: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -163,7 +163,7 @@ state: present - name: Add a new ANP - mso_schema_template_anp: + cisco.mso.mso_schema_template_anp: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -171,7 +171,7 @@ state: present - name: Add a new EPG - mso_schema_template_anp_epg: + cisco.mso.mso_schema_template_anp_epg: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -184,7 +184,7 @@ state: present - name: Add 2nd EPG - mso_schema_template_anp_epg: + cisco.mso.mso_schema_template_anp_epg: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -197,7 +197,7 @@ state: present - name: Add a new L3out - mso_schema_template_l3out: + cisco.mso.mso_schema_template_l3out: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -240,7 +240,7 @@ # ADD DHCP RELAY POLICY - name: Add a new DHCP Relay Policy 1 (Normal mode) - mso_dhcp_relay_policy: + cisco.mso.mso_dhcp_relay_policy: <<: *mso_info dhcp_relay_policy: ansible_dhcp_relay_1 description: "My Test DHCP Policy 1" @@ -249,7 +249,7 @@ # ADD PROVIDER TO DHCP RELAY POLICY - name: Add Provider to DHCP Relay Policy (check mode) - mso_dhcp_relay_policy_provider: &create_provider + cisco.mso.mso_dhcp_relay_policy_provider: &create_provider <<: *mso_info dhcp_relay_policy: ansible_dhcp_relay_1 ip: "1.1.1.1" @@ -263,12 +263,12 @@ register: dhcp_pol1_prov1_cm - name: Add Provider to DHCP Relay Policy (normal mode) - mso_dhcp_relay_policy_provider: + cisco.mso.mso_dhcp_relay_policy_provider: <<: *create_provider register: dhcp_pol1_prov1_nm - name: Verify dhcp_pol1_prov1 - assert: + ansible.builtin.assert: that: - dhcp_pol1_prov1_cm is changed - dhcp_pol1_prov1_nm is changed @@ -283,18 +283,18 @@ - dhcp_pol1_prov1_nm.current.tenantId == tenant_ansible.current.id - name: Add Provider to DHCP Relay Policy again (check mode) - mso_dhcp_relay_policy_provider: + cisco.mso.mso_dhcp_relay_policy_provider: <<: *create_provider check_mode: true register: dhcp_pol1_prov1_again_cm - name: Add Provider to DHCP Relay Policy again (normal mode) - mso_dhcp_relay_policy_provider: + cisco.mso.mso_dhcp_relay_policy_provider: <<: *create_provider register: dhcp_pol1_prov1_again_nm - name: Verify dhcp_pol1_prov1_again - assert: + ansible.builtin.assert: that: - dhcp_pol1_prov1_again_cm is not changed - dhcp_pol1_prov1_again_nm is not changed @@ -309,20 +309,20 @@ - dhcp_pol1_prov1_again_nm.current.tenantId == tenant_ansible.current.id - name: Change Provider IP to DHCP Relay Policy (check mode) - mso_dhcp_relay_policy_provider: + cisco.mso.mso_dhcp_relay_policy_provider: <<: *create_provider ip: "2.2.2.2" check_mode: true register: dhcp_pol1_prov1_change_cm - name: Change Provider IP to DHCP Relay Policy (normal mode) - mso_dhcp_relay_policy_provider: + cisco.mso.mso_dhcp_relay_policy_provider: <<: *create_provider ip: "2.2.2.2" register: dhcp_pol1_prov1_change_nm - name: Verify dhcp_pol1_prov1_change - assert: + ansible.builtin.assert: that: - dhcp_pol1_prov1_change_cm is changed - dhcp_pol1_prov1_change_nm is changed @@ -337,7 +337,7 @@ - dhcp_pol1_prov1_change_nm.current.tenantId == tenant_ansible.current.id - name: Add 2nd Provider (EPG_2) to DHCP Relay Policy (check mode) - mso_dhcp_relay_policy_provider: + cisco.mso.mso_dhcp_relay_policy_provider: <<: *create_provider ip: "2.2.2.2" endpoint_group: EPG_2 @@ -345,14 +345,14 @@ register: dhcp_pol1_prov2_cm - name: Add 2nd Provider (EPG_2) to DHCP Relay Policy (normal mode) - mso_dhcp_relay_policy_provider: + cisco.mso.mso_dhcp_relay_policy_provider: <<: *create_provider ip: "2.2.2.2" endpoint_group: EPG_2 register: dhcp_pol1_prov2_nm - name: Add 3rd Provider (EXT_EPG_1) to DHCP Relay Policy (check mode) - mso_dhcp_relay_policy_provider: &create_provider_external_epg + cisco.mso.mso_dhcp_relay_policy_provider: &create_provider_external_epg <<: *create_provider ip: "2.2.2.2" external_endpoint_group: EXT_EPG_1 @@ -362,26 +362,26 @@ register: dhcp_pol1_prov3_cm - name: Add 3rd Provider (EXT_EPG_1) to DHCP Relay Policy (normal mode) - mso_dhcp_relay_policy_provider: + cisco.mso.mso_dhcp_relay_policy_provider: <<: *create_provider_external_epg external_endpoint_group: EXT_EPG_1 register: dhcp_pol1_prov3_nm - name: Add 4th Provider (EXT_EPG_2) to DHCP Relay Policy (check mode) - mso_dhcp_relay_policy_provider: + cisco.mso.mso_dhcp_relay_policy_provider: <<: *create_provider_external_epg external_endpoint_group: EXT_EPG_2 check_mode: true register: dhcp_pol1_prov4_cm - name: Add 4th Provider (EXT_EPG_2) to DHCP Relay Policy (normal mode) - mso_dhcp_relay_policy_provider: + cisco.mso.mso_dhcp_relay_policy_provider: <<: *create_provider_external_epg external_endpoint_group: EXT_EPG_2 register: dhcp_pol1_prov4_nm - name: Verify dhcp_pol1_prov2, dhcp_pol1_prov3 and dhcp_pol1_prov4 - assert: + ansible.builtin.assert: that: - dhcp_pol1_prov2_cm is changed - dhcp_pol1_prov2_nm is changed @@ -409,7 +409,7 @@ # ADD DHCP RELAY PROVIDER WITH WRONG Attributes - name: Add Provider to DHCP Relay Policy - wrong tenant (Normal mode) - mso_dhcp_relay_policy_provider: + cisco.mso.mso_dhcp_relay_policy_provider: <<: *mso_info dhcp_relay_policy: ansible_dhcp_relay_1 ip: "2.2.2.2" @@ -423,7 +423,7 @@ register: dhcp_pol1_prov2_nm_ten_wrong - name: Add Provider to DHCP Relay Policy - wrong Schema (Normal mode) - mso_dhcp_relay_policy_provider: + cisco.mso.mso_dhcp_relay_policy_provider: <<: *mso_info dhcp_relay_policy: ansible_dhcp_relay_1 ip: "2.2.2.2" @@ -437,7 +437,7 @@ register: dhcp_pol1_prov2_nm_sch_wrong - name: Verify dhcp_pol1_prov2_nm_ten_wrong, dhcp_pol1_prov2_nm_sch_wrong & dhcp_pol1_prov2_nm_tmp_wrong - assert: + ansible.builtin.assert: that: - dhcp_pol1_prov2_nm_ten_wrong is not changed - dhcp_pol1_prov2_nm_ten_wrong.msg == "Tenant 'ansible_test_wrong' is not valid tenant name." @@ -447,7 +447,7 @@ # QUERY PROVIDER FROM DHCP RELAY POLICY - name: Query Provider from DHCP Relay Policy (check mode) - mso_dhcp_relay_policy_provider: &query_provider + cisco.mso.mso_dhcp_relay_policy_provider: &query_provider <<: *mso_info dhcp_relay_policy: ansible_dhcp_relay_1 tenant: ansible_test @@ -459,26 +459,26 @@ register: dhcp_pol1_prov1_query_cm - name: Query Provider from DHCP Relay Policy (normal mode) - mso_dhcp_relay_policy_provider: + cisco.mso.mso_dhcp_relay_policy_provider: <<: *query_provider register: dhcp_pol1_prov1_query_nm - name: Query non_existing Provider from DHCP Relay Policy - mso_dhcp_relay_policy_provider: + cisco.mso.mso_dhcp_relay_policy_provider: <<: *query_provider endpoint_group: non_existing state: query register: dhcp_pol1_prov1_query_non_existing - name: Query all Providers from a DHCP Relay Policy - mso_dhcp_relay_policy_provider: + cisco.mso.mso_dhcp_relay_policy_provider: <<: *mso_info dhcp_relay_policy: ansible_dhcp_relay_1 state: query register: dhcp_pol1_query_all - name: Verify all query variables - assert: + ansible.builtin.assert: that: - dhcp_pol1_prov1_query_cm is not changed - dhcp_pol1_prov1_query_nm is not changed @@ -496,7 +496,7 @@ # REMOVE PROVIDER FROM DHCP RELAY POLICY - name: Remove Provider (EXT_EPG) from DHCP Relay Policy (check mode) - mso_dhcp_relay_policy_provider: &delete_provider + cisco.mso.mso_dhcp_relay_policy_provider: &delete_provider <<: *mso_info dhcp_relay_policy: ansible_dhcp_relay_1 tenant: ansible_test @@ -508,43 +508,43 @@ register: dhcp_pol1_prov1_del_cm - name: Remove Provider (EXT_EPG) from DHCP Relay Policy (normal mode) - mso_dhcp_relay_policy_provider: + cisco.mso.mso_dhcp_relay_policy_provider: <<: *delete_provider register: dhcp_pol1_prov1_del_nm - name: Verify dhcp_pol1_prov1_del - assert: + ansible.builtin.assert: that: - dhcp_pol1_prov1_del_cm is changed - dhcp_pol1_prov1_del_nm is changed - dhcp_pol1_prov1_del_cm.current == dhcp_pol1_prov1_del_nm.current == {} - name: Remove Provider (EXT_EPG) from DHCP Relay Policy again (check mode) - mso_dhcp_relay_policy_provider: + cisco.mso.mso_dhcp_relay_policy_provider: <<: *delete_provider check_mode: true register: dhcp_pol1_prov1_del_again_cm - name: Remove Provider (EXT_EPG) from DHCP Relay Policy again (normal mode) - mso_dhcp_relay_policy_provider: + cisco.mso.mso_dhcp_relay_policy_provider: <<: *delete_provider register: dhcp_pol1_prov1_del_again_nm - name: Verify dhcp_pol1_prov1_again_del - assert: + ansible.builtin.assert: that: - dhcp_pol1_prov1_del_again_cm is not changed - dhcp_pol1_prov1_del_again_nm is not changed - dhcp_pol1_prov1_del_again_cm.current == dhcp_pol1_prov1_del_again_nm.current == {} - name: Remove Non-Existing Provider (EXT_EPG) - mso_dhcp_relay_policy_provider: + cisco.mso.mso_dhcp_relay_policy_provider: <<: *delete_provider external_endpoint_group: non_existing register: dhcp_pol1_prov1_del_nm_non_existing - name: Remove Provider without epg or ext_epg - mso_dhcp_relay_policy_provider: + cisco.mso.mso_dhcp_relay_policy_provider: <<: *mso_info dhcp_relay_policy: ansible_dhcp_relay_1 tenant: ansible_test @@ -555,7 +555,7 @@ register: dhcp_pol1_prov1_del_none - name: Verify dhcp_pol1_prov1_del_nm_non_existing - assert: + ansible.builtin.assert: that: - dhcp_pol1_prov1_del_nm_non_existing is not changed - dhcp_pol1_prov1_del_none is not changed @@ -564,14 +564,14 @@ # CONSUME DHCP POLICIES - name: Get DHCP Relay Policy version - mso_dhcp_relay_policy: + cisco.mso.mso_dhcp_relay_policy: <<: *mso_info dhcp_relay_policy: ansible_dhcp_relay_1 state: query register: dhcp_relay_policy_version - name: Consume DHCP Policy - mso_schema_template_bd: + cisco.mso.mso_schema_template_bd: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -585,7 +585,7 @@ register: bd_dhcp_policy - name: Stop consuming DHCP Policy - mso_schema_template_bd: + cisco.mso.mso_schema_template_bd: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -597,7 +597,7 @@ # QUERY PROVIDER FROM non_existing DHCP RELAY POLICY - name: Query Provider from DHCP Relay Policy (check mode) - mso_dhcp_relay_policy_provider: + cisco.mso.mso_dhcp_relay_policy_provider: <<: *mso_info dhcp_relay_policy: non_existing state: query @@ -605,14 +605,14 @@ register: dhcp_non_existing - name: Verify dhcp_non_existing - assert: + ansible.builtin.assert: that: - dhcp_non_existing is not changed - dhcp_non_existing.msg == "DHCP Relay Policy 'non_existing' is not a valid DHCP Relay Policy name." # CLEAN UP - name: Remove EXT_EPGs Providers from DHCP Relay Policy - mso_dhcp_relay_policy_provider: + cisco.mso.mso_dhcp_relay_policy_provider: <<: *mso_info dhcp_relay_policy: ansible_dhcp_relay_1 tenant: ansible_test @@ -626,7 +626,7 @@ - EXT_EPG_2 - name: Remove EXT_EPGs Providers from DHCP Relay Policy - mso_dhcp_relay_policy_provider: + cisco.mso.mso_dhcp_relay_policy_provider: <<: *mso_info dhcp_relay_policy: ansible_dhcp_relay_1 tenant: ansible_test @@ -641,7 +641,7 @@ - EPG_2 - name: Stop consuming DHCP Policy - mso_schema_template_bd: + cisco.mso.mso_schema_template_bd: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -652,7 +652,7 @@ ignore_errors: true - name: Remove DHCP Relay Policies - mso_dhcp_relay_policy: + cisco.mso.mso_dhcp_relay_policy: <<: *mso_info dhcp_relay_policy: '{{ item }}' state: absent diff --git a/ansible_collections/cisco/mso/tests/integration/targets/mso_label/tasks/main.yml b/ansible_collections/cisco/mso/tests/integration/targets/mso_label/tasks/main.yml index fffb0ce78..e9e2e5a46 100644 --- a/ansible_collections/cisco/mso/tests/integration/targets/mso_label/tasks/main.yml +++ b/ansible_collections/cisco/mso/tests/integration/targets/mso_label/tasks/main.yml @@ -4,14 +4,14 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI MultiSite host, username and password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: mso_hostname, mso_username and mso_password.' when: mso_hostname is not defined or mso_username is not defined or mso_password is not defined # CLEAN ENVIRONMENT - name: Set vars - set_fact: + ansible.builtin.set_fact: mso_info: &mso_info host: '{{ mso_hostname }}' username: '{{ mso_username }}' @@ -22,7 +22,7 @@ output_level: '{{ mso_output_level | default("info") }}' - name: Query MSO version - mso_version: + cisco.mso.mso_version: <<: *mso_info state: query register: version @@ -31,14 +31,14 @@ when: version.current.version is version('3.2', '<') block: - name: GET auth radius providers - mso_rest: + cisco.mso.mso_rest: <<: *mso_info path: /api/v1/auth/providers/radius method: get register: radius_providers - name: Add auth radius provider - mso_rest: + cisco.mso.mso_rest: <<: *mso_info path: /api/v1/auth/providers/radius method: post @@ -57,25 +57,25 @@ when: mso_radius_server not in (radius_providers.jsondata.radiusProviders | map(attribute='host')) - name: GET login domains - mso_rest: + cisco.mso.mso_rest: <<: *mso_info path: /api/v1/auth/domains method: get register: login_domains - name: GET auth radius providers again after creation - mso_rest: + cisco.mso.mso_rest: <<: *mso_info path: /api/v1/auth/providers/radius method: get register: radius_providers - name: GET auth radius provider ID - set_fact: + ansible.builtin.set_fact: radius_provider_id: "{{ (radius_providers.jsondata.radiusProviders | selectattr('host', 'eq', mso_radius_server) | first)['id'] }}" - name: Add test login domain - mso_rest: + cisco.mso.mso_rest: <<: *mso_info path: /api/v1/auth/domains method: post @@ -95,7 +95,7 @@ # REMOVE DHCP POLICY - name: Remove DHCP Option Policy - mso_dhcp_option_policy: &remove_dhcp + cisco.mso.mso_dhcp_option_policy: &remove_dhcp <<: *mso_info dhcp_option_policy: '{{ item }}' state: absent @@ -104,7 +104,7 @@ - ansible_dhcp_option_2 - name: Remove DHCP Relay Policy - mso_dhcp_relay_policy: + cisco.mso.mso_dhcp_relay_policy: <<: *mso_info dhcp_relay_policy: '{{ item }}' state: absent @@ -113,19 +113,19 @@ - ansible_dhcp_relay_2 - name: Remove label ansible_test - mso_label: &label_absent + cisco.mso.mso_label: &label_absent <<: *mso_info label: ansible_test state: absent - name: Remove label ansible_test2 - mso_label: + cisco.mso.mso_label: <<: *label_absent label: ansible_test2 register: cm_remove_label - name: Remove label ansible_test3 - mso_label: &domain_label_absent + cisco.mso.mso_label: &domain_label_absent <<: *mso_info state: absent label: ansible_test3 @@ -133,14 +133,14 @@ register: nm_remove_label3 - name: Remove label ansible_test4 - mso_label: + cisco.mso.mso_label: <<: *domain_label_absent label: ansible_test4 login_domain: '{{ mso_login_domain | default("test") }}' # ADD LABEL - name: Add label (check_mode) - mso_label: &label_present + cisco.mso.mso_label: &label_present <<: *mso_info label: ansible_test state: present @@ -148,7 +148,7 @@ register: cm_add_label - name: Verify cm_add_label - assert: + ansible.builtin.assert: that: - cm_add_label is changed - cm_add_label.previous == {} @@ -157,11 +157,11 @@ - cm_add_label.current.type == 'site' - name: Add label (normal mode) - mso_label: *label_present + cisco.mso.mso_label: *label_present register: nm_add_label - name: Verify nm_add_label - assert: + ansible.builtin.assert: that: - nm_add_label is changed - nm_add_label.previous == {} @@ -170,12 +170,12 @@ - nm_add_label.current.type == 'site' - name: Add label again (check_mode) - mso_label: *label_present + cisco.mso.mso_label: *label_present check_mode: true register: cm_add_label_again - name: Verify cm_add_label_again - assert: + ansible.builtin.assert: that: - cm_add_label_again is not changed - cm_add_label_again.previous.displayName == 'ansible_test' @@ -185,11 +185,11 @@ - cm_add_label_again.current.type == 'site' - name: Add label again (normal mode) - mso_label: *label_present + cisco.mso.mso_label: *label_present register: nm_add_label_again - name: Verify nm_add_label_again - assert: + ansible.builtin.assert: that: - nm_add_label_again is not changed - nm_add_label_again.previous.displayName == 'ansible_test' @@ -201,7 +201,7 @@ # CHANGE LABEL # - name: Change label (check_mode) -# mso_label: +# cisco.mso.mso_label: # <<: *label_present # label_id: '{{ nm_add_label.current.id }}' # label: ansible_test2 @@ -209,7 +209,7 @@ # register: cm_change_label # - name: Verify cm_change_label -# assert: +# ansible.builtin.assert: # that: # - cm_change_label is changed # - cm_change_label.current.displayName == 'ansible_test2' @@ -217,7 +217,7 @@ # - cm_change_label.current.type == 'site' # - name: Change label (normal mode) -# mso_label: +# cisco.mso.mso_label: # <<: *label_present # label_id: '{{ nm_add_label.current.id }}' # label: ansible_test2 @@ -225,7 +225,7 @@ # register: nm_change_label # - name: Verify nm_change_label -# assert: +# ansible.builtin.assert: # that: # - nm_change_label is changed # - cm_change_label.current.displayName == 'ansible_test2' @@ -233,7 +233,7 @@ # - nm_change_label.current.type == 'site' # - name: Change label again (check_mode) -# mso_label: +# cisco.mso.mso_label: # <<: *label_present # label_id: '{{ nm_add_label.current.id }}' # label: ansible_test2 @@ -241,7 +241,7 @@ # register: cm_change_label_again # - name: Verify cm_change_label_again -# assert: +# ansible.builtin.assert: # that: # - cm_change_label_again is not changed # - cm_change_label_again.current.displayName == 'ansible_test2' @@ -249,14 +249,14 @@ # - cm_change_label_again.current.type == 'site' # - name: Change label again (normal mode) -# mso_label: +# cisco.mso.mso_label: # <<: *label_present # label_id: '{{ nm_add_label.current.id }}' # label: ansible_test2 # register: nm_change_label_again # - name: Verify nm_change_label_again -# assert: +# ansible.builtin.assert: # that: # - nm_change_label_again is not changed # - nm_change_label_again.current.displayName == 'ansible_test2' @@ -266,18 +266,18 @@ # QUERY ALL LABELS - name: Query all labels (check_mode) - mso_label: &label_query + cisco.mso.mso_label: &label_query <<: *mso_info state: query check_mode: true register: cm_query_all_labels - name: Query all labels (normal mode) - mso_label: *label_query + cisco.mso.mso_label: *label_query register: nm_query_all_labels - name: Verify query_all_labels - assert: + ansible.builtin.assert: that: - cm_query_all_labels is not changed - nm_query_all_labels is not changed @@ -288,20 +288,20 @@ # QUERY A LABEL - name: Query our label (check mode) - mso_label: + cisco.mso.mso_label: <<: *label_query label: ansible_test check_mode: true register: cm_query_label - name: Query our label (normal mode) - mso_label: + cisco.mso.mso_label: <<: *label_query label: ansible_test register: nm_query_label - name: Verify query_label - assert: + ansible.builtin.assert: that: - cm_query_label is not changed - cm_query_label.current.displayName == 'ansible_test' @@ -316,43 +316,43 @@ # REMOVE LABEL - name: Remove label (check_mode) - mso_label: *label_absent + cisco.mso.mso_label: *label_absent check_mode: true register: cm_remove_label - name: Verify cm_remove_label - assert: + ansible.builtin.assert: that: - cm_remove_label is changed - cm_remove_label.current == {} - name: Remove label (normal mode) - mso_label: *label_absent + cisco.mso.mso_label: *label_absent register: nm_remove_label - name: Verify nm_remove_label - assert: + ansible.builtin.assert: that: - nm_remove_label is changed - nm_remove_label.current == {} - name: Remove label again (check_mode) - mso_label: *label_absent + cisco.mso.mso_label: *label_absent check_mode: true register: cm_remove_label_again - name: Verify cm_remove_label_again - assert: + ansible.builtin.assert: that: - cm_remove_label_again is not changed - cm_remove_label_again.current == {} - name: Remove label again (normal mode) - mso_label: *label_absent + cisco.mso.mso_label: *label_absent register: nm_remove_label_again - name: Verify nm_remove_label_again - assert: + ansible.builtin.assert: that: - nm_remove_label_again is not changed - nm_remove_label_again.current == {} @@ -360,21 +360,21 @@ # QUERY NON-EXISTING LABEL - name: Query non-existing label (check_mode) - mso_label: + cisco.mso.mso_label: <<: *label_query label: ansible_test check_mode: true register: cm_query_non_label - name: Query non-existing label (normal mode) - mso_label: + cisco.mso.mso_label: <<: *label_query label: ansible_test register: nm_query_non_label # TODO: Implement more tests - name: Verify query_non_label - assert: + ansible.builtin.assert: that: - cm_query_non_label is not changed - nm_query_non_label is not changed @@ -382,7 +382,7 @@ # add label with login domain - name: Add label local domain(normal mode) - mso_label: &domain_label_present + cisco.mso.mso_label: &domain_label_present <<: *mso_info state: present label: ansible_test3 @@ -390,21 +390,21 @@ register: label_local_domain - name: Verify label_local_domain - assert: + ansible.builtin.assert: that: - label_local_domain is changed - label_local_domain.current.displayName == 'ansible_test3' - label_local_domain.current.type == 'site' - name: Add label test domain(normal mode) - mso_label: + cisco.mso.mso_label: <<: *domain_label_present label: ansible_test4 login_domain: '{{ mso_login_domain | default("test") }}' register: label_test_domain - name: Verify label_test_domain - assert: + ansible.builtin.assert: that: - label_test_domain is changed - label_test_domain.current.displayName == 'ansible_test4' diff --git a/ansible_collections/cisco/mso/tests/integration/targets/mso_remote_location/tasks/main.yml b/ansible_collections/cisco/mso/tests/integration/targets/mso_remote_location/tasks/main.yml index aa543f959..d5d00010d 100644 --- a/ansible_collections/cisco/mso/tests/integration/targets/mso_remote_location/tasks/main.yml +++ b/ansible_collections/cisco/mso/tests/integration/targets/mso_remote_location/tasks/main.yml @@ -4,14 +4,14 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI MultiSite host, username and password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: mso_hostname, mso_username and mso_password.' when: mso_hostname is not defined or mso_username is not defined or mso_password is not defined # CLEAN ENVIRONMENT - name: Set vars - set_fact: + ansible.builtin.set_fact: mso_info: &mso_info host: '{{ mso_hostname }}' username: '{{ mso_username }}' @@ -25,7 +25,6 @@ cisco.mso.mso_backup: <<: *mso_info state: query - delegate_to: localhost register: backups - name: Ensure all backups with link to remote location ansible_test are removed @@ -38,14 +37,12 @@ - item.location.locationType is defined - item.location.locationType == "remote" loop: "{{ backups.current | sort(attribute='name', reverse=True) }}" - delegate_to: localhost - name: Ensure remote location ansible_test is removed cisco.mso.mso_remote_location: <<: *mso_info remote_location: ansible_test state: absent - delegate_to: localhost - name: Configure remote location scp (check mode) cisco.mso.mso_remote_location: &remote_location @@ -59,17 +56,15 @@ remote_password: '{{ mso_remote_location_password | default(mso_password) }}' state: present check_mode: true - delegate_to: localhost register: cm_config_remote - name: Configure remote location scp cisco.mso.mso_remote_location: <<: *remote_location - delegate_to: localhost register: nm_config_remote - name: Verify configuration - assert: + ansible.builtin.assert: that: - cm_config_remote is changed - cm_config_remote.current.name == "ansible_test" @@ -92,11 +87,10 @@ - name: Configure remote location again cisco.mso.mso_remote_location: <<: *remote_location - delegate_to: localhost register: nm_config_remote_again - name: Verify configuration after again - assert: + ansible.builtin.assert: that: - nm_config_remote_again is not changed @@ -105,18 +99,16 @@ <<: *remote_location description: changed_description check_mode: true - delegate_to: localhost register: cm_change_config_remote_description - name: Change remote location description cisco.mso.mso_remote_location: <<: *remote_location description: changed_description - delegate_to: localhost register: nm_change_config_remote_description - name: Verify configuration change - assert: + ansible.builtin.assert: that: - cm_change_config_remote_description is changed - cm_change_config_remote_description.current.description == "changed_description" @@ -127,14 +119,12 @@ cisco.mso.mso_remote_location: <<: *remote_location state: query - delegate_to: localhost register: nm_query_remote - name: Query all remote locations cisco.mso.mso_remote_location: <<: *mso_info state: query - delegate_to: localhost register: nm_query_all_remotes - name: Query non existing remote location @@ -143,11 +133,10 @@ remote_location: non_existing state: query ignore_errors: true - delegate_to: localhost register: nm_query_non_existing - name: Verify queries - assert: + ansible.builtin.assert: that: - nm_query_remote is not changed - nm_query_remote.current | type_debug == "dict" @@ -161,18 +150,16 @@ <<: *remote_location state: absent check_mode: true - delegate_to: localhost register: cm_delete_config_remote - name: Remove remote location cisco.mso.mso_remote_location: <<: *remote_location state: absent - delegate_to: localhost register: nm_delete_config_remote - name: Verify delete - assert: + ansible.builtin.assert: that: - cm_delete_config_remote is changed - cm_delete_config_remote.current == {} @@ -190,18 +177,16 @@ <<: *remote_location remote_path: '{{ mso_remote_location_alternate_path | default("/home/"~mso_username) }}' check_mode: true - delegate_to: localhost register: cm_config_remote_different_path - name: Configure remote location different path cisco.mso.mso_remote_location: <<: *remote_location remote_path: '{{ mso_remote_location_alternate_path | default("/home/"~mso_username) }}' - delegate_to: localhost register: nm_config_remote_different_path - name: Verify configuration different path - assert: + ansible.builtin.assert: that: - cm_config_remote_different_path is changed - cm_config_remote_different_path.current.credential.remotePath == '{{ mso_remote_location_alternate_path | default("/home/"~mso_username) }}' @@ -212,25 +197,22 @@ cisco.mso.mso_remote_location: <<: *remote_location state: absent - delegate_to: localhost - name: Configure remote location sftp (check mode) cisco.mso.mso_remote_location: <<: *remote_location remote_protocol: sftp check_mode: true - delegate_to: localhost register: cm_config_remote_sftp - name: Configure remote location sftp cisco.mso.mso_remote_location: <<: *remote_location remote_protocol: sftp - delegate_to: localhost register: nm_config_remote_sftp - name: Verify configuration sftp - assert: + ansible.builtin.assert: that: - cm_config_remote_sftp is changed - cm_config_remote_sftp.current.credential.protocolType == "sftp" @@ -241,7 +223,6 @@ cisco.mso.mso_remote_location: <<: *remote_location state: absent - delegate_to: localhost - name: Configure remote location ssh (check mode) cisco.mso.mso_remote_location: &remote_location_ssh @@ -249,17 +230,15 @@ authentication_type: ssh remote_ssh_key: "{{ lookup('file', 'pki/rsa') }}" check_mode: true - delegate_to: localhost register: cm_config_remote_ssh - name: Configure remote location ssh cisco.mso.mso_remote_location: <<: *remote_location_ssh - delegate_to: localhost register: nm_config_remote_ssh - name: Verify configuration ssh - assert: + ansible.builtin.assert: that: - cm_config_remote_ssh is changed - cm_config_remote_ssh.current.credential.authType == "sshKey" @@ -270,7 +249,6 @@ cisco.mso.mso_remote_location: <<: *remote_location_ssh state: absent - delegate_to: localhost - name: Configure remote location ssh with passphrase (check mode) cisco.mso.mso_remote_location: &remote_location_ssh_pass @@ -279,17 +257,15 @@ remote_ssh_key: "{{ lookup('file', 'pki/rsa-passphrase') }}" remote_ssh_passphrase: '{{ mso_output_level | default("ansible") }}' check_mode: true - delegate_to: localhost register: cm_config_remote_ssh_pass - name: Configure remote location ssh with passphrase cisco.mso.mso_remote_location: <<: *remote_location_ssh_pass - delegate_to: localhost register: nm_config_remote_ssh_pass - name: Verify configuration ssh - assert: + ansible.builtin.assert: that: - cm_config_remote_ssh_pass is changed - cm_config_remote_ssh_pass.current.credential.authType == "sshKey" @@ -300,4 +276,3 @@ cisco.mso.mso_remote_location: <<: *remote_location_ssh_pass state: absent - delegate_to: localhost
\ No newline at end of file diff --git a/ansible_collections/cisco/mso/tests/integration/targets/mso_rest/tasks/error_handling.yml b/ansible_collections/cisco/mso/tests/integration/targets/mso_rest/tasks/error_handling.yml index 63a241918..456220eac 100644 --- a/ansible_collections/cisco/mso/tests/integration/targets/mso_rest/tasks/error_handling.yml +++ b/ansible_collections/cisco/mso/tests/integration/targets/mso_rest/tasks/error_handling.yml @@ -5,14 +5,14 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI MultiSite host, username and password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: mso_hostname, mso_username and mso_password.' when: mso_hostname is not defined or mso_username is not defined or mso_password is not defined # SET VARs - name: Set vars - set_fact: + ansible.builtin.set_fact: mso_info: &mso_info host: '{{ mso_hostname }}' username: '{{ mso_username }}' @@ -23,7 +23,7 @@ output_level: '{{ mso_output_level | default("info") }}' - name: Query MSO version - mso_version: + cisco.mso.mso_version: <<: *mso_info state: query register: version @@ -45,7 +45,7 @@ register: error_on_missing_required_param - name: Verify error_on_missing_required_param - assert: + ansible.builtin.assert: that: - error_on_missing_required_param is failed - 'error_on_missing_required_param.msg == "missing required arguments: path"' @@ -73,19 +73,19 @@ register: error_on_name_resolution - name: Verify error_on_name_resolution - assert: + ansible.builtin.assert: that: - error_on_name_resolution is failed - name: Verify error_on_name_resolution - assert: + ansible.builtin.assert: that: - error_on_name_resolution.msg is search("Name or service not known") when: - version.current.version is version('3.7', '>=') - name: Error on invalid path - mso_rest: + cisco.mso.mso_rest: <<: *mso_info path: /mso/api/v1/tenant method: post @@ -100,14 +100,14 @@ register: error_on_invalid_path - name: Verify error_on_invalid_path - assert: + ansible.builtin.assert: that: - error_on_invalid_path is failed - error_on_invalid_path.status == 404 when: version.current.version is version('3.0.0a', '<') or version.current.version is version('3.2', '>=') - name: Verify error_on_invalid_path - assert: + ansible.builtin.assert: that: - error_on_invalid_path is failed - error_on_invalid_path.status == 405 @@ -126,7 +126,7 @@ register: error_on_missing_attributes - name: Verify error_on_missing_attributes - assert: + ansible.builtin.assert: that: - error_on_missing_attributes is failed - error_on_missing_attributes.status == 400 @@ -147,7 +147,7 @@ register: error_on_input_validation - name: Verify error_on_input_validation - assert: + ansible.builtin.assert: that: - error_on_input_validation is failed - error_on_input_validation.status == 400 diff --git a/ansible_collections/cisco/mso/tests/integration/targets/mso_rest/tasks/json_inline.yml b/ansible_collections/cisco/mso/tests/integration/targets/mso_rest/tasks/json_inline.yml index 252733c29..9eff34f24 100644 --- a/ansible_collections/cisco/mso/tests/integration/targets/mso_rest/tasks/json_inline.yml +++ b/ansible_collections/cisco/mso/tests/integration/targets/mso_rest/tasks/json_inline.yml @@ -5,14 +5,14 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI MultiSite host, username and password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: mso_hostname, mso_username and mso_password.' when: mso_hostname is not defined or mso_username is not defined or mso_password is not defined # CLEAN ENVIRONMENT - name: Set vars - set_fact: + ansible.builtin.set_fact: mso_info: &mso_info host: '{{ mso_hostname }}' username: '{{ mso_username }}' @@ -23,13 +23,13 @@ output_level: '{{ mso_output_level | default("info") }}' - name: Query MSO version - mso_version: + cisco.mso.mso_version: <<: *mso_info state: query register: version - name: Remove EXT_EPGs Providers from DHCP Relay Policy - mso_dhcp_relay_policy_provider: + cisco.mso.mso_dhcp_relay_policy_provider: <<: *mso_info dhcp_relay_policy: ansible_dhcp_relay_1 tenant: ansible_test @@ -43,7 +43,7 @@ - EXT_EPG_2 - name: Remove EXT_EPGs Providers from DHCP Relay Policy - mso_dhcp_relay_policy_provider: + cisco.mso.mso_dhcp_relay_policy_provider: <<: *mso_info dhcp_relay_policy: ansible_dhcp_relay_1 tenant: ansible_test @@ -58,7 +58,7 @@ - EPG_2 - name: Stop consuming DHCP Policy - mso_schema_template_bd: + cisco.mso.mso_schema_template_bd: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -69,7 +69,7 @@ ignore_errors: true - name: Remove DHCP Relay Policies - mso_dhcp_relay_policy: + cisco.mso.mso_dhcp_relay_policy: <<: *mso_info dhcp_relay_policy: '{{ item }}' state: absent @@ -79,7 +79,7 @@ - ansible_dhcp_relay_2 - name: Remove DHCP Option Policies - mso_dhcp_option_policy: + cisco.mso.mso_dhcp_option_policy: <<: *mso_info dhcp_option_policy: '{{ item }}' state: absent @@ -101,7 +101,7 @@ - 'azure_{{ mso_site | default("ansible_test") }}' - name: Remove tenant ansible_test - mso_tenant: + cisco.mso.mso_tenant: <<: *mso_info tenant: ansible_test state: absent @@ -109,20 +109,20 @@ # QUERY SCHEMAS - name: Query schema - mso_rest: + cisco.mso.mso_rest: <<: *mso_info path: /mso/api/v1/schemas method: get register: query_all_schema - name: Verify query_all_schema in json_inline - assert: + ansible.builtin.assert: that: - query_all_schema is not changed # QUERY A USER - name: Query our user - mso_user: + cisco.mso.mso_user: <<: *mso_info state: query user: '{{ mso_username }}' @@ -130,14 +130,14 @@ register: query_user_id - name: Verify query_user_id - assert: + ansible.builtin.assert: that: - query_user_id is not changed - query_user_id.current.username == '{{ mso_username }}' # ADD tenant - name: Add tenant - mso_rest: + cisco.mso.mso_rest: <<: *mso_info path: /api/v1/tenants method: post @@ -155,14 +155,14 @@ register: add_tenant - name: Verify add_tenant in json_inline - assert: + ansible.builtin.assert: that: - add_tenant is changed - add_tenant.jsondata.displayName == 'ansible_test' # ADD schema - name: Add schema - mso_rest: + cisco.mso.mso_rest: <<: *mso_info path: /mso/api/v1/schemas method: post @@ -190,14 +190,14 @@ register: add_schema - name: Verify add_schema in json_inline - assert: + ansible.builtin.assert: that: - add_schema is changed - add_schema.jsondata.displayName == 'ansible_test' # PUT schema - name: Put schema - mso_rest: + cisco.mso.mso_rest: <<: *mso_info port: 443 path: "/mso/api/v1/schemas/{{ add_schema.jsondata.id }}" @@ -226,14 +226,14 @@ register: put_schema - name: Verify put_schema in json_inline - assert: + ansible.builtin.assert: that: - put_schema is changed - put_schema.jsondata.displayName == 'ansible_test_2' # PATCH schema - name: Patch schema - mso_rest: + cisco.mso.mso_rest: <<: *mso_info path: "/mso/api/v1/schemas/{{ add_schema.jsondata.id }}" method: patch @@ -249,12 +249,12 @@ register: patch_schema - name: Verify patch_schema in json_inline - assert: + ansible.builtin.assert: that: - patch_schema is changed - name: Verify patch_schema in json_inline - assert: + ansible.builtin.assert: that: - patch_schema.jsondata.templates[0].anps[0].displayName == 'AP2' # MSO 3.3 PATCH does not return anything anymore. @@ -262,28 +262,28 @@ # DELETE the schema - name: Delete the schema - mso_rest: + cisco.mso.mso_rest: <<: *mso_info path: "/mso/api/v1/schemas/{{ add_schema.jsondata.id }}" method: delete register: delete_schema - name: Verify delete_schema in json_inline - assert: + ansible.builtin.assert: that: - delete_schema is changed - delete_schema.jsondata == None # DELETE TENANT - name: Delete the tenant - mso_rest: + cisco.mso.mso_rest: <<: *mso_info path: "/mso/api/v1/tenants/{{ add_tenant.jsondata.id }}" method: delete register: delete_tenant - name: Verify delete_tenant in json_inline - assert: + ansible.builtin.assert: that: - delete_tenant is changed - delete_tenant.jsondata == None
\ No newline at end of file diff --git a/ansible_collections/cisco/mso/tests/integration/targets/mso_rest/tasks/json_string.yml b/ansible_collections/cisco/mso/tests/integration/targets/mso_rest/tasks/json_string.yml index 9a9df1ea7..821e3e701 100644 --- a/ansible_collections/cisco/mso/tests/integration/targets/mso_rest/tasks/json_string.yml +++ b/ansible_collections/cisco/mso/tests/integration/targets/mso_rest/tasks/json_string.yml @@ -5,14 +5,14 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI MultiSite host, username and password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: mso_hostname, mso_username and mso_password.' when: mso_hostname is not defined or mso_username is not defined or mso_password is not defined # CLEAN ENVIRONMENT - name: Set vars - set_fact: + ansible.builtin.set_fact: mso_info: &mso_info host: '{{ mso_hostname }}' username: '{{ mso_username }}' @@ -23,7 +23,7 @@ output_level: '{{ mso_output_level | default("info") }}' - name: Query MSO version - mso_version: + cisco.mso.mso_version: <<: *mso_info state: query register: version @@ -38,27 +38,27 @@ - '{{ mso_schema | default("ansible_test") }}' - name: Remove tenant ansible_test - mso_tenant: + cisco.mso.mso_tenant: <<: *mso_info tenant: ansible_test state: absent # QUERY SCHEMAS - name: Query schema - mso_rest: + cisco.mso.mso_rest: <<: *mso_info path: /mso/api/v1/schemas method: get register: query_all_schema - name: Verify query_all_schema - assert: + ansible.builtin.assert: that: - query_all_schema is not changed # QUERY A USER - name: Query our user - mso_user: + cisco.mso.mso_user: <<: *mso_info state: query user: '{{ mso_username }}' @@ -66,14 +66,14 @@ register: query_user_id - name: Verify query_user_id - assert: + ansible.builtin.assert: that: - query_user_id is not changed - query_user_id.current.username == '{{ mso_username }}' # ADD tenant - name: Add tenant - mso_rest: + cisco.mso.mso_rest: <<: *mso_info path: /api/v1/tenants method: post @@ -91,14 +91,14 @@ register: add_tenant - name: Verify add_tenant in json_string - assert: + ansible.builtin.assert: that: - add_tenant is changed - add_tenant.jsondata.displayName == 'ansible_test' # ADD schema - name: Add schema - mso_rest: + cisco.mso.mso_rest: <<: *mso_info path: /mso/api/v1/schemas method: post @@ -126,14 +126,14 @@ register: add_schema - name: Verify add_schema in json_string - assert: + ansible.builtin.assert: that: - add_schema is changed - add_schema.jsondata.displayName == 'ansible_test' # PUT schema - name: Put schema - mso_rest: + cisco.mso.mso_rest: <<: *mso_info path: "/mso/api/v1/schemas/{{ add_schema.jsondata.id }}" method: put @@ -161,14 +161,14 @@ register: put_schema - name: Verify put_schema in json_string - assert: + ansible.builtin.assert: that: - put_schema is changed - put_schema.jsondata.displayName == 'ansible_test_2' # PATCH schema - name: Patch schema - mso_rest: + cisco.mso.mso_rest: <<: *mso_info path: "/mso/api/v1/schemas/{{ add_schema.jsondata.id }}" method: patch @@ -184,12 +184,12 @@ register: patch_schema - name: Verify patch_schema in json_string - assert: + ansible.builtin.assert: that: - patch_schema is changed - name: Verify patch_schema in json_string - assert: + ansible.builtin.assert: that: - patch_schema.jsondata.templates[0].anps[0].displayName == 'AP2' # MSO 3.3 PATCH does not return anything anymore. @@ -197,28 +197,28 @@ # DELETE the schema - name: Delete the schema - mso_rest: + cisco.mso.mso_rest: <<: *mso_info path: "/mso/api/v1/schemas/{{ add_schema.jsondata.id }}" method: delete register: delete_schema - name: Verify delete_schema in json_string - assert: + ansible.builtin.assert: that: - delete_schema is changed - delete_schema.jsondata == None # DELETE TENANT - name: Delete the tenant - mso_rest: + cisco.mso.mso_rest: <<: *mso_info path: "/mso/api/v1/tenants/{{ add_tenant.jsondata.id }}" method: delete register: delete_tenant - name: Verify delete_tenant in json_string - assert: + ansible.builtin.assert: that: - delete_tenant is changed - delete_tenant.jsondata == None
\ No newline at end of file diff --git a/ansible_collections/cisco/mso/tests/integration/targets/mso_rest/tasks/json_template.yml b/ansible_collections/cisco/mso/tests/integration/targets/mso_rest/tasks/json_template.yml index 622b3d21d..ab04225ea 100644 --- a/ansible_collections/cisco/mso/tests/integration/targets/mso_rest/tasks/json_template.yml +++ b/ansible_collections/cisco/mso/tests/integration/targets/mso_rest/tasks/json_template.yml @@ -5,14 +5,14 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI MultiSite host, username and password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: mso_hostname, mso_username and mso_password.' when: mso_hostname is not defined or mso_username is not defined or mso_password is not defined # CLEAN ENVIRONMENT - name: Set vars - set_fact: + ansible.builtin.set_fact: mso_info: &mso_info host: '{{ mso_hostname }}' username: '{{ mso_username }}' @@ -32,14 +32,14 @@ - '{{ mso_schema | default("ansible_test") }}' - name: Remove tenant ansible_test - mso_tenant: + cisco.mso.mso_tenant: <<: *mso_info tenant: ansible_test state: absent # QUERY A USER - name: Query our user - mso_user: + cisco.mso.mso_user: <<: *mso_info state: query user: '{{ mso_username }}' @@ -47,13 +47,13 @@ register: query_user_id - name: Verify query_user_id - assert: + ansible.builtin.assert: that: - query_user_id is not changed - query_user_id.current.username == '{{ mso_username }}' - name: Add a tenant from a templated payload file from templates - mso_rest: + cisco.mso.mso_rest: <<: *mso_info path: /api/v1/tenants method: post @@ -61,7 +61,7 @@ register: add_tenant - name: Verify add_tenant in json_string - assert: + ansible.builtin.assert: that: - add_tenant is changed - add_tenant.jsondata.displayName == 'ansible_test'
\ No newline at end of file diff --git a/ansible_collections/cisco/mso/tests/integration/targets/mso_rest/tasks/main.yml b/ansible_collections/cisco/mso/tests/integration/targets/mso_rest/tasks/main.yml index 22851bf72..97ef2840b 100644 --- a/ansible_collections/cisco/mso/tests/integration/targets/mso_rest/tasks/main.yml +++ b/ansible_collections/cisco/mso/tests/integration/targets/mso_rest/tasks/main.yml @@ -5,24 +5,24 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI MultiSite host, username and password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: mso_hostname, mso_username and mso_password.' when: mso_hostname is not defined or mso_username is not defined or mso_password is not defined -- include_tasks: json_inline.yml +- ansible.builtin.include_tasks: json_inline.yml tags: json_inline -- include_tasks: json_string.yml +- ansible.builtin.include_tasks: json_string.yml tags: json_string -- include_tasks: json_template.yml +- ansible.builtin.include_tasks: json_template.yml tags: json_template -- include_tasks: yaml_inline.yml +- ansible.builtin.include_tasks: yaml_inline.yml tags: yaml_inline -- include_tasks: yaml_string.yml +- ansible.builtin.include_tasks: yaml_string.yml tags: yaml_string -- include_tasks: error_handling.yml +- ansible.builtin.include_tasks: error_handling.yml tags: error_handling diff --git a/ansible_collections/cisco/mso/tests/integration/targets/mso_rest/tasks/yaml_inline.yml b/ansible_collections/cisco/mso/tests/integration/targets/mso_rest/tasks/yaml_inline.yml index 1fe44f283..f038d9c81 100644 --- a/ansible_collections/cisco/mso/tests/integration/targets/mso_rest/tasks/yaml_inline.yml +++ b/ansible_collections/cisco/mso/tests/integration/targets/mso_rest/tasks/yaml_inline.yml @@ -5,14 +5,14 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI MultiSite host, username and password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: mso_hostname, mso_username and mso_password.' when: mso_hostname is not defined or mso_username is not defined or mso_password is not defined # CLEAN ENVIRONMENT - name: Set vars - set_fact: + ansible.builtin.set_fact: mso_info: &mso_info host: '{{ mso_hostname }}' username: '{{ mso_username }}' @@ -23,7 +23,7 @@ output_level: '{{ mso_output_level | default("info") }}' - name: Query MSO version - mso_version: + cisco.mso.mso_version: <<: *mso_info state: query register: version @@ -38,27 +38,27 @@ - '{{ mso_schema | default("ansible_test") }}' - name: Remove tenant ansible_test - mso_tenant: + cisco.mso.mso_tenant: <<: *mso_info tenant: ansible_test state: absent # QUERY SCHEMAS - name: Query schema - mso_rest: + cisco.mso.mso_rest: <<: *mso_info path: /mso/api/v1/schemas method: get register: query_all_schema - name: Verify query_all_schema - assert: + ansible.builtin.assert: that: - query_all_schema is not changed # QUERY A USER - name: Query our user - mso_user: + cisco.mso.mso_user: <<: *mso_info state: query user: '{{ mso_username }}' @@ -66,14 +66,14 @@ register: query_user_id - name: Verify query_user_id - assert: + ansible.builtin.assert: that: - query_user_id is not changed - query_user_id.current.username == '{{ mso_username }}' # ADD tenant - name: Add tenant - mso_rest: + cisco.mso.mso_rest: <<: *mso_info path: /mso/api/v1/tenants method: post @@ -88,14 +88,14 @@ register: add_tenant - name: Verify add_tenant in yaml_inline - assert: + ansible.builtin.assert: that: - add_tenant is changed - add_tenant.jsondata.displayName == 'ansible_test' # ADD schema - name: Add schema - mso_rest: + cisco.mso.mso_rest: <<: *mso_info path: /mso/api/v1/schemas method: post @@ -120,14 +120,14 @@ register: add_schema - name: Verify add_schema in yaml_inline - assert: + ansible.builtin.assert: that: - add_schema is changed - add_schema.jsondata.displayName == 'ansible_test' # PUT schema - name: Put schema - mso_rest: + cisco.mso.mso_rest: <<: *mso_info path: "/mso/api/v1/schemas/{{ add_schema.jsondata.id }}" method: put @@ -152,14 +152,14 @@ register: put_schema - name: Verify put_schema in yaml_inline - assert: + ansible.builtin.assert: that: - put_schema is changed - put_schema.jsondata.displayName == 'ansible_test_2' # PATCH schema - name: Patch schema - mso_rest: + cisco.mso.mso_rest: <<: *mso_info path: "/mso/api/v1/schemas/{{ add_schema.jsondata.id }}" method: patch @@ -174,12 +174,12 @@ register: patch_schema - name: Verify patch_schema in yaml_inline - assert: + ansible.builtin.assert: that: - patch_schema is changed - name: Verify patch_schema in yaml_inline - assert: + ansible.builtin.assert: that: - patch_schema.jsondata.templates[0].anps[0].displayName == 'AP2' # MSO 3.3 PATCH does not return anything anymore. @@ -187,28 +187,28 @@ # DELETE the schema - name: Delete the schema - mso_rest: + cisco.mso.mso_rest: <<: *mso_info path: "/mso/api/v1/schemas/{{ add_schema.jsondata.id }}" method: delete register: delete_schema - name: Verify delete_schema in yaml_inline - assert: + ansible.builtin.assert: that: - delete_schema is changed - delete_schema.jsondata == None # DELETE TENANT - name: Delete the tenant - mso_rest: + cisco.mso.mso_rest: <<: *mso_info path: "/mso/api/v1/tenants/{{ add_tenant.jsondata.id }}" method: delete register: delete_tenant - name: Verify delete_tenant in yaml_inline - assert: + ansible.builtin.assert: that: - delete_tenant is changed - delete_tenant.jsondata == None
\ No newline at end of file diff --git a/ansible_collections/cisco/mso/tests/integration/targets/mso_rest/tasks/yaml_string.yml b/ansible_collections/cisco/mso/tests/integration/targets/mso_rest/tasks/yaml_string.yml index 5d9cfb05e..1824d2210 100644 --- a/ansible_collections/cisco/mso/tests/integration/targets/mso_rest/tasks/yaml_string.yml +++ b/ansible_collections/cisco/mso/tests/integration/targets/mso_rest/tasks/yaml_string.yml @@ -5,14 +5,14 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI MultiSite host, username and password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: mso_hostname, mso_username and mso_password.' when: mso_hostname is not defined or mso_username is not defined or mso_password is not defined # CLEAN ENVIRONMENT - name: Set vars - set_fact: + ansible.builtin.set_fact: mso_info: &mso_info host: '{{ mso_hostname }}' username: '{{ mso_username }}' @@ -23,7 +23,7 @@ output_level: '{{ mso_output_level | default("info") }}' - name: Query MSO version - mso_version: + cisco.mso.mso_version: <<: *mso_info state: query register: version @@ -38,27 +38,27 @@ - '{{ mso_schema | default("ansible_test") }}' - name: Remove tenant ansible_test - mso_tenant: + cisco.mso.mso_tenant: <<: *mso_info tenant: ansible_test state: absent # QUERY SCHEMAS - name: Query schema - mso_rest: + cisco.mso.mso_rest: <<: *mso_info path: /mso/api/v1/schemas method: get register: query_all_schema - name: Verify query_all_schema - assert: + ansible.builtin.assert: that: - query_all_schema is not changed # QUERY A USER - name: Query our user - mso_user: + cisco.mso.mso_user: <<: *mso_info state: query user: '{{ mso_username }}' @@ -66,14 +66,14 @@ register: query_user_id - name: Verify query_user_id - assert: + ansible.builtin.assert: that: - query_user_id is not changed - query_user_id.current.username == '{{ mso_username }}' # ADD tenant - name: Add tenant - mso_rest: + cisco.mso.mso_rest: <<: *mso_info path: /mso/api/v1/tenants method: post @@ -88,14 +88,14 @@ register: add_tenant - name: Verify add_tenant in yaml_string - assert: + ansible.builtin.assert: that: - add_tenant is changed - add_tenant.jsondata.displayName == 'ansible_test' # ADD schema - name: Add schema - mso_rest: + cisco.mso.mso_rest: <<: *mso_info path: /mso/api/v1/schemas method: post @@ -120,14 +120,14 @@ register: add_schema - name: Verify add_schema in yaml_string - assert: + ansible.builtin.assert: that: - add_schema is changed - add_schema.jsondata.displayName == 'ansible_test' # PUT schema - name: Put schema - mso_rest: + cisco.mso.mso_rest: <<: *mso_info path: "/mso/api/v1/schemas/{{ add_schema.jsondata.id }}" method: put @@ -152,14 +152,14 @@ register: put_schema - name: Verify put_schema in yaml_string - assert: + ansible.builtin.assert: that: - put_schema is changed - put_schema.jsondata.displayName == 'ansible_test_2' # PATCH schema - name: Patch schema - mso_rest: + cisco.mso.mso_rest: <<: *mso_info path: "/mso/api/v1/schemas/{{ add_schema.jsondata.id }}" method: patch @@ -174,12 +174,12 @@ register: patch_schema - name: Verify patch_schema in yaml_string - assert: + ansible.builtin.assert: that: - patch_schema is changed - name: Verify patch_schema in yaml_string - assert: + ansible.builtin.assert: that: - patch_schema.jsondata.templates[0].anps[0].displayName == 'AP2' # MSO 3.3 PATCH does not return anything anymore. @@ -187,28 +187,28 @@ # DELETE the schema - name: Delete the schema - mso_rest: + cisco.mso.mso_rest: <<: *mso_info path: "/mso/api/v1/schemas/{{ add_schema.jsondata.id }}" method: delete register: delete_schema - name: Verify delete_schema in yaml_string - assert: + ansible.builtin.assert: that: - delete_schema is changed - delete_schema.jsondata == None # DELETE TENANT - name: Delete the tenant - mso_rest: + cisco.mso.mso_rest: <<: *mso_info path: "/mso/api/v1/tenants/{{ add_tenant.jsondata.id }}" method: delete register: delete_tenant - name: Verify delete_tenant in yaml_string - assert: + ansible.builtin.assert: that: - delete_tenant is changed - delete_tenant.jsondata == None
\ No newline at end of file diff --git a/ansible_collections/cisco/mso/tests/integration/targets/mso_role/tasks/main.yml b/ansible_collections/cisco/mso/tests/integration/targets/mso_role/tasks/main.yml index a27a0e166..e081f3fcf 100644 --- a/ansible_collections/cisco/mso/tests/integration/targets/mso_role/tasks/main.yml +++ b/ansible_collections/cisco/mso/tests/integration/targets/mso_role/tasks/main.yml @@ -4,14 +4,14 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI MultiSite host, username and password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: mso_hostname, mso_username and mso_password.' when: mso_hostname is not defined or mso_username is not defined or mso_password is not defined # CLEAN ENVIRONMENT - name: Set vars - set_fact: + ansible.builtin.set_fact: mso_info: &mso_info host: '{{ mso_hostname }}' username: '{{ mso_username }}' @@ -22,23 +22,23 @@ output_level: '{{ mso_output_level | default("info") }}' - name: Query MSO version - mso_version: + cisco.mso.mso_version: <<: *mso_info state: query register: version - name: Set version vars - set_fact: - mso_rw: true + ansible.builtin.set_fact: + cisco.mso.mso_rw: true when: - version.current.version is version('2.2.4', '<') - name: Import tasks if RW of role in this MSO version - import_tasks: role-rw.yml + ansible.builtin.import_tasks: role-rw.yml when: mso_rw is defined - name: Import tasks if RO of role in this MSO version - import_tasks: role-ro.yml + ansible.builtin.import_tasks: role-ro.yml when: - mso_rw is not defined - version.current.version is version('3.2', '<')
\ No newline at end of file diff --git a/ansible_collections/cisco/mso/tests/integration/targets/mso_role/tasks/role-ro.yml b/ansible_collections/cisco/mso/tests/integration/targets/mso_role/tasks/role-ro.yml index 730202a9d..00cd5a955 100644 --- a/ansible_collections/cisco/mso/tests/integration/targets/mso_role/tasks/role-ro.yml +++ b/ansible_collections/cisco/mso/tests/integration/targets/mso_role/tasks/role-ro.yml @@ -7,7 +7,7 @@ # CLEAN ENVIRONMENT - name: Set vars - set_fact: + ansible.builtin.set_fact: mso_info: &mso_info host: '{{ mso_hostname }}' username: '{{ mso_username }}' @@ -20,18 +20,18 @@ # QUERY ALL ROLES - name: Query all roles (check_mode) - mso_role: &role_query + cisco.mso.mso_role: &role_query <<: *mso_info state: query check_mode: true register: cm_query_all_roles - name: Query all roles (normal mode) - mso_role: *role_query + cisco.mso.mso_role: *role_query register: nm_query_all_roles - name: Verify query_all_roles - assert: + ansible.builtin.assert: that: - cm_query_all_roles is not changed - nm_query_all_roles is not changed @@ -41,20 +41,20 @@ # QUERY A ROLE - name: Query our role - mso_role: + cisco.mso.mso_role: <<: *role_query role: powerUser check_mode: true register: cm_query_role - name: Query our role - mso_role: + cisco.mso.mso_role: <<: *role_query role: powerUser register: nm_query_role - name: Verify query_role - assert: + ansible.builtin.assert: that: - cm_query_role is not changed - cm_query_role.current.description == 'Elevates this user to \"admin\"' @@ -67,21 +67,21 @@ # QUERY NON-EXISTING ROLE - name: Query non-existing role (check_mode) - mso_role: + cisco.mso.mso_role: <<: *role_query role: non-existing-role check_mode: true register: cm_query_non_role - name: Query non-existing role (normal mode) - mso_role: + cisco.mso.mso_role: <<: *role_query role: non-existing-role register: nm_query_non_role # TODO: Implement more tests - name: Verify query_non_role - assert: + ansible.builtin.assert: that: - cm_query_non_role is not changed - nm_query_non_role is not changed diff --git a/ansible_collections/cisco/mso/tests/integration/targets/mso_role/tasks/role-rw.yml b/ansible_collections/cisco/mso/tests/integration/targets/mso_role/tasks/role-rw.yml index 82db67640..398a9579c 100644 --- a/ansible_collections/cisco/mso/tests/integration/targets/mso_role/tasks/role-rw.yml +++ b/ansible_collections/cisco/mso/tests/integration/targets/mso_role/tasks/role-rw.yml @@ -7,7 +7,7 @@ # CLEAN ENVIRONMENT - name: Set vars - set_fact: + ansible.builtin.set_fact: mso_info: &mso_info host: '{{ mso_hostname }}' username: '{{ mso_username }}' @@ -18,13 +18,13 @@ output_level: '{{ mso_output_level | default("info") }}' - name: Remove role ansible_test - mso_role: &role_absent + cisco.mso.mso_role: &role_absent <<: *mso_info role: ansible_test state: absent - name: Remove role ansible_test2 - mso_role: + cisco.mso.mso_role: <<: *role_absent role: ansible_test2 register: cm_remove_role @@ -32,7 +32,7 @@ # ADD ROLE - name: Add role (check_mode) - mso_role: &role_present + cisco.mso.mso_role: &role_present <<: *mso_info role: ansible_test description: Ansible test role @@ -43,7 +43,7 @@ register: cm_add_role - name: Verify cm_add_role - assert: + ansible.builtin.assert: that: - cm_add_role is changed - cm_add_role.previous == {} @@ -52,11 +52,11 @@ - cm_add_role.current.id is not defined - name: Add role (normal mode) - mso_role: *role_present + cisco.mso.mso_role: *role_present register: nm_add_role - name: Verify nm_add_role - assert: + ansible.builtin.assert: that: - nm_add_role is changed - nm_add_role.previous == {} @@ -65,12 +65,12 @@ - nm_add_role.current.id is defined - name: Add role again (check_mode) - mso_role: *role_present + cisco.mso.mso_role: *role_present check_mode: true register: cm_add_role_again - name: Verify cm_add_role_again - assert: + ansible.builtin.assert: that: - cm_add_role_again is not changed - cm_add_role_again.previous.description == 'Ansible test role' @@ -80,11 +80,11 @@ - cm_add_role_again.current.id == nm_add_role.current.id - name: Add role again (normal mode) - mso_role: *role_present + cisco.mso.mso_role: *role_present register: nm_add_role_again - name: Verify nm_add_role_again - assert: + ansible.builtin.assert: that: - nm_add_role_again is not changed - nm_add_role_again.previous.description == 'Ansible test role' @@ -96,7 +96,7 @@ # CHANGE ROLE - name: Change role (check_mode) - mso_role: + cisco.mso.mso_role: <<: *role_present role: ansible_test description: Ansible test role 2 @@ -104,7 +104,7 @@ register: cm_change_role - name: Verify cm_change_role - assert: + ansible.builtin.assert: that: - cm_change_role is changed - cm_change_role.current.description == 'Ansible test role 2' @@ -112,7 +112,7 @@ - cm_change_role.current.id == nm_add_role.current.id - name: Change role (normal mode) - mso_role: + cisco.mso.mso_role: <<: *role_present role: ansible_test description: Ansible test role 2 @@ -120,7 +120,7 @@ register: nm_change_role - name: Verify nm_change_role - assert: + ansible.builtin.assert: that: - nm_change_role is changed - nm_change_role.current.description == 'Ansible test role 2' @@ -128,7 +128,7 @@ - nm_change_role.current.id == nm_add_role.current.id - name: Change role again (check_mode) - mso_role: + cisco.mso.mso_role: <<: *role_present role: ansible_test description: Ansible test role 2 @@ -136,7 +136,7 @@ register: cm_change_role_again - name: Verify cm_change_role_again - assert: + ansible.builtin.assert: that: - cm_change_role_again is not changed - cm_change_role_again.current.description == 'Ansible test role 2' @@ -144,14 +144,14 @@ - cm_change_role_again.current.id == nm_add_role.current.id - name: Change role again (normal mode) - mso_role: + cisco.mso.mso_role: <<: *role_present role: ansible_test description: Ansible test role 2 register: nm_change_role_again - name: Verify nm_change_role_again - assert: + ansible.builtin.assert: that: - nm_change_role_again is not changed - nm_change_role_again.current.description == 'Ansible test role 2' @@ -161,18 +161,18 @@ # QUERY ALL ROLES - name: Query all roles (check_mode) - mso_role: &role_query + cisco.mso.mso_role: &role_query <<: *mso_info state: query check_mode: true register: cm_query_all_roles - name: Query all roles (normal mode) - mso_role: *role_query + cisco.mso.mso_role: *role_query register: nm_query_all_roles - name: Verify query_all_roles - assert: + ansible.builtin.assert: that: - cm_query_all_roles is not changed - nm_query_all_roles is not changed @@ -182,20 +182,20 @@ # QUERY A ROLE - name: Query our role - mso_role: + cisco.mso.mso_role: <<: *role_query role: ansible_test check_mode: true register: cm_query_role - name: Query our role - mso_role: + cisco.mso.mso_role: <<: *role_query role: ansible_test register: nm_query_role - name: Verify query_role - assert: + ansible.builtin.assert: that: - cm_query_role is not changed - cm_query_role.current.description == 'Ansible test role 2' @@ -210,43 +210,43 @@ # REMOVE ROLE - name: Remove role (check_mode) - mso_role: *role_absent + cisco.mso.mso_role: *role_absent check_mode: true register: cm_remove_role - name: Verify cm_remove_role - assert: + ansible.builtin.assert: that: - cm_remove_role is changed - cm_remove_role.current == {} - name: Remove role (normal mode) - mso_role: *role_absent + cisco.mso.mso_role: *role_absent register: nm_remove_role - name: Verify nm_remove_role - assert: + ansible.builtin.assert: that: - nm_remove_role is changed - nm_remove_role.current == {} - name: Remove role again (check_mode) - mso_role: *role_absent + cisco.mso.mso_role: *role_absent check_mode: true register: cm_remove_role_again - name: Verify cm_remove_role_again - assert: + ansible.builtin.assert: that: - cm_remove_role_again is not changed - cm_remove_role_again.current == {} - name: Remove role again (normal mode) - mso_role: *role_absent + cisco.mso.mso_role: *role_absent register: nm_remove_role_again - name: Verify nm_remove_role_again - assert: + ansible.builtin.assert: that: - nm_remove_role_again is not changed - nm_remove_role_again.current == {} @@ -254,21 +254,21 @@ # QUERY NON-EXISTING ROLE - name: Query non-existing role (check_mode) - mso_role: + cisco.mso.mso_role: <<: *role_query role: non-existing-role check_mode: true register: cm_query_non_role - name: Query non-existing role (normal mode) - mso_role: + cisco.mso.mso_role: <<: *role_query role: non-existing-role register: nm_query_non_role # TODO: Implement more tests - name: Verify query_non_role - assert: + ansible.builtin.assert: that: - cm_query_non_role is not changed - nm_query_non_role is not changed diff --git a/ansible_collections/cisco/mso/tests/integration/targets/mso_schema/tasks/main.yml b/ansible_collections/cisco/mso/tests/integration/targets/mso_schema/tasks/main.yml index 84613d63a..d7c586b61 100644 --- a/ansible_collections/cisco/mso/tests/integration/targets/mso_schema/tasks/main.yml +++ b/ansible_collections/cisco/mso/tests/integration/targets/mso_schema/tasks/main.yml @@ -1,16 +1,17 @@ # Test code for the MSO modules # Copyright: (c) 2020, Cindy Zhao (@cizhao) <cizhao@cisco.com> +# Copyright: (c) 2023, Akini Ross (@akinross) <akinross@cisco.com> # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI MultiSite host, username and password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: mso_hostname, mso_username and mso_password.' when: mso_hostname is not defined or mso_username is not defined or mso_password is not defined # CLEAN ENVIRONMENT - name: Set vars - set_fact: + ansible.builtin.set_fact: mso_info: &mso_info host: '{{ mso_hostname }}' username: '{{ mso_username }}' @@ -20,6 +21,12 @@ use_proxy: '{{ mso_use_proxy | default(true) }}' output_level: '{{ mso_output_level | default("info") }}' +- name: Query MSO version + cisco.mso.mso_version: + <<: *mso_info + state: query + register: version + - name: Remove schemas cisco.mso.mso_schema: <<: *mso_info @@ -71,7 +78,7 @@ register: query_one - name: Verify query_all and query_one - assert: + ansible.builtin.assert: that: - query_all is not changed - query_one is not changed @@ -94,7 +101,7 @@ register: nm_rm_schema - name: Verify rm_schema - assert: + ansible.builtin.assert: that: - cm_rm_schema is changed - cm_rm_schema.previous.displayName == "ansible_test" @@ -111,7 +118,135 @@ register: query_non_existing - name: Verify query_non_existing - assert: + ansible.builtin.assert: that: - query_non_existing is not changed - query_non_existing.current == {} + +# TEST BLOCK FOR MSO VERSION >= 4.1 WHICH ALLOW FOR SCHEMA WITHOUT TEMPLATES +- name: Execute tasks only for MSO version >= 4.1 + when: version.current.version is version('4.1', '>=') + block: + + - name: Ensure schema without templatess are not present + cisco.mso.mso_schema: + <<: *mso_info + schema: '{{ item }}' + state: absent + loop: + - "ansible_test" + - "ansible_test_2" + + - name: Create a schema without templates (check_mode) + cisco.mso.mso_schema: &ansible_test + <<: *mso_info + schema: ansible_test + description: ansible_test_descr + state: present + check_mode: true + register: cm_create_ansible_test + + - name: Create a schema without templates + cisco.mso.mso_schema: + <<: *ansible_test + register: nm_create_ansible_test + + - name: Create a schema without templates again + cisco.mso.mso_schema: + <<: *ansible_test + register: nm_create_ansible_test_again + + - name: Verify schema without templates creation + ansible.builtin.assert: + that: + - cm_create_ansible_test is changed + - cm_create_ansible_test.current.displayName == 'ansible_test' + - cm_create_ansible_test.current.description == 'ansible_test_descr' + - cm_create_ansible_test.proposed.displayName == 'ansible_test' + - cm_create_ansible_test.proposed.description == 'ansible_test_descr' + - cm_create_ansible_test.previous == {} + - nm_create_ansible_test is changed + - nm_create_ansible_test.current.displayName == 'ansible_test' + - nm_create_ansible_test.current.description == 'ansible_test_descr' + - nm_create_ansible_test.proposed.displayName == 'ansible_test' + - nm_create_ansible_test.proposed.description == 'ansible_test_descr' + # Commented due to description bug in schema where description is set on id specific but not schemas endpoint + # - nm_create_ansible_test_again is not changed + - nm_create_ansible_test_again.current.displayName == 'ansible_test' + - nm_create_ansible_test_again.current.description == 'ansible_test_descr' + - nm_create_ansible_test_again.previous.displayName == 'ansible_test' + # - nm_create_ansible_test_again.previous.description == 'ansible_test_descr' + + - name: Change a schema without templates display name (check_mode) + cisco.mso.mso_schema: &ansible_test_2 + <<: *mso_info + schema: ansible_test_2 + id: "{{ nm_create_ansible_test_again.current.id }}" + description: ansible_test_descr_changed + state: present + check_mode: true + register: cm_change_ansible_test + + - name: Change a schema without templates display name + cisco.mso.mso_schema: + <<: *ansible_test_2 + register: nm_change_ansible_test + + - name: Change a schema without templates display name again + cisco.mso.mso_schema: + <<: *ansible_test_2 + register: nm_change_ansible_test_again + + - name: Verify schema without templates change + ansible.builtin.assert: + that: + - cm_change_ansible_test is changed + - cm_change_ansible_test.current.displayName == 'ansible_test_2' + - cm_change_ansible_test.current.description == 'ansible_test_descr_changed' + - cm_change_ansible_test.proposed.displayName == 'ansible_test_2' + - cm_change_ansible_test.proposed.description == 'ansible_test_descr_changed' + - cm_change_ansible_test.previous.displayName == 'ansible_test' + # - cm_change_ansible_test.previous.description == 'ansible_test_descr' + - nm_change_ansible_test is changed + - nm_change_ansible_test.current.displayName == 'ansible_test_2' + - nm_change_ansible_test.current.description == 'ansible_test_descr_changed' + - nm_change_ansible_test.previous.displayName == 'ansible_test' + # - nm_change_ansible_test.previous.description == 'ansible_test_descr' + - nm_change_ansible_test_again is not changed + - nm_change_ansible_test_again.current.displayName == 'ansible_test_2' + - nm_change_ansible_test_again.current.description == 'ansible_test_descr_changed' + - nm_change_ansible_test_again.previous.displayName == 'ansible_test_2' + # - nm_change_ansible_test_again.previous.description == 'ansible_test_descr_changed' + + - name: Remove a schema without templates (check_mode) + cisco.mso.mso_schema: &ansible_test_remove + <<: *mso_info + schema: ansible_test_2 + state: absent + check_mode: true + register: cm_remove_ansible_test + + - name: Remove a schema without templates + cisco.mso.mso_schema: + <<: *ansible_test_remove + register: nm_remove_ansible_test + + - name: Remove a schema without templates again + cisco.mso.mso_schema: + <<: *ansible_test_remove + register: nm_remove_ansible_test_again + + - name: Verify schema without templates removal + ansible.builtin.assert: + that: + - cm_remove_ansible_test is changed + - cm_remove_ansible_test.current == {} + - cm_remove_ansible_test.previous.displayName == 'ansible_test_2' + # - cm_remove_ansible_test.previous.description == 'ansible_test_descr_changed' + - nm_remove_ansible_test is changed + - nm_remove_ansible_test.current == {} + - nm_remove_ansible_test.previous.displayName == 'ansible_test_2' + # - nm_remove_ansible_test.previous.description == 'ansible_test_descr_changed' + - nm_remove_ansible_test_again is not changed + - nm_remove_ansible_test_again.current == {} + - nm_remove_ansible_test_again.previous == {} diff --git a/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_clone/tasks/main.yml b/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_clone/tasks/main.yml index e26bf45d5..fd6a35e14 100644 --- a/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_clone/tasks/main.yml +++ b/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_clone/tasks/main.yml @@ -4,13 +4,13 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI MultiSite host, username and password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: mso_hostname, mso_username and mso_password.' when: mso_hostname is not defined or mso_username is not defined or mso_password is not defined # CLEAN ENVIRONMENT - name: Set vars - set_fact: + ansible.builtin.set_fact: mso_info: &mso_info host: '{{ mso_hostname }}' username: '{{ mso_username }}' @@ -31,7 +31,7 @@ - Source_Schema - name: Ensure site exists - mso_site: + cisco.mso.mso_site: <<: *mso_info site: '{{ mso_site | default("ansible_test") }}' apic_username: '{{ apic_username }}' @@ -42,7 +42,7 @@ state: present - name: Ensure tenant ansible_test exists - mso_tenant: + cisco.mso.mso_tenant: <<: *mso_info tenant: ansible_test users: @@ -64,7 +64,7 @@ - { template: Template 3} - name: Ensure VRF exist - mso_schema_template_vrf: &vrf_present + cisco.mso.mso_schema_template_vrf: &vrf_present <<: *mso_info schema: Source_Schema template: Template1 @@ -72,7 +72,7 @@ state: present - name: Add bd in Source schema - mso_schema_template_bd: &bd_present + cisco.mso.mso_schema_template_bd: &bd_present <<: *mso_info schema: Source_Schema template: Template1 @@ -90,7 +90,7 @@ register: add_schema - name: Verify add_schema - assert: + ansible.builtin.assert: that: - add_schema is changed - add_schema.previous == {} @@ -106,7 +106,7 @@ register: add_same_schema - name: Verify add_same_schema - assert: + ansible.builtin.assert: that: - add_same_schema is not changed - add_same_schema.current == {} @@ -122,7 +122,7 @@ register: add_existing_schema - name: Verify add_existing_schema - assert: + ansible.builtin.assert: that: - add_existing_schema is not changed - add_existing_schema.msg == "Schema with the name 'Destination_Schema' already exists. Please use another name." @@ -137,7 +137,7 @@ register: add_existing_schema - name: Verify add_existing_schema - assert: + ansible.builtin.assert: that: - add_existing_schema is not changed - add_existing_schema.msg == "Provided schema 'Source_Schema_1' does not exist." @@ -153,6 +153,6 @@ - Source_Schema - name: Verify rm_schema - assert: + ansible.builtin.assert: that: - rm_schema is changed
\ No newline at end of file diff --git a/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site/tasks/main.yml b/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site/tasks/main.yml index 6eede75ae..5e356a0fd 100644 --- a/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site/tasks/main.yml +++ b/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site/tasks/main.yml @@ -4,13 +4,13 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI MultiSite host, username and password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: mso_hostname, mso_username and mso_password.' when: mso_hostname is not defined or mso_username is not defined or mso_password is not defined # CLEAN ENVIRONMENT - name: Set vars - set_fact: + ansible.builtin.set_fact: mso_info: &mso_info host: '{{ mso_hostname }}' username: '{{ mso_username }}' @@ -21,7 +21,7 @@ output_level: '{{ mso_output_level | default("info") }}' - name: Ensure site exists - mso_site: + cisco.mso.mso_site: <<: *mso_info site: '{{ mso_site | default("ansible_test") }}' apic_username: '{{ apic_username }}' @@ -33,7 +33,7 @@ ignore_errors: true - name: Remove schemas - mso_schema: + cisco.mso.mso_schema: <<: *mso_info schema: '{{ item }}' state: absent @@ -42,7 +42,7 @@ - '{{ mso_schema | default("ansible_test") }}' - name: Ensure sites removed from tenant ansible_test - mso_tenant_site: + cisco.mso.mso_tenant_site: <<: *mso_info tenant: ansible_test site: '{{ item }}' @@ -53,7 +53,7 @@ - 'azure_{{ mso_site | default("ansible_test") }}' - name: Ensure tenant ansible_test exists - mso_tenant: + cisco.mso.mso_tenant: <<: *mso_info tenant: ansible_test users: @@ -63,7 +63,7 @@ state: present - name: Ensure schema 1 with Template 1 and Template 2 exists - mso_schema_template: + cisco.mso.mso_schema_template: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' tenant: ansible_test @@ -74,7 +74,7 @@ - { template: Template 2} - name: Add a new site to a schema with Template 1 in check mode - mso_schema_site: + cisco.mso.mso_schema_site: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -84,13 +84,13 @@ register: add_site_cm - name: Verify add_site_cm - assert: + ansible.builtin.assert: that: - add_site_cm.current.siteId is match ("[0-9a-zA-Z]*") - add_site_cm.current.templateName == "Template1" - name: Add a new site to a schema with Template 1 in normal mode - mso_schema_site: + cisco.mso.mso_schema_site: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -99,13 +99,13 @@ register: add_site_nm - name: Verify add_site_nm - assert: + ansible.builtin.assert: that: - add_site_nm.current.siteId is match ("[0-9a-zA-Z]*") - add_site_nm.current.templateName == "Template1" - name: Add a new site to a schema in normal mode again - mso_schema_site: + cisco.mso.mso_schema_site: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -114,13 +114,13 @@ register: add_site_nm_again - name: Verify add_site_nm_again - assert: + ansible.builtin.assert: that: - add_site_nm_again is not changed - add_site_nm_again.current.siteId is match ("[0-9a-zA-Z]*") - name: Add a new site to a schema with Template 2 in normal mode - mso_schema_site: + cisco.mso.mso_schema_site: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -130,7 +130,7 @@ register: add_site_temp2_nm - name: Verify add_site_temp2_nm - assert: + ansible.builtin.assert: that: - add_site_temp2_nm.current.siteId is match ("[0-9a-zA-Z]*") - add_site_temp2_nm.current.templateName == "Template2" @@ -144,7 +144,7 @@ - add_site_temp2_nm.sent.templateName == "Template2" - name: Query a schema site - mso_schema_site: + cisco.mso.mso_schema_site: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -153,21 +153,21 @@ register: query_site - name: Query all schema sites - mso_schema_site: + cisco.mso.mso_schema_site: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' state: query register: query_all_sites - name: Verify query_site and query_all_sites - assert: + ansible.builtin.assert: that: - query_site is not changed - query_all_sites is not changed - query_all_sites.current | length == 2 - name: Remove a site from a schema with Template1 - mso_schema_site: + cisco.mso.mso_schema_site: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -176,7 +176,7 @@ register: rm_site_temp1 - name: Remove a site from a schema with Template2 - mso_schema_site: + cisco.mso.mso_schema_site: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -185,7 +185,7 @@ register: rm_site_temp2 - name: Verify rm_site_temp1 and rm_site_temp2 - assert: + ansible.builtin.assert: that: - rm_site_temp1 is changed - rm_site_temp1.current == {} @@ -193,7 +193,7 @@ - rm_site_temp2.current == {} - name: Remove a site from a schema with Template2 again - mso_schema_site: + cisco.mso.mso_schema_site: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -202,13 +202,13 @@ register: rm_site_again - name: Verify rm_site_again - assert: + ansible.builtin.assert: that: - rm_site_again is not changed # USE NON-EXISTING STATE - name: non_existing_state state - mso_schema_site: + cisco.mso.mso_schema_site: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -218,14 +218,14 @@ register: non_existing_state - name: Verify non_existing_state - assert: + ansible.builtin.assert: that: - non_existing_state is not changed - non_existing_state.msg == "value of state must be one of{{':'}} absent, present, query, got{{':'}} non_existing_state" # USE A NON_EXISTING_SCHEMA - name: non_existing_schema - mso_schema_site: + cisco.mso.mso_schema_site: <<: *mso_info schema: non_existing_schema site: '{{ mso_site | default("ansible_test") }}' @@ -235,14 +235,14 @@ register: non_existing_schema - name: Verify non_existing_schema - assert: + ansible.builtin.assert: that: - non_existing_schema is not changed - non_existing_schema.msg == "Provided schema 'non_existing_schema' does not exist." # USE A NON_EXISTING_TEMPLATE - name: non_existing_template - mso_schema_site: + cisco.mso.mso_schema_site: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -252,13 +252,13 @@ register: non_existing_template - name: Verify non_existing_template - assert: + ansible.builtin.assert: that: - non_existing_template is not changed - non_existing_template.msg == "Template 'non_existing_template' not found" - name: Template attribute absent in task - mso_schema_site: + cisco.mso.mso_schema_site: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -267,7 +267,7 @@ register: absent_template - name: Verify absent_template - assert: + ansible.builtin.assert: that: - absent_template is not changed - absent_template.current == []
\ No newline at end of file diff --git a/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_anp/tasks/main.yml b/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_anp/tasks/main.yml index 9faffb376..03909d8cf 100644 --- a/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_anp/tasks/main.yml +++ b/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_anp/tasks/main.yml @@ -3,13 +3,13 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI MultiSite host, username and password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: mso_hostname, mso_username and mso_password.' when: mso_hostname is not defined or mso_username is not defined or mso_password is not defined # CLEAN ENVIRONMENT - name: Set vars - set_fact: + ansible.builtin.set_fact: mso_info: &mso_info host: '{{ mso_hostname }}' username: '{{ mso_username }}' @@ -20,13 +20,13 @@ output_level: '{{ mso_output_level | default("info") }}' - name: Query MSO version - mso_version: + cisco.mso.mso_version: <<: *mso_info state: query register: version - name: Remove schemas - mso_schema: + cisco.mso.mso_schema: <<: *mso_info schema: '{{ item }}' state: absent @@ -35,7 +35,7 @@ - '{{ mso_schema | default("ansible_test") }}' - name: Ensure physical site exists - mso_site: + cisco.mso.mso_site: <<: *mso_info site: '{{ mso_site | default("ansible_test") }}' apic_username: '{{ apic_username }}' @@ -46,7 +46,7 @@ state: present - name: Ensure aws site exists - mso_site: + cisco.mso.mso_site: <<: *mso_info site: 'aws_{{ mso_site | default("ansible_test") }}' apic_username: '{{ aws_apic_username }}' @@ -57,7 +57,7 @@ state: present - name: Ensure azure site exists - mso_site: + cisco.mso.mso_site: <<: *mso_info site: 'azure_{{ mso_site | default("ansible_test") }}' apic_username: '{{ azure_apic_username }}' @@ -68,7 +68,7 @@ state: present - name: Ensure sites removed from tenant ansible_test - mso_tenant_site: + cisco.mso.mso_tenant_site: <<: *mso_info tenant: ansible_test site: '{{ item }}' @@ -79,7 +79,7 @@ - 'azure_{{ mso_site | default("ansible_test") }}' - name: Ensure tenant ansible_test exists - mso_tenant: + cisco.mso.mso_tenant: <<: *mso_info tenant: ansible_test users: @@ -87,14 +87,14 @@ state: present - name: Associate non-cloud site with ansible_test again in normal mode - mso_tenant_site: + cisco.mso.mso_tenant_site: <<: *mso_info tenant: ansible_test site: '{{ mso_site | default("ansible_test") }}' state: present - name: Associate aws site with ansible_test in normal mode - mso_tenant_site: + cisco.mso.mso_tenant_site: <<: *mso_info tenant: ansible_test site: 'aws_{{ mso_site | default("ansible_test") }}' @@ -106,7 +106,7 @@ register: aaws_nm - name: Associate azure site with access_type not present, with ansible_test in normal mode - mso_tenant_site: + cisco.mso.mso_tenant_site: <<: *mso_info tenant: ansible_test site: 'azure_{{ mso_site | default("ansible_test") }}' @@ -115,7 +115,7 @@ register: aazure_shared_nm - name: Ensure schema 1 with Template 1, and Template 2 exist - mso_schema_template: + cisco.mso.mso_schema_template: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' tenant: ansible_test @@ -127,7 +127,7 @@ - { template: Template 3} - name: Ensure schema 2 with Template 4 exist - mso_schema_template: + cisco.mso.mso_schema_template: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}_2' tenant: ansible_test @@ -135,7 +135,7 @@ state: present - name: Add cloud site to a schema - mso_schema_site: + cisco.mso.mso_schema_site: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{item.site}}' @@ -146,7 +146,7 @@ - { site: 'aws_{{ mso_site | default("ansible_test") }}', template: 'Template 2' } - name: Add physical site to a schema - mso_schema_site: + cisco.mso.mso_schema_site: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -154,7 +154,7 @@ state: present - name: Ensure VRF1 exists - mso_schema_template_vrf: + cisco.mso.mso_schema_template_vrf: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 3 @@ -162,7 +162,7 @@ state: present - name: Add BD1 - mso_schema_template_bd: + cisco.mso.mso_schema_template_bd: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 3 @@ -172,7 +172,7 @@ state: present - name: Ensure ANPs exist at template level - mso_schema_template_anp: + cisco.mso.mso_schema_template_anp: <<: *mso_info schema: '{{item.schema}}' template: '{{ item.template }}' @@ -187,7 +187,7 @@ - { schema: '{{ mso_schema | default("ansible_test") }}_2', template: 'Template 4', anp: 'ANP_4' } - name: Ensure EPGs exist at template level - mso_schema_template_anp_epg: + cisco.mso.mso_schema_template_anp_epg: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 3 @@ -204,7 +204,7 @@ state: present - name: Add ANP to site azure (check_mode) - mso_schema_site_anp: + cisco.mso.mso_schema_site_anp: <<: *mso_info site: 'azure_{{ mso_site | default("ansible_test") }}' schema: '{{ mso_schema | default("ansible_test") }}' @@ -215,7 +215,7 @@ register: cm_add_anp - name: Add ANP to site azure (normal mode) - mso_schema_site_anp: + cisco.mso.mso_schema_site_anp: <<: *mso_info site: 'azure_{{ mso_site | default("ansible_test") }}' schema: '{{ mso_schema | default("ansible_test") }}' @@ -225,20 +225,20 @@ register: nm_add_anp - name: Verify add_anp values - assert: + ansible.builtin.assert: that: - cm_add_anp.current.anpRef.anpName == 'ANP' - nm_add_anp.current.anpRef.anpName == 'ANP' - name: Verify add_anp change - assert: + ansible.builtin.assert: that: - cm_add_anp is changed - nm_add_anp is changed when: version.current.version is version('4.0', '<') # no change in NDO4.0 because site will already be present when template is defined - name: Add ANP to site aws - mso_schema_site_anp: + cisco.mso.mso_schema_site_anp: <<: *mso_info site: 'aws_{{ mso_site | default("ansible_test") }}' schema: '{{ mso_schema | default("ansible_test") }}' @@ -248,18 +248,18 @@ register: add_anp - name: Verify add_anp value - assert: + ansible.builtin.assert: that: - add_anp.current.anpRef.anpName == 'ANP_2' - name: Verify add_anp change - assert: + ansible.builtin.assert: that: - add_anp is changed when: version.current.version is version('4.0', '<') # no change in NDO4.0 because site will already be present when template is defined - name: Add ANPs to site - mso_schema_site_anp: + cisco.mso.mso_schema_site_anp: <<: *mso_info site: '{{ item.site }}' schema: '{{ item.schema }}' @@ -272,7 +272,7 @@ - { site: '{{ mso_site | default("ansible_test") }}', schema: '{{ mso_schema | default("ansible_test") }}', template: 'Template 3', anp: 'ANP_3_2' } - name: Add a new site EPG for idempotency check - mso_schema_site_anp_epg: &idempotency_vmm + cisco.mso.mso_schema_site_anp_epg: &idempotency_vmm <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: 'Template 3' @@ -284,7 +284,7 @@ # Test due to inconsistency in attributes REQUEST/RESPONSE API # MSO Error 400: Bad Request: (0)(0)(0)(0)/deploymentImmediacy error.path.missing - name: Add new site domain to site EPG for idempotency check - mso_schema_site_anp_epg_domain: + cisco.mso.mso_schema_site_anp_epg_domain: <<: *idempotency_vmm domain_association_type: vmmDomain domain_profile: 'VMware-VMM' @@ -293,7 +293,7 @@ state: present - name: Add ANPs to site again - mso_schema_site_anp: + cisco.mso.mso_schema_site_anp: <<: *mso_info site: '{{ mso_site | default("ansible_test") }}' schema: '{{ mso_schema | default("ansible_test") }}' @@ -303,14 +303,14 @@ register: add_anp_again - name: Verify add_anp_again - assert: + ansible.builtin.assert: that: - add_anp_again is not changed - add_anp_again.current.anpRef.anpName == 'ANP_3' # QUERY ANPs - name: Query specific ANP (normal mode) - mso_schema_site_anp: + cisco.mso.mso_schema_site_anp: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -320,12 +320,12 @@ register: query_anp - name: Verify query_anp - assert: + ansible.builtin.assert: that: - query_anp is not changed - name: Query all ANPs (normal mode) - mso_schema_site_anp: + cisco.mso.mso_schema_site_anp: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -334,14 +334,14 @@ register: query_all - name: Verify query_all - assert: + ansible.builtin.assert: that: - query_all is not changed - query_all | length >= 3 # DELETE the ANP - name: Delete ANP3 (normal mode) - mso_schema_site_anp: + cisco.mso.mso_schema_site_anp: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -351,13 +351,13 @@ register: delete_anp - name: Verify delete_anp - assert: + ansible.builtin.assert: that: - delete_anp is changed - delete_anp.current == {} - name: Delete ANP1 again - mso_schema_site_anp: + cisco.mso.mso_schema_site_anp: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -367,14 +367,14 @@ register: delete_anp_again - name: Verify delete_anp_again - assert: + ansible.builtin.assert: that: - delete_anp_again is not changed - delete_anp_again.current == {} # QUERY NON-EXISTING ANP - name: Query non-existing ANP (normal mode) - mso_schema_site_anp: + cisco.mso.mso_schema_site_anp: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -385,14 +385,14 @@ register: nm_query_non_anp - name: Verify query_non_anp - assert: + ansible.builtin.assert: that: - nm_query_non_anp is not changed - nm_query_non_anp.msg == "ANP 'non_existing_anp' not found" # USE A NON-EXISTING STATE - name: Non-existing state (normal_mode) - mso_schema_site_anp: + cisco.mso.mso_schema_site_anp: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: 'aws_{{ mso_site | default("ansible_test") }}' @@ -403,14 +403,14 @@ register: nm_non_existing_state - name: Verify non_existing_state - assert: + ansible.builtin.assert: that: - nm_non_existing_state is not changed - nm_non_existing_state.msg == "value of state must be one of{{':'}} absent, present, query, got{{':'}} non-existing-state" # USE A NON-EXISTING SCHEMA - name: Non-existing schema (normal_mode) - mso_schema_site_anp: + cisco.mso.mso_schema_site_anp: <<: *mso_info schema: non-existing-schema site: 'aws_{{ mso_site | default("ansible_test") }}' @@ -421,14 +421,14 @@ register: nm_non_existing_schema - name: Verify non_existing_schema - assert: + ansible.builtin.assert: that: - nm_non_existing_schema is not changed - nm_non_existing_schema.msg == "Provided schema 'non-existing-schema' does not exist." # USE A NON-EXISTING SITE - name: Non-existing site (normal_mode) - mso_schema_site_anp: + cisco.mso.mso_schema_site_anp: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: non-existing-site @@ -439,14 +439,14 @@ register: nm_non_existing_site - name: Verify non_existing_site - assert: + ansible.builtin.assert: that: - nm_non_existing_site is not changed - nm_non_existing_site.msg == "Site 'non-existing-site' is not a valid site name." # USE A TEMPLATE WITHOUT ANY SITE - name: Add ANP to Template without any site associated (normal mode) - mso_schema_site_anp: + cisco.mso.mso_schema_site_anp: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}_2' site: 'azure_{{ mso_site | default("ansible_test") }}' @@ -457,14 +457,14 @@ register: nm_no_site_associated - name: Verify cm_no_site_associated and nm_no_site_associated - assert: + ansible.builtin.assert: that: - nm_no_site_associated is not changed - nm_no_site_associated.msg == "No site associated with template 'Template4'. Associate the site with the template using mso_schema_site." # USE A NON-EXISTING SITE-TEMPLATE - name: Non-existing site-template (normal_mode) - mso_schema_site_anp: + cisco.mso.mso_schema_site_anp: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -475,7 +475,7 @@ register: nm_non_existing_site_template - name: Verify non_existing_site_template - assert: + ansible.builtin.assert: that: - nm_non_existing_site_template is not changed - nm_non_existing_site_template.msg is match("Provided site/siteId/template 'ansible_test/[0-9a-zA-Z]*/Template2' does not exist. Existing siteIds/templates{{':'}} [0-9a-zA-Z]*/Template1, [0-9a-zA-Z]*/Template2, [0-9a-zA-Z]*/Template3")
\ No newline at end of file diff --git a/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_anp_epg/tasks/main.yml b/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_anp_epg/tasks/main.yml index 8373a629f..28e836a55 100644 --- a/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_anp_epg/tasks/main.yml +++ b/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_anp_epg/tasks/main.yml @@ -3,13 +3,13 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI MultiSite host, username and password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: mso_hostname, mso_username and mso_password.' when: mso_hostname is not defined or mso_username is not defined or mso_password is not defined # CLEAN ENVIRONMENT - name: Set vars - set_fact: + ansible.builtin.set_fact: mso_info: &mso_info host: '{{ mso_hostname }}' username: '{{ mso_username }}' @@ -20,13 +20,13 @@ output_level: '{{ mso_output_level | default("info") }}' - name: Query MSO version - mso_version: + cisco.mso.mso_version: <<: *mso_info state: query register: version - name: Remove schemas - mso_schema: + cisco.mso.mso_schema: <<: *mso_info schema: '{{ item }}' state: absent @@ -35,7 +35,7 @@ - '{{ mso_schema | default("ansible_test") }}' - name: Ensure site exists - mso_site: + cisco.mso.mso_site: <<: *mso_info site: '{{ mso_site | default("ansible_test") }}' apic_username: '{{ apic_username }}' @@ -47,7 +47,7 @@ ignore_errors: true - name: Ensure tenant ansible_test exists - mso_tenant: + cisco.mso.mso_tenant: <<: *mso_info tenant: ansible_test users: @@ -55,7 +55,7 @@ state: present - name: Ensure sites removed from tenant ansible_test - mso_tenant_site: + cisco.mso.mso_tenant_site: <<: *mso_info tenant: ansible_test site: '{{ item }}' @@ -66,14 +66,14 @@ - 'azure_{{ mso_site | default("ansible_test") }}' - name: Associate non-cloud site with ansible_test again in normal mode - mso_tenant_site: + cisco.mso.mso_tenant_site: <<: *mso_info tenant: ansible_test site: '{{ mso_site | default("ansible_test") }}' state: present - name: Associate aws site with ansible_test in normal mode - mso_tenant_site: + cisco.mso.mso_tenant_site: <<: *mso_info tenant: ansible_test site: 'aws_{{ mso_site | default("ansible_test") }}' @@ -85,7 +85,7 @@ register: aaws_nm - name: Associate azure site with access_type not present, with ansible_test in normal mode - mso_tenant_site: + cisco.mso.mso_tenant_site: <<: *mso_info tenant: ansible_test site: 'azure_{{ mso_site | default("ansible_test") }}' @@ -94,7 +94,7 @@ register: aazure_shared_nm - name: Ensure schema 1 with Template 1, and Template 2 exist - mso_schema_template: + cisco.mso.mso_schema_template: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' tenant: ansible_test @@ -106,7 +106,7 @@ - { template: Template 3} - name: Ensure schema 2 with Template 4 exist - mso_schema_template: + cisco.mso.mso_schema_template: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}_2' tenant: ansible_test @@ -114,7 +114,7 @@ state: present - name: Add cloud site to a schema - mso_schema_site: + cisco.mso.mso_schema_site: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{item.site}}' @@ -126,7 +126,7 @@ when: version.current.version is version('3', '<') or version.current.version is version('3.2', '>=') - name: Add physical site to a schema - mso_schema_site: + cisco.mso.mso_schema_site: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -137,7 +137,7 @@ - { template: 'Template 1' } - name: Ensure VRF1 exists - mso_schema_template_vrf: + cisco.mso.mso_schema_template_vrf: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: '{{ item.template }}' @@ -148,7 +148,7 @@ - { template: 'Template 3' } - name: Add BD1 - mso_schema_template_bd: + cisco.mso.mso_schema_template_bd: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: '{{ item.template }}' @@ -161,7 +161,7 @@ - { template: 'Template 3' } - name: Ensure ANPs exist at template level - mso_schema_template_anp: + cisco.mso.mso_schema_template_anp: <<: *mso_info schema: '{{item.schema}}' template: '{{ item.template }}' @@ -173,7 +173,7 @@ - { schema: '{{ mso_schema | default("ansible_test") }}_2', template: 'Template 4', anp: 'ANP_4' } - name: Ensure ANP exist at template level - mso_schema_template_anp: + cisco.mso.mso_schema_template_anp: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 3 @@ -181,7 +181,7 @@ state: present - name: Ensure EPGs exist at template level - mso_schema_template_anp_epg: + cisco.mso.mso_schema_template_anp_epg: <<: *mso_info schema: '{{ item.schema }}' template: '{{ item.template }}' @@ -202,7 +202,7 @@ - { schema: '{{ mso_schema | default("ansible_test") }}_2', template: 'Template 4', anp: 'ANP_4', epg: 'ansible_test_4' } - name: Ensure EPGs exist at template level - mso_schema_template_anp_epg: + cisco.mso.mso_schema_template_anp_epg: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 3 @@ -219,7 +219,7 @@ state: present - name: Add ANP to site - mso_schema_site_anp: + cisco.mso.mso_schema_site_anp: <<: *mso_info site: '{{ mso_site | default("ansible_test") }}' schema: '{{ mso_schema | default("ansible_test") }}' @@ -229,7 +229,7 @@ # ADD ANP EPGs to SITE - name: Add new EPG to site after adding ANP to site (check_mode) - mso_schema_site_anp_epg: + cisco.mso.mso_schema_site_anp_epg: <<: *mso_info site: '{{ mso_site | default("ansible_test") }}' schema: '{{ mso_schema | default("ansible_test") }}' @@ -241,7 +241,7 @@ register: cm_add_epg - name: Add new EPG to site after adding ANP to site (normal mode) - mso_schema_site_anp_epg: + cisco.mso.mso_schema_site_anp_epg: <<: *mso_info site: '{{ mso_site | default("ansible_test") }}' schema: '{{ mso_schema | default("ansible_test") }}' @@ -252,7 +252,7 @@ register: nm_add_epg - name: Verify add_epg - assert: + ansible.builtin.assert: that: - cm_add_epg is changed - nm_add_epg is changed @@ -263,7 +263,7 @@ when: version.current.version is version('4.0', '<') # no change in NDO4.0 because site will already be present when template is defined - name: Add new EPG to site after adding ANP to site again - mso_schema_site_anp_epg: &idempotency_vmm + cisco.mso.mso_schema_site_anp_epg: &idempotency_vmm <<: *mso_info site: '{{ mso_site | default("ansible_test") }}' schema: '{{ mso_schema | default("ansible_test") }}' @@ -274,7 +274,7 @@ register: add_epg_again - name: Verify add_epg_again - assert: + ansible.builtin.assert: that: - add_epg_again is not changed - add_epg_again.current.epgRef.anpName == 'ANP_3' @@ -283,7 +283,7 @@ # Test due to inconsistency in attributes REQUEST/RESPONSE API # MSO Error 400: Bad Request: (0)(0)(0)(0)/deploymentImmediacy error.path.missing - name: Add new site domain to site EPG for idempotency check - mso_schema_site_anp_epg_domain: + cisco.mso.mso_schema_site_anp_epg_domain: <<: *idempotency_vmm domain_association_type: vmmDomain domain_profile: 'VMware-VMM' @@ -292,19 +292,19 @@ state: present - name: Add new EPG to site after adding ANP to site again - mso_schema_site_anp_epg: + cisco.mso.mso_schema_site_anp_epg: <<: *idempotency_vmm register: add_epg_again_with_vmm - name: Verify add_epg_again with vmm - assert: + ansible.builtin.assert: that: - add_epg_again is not changed - add_epg_again.current.epgRef.anpName == 'ANP_3' - add_epg_again.current.epgRef.epgName == 'ansible_test_3' - name: Add new EPG to site without adding ANPs to site - mso_schema_site_anp_epg: + cisco.mso.mso_schema_site_anp_epg: <<: *mso_info site: '{{ mso_site | default("ansible_test") }}' schema: '{{ mso_schema | default("ansible_test") }}' @@ -315,7 +315,7 @@ register: add_epg_no_anp - name: Verify add_epg_no_anp - assert: + ansible.builtin.assert: that: - add_epg_no_anp is changed - add_epg_no_anp.current.epgs.0.epgRef.anpName == 'ANP' @@ -323,7 +323,7 @@ when: version.current.version is version('4.0', '<') # no change in NDO4.0 because site will already be present when template is defined - name: Add new EPG to site without adding ANPs to site again (ANP already exists from previous run) - mso_schema_site_anp_epg: + cisco.mso.mso_schema_site_anp_epg: <<: *mso_info site: '{{ mso_site | default("ansible_test") }}' schema: '{{ mso_schema | default("ansible_test") }}' @@ -334,7 +334,7 @@ register: add_epg_no_anp_again - name: Verify add_epg_no_anp_again - assert: + ansible.builtin.assert: that: - add_epg_no_anp_again is not changed - add_epg_no_anp_again.current.epgRef.anpName == 'ANP' @@ -342,7 +342,7 @@ # QUERY EPGs - name: Query all EPGs with ANP (normal mode) - mso_schema_site_anp_epg: + cisco.mso.mso_schema_site_anp_epg: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -352,12 +352,12 @@ register: query_all - name: Verify query_all - assert: + ansible.builtin.assert: that: - query_all is not changed - name: Query specific EPG1 (normal mode) - mso_schema_site_anp_epg: + cisco.mso.mso_schema_site_anp_epg: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -368,13 +368,13 @@ register: query_epg - name: Verify query_epg - assert: + ansible.builtin.assert: that: - query_epg is not changed # DELETE the EPG - name: Delete EPG1 (normal mode) - mso_schema_site_anp_epg: + cisco.mso.mso_schema_site_anp_epg: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -385,14 +385,14 @@ register: delete_epg - name: Verify delete_epg - assert: + ansible.builtin.assert: that: - delete_epg is changed - delete_epg.current == {} when: version.current.version is version('4.0', '<') # no change in NDO4.0 because site will already be present when template is defined - name: Delete EPG1 again - mso_schema_site_anp_epg: + cisco.mso.mso_schema_site_anp_epg: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -403,14 +403,14 @@ register: delete_epg_again - name: Verify delete_epg_again - assert: + ansible.builtin.assert: that: - delete_epg_again is not changed - delete_epg_again.current == {} # QUERY NON-EXISTING EPG - name: Query non-existing EPG in template (normal mode) - mso_schema_site_anp_epg: + cisco.mso.mso_schema_site_anp_epg: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -422,14 +422,14 @@ register: nm_query_non_epg - name: Verify query_non_epg - assert: + ansible.builtin.assert: that: - nm_query_non_epg is not changed - nm_query_non_epg.msg == "Provided EPG 'non_existing_epg' does not exist. Existing EPGs{{':'}} ansible_test_3" # QUERY NON-EXISTING EPG - name: Query non-existing EPG in site level - mso_schema_site_anp_epg: + cisco.mso.mso_schema_site_anp_epg: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -441,14 +441,14 @@ register: query_non_epg - name: Verify query_non_epg - assert: + ansible.builtin.assert: that: - query_non_epg is not changed - query_non_epg.msg == "EPG 'ansible_test_1' not found" when: version.current.version is version('4.0', '<') # no change in NDO4.0 because site will already be present when template is defined - name: Delete anp - mso_schema_site_anp: + cisco.mso.mso_schema_site_anp: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -458,7 +458,7 @@ # QUERY NON-EXISTING ANP - name: Query non-existing ANP in template(normal mode) - mso_schema_site_anp_epg: + cisco.mso.mso_schema_site_anp_epg: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -470,14 +470,14 @@ register: nm_query_non_anp - name: Verify query_non_anp - assert: + ansible.builtin.assert: that: - nm_query_non_anp is not changed - nm_query_non_anp.msg == "Provided anp 'non_existing_anp' does not exist. Existing anps{{':'}} ANP_3" # QUERY NON-EXISTING ANP - name: Query non-existing ANP at site level(normal mode) - mso_schema_site_anp_epg: + cisco.mso.mso_schema_site_anp_epg: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 3 @@ -488,7 +488,7 @@ register: nm_query_non_anp - name: Verify query_non_anp - assert: + ansible.builtin.assert: that: - nm_query_non_anp is not changed - nm_query_non_anp.msg == "Provided anp 'ANP_3' does not exist at site level." @@ -496,7 +496,7 @@ # USE A NON-EXISTING STATE - name: Non-existing state (normal_mode) - mso_schema_site_anp_epg: + cisco.mso.mso_schema_site_anp_epg: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: 'aws_{{ mso_site | default("ansible_test") }}' @@ -508,14 +508,14 @@ register: nm_non_existing_state - name: Verify non_existing_state - assert: + ansible.builtin.assert: that: - nm_non_existing_state is not changed - nm_non_existing_state.msg == "value of state must be one of{{':'}} absent, present, query, got{{':'}} non-existing-state" # # USE A NON-EXISTING TEMPLATE - name: Non-existing template (normal_mode) - mso_schema_site_anp_epg: + cisco.mso.mso_schema_site_anp_epg: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: 'aws_{{ mso_site | default("ansible_test") }}' @@ -527,14 +527,14 @@ register: nm_non_existing_template - name: Verify non_existing_template - assert: + ansible.builtin.assert: that: - nm_non_existing_template is not changed - nm_non_existing_template.msg == "Provided template 'non-existing-template' does not exist. Existing templates{{':'}} Template1, Template2, Template3" # USE A NON-EXISTING SCHEMA - name: Non-existing schema (normal_mode) - mso_schema_site_anp_epg: + cisco.mso.mso_schema_site_anp_epg: <<: *mso_info schema: non-existing-schema site: 'aws_{{ mso_site | default("ansible_test") }}' @@ -546,14 +546,14 @@ register: nm_non_existing_schema - name: Verify non_existing_schema - assert: + ansible.builtin.assert: that: - nm_non_existing_schema is not changed - nm_non_existing_schema.msg == "Provided schema 'non-existing-schema' does not exist." # USE A NON-EXISTING SITE - name: Non-existing site (normal_mode) - mso_schema_site_anp_epg: + cisco.mso.mso_schema_site_anp_epg: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: non-existing-site @@ -565,14 +565,14 @@ register: nm_non_existing_site - name: Verify non_existing_site - assert: + ansible.builtin.assert: that: - nm_non_existing_site is not changed - nm_non_existing_site.msg == "Site 'non-existing-site' is not a valid site name." # USE A NON-EXISTING SITE-TEMPLATE - name: Non-existing site-template (normal_mode) - mso_schema_site_anp_epg: + cisco.mso.mso_schema_site_anp_epg: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -584,14 +584,14 @@ register: nm_non_existing_site_template - name: Verify non_existing_site_template - assert: + ansible.builtin.assert: that: - nm_non_existing_site_template is not changed - nm_non_existing_site_template.msg is match("Provided site/siteId/template 'ansible_test/[0-9a-zA-Z]*/Template2' does not exist. Existing siteIds/templates{{':'}} [0-9a-zA-Z]*/Template1, [0-9a-zA-Z]*/Template2, [0-9a-zA-Z]*/Template3, [0-9a-zA-Z]*/Template1") when: version.current.version is version('3', '<') or version.current.version is version('3.2', '>=') - name: Verify non_existing_site_template - assert: + ansible.builtin.assert: that: - nm_non_existing_site_template is not changed - nm_non_existing_site_template.msg is match("Provided site/siteId/template 'ansible_test/[0-9a-zA-Z]*/Template2' does not exist. Existing siteIds/templates{{':'}} [0-9a-zA-Z]*/Template3, [0-9a-zA-Z]*/Template1") @@ -599,7 +599,7 @@ # USE A TEMPLATE WITHOUT ANY SITE - name: Add EPG to Template without any site associated (normal mode) - mso_schema_site_anp_epg: + cisco.mso.mso_schema_site_anp_epg: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}_2' site: 'azure_{{ mso_site | default("ansible_test") }}' @@ -611,7 +611,7 @@ register: nm_no_site_associated - name: Verify cm_no_site_associated and nm_no_site_associated - assert: + ansible.builtin.assert: that: - nm_no_site_associated is not changed - nm_no_site_associated.msg == "No site associated with template 'Template4'. Associate the site with the template using mso_schema_site." @@ -622,7 +622,7 @@ when: version.current.version is version('3.3', '>=') block: - name: Remove physical site from schema - mso_schema_site: + cisco.mso.mso_schema_site: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -630,7 +630,7 @@ state: absent - name: Ensure region for VRF1 at site level exists - mso_schema_site_vrf_region_cidr: + cisco.mso.mso_schema_site_vrf_region_cidr: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -641,7 +641,7 @@ state: present - name: Ensure Private Link Label in Azure VRF subnet exist (MSO >3.3) - mso_schema_site_vrf_region_cidr_subnet: + cisco.mso.mso_schema_site_vrf_region_cidr_subnet: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -654,7 +654,7 @@ zone: null - name: Ensure another Private Link Label in Azure VRF subnet exist (MSO >3.3) - mso_schema_site_vrf_region_cidr_subnet: + cisco.mso.mso_schema_site_vrf_region_cidr_subnet: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -666,7 +666,7 @@ private_link_label: 'PLL' - name: Add new EPG service type parameters (for version greater than 3.3) - mso_schema_template_anp_epg: + cisco.mso.mso_schema_template_anp_epg: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -683,7 +683,7 @@ state: present - name: Add private link label to the EPG (for version greater than 3.3) - mso_schema_site_anp_epg: + cisco.mso.mso_schema_site_anp_epg: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -694,7 +694,7 @@ state: present - name: Change private link label in the EPG (for version greater than 3.3) - mso_schema_site_anp_epg: + cisco.mso.mso_schema_site_anp_epg: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 diff --git a/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_anp_epg_bulk_staticport/tasks/main.yml b/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_anp_epg_bulk_staticport/tasks/main.yml index 0fc8943fd..2940874aa 100644 --- a/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_anp_epg_bulk_staticport/tasks/main.yml +++ b/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_anp_epg_bulk_staticport/tasks/main.yml @@ -4,13 +4,13 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI MultiSite host, username and password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: mso_hostname, mso_username and mso_password.' when: mso_hostname is not defined or mso_username is not defined or mso_password is not defined # CLEAN ENVIRONMENT - name: Set vars - set_fact: + ansible.builtin.set_fact: mso_info: &mso_info host: '{{ mso_hostname }}' username: '{{ mso_username }}' @@ -21,7 +21,7 @@ output_level: '{{ mso_output_level | default("debug") }}' - name: Remove Schemas - mso_schema: + cisco.mso.mso_schema: <<: *mso_info schema: '{{ item }}' state: absent @@ -30,7 +30,7 @@ - '{{ mso_schema | default("ansible_test") }}' - name: Ensure site exists - mso_site: + cisco.mso.mso_site: <<: *mso_info site: '{{ mso_site | default("ansible_test") }}' apic_username: '{{ apic_username }}' @@ -41,7 +41,7 @@ state: present - name: Ensure sites removed from tenant ansible_test - mso_tenant_site: + cisco.mso.mso_tenant_site: <<: *mso_info tenant: ansible_test site: '{{ item }}' @@ -52,7 +52,7 @@ - 'azure_{{ mso_site | default("ansible_test") }}' - name: Ensure tenant ansible_test exist - mso_tenant: + cisco.mso.mso_tenant: <<: *mso_info tenant: ansible_test users: @@ -62,7 +62,7 @@ state: present - name: Ensure schema 1 with Template 1 and 2 exists - mso_schema_template: + cisco.mso.mso_schema_template: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' tenant: ansible_test @@ -73,7 +73,7 @@ - Template 2 - name: Ensure schema 2 with Template 3 exists - mso_schema_template: + cisco.mso.mso_schema_template: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}_2' tenant: ansible_test @@ -81,7 +81,7 @@ state: present - name: Add a new site to a schema - mso_schema_site: + cisco.mso.mso_schema_site: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -89,7 +89,7 @@ state: present - name: Ensure VRF1 exists - mso_schema_template_vrf: + cisco.mso.mso_schema_template_vrf: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -97,7 +97,7 @@ state: present - name: Add BD1 - mso_schema_template_bd: + cisco.mso.mso_schema_template_bd: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -107,7 +107,7 @@ state: present - name: Ensure Template 1 with AP1 exists - mso_schema_template_anp: + cisco.mso.mso_schema_template_anp: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -115,7 +115,7 @@ state: present - name: Ensure Template 1 and AP1 with EPG1 exists - mso_schema_template_anp_epg: + cisco.mso.mso_schema_template_anp_epg: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -128,7 +128,7 @@ state: present - name: Ensure Template 1 and AP1 with EPG3 exists - mso_schema_template_anp_epg: + cisco.mso.mso_schema_template_anp_epg: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -141,7 +141,7 @@ state: present - name: Ensure Template 1 with AP2 exists - mso_schema_template_anp: + cisco.mso.mso_schema_template_anp: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -149,7 +149,7 @@ state: present - name: Ensure Template 1 and AP2 with EPG2 exists - mso_schema_template_anp_epg: + cisco.mso.mso_schema_template_anp_epg: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -162,7 +162,7 @@ state: present - name: Ensure Template 1 and AP2 with EPG4 exists - mso_schema_template_anp_epg: + cisco.mso.mso_schema_template_anp_epg: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -175,7 +175,7 @@ state: present - name: Ensure Template 1 and AP2 with EPG6 exists - mso_schema_template_anp_epg: + cisco.mso.mso_schema_template_anp_epg: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -189,7 +189,7 @@ # ADD STATIC PORTS - name: Add static port 1 to site EPG1 of AP1 (check mode) - mso_schema_site_anp_epg_bulk_staticport: + cisco.mso.mso_schema_site_anp_epg_bulk_staticport: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -216,7 +216,7 @@ register: cm_add_stat1e1 - name: Verify cm_add_stat1e1 - assert: + ansible.builtin.assert: that: - cm_add_stat1e1 is changed - cm_add_stat1e1.previous == [] @@ -235,7 +235,7 @@ - cm_add_stat1e1.current|length == 3 - name: Add static port 1 to site EPG1 of AP1 (normal mode) - mso_schema_site_anp_epg_bulk_staticport: &add_static_port_1 + cisco.mso.mso_schema_site_anp_epg_bulk_staticport: &add_static_port_1 <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -261,7 +261,7 @@ register: nm_add_stat1e1 - name: Verify nm_add_stat1e1 - assert: + ansible.builtin.assert: that: - nm_add_stat1e1 is changed - nm_add_stat1e1.previous == [] @@ -280,7 +280,7 @@ - nm_add_stat1e1.current|length ==3 - name: Add static port 3 (vpc) to site EPG1 of AP1 (normal mode) - mso_schema_site_anp_epg_bulk_staticport: + cisco.mso.mso_schema_site_anp_epg_bulk_staticport: <<: *add_static_port_1 static_ports: - path: eth1/2 @@ -298,7 +298,7 @@ register: nm_add_stat3e1 - name: Verify nm_add_stat3e1 - assert: + ansible.builtin.assert: that: - nm_add_stat3e1 is changed - nm_add_stat3e1.previous != [] @@ -310,7 +310,7 @@ - nm_add_stat3e1.current|length > nm_add_stat1e1.current|length # verifying length of current task (nm_add_stat3e1) is greater than the previous task (nm_add_stat1e1) - name: Add static port 2 (dpc) to EPG6 of AP2 (normal mode) - mso_schema_site_anp_epg_bulk_staticport: + cisco.mso.mso_schema_site_anp_epg_bulk_staticport: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -334,7 +334,7 @@ register: nm_add_stat2e6 - name: Verify nm_add_stat2e6 - assert: + ansible.builtin.assert: that: - nm_add_stat2e6 is changed - nm_add_stat2e6.previous == [] @@ -346,7 +346,7 @@ - nm_add_stat2e6.current[0].type == 'dpc' - name: Add static port 2 to site EPG2 (normal mode) - mso_schema_site_anp_epg_bulk_staticport: &static_port_2 + cisco.mso.mso_schema_site_anp_epg_bulk_staticport: &static_port_2 <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -368,7 +368,7 @@ register: nm_add_stat2e2 - name: Verify nm_add_stat2e2 - assert: + ansible.builtin.assert: that: - nm_add_stat2e2 is changed - nm_add_stat2e2.previous == [] @@ -380,19 +380,19 @@ # ADD EXISTING STATIC PORT - name: Add static port 1 to site EPG1 again (normal mode) - mso_schema_site_anp_epg_bulk_staticport: + cisco.mso.mso_schema_site_anp_epg_bulk_staticport: <<: *static_port_2 state: present register: nm_add_stat1e1_2 - name: Verify nm_add_stat1e1_2 - assert: + ansible.builtin.assert: that: - nm_add_stat1e1_2 is not changed # ADD STATIC FEX PORT - name: Add static fex port to site EPG1 with AP1 (normal mode) - mso_schema_site_anp_epg_bulk_staticport: + cisco.mso.mso_schema_site_anp_epg_bulk_staticport: <<: *static_port_2 static_ports: - path: eth1/2 @@ -407,7 +407,7 @@ register: nm_add_statfex - name: Verify nm_add_statfex - assert: + ansible.builtin.assert: that: - nm_add_statfex is changed - nm_add_statfex.previous != [] @@ -419,7 +419,7 @@ # QUERY STATIC PORTS - name: Query STATIC PORTS of site EPG1 with AP1 (normal mode) - mso_schema_site_anp_epg_bulk_staticport: + cisco.mso.mso_schema_site_anp_epg_bulk_staticport: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -430,37 +430,37 @@ register: nm_query_statse1 - name: Verify nm_query_statse1 - assert: + ansible.builtin.assert: that: - nm_query_statse1 is not changed #REMOVE STATIC PORT - name: Remove all static ports from EPG2 (normal mode) - mso_schema_site_anp_epg_bulk_staticport: + cisco.mso.mso_schema_site_anp_epg_bulk_staticport: <<: *static_port_2 state: absent register: nm_remove_stat2e2 - name: Verify nm_remove_stat2e2 - assert: + ansible.builtin.assert: that: - nm_remove_stat2e2 is changed - name: Remove all static ports from EPG2 again(normal mode) - mso_schema_site_anp_epg_bulk_staticport: + cisco.mso.mso_schema_site_anp_epg_bulk_staticport: <<: *static_port_2 state: absent ignore_errors: true register: nm_remove_again_stat2e2 - name: Verify nm_remove_again_stat2e2 - assert: + ansible.builtin.assert: that: - nm_remove_again_stat2e2 is not changed # VERIFY NON EXISTENT 'DEPLOYMENT IMMEDIACY', 'TYPE' AND 'MODE' - name: Add static port 1 to site EPG4 with AP2 with no deployment immediacy, type and mode (normal mode) - mso_schema_site_anp_epg_bulk_staticport: &add_static_port + cisco.mso.mso_schema_site_anp_epg_bulk_staticport: &add_static_port <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -478,7 +478,7 @@ register: nm_add_stat_no_di_type_mode - name: Verify nm_add_stat_no_di_type_mode - assert: + ansible.builtin.assert: that: - nm_add_stat_no_di_type_mode.current[0].deploymentImmediacy == 'lazy' - nm_add_stat_no_di_type_mode.current[0].mode == 'untagged' @@ -486,7 +486,7 @@ # VERIFY NON EXISTENT parent values. - name: Add static port 1 to site EPG4 with AP2 with no parent values (normal mode) - mso_schema_site_anp_epg_bulk_staticport: + cisco.mso.mso_schema_site_anp_epg_bulk_staticport: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -502,7 +502,7 @@ register: nm_add_stat_no_parent - name: Verify nm_add_stat_no_parent - assert: + ansible.builtin.assert: that: - nm_add_stat_no_parent.current[0].deploymentImmediacy == 'lazy' - nm_add_stat_no_parent.current[0].mode == 'untagged' @@ -510,7 +510,7 @@ # VERIFY NON EXISTENT required values. - name: Add static port 1 to site EPG4 with AP2 with missing required values (normal mode) - mso_schema_site_anp_epg_bulk_staticport: + cisco.mso.mso_schema_site_anp_epg_bulk_staticport: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -524,14 +524,14 @@ register: nm_add_stat_no_req - name: Verify nm_add_stat_no_req - assert: + ansible.builtin.assert: that: - nm_add_stat_no_req is not changed - nm_add_stat_no_req.msg == "state is present but all of the following are missing{{':'}} pod, leaf, path, vlan." # VERIFY path in each leaf within a pod is unique (pod->leaf->path) - name: Add static port 1 to site EPG4 with AP2 with missing required values (normal mode) - mso_schema_site_anp_epg_bulk_staticport: + cisco.mso.mso_schema_site_anp_epg_bulk_staticport: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -552,14 +552,14 @@ register: nm_add_unique_path - name: Verify nm_add_unique_path - assert: + ansible.builtin.assert: that: - nm_add_unique_path is not changed - nm_add_unique_path.msg == "Each leaf in a pod of a static port should have an unique path." # USE NON-EXISTING EPG and ANP AT TEMPLATE LEVEL - name: Add static port 1 to non-existent site EPG5 (normal mode) - mso_schema_site_anp_epg_bulk_staticport: + cisco.mso.mso_schema_site_anp_epg_bulk_staticport: <<: *add_static_port anp: AP5 epg: EPG5 @@ -568,13 +568,13 @@ register: nm_add_stat1e5 - name: Verify nm_add_stat1e5 - assert: + ansible.builtin.assert: that: - nm_add_stat1e5 is not changed # USE NON-EXISTING EPG AT TEMPLATE LEVEL - name: Add static port 1 to non-existent site EPG5 (normal mode) - mso_schema_site_anp_epg_bulk_staticport: + cisco.mso.mso_schema_site_anp_epg_bulk_staticport: <<: *add_static_port anp: AP1 epg: EPG6 @@ -583,55 +583,55 @@ register: nm_add_stat1e6 - name: Verify nm_add_stat1e6 - assert: + ansible.builtin.assert: that: - nm_add_stat1e6 is not changed # USE A NON-EXISTING SCHEMA - name: Non-existing schema for static port - mso_schema_site_anp_epg_bulk_staticport: + cisco.mso.mso_schema_site_anp_epg_bulk_staticport: <<: *add_static_port schema: non_existing_schema ignore_errors: true register: nm_non_existing_schema - name: Verify non_existing_schema - assert: + ansible.builtin.assert: that: - nm_non_existing_schema is not changed - nm_non_existing_schema.msg == "Provided schema 'non_existing_schema' does not exist." # USE A NON-EXISTING TEMPLATE - name: Non-existing template for static port (normal_mode) - mso_schema_site_anp_epg_bulk_staticport: + cisco.mso.mso_schema_site_anp_epg_bulk_staticport: <<: *add_static_port template: non_existing_template ignore_errors: true register: nm_non_existing_template - name: Verify non_existing_template - assert: + ansible.builtin.assert: that: - nm_non_existing_template is not changed - nm_non_existing_template.msg == "Provided template 'non_existing_template' not matching existing template(s){{':'}} Template1, Template2" # USE A NON-EXISTING SITE - name: Non-existing site for static port (normal_mode) - mso_schema_site_anp_epg_bulk_staticport: + cisco.mso.mso_schema_site_anp_epg_bulk_staticport: <<: *add_static_port site: 'non_existing_site' ignore_errors: true register: nm_non_existing_site - name: Verify non_existing_site - assert: + ansible.builtin.assert: that: - nm_non_existing_site is not changed - nm_non_existing_site.msg == "Site 'non_existing_site' is not a valid site name." # USE A TEMPLATE WITHOUT ANY SITE - name: Add site EPG static port association to Template 3 without any site associated (normal mode) - mso_schema_site_anp_epg_bulk_staticport: + cisco.mso.mso_schema_site_anp_epg_bulk_staticport: <<: *add_static_port schema: '{{ mso_schema | default("ansible_test") }}_2' site: '{{ mso_site | default("ansible_test") }}' @@ -640,14 +640,14 @@ register: nm_no_site_associated - name: Verify cm_no_site_associated and nm_no_site_associated - assert: + ansible.builtin.assert: that: - nm_no_site_associated is not changed - nm_no_site_associated.msg == "No sites associated with schema 'ansible_test_2'. Associate the site with the schema using (M) mso_schema_site." # Add static port 3 after adding ANP and EPG to site - name: Add a new site to a schema 2 - mso_schema_site: + cisco.mso.mso_schema_site: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}_2' site: '{{ mso_site | default("ansible_test") }}' @@ -655,7 +655,7 @@ state: present - name: Ensure VRF1 exists - mso_schema_template_vrf: + cisco.mso.mso_schema_template_vrf: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}_2' template: Template 3 @@ -663,7 +663,7 @@ state: present - name: Add BD1 - mso_schema_template_bd: + cisco.mso.mso_schema_template_bd: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}_2' template: Template 3 @@ -673,7 +673,7 @@ state: present - name: Ensure Template 3 with AP1 exists - mso_schema_template_anp: + cisco.mso.mso_schema_template_anp: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}_2' template: Template 3 @@ -681,7 +681,7 @@ state: present - name: Ensure Template 3 and AP1 with EPG1 exists - mso_schema_template_anp_epg: + cisco.mso.mso_schema_template_anp_epg: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}_2' template: Template 3 @@ -694,7 +694,7 @@ state: present - name: Add new ANP to site - mso_schema_site_anp: + cisco.mso.mso_schema_site_anp: <<: *mso_info site: '{{ mso_site | default("ansible_test") }}' schema: '{{ mso_schema | default("ansible_test") }}_2' @@ -704,7 +704,7 @@ register: cm_add_epg - name: Add new EPG to site after adding ANP to site - mso_schema_site_anp_epg: + cisco.mso.mso_schema_site_anp_epg: <<: *mso_info site: '{{ mso_site | default("ansible_test") }}' schema: '{{ mso_schema | default("ansible_test") }}_2' @@ -715,7 +715,7 @@ register: cm_add_epg - name: Add static port to site EPG1 in schema 2 (normal mode) - mso_schema_site_anp_epg_bulk_staticport: + cisco.mso.mso_schema_site_anp_epg_bulk_staticport: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}_2' site: '{{ mso_site | default("ansible_test") }}' @@ -738,7 +738,7 @@ register: nm_add_stat3 - name: Verify nm_add_stat3 - assert: + ansible.builtin.assert: that: - nm_add_stat3 is changed - nm_add_stat3.previous == [] @@ -749,7 +749,7 @@ - nm_add_stat3.current[0].type == 'port' - name: Add static port to site EPG1 in schema 2 again without static_ports(normal mode) - mso_schema_site_anp_epg_bulk_staticport: + cisco.mso.mso_schema_site_anp_epg_bulk_staticport: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}_2' site: '{{ mso_site | default("ansible_test") }}' @@ -768,7 +768,7 @@ register: nm_add_no_static_port - name: Verify nm_add_no_static_port - assert: + ansible.builtin.assert: that: - nm_add_no_static_port is not changed - nm_add_no_static_port.msg == "state is present but all of the following are missing{{':'}} static_ports" diff --git a/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_anp_epg_domain/tasks/main.yml b/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_anp_epg_domain/tasks/main.yml index 24b953a0f..969f9c449 100644 --- a/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_anp_epg_domain/tasks/main.yml +++ b/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_anp_epg_domain/tasks/main.yml @@ -2,17 +2,18 @@ # Copyright: (c) 2020, Lionel Hercot (@lhercot) <lhercot@cisco.com> # Copyright: (c) 2018, Dag Wieers (@dagwieers) <dag@wieers.com> (based on mso_site test case) # Copyright: (c) 2020, Shreyas Srish (@shrsr) <ssrish@cisco.com> +# Copyright: (c) 2024, Akini Ross (@akinross) <akinross@cisco.com> # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI MultiSite host, username and password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: mso_hostname, mso_username and mso_password.' when: mso_hostname is not defined or mso_username is not defined or mso_password is not defined # CLEAN ENVIRONMENT - name: Set vars - set_fact: + ansible.builtin.set_fact: mso_info: &mso_info host: '{{ mso_hostname }}' username: '{{ mso_username }}' @@ -23,7 +24,7 @@ output_level: '{{ mso_output_level | default("info") }}' - name: Remove Schemas - mso_schema: + cisco.mso.mso_schema: <<: *mso_info schema: '{{ item }}' state: absent @@ -32,7 +33,7 @@ - '{{ mso_schema | default("ansible_test") }}' - name: Ensure site exists - mso_site: + cisco.mso.mso_site: <<: *mso_info site: '{{ mso_site | default("ansible_test") }}' apic_username: '{{ apic_username }}' @@ -43,7 +44,7 @@ state: present - name: Ensure sites removed from tenant ansible_test - mso_tenant_site: + cisco.mso.mso_tenant_site: <<: *mso_info tenant: ansible_test site: '{{ item }}' @@ -55,7 +56,7 @@ ignore_errors: true - name: Ensure tenant ansible_test exist - mso_tenant: + cisco.mso.mso_tenant: <<: *mso_info tenant: ansible_test users: @@ -65,7 +66,7 @@ state: present - name: Ensure schema 1 with Template 1 and 2 exists - mso_schema_template: + cisco.mso.mso_schema_template: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' tenant: ansible_test @@ -76,7 +77,7 @@ - Template 2 - name: Ensure schema 2 with Template 3 exists - mso_schema_template: + cisco.mso.mso_schema_template: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}_2' tenant: ansible_test @@ -84,7 +85,7 @@ state: present - name: Add a new site to a schema - mso_schema_site: + cisco.mso.mso_schema_site: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -92,7 +93,7 @@ state: present - name: Ensure VRF1 exists - mso_schema_template_vrf: + cisco.mso.mso_schema_template_vrf: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -100,7 +101,7 @@ state: present - name: Add BD1 - mso_schema_template_bd: + cisco.mso.mso_schema_template_bd: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -110,7 +111,7 @@ state: present - name: Ensure Template 1 with AP1 exists - mso_schema_template_anp: + cisco.mso.mso_schema_template_anp: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -118,7 +119,7 @@ state: present - name: Ensure Template 1 and AP1 with EPG1 exists - mso_schema_template_anp_epg: + cisco.mso.mso_schema_template_anp_epg: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -131,7 +132,7 @@ state: present - name: Ensure Template 1 and AP1 with EPG3 exists - mso_schema_template_anp_epg: + cisco.mso.mso_schema_template_anp_epg: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -144,7 +145,7 @@ state: present - name: Ensure Template 1 with AP2 exists - mso_schema_template_anp: + cisco.mso.mso_schema_template_anp: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -152,7 +153,7 @@ state: present - name: Ensure Template 1 and AP2 with EPG2 exists - mso_schema_template_anp_epg: + cisco.mso.mso_schema_template_anp_epg: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -165,7 +166,7 @@ state: present - name: Ensure Template 1 and AP2 with EPG4 exists - mso_schema_template_anp_epg: + cisco.mso.mso_schema_template_anp_epg: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -179,7 +180,7 @@ # ADD DOMAINS - name: Add domain 1 to site EPG1 with AP1 (check mode) - mso_schema_site_anp_epg_domain: + cisco.mso.mso_schema_site_anp_epg_domain: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -195,7 +196,7 @@ register: cm_add_dom1e1 - name: Verify cm_add_dom1e1 - assert: + ansible.builtin.assert: that: - cm_add_dom1e1 is changed - cm_add_dom1e1.previous == {} @@ -205,7 +206,7 @@ - cm_add_dom1e1.current.resolutionImmediacy == 'pre-provision' - name: Add domain 1 to site EPG1 with AP1 (normal mode) - mso_schema_site_anp_epg_domain: + cisco.mso.mso_schema_site_anp_epg_domain: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -220,7 +221,7 @@ register: nm_add_dom1e1 - name: Verify nm_add_dom1e1 - assert: + ansible.builtin.assert: that: - nm_add_dom1e1 is changed - nm_add_dom1e1.previous == {} @@ -230,7 +231,7 @@ - nm_add_dom1e1.current.resolutionImmediacy == 'pre-provision' - name: Add domain 2 to site EPG1 with AP1 (normal mode) - mso_schema_site_anp_epg_domain: + cisco.mso.mso_schema_site_anp_epg_domain: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -245,7 +246,7 @@ register: nm_add_dom2e1 - name: Verify nm_add_dom2e1 - assert: + ansible.builtin.assert: that: - nm_add_dom2e1 is changed - nm_add_dom2e1.previous == {} @@ -255,7 +256,7 @@ - nm_add_dom2e1.current.resolutionImmediacy == 'pre-provision' - name: Add domain 3 to site EPG1 with AP1 (normal mode) - mso_schema_site_anp_epg_domain: + cisco.mso.mso_schema_site_anp_epg_domain: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -270,7 +271,7 @@ register: nm_add_dom3e1 - name: Verify nm_add_dom3e1 - assert: + ansible.builtin.assert: that: - nm_add_dom3e1 is changed - nm_add_dom3e1.previous != {} @@ -280,7 +281,7 @@ - nm_add_dom3e1.current.resolutionImmediacy == 'lazy' - name: Add domain1 to site EPG3 with AP1 (normal mode) - mso_schema_site_anp_epg_domain: + cisco.mso.mso_schema_site_anp_epg_domain: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -295,7 +296,7 @@ register: nm_add_dom1e3 - name: Verify nm_add_dom1e2 - assert: + ansible.builtin.assert: that: - nm_add_dom1e3 is changed - nm_add_dom1e3.previous == {} @@ -305,7 +306,7 @@ - nm_add_dom1e3.current.resolutionImmediacy == 'lazy' - name: Add domain 2 to EPG2 (check mode) - mso_schema_site_anp_epg_domain: + cisco.mso.mso_schema_site_anp_epg_domain: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -321,7 +322,7 @@ register: cm_add_dom2e2 - name: Verify cm_add_dom2e2 - assert: + ansible.builtin.assert: that: - cm_add_dom2e2 is changed - cm_add_dom2e2.previous == {} @@ -332,7 +333,7 @@ # QUERY DOMAINS - name: Query domains of site EPG1 with AP1 (normal mode) - mso_schema_site_anp_epg_domain: + cisco.mso.mso_schema_site_anp_epg_domain: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -343,13 +344,13 @@ register: nm_query_domse1 - name: Verify nm_query_domse1 - assert: + ansible.builtin.assert: that: - nm_query_domse1 is not changed # QUERY A DOMAIN - name: Query domain3 of site EPG1 with AP1 (normal mode) - mso_schema_site_anp_epg_domain: + cisco.mso.mso_schema_site_anp_epg_domain: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -364,13 +365,13 @@ register: nm_query_dom3e1 - name: Verify nm_query_dom3e1 - assert: + ansible.builtin.assert: that: - nm_query_dom3e1 is not changed # QUERY REMOVED DOMAIN - name: Add domain 2 to site EPG2 (normal mode) - mso_schema_site_anp_epg_domain: + cisco.mso.mso_schema_site_anp_epg_domain: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -385,7 +386,7 @@ register: nm_add_dom2e2 - name: Verify nm_add_dom2e2 - assert: + ansible.builtin.assert: that: - nm_add_dom2e2 is changed - nm_add_dom2e2.previous == {} @@ -395,7 +396,7 @@ - nm_add_dom2e2.current.resolutionImmediacy == 'pre-provision' - name: Remove domain2 from EPG2 (normal mode) - mso_schema_site_anp_epg_domain: + cisco.mso.mso_schema_site_anp_epg_domain: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -410,12 +411,12 @@ register: nm_remove_dom2e2 - name: Verify nm_remove_dom2e2 - assert: + ansible.builtin.assert: that: - nm_remove_dom2e2 is changed - name: Query removed domain2 from EPG2 (normal mode) - mso_schema_site_anp_epg_domain: + cisco.mso.mso_schema_site_anp_epg_domain: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -431,13 +432,13 @@ register: nm_non_existent_dom2e2 - name: Verify non_existing_domain - assert: + ansible.builtin.assert: that: - nm_non_existent_dom2e2 is not changed - nm_non_existent_dom2e2.msg == "Domain association 'physicalDomain/phys' not found" - name: Remove domain2 from EPG2 again(normal mode) - mso_schema_site_anp_epg_domain: + cisco.mso.mso_schema_site_anp_epg_domain: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -453,13 +454,13 @@ register: nm_remove_again_dom2e2 - name: Verify nm_remove_again_dom2e2 - assert: + ansible.builtin.assert: that: - nm_remove_again_dom2e2 is not changed # ADD EXISTING DOMAIN - name: Add domain 1 to site EPG1 again (normal mode) - mso_schema_site_anp_epg_domain: + cisco.mso.mso_schema_site_anp_epg_domain: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -474,13 +475,13 @@ register: nm_add_dom1e1_2 - name: Verify nm_add_dom1e1_2 - assert: + ansible.builtin.assert: that: - nm_add_dom1e1_2 is not changed # ADD DOMAIN WITH NO STATE - name: Add domain 1 to site EPG1 again with no state (normal mode) - mso_schema_site_anp_epg_domain: + cisco.mso.mso_schema_site_anp_epg_domain: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -495,13 +496,13 @@ register: nm_add_stateless_dom1e1_2 - name: Verify nm_add_stateless_dom1e1_2 - assert: + ansible.builtin.assert: that: - nm_add_stateless_dom1e1_2 is not changed # ADD OTHER DOMAIN OPTIONS - name: Add domain l3ExtDomain to site EPG1 with AP1 (normal mode) - mso_schema_site_anp_epg_domain: + cisco.mso.mso_schema_site_anp_epg_domain: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -516,7 +517,7 @@ register: nm_add_doml3 - name: Verify nm_add_doml3 - assert: + ansible.builtin.assert: that: - nm_add_doml3 is changed - nm_add_doml3.previous == {} @@ -526,7 +527,7 @@ - nm_add_doml3.current.resolutionImmediacy == 'lazy' - name: Add domain l2ExtDomain to site EPG1 with AP1 (normal mode) - mso_schema_site_anp_epg_domain: + cisco.mso.mso_schema_site_anp_epg_domain: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -542,7 +543,7 @@ register: nm_add_doml2 - name: Verify nm_add_doml2 - assert: + ansible.builtin.assert: that: - nm_add_doml2 is changed - nm_add_doml2.previous == {} @@ -552,7 +553,7 @@ - nm_add_doml2.current.resolutionImmediacy == 'lazy' - name: Add domain fibreChannel to site EPG1 with AP1 (normal mode) - mso_schema_site_anp_epg_domain: + cisco.mso.mso_schema_site_anp_epg_domain: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -567,7 +568,7 @@ register: nm_add_domfc - name: Verify nm_add_domfc - assert: + ansible.builtin.assert: that: - nm_add_domfc is changed - nm_add_domfc.previous == {} @@ -578,7 +579,7 @@ # USE OTHER ATTRIBUTES OF VMM DOMAIN - name: Add domain vmm to site EPG2 with AP2 (normal mode) - mso_schema_site_anp_epg_domain: &domain_ap1_epg2 + cisco.mso.mso_schema_site_anp_epg_domain: &domain_ap1_epg2 <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -588,7 +589,7 @@ domain_association_type: vmmDomain domain_profile: 'VMware-VMM' deployment_immediacy: immediate - resolution_immediacy: lazy + resolution_immediacy: immediate micro_seg_vlan_type: 'vlan' micro_seg_vlan: 100 port_encap_vlan_type: 'vlan' @@ -599,17 +600,26 @@ switching_mode: native enhanced_lagpolicy_name: 'ansible_check_name' enhanced_lagpolicy_dn: 'ansible_check' + delimiter: '|' + binding_type: static + num_ports: 2 + port_allocation: elastic + netflow_pref: enabled + allow_promiscuous: accept + forged_transmits: accept + mac_changes: accept + custom_epg_name: ansible_custom_epg state: present register: nm_add_domvmprop - name: Query domain vmms attached to site EPG2 with AP2 - mso_schema_site_anp_epg_domain: + cisco.mso.mso_schema_site_anp_epg_domain: <<: *domain_ap1_epg2 state: query register: nm_query_domvmprop - name: Verify domain vmm to site EPG2 with AP2 - assert: + ansible.builtin.assert: that: - nm_add_domvmprop is changed - nm_add_domvmprop.previous == {} @@ -623,10 +633,19 @@ - nm_add_domvmprop.current.microSegVlan.vlanType == "vlan" - nm_add_domvmprop.current.portEncapVlan.vlan == 100 - nm_add_domvmprop.current.portEncapVlan.vlanType == "vlan" - - nm_add_domvmprop.current.resolutionImmediacy == "lazy" + - nm_add_domvmprop.current.resolutionImmediacy == "immediate" - nm_add_domvmprop.current.switchType == "default" - nm_add_domvmprop.current.switchingMode == "native" - nm_add_domvmprop.current.vlanEncapMode == "static" + - nm_add_domvmprop.current.delimiter == "|" + - nm_add_domvmprop.current.bindingType == "static" + - nm_add_domvmprop.current.numPorts == 2 + - nm_add_domvmprop.current.portAllocation == "elastic" + - nm_add_domvmprop.current.netflowPref == "enabled" + - nm_add_domvmprop.current.allowPromiscuous == "accept" + - nm_add_domvmprop.current.forgedTransmits == "accept" + - nm_add_domvmprop.current.macChanges == "accept" + - nm_add_domvmprop.current.customEpgName == "ansible_custom_epg" - nm_add_domvmprop.current.vmmDomainProperties.allowMicroSegmentation == true - nm_add_domvmprop.current.vmmDomainProperties.epgLagPol.enhancedLagPol.dn == "ansible_check" - nm_add_domvmprop.current.vmmDomainProperties.epgLagPol.enhancedLagPol.name == "ansible_check_name" @@ -637,6 +656,15 @@ - nm_add_domvmprop.current.vmmDomainProperties.switchType == "default" - nm_add_domvmprop.current.vmmDomainProperties.switchingMode == "native" - nm_add_domvmprop.current.vmmDomainProperties.vlanEncapMode == "static" + - nm_add_domvmprop.current.vmmDomainProperties.delimiter == "|" + - nm_add_domvmprop.current.vmmDomainProperties.bindingType == "static" + - nm_add_domvmprop.current.vmmDomainProperties.numPorts == 2 + - nm_add_domvmprop.current.vmmDomainProperties.portAllocation == "elastic" + - nm_add_domvmprop.current.vmmDomainProperties.netflowPref == "enabled" + - nm_add_domvmprop.current.vmmDomainProperties.allowPromiscuous == "accept" + - nm_add_domvmprop.current.vmmDomainProperties.forgedTransmits == "accept" + - nm_add_domvmprop.current.vmmDomainProperties.macChanges == "accept" + - nm_add_domvmprop.current.vmmDomainProperties.customEpgName == "ansible_custom_epg" - nm_query_domvmprop.current.allowMicroSegmentation == true - nm_query_domvmprop.current.deployImmediacy == "immediate" - nm_query_domvmprop.current.dn == "uni/vmmp-VMware/dom-VMware-VMM" @@ -646,20 +674,29 @@ - nm_query_domvmprop.current.microSegVlan.vlanType == "vlan" - nm_query_domvmprop.current.portEncapVlan.vlan == 100 - nm_query_domvmprop.current.portEncapVlan.vlanType == "vlan" - - nm_query_domvmprop.current.resolutionImmediacy == "lazy" + - nm_query_domvmprop.current.resolutionImmediacy == "immediate" - nm_query_domvmprop.current.switchType == "default" - nm_query_domvmprop.current.switchingMode == "native" - nm_query_domvmprop.current.vlanEncapMode == "static" + - nm_query_domvmprop.current.delimiter == "|" + - nm_query_domvmprop.current.bindingType == "static" + - nm_query_domvmprop.current.numPorts == 2 + - nm_query_domvmprop.current.portAllocation == "elastic" + - nm_query_domvmprop.current.netflowPref == "enabled" + - nm_query_domvmprop.current.allowPromiscuous == "accept" + - nm_query_domvmprop.current.forgedTransmits == "accept" + - nm_query_domvmprop.current.macChanges == "accept" + - nm_query_domvmprop.current.customEpgName == "ansible_custom_epg" - name: Add another domain vmm to site EPG2 with AP2 (normal mode) - mso_schema_site_anp_epg_domain: + cisco.mso.mso_schema_site_anp_epg_domain: <<: *domain_ap1_epg2 domain_profile: 'TEST' state: present register: nm_add_another_domvmprop - name: Query all domains vmms attached to site EPG2 with AP2 - mso_schema_site_anp_epg_domain: + cisco.mso.mso_schema_site_anp_epg_domain: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -670,14 +707,14 @@ register: nm_query_another_domvmprop - name: Verify domain vmm to site EPG2 with AP2 - assert: + ansible.builtin.assert: that: - nm_add_another_domvmprop is changed - nm_query_another_domvmprop is not changed - nm_query_another_domvmprop.current | length == 2 -- name: Add domain vmm to site EPG4 with AP2 (normal mode) - mso_schema_site_anp_epg_domain: +- name: Error binding type static and port_allocation not provided (error mode) + cisco.mso.mso_schema_site_anp_epg_domain: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -688,28 +725,36 @@ domain_profile: 'VMware-VMM' deployment_immediacy: lazy resolution_immediacy: lazy - micro_seg_vlan: 100 - port_encap_vlan_type: 'vlan' - port_encap_vlan: 100 - vlan_encap_mode: static - allow_micro_segmentation: true - switch_type: 'default' - switching_mode: native - enhanced_lagpolicy_name: 'ansible_check' - enhanced_lagpolicy_dn: 'ansible_check' + binding_type: static state: present ignore_errors: true - register: nm_add_domvmprop1 + register: err_binding_type_static -- name: Verify nm_add_domvmprop1 - assert: +- name: Verify binding type static error + ansible.builtin.assert: that: - - nm_add_domvmprop1 is not changed - - nm_add_domvmprop1.previous == {} - - nm_add_domvmprop1.msg == "micro_seg_vlan_type is required when micro_seg_vlan is provided." + - err_binding_type_static is not changed + - err_binding_type_static.msg == "binding_type is static but all of the following are missing{{":"}} port_allocation" + +- name: Error micro_seg_vlan and micro_seg_vlan_type not provided (error mode) + cisco.mso.mso_schema_site_anp_epg_domain: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: '{{ mso_site | default("ansible_test") }}' + template: Template 1 + anp: AP2 + epg: EPG4 + domain_association_type: vmmDomain + domain_profile: 'VMware-VMM' + deployment_immediacy: lazy + resolution_immediacy: lazy + micro_seg_vlan: 100 + state: present + ignore_errors: true + register: err_no_micro_seg_vlan_type -- name: Add domain vmm to site EPG4 with AP2 (normal mode) - mso_schema_site_anp_epg_domain: +- name: Error micro_seg_vlan_type and micro_seg_vlan not provided (error mode) + cisco.mso.mso_schema_site_anp_epg_domain: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -721,26 +766,20 @@ deployment_immediacy: lazy resolution_immediacy: lazy micro_seg_vlan_type: 'vlan' - port_encap_vlan_type: 'vlan' - port_encap_vlan: 100 - vlan_encap_mode: static - allow_micro_segmentation: true - switch_type: 'default' - switching_mode: native - enhanced_lagpolicy_name: 'ansible_check' - enhanced_lagpolicy_dn: 'ansible_check' state: present ignore_errors: true - register: nm_add_domvmprop2 + register: err_no_micro_seg_vlan -- name: Verify nm_add_domvmprop2 - assert: +- name: Verify micro segmentation vlan error + ansible.builtin.assert: that: - - nm_add_domvmprop2 is not changed - - nm_add_domvmprop2.msg == "micro_seg_vlan is required when micro_seg_vlan_type is provided." + - err_no_micro_seg_vlan_type is not changed + - err_no_micro_seg_vlan_type.msg == "parameters are required together{{":"}} micro_seg_vlan_type, micro_seg_vlan" + - err_no_micro_seg_vlan is not changed + - err_no_micro_seg_vlan.msg == "parameters are required together{{":"}} micro_seg_vlan_type, micro_seg_vlan" -- name: Add domain vmm to site EPG4 with AP2 (normal mode) - mso_schema_site_anp_epg_domain: +- name: Error port_encap_vlan and port_encap_vlan_type not provided (error mode) + cisco.mso.mso_schema_site_anp_epg_domain: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -751,27 +790,13 @@ domain_profile: 'VMware-VMM' deployment_immediacy: lazy resolution_immediacy: lazy - micro_seg_vlan_type: 'vlan' - micro_seg_vlan: 100 port_encap_vlan: 100 - vlan_encap_mode: static - allow_micro_segmentation: true - switch_type: 'default' - switching_mode: native - enhanced_lagpolicy_name: 'ansible_check' - enhanced_lagpolicy_dn: '' state: present ignore_errors: true - register: nm_add_domvmprop3 + register: err_no_port_encap_vlan_type -- name: Verify nm_add_domvmprop3 - assert: - that: - - nm_add_domvmprop3 is not changed - - nm_add_domvmprop3.msg == "port_encap_vlan_type is required when port_encap_vlan is provided." - -- name: Add domain vmm to site EPG4 with AP2 (normal mode) - mso_schema_site_anp_epg_domain: +- name: Error port_encap_vlan_type and port_encap_vlan not provided (error mode) + cisco.mso.mso_schema_site_anp_epg_domain: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -782,27 +807,21 @@ domain_profile: 'VMware-VMM' deployment_immediacy: lazy resolution_immediacy: lazy - micro_seg_vlan_type: 'vlan' - micro_seg_vlan: 100 port_encap_vlan_type: 'vlan' - vlan_encap_mode: static - allow_micro_segmentation: true - switch_type: 'default' - switching_mode: native - enhanced_lagpolicy_name: 'ansible_check' - enhanced_lagpolicy_dn: 'ansible_check' state: present ignore_errors: true - register: nm_add_domvmprop4 + register: err_no_port_encap_vlan -- name: Verify nm_add_domvmprop4 - assert: +- name: Verify port encap vlan error + ansible.builtin.assert: that: - - nm_add_domvmprop4 is not changed - - nm_add_domvmprop4.msg == "port_encap_vlan is required when port_encap_vlan_type is provided." + - err_no_port_encap_vlan_type is not changed + - err_no_port_encap_vlan_type.msg == "parameters are required together{{":"}} port_encap_vlan_type, port_encap_vlan" + - err_no_port_encap_vlan is not changed + - err_no_port_encap_vlan.msg == "parameters are required together{{":"}} port_encap_vlan_type, port_encap_vlan" -- name: Add domain vmm to site EPG4 with AP2 (normal mode) - mso_schema_site_anp_epg_domain: +- name: Error enhanced_lagpolicy_dn and enhanced_lagpolicy_name not provided (error mode) + cisco.mso.mso_schema_site_anp_epg_domain: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -813,27 +832,13 @@ domain_profile: 'VMware-VMM' deployment_immediacy: lazy resolution_immediacy: lazy - micro_seg_vlan_type: 'vlan' - micro_seg_vlan: 100 - port_encap_vlan_type: 'vlan' - port_encap_vlan: 100 - vlan_encap_mode: static - allow_micro_segmentation: true - switch_type: 'default' - switching_mode: native enhanced_lagpolicy_dn: 'ansible_check' state: present ignore_errors: true - register: nm_add_domvmprop5 - -- name: Verify nm_add_domvmprop5 - assert: - that: - - nm_add_domvmprop5 is not changed - - nm_add_domvmprop5.msg == "enhanced_lagpolicy_name is required when enhanced_lagpolicy_dn is provided." + register: err_no_enhanced_lagpolicy_name -- name: Add domain vmm to site EPG4 with AP2 (normal mode) - mso_schema_site_anp_epg_domain: +- name: Error enhanced_lagpolicy_name and enhanced_lagpolicy_dn not provided (error mode) + cisco.mso.mso_schema_site_anp_epg_domain: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -844,28 +849,22 @@ domain_profile: 'VMware-VMM' deployment_immediacy: lazy resolution_immediacy: lazy - micro_seg_vlan_type: 'vlan' - micro_seg_vlan: 100 - port_encap_vlan_type: 'vlan' - port_encap_vlan: 100 - vlan_encap_mode: static - allow_micro_segmentation: true - switch_type: 'default' - switching_mode: native enhanced_lagpolicy_name: 'ansible_check' state: present ignore_errors: true - register: nm_add_domvmprop6 + register: err_no_enhanced_lagpolicy_dn - name: Verify nm_add_domvmprop6 - assert: + ansible.builtin.assert: that: - - nm_add_domvmprop6 is not changed - - nm_add_domvmprop6.msg == "enhanced_lagpolicy_dn is required when enhanced_lagpolicy_name is provided." + - err_no_enhanced_lagpolicy_name is not changed + - err_no_enhanced_lagpolicy_name.msg == "parameters are required together{{":"}} enhanced_lagpolicy_name, enhanced_lagpolicy_dn" + - err_no_enhanced_lagpolicy_dn is not changed + - err_no_enhanced_lagpolicy_dn.msg == "parameters are required together{{":"}} enhanced_lagpolicy_name, enhanced_lagpolicy_dn" # USE NON-EXISTING EPG and ANP AT TEMPLATE LEVEL - name: Add domain 1 to non-existent site EPG5 (normal mode) - mso_schema_site_anp_epg_domain: + cisco.mso.mso_schema_site_anp_epg_domain: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -881,13 +880,13 @@ register: nm_add_dom1e5 - name: Verify nm_add_dom1e5 - assert: + ansible.builtin.assert: that: - nm_add_dom1e5 is not changed # USE NON-EXISTING EPG AT TEMPLATE LEVEL - name: Add domain 1 to non-existent site EPG5 (normal mode) - mso_schema_site_anp_epg_domain: + cisco.mso.mso_schema_site_anp_epg_domain: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -903,13 +902,13 @@ register: nm_add_dom1e6 - name: Verify nm_add_dom1e6 - assert: + ansible.builtin.assert: that: - nm_add_dom1e6 is not changed # USE A NON-EXISTING SCHEMA - name: Non-existing schema for domain (check_mode) - mso_schema_site_anp_epg_domain: + cisco.mso.mso_schema_site_anp_epg_domain: <<: *mso_info schema: non_existing_schema site: '{{ mso_site | default("ansible_test") }}' @@ -925,7 +924,7 @@ register: cm_non_existing_schema - name: Non-existing schema for domain (normal_mode) - mso_schema_site_anp_epg_domain: + cisco.mso.mso_schema_site_anp_epg_domain: <<: *mso_info schema: non_existing_schema site: '{{ mso_site | default("ansible_test") }}' @@ -940,7 +939,7 @@ register: nm_non_existing_schema - name: Verify non_existing_schema - assert: + ansible.builtin.assert: that: - cm_non_existing_schema is not changed - nm_non_existing_schema is not changed @@ -949,7 +948,7 @@ # USE A NON-EXISTING TEMPLATE - name: Non-existing template for domain (check_mode) - mso_schema_site_anp_epg_domain: + cisco.mso.mso_schema_site_anp_epg_domain: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -965,7 +964,7 @@ register: cm_non_existing_template - name: Non-existing template for domain (normal_mode) - mso_schema_site_anp_epg_domain: + cisco.mso.mso_schema_site_anp_epg_domain: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -980,7 +979,7 @@ register: nm_non_existing_template - name: Verify non_existing_template - assert: + ansible.builtin.assert: that: - cm_non_existing_template is not changed - nm_non_existing_template is not changed @@ -989,7 +988,7 @@ # USE A NON-EXISTING SITE - name: Non-existing site for domain (check_mode) - mso_schema_site_anp_epg_domain: + cisco.mso.mso_schema_site_anp_epg_domain: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -1005,7 +1004,7 @@ register: cm_non_existing_site - name: Non-existing site for domain (normal_mode) - mso_schema_site_anp_epg_domain: + cisco.mso.mso_schema_site_anp_epg_domain: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -1020,7 +1019,7 @@ register: nm_non_existing_site - name: Verify non_existing_site - assert: + ansible.builtin.assert: that: - cm_non_existing_site is not changed - nm_non_existing_site is not changed @@ -1030,7 +1029,7 @@ # USE A TEMPLATE WITHOUT ANY SITE - name: Add site EPG domain association to Schema 2 Template 3 without any site associated (check mode) - mso_schema_site_anp_epg_domain: + cisco.mso.mso_schema_site_anp_epg_domain: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}_2' site: '{{ mso_site | default("ansible_test") }}' @@ -1046,7 +1045,7 @@ register: cm_no_site_associated - name: Add site EPG domain association to Template 3 without any site associated (normal mode) - mso_schema_site_anp_epg_domain: + cisco.mso.mso_schema_site_anp_epg_domain: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}_2' site: '{{ mso_site | default("ansible_test") }}' @@ -1061,7 +1060,7 @@ register: nm_no_site_associated - name: Verify cm_no_site_associated and nm_no_site_associated - assert: + ansible.builtin.assert: that: - cm_no_site_associated is not changed - nm_no_site_associated is not changed diff --git a/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_anp_epg_selector/tasks/main.yml b/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_anp_epg_selector/tasks/main.yml index ec69a7c47..1660e8e4c 100644 --- a/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_anp_epg_selector/tasks/main.yml +++ b/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_anp_epg_selector/tasks/main.yml @@ -6,13 +6,13 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI MultiSite host, username and password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: mso_hostname, mso_username and mso_password.' when: mso_hostname is not defined or mso_username is not defined or mso_password is not defined # CLEAN ENVIRONMENT - name: Set vars - set_fact: + ansible.builtin.set_fact: mso_info: &mso_info host: '{{ mso_hostname }}' username: '{{ mso_username }}' @@ -23,13 +23,13 @@ output_level: '{{ mso_output_level | default("info") }}' - name: Query MSO version - mso_version: + cisco.mso.mso_version: <<: *mso_info state: query register: version - name: Remove schemas - mso_schema: + cisco.mso.mso_schema: <<: *mso_info schema: '{{ item }}' state: absent @@ -38,7 +38,7 @@ - '{{ mso_schema | default("ansible_test") }}' - name: Ensure azure site exists - mso_site: + cisco.mso.mso_site: <<: *mso_info site: 'azure_{{ mso_site | default("ansible_test") }}' apic_username: '{{ azure_apic_username }}' @@ -49,7 +49,7 @@ state: present - name: Ensure aws site exists - mso_site: + cisco.mso.mso_site: <<: *mso_info site: 'aws_{{ mso_site | default("ansible_test") }}' apic_username: '{{ aws_apic_username }}' @@ -60,7 +60,7 @@ state: present - name: Ensure sites removed from tenant ansible_test - mso_tenant_site: + cisco.mso.mso_tenant_site: <<: *mso_info tenant: ansible_test site: '{{ item }}' @@ -71,7 +71,7 @@ - 'azure_{{ mso_site | default("ansible_test") }}' - name: Ensure tenant ansible_test exists - mso_tenant: + cisco.mso.mso_tenant: <<: *mso_info tenant: ansible_test users: @@ -81,7 +81,7 @@ state: present - name: Associate aws site with ansible_test in normal mode - mso_tenant_site: + cisco.mso.mso_tenant_site: <<: *mso_info tenant: ansible_test site: 'aws_{{ mso_site | default("ansible_test") }}' @@ -93,7 +93,7 @@ register: aaws_nm - name: Associate azure site with access_type not present, with ansible_test in normal mode - mso_tenant_site: + cisco.mso.mso_tenant_site: <<: *mso_info tenant: ansible_test site: 'azure_{{ mso_site | default("ansible_test") }}' @@ -102,7 +102,7 @@ register: aazure_shared_nm - name: Ensure schema 1 with Template 1, and Template 2, Template 3 exist - mso_schema_template: + cisco.mso.mso_schema_template: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' tenant: ansible_test @@ -114,7 +114,7 @@ - { template: Template 3} - name: Ensure schema 2 with Template 3 exist - mso_schema_template: + cisco.mso.mso_schema_template: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}_2' tenant: ansible_test @@ -122,7 +122,7 @@ state: present - name: Add aws site to a schema - mso_schema_site: + cisco.mso.mso_schema_site: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: 'aws_{{ mso_site | default("ansible_test") }}' @@ -134,7 +134,7 @@ when: version.current.version is version('3', '<') - name: Add azure site to a schema - mso_schema_site: + cisco.mso.mso_schema_site: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: 'azure_{{ mso_site | default("ansible_test") }}' @@ -146,7 +146,7 @@ when: version.current.version is version('3', '<') - name: Ensure VRF1 exists - mso_schema_template_vrf: + cisco.mso.mso_schema_template_vrf: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -154,7 +154,7 @@ state: present - name: Ensure ANP exist - mso_schema_template_anp: + cisco.mso.mso_schema_template_anp: <<: *mso_info schema: '{{ item.schema }}' template: '{{ item.template }}' @@ -165,7 +165,7 @@ - { schema: '{{ mso_schema | default("ansible_test") }}', template: 'Template 2' } - name: Add a new CIDR in VRF1 at site level - mso_schema_site_vrf_region_cidr: &mso_present + cisco.mso.mso_schema_site_vrf_region_cidr: &mso_present <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -181,7 +181,7 @@ # ADD EPGs - name: Ensure EPGs exist - mso_schema_template_anp_epg: + cisco.mso.mso_schema_template_anp_epg: <<: *mso_info schema: '{{ item.schema }}' template: '{{ item.template }}' @@ -197,7 +197,7 @@ - { schema: '{{ mso_schema | default("ansible_test") }}', template: 'Template 1', epg: 'ansible_test_2' } - name: Add Selector to EPG (normal_mode) - mso_schema_template_anp_epg_selector: + cisco.mso.mso_schema_template_anp_epg_selector: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -208,7 +208,7 @@ register: nm_add_selector_1 - name: Verify nm_add_selector_1 - assert: + ansible.builtin.assert: that: - nm_add_selector_1 is changed - nm_add_selector_1.previous == {} @@ -216,7 +216,7 @@ - nm_add_selector_1.current.expressions == [] - name: Add Selector 2 to EPG (normal_mode) - mso_schema_template_anp_epg_selector: + cisco.mso.mso_schema_template_anp_epg_selector: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -231,7 +231,7 @@ register: nm_add_selector_2 - name: Verify nm_add_selector_2 - assert: + ansible.builtin.assert: that: - nm_add_selector_2 is changed - nm_add_selector_2.previous == {} @@ -242,7 +242,7 @@ # ADD SELECTORS to site EPG - name: Add selector site_selector_1 to site EPG ansible_test_1 with ANP (check_mode) - mso_schema_site_anp_epg_selector: + cisco.mso.mso_schema_site_anp_epg_selector: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: 'aws_{{ mso_site | default("ansible_test") }}' @@ -255,7 +255,7 @@ register: cm_add_site_selector_1 - name: Verify cm_add_site_selector_1 - assert: + ansible.builtin.assert: that: - cm_add_site_selector_1.current.name == "site_selector_1" - cm_add_site_selector_1.current.expressions == [] @@ -263,7 +263,7 @@ - cm_add_site_selector_1.previous == {} - name: Add selector site_selector_1 to site EPG ansible_test_1 with ANP (normal_mode) - mso_schema_site_anp_epg_selector: + cisco.mso.mso_schema_site_anp_epg_selector: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: 'aws_{{ mso_site | default("ansible_test") }}' @@ -275,7 +275,7 @@ register: nm_add_site_selector_1 - name: Verify nm_add_site_selector_1 - assert: + ansible.builtin.assert: that: - nm_add_site_selector_1.current.name == "site_selector_1" - nm_add_site_selector_1.current.expressions == [] @@ -284,7 +284,7 @@ # Add selector 1 again - name: Add selector site_selector_1 to site EPG ansible_test_1 with ANP again (normal_mode) - mso_schema_site_anp_epg_selector: + cisco.mso.mso_schema_site_anp_epg_selector: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: 'aws_{{ mso_site | default("ansible_test") }}' @@ -296,14 +296,14 @@ register: nm_add_site_selector_1_again - name: Verify nm_add_site_selector_1_again - assert: + ansible.builtin.assert: that: - nm_add_site_selector_1_again is not changed - nm_add_site_selector_1_again.current.name == "site_selector_1" == nm_add_site_selector_1_again.previous.name - nm_add_site_selector_1_again.current.expressions == [] == nm_add_site_selector_1_again.previous.expressions - name: Add Selector 1 to site EPG with space in selector name (normal_mode) - mso_schema_site_anp_epg_selector: + cisco.mso.mso_schema_site_anp_epg_selector: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: 'aws_{{ mso_site | default("ansible_test") }}' @@ -316,13 +316,13 @@ register: nm_add_selector1_with_space_in_name - name: Verify nm_add_selector1_with_space_in_name - assert: + ansible.builtin.assert: that: - nm_add_selector1_with_space_in_name is not changed - nm_add_selector1_with_space_in_name.msg == "There should not be any space in selector name." - name: Add Selector 2 to site EPG with space in expression type (normal_mode) - mso_schema_site_anp_epg_selector: + cisco.mso.mso_schema_site_anp_epg_selector: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: 'aws_{{ mso_site | default("ansible_test") }}' @@ -339,13 +339,13 @@ register: nm_add_selector2_with_space_in_expression_type - name: Verify nm_add_selector2_with_space_in_expression_type - assert: + ansible.builtin.assert: that: - nm_add_selector2_with_space_in_expression_type is not changed - nm_add_selector2_with_space_in_expression_type.msg == "There should not be any space in 'type' attribute of expression 'expression 2'" - name: Add Selector 2 to site EPG (check_mode) - mso_schema_site_anp_epg_selector: + cisco.mso.mso_schema_site_anp_epg_selector: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: 'aws_{{ mso_site | default("ansible_test") }}' @@ -362,7 +362,7 @@ register: cm_add_site_selector_2 - name: Verify cm_add_selector_2 - assert: + ansible.builtin.assert: that: - cm_add_site_selector_2 is changed - cm_add_site_selector_2.previous == {} @@ -372,7 +372,7 @@ - cm_add_site_selector_2.current.expressions[0].value == "test" - name: Add Selector_2 to site EPG (normal_mode) - mso_schema_site_anp_epg_selector: + cisco.mso.mso_schema_site_anp_epg_selector: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: 'aws_{{ mso_site | default("ansible_test") }}' @@ -388,7 +388,7 @@ register: nm_add_site_selector_2 - name: Verify nm_add_site_selector_2 - assert: + ansible.builtin.assert: that: - nm_add_site_selector_2 is changed - nm_add_site_selector_2.previous == {} @@ -398,7 +398,7 @@ - nm_add_site_selector_2.current.expressions[0].value == "test" - name: Change Selector 2 - keyExist(normal_mode) - mso_schema_site_anp_epg_selector: + cisco.mso.mso_schema_site_anp_epg_selector: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: 'aws_{{ mso_site | default("ansible_test") }}' @@ -415,13 +415,13 @@ register: nm_change_site_selector_2_key_exist - name: Verify nm_change_site_selector_2_key_exist - assert: + ansible.builtin.assert: that: - nm_change_site_selector_2_key_exist is not changed - nm_change_site_selector_2_key_exist.msg == "Attribute 'value' is not supported for operator 'has_key' in expression 'expression_5'" - name: Change Selector 2 - keyNotExist (normal_mode) - mso_schema_site_anp_epg_selector: + cisco.mso.mso_schema_site_anp_epg_selector: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: 'aws_{{ mso_site | default("ansible_test") }}' @@ -438,13 +438,13 @@ register: nm_change_site_selector_2_key_not_exist - name: Verify nm_change_site_selector_2_key_not_exist - assert: + ansible.builtin.assert: that: - nm_change_site_selector_2_key_not_exist is not changed - nm_change_site_selector_2_key_not_exist.msg == "Attribute 'value' is not supported for operator 'does_not_have_key' in expression 'expression_6'" - name: Change Selector 2 - equals (normal_mode) - mso_schema_site_anp_epg_selector: + cisco.mso.mso_schema_site_anp_epg_selector: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: 'aws_{{ mso_site | default("ansible_test") }}' @@ -460,14 +460,14 @@ register: nm_change_site_selector_2_equals - name: Verify nm_change_site_selector_2_equals - assert: + ansible.builtin.assert: that: - nm_change_site_selector_2_equals is not changed - nm_change_site_selector_2_equals.msg == "Attribute 'value' needed for operator 'equals' in expression 'expression_6'" # Remove site ANP - name: Remove site ANP (normal_mode) - mso_schema_site_anp: + cisco.mso.mso_schema_site_anp: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: 'aws_{{ mso_site | default("ansible_test") }}' @@ -476,7 +476,7 @@ state: absent - name: Query site ANP - mso_schema_site_anp: + cisco.mso.mso_schema_site_anp: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: 'aws_{{ mso_site | default("ansible_test") }}' @@ -487,14 +487,14 @@ register: query_site_ANP - name: Verify query_site_ANP - assert: + ansible.builtin.assert: that: - query_site_ANP.msg == "ANP 'ANP' not found" when: version.current.version is version('4.0', '<') # no error msg is returned in NDO4.0 because site will be present when template is defined # Query without site ANP - name: Query site_selectors without site ANP - mso_schema_site_anp_epg_selector: + cisco.mso.mso_schema_site_anp_epg_selector: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: 'aws_{{ mso_site | default("ansible_test") }}' @@ -506,7 +506,7 @@ register: query_without_site_ANP - name: Verify query_without_site_ANP - assert: + ansible.builtin.assert: that: - query_without_site_ANP is not changed - query_without_site_ANP.msg == "Anp 'ANP' does not exist in site level." @@ -514,7 +514,7 @@ # - name: Add selector without ANP exist in site level - name: Add site selector 3 without site ANP exist (normal_mode) - mso_schema_site_anp_epg_selector: + cisco.mso.mso_schema_site_anp_epg_selector: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: 'aws_{{ mso_site | default("ansible_test") }}' @@ -530,7 +530,7 @@ register: nm_add_site_selector_3_without_anp - name: Verify nm_add_site_selector_3_without_anp - assert: + ansible.builtin.assert: that: - nm_add_site_selector_3_without_anp is changed - nm_add_site_selector_3_without_anp.previous == {} @@ -541,7 +541,7 @@ # Remove site level EPG - name: Remove site EPG - mso_schema_site_anp_epg: + cisco.mso.mso_schema_site_anp_epg: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: 'aws_{{ mso_site | default("ansible_test") }}' @@ -552,7 +552,7 @@ # Query without site level EPG - name: Query site_selectors without site EPG - mso_schema_site_anp_epg_selector: + cisco.mso.mso_schema_site_anp_epg_selector: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: 'aws_{{ mso_site | default("ansible_test") }}' @@ -564,14 +564,14 @@ register: query_without_site_EPG - name: Verify query_without_site_EPG - assert: + ansible.builtin.assert: that: - query_without_site_EPG is not changed - query_without_site_EPG.msg == "Epg 'ansible_test_1' does not exist in site level." when: version.current.version is version('4.0', '<') # no error msg is returned in NDO4.0 because site will be present when template is defined - name: Add site selector 1 without site EPG exist (normal_mode) - mso_schema_site_anp_epg_selector: + cisco.mso.mso_schema_site_anp_epg_selector: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: 'aws_{{ mso_site | default("ansible_test") }}' @@ -583,7 +583,7 @@ register: nm_add_site_selector_1_without_epg - name: Verify nm_add_site_selector_1_without_epg - assert: + ansible.builtin.assert: that: - nm_add_site_selector_1_without_epg is changed - nm_add_site_selector_1_without_epg.previous == {} @@ -591,7 +591,7 @@ - nm_add_site_selector_1_without_epg.current.expressions == [] - name: Add site_selector_1 site_selector_2 site_selector_3 again - mso_schema_site_anp_epg_selector: + cisco.mso.mso_schema_site_anp_epg_selector: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: 'aws_{{ mso_site | default("ansible_test") }}' @@ -611,13 +611,13 @@ register: nm_add_site_selectors_again - name: Verify nm_add_site_selectors_again - assert: + ansible.builtin.assert: that: - nm_add_site_selectors_again is changed # Query all selectors - name: Query selectors to site EPG - mso_schema_site_anp_epg_selector: + cisco.mso.mso_schema_site_anp_epg_selector: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: 'aws_{{ mso_site | default("ansible_test") }}' @@ -628,7 +628,7 @@ register: query_all_site_selectors - name: Verify query_all_site_selectors - assert: + ansible.builtin.assert: that: - query_all_site_selectors is not changed - query_all_site_selectors.current | length == 3 @@ -647,7 +647,7 @@ # Query sepecific seletor to site EPG - name: Query selector to site EPG - mso_schema_site_anp_epg_selector: + cisco.mso.mso_schema_site_anp_epg_selector: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: 'aws_{{ mso_site | default("ansible_test") }}' @@ -659,7 +659,7 @@ register: query_site_selector_1 - name: Verify query_site_selector_1 - assert: + ansible.builtin.assert: that: - query_site_selector_1 is not changed - query_site_selector_1.current.name == "site_selector_1" @@ -668,7 +668,7 @@ - query_site_selector_1.current.expressions[0].value == "test" - name: Remove site selector 3 (normal_mode) - mso_schema_site_anp_epg_selector: + cisco.mso.mso_schema_site_anp_epg_selector: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: 'aws_{{ mso_site | default("ansible_test") }}' @@ -680,13 +680,13 @@ register: nm_remove_site_selector_3 - name: Verify nm_remove_site_selector_3 - assert: + ansible.builtin.assert: that: - nm_remove_site_selector_3 is changed - nm_remove_site_selector_3.current == {} - name: Remove site selector 3 again (normal_mode) - mso_schema_site_anp_epg_selector: + cisco.mso.mso_schema_site_anp_epg_selector: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: 'aws_{{ mso_site | default("ansible_test") }}' @@ -698,14 +698,14 @@ register: nm_remove_site_selector_3_again - name: Verify nm_remove_site_selector_3_again - assert: + ansible.builtin.assert: that: - nm_remove_site_selector_3_again is not changed - nm_remove_site_selector_3_again.current == {} # QUERY NON-EXISTING Selector to EPG - name: Query non-existing selector (check_mode) - mso_schema_site_anp_epg_selector: + cisco.mso.mso_schema_site_anp_epg_selector: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: 'aws_{{ mso_site | default("ansible_test") }}' @@ -719,7 +719,7 @@ register: cm_query_non_selector - name: Query non-existing selector (normal mode) - mso_schema_site_anp_epg_selector: + cisco.mso.mso_schema_site_anp_epg_selector: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: 'aws_{{ mso_site | default("ansible_test") }}' @@ -732,7 +732,7 @@ register: nm_query_non_selector - name: Verify cm_query_non_selector and nm_query_non_selector - assert: + ansible.builtin.assert: that: - cm_query_non_selector is not changed - nm_query_non_selector is not changed @@ -742,7 +742,7 @@ # QUERY NON-EXISTING EPG - name: Query non-existing EPG (check_mode) - mso_schema_site_anp_epg_selector: + cisco.mso.mso_schema_site_anp_epg_selector: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: 'aws_{{ mso_site | default("ansible_test") }}' @@ -756,7 +756,7 @@ register: cm_query_non_epg - name: Query non-existing EPG (normal mode) - mso_schema_site_anp_epg_selector: + cisco.mso.mso_schema_site_anp_epg_selector: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: 'aws_{{ mso_site | default("ansible_test") }}' @@ -769,7 +769,7 @@ register: nm_query_non_epg - name: Verify query_non_epg - assert: + ansible.builtin.assert: that: - cm_query_non_epg is not changed - nm_query_non_epg is not changed @@ -778,7 +778,7 @@ # QUERY NON-EXISTING ANP - name: Query non-existing ANP (check_mode) - mso_schema_site_anp_epg_selector: + cisco.mso.mso_schema_site_anp_epg_selector: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: 'aws_{{ mso_site | default("ansible_test") }}' @@ -792,7 +792,7 @@ register: cm_query_non_anp - name: Query non-existing ANP (normal mode) - mso_schema_site_anp_epg_selector: + cisco.mso.mso_schema_site_anp_epg_selector: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: 'aws_{{ mso_site | default("ansible_test") }}' @@ -805,7 +805,7 @@ register: nm_query_non_anp - name: Verify query_non_anp - assert: + ansible.builtin.assert: that: - cm_query_non_anp is not changed - nm_query_non_anp is not changed @@ -814,7 +814,7 @@ # USE A NON-EXISTING STATE - name: Non-existing state (check_mode) - mso_schema_site_anp_epg_selector: + cisco.mso.mso_schema_site_anp_epg_selector: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: 'aws_{{ mso_site | default("ansible_test") }}' @@ -828,7 +828,7 @@ register: cm_non_existing_state - name: Non-existing state (normal_mode) - mso_schema_site_anp_epg_selector: + cisco.mso.mso_schema_site_anp_epg_selector: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: 'aws_{{ mso_site | default("ansible_test") }}' @@ -841,7 +841,7 @@ register: nm_non_existing_state - name: Verify non_existing_state - assert: + ansible.builtin.assert: that: - cm_non_existing_state is not changed - nm_non_existing_state is not changed @@ -850,7 +850,7 @@ # USE A NON-EXISTING TEMPLATE - name: Non-existing template (check_mode) - mso_schema_site_anp_epg_selector: + cisco.mso.mso_schema_site_anp_epg_selector: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: 'aws_{{ mso_site | default("ansible_test") }}' @@ -864,7 +864,7 @@ register: cm_non_existing_template - name: Non-existing template (normal_mode) - mso_schema_site_anp_epg_selector: + cisco.mso.mso_schema_site_anp_epg_selector: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: 'aws_{{ mso_site | default("ansible_test") }}' @@ -877,7 +877,7 @@ register: nm_non_existing_template - name: Verify non_existing_template - assert: + ansible.builtin.assert: that: - cm_non_existing_template is not changed - nm_non_existing_template is not changed @@ -886,7 +886,7 @@ # USE A NON-EXISTING SCHEMA - name: Non-existing schema (check_mode) - mso_schema_site_anp_epg_selector: + cisco.mso.mso_schema_site_anp_epg_selector: <<: *mso_info schema: non-existing-schema site: 'aws_{{ mso_site | default("ansible_test") }}' @@ -900,7 +900,7 @@ register: cm_non_existing_schema - name: Non-existing schema (normal_mode) - mso_schema_site_anp_epg_selector: + cisco.mso.mso_schema_site_anp_epg_selector: <<: *mso_info schema: non-existing-schema site: 'aws_{{ mso_site | default("ansible_test") }}' @@ -913,7 +913,7 @@ register: nm_non_existing_schema - name: Verify non_existing_schema - assert: + ansible.builtin.assert: that: - cm_non_existing_schema is not changed - nm_non_existing_schema is not changed @@ -922,7 +922,7 @@ # USE A NON-EXISTING SITE - name: Non-existing site (check_mode) - mso_schema_site_anp_epg_selector: + cisco.mso.mso_schema_site_anp_epg_selector: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: non-existing-site @@ -936,7 +936,7 @@ register: cm_non_existing_site - name: Non-existing site (normal_mode) - mso_schema_site_anp_epg_selector: + cisco.mso.mso_schema_site_anp_epg_selector: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: non-existing-site @@ -949,7 +949,7 @@ register: nm_non_existing_site - name: Verify non_existing_site - assert: + ansible.builtin.assert: that: - cm_non_existing_site is not changed - nm_non_existing_site is not changed @@ -958,7 +958,7 @@ # USE A NON-EXISTING SITE-TEMPLATE - name: Non-existing site-template (check_mode) - mso_schema_site_anp_epg_selector: + cisco.mso.mso_schema_site_anp_epg_selector: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: 'aws_{{ mso_site | default("ansible_test") }}' @@ -972,7 +972,7 @@ register: cm_non_existing_site_template - name: Non-existing site-template (normal_mode) - mso_schema_site_anp_epg_selector: + cisco.mso.mso_schema_site_anp_epg_selector: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: 'aws_{{ mso_site | default("ansible_test") }}' @@ -985,7 +985,7 @@ register: nm_non_existing_site_template - name: Verify non_existing_site_template - assert: + ansible.builtin.assert: that: - cm_non_existing_site_template is not changed - nm_non_existing_site_template is not changed @@ -993,7 +993,7 @@ - cm_non_existing_site_template.msg == nm_non_existing_site_template.msg == "Provided site-template association 'aws_{{ mso_site | default("ansible_test") }}-Template3' does not exist." - name: Add Selector_4 to site EPG (normal_mode) - mso_schema_site_anp_epg_selector: + cisco.mso.mso_schema_site_anp_epg_selector: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: 'aws_{{ mso_site | default("ansible_test") }}' @@ -1009,13 +1009,13 @@ register: nm_add_site_selector_4 - name: Verify nm_add_site_selector_4 - assert: + ansible.builtin.assert: that: - nm_add_site_selector_4 is not changed - nm_add_site_selector_4.msg == "Operator 'has_key' is not supported when expression type is 'ip_address'" - name: Add Selector_4 to site EPG again (normal_mode) - mso_schema_site_anp_epg_selector: + cisco.mso.mso_schema_site_anp_epg_selector: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: 'aws_{{ mso_site | default("ansible_test") }}' @@ -1031,13 +1031,13 @@ register: nm_add_site_selector_4_again - name: Verify nm_add_site_selector_4 - assert: + ansible.builtin.assert: that: - nm_add_site_selector_4_again is changed - nm_add_site_selector_4_again.current.name == "site_selector_4" - name: Add azure site_selector_1 to site EPG (normal_mode) - mso_schema_site_anp_epg_selector: + cisco.mso.mso_schema_site_anp_epg_selector: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: 'azure_{{ mso_site | default("ansible_test") }}' @@ -1054,14 +1054,14 @@ register: nm_add_azure_site_selector_1 - name: Verify nm_add_azure_site_selector_1 - assert: + ansible.builtin.assert: that: - nm_add_azure_site_selector_1 is not changed - nm_add_azure_site_selector_1.msg == "Type 'zone' is only supported for aws" # USE A TEMPLATE WITHOUT ANY SITE - name: Add site EPG selector to Schema 2 Template 3 without any site associated (check mode) - mso_schema_site_anp_epg_selector: + cisco.mso.mso_schema_site_anp_epg_selector: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}_2' site: 'azure_{{ mso_site | default("ansible_test") }}' @@ -1079,7 +1079,7 @@ register: cm_no_site_associated - name: Add site EPG selector to Template 3 without any site associated (normal mode) - mso_schema_site_anp_epg_selector: + cisco.mso.mso_schema_site_anp_epg_selector: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}_2' site: 'azure_{{ mso_site | default("ansible_test") }}' @@ -1096,7 +1096,7 @@ register: nm_no_site_associated - name: Verify cm_no_site_associated and nm_no_site_associated - assert: + ansible.builtin.assert: that: - cm_no_site_associated is not changed - nm_no_site_associated is not changed diff --git a/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_anp_epg_staticport/tasks/main.yml b/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_anp_epg_staticport/tasks/main.yml index cb50a64e6..054ec970e 100644 --- a/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_anp_epg_staticport/tasks/main.yml +++ b/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_anp_epg_staticport/tasks/main.yml @@ -1,4 +1,5 @@ # Test code for the MSO modules +# Copyright: (c) 2024, Akini Ross (@akinross) <akinross@cisco.com> # Copyright: (c) 2020, Lionel Hercot (@lhercot) <lhercot@cisco.com> # Copyright: (c) 2018, Dag Wieers (@dagwieers) <dag@wieers.com> (based on mso_site test case) # Copyright: (c) 2020, Shreyas Srish (@shrsr) <ssrish@cisco.com> @@ -6,13 +7,13 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI MultiSite host, username and password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: mso_hostname, mso_username and mso_password.' when: mso_hostname is not defined or mso_username is not defined or mso_password is not defined # CLEAN ENVIRONMENT - name: Set vars - set_fact: + ansible.builtin.set_fact: mso_info: &mso_info host: '{{ mso_hostname }}' username: '{{ mso_username }}' @@ -23,7 +24,7 @@ output_level: '{{ mso_output_level | default("info") }}' - name: Remove Schemas - mso_schema: + cisco.mso.mso_schema: <<: *mso_info schema: '{{ item }}' state: absent @@ -32,7 +33,7 @@ - '{{ mso_schema | default("ansible_test") }}' - name: Ensure site exists - mso_site: + cisco.mso.mso_site: <<: *mso_info site: '{{ mso_site | default("ansible_test") }}' apic_username: '{{ apic_username }}' @@ -43,7 +44,7 @@ state: present - name: Ensure sites removed from tenant ansible_test - mso_tenant_site: + cisco.mso.mso_tenant_site: <<: *mso_info tenant: ansible_test site: '{{ item }}' @@ -54,7 +55,7 @@ - 'azure_{{ mso_site | default("ansible_test") }}' - name: Ensure tenant ansible_test exist - mso_tenant: + cisco.mso.mso_tenant: <<: *mso_info tenant: ansible_test users: @@ -64,7 +65,7 @@ state: present - name: Ensure schema 1 with Template 1 and 2 exists - mso_schema_template: + cisco.mso.mso_schema_template: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' tenant: ansible_test @@ -75,7 +76,7 @@ - Template 2 - name: Ensure schema 2 with Template 3 exists - mso_schema_template: + cisco.mso.mso_schema_template: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}_2' tenant: ansible_test @@ -83,7 +84,7 @@ state: present - name: Add a new site to a schema - mso_schema_site: + cisco.mso.mso_schema_site: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -91,7 +92,7 @@ state: present - name: Ensure VRF1 exists - mso_schema_template_vrf: + cisco.mso.mso_schema_template_vrf: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -99,7 +100,7 @@ state: present - name: Add BD1 - mso_schema_template_bd: + cisco.mso.mso_schema_template_bd: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -109,7 +110,7 @@ state: present - name: Ensure Template 1 with AP1 exists - mso_schema_template_anp: + cisco.mso.mso_schema_template_anp: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -117,7 +118,7 @@ state: present - name: Ensure Template 1 and AP1 with EPG1 exists - mso_schema_template_anp_epg: + cisco.mso.mso_schema_template_anp_epg: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -130,7 +131,7 @@ state: present - name: Ensure Template 1 and AP1 with EPG3 exists - mso_schema_template_anp_epg: + cisco.mso.mso_schema_template_anp_epg: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -143,7 +144,7 @@ state: present - name: Ensure Template 1 with AP2 exists - mso_schema_template_anp: + cisco.mso.mso_schema_template_anp: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -151,7 +152,7 @@ state: present - name: Ensure Template 1 and AP2 with EPG2 exists - mso_schema_template_anp_epg: + cisco.mso.mso_schema_template_anp_epg: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -164,7 +165,7 @@ state: present - name: Ensure Template 1 and AP2 with EPG4 exists - mso_schema_template_anp_epg: + cisco.mso.mso_schema_template_anp_epg: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -177,7 +178,7 @@ state: present - name: Ensure Template 1 and AP2 with EPG6 exists - mso_schema_template_anp_epg: + cisco.mso.mso_schema_template_anp_epg: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -191,7 +192,7 @@ # ADD STATIC PORTS - name: Add static port 1 to site EPG1 of AP1 (check mode) - mso_schema_site_anp_epg_staticport: + cisco.mso.mso_schema_site_anp_epg_staticport: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -210,7 +211,7 @@ register: cm_add_stat1e1 - name: Verify cm_add_stat1e1 - assert: + ansible.builtin.assert: that: - cm_add_stat1e1 is changed - cm_add_stat1e1.previous == {} @@ -221,7 +222,7 @@ - cm_add_stat1e1.current.type == 'port' - name: Add static port 1 to site EPG1 of AP1 (normal mode) - mso_schema_site_anp_epg_staticport: + cisco.mso.mso_schema_site_anp_epg_staticport: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -238,7 +239,7 @@ register: nm_add_stat1e1 - name: Verify nm_add_stat1e1 - assert: + ansible.builtin.assert: that: - nm_add_stat1e1 is changed - nm_add_stat1e1.previous == {} @@ -249,7 +250,7 @@ - nm_add_stat1e1.current.type == 'port' - name: Add static port 2 to site EPG1 of AP1 (normal mode) - mso_schema_site_anp_epg_staticport: + cisco.mso.mso_schema_site_anp_epg_staticport: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -268,7 +269,7 @@ register: nm_add_stat2e1 - name: Verify nm_add_stat2e1 - assert: + ansible.builtin.assert: that: - nm_add_stat2e1 is changed - nm_add_stat2e1.previous == {} @@ -280,7 +281,7 @@ - name: Add static port 3 (vpc) to site EPG1 of AP1 (normal mode) - mso_schema_site_anp_epg_staticport: + cisco.mso.mso_schema_site_anp_epg_staticport: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -298,7 +299,7 @@ register: nm_add_stat3e1 - name: Verify nm_add_stat3e1 - assert: + ansible.builtin.assert: that: - nm_add_stat3e1 is changed - nm_add_stat3e1.previous == {} @@ -309,7 +310,7 @@ - nm_add_stat3e1.current.type == 'vpc' - name: Add static port 1 to site EPG3 of AP1 (normal mode) - mso_schema_site_anp_epg_staticport: + cisco.mso.mso_schema_site_anp_epg_staticport: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -327,7 +328,7 @@ register: nm_add_stat1e3 - name: Verify nm_add_stat1e3 - assert: + ansible.builtin.assert: that: - nm_add_stat1e3 is changed - nm_add_stat1e3.previous == {} @@ -338,7 +339,7 @@ - nm_add_stat1e3.current.type == 'port' - name: Add static port 2 (dpc) to EPG6 of AP2 (normal mode) - mso_schema_site_anp_epg_staticport: + cisco.mso.mso_schema_site_anp_epg_staticport: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -357,7 +358,7 @@ register: nm_add_stat2e6 - name: Verify nm_add_stat2e6 - assert: + ansible.builtin.assert: that: - nm_add_stat2e6 is changed - nm_add_stat2e6.previous == {} @@ -370,7 +371,7 @@ # QUERY STATIC PORTS - name: Query STATIC PORTS of site EPG1 with AP1 (normal mode) - mso_schema_site_anp_epg_staticport: + cisco.mso.mso_schema_site_anp_epg_staticport: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -381,13 +382,13 @@ register: nm_query_statse1 - name: Verify nm_query_statse1 - assert: + ansible.builtin.assert: that: - nm_query_statse1 is not changed # QUERY A STATIC PORT - name: Query static port 3 (vpc) of site EPG1 with AP1 (normal mode) - mso_schema_site_anp_epg_staticport: + cisco.mso.mso_schema_site_anp_epg_staticport: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -405,13 +406,13 @@ register: nm_query_stat3e1 - name: Verify nm_query_stat3e1 - assert: + ansible.builtin.assert: that: - nm_query_stat3e1 is not changed # QUERY REMOVED STATIC PORT - name: Add static port 2 to site EPG2 (normal mode) - mso_schema_site_anp_epg_staticport: + cisco.mso.mso_schema_site_anp_epg_staticport: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -429,7 +430,7 @@ register: nm_add_stat2e2 - name: Verify nm_add_stat2e2 - assert: + ansible.builtin.assert: that: - nm_add_stat2e2 is changed - nm_add_stat2e2.previous == {} @@ -440,7 +441,7 @@ - nm_add_stat2e2.current.type == 'port' - name: Remove static port 2 from EPG2 (normal mode) - mso_schema_site_anp_epg_staticport: + cisco.mso.mso_schema_site_anp_epg_staticport: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -458,12 +459,12 @@ register: nm_remove_stat2e2 - name: Verify nm_remove_stat2e2 - assert: + ansible.builtin.assert: that: - nm_remove_stat2e2 is changed - name: Query removed static port 2 from EPG2 (normal mode) - mso_schema_site_anp_epg_staticport: + cisco.mso.mso_schema_site_anp_epg_staticport: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -482,13 +483,13 @@ register: nm_non_existent_dom2e2 - name: Verify non_existing_domain - assert: + ansible.builtin.assert: that: - nm_non_existent_dom2e2 is not changed - - nm_non_existent_dom2e2.msg == "Static port 'topology/pod-2/paths-102/pathep-[eth1/2]' not found" + - nm_non_existent_dom2e2.msg == "Provided Static Port Path 'topology/pod-2/paths-102/pathep-[eth1/2]' not found" - name: Remove static port 2 from EPG2 again(normal mode) - mso_schema_site_anp_epg_staticport: + cisco.mso.mso_schema_site_anp_epg_staticport: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -507,13 +508,13 @@ register: nm_remove_again_stat2e2 - name: Verify nm_remove_again_stat2e2 - assert: + ansible.builtin.assert: that: - nm_remove_again_stat2e2 is not changed # ADD EXISTING STATIC PORT - name: Add static port 1 to site EPG1 again (normal mode) - mso_schema_site_anp_epg_staticport: + cisco.mso.mso_schema_site_anp_epg_staticport: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -531,13 +532,13 @@ register: nm_add_stat1e1_2 - name: Verify nm_add_stat1e1_2 - assert: + ansible.builtin.assert: that: - nm_add_stat1e1_2 is not changed # ADD STATIC PORT WITH NO STATE - name: Add static port 1 to site EPG1 again with no state (normal mode) - mso_schema_site_anp_epg_staticport: + cisco.mso.mso_schema_site_anp_epg_staticport: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -555,13 +556,13 @@ register: nm_add_stateless_stat1e1_2 - name: Verify nm_add_stateless_stat1e1_2 - assert: + ansible.builtin.assert: that: - nm_add_stateless_stat1e1_2 is not changed # ADD STATIC FEX PORT - name: Add static fex port to site EPG1 with AP1 (normal mode) - mso_schema_site_anp_epg_staticport: + cisco.mso.mso_schema_site_anp_epg_staticport: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -580,7 +581,7 @@ register: nm_add_statfex - name: Verify nm_add_statfex - assert: + ansible.builtin.assert: that: - nm_add_statfex is changed - nm_add_statfex.previous == {} @@ -592,7 +593,7 @@ # VERIFY NON EXISTENT DEPLOYMENT IMMEDIACY - name: Add static port 1 to site EPG4 with AP2 with no deployment immediacy (normal mode) - mso_schema_site_anp_epg_staticport: + cisco.mso.mso_schema_site_anp_epg_staticport: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -609,13 +610,13 @@ register: nm_add_stat_di - name: Verify nm_add_stat_di - assert: + ansible.builtin.assert: that: - nm_add_stat_di.current.deploymentImmediacy == 'lazy' # VERIFY NON EXISTENT MODE - name: Add static port 1 to site EPG4 with AP2 with no mode (normal mode) - mso_schema_site_anp_epg_staticport: + cisco.mso.mso_schema_site_anp_epg_staticport: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -632,13 +633,13 @@ register: nm_add_stat_mode - name: Verify nm_add_stat_mode - assert: + ansible.builtin.assert: that: - nm_add_stat_mode.current.mode == 'untagged' # USE NON-EXISTING EPG and ANP AT TEMPLATE LEVEL - name: Add static port 1 to non-existent site EPG5 (normal mode) - mso_schema_site_anp_epg_staticport: + cisco.mso.mso_schema_site_anp_epg_staticport: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -657,13 +658,13 @@ register: nm_add_stat1e5 - name: Verify nm_add_stat1e5 - assert: + ansible.builtin.assert: that: - nm_add_stat1e5 is not changed # USE NON-EXISTING EPG AT TEMPLATE LEVEL - name: Add static port 1 to non-existent site EPG5 (normal mode) - mso_schema_site_anp_epg_staticport: + cisco.mso.mso_schema_site_anp_epg_staticport: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -681,13 +682,13 @@ register: nm_add_stat1e6 - name: Verify nm_add_stat1e6 - assert: + ansible.builtin.assert: that: - nm_add_stat1e6 is not changed # USE A NON-EXISTING SCHEMA - name: Non-existing schema for static port (check_mode) - mso_schema_site_anp_epg_staticport: + cisco.mso.mso_schema_site_anp_epg_staticport: <<: *mso_info schema: non_existing_schema site: '{{ mso_site | default("ansible_test") }}' @@ -706,7 +707,7 @@ register: cm_non_existing_schema - name: Non-existing schema for static port (normal_mode) - mso_schema_site_anp_epg_staticport: + cisco.mso.mso_schema_site_anp_epg_staticport: <<: *mso_info schema: non_existing_schema site: '{{ mso_site | default("ansible_test") }}' @@ -724,7 +725,7 @@ register: nm_non_existing_schema - name: Verify non_existing_schema - assert: + ansible.builtin.assert: that: - cm_non_existing_schema is not changed - nm_non_existing_schema is not changed @@ -733,7 +734,7 @@ # USE A NON-EXISTING TEMPLATE - name: Non-existing template for static port (check_mode) - mso_schema_site_anp_epg_staticport: + cisco.mso.mso_schema_site_anp_epg_staticport: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -752,7 +753,7 @@ register: cm_non_existing_template - name: Non-existing template for static port (normal_mode) - mso_schema_site_anp_epg_staticport: + cisco.mso.mso_schema_site_anp_epg_staticport: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -770,16 +771,16 @@ register: nm_non_existing_template - name: Verify non_existing_template - assert: + ansible.builtin.assert: that: - cm_non_existing_template is not changed - nm_non_existing_template is not changed - cm_non_existing_template == nm_non_existing_template - - cm_non_existing_template.msg == nm_non_existing_template.msg == "Provided template 'non_existing_template' does not exist. Existing templates{{':'}} Template1, Template2" + - cm_non_existing_template.msg == nm_non_existing_template.msg == "Provided template 'non_existing_template' not matching existing template(s){{":"}} Template1, Template2" # USE A NON-EXISTING SITE - name: Non-existing site for static port (check_mode) - mso_schema_site_anp_epg_staticport: + cisco.mso.mso_schema_site_anp_epg_staticport: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -798,7 +799,7 @@ register: cm_non_existing_site - name: Non-existing site for static port (normal_mode) - mso_schema_site_anp_epg_staticport: + cisco.mso.mso_schema_site_anp_epg_staticport: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -816,17 +817,17 @@ register: nm_non_existing_site - name: Verify non_existing_site - assert: + ansible.builtin.assert: that: - cm_non_existing_site is not changed - nm_non_existing_site is not changed - cm_non_existing_site == nm_non_existing_site - - cm_non_existing_site.msg is match("Provided site/siteId/template 'ansible_test/[0-9a-zA-Z]*/Template2' does not exist. Existing siteIds/templates{{':'}} [0-9a-zA-Z]*/Template1") - - nm_non_existing_site.msg is match("Provided site/siteId/template 'ansible_test/[0-9a-zA-Z]*/Template2' does not exist. Existing siteIds/templates{{':'}} [0-9a-zA-Z]*/Template1") + - cm_non_existing_site.msg == "Provided site 'ansible_test' not associated with template 'Template2'. Site is currently associated with template(s){{':'}} Template1" + - nm_non_existing_site.msg == "Provided site 'ansible_test' not associated with template 'Template2'. Site is currently associated with template(s){{':'}} Template1" # USE A TEMPLATE WITHOUT ANY SITE - name: Add site EPG static port association to Schema 2 Template 3 without any site associated (check mode) - mso_schema_site_anp_epg_staticport: + cisco.mso.mso_schema_site_anp_epg_staticport: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}_2' site: '{{ mso_site | default("ansible_test") }}' @@ -845,7 +846,7 @@ register: cm_no_site_associated - name: Add site EPG static port association to Template 3 without any site associated (normal mode) - mso_schema_site_anp_epg_staticport: + cisco.mso.mso_schema_site_anp_epg_staticport: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}_2' site: '{{ mso_site | default("ansible_test") }}' @@ -863,8 +864,557 @@ register: nm_no_site_associated - name: Verify cm_no_site_associated and nm_no_site_associated - assert: + ansible.builtin.assert: that: - cm_no_site_associated is not changed - nm_no_site_associated is not changed - - cm_no_site_associated.msg == nm_no_site_associated.msg == "No site associated with template 'Template3'. Associate the site with the template using mso_schema_site."
\ No newline at end of file + - cm_no_site_associated.msg == nm_no_site_associated.msg == "No sites associated with schema 'ansible_test_2'. Associate the site with the schema using (M) mso_schema_site." + +# TESTS IN BULK + +# SETUP TEST ENVIRONMENT FOR BULK + +- name: Remove Schemas for bulk + cisco.mso.mso_schema: + <<: *mso_info + schema: '{{ item }}' + state: absent + loop: + - '{{ mso_schema | default("ansible_test") }}_2' + - '{{ mso_schema | default("ansible_test") }}' + +- name: Create schema ansible_test with template_bulk + cisco.mso.mso_schema_template: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + tenant: ansible_test + template: template_bulk + +- name: Create vrf_bulk in template_bulk + cisco.mso.mso_schema_template_vrf: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: template_bulk + vrf: vrf_bulk + +- name: Create bd_bulk in template_bulk + cisco.mso.mso_schema_template_bd: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: template_bulk + bd: bd_bulk + vrf: + name: vrf_bulk + +- name: Create anp_bulk in template_bulk + cisco.mso.mso_schema_template_anp: &anp_bulk + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: template_bulk + anp: anp_bulk + +- name: Create EPG in template_bulk + cisco.mso.mso_schema_template_anp_epg: + <<: *anp_bulk + epg: epg_bulk + bd: + name: bd_bulk + vrf: + name: vrf_bulk + +- name: Add site to template_bulk + cisco.mso.mso_schema_site: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: '{{ mso_site | default("ansible_test") }}' + template: template_bulk + +- name: Set facts for static_ports + ansible.builtin.set_fact: + static_ports_present: [] + static_ports_present_2: [] + static_ports_absent: [] + static_ports_absent_2: [] + +- name: Create static_ports list for appending + ansible.builtin.set_fact: + static_ports_present: "{{ static_ports_present + [{'pod': 'pod-1', 'leaf': '101', 'path': 'eth1/%s' | format(item), 'vlan': '110%s' | format(item)}] }}" + static_ports_present_2: "{{ static_ports_present_2 + [{'pod': 'pod-1', 'leaf': '101', 'path': 'eth2/%s' | format(item), 'vlan': '120%s' | format(item)}] }}" + loop: "{{ range(0, 10, 1) | list }}" + +- name: Create static_ports list for removing + ansible.builtin.set_fact: + static_ports_absent: "{{ static_ports_absent + [{'pod': 'pod-1', 'leaf': '101', 'path': 'eth1/%s' | format(item), 'vlan': '110%s' | format(item)}] }}" + static_ports_absent_2: "{{ static_ports_absent_2 + [{'pod': 'pod-1', 'leaf': '101', 'path': 'eth2/%s' | format(item), 'vlan': '120%s' | format(item)}] }}" + loop: "{{ range(0, 10, 2) | list }}" + +# CREATE AND UPDATE TESTS FOR BULK + +- name: Append static ports (check_mode) + cisco.mso.mso_schema_site_anp_epg_staticport: &static_ports_append + <<: *anp_bulk + epg: epg_bulk + site: '{{ mso_site | default("ansible_test") }}' + static_ports: "{{ static_ports_present }}" + register: cm_append_static_ports + check_mode: true + +- name: Append static ports + cisco.mso.mso_schema_site_anp_epg_staticport: + <<: *static_ports_append + register: nm_append_static_ports + +- name: Append static ports again + cisco.mso.mso_schema_site_anp_epg_staticport: + <<: *static_ports_append + register: nm_append_static_ports_again + +- name: Append additional static ports + cisco.mso.mso_schema_site_anp_epg_staticport: + <<: *static_ports_append + static_ports: "{{ static_ports_present_2 }}" + register: nm_append_static_ports_2 + +- name: Verify appending static ports + ansible.builtin.assert: + that: + - cm_append_static_ports is changed + - cm_append_static_ports.previous == [] + - cm_append_static_ports.current | length == 10 + - cm_append_static_ports.current.0.path == "topology/pod-1/paths-101/pathep-[eth1/0]" + - cm_append_static_ports.current.0.portEncapVlan == 1100 + - cm_append_static_ports.current.3.path == "topology/pod-1/paths-101/pathep-[eth1/3]" + - cm_append_static_ports.current.3.portEncapVlan == 1103 + - cm_append_static_ports.current.9.path == "topology/pod-1/paths-101/pathep-[eth1/9]" + - cm_append_static_ports.current.9.portEncapVlan == 1109 + - nm_append_static_ports is changed + - nm_append_static_ports.previous == [] + - nm_append_static_ports.current | length == 10 + - nm_append_static_ports.current.0.path == "topology/pod-1/paths-101/pathep-[eth1/0]" + - nm_append_static_ports.current.0.portEncapVlan == 1100 + - nm_append_static_ports.current.3.path == "topology/pod-1/paths-101/pathep-[eth1/3]" + - nm_append_static_ports.current.3.portEncapVlan == 1103 + - nm_append_static_ports.current.9.path == "topology/pod-1/paths-101/pathep-[eth1/9]" + - nm_append_static_ports.current.9.portEncapVlan == 1109 + - nm_append_static_ports_again is not changed + - nm_append_static_ports_again.previous | length == 10 + - nm_append_static_ports_again.previous.0.path == "topology/pod-1/paths-101/pathep-[eth1/0]" + - nm_append_static_ports_again.previous.0.portEncapVlan == 1100 + - nm_append_static_ports_again.previous.3.path == "topology/pod-1/paths-101/pathep-[eth1/3]" + - nm_append_static_ports_again.previous.3.portEncapVlan == 1103 + - nm_append_static_ports_again.previous.9.path == "topology/pod-1/paths-101/pathep-[eth1/9]" + - nm_append_static_ports_again.previous.9.portEncapVlan == 1109 + - nm_append_static_ports_again.current | length == 10 + - nm_append_static_ports_again.current.0.path == "topology/pod-1/paths-101/pathep-[eth1/0]" + - nm_append_static_ports_again.current.0.portEncapVlan == 1100 + - nm_append_static_ports_again.current.3.path == "topology/pod-1/paths-101/pathep-[eth1/3]" + - nm_append_static_ports_again.current.3.portEncapVlan == 1103 + - nm_append_static_ports_again.current.9.path == "topology/pod-1/paths-101/pathep-[eth1/9]" + - nm_append_static_ports_again.current.9.portEncapVlan == 1109 + - nm_append_static_ports_2 is changed + - nm_append_static_ports_2.previous | length == 10 + - nm_append_static_ports_2.previous.0.path == "topology/pod-1/paths-101/pathep-[eth1/0]" + - nm_append_static_ports_2.previous.0.portEncapVlan == 1100 + - nm_append_static_ports_2.previous.3.path == "topology/pod-1/paths-101/pathep-[eth1/3]" + - nm_append_static_ports_2.previous.3.portEncapVlan == 1103 + - nm_append_static_ports_2.previous.9.path == "topology/pod-1/paths-101/pathep-[eth1/9]" + - nm_append_static_ports_2.previous.9.portEncapVlan == 1109 + - nm_append_static_ports_2.current | length == 20 + - nm_append_static_ports_2.current.0.path == "topology/pod-1/paths-101/pathep-[eth1/0]" + - nm_append_static_ports_2.current.0.portEncapVlan == 1100 + - nm_append_static_ports_2.current.3.path == "topology/pod-1/paths-101/pathep-[eth1/3]" + - nm_append_static_ports_2.current.3.portEncapVlan == 1103 + - nm_append_static_ports_2.current.9.path == "topology/pod-1/paths-101/pathep-[eth1/9]" + - nm_append_static_ports_2.current.9.portEncapVlan == 1109 + - nm_append_static_ports_2.current.10.path == "topology/pod-1/paths-101/pathep-[eth2/0]" + - nm_append_static_ports_2.current.10.portEncapVlan == 1200 + - nm_append_static_ports_2.current.13.path == "topology/pod-1/paths-101/pathep-[eth2/3]" + - nm_append_static_ports_2.current.13.portEncapVlan == 1203 + - nm_append_static_ports_2.current.19.path == "topology/pod-1/paths-101/pathep-[eth2/9]" + - nm_append_static_ports_2.current.19.portEncapVlan == 1209 + +# REMOVE AND UPDATE TESTS FOR BULK + +- name: Remove static ports (check_mode) + cisco.mso.mso_schema_site_anp_epg_staticport: &static_ports_remove + <<: *static_ports_append + static_ports: "{{ static_ports_absent }}" + state: absent + register: cm_remove_static_ports + check_mode: true + +- name: Remove static ports + cisco.mso.mso_schema_site_anp_epg_staticport: + <<: *static_ports_remove + register: nm_remove_static_ports + +- name: Remove static ports again + cisco.mso.mso_schema_site_anp_epg_staticport: + <<: *static_ports_remove + register: nm_remove_static_ports_again + +- name: Remove additional static ports + cisco.mso.mso_schema_site_anp_epg_staticport: + <<: *static_ports_remove + static_ports: "{{ static_ports_absent_2 }}" + register: nm_remove_static_ports_2 + +- name: Verify removing static ports + ansible.builtin.assert: + that: + - cm_remove_static_ports is changed + - cm_remove_static_ports.previous | length == 20 + - cm_remove_static_ports.previous.0.path == "topology/pod-1/paths-101/pathep-[eth1/0]" + - cm_remove_static_ports.previous.0.portEncapVlan == 1100 + - cm_remove_static_ports.previous.3.path == "topology/pod-1/paths-101/pathep-[eth1/3]" + - cm_remove_static_ports.previous.3.portEncapVlan == 1103 + - cm_remove_static_ports.previous.9.path == "topology/pod-1/paths-101/pathep-[eth1/9]" + - cm_remove_static_ports.previous.9.portEncapVlan == 1109 + - cm_remove_static_ports.previous.10.path == "topology/pod-1/paths-101/pathep-[eth2/0]" + - cm_remove_static_ports.previous.10.portEncapVlan == 1200 + - cm_remove_static_ports.previous.13.path == "topology/pod-1/paths-101/pathep-[eth2/3]" + - cm_remove_static_ports.previous.13.portEncapVlan == 1203 + - cm_remove_static_ports.previous.19.path == "topology/pod-1/paths-101/pathep-[eth2/9]" + - cm_remove_static_ports.previous.19.portEncapVlan == 1209 + - cm_remove_static_ports.current | length == 15 + - cm_remove_static_ports.current.0.path == "topology/pod-1/paths-101/pathep-[eth1/1]" + - cm_remove_static_ports.current.0.portEncapVlan == 1101 + - cm_remove_static_ports.current.2.path == "topology/pod-1/paths-101/pathep-[eth1/5]" + - cm_remove_static_ports.current.2.portEncapVlan == 1105 + - cm_remove_static_ports.current.4.path == "topology/pod-1/paths-101/pathep-[eth1/9]" + - cm_remove_static_ports.current.4.portEncapVlan == 1109 + - cm_remove_static_ports.current.5.path == "topology/pod-1/paths-101/pathep-[eth2/0]" + - cm_remove_static_ports.current.5.portEncapVlan == 1200 + - cm_remove_static_ports.current.8.path == "topology/pod-1/paths-101/pathep-[eth2/3]" + - cm_remove_static_ports.current.8.portEncapVlan == 1203 + - cm_remove_static_ports.current.14.path == "topology/pod-1/paths-101/pathep-[eth2/9]" + - cm_remove_static_ports.current.14.portEncapVlan == 1209 + - nm_remove_static_ports is changed + - nm_remove_static_ports.previous | length == 20 + - nm_remove_static_ports.previous.0.path == "topology/pod-1/paths-101/pathep-[eth1/0]" + - nm_remove_static_ports.previous.0.portEncapVlan == 1100 + - nm_remove_static_ports.previous.3.path == "topology/pod-1/paths-101/pathep-[eth1/3]" + - nm_remove_static_ports.previous.3.portEncapVlan == 1103 + - nm_remove_static_ports.previous.9.path == "topology/pod-1/paths-101/pathep-[eth1/9]" + - nm_remove_static_ports.previous.9.portEncapVlan == 1109 + - nm_remove_static_ports.previous.10.path == "topology/pod-1/paths-101/pathep-[eth2/0]" + - nm_remove_static_ports.previous.10.portEncapVlan == 1200 + - nm_remove_static_ports.previous.13.path == "topology/pod-1/paths-101/pathep-[eth2/3]" + - nm_remove_static_ports.previous.13.portEncapVlan == 1203 + - nm_remove_static_ports.previous.19.path == "topology/pod-1/paths-101/pathep-[eth2/9]" + - nm_remove_static_ports.previous.19.portEncapVlan == 1209 + - nm_remove_static_ports.current | length == 15 + - nm_remove_static_ports.current.0.path == "topology/pod-1/paths-101/pathep-[eth1/1]" + - nm_remove_static_ports.current.0.portEncapVlan == 1101 + - nm_remove_static_ports.current.2.path == "topology/pod-1/paths-101/pathep-[eth1/5]" + - nm_remove_static_ports.current.2.portEncapVlan == 1105 + - nm_remove_static_ports.current.4.path == "topology/pod-1/paths-101/pathep-[eth1/9]" + - nm_remove_static_ports.current.4.portEncapVlan == 1109 + - nm_remove_static_ports.current.5.path == "topology/pod-1/paths-101/pathep-[eth2/0]" + - nm_remove_static_ports.current.5.portEncapVlan == 1200 + - nm_remove_static_ports.current.8.path == "topology/pod-1/paths-101/pathep-[eth2/3]" + - nm_remove_static_ports.current.8.portEncapVlan == 1203 + - nm_remove_static_ports.current.14.path == "topology/pod-1/paths-101/pathep-[eth2/9]" + - nm_remove_static_ports.current.14.portEncapVlan == 1209 + - nm_remove_static_ports_again is not changed + - nm_remove_static_ports_again.previous | length == 15 + - nm_remove_static_ports_again.previous.0.path == "topology/pod-1/paths-101/pathep-[eth1/1]" + - nm_remove_static_ports_again.previous.0.portEncapVlan == 1101 + - nm_remove_static_ports_again.previous.2.path == "topology/pod-1/paths-101/pathep-[eth1/5]" + - nm_remove_static_ports_again.previous.2.portEncapVlan == 1105 + - nm_remove_static_ports_again.previous.4.path == "topology/pod-1/paths-101/pathep-[eth1/9]" + - nm_remove_static_ports_again.previous.4.portEncapVlan == 1109 + - nm_remove_static_ports_again.previous.5.path == "topology/pod-1/paths-101/pathep-[eth2/0]" + - nm_remove_static_ports_again.previous.5.portEncapVlan == 1200 + - nm_remove_static_ports_again.previous.8.path == "topology/pod-1/paths-101/pathep-[eth2/3]" + - nm_remove_static_ports_again.previous.8.portEncapVlan == 1203 + - nm_remove_static_ports_again.previous.14.path == "topology/pod-1/paths-101/pathep-[eth2/9]" + - nm_remove_static_ports_again.previous.14.portEncapVlan == 1209 + - nm_remove_static_ports_again.current | length == 15 + - nm_remove_static_ports_again.current.0.path == "topology/pod-1/paths-101/pathep-[eth1/1]" + - nm_remove_static_ports_again.current.0.portEncapVlan == 1101 + - nm_remove_static_ports_again.current.2.path == "topology/pod-1/paths-101/pathep-[eth1/5]" + - nm_remove_static_ports_again.current.2.portEncapVlan == 1105 + - nm_remove_static_ports_again.current.4.path == "topology/pod-1/paths-101/pathep-[eth1/9]" + - nm_remove_static_ports_again.current.4.portEncapVlan == 1109 + - nm_remove_static_ports_again.current.5.path == "topology/pod-1/paths-101/pathep-[eth2/0]" + - nm_remove_static_ports_again.current.5.portEncapVlan == 1200 + - nm_remove_static_ports_again.current.8.path == "topology/pod-1/paths-101/pathep-[eth2/3]" + - nm_remove_static_ports_again.current.8.portEncapVlan == 1203 + - nm_remove_static_ports_again.current.14.path == "topology/pod-1/paths-101/pathep-[eth2/9]" + - nm_remove_static_ports_again.current.14.portEncapVlan == 1209 + - nm_remove_static_ports_2 is changed + - nm_remove_static_ports_2.previous | length == 15 + - nm_remove_static_ports_2.previous.0.path == "topology/pod-1/paths-101/pathep-[eth1/1]" + - nm_remove_static_ports_2.previous.0.portEncapVlan == 1101 + - nm_remove_static_ports_2.previous.2.path == "topology/pod-1/paths-101/pathep-[eth1/5]" + - nm_remove_static_ports_2.previous.2.portEncapVlan == 1105 + - nm_remove_static_ports_2.previous.4.path == "topology/pod-1/paths-101/pathep-[eth1/9]" + - nm_remove_static_ports_2.previous.4.portEncapVlan == 1109 + - nm_remove_static_ports_2.previous.5.path == "topology/pod-1/paths-101/pathep-[eth2/0]" + - nm_remove_static_ports_2.previous.5.portEncapVlan == 1200 + - nm_remove_static_ports_2.previous.8.path == "topology/pod-1/paths-101/pathep-[eth2/3]" + - nm_remove_static_ports_2.previous.8.portEncapVlan == 1203 + - nm_remove_static_ports_2.previous.14.path == "topology/pod-1/paths-101/pathep-[eth2/9]" + - nm_remove_static_ports_2.previous.14.portEncapVlan == 1209 + - nm_remove_static_ports_2.current | length == 10 + - nm_remove_static_ports_2.current.0.path == "topology/pod-1/paths-101/pathep-[eth1/1]" + - nm_remove_static_ports_2.current.0.portEncapVlan == 1101 + - nm_remove_static_ports_2.current.2.path == "topology/pod-1/paths-101/pathep-[eth1/5]" + - nm_remove_static_ports_2.current.2.portEncapVlan == 1105 + - nm_remove_static_ports_2.current.4.path == "topology/pod-1/paths-101/pathep-[eth1/9]" + - nm_remove_static_ports_2.current.4.portEncapVlan == 1109 + - nm_remove_static_ports_2.current.5.path == "topology/pod-1/paths-101/pathep-[eth2/1]" + - nm_remove_static_ports_2.current.5.portEncapVlan == 1201 + - nm_remove_static_ports_2.current.7.path == "topology/pod-1/paths-101/pathep-[eth2/5]" + - nm_remove_static_ports_2.current.7.portEncapVlan == 1205 + - nm_remove_static_ports_2.current.9.path == "topology/pod-1/paths-101/pathep-[eth2/9]" + - nm_remove_static_ports_2.current.9.portEncapVlan == 1209 + +# FORCE REPLACE TESTS + +- name: Force replace static ports with static ports (check_mode) + cisco.mso.mso_schema_site_anp_epg_staticport: + <<: *static_ports_append + force_replace: true + register: cm_force_replace_provider_static_ports + check_mode: true + +- name: Force replace static ports with static ports + cisco.mso.mso_schema_site_anp_epg_staticport: + <<: *static_ports_append + force_replace: true + register: nm_force_replace_provider_static_ports + +- name: Force replace static ports with static ports again + cisco.mso.mso_schema_site_anp_epg_staticport: + <<: *static_ports_append + force_replace: true + register: nm_force_replace_provider_static_ports_again + +- name: Force replace static ports with new static ports + cisco.mso.mso_schema_site_anp_epg_staticport: + <<: *static_ports_append + static_ports: "{{ static_ports_present_2 }}" + force_replace: true + register: nm_force_replace_new_static_ports + +- name: Verify force replacing static ports + ansible.builtin.assert: + that: + - cm_force_replace_provider_static_ports is changed + - cm_force_replace_provider_static_ports.previous | length == 10 + - cm_force_replace_provider_static_ports.previous.0.path == "topology/pod-1/paths-101/pathep-[eth1/1]" + - cm_force_replace_provider_static_ports.previous.0.portEncapVlan == 1101 + - cm_force_replace_provider_static_ports.previous.2.path == "topology/pod-1/paths-101/pathep-[eth1/5]" + - cm_force_replace_provider_static_ports.previous.2.portEncapVlan == 1105 + - cm_force_replace_provider_static_ports.previous.4.path == "topology/pod-1/paths-101/pathep-[eth1/9]" + - cm_force_replace_provider_static_ports.previous.4.portEncapVlan == 1109 + - cm_force_replace_provider_static_ports.previous.5.path == "topology/pod-1/paths-101/pathep-[eth2/1]" + - cm_force_replace_provider_static_ports.previous.5.portEncapVlan == 1201 + - cm_force_replace_provider_static_ports.previous.7.path == "topology/pod-1/paths-101/pathep-[eth2/5]" + - cm_force_replace_provider_static_ports.previous.7.portEncapVlan == 1205 + - cm_force_replace_provider_static_ports.previous.9.path == "topology/pod-1/paths-101/pathep-[eth2/9]" + - cm_force_replace_provider_static_ports.previous.9.portEncapVlan == 1209 + - cm_force_replace_provider_static_ports.current | length == 10 + - cm_force_replace_provider_static_ports.current.0.path == "topology/pod-1/paths-101/pathep-[eth1/0]" + - cm_force_replace_provider_static_ports.current.0.portEncapVlan == 1100 + - cm_force_replace_provider_static_ports.current.3.path == "topology/pod-1/paths-101/pathep-[eth1/3]" + - cm_force_replace_provider_static_ports.current.3.portEncapVlan == 1103 + - cm_force_replace_provider_static_ports.current.9.path == "topology/pod-1/paths-101/pathep-[eth1/9]" + - cm_force_replace_provider_static_ports.current.9.portEncapVlan == 1109 + - cm_force_replace_provider_static_ports.current | length == 10 + - nm_force_replace_provider_static_ports is changed + - nm_force_replace_provider_static_ports.previous | length == 10 + - nm_force_replace_provider_static_ports.previous.0.path == "topology/pod-1/paths-101/pathep-[eth1/1]" + - nm_force_replace_provider_static_ports.previous.0.portEncapVlan == 1101 + - nm_force_replace_provider_static_ports.previous.2.path == "topology/pod-1/paths-101/pathep-[eth1/5]" + - nm_force_replace_provider_static_ports.previous.2.portEncapVlan == 1105 + - nm_force_replace_provider_static_ports.previous.4.path == "topology/pod-1/paths-101/pathep-[eth1/9]" + - nm_force_replace_provider_static_ports.previous.4.portEncapVlan == 1109 + - nm_force_replace_provider_static_ports.previous.5.path == "topology/pod-1/paths-101/pathep-[eth2/1]" + - nm_force_replace_provider_static_ports.previous.5.portEncapVlan == 1201 + - nm_force_replace_provider_static_ports.previous.7.path == "topology/pod-1/paths-101/pathep-[eth2/5]" + - nm_force_replace_provider_static_ports.previous.7.portEncapVlan == 1205 + - nm_force_replace_provider_static_ports.previous.9.path == "topology/pod-1/paths-101/pathep-[eth2/9]" + - nm_force_replace_provider_static_ports.previous.9.portEncapVlan == 1209 + - nm_force_replace_provider_static_ports.current | length == 10 + - nm_force_replace_provider_static_ports.current.0.path == "topology/pod-1/paths-101/pathep-[eth1/0]" + - nm_force_replace_provider_static_ports.current.0.portEncapVlan == 1100 + - nm_force_replace_provider_static_ports.current.3.path == "topology/pod-1/paths-101/pathep-[eth1/3]" + - nm_force_replace_provider_static_ports.current.3.portEncapVlan == 1103 + - nm_force_replace_provider_static_ports.current.9.path == "topology/pod-1/paths-101/pathep-[eth1/9]" + - nm_force_replace_provider_static_ports.current.9.portEncapVlan == 1109 + - nm_force_replace_provider_static_ports_again is not changed + - nm_force_replace_provider_static_ports_again.previous | length == 10 + - nm_force_replace_provider_static_ports_again.previous.0.path == "topology/pod-1/paths-101/pathep-[eth1/0]" + - nm_force_replace_provider_static_ports_again.previous.0.portEncapVlan == 1100 + - nm_force_replace_provider_static_ports_again.previous.3.path == "topology/pod-1/paths-101/pathep-[eth1/3]" + - nm_force_replace_provider_static_ports_again.previous.3.portEncapVlan == 1103 + - nm_force_replace_provider_static_ports_again.previous.9.path == "topology/pod-1/paths-101/pathep-[eth1/9]" + - nm_force_replace_provider_static_ports_again.previous.9.portEncapVlan == 1109 + - nm_force_replace_provider_static_ports_again.current | length == 10 + - nm_force_replace_provider_static_ports_again.current.0.path == "topology/pod-1/paths-101/pathep-[eth1/0]" + - nm_force_replace_provider_static_ports_again.current.0.portEncapVlan == 1100 + - nm_force_replace_provider_static_ports_again.current.3.path == "topology/pod-1/paths-101/pathep-[eth1/3]" + - nm_force_replace_provider_static_ports_again.current.3.portEncapVlan == 1103 + - nm_force_replace_provider_static_ports_again.current.9.path == "topology/pod-1/paths-101/pathep-[eth1/9]" + - nm_force_replace_provider_static_ports_again.current.9.portEncapVlan == 1109 + - nm_force_replace_new_static_ports.previous | length == 10 + - nm_force_replace_new_static_ports.previous.0.path == "topology/pod-1/paths-101/pathep-[eth1/0]" + - nm_force_replace_new_static_ports.previous.0.portEncapVlan == 1100 + - nm_force_replace_new_static_ports.previous.3.path == "topology/pod-1/paths-101/pathep-[eth1/3]" + - nm_force_replace_new_static_ports.previous.3.portEncapVlan == 1103 + - nm_force_replace_new_static_ports.previous.9.path == "topology/pod-1/paths-101/pathep-[eth1/9]" + - nm_force_replace_new_static_ports.previous.9.portEncapVlan == 1109 + - nm_force_replace_new_static_ports.current | length == 10 + - nm_force_replace_new_static_ports.current.0.path == "topology/pod-1/paths-101/pathep-[eth2/0]" + - nm_force_replace_new_static_ports.current.0.portEncapVlan == 1200 + - nm_force_replace_new_static_ports.current.3.path == "topology/pod-1/paths-101/pathep-[eth2/3]" + - nm_force_replace_new_static_ports.current.3.portEncapVlan == 1203 + - nm_force_replace_new_static_ports.current.9.path == "topology/pod-1/paths-101/pathep-[eth2/9]" + - nm_force_replace_new_static_ports.current.9.portEncapVlan == 1209 + +# QUERY TESTS FOR BULK + +- name: Query static ports + cisco.mso.mso_schema_site_anp_epg_staticport: + <<: *static_ports_append + static_ports: "{{ static_ports_present_2 }}" + state: query + register: nm_query_static_ports + +- name: Create static ports without input (error) + cisco.mso.mso_schema_site_anp_epg_staticport: + <<: *anp_bulk + epg: epg_bulk + site: '{{ mso_site | default("ansible_test") }}' + state: present + register: err_present_static_ports + ignore_errors: true + +- name: Query static ports with non existing static ports (error) + cisco.mso.mso_schema_site_anp_epg_staticport: + <<: *static_ports_append + static_ports: + - leaf: 101 + pod: pod-1 + path: eth1/40 + type: port + vlan: 1100 + - leaf: 201 + pod: pod-1 + path: eth1/41 + type: port + vlan: 1101 + state: query + register: err_query_static_ports + ignore_errors: true + +- name: Verify queries for bulk + ansible.builtin.assert: + that: + - err_present_static_ports is failed + - err_present_static_ports.msg == "state is present or absent but all of the following are missing{{":"}} pod, leaf, path, vlan." + - nm_query_static_ports is not changed + - nm_query_static_ports.current | length == 10 + - nm_query_static_ports.current.0.path == "topology/pod-1/paths-101/pathep-[eth2/0]" + - nm_query_static_ports.current.0.portEncapVlan == 1200 + - nm_query_static_ports.current.3.path == "topology/pod-1/paths-101/pathep-[eth2/3]" + - nm_query_static_ports.current.3.portEncapVlan == 1203 + - nm_query_static_ports.current.9.path == "topology/pod-1/paths-101/pathep-[eth2/9]" + - nm_query_static_ports.current.9.portEncapVlan == 1209 + - err_query_static_ports is failed + - err_query_static_ports.msg.0 == "Provided Static Port Path 'topology/pod-1/paths-101/pathep-[eth2/0]' not found" + - err_query_static_ports.msg.1 == "Provided Static Port Path 'topology/pod-1/paths-101/pathep-[eth2/1]' not found" + +# FORCE REMOVE ALL CONTRACTS + +- name: Force remove all static ports + cisco.mso.mso_schema_site_anp_epg_staticport: &force_remove_all + <<: *anp_bulk + epg: epg_bulk + site: '{{ mso_site | default("ansible_test") }}' + force_replace: true + state: absent + register: force_remove_all_static_ports + +- name: Create new static ports without existing contracts + cisco.mso.mso_schema_site_anp_epg_staticport: + <<: *force_remove_all + static_ports: + - leaf: 101 + pod: pod-1 + path: eth1/40 + type: port + vlan: 1100 + state: present + register: force_remove_all_new_static + +- name: Force remove all static ports again + cisco.mso.mso_schema_site_anp_epg_staticport: + <<: *force_remove_all + +- name: Verify force remove all static ports + ansible.builtin.assert: + that: + - force_remove_all_static_ports is changed + - force_remove_all_static_ports.previous | length == 10 + - force_remove_all_static_ports.current == [] + - force_remove_all_new_static is changed + - force_remove_all_new_static.previous == [] + - force_remove_all_new_static.current | length == 1 + +# OVERWRITE ARGUMENTS + +- name: Overwrite static port arguments (error) + cisco.mso.mso_schema_site_anp_epg_staticport: &overwrite_static_ports + <<: *anp_bulk + epg: epg_bulk + site: '{{ mso_site | default("ansible_test") }}' + leaf: 201 + pod: pod-1 + static_ports: + - type: port + register: err_overwrite_static_ports + ignore_errors: true + +- name: Overwrite static other port arguments (error) + cisco.mso.mso_schema_site_anp_epg_staticport: + <<: *anp_bulk + epg: epg_bulk + site: '{{ mso_site | default("ansible_test") }}' + path: eth1/41 + vlan: 1101 + static_ports: + - type: port + register: err_overwrite_static_ports_other + ignore_errors: true + +- name: Overwrite static port arguments + cisco.mso.mso_schema_site_anp_epg_staticport: + <<: *overwrite_static_ports + path: eth1/41 + vlan: 1101 + register: overwrite_static_ports + ignore_errors: true + +- name: Verify overwrite static port arguments + ansible.builtin.assert: + that: + - err_overwrite_static_ports is failed + - err_overwrite_static_ports.msg == "state is present but all of the following are missing{{":"}} path, vlan." + - err_overwrite_static_ports_other is failed + - err_overwrite_static_ports_other.msg == "state is present but all of the following are missing{{":"}} pod, leaf." + - overwrite_static_ports is changed + - overwrite_static_ports.current.0.path == "topology/pod-1/paths-201/pathep-[eth1/41]" + - overwrite_static_ports.current.0.portEncapVlan == 1101 + - overwrite_static_ports.current.0.type == "port" + +# CLEAN UP TEST ENVIRONMENT + +- name: Remove schemas + cisco.mso.mso_schema: + <<: *mso_info + schema: ansible_test + state: absent diff --git a/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_anp_epg_useg_attribute/tasks/main.yml b/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_anp_epg_useg_attribute/tasks/main.yml index 9ba4c846a..889d7e83d 100644 --- a/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_anp_epg_useg_attribute/tasks/main.yml +++ b/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_anp_epg_useg_attribute/tasks/main.yml @@ -4,13 +4,13 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI MultiSite host, username and password - fail: + ansible.builtin.fail: msg: "Please define the following variables: mso_hostname, mso_username and mso_password." when: mso_hostname is not defined or mso_username is not defined or mso_password is not defined # CLEAN ENVIRONMENT - name: Set vars - set_fact: + ansible.builtin.set_fact: mso_info: &mso_info host: "{{ mso_hostname }}" username: "{{ mso_username }}" @@ -23,13 +23,13 @@ # Setup Part - name: Remove schemas - mso_schema: &ansible_test_schema_absent + cisco.mso.mso_schema: &ansible_test_schema_absent <<: *mso_info schema: ansible_test state: absent - name: Ensure ansible_test tenant absent - mso_tenant: &ansible_test_tenant_absent + cisco.mso.mso_tenant: &ansible_test_tenant_absent <<: *mso_info tenant: ansible_test users: @@ -37,12 +37,12 @@ state: absent - name: Ensure ansible_test tenant present - mso_tenant: &ansible_test_tenant_present + cisco.mso.mso_tenant: &ansible_test_tenant_present <<: *ansible_test_tenant_absent state: present - name: Ensure ansible_test schema with ans_test_template exist - mso_schema_template: + cisco.mso.mso_schema_template: <<: *mso_info schema: ansible_test tenant: ansible_test @@ -50,7 +50,7 @@ state: present - name: Ensure ans_test_anp exist - mso_schema_template_anp: + cisco.mso.mso_schema_template_anp: <<: *mso_info schema: ansible_test template: ans_test_template @@ -76,7 +76,7 @@ state: present - name: Ensure ans_test_epg exist - mso_schema_template_anp_epg: + cisco.mso.mso_schema_template_anp_epg: <<: *mso_info schema: ansible_test template: ans_test_template @@ -90,7 +90,7 @@ state: present - name: Ensure ans_test_epg_2 exist without useg_epg - mso_schema_template_anp_epg: + cisco.mso.mso_schema_template_anp_epg: <<: *mso_info schema: ansible_test template: ans_test_template @@ -103,14 +103,14 @@ state: present - name: Associate a ansible_test site with a ansible_test tenant - mso_tenant_site: + cisco.mso.mso_tenant_site: <<: *mso_info tenant: ansible_test site: ansible_test state: present - name: Ensure ansible_test site associated with ansible_test schema - mso_schema_site: + cisco.mso.mso_schema_site: <<: *mso_info schema: ansible_test site: ansible_test @@ -118,7 +118,7 @@ state: present - name: Add ans_test_epg to the ansible_test site - mso_schema_site_anp_epg: + cisco.mso.mso_schema_site_anp_epg: <<: *mso_info site: ansible_test schema: ansible_test @@ -137,7 +137,7 @@ # Test Part # Note: Ignore the below task, which is used to reference the attributes to other tasks - name: Invalid test - check for missing required attributes error message - mso_schema_site_anp_epg_useg_attribute: &useg_attribute_present + cisco.mso.mso_schema_site_anp_epg_useg_attribute: &useg_attribute_present <<: *mso_info schema: ansible_test template: ans_test_template @@ -150,7 +150,7 @@ register: ans_test_uSeg_1_nt - name: ans_test_uSeg_1 present - attribute_type - ip, useg_subnet - true, without value - mso_schema_site_anp_epg_useg_attribute: + cisco.mso.mso_schema_site_anp_epg_useg_attribute: <<: *mso_info site: ansible_test schema: ansible_test @@ -163,7 +163,7 @@ register: ans_test_uSeg_1 - name: Invalid test - ans_test_uSeg_2 present - attribute_type - ip, useg_subnet - false, without value - mso_schema_site_anp_epg_useg_attribute: + cisco.mso.mso_schema_site_anp_epg_useg_attribute: <<: *useg_attribute_present name: ans_test_uSeg_2 attribute_type: ip @@ -171,70 +171,83 @@ ignore_errors: true register: ans_test_uSeg_2_nt +- name: Invalid test - ans_test_uSeg_2 present - attribute_type - ip, useg_subnet - true, with value + cisco.mso.mso_schema_site_anp_epg_useg_attribute: + <<: *useg_attribute_present + name: ans_test_uSeg_2 + attribute_type: ip + useg_subnet: true + value: 1.2.3.4 + ignore_errors: true + register: ans_test_uSeg_2_nt1 + - name: ans_test_uSeg_2 present - attribute_type - ip, useg_subnet - false, with value - check mode - mso_schema_site_anp_epg_useg_attribute: &ans_test_uSeg_2_cm_present + cisco.mso.mso_schema_site_anp_epg_useg_attribute: &ans_test_uSeg_2_cm_present <<: *useg_attribute_present name: ans_test_uSeg_2 attribute_type: ip useg_subnet: false - value: 11.22.33.44/24 + value: 11.22.33.44 check_mode: true register: ans_test_uSeg_2_cm_present - name: ans_test_uSeg_2 present - attribute_type - ip, useg_subnet - false, with value - normal mode - mso_schema_site_anp_epg_useg_attribute: &ans_test_uSeg_2_nm_present + cisco.mso.mso_schema_site_anp_epg_useg_attribute: &ans_test_uSeg_2_nm_present <<: *ans_test_uSeg_2_cm_present + output_level: debug register: ans_test_uSeg_2_nm_present - name: ans_test_uSeg_2 present - attribute_type - ip, useg_subnet - false, with value - normal mode again - mso_schema_site_anp_epg_useg_attribute: + cisco.mso.mso_schema_site_anp_epg_useg_attribute: <<: *ans_test_uSeg_2_nm_present + output_level: debug register: ans_test_uSeg_2_nm_present_again - name: Assertions check for add ans_test_uSeg_1 and ans_test_uSeg_2 object - assert: + ansible.builtin.assert: that: - ans_test_uSeg_1 is changed - ans_test_uSeg_1.current != {} - ans_test_uSeg_1.current.name == "ans_test_uSeg_1" - ans_test_uSeg_1.current.type == "ip" - ans_test_uSeg_1.current.value == "0.0.0.0" - - ans_test_uSeg_1.current.fvSubnet == false + - ans_test_uSeg_1.current.fvSubnet == true - ans_test_uSeg_1.current.description == "ans_test_uSeg_1" - ans_test_uSeg_2_nt is not changed - ans_test_uSeg_2_nt.msg == "useg_subnet is False but all of the following are missing{{':'}} value" + - ans_test_uSeg_2_nt1 is not changed + - ans_test_uSeg_2_nt1.msg == "The value of uSeg subnet IP should be an empty string or 0.0.0.0, when the useg_subnet is set to true." - ans_test_uSeg_2_cm_present is changed - ans_test_uSeg_2_cm_present.current != {} - ans_test_uSeg_2_cm_present.previous == {} - ans_test_uSeg_2_cm_present.current.name == "ans_test_uSeg_2" - ans_test_uSeg_2_cm_present.current.type == "ip" - - ans_test_uSeg_2_cm_present.current.value == "11.22.33.44/24" - - ans_test_uSeg_2_cm_present.current.fvSubnet == true + - ans_test_uSeg_2_cm_present.current.value == "11.22.33.44" + - ans_test_uSeg_2_cm_present.current.fvSubnet == false - ans_test_uSeg_2_cm_present.current.description == "uSeg Attr object created using Ansible" - ans_test_uSeg_2_nm_present is changed - ans_test_uSeg_2_nm_present.current != {} - ans_test_uSeg_2_nm_present.previous == {} - ans_test_uSeg_2_nm_present.current.name == "ans_test_uSeg_2" - ans_test_uSeg_2_nm_present.current.type == "ip" - - ans_test_uSeg_2_nm_present.current.value == "11.22.33.44/24" - - ans_test_uSeg_2_nm_present.current.fvSubnet == true + - ans_test_uSeg_2_nm_present.current.value == "11.22.33.44" + - ans_test_uSeg_2_nm_present.sent.fvSubnet == false - ans_test_uSeg_2_nm_present.current.description == "uSeg Attr object created using Ansible" - ans_test_uSeg_2_nm_present_again is not changed - ans_test_uSeg_2_nm_present_again.current != {} - ans_test_uSeg_2_nm_present_again.previous != {} - ans_test_uSeg_2_nm_present_again.current.name == "ans_test_uSeg_2" - ans_test_uSeg_2_nm_present_again.current.type == "ip" - - ans_test_uSeg_2_nm_present_again.current.value == "11.22.33.44/24" - - ans_test_uSeg_2_nm_present_again.current.fvSubnet == true + - ans_test_uSeg_2_nm_present_again.current.value == "11.22.33.44" + - ans_test_uSeg_2_nm_present_again.sent.fvSubnet == false - ans_test_uSeg_2_nm_present_again.current.description == "uSeg Attr object created using Ansible" - ans_test_uSeg_2_nm_present_again.previous.name == "ans_test_uSeg_2" - ans_test_uSeg_2_nm_present_again.previous.type == "ip" - - ans_test_uSeg_2_nm_present_again.previous.value == "11.22.33.44/24" - - ans_test_uSeg_2_nm_present_again.previous.fvSubnet == true + - ans_test_uSeg_2_nm_present_again.previous.value == "11.22.33.44" - ans_test_uSeg_2_nm_present_again.previous.description == "uSeg Attr object created using Ansible" - name: Invalid test - ans_test_uSeg_3 present - attribute_type - mac and without value - mso_schema_site_anp_epg_useg_attribute: + cisco.mso.mso_schema_site_anp_epg_useg_attribute: <<: *useg_attribute_present name: ans_test_uSeg_3 attribute_type: mac @@ -242,7 +255,7 @@ register: ans_test_uSeg_3_nt - name: ans_test_uSeg_3 present - attribute_type - mac and with value - mso_schema_site_anp_epg_useg_attribute: + cisco.mso.mso_schema_site_anp_epg_useg_attribute: <<: *useg_attribute_present name: ans_test_uSeg_3 attribute_type: mac @@ -250,7 +263,7 @@ register: ans_test_uSeg_3 - name: Assertions check for add ans_test_uSeg_3 object - assert: + ansible.builtin.assert: that: - ans_test_uSeg_3_nt is not changed - ans_test_uSeg_3_nt.msg == "Failed due to invalid 'value' and the attribute_type is{{':'}} mac." @@ -263,7 +276,7 @@ - ans_test_uSeg_3.current.value == "aa:bb:cc:dd:ee:ff" - name: Invalid test - ans_test_uSeg_4 present - attribute_type - dns and without value - mso_schema_site_anp_epg_useg_attribute: + cisco.mso.mso_schema_site_anp_epg_useg_attribute: <<: *useg_attribute_present name: ans_test_uSeg_4 attribute_type: dns @@ -271,7 +284,7 @@ register: ans_test_uSeg_4_nt - name: ans_test_uSeg_4 present - attribute_type - dns and with value - mso_schema_site_anp_epg_useg_attribute: + cisco.mso.mso_schema_site_anp_epg_useg_attribute: <<: *useg_attribute_present name: ans_test_uSeg_4 attribute_type: dns @@ -279,7 +292,7 @@ register: ans_test_uSeg_4 - name: Assertions check for add ans_test_uSeg_4 object - assert: + ansible.builtin.assert: that: - ans_test_uSeg_4_nt is not changed - ans_test_uSeg_4_nt.msg == "Failed due to invalid 'value' and the attribute_type is{{':'}} dns." @@ -292,7 +305,7 @@ - ans_test_uSeg_4.current.value == "test_dns_value" - name: Invalid test - ans_test_uSeg_6 present - attribute_type - vm_datacenter and without operator - mso_schema_site_anp_epg_useg_attribute: + cisco.mso.mso_schema_site_anp_epg_useg_attribute: <<: *useg_attribute_present name: ans_test_uSeg_6 attribute_type: vm_datacenter @@ -301,7 +314,7 @@ register: ans_test_uSeg_6_nt - name: Invalid test - ans_test_uSeg_6 present - attribute_type - vm_datacenter, operator - equals and without value - mso_schema_site_anp_epg_useg_attribute: + cisco.mso.mso_schema_site_anp_epg_useg_attribute: <<: *useg_attribute_present name: ans_test_uSeg_6 attribute_type: vm_datacenter @@ -310,7 +323,7 @@ register: ans_test_uSeg_6_nt1 - name: ans_test_uSeg_6 present - attribute_type - vm_datacenter, operator - equals and value - mso_schema_site_anp_epg_useg_attribute: + cisco.mso.mso_schema_site_anp_epg_useg_attribute: <<: *useg_attribute_present name: ans_test_uSeg_6 attribute_type: vm_datacenter @@ -319,7 +332,7 @@ register: ans_test_uSeg_6 - name: Assertions check for add ans_test_uSeg_6 object - assert: + ansible.builtin.assert: that: - ans_test_uSeg_6_nt is not changed - ans_test_uSeg_6_nt.msg == "Failed due to invalid 'value' or 'operator' and the attribute_type is{{':'}} vm_datacenter." @@ -334,7 +347,7 @@ - ans_test_uSeg_6.current.value == "test_vm_datacenter_value" - name: Invalid test - ans_test_uSeg_7 present - attribute_type - vm_hypervisor_identifier and without operator - mso_schema_site_anp_epg_useg_attribute: + cisco.mso.mso_schema_site_anp_epg_useg_attribute: <<: *useg_attribute_present name: ans_test_uSeg_7 attribute_type: vm_hypervisor_identifier @@ -343,7 +356,7 @@ register: ans_test_uSeg_7_nt - name: Invalid test - ans_test_uSeg_7 present - attribute_type - vm_hypervisor_identifier, operator - equals and without value - mso_schema_site_anp_epg_useg_attribute: + cisco.mso.mso_schema_site_anp_epg_useg_attribute: <<: *useg_attribute_present name: ans_test_uSeg_7 attribute_type: vm_hypervisor_identifier @@ -352,7 +365,7 @@ register: ans_test_uSeg_7_nt1 - name: ans_test_uSeg_7 present - attribute_type - vm_hypervisor_identifier, operator - equals and value - mso_schema_site_anp_epg_useg_attribute: + cisco.mso.mso_schema_site_anp_epg_useg_attribute: <<: *useg_attribute_present name: ans_test_uSeg_7 attribute_type: vm_hypervisor_identifier @@ -361,7 +374,7 @@ register: ans_test_uSeg_7 - name: Assertions check for add ans_test_uSeg_7 object - assert: + ansible.builtin.assert: that: - ans_test_uSeg_7_nt is not changed - ans_test_uSeg_7_nt.msg == "Failed due to invalid 'value' or 'operator' and the attribute_type is{{':'}} vm_hypervisor_identifier." @@ -376,7 +389,7 @@ - ans_test_uSeg_7.current.value == "test_vm_hypervisor_identifier_value" - name: Invalid test - ans_test_uSeg_8 present - attribute_type - vm_operating_system and without operator - mso_schema_site_anp_epg_useg_attribute: + cisco.mso.mso_schema_site_anp_epg_useg_attribute: <<: *useg_attribute_present name: ans_test_uSeg_8 attribute_type: vm_operating_system @@ -385,7 +398,7 @@ register: ans_test_uSeg_8_nt - name: Invalid test - ans_test_uSeg_8 present - attribute_type - vm_operating_system, operator - equals and without value - mso_schema_site_anp_epg_useg_attribute: + cisco.mso.mso_schema_site_anp_epg_useg_attribute: <<: *useg_attribute_present name: ans_test_uSeg_8 attribute_type: vm_operating_system @@ -394,7 +407,7 @@ register: ans_test_uSeg_8_nt1 - name: ans_test_uSeg_8 present - attribute_type - vm_operating_system, operator - equals and value - mso_schema_site_anp_epg_useg_attribute: + cisco.mso.mso_schema_site_anp_epg_useg_attribute: <<: *useg_attribute_present name: ans_test_uSeg_8 attribute_type: vm_operating_system @@ -403,7 +416,7 @@ register: ans_test_uSeg_8 - name: Assertions check for add ans_test_uSeg_8 object - assert: + ansible.builtin.assert: that: - ans_test_uSeg_8_nt is not changed - ans_test_uSeg_8_nt.msg == "Failed due to invalid 'value' or 'operator' and the attribute_type is{{':'}} vm_operating_system." @@ -418,7 +431,7 @@ - ans_test_uSeg_8.current.value == "test_vm_operating_system_value" - name: Invalid test - ans_test_uSeg_9 present - attribute_type - vm_tag and without operator - mso_schema_site_anp_epg_useg_attribute: + cisco.mso.mso_schema_site_anp_epg_useg_attribute: <<: *useg_attribute_present name: ans_test_uSeg_9 attribute_type: vm_tag @@ -427,7 +440,7 @@ register: ans_test_uSeg_9_nt - name: Invalid test - ans_test_uSeg_9 present - attribute_type - vm_tag, operator - equals and without value - mso_schema_site_anp_epg_useg_attribute: + cisco.mso.mso_schema_site_anp_epg_useg_attribute: <<: *useg_attribute_present name: ans_test_uSeg_9 attribute_type: vm_tag @@ -436,7 +449,7 @@ register: ans_test_uSeg_9_nt1 - name: ans_test_uSeg_9 present - attribute_type - vm_tag, operator - equals and value - mso_schema_site_anp_epg_useg_attribute: + cisco.mso.mso_schema_site_anp_epg_useg_attribute: <<: *useg_attribute_present name: ans_test_uSeg_9 attribute_type: vm_tag @@ -445,7 +458,7 @@ register: ans_test_uSeg_9 - name: Assertions check for add ans_test_uSeg_9 object - assert: + ansible.builtin.assert: that: - ans_test_uSeg_9_nt is not changed - ans_test_uSeg_9_nt.msg == "Failed due to invalid 'value' or 'operator' and the attribute_type is{{':'}} vm_tag." @@ -460,7 +473,7 @@ - ans_test_uSeg_9.current.value == "test_vm_tag_value" - name: Invalid test - ans_test_uSeg_10 present - attribute_type - vm_identifier and without operator - mso_schema_site_anp_epg_useg_attribute: + cisco.mso.mso_schema_site_anp_epg_useg_attribute: <<: *useg_attribute_present name: ans_test_uSeg_10 attribute_type: vm_identifier @@ -469,7 +482,7 @@ register: ans_test_uSeg_10_nt - name: Invalid test - ans_test_uSeg_10 present - attribute_type - vm_identifier, operator - equals and without value - mso_schema_site_anp_epg_useg_attribute: + cisco.mso.mso_schema_site_anp_epg_useg_attribute: <<: *useg_attribute_present name: ans_test_uSeg_10 attribute_type: vm_identifier @@ -478,7 +491,7 @@ register: ans_test_uSeg_10_nt1 - name: ans_test_uSeg_10 present - attribute_type - vm_identifier, operator - equals and value - mso_schema_site_anp_epg_useg_attribute: + cisco.mso.mso_schema_site_anp_epg_useg_attribute: <<: *useg_attribute_present name: ans_test_uSeg_10 attribute_type: vm_identifier @@ -487,7 +500,7 @@ register: ans_test_uSeg_10 - name: Assertions check for add ans_test_uSeg_10 object - assert: + ansible.builtin.assert: that: - ans_test_uSeg_10_nt is not changed - ans_test_uSeg_10_nt.msg == "Failed due to invalid 'value' or 'operator' and the attribute_type is{{':'}} vm_identifier." @@ -502,7 +515,7 @@ - ans_test_uSeg_10.current.value == "test_vm_identifier_value" - name: Invalid test - ans_test_uSeg_11 present - attribute_type - vmm_domain and without operator - mso_schema_site_anp_epg_useg_attribute: + cisco.mso.mso_schema_site_anp_epg_useg_attribute: <<: *useg_attribute_present name: ans_test_uSeg_11 attribute_type: vmm_domain @@ -511,7 +524,7 @@ register: ans_test_uSeg_11_nt - name: Invalid test - ans_test_uSeg_11 present - attribute_type - vmm_domain, operator - equals and without value - mso_schema_site_anp_epg_useg_attribute: + cisco.mso.mso_schema_site_anp_epg_useg_attribute: <<: *useg_attribute_present name: ans_test_uSeg_11 attribute_type: vmm_domain @@ -520,7 +533,7 @@ register: ans_test_uSeg_11_nt1 - name: ans_test_uSeg_11 present - attribute_type - vmm_domain, operator - equals and value - mso_schema_site_anp_epg_useg_attribute: + cisco.mso.mso_schema_site_anp_epg_useg_attribute: <<: *useg_attribute_present name: ans_test_uSeg_11 attribute_type: vmm_domain @@ -529,7 +542,7 @@ register: ans_test_uSeg_11 - name: Assertions check for add ans_test_uSeg_11 object - assert: + ansible.builtin.assert: that: - ans_test_uSeg_11_nt is not changed - ans_test_uSeg_11_nt.msg == "Failed due to invalid 'value' or 'operator' and the attribute_type is{{':'}} vmm_domain." @@ -544,7 +557,7 @@ - ans_test_uSeg_11.current.value == "test_vmm_domain_value" - name: Invalid test - ans_test_uSeg_12 present - attribute_type - vm_name and without operator - mso_schema_site_anp_epg_useg_attribute: + cisco.mso.mso_schema_site_anp_epg_useg_attribute: <<: *useg_attribute_present name: ans_test_uSeg_12 attribute_type: vm_name @@ -553,7 +566,7 @@ register: ans_test_uSeg_12_nt - name: Invalid test - ans_test_uSeg_12 present - attribute_type - vm_name, operator - equals and without value - mso_schema_site_anp_epg_useg_attribute: + cisco.mso.mso_schema_site_anp_epg_useg_attribute: <<: *useg_attribute_present name: ans_test_uSeg_12 attribute_type: vm_name @@ -562,7 +575,7 @@ register: ans_test_uSeg_12_nt1 - name: ans_test_uSeg_12 present - attribute_type - vm_name, operator - equals and value - mso_schema_site_anp_epg_useg_attribute: + cisco.mso.mso_schema_site_anp_epg_useg_attribute: <<: *useg_attribute_present name: ans_test_uSeg_12 attribute_type: vm_name @@ -571,7 +584,7 @@ register: ans_test_uSeg_12 - name: Assertions check for add ans_test_uSeg_12 object - assert: + ansible.builtin.assert: that: - ans_test_uSeg_12_nt is not changed - ans_test_uSeg_12_nt.msg == "Failed due to invalid 'value' or 'operator' and the attribute_type is{{':'}} vm_name." @@ -586,7 +599,7 @@ - ans_test_uSeg_12.current.value == "test_vm_value" - name: Invalid test - ans_test_uSeg_13 present - attribute_type - vnic_dn and without operator - mso_schema_site_anp_epg_useg_attribute: + cisco.mso.mso_schema_site_anp_epg_useg_attribute: <<: *useg_attribute_present name: ans_test_uSeg_13 attribute_type: vnic_dn @@ -595,7 +608,7 @@ register: ans_test_uSeg_13_nt - name: Invalid test - ans_test_uSeg_13 present - attribute_type - vnic_dn, operator - equals and without value - mso_schema_site_anp_epg_useg_attribute: + cisco.mso.mso_schema_site_anp_epg_useg_attribute: <<: *useg_attribute_present name: ans_test_uSeg_13 attribute_type: vnic_dn @@ -604,7 +617,7 @@ register: ans_test_uSeg_13_nt1 - name: ans_test_uSeg_13 present - attribute_type - vnic_dn, operator - equals and value - mso_schema_site_anp_epg_useg_attribute: &ans_test_uSeg_13_present + cisco.mso.mso_schema_site_anp_epg_useg_attribute: &ans_test_uSeg_13_present <<: *useg_attribute_present name: ans_test_uSeg_13 attribute_type: vnic_dn @@ -613,7 +626,7 @@ register: ans_test_uSeg_13 - name: Assertions check for add ans_test_uSeg_12 object - assert: + ansible.builtin.assert: that: - ans_test_uSeg_13_nt is not changed - ans_test_uSeg_13_nt.msg == "Failed due to invalid 'value' or 'operator' and the attribute_type is{{':'}} vnic_dn." @@ -629,7 +642,7 @@ # Query Part - name: Invalid test - Query an uSeg Attr with name - invalid_useg_attr - mso_schema_site_anp_epg_useg_attribute: + cisco.mso.mso_schema_site_anp_epg_useg_attribute: <<: *useg_attribute_present name: invalid_useg_attr state: query @@ -637,20 +650,20 @@ ignore_errors: true - name: Query an uSeg Attr with name - ans_test_uSeg_1 - mso_schema_site_anp_epg_useg_attribute: + cisco.mso.mso_schema_site_anp_epg_useg_attribute: <<: *useg_attribute_present name: ans_test_uSeg_6 state: query register: query_a_useg_6 - name: Query all uSeg Attrs - mso_schema_site_anp_epg_useg_attribute: + cisco.mso.mso_schema_site_anp_epg_useg_attribute: <<: *useg_attribute_present state: query register: query_all_useg_objects - name: Assertions check for query uSeg Attr objects - assert: + ansible.builtin.assert: that: - invalid_useg_attr is not changed - invalid_useg_attr.msg == "The uSeg Attribute{{':'}} invalid_useg_attr not found." @@ -664,21 +677,21 @@ # Update Part - name: Update ans_test_uSeg_13 object description and value - mso_schema_site_anp_epg_useg_attribute: + cisco.mso.mso_schema_site_anp_epg_useg_attribute: <<: *ans_test_uSeg_13_present description: "ans_test_uSeg_13 updated!" value: test_vnic_dn_value_updated register: ans_test_uSeg_13_update - name: Query an uSeg Attr with name - ans_test_uSeg_13 to check the updated changes - mso_schema_site_anp_epg_useg_attribute: + cisco.mso.mso_schema_site_anp_epg_useg_attribute: <<: *useg_attribute_present name: ans_test_uSeg_13 state: query register: query_a_useg_object_with_name - name: Assertions check for update ans_test_uSeg_13 object - assert: + ansible.builtin.assert: that: - ans_test_uSeg_13_update is changed - ans_test_uSeg_13_update.current != {} @@ -700,7 +713,7 @@ # Cleanup Part - name: ans_test_uSeg_1 absent with check mode - mso_schema_site_anp_epg_useg_attribute: &ans_test_uSeg_1_cm_absent + cisco.mso.mso_schema_site_anp_epg_useg_attribute: &ans_test_uSeg_1_cm_absent <<: *useg_attribute_present name: ans_test_uSeg_1 state: absent @@ -708,17 +721,17 @@ register: ans_test_uSeg_1_cm_absent - name: ans_test_uSeg_1 absent with normal mode - mso_schema_site_anp_epg_useg_attribute: &ans_test_uSeg_1_nm_absent + cisco.mso.mso_schema_site_anp_epg_useg_attribute: &ans_test_uSeg_1_nm_absent <<: *ans_test_uSeg_1_cm_absent register: ans_test_uSeg_1_nm_absent - name: ans_test_uSeg_1 absent with normal mode again - mso_schema_site_anp_epg_useg_attribute: + cisco.mso.mso_schema_site_anp_epg_useg_attribute: <<: *ans_test_uSeg_1_nm_absent register: ans_test_uSeg_1_nm_absent_again - name: Assertions check for ans_test_uSeg_1 absent - assert: + ansible.builtin.assert: that: - ans_test_uSeg_1_cm_absent is changed - ans_test_uSeg_1_cm_absent.current == {} @@ -731,7 +744,7 @@ - ans_test_uSeg_1_nm_absent_again.previous == {} - name: Query all uSeg Attrs - invalid template name - mso_schema_site_anp_epg_useg_attribute: + cisco.mso.mso_schema_site_anp_epg_useg_attribute: <<: *useg_attribute_present template: ans_test_template_123 state: query @@ -739,7 +752,7 @@ register: query_invalid_template - name: Query all uSeg Attrs - invalid Application Profile name - mso_schema_site_anp_epg_useg_attribute: + cisco.mso.mso_schema_site_anp_epg_useg_attribute: <<: *useg_attribute_present anp: ans_test_anp_123 state: query @@ -747,7 +760,7 @@ register: query_invalid_ap - name: Query all uSeg Attrs - invalid EPG name - mso_schema_site_anp_epg_useg_attribute: + cisco.mso.mso_schema_site_anp_epg_useg_attribute: <<: *useg_attribute_present epg: ans_test_epg_123 state: query @@ -755,7 +768,7 @@ register: query_invalid_epg - name: Invalid test - ans_test_anp_123 present under ans_test_epg_2 - mso_schema_site_anp_epg_useg_attribute: + cisco.mso.mso_schema_site_anp_epg_useg_attribute: <<: *useg_attribute_present epg: ans_test_epg_2 name: ans_test_anp_123 @@ -765,7 +778,7 @@ register: ans_test_epg_2_nt - name: Assertions check for invalid inputs - assert: + ansible.builtin.assert: that: - query_invalid_template is not changed - query_invalid_template.msg is match("Provided template 'ans_test_template_123' not matching existing template.+") @@ -786,27 +799,25 @@ state: undeploy - name: Remove ansible_test schema to delete all uSeg Attr objects - mso_schema: + cisco.mso.mso_schema: <<: *ansible_test_schema_absent schema: ansible_test state: absent # To check all uSeg Attrs removed from the machine - name: Query all uSeg Attrs - Cleanup Part - mso_schema_site_anp_epg_useg_attribute: + cisco.mso.mso_schema_site_anp_epg_useg_attribute: <<: *useg_attribute_present state: query ignore_errors: true register: query_useg_absent_check - name: Assertions check for query all uSeg Attrs - Cleanup Part - assert: + ansible.builtin.assert: that: - query_useg_absent_check is not changed - query_useg_absent_check.current == {} - name: Remove ansible_test tenant - mso_tenant: - <<: *ansible_test_tenant_present - state: absent - <<: *mso_info + cisco.mso.mso_tenant: + <<: *ansible_test_tenant_absent diff --git a/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_bd/tasks/main.yml b/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_bd/tasks/main.yml index a7de528ea..c7770dfb6 100644 --- a/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_bd/tasks/main.yml +++ b/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_bd/tasks/main.yml @@ -7,13 +7,13 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI MultiSite host, username and password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: mso_hostname, mso_username and mso_password.' when: mso_hostname is not defined or mso_username is not defined or mso_password is not defined # CLEAN ENVIRONMENT - name: Set vars - set_fact: + ansible.builtin.set_fact: mso_info: &mso_info host: '{{ mso_hostname }}' username: '{{ mso_username }}' @@ -24,13 +24,13 @@ output_level: '{{ mso_output_level | default("info") }}' - name: Query MSO version - mso_version: + cisco.mso.mso_version: <<: *mso_info state: query register: version - name: Ensure site exists - mso_site: + cisco.mso.mso_site: <<: *mso_info site: '{{ mso_site | default("ansible_test") }}' apic_username: '{{ apic_username }}' @@ -42,7 +42,7 @@ ignore_errors: true - name: Remove schemas - mso_schema: + cisco.mso.mso_schema: <<: *mso_info schema: '{{ item }}' state: absent @@ -51,7 +51,7 @@ - '{{ mso_schema | default("ansible_test") }}' - name: Ensure sites removed from tenant ansible_test - mso_tenant_site: + cisco.mso.mso_tenant_site: <<: *mso_info tenant: ansible_test site: '{{ item }}' @@ -62,7 +62,7 @@ - 'azure_{{ mso_site | default("ansible_test") }}' - name: Ensure tenant ansible_test exists - mso_tenant: + cisco.mso.mso_tenant: <<: *mso_info tenant: ansible_test users: @@ -72,7 +72,7 @@ state: present - name: Ensure schema 1 with Template 1, and Template 2, Template 3 exist - mso_schema_template: + cisco.mso.mso_schema_template: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' tenant: ansible_test @@ -84,7 +84,7 @@ - { template: Template 3} - name: Ensure schema 2 with Template 3 exist - mso_schema_template: + cisco.mso.mso_schema_template: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}_2' tenant: ansible_test @@ -92,7 +92,7 @@ state: present - name: Add physical site to a schema - mso_schema_site: + cisco.mso.mso_schema_site: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -103,7 +103,7 @@ - { template: Template 2} - name: Ensure VRF1 exists - mso_schema_template_vrf: + cisco.mso.mso_schema_template_vrf: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -112,7 +112,7 @@ state: present - name: Ensure ansible_test_1 BD does not exist - mso_schema_template_bd: + cisco.mso.mso_schema_template_bd: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -122,7 +122,7 @@ state: absent - name: Add template BD - mso_schema_template_bd: + cisco.mso.mso_schema_template_bd: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -133,7 +133,7 @@ register: nm_add_bd - name: Verify nm_add_bd - assert: + ansible.builtin.assert: that: - nm_add_bd is changed - nm_add_bd.previous == {} @@ -142,7 +142,7 @@ - nm_add_bd.current.vrfRef.vrfName == "VRF1" - name: Add template BD 2 - mso_schema_template_bd: + cisco.mso.mso_schema_template_bd: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 2 @@ -154,7 +154,7 @@ register: nm_add_bd_2 - name: Verify nm_add_bd_2 - assert: + ansible.builtin.assert: that: - nm_add_bd_2 is changed - nm_add_bd_2.previous == {} @@ -163,7 +163,7 @@ - nm_add_bd_2.current.vrfRef.vrfName == "VRF1" - name: Add template BD 3 - mso_schema_template_bd: + cisco.mso.mso_schema_template_bd: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -175,7 +175,7 @@ register: nm_add_bd_3 - name: Verify nm_add_bd_3 - assert: + ansible.builtin.assert: that: - nm_add_bd_3 is changed - nm_add_bd_3.previous == {} @@ -184,7 +184,7 @@ - nm_add_bd_3.current.vrfRef.vrfName == "VRF1" - name: Add template BD 4 - mso_schema_template_bd: + cisco.mso.mso_schema_template_bd: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -196,7 +196,7 @@ register: nm_add_bd_4 - name: Verify nm_add_bd_4 - assert: + ansible.builtin.assert: that: - nm_add_bd_4 is changed - nm_add_bd_4.previous == {} @@ -205,7 +205,7 @@ - nm_add_bd_4.current.vrfRef.vrfName == "VRF1" - name: Add site BD (check_mode) - mso_schema_site_bd: + cisco.mso.mso_schema_site_bd: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -216,21 +216,21 @@ register: cm_add_site_bd - name: Verify cm_add_site_bd - assert: + ansible.builtin.assert: that: - cm_add_site_bd.current.bdRef.bdName == "ansible_test_1" - cm_add_site_bd.current.bdRef.templateName == "Template1" - cm_add_site_bd.current.hostBasedRouting == false - name: Verify cm_add_site_bd - assert: + ansible.builtin.assert: that: - cm_add_site_bd is changed - cm_add_site_bd.previous == {} when: version.current.version is version('4.0', '<') # no change in NDO4.0 because site will already be present when template is defined - name: Add site BD (normal_mode) - mso_schema_site_bd: + cisco.mso.mso_schema_site_bd: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -240,7 +240,7 @@ register: nm_add_site_bd - name: Verify nm_add_site_bd - assert: + ansible.builtin.assert: that: - nm_add_site_bd.current.bdRef.bdName == "ansible_test_1" - nm_add_site_bd.current.bdRef.templateName == "Template1" @@ -248,14 +248,14 @@ - cm_add_site_bd.current.bdRef.schemaId == nm_add_site_bd.current.bdRef.schemaId - name: Verify nm_add_site_bd - assert: + ansible.builtin.assert: that: - nm_add_site_bd is changed - nm_add_site_bd.previous == {} when: version.current.version is version('4.0', '<') # no change in NDO4.0 because site will already be present when template is defined - name: Add site BD again (check_mode) - mso_schema_site_bd: + cisco.mso.mso_schema_site_bd: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -266,7 +266,7 @@ register: cm_add_site_bd_again - name: Add site BD again (normal_mode) - mso_schema_site_bd: + cisco.mso.mso_schema_site_bd: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -276,14 +276,14 @@ register: nm_add_site_bd_again - name: Verify cm_add_site_bd_again and nm_add_site_bd_again - assert: + ansible.builtin.assert: that: - cm_add_site_bd_again is not changed - nm_add_site_bd_again is not changed - cm_add_site_bd_again.previous.bdRef.bdName == nm_add_site_bd_again.previous.bdRef.bdName == cm_add_site_bd_again.current.bdRef.bdName == nm_add_site_bd_again.current.bdRef.bdName == "ansible_test_1" - name: Change site BD (check_mode) - mso_schema_site_bd: + cisco.mso.mso_schema_site_bd: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -295,7 +295,7 @@ register: cm_change_site_bd - name: Change site BD (normal_mode) - mso_schema_site_bd: + cisco.mso.mso_schema_site_bd: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -306,7 +306,7 @@ register: nm_change_site_bd - name: Verify cm_change_site_bd and nm_change_site_bd - assert: + ansible.builtin.assert: that: - cm_change_site_bd is changed - nm_change_site_bd is changed @@ -318,7 +318,7 @@ - nm_change_site_bd.current.hostBasedRouting == true - name: Add site BD with host_route (check_mode) - mso_schema_site_bd: + cisco.mso.mso_schema_site_bd: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -330,7 +330,7 @@ register: cm_add_site_bd_with_host_route - name: Add site BD with host_route (normal_mode) - mso_schema_site_bd: + cisco.mso.mso_schema_site_bd: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -341,7 +341,7 @@ register: nm_add_site_bd_with_host_route - name: Verify cm_add_site_bd_with_host_route and nm_add_site_bd_with_host_route - assert: + ansible.builtin.assert: that: - cm_add_site_bd_with_host_route is changed - nm_add_site_bd_with_host_route is changed @@ -349,14 +349,14 @@ - nm_add_site_bd_with_host_route.current.hostBasedRouting == true - name: Verify cm_add_site_bd_with_host_route and nm_add_site_bd_with_host_route - assert: + ansible.builtin.assert: that: - cm_add_site_bd_with_host_route.previous == {} - nm_add_site_bd_with_host_route.previous == {} when: version.current.version is version('4.0', '<') # already present when template is defined, thus previous exists - name: Add site BD 3 (normal_mode) - mso_schema_site_bd: + cisco.mso.mso_schema_site_bd: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -367,7 +367,7 @@ register: nm_add_site_bd_3 - name: Verify nm_add_site_bd_3 - assert: + ansible.builtin.assert: that: - nm_add_site_bd_3 is changed - nm_add_site_bd_3.current.hostBasedRouting == true @@ -375,13 +375,13 @@ - nm_add_site_bd_3.current.bdRef.templateName == "Template1" - name: Verify nm_add_site_bd_3 - assert: + ansible.builtin.assert: that: - nm_add_site_bd_3.previous == {} when: version.current.version is version('4.0', '<') # already be present when template is defined, thus previous exists - name: Add site BD 4 (normal_mode) - mso_schema_site_bd: + cisco.mso.mso_schema_site_bd: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -392,7 +392,7 @@ register: nm_add_site_bd_4 - name: Verify nm_add_site_bd_4 - assert: + ansible.builtin.assert: that: - nm_add_site_bd_4 is changed - nm_add_site_bd_4.current.mac == "00:22:23:F1:21:F9" @@ -400,13 +400,13 @@ - nm_add_site_bd_4.current.bdRef.templateName == "Template1" - name: Verify nm_add_site_bd_4 - assert: + ansible.builtin.assert: that: - nm_add_site_bd_4.previous == {} when: version.current.version is version('4.0', '<') # already be present when template is defined, thus previous exists - name: Query a specific BD (check_mode) - mso_schema_site_bd: + cisco.mso.mso_schema_site_bd: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -417,7 +417,7 @@ register: cm_query_bd_2 - name: Query a specific BD (normal_mode) - mso_schema_site_bd: + cisco.mso.mso_schema_site_bd: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -427,7 +427,7 @@ register: nm_query_bd_2 - name: Verify cm_query_bd_2 and nm_query_bd_2 - assert: + ansible.builtin.assert: that: - cm_query_bd_2 is not changed - nm_query_bd_2 is not changed @@ -437,7 +437,7 @@ - cm_query_bd_2.current.hostBasedRouting == nm_query_bd_2.current.hostBasedRouting == true - name: Query all BDs (check_mode) - mso_schema_site_bd: + cisco.mso.mso_schema_site_bd: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -447,7 +447,7 @@ register: cm_query_all_bd - name: Query all BDs (normal_mode) - mso_schema_site_bd: + cisco.mso.mso_schema_site_bd: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -456,7 +456,7 @@ register: nm_query_all_bd - name: Verify cm_query_all_bd and cm_query_all_bd - assert: + ansible.builtin.assert: that: - cm_query_all_bd is not changed - nm_query_all_bd is not changed @@ -468,7 +468,7 @@ - cm_query_all_bd.current[1].bdRef.templateName == nm_query_all_bd.current[1].bdRef.templateName == "Template1" - name: Remove BD 2 (check_mode) - mso_schema_site_bd: + cisco.mso.mso_schema_site_bd: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -479,7 +479,7 @@ register: cm_remove_site_bd_2 - name: Remove BD 2 (normal_mode) - mso_schema_site_bd: + cisco.mso.mso_schema_site_bd: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -489,7 +489,7 @@ register: nm_remove_site_bd_2 - name: Verify cm_remove_site_bd_2 and nm_remove_site_bd_2 - assert: + ansible.builtin.assert: that: - cm_remove_site_bd_2 is changed - nm_remove_site_bd_2 is changed @@ -499,7 +499,7 @@ - cm_remove_site_bd_2.current == nm_remove_site_bd_2.current == {} - name: Remove BD 2 again(normal_mode) - mso_schema_site_bd: + cisco.mso.mso_schema_site_bd: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -509,14 +509,14 @@ register: nm_remove_site_bd_2_again - name: Verify nm_remove_site_bd_2_again - assert: + ansible.builtin.assert: that: - nm_remove_site_bd_2_again is not changed - nm_remove_site_bd_2_again.previous == nm_remove_site_bd_2_again.current == {} when: version.current.version is version('4.0', '<') # no change in NDO4.0 because site will already be present when template is defined - name: Query site without BD (normal_mode) - mso_schema_site_bd: + cisco.mso.mso_schema_site_bd: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -525,7 +525,7 @@ register: nm_query_without_bd - name: Verify nm_query_without_bd - assert: + ansible.builtin.assert: that: - nm_query_without_bd is not changed - nm_query_without_bd.current == [] @@ -534,7 +534,7 @@ # QUERY NON-EXISTING BD - name: Query non-existing BD (check_mode) - mso_schema_site_bd: + cisco.mso.mso_schema_site_bd: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -546,7 +546,7 @@ register: cm_query_non_bd - name: Query non-existing BD (normal_mode) - mso_schema_site_bd: + cisco.mso.mso_schema_site_bd: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -557,7 +557,7 @@ register: nm_query_non_bd - name: Verify cm_query_non_bd and nm_query_non_bd - assert: + ansible.builtin.assert: that: - cm_query_non_bd is not changed - nm_query_non_bd is not changed @@ -565,7 +565,7 @@ # USE NON-EXISTING STATE - name: non_existing_state state (check_mode) - mso_schema_site_bd: + cisco.mso.mso_schema_site_bd: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -576,7 +576,7 @@ register: cm_non_existing_state - name: non_existing_state state (normal_mode) - mso_schema_site_bd: + cisco.mso.mso_schema_site_bd: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -587,7 +587,7 @@ register: nm_non_existing_state - name: Verify cm_non_existing_state and nm_non_existing_state - assert: + ansible.builtin.assert: that: - cm_non_existing_state is not changed - nm_non_existing_state is not changed @@ -595,7 +595,7 @@ # USE A NON_EXISTING_TEMPLATE - name: non_existing_template (check_mode) - mso_schema_site_bd: + cisco.mso.mso_schema_site_bd: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -607,7 +607,7 @@ register: cm_non_existing_template - name: non_existing_template (normal_mode) - mso_schema_site_bd: + cisco.mso.mso_schema_site_bd: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -618,7 +618,7 @@ register: nm_non_existing_template - name: Verify cm_non_existing_template and nm_non_existing_template - assert: + ansible.builtin.assert: that: - cm_non_existing_template is not changed - nm_non_existing_template is not changed @@ -626,7 +626,7 @@ # USE A NON_EXISTING_SCHEMA - name: non_existing_schema (check_mode) - mso_schema_site_bd: + cisco.mso.mso_schema_site_bd: <<: *mso_info schema: non_existing_schema site: '{{ mso_site | default("ansible_test") }}' @@ -638,7 +638,7 @@ register: cm_non_existing_schema - name: non_existing_schema (normal_mode) - mso_schema_site_bd: + cisco.mso.mso_schema_site_bd: <<: *mso_info schema: non_existing_schema site: '{{ mso_site | default("ansible_test") }}' @@ -649,7 +649,7 @@ register: nm_non_existing_schema - name: Verify cm_non_existing_schema and nm_non_existing_schema - assert: + ansible.builtin.assert: that: - cm_non_existing_schema is not changed - nm_non_existing_schema is not changed @@ -657,7 +657,7 @@ # USE A NON_EXISTING_SITE - name: non_existing_site (check_mode) - mso_schema_site_bd: + cisco.mso.mso_schema_site_bd: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: non_existing_site @@ -669,7 +669,7 @@ register: cm_non_existing_site - name: non_existing_site (normal_mode) - mso_schema_site_bd: + cisco.mso.mso_schema_site_bd: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: non_existing_site @@ -680,7 +680,7 @@ register: nm_non_existing_site - name: Verify cm_non_existing_site and nm_non_existing_site - assert: + ansible.builtin.assert: that: - cm_non_existing_site is not changed - nm_non_existing_site is not changed @@ -688,7 +688,7 @@ # USE A NON_EXISTING_SITE_TEMPLATE - name: non_existing_site_template (check_mode) - mso_schema_site_bd: + cisco.mso.mso_schema_site_bd: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -700,7 +700,7 @@ register: cm_non_existing_site_template - name: non_existing_site_template (normal_mode) - mso_schema_site_bd: + cisco.mso.mso_schema_site_bd: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -711,7 +711,7 @@ register: nm_non_existing_site_template - name: Verify cm_non_existing_site_template and nm_non_existing_site_template - assert: + ansible.builtin.assert: that: - cm_non_existing_site_template is not changed - nm_non_existing_site_template is not changed @@ -719,7 +719,7 @@ # USE A TEMPLATE WITHOUT ANY SITE - name: Add site BD to Schema 2 Template 3 without any site associated (check mode) - mso_schema_site_bd: + cisco.mso.mso_schema_site_bd: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}_2' site: '{{ mso_site | default("ansible_test") }}' @@ -731,7 +731,7 @@ register: cm_no_site_associated - name: Add site BD to Template 3 without any site associated (normal mode) - mso_schema_site_bd: + cisco.mso.mso_schema_site_bd: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}_2' site: '{{ mso_site | default("ansible_test") }}' @@ -742,7 +742,7 @@ register: nm_no_site_associated - name: Verify cm_no_site_associated and nm_no_site_associated - assert: + ansible.builtin.assert: that: - cm_no_site_associated is not changed - nm_no_site_associated is not changed diff --git a/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_bd_l3out/tasks/main.yml b/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_bd_l3out/tasks/main.yml index 1e1914522..aaaf61b2f 100644 --- a/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_bd_l3out/tasks/main.yml +++ b/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_bd_l3out/tasks/main.yml @@ -5,13 +5,13 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI MultiSite host, username and password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: mso_hostname, mso_username and mso_password.' when: mso_hostname is not defined or mso_username is not defined or mso_password is not defined # CLEAN ENVIRONMENT - name: Set vars - set_fact: + ansible.builtin.set_fact: mso_info: &mso_info host: '{{ mso_hostname }}' username: '{{ mso_username }}' @@ -22,13 +22,13 @@ output_level: '{{ mso_output_level | default("info") }}' - name: Query MSO version - mso_version: + cisco.mso.mso_version: <<: *mso_info state: query register: version - name: Remove schemas - mso_schema: + cisco.mso.mso_schema: <<: *mso_info schema: '{{ item }}' state: absent @@ -38,7 +38,7 @@ - '{{ mso_schema | default("ansible_test") }}' - name: Ensure site exists - mso_site: + cisco.mso.mso_site: <<: *mso_info site: '{{ mso_site | default("ansible_test") }}' apic_username: '{{ apic_username }}' @@ -49,7 +49,7 @@ state: present - name: Ensure sites removed from tenant ansible_test - mso_tenant_site: + cisco.mso.mso_tenant_site: <<: *mso_info tenant: ansible_test site: '{{ item }}' @@ -60,7 +60,7 @@ - 'azure_{{ mso_site | default("ansible_test") }}' - name: Ensure tenant ansible_test exists - mso_tenant: + cisco.mso.mso_tenant: <<: *mso_info tenant: ansible_test users: @@ -70,7 +70,7 @@ state: present - name: Ensure schema with Template1 and Template2 exist - mso_schema_template: + cisco.mso.mso_schema_template: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' tenant: ansible_test @@ -81,7 +81,7 @@ - { template: Template2} - name: Ensure schema 2 with Template3 exist - mso_schema_template: + cisco.mso.mso_schema_template: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}_2' tenant: ansible_test @@ -89,7 +89,7 @@ state: present - name: Add physical site to a schema - mso_schema_site: + cisco.mso.mso_schema_site: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -97,7 +97,7 @@ state: present - name: Add physical site to a schema2 - mso_schema_site: + cisco.mso.mso_schema_site: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}_2' site: '{{ mso_site | default("ansible_test") }}' @@ -105,7 +105,7 @@ state: present - name: Ensure VRF1 exists - mso_schema_template_vrf: + cisco.mso.mso_schema_template_vrf: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template1 @@ -113,7 +113,7 @@ state: present - name: Ensure VRF2 exists - mso_schema_template_vrf: + cisco.mso.mso_schema_template_vrf: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template2 @@ -121,7 +121,7 @@ state: present - name: Ensure VRF3 exists - mso_schema_template_vrf: + cisco.mso.mso_schema_template_vrf: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}_2' template: Template3 @@ -129,7 +129,7 @@ state: present - name: Add template BD - mso_schema_template_bd: + cisco.mso.mso_schema_template_bd: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template1 @@ -140,7 +140,7 @@ register: nm_add_bd - name: Verify nm_add_bd - assert: + ansible.builtin.assert: that: - nm_add_bd is changed - nm_add_bd.previous == {} @@ -149,7 +149,7 @@ - nm_add_bd.current.vrfRef.vrfName == "VRF1" - name: Add a new L3out - mso_schema_template_l3out: + cisco.mso.mso_schema_template_l3out: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template1 @@ -160,7 +160,7 @@ register: nm_add_l3out - name: Add a new L3out2 in different template - mso_schema_template_l3out: + cisco.mso.mso_schema_template_l3out: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template2 @@ -171,7 +171,7 @@ register: nm_add_l3out - name: Add a new L3out3 in different schema - mso_schema_template_l3out: + cisco.mso.mso_schema_template_l3out: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}_2' template: Template3 @@ -182,13 +182,13 @@ register: nm_add_l3out - name: Verify nm_add_l3out - assert: + ansible.builtin.assert: that: - nm_add_l3out is changed - nm_add_l3out.previous == {} - name: Add BD to site - mso_schema_site_bd: + cisco.mso.mso_schema_site_bd: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -198,21 +198,21 @@ register: nm_add_site_bd - name: Verify nm_add_site_bd - assert: + ansible.builtin.assert: that: - nm_add_site_bd.current.bdRef.bdName == "ansible_test_1" - nm_add_site_bd.current.bdRef.templateName == "Template1" - nm_add_site_bd.current.hostBasedRouting == false - name: Verify nm_add_site_bd - assert: + ansible.builtin.assert: that: - nm_add_site_bd is changed - nm_add_site_bd.previous == {} when: version.current.version is version('4.0', '<') # no change in NDO4.0 because site will already be present when template is defined - name: Add l3out to BD Site - mso_schema_site_bd_l3out: &site_bd_l3out_again + cisco.mso.mso_schema_site_bd_l3out: &site_bd_l3out_again <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -224,12 +224,12 @@ register: nm_bd_site_l3out - name: Add l3out to BD Site again - mso_schema_site_bd_l3out: + cisco.mso.mso_schema_site_bd_l3out: <<: *site_bd_l3out_again register: nm_bd_site_l3out_again - name: Verify nm_bd_site_l3out - assert: + ansible.builtin.assert: that: - nm_bd_site_l3out is changed - nm_bd_site_l3out.previous == {} @@ -237,7 +237,7 @@ - nm_bd_site_l3out_again is not changed - name: Query a specific BD site l3out - mso_schema_site_bd_l3out: + cisco.mso.mso_schema_site_bd_l3out: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -249,13 +249,13 @@ register: query_result - name: Verify query_result - assert: + ansible.builtin.assert: that: - query_result is not changed - nm_bd_site_l3out.current.l3outName == "L3out1" - name: Add l3out2 from different template to BD Site - mso_schema_site_bd_l3out: + cisco.mso.mso_schema_site_bd_l3out: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -268,7 +268,7 @@ register: nm_bd_site_l3out2 - name: Add l3out3 from different schema to BD Site - mso_schema_site_bd_l3out: + cisco.mso.mso_schema_site_bd_l3out: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -282,7 +282,7 @@ register: nm_bd_site_l3out3 - name: Verify nm_bd_site_l3out2 and nm_bd_site_l3out3 - assert: + ansible.builtin.assert: that: - nm_bd_site_l3out2 is changed - nm_bd_site_l3out2.previous == {} @@ -292,7 +292,7 @@ - nm_bd_site_l3out3.current.l3outName == "L3out3" - name: Query all BD site l3outs - mso_schema_site_bd_l3out: + cisco.mso.mso_schema_site_bd_l3out: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -302,7 +302,7 @@ register: query_all - name: Verify query_all - assert: + ansible.builtin.assert: that: - query_all is not changed - query_all.current.0.l3outName == "L3out1" @@ -311,7 +311,7 @@ # Checking error conditions - name: Use non_existing template - mso_schema_site_bd_l3out: + cisco.mso.mso_schema_site_bd_l3out: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -324,7 +324,7 @@ register: non_existing_template - name: Use non_existing BD - mso_schema_site_bd_l3out: + cisco.mso.mso_schema_site_bd_l3out: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -335,7 +335,7 @@ register: non_existing_bd - name: Query non_existing BD site L3out - mso_schema_site_bd_l3out: + cisco.mso.mso_schema_site_bd_l3out: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -348,7 +348,7 @@ register: non_existing_l3out - name: Verify error query - assert: + ansible.builtin.assert: that: - non_existing_template is not changed - non_existing_template.msg == "Provided template 'non_existing_template' not matching existing template(s){{':'}} Template1, Template2" @@ -359,7 +359,7 @@ # Check addition of l3out to Site BD without adding BD to site - name: Remove l3out from BD Site - mso_schema_site_bd_l3out: + cisco.mso.mso_schema_site_bd_l3out: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -371,14 +371,14 @@ register: remove_bd_site_l3out - name: Verify remove_bd_site_l3out - assert: + ansible.builtin.assert: that: - remove_bd_site_l3out is changed - remove_bd_site_l3out.previous.l3outName == "L3out1" - remove_bd_site_l3out.current == {} - name: Remove BD from site - mso_schema_site_bd: + cisco.mso.mso_schema_site_bd: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -388,7 +388,7 @@ register: nm_remove_site_bd - name: Verify nm_remove_site_bd - assert: + ansible.builtin.assert: that: - nm_remove_site_bd is changed - nm_remove_site_bd.previous.bdRef.bdName == "ansible_test_1" @@ -396,7 +396,7 @@ - nm_remove_site_bd.current == {} - name: Remove template BD - mso_schema_template_bd: + cisco.mso.mso_schema_template_bd: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template1 @@ -405,13 +405,13 @@ register: nm_remove_bd - name: Verify nm_remove_bd - assert: + ansible.builtin.assert: that: - nm_remove_bd is changed - nm_remove_bd.current == {} - name: Add new template BD - mso_schema_template_bd: + cisco.mso.mso_schema_template_bd: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template1 @@ -422,13 +422,13 @@ register: nm_add_bd_template - name: Verify nm_add_bd_template - assert: + ansible.builtin.assert: that: - nm_add_bd_template is changed - nm_add_bd_template.previous == {} - name: Add a new l3 out to BD (BD not associated to Site) - mso_schema_site_bd_l3out: + cisco.mso.mso_schema_site_bd_l3out: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -440,7 +440,7 @@ register: add_bd_site_l3out - name: Verify add_bd_site_l3out - assert: + ansible.builtin.assert: that: - add_bd_site_l3out is changed - add_bd_site_l3out.previous == {} diff --git a/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_bd_subnet/tasks/main.yml b/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_bd_subnet/tasks/main.yml index 1f6f94c02..9da901308 100644 --- a/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_bd_subnet/tasks/main.yml +++ b/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_bd_subnet/tasks/main.yml @@ -4,13 +4,13 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI MultiSite host, username and password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: mso_hostname, mso_username and mso_password.' when: mso_hostname is not defined or mso_username is not defined or mso_password is not defined # CLEAN ENVIRONMENT - name: Set vars - set_fact: + ansible.builtin.set_fact: mso_info: &mso_info host: '{{ mso_hostname }}' username: '{{ mso_username }}' @@ -21,13 +21,13 @@ output_level: '{{ mso_output_level | default("info") }}' - name: Query MSO version - mso_version: + cisco.mso.mso_version: <<: *mso_info state: query register: version - name: Remove schemas - mso_schema: + cisco.mso.mso_schema: <<: *mso_info schema: '{{ item }}' state: absent @@ -36,7 +36,7 @@ - '{{ mso_schema | default("ansible_test") }}' - name: Ensure site exists - mso_site: + cisco.mso.mso_site: <<: *mso_info site: '{{ mso_site | default("ansible_test") }}' apic_username: '{{ apic_username }}' @@ -47,7 +47,7 @@ state: present - name: Ensure sites removed from tenant ansible_test - mso_tenant_site: + cisco.mso.mso_tenant_site: <<: *mso_info tenant: ansible_test site: '{{ item }}' @@ -58,7 +58,7 @@ - 'azure_{{ mso_site | default("ansible_test") }}' - name: Ensure tenant ansible_test exists - mso_tenant: + cisco.mso.mso_tenant: <<: *mso_info tenant: ansible_test users: @@ -68,7 +68,7 @@ state: present - name: Ensure schema 1 with Template1, Template2, Template4 and Template5 - mso_schema_template: + cisco.mso.mso_schema_template: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' tenant: ansible_test @@ -81,7 +81,7 @@ - Template5 - name: Ensure schema 2 with Template3 exist - mso_schema_template: + cisco.mso.mso_schema_template: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}_2' tenant: ansible_test @@ -89,7 +89,7 @@ state: present - name: Add physical site to templates - mso_schema_site: + cisco.mso.mso_schema_site: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -101,7 +101,7 @@ - Template5 - name: Ensure VRF1 exists - mso_schema_template_vrf: + cisco.mso.mso_schema_template_vrf: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template1 @@ -110,7 +110,7 @@ state: present - name: Add template BD to Template1 for create in site subnet - mso_schema_template_bd: + cisco.mso.mso_schema_template_bd: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template1 @@ -123,7 +123,7 @@ state: present - name: Add template BD to Template3 - mso_schema_template_bd: + cisco.mso.mso_schema_template_bd: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}_2' template: Template3 @@ -136,7 +136,7 @@ register: nm_add_bd_template_3 - name: Add template BD to Template2 - mso_schema_template_bd: + cisco.mso.mso_schema_template_bd: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template2 @@ -149,7 +149,7 @@ register: nm_add_bd_template_2 - name: Add template BD to Template4 - mso_schema_template_bd: + cisco.mso.mso_schema_template_bd: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template4 @@ -162,7 +162,7 @@ register: nm_add_bd_template_4 - name: Add template BD to Template1 without disabling layer2_stretch - mso_schema_template_bd: + cisco.mso.mso_schema_template_bd: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template1 @@ -173,7 +173,7 @@ register: nm_add_bd - name: Add site BD - mso_schema_site_bd: + cisco.mso.mso_schema_site_bd: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -183,7 +183,7 @@ register: nm_add_site_bd - name: Add site BD subnet with layer2_stretch enabled - mso_schema_site_bd_subnet: + cisco.mso.mso_schema_site_bd_subnet: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -195,12 +195,12 @@ register: add_site_bd_subnet_with_l2Stretch_enabled - name: Verify add_site_bd_subnet_with_l2Stretch_enabled - assert: + ansible.builtin.assert: that: - add_site_bd_subnet_with_l2Stretch_enabled.msg == "The l2Stretch of template bd should be false in order to create a site bd subnet. Set l2Stretch as false using mso_schema_template_bd" - name: Disable layer2_stretch in template BD - mso_schema_template_bd: + cisco.mso.mso_schema_template_bd: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template1 @@ -212,7 +212,7 @@ register: nm_add_bd - name: Add site BD subnet with layer2_stretch disabled (check_mode) - mso_schema_site_bd_subnet: + cisco.mso.mso_schema_site_bd_subnet: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -224,7 +224,7 @@ register: cm_add_site_bd_subnet - name: Verify cm_add_site_bd_subnet - assert: + ansible.builtin.assert: that: - cm_add_site_bd_subnet is changed - cm_add_site_bd_subnet.previous == {} @@ -236,7 +236,7 @@ - cm_add_site_bd_subnet.current.querier == False - name: Add site BD subnet with layer2_stretch disabled (normal_mode) - mso_schema_site_bd_subnet: + cisco.mso.mso_schema_site_bd_subnet: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -247,7 +247,7 @@ register: nm_add_site_bd_subnet - name: Verify nm_add_site_bd_subnet - assert: + ansible.builtin.assert: that: - nm_add_site_bd_subnet is changed - nm_add_site_bd_subnet.previous == {} @@ -259,7 +259,7 @@ - nm_add_site_bd_subnet.current.querier == False - name: Add site BD subnet again - mso_schema_site_bd_subnet: + cisco.mso.mso_schema_site_bd_subnet: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -270,12 +270,12 @@ register: nm_add_site_bd_subnet_again - name: Verify nm_add_site_bd_subnet_again - assert: + ansible.builtin.assert: that: - nm_add_site_bd_subnet_again is not changed - name: Add another site BD subnet - mso_schema_site_bd_subnet: + cisco.mso.mso_schema_site_bd_subnet: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -291,7 +291,7 @@ register: nm_add_another_site_bd_subnet - name: Verify nm_add_another_site_bd_subnet - assert: + ansible.builtin.assert: that: - nm_add_another_site_bd_subnet is changed - nm_add_another_site_bd_subnet.previous == {} @@ -302,7 +302,7 @@ - nm_add_another_site_bd_subnet.current.querier == true - name: Add BD ansible_test_5 to Schema1, template5 - mso_schema_template_bd: + cisco.mso.mso_schema_template_bd: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template5 @@ -315,7 +315,7 @@ state: present - name: Add site BD5 - mso_schema_site_bd: + cisco.mso.mso_schema_site_bd: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -324,7 +324,7 @@ state: present - name: Add site BD5 subnet with layer2_stretch disabled (normal_mode) - mso_schema_site_bd_subnet: + cisco.mso.mso_schema_site_bd_subnet: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -341,7 +341,7 @@ register: nm_add_site_bd_subnet5 - name: Verify nm_add_site_bd_subnet5 for a version that's < 3.1 - assert: + ansible.builtin.assert: that: - nm_add_site_bd_subnet5 is changed - nm_add_site_bd_subnet5.previous == {} @@ -354,7 +354,7 @@ when: version.current.version is version('3.1.1g', '<') - name: Verify nm_add_site_bd_subnet5 for a version that's >= 3.1 - assert: + ansible.builtin.assert: that: - nm_add_site_bd_subnet5 is changed - nm_add_site_bd_subnet5.previous == {} @@ -368,13 +368,13 @@ when: version.current.version is version('3.1.1g', '>=') - name: Verify nm_add_site_bd_subnet5 for a version that's >= 3.1.1h - assert: + ansible.builtin.assert: that: - nm_add_site_bd_subnet5.current.primary == True when: version.current.version is version('3.1.1h', '>=') - name: Add site BD subnet with non existing site bd (normal_mode) - mso_schema_site_bd_subnet: + cisco.mso.mso_schema_site_bd_subnet: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -385,7 +385,7 @@ register: nm_add_site_bd_subnet_and_site_bd - name: Verify nm_add_site_bd_subnet_and_site_bd - assert: + ansible.builtin.assert: that: - nm_add_site_bd_subnet_and_site_bd is changed - nm_add_site_bd_subnet_and_site_bd.previous == {} @@ -397,7 +397,7 @@ - nm_add_site_bd_subnet_and_site_bd.current.querier == False - name: Query site bd - mso_schema_site_bd: + cisco.mso.mso_schema_site_bd: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -407,12 +407,12 @@ register: query_site_bd - name: Verify query_site_bd - assert: + ansible.builtin.assert: that: - query_site_bd.current.bdRef.bdName == "ansible_test_site_bd_from_subnet" - name: Add site BD subnet with now existing site bd again (normal_mode) - mso_schema_site_bd_subnet: + cisco.mso.mso_schema_site_bd_subnet: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -423,12 +423,12 @@ register: nm_add_site_bd_subnet_and_site_bd_again - name: Verify nm_add_site_bd_subnet_and_site_bd_again - assert: + ansible.builtin.assert: that: - nm_add_site_bd_subnet_and_site_bd_again is not changed - name: Query all subnets - mso_schema_site_bd_subnet: + cisco.mso.mso_schema_site_bd_subnet: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -438,7 +438,7 @@ register: query_all - name: Verify query_all - assert: + ansible.builtin.assert: that: - query_all is not changed - query_all.current | length == 2 @@ -446,7 +446,7 @@ - query_all.current.1.ip == "10.10.10.1/16" - name: Query a specific site BD subnet - mso_schema_site_bd_subnet: + cisco.mso.mso_schema_site_bd_subnet: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -457,13 +457,13 @@ register: query_subnet - name: Verify query_subnet - assert: + ansible.builtin.assert: that: - query_subnet is not changed - query_subnet.current.ip == "10.1.0.1/16" - name: Query a specific site BD5 subnet - mso_schema_site_bd_subnet: + cisco.mso.mso_schema_site_bd_subnet: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -474,14 +474,14 @@ register: query_subnet5 - name: Verify query_subnet5 for version before 3.1 - assert: + ansible.builtin.assert: that: - query_subnet5 is not changed - query_subnet5.current.ip == "10.1.0.5/16" when: version.current.version is version('3.1.1g', '<') - name: Verify query_subnet5 for 3.1 version and later - assert: + ansible.builtin.assert: that: - query_subnet5 is not changed - query_subnet5.current.ip == "10.1.0.5/16" @@ -489,13 +489,13 @@ when: version.current.version is version('3.1.1g', '>=') - name: Verify query_subnet5 for 3.1.1h version and later - assert: + ansible.builtin.assert: that: - query_subnet5.current.primary == true when: version.current.version is version('3.1.1h', '>=') - name: Remove a site BD subnet - mso_schema_site_bd_subnet: + cisco.mso.mso_schema_site_bd_subnet: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -506,14 +506,14 @@ register: rm_subnet - name: Verify rm_subnet - assert: + ansible.builtin.assert: that: - rm_subnet is changed - rm_subnet.current == {} - rm_subnet.previous.ip == "10.1.0.1/16" - name: Remove the site BD subnet again - mso_schema_site_bd_subnet: + cisco.mso.mso_schema_site_bd_subnet: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -524,13 +524,13 @@ register: rm_subnet_again - name: Verify rm_subnet_again - assert: + ansible.builtin.assert: that: - rm_subnet_again is not changed - rm_subnet_again.previous == rm_subnet_again.current == {} - name: Remove a site BD 5 subnet - mso_schema_site_bd_subnet: + cisco.mso.mso_schema_site_bd_subnet: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -541,7 +541,7 @@ register: rm_subnet5 - name: Verify rm_subnet5 - assert: + ansible.builtin.assert: that: - rm_subnet5 is changed - rm_subnet5.current == {} @@ -549,7 +549,7 @@ # Use non_existing_schema - name: Query subnet by non_existing_schema - mso_schema_site_bd_subnet: + cisco.mso.mso_schema_site_bd_subnet: <<: *mso_info schema: non_existing_schema site: '{{ mso_site | default("ansible_test") }}' @@ -561,13 +561,13 @@ register: non_existing_schema - name: Verify non_existing_schema - assert: + ansible.builtin.assert: that: - non_existing_schema.msg == "Provided schema 'non_existing_schema' does not exist." # Use non_existing_template - name: Query subnet by non_existing_template - mso_schema_site_bd_subnet: + cisco.mso.mso_schema_site_bd_subnet: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -579,13 +579,13 @@ register: non_existing_template - name: Verify non_existing_template - assert: + ansible.builtin.assert: that: - non_existing_template.msg == "Provided template 'non_existing_template' not matching existing template(s){{':'}} Template1, Template2, Template4, Template5" # Use non_existing_template_bd - name: Query subnet by non_existing_template_bd - mso_schema_site_bd_subnet: + cisco.mso.mso_schema_site_bd_subnet: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -597,13 +597,13 @@ register: non_existing_template_bd - name: Verify non_existing_template_bd - assert: + ansible.builtin.assert: that: - non_existing_template_bd.msg == "Provided BD 'non_existing_template_bd' not matching existing bd(s){{':'}} ansible_test_site_bd_from_subnet, ansible_test_1" # Use template without site associated - name: Query with no site associated to template - mso_schema_site_bd_subnet: + cisco.mso.mso_schema_site_bd_subnet: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}_2' site: '{{ mso_site | default("ansible_test") }}' @@ -615,13 +615,13 @@ register: template_without_sites - name: Verify template_without_sites - assert: + ansible.builtin.assert: that: - template_without_sites.msg == "No sites associated with schema 'ansible_test_2'. Associate the site with the schema using (M) mso_schema_site." # Use non_existing_subnet - name: Query with non_existing_subnet - mso_schema_site_bd_subnet: + cisco.mso.mso_schema_site_bd_subnet: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -633,13 +633,13 @@ register: non_existing_subnet - name: Verify non_existing_subnet - assert: + ansible.builtin.assert: that: - non_existing_subnet.msg.startswith("Provided subnet 'non_existing_subnet' not matching existing site bd subnet(s){{':'}}") # Use non_existing_site_template_association - name: Query with non_existing_site_template_association - mso_schema_site_bd_subnet: + cisco.mso.mso_schema_site_bd_subnet: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -651,12 +651,12 @@ register: non_existing_site_template_association - name: Verify non_existing_site_template_association - assert: + ansible.builtin.assert: that: - non_existing_site_template_association.msg == "Provided site 'ansible_test' not associated with template 'Template4'. Site is currently associated with template(s){{':'}} Template1, Template2, Template5" - name: Remove schemas for next ci test case - mso_schema: + cisco.mso.mso_schema: <<: *mso_info schema: '{{ item }}' state: absent diff --git a/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_contract_service_graph/aliases b/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_contract_service_graph/aliases new file mode 100644 index 000000000..5042c9c09 --- /dev/null +++ b/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_contract_service_graph/aliases @@ -0,0 +1,2 @@ +# No ACI MultiSite infrastructure, so not enabled +# unsupported diff --git a/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_contract_service_graph/tasks/l4_l7_devices.yml b/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_contract_service_graph/tasks/l4_l7_devices.yml new file mode 100644 index 000000000..e7bacfa91 --- /dev/null +++ b/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_contract_service_graph/tasks/l4_l7_devices.yml @@ -0,0 +1,312 @@ +# Test code for the MSO modules +# Copyright: (c) 2024, Sabari Jaganathan (@sajagana) <sajagana@cisco.com> + +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +- name: Test that we have an ACI MultiSite host, username and password + ansible.builtin.fail: + msg: "Please define the following variables: mso_hostname, mso_username and mso_password." + when: mso_hostname is not defined or mso_username is not defined or mso_password is not defined + +# CLEAN ENVIRONMENT +- name: Set vars + ansible.builtin.set_fact: + aci_info: &aci_info + host: "{{ apic_hostname }}" + username: "{{ apic_username }}" + password: "{{ apic_password }}" + validate_certs: "{{ apic_validate_certs | default(false) }}" + use_ssl: "{{ apic_use_ssl | default(true) }}" + use_proxy: "{{ apic_use_proxy | default(true) }}" + output_level: '{{ mso_output_level | default("info") }}' + +- name: Query system information + cisco.aci.aci_system: + <<: *aci_info + id: 1 + state: query + register: aci_version + +- name: Remove an existing tenant on APIC + cisco.aci.aci_tenant: + <<: *aci_info + name: '{{ mso_tenant | default("ansible_test") }}' + state: absent + +- name: Add a tenant on APIC + cisco.aci.aci_tenant: + <<: *aci_info + name: '{{ mso_tenant | default("ansible_test") }}' + +# Site type checking for L4-L7 Device configuration +# QUERY OBJECTS +- name: Query cloud provider object + cisco.aci.aci_cloud_provider: + <<: *aci_info + state: query + register: query_cloud + when: aci_version.current.0.topSystem.attributes.version is version('4.1', '>=') + +- name: Set vars + ansible.builtin.set_fact: + query_cloud: + current: [] + when: aci_version.current.0.topSystem.attributes.version is version('4.1', '<') + +- name: Verify query_cloud for all sites + ansible.builtin.assert: + that: + - query_cloud is not changed + +- name: Verify query_cloud for Cloud Sites + ansible.builtin.assert: + that: + - query_cloud is not changed + - query_cloud.current.0.cloudProvP.attributes.environment == "public-cloud" + - '"vendor" in query_cloud.current.0.cloudProvP.attributes' + when: + - query_cloud.current | length > 0 # This condition will execute only cloud sites + +# Cloud Site block +- name: Execute tasks only for cloud sites + when: + - query_cloud.current | length > 0 + - query_cloud.current.0.cloudProvP.attributes.vendor == "azure" + block: + - name: Add azure_vrf to the {{ mso_tenant | default("ansible_test") }} + cisco.aci.aci_vrf: + <<: *aci_info + tenant: '{{ mso_tenant | default("ansible_test") }}' + vrf: azure_vrf + + - name: Add azure_ctxprof to the {{ mso_tenant | default("ansible_test") }} + cisco.aci.aci_cloud_ctx_profile: + <<: *aci_info + tenant: '{{ mso_tenant | default("ansible_test") }}' + cloud: azure + name: azure_ctxprof + vrf: azure_vrf + region: westus2 + primary_cidr: "1.1.1.2/32" + state: present + + - name: Add the subnet to the azure_ctxprof + cisco.aci.aci_rest: + <<: *aci_info + path: api/mo/uni/tn-{{ mso_tenant | default("ansible_test") }}/ctxprofile-azure_ctxprof/cidr-[1.1.1.2/32]/subnet-[1.1.1.2/32].json + method: post + content: + cloudSubnet: + attributes: + ip: 1.1.1.2/32 + name: azure_ctxprof_cidr + children: + - cloudRsZoneAttach: + attributes: + tDn: "uni/clouddomp/provp-azure/region-westus2/zone-default" + + - name: Add the {{ mso_tenant | default("ansible_test") }}_adc device - ThirdParty_LB + cisco.aci.aci_rest: + <<: *aci_info + path: /api/node/mo/uni/tn-{{ mso_tenant | default("ansible_test") }}/cld-{{ mso_tenant | default("ansible_test") }}_adc.json + method: post + content: + cloudLDev: + attributes: + targetMode: unspecified + name: '{{ mso_tenant | default("ansible_test") }}_adc' + svcType: ADC + children: + - cloudRsLDevToCtx: + attributes: + tDn: uni/tn-{{ mso_tenant | default("ansible_test") }}/ctx-azure_vrf + - cloudLIf: + attributes: + allowAll: "yes" + name: TP_LB_Inf + children: + - cloudEPSelector: + attributes: + name: TP_LB_Inf_Selector + matchExpression: IP=='1.1.1.1' + + - name: Add the {{ mso_tenant | default("ansible_test") }}_firewall1 device + cisco.aci.aci_rest: + <<: *aci_info + path: /api/node/mo/uni/tn-{{ mso_tenant | default("ansible_test") }}/cld-{{ mso_tenant | default("ansible_test") }}_firewall1.json + method: post + content: + cloudLDev: + attributes: + name: '{{ mso_tenant | default("ansible_test") }}_firewall1' + svcType: FW + children: + - cloudRsLDevToCtx: + attributes: + tDn: uni/tn-{{ mso_tenant | default("ansible_test") }}/ctx-azure_vrf + - cloudLIf: + attributes: + allowAll: "yes" + name: TP_FW_Inf1 + children: + - cloudEPSelector: + attributes: + name: TP_FW_Inf_Selector + matchExpression: IP=='1.1.1.1' + + - name: Add the {{ mso_tenant | default("ansible_test") }}_firewall2 device + cisco.aci.aci_rest: + <<: *aci_info + path: /api/node/mo/uni/tn-{{ mso_tenant | default("ansible_test") }}/cld-{{ mso_tenant | default("ansible_test") }}_firewall2.json + method: post + content: + cloudLDev: + attributes: + name: '{{ mso_tenant | default("ansible_test") }}_firewall2' + svcType: FW + children: + - cloudRsLDevToCtx: + attributes: + tDn: uni/tn-{{ mso_tenant | default("ansible_test") }}/ctx-azure_vrf + - cloudLIf: + attributes: + allowAll: "yes" + name: TP_FW_Inf2 + children: + - cloudEPSelector: + attributes: + name: TP_FW_Inf_Selector + matchExpression: IP=='1.1.1.1' + + - name: Add the {{ mso_tenant | default("ansible_test") }}_other device + cisco.aci.aci_rest: + <<: *aci_info + path: /api/node/mo/uni/tn-{{ mso_tenant | default("ansible_test") }}/clb-{{ mso_tenant | default("ansible_test") }}_other.json + method: post + content: + cloudLB: + attributes: + name: '{{ mso_tenant | default("ansible_test") }}_other' + type: network + children: + - cloudRsLDevToCloudSubnet: + attributes: + tDn: 'uni/tn-{{ mso_tenant | default("ansible_test") }}/ctxprofile-azure_ctxprof/cidr-[1.1.1.2/32]/subnet-[1.1.1.2/32]' + + - name: Add the {{ mso_tenant | default("ansible_test") }}_app_lb device + cisco.aci.aci_rest: + <<: *aci_info + path: /api/node/mo/uni/tn-{{ mso_tenant | default("ansible_test") }}/clb-{{ mso_tenant | default("ansible_test") }}_app_lb.json + method: post + content: + cloudLB: + attributes: + name: '{{ mso_tenant | default("ansible_test") }}_app_lb' + type: application + children: + - cloudRsLDevToCloudSubnet: + attributes: + tDn: 'uni/tn-{{ mso_tenant | default("ansible_test") }}/ctxprofile-azure_ctxprof/cidr-[1.1.1.2/32]/subnet-[1.1.1.2/32]' + +- name: Execute tasks only for non-cloud sites + when: query_cloud.current | length == 0 # Non-Cloud Site block + block: + - name: Remove the redirect_policy2 from the common tenant - setup part + cisco.aci.aci_rest: + <<: *aci_info + path: "/api/node/mo/uni/tn-common/svcCont.json" + method: post + content: + vnsSvcRedirectPol: + attributes: + name: redirect_policy2 + status: deleted + + - name: Remove ansible_tenant from the APIC - setup part + cisco.aci.aci_tenant: + <<: *aci_info + tenant: '{{ mso_tenant | default("ansible_test") }}' + state: absent + + - name: Add ansible_tenant to the APIC + cisco.aci.aci_tenant: + <<: *aci_info + tenant: '{{ mso_tenant | default("ansible_test") }}' + state: present + + - name: Add devices and cluster interfaces to the ansible_tenant + cisco.aci.aci_rest: + <<: *aci_info + path: "/api/node/mo/uni/tn-{{ item.tenant }}.json" + method: post + content: + vnsLDevVip: + attributes: + svcType: "{{ item.type }}" + managed: "false" + name: "{{ item.name }}" + children: + - vnsCDev: + attributes: + name: "{{ item.name }}" + children: + - vnsCIf: + attributes: + name: "{{ item.concrete_interface }}" + children: + - vnsRsCIfPathAtt: + attributes: + tDn: "topology/pod-1/paths-101/pathep-[eth1/1]" + - vnsLIf: + attributes: + name: "{{ item.cluster_interface }}" + children: + - vnsRsCIfAttN: + attributes: + tDn: "uni/tn-{{ item.tenant }}/lDevVip-{{ item.name }}/cDev-{{ item.name }}/cIf-[{{ item.concrete_interface }}]" + - vnsLIf: + attributes: + name: "{{ item.cluster_interface }}_2" + children: + - vnsRsCIfAttN: + attributes: + tDn: "uni/tn-{{ item.tenant }}/lDevVip-{{ item.name }}/cDev-{{ item.name }}/cIf-[{{ item.concrete_interface }}]" + + loop: + - { + tenant: '{{ mso_tenant | default("ansible_test") }}', + type: FW, + name: ansible_tenant_firewall1, + cluster_interface: clu_if1, + concrete_interface: cn_if1, + } + - { + tenant: '{{ mso_tenant | default("ansible_test") }}', + type: ADC, + name: ansible_tenant_adc, + cluster_interface: clu_if3, + concrete_interface: cn_if3, + } + - { + tenant: '{{ mso_tenant | default("ansible_test") }}', + type: OTHERS, + name: ansible_tenant_other, + cluster_interface: clu_if4, + concrete_interface: cn_if4, + } + + - name: Add redirect policies to the common and ansible_tenant tenants + cisco.aci.aci_rest: + <<: *aci_info + path: "/api/node/mo/uni/tn-{{ item.tenant }}/svcCont.json" + method: post + content: + vnsSvcRedirectPol: + attributes: + name: "{{ item.name }}" + loop: + - { + tenant: '{{ mso_tenant | default("ansible_test") }}', + name: redirect_policy1, + } + - { tenant: common, name: redirect_policy2 } diff --git a/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_contract_service_graph/tasks/main.yml b/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_contract_service_graph/tasks/main.yml new file mode 100644 index 000000000..ebee2fb2a --- /dev/null +++ b/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_contract_service_graph/tasks/main.yml @@ -0,0 +1,935 @@ +# Test code for the MSO modules +# Copyright: (c) 2024, Sabari Jaganathan (@sajagana) <sajagana@cisco.com> + +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +- name: Test that we have an ACI MultiSite host, username and password + ansible.builtin.fail: + msg: "Please define the following variables: mso_hostname, mso_username and mso_password." + when: mso_hostname is not defined or mso_username is not defined or mso_password is not defined + +# CLEAN ENVIRONMENT +- name: Set vars + ansible.builtin.set_fact: + mso_info: &mso_info + host: "{{ mso_hostname }}" + username: "{{ mso_username }}" + password: "{{ mso_password }}" + validate_certs: "{{ mso_validate_certs | default(false) }}" + use_ssl: "{{ mso_use_ssl | default(true) }}" + use_proxy: "{{ mso_use_proxy | default(false) }}" + output_level: '{{ mso_output_level | default("info") }}' + aci_info: &aci_info + host: "{{ apic_hostname }}" + username: "{{ apic_username }}" + password: "{{ apic_password }}" + validate_certs: "{{ apic_validate_certs | default(false) }}" + use_ssl: "{{ apic_use_ssl | default(true) }}" + use_proxy: "{{ apic_use_proxy | default(true) }}" + output_level: '{{ mso_output_level | default("info") }}' + +# Setup part begins +- name: Set ansible_network_os to cisco.aci.aci and ansible_connection to local + ansible.builtin.set_fact: + ansible_connection: local + ansible_network_os: cisco.aci.aci + +- name: Reset the ansible_connection to access the APIC + ansible.builtin.meta: reset_connection + +- name: Include tasks for L4-L7 devices + ansible.builtin.include_tasks: l4_l7_devices.yml + +- name: Set ansible_network_os to cisco.nd.nd and ansible_connection to ansible.netcommon.httpapi + ansible.builtin.set_fact: + ansible_connection: ansible.netcommon.httpapi + ansible_network_os: cisco.nd.nd + +- name: Reset the ansible_connection to access the MSO/NDO + ansible.builtin.meta: reset_connection + +- name: Remove ansible_schema to start the test - setup part + cisco.mso.mso_schema: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_schema") }}' + state: absent + +- name: Remove {{ mso_tenant | default("ansible_test") }} tenant to start the test - setup part + cisco.mso.mso_tenant: + <<: *mso_info + tenant: '{{ mso_tenant | default("ansible_test") }}' + state: absent + +- name: Add {{ mso_tenant | default("ansible_test") }} tenant + cisco.mso.mso_tenant: + <<: *mso_info + tenant: '{{ mso_tenant | default("ansible_test") }}' + users: ["{{ mso_username }}"] + state: present + +- name: Associate Azure site with '{{ mso_tenant | default("ansible_test") }}' + cisco.mso.mso_tenant_site: + <<: *mso_info + tenant: '{{ mso_tenant | default("ansible_test") }}' + site: ansible_test + state: present + when: + - query_cloud.current | length == 0 + +- name: Associate Azure site with '{{ mso_tenant | default("ansible_test") }}' # Azure Task + cisco.mso.mso_tenant_site: + <<: *mso_info + tenant: '{{ mso_tenant | default("ansible_test") }}' + site: azure_ansible_test_2 + cloud_account: "uni/tn-{{ mso_tenant | default('ansible_test') }}/act-[{{ azure_cloud_account | default(123) }}]-vendor-azure" + state: present + when: + - query_cloud.current | length > 0 + - query_cloud.current.0.cloudProvP.attributes.vendor == "azure" + +- name: Ensure ansible_schema with ansible_template1 and ansible_template2 exist + cisco.mso.mso_schema_template: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_schema") }}' + tenant: '{{ mso_tenant | default("ansible_test") }}' + template: "{{ item }}" + state: present + loop: + - "ansible_template1" + - "ansible_template2" + +- name: Create ansible_service_graph schema template service graph + cisco.mso.mso_schema_template_service_graph: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_schema") }}' + template: "ansible_template1" + service_graph: "ansible_service_graph" + display_name: "ansible_service_graph" + service_nodes: + - type: firewall + - type: load-balancer + - type: other + filter_after_first_node: allow_all + state: present + +- name: Bind ansible_test site with ansible_template1 and ansible_template2 + cisco.mso.mso_schema_site: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_schema") }}' + template: "{{ item }}" + site: '{{ mso_site | default("ansible_test") }}' + state: present + loop: + - "ansible_template1" + - "ansible_template2" + +- name: Configure the site service graph ansible_service_graph + cisco.mso.mso_schema_site_service_graph: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_schema") }}' + template: "ansible_template1" + service_graph: "ansible_service_graph" + site: '{{ mso_site | default("ansible_test") }}' + tenant: '{{ mso_tenant | default("ansible_test") }}' + devices: + - name: '{{ mso_tenant | default("ansible_test") }}_firewall1' + - name: '{{ mso_tenant | default("ansible_test") }}_adc' + - name: '{{ mso_tenant | default("ansible_test") }}_other' + state: present + +- name: Add Filter1 to ansible_template1 + cisco.mso.mso_schema_template_filter_entry: &filter_present + <<: *mso_info + schema: '{{ mso_schema | default("ansible_schema") }}' + template: "ansible_template1" + filter: Filter1 + entry: Filter1Entry + state: present + +- name: Add Filter2 to ansible_template1 + cisco.mso.mso_schema_template_filter_entry: + <<: *filter_present + filter: Filter2 + entry: Filter2Entry + state: present + +- name: Add Contracts to the ansible_template1 + cisco.mso.mso_schema_template_contract_filter: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_schema") }}' + template: "ansible_template1" + contract: "{{ item }}" + filter: Filter1 + state: present + loop: + - Contract1 + - Contract2 + - Contract3 + +- name: Add a VRF1 to ansible_template1 + cisco.mso.mso_schema_template_vrf: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_schema") }}' + template: "ansible_template1" + vrf: VRF1 + state: present + +- name: Add a VRF2 to ansible_template1 + cisco.mso.mso_schema_template_vrf: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_schema") }}' + template: "ansible_template1" + vrf: VRF2 + state: present + +- name: Add BD1 to ansible_template1 + cisco.mso.mso_schema_template_bd: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_schema") }}' + template: "ansible_template1" + bd: BD1 + vrf: + name: VRF1 + state: present + +- name: Add BD2 to ansible_template1 + cisco.mso.mso_schema_template_bd: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_schema") }}' + template: "ansible_template1" + bd: BD2 + vrf: + name: VRF2 + state: present + +- name: Add AP1 to ansible_template1 + cisco.mso.mso_schema_template_anp: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_schema") }}' + template: "ansible_template1" + anp: AP1 + state: present + +- name: Add EPG1 to AP1 in ansible_template1 + cisco.mso.mso_schema_template_anp_epg: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_schema") }}' + template: "ansible_template1" + anp: AP1 + epg: EPG1 + bd: + name: BD1 + vrf: + name: VRF1 + state: present + +- name: Bind Contract1 and 2 with EPG1 provider + cisco.mso.mso_schema_template_anp_epg_contract: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_schema") }}' + template: "ansible_template1" + anp: AP1 + epg: EPG1 + contract: + name: "{{ item }}" + type: provider + state: present + loop: + - Contract1 + - Contract2 + +- name: Bind Contract1 with EPG1 consumer + cisco.mso.mso_schema_template_anp_epg_contract: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_schema") }}' + template: "ansible_template1" + anp: AP1 + epg: EPG1 + contract: + name: "{{ item }}" + type: consumer + state: present + loop: + - Contract1 + - Contract2 + +- name: Bind Contract1 and 2 with template service graph - ansible_service_graph + cisco.mso.mso_schema_template_contract_service_graph: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_schema") }}' + template: "ansible_template1" + contract: "{{ item }}" + service_graph: ansible_service_graph + service_nodes: + - provider: BD1 + consumer: BD2 + - provider: BD1 + consumer: BD2 + - provider: BD1 + consumer: BD2 + state: present + loop: + - Contract1 + - Contract2 + +# Test part +# Azure tests part +- name: Execute tasks only for cloud sites + when: + - query_cloud.current | length > 0 + - query_cloud.current.0.cloudProvP.attributes.vendor == "azure" + block: + - name: Add Service Graph 1 at site level for the Azure site service graph test # Azure Task + cisco.mso.mso_schema_site_service_graph: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_schema") }}' + template: ansible_template1 + service_graph: ansible_service_graph + site: '{{ mso_site | default("ansible_test") }}' + tenant: '{{ mso_tenant | default("ansible_test") }}' + devices: + - name: '{{ mso_tenant | default("ansible_test") }}_firewall1' + provider_connector_type: source_nat + provider_interface: TP_FW_Inf1 + consumer_connector_type: redirect + consumer_interface: TP_FW_Inf1 + - name: '{{ mso_tenant | default("ansible_test") }}_app_lb' + - name: '{{ mso_tenant | default("ansible_test") }}_other' + provider_connector_type: destination_nat + consumer_connector_type: redirect + state: present + output_level: debug + register: az_sg1_cm_present + + - name: Bind the Contract1 with site service graph - ansible_service_graph - check_mode # Azure Task + cisco.mso.mso_schema_site_contract_service_graph: &az_add_site_con_sg_cm + <<: *mso_info + tenant: '{{ mso_tenant | default("ansible_test") }}' + schema: '{{ mso_schema | default("ansible_schema") }}' + template: ansible_template1 + site: '{{ mso_site | default("ansible_test") }}' + contract: Contract1 + service_graph_schema: '{{ mso_schema | default("ansible_schema") }}' + service_graph_template: ansible_template1 + service_graph: ansible_service_graph + state: present + output_level: debug + check_mode: true + register: az_add_site_con_sg_cm + + - name: Bind the Contract1 with site service graph - ansible_service_graph - normal_mode # Azure Task + cisco.mso.mso_schema_site_contract_service_graph: + <<: *az_add_site_con_sg_cm + register: az_add_site_con_sg_nm + + - name: Bind the Contract1 with site service graph - ansible_service_graph - normal_mode again # Azure Task + cisco.mso.mso_schema_site_contract_service_graph: + <<: *az_add_site_con_sg_cm + register: az_add_site_con_sg_nm_again + + - name: Assertions check for the bind site contract service graph + ansible.builtin.assert: + that: + - az_add_site_con_sg_cm is changed + - az_add_site_con_sg_cm.current != {} + - az_add_site_con_sg_cm.previous == {} + - az_add_site_con_sg_cm.current.serviceNodesRelationship.0.serviceNodeRef is match("/schemas/.+/templates/ansible_template1/serviceGraphs/ansible_service_graph/serviceNodes/node1") + - az_add_site_con_sg_cm.current.serviceNodesRelationship.1.serviceNodeRef is match("/schemas/.+/templates/ansible_template1/serviceGraphs/ansible_service_graph/serviceNodes/node2") + - az_add_site_con_sg_cm.current.serviceNodesRelationship.2.serviceNodeRef is match("/schemas/.+/templates/ansible_template1/serviceGraphs/ansible_service_graph/serviceNodes/node3") + - az_add_site_con_sg_cm.proposed.serviceNodesRelationship.0.serviceNodeRef is match("/schemas/.+/templates/ansible_template1/serviceGraphs/ansible_service_graph/serviceNodes/node1") + - az_add_site_con_sg_cm.proposed.serviceNodesRelationship.1.serviceNodeRef is match("/schemas/.+/templates/ansible_template1/serviceGraphs/ansible_service_graph/serviceNodes/node2") + - az_add_site_con_sg_cm.proposed.serviceNodesRelationship.2.serviceNodeRef is match("/schemas/.+/templates/ansible_template1/serviceGraphs/ansible_service_graph/serviceNodes/node3") + - az_add_site_con_sg_nm is changed + - az_add_site_con_sg_nm.current != {} + - az_add_site_con_sg_nm.previous == {} + - az_add_site_con_sg_nm.current.serviceGraphRef.serviceGraphName == "ansible_service_graph" + - az_add_site_con_sg_nm.current.serviceGraphRef.templateName == "ansible_template1" + - az_add_site_con_sg_nm.current.serviceNodesRelationship.0.serviceNodeRef is match("/schemas/.+/templates/ansible_template1/serviceGraphs/ansible_service_graph/serviceNodes/node1") + - az_add_site_con_sg_nm.current.serviceNodesRelationship.1.serviceNodeRef is match("/schemas/.+/templates/ansible_template1/serviceGraphs/ansible_service_graph/serviceNodes/node2") + - az_add_site_con_sg_nm.current.serviceNodesRelationship.2.serviceNodeRef is match("/schemas/.+/templates/ansible_template1/serviceGraphs/ansible_service_graph/serviceNodes/node3") + - az_add_site_con_sg_nm.proposed.serviceNodesRelationship.0.serviceNodeRef is match("/schemas/.+/templates/ansible_template1/serviceGraphs/ansible_service_graph/serviceNodes/node1") + - az_add_site_con_sg_nm.proposed.serviceNodesRelationship.1.serviceNodeRef is match("/schemas/.+/templates/ansible_template1/serviceGraphs/ansible_service_graph/serviceNodes/node2") + - az_add_site_con_sg_nm.proposed.serviceNodesRelationship.2.serviceNodeRef is match("/schemas/.+/templates/ansible_template1/serviceGraphs/ansible_service_graph/serviceNodes/node3") + - az_add_site_con_sg_nm_again is not changed + - az_add_site_con_sg_nm_again.current != {} + - az_add_site_con_sg_nm_again.previous != {} + - az_add_site_con_sg_nm_again.current.serviceGraphRef.serviceGraphName == "ansible_service_graph" + - az_add_site_con_sg_nm_again.current.serviceGraphRef.templateName == "ansible_template1" + - az_add_site_con_sg_nm_again.previous.serviceNodesRelationship.0.serviceNodeRef is match("/schemas/.+/templates/ansible_template1/serviceGraphs/ansible_service_graph/serviceNodes/node1") + - az_add_site_con_sg_nm_again.previous.serviceNodesRelationship.1.serviceNodeRef is match("/schemas/.+/templates/ansible_template1/serviceGraphs/ansible_service_graph/serviceNodes/node2") + - az_add_site_con_sg_nm_again.previous.serviceNodesRelationship.2.serviceNodeRef is match("/schemas/.+/templates/ansible_template1/serviceGraphs/ansible_service_graph/serviceNodes/node3") + - az_add_site_con_sg_nm_again.previous.serviceNodesRelationship.0.serviceNodeRef is match("/schemas/.+/templates/ansible_template1/serviceGraphs/ansible_service_graph/serviceNodes/node1") + - az_add_site_con_sg_nm_again.previous.serviceNodesRelationship.1.serviceNodeRef is match("/schemas/.+/templates/ansible_template1/serviceGraphs/ansible_service_graph/serviceNodes/node2") + - az_add_site_con_sg_nm_again.previous.serviceNodesRelationship.2.serviceNodeRef is match("/schemas/.+/templates/ansible_template1/serviceGraphs/ansible_service_graph/serviceNodes/node3") + +# Non-Cloud sites part +- name: Execute tasks only for non-cloud sites + when: + - query_cloud.current | length == 0 + block: + - name: Bind the Contract1 with site service graph - ansible_service_graph - check_mode + cisco.mso.mso_schema_site_contract_service_graph: &add_site_con_sg_cm + <<: *mso_info + tenant: '{{ mso_tenant | default("ansible_test") }}' + schema: '{{ mso_schema | default("ansible_schema") }}' + template: ansible_template1 + site: '{{ mso_site | default("ansible_test") }}' + contract: Contract1 + service_graph_schema: '{{ mso_schema | default("ansible_schema") }}' + service_graph_template: ansible_template1 + service_graph: ansible_service_graph + node_relationship: + - cluster_interface_device: '{{ mso_tenant | default("ansible_test") }}_firewall1' + provider_connector_cluster_interface: clu_if1 + provider_connector_redirect_policy: redirect_policy1 + consumer_connector_cluster_interface: clu_if1 + consumer_connector_redirect_policy: redirect_policy1 + - cluster_interface_device: '{{ mso_tenant | default("ansible_test") }}_adc' + provider_connector_cluster_interface: clu_if3 + provider_connector_redirect_policy: redirect_policy1 + consumer_connector_cluster_interface: clu_if3 + consumer_connector_redirect_policy: redirect_policy1 + consumer_subnet_ips: ["1.1.1.1/24", "4.4.4.4/24"] + - cluster_interface_device: '{{ mso_tenant | default("ansible_test") }}_other' + provider_connector_cluster_interface: clu_if4 + provider_connector_redirect_policy: redirect_policy1 + consumer_connector_cluster_interface: clu_if4 + consumer_connector_redirect_policy: redirect_policy1 + state: present + output_level: debug + check_mode: true + register: add_sg_cm + + - name: Bind the Contract1 with site service graph - ansible_service_graph - normal_mode + cisco.mso.mso_schema_site_contract_service_graph: + <<: *add_site_con_sg_cm + contract: Contract1 + register: add_sg_nm + + - name: Bind the Contract2 with site service graph - ansible_service_graph - normal_mode + cisco.mso.mso_schema_site_contract_service_graph: + <<: *add_site_con_sg_cm + contract: Contract2 + register: add_sg_nm_c2 + + - name: Bind the Contract1 with site service graph - ansible_service_graph - normal_mode - again + cisco.mso.mso_schema_site_contract_service_graph: + <<: *add_site_con_sg_cm + contract: Contract1 + register: add_sg_nm_again + + - name: Assertions check for the bind site contract service graph + ansible.builtin.assert: + that: + - add_sg_cm is changed + - add_sg_cm.current != {} + - add_sg_cm.previous == {} + - add_sg_cm.current.serviceNodesRelationship.0.serviceNodeRef.serviceGraphName == "ansible_service_graph" + - add_sg_cm.current.serviceNodesRelationship.0.serviceNodeRef.serviceNodeName == "node1" + - add_sg_cm.current.serviceNodesRelationship.0.serviceNodeRef.templateName == "ansible_template1" + - add_sg_cm.current.serviceGraphRef.serviceGraphName == "ansible_service_graph" + - add_sg_cm.current.serviceGraphRef.templateName == "ansible_template1" + - add_sg_cm.current.serviceNodesRelationship.1.consumerConnector.subnets | length == 2 + - add_sg_cm.current.serviceNodesRelationship.1.consumerConnector.subnets.0.ip == "1.1.1.1/24" + - add_sg_cm.current.serviceNodesRelationship.1.consumerConnector.subnets.1.ip == "4.4.4.4/24" + - add_sg_cm.current.serviceNodesRelationship.2.consumerConnector.clusterInterface.dn == "uni/tn-{{ mso_tenant | default("ansible_test") }}/lDevVip-{{ mso_tenant | default("ansible_test") }}_other/lIf-clu_if4" + - add_sg_cm.current.serviceNodesRelationship.2.consumerConnector.redirectPolicy.dn == "uni/tn-{{ mso_tenant | default("ansible_test") }}/svcCont/svcRedirectPol-redirect_policy1" + - add_sg_cm.current.serviceNodesRelationship.2.providerConnector.clusterInterface.dn == "uni/tn-{{ mso_tenant | default("ansible_test") }}/lDevVip-{{ mso_tenant | default("ansible_test") }}_other/lIf-clu_if4" + - add_sg_cm.current.serviceNodesRelationship.2.providerConnector.redirectPolicy.dn == "uni/tn-{{ mso_tenant | default("ansible_test") }}/svcCont/svcRedirectPol-redirect_policy1" + - add_sg_cm.proposed.serviceNodesRelationship.0.serviceNodeRef.serviceGraphName == "ansible_service_graph" + - add_sg_cm.proposed.serviceNodesRelationship.0.serviceNodeRef.serviceNodeName == "node1" + - add_sg_cm.proposed.serviceNodesRelationship.0.serviceNodeRef.templateName == "ansible_template1" + - add_sg_cm.proposed.serviceGraphRef.serviceGraphName == "ansible_service_graph" + - add_sg_cm.proposed.serviceGraphRef.templateName == "ansible_template1" + - add_sg_cm.proposed.serviceNodesRelationship.1.consumerConnector.subnets | length == 2 + - add_sg_cm.proposed.serviceNodesRelationship.1.consumerConnector.subnets.0.ip == "1.1.1.1/24" + - add_sg_cm.proposed.serviceNodesRelationship.1.consumerConnector.subnets.1.ip == "4.4.4.4/24" + - add_sg_cm.proposed.serviceNodesRelationship.2.consumerConnector.clusterInterface.dn == "uni/tn-{{ mso_tenant | default("ansible_test") }}/lDevVip-{{ mso_tenant | default("ansible_test") }}_other/lIf-clu_if4" + - add_sg_cm.proposed.serviceNodesRelationship.2.consumerConnector.redirectPolicy.dn == "uni/tn-{{ mso_tenant | default("ansible_test") }}/svcCont/svcRedirectPol-redirect_policy1" + - add_sg_cm.proposed.serviceNodesRelationship.2.providerConnector.clusterInterface.dn == "uni/tn-{{ mso_tenant | default("ansible_test") }}/lDevVip-{{ mso_tenant | default("ansible_test") }}_other/lIf-clu_if4" + - add_sg_cm.proposed.serviceNodesRelationship.2.providerConnector.redirectPolicy.dn == "uni/tn-{{ mso_tenant | default("ansible_test") }}/svcCont/svcRedirectPol-redirect_policy1" + - add_sg_nm is changed + - add_sg_nm.current != {} + - add_sg_nm.current.serviceGraphRef.serviceGraphName == "ansible_service_graph" + - add_sg_nm.current.serviceGraphRef.templateName == "ansible_template1" + - add_sg_nm.current.serviceNodesRelationship.1.consumerConnector.subnets | length == 2 + - add_sg_nm.current.serviceNodesRelationship.1.consumerConnector.subnets.0.ip == "1.1.1.1/24" + - add_sg_nm.current.serviceNodesRelationship.1.consumerConnector.subnets.1.ip == "4.4.4.4/24" + - add_sg_nm.current.serviceNodesRelationship.2.consumerConnector.clusterInterface.dn == "uni/tn-{{ mso_tenant | default("ansible_test") }}/lDevVip-{{ mso_tenant | default("ansible_test") }}_other/lIf-clu_if4" + - add_sg_nm.current.serviceNodesRelationship.2.consumerConnector.redirectPolicy.dn == "uni/tn-{{ mso_tenant | default("ansible_test") }}/svcCont/svcRedirectPol-redirect_policy1" + - add_sg_nm.current.serviceNodesRelationship.2.providerConnector.clusterInterface.dn == "uni/tn-{{ mso_tenant | default("ansible_test") }}/lDevVip-{{ mso_tenant | default("ansible_test") }}_other/lIf-clu_if4" + - add_sg_nm.current.serviceNodesRelationship.2.providerConnector.redirectPolicy.dn == "uni/tn-{{ mso_tenant | default("ansible_test") }}/svcCont/svcRedirectPol-redirect_policy1" + - add_sg_nm.previous == {} + - add_sg_nm_again is not changed + - add_sg_nm_again.current != {} + - add_sg_nm_again.previous != {} + - add_sg_nm_again.previous.serviceNodesRelationship.1.consumerConnector.subnets | length == 2 + - add_sg_nm_again.previous.serviceNodesRelationship.1.consumerConnector.subnets.0.ip == "1.1.1.1/24" + - add_sg_nm_again.previous.serviceNodesRelationship.1.consumerConnector.subnets.1.ip == "4.4.4.4/24" + - add_sg_nm_again.current.serviceGraphRef.serviceGraphName == "ansible_service_graph" + - add_sg_nm_again.current.serviceGraphRef.templateName == "ansible_template1" + - add_sg_nm_again.current.serviceNodesRelationship.1.consumerConnector.subnets | length == 2 + + - name: Update the Contract1 - site service graph - ansible_service_graph - node properties - check_mode + cisco.mso.mso_schema_site_contract_service_graph: &update_site_con_sg_cm + <<: *mso_info + tenant: '{{ mso_tenant | default("ansible_test") }}' + schema: '{{ mso_schema | default("ansible_schema") }}' + template: ansible_template1 + site: '{{ mso_site | default("ansible_test") }}' + contract: Contract1 + service_graph_schema: '{{ mso_schema | default("ansible_schema") }}' + service_graph_template: ansible_template1 + service_graph: ansible_service_graph + node_relationship: + - cluster_interface_device: '{{ mso_tenant | default("ansible_test") }}_firewall1' + provider_connector_cluster_interface: clu_if1 + provider_connector_redirect_policy: redirect_policy1 + consumer_connector_cluster_interface: clu_if1 + consumer_connector_redirect_policy: redirect_policy1 + - cluster_interface_device: '{{ mso_tenant | default("ansible_test") }}_adc' + provider_connector_cluster_interface: clu_if3 + provider_connector_redirect_policy: redirect_policy1 + consumer_connector_cluster_interface: clu_if3 + consumer_connector_redirect_policy: redirect_policy1 + consumer_subnet_ips: ["1.1.1.1/24", "4.4.4.3/24"] + - cluster_interface_device: '{{ mso_tenant | default("ansible_test") }}_other' + provider_connector_cluster_interface: clu_if4 + provider_connector_redirect_policy_tenant: common + provider_connector_redirect_policy: redirect_policy2 + consumer_connector_cluster_interface: clu_if4 + consumer_connector_redirect_policy_tenant: common + consumer_connector_redirect_policy: redirect_policy2 + state: present + output_level: debug + check_mode: true + register: update_sg_cm + + - name: Update the Contract1 - site service graph - ansible_service_graph - node properties - normal_mode + cisco.mso.mso_schema_site_contract_service_graph: + <<: *update_site_con_sg_cm + register: update_sg_nm + + - name: Update the Contract1 - site service graph - ansible_service_graph - node properties - normal_mode again + cisco.mso.mso_schema_site_contract_service_graph: + <<: *update_site_con_sg_cm + register: update_sg_nm_again + + - name: Assertions check for the update site contract service graph + ansible.builtin.assert: + that: + - update_sg_cm is changed + - update_sg_cm.current != {} + - update_sg_cm.previous != {} + - update_sg_cm.current.serviceGraphRef.serviceGraphName == "ansible_service_graph" + - update_sg_cm.current.serviceGraphRef.templateName == "ansible_template1" + - update_sg_cm.current.serviceNodesRelationship.1.consumerConnector.subnets | length == 2 + - update_sg_cm.current.serviceNodesRelationship.1.consumerConnector.subnets.0.ip == "1.1.1.1/24" + - update_sg_cm.current.serviceNodesRelationship.1.consumerConnector.subnets.1.ip == "4.4.4.3/24" + - update_sg_cm.previous.serviceNodesRelationship.1.consumerConnector.subnets | length == 2 + - update_sg_cm.previous.serviceNodesRelationship.1.consumerConnector.subnets.0.ip == "1.1.1.1/24" + - update_sg_cm.previous.serviceNodesRelationship.1.consumerConnector.subnets.1.ip == "4.4.4.4/24" + - update_sg_cm.proposed.serviceNodesRelationship.1.consumerConnector.subnets | length == 2 + - update_sg_cm.proposed.serviceNodesRelationship.1.consumerConnector.subnets.0.ip == "1.1.1.1/24" + - update_sg_cm.proposed.serviceNodesRelationship.1.consumerConnector.subnets.1.ip == "4.4.4.3/24" + - update_sg_cm.current.serviceNodesRelationship.2.consumerConnector.clusterInterface.dn == "uni/tn-{{ mso_tenant | default("ansible_test") }}/lDevVip-{{ mso_tenant | default("ansible_test") }}_other/lIf-clu_if4" + - update_sg_cm.current.serviceNodesRelationship.2.consumerConnector.redirectPolicy.dn == "uni/tn-common/svcCont/svcRedirectPol-redirect_policy2" + - update_sg_cm.current.serviceNodesRelationship.2.providerConnector.clusterInterface.dn == "uni/tn-{{ mso_tenant | default("ansible_test") }}/lDevVip-{{ mso_tenant | default("ansible_test") }}_other/lIf-clu_if4" + - update_sg_cm.current.serviceNodesRelationship.2.providerConnector.redirectPolicy.dn == "uni/tn-common/svcCont/svcRedirectPol-redirect_policy2" + - update_sg_cm.proposed.serviceNodesRelationship.2.consumerConnector.clusterInterface.dn == "uni/tn-{{ mso_tenant | default("ansible_test") }}/lDevVip-{{ mso_tenant | default("ansible_test") }}_other/lIf-clu_if4" + - update_sg_cm.proposed.serviceNodesRelationship.2.consumerConnector.redirectPolicy.dn == "uni/tn-common/svcCont/svcRedirectPol-redirect_policy2" + - update_sg_cm.proposed.serviceNodesRelationship.2.providerConnector.clusterInterface.dn == "uni/tn-{{ mso_tenant | default("ansible_test") }}/lDevVip-{{ mso_tenant | default("ansible_test") }}_other/lIf-clu_if4" + - update_sg_cm.proposed.serviceNodesRelationship.2.providerConnector.redirectPolicy.dn == "uni/tn-common/svcCont/svcRedirectPol-redirect_policy2" + - update_sg_cm.previous.serviceNodesRelationship.2.consumerConnector.clusterInterface.dn == "uni/tn-{{ mso_tenant | default("ansible_test") }}/lDevVip-{{ mso_tenant | default("ansible_test") }}_other/lIf-clu_if4" + - update_sg_cm.previous.serviceNodesRelationship.2.consumerConnector.redirectPolicy.dn == "uni/tn-{{ mso_tenant | default("ansible_test") }}/svcCont/svcRedirectPol-redirect_policy1" + - update_sg_cm.previous.serviceNodesRelationship.2.providerConnector.clusterInterface.dn == "uni/tn-{{ mso_tenant | default("ansible_test") }}/lDevVip-{{ mso_tenant | default("ansible_test") }}_other/lIf-clu_if4" + - update_sg_cm.previous.serviceNodesRelationship.2.providerConnector.redirectPolicy.dn == "uni/tn-{{ mso_tenant | default("ansible_test") }}/svcCont/svcRedirectPol-redirect_policy1" + - update_sg_nm is changed + - update_sg_nm.current != {} + - update_sg_nm.current.serviceGraphRef.serviceGraphName == "ansible_service_graph" + - update_sg_nm.current.serviceGraphRef.templateName == "ansible_template1" + - update_sg_nm.current.serviceNodesRelationship.0.consumerConnector.clusterInterface.dn == "uni/tn-{{ mso_tenant | default("ansible_test") }}/lDevVip-{{ mso_tenant | default("ansible_test") }}_firewall1/lIf-clu_if1" + - update_sg_nm.current.serviceNodesRelationship.0.consumerConnector.redirectPolicy.dn == "uni/tn-{{ mso_tenant | default("ansible_test") }}/svcCont/svcRedirectPol-redirect_policy1" + - update_sg_nm.current.serviceNodesRelationship.0.consumerConnector.subnets | length == 0 + - update_sg_nm.current.serviceNodesRelationship.1.consumerConnector.subnets | length == 2 + - update_sg_nm.current.serviceNodesRelationship.1.consumerConnector.subnets.0.ip == "1.1.1.1/24" + - update_sg_nm.current.serviceNodesRelationship.1.consumerConnector.subnets.1.ip == "4.4.4.3/24" + - update_sg_nm.previous.serviceNodesRelationship.1.consumerConnector.subnets | length == 2 + - update_sg_nm.previous.serviceNodesRelationship.1.consumerConnector.subnets.0.ip == "1.1.1.1/24" + - update_sg_nm.previous.serviceNodesRelationship.1.consumerConnector.subnets.1.ip == "4.4.4.4/24" + - update_sg_nm.current.serviceNodesRelationship.2.consumerConnector.clusterInterface.dn == "uni/tn-{{ mso_tenant | default("ansible_test") }}/lDevVip-{{ mso_tenant | default("ansible_test") }}_other/lIf-clu_if4" + - update_sg_nm.current.serviceNodesRelationship.2.consumerConnector.redirectPolicy.dn == "uni/tn-common/svcCont/svcRedirectPol-redirect_policy2" + - update_sg_nm.current.serviceNodesRelationship.2.providerConnector.clusterInterface.dn == "uni/tn-{{ mso_tenant | default("ansible_test") }}/lDevVip-{{ mso_tenant | default("ansible_test") }}_other/lIf-clu_if4" + - update_sg_nm.current.serviceNodesRelationship.2.providerConnector.redirectPolicy.dn == "uni/tn-common/svcCont/svcRedirectPol-redirect_policy2" + - update_sg_nm.previous.serviceNodesRelationship.2.consumerConnector.clusterInterface.dn == "uni/tn-{{ mso_tenant | default("ansible_test") }}/lDevVip-{{ mso_tenant | default("ansible_test") }}_other/lIf-clu_if4" + - update_sg_nm.previous.serviceNodesRelationship.2.consumerConnector.redirectPolicy.dn == "uni/tn-{{ mso_tenant | default("ansible_test") }}/svcCont/svcRedirectPol-redirect_policy1" + - update_sg_nm.previous.serviceNodesRelationship.2.providerConnector.clusterInterface.dn == "uni/tn-{{ mso_tenant | default("ansible_test") }}/lDevVip-{{ mso_tenant | default("ansible_test") }}_other/lIf-clu_if4" + - update_sg_nm.previous.serviceNodesRelationship.2.providerConnector.redirectPolicy.dn == "uni/tn-{{ mso_tenant | default("ansible_test") }}/svcCont/svcRedirectPol-redirect_policy1" + - update_sg_nm_again is not changed + - update_sg_nm_again.current != {} + - update_sg_nm_again.current.serviceGraphRef.serviceGraphName == "ansible_service_graph" + - update_sg_nm_again.current.serviceGraphRef.templateName == "ansible_template1" + + - name: Negative test - Add site contract service graph with invalid service_graph + cisco.mso.mso_schema_site_contract_service_graph: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_schema") }}' + template: ansible_template1 + site: '{{ mso_site | default("ansible_test") }}' + contract: Contract1 + tenant: '{{ mso_tenant | default("ansible_test") }}' + service_graph_template: ansible_template1 + service_graph: ansible_service_graph_invalid + node_relationship: + - cluster_interface_device: '{{ mso_tenant | default("ansible_test") }}_firewall1' + provider_connector_cluster_interface: clu_if1 + provider_connector_redirect_policy: redirect_policy1 + consumer_connector_cluster_interface: clu_if1 + consumer_connector_redirect_policy: redirect_policy1 + - cluster_interface_device: '{{ mso_tenant | default("ansible_test") }}_adc' + provider_connector_cluster_interface: clu_if3 + provider_connector_redirect_policy: redirect_policy1 + consumer_connector_cluster_interface: clu_if3 + consumer_connector_redirect_policy: redirect_policy1 + consumer_subnet_ips: ["1.1.1.1/24", "4.4.4.4/24"] + - cluster_interface_device: '{{ mso_tenant | default("ansible_test") }}_other' + provider_connector_cluster_interface: clu_if3 + provider_connector_redirect_policy_tenant: common + provider_connector_redirect_policy: redirect_policy2 + consumer_connector_cluster_interface: clu_if3 + consumer_connector_redirect_policy_tenant: common + consumer_connector_redirect_policy: redirect_policy2 + state: present + ignore_errors: true + register: nt_add_sg_with_invalid_sg + + - name: Negative test - use invalid service graph schema to check the failure + cisco.mso.mso_schema_site_contract_service_graph: + <<: *mso_info + tenant: '{{ mso_tenant | default("ansible_test") }}' + schema: '{{ mso_schema | default("ansible_schema") }}' + template: ansible_template1 + site: '{{ mso_site | default("ansible_test") }}' + contract: Contract1 + service_graph_schema: '{{ mso_schema | default("ansible_schema") }}_temp' + service_graph_template: ansible_template1 + service_graph: ansible_service_graph + node_relationship: + - cluster_interface_device: '{{ mso_tenant | default("ansible_test") }}_firewall1' + provider_connector_cluster_interface: clu_if1 + provider_connector_redirect_policy: redirect_policy1 + consumer_connector_cluster_interface: clu_if1 + consumer_connector_redirect_policy: redirect_policy1 + - cluster_interface_device: '{{ mso_tenant | default("ansible_test") }}_adc' + provider_connector_cluster_interface: clu_if3 + provider_connector_redirect_policy: redirect_policy1 + consumer_connector_cluster_interface: clu_if3 + consumer_connector_redirect_policy: redirect_policy1 + consumer_subnet_ips: ["1.1.1.1/24", "4.4.4.4/24"] + - cluster_interface_device: '{{ mso_tenant | default("ansible_test") }}_other' + provider_connector_cluster_interface: clu_if3 + provider_connector_redirect_policy_tenant: common + provider_connector_redirect_policy: redirect_policy2 + consumer_connector_cluster_interface: clu_if3 + consumer_connector_redirect_policy_tenant: common + consumer_connector_redirect_policy: redirect_policy2 + state: present + ignore_errors: true + register: nt_with_invalid_sg_schema + + - name: Negative test - Add site contract service graph without node_relationship and tenant + cisco.mso.mso_schema_site_contract_service_graph: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_schema") }}' + template: ansible_template1 + site: '{{ mso_site | default("ansible_test") }}' + contract: Contract1 + service_graph: ansible_service_graph + state: present + ignore_errors: true + register: nt_add_sg_without_node_relationship_and_tenant + + - name: Negative test - Add site contract service graph without node_relationship + cisco.mso.mso_schema_site_contract_service_graph: + <<: *mso_info + tenant: '{{ mso_tenant | default("ansible_test") }}' + schema: '{{ mso_schema | default("ansible_schema") }}' + template: ansible_template1 + site: '{{ mso_site | default("ansible_test") }}' + contract: Contract1 + service_graph: ansible_service_graph + state: present + ignore_errors: true + register: nt_add_sg_without_node_relationship + + - name: Negative test - Add site contract service graph without tenant + cisco.mso.mso_schema_site_contract_service_graph: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_schema") }}' + template: ansible_template1 + site: '{{ mso_site | default("ansible_test") }}' + contract: Contract1 + service_graph_template: ansible_template1 + service_graph: ansible_service_graph + node_relationship: + - cluster_interface_device: '{{ mso_tenant | default("ansible_test") }}_firewall1' + provider_connector_cluster_interface: clu_if1 + provider_connector_redirect_policy: redirect_policy1 + consumer_connector_cluster_interface: clu_if1 + consumer_connector_redirect_policy: redirect_policy1 + - cluster_interface_device: '{{ mso_tenant | default("ansible_test") }}_adc' + provider_connector_cluster_interface: clu_if3 + provider_connector_redirect_policy: redirect_policy1 + consumer_connector_cluster_interface: clu_if3 + consumer_connector_redirect_policy: redirect_policy1 + consumer_subnet_ips: ["1.1.1.1/24", "4.4.4.4/24"] + - cluster_interface_device: '{{ mso_tenant | default("ansible_test") }}_other' + provider_connector_cluster_interface: clu_if3 + provider_connector_redirect_policy_tenant: common + provider_connector_redirect_policy: redirect_policy2 + consumer_connector_cluster_interface: clu_if3 + consumer_connector_redirect_policy_tenant: common + consumer_connector_redirect_policy: redirect_policy2 + state: present + ignore_errors: true + register: nt_add_sg_without_tenant + + - name: Negative test - Add site contract service graph without tenant + cisco.mso.mso_schema_site_contract_service_graph: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_schema") }}' + template: ansible_template1 + site: '{{ mso_site | default("ansible_test") }}' + contract: Contract1 + service_graph_template: ansible_template1 + service_graph: ansible_service_graph_invalid + node_relationship: + - cluster_interface_device: '{{ mso_tenant | default("ansible_test") }}_firewall1' + provider_connector_cluster_interface: clu_if1 + provider_connector_redirect_policy: redirect_policy1 + consumer_connector_cluster_interface: clu_if1 + consumer_connector_redirect_policy: redirect_policy1 + - cluster_interface_device: '{{ mso_tenant | default("ansible_test") }}_adc' + provider_connector_cluster_interface: clu_if3 + provider_connector_redirect_policy: redirect_policy1 + consumer_connector_cluster_interface: clu_if3 + consumer_connector_redirect_policy: redirect_policy1 + consumer_subnet_ips: ["1.1.1.1/24", "4.4.4.4/24"] + - cluster_interface_device: '{{ mso_tenant | default("ansible_test") }}_other' + provider_connector_cluster_interface: clu_if3 + provider_connector_redirect_policy_tenant: common + provider_connector_redirect_policy: redirect_policy2 + consumer_connector_cluster_interface: clu_if3 + consumer_connector_redirect_policy_tenant: common + consumer_connector_redirect_policy: redirect_policy2 + state: present + ignore_errors: true + register: nt_add_sg_without_tenant + + - name: Assertions check for the negative site contract tests + ansible.builtin.assert: + that: + - nt_with_invalid_sg_schema is not changed + - nt_with_invalid_sg_schema.current == {} + - nt_with_invalid_sg_schema.msg == "Provided service_graph_schema{{':'}} 'ansible_schema_temp' does not exist." + - nt_add_sg_without_node_relationship_and_tenant is not changed + - nt_add_sg_without_node_relationship_and_tenant.current == {} + - nt_add_sg_without_node_relationship_and_tenant.msg == "The node_relationship and tenant attributes are required when state is present and site type is on-premise." + - nt_add_sg_without_node_relationship is not changed + - nt_add_sg_without_node_relationship.current == {} + - nt_add_sg_without_node_relationship.msg == "The node_relationship attribute is required when state is present and site type is on-premise." + - nt_add_sg_without_tenant is not changed + - nt_add_sg_without_tenant.current == {} + - nt_add_sg_without_tenant.msg == "The tenant attribute is required when state is present and site type is on-premise." + - nt_add_sg_with_invalid_sg is not changed + - nt_add_sg_with_invalid_sg.msg == "The service graph{{':'}} ansible_service_graph_invalid does not associated with the site contract{{':'}} Contract1." + + - name: Query a empty site contract without passing the service graph name + cisco.mso.mso_schema_site_contract_service_graph: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_schema") }}' + template: ansible_template1 + site: '{{ mso_site | default("ansible_test") }}' + contract: Contract3 + state: query + register: query_empty_contract_without_sg_name + + - name: Query a invalid site contract without passing the service graph value + cisco.mso.mso_schema_site_contract_service_graph: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_schema") }}' + template: ansible_template1 + site: '{{ mso_site | default("ansible_test") }}' + contract: Contract4 + state: query + ignore_errors: true + register: query_invalid_contract_sg + + - name: Query all site contract service graphs with an empty template + cisco.mso.mso_schema_site_contract_service_graph: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_schema") }}' + template: ansible_template2 + site: '{{ mso_site | default("ansible_test") }}' + service_graph: ansible_service_graph + state: query + register: query_all_sg_with_empty_template + + - name: Query a site contract - Contract1 service graph without passing service graph name + cisco.mso.mso_schema_site_contract_service_graph: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_schema") }}' + template: ansible_template1 + contract: Contract1 + site: '{{ mso_site | default("ansible_test") }}' + state: query + register: query_sg_without_name + + - name: Query all site contract service graphs without passing the service_graph and contract name + cisco.mso.mso_schema_site_contract_service_graph: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_schema") }}' + template: ansible_template1 + site: '{{ mso_site | default("ansible_test") }}' + state: query + register: query_all_sg_without_contract_sg + + - name: Assertions check for the query results + ansible.builtin.assert: + that: + - query_empty_contract_without_sg_name is not changed + - query_empty_contract_without_sg_name.current == {} + - query_invalid_contract_sg is not changed + - query_invalid_contract_sg.current == {} + - query_invalid_contract_sg.msg == "The site contract{{':'}} Contract4 does not exist." + - query_all_sg_with_empty_template is not changed + - query_all_sg_with_empty_template.current == {} + - query_sg_without_name is not changed + - query_sg_without_name.current != {} + - query_sg_without_name.current.serviceGraphRef is match(".+/templates/ansible_template1/serviceGraphs/ansible_service_graph") + - query_sg_without_name.current.serviceNodesRelationship | length == 3 + - query_sg_without_name.current.serviceNodesRelationship.0.consumerConnector.clusterInterface.dn == "uni/tn-{{ mso_tenant | default("ansible_test") }}/lDevVip-{{ mso_tenant | default("ansible_test") }}_firewall1/lIf-clu_if1" + - query_sg_without_name.current.serviceNodesRelationship.0.consumerConnector.redirectPolicy.dn == "uni/tn-{{ mso_tenant | default("ansible_test") }}/svcCont/svcRedirectPol-redirect_policy1" + - query_sg_without_name.current.serviceNodesRelationship.0.consumerConnector.subnets | length == 0 + - query_sg_without_name.current.serviceNodesRelationship.0.providerConnector.subnets | length == 0 + - query_sg_without_name.current.serviceNodesRelationship.0.serviceNodeRef is match(".+/templates/ansible_template1/serviceGraphs/ansible_service_graph/serviceNodes/node1") + - query_all_sg_without_contract_sg is not changed + - query_all_sg_without_contract_sg.current | length == 2 + - query_all_sg_without_contract_sg.current.0.serviceGraphRef is match(".+/templates/ansible_template1/serviceGraphs/ansible_service_graph") + - query_all_sg_without_contract_sg.current.1.serviceGraphRef is match(".+/templates/ansible_template1/serviceGraphs/ansible_service_graph") + - query_all_sg_without_contract_sg.current.0.serviceNodesRelationship.1.consumerConnector.subnets | length == 2 + - query_all_sg_without_contract_sg.current.0.serviceNodesRelationship.1.providerConnector.subnets | length == 0 + - query_all_sg_without_contract_sg.current.0.serviceNodesRelationship.2.consumerConnector.redirectPolicy.dn == "uni/tn-common/svcCont/svcRedirectPol-redirect_policy2" + - query_all_sg_without_contract_sg.current.0.serviceNodesRelationship.2.consumerConnector.clusterInterface.dn == "uni/tn-{{ mso_tenant | default("ansible_test") }}/lDevVip-{{ mso_tenant | default("ansible_test") }}_other/lIf-clu_if4" + - query_all_sg_without_contract_sg.current.0.serviceNodesRelationship.2.providerConnector.redirectPolicy.dn == "uni/tn-common/svcCont/svcRedirectPol-redirect_policy2" + - query_all_sg_without_contract_sg.current.0.serviceNodesRelationship.2.providerConnector.clusterInterface.dn == "uni/tn-{{ mso_tenant | default("ansible_test") }}/lDevVip-{{ mso_tenant | default("ansible_test") }}_other/lIf-clu_if4" + + - name: Remove the site contract Contract1 - service graph from the ansible_template1 - check_mode + cisco.mso.mso_schema_site_contract_service_graph: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_schema") }}' + template: ansible_template1 + site: '{{ mso_site | default("ansible_test") }}' + contract: Contract1 + state: absent + output_level: debug + check_mode: true + register: site_con_sg_absent_cm + + - name: Remove the site contract Contract1 - service graph from the ansible_template1 - normal_mode + cisco.mso.mso_schema_site_contract_service_graph: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_schema") }}' + template: ansible_template1 + site: '{{ mso_site | default("ansible_test") }}' + contract: Contract1 + state: absent + register: site_con_sg_absent_nm + + - name: Remove the site contract Contract1 - service graph from the ansible_template1 - normal_mode again + cisco.mso.mso_schema_site_contract_service_graph: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_schema") }}' + template: ansible_template1 + site: '{{ mso_site | default("ansible_test") }}' + contract: Contract1 + state: absent + ignore_errors: true + register: site_con_sg_absent_nm_again + + - name: Assertions check for remove the site contract Contract1 - service graph from the ansible_template1 + ansible.builtin.assert: + that: + - site_con_sg_absent_cm is changed + - site_con_sg_absent_cm.current == {} + - site_con_sg_absent_cm.previous != {} + - site_con_sg_absent_cm.previous.serviceGraphRef is match("/schemas/.+/templates/ansible_template1/serviceGraphs/ansible_service_graph") + - site_con_sg_absent_cm.previous.serviceNodesRelationship | length == 3 + - site_con_sg_absent_cm.previous.serviceNodesRelationship.1.consumerConnector.subnets | length == 2 + - site_con_sg_absent_cm.previous.serviceNodesRelationship.2.serviceNodeRef is match("/schemas/.+/templates/ansible_template1/serviceGraphs/ansible_service_graph/serviceNodes/node3") + - site_con_sg_absent_cm.proposed == {} + - site_con_sg_absent_cm.sent == {} + - site_con_sg_absent_nm is changed + - site_con_sg_absent_nm.current == {} + - site_con_sg_absent_nm.previous != {} + - site_con_sg_absent_nm.previous.serviceGraphRef is match("/schemas/.+/templates/ansible_template1/serviceGraphs/ansible_service_graph") + - site_con_sg_absent_nm.previous.serviceNodesRelationship | length == 3 + - site_con_sg_absent_nm.previous.serviceNodesRelationship.1.consumerConnector.subnets | length == 2 + - site_con_sg_absent_nm.previous.serviceNodesRelationship.2.serviceNodeRef is match("/schemas/.+/templates/ansible_template1/serviceGraphs/ansible_service_graph/serviceNodes/node3") + - site_con_sg_absent_nm_again is not changed + - site_con_sg_absent_nm_again.current == {} + - site_con_sg_absent_nm_again.previous == {} + - site_con_sg_absent_nm_again.msg is match("MSO Error 400{{':'}} error in remove for path{{':'}} '/sites/0/contracts/0/serviceGraphRelationship'{{':'}} unable to remove nonexistent key{{':'}} serviceGraphRelationship{{':'}} missing value") + +# Cleanup part + +- name: Remove the site association for the ansible_schema templates + cisco.mso.mso_schema_site: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_schema") }}' + template: "{{ item }}" + site: '{{ mso_site | default("ansible_test") }}' + state: present + loop: + - "ansible_template1" + - "ansible_template2" + +- name: Remove the ansible_schema schema + cisco.mso.mso_schema: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_schema") }}' + state: absent + +- name: Remove the {{ mso_tenant | default("ansible_test") }} tenant + cisco.mso.mso_tenant: + <<: *mso_info + tenant: '{{ mso_tenant | default("ansible_test") }}' + state: absent + +- name: Set ansible_network_os to cisco.aci.aci and ansible_connection to local + ansible.builtin.set_fact: + ansible_connection: local + ansible_network_os: cisco.aci.aci + +- name: Reset the ansible_connection to access the APIC + ansible.builtin.meta: reset_connection + +- name: Remove the common tenant redirect policy + cisco.aci.aci_rest: + host: "{{ apic_hostname }}" + username: "{{ apic_username }}" + password: "{{ apic_password }}" + validate_certs: no + path: "/api/node/mo/uni/tn-common/svcCont.json" + method: post + content: + vnsSvcRedirectPol: + attributes: + name: redirect_policy2 + status: deleted + +- name: Remove the {{ mso_tenant | default("ansible_test") }} from the APIC + cisco.aci.aci_tenant: + <<: *aci_info + tenant: '{{ mso_tenant | default("ansible_test") }}' + state: absent diff --git a/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_contract_service_graph_listener/aliases b/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_contract_service_graph_listener/aliases new file mode 100644 index 000000000..5042c9c09 --- /dev/null +++ b/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_contract_service_graph_listener/aliases @@ -0,0 +1,2 @@ +# No ACI MultiSite infrastructure, so not enabled +# unsupported diff --git a/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_contract_service_graph_listener/tasks/l4_l7_devices.yml b/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_contract_service_graph_listener/tasks/l4_l7_devices.yml new file mode 100644 index 000000000..5c325ba44 --- /dev/null +++ b/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_contract_service_graph_listener/tasks/l4_l7_devices.yml @@ -0,0 +1,222 @@ +# Test code for the MSO modules +# Copyright: (c) 2024, Sabari Jaganathan (@sajagana) <sajagana@cisco.com> + +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +- name: Test that we have an ACI MultiSite host, username and password + ansible.builtin.fail: + msg: "Please define the following variables: mso_hostname, mso_username and mso_password." + when: mso_hostname is not defined or mso_username is not defined or mso_password is not defined + +# CLEAN ENVIRONMENT +- name: Set vars + ansible.builtin.set_fact: + aci_info: &aci_info + host: "{{ apic_hostname }}" + username: "{{ apic_username }}" + password: "{{ apic_password }}" + validate_certs: "{{ apic_validate_certs | default(false) }}" + use_ssl: "{{ apic_use_ssl | default(true) }}" + use_proxy: "{{ apic_use_proxy | default(true) }}" + output_level: '{{ mso_output_level | default("info") }}' + +- name: Query system information + cisco.aci.aci_system: + <<: *aci_info + id: 1 + state: query + register: aci_version + +- name: Remove an existing tenant on APIC + cisco.aci.aci_tenant: + <<: *aci_info + name: '{{ mso_tenant | default("ansible_test") }}' + state: absent + +- name: Add a tenant on APIC + cisco.aci.aci_tenant: + <<: *aci_info + name: '{{ mso_tenant | default("ansible_test") }}' + +# Site type checking for L4-L7 Device configuration +# QUERY OBJECTS +- name: Query cloud provider object + cisco.aci.aci_cloud_provider: + <<: *aci_info + state: query + register: query_cloud + when: aci_version.current.0.topSystem.attributes.version is version('4.1', '>=') + +- name: Set vars + ansible.builtin.set_fact: + query_cloud: + current: [] + when: aci_version.current.0.topSystem.attributes.version is version('4.1', '<') + +- name: Verify query_cloud for all sites + ansible.builtin.assert: + that: + - query_cloud is not changed + +- name: Verify query_cloud for Cloud Sites + ansible.builtin.assert: + that: + - query_cloud is not changed + - query_cloud.current.0.cloudProvP.attributes.environment == "public-cloud" + - '"vendor" in query_cloud.current.0.cloudProvP.attributes' + when: + - query_cloud.current | length > 0 # This condition will execute only cloud sites + +# Cloud Site block +- name: Execute tasks only for cloud sites + when: + - query_cloud.current | length > 0 + - query_cloud.current.0.cloudProvP.attributes.vendor == "azure" + block: + - name: Add azure_vrf to the {{ mso_tenant | default("ansible_test") }} + cisco.aci.aci_vrf: + <<: *aci_info + tenant: '{{ mso_tenant | default("ansible_test") }}' + vrf: azure_vrf + + - name: Add azure_ctxprof to the {{ mso_tenant | default("ansible_test") }} + cisco.aci.aci_cloud_ctx_profile: + <<: *aci_info + tenant: '{{ mso_tenant | default("ansible_test") }}' + cloud: azure + name: azure_ctxprof + vrf: azure_vrf + region: westus2 + primary_cidr: "1.1.1.2/32" + state: present + + - name: Add the subnet to the azure_ctxprof + cisco.aci.aci_rest: + <<: *aci_info + path: api/mo/uni/tn-{{ mso_tenant | default("ansible_test") }}/ctxprofile-azure_ctxprof/cidr-[1.1.1.2/32]/subnet-[1.1.1.2/32].json + method: post + content: + cloudSubnet: + attributes: + ip: 1.1.1.2/32 + name: azure_ctxprof_cidr + children: + - cloudRsZoneAttach: + attributes: + tDn: "uni/clouddomp/provp-azure/region-westus2/zone-default" + + - name: Add the {{ mso_tenant | default("ansible_test") }}_tplb device - ThirdParty_LB + cisco.aci.aci_rest: + <<: *aci_info + path: /api/node/mo/uni/tn-{{ mso_tenant | default("ansible_test") }}/cld-{{ mso_tenant | default("ansible_test") }}_tplb.json + method: post + content: + cloudLDev: + attributes: + targetMode: unspecified + name: '{{ mso_tenant | default("ansible_test") }}_tplb' + svcType: ADC + children: + - cloudRsLDevToCtx: + attributes: + tDn: uni/tn-{{ mso_tenant | default("ansible_test") }}/ctx-azure_vrf + - cloudLIf: + attributes: + allowAll: "yes" + name: TP_LB_Inf + children: + - cloudEPSelector: + attributes: + name: TP_LB_Inf_Selector + matchExpression: IP=='1.1.1.1' + + - name: Add the {{ mso_tenant | default("ansible_test") }}_firewall1 device + cisco.aci.aci_rest: + <<: *aci_info + path: /api/node/mo/uni/tn-{{ mso_tenant | default("ansible_test") }}/cld-{{ mso_tenant | default("ansible_test") }}_firewall1.json + method: post + content: + cloudLDev: + attributes: + name: '{{ mso_tenant | default("ansible_test") }}_firewall1' + svcType: FW + children: + - cloudRsLDevToCtx: + attributes: + tDn: uni/tn-{{ mso_tenant | default("ansible_test") }}/ctx-azure_vrf + - cloudLIf: + attributes: + allowAll: "yes" + name: TP_FW_Inf1 + children: + - cloudEPSelector: + attributes: + name: TP_FW_Inf_Selector + matchExpression: IP=='1.1.1.1' + + - name: Add the {{ mso_tenant | default("ansible_test") }}_nlb device + cisco.aci.aci_rest: + <<: *aci_info + path: /api/node/mo/uni/tn-{{ mso_tenant | default("ansible_test") }}/clb-{{ mso_tenant | default("ansible_test") }}_nlb.json + method: post + content: + cloudLB: + attributes: + name: '{{ mso_tenant | default("ansible_test") }}_nlb' + type: network + children: + - cloudRsLDevToCloudSubnet: + attributes: + tDn: 'uni/tn-{{ mso_tenant | default("ansible_test") }}/ctxprofile-azure_ctxprof/cidr-[1.1.1.2/32]/subnet-[1.1.1.2/32]' + - cloudVip: + attributes: + name: 10.10.10.10 + + - name: Add the {{ mso_tenant | default("ansible_test") }}_aplb device + cisco.aci.aci_rest: + <<: *aci_info + path: /api/node/mo/uni/tn-{{ mso_tenant | default("ansible_test") }}/clb-{{ mso_tenant | default("ansible_test") }}_aplb.json + method: post + content: + cloudLB: + attributes: + name: '{{ mso_tenant | default("ansible_test") }}_aplb' + type: application + children: + - cloudRsLDevToCloudSubnet: + attributes: + tDn: 'uni/tn-{{ mso_tenant | default("ansible_test") }}/ctxprofile-azure_ctxprof/cidr-[1.1.1.2/32]/subnet-[1.1.1.2/32]' + + - name: Add certificate store to the {{ mso_tenant | default("ansible_test") }} tenant + cisco.aci.aci_rest: + <<: *aci_info + path: /api/node/mo/uni/tn-{{ mso_tenant | default("ansible_test") }}/certstore.json + method: post + content: + cloudCertStore: + attributes: + name: default + + - name: Add certificate authority to the {{ mso_tenant | default("ansible_test") }} tenant + cisco.aci.aci_rest: + <<: *aci_info + path: /api/node/mo/uni/tn-{{ mso_tenant | default("ansible_test") }}/certstore/tp-{{ mso_tenant | default("ansible_test") }}_ca.json + method: post + content: + pkiTP: + attributes: + certChain: '{{ lookup("file", "pki/admin.crt") }}' + name: '{{ mso_tenant | default("ansible_test") }}_ca' + + - name: Add key ring to the {{ mso_tenant | default("ansible_test") }} tenant + cisco.aci.aci_rest: + <<: *aci_info + path: /api/node/mo/uni/tn-{{ mso_tenant | default("ansible_test") }}/certstore/keyring-{{ mso_tenant | default("ansible_test") }}_keyring.json + method: post + content: + pkiKeyRing: + attributes: + name: '{{ mso_tenant | default("ansible_test") }}_keyring' + tp: '{{ mso_tenant | default("ansible_test") }}_ca' + modulus: mod2048 + adminState: started diff --git a/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_contract_service_graph_listener/tasks/main.yml b/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_contract_service_graph_listener/tasks/main.yml new file mode 100644 index 000000000..7552c563d --- /dev/null +++ b/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_contract_service_graph_listener/tasks/main.yml @@ -0,0 +1,1604 @@ +# Test code for the MSO modules +# Copyright: (c) 2024, Sabari Jaganathan (@sajagana) <sajagana@cisco.com> + +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +- name: Test that we have an ACI MultiSite host, username and password + ansible.builtin.fail: + msg: "Please define the following variables: mso_hostname, mso_username and mso_password." + when: mso_hostname is not defined or mso_username is not defined or mso_password is not defined + +# CLEAN ENVIRONMENT +- name: Set vars + ansible.builtin.set_fact: + mso_info: &mso_info + host: "{{ mso_hostname }}" + username: "{{ mso_username }}" + password: "{{ mso_password }}" + validate_certs: "{{ mso_validate_certs | default(false) }}" + use_ssl: "{{ mso_use_ssl | default(true) }}" + use_proxy: "{{ mso_use_proxy | default(false) }}" + output_level: '{{ mso_output_level | default("info") }}' + aci_info: &aci_info + host: "{{ apic_hostname }}" + username: "{{ apic_username }}" + password: "{{ apic_password }}" + validate_certs: "{{ apic_validate_certs | default(false) }}" + use_ssl: "{{ apic_use_ssl | default(true) }}" + use_proxy: "{{ apic_use_proxy | default(true) }}" + output_level: '{{ mso_output_level | default("info") }}' + +# Setup part begins +- name: Set ansible_network_os to cisco.aci.aci and ansible_connection to local + ansible.builtin.set_fact: + ansible_connection: local + ansible_network_os: cisco.aci.aci + +- name: Reset the ansible_connection to access the APIC + ansible.builtin.meta: reset_connection + +- name: Include tasks for L4-L7 devices + ansible.builtin.include_tasks: l4_l7_devices.yml + +- name: Set ansible_network_os to cisco.nd.nd and ansible_connection to ansible.netcommon.httpapi + ansible.builtin.set_fact: + ansible_connection: ansible.netcommon.httpapi + ansible_network_os: cisco.nd.nd + +- name: Reset the ansible_connection to access the MSO/NDO + ansible.builtin.meta: reset_connection + +- name: Remove ansible_schema to start the test - setup part + cisco.mso.mso_schema: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_schema") }}' + state: absent + +- name: Remove {{ mso_tenant | default("ansible_test") }} tenant to start the test - setup part + cisco.mso.mso_tenant: + <<: *mso_info + tenant: '{{ mso_tenant | default("ansible_test") }}' + state: absent + +- name: Add {{ mso_tenant | default("ansible_test") }} tenant + cisco.mso.mso_tenant: + <<: *mso_info + tenant: '{{ mso_tenant | default("ansible_test") }}' + users: ["{{ mso_username }}"] + state: present + +- name: Associate Azure site with '{{ mso_tenant | default("ansible_test") }}' + cisco.mso.mso_tenant_site: + <<: *mso_info + tenant: '{{ mso_tenant | default("ansible_test") }}' + site: azure_ansible_test_2 + cloud_account: "uni/tn-{{ mso_tenant | default('ansible_test') }}/act-[{{ azure_cloud_account | default(123) }}]-vendor-azure" + state: present + when: + - query_cloud.current | length > 0 + - query_cloud.current.0.cloudProvP.attributes.vendor == "azure" + +- name: Ensure ansible_schema with ansible_template1 and ansible_template2 exist + cisco.mso.mso_schema_template: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_schema") }}' + tenant: '{{ mso_tenant | default("ansible_test") }}' + template: "{{ item }}" + state: present + loop: + - "ansible_template1" + - "ansible_template2" + +- name: Create ansible_service_graph schema template service graph + cisco.mso.mso_schema_template_service_graph: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_schema") }}' + template: "ansible_template1" + service_graph: "ansible_service_graph" + display_name: "ansible_service_graph" + service_nodes: + - type: firewall + - type: load-balancer + filter_after_first_node: allow_all + state: present + +- name: Create ansible_service_graph2 schema template service graph + cisco.mso.mso_schema_template_service_graph: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_schema") }}' + template: "ansible_template1" + service_graph: "ansible_service_graph2" + display_name: "ansible_service_graph2" + service_nodes: + - type: load-balancer + - type: load-balancer + filter_after_first_node: allow_all + state: present + +- name: Bind ansible_test site with ansible_template1 and ansible_template2 + cisco.mso.mso_schema_site: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_schema") }}' + template: "{{ item }}" + site: '{{ mso_site | default("ansible_test") }}' + state: present + loop: + - "ansible_template1" + +- name: Add Filter1 to ansible_template1 + cisco.mso.mso_schema_template_filter_entry: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_schema") }}' + template: "ansible_template1" + filter: Filter1 + entry: Filter1Entry + state: present + +- name: Add Contracts to the ansible_template1 + cisco.mso.mso_schema_template_contract_filter: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_schema") }}' + template: "ansible_template1" + contract: "{{ item }}" + filter: Filter1 + state: present + loop: + - Contract1 + - Contract2 + - Contract3 + +- name: Add a VRF1 to ansible_template1 + cisco.mso.mso_schema_template_vrf: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_schema") }}' + template: "ansible_template1" + vrf: VRF1 + state: present + +- name: Add BD1 to ansible_template1 + cisco.mso.mso_schema_template_bd: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_schema") }}' + template: "ansible_template1" + bd: BD1 + vrf: + name: VRF1 + state: present + +- name: Add AP1 to ansible_template1 + cisco.mso.mso_schema_template_anp: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_schema") }}' + template: "ansible_template1" + anp: AP1 + state: present + +- name: Add EPG1 to AP1 in ansible_template1 + cisco.mso.mso_schema_template_anp_epg: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_schema") }}' + template: "ansible_template1" + anp: AP1 + epg: EPG1 + bd: + name: BD1 + vrf: + name: VRF1 + state: present + +- name: Bind Contract1 and 2 with EPG1 provider + cisco.mso.mso_schema_template_anp_epg_contract: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_schema") }}' + template: "ansible_template1" + anp: AP1 + epg: EPG1 + contract: + name: "{{ item }}" + type: provider + state: present + loop: + - Contract1 + - Contract2 + +- name: Bind Contract1 with EPG1 consumer + cisco.mso.mso_schema_template_anp_epg_contract: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_schema") }}' + template: "ansible_template1" + anp: AP1 + epg: EPG1 + contract: + name: "{{ item }}" + type: consumer + state: present + loop: + - Contract1 + - Contract2 + - Contract3 + +- name: Bind Contract1 with template service graph - ansible_service_graph + cisco.mso.mso_schema_template_contract_service_graph: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_schema") }}' + template: "ansible_template1" + contract: Contract1 + service_graph: ansible_service_graph + service_nodes: + - provider: BD1 + consumer: BD1 + - provider: BD1 + consumer: BD1 + state: present + +- name: Bind Contract2 with template service graph - ansible_service_graph2 + cisco.mso.mso_schema_template_contract_service_graph: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_schema") }}' + template: "ansible_template1" + contract: Contract2 + service_graph: ansible_service_graph2 + service_nodes: + - provider: BD1 + consumer: BD1 + - provider: BD1 + consumer: BD1 + state: present + +- name: Add site VRF region CIDR to the VRF1 + cisco.mso.mso_schema_site_vrf_region_cidr: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_schema") }}' + template: ansible_template1 + site: '{{ mso_site | default("ansible_test") }}' + vrf: VRF1 + region: westus2 + cidr: 14.14.14.1/24 + state: present + +- name: Execute tasks only for cloud sites + when: + - query_cloud.current | length > 0 + - query_cloud.current.0.cloudProvP.attributes.vendor == "azure" + block: + - name: Add Service Graph 1 at site level for the Azure site service graph test + cisco.mso.mso_schema_site_service_graph: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_schema") }}' + template: ansible_template1 + service_graph: ansible_service_graph + site: '{{ mso_site | default("ansible_test") }}' + tenant: '{{ mso_tenant | default("ansible_test") }}' + devices: + - name: '{{ mso_tenant | default("ansible_test") }}_firewall1' # Third-Party Firewall - Listener not supported + - name: '{{ mso_tenant | default("ansible_test") }}_tplb' # Third-Party Load Balancer - Listener not supported + state: present + register: az_sg1_cm_present + + - name: Add Service Graph 2 at site level for the Azure site service graph test + cisco.mso.mso_schema_site_service_graph: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_schema") }}' + template: ansible_template1 + service_graph: ansible_service_graph2 + site: '{{ mso_site | default("ansible_test") }}' + tenant: '{{ mso_tenant | default("ansible_test") }}' + devices: + - name: '{{ mso_tenant | default("ansible_test") }}_nlb' # Network Load Balancer - Listener supported + - name: '{{ mso_tenant | default("ansible_test") }}_aplb' # Application Load Balancer - Listener supported + state: present + register: az_sg1_cm_present + + - name: Bind the Contract1 with site service graph - ansible_service_graph + cisco.mso.mso_schema_site_contract_service_graph: + <<: *mso_info + tenant: '{{ mso_tenant | default("ansible_test") }}' + schema: '{{ mso_schema | default("ansible_schema") }}' + template: ansible_template1 + site: '{{ mso_site | default("ansible_test") }}' + contract: Contract1 + service_graph_schema: '{{ mso_schema | default("ansible_schema") }}' + service_graph_template: ansible_template1 + service_graph: ansible_service_graph + state: present + register: az_add_site_con_sg_cm + + - name: Bind the Contract2 with site service graph - ansible_service_graph2 + cisco.mso.mso_schema_site_contract_service_graph: + <<: *mso_info + tenant: '{{ mso_tenant | default("ansible_test") }}' + schema: '{{ mso_schema | default("ansible_schema") }}' + template: ansible_template1 + site: '{{ mso_site | default("ansible_test") }}' + contract: Contract2 + service_graph_schema: '{{ mso_schema | default("ansible_schema") }}' + service_graph_template: ansible_template1 + service_graph: ansible_service_graph2 + state: present + register: az_add_site_con_sg_cm + +# Test part +- name: Negative test - add listener - nlb_li_tcp without device when the parent is not present + cisco.mso.mso_schema_site_contract_service_graph_listener: + <<: *mso_info + contract: "Contract2" + schema: '{{ mso_schema | default("ansible_test") }}' + template: ansible_template1 + site: '{{ mso_site | default("ansible_test") }}' + service_node_index: 0 + listener: nlb_li_tcp + listener_port: 80 + listener_protocol: tcp + tenant: '{{ mso_tenant | default("ansible_test") }}' + frontend_ip: "10.10.10.10" + security_policy: default + rules: + - name: rule1 + priority: 1 + action_type: forward + port: 80 + protocol: tcp + health_check: + port: 80 + protocol: tcp + interval: 5 + unhealthy_threshold: 2 + success_code: 200-399 + ignore_errors: true + register: nt_add_listener_without_device + +- name: Add listener - nlb_li_tcp - check_mode + cisco.mso.mso_schema_site_contract_service_graph_listener: + <<: *mso_info + contract: "Contract2" + schema: '{{ mso_schema | default("ansible_test") }}' + template: ansible_template1 + site: '{{ mso_site | default("ansible_test") }}' + service_node_index: 0 + listener: nlb_li_tcp + listener_port: 80 + listener_protocol: tcp + tenant: '{{ mso_tenant | default("ansible_test") }}' + frontend_ip: "10.10.10.10" + device: '{{ mso_tenant | default("ansible_test") }}_nlb' + security_policy: default + rules: + - name: rule1 + priority: 1 + action_type: forward + port: 80 + protocol: tcp + health_check: + port: 80 + protocol: tcp + interval: 5 + unhealthy_threshold: 2 + success_code: 200-399 + output_level: debug + check_mode: true + register: add_nlb_li_tcp_cm + +- name: Add listener - nlb_li_tcp - normal_mode + cisco.mso.mso_schema_site_contract_service_graph_listener: + <<: *mso_info + contract: "Contract2" + schema: '{{ mso_schema | default("ansible_test") }}' + template: ansible_template1 + site: '{{ mso_site | default("ansible_test") }}' + service_node_index: 0 + listener: nlb_li_tcp + listener_port: 80 + listener_protocol: tcp + tenant: '{{ mso_tenant | default("ansible_test") }}' + frontend_ip: "10.10.10.10" + device: '{{ mso_tenant | default("ansible_test") }}_nlb' + security_policy: default + rules: + - name: rule1 + priority: 1 + action_type: forward + port: 80 + protocol: tcp + health_check: + port: 80 + protocol: tcp + interval: 5 + unhealthy_threshold: 2 + success_code: 200-399 + register: add_nlb_li_tcp_nm + +- name: Add listener - nlb_li_tcp normal_mode again + cisco.mso.mso_schema_site_contract_service_graph_listener: + <<: *mso_info + contract: "Contract2" + schema: '{{ mso_schema | default("ansible_test") }}' + template: ansible_template1 + site: '{{ mso_site | default("ansible_test") }}' + service_node_index: 0 + listener: nlb_li_tcp + listener_port: 80 + listener_protocol: tcp + tenant: '{{ mso_tenant | default("ansible_test") }}' + frontend_ip: "10.10.10.10" + device: '{{ mso_tenant | default("ansible_test") }}_nlb' + security_policy: default + rules: + - name: rule1 + priority: 1 + action_type: forward + port: 80 + protocol: tcp + health_check: + port: 80 + protocol: tcp + interval: 5 + unhealthy_threshold: 2 + success_code: 200-399 + register: add_nlb_li_tcp_nm_again + +- name: Add listener - nlb_li_udp without device when the parent is present + cisco.mso.mso_schema_site_contract_service_graph_listener: + <<: *mso_info + contract: "Contract2" + schema: '{{ mso_schema | default("ansible_test") }}' + template: ansible_template1 + site: '{{ mso_site | default("ansible_test") }}' + service_node_index: 0 + listener: nlb_li_udp + listener_port: 80 + listener_protocol: udp + tenant: '{{ mso_tenant | default("ansible_test") }}' + frontend_ip: "10.10.10.10" + security_policy: default + rules: + - name: rule2 + priority: 2 + action_type: forward + port: 80 + protocol: tcp + health_check: + port: 80 + protocol: tcp + interval: 5 + unhealthy_threshold: 2 + success_code: 200-399 + ignore_errors: true + register: add_nlb_li_udp + +- name: Add listener - ans_li_common - udp + cisco.mso.mso_schema_site_contract_service_graph_listener: + <<: *mso_info + contract: "Contract2" + schema: '{{ mso_schema | default("ansible_test") }}' + template: ansible_template1 + site: '{{ mso_site | default("ansible_test") }}' + service_node_index: 0 + listener: ans_li_common + listener_port: 80 + listener_protocol: udp + tenant: '{{ mso_tenant | default("ansible_test") }}' + frontend_ip: "10.10.10.10" + device: '{{ mso_tenant | default("ansible_test") }}_nlb' + security_policy: default + rules: + - name: common3 + priority: 3 + action_type: forward + port: 80 + protocol: tcp + health_check: + port: 80 + protocol: http + path: health_check_path + interval: 5 + unhealthy_threshold: 2 + success_code: 200-399 + register: add_ans_li_common_udp + +- name: Add listener - aplb_li_https + cisco.mso.mso_schema_site_contract_service_graph_listener: + <<: *mso_info + contract: "Contract2" + schema: '{{ mso_schema | default("ansible_test") }}' + template: ansible_template1 + site: '{{ mso_site | default("ansible_test") }}' + service_node_index: 1 + listener: aplb_li_https + tenant: '{{ mso_tenant | default("ansible_test") }}' + device: '{{ mso_tenant | default("ansible_test") }}_aplb' + listener_port: 443 + listener_protocol: https + security_policy: default + ssl_certificates: + - name: '{{ mso_tenant | default("ansible_test") }}_keyring' + certificate_store: default + rules: + - name: rule1 + priority: 1 + action_type: forward + port: 80 + protocol: http + provider_epg_ref: + anp_name: AP1 + epg_name: EPG1 + health_check: + port: 80 + protocol: http + path: "health_check_path" + interval: 30 + timeout: 30 + unhealthy_threshold: 3 + use_host_from_rule: true # "yes" - host should be empty in the rule + success_code: "200" + target_ip_type: unspecified + register: add_aplb_li_https + +- name: Add listener - aplb_li_http + cisco.mso.mso_schema_site_contract_service_graph_listener: + <<: *mso_info + contract: "Contract2" + schema: '{{ mso_schema | default("ansible_test") }}' + template: ansible_template1 + site: '{{ mso_site | default("ansible_test") }}' + service_node_index: 1 + tenant: '{{ mso_tenant | default("ansible_test") }}' + device: '{{ mso_tenant | default("ansible_test") }}_aplb' + listener: aplb_li_http + listener_port: 80 + listener_protocol: http + security_policy: default + rules: + - name: rule2 + priority: 2 + action_type: forward + port: 443 + protocol: https + provider_epg_ref: + anp_name: AP1 + epg_name: EPG1 + health_check: + port: 443 + protocol: https + path: "/" + interval: 30 + timeout: 30 + unhealthy_threshold: 3 + host: use_host_from_rule + use_host_from_rule: false # "no"(unchecked) - host should be specified in the rule + success_code: "200" + target_ip_type: unspecified + register: add_aplb_li_http + +- name: Add listener - ans_li_common - http + cisco.mso.mso_schema_site_contract_service_graph_listener: + <<: *mso_info + contract: "Contract2" + schema: '{{ mso_schema | default("ansible_test") }}' + template: ansible_template1 + site: '{{ mso_site | default("ansible_test") }}' + service_node_index: 1 + tenant: '{{ mso_tenant | default("ansible_test") }}' + device: '{{ mso_tenant | default("ansible_test") }}_aplb' + listener: ans_li_common + listener_port: 80 + listener_protocol: http + security_policy: default + rules: + - name: rule3 + priority: 3 + action_type: forward + port: 443 + protocol: https + provider_epg_ref: + anp_name: AP1 + epg_name: EPG1 + health_check: + port: 443 + protocol: https + path: "/" + interval: 30 + timeout: 30 + unhealthy_threshold: 3 + host: use_host_from_rule + use_host_from_rule: false + success_code: "200" + target_ip_type: unspecified + register: add_ans_li_common_http + +- name: Assertions check for the add listeners test + ansible.builtin.assert: + that: + - nt_add_listener_without_device is not changed + - nt_add_listener_without_device.current == {} + - nt_add_listener_without_device.msg == "The 'device' name is required to initialize the parent object." + - add_nlb_li_tcp_cm is changed + - add_nlb_li_tcp_cm.current != {} + - add_nlb_li_tcp_cm.current.deviceConfiguration.cloudLoadBalancer.listeners.0.name == "nlb_li_tcp" + - add_nlb_li_tcp_cm.current.deviceConfiguration.cloudLoadBalancer.listeners.0.nlbDevIp.name == "10.10.10.10" + - add_nlb_li_tcp_cm.current.deviceConfiguration.cloudLoadBalancer.listeners.0.nlbDevIp.dn == "uni/tn-{{ mso_tenant | default("ansible_test") }}/clb-{{ mso_tenant | default("ansible_test") }}_nlb/vip-10.10.10.10" + - add_nlb_li_tcp_cm.current.deviceConfiguration.cloudLoadBalancer.listeners.0.protocol == "tcp" + - add_nlb_li_tcp_cm.current.deviceConfiguration.cloudLoadBalancer.listeners.0.rules.0.index == 1 + - add_nlb_li_tcp_cm.current.deviceConfiguration.cloudLoadBalancer.listeners.0.rules.0.name == "rule1" + - add_nlb_li_tcp_cm.proposed != {} + - add_nlb_li_tcp_cm.proposed.deviceConfiguration.cloudLoadBalancer.listeners.0.name == "nlb_li_tcp" + - add_nlb_li_tcp_cm.proposed.deviceConfiguration.cloudLoadBalancer.listeners.0.nlbDevIp.name == "10.10.10.10" + - add_nlb_li_tcp_cm.proposed.deviceConfiguration.cloudLoadBalancer.listeners.0.nlbDevIp.dn == "uni/tn-{{ mso_tenant | default("ansible_test") }}/clb-{{ mso_tenant | default("ansible_test") }}_nlb/vip-10.10.10.10" + - add_nlb_li_tcp_cm.proposed.deviceConfiguration.cloudLoadBalancer.listeners.0.protocol == "tcp" + - add_nlb_li_tcp_cm.proposed.deviceConfiguration.cloudLoadBalancer.listeners.0.rules.0.index == 1 + - add_nlb_li_tcp_cm.proposed.deviceConfiguration.cloudLoadBalancer.listeners.0.rules.0.name == "rule1" + - add_nlb_li_tcp_nm is changed + - add_nlb_li_tcp_nm.current != {} + - add_nlb_li_tcp_nm.current.deviceConfiguration.cloudLoadBalancer.listeners.0.name == "nlb_li_tcp" + - add_nlb_li_tcp_nm.current.deviceConfiguration.cloudLoadBalancer.listeners.0.nlbDevIp.name == "10.10.10.10" + - add_nlb_li_tcp_nm.current.deviceConfiguration.cloudLoadBalancer.listeners.0.nlbDevIp.dn == "uni/tn-{{ mso_tenant | default("ansible_test") }}/clb-{{ mso_tenant | default("ansible_test") }}_nlb/vip-10.10.10.10" + - add_nlb_li_tcp_nm.current.deviceConfiguration.cloudLoadBalancer.listeners.0.protocol == "tcp" + - add_nlb_li_tcp_nm.current.deviceConfiguration.cloudLoadBalancer.listeners.0.rules.0.index == 1 + - add_nlb_li_tcp_nm.current.deviceConfiguration.cloudLoadBalancer.listeners.0.rules.0.name == "rule1" + - add_nlb_li_tcp_nm.previous == {} + - add_nlb_li_tcp_nm_again is not changed + - add_nlb_li_tcp_nm_again.current.name == "nlb_li_tcp" + - add_nlb_li_tcp_nm_again.current.nlbDevIp.name == "10.10.10.10" + - add_nlb_li_tcp_nm_again.current.nlbDevIp.dn == "uni/tn-{{ mso_tenant | default("ansible_test") }}/clb-{{ mso_tenant | default("ansible_test") }}_nlb/vip-10.10.10.10" + - add_nlb_li_tcp_nm_again.current.protocol == "tcp" + - add_nlb_li_tcp_nm_again.current.rules.0.index == 1 + - add_nlb_li_tcp_nm_again.current.rules.0.name == "rule1" + - add_nlb_li_udp is not changed + - add_nlb_li_udp.msg == "When the 'frontend_ip' is '10.10.10.10', the ['device'] attributes must be set and the object name{{':'}} nlb_li_udp" + - add_ans_li_common_udp is changed + - add_ans_li_common_udp.current.name == "ans_li_common" + - add_ans_li_common_udp.current.protocol == "udp" + - add_ans_li_common_udp.current.nlbDevIp.name == "10.10.10.10" + - add_ans_li_common_udp.current.nlbDevIp.dn == "uni/tn-{{ mso_tenant | default("ansible_test") }}/clb-{{ mso_tenant | default("ansible_test") }}_nlb/vip-10.10.10.10" + - add_aplb_li_https is changed + - add_aplb_li_https.current.deviceConfiguration.cloudLoadBalancer.listeners.0.name == "aplb_li_https" + - add_aplb_li_https.current.deviceConfiguration.cloudLoadBalancer.listeners.0.protocol == "https" + - add_aplb_li_https.current.deviceConfiguration.cloudLoadBalancer.listeners.0.port == 443 + - add_aplb_li_https.current.deviceConfiguration.cloudLoadBalancer.listeners.0.certificates.0.default == true + - add_aplb_li_https.current.deviceConfiguration.cloudLoadBalancer.listeners.0.certificates.0.name == "ans_li_tenant_keyring" + - add_aplb_li_https.current.deviceConfiguration.cloudLoadBalancer.listeners.0.certificates.0.store == "default" + - add_aplb_li_https.current.deviceConfiguration.cloudLoadBalancer.listeners.0.certificates.0.tDn == "uni/tn-{{ mso_tenant | default("ansible_test") }}/certstore" + - add_aplb_li_https.current.deviceConfiguration.cloudLoadBalancer.listeners.0.rules.0.index == 1 + - add_aplb_li_https.current.deviceConfiguration.cloudLoadBalancer.listeners.0.rules.0.name == "rule1" + - add_aplb_li_https.current.deviceConfiguration.cloudLoadBalancer.listeners.0.rules.0.protocol == "http" + - add_aplb_li_https.current.deviceConfiguration.cloudLoadBalancer.listeners.0.rules.0.actionType == "forward" + - add_aplb_li_https.current.deviceConfiguration.cloudLoadBalancer.listeners.0.rules.0.healthCheck.protocol == "http" + - add_aplb_li_https.current.deviceConfiguration.cloudLoadBalancer.listeners.0.rules.0.healthCheck.path == "health_check_path" + - add_aplb_li_https.current.deviceConfiguration.cloudLoadBalancer.listeners.0.rules.0.providerEpgRef is match("/schemas/.+/templates/ansible_template1/anps/AP1/epgs/EPG1") + - add_aplb_li_http is changed + - add_aplb_li_http.current.name == "aplb_li_http" + - add_aplb_li_http.current.protocol == "http" + - add_aplb_li_http.current.rules.0.healthCheck.host == "use_host_from_rule" + - add_aplb_li_http.current.rules.0.healthCheck.useHostFromRule == "no" + - add_aplb_li_http.current.rules.0.healthCheck.protocol == "https" + - add_ans_li_common_http is changed + - add_ans_li_common_http.current.name == "ans_li_common" + - add_ans_li_common_http.current.protocol == "http" + - add_ans_li_common_http.current.rules.0.healthCheck.protocol == "https" + - add_ans_li_common_http.current.rules.0.healthCheck.host == "use_host_from_rule" + - add_ans_li_common_http.current.rules.0.healthCheck.useHostFromRule == "no" + - add_ans_li_common_http.current.rules.0.actionType == "forward" + - add_ans_li_common_http.current.rules.0.protocol == "https" + - add_ans_li_common_http.current.rules.0.name == "rule3" + - add_ans_li_common_http.current.rules.0.providerEpgRef is match("/schemas/.+/templates/ansible_template1/anps/AP1/epgs/EPG1") + +- name: Update listener - ans_li_common rule health_check property - timeout value 30 to 60 + cisco.mso.mso_schema_site_contract_service_graph_listener: + <<: *mso_info + contract: "Contract2" + schema: '{{ mso_schema | default("ansible_test") }}' + template: ansible_template1 + site: '{{ mso_site | default("ansible_test") }}' + service_node_index: 1 + tenant: '{{ mso_tenant | default("ansible_test") }}' + device: '{{ mso_tenant | default("ansible_test") }}_aplb' + listener: ans_li_common + listener_port: 80 + listener_protocol: http + security_policy: default + rules: + - name: rule3 + priority: 3 + action_type: forward + port: 443 + protocol: https + provider_epg_ref: + anp_name: AP1 + epg_name: EPG1 + health_check: + port: 443 + protocol: https + path: "/" + interval: 30 + timeout: 60 + unhealthy_threshold: 3 + host: use_host_from_rule + use_host_from_rule: false + success_code: "200" + target_ip_type: unspecified + register: update_ans_li_common + +- name: Update listener - ans_li_common with invalid service_node_index 5 + cisco.mso.mso_schema_site_contract_service_graph_listener: + <<: *mso_info + contract: "Contract2" + schema: '{{ mso_schema | default("ansible_test") }}' + template: ansible_template1 + site: '{{ mso_site | default("ansible_test") }}' + service_node_index: 5 + tenant: '{{ mso_tenant | default("ansible_test") }}' + device: '{{ mso_tenant | default("ansible_test") }}_aplb' + listener: ans_li_common + listener_port: 80 + listener_protocol: http + security_policy: default + rules: + - name: rule3 + priority: 3 + action_type: forward + port: 443 + protocol: https + provider_epg_ref: + anp_name: AP1 + epg_name: EPG1 + health_check: + port: 443 + protocol: https + path: "/" + interval: 30 + timeout: 60 + unhealthy_threshold: 3 + host: use_host_from_rule + use_host_from_rule: false + success_code: "200" + target_ip_type: unspecified + ignore_errors: true + register: nt_update_ans_li_common + +- name: Assertions check for the update listeners test + ansible.builtin.assert: + that: + - update_ans_li_common is changed + - update_ans_li_common.current.name == "ans_li_common" + - update_ans_li_common.current.protocol == "http" + - update_ans_li_common.current.rules.0.actionType == "forward" + - update_ans_li_common.current.rules.0.providerEpgRef is match( "/schemas/.+/templates/ansible_template1/anps/AP1/epgs/EPG1") + - update_ans_li_common.current.rules.0.protocol == "https" + - update_ans_li_common.current.rules.0.healthCheck.protocol == "https" + - nt_update_ans_li_common is not changed + - nt_update_ans_li_common.msg == "The service_node_index{{':'}} 5 is out of range." + +- name: Query all listeners + cisco.mso.mso_schema_site_contract_service_graph_listener: + <<: *mso_info + contract: "Contract2" + schema: '{{ mso_schema | default("ansible_test") }}' + template: ansible_template1 + site: '{{ mso_site | default("ansible_test") }}' + state: query + register: query_all_listeners + +- name: Query all listeners with service_node_index 0 + cisco.mso.mso_schema_site_contract_service_graph_listener: + <<: *mso_info + contract: "Contract2" + schema: '{{ mso_schema | default("ansible_test") }}' + template: ansible_template1 + site: '{{ mso_site | default("ansible_test") }}' + service_node_index: 0 + state: query + register: node1_query_all_listeners + +- name: Query all listeners with name ans_li_common without service_node_index + cisco.mso.mso_schema_site_contract_service_graph_listener: + <<: *mso_info + contract: "Contract2" + schema: '{{ mso_schema | default("ansible_test") }}' + template: ansible_template1 + site: '{{ mso_site | default("ansible_test") }}' + listener: ans_li_common + state: query + register: query_all_ans_li_common + +- name: Query a listener with name ans_li_common and service_node_index 0 + cisco.mso.mso_schema_site_contract_service_graph_listener: + <<: *mso_info + contract: "Contract2" + schema: '{{ mso_schema | default("ansible_test") }}' + template: ansible_template1 + site: '{{ mso_site | default("ansible_test") }}' + listener: ans_li_common + service_node_index: 0 + state: query + register: query_a_ans_li_common + +- name: Query an invalid listener with name invalid_ans_li_common - under Contract2 + cisco.mso.mso_schema_site_contract_service_graph_listener: + <<: *mso_info + contract: "Contract2" + schema: '{{ mso_schema | default("ansible_test") }}' + template: ansible_template1 + site: '{{ mso_site | default("ansible_test") }}' + listener: invalid_ans_li_common + state: query + register: nt_query_c1_listeners + +- name: Query an invalid listener with name invalid_ans_li_common - under Contract2 with service_node_index 1 + cisco.mso.mso_schema_site_contract_service_graph_listener: + <<: *mso_info + contract: "Contract2" + schema: '{{ mso_schema | default("ansible_test") }}' + template: ansible_template1 + site: '{{ mso_site | default("ansible_test") }}' + listener: invalid_ans_li_common + service_node_index: 1 + state: query + register: nt_query_invalid_listener_node1 + +- name: Assertions check for the query listeners test + ansible.builtin.assert: + that: + - query_all_listeners is not changed + - query_all_listeners.current | length >= 5 + - node1_query_all_listeners is not changed + - node1_query_all_listeners.current | length == 2 + - query_all_ans_li_common is not changed + - query_all_ans_li_common.current | length == 2 + - query_all_ans_li_common.current.0.name == "ans_li_common" + - query_all_ans_li_common.current.1.name == "ans_li_common" + - query_a_ans_li_common is not changed + - query_a_ans_li_common.current != {} + - query_a_ans_li_common.current.name == "ans_li_common" + - nt_query_c1_listeners is not changed + - nt_query_c1_listeners.current == {} + - nt_query_invalid_listener_node1 is not changed + - nt_query_invalid_listener_node1.current == {} + +- name: Query all listeners under Contract1 - Negative test + cisco.mso.mso_schema_site_contract_service_graph_listener: + <<: *mso_info + contract: "Contract1" + schema: '{{ mso_schema | default("ansible_test") }}' + template: ansible_template1 + site: '{{ mso_site | default("ansible_test") }}' + listener: invalid_ans_li_common + state: query + register: nt_query_all_c1_listeners + +- name: Query all listeners under Contract1 with service_node_index 1 - Negative test + cisco.mso.mso_schema_site_contract_service_graph_listener: + <<: *mso_info + contract: "Contract1" + schema: '{{ mso_schema | default("ansible_test") }}' + template: ansible_template1 + site: '{{ mso_site | default("ansible_test") }}' + listener: invalid_ans_li_common + service_node_index: 1 + state: query + register: nt_query_c1_listeners + +- name: Assertions check for the query listeners negative test + ansible.builtin.assert: + that: + - nt_query_all_c1_listeners is not changed + - nt_query_all_c1_listeners.current == {} + - nt_query_c1_listeners is not changed + - nt_query_c1_listeners.current == {} + +- name: Negative test - query all listeners with the non-cloud site + cisco.mso.mso_schema_site_contract_service_graph_listener: + <<: *mso_info + contract: "Contract1" + schema: '{{ mso_schema | default("ansible_test") }}' + template: ansible_template1 + site: "ansible_test" + service_node_index: 0 + state: query + ignore_errors: true + register: nt_non_cloud_site + +- name: Negative test - add listener - nt_aplb_li_https - ssl cert missing + cisco.mso.mso_schema_site_contract_service_graph_listener: + <<: *mso_info + contract: "Contract2" + schema: '{{ mso_schema | default("ansible_test") }}' + template: ansible_template1 + site: '{{ mso_site | default("ansible_test") }}' + service_node_index: 1 + listener: nt_aplb_li_https + tenant: '{{ mso_tenant | default("ansible_test") }}' + device: '{{ mso_tenant | default("ansible_test") }}_aplb' + listener_port: 443 + listener_protocol: https + rules: + - name: rule1 + priority: 1 + action_type: forward + port: 80 + protocol: http + provider_epg_ref: + anp_name: AP1 + epg_name: EPG1 + health_check: + port: 80 + protocol: http + path: "health_check_path" + interval: 30 + timeout: 30 + unhealthy_threshold: 3 + use_host_from_rule: true + success_code: "200" + target_ip_type: unspecified + ignore_errors: true + register: nt_lp_https_ssl_cert_missing + +- name: Negative test - add listener - nt_aplb_li_https - Contract3 SG Ref missing + cisco.mso.mso_schema_site_contract_service_graph_listener: + <<: *mso_info + contract: "Contract3" + schema: '{{ mso_schema | default("ansible_test") }}' + template: ansible_template1 + site: '{{ mso_site | default("ansible_test") }}' + service_node_index: 1 + listener: nt_aplb_li_https + tenant: '{{ mso_tenant | default("ansible_test") }}' + device: '{{ mso_tenant | default("ansible_test") }}_aplb' + listener_port: 443 + listener_protocol: https + security_policy: default + ssl_certificates: + - name: '{{ mso_tenant | default("ansible_test") }}_keyring' + certificate_store: default + rules: + - name: rule1 + priority: 1 + action_type: forward + port: 80 + protocol: http + provider_epg_ref: + anp_name: AP1 + epg_name: EPG1 + health_check: + port: 80 + protocol: http + path: "health_check_path" + interval: 30 + timeout: 30 + unhealthy_threshold: 3 + use_host_from_rule: true + success_code: "200" + target_ip_type: unspecified + ignore_errors: true + register: nt_invalid_contract3 + +- name: Negative test - add listener - nt_aplb_li_https - with invalid device + cisco.mso.mso_schema_site_contract_service_graph_listener: + <<: *mso_info + contract: "Contract3" + schema: '{{ mso_schema | default("ansible_test") }}' + template: ansible_template1 + site: '{{ mso_site | default("ansible_test") }}' + service_node_index: 1 + listener: nt_aplb_li_https + tenant: '{{ mso_tenant | default("ansible_test") }}' + device: '{{ mso_tenant | default("ansible_test") }}_aplb_invalid' + listener_port: 443 + listener_protocol: https + security_policy: default + ssl_certificates: + - name: '{{ mso_tenant | default("ansible_test") }}_keyring' + certificate_store: default + rules: + - name: rule1 + priority: 1 + action_type: forward + port: 80 + protocol: http + provider_epg_ref: + anp_name: AP1 + epg_name: EPG1 + health_check: + port: 80 + protocol: http + path: "health_check_path" + interval: 30 + timeout: 30 + unhealthy_threshold: 3 + use_host_from_rule: true + success_code: "200" + target_ip_type: unspecified + ignore_errors: true + register: nt_invalid_device + +- name: Negative test - add listener - nt_fw_li_https to the Third-Party Firewall + cisco.mso.mso_schema_site_contract_service_graph_listener: + <<: *mso_info + contract: "Contract1" + schema: '{{ mso_schema | default("ansible_test") }}' + template: ansible_template1 + site: '{{ mso_site | default("ansible_test") }}' + service_node_index: 0 + listener: nt_fw_li_https + tenant: '{{ mso_tenant | default("ansible_test") }}' + device: '{{ mso_tenant | default("ansible_test") }}_firewall1' + listener_port: 443 + listener_protocol: https + security_policy: default + ssl_certificates: + - name: '{{ mso_tenant | default("ansible_test") }}_keyring' + certificate_store: default + rules: + - name: rule1 + priority: 1 + action_type: forward + port: 80 + protocol: http + provider_epg_ref: + anp_name: AP1 + epg_name: EPG1 + health_check: + port: 80 + protocol: http + path: "health_check_path" + interval: 30 + timeout: 30 + unhealthy_threshold: 3 + use_host_from_rule: true + success_code: "200" + target_ip_type: unspecified + ignore_errors: true + register: nt_tp_fw_listener + +- name: Negative test - add listener - nt_tplb_li_https to the Third-Party load-balancer + cisco.mso.mso_schema_site_contract_service_graph_listener: + <<: *mso_info + contract: "Contract1" + schema: '{{ mso_schema | default("ansible_test") }}' + template: ansible_template1 + site: '{{ mso_site | default("ansible_test") }}' + service_node_index: 1 + listener: nt_tplb_li_https + tenant: '{{ mso_tenant | default("ansible_test") }}' + device: '{{ mso_tenant | default("ansible_test") }}_tplb' + listener_port: 443 + listener_protocol: https + security_policy: default + ssl_certificates: + - name: '{{ mso_tenant | default("ansible_test") }}_keyring' + certificate_store: default + rules: + - name: rule1 + priority: 1 + action_type: forward + port: 80 + protocol: http + provider_epg_ref: + anp_name: AP1 + epg_name: EPG1 + health_check: + port: 80 + protocol: http + path: "health_check_path" + interval: 30 + timeout: 30 + unhealthy_threshold: 3 + use_host_from_rule: true + success_code: "200" + target_ip_type: unspecified + ignore_errors: true + register: nt_tp_lb_listener + +- name: Negative test - add listener - nt_aplb_li_https - with same listener and rule protocol - https + cisco.mso.mso_schema_site_contract_service_graph_listener: + <<: *mso_info + contract: "Contract2" + schema: '{{ mso_schema | default("ansible_test") }}' + template: ansible_template1 + site: '{{ mso_site | default("ansible_test") }}' + service_node_index: 1 + listener: nt_aplb_li_https + tenant: '{{ mso_tenant | default("ansible_test") }}' + device: '{{ mso_tenant | default("ansible_test") }}_aplb' + listener_port: 443 + listener_protocol: https + security_policy: default + ssl_certificates: + - name: '{{ mso_tenant | default("ansible_test") }}_keyring' + certificate_store: default + rules: + - name: rule1 + priority: 1 + action_type: forward + port: 80 + protocol: https + provider_epg_ref: + anp_name: AP1 + epg_name: EPG1 + health_check: + port: 80 + protocol: http + path: "health_check_path" + interval: 30 + timeout: 30 + unhealthy_threshold: 3 + use_host_from_rule: true + success_code: "200" + target_ip_type: unspecified + ignore_errors: true + register: nt_lp_and_rp_https + +- name: Negative test - add listener - nt_aplb_li_https - with same listener and rule protocol - http + cisco.mso.mso_schema_site_contract_service_graph_listener: + <<: *mso_info + contract: "Contract2" + schema: '{{ mso_schema | default("ansible_test") }}' + template: ansible_template1 + site: '{{ mso_site | default("ansible_test") }}' + service_node_index: 1 + listener: nt_aplb_li_https + tenant: '{{ mso_tenant | default("ansible_test") }}' + device: '{{ mso_tenant | default("ansible_test") }}_aplb' + listener_port: 443 + listener_protocol: http + rules: + - name: rule1 + priority: 1 + action_type: forward + port: 80 + protocol: http + provider_epg_ref: + anp_name: AP1 + epg_name: EPG1 + health_check: + port: 80 + protocol: http + path: "health_check_path" + interval: 30 + timeout: 30 + unhealthy_threshold: 3 + use_host_from_rule: true + success_code: "200" + target_ip_type: unspecified + ignore_errors: true + register: nt_lp_and_rp_http + +- name: Negative test - add listener - nt_aplb_li_https - rule action_type is redirect + cisco.mso.mso_schema_site_contract_service_graph_listener: + <<: *mso_info + contract: "Contract2" + schema: '{{ mso_schema | default("ansible_test") }}' + template: ansible_template1 + site: '{{ mso_site | default("ansible_test") }}' + service_node_index: 1 + listener: nt_aplb_li_https + tenant: '{{ mso_tenant | default("ansible_test") }}' + device: '{{ mso_tenant | default("ansible_test") }}_aplb' + listener_port: 443 + listener_protocol: https + security_policy: default + ssl_certificates: + - name: '{{ mso_tenant | default("ansible_test") }}_keyring' + certificate_store: default + rules: + - name: rule1 + priority: 1 + action_type: redirect + port: 80 + protocol: http + provider_epg_ref: + anp_name: AP1 + epg_name: EPG1 + health_check: + port: 80 + protocol: http + path: "health_check_path" + interval: 30 + timeout: 30 + unhealthy_threshold: 3 + use_host_from_rule: true + success_code: "200" + target_ip_type: unspecified + ignore_errors: true + register: nt_action_type_redirect + +- name: Negative test - add listener - nt_aplb_li_https - rule action_type is forward + cisco.mso.mso_schema_site_contract_service_graph_listener: + <<: *mso_info + contract: "Contract2" + schema: '{{ mso_schema | default("ansible_test") }}' + template: ansible_template1 + site: '{{ mso_site | default("ansible_test") }}' + service_node_index: 1 + listener: nt_aplb_li_https + tenant: '{{ mso_tenant | default("ansible_test") }}' + device: '{{ mso_tenant | default("ansible_test") }}_aplb' + listener_port: 443 + listener_protocol: https + security_policy: default + ssl_certificates: + - name: '{{ mso_tenant | default("ansible_test") }}_keyring' + certificate_store: default + rules: + - name: rule1 + priority: 1 + action_type: forward + port: 80 + protocol: http + provider_epg_ref: + anp_name: AP1 + epg_name: EPG1 + target_ip_type: unspecified + ignore_errors: true + register: nt_action_type_forward + +- name: Negative test - add listener - nt_aplb_li_https - rule url_type is custom + cisco.mso.mso_schema_site_contract_service_graph_listener: + <<: *mso_info + contract: "Contract2" + schema: '{{ mso_schema | default("ansible_test") }}' + template: ansible_template1 + site: '{{ mso_site | default("ansible_test") }}' + service_node_index: 1 + listener: nt_aplb_li_https + tenant: '{{ mso_tenant | default("ansible_test") }}' + device: '{{ mso_tenant | default("ansible_test") }}_aplb' + listener_port: 443 + listener_protocol: https + security_policy: default + ssl_certificates: + - name: '{{ mso_tenant | default("ansible_test") }}_keyring' + certificate_store: default + rules: + - name: rule1 + priority: 1 + action_type: forward + port: 80 + protocol: http + provider_epg_ref: + anp_name: AP1 + epg_name: EPG1 + url_type: custom + health_check: + port: 80 + protocol: http + path: "health_check_path" + interval: 30 + timeout: 30 + unhealthy_threshold: 3 + use_host_from_rule: true + success_code: "200" + target_ip_type: unspecified + ignore_errors: true + register: nt_url_type_custom + +- name: Negative test - add listener - nlb_li_tcp - listener protocol is tcp/udp - health_check missing + cisco.mso.mso_schema_site_contract_service_graph_listener: + <<: *mso_info + contract: "Contract2" + schema: '{{ mso_schema | default("ansible_test") }}' + template: ansible_template1 + site: '{{ mso_site | default("ansible_test") }}' + service_node_index: 0 + listener: nlb_li_tcp + listener_port: 80 + listener_protocol: tcp + tenant: '{{ mso_tenant | default("ansible_test") }}' + frontend_ip: "10.10.10.10" + device: '{{ mso_tenant | default("ansible_test") }}_nlb' + security_policy: default + rules: + - name: rule1 + priority: 1 + action_type: forward + port: 80 + protocol: tcp + ignore_errors: true + register: nt_lp_tcp_udp_hp_missing + +- name: Negative test - add listener - nlb_li_tcp - listener protocol is tcp/udp - health_check protocol tcp - unhealthy_threshold missing + cisco.mso.mso_schema_site_contract_service_graph_listener: + <<: *mso_info + contract: "Contract2" + schema: '{{ mso_schema | default("ansible_test") }}' + template: ansible_template1 + site: '{{ mso_site | default("ansible_test") }}' + service_node_index: 0 + listener: nlb_li_tcp + listener_port: 80 + listener_protocol: tcp + tenant: '{{ mso_tenant | default("ansible_test") }}' + frontend_ip: "10.10.10.10" + device: '{{ mso_tenant | default("ansible_test") }}_nlb' + security_policy: default + rules: + - name: rule1 + priority: 1 + action_type: forward + port: 80 + protocol: tcp + health_check: + port: 80 + protocol: tcp + interval: 5 + success_code: 200-399 + ignore_errors: true + register: nt_lp_tcp_udp_hp_tcp_ut_missing + +- name: Negative test - add listener - nlb_li_tcp - listener protocol is tcp/udp - health_check protocol http/https - unhealthy_threshold missing + cisco.mso.mso_schema_site_contract_service_graph_listener: + <<: *mso_info + contract: "Contract2" + schema: '{{ mso_schema | default("ansible_test") }}' + template: ansible_template1 + site: '{{ mso_site | default("ansible_test") }}' + service_node_index: 0 + listener: nlb_li_tcp + listener_port: 80 + listener_protocol: tcp + tenant: '{{ mso_tenant | default("ansible_test") }}' + frontend_ip: "10.10.10.10" + device: '{{ mso_tenant | default("ansible_test") }}_nlb' + security_policy: default + rules: + - name: rule1 + priority: 1 + action_type: forward + port: 80 + protocol: tcp + health_check: + port: 80 + protocol: http + interval: 5 + success_code: 200-399 + ignore_errors: true + register: nt_lp_tcp_udp_hp_http_https_ut_missing + +- name: Negative test - add listener - nlb_li_http - listener protocol is http - health_check protocol https - unhealthy_threshold missing + cisco.mso.mso_schema_site_contract_service_graph_listener: + <<: *mso_info + contract: "Contract2" + schema: '{{ mso_schema | default("ansible_test") }}' + template: ansible_template1 + site: '{{ mso_site | default("ansible_test") }}' + service_node_index: 0 + listener: nlb_li_http + listener_port: 80 + listener_protocol: http + tenant: '{{ mso_tenant | default("ansible_test") }}' + frontend_ip: "10.10.10.10" + device: '{{ mso_tenant | default("ansible_test") }}_nlb' + security_policy: default + rules: + - name: rule1 + priority: 1 + action_type: forward + port: 80 + protocol: tcp + health_check: + port: 80 + protocol: https + interval: 5 + success_code: 200-399 + ignore_errors: true + register: nt_lp_http_hp_https_ut_missing + +- name: Negative test - add listener - nlb_li_http - listener protocol is http - health_check protocol http + cisco.mso.mso_schema_site_contract_service_graph_listener: + <<: *mso_info + contract: "Contract2" + schema: '{{ mso_schema | default("ansible_test") }}' + template: ansible_template1 + site: '{{ mso_site | default("ansible_test") }}' + service_node_index: 0 + listener: nlb_li_http + listener_port: 80 + listener_protocol: http + tenant: '{{ mso_tenant | default("ansible_test") }}' + frontend_ip: "10.10.10.10" + device: '{{ mso_tenant | default("ansible_test") }}_nlb' + security_policy: default + rules: + - name: rule1 + priority: 1 + action_type: forward + port: 80 + protocol: tcp + health_check: + port: 80 + protocol: http + interval: 5 + success_code: 200-399 + ignore_errors: true + register: nt_lp_http_hp_http + +- name: Negative test - add listener - nlb_li_https - listener protocol is https - health_check protocol https + cisco.mso.mso_schema_site_contract_service_graph_listener: + <<: *mso_info + contract: "Contract2" + schema: '{{ mso_schema | default("ansible_test") }}' + template: ansible_template1 + site: '{{ mso_site | default("ansible_test") }}' + service_node_index: 0 + listener: nlb_li_https + listener_port: 80 + listener_protocol: https + tenant: '{{ mso_tenant | default("ansible_test") }}' + frontend_ip: "10.10.10.10" + device: '{{ mso_tenant | default("ansible_test") }}_nlb' + security_policy: default + ssl_certificates: + - name: '{{ mso_tenant | default("ansible_test") }}_keyring' + certificate_store: default + rules: + - name: rule1 + priority: 1 + action_type: forward + port: 80 + protocol: tcp + health_check: + port: 80 + protocol: https + interval: 5 + success_code: 200-399 + ignore_errors: true + register: nt_lp_https_hp_https + +- name: Negative test - remove a listener - ans_li_common - with invalid service_node_index is -1 + cisco.mso.mso_schema_site_contract_service_graph_listener: + <<: *mso_info + contract: "Contract2" + schema: '{{ mso_schema | default("ansible_test") }}' + template: ansible_template1 + site: '{{ mso_site | default("ansible_test") }}' + service_node_index: -1 + listener: ans_li_common + state: absent + ignore_errors: true + register: rm_ans_li_common_nm_again + +- name: Assertions check for the listeners negative test + ansible.builtin.assert: + that: + - nt_non_cloud_site is not changed + - nt_non_cloud_site.msg == "The Site Contract Service Graph Listener is not supported for the site{{':'}} ansible_test." + - nt_lp_https_ssl_cert_missing is not changed + - nt_lp_https_ssl_cert_missing.msg == "When the 'listener_protocol' is 'https', the ['security_policy', 'ssl_certificates'] attributes must be set and the object name{{':'}} nt_aplb_li_https" + - nt_invalid_contract3 is not changed + - nt_invalid_contract3.msg == "The site contract{{':'}} Contract3 is not associated with a service graph." + - nt_invalid_device is not changed + - nt_invalid_device.msg == "The site contract{{':'}} Contract3 is not associated with a service graph." + - nt_tp_fw_listener is not changed + - nt_tp_fw_listener.msg == "Listener is not supported for the 'service_node_index'{{':'}} 0 is associated with the Third-Party Firewall device." + - nt_tp_lb_listener is not changed + - nt_tp_lb_listener.msg == "Listener is not supported for the 'service_node_index'{{':'}} 1 is associated with the Third-Party Load Balancer device." + - nt_lp_and_rp_https is not changed + - nt_lp_and_rp_https.msg == "When the 'listener_protocol' is 'https', the rule 'protocol' must be 'https'" + - nt_lp_and_rp_http is not changed + - nt_lp_and_rp_http.msg == "When the 'listener_protocol' is 'http', the rule 'protocol' must be 'http'" + - nt_action_type_redirect is not changed + - nt_action_type_redirect.msg == "When the 'action_type' is 'redirect', the ['redirect_protocol', 'redirect_port', 'url_type', 'redirect_code'] attributes must be set at the object position{{':'}} 0 and the object name{{':'}} rule1" + - nt_action_type_forward is not changed + - nt_action_type_forward.msg == "When the 'action_type' is 'forward', the ['health_check'] attributes must be set at the object position{{':'}} 0 and the object name{{':'}} rule1" + - nt_url_type_custom is not changed + - nt_url_type_custom.msg == "When the 'url_type' is 'custom', the ['redirect_host_name', 'redirect_path', 'redirect_query', 'response_code'] attributes must be set at the object position{{':'}} 0 and the object name{{':'}} rule1" + - nt_lp_tcp_udp_hp_missing is not changed + - nt_lp_tcp_udp_hp_missing.msg == "When the 'action_type' is 'forward', the ['health_check'] attributes must be set at the object position{{':'}} 0 and the object name{{':'}} rule1" + - nt_lp_tcp_udp_hp_tcp_ut_missing is not changed + - nt_lp_tcp_udp_hp_tcp_ut_missing.msg == "When the 'health_check - 'protocol'' is 'tcp', the ['unhealthy_threshold'] attributes must be set" + - nt_lp_tcp_udp_hp_http_https_ut_missing is not changed + - nt_lp_tcp_udp_hp_http_https_ut_missing.msg == "When the 'health_check - 'protocol'' is 'http/https', the ['path', 'unhealthy_threshold'] attributes must be set" + - nt_lp_http_hp_https_ut_missing is not changed + - nt_lp_http_hp_https_ut_missing.msg == "When the 'health_check - 'protocol'' is 'http/https', the ['path', 'unhealthy_threshold', 'timeout'] attributes must be set" + - nt_lp_http_hp_http is not changed + - nt_lp_http_hp_http.msg == "The 'listener_protocol'{{':'}} http and the health_check protocol{{':'}} http is not a valid configuration at the object position{{':'}} 0 and the object name{{':'}} rule1" + - nt_lp_https_hp_https is not changed + - nt_lp_https_hp_https.msg == "The 'listener_protocol'{{':'}} https and the health_check protocol{{':'}} https is not a valid configuration at the object position{{':'}} 0 and the object name{{':'}} rule1" + - rm_ans_li_common_nm_again is not changed + - rm_ans_li_common_nm_again.msg == "The service_node_index{{':'}} -1 is not valid." + +- name: Remove an existing listener - ans_li_common - check_mode + cisco.mso.mso_schema_site_contract_service_graph_listener: + <<: *mso_info + contract: "Contract2" + schema: '{{ mso_schema | default("ansible_test") }}' + template: ansible_template1 + site: '{{ mso_site | default("ansible_test") }}' + service_node_index: 0 + listener: ans_li_common + state: absent + output_level: debug + check_mode: true + register: rm_ans_li_common_cm + +- name: Remove an existing listener - ans_li_common - normal_mode + cisco.mso.mso_schema_site_contract_service_graph_listener: + <<: *mso_info + contract: "Contract2" + schema: '{{ mso_schema | default("ansible_test") }}' + template: ansible_template1 + site: '{{ mso_site | default("ansible_test") }}' + service_node_index: 0 + listener: ans_li_common + state: absent + register: rm_ans_li_common_nm + +- name: Remove an existing listener - ans_li_common - normal_mode again + cisco.mso.mso_schema_site_contract_service_graph_listener: + <<: *mso_info + contract: "Contract2" + schema: '{{ mso_schema | default("ansible_test") }}' + template: ansible_template1 + site: '{{ mso_site | default("ansible_test") }}' + service_node_index: 0 + listener: ans_li_common + state: absent + register: rm_ans_li_common_nm_again + +- name: Assertions check for remove listeners + ansible.builtin.assert: + that: + - rm_ans_li_common_cm is changed + - rm_ans_li_common_cm.current == {} + - rm_ans_li_common_cm.previous != {} + - rm_ans_li_common_cm.previous.name == "ans_li_common" + - rm_ans_li_common_cm.previous.protocol == "udp" + - rm_ans_li_common_cm.proposed == {} + - rm_ans_li_common_nm is changed + - rm_ans_li_common_nm.current == {} + - rm_ans_li_common_nm.previous != {} + - rm_ans_li_common_nm.previous.name == "ans_li_common" + - rm_ans_li_common_nm.previous.protocol == "udp" + - rm_ans_li_common_nm_again is not changed + - rm_ans_li_common_nm_again.current == {} + - rm_ans_li_common_nm_again.previous == {} + +# Cleanup part +- name: Remove the site association for the ansible_schema templates + cisco.mso.mso_schema_site: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_schema") }}' + template: "{{ item }}" + site: '{{ mso_site | default("ansible_test") }}' + state: present + loop: + - "ansible_template1" + - "ansible_template2" + +- name: Remove the ansible_schema schema + cisco.mso.mso_schema: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_schema") }}' + state: absent + +- name: Remove the {{ mso_tenant | default("ansible_test") }} tenant + cisco.mso.mso_tenant: + <<: *mso_info + tenant: '{{ mso_tenant | default("ansible_test") }}' + state: absent + +- name: Set ansible_network_os to cisco.aci.aci and ansible_connection to local + ansible.builtin.set_fact: + ansible_connection: local + ansible_network_os: cisco.aci.aci + +- name: Reset the ansible_connection to access the APIC + ansible.builtin.meta: reset_connection + +- name: Remove the common tenant redirect policy + cisco.aci.aci_rest: + host: "{{ apic_hostname }}" + username: "{{ apic_username }}" + password: "{{ apic_password }}" + validate_certs: no + path: "/api/node/mo/uni/tn-common/svcCont.json" + method: post + content: + vnsSvcRedirectPol: + attributes: + name: redirect_policy2 + status: deleted + +- name: Remove the {{ mso_tenant | default("ansible_test") }} from the APIC + cisco.aci.aci_tenant: + <<: *aci_info + tenant: '{{ mso_tenant | default("ansible_test") }}' + state: absent diff --git a/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_contract_service_graph_listener/tasks/pki/admin.crt b/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_contract_service_graph_listener/tasks/pki/admin.crt new file mode 100644 index 000000000..1f797a4c2 --- /dev/null +++ b/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_contract_service_graph_listener/tasks/pki/admin.crt @@ -0,0 +1,14 @@ +-----BEGIN CERTIFICATE----- +MIICODCCAaGgAwIBAgIJAIt8XMntue0VMA0GCSqGSIb3DQEBCwUAMDQxDjAMBgNV +BAMMBUFkbWluMRUwEwYDVQQKDAxZb3VyIENvbXBhbnkxCzAJBgNVBAYTAlVTMCAX +DTE4MDEwOTAwNTk0NFoYDzIxMTcxMjE2MDA1OTQ0WjA0MQ4wDAYDVQQDDAVBZG1p +bjEVMBMGA1UECgwMWW91ciBDb21wYW55MQswCQYDVQQGEwJVUzCBnzANBgkqhkiG +9w0BAQEFAAOBjQAwgYkCgYEAohG/7axtt7CbSaMP7r+2mhTKbNgh0Ww36C7Ta14i +v+VmLyKkQHnXinKGhp6uy3Nug+15a+eIu7CrgpBVMQeCiWfsnwRocKcQJWIYDrWl +XHxGQn31yYKR6mylE7Dcj3rMFybnyhezr5D8GcP85YRPmwG9H2hO/0Y1FUnWu9Iw +AQkCAwEAAaNQME4wHQYDVR0OBBYEFD0jLXfpkrU/ChzRvfruRs/fy1VXMB8GA1Ud +IwQYMBaAFD0jLXfpkrU/ChzRvfruRs/fy1VXMAwGA1UdEwQFMAMBAf8wDQYJKoZI +hvcNAQELBQADgYEAOmvre+5tgZ0+F3DgsfxNQqLTrGiBgGCIymPkP/cBXXkNuJyl +3ac7tArHQc7WEA4U2R2rZbEq8FC3UJJm4nUVtCPvEh3G9OhN2xwYev79yt6pIn/l +KU0Td2OpVyo0eLqjoX5u2G90IBWzhyjFbo+CcKMrSVKj1YOdG0E3OuiJf00= +-----END CERTIFICATE-----
\ No newline at end of file diff --git a/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_external_epg/tasks/main.yml b/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_external_epg/tasks/main.yml index 5b8c799db..8dc05d9fb 100644 --- a/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_external_epg/tasks/main.yml +++ b/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_external_epg/tasks/main.yml @@ -5,13 +5,13 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI MultiSite host, username and password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: mso_hostname, mso_username and mso_password.' when: mso_hostname is not defined or mso_username is not defined or mso_password is not defined # CLEAN ENVIRONMENT - name: Set vars - set_fact: + ansible.builtin.set_fact: mso_info: &mso_info host: '{{ mso_hostname }}' username: '{{ mso_username }}' @@ -22,13 +22,13 @@ output_level: '{{ mso_output_level | default("info") }}' - name: Query MSO version - mso_version: + cisco.mso.mso_version: <<: *mso_info state: query register: version - name: Remove schemas - mso_schema: + cisco.mso.mso_schema: <<: *mso_info schema: '{{ item }}' state: absent @@ -37,7 +37,7 @@ - '{{ mso_schema | default("ansible_test") }}' - name: Ensure site exists - mso_site: + cisco.mso.mso_site: <<: *mso_info site: '{{ mso_site | default("ansible_test") }}' apic_username: '{{ apic_username }}' @@ -48,7 +48,7 @@ state: present - name: Ensure sites removed from tenant ansible_test - mso_tenant_site: + cisco.mso.mso_tenant_site: <<: *mso_info tenant: ansible_test site: '{{ item }}' @@ -59,7 +59,7 @@ - 'azure_{{ mso_site | default("ansible_test") }}' - name: Ensure tenant ansible_test exist - mso_tenant: + cisco.mso.mso_tenant: <<: *mso_info tenant: ansible_test users: @@ -70,7 +70,7 @@ ignore_errors: true - name: Associate non-cloud site with ansible_test - mso_tenant_site: + cisco.mso.mso_tenant_site: <<: *mso_info tenant: ansible_test site: '{{ mso_site | default("ansible_test") }}' @@ -78,12 +78,12 @@ register: add_ncs - name: Verify add_ncs - assert: + ansible.builtin.assert: that: - add_ncs is not changed - name: Remove a site from a schema with Template1 and Template2 - mso_schema_site: + cisco.mso.mso_schema_site: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -91,11 +91,13 @@ state: absent ignore_errors: true loop: + - Template4 + - Template3 - Template2 - Template1 - name: Remove schemas - mso_schema: + cisco.mso.mso_schema: <<: *mso_info schema: '{{ item }}' state: absent @@ -105,7 +107,7 @@ # Ensure pre requisites exist - name: Ensure schema 1 with Template1 and 2 exists - mso_schema_template: + cisco.mso.mso_schema_template: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' tenant: ansible_test @@ -115,9 +117,10 @@ - Template1 - Template2 - Template3 + - Template4 - name: Ensure VRF1 exists - mso_schema_template_vrf: + cisco.mso.mso_schema_template_vrf: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template1 @@ -125,15 +128,23 @@ state: present - name: Ensure VRF2 exists - mso_schema_template_vrf: + cisco.mso.mso_schema_template_vrf: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template2 vrf: VRF2 state: present +- name: Ensure VRF3 exists + cisco.mso.mso_schema_template_vrf: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template3 + vrf: VRF3 + state: present + - name: Ensure L3Out1 Exists - mso_schema_template_l3out: + cisco.mso.mso_schema_template_l3out: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template1 @@ -143,7 +154,7 @@ state: present - name: Ensure L3Out2 Exists - mso_schema_template_l3out: + cisco.mso.mso_schema_template_l3out: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template2 @@ -152,9 +163,19 @@ l3out: L3out2 state: present +- name: Ensure L3Out3 Exists + cisco.mso.mso_schema_template_l3out: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template3 + vrf: + name: VRF3 + l3out: L3out3 + state: present + # ADD external EPG to template - name: Add external EPG at template level(check_mode) - mso_schema_template_external_epg: + cisco.mso.mso_schema_template_external_epg: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template1 @@ -172,7 +193,7 @@ register: cm_add_epg - name: Verify cm_add_epg - assert: + ansible.builtin.assert: that: - cm_add_epg is changed - cm_add_epg.previous == {} @@ -181,7 +202,7 @@ - cm_add_epg.current.vrfRef.vrfName == "VRF1" - name: Add external EPG at template level(normal mode) - mso_schema_template_external_epg: + cisco.mso.mso_schema_template_external_epg: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template1 @@ -198,7 +219,7 @@ register: nm_add_epg - name: Verify nm_add_epg - assert: + ansible.builtin.assert: that: - nm_add_epg is changed - nm_add_epg.previous == {} @@ -213,7 +234,7 @@ block: # Associate site to schema/template after creating External EPG - name: Add non-cloud site to a schema - mso_schema_site: + cisco.mso.mso_schema_site: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -222,13 +243,13 @@ register: add_site - name: Verify add_site - assert: + ansible.builtin.assert: that: - add_site.current.siteId is match ("[0-9a-zA-Z]*") - add_site.current.templateName == "Template1" - name: Add site L3Out (normal_mode) - mso_schema_site_l3out: + cisco.mso.mso_schema_site_l3out: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -244,7 +265,7 @@ # ADD External EPGs to site - name: ADD External EPG1 to site (check_mode) - mso_schema_site_external_epg: + cisco.mso.mso_schema_site_external_epg: <<: *mso_info site: '{{ mso_site | default("ansible_test") }}' schema: '{{ mso_schema | default("ansible_test") }}' @@ -256,20 +277,20 @@ register: cm_add_epg - name: Verify cm_add_epg - assert: + ansible.builtin.assert: that: - cm_add_epg.current.externalEpgRef.externalEpgName == "ansible_test_1" - cm_add_epg.current.externalEpgRef.templateName == "Template1" - name: Verify cm_add_epg - assert: + ansible.builtin.assert: that: - cm_add_epg is changed - cm_add_epg.previous == {} - when: version.current.version is version('4.0', '<') # no change in NDO4.0 because site will already be present when template is defined + when: version.current.version is version('4.0', '<') - name: Add external EPG to site (normal mode) - mso_schema_site_external_epg: + cisco.mso.mso_schema_site_external_epg: <<: *mso_info site: '{{ mso_site | default("ansible_test") }}' schema: '{{ mso_schema | default("ansible_test") }}' @@ -280,21 +301,21 @@ register: nm_add_epg - name: Verify nm_add_epg - assert: + ansible.builtin.assert: that: - nm_add_epg.current.externalEpgRef.externalEpgName == "ansible_test_1" - nm_add_epg.current.externalEpgRef.templateName == "Template1" - cm_add_epg.current.externalEpgRef.schemaId == nm_add_epg.current.externalEpgRef.schemaId - name: Verify nm_add_epg - assert: + ansible.builtin.assert: that: - nm_add_epg is changed - nm_add_epg.previous == {} - when: version.current.version is version('4.0', '<') # no change in NDO4.0 because site will already be present when template is defined + when: version.current.version is version('4.0', '<') - name: ADD External EPG1 to site again - mso_schema_site_external_epg: + cisco.mso.mso_schema_site_external_epg: <<: *mso_info site: '{{ mso_site | default("ansible_test") }}' schema: '{{ mso_schema | default("ansible_test") }}' @@ -305,7 +326,7 @@ register: add_epg_again - name: Verify add_epg_again - assert: + ansible.builtin.assert: that: - add_epg_again is not changed - add_epg_again.current.externalEpgRef.externalEpgName == "ansible_test_1" @@ -313,7 +334,7 @@ # QUERY ALL EPG - name: Query all external EPGs in site (check_mode) - mso_schema_site_external_epg: + cisco.mso.mso_schema_site_external_epg: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -323,7 +344,7 @@ register: cm_query_all_epgs - name: Query all EPG (normal mode) - mso_schema_site_external_epg: + cisco.mso.mso_schema_site_external_epg: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -332,14 +353,14 @@ register: nm_query_all_epgs - name: Verify query_all_epgs - assert: + ansible.builtin.assert: that: - cm_query_all_epgs is not changed - nm_query_all_epgs is not changed # QUERY AN EPG - name: Query epg 1(check_mode) - mso_schema_site_external_epg: + cisco.mso.mso_schema_site_external_epg: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -351,7 +372,7 @@ register: cm_query_epg_1 - name: Query epg 1(normal_mode) - mso_schema_site_external_epg: + cisco.mso.mso_schema_site_external_epg: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -362,13 +383,13 @@ register: nm_query_epg_1 - name: Verify cm_query_epg_1 and nm_query_epg_1 - assert: + ansible.builtin.assert: that: - cm_query_epg_1 is not changed - nm_query_epg_1 is not changed - name: Query epg 1 without l3Out - mso_schema_site_external_epg: + cisco.mso.mso_schema_site_external_epg: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -378,13 +399,13 @@ register: nm_query_epg_l3out - name: Verify nm_query_epg_l3out - assert: + ansible.builtin.assert: that: - nm_query_epg_l3out is not changed # REMOVE EPG - name: Remove EPG (check_mode) - mso_schema_site_external_epg: + cisco.mso.mso_schema_site_external_epg: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -396,13 +417,13 @@ register: cm_remove_epg - name: Verify cm_remove_epg - assert: + ansible.builtin.assert: that: - cm_remove_epg is changed - cm_remove_epg.current == {} - name: Remove EPG (normal_mode) - mso_schema_site_external_epg: + cisco.mso.mso_schema_site_external_epg: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -413,7 +434,7 @@ register: nm_remove_epg - name: Add site external EPG without L3Out when template external EPG type is on-premise (normal_mode) - mso_schema_site_external_epg: + cisco.mso.mso_schema_site_external_epg: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -424,13 +445,13 @@ register: nm_add_epg_no_l3out - name: Verify nm_add_epg_no_l3out - assert: + ansible.builtin.assert: that: - nm_add_epg_no_l3out is not changed - nm_add_epg_no_l3out.msg == "L3Out cannot be empty when template external EPG type is 'on-premise'." - name: Remove external EPG at template level - mso_schema_template_external_epg: + cisco.mso.mso_schema_template_external_epg: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template1 @@ -439,14 +460,14 @@ register: nm_remove_epg - name: Verify nm_remove_epg - assert: + ansible.builtin.assert: that: - nm_remove_epg is changed - nm_remove_epg.current == {} # Associate site to schema/template before creating External EPG - name: Add non-cloud site to a schema - mso_schema_site: + cisco.mso.mso_schema_site: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -456,14 +477,30 @@ register: add_site - name: Verify add_site - assert: + ansible.builtin.assert: that: - add_site.current.siteId is match ("[0-9a-zA-Z]*") - add_site.current.templateName == "Template2" + - name: Add non-cloud site to a schema + cisco.mso.mso_schema_site: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: '{{ mso_site | default("ansible_test") }}' + template: Template3 + state: present + when: version.current.version is version('3.3', '>=') + register: add_site + + - name: Verify add_site + assert: + that: + - add_site.current.siteId is match ("[0-9a-zA-Z]*") + - add_site.current.templateName == "Template3" + # Create template External EPG after site association - name: Add external EPG (at template level) - mso_schema_template_external_epg: + cisco.mso.mso_schema_template_external_epg: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template2 @@ -480,7 +517,7 @@ register: nm_add_ex_epg - name: Verify nm_add_ex_epg - assert: + ansible.builtin.assert: that: - nm_add_ex_epg is changed - nm_add_ex_epg.previous == {} @@ -488,7 +525,7 @@ - nm_add_ex_epg.current.vrfRef.vrfName == "VRF2" - name: Add external EPG to site (normal mode) - mso_schema_site_external_epg: + cisco.mso.mso_schema_site_external_epg: <<: *mso_info site: '{{ mso_site | default("ansible_test") }}' schema: '{{ mso_schema | default("ansible_test") }}' @@ -499,21 +536,177 @@ register: nm_add_epg - name: Verify nm_add_epg - assert: + ansible.builtin.assert: that: - nm_add_epg.current.externalEpgRef.externalEpgName == "ansible_test_2" - nm_add_epg.current.externalEpgRef.templateName == "Template2" - name: Verify nm_add_epg - assert: + ansible.builtin.assert: that: - nm_add_epg is changed - nm_add_epg.previous == {} - when: version.current.version is version('4.0', '<') # no change in NDO4.0 because site will already be present when template is defined + when: version.current.version is version('4.0', '<') + + # Verify L3Out association at site level External EPG + + # 1. Verifying External EPG association with VRFs of different templates in same schema + - name: Execute tasks only for MSO version < 4.0 + when: version.current.version is version('4.0', '<') + block: + # 1.1. Verifying External EPG association with VRF in the same template of the same schema + - name: Add external EPG 1 at Template1 and associate it with the VRF1 in the Template1 + cisco.mso.mso_schema_template_external_epg: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template1 + external_epg: ansible_test_1 + vrf: + name: VRF1 + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template1 + state: present + register: add_epg1 + + - name: Verify add External EPG 1 + assert: + that: + - add_epg1 is changed + - add_epg1.previous == {} + - add_epg1.current.name == "ansible_test_1" + - add_epg1.current.vrfRef.templateName == "Template1" + - add_epg1.current.vrfRef.vrfName == "VRF1" + - add_epg1.current.vrfRef.schemaId == add_epg1.current.vrfRef.schemaId + + - name: Add external EPG to site and associate it with the L3Out1 in Template1 + cisco.mso.mso_schema_site_external_epg: + <<: *mso_info + site: '{{ mso_site | default("ansible_test") }}' + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template1 + external_epg: ansible_test_1 + l3out: L3out1 + l3out_template: Template1 + l3out_schema: '{{ mso_schema | default("ansible_test") }}' + state: present + register: add_epg_site_1 + + - name: Verify add_epg_site_1 + assert: + that: + - add_epg_site_1.current.externalEpgRef.externalEpgName == "ansible_test_1" + - add_epg_site_1.current.externalEpgRef.templateName == "Template1" + + - name: Verify add_epg_site_1 + assert: + that: + - add_epg_site_1 is changed + - add_epg_site_1.previous == {} + + - name: Add external EPG to site and associate it with the L3Out3 in Template3 (VRF in same template) + cisco.mso.mso_schema_site_external_epg: + <<: *mso_info + site: '{{ mso_site | default("ansible_test") }}' + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template1 + external_epg: ansible_test_1 + l3out: L3out3 + l3out_template: Template3 + l3out_schema: '{{ mso_schema | default("ansible_test") }}' + state: present + register: add_epg_site1_l3out3 + + - name: Verify add_epg_site1_l3out3 + assert: + that: + - add_epg_site1_l3out3.current.externalEpgRef.externalEpgName == "ansible_test_1" + - add_epg_site1_l3out3.current.externalEpgRef.templateName == "Template1" + + - name: Verify add_epg_site1_l3out3 + assert: + that: + - add_epg_site1_l3out3 is changed + - add_epg_site1_l3out3.previous.l3outDn == "uni/tn-ansible_test/out-L3out1" + + # 1.2. Verifying External EPG association with VRF in the different template of the same schema + - name: Add external EPG 1 at Template1 and associate it with the VRF3 in Template3 + cisco.mso.mso_schema_template_external_epg: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template1 + external_epg: ansible_test_3 + vrf: + name: VRF3 + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template3 + state: present + register: add_epg3 + + - name: Verify add External EPG 3 + assert: + that: + - add_epg3 is changed + - add_epg3.previous == {} + - add_epg3.current.name == "ansible_test_3" + - add_epg3.current.vrfRef.templateName == "Template3" + - add_epg3.current.vrfRef.vrfName == "VRF3" + - add_epg3.current.vrfRef.schemaId == add_epg3.current.vrfRef.schemaId + + # ExternalEpg and its L3Out are associated with different VRF in a template + - name: Add external EPG to site and associate it with the L3Out1 in Template1 + cisco.mso.mso_schema_site_external_epg: + <<: *mso_info + site: '{{ mso_site | default("ansible_test") }}' + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template1 + external_epg: ansible_test_3 + l3out: L3out1 + l3out_template: Template1 + l3out_schema: '{{ mso_schema | default("ansible_test") }}' + state: present + register: add_epg_site_3 + + - name: Verify add_epg_site_3 + assert: + that: + - add_epg_site_3.current.externalEpgRef.externalEpgName == "ansible_test_3" + - add_epg_site_3.current.externalEpgRef.templateName == "Template1" + - add_epg_site_3.current.l3outRef is match('/schemas/[0-9a-zA-Z]*/templates/Template1/l3outs/L3out1') + + - name: Verify add_epg_site_3 + assert: + that: + - add_epg_site_3 is changed + - add_epg_site_3.previous == {} + + - name: Add external EPG to site and associate it with the L3Out3 in Template3 + cisco.mso.mso_schema_site_external_epg: + <<: *mso_info + site: '{{ mso_site | default("ansible_test") }}' + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template1 + external_epg: ansible_test_3 + l3out: L3out3 + l3out_template: Template3 + l3out_schema: '{{ mso_schema | default("ansible_test") }}' + state: present + register: add_epg_site_3_l3out3 + + - name: Verify add_epg_site_3_l3out3 + assert: + that: + - add_epg_site_3_l3out3.current.externalEpgRef.externalEpgName == "ansible_test_1" + - add_epg_site_3_l3out3.current.externalEpgRef.templateName == "Template1" + + - name: Verify add_epg_site_3_l3out3 + assert: + that: + - add_epg_site_3_l3out3 is changed + - add_epg_site_3_l3out3.previous == {} # QUERY NON-EXISTING external EPG - name: Query non-existing External EPG (check_mode) - mso_schema_site_external_epg: + cisco.mso.mso_schema_site_external_epg: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -526,7 +719,7 @@ register: cm_query_non_external_epg - name: Query non-existing External EPG (normal_mode) - mso_schema_site_external_epg: + cisco.mso.mso_schema_site_external_epg: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -538,7 +731,7 @@ register: nm_query_non_external_epg - name: Verify cm_query_non_external_epg and nm_query_non_external_epg - assert: + ansible.builtin.assert: that: - cm_query_non_external_epg is not changed - nm_query_non_external_epg is not changed @@ -546,7 +739,7 @@ # USE NON-EXISTING STATE - name: non_existing_state state (check_mode) - mso_schema_site_external_epg: + cisco.mso.mso_schema_site_external_epg: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -558,7 +751,7 @@ register: cm_non_existing_state - name: non_existing_state state (normal_mode) - mso_schema_site_external_epg: + cisco.mso.mso_schema_site_external_epg: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -570,7 +763,7 @@ register: nm_non_existing_state - name: Verify cm_non_existing_state and nm_non_existing_state - assert: + ansible.builtin.assert: that: - cm_non_existing_state is not changed - nm_non_existing_state is not changed @@ -578,7 +771,7 @@ # USE A NON_EXISTING_TEMPLATE - name: non_existing_template (check_mode) - mso_schema_site_external_epg: + cisco.mso.mso_schema_site_external_epg: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -591,7 +784,7 @@ register: cm_non_existing_template - name: non_existing_template site association(normal_mode) - mso_schema_site_external_epg: + cisco.mso.mso_schema_site_external_epg: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -603,15 +796,15 @@ register: nm_non_existing_template - name: Verify cm_non_existing_template and nm_non_existing_template - assert: + ansible.builtin.assert: that: - cm_non_existing_template is not changed - nm_non_existing_template is not changed - - cm_non_existing_template.msg == nm_non_existing_template.msg == "Provided template 'non_existing_template' not matching existing template(s){{':'}} Template1, Template2, Template3" + - cm_non_existing_template.msg == nm_non_existing_template.msg == "Provided template 'non_existing_template' not matching existing template(s){{':'}} Template1, Template2, Template3, Template4" # USE A NON_EXISTING_SCHEMA - name: non_existing_schema (check_mode) - mso_schema_site_external_epg: + cisco.mso.mso_schema_site_external_epg: <<: *mso_info schema: non_existing_schema site: '{{ mso_site | default("ansible_test") }}' @@ -624,7 +817,7 @@ register: cm_non_existing_schema - name: non_existing_schema (normal_mode) - mso_schema_site_external_epg: + cisco.mso.mso_schema_site_external_epg: <<: *mso_info schema: non_existing_schema site: '{{ mso_site | default("ansible_test") }}' @@ -636,7 +829,7 @@ register: nm_non_existing_schema - name: Verify cm_non_existing_schema and nm_non_existing_schema - assert: + ansible.builtin.assert: that: - cm_non_existing_schema is not changed - nm_non_existing_schema is not changed @@ -644,7 +837,7 @@ # USE A NON_EXISTING_SITE - name: non_existing_site (check_mode) - mso_schema_site_external_epg: + cisco.mso.mso_schema_site_external_epg: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: non_existing_site @@ -657,7 +850,7 @@ register: cm_non_existing_site - name: non_existing_site (normal_mode) - mso_schema_site_external_epg: + cisco.mso.mso_schema_site_external_epg: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: non_existing_site @@ -669,7 +862,7 @@ register: nm_non_existing_site - name: Verify cm_non_existing_site and nm_non_existing_site - assert: + ansible.builtin.assert: that: - cm_non_existing_site is not changed - nm_non_existing_site is not changed @@ -677,11 +870,11 @@ # USE A NON_EXISTING_SITE_TEMPLATE - name: non_existing_site_template (check_mode) - mso_schema_site_external_epg: + cisco.mso.mso_schema_site_external_epg: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' - template: Template3 + template: Template4 external_epg: ansible_test_2 l3out: L3out1 state: query @@ -690,11 +883,11 @@ register: cm_non_existing_site_template - name: non_existing_site_template (normal_mode) - mso_schema_site_external_epg: + cisco.mso.mso_schema_site_external_epg: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' - template: Template3 + template: Template4 external_epg: ansible_test_2 l3out: L3out1 state: query @@ -702,32 +895,32 @@ register: nm_non_existing_site_template - name: Verify cm_non_existing_site_template and nm_non_existing_site_template - assert: + ansible.builtin.assert: that: - cm_non_existing_site_template is not changed - nm_non_existing_site_template is not changed - - cm_non_existing_site_template.msg == nm_non_existing_site_template.msg == "Provided site 'ansible_test' not associated with template 'Template3'. Site is currently associated with template(s){{':'}} Template1, Template2" + - cm_non_existing_site_template.msg == nm_non_existing_site_template.msg == "Provided site 'ansible_test' not associated with template 'Template4'. Site is currently associated with template(s){{':'}} Template1, Template2, Template3" # USE A TEMPLATE WITHOUT ANY SITE - - name: Add site L3Out to Schema Template2 without any site associated (check mode) - mso_schema_site_external_epg: + - name: Add site External EPG to Schema Template4 without any site associated (check mode) + cisco.mso.mso_schema_site_external_epg: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' - template: Template3 - external_epg: ansible_test_2 + template: Template4 + external_epg: ansible_test_4 l3out: L3out1 state: present check_mode: true ignore_errors: true register: cm_no_site_associated - - name: Add site L3Out to Template2 without any site associated (normal mode) - mso_schema_site_external_epg: + - name: Add site External EPG to Template4 without any site associated (normal mode) + cisco.mso.mso_schema_site_external_epg: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' - template: Template3 + template: Template4 external_epg: ansible_test_2 l3out: L3out1 state: present @@ -735,99 +928,99 @@ register: nm_no_site_associated - name: Verify cm_no_site_associated and nm_no_site_associated - assert: + ansible.builtin.assert: that: - cm_no_site_associated is not changed - nm_no_site_associated is not changed - - cm_no_site_associated.msg == nm_no_site_associated.msg == "Provided site 'ansible_test' not associated with template 'Template3'. Site is currently associated with template(s){{':'}} Template1, Template2" + - cm_no_site_associated.msg == nm_no_site_associated.msg == "Provided site 'ansible_test' not associated with template 'Template4'. Site is currently associated with template(s){{':'}} Template1, Template2, Template3" # Verify route_reachability argument when template_external_epg is associated with Azure site and # template_external_epg type argument is set to cloud - name: Ensure ANP exists - mso_schema_template_anp: + cisco.mso.mso_schema_template_anp: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' - template: Template2 - anp: ANP2 + template: Template4 + anp: ANP4 state: present -- name: Ensure VRF3 exists - mso_schema_template_vrf: +- name: Ensure VRF4 exists + cisco.mso.mso_schema_template_vrf: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' - template: Template3 - vrf: VRF3 + template: Template4 + vrf: VRF4 state: present -- name: Ensure L3Out3 Exists - mso_schema_template_l3out: +- name: Ensure L3Out4 Exists + cisco.mso.mso_schema_template_l3out: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' - template: Template3 + template: Template4 vrf: - name: VRF3 - l3out: L3out3 + name: VRF4 + l3out: L3out4 state: present -- name: Add external EPG3 at template3 level type cloud (normal mode) - mso_schema_template_external_epg: +- name: Add external EPG4 at template4 level type cloud (normal mode) + cisco.mso.mso_schema_template_external_epg: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' - template: Template3 - external_epg: ext_epg_3 + template: Template4 + external_epg: ext_epg_4 type: cloud vrf: - name: VRF3 + name: VRF4 schema: '{{ mso_schema | default("ansible_test") }}' - template: Template3 + template: Template4 anp: - name: ANP3 + name: ANP4 schema: '{{ mso_schema | default("ansible_test") }}' - template: Template3 + template: Template4 state: present - register: nm_add_ext_epg_3 + register: nm_add_ext_epg_4 -- name: Add azure site to a schema Template3 - mso_schema_site: +- name: Add azure site to a schema Template4 + cisco.mso.mso_schema_site: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: 'azure_{{ mso_site | default("ansible_test") }}' - template: Template3 + template: Template4 state: present when: version.current.version is version('3.3', '>=') register: add_cloud_site - name: Add external EPG to site (normal mode) - mso_schema_site_external_epg: + cisco.mso.mso_schema_site_external_epg: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: 'azure_{{ mso_site | default("ansible_test") }}' - template: Template3 - external_epg: ext_epg_3 + template: Template4 + external_epg: ext_epg_4 route_reachability: site-ext state: present register: nm_add_ext_epg_site - name: Verify nm_add_ext_epg_site - assert: + ansible.builtin.assert: that: - - nm_add_ext_epg_site.current.externalEpgRef.externalEpgName == "ext_epg_3" + - nm_add_ext_epg_site.current.externalEpgRef.externalEpgName == "ext_epg_4" - nm_add_ext_epg_site.current.routeReachabilityInternetType == "site-ext" - name: Add external EPG to site again(normal mode) - mso_schema_site_external_epg: + cisco.mso.mso_schema_site_external_epg: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: 'azure_{{ mso_site | default("ansible_test") }}' - template: Template3 - external_epg: ext_epg_3 + template: Template4 + external_epg: ext_epg_4 route_reachability: site-ext state: present register: nm_add_ext_epg_site_again - name: Verify nm_add_ext_epg_site_again - assert: + ansible.builtin.assert: that: - nm_add_ext_epg_site_again is not changed - - nm_add_ext_epg_site_again.current.externalEpgRef.externalEpgName == "ext_epg_3" + - nm_add_ext_epg_site_again.current.externalEpgRef.externalEpgName == "ext_epg_4" - nm_add_ext_epg_site_again.current.routeReachabilityInternetType == "site-ext"
\ No newline at end of file diff --git a/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_external_epg_selector/tasks/main.yml b/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_external_epg_selector/tasks/main.yml index 3701ba781..49e821980 100644 --- a/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_external_epg_selector/tasks/main.yml +++ b/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_external_epg_selector/tasks/main.yml @@ -6,13 +6,13 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI MultiSite host, username and password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: mso_hostname, mso_username and mso_password.' when: mso_hostname is not defined or mso_username is not defined or mso_password is not defined # CLEAN ENVIRONMENT - name: Set vars - set_fact: + ansible.builtin.set_fact: mso_info: &mso_info host: '{{ mso_hostname }}' username: '{{ mso_username }}' @@ -23,13 +23,13 @@ output_level: '{{ mso_output_level | default("info") }}' - name: Query MSO version - mso_version: + cisco.mso.mso_version: <<: *mso_info state: query register: version - name: Ensure azure site exists - mso_site: + cisco.mso.mso_site: <<: *mso_info site: 'azure_{{ mso_site | default("ansible_test") }}' apic_username: '{{ azure_apic_username }}' @@ -40,7 +40,7 @@ state: present - name: Ensure aws site exists - mso_site: + cisco.mso.mso_site: <<: *mso_info site: 'aws_{{ mso_site | default("ansible_test") }}' apic_username: '{{ aws_apic_username }}' @@ -51,7 +51,7 @@ state: present - name: Remove schemas - mso_schema: + cisco.mso.mso_schema: <<: *mso_info schema: '{{ item }}' state: absent @@ -60,7 +60,7 @@ - '{{ mso_schema | default("ansible_test") }}' - name: Ensure sites removed from tenant ansible_test - mso_tenant_site: + cisco.mso.mso_tenant_site: <<: *mso_info tenant: ansible_test site: '{{ item }}' @@ -71,7 +71,7 @@ - 'azure_{{ mso_site | default("ansible_test") }}' - name: Ensure tenant ansible_test exist - mso_tenant: + cisco.mso.mso_tenant: <<: *mso_info tenant: ansible_test users: @@ -81,7 +81,7 @@ state: present - name: Associate aws site with ansible_test - mso_tenant_site: + cisco.mso.mso_tenant_site: <<: *mso_info tenant: ansible_test site: 'aws_{{ mso_site | default("ansible_test") }}' @@ -92,7 +92,7 @@ state: present - name: Associate azure site with ansible_test - mso_tenant_site: + cisco.mso.mso_tenant_site: <<: *mso_info tenant: ansible_test site: 'azure_{{ mso_site | default("ansible_test") }}' @@ -100,7 +100,7 @@ state: present - name: Ensure schema 1 with Template 1 and 2 exists - mso_schema_template: + cisco.mso.mso_schema_template: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' tenant: ansible_test @@ -111,7 +111,7 @@ - Template 2 - name: Ensure schema 2 with Template 3 exists - mso_schema_template: + cisco.mso.mso_schema_template: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}_2' tenant: ansible_test @@ -119,7 +119,7 @@ state: present - name: Ensure VRF1 exists - mso_schema_template_vrf: + cisco.mso.mso_schema_template_vrf: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -127,7 +127,7 @@ state: present - name: Ensure Template 1 with AP1 exists - mso_schema_template_anp: + cisco.mso.mso_schema_template_anp: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -135,7 +135,7 @@ state: present - name: Ensure L3Out Exists - mso_schema_template_l3out: + cisco.mso.mso_schema_template_l3out: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -145,7 +145,7 @@ state: present - name: Ensure External EPG1 exists - mso_schema_template_externalepg: + cisco.mso.mso_schema_template_externalepg: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -165,7 +165,7 @@ state: present - name: Ensure External EPG2 exists - mso_schema_template_externalepg: + cisco.mso.mso_schema_template_externalepg: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -185,7 +185,7 @@ state: present - name: Add Azure site to a schema - mso_schema_site: + cisco.mso.mso_schema_site: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: 'azure_{{ mso_site | default("ansible_test") }}' @@ -194,7 +194,7 @@ when: version.current.version is version('3', '<') - name: Add AWS site to a schema - mso_schema_site: + cisco.mso.mso_schema_site: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: 'aws_{{ mso_site | default("ansible_test") }}' @@ -203,7 +203,7 @@ when: version.current.version is version('3', '<') - name: Add a new CIDR in VRF1 at site level - mso_schema_site_vrf_region_cidr: &mso_present + cisco.mso.mso_schema_site_vrf_region_cidr: &mso_present <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -219,7 +219,7 @@ # ADD SELECTORS - name: Add a selector to Azure in check mode - mso_schema_site_external_epg_selector: + cisco.mso.mso_schema_site_external_epg_selector: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -235,7 +235,7 @@ register: cm_azure_e1 - name: Verify cm_azure_e1 - assert: + ansible.builtin.assert: that: - cm_azure_e1 is changed - cm_azure_e1.previous == {} @@ -244,7 +244,7 @@ - name: Add a selector to Azure in normal mode - mso_schema_site_external_epg_selector: + cisco.mso.mso_schema_site_external_epg_selector: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -259,7 +259,7 @@ register: nm_azure_e1 - name: Verify nm_azure_e1 - assert: + ansible.builtin.assert: that: - nm_azure_e1 is changed - nm_azure_e1.previous == {} @@ -267,7 +267,7 @@ - nm_azure_e1.current.subnets[0].name == 'e1' - name: Add a selector to AWS in normal mode - mso_schema_site_external_epg_selector: + cisco.mso.mso_schema_site_external_epg_selector: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -282,7 +282,7 @@ register: nm_aws_e2 - name: Verify nm_aws_e2 - assert: + ansible.builtin.assert: that: - nm_aws_e2 is changed - nm_aws_e2.previous == {} @@ -290,7 +290,7 @@ - nm_aws_e2.current.subnets[0].name == 'e2' - name: Add a selector to AWS in normal mode again - mso_schema_site_external_epg_selector: + cisco.mso.mso_schema_site_external_epg_selector: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -305,12 +305,12 @@ register: nm_aws_e1_again - name: Verify nm_aws_e1_again - assert: + ansible.builtin.assert: that: - nm_aws_e1_again is not changed - name: Add a selector to AWS in normal mode again with no expressions - mso_schema_site_external_epg_selector: + cisco.mso.mso_schema_site_external_epg_selector: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -322,14 +322,14 @@ register: nm_aws_e1_again_noexp - name: Verify nm_aws_e1_again_noexp - assert: + ansible.builtin.assert: that: - nm_aws_e1_again_noexp is not changed - nm_aws_e1_again_noexp.msg == "Missing expressions in selector" # QUERY A SELECTOR - name: Query a selector of Azure - mso_schema_site_external_epg_selector: + cisco.mso.mso_schema_site_external_epg_selector: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -340,13 +340,13 @@ register: query_azure_e1 - name: Verify query_azure_e1 - assert: + ansible.builtin.assert: that: - query_azure_e1 is not changed # QUERY ALL - name: Query all selectors of Azure - mso_schema_site_external_epg_selector: + cisco.mso.mso_schema_site_external_epg_selector: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -356,13 +356,13 @@ register: query_all - name: Verify query_all - assert: + ansible.builtin.assert: that: - query_all is not changed # REMOVE A SELECTOR - name: Remove a selector of Azure - mso_schema_site_external_epg_selector: + cisco.mso.mso_schema_site_external_epg_selector: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -373,12 +373,12 @@ register: remove_azure_e1 - name: Verify remove_azure_e1 - assert: + ansible.builtin.assert: that: - remove_azure_e1 is changed - name: Remove a selector of Azure again - mso_schema_site_external_epg_selector: + cisco.mso.mso_schema_site_external_epg_selector: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -390,13 +390,13 @@ register: remove_azure_e1_again - name: Verify remove_azure_e1_again - assert: + ansible.builtin.assert: that: - remove_azure_e1_again is not changed # QUERY REMOVED SELECTOR - name: Query a removed selector of Azure - mso_schema_site_external_epg_selector: + cisco.mso.mso_schema_site_external_epg_selector: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -408,13 +408,13 @@ register: query_removed_azure_e1 - name: Verify query_removed_azure_e1 - assert: + ansible.builtin.assert: that: - query_removed_azure_e1 is not changed # USE A NON-EXISTING SCHEMA - name: Non-existing schema for selector (check_mode) - mso_schema_site_external_epg_selector: + cisco.mso.mso_schema_site_external_epg_selector: <<: *mso_info schema: non_existing_schema site: 'aws_{{ mso_site | default("ansible_test") }}' @@ -425,7 +425,7 @@ register: cm_non_existing_schema - name: Non-existing schema for selector (normal_mode) - mso_schema_site_external_epg_selector: + cisco.mso.mso_schema_site_external_epg_selector: <<: *mso_info schema: non_existing_schema site: 'aws_{{ mso_site | default("ansible_test") }}' @@ -435,7 +435,7 @@ register: nm_non_existing_schema - name: Verify non_existing_schema - assert: + ansible.builtin.assert: that: - cm_non_existing_schema is not changed - nm_non_existing_schema is not changed @@ -444,7 +444,7 @@ # USE A NON-EXISTING TEMPLATE - name: Non-existing template for selector (check_mode) - mso_schema_site_external_epg_selector: + cisco.mso.mso_schema_site_external_epg_selector: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: 'aws_{{ mso_site | default("ansible_test") }}' @@ -455,7 +455,7 @@ register: cm_non_existing_template - name: Non-existing template for selector (normal_mode) - mso_schema_site_external_epg_selector: + cisco.mso.mso_schema_site_external_epg_selector: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: 'aws_{{ mso_site | default("ansible_test") }}' @@ -465,7 +465,7 @@ register: nm_non_existing_template - name: Verify non_existing_template - assert: + ansible.builtin.assert: that: - cm_non_existing_template is not changed - nm_non_existing_template is not changed @@ -474,7 +474,7 @@ # USE A NON-EXISTING SITE - name: Non-existing site for static port (check_mode) - mso_schema_site_external_epg_selector: + cisco.mso.mso_schema_site_external_epg_selector: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: 'azure_{{ mso_site | default("ansible_test") }}' @@ -485,7 +485,7 @@ register: cm_non_existing_site - name: Non-existing site for static port (normal_mode) - mso_schema_site_external_epg_selector: + cisco.mso.mso_schema_site_external_epg_selector: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: 'azure_{{ mso_site | default("ansible_test") }}' @@ -495,7 +495,7 @@ register: nm_non_existing_site - name: Verify non_existing_site - assert: + ansible.builtin.assert: that: - cm_non_existing_site is not changed - nm_non_existing_site is not changed @@ -505,7 +505,7 @@ # USE A TEMPLATE WITHOUT ANY SITE - name: Add site external EPG selector to Schema 2 Template 3 without any site associated (check mode) - mso_schema_site_external_epg_selector: + cisco.mso.mso_schema_site_external_epg_selector: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}_2' site: 'azure_{{ mso_site | default("ansible_test") }}' @@ -516,7 +516,7 @@ register: cm_no_site_associated - name: Add site external EPG selector to Template 3 without any site associated (normal mode) - mso_schema_site_external_epg_selector: + cisco.mso.mso_schema_site_external_epg_selector: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}_2' site: 'azure_{{ mso_site | default("ansible_test") }}' @@ -526,7 +526,7 @@ register: nm_no_site_associated - name: Verify cm_no_site_associated and nm_no_site_associated - assert: + ansible.builtin.assert: that: - cm_no_site_associated is not changed - nm_no_site_associated is not changed diff --git a/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_service_graph/tasks/l4_l7_devices.yml b/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_service_graph/tasks/l4_l7_devices.yml new file mode 100644 index 000000000..1d5585200 --- /dev/null +++ b/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_service_graph/tasks/l4_l7_devices.yml @@ -0,0 +1,237 @@ +# Test code for the MSO modules +# Copyright: (c) 2024, Sabari Jaganathan (@sajagana) <sajagana@cisco.com> + +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +- name: Test that we have an ACI MultiSite host, username and password + ansible.builtin.fail: + msg: "Please define the following variables: mso_hostname, mso_username and mso_password." + when: mso_hostname is not defined or mso_username is not defined or mso_password is not defined + +# CLEAN ENVIRONMENT +- name: Set vars + ansible.builtin.set_fact: + aci_info: &aci_info + host: "{{ apic_hostname }}" + username: "{{ apic_username }}" + password: "{{ apic_password }}" + validate_certs: "{{ apic_validate_certs | default(false) }}" + use_ssl: "{{ apic_use_ssl | default(true) }}" + use_proxy: "{{ apic_use_proxy | default(true) }}" + output_level: '{{ mso_output_level | default("info") }}' + +- name: Query system information + cisco.aci.aci_system: + <<: *aci_info + id: 1 + state: query + register: aci_version + +- name: Remove an existing tenant on APIC + cisco.aci.aci_tenant: + <<: *aci_info + name: ansible_test + state: absent + +- name: Add a tenant on APIC + cisco.aci.aci_tenant: + <<: *aci_info + name: ansible_test + +# Site type checking for L4-L7 Device configuration +# QUERY OBJECTS +- name: Query cloud provider object + cisco.aci.aci_cloud_provider: + <<: *aci_info + state: query + register: query_cloud + when: aci_version.current.0.topSystem.attributes.version is version('4.1', '>=') + +- name: Set vars + ansible.builtin.set_fact: + query_cloud: + current: [] + when: aci_version.current.0.topSystem.attributes.version is version('4.1', '<') + +- name: Verify query_cloud for all sites + ansible.builtin.assert: + that: + - query_cloud is not changed + +- name: Verify query_cloud for Cloud Sites + ansible.builtin.assert: + that: + - query_cloud is not changed + - query_cloud.current.0.cloudProvP.attributes.environment == "public-cloud" + - '"vendor" in query_cloud.current.0.cloudProvP.attributes' + when: + - query_cloud.current | length > 0 # This condition will execute only cloud sites + +# Cloud Site block +- name: Execute tasks only for cloud sites + when: + - query_cloud.current | length > 0 + - query_cloud.current.0.cloudProvP.attributes.vendor == "azure" + block: + - name: Add azure_vrf to the ansible_test + cisco.aci.aci_vrf: + <<: *aci_info + tenant: ansible_test + vrf: azure_vrf + + - name: Add azure_ctxprof to the ansible_test + cisco.aci.aci_cloud_ctx_profile: + <<: *aci_info + tenant: ansible_test + cloud: azure + name: azure_ctxprof + vrf: azure_vrf + region: westus2 + primary_cidr: "1.1.1.2/32" + state: present + + - name: Add the subnet to the azure_ctxprof + cisco.aci.aci_rest: + <<: *aci_info + path: api/mo/uni/tn-ansible_test/ctxprofile-azure_ctxprof/cidr-[1.1.1.2/32]/subnet-[1.1.1.2/32].json + method: post + content: + cloudSubnet: + attributes: + ip: 1.1.1.2/32 + name: azure_ctxprof_cidr + children: + - cloudRsZoneAttach: + attributes: + tDn: "uni/clouddomp/provp-azure/region-westus2/zone-default" + + - name: Add the ansible_test_adc device - ThirdParty_LB + cisco.aci.aci_rest: + <<: *aci_info + path: /api/node/mo/uni/tn-ansible_test/cld-ansible_test_adc.json + method: post + content: + cloudLDev: + attributes: + targetMode: unspecified + name: ansible_test_adc + svcType: ADC + children: + - cloudRsLDevToCtx: + attributes: + tDn: uni/tn-ansible_test/ctx-azure_vrf + - cloudLIf: + attributes: + allowAll: "yes" + name: TP_LB_Inf + children: + - cloudEPSelector: + attributes: + name: TP_LB_Inf_Selector + matchExpression: IP=='1.1.1.1' + + - name: Add the ansible_test_firewall1 device + cisco.aci.aci_rest: + <<: *aci_info + path: /api/node/mo/uni/tn-ansible_test/cld-ansible_test_firewall1.json + method: post + content: + cloudLDev: + attributes: + name: ansible_test_firewall1 + svcType: FW + children: + - cloudRsLDevToCtx: + attributes: + tDn: uni/tn-ansible_test/ctx-azure_vrf + - cloudLIf: + attributes: + allowAll: "yes" + name: TP_FW_Inf1 + children: + - cloudEPSelector: + attributes: + name: TP_FW_Inf_Selector + matchExpression: IP=='1.1.1.1' + + - name: Add the ansible_test_firewall2 device + cisco.aci.aci_rest: + <<: *aci_info + path: /api/node/mo/uni/tn-ansible_test/cld-ansible_test_firewall2.json + method: post + content: + cloudLDev: + attributes: + name: ansible_test_firewall2 + svcType: FW + children: + - cloudRsLDevToCtx: + attributes: + tDn: uni/tn-ansible_test/ctx-azure_vrf + - cloudLIf: + attributes: + allowAll: "yes" + name: TP_FW_Inf2 + children: + - cloudEPSelector: + attributes: + name: TP_FW_Inf_Selector + matchExpression: IP=='1.1.1.1' + + - name: Add the ansible_test_other device + cisco.aci.aci_rest: + <<: *aci_info + path: /api/node/mo/uni/tn-ansible_test/clb-ansible_test_other.json + method: post + content: + cloudLB: + attributes: + name: ansible_test_other + type: network + children: + - cloudRsLDevToCloudSubnet: + attributes: + tDn: "uni/tn-ansible_test/ctxprofile-azure_ctxprof/cidr-[1.1.1.2/32]/subnet-[1.1.1.2/32]" + + - name: Add the ansible_test_app_lb device + cisco.aci.aci_rest: + <<: *aci_info + path: /api/node/mo/uni/tn-ansible_test/clb-ansible_test_app_lb.json + method: post + content: + cloudLB: + attributes: + name: ansible_test_app_lb + type: application + children: + - cloudRsLDevToCloudSubnet: + attributes: + tDn: "uni/tn-ansible_test/ctxprofile-azure_ctxprof/cidr-[1.1.1.2/32]/subnet-[1.1.1.2/32]" + +- name: Execute tasks only for non-cloud sites + when: query_cloud.current | length == 0 # Non-Cloud Site block + block: + - name: Add devices to APIC + cisco.aci.aci_rest: + <<: *aci_info + path: /api/node/mo/uni/tn-ansible_test.json + method: post + content: + vnsLDevVip: + attributes: + svcType: "{{ item.type }}" + managed: "false" + name: "{{ item.name }}" + children: + - vnsCDev: + attributes: + name: "{{ item.name }}" + loop: + - type: FW + name: ansible_test_firewall1 + - type: FW + name: ansible_test_firewall2 + - type: ADC + name: ansible_test_adc + - type: OTHERS + name: ansible_test_other diff --git a/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_service_graph/tasks/main.yml b/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_service_graph/tasks/main.yml index a9b60bab6..369fde0b7 100644 --- a/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_service_graph/tasks/main.yml +++ b/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_service_graph/tasks/main.yml @@ -4,25 +4,32 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI MultiSite host, username and password - fail: - msg: 'Please define the following variables: mso_hostname, mso_username and mso_password.' + ansible.builtin.fail: + msg: "Please define the following variables: mso_hostname, mso_username and mso_password." when: mso_hostname is not defined or mso_username is not defined or mso_password is not defined - # CLEAN ENVIRONMENT - name: Set vars - set_fact: + ansible.builtin.set_fact: mso_info: &mso_info - host: '{{ mso_hostname }}' - username: '{{ mso_username }}' - password: '{{ mso_password }}' - validate_certs: '{{ mso_validate_certs | default(false) }}' - use_ssl: '{{ mso_use_ssl | default(true) }}' - use_proxy: '{{ mso_use_proxy | default(false) }}' + host: "{{ mso_hostname }}" + username: "{{ mso_username }}" + password: "{{ mso_password }}" + validate_certs: "{{ mso_validate_certs | default(false) }}" + use_ssl: "{{ mso_use_ssl | default(true) }}" + use_proxy: "{{ mso_use_proxy | default(false) }}" + output_level: '{{ mso_output_level | default("info") }}' + aci_info: &aci_info + host: "{{ apic_hostname }}" + username: "{{ apic_username }}" + password: "{{ apic_password }}" + validate_certs: "{{ apic_validate_certs | default(false) }}" + use_ssl: "{{ apic_use_ssl | default(true) }}" + use_proxy: "{{ apic_use_proxy | default(true) }}" output_level: '{{ mso_output_level | default("info") }}' - name: Query MSO version - mso_version: + cisco.mso.mso_version: <<: *mso_info state: query register: version @@ -32,764 +39,1161 @@ - name: Execute tasks only for MSO version >= 3.3 when: version.current.version is version('3.3', '>=') block: - - name: Ensure site exists - cisco.mso.mso_site: - <<: *mso_info - site: '{{ mso_site | default("ansible_test") }}' - apic_username: '{{ apic_username }}' - apic_password: '{{ apic_password }}' - apic_site_id: '{{ apic_site_id | default(101) }}' - urls: - - https://{{ apic_hostname }} - state: present - ignore_errors: true - - - name: Remove schemas - cisco.mso.mso_schema: - <<: *mso_info - schema: '{{ mso_schema | default("ansible_test") }}' - state: absent - - - name: Ensure sites removed from tenant ansible_test - mso_tenant_site: - <<: *mso_info - tenant: ansible_test - site: '{{ item }}' - state: absent - loop: - - '{{ mso_site | default("ansible_test") }}' - - 'aws_{{ mso_site | default("ansible_test") }}' - - 'azure_{{ mso_site | default("ansible_test") }}' - - - name: Ensure tenant ansible_test exist - cisco.mso.mso_tenant: - <<: *mso_info - tenant: ansible_test - users: - - '{{ mso_username }}' - state: present - - - name: Associate site with ansible_test - cisco.mso.mso_tenant_site: - <<: *mso_info - tenant: ansible_test - site: '{{ mso_site | default("ansible_test") }}' - state: present - - - name: Add a tenant on APIC - cisco.aci.aci_tenant: - host: '{{ apic_hostname }}' - username: '{{ apic_username }}' - password: '{{ apic_password }}' - validate_certs: no - name: "ansible_test" - - - name: Add devices to APIC - cisco.aci.aci_rest: - host: '{{ apic_hostname }}' - username: '{{ apic_username }}' - password: '{{ apic_password }}' - validate_certs: no - path: /api/node/mo/uni/tn-ansible_test.json - method: post - content: - vnsLDevVip: - attributes: - svcType: '{{ item.type }}' - managed: 'false' - name: '{{ item.name }}' - children: - - vnsCDev: - attributes: - name: '{{ item.name }}' - loop: - - { type: FW, name: ansible_test_firewall1 } - - { type: FW, name: ansible_test_firewall2 } - - { type: ADC, name: ansible_test_adc } - - { type: OTHERS, name: ansible_test_other } - - - name: Ensure schema 1 with Template1 and 2 exist - cisco.mso.mso_schema_template: - <<: *mso_info - schema: '{{ mso_schema | default("ansible_test") }}' - tenant: ansible_test - template: '{{ item }}' - state: present - loop: - - 'Template1' - - 'Template2' - - - name: Ensure schema 2 with Template1 exists - cisco.mso.mso_schema_template: - <<: *mso_info - schema: '{{ mso_schema | default("ansible_test") }}_2' - tenant: ansible_test - template: Template1 - state: present - - - name: Add Node1 - cisco.mso.mso_service_node_type: - <<: *mso_info - name: ansible_test_other1 - display_name: ansible_test_other1 - state: present - - - name: Add Node2 - cisco.mso.mso_service_node_type: - <<: *mso_info - name: ansible_test_other2 - display_name: ansible_test_other2 - state: present - - - name: Create a service graph 1 at Template level - cisco.mso.mso_schema_template_service_graph: - <<: *mso_info - schema: '{{ mso_schema | default("ansible_test") }}' - template: Template1 - service_graph: SG1 - display_name: sg1 - service_nodes: - - type: firewall - filter_after_first_node: allow_all - state: present - - - name: Create service graph 2 at Template level - cisco.mso.mso_schema_template_service_graph: - <<: *mso_info - schema: '{{ mso_schema | default("ansible_test") }}' - template: Template1 - service_graph: SG2 - display_name: sg2 - service_nodes: - - type: firewall - - type: load-balancer - filter_after_first_node: allow_all - state: present - register: sg1_again - - - name: Create service graph 3 at Template level - cisco.mso.mso_schema_template_service_graph: - <<: *mso_info - schema: '{{ mso_schema | default("ansible_test") }}' - template: Template1 - service_graph: SG3 - display_name: sg3 - service_nodes: - - type: firewall - - type: load-balancer - - type: other - filter_after_first_node: allow_all - state: present - register: sg1_again - - - name: Create a service graph 4 at Template level - cisco.mso.mso_schema_template_service_graph: - <<: *mso_info - schema: '{{ mso_schema | default("ansible_test") }}' - template: Template1 - service_graph: SG4 - display_name: sg4 - service_nodes: - - type: other - - type: load-balancer - - type: firewall - filter_after_first_node: filters_from_contract - state: present - - - name: Create a service graph 5 at Template level - cisco.mso.mso_schema_template_service_graph: - <<: *mso_info - schema: '{{ mso_schema | default("ansible_test") }}' - template: Template1 - service_graph: SG5 - display_name: sg5 - service_nodes: - - type: other - - type: firewall - - type: firewall - filter_after_first_node: filters_from_contract - state: present - - - name: Create a service graph 6 at Template level - cisco.mso.mso_schema_template_service_graph: - <<: *mso_info - schema: '{{ mso_schema | default("ansible_test") }}' - template: Template1 - service_graph: SG6 - display_name: sg6 - service_nodes: - - type: other - - type: other - - type: other - filter_after_first_node: filters_from_contract - state: present - - - name: Create a service graph 7 at Template level - cisco.mso.mso_schema_template_service_graph: - <<: *mso_info - schema: '{{ mso_schema | default("ansible_test") }}' - template: Template1 - service_graph: SG7 - display_name: sg7 - service_nodes: - - type: load-balancer - - type: load-balancer - filter_after_first_node: filters_from_contract - state: present - - - name: Add physical site to a schema - cisco.mso.mso_schema_site: - <<: *mso_info - schema: '{{ mso_schema | default("ansible_test") }}' - site: '{{ mso_site | default("ansible_test") }}' - template: Template1 - state: present - - - name: Add a new Graph at site level (check mode) - cisco.mso.mso_schema_site_service_graph: - <<: *mso_info - schema: '{{ mso_schema | default("ansible_test") }}' - template: Template1 - service_graph: SG1 - site: '{{ mso_site | default("ansible_test") }}' - tenant: ansible_test - devices: - - name: ansible_test_firewall1 - state: present - register: cm_sg1 - check_mode: true - - - name: Verify cm_sg1 - assert: - that: - - cm_sg1 is changed - - cm_sg1.current.serviceGraphRef.serviceGraphName == "SG1" - - cm_sg1.current.serviceGraphRef.templateName == "Template1" - - cm_sg1.current.serviceNodes | length == 1 - - cm_sg1.current.serviceNodes.0.device.dn == "uni/tn-ansible_test/lDevVip-ansible_test_firewall1" - - - name: Add a new Graph SG1 at site level (normal mode) - cisco.mso.mso_schema_site_service_graph: - <<: *mso_info - schema: '{{ mso_schema | default("ansible_test") }}' - template: Template1 - service_graph: SG1 - site: '{{ mso_site | default("ansible_test") }}' - tenant: ansible_test - devices: - - name: ansible_test_firewall1 - state: present - register: nm_sg1 - - - name: Verify change_sg1 - assert: - that: - - nm_sg1 is changed - - nm_sg1.current.serviceGraphRef.serviceGraphName == "SG1" - - nm_sg1.current.serviceGraphRef.templateName == "Template1" - - nm_sg1.current.serviceNodes | length == 1 - - nm_sg1.current.serviceNodes.0.device.dn == "uni/tn-ansible_test/lDevVip-ansible_test_firewall1" - - - name: Add Graph SG1 at site level again - cisco.mso.mso_schema_site_service_graph: - <<: *mso_info - schema: '{{ mso_schema | default("ansible_test") }}' - template: Template1 - service_graph: SG1 - site: '{{ mso_site | default("ansible_test") }}' - tenant: ansible_test - devices: - - name: ansible_test_firewall1 - state: present - register: nm_sg1_again - - - name: Verify change_sg1 - assert: - that: - - nm_sg1_again is not changed - - nm_sg1_again.current.serviceGraphRef.serviceGraphName == "SG1" - - nm_sg1_again.current.serviceGraphRef.templateName == "Template1" - - nm_sg1_again.current.serviceNodes | length == 1 - - nm_sg1_again.current.serviceNodes.0.device.dn == "uni/tn-ansible_test/lDevVip-ansible_test_firewall1" - - - name: Change service graph SG1 at site level - cisco.mso.mso_schema_site_service_graph: - <<: *mso_info - schema: '{{ mso_schema | default("ansible_test") }}' - template: Template1 - service_graph: SG1 - site: '{{ mso_site | default("ansible_test") }}' - tenant: ansible_test - devices: - - name: ansible_test_firewall2 - state: present - register: change_sg1 - - - name: Verify change_sg1 - assert: - that: - - change_sg1 is changed - - change_sg1.current.serviceGraphRef.serviceGraphName == "SG1" - - change_sg1.current.serviceGraphRef.templateName == "Template1" - - change_sg1.current.serviceNodes | length == 1 - - change_sg1.current.serviceNodes.0.device.dn == "uni/tn-ansible_test/lDevVip-ansible_test_firewall2" - - - name: Add a new Graph SG2 at site level - cisco.mso.mso_schema_site_service_graph: - <<: *mso_info - schema: '{{ mso_schema | default("ansible_test") }}' - template: Template1 - service_graph: SG2 - site: '{{ mso_site | default("ansible_test") }}' - tenant: ansible_test - devices: - - name: ansible_test_firewall1 - - name: ansible_test_adc - state: present - register: sg2 - - - name: Verify sg2 - assert: - that: - - sg2 is changed - - sg2.current.serviceGraphRef.serviceGraphName == "SG2" - - sg2.current.serviceGraphRef.templateName == "Template1" - - sg2.current.serviceNodes | length == 2 - - sg2.current.serviceNodes.0.device.dn == "uni/tn-ansible_test/lDevVip-ansible_test_firewall1" - - sg2.current.serviceNodes.1.device.dn == "uni/tn-ansible_test/lDevVip-ansible_test_adc" - - - name: Add a new Graph SG3 at site level - cisco.mso.mso_schema_site_service_graph: - <<: *mso_info - schema: '{{ mso_schema | default("ansible_test") }}' - template: Template1 - service_graph: SG3 - site: '{{ mso_site | default("ansible_test") }}' - tenant: ansible_test - devices: - - name: ansible_test_firewall1 - - name: ansible_test_adc - - name: ansible_test_other - state: present - register: sg3 - - - name: Verify sg3 - assert: - that: - - sg3 is changed - - sg3.current.serviceGraphRef.serviceGraphName == "SG3" - - sg3.current.serviceGraphRef.templateName == "Template1" - - sg3.current.serviceNodes | length == 3 - - sg3.current.serviceNodes.0.device.dn == "uni/tn-ansible_test/lDevVip-ansible_test_firewall1" - - sg3.current.serviceNodes.1.device.dn == "uni/tn-ansible_test/lDevVip-ansible_test_adc" - - sg3.current.serviceNodes.2.device.dn == "uni/tn-ansible_test/lDevVip-ansible_test_other" - - - name: Add a new Graph SG4 at site level - cisco.mso.mso_schema_site_service_graph: - <<: *mso_info - schema: '{{ mso_schema | default("ansible_test") }}' - template: Template1 - service_graph: SG4 - site: '{{ mso_site | default("ansible_test") }}' - tenant: ansible_test - devices: - - name: ansible_test_other - - name: ansible_test_adc - - name: ansible_test_firewall1 - state: present - register: sg4 - - - name: Verify sg4 - assert: - that: - - sg4 is changed - - sg4.current.serviceGraphRef.serviceGraphName == "SG4" - - sg4.current.serviceGraphRef.templateName == "Template1" - - sg4.current.serviceNodes | length == 3 - - sg4.current.serviceNodes.0.device.dn == "uni/tn-ansible_test/lDevVip-ansible_test_other" - - sg4.current.serviceNodes.1.device.dn == "uni/tn-ansible_test/lDevVip-ansible_test_adc" - - sg4.current.serviceNodes.2.device.dn == "uni/tn-ansible_test/lDevVip-ansible_test_firewall1" - - - name: Change Graph SG4 at site level - cisco.mso.mso_schema_site_service_graph: - <<: *mso_info - schema: '{{ mso_schema | default("ansible_test") }}' - template: Template1 - service_graph: SG4 - site: '{{ mso_site | default("ansible_test") }}' - tenant: ansible_test - devices: - - name: ansible_test_other - - name: ansible_test_adc - - name: ansible_test_firewall2 - state: present - register: change1_sg4 - - - name: Verify change1_sg4 - assert: - that: - - change1_sg4 is changed - - change1_sg4.current.serviceGraphRef.serviceGraphName == "SG4" - - change1_sg4.current.serviceGraphRef.templateName == "Template1" - - change1_sg4.current.serviceNodes | length == 3 - - change1_sg4.current.serviceNodes.0.device.dn == "uni/tn-ansible_test/lDevVip-ansible_test_other" - - change1_sg4.current.serviceNodes.1.device.dn == "uni/tn-ansible_test/lDevVip-ansible_test_adc" - - change1_sg4.current.serviceNodes.2.device.dn == "uni/tn-ansible_test/lDevVip-ansible_test_firewall2" - - - name: Change Graph SG4 at site level - cisco.mso.mso_schema_site_service_graph: - <<: *mso_info - schema: '{{ mso_schema | default("ansible_test") }}' - template: Template1 - service_graph: SG4 - site: '{{ mso_site | default("ansible_test") }}' - tenant: ansible_test - devices: - - name: ansible_test_other - state: present - ignore_errors: true - register: change2_sg4 - - - name: Verify change2_sg4 - assert: - that: - - change2_sg4 is not changed - - change2_sg4.msg == "Service Graph 'SG4' has '3' service node type(s) but '1' service node(s) were given for the service graph" - - - name: Change Graph SG4 at site level - cisco.mso.mso_schema_site_service_graph: - <<: *mso_info - schema: '{{ mso_schema | default("ansible_test") }}' - template: Template1 - service_graph: SG4 - site: '{{ mso_site | default("ansible_test") }}' - tenant: ansible_test - devices: - - name: ansible_test_adc - state: present - ignore_errors: true - register: change3_sg4 - - - name: Verify change3_sg4 - assert: - that: - - change3_sg4 is not changed - - change3_sg4.msg == "Service Graph 'SG4' has '3' service node type(s) but '1' service node(s) were given for the service graph" - - - name: Change Graph SG4 at site level - cisco.mso.mso_schema_site_service_graph: - <<: *mso_info - schema: '{{ mso_schema | default("ansible_test") }}' - template: Template1 - service_graph: SG4 - site: '{{ mso_site | default("ansible_test") }}' - tenant: ansible_test - devices: - - name: ansible_test_firewall1 - state: present - ignore_errors: true - register: change4_sg4 - - - name: Verify change4_sg4 - assert: - that: - - change4_sg4 is not changed - - change4_sg4.msg == "Service Graph 'SG4' has '3' service node type(s) but '1' service node(s) were given for the service graph" - - - name: Change Graph SG4 at site level - cisco.mso.mso_schema_site_service_graph: - <<: *mso_info - schema: '{{ mso_schema | default("ansible_test") }}' - template: Template1 - service_graph: SG4 - site: '{{ mso_site | default("ansible_test") }}' - tenant: ansible_test - devices: - - name: ansible_test_other - - name: ansible_test_adc - state: present - ignore_errors: true - register: change5_sg4 - - - name: Verify change5_sg4 - assert: - that: - - change5_sg4 is not changed - - change5_sg4.msg == "Service Graph 'SG4' has '3' service node type(s) but '2' service node(s) were given for the service graph" - - - name: Change Graph SG4 at site level - cisco.mso.mso_schema_site_service_graph: - <<: *mso_info - schema: '{{ mso_schema | default("ansible_test") }}' - template: Template1 - service_graph: SG4 - site: '{{ mso_site | default("ansible_test") }}' - tenant: ansible_test - devices: - - name: ansible_test_other - - name: ansible_test_other - - name: ansible_test_adc - state: present - ignore_errors: true - register: change6_sg4 - - - name: Verify change6_sg4 - assert: - that: - - change6_sg4 is not changed - - change6_sg4.msg == "Provided device 'ansible_test_other' of type 'ADC' does not exist." - - - name: Add Graph SG5 at site level - cisco.mso.mso_schema_site_service_graph: - <<: *mso_info - schema: '{{ mso_schema | default("ansible_test") }}' - template: Template1 - service_graph: SG5 - site: '{{ mso_site | default("ansible_test") }}' - tenant: ansible_test - devices: - - name: ansible_test_other - - name: ansible_test_firewall1 - - name: ansible_test_firewall1 - state: present - register: sg5 - - - name: Verify sg5 - assert: - that: - - sg5 is changed - - sg5.current.serviceGraphRef.serviceGraphName == "SG5" - - sg5.current.serviceGraphRef.templateName == "Template1" - - sg5.current.serviceNodes | length == 3 - - sg5.current.serviceNodes.0.device.dn == "uni/tn-ansible_test/lDevVip-ansible_test_other" - - sg5.current.serviceNodes.1.device.dn == "uni/tn-ansible_test/lDevVip-ansible_test_firewall1" - - sg5.current.serviceNodes.2.device.dn == "uni/tn-ansible_test/lDevVip-ansible_test_firewall1" - - - name: Add Graph SG6 at site level - cisco.mso.mso_schema_site_service_graph: - <<: *mso_info - schema: '{{ mso_schema | default("ansible_test") }}' - template: Template1 - service_graph: SG6 - site: '{{ mso_site | default("ansible_test") }}' - tenant: ansible_test - devices: - - name: ansible_test_other - - name: ansible_test_other - - name: ansible_test_other - state: present - register: sg6 - - - name: Verify sg6 - assert: - that: - - sg6 is changed - - sg6.current.serviceGraphRef.serviceGraphName == "SG6" - - sg6.current.serviceGraphRef.templateName == "Template1" - - sg6.current.serviceNodes | length == 3 - - sg6.current.serviceNodes.0.device.dn == "uni/tn-ansible_test/lDevVip-ansible_test_other" - - sg6.current.serviceNodes.1.device.dn == "uni/tn-ansible_test/lDevVip-ansible_test_other" - - sg6.current.serviceNodes.2.device.dn == "uni/tn-ansible_test/lDevVip-ansible_test_other" - - - name: Add Graph SG7 at site level - cisco.mso.mso_schema_site_service_graph: - <<: *mso_info - schema: '{{ mso_schema | default("ansible_test") }}' - template: Template1 - service_graph: SG7 - site: '{{ mso_site | default("ansible_test") }}' - tenant: ansible_test - devices: - - name: ansible_test_adc - - name: ansible_test_adc - state: present - register: sg7 - - - name: Verify sg7 - assert: - that: - - sg7 is changed - - sg7.current.serviceGraphRef.serviceGraphName == "SG7" - - sg7.current.serviceGraphRef.templateName == "Template1" - - sg7.current.serviceNodes | length == 2 - - sg7.current.serviceNodes.0.device.dn == "uni/tn-ansible_test/lDevVip-ansible_test_adc" - - sg7.current.serviceNodes.1.device.dn == "uni/tn-ansible_test/lDevVip-ansible_test_adc" - - - name: Query service graph SG at site level - cisco.mso.mso_schema_site_service_graph: - <<: *mso_info - schema: '{{ mso_schema | default("ansible_test") }}' - template: Template1 - service_graph: SG1 - site: '{{ mso_site | default("ansible_test") }}' - tenant: ansible_test - state: query - register: query_sg - - - name: Verify query_sg - assert: - that: - - query_sg is not changed - - query_sg.current.serviceGraphRef is match("/schemas/[0-9a-zA-Z]*/templates/Template1/serviceGraphs/SG1") - - - name: Query all service graphs at site level - cisco.mso.mso_schema_site_service_graph: - <<: *mso_info - schema: '{{ mso_schema | default("ansible_test") }}' - template: Template1 - site: '{{ mso_site | default("ansible_test") }}' - tenant: ansible_test - state: query - register: query_all - - - name: Verify query_all - assert: - that: - - query_all is not changed - - query_all.current | length == 7 - - - name: Query non_existing service graph at site level - cisco.mso.mso_schema_site_service_graph: - <<: *mso_info - schema: '{{ mso_schema | default("ansible_test") }}' - template: Template1 - site: '{{ mso_site | default("ansible_test") }}' - service_graph: non_existent - tenant: ansible_test - state: query - ignore_errors: true - register: query_non_existing_sg - - - name: Verify query_non_existing_sg - assert: - that: - - query_non_existing_sg.msg == "Service Graph 'non_existent' not found" - - - name: Use non_existing schema - cisco.mso.mso_schema_site_service_graph: - <<: *mso_info - schema: non_existing_schema - template: Template1 - service_graph: SG - tenant: ansible_test - site: '{{ mso_site | default("ansible_test") }}' - state: query - ignore_errors: true - register: query_non_existing_schema - - - name: Verify non_existing_schema - assert: - that: - - query_non_existing_schema is not changed - - query_non_existing_schema.msg == "Provided schema 'non_existing_schema' does not exist." - - - name: Use non_existing template - cisco.mso.mso_schema_site_service_graph: - <<: *mso_info - schema: '{{ mso_schema | default("ansible_test") }}' - template: non_existing_template - service_graph: SG - tenant: ansible_test - site: '{{ mso_site | default("ansible_test") }}' - state: query - ignore_errors: true - register: query_non_existing_template - - - name: Verify query_non_existing_template - assert: - that: - - query_non_existing_template.msg == "Provided template 'non_existing_template' does not exist. Existing templates{{':'}} Template1, Template2" - - - name: Use non_existing_site_template - cisco.mso.mso_schema_site_service_graph: - <<: *mso_info - schema: '{{ mso_schema | default("ansible_test") }}' - site: '{{ mso_site | default("ansible_test") }}' - service_graph: SG - template: Template2 - tenant: ansible_test - state: query - ignore_errors: true - register: nm_non_existing_site_template - - - name: Verify cm_non_existing_site_template and nm_non_existing_site_template - assert: - that: - - nm_non_existing_site_template is not changed - - nm_non_existing_site_template.msg == "Provided site-template association 'ansible_test-Template2' does not exist." - - - name: Add site Service Graph to Template2 without any site association - cisco.mso.mso_schema_site_service_graph: - <<: *mso_info - schema: '{{ mso_schema | default("ansible_test") }}_2' - site: '{{ mso_site | default("ansible_test") }}' - template: Template1 - service_graph: SG1 - tenant: ansible_test - devices: - - name: ansible_test_firewall2 - state: present - ignore_errors: true - register: nm_no_site_associated - - - name: Verify nm_no_site_associated - assert: - that: - - nm_no_site_associated is not changed - - nm_no_site_associated.msg == "No site associated with template 'Template1'. Associate the site with the template using mso_schema_site." - - - name: Remove service graph from site level(check mode) - cisco.mso.mso_schema_site_service_graph: - <<: *mso_info - schema: '{{ mso_schema | default("ansible_test") }}' - template: Template1 - service_graph: SG1 - site: '{{ mso_site | default("ansible_test") }}' - tenant: ansible_test - state: absent - register: rm_sg_cm - check_mode: true - - - name: Verify rm_sg_cm - assert: - that: - - rm_sg_cm is changed - - rm_sg_cm.current == {} - - rm_sg_cm.previous.serviceGraphRef is match("/schemas/[0-9a-zA-Z]*/templates/Template1/serviceGraphs/SG1") - - - name: Remove service graph from site level (normal mode) - cisco.mso.mso_schema_site_service_graph: - <<: *mso_info - schema: '{{ mso_schema | default("ansible_test") }}' - template: Template1 - service_graph: SG1 - tenant: ansible_test - site: '{{ mso_site | default("ansible_test") }}' - state: absent - register: rm_sg - - - name: Verify rm_sg - assert: - that: - - rm_sg is changed - - rm_sg.current == {} - - rm_sg.previous.serviceGraphRef is match("/schemas/[0-9a-zA-Z]*/templates/Template1/serviceGraphs/SG1") - - - name: Remove service graph again - cisco.mso.mso_schema_site_service_graph: - <<: *mso_info - schema: '{{ mso_schema | default("ansible_test") }}' - template: Template1 - service_graph: SG1 - tenant: ansible_test - site: '{{ mso_site | default("ansible_test") }}' - state: absent - register: rm_sg_again - - - name: Verify rm_sg_again - assert: - that: - - rm_sg_again is not changed - - rm_sg_again.current == {} - - rm_sg_again.previous == {} - when: version.current.version is version('4.0', '<') # no change in NDO4.0 because site will already be present when template is defined + - name: Ensure site exists + cisco.mso.mso_site: + <<: *mso_info + site: '{{ mso_site | default("ansible_test") }}' + apic_username: "{{ apic_username }}" + apic_password: "{{ apic_password }}" + apic_site_id: "{{ apic_site_id | default(101) }}" + urls: + - https://{{ apic_hostname }} + state: present + ignore_errors: true + + - name: Remove schemas + cisco.mso.mso_schema: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + state: absent + + - name: Ensure sites removed from tenant ansible_test + cisco.mso.mso_tenant_site: + <<: *mso_info + tenant: ansible_test + site: "{{ item }}" + state: absent + loop: + - '{{ mso_site | default("ansible_test") }}' + - 'aws_{{ mso_site | default("ansible_test") }}' + - 'azure_{{ mso_site | default("ansible_test") }}' + - '{{ mso_site | default("azure_ansible_test_2") }}' + ignore_errors: true + + - name: Ensure tenant ansible_test exist + cisco.mso.mso_tenant: + <<: *mso_info + tenant: ansible_test + users: + - "{{ mso_username }}" + state: present + + - name: Set ansible_network_os to cisco.aci.aci and ansible_connection to local + ansible.builtin.set_fact: + ansible_connection: local + ansible_network_os: cisco.aci.aci + + - name: Reset the ansible_connection to access the APIC + ansible.builtin.meta: reset_connection + + - name: Include tasks for L4-L7 devices + ansible.builtin.include_tasks: l4_l7_devices.yml + + - name: Set ansible_network_os to cisco.nd.nd and ansible_connection to ansible.netcommon.httpapi + ansible.builtin.set_fact: + ansible_connection: ansible.netcommon.httpapi + ansible_network_os: cisco.nd.nd + + - name: Reset the ansible_connection to access the MSO/NDO + ansible.builtin.meta: reset_connection + + - name: Associate site with ansible_test + cisco.mso.mso_tenant_site: + <<: *mso_info + tenant: ansible_test + site: '{{ mso_site | default("ansible_test") }}' + state: present + when: + - query_cloud.current | length == 0 + + - name: Associate Azure site with ansible_test # Azure Task + cisco.mso.mso_tenant_site: + <<: *mso_info + tenant: ansible_test + site: azure_ansible_test_2 + cloud_account: "uni/tn-{{ mso_tenant | default('ansible_test') }}/act-[{{ azure_cloud_account | default(123) }}]-vendor-azure" + state: present + when: + - query_cloud.current | length > 0 + - query_cloud.current.0.cloudProvP.attributes.vendor == "azure" + + - name: Ensure schema 1 with Template1, 2 and 3 exist + cisco.mso.mso_schema_template: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + tenant: ansible_test + template: "{{ item }}" + state: present + loop: + - "Template1" + - "Template2" + - "Template3" # Azure Task + + - name: Ensure schema 2 with Template1 exists + cisco.mso.mso_schema_template: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}_2' + tenant: ansible_test + template: Template1 + state: present + + - name: Add Node1 + cisco.mso.mso_service_node_type: + <<: *mso_info + name: ansible_test_other1 + display_name: ansible_test_other1 + state: present + + - name: Add Node2 + cisco.mso.mso_service_node_type: + <<: *mso_info + name: ansible_test_other2 + display_name: ansible_test_other2 + state: present + + - name: Create a service graph 1 at Template level + cisco.mso.mso_schema_template_service_graph: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template1 + service_graph: SG1 + display_name: sg1 + service_nodes: + - type: firewall + filter_after_first_node: allow_all + state: present + + - name: Create service graph 2 at Template level + cisco.mso.mso_schema_template_service_graph: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template1 + service_graph: SG2 + display_name: sg2 + service_nodes: + - type: firewall + - type: load-balancer + filter_after_first_node: allow_all + state: present + register: sg1_again + + - name: Create service graph 3 at Template level + cisco.mso.mso_schema_template_service_graph: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template1 + service_graph: SG3 + display_name: sg3 + service_nodes: + - type: firewall + - type: load-balancer + - type: other + filter_after_first_node: allow_all + state: present + register: sg1_again + + - name: Create a service graph 4 at Template level + cisco.mso.mso_schema_template_service_graph: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template1 + service_graph: SG4 + display_name: sg4 + service_nodes: + - type: other + - type: load-balancer + - type: firewall + filter_after_first_node: filters_from_contract + state: present + + - name: Create a service graph 5 at Template level + cisco.mso.mso_schema_template_service_graph: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template1 + service_graph: SG5 + display_name: sg5 + service_nodes: + - type: other + - type: firewall + - type: firewall + filter_after_first_node: filters_from_contract + state: present + + - name: Create a service graph 6 at Template level + cisco.mso.mso_schema_template_service_graph: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template1 + service_graph: SG6 + display_name: sg6 + service_nodes: + - type: other + - type: other + - type: other + filter_after_first_node: filters_from_contract + state: present + + - name: Create a service graph 7 at Template level + cisco.mso.mso_schema_template_service_graph: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template1 + service_graph: SG7 + display_name: sg7 + service_nodes: + - type: load-balancer + - type: load-balancer + filter_after_first_node: filters_from_contract + state: present + + - name: Add physical site to a schema + cisco.mso.mso_schema_site: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: '{{ mso_site | default("ansible_test") }}' + template: Template1 + state: present + + - name: Add a new Graph at site level (check mode) + cisco.mso.mso_schema_site_service_graph: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template1 + service_graph: SG1 + site: '{{ mso_site | default("ansible_test") }}' + tenant: ansible_test + devices: + - name: ansible_test_firewall1 + state: present + register: cm_sg1 + check_mode: true + + - name: Verify cm_sg1 + ansible.builtin.assert: + that: + - cm_sg1 is changed + - cm_sg1.current.serviceGraphRef.serviceGraphName == "SG1" + - cm_sg1.current.serviceGraphRef.templateName == "Template1" + - cm_sg1.current.serviceNodes | length == 1 + - cm_sg1.current.serviceNodes.0.device.dn is match("uni/tn-ansible_test/(lDevVip|clb|cld)-ansible_test_firewall1") + + - name: Add a new Graph SG1 at site level (normal mode) + cisco.mso.mso_schema_site_service_graph: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template1 + service_graph: SG1 + site: '{{ mso_site | default("ansible_test") }}' + tenant: ansible_test + devices: + - name: ansible_test_firewall1 + state: present + register: nm_sg1 + + - name: Verify change_sg1 + ansible.builtin.assert: + that: + - nm_sg1 is changed + - nm_sg1.current.serviceGraphRef.serviceGraphName == "SG1" + - nm_sg1.current.serviceGraphRef.templateName == "Template1" + - nm_sg1.current.serviceNodes | length == 1 + - nm_sg1.current.serviceNodes.0.device.dn is match("uni/tn-ansible_test/(lDevVip|clb|cld)-ansible_test_firewall1") + + - name: Add Graph SG1 at site level again + cisco.mso.mso_schema_site_service_graph: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template1 + service_graph: SG1 + site: '{{ mso_site | default("ansible_test") }}' + tenant: ansible_test + devices: + - name: ansible_test_firewall1 + state: present + register: nm_sg1_again + + - name: Verify change_sg1 + ansible.builtin.assert: + that: + - nm_sg1_again is not changed + - nm_sg1_again.current.serviceGraphRef.serviceGraphName == "SG1" + - nm_sg1_again.current.serviceGraphRef.templateName == "Template1" + - nm_sg1_again.current.serviceNodes | length == 1 + - nm_sg1_again.current.serviceNodes.0.device.dn is match("uni/tn-ansible_test/(lDevVip|clb|cld)-ansible_test_firewall1") + + - name: Change service graph SG1 at site level + cisco.mso.mso_schema_site_service_graph: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template1 + service_graph: SG1 + site: '{{ mso_site | default("ansible_test") }}' + tenant: ansible_test + devices: + - name: ansible_test_firewall2 + state: present + register: change_sg1 + + - name: Verify change_sg1 + ansible.builtin.assert: + that: + - change_sg1 is changed + - change_sg1.current.serviceGraphRef.serviceGraphName == "SG1" + - change_sg1.current.serviceGraphRef.templateName == "Template1" + - change_sg1.current.serviceNodes | length == 1 + - change_sg1.current.serviceNodes.0.device.dn is match("uni/tn-ansible_test/(lDevVip|clb|cld)-ansible_test_firewall2") + + - name: Add a new Graph SG2 at site level + cisco.mso.mso_schema_site_service_graph: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template1 + service_graph: SG2 + site: '{{ mso_site | default("ansible_test") }}' + tenant: ansible_test + devices: + - name: ansible_test_firewall1 + - name: ansible_test_adc + state: present + register: sg2 + + - name: Verify sg2 + ansible.builtin.assert: + that: + - sg2 is changed + - sg2.current.serviceGraphRef.serviceGraphName == "SG2" + - sg2.current.serviceGraphRef.templateName == "Template1" + - sg2.current.serviceNodes | length == 2 + - sg2.current.serviceNodes.0.device.dn is match("uni/tn-ansible_test/(lDevVip|clb|cld)-ansible_test_firewall1") + - sg2.current.serviceNodes.1.device.dn is match("uni/tn-ansible_test/(lDevVip|clb|cld)-ansible_test_adc") + + - name: Add a new Graph SG3 at site level + cisco.mso.mso_schema_site_service_graph: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template1 + service_graph: SG3 + site: '{{ mso_site | default("ansible_test") }}' + tenant: ansible_test + devices: + - name: ansible_test_firewall1 + - name: ansible_test_adc + - name: ansible_test_other + state: present + register: sg3 + + - name: Verify sg3 + ansible.builtin.assert: + that: + - sg3 is changed + - sg3.current.serviceGraphRef.serviceGraphName == "SG3" + - sg3.current.serviceGraphRef.templateName == "Template1" + - sg3.current.serviceNodes | length == 3 + - sg3.current.serviceNodes.0.device.dn is match("uni/tn-ansible_test/(lDevVip|clb|cld)-ansible_test_firewall1") + - sg3.current.serviceNodes.1.device.dn is match("uni/tn-ansible_test/(lDevVip|clb|cld)-ansible_test_adc") + - sg3.current.serviceNodes.2.device.dn is match("uni/tn-ansible_test/(lDevVip|clb|cld)-ansible_test_other") + + - name: Add a new Graph SG4 at site level + cisco.mso.mso_schema_site_service_graph: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template1 + service_graph: SG4 + site: '{{ mso_site | default("ansible_test") }}' + tenant: ansible_test + devices: + - name: ansible_test_other + - name: ansible_test_adc + - name: ansible_test_firewall1 + state: present + register: sg4 + + - name: Verify sg4 + ansible.builtin.assert: + that: + - sg4 is changed + - sg4.current.serviceGraphRef.serviceGraphName == "SG4" + - sg4.current.serviceGraphRef.templateName == "Template1" + - sg4.current.serviceNodes | length == 3 + - sg4.current.serviceNodes.0.device.dn is match("uni/tn-ansible_test/(lDevVip|clb|cld)-ansible_test_other") + - sg4.current.serviceNodes.1.device.dn is match("uni/tn-ansible_test/(lDevVip|clb|cld)-ansible_test_adc") + - sg4.current.serviceNodes.2.device.dn is match("uni/tn-ansible_test/(lDevVip|clb|cld)-ansible_test_firewall1") + + - name: Change Graph SG4 at site level + cisco.mso.mso_schema_site_service_graph: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template1 + service_graph: SG4 + site: '{{ mso_site | default("ansible_test") }}' + tenant: ansible_test + devices: + - name: ansible_test_other + - name: ansible_test_adc + - name: ansible_test_firewall2 + state: present + register: change1_sg4 + + - name: Verify change1_sg4 + ansible.builtin.assert: + that: + - change1_sg4 is changed + - change1_sg4.current.serviceGraphRef.serviceGraphName == "SG4" + - change1_sg4.current.serviceGraphRef.templateName == "Template1" + - change1_sg4.current.serviceNodes | length == 3 + - change1_sg4.current.serviceNodes.0.device.dn is match("uni/tn-ansible_test/(lDevVip|clb|cld)-ansible_test_other") + - change1_sg4.current.serviceNodes.1.device.dn is match("uni/tn-ansible_test/(lDevVip|clb|cld)-ansible_test_adc") + - change1_sg4.current.serviceNodes.2.device.dn is match("uni/tn-ansible_test/(lDevVip|clb|cld)-ansible_test_firewall2") + + - name: Change Graph SG4 at site level + cisco.mso.mso_schema_site_service_graph: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template1 + service_graph: SG4 + site: '{{ mso_site | default("ansible_test") }}' + tenant: ansible_test + devices: + - name: ansible_test_other + state: present + ignore_errors: true + register: change2_sg4 + + - name: Verify change2_sg4 + ansible.builtin.assert: + that: + - change2_sg4 is not changed + - change2_sg4.msg == "Service Graph 'SG4' has '3' service node type(s) but '1' service node(s) were given for the service graph" + + - name: Change Graph SG4 at site level + cisco.mso.mso_schema_site_service_graph: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template1 + service_graph: SG4 + site: '{{ mso_site | default("ansible_test") }}' + tenant: ansible_test + devices: + - name: ansible_test_adc + state: present + ignore_errors: true + register: change3_sg4 + + - name: Verify change3_sg4 + ansible.builtin.assert: + that: + - change3_sg4 is not changed + - change3_sg4.msg == "Service Graph 'SG4' has '3' service node type(s) but '1' service node(s) were given for the service graph" + + - name: Change Graph SG4 at site level + cisco.mso.mso_schema_site_service_graph: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template1 + service_graph: SG4 + site: '{{ mso_site | default("ansible_test") }}' + tenant: ansible_test + devices: + - name: ansible_test_firewall1 + state: present + ignore_errors: true + register: change4_sg4 + + - name: Verify change4_sg4 + ansible.builtin.assert: + that: + - change4_sg4 is not changed + - change4_sg4.msg == "Service Graph 'SG4' has '3' service node type(s) but '1' service node(s) were given for the service graph" + + - name: Change Graph SG4 at site level + cisco.mso.mso_schema_site_service_graph: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template1 + service_graph: SG4 + site: '{{ mso_site | default("ansible_test") }}' + tenant: ansible_test + devices: + - name: ansible_test_other + - name: ansible_test_adc + state: present + ignore_errors: true + register: change5_sg4 + + - name: Verify change5_sg4 + ansible.builtin.assert: + that: + - change5_sg4 is not changed + - change5_sg4.msg == "Service Graph 'SG4' has '3' service node type(s) but '2' service node(s) were given for the service graph" + + - name: Add Graph SG5 at site level + cisco.mso.mso_schema_site_service_graph: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template1 + service_graph: SG5 + site: '{{ mso_site | default("ansible_test") }}' + tenant: ansible_test + devices: + - name: ansible_test_other + - name: ansible_test_firewall1 + - name: ansible_test_firewall1 + state: present + register: sg5 + + - name: Verify sg5 + ansible.builtin.assert: + that: + - sg5 is changed + - sg5.current.serviceGraphRef.serviceGraphName == "SG5" + - sg5.current.serviceGraphRef.templateName == "Template1" + - sg5.current.serviceNodes | length == 3 + - sg5.current.serviceNodes.0.device.dn is match("uni/tn-ansible_test/(lDevVip|clb|cld)-ansible_test_other") + - sg5.current.serviceNodes.1.device.dn is match("uni/tn-ansible_test/(lDevVip|clb|cld)-ansible_test_firewall1") + - sg5.current.serviceNodes.2.device.dn is match("uni/tn-ansible_test/(lDevVip|clb|cld)-ansible_test_firewall1") + + - name: Add Graph SG6 at site level + cisco.mso.mso_schema_site_service_graph: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template1 + service_graph: SG6 + site: '{{ mso_site | default("ansible_test") }}' + tenant: ansible_test + devices: + - name: ansible_test_other + - name: ansible_test_other + - name: ansible_test_other + state: present + register: sg6 + + - name: Verify sg6 + ansible.builtin.assert: + that: + - sg6 is changed + - sg6.current.serviceGraphRef.serviceGraphName == "SG6" + - sg6.current.serviceGraphRef.templateName == "Template1" + - sg6.current.serviceNodes | length == 3 + - sg6.current.serviceNodes.0.device.dn is match("uni/tn-ansible_test/(lDevVip|clb|cld)-ansible_test_other") + - sg6.current.serviceNodes.1.device.dn is match("uni/tn-ansible_test/(lDevVip|clb|cld)-ansible_test_other") + - sg6.current.serviceNodes.2.device.dn is match("uni/tn-ansible_test/(lDevVip|clb|cld)-ansible_test_other") + + - name: Add Graph SG7 at site level + cisco.mso.mso_schema_site_service_graph: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template1 + service_graph: SG7 + site: '{{ mso_site | default("ansible_test") }}' + tenant: ansible_test + devices: + - name: ansible_test_adc + - name: ansible_test_adc + state: present + register: sg7 + + - name: Verify sg7 + ansible.builtin.assert: + that: + - sg7 is changed + - sg7.current.serviceGraphRef.serviceGraphName == "SG7" + - sg7.current.serviceGraphRef.templateName == "Template1" + - sg7.current.serviceNodes | length == 2 + - sg7.current.serviceNodes.0.device.dn is match("uni/tn-ansible_test/(lDevVip|clb|cld)-ansible_test_adc") + - sg7.current.serviceNodes.1.device.dn is match("uni/tn-ansible_test/(lDevVip|clb|cld)-ansible_test_adc") + + - name: Query service graph SG at site level + cisco.mso.mso_schema_site_service_graph: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template1 + service_graph: SG1 + site: '{{ mso_site | default("ansible_test") }}' + tenant: ansible_test + state: query + register: query_sg + + - name: Verify query_sg + ansible.builtin.assert: + that: + - query_sg is not changed + - query_sg.current.serviceGraphRef is match("/schemas/[0-9a-zA-Z]*/templates/Template1/serviceGraphs/SG1") + + - name: Query all service graphs at site level + cisco.mso.mso_schema_site_service_graph: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template1 + site: '{{ mso_site | default("ansible_test") }}' + tenant: ansible_test + state: query + register: query_all + + - name: Verify query_all + ansible.builtin.assert: + that: + - query_all is not changed + - query_all.current | length == 7 + + # Azure tests part + - name: Execute tasks only for cloud sites + when: + - query_cloud.current | length > 0 + - query_cloud.current.0.cloudProvP.attributes.vendor == "azure" + block: + - name: Create a service graph 1 at Template3 for the Azure site service graph test # Azure Task + cisco.mso.mso_schema_template_service_graph: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template3 + service_graph: SG1 + display_name: sg1 + service_nodes: + - type: firewall + - type: load-balancer + - type: other + filter_after_first_node: allow_all + state: present + + - name: Create a service graph 2 at Template3 for the Azure site service graph test # Azure Task + cisco.mso.mso_schema_template_service_graph: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template3 + service_graph: SG2 + display_name: sg2 + service_nodes: + - type: other + filter_after_first_node: allow_all + state: present + + - name: Add Azure site to a schema Template3 for the Azure site service graph test # Azure Task + cisco.mso.mso_schema_site: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: '{{ mso_site | default("ansible_test") }}' + template: Template3 + state: present + + - name: Add Service Graph 1 at site level for the Azure site service graph test - check_mode # Azure Task + cisco.mso.mso_schema_site_service_graph: &az_sg1_cm_present + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template3 + service_graph: SG1 + site: '{{ mso_site | default("ansible_test") }}' + tenant: ansible_test + devices: + - name: ansible_test_firewall1 + provider_connector_type: source_nat + provider_interface: TP_FW_Inf1 + consumer_connector_type: redirect + consumer_interface: TP_FW_Inf1 + - name: ansible_test_app_lb + - name: ansible_test_other + provider_connector_type: destination_nat + consumer_connector_type: redirect + state: present + output_level: debug + register: az_sg1_cm_present + check_mode: true + + - name: Add Service Graph 1 at site level for the Azure site service graph test - normal_mode # Azure Task + cisco.mso.mso_schema_site_service_graph: + <<: *az_sg1_cm_present + output_level: debug + register: az_sg1_nm_present + + - name: Add Service Graph 1 at site level for the Azure site service graph test - normal_mode again # Azure Task + cisco.mso.mso_schema_site_service_graph: + <<: *az_sg1_cm_present + register: az_sg1_nm_present_again + + - name: Add Service Graph 2 at site level for the Azure site service graph test # Azure Task + cisco.mso.mso_schema_site_service_graph: &az_sg2_nm_present + <<: *az_sg1_cm_present + service_graph: SG2 + devices: + - name: ansible_test_firewall2 + provider_connector_type: destination_nat + provider_interface: TP_FW_Inf12 + consumer_connector_type: redirect + consumer_interface: TP_FW_Inf2 + state: present + register: az_sg2_nm_present + + - name: Assertions check for the add Azure site service graph + ansible.builtin.assert: + that: + - az_sg1_cm_present is changed + - az_sg1_cm_present.current.serviceGraphRef.serviceGraphName == "SG1" + - az_sg1_cm_present.current.serviceGraphRef.templateName == "Template3" + - az_sg1_cm_present.current.serviceNodes | length == 3 + - az_sg1_cm_present.current.serviceNodes.0.device.dn is match("uni/tn-ansible_test/(lDevVip|clb|cld)-ansible_test_firewall1") + - az_sg1_cm_present.current.serviceNodes.1.device.dn is match("uni/tn-ansible_test/(lDevVip|clb|cld)-ansible_test_app_lb") + - az_sg1_cm_present.current.serviceNodes.2.device.dn is match("uni/tn-ansible_test/(lDevVip|clb|cld)-ansible_test_other") + - az_sg1_cm_present.previous.serviceNodes is none + - az_sg1_cm_present.previous.serviceGraphRef is match("/schemas/.+/templates/Template3/serviceGraphs/SG1") + - az_sg1_cm_present.proposed.serviceGraphRef.serviceGraphName == "SG1" + - az_sg1_cm_present.proposed.serviceGraphRef.templateName == "Template3" + - az_sg1_cm_present.proposed.serviceNodes | length == 3 + - az_sg1_cm_present.proposed.serviceNodes.0.consumerConnectorType == "redir" + - az_sg1_cm_present.proposed.serviceNodes.0.consumerInterface == "TP_FW_Inf1" + - az_sg1_cm_present.proposed.serviceNodes.0.device.dn == "uni/tn-ansible_test/cld-ansible_test_firewall1" + - az_sg1_cm_present.proposed.serviceNodes.0.providerConnectorType == "snat" + - az_sg1_cm_present.proposed.serviceNodes.0.providerInterface == "TP_FW_Inf1" + - az_sg1_cm_present.proposed.serviceNodes.0.serviceNodeRef.serviceGraphName == "SG1" + - az_sg1_cm_present.proposed.serviceNodes.0.serviceNodeRef.serviceNodeName == "node1" + - az_sg1_cm_present.proposed.serviceNodes.0.serviceNodeRef.templateName == "Template3" + - az_sg1_cm_present.proposed.serviceNodes.1.device.dn is match("uni/tn-ansible_test/(lDevVip|clb|cld)-ansible_test_app_lb") + - az_sg1_cm_present.proposed.serviceNodes.2.device.dn is match("uni/tn-ansible_test/(lDevVip|clb|cld)-ansible_test_other") + - az_sg1_nm_present is changed + - az_sg1_nm_present.current.serviceGraphRef.serviceGraphName == "SG1" + - az_sg1_nm_present.current.serviceGraphRef.templateName == "Template3" + - az_sg1_nm_present.current.serviceNodes | length == 3 + - az_sg1_nm_present.current.serviceNodes.0.device.dn is match("uni/tn-ansible_test/(lDevVip|clb|cld)-ansible_test_firewall1") + - az_sg1_nm_present.current.serviceNodes.1.device.dn is match("uni/tn-ansible_test/(lDevVip|clb|cld)-ansible_test_app_lb") + - az_sg1_nm_present.current.serviceNodes.2.device.dn is match("uni/tn-ansible_test/(lDevVip|clb|cld)-ansible_test_other") + - az_sg1_nm_present.previous.serviceGraphRef is match("/schemas/.+/templates/Template3/serviceGraphs/SG1") + - az_sg1_nm_present.previous.serviceNodes is none + - az_sg1_nm_present_again is not changed + - az_sg1_nm_present_again.current.serviceGraphRef.serviceGraphName == "SG1" + - az_sg1_nm_present_again.current.serviceGraphRef.templateName == "Template3" + - az_sg1_nm_present_again.current.serviceNodes | length == 3 + - az_sg1_nm_present_again.current.serviceNodes.0.device.dn is match("uni/tn-ansible_test/(lDevVip|clb|cld)-ansible_test_firewall1") + - az_sg1_nm_present_again.current.serviceNodes.1.device.dn is match("uni/tn-ansible_test/(lDevVip|clb|cld)-ansible_test_app_lb") + - az_sg1_nm_present_again.current.serviceNodes.2.device.dn is match("uni/tn-ansible_test/(lDevVip|clb|cld)-ansible_test_other") + - az_sg1_nm_present_again.previous.serviceGraphRef is match("/schemas/.+/templates/Template3/serviceGraphs/SG1") + - az_sg1_nm_present_again.previous.serviceNodes | length == 3 + - az_sg1_nm_present_again.previous.serviceNodes.0.device.dn is match("uni/tn-ansible_test/(lDevVip|clb|cld)-ansible_test_firewall1") + - az_sg1_nm_present_again.previous.serviceNodes.1.device.dn is match("uni/tn-ansible_test/(lDevVip|clb|cld)-ansible_test_app_lb") + - az_sg1_nm_present_again.previous.serviceNodes.2.device.dn is match("uni/tn-ansible_test/(lDevVip|clb|cld)-ansible_test_other") + - az_sg2_nm_present is changed + - az_sg2_nm_present.current.serviceGraphRef.serviceGraphName == "SG2" + - az_sg2_nm_present.current.serviceGraphRef.templateName == "Template3" + - az_sg2_nm_present.current.serviceNodes | length == 1 + - az_sg2_nm_present.current.serviceNodes.0.consumerConnectorType == "redir" + - az_sg2_nm_present.current.serviceNodes.0.consumerInterface == "TP_FW_Inf2" + - az_sg2_nm_present.current.serviceNodes.0.providerConnectorType == "dnat" + - az_sg2_nm_present.current.serviceNodes.0.providerInterface == "TP_FW_Inf12" + - az_sg2_nm_present.current.serviceNodes.0.device.dn is match("uni/tn-ansible_test/(lDevVip|clb|cld)-ansible_test_firewall2") + - az_sg2_nm_present.current.serviceNodes.0.serviceNodeRef.serviceGraphName == "SG2" + - az_sg2_nm_present.current.serviceNodes.0.serviceNodeRef.serviceNodeName == "node1" + - az_sg2_nm_present.current.serviceNodes.0.serviceNodeRef.templateName == "Template3" + - az_sg2_nm_present.previous.serviceGraphRef is match("/schemas/.+/templates/Template3/serviceGraphs/SG2") + - az_sg2_nm_present.previous.serviceNodes is none + + - name: Update Service Graph 2 node with ansible_test_app_lb - check_mode # Azure Task + cisco.mso.mso_schema_site_service_graph: &az_update_sg2_cm + <<: *az_sg2_nm_present + service_graph: SG2 + devices: + - name: ansible_test_app_lb + state: present + output_level: debug + register: az_update_sg2_cm + check_mode: true + + - name: Update Service Graph 2 node with ansible_test_app_lb - normal_mode # Azure Task + cisco.mso.mso_schema_site_service_graph: + <<: *az_update_sg2_cm + output_level: debug + register: az_update_sg2_nm + + - name: Update Service Graph 2 node with ansible_test_app_lb - normal_mode again # Azure Task + cisco.mso.mso_schema_site_service_graph: + <<: *az_update_sg2_cm + register: az_update_sg2_nm_again + + - name: Update Service Graph 2 node with ansible_test_app_lb - Negative Test # Azure Task + cisco.mso.mso_schema_site_service_graph: + <<: *az_update_sg2_cm + devices: + - name: ansible_test_app_lb + provider_connector_type: destination_nat + consumer_connector_type: redirect + state: present + output_level: debug + register: nt_ansible_test_app_lb + ignore_errors: true + + - name: Update Service Graph 2 node with ansible_test_other # Azure Task + cisco.mso.mso_schema_site_service_graph: + <<: *az_update_sg2_cm + devices: + - name: ansible_test_other + provider_connector_type: source_and_destination_nat + consumer_connector_type: none + state: present + register: pt_ansible_test_other + + - name: Update Service Graph 2 node with ansible_test_other - Negative Test # Azure Task + cisco.mso.mso_schema_site_service_graph: + <<: *az_update_sg2_cm + devices: + - name: ansible_test_other + provider_connector_type: source_and_destination_nat + consumer_connector_type: none + consumer_interface: invalid_inf + state: present + output_level: debug + register: nt_ansible_test_other + ignore_errors: true + + - name: Update Service Graph 2 node with ansible_test_adc # Azure Task + cisco.mso.mso_schema_site_service_graph: + <<: *az_update_sg2_cm + devices: + - name: ansible_test_adc + provider_interface: TP_LB_Inf + consumer_interface: TP_LB_Inf + state: present + register: pt_ansible_test_adc + + - name: Assertions check for the update Azure site service graph + ansible.builtin.assert: + that: + - az_update_sg2_cm is changed + - az_update_sg2_cm.current.serviceGraphRef.serviceGraphName == "SG2" + - az_update_sg2_cm.current.serviceGraphRef.templateName == "Template3" + - az_update_sg2_cm.current.serviceNodes | length == 1 + - az_update_sg2_cm.current.serviceNodes.0.device.dn is match("uni/tn-ansible_test/(lDevVip|clb|cld)-ansible_test_app_lb") + - az_update_sg2_cm.current.serviceNodes.0.device.funcType == "GoTo" + - az_update_sg2_cm.current.serviceNodes.0.consumerConnectorType is none + - az_update_sg2_cm.current.serviceNodes.0.consumerInterface is none + - az_update_sg2_cm.current.serviceNodes.0.providerConnectorType is none + - az_update_sg2_cm.current.serviceNodes.0.providerInterface is none + - az_update_sg2_cm.current.serviceNodes.0.serviceNodeRef.serviceGraphName == "SG2" + - az_update_sg2_cm.current.serviceNodes.0.serviceNodeRef.serviceNodeName == "node1" + - az_update_sg2_cm.current.serviceNodes.0.serviceNodeRef.templateName == "Template3" + - az_update_sg2_cm.previous.serviceGraphRef is match("/schemas/.+/templates/Template3/serviceGraphs/SG2") + - az_update_sg2_cm.previous.serviceNodes | length == 1 + - az_update_sg2_cm.previous.serviceNodes.0.consumerConnectorType == "redir" + - az_update_sg2_cm.previous.serviceNodes.0.consumerInterface == "TP_FW_Inf2" + - az_update_sg2_cm.previous.serviceNodes.0.device.dn is match("uni/tn-ansible_test/(lDevVip|clb|cld)-ansible_test_firewall2") + - az_update_sg2_cm.previous.serviceNodes.0.device.funcType == "GoTo" + - az_update_sg2_cm.previous.serviceNodes.0.providerConnectorType == "dnat" + - az_update_sg2_cm.previous.serviceNodes.0.providerInterface == "TP_FW_Inf12" + - az_update_sg2_cm.previous.serviceNodes.0.serviceNodeRef.serviceGraphName == "SG2" + - az_update_sg2_cm.previous.serviceNodes.0.serviceNodeRef.serviceNodeName == "node1" + - az_update_sg2_cm.previous.serviceNodes.0.serviceNodeRef.templateName == "Template3" + - az_update_sg2_cm.proposed.serviceGraphRef.serviceGraphName == "SG2" + - az_update_sg2_cm.proposed.serviceGraphRef.templateName == "Template3" + - az_update_sg2_cm.proposed.serviceNodes | length == 1 + - az_update_sg2_cm.proposed.serviceNodes.0.consumerConnectorType is none + - az_update_sg2_cm.proposed.serviceNodes.0.consumerInterface is none + - az_update_sg2_cm.proposed.serviceNodes.0.device.dn is match("uni/tn-ansible_test/(lDevVip|clb|cld)-ansible_test_app_lb") + - az_update_sg2_cm.proposed.serviceNodes.0.device.funcType == "GoTo" + - az_update_sg2_cm.proposed.serviceNodes.0.providerConnectorType is none + - az_update_sg2_cm.proposed.serviceNodes.0.providerInterface is none + - az_update_sg2_cm.proposed.serviceNodes.0.serviceNodeRef.serviceGraphName == "SG2" + - az_update_sg2_cm.proposed.serviceNodes.0.serviceNodeRef.serviceNodeName == "node1" + - az_update_sg2_cm.proposed.serviceNodes.0.serviceNodeRef.templateName == "Template3" + - az_update_sg2_nm is changed + - az_update_sg2_nm.current.serviceGraphRef.serviceGraphName == "SG2" + - az_update_sg2_nm.current.serviceGraphRef.templateName == "Template3" + - az_update_sg2_nm.current.serviceNodes | length == 1 + - az_update_sg2_nm.current.serviceNodes.0.consumerConnectorType is none + - az_update_sg2_nm.current.serviceNodes.0.consumerInterface is none + - az_update_sg2_nm.current.serviceNodes.0.device.dn is match("uni/tn-ansible_test/(lDevVip|clb|cld)-ansible_test_app_lb") + - az_update_sg2_nm.current.serviceNodes.0.providerConnectorType is none + - az_update_sg2_nm.current.serviceNodes.0.providerInterface is none + - az_update_sg2_nm.current.serviceNodes.0.serviceNodeRef.serviceGraphName == "SG2" + - az_update_sg2_nm.current.serviceNodes.0.serviceNodeRef.serviceNodeName == "node1" + - az_update_sg2_nm.current.serviceNodes.0.serviceNodeRef.templateName == "Template3" + - az_update_sg2_nm.previous.serviceGraphRef is match("/schemas/.+/templates/Template3/serviceGraphs/SG2") + - az_update_sg2_nm.previous.serviceNodes | length == 1 + - az_update_sg2_nm.previous.serviceNodes.0.consumerConnectorType == "redir" + - az_update_sg2_nm.previous.serviceNodes.0.consumerInterface == "TP_FW_Inf2" + - az_update_sg2_nm.previous.serviceNodes.0.device.dn is match("uni/tn-ansible_test/(lDevVip|clb|cld)-ansible_test_firewall2") + - az_update_sg2_nm.previous.serviceNodes.0.device.funcType == "GoTo" + - az_update_sg2_nm.previous.serviceNodes.0.providerConnectorType == "dnat" + - az_update_sg2_nm.previous.serviceNodes.0.providerInterface == "TP_FW_Inf12" + - az_update_sg2_nm.previous.serviceNodes.0.serviceNodeRef.serviceGraphName == "SG2" + - az_update_sg2_nm.previous.serviceNodes.0.serviceNodeRef.serviceNodeName == "node1" + - az_update_sg2_nm.previous.serviceNodes.0.serviceNodeRef.templateName == "Template3" + - az_update_sg2_nm_again is not changed + - az_update_sg2_nm_again.current.serviceGraphRef.serviceGraphName == "SG2" + - az_update_sg2_nm_again.current.serviceGraphRef.templateName == "Template3" + - az_update_sg2_nm_again.current.serviceNodes | length == 1 + - az_update_sg2_nm_again.current.serviceNodes.0.consumerConnectorType is none + - az_update_sg2_nm_again.current.serviceNodes.0.consumerInterface is none + - az_update_sg2_nm_again.current.serviceNodes.0.device.dn is match("uni/tn-ansible_test/(lDevVip|clb|cld)-ansible_test_app_lb") + - az_update_sg2_nm_again.current.serviceNodes.0.providerConnectorType is none + - az_update_sg2_nm_again.current.serviceNodes.0.providerInterface is none + - az_update_sg2_nm_again.current.serviceNodes.0.serviceNodeRef.serviceGraphName == "SG2" + - az_update_sg2_nm_again.current.serviceNodes.0.serviceNodeRef.serviceNodeName == "node1" + - az_update_sg2_nm_again.current.serviceNodes.0.serviceNodeRef.templateName == "Template3" + - az_update_sg2_nm_again.previous.serviceGraphRef is match("/schemas/.+/templates/Template3/serviceGraphs/SG2") + - az_update_sg2_nm_again.previous.serviceNodes.0.device.dn is match("uni/tn-ansible_test/(lDevVip|clb|cld)-ansible_test_app_lb") + - az_update_sg2_nm_again.previous.serviceNodes.0.serviceNodeRef.serviceGraphName == "SG2" + - az_update_sg2_nm_again.previous.serviceNodes.0.serviceNodeRef.serviceNodeName == "node1" + - az_update_sg2_nm_again.previous.serviceNodes.0.serviceNodeRef.templateName == "Template3" + - pt_ansible_test_adc is changed + - pt_ansible_test_adc.current.serviceGraphRef + - pt_ansible_test_adc.current.serviceGraphRef.serviceGraphName == "SG2" + - pt_ansible_test_adc.current.serviceGraphRef.templateName == "Template3" + - pt_ansible_test_adc.current.serviceNodes.0.consumerConnectorType is none + - pt_ansible_test_adc.current.serviceNodes.0.consumerInterface == "TP_LB_Inf" + - pt_ansible_test_adc.current.serviceNodes.0.device.dn is match("uni/tn-ansible_test/(lDevVip|clb|cld)-ansible_test_adc") + - pt_ansible_test_adc.current.serviceNodes.0.providerConnectorType is none + - pt_ansible_test_adc.current.serviceNodes.0.providerInterface == "TP_LB_Inf" + - pt_ansible_test_adc.current.serviceNodes.0.serviceNodeRef.serviceGraphName == "SG2" + - pt_ansible_test_adc.current.serviceNodes.0.serviceNodeRef.serviceNodeName == "node1" + - pt_ansible_test_adc.current.serviceNodes.0.serviceNodeRef.templateName == "Template3" + - pt_ansible_test_adc.previous.serviceGraphRef is match("/schemas/.+/templates/Template3/serviceGraphs/SG2") + - pt_ansible_test_adc.previous.serviceNodes.0.consumerConnectorType == "none" + - pt_ansible_test_adc.previous.serviceNodes.0.device.dn is match("uni/tn-ansible_test/(lDevVip|clb|cld)-ansible_test_other") + - pt_ansible_test_adc.previous.serviceNodes.0.providerConnectorType == "snat_dnat" + - pt_ansible_test_adc.previous.serviceNodes.0.serviceNodeRef.serviceGraphName == "SG2" + - pt_ansible_test_adc.previous.serviceNodes.0.serviceNodeRef.serviceNodeName == "node1" + - pt_ansible_test_adc.previous.serviceNodes.0.serviceNodeRef.templateName == "Template3" + - pt_ansible_test_other is changed + - pt_ansible_test_other.current.serviceGraphRef.serviceGraphName == "SG2" + - pt_ansible_test_other.current.serviceGraphRef.templateName == "Template3" + - pt_ansible_test_other.current.serviceNodes.0.consumerConnectorType == "none" + - pt_ansible_test_other.current.serviceNodes.0.consumerInterface is none + - pt_ansible_test_other.current.serviceNodes.0.device.dn is match("uni/tn-ansible_test/(lDevVip|clb|cld)-ansible_test_other") + - pt_ansible_test_other.current.serviceNodes.0.providerConnectorType == "snat_dnat" + - pt_ansible_test_other.current.serviceNodes.0.providerInterface is none + - pt_ansible_test_other.current.serviceNodes.0.serviceNodeRef.serviceGraphName == "SG2" + - pt_ansible_test_other.current.serviceNodes.0.serviceNodeRef.serviceNodeName == "node1" + - pt_ansible_test_other.current.serviceNodes.0.serviceNodeRef.templateName == "Template3" + - pt_ansible_test_other.previous.serviceGraphRef is match("/schemas/.+/templates/Template3/serviceGraphs/SG2") + - pt_ansible_test_other.previous.serviceNodes | length == 1 + - pt_ansible_test_other.previous.serviceNodes.0.device.dn is match("uni/tn-ansible_test/(lDevVip|clb|cld)-ansible_test_app_lb") + - pt_ansible_test_other.previous.serviceNodes.0.serviceNodeRef.serviceGraphName == "SG2" + - pt_ansible_test_other.previous.serviceNodes.0.serviceNodeRef.serviceNodeName == "node1" + - pt_ansible_test_other.previous.serviceNodes.0.serviceNodeRef.templateName == "Template3" + + - name: Update Service Graph 2 node with ansible_test_adc - Negative Test # Azure Task + cisco.mso.mso_schema_site_service_graph: + <<: *az_update_sg2_cm + devices: + - name: ansible_test_adc + provider_interface: TP_LB_Inf + consumer_interface: TP_LB_Inf + consumer_connector_type: none + state: present + output_level: debug + register: nt_ansible_test_adc + ignore_errors: true + + - name: Assertions check for the Azure site service graph negative tests + ansible.builtin.assert: + that: + - nt_ansible_test_adc is not changed + - nt_ansible_test_adc.msg is match("Unsupported attributes{{':'}} provider_connector_type and consumer_connector_type should be 'None' for the Third-Party Load Balancer.") + - nt_ansible_test_other is not changed + - nt_ansible_test_other.msg is match("Unsupported attributes{{':'}} provider_interface and consumer_interface should be 'None' for the Network Load Balancer device.") + - nt_ansible_test_app_lb is not changed + - nt_ansible_test_app_lb.msg is match("Unsupported attributes{{':'}} provider_connector_type, provider_interface, consumer_connector_type, consumer_interface should be 'None' for the Application Load Balancer device.") + + - name: Query all service graphs at Azure site level # Azure Task + cisco.mso.mso_schema_site_service_graph: &az_site_sg_query_all + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template3 + site: '{{ mso_site | default("ansible_test") }}' + tenant: ansible_test + state: query + register: az_site_sg_query_all + + - name: Query a service graph with name at Azure site level # Azure Task + cisco.mso.mso_schema_site_service_graph: + <<: *az_site_sg_query_all + service_graph: SG2 + state: query + register: az_site_sg_query_sg2 + + - name: Assertions check for the query Azure site service graph + ansible.builtin.assert: + that: + - az_site_sg_query_all is not changed + - az_site_sg_query_all.current | length == 2 + - az_site_sg_query_all.current.0.serviceGraphRef is match("/schemas/.+/templates/Template3/serviceGraphs/SG1") + - az_site_sg_query_all.current.0.serviceNodes | length == 3 + - az_site_sg_query_all.current.0.serviceNodes.0.consumerConnectorType == "redir" + - az_site_sg_query_all.current.0.serviceNodes.0.consumerInterface == "TP_FW_Inf1" + - az_site_sg_query_all.current.0.serviceNodes.0.device.dn is match("uni/tn-ansible_test/(lDevVip|clb|cld)-ansible_test_firewall1") + - az_site_sg_query_all.current.0.serviceNodes.0.device.funcType == "GoTo" + - az_site_sg_query_all.current.0.serviceNodes.0.providerConnectorType == "snat" + - az_site_sg_query_all.current.0.serviceNodes.0.providerInterface == "TP_FW_Inf1" + - az_site_sg_query_all.current.0.serviceNodes.0.serviceNodeRef is match("/schemas/.+/templates/Template3/serviceGraphs/SG1/serviceNodes/node1") + - az_site_sg_query_all.current.0.serviceNodes.1.device.dn is match("uni/tn-ansible_test/(lDevVip|clb|cld)-ansible_test_app_lb") + - az_site_sg_query_all.current.0.serviceNodes.1.serviceNodeRef is match("/schemas/.+/templates/Template3/serviceGraphs/SG1/serviceNodes/node2") + - az_site_sg_query_all.current.0.serviceNodes.2.consumerConnectorType == "redir" + - az_site_sg_query_all.current.0.serviceNodes.2.device.dn is match("uni/tn-ansible_test/(lDevVip|clb|cld)-ansible_test_other") + - az_site_sg_query_all.current.0.serviceNodes.2.providerConnectorType == "dnat" + - az_site_sg_query_all.current.0.serviceNodes.2.serviceNodeRef is match("/schemas/.+/templates/Template3/serviceGraphs/SG1/serviceNodes/node3") + - az_site_sg_query_sg2 is not changed + - az_site_sg_query_sg2.current.serviceGraphRef is match("/schemas/.+/templates/Template3/serviceGraphs/SG2") + - az_site_sg_query_sg2.current.serviceNodes | length == 1 + - az_site_sg_query_sg2.current.serviceNodes.0.consumerInterface == "TP_LB_Inf" + - az_site_sg_query_sg2.current.serviceNodes.0.device.dn is match("uni/tn-ansible_test/(lDevVip|clb|cld)-ansible_test_adc") + - az_site_sg_query_sg2.current.serviceNodes.0.device.funcType == "GoTo" + - az_site_sg_query_sg2.current.serviceNodes.0.providerInterface == "TP_LB_Inf" + - az_site_sg_query_sg2.current.serviceNodes.0.serviceNodeRef is match("/schemas/.+/templates/Template3/serviceGraphs/SG2/serviceNodes/node1") + # Azure tests ends + + - name: Query non_existing service graph at site level + cisco.mso.mso_schema_site_service_graph: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template1 + site: '{{ mso_site | default("ansible_test") }}' + service_graph: non_existent + tenant: ansible_test + state: query + ignore_errors: true + register: query_non_existing_sg + + - name: Verify query_non_existing_sg + ansible.builtin.assert: + that: + - query_non_existing_sg.msg == "Service Graph 'non_existent' not found" + + - name: Use non_existing schema + cisco.mso.mso_schema_site_service_graph: + <<: *mso_info + schema: non_existing_schema + template: Template1 + service_graph: SG + tenant: ansible_test + site: '{{ mso_site | default("ansible_test") }}' + state: query + ignore_errors: true + register: query_non_existing_schema + + - name: Verify non_existing_schema + ansible.builtin.assert: + that: + - query_non_existing_schema is not changed + - query_non_existing_schema.msg == "Provided schema 'non_existing_schema' does not exist." + + - name: Use non_existing template + cisco.mso.mso_schema_site_service_graph: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: non_existing_template + service_graph: SG + tenant: ansible_test + site: '{{ mso_site | default("ansible_test") }}' + state: query + ignore_errors: true + register: query_non_existing_template + + - name: Verify query_non_existing_template + ansible.builtin.assert: + that: + - query_non_existing_template.msg == "Provided template 'non_existing_template' does not exist. Existing templates{{':'}} Template1, Template2, Template3" + + - name: Use non_existing_site_template + cisco.mso.mso_schema_site_service_graph: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: '{{ mso_site | default("ansible_test") }}' + service_graph: SG + template: Template2 + tenant: ansible_test + state: query + ignore_errors: true + register: nm_non_existing_site_template + + - name: Verify cm_non_existing_site_template and nm_non_existing_site_template + ansible.builtin.assert: + that: + - nm_non_existing_site_template is not changed + - nm_non_existing_site_template.msg is match("Provided site-template association '.+' does not exist.") + + - name: Add site Service Graph to Template2 without any site association + cisco.mso.mso_schema_site_service_graph: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}_2' + site: '{{ mso_site | default("ansible_test") }}' + template: Template1 + service_graph: SG1 + tenant: ansible_test + devices: + - name: ansible_test_firewall2 + state: present + ignore_errors: true + register: nm_no_site_associated + + - name: Verify nm_no_site_associated + ansible.builtin.assert: + that: + - nm_no_site_associated is not changed + - nm_no_site_associated.msg == "No site associated with template 'Template1'. Associate the site with the template using mso_schema_site." + + - name: Remove service graph from site level(check mode) + cisco.mso.mso_schema_site_service_graph: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template1 + service_graph: SG1 + site: '{{ mso_site | default("ansible_test") }}' + tenant: ansible_test + state: absent + register: rm_sg_cm + check_mode: true + + - name: Verify rm_sg_cm + ansible.builtin.assert: + that: + - rm_sg_cm is changed + - rm_sg_cm.current == {} + - rm_sg_cm.previous.serviceGraphRef is match("/schemas/[0-9a-zA-Z]*/templates/Template1/serviceGraphs/SG1") + + - name: Remove service graph from site level (normal mode) + cisco.mso.mso_schema_site_service_graph: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template1 + service_graph: SG1 + tenant: ansible_test + site: '{{ mso_site | default("ansible_test") }}' + state: absent + register: rm_sg + + - name: Verify rm_sg + ansible.builtin.assert: + that: + - rm_sg is changed + - rm_sg.current == {} + - rm_sg.previous.serviceGraphRef is match("/schemas/[0-9a-zA-Z]*/templates/Template1/serviceGraphs/SG1") + + - name: Remove service graph again + cisco.mso.mso_schema_site_service_graph: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template1 + service_graph: SG1 + tenant: ansible_test + site: '{{ mso_site | default("ansible_test") }}' + state: absent + register: rm_sg_again + + - name: Verify rm_sg_again + ansible.builtin.assert: + that: + - rm_sg_again is not changed + - rm_sg_again.current == {} + - rm_sg_again.previous == {} + when: version.current.version is version('4.0', '<') # no change in NDO4.0 because site will already be present when template is defined + + # To clear the ACI Config + - name: Set ansible_network_os to cisco.aci.aci and ansible_connection to local + ansible.builtin.set_fact: + ansible_connection: local + ansible_network_os: cisco.aci.aci + + - name: Reset the ansible_connection to access the APIC + ansible.builtin.meta: reset_connection + + - name: Remove the ansible_test tenant from APIC + cisco.aci.aci_tenant: + <<: *aci_info + name: ansible_test + state: absent diff --git a/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_vrf_region/tasks/main.yml b/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_vrf_region/tasks/main.yml index c31a31eeb..315a4d94d 100644 --- a/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_vrf_region/tasks/main.yml +++ b/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_vrf_region/tasks/main.yml @@ -5,7 +5,7 @@ # CLEAN ENVIRONMENT - name: Set vars - set_fact: + ansible.builtin.set_fact: mso_info: &mso_info host: '{{ mso_hostname }}' username: '{{ mso_username }}' @@ -19,13 +19,13 @@ '{{ mso_site | default(\"ansible_test\") }}']" - name: Query MSO version - mso_version: + cisco.mso.mso_version: <<: *mso_info state: query register: version - name: Ensure aws site exists - mso_site: + cisco.mso.mso_site: <<: *mso_info site: 'aws_{{ mso_site | default("ansible_test") }}' apic_username: '{{ aws_apic_username }}' @@ -36,7 +36,7 @@ state: present - name: Ensure azure site exists - mso_site: + cisco.mso.mso_site: <<: *mso_info site: 'azure_{{ mso_site | default("ansible_test") }}' apic_username: '{{ azure_apic_username }}' @@ -47,7 +47,7 @@ state: present - name: Remove Schemas - mso_schema: + cisco.mso.mso_schema: <<: *mso_info schema: '{{ item }}' state: absent @@ -56,7 +56,7 @@ - '{{ mso_schema | default("ansible_test") }}' - name: Ensure sites removed from tenant ansible_test - mso_tenant_site: + cisco.mso.mso_tenant_site: <<: *mso_info tenant: ansible_test site: '{{ item }}' @@ -67,7 +67,7 @@ - 'azure_{{ mso_site | default("ansible_test") }}' - name: Ensure tenant ansible_test exist - mso_tenant: + cisco.mso.mso_tenant: <<: *mso_info tenant: ansible_test users: @@ -75,7 +75,7 @@ state: present - name: Ensure AWS site is present under tenant ansible_test - mso_tenant_site: + cisco.mso.mso_tenant_site: <<: *mso_info tenant: ansible_test site: 'aws_{{ mso_site | default("ansible_test") }}' @@ -85,7 +85,7 @@ state: present - name: Ensure Azure site is present under tenant ansible_test - mso_tenant_site: + cisco.mso.mso_tenant_site: <<: *mso_info tenant: ansible_test site: 'azure_{{ mso_site | default("ansible_test") }}' @@ -93,7 +93,7 @@ state: present - name: Ensure schema 1 with Template 1 and 2 exists - mso_schema_template: + cisco.mso.mso_schema_template: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' tenant: ansible_test @@ -104,7 +104,7 @@ - Template 2 - name: Ensure schema 2 with Template 3 exists - mso_schema_template: + cisco.mso.mso_schema_template: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}_2' tenant: ansible_test @@ -112,7 +112,7 @@ state: present - name: Ensure VRF1 exists - mso_schema_template_vrf: + cisco.mso.mso_schema_template_vrf: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -120,7 +120,7 @@ state: present - name: Add region and cidr in VRF1 at AWS site level - mso_schema_site_vrf_region_cidr: + cisco.mso.mso_schema_site_vrf_region_cidr: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -133,7 +133,7 @@ register: aws_add_region_cidr - name: Add region and cidr in VRF1 at Azure site level - mso_schema_site_vrf_region_cidr: + cisco.mso.mso_schema_site_vrf_region_cidr: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -146,7 +146,7 @@ register: azure_add_region_cidr - name: Add another region and cidr in VRF1 at AWS site level - mso_schema_site_vrf_region_cidr: + cisco.mso.mso_schema_site_vrf_region_cidr: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -159,7 +159,7 @@ register: aws_add_another_region_cidr - name: Add another region and cidr in VRF1 at Azure site level - mso_schema_site_vrf_region_cidr: + cisco.mso.mso_schema_site_vrf_region_cidr: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -176,7 +176,7 @@ when: version.current.version is version('3.3', '>=') block: - name: Ensure VRF2 exists - mso_schema_template_vrf: + cisco.mso.mso_schema_template_vrf: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -184,7 +184,7 @@ state: present - name: Add region and cidr in VRF2 at Azure site level - mso_schema_site_vrf_region_cidr: + cisco.mso.mso_schema_site_vrf_region_cidr: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -197,7 +197,7 @@ register: azure_add_another_region_cidr - name: Add region and cidr in VRF2 at AWS site level - mso_schema_site_vrf_region_cidr: + cisco.mso.mso_schema_site_vrf_region_cidr: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -210,7 +210,7 @@ register: azure_add_another_region_cidr - name: Add context underlay parameters in VRF1 at Azure site level - mso_schema_site_vrf_region: + cisco.mso.mso_schema_site_vrf_region: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -225,7 +225,7 @@ register: azure_add_context_underlay - name: Add context underlay parameters in VRF1 at AWS site level - mso_schema_site_vrf_region: + cisco.mso.mso_schema_site_vrf_region: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -240,7 +240,7 @@ register: aws_add_context_underlay - name: Verify add_context_underlay - assert: + ansible.builtin.assert: that: - azure_add_context_underlay is changed - azure_add_context_underlay.current.contextProfileType == "container-overlay" @@ -248,31 +248,31 @@ - aws_add_context_underlay.current.contextProfileType == "container-overlay" - name: Get Validation status - mso_schema_validate: + cisco.mso.mso_schema_validate: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' state: query register: query_validate - name: Verify query_validate - assert: + ansible.builtin.assert: that: - query_validate is not changed - name: Verify query_validate result < 4.0 - assert: + ansible.builtin.assert: that: - query_validate.current.result == "true" when: version.current.version is version('4.0', '<') - name: Verify query_validate result => 4.0 - assert: + ansible.builtin.assert: that: - query_validate.current.result == true when: version.current.version is version('4.0', '>=') - name: Query all aws regions - mso_schema_site_vrf_region: + cisco.mso.mso_schema_site_vrf_region: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -282,7 +282,7 @@ register: aws_query_all - name: Query all azure regions - mso_schema_site_vrf_region: + cisco.mso.mso_schema_site_vrf_region: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -292,7 +292,7 @@ register: azure_query_all - name: Query specific aws region - mso_schema_site_vrf_region: + cisco.mso.mso_schema_site_vrf_region: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -303,7 +303,7 @@ register: aws_query_region - name: Query specific azure region - mso_schema_site_vrf_region: + cisco.mso.mso_schema_site_vrf_region: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -314,7 +314,7 @@ register: azure_query_region - name: Verify query - assert: + ansible.builtin.assert: that: - aws_query_all is not changed - azure_query_all is not changed @@ -332,7 +332,7 @@ - azure_query_region.current.cidrs.0.subnets == [] - name: Remove aws VRF region (check mode) - mso_schema_site_vrf_region: + cisco.mso.mso_schema_site_vrf_region: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -344,7 +344,7 @@ register: cm_rm_aws_region - name: Remove aws VRF region (normal mode) - mso_schema_site_vrf_region: + cisco.mso.mso_schema_site_vrf_region: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -355,7 +355,7 @@ register: nm_rm_aws_region - name: Remove azure VRF region (check mode) - mso_schema_site_vrf_region: + cisco.mso.mso_schema_site_vrf_region: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -367,7 +367,7 @@ register: cm_rm_azure_region - name: Remove azure VRF region (normal mode) - mso_schema_site_vrf_region: + cisco.mso.mso_schema_site_vrf_region: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -378,7 +378,7 @@ register: nm_rm_azure_region - name: Verify deletion - assert: + ansible.builtin.assert: that: - cm_rm_aws_region is changed - nm_rm_aws_region is changed @@ -418,7 +418,7 @@ register: add_vpn_gateway_router_azure - name: Verify adding VPN Gateway Router - assert: + ansible.builtin.assert: that: - add_vpn_gateway_router_aws.current.isVpnGatewayRouter == add_vpn_gateway_router_azure.current.isVpnGatewayRouter == true when: version.current.version is version('3.0.0a', '>=') @@ -478,7 +478,7 @@ register: nm_rm_vpn_gateway_router_azure - name: Verify removing VPN Gateway Router - assert: + ansible.builtin.assert: that: - cm_rm_vpn_gateway_router_aws is changed - nm_rm_vpn_gateway_router_aws is changed @@ -491,7 +491,7 @@ when: version.current.version is version('3.0.0a', '>=') - name: Use non_existing schema - mso_schema_site_vrf_region: + cisco.mso.mso_schema_site_vrf_region: <<: *mso_info schema: non_existing template: Template 1 @@ -503,7 +503,7 @@ ignore_errors: true - name: Use non_existing site - mso_schema_site_vrf_region: + cisco.mso.mso_schema_site_vrf_region: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -515,7 +515,7 @@ ignore_errors: true - name: Use non_existing site/template association - mso_schema_site_vrf_region: + cisco.mso.mso_schema_site_vrf_region: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 2 @@ -527,7 +527,7 @@ ignore_errors: true - name: Use non_existing VRF - mso_schema_site_vrf_region: + cisco.mso.mso_schema_site_vrf_region: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -539,7 +539,7 @@ ignore_errors: true - name: Use non_existing region - mso_schema_site_vrf_region: + cisco.mso.mso_schema_site_vrf_region: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -551,7 +551,7 @@ ignore_errors: true - name: Verify non_existing - assert: + ansible.builtin.assert: that: - non_existing_schema.msg == "Provided schema 'non_existing' does not exist." - non_existing_site.msg == "Site 'non_existing' is not a valid site name." @@ -559,19 +559,19 @@ - non_existing_region.msg == "Region 'non_existing' not found" - name: Verify non_existing (version < 3.3) - assert: + ansible.builtin.assert: that: - non_existing_vrf.msg == "Provided vrf 'non_existing' does not exist. Existing vrfs{{':'}} VRF1" when: version.current.version is version('3.3', '<') - name: Verify non_existing (version >= 3.3) - assert: + ansible.builtin.assert: that: - non_existing_vrf.msg == "Provided vrf 'non_existing' does not exist. Existing vrfs{{':'}} VRF1, VRF2" when: version.current.version is version('3.3', '>=') - name: Delete non_existing region - mso_schema_site_vrf_region: + cisco.mso.mso_schema_site_vrf_region: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -582,7 +582,7 @@ register: rm_non_existing_region - name: Verify rm_non_existing_region - assert: + ansible.builtin.assert: that: - rm_non_existing_region is not changed - rm_non_existing_region.previous == rm_non_existing_region.current == {}
\ No newline at end of file diff --git a/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_vrf_region_cidr/tasks/main.yml b/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_vrf_region_cidr/tasks/main.yml index 64d08821c..c818b6e59 100644 --- a/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_vrf_region_cidr/tasks/main.yml +++ b/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_vrf_region_cidr/tasks/main.yml @@ -7,13 +7,13 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI MultiSite host, username and password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: mso_hostname, mso_username and mso_password.' when: mso_hostname is not defined or mso_username is not defined or mso_password is not defined # CLEAN ENVIRONMENT - name: Set vars - set_fact: + ansible.builtin.set_fact: mso_info: &mso_info host: '{{ mso_hostname }}' username: '{{ mso_username }}' @@ -27,13 +27,13 @@ '{{ mso_site | default(\"ansible_test\") }}']" - name: Query MSO version - mso_version: + cisco.mso.mso_version: <<: *mso_info state: query register: version - name: Ensure site exists - mso_site: + cisco.mso.mso_site: <<: *mso_info site: '{{ mso_site | default("ansible_test") }}' apic_username: '{{ apic_username }}' @@ -44,7 +44,7 @@ state: present - name: Ensure site exists - mso_site: + cisco.mso.mso_site: <<: *mso_info site: 'aws_{{ mso_site | default("ansible_test") }}' apic_username: '{{ aws_apic_username }}' @@ -55,7 +55,7 @@ state: present - name: Ensure site exists - mso_site: + cisco.mso.mso_site: <<: *mso_info site: 'azure_{{ mso_site | default("ansible_test") }}' apic_username: '{{ azure_apic_username }}' @@ -66,7 +66,7 @@ state: present - name: Remove Schemas - mso_schema: + cisco.mso.mso_schema: <<: *mso_info schema: '{{ item }}' state: absent @@ -75,7 +75,7 @@ - '{{ mso_schema | default("ansible_test") }}' - name: Ensure sites removed from tenant ansible_test - mso_tenant_site: + cisco.mso.mso_tenant_site: <<: *mso_info tenant: ansible_test site: '{{ item }}' @@ -86,7 +86,7 @@ - 'azure_{{ mso_site | default("ansible_test") }}' - name: Ensure tenant ansible_test exist - mso_tenant: + cisco.mso.mso_tenant: <<: *mso_info tenant: ansible_test sites: @@ -96,7 +96,7 @@ state: present - name: Ensure AWS site is present under tenant ansible_test - mso_tenant_site: + cisco.mso.mso_tenant_site: <<: *mso_info tenant: ansible_test site: 'aws_{{ mso_site | default("ansible_test") }}' @@ -106,7 +106,7 @@ state: present - name: Ensure Azure site is present under tenant ansible_test - mso_tenant_site: + cisco.mso.mso_tenant_site: <<: *mso_info tenant: ansible_test site: 'azure_{{ mso_site | default("ansible_test") }}' @@ -114,7 +114,7 @@ state: present - name: Ensure schema 1 with Template 1 and 2 exists - mso_schema_template: + cisco.mso.mso_schema_template: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' tenant: ansible_test @@ -125,7 +125,7 @@ - Template 2 - name: Ensure schema 2 with Template 3 exists - mso_schema_template: + cisco.mso.mso_schema_template: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}_2' tenant: ansible_test @@ -133,7 +133,7 @@ state: present - name: Add physical site to Template 1 - mso_schema_site: + cisco.mso.mso_schema_site: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -141,7 +141,7 @@ state: present - name: Ensure VRF1 exists - mso_schema_template_vrf: + cisco.mso.mso_schema_template_vrf: <<: *mso_info schema: '{{ item.schema }}' template: '{{ item.template }}' @@ -153,7 +153,7 @@ - { schema: '{{ mso_schema | default("ansible_test") }}_2', template: 'Template 3' } - name: Ensure VRF2 exists - mso_schema_template_vrf: + cisco.mso.mso_schema_template_vrf: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -162,7 +162,7 @@ when: version.current.version is version('3', '<') - name: Ensure VRF1 exists at Site level for the physical site - mso_schema_site_vrf: + cisco.mso.mso_schema_site_vrf: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -172,7 +172,7 @@ # ADD SUBNET - name: Add a new CIDR in VRF1 at AWS site level (check mode) - mso_schema_site_vrf_region_cidr: &mso_present + cisco.mso.mso_schema_site_vrf_region_cidr: &mso_present <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -186,7 +186,7 @@ register: cm_add_cidr - name: Verify cm_add_cidr - assert: + ansible.builtin.assert: that: - cm_add_cidr is changed - cm_add_cidr.previous == {} @@ -194,12 +194,12 @@ - cm_add_cidr.current.primary == true - name: Add a new CIDR in VRF1 at AWS site level (normal mode) - mso_schema_site_vrf_region_cidr: + cisco.mso.mso_schema_site_vrf_region_cidr: <<: *mso_present register: nm_add_cidr - name: Verify nm_add_cidr - assert: + ansible.builtin.assert: that: - nm_add_cidr is changed - nm_add_cidr.previous == {} @@ -207,31 +207,31 @@ - nm_add_cidr.current.primary == true - name: Add same CIDR in VRF1 at AWS site level (check mode) - mso_schema_site_vrf_region_cidr: + cisco.mso.mso_schema_site_vrf_region_cidr: <<: *mso_present register: cm_add_cidr_again - name: Verify cm_add_cidr_again - assert: + ansible.builtin.assert: that: - cm_add_cidr_again is not changed - cm_add_cidr_again.current.ip == cm_add_cidr_again.previous.ip == '10.0.0.0/16' - cm_add_cidr_again.current.primary == cm_add_cidr_again.previous.primary == true - name: Add same CIDR in VRF1 at AWS site level (normal mode) - mso_schema_site_vrf_region_cidr: + cisco.mso.mso_schema_site_vrf_region_cidr: <<: *mso_present register: nm_add_cidr_again - name: Verify nm_add_cidr_again - assert: + ansible.builtin.assert: that: - nm_add_cidr_again is not changed - nm_add_cidr_again.current.ip == nm_add_cidr_again.previous.ip == '10.0.0.0/16' - nm_add_cidr_again.current.primary == nm_add_cidr_again.previous.primary == true - name: Add a CIDR in VRF1 at Azure site level (check mode) - mso_schema_site_vrf_region_cidr: + cisco.mso.mso_schema_site_vrf_region_cidr: <<: *mso_present site: 'azure_{{ mso_site | default("ansible_test") }}' region: westus @@ -241,7 +241,7 @@ register: cm_add_cidr_2 - name: Verify cm_add_cidr_2 - assert: + ansible.builtin.assert: that: - cm_add_cidr_2 is changed - cm_add_cidr_2.previous == {} @@ -249,7 +249,7 @@ - cm_add_cidr_2.current.primary == true - name: Add a CIDR in VRF1 at Azure site level (normal mode) - mso_schema_site_vrf_region_cidr: + cisco.mso.mso_schema_site_vrf_region_cidr: <<: *mso_present site: 'azure_{{ mso_site | default("ansible_test") }}' region: westus @@ -258,7 +258,7 @@ register: nm_add_cidr_2 - name: Verify nm_add_cidr_2 - assert: + ansible.builtin.assert: that: - nm_add_cidr_2 is changed - nm_add_cidr_2.previous == {} @@ -266,7 +266,7 @@ - nm_add_cidr_2.current.primary == true - name: Add a second CIDR in VRF1 at AWS site level (check mode) - mso_schema_site_vrf_region_cidr: &mso_present_2 + cisco.mso.mso_schema_site_vrf_region_cidr: &mso_present_2 <<: *mso_present site: 'aws_{{ mso_site | default("ansible_test") }}' region: us-west-1 @@ -276,7 +276,7 @@ register: cm_add_cidr_3 - name: Verify cm_add_cidr_3 - assert: + ansible.builtin.assert: that: - cm_add_cidr_3 is changed - cm_add_cidr_3.previous == {} @@ -284,12 +284,12 @@ - cm_add_cidr_3.current.primary == false - name: Add a second CIDR in VRF1 at AWS site level (normal mode) - mso_schema_site_vrf_region_cidr: + cisco.mso.mso_schema_site_vrf_region_cidr: <<: *mso_present_2 register: nm_add_cidr_3 - name: Verify nm_add_cidr_3 - assert: + ansible.builtin.assert: that: - nm_add_cidr_3 is changed - nm_add_cidr_3.previous == {} @@ -297,7 +297,7 @@ - nm_add_cidr_3.current.primary == false - name: Add a second CIDR in VRF1 at Azure site level (check mode) - mso_schema_site_vrf_region_cidr: + cisco.mso.mso_schema_site_vrf_region_cidr: <<: *mso_present site: 'azure_{{ mso_site | default("ansible_test") }}' region: westus @@ -307,7 +307,7 @@ register: cm_add_cidr_4 - name: Verify cm_add_cidr_4 - assert: + ansible.builtin.assert: that: - cm_add_cidr_4 is changed - cm_add_cidr_4.previous == {} @@ -315,7 +315,7 @@ - cm_add_cidr_4.current.primary == false - name: Add a second CIDR in VRF1 at Azure site level (normal mode) - mso_schema_site_vrf_region_cidr: + cisco.mso.mso_schema_site_vrf_region_cidr: <<: *mso_present site: 'azure_{{ mso_site | default("ansible_test") }}' region: westus @@ -324,7 +324,7 @@ register: nm_add_cidr_4 - name: Verify nm_add_cidr_4 - assert: + ansible.builtin.assert: that: - nm_add_cidr_4 is changed - nm_add_cidr_4.previous == {} @@ -333,7 +333,7 @@ # QUERY CIDR - name: Query CIDR in VRF1 at AWS site level (check mode) - mso_schema_site_vrf_region_cidr: &mso_query + cisco.mso.mso_schema_site_vrf_region_cidr: &mso_query <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -346,19 +346,19 @@ register: cm_query_cidr - name: Verify cm_query_cidr - assert: + ansible.builtin.assert: that: - cm_query_cidr is not changed - cm_query_cidr.current.ip == '10.0.0.0/16' - cm_query_cidr.current.primary == true - name: Query CIDR in VRF1 at AWS site level (normal mode) - mso_schema_site_vrf_region_cidr: + cisco.mso.mso_schema_site_vrf_region_cidr: <<: *mso_query register: nm_query_cidr - name: Query CIDR in VRF1 at Azure site level (check mode) - mso_schema_site_vrf_region_cidr: &mso_query_2 + cisco.mso.mso_schema_site_vrf_region_cidr: &mso_query_2 <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -371,19 +371,19 @@ register: cm_query_cidr_2 - name: Verify cm_query_cidr_2 - assert: + ansible.builtin.assert: that: - cm_query_cidr_2 is not changed - cm_query_cidr_2.current.ip == '10.1.0.0/16' - cm_query_cidr_2.current.primary == true - name: Query CIDR in VRF1 at Azure site level (normal mode) - mso_schema_site_vrf_region_cidr: + cisco.mso.mso_schema_site_vrf_region_cidr: <<: *mso_query_2 register: nm_query_cidr_2 - name: Verify nm_query_cidr_2 - assert: + ansible.builtin.assert: that: - nm_query_cidr_2 is not changed - nm_query_cidr_2.current.ip == '10.1.0.0/16' @@ -391,7 +391,7 @@ # QUERY ALL CIDR - name: Query all CIDR in VRF1 at AWS site level (check mode) - mso_schema_site_vrf_region_cidr: &mso_query_all + cisco.mso.mso_schema_site_vrf_region_cidr: &mso_query_all <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -403,7 +403,7 @@ register: cm_query_cidr_all_aws - name: Query CIDR in VRF1 at Azure site level (check mode) - mso_schema_site_vrf_region_cidr: + cisco.mso.mso_schema_site_vrf_region_cidr: <<: *mso_query_all site: 'azure_{{ mso_site | default("ansible_test") }}' region: westus @@ -412,7 +412,7 @@ register: cm_query_cidr_all_azure - name: Verify cm_query_cidr_all_aws and cm_query_cidr_all_azure - assert: + ansible.builtin.assert: that: - cm_query_cidr_all_aws is not changed - cm_query_cidr_all_aws.current[0].ip == '10.0.0.0/16' @@ -426,19 +426,19 @@ - cm_query_cidr_all_azure.current[1].primary == false - name: Query CIDR in VRF1 at AWS site level (normal mode) - mso_schema_site_vrf_region_cidr: + cisco.mso.mso_schema_site_vrf_region_cidr: <<: *mso_query_all register: nm_query_cidr_all_aws - name: Query CIDR in VRF1 at Azure site level (normal mode) - mso_schema_site_vrf_region_cidr: + cisco.mso.mso_schema_site_vrf_region_cidr: <<: *mso_query_all site: 'azure_{{ mso_site | default("ansible_test") }}' region: westus register: nm_query_cidr_all_azure - name: Verify nm_query_cidr_all_aws and nm_query_cidr_all_azure - assert: + ansible.builtin.assert: that: - nm_query_cidr_all_aws is not changed - nm_query_cidr_all_aws.current[0].ip == '10.0.0.0/16' @@ -452,14 +452,14 @@ - nm_query_cidr_all_azure.current[1].primary == false - name: Query CIDR in VRF2 (not present a Site level) for AWS Site (normal mode) - mso_schema_site_vrf_region_cidr: + cisco.mso.mso_schema_site_vrf_region_cidr: <<: *mso_query_all vrf: VRF2 ignore_errors: true register: nm_query_cidr_all_aws_2 - name: Query CIDR in VRF1 (with VRF present a Site level) for Physical Site (normal mode) - mso_schema_site_vrf_region_cidr: + cisco.mso.mso_schema_site_vrf_region_cidr: <<: *mso_query_all site: '{{ mso_site | default("ansible_test") }}' vrf: VRF1 @@ -467,7 +467,7 @@ register: nm_query_cidr_all_aws_3 - name: Verify nm_query_cidr_all_aws_2 and nm_query_cidr_all_aws_3 - assert: + ansible.builtin.assert: that: - nm_query_cidr_all_aws_2.msg == "Provided vrf 'VRF2' does not exist at site level." - nm_query_cidr_all_aws_3.msg == "Provided region 'us-west-1' does not exist. Existing regions{{':'}} " @@ -475,58 +475,58 @@ # REMOVE CIDR - name: Remove CIDR (check_mode) - mso_schema_site_vrf_region_cidr: + cisco.mso.mso_schema_site_vrf_region_cidr: <<: *mso_present_2 state: absent check_mode: true register: cm_remove_cidr - name: Verify cm_remove_cidr - assert: + ansible.builtin.assert: that: - cm_remove_cidr is changed - cm_remove_cidr.current == {} - name: Remove CIDR (normal mode) - mso_schema_site_vrf_region_cidr: + cisco.mso.mso_schema_site_vrf_region_cidr: <<: *mso_present_2 state: absent register: nm_remove_cidr - name: Verify nm_remove_cidr - assert: + ansible.builtin.assert: that: - nm_remove_cidr is changed - nm_remove_cidr.current == {} - name: Remove CIDR again (check_mode) - mso_schema_site_vrf_region_cidr: + cisco.mso.mso_schema_site_vrf_region_cidr: <<: *mso_present_2 state: absent check_mode: true register: cm_remove_cidr_again - name: Verify cm_remove_cidr_again - assert: + ansible.builtin.assert: that: - cm_remove_cidr_again is not changed - cm_remove_cidr_again.current == {} - name: Remove CIDR again (normal mode) - mso_schema_site_vrf_region_cidr: + cisco.mso.mso_schema_site_vrf_region_cidr: <<: *mso_present_2 state: absent register: nm_remove_cidr_again - name: Verify nm_remove_cidr_again - assert: + ansible.builtin.assert: that: - nm_remove_cidr_again is not changed - nm_remove_cidr_again.current == {} # QUERY NON-EXISTING CIDR - name: Query non-existing CIDR (check_mode) - mso_schema_site_vrf_region_cidr: + cisco.mso.mso_schema_site_vrf_region_cidr: <<: *mso_query cidr: non_existing_cidr check_mode: true @@ -534,14 +534,14 @@ register: cm_query_non_cidr - name: Query non-existing CIDR (normal mode) - mso_schema_site_vrf_region_cidr: + cisco.mso.mso_schema_site_vrf_region_cidr: <<: *mso_query cidr: non_existing_cidr ignore_errors: true register: nm_query_non_cidr - name: Verify query_non_cidr - assert: + ansible.builtin.assert: that: - cm_query_non_cidr is not changed - nm_query_non_cidr is not changed @@ -550,7 +550,7 @@ # QUERY NON-EXISTING region - name: Query non-existing region (check_mode) - mso_schema_site_vrf_region_cidr: + cisco.mso.mso_schema_site_vrf_region_cidr: <<: *mso_query region: non_existing_region check_mode: true @@ -558,14 +558,14 @@ register: cm_query_non_region - name: Query non-existing region (normal mode) - mso_schema_site_vrf_region_cidr: + cisco.mso.mso_schema_site_vrf_region_cidr: <<: *mso_query region: non_existing_region ignore_errors: true register: nm_query_non_region - name: Verify query_non_region - assert: + ansible.builtin.assert: that: - cm_query_non_region is not changed - nm_query_non_region is not changed @@ -574,7 +574,7 @@ # QUERY NON-EXISTING VRF - name: Query non-existing VRF (check_mode) - mso_schema_site_vrf_region_cidr: + cisco.mso.mso_schema_site_vrf_region_cidr: <<: *mso_query vrf: non_existing_vrf check_mode: true @@ -582,28 +582,28 @@ register: cm_query_non_vrf - name: Query non-existing VRF (normal mode) - mso_schema_site_vrf_region_cidr: + cisco.mso.mso_schema_site_vrf_region_cidr: <<: *mso_query vrf: non_existing_vrf ignore_errors: true register: nm_query_non_vrf - name: Verify query_non_vrf - assert: + ansible.builtin.assert: that: - cm_query_non_vrf is not changed - nm_query_non_vrf is not changed - cm_query_non_vrf == nm_query_non_vrf - name: Verify query_non_vrf (version < 3.0) - assert: + ansible.builtin.assert: that: - cm_query_non_vrf.msg == nm_query_non_vrf.msg == "Provided vrf 'non_existing_vrf' does not exist. Existing vrfs{{':'}} VRF1, VRF2" when: version.current.version is version('3', '<') # USE A NON-EXISTING STATE - name: Non-existing state for site cidr (check_mode) - mso_schema_site_vrf_region_cidr: + cisco.mso.mso_schema_site_vrf_region_cidr: <<: *mso_query state: non-existing-state check_mode: true @@ -611,14 +611,14 @@ register: cm_non_existing_state - name: Non-existing state for site cidr (normal_mode) - mso_schema_site_vrf_region_cidr: + cisco.mso.mso_schema_site_vrf_region_cidr: <<: *mso_query state: non-existing-state ignore_errors: true register: nm_non_existing_state - name: Verify non_existing_state - assert: + ansible.builtin.assert: that: - cm_non_existing_state is not changed - nm_non_existing_state is not changed @@ -627,7 +627,7 @@ # USE A NON-EXISTING SCHEMA - name: Non-existing schema for site cidr (check_mode) - mso_schema_site_vrf_region_cidr: + cisco.mso.mso_schema_site_vrf_region_cidr: <<: *mso_query schema: non-existing-schema check_mode: true @@ -635,14 +635,14 @@ register: cm_non_existing_schema - name: Non-existing schema for site cidr (normal_mode) - mso_schema_site_vrf_region_cidr: + cisco.mso.mso_schema_site_vrf_region_cidr: <<: *mso_query schema: non-existing-schema ignore_errors: true register: nm_non_existing_schema - name: Verify non_existing_schema - assert: + ansible.builtin.assert: that: - cm_non_existing_schema is not changed - nm_non_existing_schema is not changed @@ -651,7 +651,7 @@ # USE A NON-EXISTING TEMPLATE - name: Non-existing template for site cidr (check_mode) - mso_schema_site_vrf_region_cidr: + cisco.mso.mso_schema_site_vrf_region_cidr: <<: *mso_query template: non-existing-template check_mode: true @@ -659,14 +659,14 @@ register: cm_non_existing_template - name: Non-existing template for site cidr (normal_mode) - mso_schema_site_vrf_region_cidr: + cisco.mso.mso_schema_site_vrf_region_cidr: <<: *mso_query template: non-existing-template ignore_errors: true register: nm_non_existing_template - name: Verify non_existing_template - assert: + ansible.builtin.assert: that: - cm_non_existing_template is not changed - nm_non_existing_template is not changed @@ -675,7 +675,7 @@ # USE A NON-ASSOCIATED TEMPLATE - name: Non-associated template for site cidr (check_mode) - mso_schema_site_vrf_region_cidr: + cisco.mso.mso_schema_site_vrf_region_cidr: <<: *mso_query template: Template 2 check_mode: true @@ -683,14 +683,14 @@ register: cm_non_associated_template - name: Non-associated template for site cidr (normal_mode) - mso_schema_site_vrf_region_cidr: + cisco.mso.mso_schema_site_vrf_region_cidr: <<: *mso_query template: Template 2 ignore_errors: true register: nm_non_associated_template - name: Verify non_associated_template - assert: + ansible.builtin.assert: that: - cm_non_associated_template is not changed - nm_non_associated_template is not changed @@ -700,7 +700,7 @@ # USE A TEMPLATE WITHOUT ANY SITE - name: Add site VRF region cidr to Schema 2 Template 3 without any site associated (check mode) - mso_schema_site_vrf_region_cidr: + cisco.mso.mso_schema_site_vrf_region_cidr: <<: *mso_present schema: '{{ mso_schema | default("ansible_test") }}_2' template: Template 3 @@ -708,14 +708,14 @@ register: cm_no_site_associated - name: Add site VRF region cidr to Template 3 without any site associated (normal mode) - mso_schema_site_vrf_region_cidr: + cisco.mso.mso_schema_site_vrf_region_cidr: <<: *mso_present schema: '{{ mso_schema | default("ansible_test") }}_2' template: Template 3 register: nm_no_site_associated - name: Verify cm_no_site_associated and nm_no_site_associated - assert: + ansible.builtin.assert: that: - cm_no_site_associated is changed - nm_no_site_associated is changed
\ No newline at end of file diff --git a/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_vrf_region_cidr_subnet/tasks/main.yml b/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_vrf_region_cidr_subnet/tasks/main.yml index e5e8d3ca7..0858d5cf3 100644 --- a/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_vrf_region_cidr_subnet/tasks/main.yml +++ b/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_vrf_region_cidr_subnet/tasks/main.yml @@ -8,13 +8,13 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI MultiSite host, username and password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: mso_hostname, mso_username and mso_password.' when: mso_hostname is not defined or mso_username is not defined or mso_password is not defined # CLEAN ENVIRONMENT - name: Set vars - set_fact: + ansible.builtin.set_fact: mso_info: &mso_info host: '{{ mso_hostname }}' username: '{{ mso_username }}' @@ -27,13 +27,13 @@ { 'site': 'azure_{{ mso_site | default(\"ansible_test\") }}', 'region': 'westus', 'cidr': '10.1.0.0/16'}]" - name: Query MSO version - mso_version: + cisco.mso.mso_version: <<: *mso_info state: query register: version - name: Ensure site exists - mso_site: + cisco.mso.mso_site: <<: *mso_info site: 'aws_{{ mso_site | default("ansible_test") }}' apic_username: '{{ aws_apic_username }}' @@ -44,7 +44,7 @@ state: present - name: Ensure site exists - mso_site: + cisco.mso.mso_site: <<: *mso_info site: 'azure_{{ mso_site | default("ansible_test") }}' apic_username: '{{ azure_apic_username }}' @@ -55,7 +55,7 @@ state: present - name: Remove Schemas - mso_schema: + cisco.mso.mso_schema: <<: *mso_info schema: '{{ item }}' state: absent @@ -64,7 +64,7 @@ - '{{ mso_schema | default("ansible_test") }}' - name: Ensure sites removed from tenant ansible_test - mso_tenant_site: + cisco.mso.mso_tenant_site: <<: *mso_info tenant: ansible_test site: '{{ item }}' @@ -75,7 +75,7 @@ - 'azure_{{ mso_site | default("ansible_test") }}' - name: Ensure tenant ansible_test exist - mso_tenant: + cisco.mso.mso_tenant: <<: *mso_info tenant: ansible_test users: @@ -83,7 +83,7 @@ state: present - name: Ensure AWS site is present under tenant ansible_test - mso_tenant_site: + cisco.mso.mso_tenant_site: <<: *mso_info tenant: ansible_test site: 'aws_{{ mso_site | default("ansible_test") }}' @@ -93,7 +93,7 @@ state: present - name: Ensure Azure site is present under tenant ansible_test - mso_tenant_site: + cisco.mso.mso_tenant_site: <<: *mso_info tenant: ansible_test site: 'azure_{{ mso_site | default("ansible_test") }}' @@ -101,7 +101,7 @@ state: present - name: Ensure schema 1 with Template 1 and 2 exists - mso_schema_template: + cisco.mso.mso_schema_template: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' tenant: ansible_test @@ -112,7 +112,7 @@ - Template 2 - name: Ensure schema 2 with Template 3 exists - mso_schema_template: + cisco.mso.mso_schema_template: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}_2' tenant: ansible_test @@ -120,7 +120,7 @@ state: present - name: Add a new sites to a Template 1 - mso_schema_site: + cisco.mso.mso_schema_site: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ item.site }}' @@ -130,7 +130,7 @@ when: version.current.version is version('3', '<') - name: Ensure VRF1 exists - mso_schema_template_vrf: + cisco.mso.mso_schema_template_vrf: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -138,7 +138,7 @@ state: present - name: Ensure region for VRF1 at site level exists - mso_schema_site_vrf_region_cidr: + cisco.mso.mso_schema_site_vrf_region_cidr: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -152,7 +152,7 @@ # ADD SUBNET - name: Add a new subnet to AWS CIDR in VRF1 at site level (check mode) - mso_schema_site_vrf_region_cidr_subnet: &mso_present + cisco.mso.mso_schema_site_vrf_region_cidr_subnet: &mso_present <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -167,7 +167,7 @@ register: cm_add_subnet - name: Verify cm_add_subnet - assert: + ansible.builtin.assert: that: - cm_add_subnet is changed - cm_add_subnet.previous == {} @@ -175,12 +175,12 @@ - cm_add_subnet.current.zone == 'us-west-1a' - name: Add a new subnet to AWS CIDR in VRF1 at site level (normal mode) - mso_schema_site_vrf_region_cidr_subnet: + cisco.mso.mso_schema_site_vrf_region_cidr_subnet: <<: *mso_present register: nm_add_subnet - name: Verify nm_add_subnet - assert: + ansible.builtin.assert: that: - nm_add_subnet is changed - nm_add_subnet.previous == {} @@ -188,31 +188,31 @@ - nm_add_subnet.current.zone == 'us-west-1a' - name: Add same subnet again to AWS CIDR in VRF1 at site level (check mode) - mso_schema_site_vrf_region_cidr_subnet: + cisco.mso.mso_schema_site_vrf_region_cidr_subnet: <<: *mso_present register: cm_add_subnet_again - name: Verify cm_add_subnet_again - assert: + ansible.builtin.assert: that: - cm_add_subnet_again is not changed - cm_add_subnet_again.current.ip == cm_add_subnet_again.previous.ip == '10.0.0.0/24' - cm_add_subnet_again.current.zone == cm_add_subnet_again.previous.zone == 'us-west-1a' - name: Add same subnet again to AWS CIDR in VRF1 at site level (normal mode) - mso_schema_site_vrf_region_cidr_subnet: + cisco.mso.mso_schema_site_vrf_region_cidr_subnet: <<: *mso_present register: nm_add_subnet_again - name: Verify nm_add_subnet_again - assert: + ansible.builtin.assert: that: - nm_add_subnet_again is not changed - nm_add_subnet_again.current.ip == nm_add_subnet_again.previous.ip == '10.0.0.0/24' - nm_add_subnet_again.current.zone == nm_add_subnet_again.previous.zone == 'us-west-1a' - name: Add a new subnet to Azure CIDR in VRF1 at site level (check mode) - mso_schema_site_vrf_region_cidr_subnet: + cisco.mso.mso_schema_site_vrf_region_cidr_subnet: <<: *mso_present site: 'azure_{{ mso_site | default("ansible_test") }}' region: westus @@ -223,7 +223,7 @@ register: cm_add_subnet_2 - name: Verify cm_add_subnet_2 - assert: + ansible.builtin.assert: that: - cm_add_subnet_2 is changed - cm_add_subnet_2.previous == {} @@ -231,7 +231,7 @@ - cm_add_subnet_2.current.zone == '' - name: Add a new subnet to Azure CIDR in VRF1 at site level (normal mode) - mso_schema_site_vrf_region_cidr_subnet: + cisco.mso.mso_schema_site_vrf_region_cidr_subnet: <<: *mso_present site: 'azure_{{ mso_site | default("ansible_test") }}' region: westus @@ -241,7 +241,7 @@ register: nm_add_subnet_2 - name: Verify nm_add_subnet_2 - assert: + ansible.builtin.assert: that: - nm_add_subnet_2 is changed - nm_add_subnet_2.previous == {} @@ -249,7 +249,7 @@ - nm_add_subnet_2.current.zone == '' - name: Add a second subnet to Azure CIDR in VRF1 at site level for VGW (check mode) - mso_schema_site_vrf_region_cidr_subnet: + cisco.mso.mso_schema_site_vrf_region_cidr_subnet: <<: *mso_present site: 'azure_{{ mso_site | default("ansible_test") }}' region: westus @@ -261,7 +261,7 @@ register: cm_add_subnet_3 - name: Verify cm_add_subnet_3 - assert: + ansible.builtin.assert: that: - cm_add_subnet_3 is changed - cm_add_subnet_3.previous == {} @@ -271,7 +271,7 @@ # VGW - name: Add a second subnet to Azure CIDR in VRF1 at site level for VGW (normal mode) - mso_schema_site_vrf_region_cidr_subnet: + cisco.mso.mso_schema_site_vrf_region_cidr_subnet: <<: *mso_present site: 'azure_{{ mso_site | default("ansible_test") }}' region: westus @@ -282,7 +282,7 @@ register: nm_add_subnet_3 - name: Verify nm_add_subnet_3 - assert: + ansible.builtin.assert: that: - nm_add_subnet_3 is changed - nm_add_subnet_3.previous == {} @@ -292,7 +292,7 @@ # Private Link Label - name: Add a new subnet to Azure CIDR in VRF1 at site level for Private Link Label (MSO >3.3) - mso_schema_site_vrf_region_cidr_subnet: + cisco.mso.mso_schema_site_vrf_region_cidr_subnet: <<: *mso_present site: 'azure_{{ mso_site | default("ansible_test") }}' region: westus @@ -304,7 +304,7 @@ when: version.current.version is version('3.3', '>=') - name: Verify nm_add_subnet_4 - assert: + ansible.builtin.assert: that: - nm_add_subnet_4 is changed - nm_add_subnet_4.current.ip == '10.1.0.0/24' @@ -313,7 +313,7 @@ # QUERY SUBNETS - name: Query subnet to AWS CIDR in VRF1 at site level (check mode) - mso_schema_site_vrf_region_cidr_subnet: &mso_query + cisco.mso.mso_schema_site_vrf_region_cidr_subnet: &mso_query <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -327,25 +327,25 @@ register: cm_query_subnet - name: Verify cm_query_subnet - assert: + ansible.builtin.assert: that: - cm_query_subnet is not changed - cm_query_subnet.current.ip == '10.0.0.0/24' - cm_query_subnet.current.zone == 'us-west-1a' - name: Query subnet to AWS CIDR in VRF1 at site level (normal mode) - mso_schema_site_vrf_region_cidr_subnet: + cisco.mso.mso_schema_site_vrf_region_cidr_subnet: <<: *mso_query register: nm_query_subnet - name: Verify nm_query_subnet - assert: + ansible.builtin.assert: that: - nm_query_subnet is not changed # QUERY ALL SUBNETS - name: Query all subnets to AWS CIDR in VRF1 at site level (check mode) - mso_schema_site_vrf_region_cidr_subnet: &mso_query_all + cisco.mso.mso_schema_site_vrf_region_cidr_subnet: &mso_query_all <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -358,7 +358,7 @@ register: cm_query_subnet_all_aws - name: Query all subnets to Azure CIDR in VRF1 at site level (check mode) - mso_schema_site_vrf_region_cidr_subnet: + cisco.mso.mso_schema_site_vrf_region_cidr_subnet: <<: *mso_query_all site: 'azure_{{ mso_site | default("ansible_test") }}' region: westus @@ -368,7 +368,7 @@ register: cm_query_subnet_all_azure - name: Verify cm_query_subnet_all_aws and cm_query_subnet_all_azure - assert: + ansible.builtin.assert: that: - cm_query_subnet_all_aws is not changed - cm_query_subnet_all_aws.current[0].ip == '10.0.0.0/24' @@ -378,7 +378,7 @@ - cm_query_subnet_all_azure.current[1].ip == '10.1.1.0/24' - name: Verify cm_query_subnet_all_aws and cm_query_subnet_all_azure zone - assert: + ansible.builtin.assert: that: - cm_query_subnet_all_azure.current[0].zone == '' - cm_query_subnet_all_azure.current[1].zone == '' @@ -386,19 +386,19 @@ - name: Verify cm_query_subnet_all_aws and cm_query_subnet_all_azure zone - assert: + ansible.builtin.assert: that: - cm_query_subnet_all_azure.current[0].zone == 'default' - cm_query_subnet_all_azure.current[1].zone == 'default' when: version.current.version is version('4.0', '>=') - name: Query subnet to AWS CIDR in VRF1 at site level (normal mode) - mso_schema_site_vrf_region_cidr_subnet: + cisco.mso.mso_schema_site_vrf_region_cidr_subnet: <<: *mso_query_all register: nm_query_subnet_all_aws - name: Query subnet to AWS CIDR in VRF1 at site level (normal mode) - mso_schema_site_vrf_region_cidr_subnet: + cisco.mso.mso_schema_site_vrf_region_cidr_subnet: <<: *mso_query_all site: 'azure_{{ mso_site | default("ansible_test") }}' region: westus @@ -407,7 +407,7 @@ register: nm_query_subnet_all_azure - name: Verify nm_query_subnet_all_aws and nm_query_subnet_all_azure - assert: + ansible.builtin.assert: that: - nm_query_subnet_all_aws is not changed - nm_query_subnet_all_aws.current[0].ip == '10.0.0.0/24' @@ -417,7 +417,7 @@ - nm_query_subnet_all_azure.current[1].ip == '10.1.1.0/24' - name: Verify cm_query_subnet_all_aws and cm_query_subnet_all_azure zone - assert: + ansible.builtin.assert: that: - nm_query_subnet_all_azure.current[0].zone == '' - nm_query_subnet_all_azure.current[1].zone == '' @@ -425,7 +425,7 @@ - name: Verify cm_query_subnet_all_aws and cm_query_subnet_all_azure zone - assert: + ansible.builtin.assert: that: - nm_query_subnet_all_azure.current[0].zone == 'default' - nm_query_subnet_all_azure.current[1].zone == 'default' @@ -436,7 +436,7 @@ when: version.current.version is version('3.3', '>=') block: - name: Ensure VRF2 exists - mso_schema_template_vrf: + cisco.mso.mso_schema_template_vrf: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -444,7 +444,7 @@ state: present - name: Add a secondary CIDR in VRF1 at AWS site level - mso_schema_site_vrf_region_cidr: &secondary_cidr + cisco.mso.mso_schema_site_vrf_region_cidr: &secondary_cidr <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -456,7 +456,7 @@ register: nm_add_cidr_3 - name: Verify nm_add_cidr_3 - assert: + ansible.builtin.assert: that: - nm_add_cidr_3 is changed - nm_add_cidr_3.previous == {} @@ -464,7 +464,7 @@ - nm_add_cidr_3.current.primary == false - name: Add a secondary CIDR in VRF1 at Azure site level - mso_schema_site_vrf_region_cidr: + cisco.mso.mso_schema_site_vrf_region_cidr: <<: *secondary_cidr schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -476,7 +476,7 @@ register: nm_add_cidr_4 - name: Verify nm_add_cidr_4 - assert: + ansible.builtin.assert: that: - nm_add_cidr_4 is changed - nm_add_cidr_4.previous == {} @@ -484,7 +484,7 @@ - nm_add_cidr_4.current.primary == false - name: Add hosted vrf parameters in VRF1 at Azure site level - mso_schema_site_vrf_region_cidr_subnet: + cisco.mso.mso_schema_site_vrf_region_cidr_subnet: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -500,7 +500,7 @@ register: azure_add_hosted_vrf - name: Verify azure_add_hosted_vrf - assert: + ansible.builtin.assert: that: - azure_add_hosted_vrf is changed - azure_add_hosted_vrf.previous == {} @@ -508,7 +508,7 @@ - azure_add_hosted_vrf.current.vrfRef.vrfName == 'VRF2' - name: Add hosted vrf parameters in VRF1 at AWS site level - mso_schema_site_vrf_region_cidr_subnet: &aws_cidr + cisco.mso.mso_schema_site_vrf_region_cidr_subnet: &aws_cidr <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -524,7 +524,7 @@ register: aws_add_hosted_vrf - name: Verify aws_add_hosted_vrf - assert: + ansible.builtin.assert: that: - aws_add_hosted_vrf is changed - aws_add_hosted_vrf.previous == {} @@ -532,89 +532,89 @@ - aws_add_hosted_vrf.current.vrfRef.vrfName == 'VRF2' - name: Get Validation status - mso_schema_validate: + cisco.mso.mso_schema_validate: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' state: query register: query_validate - name: Verify query_validate - assert: + ansible.builtin.assert: that: - query_validate is not changed - name: Verify query_validate result < 4.0 - assert: + ansible.builtin.assert: that: - query_validate.current.result == "true" when: version.current.version is version('4.0', '<') - name: Verify query_validate result => 4.0 - assert: + ansible.builtin.assert: that: - query_validate.current.result == true when: version.current.version is version('4.0', '>=') # REMOVE SUBNETS - name: Remove Subnet from CIDR (check_mode) - mso_schema_site_vrf_region_cidr_subnet: + cisco.mso.mso_schema_site_vrf_region_cidr_subnet: <<: *mso_present state: absent check_mode: true register: cm_remove_subnet - name: Verify cm_remove_subnet - assert: + ansible.builtin.assert: that: - cm_remove_subnet is changed - cm_remove_subnet.current == {} - name: Remove Subnet from CIDR (normal mode) - mso_schema_site_vrf_region_cidr_subnet: + cisco.mso.mso_schema_site_vrf_region_cidr_subnet: <<: *mso_present state: absent register: nm_remove_subnet - name: Verify nm_remove_subnet - assert: + ansible.builtin.assert: that: - nm_remove_subnet is changed - nm_remove_subnet.current == {} - name: Remove Subnet from CIDR again (check_mode) - mso_schema_site_vrf_region_cidr_subnet: + cisco.mso.mso_schema_site_vrf_region_cidr_subnet: <<: *mso_present state: absent check_mode: true register: cm_remove_subnet_again - name: Verify cm_remove_subnet_again - assert: + ansible.builtin.assert: that: - cm_remove_subnet_again is not changed - cm_remove_subnet_again.current == {} - name: Remove Subnet from CIDR again (normal mode) - mso_schema_site_vrf_region_cidr_subnet: + cisco.mso.mso_schema_site_vrf_region_cidr_subnet: <<: *mso_present state: absent register: nm_remove_subnet_again - name: Verify nm_remove_subnet_again - assert: + ansible.builtin.assert: that: - nm_remove_subnet_again is not changed - nm_remove_subnet_again.current == {} - name: Remove Subnet from CIDR (normal mode) - mso_schema_site_vrf_region_cidr_subnet: + cisco.mso.mso_schema_site_vrf_region_cidr_subnet: <<: *aws_cidr state: absent register: remove_subnet when: version.current.version is version('3.3', '>=') - name: Verify nm_remove_subnet - assert: + ansible.builtin.assert: that: - remove_subnet is changed - remove_subnet.current == {} @@ -622,7 +622,7 @@ # QUERY NON-EXISTING subnet in CIDR - name: Query non-existing subnet (check_mode) - mso_schema_site_vrf_region_cidr_subnet: + cisco.mso.mso_schema_site_vrf_region_cidr_subnet: <<: *mso_query subnet: non_existing_subnet check_mode: true @@ -630,14 +630,14 @@ register: cm_query_non_subnet - name: Query non-existing subnet (normal mode) - mso_schema_site_vrf_region_cidr_subnet: + cisco.mso.mso_schema_site_vrf_region_cidr_subnet: <<: *mso_query subnet: non_existing_subnet ignore_errors: true register: nm_query_non_subnet - name: Verify query_non_subnet - assert: + ansible.builtin.assert: that: - cm_query_non_subnet is not changed - nm_query_non_subnet is not changed @@ -647,7 +647,7 @@ # QUERY NON-EXISTING CIDR - name: Query non-existing CIDR (check_mode) - mso_schema_site_vrf_region_cidr_subnet: + cisco.mso.mso_schema_site_vrf_region_cidr_subnet: <<: *mso_query cidr: non_existing_cidr check_mode: true @@ -655,34 +655,34 @@ register: cm_query_non_cidr - name: Query non-existing CIDR (normal mode) - mso_schema_site_vrf_region_cidr_subnet: + cisco.mso.mso_schema_site_vrf_region_cidr_subnet: <<: *mso_query cidr: non_existing_cidr ignore_errors: true register: nm_query_non_cidr - name: Verify query_non_cidr - assert: + ansible.builtin.assert: that: - cm_query_non_cidr is not changed - nm_query_non_cidr is not changed - cm_query_non_cidr == nm_query_non_cidr - name: Verify query_non_cidr value (version < 3.3) - assert: + ansible.builtin.assert: that: - cm_query_non_cidr.msg == nm_query_non_cidr.msg == "Provided CIDR IP 'non_existing_cidr' does not exist. Existing CIDR IPs{{':'}} 10.0.0.0/16. Use mso_schema_site_vrf_region_cidr to create it." when: version.current.version is version('3.3', '<') - name: Verify query_non_cidr value (version >= 3.3) - assert: + ansible.builtin.assert: that: - cm_query_non_cidr.msg == nm_query_non_cidr.msg == "Provided CIDR IP 'non_existing_cidr' does not exist. Existing CIDR IPs{{':'}} 10.0.0.0/16, 10.2.0.0/16. Use mso_schema_site_vrf_region_cidr to create it." when: version.current.version is version('3.3', '>=') # QUERY NON-EXISTING region - name: Query non-existing region (check_mode) - mso_schema_site_vrf_region_cidr_subnet: + cisco.mso.mso_schema_site_vrf_region_cidr_subnet: <<: *mso_query region: non_existing_region check_mode: true @@ -690,14 +690,14 @@ register: cm_query_non_region - name: Query non-existing region (normal mode) - mso_schema_site_vrf_region_cidr_subnet: + cisco.mso.mso_schema_site_vrf_region_cidr_subnet: <<: *mso_query region: non_existing_region ignore_errors: true register: nm_query_non_region - name: Verify query_non_region - assert: + ansible.builtin.assert: that: - cm_query_non_region is not changed - nm_query_non_region is not changed @@ -706,7 +706,7 @@ # QUERY NON-EXISTING VRF - name: Query non-existing VRF (check_mode) - mso_schema_site_vrf_region_cidr_subnet: + cisco.mso.mso_schema_site_vrf_region_cidr_subnet: <<: *mso_query vrf: non_existing_vrf check_mode: true @@ -714,14 +714,14 @@ register: cm_query_non_vrf - name: Query non-existing VRF (normal mode) - mso_schema_site_vrf_region_cidr_subnet: + cisco.mso.mso_schema_site_vrf_region_cidr_subnet: <<: *mso_query vrf: non_existing_vrf ignore_errors: true register: nm_query_non_vrf - name: Verify query_non_vrf - assert: + ansible.builtin.assert: that: - cm_query_non_vrf is not changed - nm_query_non_vrf is not changed @@ -730,7 +730,7 @@ # USE A NON-EXISTING STATE - name: Non-existing state for site cidr subnet (check_mode) - mso_schema_site_vrf_region_cidr_subnet: + cisco.mso.mso_schema_site_vrf_region_cidr_subnet: <<: *mso_query state: non-existing-state check_mode: true @@ -738,14 +738,14 @@ register: cm_non_existing_state - name: Non-existing state for site cidr subnet (normal_mode) - mso_schema_site_vrf_region_cidr_subnet: + cisco.mso.mso_schema_site_vrf_region_cidr_subnet: <<: *mso_query state: non-existing-state ignore_errors: true register: nm_non_existing_state - name: Verify non_existing_state - assert: + ansible.builtin.assert: that: - cm_non_existing_state is not changed - nm_non_existing_state is not changed @@ -754,7 +754,7 @@ # USE A NON-EXISTING SCHEMA - name: Non-existing schema for site cidr subnet (check_mode) - mso_schema_site_vrf_region_cidr_subnet: + cisco.mso.mso_schema_site_vrf_region_cidr_subnet: <<: *mso_query schema: non-existing-schema check_mode: true @@ -762,14 +762,14 @@ register: cm_non_existing_schema - name: Non-existing schema for site cidr subnet (normal_mode) - mso_schema_site_vrf_region_cidr_subnet: + cisco.mso.mso_schema_site_vrf_region_cidr_subnet: <<: *mso_query schema: non-existing-schema ignore_errors: true register: nm_non_existing_schema - name: Verify non_existing_schema - assert: + ansible.builtin.assert: that: - cm_non_existing_schema is not changed - nm_non_existing_schema is not changed @@ -778,7 +778,7 @@ # USE A NON-EXISTING TEMPLATE - name: Non-existing template for site cidr subnet (check_mode) - mso_schema_site_vrf_region_cidr_subnet: + cisco.mso.mso_schema_site_vrf_region_cidr_subnet: <<: *mso_query template: non-existing-template check_mode: true @@ -786,14 +786,14 @@ register: cm_non_existing_template - name: Non-existing template for site cidr subnet (normal_mode) - mso_schema_site_vrf_region_cidr_subnet: + cisco.mso.mso_schema_site_vrf_region_cidr_subnet: <<: *mso_query template: non-existing-template ignore_errors: true register: nm_non_existing_template - name: Verify non_existing_template - assert: + ansible.builtin.assert: that: - cm_non_existing_template is not changed - nm_non_existing_template is not changed @@ -802,7 +802,7 @@ # USE A NON-ASSOCIATED TEMPLATE - name: Non-associated template for site cidr subnet (check_mode) - mso_schema_site_vrf_region_cidr_subnet: + cisco.mso.mso_schema_site_vrf_region_cidr_subnet: <<: *mso_query template: Template 2 check_mode: true @@ -810,14 +810,14 @@ register: cm_non_associated_template - name: Non-associated template for site cidr subnet (normal_mode) - mso_schema_site_vrf_region_cidr_subnet: + cisco.mso.mso_schema_site_vrf_region_cidr_subnet: <<: *mso_query template: Template 2 ignore_errors: true register: nm_non_associated_template - name: Verify non_associated_template - assert: + ansible.builtin.assert: that: - cm_non_associated_template is not changed - nm_non_associated_template is not changed @@ -827,7 +827,7 @@ # USE A TEMPLATE WITHOUT ANY SITE - name: Add site cidr subnet to Schema 2 Template 3 without any site associated (check mode) - mso_schema_site_vrf_region_cidr_subnet: + cisco.mso.mso_schema_site_vrf_region_cidr_subnet: <<: *mso_query schema: '{{ mso_schema | default("ansible_test") }}_2' template: Template 3 @@ -836,7 +836,7 @@ register: cm_no_site_associated - name: Add site cidr subnet to Template 3 without any site associated (normal mode) - mso_schema_site_vrf_region_cidr_subnet: + cisco.mso.mso_schema_site_vrf_region_cidr_subnet: <<: *mso_query schema: '{{ mso_schema | default("ansible_test") }}_2' template: Template 3 @@ -844,7 +844,7 @@ register: nm_no_site_associated - name: Verify cm_no_site_associated and nm_no_site_associated - assert: + ansible.builtin.assert: that: - cm_no_site_associated is not changed - nm_no_site_associated is not changed @@ -852,7 +852,7 @@ # Checking if issue when adding subnet to Hub Network (#126) - name: Add hub network in VRF1 region us-west-1 at AWS site level - mso_schema_site_vrf_region_hub_network: + cisco.mso.mso_schema_site_vrf_region_hub_network: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -865,7 +865,7 @@ state: present - name: Add a new subnet to AWS CIDR in VRF1 at site level - mso_schema_site_vrf_region_cidr_subnet: + cisco.mso.mso_schema_site_vrf_region_cidr_subnet: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -880,7 +880,7 @@ register: nm_add_subnet_hub_network - name: Verify nm_add_subnet_hub_network - assert: + ansible.builtin.assert: that: - nm_add_subnet_hub_network is changed - nm_add_subnet_hub_network.current.usage == 'gateway'
\ No newline at end of file diff --git a/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_vrf_region_hub_network/tasks/hub_network.yml b/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_vrf_region_hub_network/tasks/hub_network.yml index 33fde6710..61936621a 100644 --- a/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_vrf_region_hub_network/tasks/hub_network.yml +++ b/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_vrf_region_hub_network/tasks/hub_network.yml @@ -6,7 +6,7 @@ # CLEAN ENVIRONMENT - name: Set vars - set_fact: + ansible.builtin.set_fact: mso_info: &mso_info host: '{{ mso_hostname }}' username: '{{ mso_username }}' @@ -20,7 +20,7 @@ '{{ mso_site | default(\"ansible_test\") }}']" - name: Ensure site exists - mso_site: + cisco.mso.mso_site: <<: *mso_info site: 'aws_{{ mso_site | default("ansible_test") }}' apic_username: '{{ aws_apic_username }}' @@ -31,7 +31,7 @@ state: present - name: Ensure site exists - mso_site: + cisco.mso.mso_site: <<: *mso_info site: 'azure_{{ mso_site | default("ansible_test") }}' apic_username: '{{ azure_apic_username }}' @@ -42,7 +42,7 @@ state: present - name: Remove Schemas - mso_schema: + cisco.mso.mso_schema: <<: *mso_info schema: '{{ item }}' state: absent @@ -51,7 +51,7 @@ - '{{ mso_schema | default("ansible_test") }}' - name: Ensure sites removed from tenant ansible_test - mso_tenant_site: + cisco.mso.mso_tenant_site: <<: *mso_info tenant: ansible_test site: '{{ item }}' @@ -62,7 +62,7 @@ - 'azure_{{ mso_site | default("ansible_test") }}' - name: Ensure tenant ansible_test exist - mso_tenant: + cisco.mso.mso_tenant: <<: *mso_info tenant: ansible_test # sites: @@ -72,7 +72,7 @@ state: present - name: Ensure AWS site is present under tenant ansible_test - mso_tenant_site: + cisco.mso.mso_tenant_site: <<: *mso_info tenant: ansible_test site: 'aws_{{ mso_site | default("ansible_test") }}' @@ -82,7 +82,7 @@ state: present - name: Ensure Azure site is present under tenant ansible_test - mso_tenant_site: + cisco.mso.mso_tenant_site: <<: *mso_info tenant: ansible_test site: 'azure_{{ mso_site | default("ansible_test") }}' @@ -90,7 +90,7 @@ state: present - name: Ensure schema 1 with Template 1 and 2 exists - mso_schema_template: + cisco.mso.mso_schema_template: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' tenant: ansible_test @@ -101,7 +101,7 @@ - Template 2 - name: Ensure schema 2 with Template 3 exists - mso_schema_template: + cisco.mso.mso_schema_template: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}_2' tenant: ansible_test @@ -109,7 +109,7 @@ state: present - name: Ensure VRF1 exists - mso_schema_template_vrf: + cisco.mso.mso_schema_template_vrf: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -117,7 +117,7 @@ state: present - name: Add a new CIDR in VRF1 at AWS site level (check mode) - mso_schema_site_vrf_region_cidr: &mso_present + cisco.mso.mso_schema_site_vrf_region_cidr: &mso_present <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -131,7 +131,7 @@ register: cm_add_cidr - name: Verify cm_add_cidr - assert: + ansible.builtin.assert: that: - cm_add_cidr is changed - cm_add_cidr.previous == {} @@ -139,12 +139,12 @@ - cm_add_cidr.current.primary == true - name: Add a new CIDR in VRF1 at AWS site level (normal mode) - mso_schema_site_vrf_region_cidr: + cisco.mso.mso_schema_site_vrf_region_cidr: <<: *mso_present register: nm_add_cidr - name: Verify nm_add_cidr - assert: + ansible.builtin.assert: that: - nm_add_cidr is changed - nm_add_cidr.previous == {} @@ -153,7 +153,7 @@ # ADD Hub Network - name: Add hub network in VRF1 region us-west-1 at AWS site level (check mode) - mso_schema_site_vrf_region_hub_network: + cisco.mso.mso_schema_site_vrf_region_hub_network: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -168,7 +168,7 @@ register: cm_add_hub_network - name: Add hub network in VRF1 region us-west-1 at AWS site level (normal mode) - mso_schema_site_vrf_region_hub_network: + cisco.mso.mso_schema_site_vrf_region_hub_network: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -182,7 +182,7 @@ register: nm_add_hub_network - name: Verify cm_add_hub_network and nm_add_hub_network - assert: + ansible.builtin.assert: that: - cm_add_hub_network is changed - nm_add_hub_network is changed @@ -195,7 +195,7 @@ # Add hub network again - name: Add hub network again in VRF1 region us-west-1 at AWS site level (normal mode) - mso_schema_site_vrf_region_hub_network: + cisco.mso.mso_schema_site_vrf_region_hub_network: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -209,7 +209,7 @@ register: nm_add_hub_network_again - name: Verify nm_add_hub_network_again - assert: + ansible.builtin.assert: that: - nm_add_hub_network_again is not changed - nm_add_hub_network_again.previous.name == nm_add_hub_network_again.current.name == "hub-test" @@ -217,7 +217,7 @@ # Update hub network - name: Update hub network in VRF1 region us-west-1 at AWS site level (check_mode) - mso_schema_site_vrf_region_hub_network: + cisco.mso.mso_schema_site_vrf_region_hub_network: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -232,7 +232,7 @@ register: cm_update_hub_network - name: Update hub network in VRF1 region us-west-1 at AWS site level (normal_mode) - mso_schema_site_vrf_region_hub_network: + cisco.mso.mso_schema_site_vrf_region_hub_network: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -246,7 +246,7 @@ register: nm_update_hub_network - name: Verify cm_update_hub_network and nm_update_hub_network - assert: + ansible.builtin.assert: that: - cm_update_hub_network is changed - nm_update_hub_network is changed @@ -261,7 +261,7 @@ # Query Hub Network - name: Query hub network in VRF1 region us-west-1 at AWS site level - mso_schema_site_vrf_region_hub_network: + cisco.mso.mso_schema_site_vrf_region_hub_network: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -273,7 +273,7 @@ register: cm_query_hub_network - name: Verify cm_query_hub_network - assert: + ansible.builtin.assert: that: - cm_query_hub_network is not changed - cm_query_hub_network.current.name == "hub-default" @@ -281,7 +281,7 @@ # Remove Hub Network - name: Remove hub network in VRF1 region us-west-1 at AWS site level (check_mode) - mso_schema_site_vrf_region_hub_network: + cisco.mso.mso_schema_site_vrf_region_hub_network: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -293,7 +293,7 @@ register: cm_remove_hub_network - name: Remove hub network in VRF1 region us-west-1 at AWS site level (normal mode) - mso_schema_site_vrf_region_hub_network: + cisco.mso.mso_schema_site_vrf_region_hub_network: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -304,7 +304,7 @@ register: nm_remove_hub_network - name: Verify cm_remove_hub_network and nm_remove_hub_network - assert: + ansible.builtin.assert: that: - cm_remove_hub_network is changed - cm_remove_hub_network.current == {} @@ -317,7 +317,7 @@ # Remove Hub Network again - name: Remove again hub network in VRF1 region us-west-1 at AWS site level (check_mode) - mso_schema_site_vrf_region_hub_network: + cisco.mso.mso_schema_site_vrf_region_hub_network: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -329,7 +329,7 @@ register: cm_remove_hub_network_again - name: Remove again hub network in VRF1 region us-west-1 at AWS site level (normal_mode) - mso_schema_site_vrf_region_hub_network: + cisco.mso.mso_schema_site_vrf_region_hub_network: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -340,7 +340,7 @@ register: nm_remove_hub_network_again - name: Verify cm_remove_hub_network_again and nm_remove_hub_network_again - assert: + ansible.builtin.assert: that: - cm_remove_hub_network_again is not changed - nm_remove_hub_network_again is not changed @@ -349,7 +349,7 @@ # query when hub network does not exist - name: Query non_existing_hub_network - mso_schema_site_vrf_region_hub_network: + cisco.mso.mso_schema_site_vrf_region_hub_network: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -361,13 +361,13 @@ register: query_non_existing_hub_network - name: Verify query_non_existing_hub_network - assert: + ansible.builtin.assert: that: - query_non_existing_hub_network.msg == "Hub network not found" # Re-Add hub network - name: Re-Add hub network in VRF1 region us-west-1 at AWS site level (normal mode) - mso_schema_site_vrf_region_hub_network: + cisco.mso.mso_schema_site_vrf_region_hub_network: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -381,7 +381,7 @@ register: re_add_hub_network - name: Verify re_add_hub_network - assert: + ansible.builtin.assert: that: - re_add_hub_network is changed - re_add_hub_network.previous == {} @@ -390,7 +390,7 @@ # QUERY NON-EXISTING region - name: Query non-existing region (check_mode) - mso_schema_site_vrf_region_hub_network: + cisco.mso.mso_schema_site_vrf_region_hub_network: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -403,7 +403,7 @@ register: cm_query_non_region - name: Query non-existing region (normal mode) - mso_schema_site_vrf_region_hub_network: + cisco.mso.mso_schema_site_vrf_region_hub_network: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -415,7 +415,7 @@ register: nm_query_non_region - name: Verify query_non_region - assert: + ansible.builtin.assert: that: - cm_query_non_region is not changed - nm_query_non_region is not changed @@ -424,7 +424,7 @@ # QUERY NON-EXISTING VRF - name: Query non-existing VRF (check_mode) - mso_schema_site_vrf_region_hub_network: + cisco.mso.mso_schema_site_vrf_region_hub_network: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -437,7 +437,7 @@ register: cm_query_non_vrf - name: Query non-existing VRF (normal mode) - mso_schema_site_vrf_region_hub_network: + cisco.mso.mso_schema_site_vrf_region_hub_network: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -449,7 +449,7 @@ register: nm_query_non_vrf - name: Verify query_non_vrf - assert: + ansible.builtin.assert: that: - cm_query_non_vrf is not changed - nm_query_non_vrf is not changed @@ -458,7 +458,7 @@ # USE A NON-EXISTING STATE - name: Non-existing state for site hub network (check_mode) - mso_schema_site_vrf_region_hub_network: + cisco.mso.mso_schema_site_vrf_region_hub_network: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -471,7 +471,7 @@ register: cm_non_existing_state - name: Non-existing state for hub network (normal_mode) - mso_schema_site_vrf_region_hub_network: + cisco.mso.mso_schema_site_vrf_region_hub_network: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -483,7 +483,7 @@ register: nm_non_existing_state - name: Verify non_existing_state - assert: + ansible.builtin.assert: that: - cm_non_existing_state is not changed - nm_non_existing_state is not changed @@ -492,7 +492,7 @@ # USE A NON-EXISTING SCHEMA - name: Non-existing schema for site hub network (check_mode) - mso_schema_site_vrf_region_hub_network: + cisco.mso.mso_schema_site_vrf_region_hub_network: <<: *mso_info schema: non-existing-schema template: Template 1 @@ -505,7 +505,7 @@ register: cm_non_existing_schema - name: Non-existing schema for site hub network (normal_mode) - mso_schema_site_vrf_region_hub_network: + cisco.mso.mso_schema_site_vrf_region_hub_network: <<: *mso_info schema: non-existing-schema template: Template 1 @@ -517,7 +517,7 @@ register: nm_non_existing_schema - name: Verify non_existing_schema - assert: + ansible.builtin.assert: that: - cm_non_existing_schema is not changed - nm_non_existing_schema is not changed @@ -526,7 +526,7 @@ # USE A NON-EXISTING TEMPLATE - name: Non-existing template for site hub network (check_mode) - mso_schema_site_vrf_region_hub_network: + cisco.mso.mso_schema_site_vrf_region_hub_network: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: non-existing-template @@ -539,7 +539,7 @@ register: cm_non_existing_template - name: Non-existing template for site hub network (normal_mode) - mso_schema_site_vrf_region_hub_network: + cisco.mso.mso_schema_site_vrf_region_hub_network: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: non-existing-template @@ -551,7 +551,7 @@ register: nm_non_existing_template - name: Verify non_existing_template - assert: + ansible.builtin.assert: that: - cm_non_existing_template is not changed - nm_non_existing_template is not changed @@ -560,7 +560,7 @@ # USE A NON_EXISTING_SITE_TEMPLATE - name: non_existing_site_template (check_mode) - mso_schema_site_vrf_region_hub_network: + cisco.mso.mso_schema_site_vrf_region_hub_network: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 2 @@ -573,7 +573,7 @@ register: cm_non_existing_site_template - name: non_existing_site_template (normal_mode) - mso_schema_site_vrf_region_hub_network: + cisco.mso.mso_schema_site_vrf_region_hub_network: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 2 @@ -585,7 +585,7 @@ register: nm_non_existing_site_template - name: Verify cm_non_existing_site_template and nm_non_existing_site_template - assert: + ansible.builtin.assert: that: - cm_non_existing_site_template is not changed - nm_non_existing_site_template is not changed @@ -593,7 +593,7 @@ # USE A NON_EXISTING_SITE - name: non_existing_site (check_mode) - mso_schema_site_vrf_region_hub_network: + cisco.mso.mso_schema_site_vrf_region_hub_network: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -606,7 +606,7 @@ register: cm_non_existing_site - name: non_existing_site (normal_mode) - mso_schema_site_vrf_region_hub_network: + cisco.mso.mso_schema_site_vrf_region_hub_network: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -618,7 +618,7 @@ register: nm_non_existing_site - name: Verify cm_non_existing_site and nm_non_existing_site - assert: + ansible.builtin.assert: that: - cm_non_existing_site is not changed - nm_non_existing_site is not changed @@ -626,7 +626,7 @@ # use mso_schema_site_vrf_region_cidr_subnet module to update region - name: Add a new CIDR in VRF1 at AWS site level (check mode) - mso_schema_site_vrf_region_cidr: &cidr_present + cisco.mso.mso_schema_site_vrf_region_cidr: &cidr_present <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -640,7 +640,7 @@ register: cm_add_cidr - name: Verify cm_add_cidr - assert: + ansible.builtin.assert: that: - cm_add_cidr is changed - cm_add_cidr.previous == {} @@ -648,12 +648,12 @@ - cm_add_cidr.current.primary == false - name: Add a new CIDR in VRF1 at AWS site level (normal mode) - mso_schema_site_vrf_region_cidr: + cisco.mso.mso_schema_site_vrf_region_cidr: <<: *cidr_present register: nm_add_cidr - name: Verify nm_add_cidr - assert: + ansible.builtin.assert: that: - nm_add_cidr is changed - nm_add_cidr.previous == {} @@ -662,7 +662,7 @@ # query hub network after using mso_schema_site_vrf_region_cidr_subnet module to update region - name: Query hub_network after region updated - mso_schema_site_vrf_region_hub_network: + cisco.mso.mso_schema_site_vrf_region_hub_network: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -673,7 +673,7 @@ register: query_after_region_update - name: Verify query_after_region_update - assert: + ansible.builtin.assert: that: - query_after_region_update is not changed - query_after_region_update.current.name == "hub-test" @@ -681,7 +681,7 @@ # USE A TEMPLATE WITHOUT ANY SITE - name: Add site VRF region hub network to Schema 2 Template 3 without any site associated (check mode) - mso_schema_site_vrf_region_hub_network: + cisco.mso.mso_schema_site_vrf_region_hub_network: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}_2' template: Template 3 @@ -697,7 +697,7 @@ register: cm_no_site_associated - name: Add site VRF region hub network to Template 3 without any site associated (normal mode) - mso_schema_site_vrf_region_hub_network: + cisco.mso.mso_schema_site_vrf_region_hub_network: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}_2' template: Template 3 @@ -712,7 +712,7 @@ register: nm_no_site_associated - name: Verify cm_no_site_associated and nm_no_site_associated - assert: + ansible.builtin.assert: that: - cm_no_site_associated is not changed - nm_no_site_associated is not changed diff --git a/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_vrf_region_hub_network/tasks/main.yml b/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_vrf_region_hub_network/tasks/main.yml index 6eb612ad0..a282da449 100644 --- a/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_vrf_region_hub_network/tasks/main.yml +++ b/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_vrf_region_hub_network/tasks/main.yml @@ -5,13 +5,13 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI MultiSite host, username and password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: mso_hostname, mso_username and mso_password.' when: mso_hostname is not defined or mso_username is not defined or mso_password is not defined # CLEAN ENVIRONMENT - name: Set vars - set_fact: + ansible.builtin.set_fact: mso_info: &mso_info host: '{{ mso_hostname }}' username: '{{ mso_username }}' @@ -22,7 +22,7 @@ output_level: '{{ mso_output_level | default("info") }}' - name: Query MSO version - mso_version: + cisco.mso.mso_version: <<: *mso_info state: query register: version diff --git a/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template/tasks/main.yml b/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template/tasks/main.yml index 9823bcfd4..c3da18453 100644 --- a/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template/tasks/main.yml +++ b/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template/tasks/main.yml @@ -1,16 +1,17 @@ # Test code for the MSO modules # Copyright: (c) 2020, Shreyas Srish (@shrsr) <ssrish@cisco.com> +# Copyright: (c) 2023, Akini Ross (@akinross) <akinross@cisco.com> # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI MultiSite host, username and password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: mso_hostname, mso_username and mso_password.' when: mso_hostname is not defined or mso_username is not defined or mso_password is not defined # CLEAN ENVIRONMENT - name: Set vars - set_fact: + ansible.builtin.set_fact: mso_info: &mso_info host: '{{ mso_hostname }}' username: '{{ mso_username }}' @@ -21,13 +22,13 @@ output_level: '{{ mso_output_level | default("info") }}' - name: Query MSO version - mso_version: + cisco.mso.mso_version: <<: *mso_info state: query register: version - name: Ensure site exists - mso_site: + cisco.mso.mso_site: <<: *mso_info site: '{{ mso_site | default("ansible_test") }}' apic_username: '{{ apic_username }}' @@ -39,7 +40,7 @@ ignore_errors: true - name: Remove schemas - mso_schema: + cisco.mso.mso_schema: <<: *mso_info schema: '{{ item }}' state: absent @@ -49,7 +50,7 @@ - '{{ mso_schema | default("ansible_test") }}' - name: Ensure tenant ansible_test exists - mso_tenant: + cisco.mso.mso_tenant: <<: *mso_info tenant: '{{ item }}' users: @@ -62,7 +63,7 @@ - 'ansible_test_2' - name: Ensure schema 1 with Template 1 exists in check mode - mso_schema_template: + cisco.mso.mso_schema_template: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' tenant: ansible_test @@ -72,7 +73,7 @@ register: add_template1_schema1_cm - name: Ensure schema 1 with Template 1 exists - mso_schema_template: + cisco.mso.mso_schema_template: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' tenant: ansible_test @@ -81,7 +82,7 @@ register: add_template1_schema1 - name: Ensure schema 1 with Template 2 exists - mso_schema_template: + cisco.mso.mso_schema_template: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' tenant: ansible_test @@ -90,7 +91,7 @@ register: add_template2_schema1 - name: Ensure schema 2 with Template 3 exists - mso_schema_template: + cisco.mso.mso_schema_template: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}_2' tenant: ansible_test @@ -99,7 +100,7 @@ register: add_template3_schema2 - name: Ensure schema 2 with Template 3 exists again - mso_schema_template: + cisco.mso.mso_schema_template: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}_2' tenant: ansible_test @@ -108,7 +109,7 @@ register: add_template3_schema2_again - name: Ensure schema 3 with Template 1 exists - mso_schema_template: + cisco.mso.mso_schema_template: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}_3' tenant: ansible_test @@ -117,7 +118,7 @@ register: add_template1_schema3 - name: Ensure schema 3 with Template 2 exists - mso_schema_template: + cisco.mso.mso_schema_template: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}_3' tenant: ansible_test_2 @@ -126,7 +127,7 @@ register: add_template2_schema3 - name: Update display name of Template 3 in schema 2 - mso_schema_template: + cisco.mso.mso_schema_template: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}_2' tenant: ansible_test @@ -136,7 +137,7 @@ register: update_template3_schema2 - name: Verify add - assert: + ansible.builtin.assert: that: - add_template1_schema1_cm is changed - add_template1_schema1_cm.current.name == 'Template1' @@ -155,7 +156,7 @@ - update_template3_schema2.current.displayName == 'Temp 3' - name: Query Template 1 in Schema 1 - mso_schema_template: + cisco.mso.mso_schema_template: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' tenant: ansible_test @@ -164,7 +165,7 @@ register: query_template1_schema1 - name: Query all Templates in Schema 1 - mso_schema_template: + cisco.mso.mso_schema_template: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' tenant: ansible_test @@ -172,7 +173,7 @@ register: query_all_templates_schema1 - name: Query Template 1 in Schema 3 - mso_schema_template: + cisco.mso.mso_schema_template: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}_3' tenant: ansible_test @@ -181,7 +182,7 @@ register: query_template1_schema3 - name: Query Template 2 in Schema 3 - mso_schema_template: + cisco.mso.mso_schema_template: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}_3' tenant: ansible_test_2 @@ -190,7 +191,7 @@ register: query_template2_schema3 - name: Verify query - assert: + ansible.builtin.assert: that: - query_template1_schema1 is not changed - query_template1_schema1.current.name == 'Template1' @@ -202,7 +203,7 @@ - query_template2_schema3.current.name == 'Template2' - name: Remove Template 1 of Schema 1 - mso_schema_template: + cisco.mso.mso_schema_template: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' tenant: ansible_test @@ -212,7 +213,7 @@ register: remove_template1_schema1 - name: Remove Template 2 of Schema 1 - mso_schema_template: + cisco.mso.mso_schema_template: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' tenant: ansible_test @@ -221,7 +222,7 @@ register: remove_template2_schema1 - name: Remove non_existing_template - mso_schema_template: + cisco.mso.mso_schema_template: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}_2' tenant: ansible_test @@ -231,7 +232,7 @@ register: remove_template_non_existing_template - name: Remove Template 3 in schema 2 in check mode - mso_schema_template: + cisco.mso.mso_schema_template: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}_2' tenant: ansible_test @@ -241,7 +242,7 @@ register: remove_template3_schema2_cm - name: Remove Template 3 in schema 2 in normal mode - mso_schema_template: + cisco.mso.mso_schema_template: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}_2' tenant: ansible_test @@ -250,7 +251,7 @@ register: remove_template3_schema2_nm - name: Remove Template 3 in schema 2 again - mso_schema_template: + cisco.mso.mso_schema_template: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}_2' tenant: ansible_test @@ -259,7 +260,7 @@ register: remove_template3_schema2_nm_again - name: Remove Template 1 of Schema 3 - mso_schema_template: + cisco.mso.mso_schema_template: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}_3' tenant: ansible_test @@ -268,7 +269,7 @@ register: remove_template1_schema3 - name: Remove Template 2 of Schema 3 - mso_schema_template: + cisco.mso.mso_schema_template: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}_3' tenant: ansible_test_2 @@ -277,7 +278,7 @@ register: remove_template2_schema3 - name: non_existing_schema - mso_schema_template: + cisco.mso.mso_schema_template: <<: *mso_info schema: non_schema tenant: ansible_test @@ -287,7 +288,7 @@ register: remove_template_non_existing_schema - name: Verify remove - assert: + ansible.builtin.assert: that: - remove_template1_schema1.current == {} - remove_template1_schema1.previous.name == 'Template1' @@ -307,7 +308,7 @@ # USE NON-EXISTING STATE - name: non_existing_state state - mso_schema_template: + cisco.mso.mso_schema_template: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' tenant: ansible_test @@ -317,14 +318,14 @@ register: non_existing_state - name: Verify non_existing_state - assert: + ansible.builtin.assert: that: - non_existing_state is not changed - non_existing_state.msg == "value of state must be one of{{':'}} absent, present, query, got{{':'}} non_existing_state" # USE A NON_EXISTING_TEMPLATE - name: non_existing_template - mso_schema_template: + cisco.mso.mso_schema_template: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' tenant: ansible_test @@ -334,13 +335,13 @@ register: non_existing_template - name: Verify non_existing_template - assert: + ansible.builtin.assert: that: - non_existing_template is not changed - non_existing_template.msg == "Template 'non_existing_template' not found" - name: Template attribute absent in task - mso_schema_template: + cisco.mso.mso_schema_template: <<: *mso_info schema: non_schema tenant: ansible_test @@ -349,13 +350,13 @@ register: absent_template - name: Verify absent_template - assert: + ansible.builtin.assert: that: - absent_template is not changed - absent_template.current == [] - name: Update description schema 1 with Template 1 when version is greater than 3.3 - mso_schema_template: + cisco.mso.mso_schema_template: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' schema_description: "this is schema" @@ -367,14 +368,14 @@ when: version.current.version is version('3.3', '>=') - name: Verify add description - assert: + ansible.builtin.assert: that: - add_description is changed when: version.current.version is version('3.3', '>=') # REMOVE Schemas for next CI Run - name: Remove schemas for next ci test - mso_schema: + cisco.mso.mso_schema: <<: *mso_info schema: '{{ item }}' state: absent @@ -385,7 +386,84 @@ # REMOVE Tenant2 specific to this test case - name: Remove tenant2 - mso_tenant: + cisco.mso.mso_tenant: <<: *mso_info tenant: ansible_test_2 - state: absent
\ No newline at end of file + state: absent + +# TEST BLOCK FOR MSO VERSION >= 4.1 WHICH ALLOW FOR SCHEMA WITHOUT TEMPLATES +- name: Execute tasks only for MSO version >= 4.1 + when: version.current.version is version('4.1', '>=') + block: + + - name: Ensure schema without templates is not present + cisco.mso.mso_schema: + <<: *mso_info + schema: ansible_test + state: absent + + - name: Create a schema without templates + cisco.mso.mso_schema: + <<: *mso_info + schema: ansible_test + state: present + + - name: Query all templates in schema without templates + cisco.mso.mso_schema_template: + <<: *mso_info + schema: ansible_test + state: query + register: query_all_templates_ansible_test + + - name: Verify schema without templates creation has no templates + ansible.builtin.assert: + that: + - query_all_templates_ansible_test.current == [] + + # Templates are not allowed to do PATCH add operation on schema without templates in earlier versions + # Error would be: "message": "add operation does not apply: doc is missing path: \"/templates/-\": missing value" + - name: Create a template in schema without templates for version >= 4.2 + cisco.mso.mso_schema_template: &ansible_test_template + <<: *mso_info + schema: ansible_test + tenant: ansible_test + template: template_1 + state: present + register: create_template_in_ansible_test + when: version.current.version is version('4.2', '>=') + + - name: Verify creation of template in schema without templates for version >= 4.2 + ansible.builtin.assert: + that: + - create_template_in_ansible_test is changed + - create_template_in_ansible_test.current.displayName == "template_1" + when: version.current.version is version('4.2', '>=') + + - name: Remove a template in schema without templates + cisco.mso.mso_schema_template: + <<: *ansible_test_template + state: absent + register: remove_template_in_ansible_test + + - name: Remove schema without templates + cisco.mso.mso_schema: + <<: *mso_info + schema: ansible_test + state: absent + register: remove_ansible_test + + - name: Verify schema without templates creation is removed + ansible.builtin.assert: + that: + - remove_template_in_ansible_test is not changed + - remove_template_in_ansible_test.current == {} + - remove_ansible_test is changed + when: version.current.version is version('4.2', '<') + + - name: Verify schema without templates creation is removed + ansible.builtin.assert: + that: + - remove_template_in_ansible_test is changed + - remove_template_in_ansible_test.current == {} + - remove_ansible_test is not changed + when: version.current.version is version('4.2', '>=') diff --git a/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_anp/tasks/main.yml b/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_anp/tasks/main.yml index bbd5bb1cb..0084bfcd6 100644 --- a/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_anp/tasks/main.yml +++ b/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_anp/tasks/main.yml @@ -4,14 +4,14 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI MultiSite host, username and password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: mso_hostname, mso_username and mso_password.' when: mso_hostname is not defined or mso_username is not defined or mso_password is not defined # CLEAN ENVIRONMENT - name: Set vars - set_fact: + ansible.builtin.set_fact: mso_info: &mso_info host: '{{ mso_hostname }}' username: '{{ mso_username }}' @@ -22,13 +22,13 @@ output_level: '{{ mso_output_level | default("info") }}' - name: Query MSO version - mso_version: + cisco.mso.mso_version: <<: *mso_info state: query register: version - name: Remove schemas - mso_schema: + cisco.mso.mso_schema: <<: *mso_info schema: '{{ item }}' state: absent @@ -38,13 +38,13 @@ - '{{ mso_schema | default("ansible_test") }}' - name: Remove tenant2 - mso_tenant: + cisco.mso.mso_tenant: <<: *mso_info tenant: ansible_test_2 state: absent - name: Ensure tenant ansible_test exist - mso_tenant: + cisco.mso.mso_tenant: <<: *mso_info tenant: ansible_test users: @@ -52,7 +52,7 @@ state: present - name: Ensure schema 1 with Template 1 exist - mso_schema_template: + cisco.mso.mso_schema_template: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' tenant: ansible_test @@ -60,7 +60,7 @@ state: present - name: Ensure schema 1 with Template 2 exist - mso_schema_template: + cisco.mso.mso_schema_template: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' tenant: ansible_test @@ -68,7 +68,7 @@ state: present - name: Ensure schema 2 with Template 3 exist - mso_schema_template: + cisco.mso.mso_schema_template: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}_2' tenant: ansible_test @@ -76,7 +76,7 @@ state: present - name: Ensure ANP exist (check_mode) - mso_schema_template_anp: + cisco.mso.mso_schema_template_anp: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -86,7 +86,7 @@ register: cm_create_anp - name: Ensure ANP exist (normal_mode) - mso_schema_template_anp: + cisco.mso.mso_schema_template_anp: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -95,7 +95,7 @@ register: nm_create_anp - name: Create ANP again (normal_mode) - mso_schema_template_anp: + cisco.mso.mso_schema_template_anp: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -104,7 +104,7 @@ register: nm_create_anp_again - name: Verify cm_create_anp, nm_create_anp and nm_create_anp_again - assert: + ansible.builtin.assert: that: - cm_create_anp is changed - nm_create_anp is changed @@ -123,7 +123,7 @@ - nm_create_anp_again.current.epgs == [] - name: Create another anp (normal_mode) - mso_schema_template_anp: + cisco.mso.mso_schema_template_anp: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -133,7 +133,7 @@ register: nm_create_another_anp - name: Verify nm_create_another_anp - assert: + ansible.builtin.assert: that: - nm_create_another_anp is changed - nm_create_another_anp.previous == {} @@ -144,7 +144,7 @@ # Add description for version >= 3.3 - name: Create another anp with description(normal_mode) - mso_schema_template_anp: + cisco.mso.mso_schema_template_anp: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -156,7 +156,7 @@ when: version.current.version is version('3.3', '>=') - name: Verify nm_create_another_anp with description - assert: + ansible.builtin.assert: that: - nm_create_another_anp is changed - nm_create_another_anp.previous == {} @@ -167,7 +167,7 @@ when: version.current.version is version('3.3', '>=') - name: Change anp (normal_mode) - mso_schema_template_anp: + cisco.mso.mso_schema_template_anp: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -177,7 +177,7 @@ register: nm_change_anp - name: Verify nm_change_anp - assert: + ansible.builtin.assert: that: - nm_change_anp is changed - nm_change_anp.previous.name == nm_change_anp.current.name == "ANP" @@ -186,7 +186,7 @@ - nm_change_anp.previous.epgs == nm_change_anp.current.epgs == [] - name: Query anp - mso_schema_template_anp: + cisco.mso.mso_schema_template_anp: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -195,7 +195,7 @@ register: query_anp - name: Verify query_anp - assert: + ansible.builtin.assert: that: - query_anp is not changed - query_anp.current.name == "ANP" @@ -203,7 +203,7 @@ - query_anp.current.displayName == "displayName for ANP" - name: Query all - mso_schema_template_anp: + cisco.mso.mso_schema_template_anp: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -211,21 +211,21 @@ register: query_all - name: Verify query_all - assert: + ansible.builtin.assert: that: - query_all is not changed - query_all.current | length == 2 when: version.current.version is version('3.3', '<') - name: Verify query_all - assert: + ansible.builtin.assert: that: - query_all is not changed - query_all.current | length == 3 when: version.current.version is version('3.3', '>=') - name: Query non_existing anp - mso_schema_template_anp: + cisco.mso.mso_schema_template_anp: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -235,12 +235,12 @@ register: query_non_existing_anp - name: Verify query_non_existing_anp - assert: + ansible.builtin.assert: that: - query_non_existing_anp.msg == "ANP 'non_existing_anp' not found" - name: Use non_existing schema - mso_schema_template_anp: + cisco.mso.mso_schema_template_anp: <<: *mso_info schema: non_existing_schema template: Template 1 @@ -250,7 +250,7 @@ register: query_non_existing_schema - name: Use non_existing template - mso_schema_template_anp: + cisco.mso.mso_schema_template_anp: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: non_existing_template @@ -260,13 +260,13 @@ register: query_non_existing_template - name: Verify query_non_existing_schema and query_non_existing_template - assert: + ansible.builtin.assert: that: - query_non_existing_schema.msg == "Provided schema 'non_existing_schema' does not exist." - query_non_existing_template.msg == "Provided template 'non_existing_template' does not exist. Existing templates{{':'}} Template1, Template2" - name: Remove anp (check_mode) - mso_schema_template_anp: + cisco.mso.mso_schema_template_anp: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -276,7 +276,7 @@ register: cm_rm_anp - name: Remove anp (normal_mode) - mso_schema_template_anp: + cisco.mso.mso_schema_template_anp: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -285,7 +285,7 @@ register: nm_rm_anp - name: Verify cm_rm_anp and nm_rm_anp - assert: + ansible.builtin.assert: that: - cm_rm_anp is changed - nm_rm_anp is changed @@ -296,7 +296,7 @@ - nm_rm_anp.previous.epgs == cm_rm_anp.previous.epgs == [] - name: Remove anp again - mso_schema_template_anp: + cisco.mso.mso_schema_template_anp: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -305,7 +305,7 @@ register: nm_rm_anp_again - name: Verify nm_rm_anp_again - assert: + ansible.builtin.assert: that: - nm_rm_anp_again is not changed - nm_rm_anp_again.previous == nm_rm_anp_again.current == {} diff --git a/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_anp_epg/tasks/main.yml b/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_anp_epg/tasks/main.yml index a4af6fb6d..16fdddc28 100644 --- a/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_anp_epg/tasks/main.yml +++ b/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_anp_epg/tasks/main.yml @@ -7,14 +7,14 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI MultiSite host, username and password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: mso_hostname, mso_username and mso_password.' when: mso_hostname is not defined or mso_username is not defined or mso_password is not defined # CLEAN ENVIRONMENT - name: Set vars - set_fact: + ansible.builtin.set_fact: mso_info: &mso_info host: '{{ mso_hostname }}' username: '{{ mso_username }}' @@ -25,13 +25,13 @@ output_level: '{{ mso_output_level | default("info") }}' - name: Query MSO version - mso_version: + cisco.mso.mso_version: <<: *mso_info state: query register: version - name: Remove schemas - mso_schema: + cisco.mso.mso_schema: <<: *mso_info schema: '{{ item }}' state: absent @@ -40,7 +40,7 @@ - '{{ mso_schema | default("ansible_test") }}' - name: Ensure tenant ansible_test exist - mso_tenant: &tenant_present + cisco.mso.mso_tenant: &tenant_present <<: *mso_info tenant: ansible_test users: @@ -48,7 +48,7 @@ state: present - name: Ensure schema 1 with Template 1 exist - mso_schema_template: &schema_present + cisco.mso.mso_schema_template: &schema_present <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' tenant: ansible_test @@ -56,7 +56,7 @@ state: present - name: Ensure schema 1 with Template 2 exist - mso_schema_template: + cisco.mso.mso_schema_template: <<: *schema_present schema: '{{ mso_schema | default("ansible_test") }}' tenant: ansible_test @@ -64,7 +64,7 @@ state: present - name: Ensure schema 2 with Template 3 exist - mso_schema_template: + cisco.mso.mso_schema_template: <<: *schema_present schema: '{{ mso_schema | default("ansible_test") }}_2' tenant: ansible_test @@ -72,7 +72,7 @@ state: present - name: Ensure VRF exist - mso_schema_template_vrf: &vrf_present + cisco.mso.mso_schema_template_vrf: &vrf_present <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -81,13 +81,13 @@ state: present - name: Ensure VRF2 exist - mso_schema_template_vrf: + cisco.mso.mso_schema_template_vrf: <<: *vrf_present vrf: VRF2 state: present - name: Ensure VRF3 exist - mso_schema_template_vrf: + cisco.mso.mso_schema_template_vrf: <<: *vrf_present schema: '{{ mso_schema | default("ansible_test") }}' template: Template 2 @@ -95,7 +95,7 @@ state: present - name: Ensure VRF4 exist - mso_schema_template_vrf: + cisco.mso.mso_schema_template_vrf: <<: *vrf_present schema: '{{ mso_schema | default("ansible_test") }}_2' template: Template 3 @@ -103,7 +103,7 @@ state: present - name: Ensure ANP exist - mso_schema_template_anp: + cisco.mso.mso_schema_template_anp: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -111,7 +111,7 @@ state: present - name: Ensure ANP2 exist - mso_schema_template_anp: + cisco.mso.mso_schema_template_anp: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 2 @@ -119,7 +119,7 @@ state: present - name: Ensure ANP3 exist - mso_schema_template_anp: + cisco.mso.mso_schema_template_anp: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}_2' template: Template 3 @@ -127,7 +127,7 @@ state: present - name: Ensure Filter 1 exist - mso_schema_template_filter_entry: + cisco.mso.mso_schema_template_filter_entry: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -136,7 +136,7 @@ state: present - name: Ensure Contract1 exist - mso_schema_template_contract_filter: &contract_present + cisco.mso.mso_schema_template_contract_filter: &contract_present <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -147,7 +147,7 @@ state: present - name: Ensure Filter 2 exist - mso_schema_template_filter_entry: + cisco.mso.mso_schema_template_filter_entry: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 2 @@ -156,7 +156,7 @@ state: present - name: Ensure Contract2 exist - mso_schema_template_contract_filter: &contract2_present + cisco.mso.mso_schema_template_contract_filter: &contract2_present <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 2 @@ -167,7 +167,7 @@ state: present - name: Ensure ansible_test_1 BD exist - mso_schema_template_bd: + cisco.mso.mso_schema_template_bd: <<: *vrf_present schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -178,7 +178,7 @@ state: present - name: Ensure ansible_test_2 BD exist - mso_schema_template_bd: + cisco.mso.mso_schema_template_bd: <<: *vrf_present schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -190,7 +190,7 @@ state: present - name: Ensure ansible_test_3 BD exist - mso_schema_template_bd: + cisco.mso.mso_schema_template_bd: <<: *vrf_present schema: '{{ mso_schema | default("ansible_test") }}' template: Template 2 @@ -203,7 +203,7 @@ state: present - name: Ensure ansible_test_4 BD exist - mso_schema_template_bd: + cisco.mso.mso_schema_template_bd: <<: *vrf_present schema: '{{ mso_schema | default("ansible_test") }}_2' template: Template 3 @@ -217,7 +217,7 @@ # ADD EPG - name: Add EPG (check_mode) - mso_schema_template_anp_epg: &epg_present + cisco.mso.mso_schema_template_anp_epg: &epg_present <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -232,7 +232,7 @@ register: cm_add_epg - name: Verify cm_add_epg - assert: + ansible.builtin.assert: that: - cm_add_epg is changed - cm_add_epg.previous == {} @@ -243,12 +243,12 @@ - cm_add_epg.current.bdRef.bdName == "ansible_test_1" - name: Add EPG (normal mode) - mso_schema_template_anp_epg: + cisco.mso.mso_schema_template_anp_epg: <<: *epg_present register: nm_add_epg - name: Verify nm_add_epg - assert: + ansible.builtin.assert: that: - nm_add_epg is changed - nm_add_epg.previous == {} @@ -261,13 +261,13 @@ - cm_add_epg.current.bdRef.schemaId == nm_add_epg.current.bdRef.schemaId - name: Add EPG again (check_mode) - mso_schema_template_anp_epg: + cisco.mso.mso_schema_template_anp_epg: <<: *epg_present check_mode: true register: cm_add_epg_again - name: Verify cm_add_epg_again - assert: + ansible.builtin.assert: that: - cm_add_epg_again is not changed - cm_add_epg_again.current.name == cm_add_epg_again.previous.name == "ansible_test_1" @@ -280,12 +280,12 @@ - name: Add EPG again (normal mode) - mso_schema_template_anp_epg: + cisco.mso.mso_schema_template_anp_epg: <<: *epg_present register: nm_add_epg_again - name: Verify nm_add_epg_again - assert: + ansible.builtin.assert: that: - nm_add_epg_again is not changed - nm_add_epg_again.current.name == nm_add_epg_again.previous.name == "ansible_test_1" @@ -297,13 +297,13 @@ - nm_add_epg_again.previous.bdRef.schemaId == nm_add_epg_again.current.bdRef.schemaId - name: Add EPG 2 (normal mode) - mso_schema_template_anp_epg: + cisco.mso.mso_schema_template_anp_epg: <<: *epg_present schema: '{{ mso_schema | default("ansible_test") }}' epg: ansible_test_2 - name: Add EPG 3 in template of schema 1(normal mode) - mso_schema_template_anp_epg: &epg_schema_1_template_2 + cisco.mso.mso_schema_template_anp_epg: &epg_schema_1_template_2 <<: *epg_present schema: '{{ mso_schema | default("ansible_test") }}' template: Template 2 @@ -338,7 +338,7 @@ register: nm_add_epg_3 - name: Add EPG 4 in template3 of schema 2(normal mode) - mso_schema_template_anp_epg: &epg_schema_2_template_3 + cisco.mso.mso_schema_template_anp_epg: &epg_schema_2_template_3 <<: *epg_present schema: '{{ mso_schema | default("ansible_test") }}_2' template: Template 3 @@ -355,7 +355,7 @@ register: nm_add_epg_4 - name: Verify nm_add_epg_3 and nm_add_epg_4 - assert: + ansible.builtin.assert: that: - nm_add_epg_3 is changed - nm_add_epg_4 is changed @@ -397,7 +397,7 @@ # CHANGE EPG - name: Change EPG (check_mode) - mso_schema_template_anp_epg: + cisco.mso.mso_schema_template_anp_epg: <<: *epg_present vrf: name: VRF2 @@ -407,7 +407,7 @@ register: cm_change_epg - name: Verify cm_change_epg - assert: + ansible.builtin.assert: that: - cm_change_epg is changed - cm_change_epg.current.name == 'ansible_test_1' @@ -418,7 +418,7 @@ - cm_change_epg.current.bdRef.schemaId == cm_change_epg.previous.bdRef.schemaId - name: Change EPG (normal mode) - mso_schema_template_anp_epg: + cisco.mso.mso_schema_template_anp_epg: <<: *epg_present vrf: name: VRF2 @@ -428,7 +428,7 @@ register: nm_change_epg - name: Verify nm_change_epg - assert: + ansible.builtin.assert: that: - nm_change_epg is changed - nm_change_epg.current.name == 'ansible_test_1' @@ -439,7 +439,7 @@ - nm_change_epg.current.bdRef.schemaId == nm_change_epg.previous.bdRef.schemaId - name: Change EPG again (check_mode) - mso_schema_template_anp_epg: + cisco.mso.mso_schema_template_anp_epg: <<: *epg_present vrf: name: VRF2 @@ -449,7 +449,7 @@ register: cm_change_epg_again - name: Verify cm_change_epg_again - assert: + ansible.builtin.assert: that: - cm_change_epg_again is not changed - cm_change_epg_again.current.name == 'ansible_test_1' @@ -460,7 +460,7 @@ - cm_change_epg_again.current.bdRef.schemaId == cm_change_epg_again.previous.bdRef.schemaId - name: Change EPG again (normal mode) - mso_schema_template_anp_epg: + cisco.mso.mso_schema_template_anp_epg: <<: *epg_present vrf: name: VRF2 @@ -469,7 +469,7 @@ register: nm_change_epg_again - name: Verify nm_change_epg_again - assert: + ansible.builtin.assert: that: - nm_change_epg_again is not changed - nm_change_epg_again.current.name == 'ansible_test_1' @@ -480,7 +480,7 @@ - nm_change_epg_again.current.bdRef.schemaId == nm_change_epg_again.previous.bdRef.schemaId - name: Change EPG to VRF in different template (normal mode) - mso_schema_template_anp_epg: + cisco.mso.mso_schema_template_anp_epg: <<: *epg_schema_1_template_2 vrf: name: VRF @@ -491,7 +491,7 @@ register: nm_change_epg_vrf3 - name: Change EPG 4 to VRF (normal mode) - mso_schema_template_anp_epg: + cisco.mso.mso_schema_template_anp_epg: <<: *epg_schema_2_template_3 schema: '{{ mso_schema | default("ansible_test") }}_2' template: Template 3 @@ -508,7 +508,7 @@ register: nm_change_epg_vrf4 - name: Verify nm_change_epg_vrf3 and nm_change_epg_vrf4 - assert: + ansible.builtin.assert: that: - nm_change_epg_vrf3 is changed - nm_change_epg_vrf3.current.name == 'ansible_test_3' @@ -521,7 +521,7 @@ - nm_change_epg_vrf4.current.vrfRef.templateName == nm_change_epg_vrf4.current.bdRef.templateName == "Template1" - name: Change EPG 1 settings(normal mode) - mso_schema_template_anp_epg: + cisco.mso.mso_schema_template_anp_epg: <<: *epg_present schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -547,7 +547,7 @@ register: nm_change_epg_1_settings - name: Change EPG 1 subnets (normal mode) - mso_schema_template_anp_epg: + cisco.mso.mso_schema_template_anp_epg: <<: *epg_present schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -571,7 +571,7 @@ register: nm_change_epg_1_subnets - name: Verify nm_change_epg_1_subnets - assert: + ansible.builtin.assert: that: - nm_change_epg_1_settings is changed - nm_change_epg_1_settings.current.name == "ansible_test_1" @@ -633,7 +633,7 @@ # # QUERY ALL EPGs - name: Query all EPGs in an ANP (check_mode) - mso_schema_template_anp_epg: &epg_query + cisco.mso.mso_schema_template_anp_epg: &epg_query <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -643,12 +643,12 @@ register: cm_query_all_epgs - name: Query all EPGs (normal mode) - mso_schema_template_anp_epg: + cisco.mso.mso_schema_template_anp_epg: <<: *epg_query register: nm_query_all_epgs - name: Verify query_all_epgs - assert: + ansible.builtin.assert: that: - cm_query_all_epgs is not changed - nm_query_all_epgs is not changed @@ -657,20 +657,20 @@ # QUERY AN EPG - name: Query EPG 1 (check_mode) - mso_schema_template_anp_epg: + cisco.mso.mso_schema_template_anp_epg: <<: *epg_query epg: ansible_test_1 check_mode: true register: cm_query_epg_1 - name: Query EPG 1 (normal mode) - mso_schema_template_anp_epg: + cisco.mso.mso_schema_template_anp_epg: <<: *epg_query epg: ansible_test_1 register: nm_query_epg_1 - name: Query EPG 3 (normal mode) - mso_schema_template_anp_epg: + cisco.mso.mso_schema_template_anp_epg: <<: *epg_query template: Template 2 anp: ANP2 @@ -678,7 +678,7 @@ register: nm_query_epg_3 - name: Query EPG 4 (normal mode) - mso_schema_template_anp_epg: + cisco.mso.mso_schema_template_anp_epg: <<: *epg_query schema: '{{ mso_schema | default("ansible_test") }}_2' template: Template 3 @@ -687,7 +687,7 @@ register: nm_query_epg_4 - name: Verify query_epg_x - assert: + ansible.builtin.assert: that: - cm_query_epg_1 is not changed - nm_query_epg_1 is not changed @@ -752,57 +752,57 @@ # REMOVE EPG - name: Remove EPG (check_mode) - mso_schema_template_anp_epg: + cisco.mso.mso_schema_template_anp_epg: <<: *epg_present state: absent check_mode: true register: cm_remove_epg - name: Verify cm_remove_epg - assert: + ansible.builtin.assert: that: - cm_remove_epg is changed - cm_remove_epg.current == {} - name: Remove EPG (normal mode) - mso_schema_template_anp_epg: + cisco.mso.mso_schema_template_anp_epg: <<: *epg_present state: absent register: nm_remove_epg - name: Verify nm_remove_epg - assert: + ansible.builtin.assert: that: - nm_remove_epg is changed - nm_remove_epg.current == {} - name: Remove EPG again (check_mode) - mso_schema_template_anp_epg: + cisco.mso.mso_schema_template_anp_epg: <<: *epg_present state: absent check_mode: true register: cm_remove_epg_again - name: Verify cm_remove_epg_again - assert: + ansible.builtin.assert: that: - cm_remove_epg_again is not changed - cm_remove_epg_again.current == {} - name: Remove EPG again (normal mode) - mso_schema_template_anp_epg: + cisco.mso.mso_schema_template_anp_epg: <<: *epg_present state: absent register: nm_remove_epg_again - name: Verify nm_remove_epg_again - assert: + ansible.builtin.assert: that: - nm_remove_epg_again is not changed - nm_remove_epg_again.current == {} - name: Remove EPG (normal mode) - mso_schema_template_anp_epg: + cisco.mso.mso_schema_template_anp_epg: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -817,7 +817,7 @@ - version.current.version is version('3.3', '>=') block: - name: Add EPG (for version greater than 3.3) - mso_schema_template_anp_epg: &new_epg + cisco.mso.mso_schema_template_anp_epg: &new_epg <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -828,13 +828,13 @@ register: add_epg_desc - name: Verify Add description - assert: + ansible.builtin.assert: that: - add_epg_desc is changed - add_epg_desc.current.description == "Description of ANP EPG" - name: Remove EPG (for version greater than 3.3) - mso_schema_template_anp_epg: + cisco.mso.mso_schema_template_anp_epg: <<: *new_epg state: absent @@ -843,7 +843,7 @@ - version.current.version is version('4.0', '>=') block: - name: Add EPG service type parameters (for version greater than 4.0) - mso_schema_template_anp_epg: + cisco.mso.mso_schema_template_anp_epg: <<: *new_epg epg_type: 'service' deployment_type: 'third_party' @@ -852,7 +852,7 @@ register: service_type_epg - name: Add EPG service type parameters (for version greater than 4.0) with error - mso_schema_template_anp_epg: + cisco.mso.mso_schema_template_anp_epg: <<: *new_epg epg_type: 'service' deployment_type: 'third_party' @@ -862,7 +862,7 @@ register: service_type_epg_error - name: Verify service type error - assert: + ansible.builtin.assert: that: - service_type_epg_error.msg == "MSO Error 400{{':'}} EPG{{':'}} ansible_test_1 in Schema{{':'}} ansible_test , Template{{':'}} Template1 DeploymentType{{':'}} saas, AccessType {{':'}}publicAndPrivateType, Combination is not supported" @@ -873,7 +873,7 @@ - version.current.version is version('4.0', '<') block: - name: Add EPG service type parameters (for version greater than 3.3 and less than 4.0) - mso_schema_template_anp_epg: + cisco.mso.mso_schema_template_anp_epg: <<: *new_epg epg_type: 'service' deployment_type: 'third_party' @@ -882,7 +882,7 @@ register: add_epg - name: Get Validation status for service type parameters - mso_schema_validate: + cisco.mso.mso_schema_validate: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' state: query @@ -890,13 +890,13 @@ register: query_validate - name: Verify validation - assert: + ansible.builtin.assert: that: - query_validate is not changed - query_validate.msg == "MSO Error 400{{':'}} Bad Request{{':'}} Patch Failed, Received{{':'}} For Deployment type 'Third-party' access type 'PublicAndPrivate' is not supported exception while trying to update schema" - name: Add EPG service type parameters (for version greater than 3.3 and less than 4.0) - mso_schema_template_anp_epg: + cisco.mso.mso_schema_template_anp_epg: <<: *new_epg epg_type: 'service' deployment_type: 'cloud_native' @@ -905,7 +905,7 @@ register: add_epg - name: Get Validation status for service type parameters - mso_schema_validate: + cisco.mso.mso_schema_validate: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' state: query @@ -913,13 +913,13 @@ register: query_validate - name: Verify validation - assert: + ansible.builtin.assert: that: - query_validate is not changed - query_validate.current.result == "true" - name: Add new EPG service type parameters (for version greater than 3.3 and less than 4.0) - mso_schema_template_anp_epg: + cisco.mso.mso_schema_template_anp_epg: <<: *new_epg epg_type: 'service' deployment_type: 'third_party' @@ -928,7 +928,7 @@ register: add_epg - name: Get Validation status for service type parameters - mso_schema_validate: + cisco.mso.mso_schema_validate: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' state: query @@ -936,14 +936,14 @@ register: query_validate - name: Verify validation - assert: + ansible.builtin.assert: that: - query_validate is not changed - query_validate.current.result == "true" # Add QoS level to EPG - name: Add EPG (for version greater than 3.1) - mso_schema_template_anp_epg: + cisco.mso.mso_schema_template_anp_epg: <<: *epg_present name: ansible_test_5 qos_level: 'level2' @@ -951,14 +951,14 @@ when: version.current.version is version('3.1', '>=') - name: Verify Add contract for version greater than 3.1 - assert: + ansible.builtin.assert: that: - add_epg is changed when: version.current.version is version('3.1', '>=') # QUERY NON-EXISTING EPG - name: Query non-existing EPG (check_mode) - mso_schema_template_anp_epg: + cisco.mso.mso_schema_template_anp_epg: <<: *epg_query epg: non_existing_epg check_mode: true @@ -966,14 +966,14 @@ register: cm_query_non_epg - name: Query non-existing EPG (normal mode) - mso_schema_template_anp_epg: + cisco.mso.mso_schema_template_anp_epg: <<: *epg_query epg: non_existing_epg ignore_errors: true register: nm_query_non_epg - name: Verify query_non_epg - assert: + ansible.builtin.assert: that: - cm_query_non_epg is not changed - nm_query_non_epg is not changed @@ -982,7 +982,7 @@ # QUERY NON-EXISTING ANP - name: Query non-existing ANP (check_mode) - mso_schema_template_anp_epg: + cisco.mso.mso_schema_template_anp_epg: <<: *epg_query anp: non_existing_anp check_mode: true @@ -990,14 +990,14 @@ register: cm_query_non_anp - name: Query non-existing ANP (normal mode) - mso_schema_template_anp_epg: + cisco.mso.mso_schema_template_anp_epg: <<: *epg_query anp: non_existing_anp ignore_errors: true register: nm_query_non_anp - name: Verify query_non_anp - assert: + ansible.builtin.assert: that: - cm_query_non_anp is not changed - nm_query_non_anp is not changed @@ -1006,7 +1006,7 @@ # USE A NON-EXISTING STATE - name: Non-existing state for EPG (check_mode) - mso_schema_template_anp_epg: + cisco.mso.mso_schema_template_anp_epg: <<: *epg_query epg: ansible_test_2 state: non-existing-state @@ -1015,7 +1015,7 @@ register: cm_non_existing_state - name: Non-existing state for EPG (normal_mode) - mso_schema_template_anp_epg: + cisco.mso.mso_schema_template_anp_epg: <<: *epg_query epg: ansible_test_2 state: non-existing-state @@ -1023,7 +1023,7 @@ register: nm_non_existing_state - name: Verify non_existing_state - assert: + ansible.builtin.assert: that: - cm_non_existing_state is not changed - nm_non_existing_state is not changed @@ -1032,7 +1032,7 @@ # USE A NON-EXISTING SCHEMA - name: Non-existing schema for EPG (check_mode) - mso_schema_template_anp_epg: + cisco.mso.mso_schema_template_anp_epg: <<: *epg_present schema: non-existing-schema epg: ansible_test_2 @@ -1041,7 +1041,7 @@ register: cm_non_existing_schema - name: Non-existing schema for EPG (normal_mode) - mso_schema_template_anp_epg: + cisco.mso.mso_schema_template_anp_epg: <<: *epg_present schema: non-existing-schema epg: ansible_test_2 @@ -1049,7 +1049,7 @@ register: nm_non_existing_schema - name: Verify non_existing_schema - assert: + ansible.builtin.assert: that: - cm_non_existing_schema is not changed - nm_non_existing_schema is not changed @@ -1057,7 +1057,7 @@ - cm_non_existing_schema.msg == nm_non_existing_schema.msg == "Provided schema 'non-existing-schema' does not exist." - name: Non-existing BD schema for EPG (check_mode) - mso_schema_template_anp_epg: + cisco.mso.mso_schema_template_anp_epg: <<: *epg_present epg: ansible_test_2 bd: @@ -1069,7 +1069,7 @@ register: cm_non_existing_bd_schema - name: Non-existing BD schema for EPG (normal_mode) - mso_schema_template_anp_epg: + cisco.mso.mso_schema_template_anp_epg: <<: *epg_present epg: ansible_test_2 bd: @@ -1080,7 +1080,7 @@ register: nm_non_existing_bd_schema - name: Verify non_existing_bd_schema - assert: + ansible.builtin.assert: that: - cm_non_existing_bd_schema is not changed - nm_non_existing_bd_schema is not changed @@ -1088,7 +1088,7 @@ - cm_non_existing_bd_schema.msg == nm_non_existing_bd_schema.msg == "Referenced schema 'non-existing-schema' in bdref does not exist" - name: Non-existing VRF schema for EPG (check_mode) - mso_schema_template_anp_epg: + cisco.mso.mso_schema_template_anp_epg: <<: *epg_present epg: ansible_test_2 vrf: @@ -1100,7 +1100,7 @@ register: cm_non_existing_vrf_schema - name: Non-existing VRF schema for EPG (normal_mode) - mso_schema_template_anp_epg: + cisco.mso.mso_schema_template_anp_epg: <<: *epg_present epg: ansible_test_2 vrf: @@ -1111,7 +1111,7 @@ register: nm_non_existing_vrf_schema - name: Verify non_existing_vrf_schema - assert: + ansible.builtin.assert: that: - cm_non_existing_vrf_schema is not changed - nm_non_existing_vrf_schema is not changed @@ -1120,7 +1120,7 @@ # USE A NON-EXISTING TEMPLATE - name: Non-existing template for EPG (check_mode) - mso_schema_template_anp_epg: + cisco.mso.mso_schema_template_anp_epg: <<: *epg_present template: non-existing-template epg: ansible_test_2 @@ -1129,7 +1129,7 @@ register: cm_non_existing_template - name: Non-existing template for EPG (normal_mode) - mso_schema_template_anp_epg: + cisco.mso.mso_schema_template_anp_epg: <<: *epg_present template: non-existing-template epg: ansible_test_2 @@ -1137,7 +1137,7 @@ register: nm_non_existing_template - name: Verify non_existing_template - assert: + ansible.builtin.assert: that: - cm_non_existing_template is not changed - nm_non_existing_template is not changed @@ -1146,12 +1146,12 @@ # Checking if contract are removed after re-applying an EPG. (#13 | #62137) - name: Reset EPG 3 in template of schema 1 to avoid cyclic circles (normal mode) - mso_schema_template_anp_epg: + cisco.mso.mso_schema_template_anp_epg: <<: *epg_schema_1_template_2 register: nm_add_epg_3 - name: Add Contracts to EPG 2 - mso_schema_template_anp_epg_contract: + cisco.mso.mso_schema_template_anp_epg_contract: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -1169,41 +1169,41 @@ - { name: Contract2, template: Template 2, type: provider } - name: Query EPG 2 - mso_schema_template_anp_epg: + cisco.mso.mso_schema_template_anp_epg: <<: *epg_query epg: ansible_test_2 register: nm_query_contract_epg - name: Verify that 4 contracts are in EPG 2 using nm_query_contract_epg - assert: + ansible.builtin.assert: that: - nm_query_contract_epg.current.contractRelationships | length == 4 - name: Add EPG 2 again (normal_mode) - mso_schema_template_anp_epg: + cisco.mso.mso_schema_template_anp_epg: <<: *epg_present epg: ansible_test_2 register: nm_add_epg_2_again - name: Verify that EPG 2 didn't change - assert: + ansible.builtin.assert: that: - nm_add_epg_2_again is not changed - name: Query EPG 2 - mso_schema_template_anp_epg: + cisco.mso.mso_schema_template_anp_epg: <<: *epg_query epg: ansible_test_2 register: nm_query_contract_epg - name: Verify that 4 contracts are in EPG 2 using nm_query_contract_epg - assert: + ansible.builtin.assert: that: - nm_query_contract_epg.current.contractRelationships | length == 4 # Checking if issue when querying EPG and VRF is not defined (#66) - name: Add new test EPG 3 (normal mode) - mso_schema_template_anp_epg: &epg_present_2 + cisco.mso.mso_schema_template_anp_epg: &epg_present_2 <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -1214,19 +1214,19 @@ register: nm_add_epg_3 - name: Verify nm_add_epg_3 - assert: + ansible.builtin.assert: that: - nm_add_epg_3 is changed - nm_add_epg_3.current.name == 'ansible_test_3' - "'vrfRef' not in nm_add_epg_3.current" - name: Query test EPG 3 - mso_schema_template_anp_epg: + cisco.mso.mso_schema_template_anp_epg: <<: *epg_present_2 register: nm_query_epg_3 - name: Verify nm_query_epg_3 - assert: + ansible.builtin.assert: that: - nm_query_epg_3 is not changed - nm_query_epg_3.current.name == 'ansible_test_3' @@ -1234,7 +1234,7 @@ # Checking if modifying an EPG with existing contracts throw an MSO error. (#82) - name: Change EPG 2 to add VRF (normal_mode) - mso_schema_template_anp_epg: + cisco.mso.mso_schema_template_anp_epg: <<: *epg_present epg: ansible_test_2 vrf: @@ -1244,7 +1244,7 @@ register: nm_change_epg_2_vrf - name: Verify that EPG 2 did change - assert: + ansible.builtin.assert: that: - nm_change_epg_2_vrf is changed - nm_change_epg_2_vrf.current.vrfRef.templateName == "Template1" @@ -1252,12 +1252,12 @@ - nm_change_epg_2_vrf.current.bdRef.bdName == "ansible_test_2" - name: Query EPG 2 - mso_schema_template_anp_epg: + cisco.mso.mso_schema_template_anp_epg: <<: *epg_query epg: ansible_test_2 register: nm_query_contract_epg_2 - name: Verify that 4 contracts are in EPG 2 using nm_query_contract_epg_2 - assert: + ansible.builtin.assert: that: - nm_query_contract_epg_2.current.contractRelationships | length == 4
\ No newline at end of file diff --git a/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_anp_epg_contract/tasks/main.yml b/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_anp_epg_contract/tasks/main.yml index 0027cfda4..9ffe1b7fe 100644 --- a/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_anp_epg_contract/tasks/main.yml +++ b/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_anp_epg_contract/tasks/main.yml @@ -1,17 +1,17 @@ # Test code for the MSO modules +# Copyright: (c) 2024, Akini Ross (@akinross) <akinross@cisco.com> # Copyright: (c) 2020, Lionel Hercot (@lhercot) <lhercot@cisco.com> # Copyright: (c) 2018, Dag Wieers (@dagwieers) <dag@wieers.com> (based on mso_site test case) -# # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI MultiSite host, username and password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: mso_hostname, mso_username and mso_password.' when: mso_hostname is not defined or mso_username is not defined or mso_password is not defined - name: Set vars - set_fact: + ansible.builtin.set_fact: mso_info: &mso_info host: '{{ mso_hostname }}' username: '{{ mso_username }}' @@ -23,7 +23,7 @@ # CLEAN ENVIRONMENT # - name: Ensure site exist -# mso_site: &site_present +# cisco.mso.mso_site: &site_present # host: '{{ mso_hostname }}' # username: '{{ mso_username }}' # password: '{{ mso_password }}' @@ -40,7 +40,7 @@ # state: present - name: Remove schemas - mso_schema: + cisco.mso.mso_schema: <<: *mso_info schema: '{{ item }}' state: absent @@ -49,7 +49,7 @@ - '{{ mso_schema | default("ansible_test") }}' - name: Ensure tenant ansible_test exist - mso_tenant: &tenant_present + cisco.mso.mso_tenant: &tenant_present <<: *mso_info tenant: ansible_test users: @@ -59,7 +59,7 @@ state: present - name: Ensure schema 1 with Template 1 exist - mso_schema_template: + cisco.mso.mso_schema_template: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' tenant: ansible_test @@ -67,7 +67,7 @@ state: present - name: Ensure schema 1 with Template 2 exist - mso_schema_template: + cisco.mso.mso_schema_template: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' tenant: ansible_test @@ -75,7 +75,7 @@ state: present - name: Ensure schema 2 with Template 3 exist - mso_schema_template: + cisco.mso.mso_schema_template: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}_2' tenant: ansible_test @@ -83,7 +83,7 @@ state: present - name: Ensure ANP exist - mso_schema_template_anp: + cisco.mso.mso_schema_template_anp: <<: *mso_info schema: '{{ item.schema }}' template: '{{ item.template }}' @@ -94,7 +94,7 @@ - { schema: '{{ mso_schema | default("ansible_test") }}_2', template: 'Template 3' } - name: Ensure Filter 1 exist - mso_schema_template_filter_entry: + cisco.mso.mso_schema_template_filter_entry: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -103,7 +103,7 @@ state: present - name: Ensure Contract1 exist - mso_schema_template_contract_filter: &contract_present + cisco.mso.mso_schema_template_contract_filter: &contract_present <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -114,7 +114,7 @@ state: present - name: Ensure Filter 2 exist - mso_schema_template_filter_entry: + cisco.mso.mso_schema_template_filter_entry: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 2 @@ -123,7 +123,7 @@ state: present - name: Ensure Contract2 exist - mso_schema_template_contract_filter: &contract2_present + cisco.mso.mso_schema_template_contract_filter: &contract2_present <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 2 @@ -134,7 +134,7 @@ state: present - name: Ensure EPGs exist - mso_schema_template_anp_epg: + cisco.mso.mso_schema_template_anp_epg: <<: *mso_info schema: '{{ item.schema }}' template: '{{ item.template }}' @@ -147,7 +147,7 @@ # ADD Contract to EPG - name: Add Contract1 to EPG (check_mode) - mso_schema_template_anp_epg_contract: &contract_epg_present + cisco.mso.mso_schema_template_anp_epg_contract: &contract_epg_present <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -161,7 +161,7 @@ register: cm_add_contract_rel - name: Verify cm_add_contract_rel - assert: + ansible.builtin.assert: that: - cm_add_contract_rel is changed - cm_add_contract_rel.previous == {} @@ -170,12 +170,12 @@ - cm_add_contract_rel.current.relationshipType == "consumer" - name: Add Contract to EPG (normal mode) - mso_schema_template_anp_epg_contract: + cisco.mso.mso_schema_template_anp_epg_contract: <<: *contract_epg_present register: nm_add_contract_rel - name: Verify nm_add_contract_rel - assert: + ansible.builtin.assert: that: - nm_add_contract_rel is changed - nm_add_contract_rel.previous == {} @@ -185,13 +185,13 @@ - cm_add_contract_rel.current.contractRef.schemaId == nm_add_contract_rel.current.contractRef.schemaId - name: Add Contract to EPG again (check_mode) - mso_schema_template_anp_epg_contract: + cisco.mso.mso_schema_template_anp_epg_contract: <<: *contract_epg_present check_mode: true register: cm_add_contract_rel_again - name: Verify cm_add_contract_rel_again - assert: + ansible.builtin.assert: that: - cm_add_contract_rel_again is not changed - cm_add_contract_rel_again.previous.contractRef.templateName == "Template1" @@ -204,12 +204,12 @@ - name: Add Contract to EPG again (normal mode) - mso_schema_template_anp_epg_contract: + cisco.mso.mso_schema_template_anp_epg_contract: <<: *contract_epg_present register: nm_add_contract_rel_again - name: Verify nm_add_contract_rel_again - assert: + ansible.builtin.assert: that: - nm_add_contract_rel_again is not changed - nm_add_contract_rel_again.previous.contractRef.templateName == "Template1" @@ -221,7 +221,7 @@ - nm_add_contract_rel_again.previous.contractRef.schemaId == nm_add_contract_rel_again.current.contractRef.schemaId - name: Add Contract1 to EPG - provider (normal mode) - mso_schema_template_anp_epg_contract: + cisco.mso.mso_schema_template_anp_epg_contract: <<: *contract_epg_present contract: name: Contract1 @@ -229,7 +229,7 @@ register: nm_add_contract1_rel_provider - name: Add Contract2 to EPG - consumer (normal mode) - mso_schema_template_anp_epg_contract: + cisco.mso.mso_schema_template_anp_epg_contract: <<: *contract_epg_present contract: name: Contract2 @@ -238,7 +238,7 @@ register: nm_add_contract2_rel_consumer - name: Add Contract1 to EPG 3 - provider (normal mode) - mso_schema_template_anp_epg_contract: + cisco.mso.mso_schema_template_anp_epg_contract: <<: *contract_epg_present schema: '{{ mso_schema | default("ansible_test") }}_2' template: Template 3 @@ -252,7 +252,7 @@ register: nm_add_contract3_rel_provider - name: Verify nm_add_contract1_rel_provider, nm_add_contract2_rel_consumer and nm_add_contract3_rel_provider - assert: + ansible.builtin.assert: that: - nm_add_contract1_rel_provider is changed - nm_add_contract2_rel_consumer is changed @@ -267,7 +267,7 @@ # # QUERY ALL Contract to EPG - name: Query all contract relationship for EPG (check_mode) - mso_schema_template_anp_epg_contract: &contract_epg_query + cisco.mso.mso_schema_template_anp_epg_contract: &contract_epg_query <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -278,12 +278,12 @@ register: cm_query_all_contract_rels - name: Query all contract relationship for EPG (normal mode) - mso_schema_template_anp_epg_contract: + cisco.mso.mso_schema_template_anp_epg_contract: <<: *contract_epg_query register: nm_query_all_contract_rels - name: Verify query_all_contract_rels - assert: + ansible.builtin.assert: that: - cm_query_all_contract_rels is not changed - nm_query_all_contract_rels is not changed @@ -292,7 +292,7 @@ # QUERY A Contract to EPG - name: Query Contract1 relationship for EPG - consumer (check_mode) - mso_schema_template_anp_epg_contract: + cisco.mso.mso_schema_template_anp_epg_contract: <<: *contract_epg_query contract: name: Contract1 @@ -301,7 +301,7 @@ register: cm_query_contract1_consumer_rel - name: Query Contract1 relationship for EPG - consumer (normal mode) - mso_schema_template_anp_epg_contract: + cisco.mso.mso_schema_template_anp_epg_contract: <<: *contract_epg_query contract: name: Contract1 @@ -309,7 +309,7 @@ register: nm_query_contract1_consumer_rel - name: Query Contract1 relationship for EPG - provider (normal mode) - mso_schema_template_anp_epg_contract: + cisco.mso.mso_schema_template_anp_epg_contract: <<: *contract_epg_query contract: name: Contract1 @@ -317,7 +317,7 @@ register: nm_query_contract1_provider_rel - name: Query Contract1 relationship for EPG - consumer (normal mode) - mso_schema_template_anp_epg_contract: + cisco.mso.mso_schema_template_anp_epg_contract: <<: *contract_epg_query contract: name: Contract2 @@ -326,7 +326,7 @@ register: nm_query_contract2_consumer_rel - name: Query Contract1 relationship for EPG - provider (normal mode) - mso_schema_template_anp_epg_contract: + cisco.mso.mso_schema_template_anp_epg_contract: <<: *contract_epg_query schema: '{{ mso_schema | default("ansible_test") }}_2' template: Template 3 @@ -340,7 +340,7 @@ register: nm_query_contract3_provider_rel - name: Verify query_contractX_YYYYY_rel - assert: + ansible.builtin.assert: that: - cm_query_contract1_consumer_rel is not changed - nm_query_contract1_consumer_rel is not changed @@ -359,51 +359,51 @@ # REMOVE Contract to EPG - name: Remove Contract to EPG (check_mode) - mso_schema_template_anp_epg_contract: + cisco.mso.mso_schema_template_anp_epg_contract: <<: *contract_epg_present state: absent check_mode: true register: cm_remove_contract_rel - name: Verify cm_remove_contract_rel - assert: + ansible.builtin.assert: that: - cm_remove_contract_rel is changed - cm_remove_contract_rel.current == {} - name: Remove Contract to EPG (normal mode) - mso_schema_template_anp_epg_contract: + cisco.mso.mso_schema_template_anp_epg_contract: <<: *contract_epg_present state: absent register: nm_remove_contract_rel - name: Verify nm_remove_contract_rel - assert: + ansible.builtin.assert: that: - nm_remove_contract_rel is changed - nm_remove_contract_rel.current == {} - name: Remove Contract to EPG again (check_mode) - mso_schema_template_anp_epg_contract: + cisco.mso.mso_schema_template_anp_epg_contract: <<: *contract_epg_present state: absent check_mode: true register: cm_remove_contract_rel_again - name: Verify cm_remove_contract_rel_again - assert: + ansible.builtin.assert: that: - cm_remove_contract_rel_again is not changed - cm_remove_contract_rel_again.current == {} - name: Remove Contract to EPG again (normal mode) - mso_schema_template_anp_epg_contract: + cisco.mso.mso_schema_template_anp_epg_contract: <<: *contract_epg_present state: absent register: nm_remove_contract_rel_again - name: Verify nm_remove_contract_rel_again - assert: + ansible.builtin.assert: that: - nm_remove_contract_rel_again is not changed - nm_remove_contract_rel_again.current == {} @@ -411,7 +411,7 @@ # QUERY NON-EXISTING Contract to EPG - name: Query non-existing contract (check_mode) - mso_schema_template_anp_epg_contract: + cisco.mso.mso_schema_template_anp_epg_contract: <<: *contract_epg_query contract: name: non_existing_contract @@ -421,7 +421,7 @@ register: cm_query_non_contract - name: Query non-existing contract (normal mode) - mso_schema_template_anp_epg_contract: + cisco.mso.mso_schema_template_anp_epg_contract: <<: *contract_epg_query contract: name: non_existing_contract @@ -430,17 +430,17 @@ register: nm_query_non_contract - name: Verify query_non_contract - assert: + ansible.builtin.assert: that: - cm_query_non_contract is not changed - nm_query_non_contract is not changed - cm_query_non_contract == nm_query_non_contract - - cm_query_non_contract.msg is match("Contract '/schemas/[0-9a-zA-Z]*/templates/Template1/contracts/non_existing_contract' not found") - - nm_query_non_contract.msg is match("Contract '/schemas/[0-9a-zA-Z]*/templates/Template1/contracts/non_existing_contract' not found") + - cm_query_non_contract.msg is match("Contract with Reference '/schemas/[0-9a-zA-Z]*/templates/Template1/contracts/non_existing_contract' and type 'provider' not found") + - nm_query_non_contract.msg is match("Contract with Reference '/schemas/[0-9a-zA-Z]*/templates/Template1/contracts/non_existing_contract' and type 'provider' not found") # QUERY NON-EXISTING EPG - name: Query non-existing EPG (check_mode) - mso_schema_template_anp_epg_contract: + cisco.mso.mso_schema_template_anp_epg_contract: <<: *contract_epg_query epg: non_existing_epg check_mode: true @@ -448,23 +448,23 @@ register: cm_query_non_epg - name: Query non-existing EPG (normal mode) - mso_schema_template_anp_epg_contract: + cisco.mso.mso_schema_template_anp_epg_contract: <<: *contract_epg_query epg: non_existing_epg ignore_errors: true register: nm_query_non_epg - name: Verify query_non_epg - assert: + ansible.builtin.assert: that: - cm_query_non_epg is not changed - nm_query_non_epg is not changed - cm_query_non_epg == nm_query_non_epg - - cm_query_non_epg.msg == nm_query_non_epg.msg == "Provided epg 'non_existing_epg' does not exist. Existing epgs{{':'}} ansible_test_1" + - cm_query_non_epg.msg == nm_query_non_epg.msg == "Provided EPG 'non_existing_epg' not matching existing epg(s){{":"}} ansible_test_1" # QUERY NON-EXISTING ANP - name: Query non-existing ANP (check_mode) - mso_schema_template_anp_epg_contract: + cisco.mso.mso_schema_template_anp_epg_contract: <<: *contract_epg_query anp: non_existing_anp check_mode: true @@ -472,23 +472,23 @@ register: cm_query_non_anp - name: Query non-existing ANP (normal mode) - mso_schema_template_anp_epg_contract: + cisco.mso.mso_schema_template_anp_epg_contract: <<: *contract_epg_query anp: non_existing_anp ignore_errors: true register: nm_query_non_anp - name: Verify query_non_anp - assert: + ansible.builtin.assert: that: - cm_query_non_anp is not changed - nm_query_non_anp is not changed - cm_query_non_anp == nm_query_non_anp - - cm_query_non_anp.msg == nm_query_non_anp.msg == "Provided anp 'non_existing_anp' does not exist. Existing anps{{':'}} ANP" + - cm_query_non_anp.msg == nm_query_non_anp.msg == "Provided ANP 'non_existing_anp' not matching existing anp(s){{":"}} ANP" # USE A NON-EXISTING STATE - name: Non-existing state for contract relationship (check_mode) - mso_schema_template_anp_epg_contract: + cisco.mso.mso_schema_template_anp_epg_contract: <<: *contract_epg_query state: non-existing-state check_mode: true @@ -496,14 +496,14 @@ register: cm_non_existing_state - name: Non-existing state for contract relationship (normal_mode) - mso_schema_template_anp_epg_contract: + cisco.mso.mso_schema_template_anp_epg_contract: <<: *contract_epg_query state: non-existing-state ignore_errors: true register: nm_non_existing_state - name: Verify non_existing_state - assert: + ansible.builtin.assert: that: - cm_non_existing_state is not changed - nm_non_existing_state is not changed @@ -512,7 +512,7 @@ # USE A NON-EXISTING SCHEMA - name: Non-existing schema for contract relationship (check_mode) - mso_schema_template_anp_epg_contract: + cisco.mso.mso_schema_template_anp_epg_contract: <<: *contract_epg_query schema: non-existing-schema check_mode: true @@ -520,14 +520,14 @@ register: cm_non_existing_schema - name: Non-existing schema for contract relationship (normal_mode) - mso_schema_template_anp_epg_contract: + cisco.mso.mso_schema_template_anp_epg_contract: <<: *contract_epg_query schema: non-existing-schema ignore_errors: true register: nm_non_existing_schema - name: Verify non_existing_schema - assert: + ansible.builtin.assert: that: - cm_non_existing_schema is not changed - nm_non_existing_schema is not changed @@ -535,7 +535,7 @@ - cm_non_existing_schema.msg == nm_non_existing_schema.msg == "Provided schema 'non-existing-schema' does not exist." - name: Non-existing contract schema for contract relationship (check_mode) - mso_schema_template_anp_epg_contract: + cisco.mso.mso_schema_template_anp_epg_contract: <<: *contract_epg_query contract: name: Contract1 @@ -547,7 +547,7 @@ register: cm_non_existing_contract_schema - name: Non-existing contract schema for contract relationship (normal_mode) - mso_schema_template_anp_epg_contract: + cisco.mso.mso_schema_template_anp_epg_contract: <<: *contract_epg_query contract: name: Contract1 @@ -558,7 +558,7 @@ register: nm_non_existing_contract_schema - name: Verify non_existing_contract_schema - assert: + ansible.builtin.assert: that: - cm_non_existing_contract_schema is not changed - nm_non_existing_contract_schema is not changed @@ -567,7 +567,7 @@ # USE A NON-EXISTING TEMPLATE - name: Non-existing template for contract relationship (check_mode) - mso_schema_template_anp_epg_contract: + cisco.mso.mso_schema_template_anp_epg_contract: <<: *contract_epg_query template: non-existing-template check_mode: true @@ -575,22 +575,22 @@ register: cm_non_existing_template - name: Non-existing template for contract relationship (normal_mode) - mso_schema_template_anp_epg_contract: + cisco.mso.mso_schema_template_anp_epg_contract: <<: *contract_epg_query template: non-existing-template ignore_errors: true register: nm_non_existing_template - name: Verify non_existing_template - assert: + ansible.builtin.assert: that: - cm_non_existing_template is not changed - nm_non_existing_template is not changed - cm_non_existing_template == nm_non_existing_template - - cm_non_existing_template.msg == nm_non_existing_template.msg == "Provided template 'non-existing-template' does not exist. Existing templates{{':'}} Template1, Template2" + - cm_non_existing_template.msg == nm_non_existing_template.msg == "Provided template 'non-existing-template' not matching existing template(s){{":"}} Template1, Template2" - name: Non-existing contract template for contract relationship (check_mode) - mso_schema_template_anp_epg_contract: + cisco.mso.mso_schema_template_anp_epg_contract: <<: *contract_epg_query contract: name: Contract1 @@ -601,7 +601,7 @@ register: cm_non_existing_contract_template - name: Non-existing contract template for contract relationship (normal_mode) - mso_schema_template_anp_epg_contract: + cisco.mso.mso_schema_template_anp_epg_contract: <<: *contract_epg_query contract: name: Contract1 @@ -611,10 +611,502 @@ register: nm_non_existing_contract_template - name: Verify non_existing_contract_template - assert: + ansible.builtin.assert: that: - cm_non_existing_contract_template is not changed - nm_non_existing_contract_template is not changed - cm_non_existing_contract_template == nm_non_existing_contract_template - - cm_non_existing_contract_template.msg is match("Contract '/schemas/[0-9a-zA-Z]*/templates/non-existing-template/contracts/Contract1' not found") - - nm_non_existing_contract_template.msg is match("Contract '/schemas/[0-9a-zA-Z]*/templates/non-existing-template/contracts/Contract1' not found")
\ No newline at end of file + - cm_non_existing_contract_template.msg is match("Contract with Reference '/schemas/[0-9a-zA-Z]*/templates/non-existing-template/contracts/Contract1' and type 'provider' not found") + - nm_non_existing_contract_template.msg is match("Contract with Reference '/schemas/[0-9a-zA-Z]*/templates/non-existing-template/contracts/Contract1' and type 'provider' not found") + +# TESTS IN BULK + +# SETUP TEST ENVIRONMENT FOR BULK + +- name: Create template_bulk in schema ansible_test + cisco.mso.mso_schema_template: &bulk_template_present + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: template_bulk + tenant: ansible_test + +- name: Create filter_bulk in template_bulk + cisco.mso.mso_schema_template_filter_entry: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: template_bulk + filter: filter_bulk + entry: filter_entry_bulk + +- name: Create 20 contract_bulk_x in template_bulk + cisco.mso.mso_schema_template_contract_filter: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: template_bulk + contract: "contract_bulk_{{ item }}" + filter: filter_bulk + loop: "{{ range(1, 21, 1) | list }}" + +- name: Create ANP in template_bulk + cisco.mso.mso_schema_template_anp: &anp_bulk + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: template_bulk + anp: anp_bulk + +- name: Create EPG in template_bulk + cisco.mso.mso_schema_template_anp_epg: &epg_bulk + <<: *anp_bulk + epg: epg_bulk + +- name: Set facts for provider contracts + ansible.builtin.set_fact: + provider_contracts_present: [] + provider_contracts_absent: [] + consumer_contracts_present: [] + consumer_contracts_absent: [] + +- name: Create contracts list for appending + ansible.builtin.set_fact: + provider_contracts_present: "{{ provider_contracts_present + [{'name': 'contract_bulk_%s' | format(item), 'type': 'provider'}] }}" + consumer_contracts_present: "{{ consumer_contracts_present + [{'name': 'contract_bulk_%s' | format(item), 'type': 'consumer'}] }}" + loop: "{{ range(1, 21, 1) | list }}" + +- name: Create contracts list for removing + ansible.builtin.set_fact: + provider_contracts_absent: "{{ provider_contracts_absent + [{'name': 'contract_bulk_%s' | format(item), 'type': 'provider'}] }}" + consumer_contracts_absent: "{{ consumer_contracts_absent + [{'name': 'contract_bulk_%s' | format(item), 'type': 'consumer'}] }}" + loop: "{{ range(1, 21, 2) | list }}" + +# CREATE AND UPDATE TESTS FOR BULK + +- name: Append provider contracts (check_mode) + cisco.mso.mso_schema_template_anp_epg_contract: &provider_contracts_append + <<: *epg_bulk + contracts: "{{ provider_contracts_present }}" + register: cm_append_provider_contracts + check_mode: true + +- name: Append provider contracts + cisco.mso.mso_schema_template_anp_epg_contract: + <<: *provider_contracts_append + register: nm_append_provider_contracts + +- name: Append provider contracts again + cisco.mso.mso_schema_template_anp_epg_contract: + <<: *provider_contracts_append + register: nm_append_provider_contracts_again + +- name: Append consumer contracts + cisco.mso.mso_schema_template_anp_epg_contract: + <<: *provider_contracts_append + contracts: "{{ consumer_contracts_present }}" + register: nm_append_consumer_contracts + +- name: Verify appending contracts + ansible.builtin.assert: + that: + - cm_append_provider_contracts is changed + - cm_append_provider_contracts.previous == [] + - cm_append_provider_contracts.current | length == 20 + - cm_append_provider_contracts.current.0.contractRef.contractName == "contract_bulk_1" + - cm_append_provider_contracts.current.0.relationshipType == "provider" + - cm_append_provider_contracts.current.9.contractRef.contractName == "contract_bulk_10" + - cm_append_provider_contracts.current.9.relationshipType == "provider" + - cm_append_provider_contracts.current.19.contractRef.contractName == "contract_bulk_20" + - cm_append_provider_contracts.current.19.relationshipType == "provider" + - nm_append_provider_contracts is changed + - nm_append_provider_contracts.previous == [] + - nm_append_provider_contracts.current | length == 20 + - nm_append_provider_contracts.current.0.contractRef.contractName == "contract_bulk_1" + - nm_append_provider_contracts.current.0.relationshipType == "provider" + - nm_append_provider_contracts.current.9.contractRef.contractName == "contract_bulk_10" + - nm_append_provider_contracts.current.9.relationshipType == "provider" + - nm_append_provider_contracts.current.19.contractRef.contractName == "contract_bulk_20" + - nm_append_provider_contracts.current.19.relationshipType == "provider" + - nm_append_provider_contracts_again is not changed + - nm_append_provider_contracts_again.previous.0.contractRef.contractName == "contract_bulk_1" + - nm_append_provider_contracts_again.previous.0.relationshipType == "provider" + - nm_append_provider_contracts_again.previous.9.contractRef.contractName == "contract_bulk_10" + - nm_append_provider_contracts_again.previous.9.relationshipType == "provider" + - nm_append_provider_contracts_again.previous.19.contractRef.contractName == "contract_bulk_20" + - nm_append_provider_contracts_again.previous.19.relationshipType == "provider" + - nm_append_provider_contracts_again.current | length == 20 + - nm_append_provider_contracts_again.current.0.contractRef.contractName == "contract_bulk_1" + - nm_append_provider_contracts_again.current.0.relationshipType == "provider" + - nm_append_provider_contracts_again.current.9.contractRef.contractName == "contract_bulk_10" + - nm_append_provider_contracts_again.current.9.relationshipType == "provider" + - nm_append_provider_contracts_again.current.19.contractRef.contractName == "contract_bulk_20" + - nm_append_provider_contracts_again.current.19.relationshipType == "provider" + - nm_append_consumer_contracts is changed + - nm_append_consumer_contracts.previous.0.contractRef.contractName == "contract_bulk_1" + - nm_append_consumer_contracts.previous.0.relationshipType == "provider" + - nm_append_consumer_contracts.previous.9.contractRef.contractName == "contract_bulk_10" + - nm_append_consumer_contracts.previous.9.relationshipType == "provider" + - nm_append_consumer_contracts.previous.19.contractRef.contractName == "contract_bulk_20" + - nm_append_consumer_contracts.previous.19.relationshipType == "provider" + - nm_append_consumer_contracts.current | length == 40 + - nm_append_consumer_contracts.current.0.contractRef.contractName == "contract_bulk_1" + - nm_append_consumer_contracts.current.0.relationshipType == "provider" + - nm_append_consumer_contracts.current.9.contractRef.contractName == "contract_bulk_10" + - nm_append_consumer_contracts.current.9.relationshipType == "provider" + - nm_append_consumer_contracts.current.19.contractRef.contractName == "contract_bulk_20" + - nm_append_consumer_contracts.current.19.relationshipType == "provider" + - nm_append_consumer_contracts.current.20.contractRef.contractName == "contract_bulk_1" + - nm_append_consumer_contracts.current.20.relationshipType == "consumer" + - nm_append_consumer_contracts.current.29.contractRef.contractName == "contract_bulk_10" + - nm_append_consumer_contracts.current.29.relationshipType == "consumer" + - nm_append_consumer_contracts.current.39.contractRef.contractName == "contract_bulk_20" + - nm_append_consumer_contracts.current.39.relationshipType == "consumer" + +# REMOVE TESTS FOR BULK + +- name: Remove provider contracts (check_mode) + cisco.mso.mso_schema_template_anp_epg_contract: &provider_contracts_remove + <<: *epg_bulk + contracts: "{{ provider_contracts_absent }}" + state: absent + register: cm_remove_provider_contracts + check_mode: true + +- name: Remove provider contracts + cisco.mso.mso_schema_template_anp_epg_contract: + <<: *provider_contracts_remove + register: nm_remove_provider_contracts + +- name: Remove provider contracts again + cisco.mso.mso_schema_template_anp_epg_contract: + <<: *provider_contracts_remove + register: nm_remove_provider_contracts_again + +- name: Remove consumer contracts + cisco.mso.mso_schema_template_anp_epg_contract: + <<: *provider_contracts_remove + contracts: "{{ consumer_contracts_absent }}" + register: nm_remove_consumer_contracts + +- name: Verify removing contracts + ansible.builtin.assert: + that: + - cm_remove_provider_contracts is changed + - cm_remove_provider_contracts.previous | length == 40 + - cm_remove_provider_contracts.previous.0.contractRef.contractName == "contract_bulk_1" + - cm_remove_provider_contracts.previous.0.relationshipType == "provider" + - cm_remove_provider_contracts.previous.9.contractRef.contractName == "contract_bulk_10" + - cm_remove_provider_contracts.previous.9.relationshipType == "provider" + - cm_remove_provider_contracts.previous.19.contractRef.contractName == "contract_bulk_20" + - cm_remove_provider_contracts.previous.19.relationshipType == "provider" + - cm_remove_provider_contracts.previous.20.contractRef.contractName == "contract_bulk_1" + - cm_remove_provider_contracts.previous.20.relationshipType == "consumer" + - cm_remove_provider_contracts.previous.29.contractRef.contractName == "contract_bulk_10" + - cm_remove_provider_contracts.previous.29.relationshipType == "consumer" + - cm_remove_provider_contracts.previous.39.contractRef.contractName == "contract_bulk_20" + - cm_remove_provider_contracts.previous.39.relationshipType == "consumer" + - cm_remove_provider_contracts.current | length == 30 + - cm_remove_provider_contracts.current.0.contractRef.contractName == "contract_bulk_2" + - cm_remove_provider_contracts.current.0.relationshipType == "provider" + - cm_remove_provider_contracts.current.4.contractRef.contractName == "contract_bulk_10" + - cm_remove_provider_contracts.current.4.relationshipType == "provider" + - cm_remove_provider_contracts.current.9.contractRef.contractName == "contract_bulk_20" + - cm_remove_provider_contracts.current.9.relationshipType == "provider" + - cm_remove_provider_contracts.current.10.contractRef.contractName == "contract_bulk_1" + - cm_remove_provider_contracts.current.10.relationshipType == "consumer" + - cm_remove_provider_contracts.current.19.contractRef.contractName == "contract_bulk_10" + - cm_remove_provider_contracts.current.19.relationshipType == "consumer" + - cm_remove_provider_contracts.current.29.contractRef.contractName == "contract_bulk_20" + - cm_remove_provider_contracts.current.29.relationshipType == "consumer" + - nm_remove_provider_contracts is changed + - nm_remove_provider_contracts.previous | length == 40 + - nm_remove_provider_contracts.previous.0.contractRef.contractName == "contract_bulk_1" + - nm_remove_provider_contracts.previous.0.relationshipType == "provider" + - nm_remove_provider_contracts.previous.9.contractRef.contractName == "contract_bulk_10" + - nm_remove_provider_contracts.previous.9.relationshipType == "provider" + - nm_remove_provider_contracts.previous.19.contractRef.contractName == "contract_bulk_20" + - nm_remove_provider_contracts.previous.19.relationshipType == "provider" + - nm_remove_provider_contracts.previous.20.contractRef.contractName == "contract_bulk_1" + - nm_remove_provider_contracts.previous.20.relationshipType == "consumer" + - nm_remove_provider_contracts.previous.29.contractRef.contractName == "contract_bulk_10" + - nm_remove_provider_contracts.previous.29.relationshipType == "consumer" + - nm_remove_provider_contracts.previous.39.contractRef.contractName == "contract_bulk_20" + - nm_remove_provider_contracts.previous.39.relationshipType == "consumer" + - nm_remove_provider_contracts.current | length == 30 + - nm_remove_provider_contracts.current.0.contractRef.contractName == "contract_bulk_2" + - nm_remove_provider_contracts.current.0.relationshipType == "provider" + - nm_remove_provider_contracts.current.4.contractRef.contractName == "contract_bulk_10" + - nm_remove_provider_contracts.current.4.relationshipType == "provider" + - nm_remove_provider_contracts.current.9.contractRef.contractName == "contract_bulk_20" + - nm_remove_provider_contracts.current.9.relationshipType == "provider" + - nm_remove_provider_contracts.current.10.contractRef.contractName == "contract_bulk_1" + - nm_remove_provider_contracts.current.10.relationshipType == "consumer" + - nm_remove_provider_contracts.current.19.contractRef.contractName == "contract_bulk_10" + - nm_remove_provider_contracts.current.19.relationshipType == "consumer" + - nm_remove_provider_contracts.current.29.contractRef.contractName == "contract_bulk_20" + - nm_remove_provider_contracts.current.29.relationshipType == "consumer" + - nm_remove_provider_contracts_again is not changed + - nm_remove_provider_contracts_again.previous | length == 30 + - nm_remove_provider_contracts_again.previous.0.contractRef.contractName == "contract_bulk_2" + - nm_remove_provider_contracts_again.previous.0.relationshipType == "provider" + - nm_remove_provider_contracts_again.previous.4.contractRef.contractName == "contract_bulk_10" + - nm_remove_provider_contracts_again.previous.4.relationshipType == "provider" + - nm_remove_provider_contracts_again.previous.9.contractRef.contractName == "contract_bulk_20" + - nm_remove_provider_contracts_again.previous.9.relationshipType == "provider" + - nm_remove_provider_contracts_again.previous.10.contractRef.contractName == "contract_bulk_1" + - nm_remove_provider_contracts_again.previous.10.relationshipType == "consumer" + - nm_remove_provider_contracts_again.previous.19.contractRef.contractName == "contract_bulk_10" + - nm_remove_provider_contracts_again.previous.19.relationshipType == "consumer" + - nm_remove_provider_contracts_again.previous.29.contractRef.contractName == "contract_bulk_20" + - nm_remove_provider_contracts_again.previous.29.relationshipType == "consumer" + - nm_remove_provider_contracts_again.current | length == 30 + - nm_remove_provider_contracts_again.current.0.contractRef.contractName == "contract_bulk_2" + - nm_remove_provider_contracts_again.current.0.relationshipType == "provider" + - nm_remove_provider_contracts_again.current.4.contractRef.contractName == "contract_bulk_10" + - nm_remove_provider_contracts_again.current.4.relationshipType == "provider" + - nm_remove_provider_contracts_again.current.9.contractRef.contractName == "contract_bulk_20" + - nm_remove_provider_contracts_again.current.9.relationshipType == "provider" + - nm_remove_provider_contracts_again.current.10.contractRef.contractName == "contract_bulk_1" + - nm_remove_provider_contracts_again.current.10.relationshipType == "consumer" + - nm_remove_provider_contracts_again.current.19.contractRef.contractName == "contract_bulk_10" + - nm_remove_provider_contracts_again.current.19.relationshipType == "consumer" + - nm_remove_provider_contracts_again.current.29.contractRef.contractName == "contract_bulk_20" + - nm_remove_provider_contracts_again.current.29.relationshipType == "consumer" + - nm_remove_consumer_contracts is changed + - nm_remove_consumer_contracts.previous | length == 30 + - nm_remove_consumer_contracts.previous.0.contractRef.contractName == "contract_bulk_2" + - nm_remove_consumer_contracts.previous.0.relationshipType == "provider" + - nm_remove_consumer_contracts.previous.4.contractRef.contractName == "contract_bulk_10" + - nm_remove_consumer_contracts.previous.4.relationshipType == "provider" + - nm_remove_consumer_contracts.previous.9.contractRef.contractName == "contract_bulk_20" + - nm_remove_consumer_contracts.previous.9.relationshipType == "provider" + - nm_remove_consumer_contracts.previous.10.contractRef.contractName == "contract_bulk_1" + - nm_remove_consumer_contracts.previous.10.relationshipType == "consumer" + - nm_remove_consumer_contracts.previous.19.contractRef.contractName == "contract_bulk_10" + - nm_remove_consumer_contracts.previous.19.relationshipType == "consumer" + - nm_remove_consumer_contracts.previous.29.contractRef.contractName == "contract_bulk_20" + - nm_remove_consumer_contracts.previous.29.relationshipType == "consumer" + - nm_remove_consumer_contracts.current | length == 20 + - nm_remove_consumer_contracts.current.0.contractRef.contractName == "contract_bulk_2" + - nm_remove_consumer_contracts.current.0.relationshipType == "provider" + - nm_remove_consumer_contracts.current.4.contractRef.contractName == "contract_bulk_10" + - nm_remove_consumer_contracts.current.4.relationshipType == "provider" + - nm_remove_consumer_contracts.current.9.contractRef.contractName == "contract_bulk_20" + - nm_remove_consumer_contracts.current.9.relationshipType == "provider" + - nm_remove_consumer_contracts.current.10.contractRef.contractName == "contract_bulk_2" + - nm_remove_consumer_contracts.current.10.relationshipType == "consumer" + - nm_remove_consumer_contracts.current.14.contractRef.contractName == "contract_bulk_10" + - nm_remove_consumer_contracts.current.14.relationshipType == "consumer" + - nm_remove_consumer_contracts.current.19.contractRef.contractName == "contract_bulk_20" + - nm_remove_consumer_contracts.current.19.relationshipType == "consumer" + +# FORCE REPLACE TESTS + +- name: Force replace contracts with contracts (check_mode) + cisco.mso.mso_schema_template_anp_epg_contract: + <<: *provider_contracts_append + force_replace: true + register: cm_force_replace_provider_contracts + check_mode: true + +- name: Force replace contracts with contracts + cisco.mso.mso_schema_template_anp_epg_contract: + <<: *provider_contracts_append + force_replace: true + register: nm_force_replace_provider_contracts + +- name: Force replace contracts with contracts again + cisco.mso.mso_schema_template_anp_epg_contract: + <<: *provider_contracts_append + force_replace: true + register: nm_force_replace_provider_contracts_again + +- name: Force replace contracts with new contracts + cisco.mso.mso_schema_template_anp_epg_contract: + <<: *provider_contracts_append + contracts: "{{ consumer_contracts_present }}" + force_replace: true + register: nm_force_replace_consumer_contracts + +- name: Verify force replacing contracts + ansible.builtin.assert: + that: + - cm_force_replace_provider_contracts is changed + - cm_force_replace_provider_contracts.previous | length == 20 + - cm_force_replace_provider_contracts.previous.0.contractRef.contractName == "contract_bulk_2" + - cm_force_replace_provider_contracts.previous.0.relationshipType == "provider" + - cm_force_replace_provider_contracts.previous.4.contractRef.contractName == "contract_bulk_10" + - cm_force_replace_provider_contracts.previous.4.relationshipType == "provider" + - cm_force_replace_provider_contracts.previous.9.contractRef.contractName == "contract_bulk_20" + - cm_force_replace_provider_contracts.previous.9.relationshipType == "provider" + - cm_force_replace_provider_contracts.previous.10.contractRef.contractName == "contract_bulk_2" + - cm_force_replace_provider_contracts.previous.10.relationshipType == "consumer" + - cm_force_replace_provider_contracts.previous.14.contractRef.contractName == "contract_bulk_10" + - cm_force_replace_provider_contracts.previous.14.relationshipType == "consumer" + - cm_force_replace_provider_contracts.previous.19.contractRef.contractName == "contract_bulk_20" + - cm_force_replace_provider_contracts.previous.19.relationshipType == "consumer" + - cm_force_replace_provider_contracts.current | length == 20 + - cm_force_replace_provider_contracts.current.0.contractRef.contractName == "contract_bulk_1" + - cm_force_replace_provider_contracts.current.0.relationshipType == "provider" + - cm_force_replace_provider_contracts.current.9.contractRef.contractName == "contract_bulk_10" + - cm_force_replace_provider_contracts.current.9.relationshipType == "provider" + - cm_force_replace_provider_contracts.current.19.contractRef.contractName == "contract_bulk_20" + - cm_force_replace_provider_contracts.current.19.relationshipType == "provider" + - nm_force_replace_provider_contracts is changed + - nm_force_replace_provider_contracts.previous | length == 20 + - nm_force_replace_provider_contracts.previous.0.contractRef.contractName == "contract_bulk_2" + - nm_force_replace_provider_contracts.previous.0.relationshipType == "provider" + - nm_force_replace_provider_contracts.previous.4.contractRef.contractName == "contract_bulk_10" + - nm_force_replace_provider_contracts.previous.4.relationshipType == "provider" + - nm_force_replace_provider_contracts.previous.9.contractRef.contractName == "contract_bulk_20" + - nm_force_replace_provider_contracts.previous.9.relationshipType == "provider" + - nm_force_replace_provider_contracts.previous.10.contractRef.contractName == "contract_bulk_2" + - nm_force_replace_provider_contracts.previous.10.relationshipType == "consumer" + - nm_force_replace_provider_contracts.previous.14.contractRef.contractName == "contract_bulk_10" + - nm_force_replace_provider_contracts.previous.14.relationshipType == "consumer" + - nm_force_replace_provider_contracts.previous.19.contractRef.contractName == "contract_bulk_20" + - nm_force_replace_provider_contracts.previous.19.relationshipType == "consumer" + - nm_force_replace_provider_contracts.current | length == 20 + - nm_force_replace_provider_contracts.current.0.contractRef.contractName == "contract_bulk_1" + - nm_force_replace_provider_contracts.current.0.relationshipType == "provider" + - nm_force_replace_provider_contracts.current.9.contractRef.contractName == "contract_bulk_10" + - nm_force_replace_provider_contracts.current.9.relationshipType == "provider" + - nm_force_replace_provider_contracts.current.19.contractRef.contractName == "contract_bulk_20" + - nm_force_replace_provider_contracts.current.19.relationshipType == "provider" + - nm_force_replace_provider_contracts_again is not changed + - nm_force_replace_provider_contracts_again.previous | length == 20 + - nm_force_replace_provider_contracts_again.previous.0.contractRef.contractName == "contract_bulk_1" + - nm_force_replace_provider_contracts_again.previous.0.relationshipType == "provider" + - nm_force_replace_provider_contracts_again.previous.9.contractRef.contractName == "contract_bulk_10" + - nm_force_replace_provider_contracts_again.previous.9.relationshipType == "provider" + - nm_force_replace_provider_contracts_again.previous.19.contractRef.contractName == "contract_bulk_20" + - nm_force_replace_provider_contracts_again.previous.19.relationshipType == "provider" + - nm_force_replace_provider_contracts.current | length == 20 + - nm_force_replace_provider_contracts.current.0.contractRef.contractName == "contract_bulk_1" + - nm_force_replace_provider_contracts.current.0.relationshipType == "provider" + - nm_force_replace_provider_contracts.current.9.contractRef.contractName == "contract_bulk_10" + - nm_force_replace_provider_contracts.current.9.relationshipType == "provider" + - nm_force_replace_provider_contracts.current.19.contractRef.contractName == "contract_bulk_20" + - nm_force_replace_provider_contracts.current.19.relationshipType == "provider" + - nm_force_replace_consumer_contracts.current | length == 20 + - nm_force_replace_consumer_contracts.current.0.contractRef.contractName == "contract_bulk_1" + - nm_force_replace_consumer_contracts.current.0.relationshipType == "consumer" + - nm_force_replace_consumer_contracts.current.9.contractRef.contractName == "contract_bulk_10" + - nm_force_replace_consumer_contracts.current.9.relationshipType == "consumer" + - nm_force_replace_consumer_contracts.current.19.contractRef.contractName == "contract_bulk_20" + - nm_force_replace_consumer_contracts.current.19.relationshipType == "consumer" + +# QUERY TESTS FOR BULK + +- name: Query contracts + cisco.mso.mso_schema_template_anp_epg_contract: + <<: *provider_contracts_append + contracts: "{{ consumer_contracts_present }}" + state: query + register: nm_query_contracts + +- name: Query contracts with non existing contracts (error) + cisco.mso.mso_schema_template_anp_epg_contract: + <<: *provider_contracts_append + contracts: + - name: non_contract_3 + type: provider + - name: non_contract_3 + type: consumer + state: query + register: err_query_contracts + ignore_errors: true + +- name: Verify queries for bulk + ansible.builtin.assert: + that: + - nm_query_contracts is not changed + - nm_query_contracts.current | length == 20 + - nm_query_contracts.current.0.contractRef.contractName == "contract_bulk_1" + - nm_query_contracts.current.0.relationshipType == "consumer" + - nm_query_contracts.current.9.contractRef.contractName == "contract_bulk_10" + - nm_query_contracts.current.9.relationshipType == "consumer" + - nm_query_contracts.current.19.contractRef.contractName == "contract_bulk_20" + - nm_query_contracts.current.19.relationshipType == "consumer" + - err_query_contracts is failed + - err_query_contracts.msg.0 is match("Contract with Reference '/schemas/[0-9a-zA-Z]*/templates/template_bulk/contracts/non_contract_3' and type 'provider' not found") + - err_query_contracts.msg.1 is match("Contract with Reference '/schemas/[0-9a-zA-Z]*/templates/template_bulk/contracts/non_contract_3' and type 'consumer' not found") + +# ERROR TESTS FOR BULK + +- name: Mutually exclusive contract and contracts (error) + cisco.mso.mso_schema_template_anp_epg_contract: + <<: *provider_contracts_append + contract: + - name: contract_bulk_1 + type: provider + register: err_mutually_exclusive_contract_and_contracts + ignore_errors: true + +- name: Mutually exclusive contract and force_replace (error) + cisco.mso.mso_schema_template_anp_epg_contract: + <<: *epg_bulk + contract: + - name: contract_bulk_1 + type: provider + force_replace: true + register: err_mutually_exclusive_contract_and_force_replace + ignore_errors: true + +- name: Missing required attributes for present (error) + cisco.mso.mso_schema_template_anp_epg_contract: + <<: *epg_bulk + register: err_missing_required_attributes_present + ignore_errors: true + +- name: Missing required attributes for absent (error) + cisco.mso.mso_schema_template_anp_epg_contract: + <<: *epg_bulk + state: absent + register: err_missing_required_attributes_absent + ignore_errors: true + +- name: Verify queries for bulk + ansible.builtin.assert: + that: + - err_mutually_exclusive_contract_and_contracts is failed + - err_mutually_exclusive_contract_and_contracts.msg == "parameters are mutually exclusive{{":"}} contract|contracts" + - err_mutually_exclusive_contract_and_force_replace is failed + - err_mutually_exclusive_contract_and_force_replace.msg == "parameters are mutually exclusive{{":"}} contract|force_replace" + - err_missing_required_attributes_present is failed + - err_missing_required_attributes_present.msg == "state is present but any of the following are missing{{":"}} contract, contracts" + - err_missing_required_attributes_absent is failed + - err_missing_required_attributes_absent.msg == "state is absent but any of the following are missing{{":"}} contract, contracts, force_replace" + +# FORCE REMOVE ALL CONTRACTS + +- name: Force remove all contracts + cisco.mso.mso_schema_template_anp_epg_contract: + <<: *epg_bulk + force_replace: true + state: absent + register: force_remove_all_contracts + +- name: Force replace all contracts without existing contracts + cisco.mso.mso_schema_template_anp_epg_contract: + <<: *provider_contracts_append + force_replace: true + register: force_replace_all_contracts_without_existing_contracts + +- name: Verify froce removing all contracts + ansible.builtin.assert: + that: + - force_remove_all_contracts is changed + - force_remove_all_contracts.previous | length == 20 + - force_remove_all_contracts.current == [] + - force_replace_all_contracts_without_existing_contracts is changed + - force_replace_all_contracts_without_existing_contracts.previous == [] + - force_replace_all_contracts_without_existing_contracts.current | length == 20 + +# CLEAN UP TEST ENVIRONMENT + +- name: Remove schemas + cisco.mso.mso_schema: + <<: *mso_info + schema: '{{ item }}' + state: absent + loop: + - '{{ mso_schema | default("ansible_test") }}_2' + - '{{ mso_schema | default("ansible_test") }}' diff --git a/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_anp_epg_selector/tasks/main.yml b/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_anp_epg_selector/tasks/main.yml index 013b96b71..0b3264d09 100644 --- a/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_anp_epg_selector/tasks/main.yml +++ b/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_anp_epg_selector/tasks/main.yml @@ -6,14 +6,14 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI MultiSite host, username and password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: mso_hostname, mso_username and mso_password.' when: mso_hostname is not defined or mso_username is not defined or mso_password is not defined # CLEAN ENVIRONMENT - name: Set vars - set_fact: + ansible.builtin.set_fact: mso_info: &mso_info host: '{{ mso_hostname }}' username: '{{ mso_username }}' @@ -24,13 +24,13 @@ output_level: '{{ mso_output_level | default("info") }}' - name: Query MSO version - mso_version: + cisco.mso.mso_version: <<: *mso_info state: query register: version # - name: Ensure site exist -# mso_site: &site_present +# cisco.mso.mso_site: &site_present # host: '{{ mso_hostname }}' # username: '{{ mso_username }}' # password: '{{ mso_password }}' @@ -47,7 +47,7 @@ # state: present - name: Remove schemas - mso_schema: + cisco.mso.mso_schema: <<: *mso_info schema: '{{ item }}' state: absent @@ -56,7 +56,7 @@ - '{{ mso_schema | default("ansible_test") }}' - name: Ensure tenant ansible_test exist - mso_tenant: + cisco.mso.mso_tenant: <<: *mso_info tenant: ansible_test users: @@ -66,7 +66,7 @@ state: present - name: Ensure schema 1 with Template 1 exist - mso_schema_template: + cisco.mso.mso_schema_template: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' tenant: ansible_test @@ -74,7 +74,7 @@ state: present - name: Ensure schema 1 with Template 2 exist - mso_schema_template: + cisco.mso.mso_schema_template: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' tenant: ansible_test @@ -82,7 +82,7 @@ state: present - name: Ensure schema 2 with Template 3 exist - mso_schema_template: + cisco.mso.mso_schema_template: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}_2' tenant: ansible_test @@ -90,7 +90,7 @@ state: present - name: Ensure ANP exist - mso_schema_template_anp: + cisco.mso.mso_schema_template_anp: <<: *mso_info schema: '{{ item.schema }}' template: '{{ item.template }}' @@ -102,7 +102,7 @@ # ADD EPGs - name: Ensure EPGs exist - mso_schema_template_anp_epg: + cisco.mso.mso_schema_template_anp_epg: <<: *mso_info schema: '{{ item.schema }}' template: '{{ item.template }}' @@ -115,7 +115,7 @@ # ADD Selector to EPG - name: Add Selector to EPG (check_mode) - mso_schema_template_anp_epg_selector: + cisco.mso.mso_schema_template_anp_epg_selector: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -127,7 +127,7 @@ register: cm_add_selector_1 - name: Verify cm_add_selector_1 - assert: + ansible.builtin.assert: that: - cm_add_selector_1 is changed - cm_add_selector_1.previous == {} @@ -135,7 +135,7 @@ - cm_add_selector_1.current.expressions == [] - name: Add Selector 1 to EPG with space in selector name (normal_mode) - mso_schema_template_anp_epg_selector: + cisco.mso.mso_schema_template_anp_epg_selector: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -147,13 +147,13 @@ register: nm_add_selector1_with_space_in_name - name: Verify nm_add_selector1_with_space_in_name - assert: + ansible.builtin.assert: that: - nm_add_selector1_with_space_in_name is not changed - nm_add_selector1_with_space_in_name.msg == "There should not be any space in selector name." - name: Add Selector to EPG (normal_mode) - mso_schema_template_anp_epg_selector: + cisco.mso.mso_schema_template_anp_epg_selector: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -164,7 +164,7 @@ register: nm_add_selector_1 - name: Verify nm_add_selector_1 - assert: + ansible.builtin.assert: that: - nm_add_selector_1 is changed - nm_add_selector_1.previous == {} @@ -172,7 +172,7 @@ - nm_add_selector_1.current.expressions == [] - name: Add Selector to EPG again (check_mode) - mso_schema_template_anp_epg_selector: + cisco.mso.mso_schema_template_anp_epg_selector: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -184,7 +184,7 @@ register: cm_add_selector_1_again - name: Verify cm_add_selector_1_again - assert: + ansible.builtin.assert: that: - cm_add_selector_1_again is not changed - cm_add_selector_1_again.previous.name == "selector_1" @@ -193,7 +193,7 @@ - cm_add_selector_1_again.current.expressions == [] - name: Add Selector to EPG again (normal_mode) - mso_schema_template_anp_epg_selector: + cisco.mso.mso_schema_template_anp_epg_selector: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -204,7 +204,7 @@ register: nm_add_selector_1_again - name: Verify nm_add_selector_1_again - assert: + ansible.builtin.assert: that: - nm_add_selector_1_again is not changed - nm_add_selector_1_again.previous.name == "selector_1" @@ -213,7 +213,7 @@ - nm_add_selector_1_again.current.expressions == [] - name: Add Selector 2 to EPG (check_mode) - mso_schema_template_anp_epg_selector: + cisco.mso.mso_schema_template_anp_epg_selector: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -229,7 +229,7 @@ register: cm_add_selector_2 - name: Verify cm_add_selector_2 - assert: + ansible.builtin.assert: that: - cm_add_selector_2 is changed - cm_add_selector_2.previous == {} @@ -239,7 +239,7 @@ - cm_add_selector_2.current.expressions[0].value == "test" - name: Add Selector 2 to EPG (normal_mode) - mso_schema_template_anp_epg_selector: + cisco.mso.mso_schema_template_anp_epg_selector: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -254,7 +254,7 @@ register: nm_add_selector_2 - name: Verify nm_add_selector_2 - assert: + ansible.builtin.assert: that: - nm_add_selector_2 is changed - nm_add_selector_2.previous == {} @@ -264,7 +264,7 @@ - nm_add_selector_2.current.expressions[0].value == "test" - name: Add Selector 2 to EPG with space in expression type (normal_mode) - mso_schema_template_anp_epg_selector: + cisco.mso.mso_schema_template_anp_epg_selector: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -280,13 +280,13 @@ register: nm_add_selector2_with_space_in_expression_type - name: Verify nm_add_selector2_with_space_in_expression_type - assert: + ansible.builtin.assert: that: - nm_add_selector2_with_space_in_expression_type is not changed - nm_add_selector2_with_space_in_expression_type.msg == "There should not be any space in 'type' attribute of expression 'expression 1'" - name: Change Selector 2 - keyExist(normal_mode) - mso_schema_template_anp_epg_selector: + cisco.mso.mso_schema_template_anp_epg_selector: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -302,13 +302,13 @@ register: nm_change_selector_2_key_exist - name: Verify nm_change_selector_2_key_exist - assert: + ansible.builtin.assert: that: - nm_change_selector_2_key_exist is not changed - nm_change_selector_2_key_exist.msg == "Attribute 'value' is not supported for operator 'has_key' in expression 'expression_5'" - name: Change Selector 2 - keyNotExist (normal_mode) - mso_schema_template_anp_epg_selector: + cisco.mso.mso_schema_template_anp_epg_selector: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -324,13 +324,13 @@ register: nm_change_selector_2_key_not_exist - name: Verify nm_change_selector_2_key_not_exist - assert: + ansible.builtin.assert: that: - nm_change_selector_2_key_not_exist is not changed - nm_change_selector_2_key_not_exist.msg == "Attribute 'value' is not supported for operator 'does_not_have_key' in expression 'expression_6'" - name: Change Selector 2 - equals (normal_mode) - mso_schema_template_anp_epg_selector: + cisco.mso.mso_schema_template_anp_epg_selector: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -345,13 +345,13 @@ register: nm_change_selector_2_equals - name: Verify nm_change_selector_2_equals - assert: + ansible.builtin.assert: that: - nm_change_selector_2_equals is not changed - nm_change_selector_2_equals.msg == "Attribute 'value' needed for operator 'equals' in expression 'expression_6'" - name: Change Selector 2 expressions (normal_mode) - mso_schema_template_anp_epg_selector: + cisco.mso.mso_schema_template_anp_epg_selector: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -380,14 +380,14 @@ register: nm_change_selector_2 - name: Verify nm_change_selector_2 - assert: + ansible.builtin.assert: that: - nm_change_selector_2 is changed - nm_change_selector_2.current.name == "selector_2" - nm_change_selector_2.current.expressions | length == 6 - name: Change Selector 2 expressions again (normal_mode) - mso_schema_template_anp_epg_selector: + cisco.mso.mso_schema_template_anp_epg_selector: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -416,14 +416,14 @@ register: nm_change_selector_2_again - name: Verify nm_change_selector_2_again - assert: + ansible.builtin.assert: that: - nm_change_selector_2_again is not changed - nm_change_selector_2_again.current.name == "selector_2" - nm_change_selector_2_again.current.expressions | length == 6 - name: Query all selectors (check_mode) - mso_schema_template_anp_epg_selector: + cisco.mso.mso_schema_template_anp_epg_selector: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -434,7 +434,7 @@ register: cm_query_all_selectors - name: Verify cm_query_all_selectors - assert: + ansible.builtin.assert: that: - cm_query_all_selectors is not changed - cm_query_all_selectors.current | length == 2 @@ -444,7 +444,7 @@ - cm_query_all_selectors.current[1].expressions | length == 6 - name: Query all selectors (normal_mode) - mso_schema_template_anp_epg_selector: + cisco.mso.mso_schema_template_anp_epg_selector: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -454,7 +454,7 @@ register: nm_query_all_selectors - name: Verify nm_query_all_selectors - assert: + ansible.builtin.assert: that: - nm_query_all_selectors is not changed - nm_query_all_selectors.current | length == 2 @@ -464,7 +464,7 @@ - nm_query_all_selectors.current[1].expressions | length == 6 - name: Query specific selector (check_mode) - mso_schema_template_anp_epg_selector: + cisco.mso.mso_schema_template_anp_epg_selector: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -476,14 +476,14 @@ register: cm_query_selector1 - name: Verify cm_query_selector1 - assert: + ansible.builtin.assert: that: - cm_query_selector1 is not changed - cm_query_selector1.current.name == "selector_1" - cm_query_selector1.current.expressions == [] - name: Query specific selector (normal_mode) - mso_schema_template_anp_epg_selector: + cisco.mso.mso_schema_template_anp_epg_selector: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -494,14 +494,14 @@ register: nm_query_selector1 - name: Verify nm_query_selector1 - assert: + ansible.builtin.assert: that: - nm_query_selector1 is not changed - nm_query_selector1.current.name == "selector_1" - nm_query_selector1.current.expressions == [] - name: Query specific selector2 (normal_mode) - mso_schema_template_anp_epg_selector: + cisco.mso.mso_schema_template_anp_epg_selector: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -512,7 +512,7 @@ register: nm_query_selector2 - name: Verify nm_query_selector2 - assert: + ansible.builtin.assert: that: - nm_query_selector2 is not changed - nm_query_selector2.current.name == "selector_2" @@ -537,7 +537,7 @@ - nm_query_selector2.current.expressions[5].value == "" # - name: Remove selector 1 (check_mode) -# mso_schema_template_anp_epg_selector: +# cisco.mso.mso_schema_template_anp_epg_selector: # <<: *mso_info # schema: '{{ mso_schema | default("ansible_test") }}' # template: Template 1 @@ -549,13 +549,13 @@ # register: cm_remove_selector_1 # - name: Verify cm_remove_selector_1 -# assert: +# ansible.builtin.assert: # that: # - cm_remove_selector_1 is changed # - cm_remove_selector_1.current == {} # - name: Remove selector 1 (normal_mode) -# mso_schema_template_anp_epg_selector: +# cisco.mso.mso_schema_template_anp_epg_selector: # <<: *mso_info # schema: '{{ mso_schema | default("ansible_test") }}' # template: Template 1 @@ -566,13 +566,13 @@ # register: nm_remove_selector_1 # - name: Verify nm_remove_selector_1 -# assert: +# ansible.builtin.assert: # that: # - nm_remove_selector_1 is changed # - nm_remove_selector_1.current == {} - name: Remove selector 2 (normal_mode) - mso_schema_template_anp_epg_selector: + cisco.mso.mso_schema_template_anp_epg_selector: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -583,14 +583,14 @@ register: nm_remove_selector_2 - name: Verify nm_remove_selector_2 - assert: + ansible.builtin.assert: that: - nm_remove_selector_2 is changed - nm_remove_selector_2.current == {} # QUERY NON-EXISTING Selector to EPG - name: Query non-existing selector (check_mode) - mso_schema_template_anp_epg_selector: + cisco.mso.mso_schema_template_anp_epg_selector: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -603,7 +603,7 @@ register: cm_query_non_selector - name: Query non-existing selector (normal mode) - mso_schema_template_anp_epg_selector: + cisco.mso.mso_schema_template_anp_epg_selector: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -615,7 +615,7 @@ register: nm_query_non_selector - name: Verify cm_query_non_selector and nm_query_non_selector - assert: + ansible.builtin.assert: that: - cm_query_non_selector is not changed - nm_query_non_selector is not changed @@ -625,7 +625,7 @@ # QUERY NON-EXISTING EPG - name: Query non-existing EPG (check_mode) - mso_schema_template_anp_epg_selector: + cisco.mso.mso_schema_template_anp_epg_selector: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -638,7 +638,7 @@ register: cm_query_non_epg - name: Query non-existing EPG (normal mode) - mso_schema_template_anp_epg_selector: + cisco.mso.mso_schema_template_anp_epg_selector: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -650,7 +650,7 @@ register: nm_query_non_epg - name: Verify query_non_epg - assert: + ansible.builtin.assert: that: - cm_query_non_epg is not changed - nm_query_non_epg is not changed @@ -659,7 +659,7 @@ # QUERY NON-EXISTING ANP - name: Query non-existing ANP (check_mode) - mso_schema_template_anp_epg_selector: + cisco.mso.mso_schema_template_anp_epg_selector: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -672,7 +672,7 @@ register: cm_query_non_anp - name: Query non-existing ANP (normal mode) - mso_schema_template_anp_epg_selector: + cisco.mso.mso_schema_template_anp_epg_selector: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -684,7 +684,7 @@ register: nm_query_non_anp - name: Verify query_non_anp - assert: + ansible.builtin.assert: that: - cm_query_non_anp is not changed - nm_query_non_anp is not changed @@ -693,7 +693,7 @@ # USE A NON-EXISTING STATE - name: Non-existing state (check_mode) - mso_schema_template_anp_epg_selector: + cisco.mso.mso_schema_template_anp_epg_selector: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -706,7 +706,7 @@ register: cm_non_existing_state - name: Non-existing state (normal_mode) - mso_schema_template_anp_epg_selector: + cisco.mso.mso_schema_template_anp_epg_selector: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -718,7 +718,7 @@ register: nm_non_existing_state - name: Verify non_existing_state - assert: + ansible.builtin.assert: that: - cm_non_existing_state is not changed - nm_non_existing_state is not changed @@ -727,7 +727,7 @@ # USE A NON-EXISTING TEMPLATE - name: Non-existing template (check_mode) - mso_schema_template_anp_epg_selector: + cisco.mso.mso_schema_template_anp_epg_selector: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: non-existing-template @@ -740,7 +740,7 @@ register: cm_non_existing_template - name: Non-existing template (normal_mode) - mso_schema_template_anp_epg_selector: + cisco.mso.mso_schema_template_anp_epg_selector: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: non-existing-template @@ -752,7 +752,7 @@ register: nm_non_existing_template - name: Verify non_existing_template - assert: + ansible.builtin.assert: that: - cm_non_existing_template is not changed - nm_non_existing_template is not changed @@ -761,7 +761,7 @@ # USE A NON-EXISTING SCHEMA - name: Non-existing schema (check_mode) - mso_schema_template_anp_epg_selector: + cisco.mso.mso_schema_template_anp_epg_selector: <<: *mso_info schema: non-existing-schema template: Template 1 @@ -774,7 +774,7 @@ register: cm_non_existing_schema - name: Non-existing schema (normal_mode) - mso_schema_template_anp_epg_selector: + cisco.mso.mso_schema_template_anp_epg_selector: <<: *mso_info schema: non-existing-schema template: Template 1 @@ -786,7 +786,7 @@ register: nm_non_existing_schema - name: Verify non_existing_schema - assert: + ansible.builtin.assert: that: - cm_non_existing_schema is not changed - nm_non_existing_schema is not changed diff --git a/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_anp_epg_useg_attribute/tasks/main.yml b/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_anp_epg_useg_attribute/tasks/main.yml index ef17edac1..8445b226c 100644 --- a/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_anp_epg_useg_attribute/tasks/main.yml +++ b/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_anp_epg_useg_attribute/tasks/main.yml @@ -4,13 +4,13 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI MultiSite host, username and password - fail: + ansible.builtin.fail: msg: "Please define the following variables: mso_hostname, mso_username and mso_password." when: mso_hostname is not defined or mso_username is not defined or mso_password is not defined # CLEAN ENVIRONMENT - name: Set vars - set_fact: + ansible.builtin.set_fact: mso_info: &mso_info host: "{{ mso_hostname }}" username: "{{ mso_username }}" @@ -23,13 +23,13 @@ # Setup Part - name: Remove schemas - mso_schema: &ansible_schema_absent + cisco.mso.mso_schema: &ansible_schema_absent <<: *mso_info schema: ansible_test state: absent - name: Ensure ansible_test tenant absent - mso_tenant: &ansible_tenant_absent + cisco.mso.mso_tenant: &ansible_tenant_absent <<: *mso_info tenant: ansible_test users: @@ -37,12 +37,12 @@ state: absent - name: Ensure ansible_test tenant present - mso_tenant: &ansible_tenant_present + cisco.mso.mso_tenant: &ansible_tenant_present <<: *ansible_tenant_absent state: present - name: Ensure ansible_test schema with ans_test_template exist - mso_schema_template: + cisco.mso.mso_schema_template: <<: *mso_info schema: ansible_test tenant: ansible_test @@ -50,7 +50,7 @@ state: present - name: Ensure ans_test_anp exist - mso_schema_template_anp: + cisco.mso.mso_schema_template_anp: <<: *mso_info schema: ansible_test template: ans_test_template @@ -58,7 +58,7 @@ state: present - name: Ensure ans_test_epg exist - mso_schema_template_anp_epg: + cisco.mso.mso_schema_template_anp_epg: <<: *mso_info schema: ansible_test template: ans_test_template @@ -68,7 +68,7 @@ state: present - name: Ensure ans_test_epg_2 exist without useg_epg - mso_schema_template_anp_epg: + cisco.mso.mso_schema_template_anp_epg: <<: *mso_info schema: ansible_test template: ans_test_template @@ -79,7 +79,7 @@ # Test Part # Note: Ignore the below task, which is used to reference the attributes to other tasks - name: Invalid test - check for missing required attributes error message - mso_schema_template_anp_epg_useg_attribute: &useg_attribute_present + cisco.mso.mso_schema_template_anp_epg_useg_attribute: &useg_attribute_present <<: *mso_info schema: ansible_test template: ans_test_template @@ -90,8 +90,26 @@ ignore_errors: true register: ans_test_uSeg_1_nt +- name: Invalid test - ans_test_uSeg_1 present - attribute_type - ip, useg_subnet - true, with value + cisco.mso.mso_schema_template_anp_epg_useg_attribute: + <<: *useg_attribute_present + name: ans_test_uSeg_2 + attribute_type: ip + useg_subnet: true + value: "1.2.3.4" + ignore_errors: true + register: ans_test_uSeg_1_nt1 + +- name: Assertions check for invalid tests - ans_test_uSeg_1 + ansible.builtin.assert: + that: + - ans_test_uSeg_1_nt is not changed + - ans_test_uSeg_1_nt.msg == "state is present but all of the following are missing{{':'}} name, type" + - ans_test_uSeg_1_nt1 is not changed + - ans_test_uSeg_1_nt1.msg == "The value of uSeg subnet IP should be an empty string or 0.0.0.0, when the useg_subnet is set to true." + - name: ans_test_uSeg_1 present - attribute_type - ip, useg_subnet - true, without value - mso_schema_template_anp_epg_useg_attribute: + cisco.mso.mso_schema_template_anp_epg_useg_attribute: <<: *mso_info schema: ansible_test template: ans_test_template @@ -103,7 +121,7 @@ register: ans_test_uSeg_1 - name: Invalid test - ans_test_uSeg_2 present - attribute_type - ip, useg_subnet - false, without value - mso_schema_template_anp_epg_useg_attribute: + cisco.mso.mso_schema_template_anp_epg_useg_attribute: <<: *useg_attribute_present name: ans_test_uSeg_2 attribute_type: ip @@ -112,34 +130,36 @@ register: ans_test_uSeg_2_nt - name: ans_test_uSeg_2 present - attribute_type - ip, useg_subnet - false, with value - check mode - mso_schema_template_anp_epg_useg_attribute: &ans_test_uSeg_2_cm_present + cisco.mso.mso_schema_template_anp_epg_useg_attribute: &ans_test_uSeg_2_cm_present <<: *useg_attribute_present name: ans_test_uSeg_2 attribute_type: ip useg_subnet: false - value: 11.22.33.44/24 + value: 11.22.33.44 check_mode: true register: ans_test_uSeg_2_cm_present - name: ans_test_uSeg_2 present - attribute_type - ip, useg_subnet - false, with value - normal mode - mso_schema_template_anp_epg_useg_attribute: &ans_test_uSeg_2_nm_present + cisco.mso.mso_schema_template_anp_epg_useg_attribute: &ans_test_uSeg_2_nm_present <<: *ans_test_uSeg_2_cm_present + output_level: debug register: ans_test_uSeg_2_nm_present - name: ans_test_uSeg_2 present - attribute_type - ip, useg_subnet - false, with value - normal mode again - mso_schema_template_anp_epg_useg_attribute: + cisco.mso.mso_schema_template_anp_epg_useg_attribute: <<: *ans_test_uSeg_2_nm_present + output_level: debug register: ans_test_uSeg_2_nm_present_again - name: Assertions check for add ans_test_uSeg_1 and ans_test_uSeg_2 object - assert: + ansible.builtin.assert: that: - ans_test_uSeg_1 is changed - ans_test_uSeg_1.current != {} - ans_test_uSeg_1.current.name == "ans_test_uSeg_1" - ans_test_uSeg_1.current.type == "ip" - ans_test_uSeg_1.current.value == "0.0.0.0" - - ans_test_uSeg_1.current.fvSubnet == false + - ans_test_uSeg_1.current.fvSubnet == true - ans_test_uSeg_1.current.description == "ans_test_uSeg_1" - ans_test_uSeg_2_nt is not changed - ans_test_uSeg_2_nt.msg == "useg_subnet is False but all of the following are missing{{':'}} value" @@ -148,33 +168,31 @@ - ans_test_uSeg_2_cm_present.previous == {} - ans_test_uSeg_2_cm_present.current.name == "ans_test_uSeg_2" - ans_test_uSeg_2_cm_present.current.type == "ip" - - ans_test_uSeg_2_cm_present.current.value == "11.22.33.44/24" - - ans_test_uSeg_2_cm_present.current.fvSubnet == true + - ans_test_uSeg_2_cm_present.current.value == "11.22.33.44" - ans_test_uSeg_2_cm_present.current.description == "uSeg Attr object created using Ansible" - ans_test_uSeg_2_nm_present is changed - ans_test_uSeg_2_nm_present.current != {} - ans_test_uSeg_2_nm_present.previous == {} - ans_test_uSeg_2_nm_present.current.name == "ans_test_uSeg_2" - ans_test_uSeg_2_nm_present.current.type == "ip" - - ans_test_uSeg_2_nm_present.current.value == "11.22.33.44/24" - - ans_test_uSeg_2_nm_present.current.fvSubnet == true + - ans_test_uSeg_2_nm_present.current.value == "11.22.33.44" + - ans_test_uSeg_2_nm_present.sent.fvSubnet == false - ans_test_uSeg_2_nm_present.current.description == "uSeg Attr object created using Ansible" - ans_test_uSeg_2_nm_present_again is not changed - ans_test_uSeg_2_nm_present_again.current != {} - ans_test_uSeg_2_nm_present_again.previous != {} - ans_test_uSeg_2_nm_present_again.current.name == "ans_test_uSeg_2" - ans_test_uSeg_2_nm_present_again.current.type == "ip" - - ans_test_uSeg_2_nm_present_again.current.value == "11.22.33.44/24" - - ans_test_uSeg_2_nm_present_again.current.fvSubnet == true + - ans_test_uSeg_2_nm_present_again.current.value == "11.22.33.44" + - ans_test_uSeg_2_nm_present_again.sent.fvSubnet == false - ans_test_uSeg_2_nm_present_again.current.description == "uSeg Attr object created using Ansible" - ans_test_uSeg_2_nm_present_again.previous.name == "ans_test_uSeg_2" - ans_test_uSeg_2_nm_present_again.previous.type == "ip" - - ans_test_uSeg_2_nm_present_again.previous.value == "11.22.33.44/24" - - ans_test_uSeg_2_nm_present_again.previous.fvSubnet == true + - ans_test_uSeg_2_nm_present_again.previous.value == "11.22.33.44" - ans_test_uSeg_2_nm_present_again.previous.description == "uSeg Attr object created using Ansible" - name: Invalid test - ans_test_uSeg_3 present - attribute_type - mac and without value - mso_schema_template_anp_epg_useg_attribute: + cisco.mso.mso_schema_template_anp_epg_useg_attribute: <<: *useg_attribute_present name: ans_test_uSeg_3 attribute_type: mac @@ -182,7 +200,7 @@ register: ans_test_uSeg_3_nt - name: ans_test_uSeg_3 present - attribute_type - mac and with value - mso_schema_template_anp_epg_useg_attribute: + cisco.mso.mso_schema_template_anp_epg_useg_attribute: <<: *useg_attribute_present name: ans_test_uSeg_3 attribute_type: mac @@ -190,7 +208,7 @@ register: ans_test_uSeg_3 - name: Assertions check for add ans_test_uSeg_3 object - assert: + ansible.builtin.assert: that: - ans_test_uSeg_3_nt is not changed - ans_test_uSeg_3_nt.msg == "Failed due to invalid 'value' and the attribute_type is{{':'}} mac." @@ -203,7 +221,7 @@ - ans_test_uSeg_3.current.value == "aa:bb:cc:dd:ee:ff" - name: Invalid test - ans_test_uSeg_4 present - attribute_type - dns and without value - mso_schema_template_anp_epg_useg_attribute: + cisco.mso.mso_schema_template_anp_epg_useg_attribute: <<: *useg_attribute_present name: ans_test_uSeg_4 attribute_type: dns @@ -211,7 +229,7 @@ register: ans_test_uSeg_4_nt - name: ans_test_uSeg_4 present - attribute_type - dns and with value - mso_schema_template_anp_epg_useg_attribute: + cisco.mso.mso_schema_template_anp_epg_useg_attribute: <<: *useg_attribute_present name: ans_test_uSeg_4 attribute_type: dns @@ -219,7 +237,7 @@ register: ans_test_uSeg_4 - name: Assertions check for add ans_test_uSeg_4 object - assert: + ansible.builtin.assert: that: - ans_test_uSeg_4_nt is not changed - ans_test_uSeg_4_nt.msg == "Failed due to invalid 'value' and the attribute_type is{{':'}} dns." @@ -232,7 +250,7 @@ - ans_test_uSeg_4.current.value == "test_dns_value" - name: Invalid test - ans_test_uSeg_6 present - attribute_type - vm_datacenter and without operator - mso_schema_template_anp_epg_useg_attribute: + cisco.mso.mso_schema_template_anp_epg_useg_attribute: <<: *useg_attribute_present name: ans_test_uSeg_6 attribute_type: vm_datacenter @@ -241,7 +259,7 @@ register: ans_test_uSeg_6_nt - name: Invalid test - ans_test_uSeg_6 present - attribute_type - vm_datacenter, operator - equals and without value - mso_schema_template_anp_epg_useg_attribute: + cisco.mso.mso_schema_template_anp_epg_useg_attribute: <<: *useg_attribute_present name: ans_test_uSeg_6 attribute_type: vm_datacenter @@ -250,7 +268,7 @@ register: ans_test_uSeg_6_nt1 - name: ans_test_uSeg_6 present - attribute_type - vm_datacenter, operator - equals and value - mso_schema_template_anp_epg_useg_attribute: + cisco.mso.mso_schema_template_anp_epg_useg_attribute: <<: *useg_attribute_present name: ans_test_uSeg_6 attribute_type: vm_datacenter @@ -259,7 +277,7 @@ register: ans_test_uSeg_6 - name: Assertions check for add ans_test_uSeg_6 object - assert: + ansible.builtin.assert: that: - ans_test_uSeg_6_nt is not changed - ans_test_uSeg_6_nt.msg == "Failed due to invalid 'value' or 'operator' and the attribute_type is{{':'}} vm_datacenter." @@ -274,7 +292,7 @@ - ans_test_uSeg_6.current.value == "test_vm_datacenter_value" - name: Invalid test - ans_test_uSeg_7 present - attribute_type - vm_hypervisor_identifier and without operator - mso_schema_template_anp_epg_useg_attribute: + cisco.mso.mso_schema_template_anp_epg_useg_attribute: <<: *useg_attribute_present name: ans_test_uSeg_7 attribute_type: vm_hypervisor_identifier @@ -283,7 +301,7 @@ register: ans_test_uSeg_7_nt - name: Invalid test - ans_test_uSeg_7 present - attribute_type - vm_hypervisor_identifier, operator - equals and without value - mso_schema_template_anp_epg_useg_attribute: + cisco.mso.mso_schema_template_anp_epg_useg_attribute: <<: *useg_attribute_present name: ans_test_uSeg_7 attribute_type: vm_hypervisor_identifier @@ -292,7 +310,7 @@ register: ans_test_uSeg_7_nt1 - name: ans_test_uSeg_7 present - attribute_type - vm_hypervisor_identifier, operator - equals and value - mso_schema_template_anp_epg_useg_attribute: + cisco.mso.mso_schema_template_anp_epg_useg_attribute: <<: *useg_attribute_present name: ans_test_uSeg_7 attribute_type: vm_hypervisor_identifier @@ -301,7 +319,7 @@ register: ans_test_uSeg_7 - name: Assertions check for add ans_test_uSeg_7 object - assert: + ansible.builtin.assert: that: - ans_test_uSeg_7_nt is not changed - ans_test_uSeg_7_nt.msg == "Failed due to invalid 'value' or 'operator' and the attribute_type is{{':'}} vm_hypervisor_identifier." @@ -316,7 +334,7 @@ - ans_test_uSeg_7.current.value == "test_vm_hypervisor_identifier_value" - name: Invalid test - ans_test_uSeg_8 present - attribute_type - vm_operating_system and without operator - mso_schema_template_anp_epg_useg_attribute: + cisco.mso.mso_schema_template_anp_epg_useg_attribute: <<: *useg_attribute_present name: ans_test_uSeg_8 attribute_type: vm_operating_system @@ -325,7 +343,7 @@ register: ans_test_uSeg_8_nt - name: Invalid test - ans_test_uSeg_8 present - attribute_type - vm_operating_system, operator - equals and without value - mso_schema_template_anp_epg_useg_attribute: + cisco.mso.mso_schema_template_anp_epg_useg_attribute: <<: *useg_attribute_present name: ans_test_uSeg_8 attribute_type: vm_operating_system @@ -334,7 +352,7 @@ register: ans_test_uSeg_8_nt1 - name: ans_test_uSeg_8 present - attribute_type - vm_operating_system, operator - equals and value - mso_schema_template_anp_epg_useg_attribute: + cisco.mso.mso_schema_template_anp_epg_useg_attribute: <<: *useg_attribute_present name: ans_test_uSeg_8 attribute_type: vm_operating_system @@ -343,7 +361,7 @@ register: ans_test_uSeg_8 - name: Assertions check for add ans_test_uSeg_8 object - assert: + ansible.builtin.assert: that: - ans_test_uSeg_8_nt is not changed - ans_test_uSeg_8_nt.msg == "Failed due to invalid 'value' or 'operator' and the attribute_type is{{':'}} vm_operating_system." @@ -358,7 +376,7 @@ - ans_test_uSeg_8.current.value == "test_vm_operating_system_value" - name: Invalid test - ans_test_uSeg_9 present - attribute_type - vm_tag and without operator - mso_schema_template_anp_epg_useg_attribute: + cisco.mso.mso_schema_template_anp_epg_useg_attribute: <<: *useg_attribute_present name: ans_test_uSeg_9 attribute_type: vm_tag @@ -367,7 +385,7 @@ register: ans_test_uSeg_9_nt - name: Invalid test - ans_test_uSeg_9 present - attribute_type - vm_tag, operator - equals and without value - mso_schema_template_anp_epg_useg_attribute: + cisco.mso.mso_schema_template_anp_epg_useg_attribute: <<: *useg_attribute_present name: ans_test_uSeg_9 attribute_type: vm_tag @@ -376,7 +394,7 @@ register: ans_test_uSeg_9_nt1 - name: ans_test_uSeg_9 present - attribute_type - vm_tag, operator - equals and value - mso_schema_template_anp_epg_useg_attribute: + cisco.mso.mso_schema_template_anp_epg_useg_attribute: <<: *useg_attribute_present name: ans_test_uSeg_9 attribute_type: vm_tag @@ -385,7 +403,7 @@ register: ans_test_uSeg_9 - name: Assertions check for add ans_test_uSeg_9 object - assert: + ansible.builtin.assert: that: - ans_test_uSeg_9_nt is not changed - ans_test_uSeg_9_nt.msg == "Failed due to invalid 'value' or 'operator' and the attribute_type is{{':'}} vm_tag." @@ -400,7 +418,7 @@ - ans_test_uSeg_9.current.value == "test_vm_tag_value" - name: Invalid test - ans_test_uSeg_10 present - attribute_type - vm_identifier and without operator - mso_schema_template_anp_epg_useg_attribute: + cisco.mso.mso_schema_template_anp_epg_useg_attribute: <<: *useg_attribute_present name: ans_test_uSeg_10 attribute_type: vm_identifier @@ -409,7 +427,7 @@ register: ans_test_uSeg_10_nt - name: Invalid test - ans_test_uSeg_10 present - attribute_type - vm_identifier, operator - equals and without value - mso_schema_template_anp_epg_useg_attribute: + cisco.mso.mso_schema_template_anp_epg_useg_attribute: <<: *useg_attribute_present name: ans_test_uSeg_10 attribute_type: vm_identifier @@ -418,7 +436,7 @@ register: ans_test_uSeg_10_nt1 - name: ans_test_uSeg_10 present - attribute_type - vm_identifier, operator - equals and value - mso_schema_template_anp_epg_useg_attribute: + cisco.mso.mso_schema_template_anp_epg_useg_attribute: <<: *useg_attribute_present name: ans_test_uSeg_10 attribute_type: vm_identifier @@ -427,7 +445,7 @@ register: ans_test_uSeg_10 - name: Assertions check for add ans_test_uSeg_10 object - assert: + ansible.builtin.assert: that: - ans_test_uSeg_10_nt is not changed - ans_test_uSeg_10_nt.msg == "Failed due to invalid 'value' or 'operator' and the attribute_type is{{':'}} vm_identifier." @@ -442,7 +460,7 @@ - ans_test_uSeg_10.current.value == "test_vm_identifier_value" - name: Invalid test - ans_test_uSeg_11 present - attribute_type - vmm_domain and without operator - mso_schema_template_anp_epg_useg_attribute: + cisco.mso.mso_schema_template_anp_epg_useg_attribute: <<: *useg_attribute_present name: ans_test_uSeg_11 attribute_type: vmm_domain @@ -451,7 +469,7 @@ register: ans_test_uSeg_11_nt - name: Invalid test - ans_test_uSeg_11 present - attribute_type - vmm_domain, operator - equals and without value - mso_schema_template_anp_epg_useg_attribute: + cisco.mso.mso_schema_template_anp_epg_useg_attribute: <<: *useg_attribute_present name: ans_test_uSeg_11 attribute_type: vmm_domain @@ -460,7 +478,7 @@ register: ans_test_uSeg_11_nt1 - name: ans_test_uSeg_11 present - attribute_type - vmm_domain, operator - equals and value - mso_schema_template_anp_epg_useg_attribute: + cisco.mso.mso_schema_template_anp_epg_useg_attribute: <<: *useg_attribute_present name: ans_test_uSeg_11 attribute_type: vmm_domain @@ -469,7 +487,7 @@ register: ans_test_uSeg_11 - name: Assertions check for add ans_test_uSeg_11 object - assert: + ansible.builtin.assert: that: - ans_test_uSeg_11_nt is not changed - ans_test_uSeg_11_nt.msg == "Failed due to invalid 'value' or 'operator' and the attribute_type is{{':'}} vmm_domain." @@ -484,7 +502,7 @@ - ans_test_uSeg_11.current.value == "test_vmm_domain_value" - name: Invalid test - ans_test_uSeg_12 present - attribute_type - vm_name and without operator - mso_schema_template_anp_epg_useg_attribute: + cisco.mso.mso_schema_template_anp_epg_useg_attribute: <<: *useg_attribute_present name: ans_test_uSeg_12 attribute_type: vm_name @@ -493,7 +511,7 @@ register: ans_test_uSeg_12_nt - name: Invalid test - ans_test_uSeg_12 present - attribute_type - vm_name, operator - equals and without value - mso_schema_template_anp_epg_useg_attribute: + cisco.mso.mso_schema_template_anp_epg_useg_attribute: <<: *useg_attribute_present name: ans_test_uSeg_12 attribute_type: vm_name @@ -502,7 +520,7 @@ register: ans_test_uSeg_12_nt1 - name: ans_test_uSeg_12 present - attribute_type - vm_name, operator - equals and value - mso_schema_template_anp_epg_useg_attribute: + cisco.mso.mso_schema_template_anp_epg_useg_attribute: <<: *useg_attribute_present name: ans_test_uSeg_12 attribute_type: vm_name @@ -511,7 +529,7 @@ register: ans_test_uSeg_12 - name: Assertions check for add ans_test_uSeg_12 object - assert: + ansible.builtin.assert: that: - ans_test_uSeg_12_nt is not changed - ans_test_uSeg_12_nt.msg == "Failed due to invalid 'value' or 'operator' and the attribute_type is{{':'}} vm_name." @@ -526,7 +544,7 @@ - ans_test_uSeg_12.current.value == "test_vm_value" - name: Invalid test - ans_test_uSeg_13 present - attribute_type - vnic_dn and without operator - mso_schema_template_anp_epg_useg_attribute: + cisco.mso.mso_schema_template_anp_epg_useg_attribute: <<: *useg_attribute_present name: ans_test_uSeg_13 attribute_type: vnic_dn @@ -535,7 +553,7 @@ register: ans_test_uSeg_13_nt - name: Invalid test - ans_test_uSeg_13 present - attribute_type - vnic_dn, operator - equals and without value - mso_schema_template_anp_epg_useg_attribute: + cisco.mso.mso_schema_template_anp_epg_useg_attribute: <<: *useg_attribute_present name: ans_test_uSeg_13 attribute_type: vnic_dn @@ -544,7 +562,7 @@ register: ans_test_uSeg_13_nt1 - name: ans_test_uSeg_13 present - attribute_type - vnic_dn, operator - equals and value - mso_schema_template_anp_epg_useg_attribute: &ans_test_uSeg_13_present + cisco.mso.mso_schema_template_anp_epg_useg_attribute: &ans_test_uSeg_13_present <<: *useg_attribute_present name: ans_test_uSeg_13 attribute_type: vnic_dn @@ -553,7 +571,7 @@ register: ans_test_uSeg_13 - name: Assertions check for add ans_test_uSeg_12 object - assert: + ansible.builtin.assert: that: - ans_test_uSeg_13_nt is not changed - ans_test_uSeg_13_nt.msg == "Failed due to invalid 'value' or 'operator' and the attribute_type is{{':'}} vnic_dn." @@ -569,7 +587,7 @@ # Query Part - name: Invalid test - Query an uSeg Attr with name - invalid_useg_attr - mso_schema_template_anp_epg_useg_attribute: + cisco.mso.mso_schema_template_anp_epg_useg_attribute: <<: *useg_attribute_present name: invalid_useg_attr state: query @@ -577,20 +595,20 @@ ignore_errors: true - name: Query an uSeg Attr with name - ans_test_uSeg_1 - mso_schema_template_anp_epg_useg_attribute: + cisco.mso.mso_schema_template_anp_epg_useg_attribute: <<: *useg_attribute_present name: ans_test_uSeg_6 state: query register: query_a_useg_6 - name: Query all uSeg Attrs - mso_schema_template_anp_epg_useg_attribute: + cisco.mso.mso_schema_template_anp_epg_useg_attribute: <<: *useg_attribute_present state: query register: query_all_useg_objects - name: Assertions check for query uSeg Attr objects - assert: + ansible.builtin.assert: that: - invalid_useg_attr is not changed - invalid_useg_attr.msg == "The uSeg Attribute{{':'}} invalid_useg_attr not found." @@ -604,21 +622,21 @@ # Update Part - name: Update ans_test_uSeg_13 object description and value - mso_schema_template_anp_epg_useg_attribute: + cisco.mso.mso_schema_template_anp_epg_useg_attribute: <<: *ans_test_uSeg_13_present description: "ans_test_uSeg_13 updated!" value: test_vnic_dn_value_updated register: ans_test_uSeg_13_update - name: Query an uSeg Attr with name - ans_test_uSeg_13 to check the updated changes - mso_schema_template_anp_epg_useg_attribute: + cisco.mso.mso_schema_template_anp_epg_useg_attribute: <<: *useg_attribute_present name: ans_test_uSeg_13 state: query register: query_a_useg_object_with_name - name: Assertions check for update ans_test_uSeg_13 object - assert: + ansible.builtin.assert: that: - ans_test_uSeg_13_update is changed - ans_test_uSeg_13_update.current != {} @@ -640,7 +658,7 @@ # Cleanup Part - name: ans_test_uSeg_1 absent with check mode - mso_schema_template_anp_epg_useg_attribute: &ans_test_uSeg_1_cm_absent + cisco.mso.mso_schema_template_anp_epg_useg_attribute: &ans_test_uSeg_1_cm_absent <<: *useg_attribute_present name: ans_test_uSeg_1 state: absent @@ -648,17 +666,17 @@ register: ans_test_uSeg_1_cm_absent - name: ans_test_uSeg_1 absent with normal mode - mso_schema_template_anp_epg_useg_attribute: &ans_test_uSeg_1_nm_absent + cisco.mso.mso_schema_template_anp_epg_useg_attribute: &ans_test_uSeg_1_nm_absent <<: *ans_test_uSeg_1_cm_absent register: ans_test_uSeg_1_nm_absent - name: ans_test_uSeg_1 absent with normal mode again - mso_schema_template_anp_epg_useg_attribute: + cisco.mso.mso_schema_template_anp_epg_useg_attribute: <<: *ans_test_uSeg_1_nm_absent register: ans_test_uSeg_1_nm_absent_again - name: Assertions check for ans_test_uSeg_1 absent - assert: + ansible.builtin.assert: that: - ans_test_uSeg_1_cm_absent is changed - ans_test_uSeg_1_cm_absent.current == {} @@ -671,7 +689,7 @@ - ans_test_uSeg_1_nm_absent_again.previous == {} - name: Query all uSeg Attrs - invalid template name - mso_schema_template_anp_epg_useg_attribute: + cisco.mso.mso_schema_template_anp_epg_useg_attribute: <<: *useg_attribute_present template: ans_test_template_123 state: query @@ -679,7 +697,7 @@ register: query_invalid_template - name: Query all uSeg Attrs - invalid Application Profile name - mso_schema_template_anp_epg_useg_attribute: + cisco.mso.mso_schema_template_anp_epg_useg_attribute: <<: *useg_attribute_present anp: ans_test_anp_123 state: query @@ -687,7 +705,7 @@ register: query_invalid_ap - name: Query all uSeg Attrs - invalid EPG name - mso_schema_template_anp_epg_useg_attribute: + cisco.mso.mso_schema_template_anp_epg_useg_attribute: <<: *useg_attribute_present epg: ans_test_epg_123 state: query @@ -695,7 +713,7 @@ register: query_invalid_epg - name: Invalid test - ans_test_anp_123 present under ans_test_epg_2 - mso_schema_template_anp_epg_useg_attribute: + cisco.mso.mso_schema_template_anp_epg_useg_attribute: <<: *useg_attribute_present epg: ans_test_epg_2 name: ans_test_anp_123 @@ -705,7 +723,7 @@ register: ans_test_epg_2_nt - name: Assertions check for invalid inputs - assert: + ansible.builtin.assert: that: - query_invalid_template is not changed - query_invalid_template.msg is match("Provided template 'ans_test_template_123' not matching existing template.+") @@ -717,27 +735,26 @@ - ans_test_epg_2_nt.msg is match("ans_test_epg_2{{':'}} is not a valid uSeg EPG.") - name: Remove ansible_test schema to delete all uSeg Attr objects - mso_schema: + cisco.mso.mso_schema: <<: *ansible_schema_absent schema: ansible_test state: absent # To check all uSeg Attrs removed from the machine - name: Query all uSeg Attrs - Cleanup Part - mso_schema_template_anp_epg_useg_attribute: + cisco.mso.mso_schema_template_anp_epg_useg_attribute: <<: *useg_attribute_present state: query ignore_errors: true register: query_useg_absent_check - name: Assertions check for query all uSeg Attrs - Cleanup Part - assert: + ansible.builtin.assert: that: - query_useg_absent_check is not changed - query_useg_absent_check.current == {} - name: Remove ansible_test tenant - mso_tenant: - <<: *ansible_tenant_present + cisco.mso.mso_tenant: + <<: *ansible_tenant_absent state: absent - <<: *mso_info
\ No newline at end of file diff --git a/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_bd/tasks/main.yml b/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_bd/tasks/main.yml index a10ed8e14..6f87222cb 100644 --- a/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_bd/tasks/main.yml +++ b/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_bd/tasks/main.yml @@ -6,14 +6,14 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI MultiSite host, username and password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: mso_hostname, mso_username and mso_password.' when: mso_hostname is not defined or mso_username is not defined or mso_password is not defined # CLEAN ENVIRONMENT - name: Set vars - set_fact: + ansible.builtin.set_fact: mso_info: &mso_info host: '{{ mso_hostname }}' username: '{{ mso_username }}' @@ -24,18 +24,18 @@ output_level: '{{ mso_output_level | default("info") }}' - name: Query MSO version - mso_version: + cisco.mso.mso_version: <<: *mso_info state: query register: version - name: Set version vars - set_fact: - mso_l3mcast: false + ansible.builtin.set_fact: + cisco.mso.mso_l3mcast: false when: version.current.version is version('2.2.4', '=') - name: Ensure site exist - mso_site: &site_present + cisco.mso.mso_site: &site_present <<: *mso_info site: '{{ mso_site | default("ansible_test") }}' apic_username: '{{ apic_username }}' @@ -46,7 +46,7 @@ state: present - name: Remove schemas - mso_schema: + cisco.mso.mso_schema: <<: *mso_info schema: '{{ item }}' state: absent @@ -55,7 +55,7 @@ - '{{ mso_schema | default("ansible_test") }}' - name: Remove DHCP policies - mso_dhcp_relay_policy: + cisco.mso.mso_dhcp_relay_policy: <<: *mso_info dhcp_relay_policy: '{{ item }}' tenant: ansible_test @@ -69,7 +69,7 @@ - version.current.version is version('4.0', '<') - name: Remove DHCP option policies - mso_dhcp_option_policy: + cisco.mso.mso_dhcp_option_policy: <<: *mso_info dhcp_option_policy: '{{ item }}' tenant: ansible_test @@ -83,7 +83,7 @@ - version.current.version is version('4.0', '<') - name: Ensure tenant ansible_test exist - mso_tenant: &tenant_present + cisco.mso.mso_tenant: &tenant_present <<: *mso_info tenant: ansible_test users: @@ -93,7 +93,7 @@ state: present - name: Ensure schema 1 with Template1 exist - mso_schema_template: &schema_present + cisco.mso.mso_schema_template: &schema_present <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' tenant: ansible_test @@ -101,28 +101,28 @@ state: present - name: Ensure schema 1 with Template2 exists - mso_schema_template: + cisco.mso.mso_schema_template: <<: *schema_present schema: '{{ mso_schema | default("ansible_test") }}' tenant: ansible_test template: Template2 - name: Ensure schema 2 with Template3 exists - mso_schema_template: + cisco.mso.mso_schema_template: <<: *schema_present schema: '{{ mso_schema | default("ansible_test") }}_2' tenant: ansible_test template: Template3 - name: Ensure schema 2 with Template5 exists - mso_schema_template: + cisco.mso.mso_schema_template: <<: *schema_present schema: '{{ mso_schema | default("ansible_test") }}_2' tenant: ansible_test template: Template5 - name: Ensure VRF exist - mso_schema_template_vrf: &vrf_present + cisco.mso.mso_schema_template_vrf: &vrf_present <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template1 @@ -131,32 +131,32 @@ state: present - name: Ensure VRF2 exist - mso_schema_template_vrf: + cisco.mso.mso_schema_template_vrf: <<: *vrf_present vrf: VRF2 - name: Ensure VRF3 exist - mso_schema_template_vrf: + cisco.mso.mso_schema_template_vrf: <<: *vrf_present template: Template2 vrf: VRF3 - name: Ensure VRF4 exist - mso_schema_template_vrf: + cisco.mso.mso_schema_template_vrf: <<: *vrf_present schema: '{{ mso_schema | default("ansible_test") }}_2' template: Template3 vrf: VRF4 - name: Ensure VRF5 exists - mso_schema_template_vrf: + cisco.mso.mso_schema_template_vrf: <<: *vrf_present schema: '{{ mso_schema | default("ansible_test") }}_2' template: Template5 vrf: VRF5 - name: Ensure ansible_test_1 BD does not exist - mso_schema_template_bd: + cisco.mso.mso_schema_template_bd: <<: *vrf_present schema: '{{ mso_schema | default("ansible_test") }}' template: Template1 @@ -166,7 +166,7 @@ state: absent - name: Ensure ansible_test_2 BD does not exist - mso_schema_template_bd: + cisco.mso.mso_schema_template_bd: <<: *vrf_present schema: '{{ mso_schema | default("ansible_test") }}' template: Template2 @@ -176,7 +176,7 @@ state: absent - name: Ensure ansible_test_3 BD does not exist - mso_schema_template_bd: + cisco.mso.mso_schema_template_bd: <<: *vrf_present schema: '{{ mso_schema | default("ansible_test") }}_2' template: Template3 @@ -188,7 +188,7 @@ state: absent - name: Ensure ansible_test_4 BD does not exist - mso_schema_template_bd: + cisco.mso.mso_schema_template_bd: <<: *vrf_present schema: '{{ mso_schema | default("ansible_test") }}' template: Template1 @@ -200,7 +200,7 @@ state: absent - name: Ensure multiple DHCP policies exist - mso_dhcp_relay_policy: + cisco.mso.mso_dhcp_relay_policy: <<: *mso_info dhcp_relay_policy: '{{ item }}' description: "My Test DHCP Policies" @@ -215,7 +215,7 @@ - version.current.version is version('4.0', '<') - name: Ensure multiple DHCP option policies exist - mso_dhcp_option_policy: + cisco.mso.mso_dhcp_option_policy: <<: *mso_info dhcp_option_policy: '{{ item }}' description: "My Test DHCP Policy Options" @@ -231,7 +231,7 @@ # ADD BD - name: Add bd (check_mode) - mso_schema_template_bd: &bd_present + cisco.mso.mso_schema_template_bd: &bd_present <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template1 @@ -243,7 +243,7 @@ register: cm_add_bd - name: Verify cm_add_bd - assert: + ansible.builtin.assert: that: - cm_add_bd is changed - cm_add_bd.previous == {} @@ -252,12 +252,12 @@ - cm_add_bd.current.vrfRef.vrfName == "VRF" - name: Add bd (normal mode) - mso_schema_template_bd: + cisco.mso.mso_schema_template_bd: <<: *bd_present register: nm_add_bd - name: Verify nm_add_bd - assert: + ansible.builtin.assert: that: - nm_add_bd is changed - nm_add_bd.previous == {} @@ -267,13 +267,13 @@ - cm_add_bd.current.vrfRef.schemaId == nm_add_bd.current.vrfRef.schemaId - name: Add bd again (check_mode) - mso_schema_template_bd: + cisco.mso.mso_schema_template_bd: <<: *bd_present check_mode: true register: cm_add_bd_again - name: Verify cm_add_bd_again - assert: + ansible.builtin.assert: that: - cm_add_bd_again is not changed - cm_add_bd_again.previous.name == "ansible_test_1" @@ -285,12 +285,12 @@ - cm_add_bd_again.previous.vrfRef.schemaId == cm_add_bd_again.current.vrfRef.schemaId - name: Add bd again (normal mode) - mso_schema_template_bd: + cisco.mso.mso_schema_template_bd: <<: *bd_present register: nm_add_bd_again - name: Verify nm_add_bd_again - assert: + ansible.builtin.assert: that: - nm_add_bd_again is not changed - nm_add_bd_again.previous.name == "ansible_test_1" @@ -302,7 +302,7 @@ - nm_add_bd_again.previous.vrfRef.schemaId == nm_add_bd_again.current.vrfRef.schemaId - name: Add bd 2 (normal mode) - mso_schema_template_bd: + cisco.mso.mso_schema_template_bd: <<: *bd_present schema: '{{ mso_schema | default("ansible_test") }}' template: Template2 @@ -340,7 +340,7 @@ register: nm_add_bd_2 - name: Add bd 3 (normal mode) - mso_schema_template_bd: + cisco.mso.mso_schema_template_bd: <<: *bd_present schema: '{{ mso_schema | default("ansible_test") }}_2' template: Template3 @@ -352,7 +352,7 @@ register: nm_add_bd_3 - name: Add bd 4 (normal mode) - mso_schema_template_bd: + cisco.mso.mso_schema_template_bd: <<: *bd_present schema: '{{ mso_schema | default("ansible_test") }}' template: Template1 @@ -364,7 +364,7 @@ register: nm_add_bd_4 - name: Verify nm_add_bd_2 and nm_add_bd_3 - assert: + ansible.builtin.assert: that: - nm_add_bd_2 is changed - nm_add_bd_3 is changed @@ -406,7 +406,7 @@ - nm_add_bd_2.current.subnets[3].querier == false - name: Add bd 5 (normal mode) - mso_schema_template_bd: + cisco.mso.mso_schema_template_bd: <<: *bd_present schema: '{{ mso_schema | default("ansible_test") }}_2' template: Template5 @@ -434,7 +434,7 @@ register: nm_add_bd_5 - name: Verify nm_add_bd_5 for a version that's before 3.1 - assert: + ansible.builtin.assert: that: - nm_add_bd_5 is changed - nm_add_bd_5.current.name == "ansible_test_5" @@ -448,7 +448,7 @@ when: version.current.version is version('3.1.1g', '<') - name: Verify nm_add_bd_5 for a version that's 3.1 - assert: + ansible.builtin.assert: that: - nm_add_bd_5 is changed - nm_add_bd_5.current.name == "ansible_test_5" @@ -467,7 +467,7 @@ when: version.current.version is version('3.1.1g', '>=') - name: Add bd 5 again (normal mode) - mso_schema_template_bd: + cisco.mso.mso_schema_template_bd: <<: *bd_present schema: '{{ mso_schema | default("ansible_test") }}_2' template: Template5 @@ -495,20 +495,20 @@ register: nm_add_again_bd_5 - name: Verify nm_add_again_bd_5 for a version that's before 3.1 - assert: + ansible.builtin.assert: that: - nm_add_again_bd_5 is not changed when: version.current.version is version('3.1.1g', '<') - name: Verify nm_add_again_bd_5 for a version that's between 3.1 and 4.0 - assert: + ansible.builtin.assert: that: - nm_add_again_bd_5 is not changed when: - version.current.version is version('3.1.1g', '>=') - name: Add bd 5 with different values for new options (normal mode) - mso_schema_template_bd: + cisco.mso.mso_schema_template_bd: <<: *bd_present schema: '{{ mso_schema | default("ansible_test") }}_2' template: Template5 @@ -536,13 +536,13 @@ register: nm_bd_5_options - name: Verify nm_bd_5_options for a version that's before 3.1 - assert: + ansible.builtin.assert: that: - nm_bd_5_options is not changed when: version.current.version is version('3.1.1g', '<') - name: Verify nm_bd_5_options for a version that's 3.1 - assert: + ansible.builtin.assert: that: - nm_bd_5_options is changed - nm_bd_5_options.current.unkMcastAct == "opt-flood" @@ -552,7 +552,7 @@ when: version.current.version is version('3.1.1g', '>=') - name: Change bd 5_1 (normal mode) - mso_schema_template_bd: + cisco.mso.mso_schema_template_bd: <<: *bd_present schema: '{{ mso_schema | default("ansible_test") }}_2' template: Template5 @@ -580,20 +580,20 @@ register: nm_change_bd_5_1 - name: Verify nm_change_bd_5_1 for a version that's before 3.1 - assert: + ansible.builtin.assert: that: - nm_change_bd_5_1 is changed when: version.current.version is version('3.1.1g', '<') - name: Verify nm_change_bd_5_1 for a version that's 3.1 - assert: + ansible.builtin.assert: that: - nm_change_bd_5_1 is changed - nm_change_bd_5_1.current.arpFlood == true when: version.current.version is version('3.1.1g', '>=') - name: Change bd 5_2 (normal mode) - mso_schema_template_bd: &change_bd5_2 + cisco.mso.mso_schema_template_bd: &change_bd5_2 <<: *bd_present schema: '{{ mso_schema | default("ansible_test") }}_2' template: Template5 @@ -622,21 +622,21 @@ register: nm_change_bd_5_2 - name: Verify nm_change_bd_5_2 for a version that's before 3.1 - assert: + ansible.builtin.assert: that: - nm_change_bd_5_2 is changed - nm_change_bd_5_2.current.l2UnknownUnicast == "flood" when: version.current.version is version('3.1.1g', '<') - name: Verify nm_change_bd_5_2 for a version that's after 3.1 - assert: + ansible.builtin.assert: that: - nm_change_bd_5_2 is changed - nm_change_bd_5_2.current.arpFlood == true when: version.current.version is version('3.1.1g', '>=') - name: Change bd 5_3 (normal mode) - mso_schema_template_bd: + cisco.mso.mso_schema_template_bd: <<: *bd_present schema: '{{ mso_schema | default("ansible_test") }}_2' template: Template5 @@ -665,14 +665,14 @@ register: nm_change_bd_5_3 - name: Verify nm_change_bd_5_3 for a version that's before 3.1 - assert: + ansible.builtin.assert: that: - nm_change_bd_5_3 is changed - nm_change_bd_5_3.msg is match ("MSO Error 143{{':'}} Invalid Field{{':'}} BD 'ansible_test_5' l2UnknownUnicast cannot be flood when intersiteBumTrafficAllow is off") when: version.current.version is version('3.1.1g', '<') - name: Verify nm_change_bd_5_3 for a version that's after 3.1 and before 3.3 - assert: + ansible.builtin.assert: that: - nm_change_bd_5_3 is changed # Inconsistency shown in returned error messages for v3.1.1 @@ -686,7 +686,7 @@ - version.current.version is version('3.1.1g', '>=') - name: Verify nm_change_bd_5_3 for a version that's after 4.0 - assert: + ansible.builtin.assert: that: - nm_change_bd_5_3 is changed - nm_change_bd_5_3.msg is match ("MSO Error 400{{':'}} BD{{':'}} ansible_test_5 in Schema{{':'}} ansible_test_2 , Template{{':'}} Template5 BD ansible_test_5 l2UnknownUnicast cannot be flood when intersiteBumTrafficAllow is off") @@ -694,7 +694,7 @@ - version.current.version is version('4.0', '>=') - name: Get Validation status - mso_schema_validate: + cisco.mso.mso_schema_validate: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}_2' state: query @@ -705,7 +705,7 @@ - version.current.version is version('4.0', '<') # mso_schema_validate not needed after 4.0 because validation is done upon request - name: Verify query_validate for a version that's after 3.3 - assert: + ansible.builtin.assert: that: - query_validate is not changed - query_validate.msg is match ("MSO Error 400{{':'}} Bad Request{{':'}} Patch Failed, Received{{':'}} Template 'Template5', BD 'ansible_test_5' {{':'}} ARP Flooding has to be disabled if L2 Stretch enabled and BUM traffic disabled exception while trying to update schema") @@ -715,13 +715,13 @@ # Reverting back to bd 5_2 - name: Change bd 5_3 (normal mode) - mso_schema_template_bd: + cisco.mso.mso_schema_template_bd: <<: *change_bd5_2 register: nm_change_bd_5_3_again when: query_validate is failed - name: Get Validation status - mso_schema_validate: + cisco.mso.mso_schema_validate: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}_2' state: query @@ -731,7 +731,7 @@ - version.current.version is version('4.0', '<') # mso_schema_validate not needed after 4.0 because validation is done upon request - name: Change bd 5 for query (normal mode) - mso_schema_template_bd: + cisco.mso.mso_schema_template_bd: <<: *bd_present schema: '{{ mso_schema | default("ansible_test") }}_2' template: Template5 @@ -759,7 +759,7 @@ # CHANGE BD - name: Change bd (check_mode) - mso_schema_template_bd: + cisco.mso.mso_schema_template_bd: <<: *bd_present vrf: name: VRF2 @@ -767,7 +767,7 @@ register: cm_change_bd - name: Verify cm_change_bd - assert: + ansible.builtin.assert: that: - cm_change_bd is changed - cm_change_bd.current.name == 'ansible_test_1' @@ -776,7 +776,7 @@ - cm_change_bd.current.vrfRef.schemaId == cm_change_bd.previous.vrfRef.schemaId - name: Change bd (normal mode) - mso_schema_template_bd: + cisco.mso.mso_schema_template_bd: <<: *bd_present vrf: name: VRF2 @@ -784,7 +784,7 @@ register: nm_change_bd - name: Verify nm_change_bd - assert: + ansible.builtin.assert: that: - nm_change_bd is changed - nm_change_bd.current.name == 'ansible_test_1' @@ -793,7 +793,7 @@ - nm_change_bd.current.vrfRef.schemaId == nm_change_bd.previous.vrfRef.schemaId - name: Change bd again (check_mode) - mso_schema_template_bd: + cisco.mso.mso_schema_template_bd: <<: *bd_present vrf: name: VRF2 @@ -801,7 +801,7 @@ register: cm_change_bd_again - name: Verify cm_change_bd_again - assert: + ansible.builtin.assert: that: - cm_change_bd_again is not changed - cm_change_bd_again.current.name == 'ansible_test_1' @@ -810,14 +810,14 @@ - cm_change_bd_again.current.vrfRef.schemaId == cm_change_bd_again.previous.vrfRef.schemaId - name: Change bd again (normal mode) - mso_schema_template_bd: + cisco.mso.mso_schema_template_bd: <<: *bd_present vrf: name: VRF2 register: nm_change_bd_again - name: Verify nm_change_bd_again - assert: + ansible.builtin.assert: that: - nm_change_bd_again is not changed - nm_change_bd_again.current.name == 'ansible_test_1' @@ -826,7 +826,7 @@ - nm_change_bd_again.current.vrfRef.schemaId == nm_change_bd_again.previous.vrfRef.schemaId - name: Change bd to VRF3 in other template (normal mode) - mso_schema_template_bd: + cisco.mso.mso_schema_template_bd: <<: *bd_present vrf: name: VRF3 @@ -834,7 +834,7 @@ register: nm_change_bd_vrf3 - name: Change bd to VRF4 in other schema (normal mode) - mso_schema_template_bd: + cisco.mso.mso_schema_template_bd: <<: *bd_present vrf: name: VRF4 @@ -843,7 +843,7 @@ register: nm_change_bd_vrf4 - name: Verify nm_change_bd_vrf3 and nm_change_bd_vrf4 - assert: + ansible.builtin.assert: that: - nm_change_bd_vrf3 is changed - nm_change_bd_vrf3.current.name == nm_change_bd_vrf4.current.name == 'ansible_test_1' @@ -853,7 +853,7 @@ - nm_change_bd_vrf4.current.vrfRef.templateName == "Template3" - name: Change bd 1 settings(normal mode) - mso_schema_template_bd: + cisco.mso.mso_schema_template_bd: <<: *bd_present schema: '{{ mso_schema | default("ansible_test") }}' template: Template1 @@ -885,7 +885,7 @@ register: nm_change_bd_1_settings - name: Change bd 1 subnets (normal mode) - mso_schema_template_bd: + cisco.mso.mso_schema_template_bd: <<: *bd_present schema: '{{ mso_schema | default("ansible_test") }}' template: Template1 @@ -916,7 +916,7 @@ register: nm_change_bd_1_subnets - name: Verify nm_change_bd_1_subnets - assert: + ansible.builtin.assert: that: - nm_change_bd_1_settings is changed - nm_change_bd_1_settings.current.name == "ansible_test_1" @@ -979,21 +979,21 @@ - nm_change_bd_1_subnets.current.subnets[2].querier == true - name: Verify l3MCast nm_change_bd_1_subnets (version == 2.2.4) - assert: + ansible.builtin.assert: that: - nm_change_bd_1_settings.current.l3MCast == false - nm_change_bd_1_subnets.current.l3MCast == false when: version.current.version is version('2.2.4', '=') - name: Verify l3MCast nm_change_bd_1_subnets (version != 2.2.4) - assert: + ansible.builtin.assert: that: - nm_change_bd_1_settings.current.l3MCast == true - nm_change_bd_1_subnets.current.l3MCast == true when: version.current.version is version('2.2.4', '!=') - name: Add bd with multiple dhcp policies for mso version > 3.1.1g - mso_schema_template_bd: + cisco.mso.mso_schema_template_bd: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template1 @@ -1045,7 +1045,7 @@ - version.current.version is version('4.0', '<') - name: Verify addition of DHCP policies for mso version > 3.1.1g - assert: + ansible.builtin.assert: that: - nm_bd_dhcp_policies is changed - nm_bd_dhcp_policies.current.dhcpLabels | length == 3 @@ -1067,7 +1067,7 @@ - version.current.version is version('4.0', '<') - name: Change bd with multiple dhcp policies for mso version > 3.1.1g - mso_schema_template_bd: + cisco.mso.mso_schema_template_bd: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template1 @@ -1114,7 +1114,7 @@ - version.current.version is version('4.0', '<') - name: Verify change in DHCP policies for mso version > 3.1.1g - assert: + ansible.builtin.assert: that: - change_nm_bd_dhcp_policies is changed - change_nm_bd_dhcp_policies.current.dhcpLabels | length == 2 @@ -1133,7 +1133,7 @@ # Add BD with new options for mso version > 3.1.1g - name: Add bd with new options available in mso versions > 3.1.1g - mso_schema_template_bd: + cisco.mso.mso_schema_template_bd: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template1 @@ -1169,7 +1169,7 @@ when: version.current.version is version('3.1.1g', '>') - name: Verify subnets in nm_bd_new_subnet_options - assert: + ansible.builtin.assert: that: - nm_bd_new_subnet_options is changed - nm_bd_new_subnet_options.current.name == 'ansible_test_new_options' @@ -1194,7 +1194,7 @@ # Change BD with new options for mso version > 3.1.1g - name: Try Changing bd with another subnet to primary IP - mso_schema_template_bd: + cisco.mso.mso_schema_template_bd: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template1 @@ -1232,7 +1232,7 @@ when: version.current.version is version('3.1.1g', '>') - name: Verify subnets in nm_bd_subnet_second_primary - assert: + ansible.builtin.assert: that: - nm_bd_subnet_second_primary.msg is match ("MSO Error 400{{':'}} Bad Request{{':'}} Patch Failed, Received{{':'}} Only one preferred subnet per address family is allowed under BD ansible_test_new_options of Template Template1 exception while trying to update schema") when: @@ -1240,7 +1240,7 @@ - version.current.version is version('3.3', '<') - name: Add bd with new option flood in encap available in mso versions > 3.1.1g with l2 set to true - mso_schema_template_bd: + cisco.mso.mso_schema_template_bd: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template1 @@ -1264,7 +1264,7 @@ when: version.current.version is version('3.1.1g', '>') - name: Verify nm_bd_new_encap_flood_non - assert: + ansible.builtin.assert: that: - nm_bd_new_encap_flood_non.msg is match ("MSO Error 400{{':'}} Bad Request{{':'}} Patch Failed, Received{{':'}} Template 'Template1', BD 'ansible_test_flood_encap' {{':'}} Multi destination flood in encapsulation is only supported when l2Stretch is disabled exception while trying to update schema") when: @@ -1272,7 +1272,7 @@ - version.current.version is version('3.3', '<') - name: Add bd with new option flood in encap available in mso versions > 3.1.1g l2 set to false - mso_schema_template_bd: + cisco.mso.mso_schema_template_bd: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template1 @@ -1293,13 +1293,13 @@ when: version.current.version is version('3.1.1g', '>') - name: Verify nm_bd_new_encap_flood - assert: + ansible.builtin.assert: that: - nm_bd_new_encap_flood.current.multiDstPktAct == "encap-flood" when: version.current.version is version('3.1.1g', '>') - name: Add bd with new option description in mso versions >= 3.3 - mso_schema_template_bd: + cisco.mso.mso_schema_template_bd: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template1 @@ -1319,13 +1319,13 @@ when: version.current.version is version('3.3', '>=') - name: Verify nm_bd_desc - assert: + ansible.builtin.assert: that: - nm_bd_desc.current.description == "ansible_test_bd" when: version.current.version is version('3.3', '>=') - name: Add bd with change in description in mso versions >= 3.3 - mso_schema_template_bd: + cisco.mso.mso_schema_template_bd: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template1 @@ -1345,13 +1345,13 @@ when: version.current.version is version('3.3', '>=') - name: Verify nm_bd_desc_2 - assert: + ansible.builtin.assert: that: - nm_bd_desc_2.current.description == "ansible_test_bd_again" when: version.current.version is version('3.3', '>=') - name: Ensure bd ansible_test_unicast_false is removed >= 3.1.1g - mso_schema_template_bd: + cisco.mso.mso_schema_template_bd: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template1 @@ -1360,7 +1360,7 @@ when: version.current.version is version('3.1.1g', '>') - name: Ensure bd ansible_test_unicast_true is removed >= 3.1.1g - mso_schema_template_bd: + cisco.mso.mso_schema_template_bd: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template1 @@ -1369,7 +1369,7 @@ when: version.current.version is version('3.1.1g', '>') - name: Add bd with change in unicast routing false in mso versions >= 3.1.1g (check mode) - mso_schema_template_bd: &unicast_routing_false_present + cisco.mso.mso_schema_template_bd: &unicast_routing_false_present <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template1 @@ -1385,26 +1385,26 @@ when: version.current.version is version('3.1.1g', '>') - name: Add bd with change in unicast routing false in mso versions >= 3.1.1g - mso_schema_template_bd: + cisco.mso.mso_schema_template_bd: <<: *unicast_routing_false_present register: nm_ansible_test_unicast_false when: version.current.version is version('3.1.1g', '>') - name: Add bd again with unicast routing false in mso versions >= 3.1.1g - mso_schema_template_bd: + cisco.mso.mso_schema_template_bd: <<: *unicast_routing_false_present register: nm_ansible_test_unicast_false_again when: version.current.version is version('3.1.1g', '>') - name: Change bd with unicast routing to true in mso versions >= 3.1.1g - mso_schema_template_bd: + cisco.mso.mso_schema_template_bd: <<: *unicast_routing_false_present unicast_routing: true register: nm_ansible_test_unicast_false_to_true when: version.current.version is version('3.1.1g', '>') - name: Add bd with change in unicast routing true in mso versions >= 3.1.1g (check mode) - mso_schema_template_bd: &unicast_routing_true_present + cisco.mso.mso_schema_template_bd: &unicast_routing_true_present <<: *unicast_routing_false_present bd: ansible_test_unicast_true unicast_routing: true @@ -1413,26 +1413,26 @@ when: version.current.version is version('3.1.1g', '>') - name: Add bd with change in unicast routing true in mso versions >= 3.1.1g - mso_schema_template_bd: + cisco.mso.mso_schema_template_bd: <<: *unicast_routing_true_present register: nm_ansible_test_unicast_true when: version.current.version is version('3.1.1g', '>') - name: Add bd again with unicast routing true in mso versions >= 3.1.1g - mso_schema_template_bd: + cisco.mso.mso_schema_template_bd: <<: *unicast_routing_true_present register: nm_ansible_test_unicast_true_again when: version.current.version is version('3.1.1g', '>') - name: Change bd with unicast routing to false in mso versions >= 3.1.1g - mso_schema_template_bd: + cisco.mso.mso_schema_template_bd: <<: *unicast_routing_true_present unicast_routing: false register: nm_ansible_test_unicast_true_to_false when: version.current.version is version('3.1.1g', '>') - name: Verify unicast routing - assert: + ansible.builtin.assert: that: - cm_ansible_test_unicast_false is changed - cm_ansible_test_unicast_false.current.unicastRouting == false @@ -1455,14 +1455,14 @@ when: version.current.version is version('3.1.1g', '>') - name: Remove bd with change in unicast routing false in mso versions >= 3.1.1g - mso_schema_template_bd: + cisco.mso.mso_schema_template_bd: <<: *unicast_routing_false_present state: absent register: ansible_test_unicast_false when: version.current.version is version('3.1.1g', '>') - name: Remove bd with change in unicast routing true in mso versions >= 3.1.1g - mso_schema_template_bd: + cisco.mso.mso_schema_template_bd: <<: *unicast_routing_true_present state: absent register: ansible_test_unicast_true @@ -1472,7 +1472,7 @@ # QUERY ALL BD - name: Query all bd (check_mode) - mso_schema_template_bd: &bd_query + cisco.mso.mso_schema_template_bd: &bd_query <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template1 @@ -1481,12 +1481,12 @@ register: cm_query_all_bds - name: Query all bd (normal mode) - mso_schema_template_bd: + cisco.mso.mso_schema_template_bd: <<: *bd_query register: nm_query_all_bds - name: Verify query_all_bds for version < 3.1.1g - assert: + ansible.builtin.assert: that: - cm_query_all_bds is not changed - nm_query_all_bds is not changed @@ -1494,7 +1494,7 @@ when: version.current.version is version('3.1.1g', '<') - name: Verify query_all_bds for version > 3.1.1g and version < 3.3 - assert: + ansible.builtin.assert: that: - cm_query_all_bds is not changed - nm_query_all_bds is not changed @@ -1504,7 +1504,7 @@ - version.current.version is version('3.3', '<') - name: Verify query_all_bds for version >= 3.3 and < 4.0 - assert: + ansible.builtin.assert: that: - cm_query_all_bds is not changed - nm_query_all_bds is not changed @@ -1514,7 +1514,7 @@ - version.current.version is version('3.7', '<') - name: Verify query_all_bds for version >= 4.0 - assert: + ansible.builtin.assert: that: - cm_query_all_bds is not changed - nm_query_all_bds is not changed @@ -1523,27 +1523,27 @@ # QUERY A BD - name: Query bd 1 - mso_schema_template_bd: + cisco.mso.mso_schema_template_bd: <<: *bd_query bd: ansible_test_1 check_mode: true register: cm_query_bd - name: Query bd 1 - mso_schema_template_bd: + cisco.mso.mso_schema_template_bd: <<: *bd_query bd: ansible_test_1 register: nm_query_bd - name: Query bd 2 - mso_schema_template_bd: + cisco.mso.mso_schema_template_bd: <<: *bd_query template: Template2 bd: ansible_test_2 register: nm_query_bd_2 - name: Query bd 3 - mso_schema_template_bd: + cisco.mso.mso_schema_template_bd: <<: *bd_query schema: '{{ mso_schema | default("ansible_test") }}_2' template: Template3 @@ -1551,7 +1551,7 @@ register: nm_query_bd_3 - name: Query bd 5 - mso_schema_template_bd: + cisco.mso.mso_schema_template_bd: <<: *bd_query schema: '{{ mso_schema | default("ansible_test") }}_2' template: Template5 @@ -1559,7 +1559,7 @@ register: nm_query_bd_5 - name: Verify query_bd - assert: + ansible.builtin.assert: that: - cm_query_bd is not changed - nm_query_bd is not changed @@ -1594,7 +1594,7 @@ - nm_query_bd_2.current.subnets[3].shared == false - name: Verify nm_query_bd_5 for a version that's before 3.1 - assert: + ansible.builtin.assert: that: - nm_query_bd_5 is not changed - nm_query_bd_5.current.name == "ansible_test_5" @@ -1606,7 +1606,7 @@ when: version.current.version is version('3.1.1g', '<') - name: Verify nm_query_bd_5 for a version that's 3.1 - assert: + ansible.builtin.assert: that: - nm_query_bd_5 is not changed - nm_query_bd_5.current.name == "ansible_test_5" @@ -1623,7 +1623,7 @@ when: version.current.version is version('3.1.1g', '>=') - name: Query bd with multiple dhcp policies for mso version > 3.1.1g - mso_schema_template_bd: + cisco.mso.mso_schema_template_bd: <<: *bd_query bd: ansible_test_multiple_dhcp state: query @@ -1634,7 +1634,7 @@ - version.current.version is version('4.0', '<') - name: Verify query of DHCP policies for mso version > 3.1.1g - assert: + ansible.builtin.assert: that: - query_nm_bd_dhcp_policies is not changed - query_nm_bd_dhcp_policies.current.name == 'ansible_test_multiple_dhcp' @@ -1654,7 +1654,7 @@ # Query BD with new options for mso version > 3.1.1g - name: Query bd with new option flood in encap available in mso versions > 3.1.1g with l2 set to false - mso_schema_template_bd: + cisco.mso.mso_schema_template_bd: <<: *bd_query bd: ansible_test_flood_encap state: query @@ -1662,7 +1662,7 @@ when: version.current.version is version('3.1.1g', '>') - name: Verify query_bd_new_encap_flood - assert: + ansible.builtin.assert: that: - query_bd_new_encap_flood is not changed - query_bd_new_encap_flood.current.name == 'ansible_test_flood_encap' @@ -1678,14 +1678,14 @@ when: version.current.version is version('3.1.1g', '>') - name: Verify query_bd_new_encap_flood - assert: + ansible.builtin.assert: that: - query_bd_new_encap_flood.current.l3MCast == false when: version.current.version is version('3.2', '>=') # REMOVE BD - name: Remove bd (check_mode) - mso_schema_template_bd: &bd_absent + cisco.mso.mso_schema_template_bd: &bd_absent <<: *bd_query schema: '{{ mso_schema | default("ansible_test") }}' template: Template1 @@ -1695,47 +1695,47 @@ register: cm_remove_bd - name: Verify cm_remove_bd - assert: + ansible.builtin.assert: that: - cm_remove_bd is changed - cm_remove_bd.current == {} - name: Remove bd (normal mode) - mso_schema_template_bd: + cisco.mso.mso_schema_template_bd: <<: *bd_absent register: nm_remove_bd - name: Verify nm_remove_bd - assert: + ansible.builtin.assert: that: - nm_remove_bd is changed - nm_remove_bd.current == {} - name: Remove bd again (check_mode) - mso_schema_template_bd: + cisco.mso.mso_schema_template_bd: <<: *bd_absent check_mode: true register: cm_remove_bd_again - name: Verify cm_remove_bd_again - assert: + ansible.builtin.assert: that: - cm_remove_bd_again is not changed - cm_remove_bd_again.current == {} - name: Remove bd again (normal mode) - mso_schema_template_bd: + cisco.mso.mso_schema_template_bd: <<: *bd_absent register: nm_remove_bd_again - name: Verify nm_remove_bd_again - assert: + ansible.builtin.assert: that: - nm_remove_bd_again is not changed - nm_remove_bd_again.current == {} - name: Remove bd 5 (normal mode) - mso_schema_template_bd: + cisco.mso.mso_schema_template_bd: <<: *bd_absent schema: '{{ mso_schema | default("ansible_test") }}_2' template: Template5 @@ -1743,13 +1743,13 @@ register: nm_remove_bd_5 - name: Verify nm_remove_bd_5 - assert: + ansible.builtin.assert: that: - nm_remove_bd_5 is changed - nm_remove_bd_5.current == {} - name: Remove bd ansible_test_multiple_dhcp (normal mode) - mso_schema_template_bd: + cisco.mso.mso_schema_template_bd: <<: *bd_absent schema: '{{ mso_schema | default("ansible_test") }}' template: Template1 @@ -1761,7 +1761,7 @@ - version.current.version is version('4.0', '<') - name: Verify nm_remove_ansible_test_multiple_dhcp - assert: + ansible.builtin.assert: that: - nm_remove_ansible_test_multiple_dhcp is changed - nm_remove_ansible_test_multiple_dhcp.current == {} @@ -1772,7 +1772,7 @@ # QUERY NON-EXISTING BD - name: Query non-existing bd (check_mode) - mso_schema_template_bd: + cisco.mso.mso_schema_template_bd: <<: *bd_query bd: ansible_test_1 check_mode: true @@ -1780,14 +1780,14 @@ register: cm_query_non_bd - name: Query non-existing bd (normal mode) - mso_schema_template_bd: + cisco.mso.mso_schema_template_bd: <<: *bd_query bd: ansible_test_1 ignore_errors: true register: nm_query_non_bd - name: Verify query_non_bd - assert: + ansible.builtin.assert: that: - cm_query_non_bd is not changed - nm_query_non_bd is not changed @@ -1797,7 +1797,7 @@ # USE A NON-EXISTING STATE - name: Non-existing state for bd (check_mode) - mso_schema_template_bd: + cisco.mso.mso_schema_template_bd: <<: *bd_query state: non-existing-state check_mode: true @@ -1805,14 +1805,14 @@ register: cm_non_existing_state - name: Non-existing state for bd (normal_mode) - mso_schema_template_bd: + cisco.mso.mso_schema_template_bd: <<: *bd_query state: non-existing-state ignore_errors: true register: nm_non_existing_state - name: Verify non_existing_state - assert: + ansible.builtin.assert: that: - cm_non_existing_state is not changed - nm_non_existing_state is not changed @@ -1821,7 +1821,7 @@ # USE A NON-EXISTING SCHEMA - name: Non-existing schema for bd (check_mode) - mso_schema_template_bd: + cisco.mso.mso_schema_template_bd: <<: *bd_query schema: non-existing-schema check_mode: true @@ -1829,14 +1829,14 @@ register: cm_non_existing_schema - name: Non-existing schema for bd (normal_mode) - mso_schema_template_bd: + cisco.mso.mso_schema_template_bd: <<: *bd_query schema: non-existing-schema ignore_errors: true register: nm_non_existing_schema - name: Verify non_existing_schema - assert: + ansible.builtin.assert: that: - cm_non_existing_schema is not changed - nm_non_existing_schema is not changed @@ -1845,7 +1845,7 @@ # USE A NON-EXISTING TEMPLATE - name: Non-existing template for bd (check_mode) - mso_schema_template_bd: + cisco.mso.mso_schema_template_bd: <<: *bd_query template: non-existing-template check_mode: true @@ -1853,14 +1853,14 @@ register: cm_non_existing_template - name: Non-existing template for bd (normal_mode) - mso_schema_template_bd: + cisco.mso.mso_schema_template_bd: <<: *bd_query template: non-existing-template ignore_errors: true register: nm_non_existing_template - name: Verify non_existing_template - assert: + ansible.builtin.assert: that: - cm_non_existing_template is not changed - nm_non_existing_template is not changed @@ -1869,7 +1869,7 @@ # CLEAN UP DHCP Policies - name: Ensure DHCP policies are removed - mso_dhcp_relay_policy: + cisco.mso.mso_dhcp_relay_policy: <<: *mso_info dhcp_relay_policy: '{{ item }}' tenant: ansible_test @@ -1883,7 +1883,7 @@ - version.current.version is version('4.0', '<') - name: Ensure DHCP option policies are removed - mso_dhcp_option_policy: + cisco.mso.mso_dhcp_option_policy: <<: *mso_info dhcp_option_policy: '{{ item }}' tenant: ansible_test @@ -1898,7 +1898,7 @@ # REMOVE Schemas for next CI Run - name: Remove schemas for next ci test - mso_schema: + cisco.mso.mso_schema: <<: *mso_info schema: '{{ item }}' state: absent diff --git a/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_bd_dhcp_policy/tasks/main.yml b/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_bd_dhcp_policy/tasks/main.yml index b6b2d7a80..b7f0d632f 100644 --- a/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_bd_dhcp_policy/tasks/main.yml +++ b/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_bd_dhcp_policy/tasks/main.yml @@ -4,14 +4,14 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI MultiSite host, username and password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: mso_hostname, mso_username and mso_password.' when: mso_hostname is not defined or mso_username is not defined or mso_password is not defined # CLEAN ENVIRONMENT - name: Set vars - set_fact: + ansible.builtin.set_fact: mso_info: &mso_info host: '{{ mso_hostname }}' username: '{{ mso_username }}' @@ -22,7 +22,7 @@ output_level: '{{ mso_output_level | default("info") }}' - name: Query MSO version - mso_version: + cisco.mso.mso_version: <<: *mso_info state: query register: version @@ -34,7 +34,7 @@ - version.current.version is version('4.0', '<') block: - name: Remove schemas - mso_schema: + cisco.mso.mso_schema: <<: *mso_info schema: '{{ item }}' state: absent @@ -43,7 +43,7 @@ - '{{ mso_schema | default("ansible_test") }}' - name: Remove DHCP policies - mso_dhcp_relay_policy: + cisco.mso.mso_dhcp_relay_policy: <<: *mso_info dhcp_relay_policy: '{{ item }}' tenant: ansible_test @@ -54,7 +54,7 @@ - 'ansible_test_dhcp_policy3' - name: Remove DHCP option policies - mso_dhcp_option_policy: + cisco.mso.mso_dhcp_option_policy: <<: *mso_info dhcp_option_policy: '{{ item }}' tenant: ansible_test @@ -64,7 +64,7 @@ - 'ansible_test_dhcp_policy_option2' - name: Ensure tenant ansible_test exist - mso_tenant: &tenant_present + cisco.mso.mso_tenant: &tenant_present <<: *mso_info tenant: ansible_test users: @@ -74,7 +74,7 @@ state: present - name: Ensure schema 1 with Template1 exist - mso_schema_template: &schema_present + cisco.mso.mso_schema_template: &schema_present <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' tenant: ansible_test @@ -82,7 +82,7 @@ state: present - name: Ensure VRF exists - mso_schema_template_vrf: &vrf_present + cisco.mso.mso_schema_template_vrf: &vrf_present <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template1 @@ -91,7 +91,7 @@ state: present - name: Ensure multiple DHCP policies exist - mso_dhcp_relay_policy: + cisco.mso.mso_dhcp_relay_policy: <<: *mso_info dhcp_relay_policy: '{{ item }}' description: "My Test DHCP Policies" @@ -103,7 +103,7 @@ - 'ansible_test_dhcp_policy3' - name: Ensure multiple DHCP option policies exist - mso_dhcp_option_policy: + cisco.mso.mso_dhcp_option_policy: <<: *mso_info dhcp_option_policy: '{{ item }}' description: "My Test DHCP Policy Options" @@ -115,7 +115,7 @@ # ADD BD - name: Add bd - mso_schema_template_bd: &bd_present + cisco.mso.mso_schema_template_bd: &bd_present <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template1 @@ -131,14 +131,14 @@ state: present - name: Add bd2 - mso_schema_template_bd: + cisco.mso.mso_schema_template_bd: <<: *bd_present bd: ansible_test_2 state: present # Add dhcp policies - name: Add DHCP policy in check mode - mso_schema_template_bd_dhcp_policy: &dhcp_present + cisco.mso.mso_schema_template_bd_dhcp_policy: &dhcp_present <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template1 @@ -152,17 +152,17 @@ check_mode: true - name: Add DHCP policy in normal mode - mso_schema_template_bd_dhcp_policy: + cisco.mso.mso_schema_template_bd_dhcp_policy: <<: *dhcp_present register: nm_add_dhcp - name: Add DHCP policy again in normal mode - mso_schema_template_bd_dhcp_policy: + cisco.mso.mso_schema_template_bd_dhcp_policy: <<: *dhcp_present register: nm_add_dhcp_again - name: Add another DHCP policy in normal mode - mso_schema_template_bd_dhcp_policy: + cisco.mso.mso_schema_template_bd_dhcp_policy: <<: *dhcp_present name: ansible_test_dhcp_policy2 version: 1 @@ -173,14 +173,14 @@ - name: Add dhcp for query all (normal mode) - mso_schema_template_bd_dhcp_policy: + cisco.mso.mso_schema_template_bd_dhcp_policy: <<: *dhcp_present name: ansible_test_dhcp_policy3 version: 1 register: nm_add_dhcp3 - name: Verify cm_add_dhcp, nm_add_dhcp, nm_add_dhcp2 and nm_add_dhcp3 - assert: + ansible.builtin.assert: that: - cm_add_dhcp is changed - nm_add_dhcp is changed @@ -198,7 +198,7 @@ # CHANGE dhcp policies - name: Change dhcp policy (normal mode) - mso_schema_template_bd_dhcp_policy: + cisco.mso.mso_schema_template_bd_dhcp_policy: <<: *dhcp_present schema: '{{ mso_schema | default("ansible_test") }}' template: Template1 @@ -211,7 +211,7 @@ register: nm_change_dhcp - name: Verify nm_change_dhcp - assert: + ansible.builtin.assert: that: - nm_change_dhcp is changed - nm_change_dhcp.current.name == 'ansible_test_dhcp_policy1' @@ -219,7 +219,7 @@ - nm_change_dhcp.current.dhcpOptionLabel.name == 'ansible_test_dhcp_policy_option2' - name: Change dhcp policy again (normal mode) - mso_schema_template_bd_dhcp_policy: + cisco.mso.mso_schema_template_bd_dhcp_policy: <<: *dhcp_present schema: '{{ mso_schema | default("ansible_test") }}' template: Template1 @@ -233,7 +233,7 @@ - name: Verify nm_change_dhcp - assert: + ansible.builtin.assert: that: - nm_change_dhcp_again is changed - nm_change_dhcp_again.current.name == 'ansible_test_dhcp_policy1' @@ -242,7 +242,7 @@ # QUERY ALL dhcp policies - name: Query all dhcp (check_mode) - mso_schema_template_bd_dhcp_policy: &dhcp_query + cisco.mso.mso_schema_template_bd_dhcp_policy: &dhcp_query <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template1 @@ -253,13 +253,13 @@ - name: Query all dhcp (normal mode) - mso_schema_template_bd_dhcp_policy: + cisco.mso.mso_schema_template_bd_dhcp_policy: <<: *dhcp_query register: nm_query_all_dhcp - name: Verify query_all_dhcp - assert: + ansible.builtin.assert: that: - cm_query_all_dhcp is not changed - nm_query_all_dhcp is not changed @@ -267,13 +267,13 @@ # QUERY a DHCP policy - name: Query single dhcp - mso_schema_template_bd_dhcp_policy: + cisco.mso.mso_schema_template_bd_dhcp_policy: <<: *dhcp_query name: ansible_test_dhcp_policy1 register: nm_query_dhcp - name: Verify nm_query_dhcp - assert: + ansible.builtin.assert: that: - nm_query_dhcp is not changed - nm_query_dhcp.current.name == 'ansible_test_dhcp_policy1' @@ -282,7 +282,7 @@ # QUERY a non associated DHCP policy - name: Query non associated dhcp - mso_schema_template_bd_dhcp_policy: + cisco.mso.mso_schema_template_bd_dhcp_policy: <<: *dhcp_query bd: ansible_test_2 name: ansible_test_dhcp_policy1 @@ -290,13 +290,13 @@ register: non_dhcp - name: Verify non_dhcp - assert: + ansible.builtin.assert: that: - non_dhcp.msg is match ("DHCP policy not associated with the bd") # REMOVE DHCP policy - name: Remove dhcp policy - mso_schema_template_bd_dhcp_policy: &dhcp_absent + cisco.mso.mso_schema_template_bd_dhcp_policy: &dhcp_absent <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template1 @@ -306,26 +306,26 @@ register: nm_remove_dhcp - name: Verify nm_remove_dhcp - assert: + ansible.builtin.assert: that: - nm_remove_dhcp is changed - nm_remove_dhcp.current == {} - name: Remove dhcp again (check_mode) - mso_schema_template_bd_dhcp_policy: + cisco.mso.mso_schema_template_bd_dhcp_policy: <<: *dhcp_absent register: nm_remove_dhcp_again - name: Verify nm_remove_dhcp_again - assert: + ansible.builtin.assert: that: - nm_remove_dhcp_again is not changed - nm_remove_dhcp_again.current == {} # QUERY NON-EXISTING DHCP policy - name: Query non-existing dhcp policy - mso_schema_template_bd_dhcp_policy: + cisco.mso.mso_schema_template_bd_dhcp_policy: <<: *dhcp_query schema: '{{ mso_schema | default("ansible_test") }}' template: Template1 @@ -339,14 +339,14 @@ register: nm_query_non_dhcp - name: Verify nm_query_non_dhcp - assert: + ansible.builtin.assert: that: - nm_query_non_dhcp is not changed - nm_query_non_dhcp.msg is match ("DHCP policy 'non_policy' does not exist") # QUERY NON-EXISTING DHCP policy option - name: Query non-existing dhcp policy option - mso_schema_template_bd_dhcp_policy: + cisco.mso.mso_schema_template_bd_dhcp_policy: <<: *dhcp_query schema: '{{ mso_schema | default("ansible_test") }}' template: Template1 @@ -360,70 +360,70 @@ register: nm_query_non_dhcp_option - name: Verify nm_query_non_dhcp - assert: + ansible.builtin.assert: that: - nm_query_non_dhcp_option is not changed - nm_query_non_dhcp_option.msg is match ("DHCP option policy 'non_option' does not exist") # USE A NON-EXISTING STATE - name: Non-existing state for dhcp - mso_schema_template_bd_dhcp_policy: + cisco.mso.mso_schema_template_bd_dhcp_policy: <<: *dhcp_query state: non-existing-state ignore_errors: true register: nm_non_existing_state - name: Verify non_existing_state - assert: + ansible.builtin.assert: that: - nm_non_existing_state is not changed - nm_non_existing_state.msg is match ("value of state must be one of{{':'}} absent, present, query, got{{':'}} non-existing-state") # USE A NON-EXISTING SCHEMA - name: Non-existing schema for dhcp - mso_schema_template_bd_dhcp_policy: + cisco.mso.mso_schema_template_bd_dhcp_policy: <<: *dhcp_query schema: non-existing-schema ignore_errors: true register: nm_non_existing_schema - name: Verify non_existing_schema - assert: + ansible.builtin.assert: that: - nm_non_existing_schema is not changed - nm_non_existing_schema.msg is match ("Provided schema 'non-existing-schema' does not exist.") # USE A NON-EXISTING TEMPLATE - name: Non-existing template for dhcp - mso_schema_template_bd_dhcp_policy: + cisco.mso.mso_schema_template_bd_dhcp_policy: <<: *dhcp_query template: non-existing-template ignore_errors: true register: nm_non_existing_template - name: Verify non_existing_template - assert: + ansible.builtin.assert: that: - nm_non_existing_template is not changed - nm_non_existing_template.msg is match ("Provided template 'non-existing-template' does not exist. Existing templates{{':'}} Template1") # USE A NON-EXISTING BD - name: Non-existing bd for dhcp - mso_schema_template_bd_dhcp_policy: + cisco.mso.mso_schema_template_bd_dhcp_policy: <<: *dhcp_query bd: non-existing-bd ignore_errors: true register: nm_non_existing_bd - name: Verify non_existing_bd - assert: + ansible.builtin.assert: that: - nm_non_existing_bd is not changed - nm_non_existing_bd.msg is match ("Provided BD 'non-existing-bd' does not exist. Existing BDs{{':'}} ansible_test_1") # REMOVE Schemas for next CI Run - name: Remove schemas for next ci test - mso_schema: + cisco.mso.mso_schema: <<: *mso_info schema: '{{ item }}' state: absent @@ -433,7 +433,7 @@ # CLEAN UP DHCP Policies - name: Ensure DHCP policies are removed - mso_dhcp_relay_policy: + cisco.mso.mso_dhcp_relay_policy: <<: *mso_info dhcp_relay_policy: '{{ item }}' tenant: ansible_test @@ -444,7 +444,7 @@ - 'ansible_test_dhcp_policy3' - name: Ensure DHCP option policies are removed - mso_dhcp_option_policy: + cisco.mso.mso_dhcp_option_policy: <<: *mso_info dhcp_option_policy: '{{ item }}' tenant: ansible_test diff --git a/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_bd_subnet/tasks/main.yml b/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_bd_subnet/tasks/main.yml index 75a3b4747..45d5612d6 100644 --- a/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_bd_subnet/tasks/main.yml +++ b/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_bd_subnet/tasks/main.yml @@ -6,14 +6,14 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI MultiSite host, username and password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: mso_hostname, mso_username and mso_password.' when: mso_hostname is not defined or mso_username is not defined or mso_password is not defined # CLEAN ENVIRONMENT - name: Set vars - set_fact: + ansible.builtin.set_fact: mso_info: &mso_info host: '{{ mso_hostname }}' username: '{{ mso_username }}' @@ -24,18 +24,18 @@ output_level: '{{ mso_output_level | default("info") }}' - name: Query MSO version - mso_version: + cisco.mso.mso_version: <<: *mso_info state: query register: version - name: Set version vars - set_fact: - mso_l3mcast: false + ansible.builtin.set_fact: + cisco.mso.mso_l3mcast: false when: version.current.version is version('2.2.4', '=') - name: Ensure site exist - mso_site: &site_present + cisco.mso.mso_site: &site_present <<: *mso_info site: '{{ mso_site | default("ansible_test") }}' apic_username: '{{ apic_username }}' @@ -46,7 +46,7 @@ state: present - name: Remove schemas - mso_schema: + cisco.mso.mso_schema: <<: *mso_info schema: '{{ item }}' state: absent @@ -55,7 +55,7 @@ - '{{ mso_schema | default("ansible_test") }}' - name: Ensure tenant ansible_test exist - mso_tenant: &tenant_present + cisco.mso.mso_tenant: &tenant_present <<: *mso_info tenant: ansible_test users: @@ -65,7 +65,7 @@ state: present - name: Ensure schema 1 with Template1 exist - mso_schema_template: &schema_present + cisco.mso.mso_schema_template: &schema_present <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' tenant: ansible_test @@ -73,7 +73,7 @@ state: present - name: Ensure schema 2 with Template2 exists - mso_schema_template: + cisco.mso.mso_schema_template: <<: *schema_present schema: '{{ mso_schema | default("ansible_test") }}_2' tenant: ansible_test @@ -81,7 +81,7 @@ state: present - name: Ensure VRF exists - mso_schema_template_vrf: &vrf_present + cisco.mso.mso_schema_template_vrf: &vrf_present <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template1 @@ -90,7 +90,7 @@ state: present - name: Ensure VRF2 exists - mso_schema_template_vrf: + cisco.mso.mso_schema_template_vrf: <<: *vrf_present schema: '{{ mso_schema | default("ansible_test") }}_2' template: Template2 @@ -98,7 +98,7 @@ # ADD BD - name: Add bd - mso_schema_template_bd: &bd_present + cisco.mso.mso_schema_template_bd: &bd_present <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template1 @@ -120,7 +120,7 @@ state: present - name: Add bd 2 - mso_schema_template_bd: + cisco.mso.mso_schema_template_bd: <<: *bd_present schema: '{{ mso_schema | default("ansible_test") }}_2' template: Template2 @@ -141,7 +141,7 @@ version: 1 - name: Add bd - mso_schema_template_bd: + cisco.mso.mso_schema_template_bd: <<: *bd_present schema: '{{ mso_schema | default("ansible_test") }}' template: Template1 @@ -164,7 +164,7 @@ # Add subnet - name: Add subnet in check mode - mso_schema_template_bd_subnet: &subnet_present + cisco.mso.mso_schema_template_bd_subnet: &subnet_present <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template1 @@ -180,22 +180,22 @@ check_mode: true - name: Add subnet (normal mode) - mso_schema_template_bd_subnet: + cisco.mso.mso_schema_template_bd_subnet: <<: *subnet_present register: nm_add_subnet - name: Add subnet again (normal mode) - mso_schema_template_bd_subnet: + cisco.mso.mso_schema_template_bd_subnet: <<: *subnet_present register: nm_add_subnet_again - name: Add subnet for query all (normal mode) - mso_schema_template_bd_subnet: + cisco.mso.mso_schema_template_bd_subnet: <<: *subnet_present subnet: 2.16.0.1/24 - name: Verify cm_add_subnet and nm_add_subnet - assert: + ansible.builtin.assert: that: - cm_add_subnet is changed - nm_add_subnet is changed @@ -214,7 +214,7 @@ - nm_add_subnet.current.querier == true - name: Add subnet 2 (normal mode) - mso_schema_template_bd_subnet: + cisco.mso.mso_schema_template_bd_subnet: <<: *subnet_present schema: '{{ mso_schema | default("ansible_test") }}_2' template: Template2 @@ -229,7 +229,7 @@ register: nm_add_subnet_2 - name: Verify nm_bd_2 for a version that's < 3.1 - assert: + ansible.builtin.assert: that: - nm_add_subnet_2.current.ip == "10.1.1.1/24" - nm_add_subnet_2.current.noDefaultGateway == false @@ -239,7 +239,7 @@ when: version.current.version is version('3.1.1g', '<') - name: Verify nm_bd_2 for a version that's >= 3.1 - assert: + ansible.builtin.assert: that: - nm_add_subnet_2.current.ip == "10.1.1.1/24" - nm_add_subnet_2.current.noDefaultGateway == false @@ -251,7 +251,7 @@ # CHANGE Subnet - name: Change subnet 2 (normal mode) - mso_schema_template_bd_subnet: + cisco.mso.mso_schema_template_bd_subnet: <<: *subnet_present schema: '{{ mso_schema | default("ansible_test") }}_2' template: Template2 @@ -266,7 +266,7 @@ register: nm_change_subnet2 - name: Verify nm_change_subnet2 for a version < 3.1 - assert: + ansible.builtin.assert: that: - nm_change_subnet2 is not changed - nm_change_subnet2.current.ip == "10.1.1.1/24" @@ -277,7 +277,7 @@ when: version.current.version is version('3.1.1g', '<') - name: Verify nm_change_subnet2 for a version >= 3.1 - assert: + ansible.builtin.assert: that: - nm_change_subnet2 is changed - nm_change_subnet2.current.ip == "10.1.1.1/24" @@ -289,7 +289,7 @@ when: version.current.version is version('3.1.1g', '>=') - name: Change subnet2 again (normal mode) - mso_schema_template_bd_subnet: + cisco.mso.mso_schema_template_bd_subnet: <<: *subnet_present schema: '{{ mso_schema | default("ansible_test") }}_2' template: Template2 @@ -304,7 +304,7 @@ register: nm_change_subnet2_again - name: Verify nm_change_subnet2_again for a version that's < 3.1 - assert: + ansible.builtin.assert: that: - nm_change_subnet2_again is not changed - nm_change_subnet2_again.current.ip == "10.1.1.1/24" @@ -315,7 +315,7 @@ when: version.current.version is version('3.1.1g', '<') - name: Verify cm_change_subnet2 for a version that's >= 3.1 - assert: + ansible.builtin.assert: that: - nm_change_subnet2_again is not changed - nm_change_subnet2_again.current.ip == "10.1.1.1/24" @@ -328,7 +328,7 @@ # Primary parameter - name: Add subnet 3 with primary and querier parameters (normal mode) - mso_schema_template_bd_subnet: + cisco.mso.mso_schema_template_bd_subnet: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template1 @@ -345,7 +345,7 @@ register: nm_add_subnet_3 - name: Verify nm_add_subnet_3 for a version that's < 3.1 - assert: + ansible.builtin.assert: that: - nm_add_subnet_3.current.ip == "10.1.1.5/24" - nm_add_subnet_3.current.noDefaultGateway == false @@ -355,7 +355,7 @@ when: version.current.version is version('3.1.1g', '<') - name: Verify nm_add_subnet_3 for a version that's >= 3.1 - assert: + ansible.builtin.assert: that: - nm_add_subnet_3.current.ip == "10.1.1.5/24" - nm_add_subnet_3.current.noDefaultGateway == false @@ -368,7 +368,7 @@ # CHANGE Subnet - name: Change subnet 3 (normal mode) - mso_schema_template_bd_subnet: + cisco.mso.mso_schema_template_bd_subnet: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template1 @@ -385,7 +385,7 @@ register: nm_change_subnet3 - name: Verify nm_change_subnet3 for a version < 3.1 - assert: + ansible.builtin.assert: that: - nm_change_subnet3 is not changed - nm_change_subnet3.current.ip == "10.1.1.5/24" @@ -396,7 +396,7 @@ when: version.current.version is version('3.1.1g', '<') - name: Verify nm_change_subnet2 for a version >= 3.1 - assert: + ansible.builtin.assert: that: - nm_change_subnet3 is changed - nm_change_subnet3.current.ip == "10.1.1.5/24" @@ -409,7 +409,7 @@ when: version.current.version is version('3.1.1g', '>=') - name: Change subnet3 again (normal mode) - mso_schema_template_bd_subnet: + cisco.mso.mso_schema_template_bd_subnet: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template1 @@ -426,7 +426,7 @@ register: nm_change_subnet3_again - name: Verify nm_change_subnet2_again for a version that's < 3.1 - assert: + ansible.builtin.assert: that: - nm_change_subnet3_again is not changed - nm_change_subnet3_again.current.ip == "10.1.1.5/24" @@ -437,7 +437,7 @@ when: version.current.version is version('3.1.1g', '<') - name: Verify cm_change_subnet2 for a version that's >= 3.1 - assert: + ansible.builtin.assert: that: - nm_change_subnet3_again is not changed - nm_change_subnet3_again.current.ip == "10.1.1.5/24" @@ -451,7 +451,7 @@ # QUERY ALL Subnets - name: Query all subnet (check_mode) - mso_schema_template_bd_subnet: &subnet_query + cisco.mso.mso_schema_template_bd_subnet: &subnet_query <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template1 @@ -461,12 +461,12 @@ register: cm_query_all_subnet - name: Query all subnet (normal mode) - mso_schema_template_bd_subnet: + cisco.mso.mso_schema_template_bd_subnet: <<: *subnet_query register: nm_query_all_subnet - name: Verify query_all_subnet - assert: + ansible.builtin.assert: that: - cm_query_all_subnet is not changed - nm_query_all_subnet is not changed @@ -474,7 +474,7 @@ # QUERY A subnet - name: Query subnet2 - mso_schema_template_bd_subnet: + cisco.mso.mso_schema_template_bd_subnet: <<: *subnet_query schema: '{{ mso_schema | default("ansible_test") }}_2' template: Template2 @@ -483,7 +483,7 @@ register: nm_query_subnet2 - name: Verify nm_query_subnet2 for a version that's < 3.1 - assert: + ansible.builtin.assert: that: - nm_query_subnet2 is not changed - nm_query_subnet2.current.ip == "10.1.1.1/24" @@ -494,7 +494,7 @@ when: version.current.version is version('3.1.1g', '<') - name: Verify nm_query_subnet2 for a version that's >= 3.1 - assert: + ansible.builtin.assert: that: - nm_query_subnet2 is not changed - nm_query_subnet2.current.ip == "10.1.1.1/24" @@ -507,7 +507,7 @@ # REMOVE Subnet - name: Remove subnet - mso_schema_template_bd_subnet: &subnet_absent + cisco.mso.mso_schema_template_bd_subnet: &subnet_absent <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template1 @@ -517,25 +517,25 @@ register: nm_remove_subnet - name: Verify nm_remove_subnet - assert: + ansible.builtin.assert: that: - nm_remove_subnet is changed - nm_remove_subnet.current == {} - name: Remove subnet again (check_mode) - mso_schema_template_bd_subnet: + cisco.mso.mso_schema_template_bd_subnet: <<: *subnet_absent register: nm_remove_subnet_again - name: Verify nm_remove_subnet_again - assert: + ansible.builtin.assert: that: - nm_remove_subnet_again is not changed - nm_remove_subnet_again.current == {} # QUERY NON-EXISTING Subnet - name: Query non-existing subnet - mso_schema_template_bd_subnet: + cisco.mso.mso_schema_template_bd_subnet: <<: *subnet_query bd: ansible_test_1 subnet: 172.16.0.3/24 @@ -543,56 +543,56 @@ register: nm_query_non_subnet - name: Verify nm_query_non_subnet - assert: + ansible.builtin.assert: that: - nm_query_non_subnet is not changed - nm_query_non_subnet.msg is match ("Subnet IP '172.16.0.3/24' not found") # USE A NON-EXISTING STATE - name: Non-existing state for subnet - mso_schema_template_bd_subnet: + cisco.mso.mso_schema_template_bd_subnet: <<: *subnet_query state: non-existing-state ignore_errors: true register: nm_non_existing_state - name: Verify non_existing_state - assert: + ansible.builtin.assert: that: - nm_non_existing_state is not changed - nm_non_existing_state.msg is match ("value of state must be one of{{':'}} absent, present, query, got{{':'}} non-existing-state") # USE A NON-EXISTING SCHEMA - name: Non-existing schema for subnet - mso_schema_template_bd_subnet: + cisco.mso.mso_schema_template_bd_subnet: <<: *subnet_query schema: non-existing-schema ignore_errors: true register: nm_non_existing_schema - name: Verify non_existing_schema - assert: + ansible.builtin.assert: that: - nm_non_existing_schema is not changed - nm_non_existing_schema.msg is match ("Provided schema 'non-existing-schema' does not exist.") # USE A NON-EXISTING TEMPLATE - name: Non-existing template for subnet - mso_schema_template_bd_subnet: + cisco.mso.mso_schema_template_bd_subnet: <<: *subnet_query template: non-existing-template ignore_errors: true register: nm_non_existing_template - name: Verify non_existing_template - assert: + ansible.builtin.assert: that: - nm_non_existing_template is not changed - nm_non_existing_template.msg is match ("Provided template 'non-existing-template' does not exist. Existing templates{{':'}} Template1") # USE NON-EXISTING OPTIONS - name: Add subnet with no description - mso_schema_template_bd_subnet: + cisco.mso.mso_schema_template_bd_subnet: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template1 @@ -602,26 +602,26 @@ register: nm_add_subnet_no_desc - name: Verify nm_add_subnet_no_desc - assert: + ansible.builtin.assert: that: - nm_add_subnet_no_desc.current.description == "172.16.0.5/24" # USE A NON-EXISTING BD - name: Non-existing bd for subnet - mso_schema_template_bd_subnet: + cisco.mso.mso_schema_template_bd_subnet: <<: *subnet_query bd: non-existing-bd ignore_errors: true register: nm_non_existing_bd - name: Verify non_existing_bd - assert: + ansible.builtin.assert: that: - nm_non_existing_bd is not changed - nm_non_existing_bd.msg is match ("Provided BD 'non-existing-bd' does not exist. Existing BDs{{':'}} ansible_test_1") - name: Remove schemas for next ci test - mso_schema: + cisco.mso.mso_schema: <<: *mso_info schema: '{{ item }}' state: absent diff --git a/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_clone/tasks/main.yml b/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_clone/tasks/main.yml index 0039a9b02..1128a3ee8 100644 --- a/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_clone/tasks/main.yml +++ b/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_clone/tasks/main.yml @@ -4,13 +4,13 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI MultiSite host, username and password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: mso_hostname, mso_username and mso_password.' when: mso_hostname is not defined or mso_username is not defined or mso_password is not defined # CLEAN ENVIRONMENT - name: Set vars - set_fact: + ansible.builtin.set_fact: mso_info: &mso_info host: '{{ mso_hostname }}' username: '{{ mso_username }}' @@ -21,7 +21,7 @@ output_level: '{{ mso_output_level | default("info") }}' - name: Query MSO version - mso_version: + cisco.mso.mso_version: <<: *mso_info state: query register: version @@ -37,7 +37,7 @@ - Schema2 - name: Ensure tenant ansible_test exists - mso_tenant: + cisco.mso.mso_tenant: <<: *mso_info tenant: ansible_test users: @@ -47,7 +47,7 @@ state: present - name: Ensure user is defined under common tenant - mso_tenant: + cisco.mso.mso_tenant: <<: *mso_info tenant: common users: @@ -100,7 +100,7 @@ - { schema: 'Schema2', template: 'Template3', epg: 'ansible_test_3' } - name: Add Selector to EPG (normal_mode) - mso_schema_template_anp_epg_selector: + cisco.mso.mso_schema_template_anp_epg_selector: <<: *mso_info schema: 'Schema1' template: Template1 @@ -176,7 +176,7 @@ register: add_template_tenant - name: Verify add_templates - assert: + ansible.builtin.assert: that: - cm_add_template is not changed - add_template is changed @@ -205,7 +205,7 @@ register: non_existing_template - name: Verify non_existing_template - assert: + ansible.builtin.assert: that: - non_existing_template is not changed - non_existing_template.msg == "Source template with the name 'non_existing_template' does not exist." @@ -222,7 +222,7 @@ register: non_existing_source_schema - name: Verify non_existing_source_schema - assert: + ansible.builtin.assert: that: - non_existing_source_schema is not changed - non_existing_source_schema.msg == "Schema with the name 'non_existing_schema' does not exist." @@ -241,7 +241,7 @@ register: non_existing_schema - name: Verify non_existing_schema - assert: + ansible.builtin.assert: that: - non_existing_schema is not changed - non_existing_schema.msg == "Schema with the name 'non_existing_schema' does not exist." @@ -256,7 +256,7 @@ register: wrong_template_name - name: Verify wrong_template_name - assert: + ansible.builtin.assert: that: - wrong_template_name is not changed - wrong_template_name.msg == "Source and destination templates in the same schema cannot have same names." @@ -272,7 +272,7 @@ register: template_already_exist - name: Verify template_already_exist - assert: + ansible.builtin.assert: that: - template_already_exist is not changed - template_already_exist.msg == "Template with the name 'Template2' already exists. Please use another name." @@ -288,6 +288,6 @@ - Schema1 - name: Verify rm_schema - assert: + ansible.builtin.assert: that: - rm_schema is changed
\ No newline at end of file diff --git a/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_contract_filter/tasks/main.yml b/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_contract_filter/tasks/main.yml index 08f6d5cf5..9236b1b58 100644 --- a/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_contract_filter/tasks/main.yml +++ b/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_contract_filter/tasks/main.yml @@ -9,14 +9,14 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI MultiSite host, username and password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: mso_hostname, mso_username and mso_password.' when: mso_hostname is not defined or mso_username is not defined or mso_password is not defined # CLEAN ENVIRONMENT - name: Set vars - set_fact: + ansible.builtin.set_fact: mso_info: &mso_info host: '{{ mso_hostname }}' username: '{{ mso_username }}' @@ -27,25 +27,25 @@ output_level: '{{ mso_output_level | default("info") }}' - name: Query MSO version - mso_version: + cisco.mso.mso_version: <<: *mso_info state: query register: version - name: Remove schema 2 - mso_schema: + cisco.mso.mso_schema: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}_2' state: absent - name: Remove schema 1 - mso_schema: + cisco.mso.mso_schema: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' state: absent - name: Ensure tenant ansible_test exist - mso_tenant: &tenant_present + cisco.mso.mso_tenant: &tenant_present <<: *mso_info tenant: ansible_test users: @@ -53,7 +53,7 @@ state: present - name: Ensure schema 1 with Template 1 exist - mso_schema_template: &schema_present + cisco.mso.mso_schema_template: &schema_present <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' tenant: ansible_test @@ -61,13 +61,13 @@ state: present - name: Ensure schema 1 with Template 2 exist - mso_schema_template: + cisco.mso.mso_schema_template: <<: *schema_present template: Template 2 state: present - name: Ensure schema 2 with Template 3 exist - mso_schema_template: + cisco.mso.mso_schema_template: <<: *schema_present schema: '{{ mso_schema | default("ansible_test") }}_2' tenant: ansible_test @@ -86,7 +86,7 @@ register: add_filter - name: Ensure Filter2 exist - mso_schema_template_filter_entry: + cisco.mso.mso_schema_template_filter_entry: <<: *filter_present template: Template 2 filter: Filter2 @@ -94,7 +94,7 @@ state: present - name: Ensure Filter3 exist - mso_schema_template_filter_entry: + cisco.mso.mso_schema_template_filter_entry: <<: *filter_present schema: '{{ mso_schema | default("ansible_test") }}_2' template: Template 3 @@ -103,28 +103,28 @@ state: present - name: Ensure Filter4 exist - mso_schema_template_filter_entry: + cisco.mso.mso_schema_template_filter_entry: <<: *filter_present filter: Filter4 entry: Filter4Entry state: present - name: Ensure Filter5 exist - mso_schema_template_filter_entry: + cisco.mso.mso_schema_template_filter_entry: <<: *filter_present filter: Filter5 entry: Filter5Entry state: present - name: Ensure Filter-6 exist - mso_schema_template_filter_entry: + cisco.mso.mso_schema_template_filter_entry: <<: *filter_present filter: Filter-6 entry: Filter-6Entry state: present - name: Ensure Contract_1 contract does not exist - mso_schema_template_contract_filter: &contract_present + cisco.mso.mso_schema_template_contract_filter: &contract_present <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -135,14 +135,14 @@ state: absent - name: Ensure Contract_2 contract does not exist - mso_schema_template_contract_filter: + cisco.mso.mso_schema_template_contract_filter: <<: *contract_present template: Template 2 contract: Contract2 state: absent - name: Ensure Contract_3 contract does not exist - mso_schema_template_contract_filter: + cisco.mso.mso_schema_template_contract_filter: <<: *contract_present schema: '{{ mso_schema | default("ansible_test") }}_2' template: Template 3 @@ -150,26 +150,26 @@ state: absent - name: Ensure Contract_4 contract does not exist - mso_schema_template_contract_filter: + cisco.mso.mso_schema_template_contract_filter: <<: *contract_present contract: Contract4 state: absent - name: Ensure Contract_5 contract does not exist - mso_schema_template_contract_filter: + cisco.mso.mso_schema_template_contract_filter: <<: *contract_present contract: Contract5 state: absent - name: Ensure Contract_6 contract does not exist - mso_schema_template_contract_filter: + cisco.mso.mso_schema_template_contract_filter: <<: *contract_present contract: Contract-6 state: absent # ADD CONTRACT - name: Add contract (check_mode) - mso_schema_template_contract_filter: + cisco.mso.mso_schema_template_contract_filter: <<: *contract_present contract: Contract1 filter: Filter1 @@ -178,7 +178,7 @@ register: cm_add_contract - name: Verify cm_add_contract - assert: + ansible.builtin.assert: that: - cm_add_contract is changed - cm_add_contract.previous == {} @@ -186,7 +186,7 @@ - cm_add_contract.current.filterRef.templateName == "Template1" - name: Add contract (normal mode) - mso_schema_template_contract_filter: + cisco.mso.mso_schema_template_contract_filter: <<: *contract_present contract: Contract1 filter: Filter1 @@ -194,7 +194,7 @@ register: nm_add_contract - name: Verify nm_add_contract - assert: + ansible.builtin.assert: that: - nm_add_contract is changed - nm_add_contract.previous == {} @@ -203,7 +203,7 @@ - cm_add_contract.current.filterRef.schemaId == nm_add_contract.current.filterRef.schemaId - name: Add contract again (check_mode) - mso_schema_template_contract_filter: + cisco.mso.mso_schema_template_contract_filter: <<: *contract_present contract: Contract1 filter: Filter1 @@ -212,7 +212,7 @@ register: cm_add_contract_again - name: Verify cm_add_contract_again - assert: + ansible.builtin.assert: that: - cm_add_contract_again is not changed - cm_add_contract_again.current.filterRef.filterName == "Filter1" @@ -222,7 +222,7 @@ - cm_add_contract_again.previous.filterRef.schemaId == cm_add_contract_again.current.filterRef.schemaId - name: Add contract again (normal mode) - mso_schema_template_contract_filter: + cisco.mso.mso_schema_template_contract_filter: <<: *contract_present contract: Contract1 filter: Filter1 @@ -230,7 +230,7 @@ register: nm_add_contract_again - name: Verify nm_add_contract_again - assert: + ansible.builtin.assert: that: - nm_add_contract_again is not changed - nm_add_contract_again.current.filterRef.filterName == "Filter1" @@ -241,7 +241,7 @@ - nm_add_contract_again.previous.filterRef.schemaId == nm_add_contract_again.current.filterRef.schemaId - name: Add Contract2 (check_mode) - mso_schema_template_contract_filter: + cisco.mso.mso_schema_template_contract_filter: <<: *contract_present template: Template 2 contract: Contract2 @@ -252,14 +252,14 @@ register: cm_add_contract_2 - name: Verify cm_add_contract_2 - assert: + ansible.builtin.assert: that: - cm_add_contract_2 is changed - cm_add_contract_2.current.filterRef.filterName == "Filter1" - cm_add_contract_2.current.filterRef.templateName == "Template1" - name: Add Contract2 (nomal mode) - mso_schema_template_contract_filter: + cisco.mso.mso_schema_template_contract_filter: <<: *contract_present template: Template 2 contract: Contract2 @@ -269,7 +269,7 @@ register: nm_add_contract_2 - name: Verify nm_add_contract_2 - assert: + ansible.builtin.assert: that: - nm_add_contract_2 is changed - nm_add_contract_2.current.filterRef.filterName == "Filter1" @@ -277,7 +277,7 @@ - cm_add_contract_2.current.filterRef.schemaId == nm_add_contract_2.current.filterRef.schemaId - name: Add Contract3 (nomal mode) - mso_schema_template_contract_filter: + cisco.mso.mso_schema_template_contract_filter: <<: *contract_present schema: '{{ mso_schema | default("ansible_test") }}_2' template: Template 3 @@ -289,14 +289,14 @@ register: nm_add_contract_3 - name: Verify nm_add_contract_3 - assert: + ansible.builtin.assert: that: - nm_add_contract_3 is changed - nm_add_contract_3.current.filterRef.filterName == "Filter1" - nm_add_contract_3.current.filterRef.templateName == "Template1" - name: Add Contract4 (nomal mode) - mso_schema_template_contract_filter: + cisco.mso.mso_schema_template_contract_filter: <<: *contract_present contract: Contract4 filter: Filter1 @@ -305,7 +305,7 @@ register: nm_add_contract_4 - name: Verify nm_add_contract_4 - assert: + ansible.builtin.assert: that: - nm_add_contract_4 is changed - nm_add_contract_4.current.filterRef.filterName == "Filter1" @@ -314,7 +314,7 @@ # create CONTRACT FILTER with diff options - name: Add Contract filter to both-way(check_mode) - mso_schema_template_contract_filter: + cisco.mso.mso_schema_template_contract_filter: <<: *contract_present contract: Contract1 contract_filter_type: both-way @@ -325,7 +325,7 @@ register: cm_add_contract_filter_both_way - name: Add Contract filter to both-way(normal_mode) - mso_schema_template_contract_filter: + cisco.mso.mso_schema_template_contract_filter: <<: *contract_present contract: Contract1 contract_filter_type: both-way @@ -335,7 +335,7 @@ register: nm_add_contract_filter_both_way - name: Verify cm_change_contract_filter_both_way - assert: + ansible.builtin.assert: that: - cm_add_contract_filter_both_way is changed - nm_add_contract_filter_both_way is changed @@ -352,7 +352,7 @@ - cm_add_contract_filter_both_way.current.filterType == "both-way" - name: Change Contract type one_way Filter type consumer-to-provider(normal_mode) - mso_schema_template_contract_filter: + cisco.mso.mso_schema_template_contract_filter: <<: *contract_present contract: Contract5 contract_filter_type: one-way @@ -362,7 +362,7 @@ register: nm_one_way_and_consumer_to_provider - name: Verify nm_one_way_and_consumer_to_provider - assert: + ansible.builtin.assert: that: - nm_one_way_and_consumer_to_provider is changed - nm_one_way_and_consumer_to_provider.previous == {} @@ -372,7 +372,7 @@ - nm_one_way_and_consumer_to_provider.current.filterType == "consumer-to-provider" - name: Change Contract type one_way Filter type provider-to-consumer(normal_mode) - mso_schema_template_contract_filter: + cisco.mso.mso_schema_template_contract_filter: <<: *contract_present contract: Contract-6 contract_filter_type: one-way @@ -382,7 +382,7 @@ register: nm_one_way_and_provider_to_consumer - name: Verify nm create contract filter with different type - assert: + ansible.builtin.assert: that: - nm_one_way_and_provider_to_consumer is changed - nm_one_way_and_provider_to_consumer.current.contractFilterType == "oneWay" @@ -392,7 +392,7 @@ # change contract display name - name: change contract display name - mso_schema_template_contract_filter: + cisco.mso.mso_schema_template_contract_filter: <<: *contract_present contract: Contract4 filter: Filter1 @@ -401,7 +401,7 @@ register: nm_change_display_name - name: Verify nm_change_display_name - assert: + ansible.builtin.assert: that: - nm_change_display_name is changed - nm_change_display_name.current.displayName == "newDisplayContract4" @@ -409,7 +409,7 @@ # change contract filter_directives to log - name: change contract filter_directives to log(check_mode) - mso_schema_template_contract_filter: + cisco.mso.mso_schema_template_contract_filter: <<: *contract_present contract: Contract4 filter: Filter1 @@ -419,7 +419,7 @@ register: cm_change_filter_directives_log - name: change contract filter_directives to log(normal_mode) - mso_schema_template_contract_filter: + cisco.mso.mso_schema_template_contract_filter: <<: *contract_present contract: Contract4 filter: Filter1 @@ -428,7 +428,7 @@ register: nm_change_filter_directives_log - name: Verify change_contract_filter_directives to log - assert: + ansible.builtin.assert: that: - cm_change_filter_directives_log is changed - nm_change_filter_directives_log is changed @@ -438,7 +438,7 @@ - nm_change_filter_directives_log.current.directives[0] == "log" - name: change contract filter_directives to log and none(normal_mode) - mso_schema_template_contract_filter: + cisco.mso.mso_schema_template_contract_filter: <<: *contract_present contract: Contract4 filter: Filter1 @@ -447,7 +447,7 @@ register: nm_change_filter_directives_log_and_none - name: Verify nm_change_filter_directives_log_and_none - assert: + ansible.builtin.assert: that: - nm_change_filter_directives_log_and_none is changed - nm_change_filter_directives_log_and_none.previous.directives[0] == "log" @@ -455,7 +455,7 @@ # change contract filter_directives to policy_compression - name: change contract filter_directives to policy_compression (check_mode) - mso_schema_template_contract_filter: + cisco.mso.mso_schema_template_contract_filter: <<: *contract_present contract: Contract4 filter: Filter1 @@ -465,7 +465,7 @@ register: cm_change_filter_directives_pc - name: change contract filter_directives to policy_compression (normal_mode) - mso_schema_template_contract_filter: + cisco.mso.mso_schema_template_contract_filter: <<: *contract_present contract: Contract4 filter: Filter1 @@ -474,7 +474,7 @@ register: nm_change_filter_directives_pc - name: Verify change_contract_filter_directives to pc - assert: + ansible.builtin.assert: that: - cm_change_filter_directives_pc is changed - nm_change_filter_directives_pc is changed @@ -484,7 +484,7 @@ - nm_change_filter_directives_pc.current.directives[0] == "no_stats" - name: change contract filter_directives to log, none, policy compression (normal_mode) - mso_schema_template_contract_filter: + cisco.mso.mso_schema_template_contract_filter: <<: *contract_present contract: Contract4 filter: Filter1 @@ -493,14 +493,14 @@ register: nm_change_filter_directives_log_and_none_pc - name: Verify nm_change_filter_directives_log_and_none_pc - assert: + ansible.builtin.assert: that: - nm_change_filter_directives_log_and_none_pc is changed - nm_change_filter_directives_log_and_none_pc.previous.directives[0] == "no_stats" - nm_change_filter_directives_log_and_none_pc.current.directives == ["log", "none", "no_stats"] - name: Change Contract1 scope to global (normal mode) - mso_schema_template_contract_filter: + cisco.mso.mso_schema_template_contract_filter: <<: *contract_present contract: Contract1 contract_scope: global @@ -508,14 +508,14 @@ register: nm_change_contract_scope_global - name: Verify nm_change_contract_scope_global - assert: + ansible.builtin.assert: that: - nm_change_contract_scope_global is changed - nm_change_contract_scope_global.current.contractScope == "global" - nm_change_contract_scope_global.previous.contractScope == "context" - name: Change Contract1 scope to tenant(normal mode) - mso_schema_template_contract_filter: + cisco.mso.mso_schema_template_contract_filter: <<: *contract_present contract: Contract1 contract_scope: tenant @@ -523,14 +523,14 @@ register: nm_change_contract_scope_tenant - name: Verify nm_change_contract_scope_tenant - assert: + ansible.builtin.assert: that: - nm_change_contract_scope_tenant is changed - nm_change_contract_scope_tenant.previous.contractScope == "global" - nm_change_contract_scope_tenant.current.contractScope == "tenant" - name: Change Contract1 scope application_profile(normal mode) - mso_schema_template_contract_filter: + cisco.mso.mso_schema_template_contract_filter: <<: *contract_present contract: Contract1 contract_scope: application-profile @@ -538,14 +538,14 @@ register: nm_change_contract_scope_application_profile - name: Verify nm_change_contract_scope_application_profile - assert: + ansible.builtin.assert: that: - nm_change_contract_scope_application_profile is changed - nm_change_contract_scope_application_profile.previous.contractScope == "tenant" - nm_change_contract_scope_application_profile.current.contractScope == "application-profile" - name: Change Contract1 scope to vrf(normal mode) - mso_schema_template_contract_filter: + cisco.mso.mso_schema_template_contract_filter: <<: *contract_present contract: Contract1 contract_scope: vrf @@ -553,28 +553,28 @@ register: nm_change_contract_scope_vrf - name: Verify nm_change_contract_scope_vrf - assert: + ansible.builtin.assert: that: - nm_change_contract_scope_vrf is changed - nm_change_contract_scope_vrf.current.contractScope == "context" - nm_change_contract_scope_vrf.previous.contractScope == "application-profile" - name: Change Contract1 scope to default(normal mode) - mso_schema_template_contract_filter: + cisco.mso.mso_schema_template_contract_filter: <<: *contract_present contract: Contract1 state: present register: nm_change_contract_scope_default - name: Verify nm_change_contract_scope_default - assert: + ansible.builtin.assert: that: - nm_change_contract_scope_default is not changed - nm_change_contract_scope_default.current.contractScope == "context" - nm_change_contract_scope_default.previous.contractScope == "context" - name: Change Contract1 description (normal mode) - mso_schema_template_contract_filter: + cisco.mso.mso_schema_template_contract_filter: <<: *contract_present contract: Contract1 description: changed description @@ -583,7 +583,7 @@ when: version.current.version is version('3.3', '>=') - name: Verify nm_change_contract_description - assert: + ansible.builtin.assert: that: - nm_change_contract_description is changed - nm_change_contract_description.current.description == "changed description" @@ -591,7 +591,7 @@ when: version.current.version is version('3.3', '>=') - name: Change Contract1 description empty (normal mode) - mso_schema_template_contract_filter: + cisco.mso.mso_schema_template_contract_filter: <<: *contract_present contract: Contract1 description: "" @@ -600,7 +600,7 @@ when: version.current.version is version('3.3', '>=') - name: Verify nm_change_contract_description_empty - assert: + ansible.builtin.assert: that: - nm_change_contract_description_empty is changed - nm_change_contract_description_empty.current.description == "" @@ -608,7 +608,7 @@ when: version.current.version is version('3.3', '>=') - name: Change Contract1 qos_level (normal mode) - mso_schema_template_contract_filter: + cisco.mso.mso_schema_template_contract_filter: <<: *contract_present contract: Contract1 qos_level: level1 @@ -617,14 +617,14 @@ when: version.current.version is version('3.3', '>=') - name: Verify nm_change_contract_qos_level - assert: + ansible.builtin.assert: that: - nm_change_contract_qos is changed - nm_change_contract_qos.current.prio == "level1" when: version.current.version is version('3.3', '>=') - name: Change Contract1 qos_level unspecified (normal mode) - mso_schema_template_contract_filter: + cisco.mso.mso_schema_template_contract_filter: <<: *contract_present contract: Contract1 qos_level: unspecified @@ -633,7 +633,7 @@ when: version.current.version is version('3.3', '>=') - name: Verify nm_change_contract_qos_level_unspecified - assert: + ansible.builtin.assert: that: - nm_change_contract_qos_unspecified is changed - nm_change_contract_qos_unspecified.current.prio == "unspecified" @@ -641,7 +641,7 @@ when: version.current.version is version('3.3', '>=') - name: Ensure contract filter_type set to both-way (normal mode) - mso_schema_template_contract_filter: + cisco.mso.mso_schema_template_contract_filter: <<: *contract_present contract: Contract1 filter: Filter1 @@ -651,7 +651,7 @@ when: version.current.version is version('3.3', '>=') - name: Verify nm_contract_filter_both_way - assert: + ansible.builtin.assert: that: - nm_contract_filter_both_way.current.contractFilterType == "bothWay" - nm_contract_filter_both_way.current.filterType == "both-way" @@ -660,7 +660,7 @@ - name: Change contract filter_type set to one-way with consumer-to-provider (normal mode) # Test to check that filter type cannot be changed from two-way to one-way type # changed behaviour due to error handling is now handled in code - mso_schema_template_contract_filter: + cisco.mso.mso_schema_template_contract_filter: <<: *contract_present contract: Contract1 filter: Filter1 @@ -671,14 +671,14 @@ when: version.current.version is version('3.3', '>=') - name: Verify nm_contract_filter_consumer_to_provider - assert: + ansible.builtin.assert: that: - nm_contract_filter_consumer_to_provider.msg == "Current filter type 'bothWay' for contract 'Contract1' is not allowed to change to 'oneWay'." when: version.current.version is version('3.3', '>=') # QUERY ALL CONTRACT - name: Query Contract1 filters (check_mode) - mso_schema_template_contract_filter: &Contract_query + cisco.mso.mso_schema_template_contract_filter: &Contract_query host: '{{ mso_hostname }}' username: '{{ mso_username }}' password: '{{ mso_password }}' @@ -694,19 +694,19 @@ register: cm_contract1_query_result - name: Query Contract1 filters (normal_mode) - mso_schema_template_contract_filter: + cisco.mso.mso_schema_template_contract_filter: <<: *Contract_query register: nm_contract1_query_result - name: Verify query_contract_1 - assert: + ansible.builtin.assert: that: - cm_contract1_query_result is not changed - nm_contract1_query_result is not changed - cm_contract1_query_result.current | length == nm_contract1_query_result.current | length == 2 - name: Query Contract2 filters (normal_mode) - mso_schema_template_contract_filter: + cisco.mso.mso_schema_template_contract_filter: <<: *Contract_query schema: '{{ mso_schema | default("ansible_test") }}' template: Template 2 @@ -715,7 +715,7 @@ register: nm_contract2_query_result - name: Query Contract3 filters (normal_mode) - mso_schema_template_contract_filter: + cisco.mso.mso_schema_template_contract_filter: <<: *Contract_query schema: '{{ mso_schema | default("ansible_test") }}_2' template: Template 3 @@ -723,7 +723,7 @@ register: nm_contract3_query_result - name: Query Contract4 filters (normal_mode) - mso_schema_template_contract_filter: + cisco.mso.mso_schema_template_contract_filter: <<: *Contract_query schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -731,7 +731,7 @@ register: nm_contract4_query_result - name: Query Contract5 filters (normal_mode) - mso_schema_template_contract_filter: + cisco.mso.mso_schema_template_contract_filter: <<: *Contract_query schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -741,7 +741,7 @@ register: nm_contract5_query_result - name: Query Contract-6 filters (normal_mode) - mso_schema_template_contract_filter: + cisco.mso.mso_schema_template_contract_filter: <<: *Contract_query schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -751,7 +751,7 @@ register: nm_contract6_query_result - name: Verify query_contract - assert: + ansible.builtin.assert: that: - nm_contract2_query_result is not changed - nm_contract3_query_result is not changed @@ -764,7 +764,7 @@ # QUERY A SPECIFIC CONTRACT FILTER - name: Query Contract1 Filter1 (check_mode) - mso_schema_template_contract_filter: &Contract_filter_query + cisco.mso.mso_schema_template_contract_filter: &Contract_filter_query host: '{{ mso_hostname }}' username: '{{ mso_username }}' password: '{{ mso_password }}' @@ -781,7 +781,7 @@ register: cm_contract1_filter1_query_result - name: Query Contract1 Filter4 (normal_mode) - mso_schema_template_contract_filter: + cisco.mso.mso_schema_template_contract_filter: <<: *Contract_filter_query schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -791,7 +791,7 @@ register: nm_contract1_filter4_query_result - name: Query Contract2 Filter1 (normal_mode) - mso_schema_template_contract_filter: + cisco.mso.mso_schema_template_contract_filter: <<: *Contract_filter_query schema: '{{ mso_schema | default("ansible_test") }}' template: Template 2 @@ -802,7 +802,7 @@ register: nm_contract2_filter1_query_result - name: Query Contract3 Filter1 (normal_mode) - mso_schema_template_contract_filter: + cisco.mso.mso_schema_template_contract_filter: <<: *Contract_filter_query schema: '{{ mso_schema | default("ansible_test") }}_2' template: Template 3 @@ -814,7 +814,7 @@ register: nm_contract3_filter1_query_result - name: Query Contract4 Filter1 (normal_mode) - mso_schema_template_contract_filter: + cisco.mso.mso_schema_template_contract_filter: <<: *Contract_filter_query schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -824,7 +824,7 @@ register: nm_contract4_filter1_query_result - name: Query Contract5 Filter5 (normal_mode) - mso_schema_template_contract_filter: + cisco.mso.mso_schema_template_contract_filter: <<: *Contract_filter_query schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -836,7 +836,7 @@ register: nm_contract5_filter5_query_result - name: Query Contract-6 Filter-6 (normal_mode) - mso_schema_template_contract_filter: + cisco.mso.mso_schema_template_contract_filter: <<: *Contract_filter_query schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -848,7 +848,7 @@ register: nm_contract6_filter6_query_result - name: Verify contract1_filter1_query_result - assert: + ansible.builtin.assert: that: - cm_contract1_filter1_query_result is not changed - nm_contract1_filter4_query_result is not changed @@ -860,7 +860,7 @@ # REMOVE CONTRACT Filter - name: Remove contract1 filter1 (check_mode) - mso_schema_template_contract_filter: &contract1_filter1_absent + cisco.mso.mso_schema_template_contract_filter: &contract1_filter1_absent host: '{{ mso_hostname }}' username: '{{ mso_username }}' password: '{{ mso_password }}' @@ -877,7 +877,7 @@ register: cm_remove_contract1_filter1 - name: Verify cm_remove_contract1_filter1 - assert: + ansible.builtin.assert: that: - cm_remove_contract1_filter1 is changed - cm_remove_contract1_filter1.current == {} @@ -885,12 +885,12 @@ - cm_remove_contract1_filter1.previous.filterRef.templateName == "Template1" - name: Remove contract1 filter1 (normal_mode) - mso_schema_template_contract_filter: + cisco.mso.mso_schema_template_contract_filter: <<: *contract1_filter1_absent register: nm_remove_contract1_filter1 - name: Verify nm_remove_contract1_filter1 - assert: + ansible.builtin.assert: that: - nm_remove_contract1_filter1 is changed - nm_remove_contract1_filter1.current == {} @@ -898,38 +898,38 @@ - nm_remove_contract1_filter1.previous.filterRef.templateName == "Template1" - name: Remove contract1 filter1 again (check_mode) - mso_schema_template_contract_filter: + cisco.mso.mso_schema_template_contract_filter: <<: *contract1_filter1_absent check_mode: true register: cm_remove_contract1_filter1_again - name: Verify cm_remove_contract1_filter1_again - assert: + ansible.builtin.assert: that: - cm_remove_contract1_filter1_again is not changed - cm_remove_contract1_filter1_again.current == {} - cm_remove_contract1_filter1_again.previous == {} - name: Remove contract1 filter1 again (normal_mode) - mso_schema_template_contract_filter: + cisco.mso.mso_schema_template_contract_filter: <<: *contract1_filter1_absent register: nm_remove_contract1_filter1_again - name: Verify nm_remove_contract1_filter1_again - assert: + ansible.builtin.assert: that: - nm_remove_contract1_filter1_again is not changed - nm_remove_contract1_filter1_again.current == {} - nm_remove_contract1_filter1_again.previous == {} - name: Remove contract1 filter4 (normal_mode) - mso_schema_template_contract_filter: + cisco.mso.mso_schema_template_contract_filter: <<: *contract1_filter1_absent filter: Filter4 register: nm_remove_contract1_filter4 - name: Verify nm_remove_contract1_filter4 - assert: + ansible.builtin.assert: that: - nm_remove_contract1_filter4 is changed - nm_remove_contract1_filter4.current == {} @@ -937,20 +937,20 @@ - nm_remove_contract1_filter4.previous.filterRef.templateName == "Template1" - name: Remove contract1 filter4 again (normal_mode) - mso_schema_template_contract_filter: + cisco.mso.mso_schema_template_contract_filter: <<: *contract1_filter1_absent filter: Filter4 register: nm_remove_contract1_filter4_again - name: Verify nm_remove_contract1_filter4_again - assert: + ansible.builtin.assert: that: - nm_remove_contract1_filter4_again is not changed - nm_remove_contract1_filter4_again.previous == nm_remove_contract1_filter4_again.current == {} # QUERY NON-EXISTING FILTER - name: Query non-existing filter (check_mode) - mso_schema_template_contract_filter: + cisco.mso.mso_schema_template_contract_filter: <<: *Contract_query schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -961,7 +961,7 @@ register: cm_query_non_filter - name: Query non-existing filter (normal_mode) - mso_schema_template_contract_filter: + cisco.mso.mso_schema_template_contract_filter: <<: *Contract_query schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -971,13 +971,13 @@ register: nm_query_non_filter - name: Verify query_non_filter - assert: + ansible.builtin.assert: that: - cm_query_non_filter is not changed - nm_query_non_filter is not changed - name: Add contract (for version greater than 3.3) - mso_schema_template_contract_filter: + cisco.mso.mso_schema_template_contract_filter: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -992,7 +992,7 @@ when: version.current.version is version('3.3', '>=') - name: Verify Add contract for version greater than 3.3 - assert: + ansible.builtin.assert: that: - add_contract is changed - add_contract.current.action == "deny" @@ -1001,7 +1001,7 @@ # # QUERY NON-EXISTING CONTRACT - name: Query non-existing contract (check_mode) - mso_schema_template_contract_filter: + cisco.mso.mso_schema_template_contract_filter: <<: *Contract_query schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -1011,7 +1011,7 @@ register: cm_query_non_contract - name: Query non-existing contract (normal_mode) - mso_schema_template_contract_filter: + cisco.mso.mso_schema_template_contract_filter: <<: *Contract_query schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -1020,7 +1020,7 @@ register: nm_query_non_contract - name: Verify query_non_contract - assert: + ansible.builtin.assert: that: - cm_query_non_contract is not changed - nm_query_non_contract is not changed @@ -1029,14 +1029,14 @@ when: version.current.version is version('3.3', '<') - name: Verify query_non_contract when version greater than 3.3 - assert: + ansible.builtin.assert: that: - cm_query_non_contract.msg == nm_query_non_contract.msg == "Provided contract 'non-existing-contract' does not exist. Existing contracts{{':'}} Contract4, Contract5, Contract-6, Contract1" when: version.current.version is version('3.3', '>=') # USE A NON-EXISTING SCHEMA - name: Non-existing schema for contrct (check_mode) - mso_schema_template_contract_filter: + cisco.mso.mso_schema_template_contract_filter: <<: *Contract_query template: Template 1 schema: non-existing-schema @@ -1045,7 +1045,7 @@ register: cm_query_non_schema - name: Non-existing schema for contrct (normal_mode) - mso_schema_template_contract_filter: + cisco.mso.mso_schema_template_contract_filter: <<: *Contract_query template: Template 1 schema: non-existing-schema @@ -1054,7 +1054,7 @@ - name: Verify non_existing_schema - assert: + ansible.builtin.assert: that: - cm_query_non_schema is not changed - nm_query_non_schema is not changed @@ -1063,7 +1063,7 @@ # USE A NON-EXISTING TEMPLATE - name: Non-existing template for contract (check_mode) - mso_schema_template_contract_filter: + cisco.mso.mso_schema_template_contract_filter: <<: *Contract_query schema: '{{ mso_schema | default("ansible_test") }}' template: non-existing-template @@ -1072,7 +1072,7 @@ register: cm_query_non_template - name: Non-existing template for contract (normal_mode) - mso_schema_template_contract_filter: + cisco.mso.mso_schema_template_contract_filter: <<: *Contract_query schema: '{{ mso_schema | default("ansible_test") }}' template: non-existing-template @@ -1080,7 +1080,7 @@ register: nm_query_non_template - name: Verify non_existing_template - assert: + ansible.builtin.assert: that: - cm_query_non_template is not changed - nm_query_non_template is not changed diff --git a/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_contract_service_graph/tasks/main.yml b/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_contract_service_graph/tasks/main.yml index 8bc3ce625..6c39668b6 100644 --- a/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_contract_service_graph/tasks/main.yml +++ b/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_contract_service_graph/tasks/main.yml @@ -4,14 +4,14 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI MultiSite host, username and password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: mso_hostname, mso_username and mso_password.' when: mso_hostname is not defined or mso_username is not defined or mso_password is not defined # CLEAN ENVIRONMENT - name: Set vars - set_fact: + ansible.builtin.set_fact: mso_info: &mso_info host: '{{ mso_hostname }}' username: '{{ mso_username }}' @@ -22,19 +22,19 @@ output_level: '{{ mso_output_level | default("info") }}' - name: Remove schema 2 - mso_schema: + cisco.mso.mso_schema: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}_2' state: absent - name: Remove schema 1 - mso_schema: + cisco.mso.mso_schema: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' state: absent - name: Ensure tenant ansible_test exist - mso_tenant: + cisco.mso.mso_tenant: <<: *mso_info tenant: ansible_test users: @@ -42,7 +42,7 @@ state: present - name: Ensure schema 1 with Template 1 exist - mso_schema_template: &schema_present + cisco.mso.mso_schema_template: &schema_present <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' tenant: ansible_test @@ -50,13 +50,13 @@ state: present - name: Ensure schema 1 with Template 2 exist - mso_schema_template: + cisco.mso.mso_schema_template: <<: *schema_present template: Template 2 state: present - name: Ensure schema 2 with Template 1 exist - mso_schema_template: + cisco.mso.mso_schema_template: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}_2' tenant: ansible_test @@ -89,7 +89,7 @@ state: present - name: Ensure Contract_1 contract exist - mso_schema_template_contract_filter: &contract_present + cisco.mso.mso_schema_template_contract_filter: &contract_present <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -98,7 +98,7 @@ state: present - name: Ensure Contract_2 contract exist - mso_schema_template_contract_filter: + cisco.mso.mso_schema_template_contract_filter: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}_2' template: Template 1 @@ -131,7 +131,7 @@ state: present - name: Ensure VRF_1 vrf exist - mso_schema_template_vrf: + cisco.mso.mso_schema_template_vrf: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -140,7 +140,7 @@ state: present - name: Ensure BD_1 bd exist - mso_schema_template_bd: &bd_present + cisco.mso.mso_schema_template_bd: &bd_present <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -150,13 +150,13 @@ state: present - name: Ensure BD_2 bd exist - mso_schema_template_bd: + cisco.mso.mso_schema_template_bd: <<: *bd_present bd: BD2 state: present - name: Ensure BD_3 bd exist - mso_schema_template_bd: + cisco.mso.mso_schema_template_bd: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}_2' template: Template 1 @@ -167,7 +167,7 @@ state: present - name: Ensure AP1 in Template 1 exists - mso_schema_template_anp: + cisco.mso.mso_schema_template_anp: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -175,7 +175,7 @@ state: present - name: Ensure AP1 in Template 1 exists - mso_schema_template_anp: + cisco.mso.mso_schema_template_anp: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}_2' template: Template 1 @@ -183,7 +183,7 @@ state: present - name: Ensure EPG1 in AP1 in Template 1 exists - mso_schema_template_anp_epg: + cisco.mso.mso_schema_template_anp_epg: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -194,7 +194,7 @@ state: present - name: Ensure EPG2 in AP1 in Template 1 exists - mso_schema_template_anp_epg: + cisco.mso.mso_schema_template_anp_epg: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}_2' template: Template 1 @@ -205,7 +205,7 @@ state: present - name: Add Contract1 to EPG1 provider - mso_schema_template_anp_epg_contract: + cisco.mso.mso_schema_template_anp_epg_contract: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -217,7 +217,7 @@ state: present - name: Add Contract1 to EPG1 consumer - mso_schema_template_anp_epg_contract: + cisco.mso.mso_schema_template_anp_epg_contract: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -229,7 +229,7 @@ state: present - name: Add Contract2 to EPG2 provider - mso_schema_template_anp_epg_contract: + cisco.mso.mso_schema_template_anp_epg_contract: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}_2' template: Template 1 @@ -241,7 +241,7 @@ state: present - name: Add Contract2 to EPG2 consumer - mso_schema_template_anp_epg_contract: + cisco.mso.mso_schema_template_anp_epg_contract: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}_2' template: Template 1 @@ -255,7 +255,7 @@ # TESTS - name: Add service graph 1 to Contract1 (check_mode) - mso_schema_template_contract_service_graph: + cisco.mso.mso_schema_template_contract_service_graph: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -271,7 +271,7 @@ register: cm_add_sg1_to_c1 - name: Add service graph 1 to Contract1 - mso_schema_template_contract_service_graph: + cisco.mso.mso_schema_template_contract_service_graph: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -286,7 +286,7 @@ register: nm_add_sg1_to_c1 - name: Verify service graph 1 is added to Contract1 - assert: + ansible.builtin.assert: that: - cm_add_sg1_to_c1 is changed - cm_add_sg1_to_c1.previous == {} @@ -312,7 +312,7 @@ - nm_add_sg1_to_c1.current.serviceNodesRelationship.1.serviceNodeRef.serviceNodeName == "load-balancer" - name: Add service graph 1 to Contract1 again (check_mode) - mso_schema_template_contract_service_graph: + cisco.mso.mso_schema_template_contract_service_graph: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -328,7 +328,7 @@ register: cm_add_sg1_to_c1_again - name: Add service graph 1 to Contract1 again - mso_schema_template_contract_service_graph: + cisco.mso.mso_schema_template_contract_service_graph: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -343,7 +343,7 @@ register: nm_add_sg1_to_c1_again - name: Verify service graph 1 is added to Contract1 again - assert: + ansible.builtin.assert: that: - cm_add_sg1_to_c1_again is not changed - cm_add_sg1_to_c1_again.previous.serviceGraphRef.serviceGraphName == "SG1" @@ -367,7 +367,7 @@ - nm_add_sg1_to_c1_again.previous.serviceNodesRelationship.1.serviceNodeRef.serviceNodeName == "load-balancer" - name: Change service graph 1 node to Contract1 (check_mode) - mso_schema_template_contract_service_graph: + cisco.mso.mso_schema_template_contract_service_graph: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -383,7 +383,7 @@ register: cm_change_sg1_to_c1 - name: Change service graph 1 node to Contract1 - mso_schema_template_contract_service_graph: + cisco.mso.mso_schema_template_contract_service_graph: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -398,7 +398,7 @@ register: nm_change_sg1_to_c1 - name: Verify service graph 1 is added to Contract1 again - assert: + ansible.builtin.assert: that: - cm_change_sg1_to_c1 is changed - cm_change_sg1_to_c1.current.serviceNodesRelationship.0.consumerConnector.bdRef.bdName == "BD2" @@ -420,7 +420,7 @@ - nm_change_sg1_to_c1.previous.serviceNodesRelationship.0.providerConnector.connectorType == "general" - name: Query service graph 1 to Contract1 (check_mode) - mso_schema_template_contract_service_graph: + cisco.mso.mso_schema_template_contract_service_graph: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -430,7 +430,7 @@ register: cm_query_sg1_to_c1 - name: Query service graph 1 to Contract1 - mso_schema_template_contract_service_graph: + cisco.mso.mso_schema_template_contract_service_graph: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -440,7 +440,7 @@ register: nm_query_sg1_to_c1 - name: Verify queried service graph 1 - assert: + ansible.builtin.assert: that: - cm_query_sg1_to_c1 is not changed - cm_query_sg1_to_c1.current.serviceNodesRelationship.0.consumerConnector.bdRef.bdName == "BD2" @@ -458,7 +458,7 @@ - nm_query_sg1_to_c1.current.serviceNodesRelationship.0.providerConnector.connectorType == "general" - name: Remove service graph 1 from Contract1 (check_mode) - mso_schema_template_contract_service_graph: + cisco.mso.mso_schema_template_contract_service_graph: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -469,7 +469,7 @@ register: cm_remove_sg1_from_c1 - name: Remove service graph 1 from Contract1 - mso_schema_template_contract_service_graph: + cisco.mso.mso_schema_template_contract_service_graph: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -479,7 +479,7 @@ register: nm_remove_sg1_from_c1 - name: Verify service graph 1 is removed from Contract1 - assert: + ansible.builtin.assert: that: - cm_remove_sg1_from_c1 is changed - cm_remove_sg1_from_c1.current == {} @@ -505,7 +505,7 @@ - nm_remove_sg1_from_c1.previous.serviceNodesRelationship.1.serviceNodeRef.serviceNodeName == "load-balancer" - name: Add service graph 2 to Contract2 with BD in other schema (check_mode) - mso_schema_template_contract_service_graph: + cisco.mso.mso_schema_template_contract_service_graph: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}_2' template: Template 1 @@ -525,7 +525,7 @@ register: cm_add_sg2_to_c2 - name: Add service graph 2 to Contract2 with BD in other schema - mso_schema_template_contract_service_graph: + cisco.mso.mso_schema_template_contract_service_graph: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}_2' template: Template 1 @@ -544,7 +544,7 @@ register: nm_add_sg2_to_c2 - name: Verify service graph 2 is added to Contract2 - assert: + ansible.builtin.assert: that: - cm_add_sg2_to_c2 is changed - cm_add_sg2_to_c2.previous == {} @@ -570,7 +570,7 @@ - nm_add_sg2_to_c2.current.serviceNodesRelationship.1.serviceNodeRef.serviceNodeName == "load-balancer" - name: Query service graph 2 to Contract2 (check_mode) - mso_schema_template_contract_service_graph: + cisco.mso.mso_schema_template_contract_service_graph: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}_2' template: Template 1 @@ -580,7 +580,7 @@ register: cm_query_sg2_to_c2 - name: Query service graph 2 to Contract2 - mso_schema_template_contract_service_graph: + cisco.mso.mso_schema_template_contract_service_graph: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}_2' template: Template 1 @@ -590,7 +590,7 @@ register: nm_query_sg2_to_c2 - name: Verify queried service graph 1 - assert: + ansible.builtin.assert: that: - cm_query_sg2_to_c2 is not changed - cm_query_sg2_to_c2.current.serviceNodesRelationship.0.consumerConnector.bdRef.bdName == "BD1" @@ -612,7 +612,7 @@ # NOT EXISTING INPUT - name: Not existing template provided for absent - mso_schema_template_contract_service_graph: + cisco.mso.mso_schema_template_contract_service_graph: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template False @@ -623,7 +623,7 @@ register: not_existing_template_input_absent - name: Not existing contract provided for absent - mso_schema_template_contract_service_graph: + cisco.mso.mso_schema_template_contract_service_graph: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -634,7 +634,7 @@ register: not_existing_contract_input_absent - name: Not existing service graph provided for absent - mso_schema_template_contract_service_graph: + cisco.mso.mso_schema_template_contract_service_graph: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -644,7 +644,7 @@ register: not_existing_service_graph_input_absent - name: Not existing service graph provided for query - mso_schema_template_contract_service_graph: + cisco.mso.mso_schema_template_contract_service_graph: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -654,7 +654,7 @@ register: not_existing_service_graph_input_query - name: Not existing template provided for present - mso_schema_template_contract_service_graph: + cisco.mso.mso_schema_template_contract_service_graph: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -671,7 +671,7 @@ register: not_existing_template_input_present - name: Not existing service graph provided for present - mso_schema_template_contract_service_graph: + cisco.mso.mso_schema_template_contract_service_graph: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -688,7 +688,7 @@ register: not_existing_service_graph_input_present - name: Verify non_existing_input - assert: + ansible.builtin.assert: that: - not_existing_template_input_absent is not changed - not_existing_template_input_absent.msg.startswith("Provided template") @@ -704,7 +704,7 @@ # False input - name: False service graph node amount provided ( less than 2 as provided in SG1 config ) - mso_schema_template_contract_service_graph: + cisco.mso.mso_schema_template_contract_service_graph: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -718,7 +718,7 @@ register: nm_false_sg1_to_c1_less_than_2 - name: False service graph node amount provided ( more than 2 as provided in SG1 config ) - mso_schema_template_contract_service_graph: + cisco.mso.mso_schema_template_contract_service_graph: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -736,7 +736,7 @@ register: nm_false_sg1_to_c1_more_than_2 - name: Verify false_sg1_to_c1 - assert: + ansible.builtin.assert: that: - nm_false_sg1_to_c1_less_than_2 is not changed - nm_false_sg1_to_c1_less_than_2.msg.startswith("Not enough service nodes defined") diff --git a/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_deploy/tasks/main.yml b/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_deploy/tasks/main.yml index 58f043256..5e9a46801 100644 --- a/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_deploy/tasks/main.yml +++ b/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_deploy/tasks/main.yml @@ -4,7 +4,7 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI MultiSite host, username and password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: mso_hostname, mso_username and mso_password.' when: mso_hostname is not defined or mso_username is not defined or mso_password is not defined diff --git a/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_deploy_status/tasks/main.yml b/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_deploy_status/tasks/main.yml index fce5cf8e8..34607bec5 100644 --- a/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_deploy_status/tasks/main.yml +++ b/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_deploy_status/tasks/main.yml @@ -4,14 +4,14 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3[0].txt) - name: Test that we have an ACI MultiSite host, username and password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: mso_hostname, mso_username and mso_password.' when: mso_hostname is not defined or mso_username is not defined or mso_password is not defined # CLEAN ENVIRONMENT - name: Set vars - set_fact: + ansible.builtin.set_fact: mso_info: &mso_info host: '{{ mso_hostname }}' username: '{{ mso_username }}' @@ -22,13 +22,13 @@ output_level: '{{ mso_output_level | default("info") }}' - name: Query MSO version - mso_version: + cisco.mso.mso_version: <<: *mso_info state: query register: version - name: Ensure site exist - mso_site: &site_present + cisco.mso.mso_site: &site_present <<: *mso_info site: '{{ mso_site | default("ansible_test") }}' apic_username: '{{ apic_username }}' @@ -39,7 +39,7 @@ state: present - name: Ensure aws site exists - mso_site: + cisco.mso.mso_site: <<: *mso_info site: 'aws_{{ mso_site | default("ansible_test") }}' apic_username: '{{ aws_apic_username }}' @@ -50,7 +50,7 @@ state: present - name: Undeploy templates if deployed to clean the environment before ndo 4.0 - mso_schema_template_deploy: + cisco.mso.mso_schema_template_deploy: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: "{{ item }}" @@ -76,7 +76,7 @@ # when: version.current.version is version('4.0', '>=') - name: Remove schemas - mso_schema: + cisco.mso.mso_schema: <<: *mso_info schema: '{{ item }}' state: absent @@ -85,7 +85,7 @@ - '{{ mso_schema | default("ansible_test") }}' - name: Ensure tenant ansible_test exists - mso_tenant: + cisco.mso.mso_tenant: <<: *mso_info tenant: ansible_test users: @@ -95,7 +95,7 @@ state: present - name: Ensure schema 1 with Template 1, Template 2 - mso_schema_template: + cisco.mso.mso_schema_template: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' tenant: ansible_test @@ -106,7 +106,7 @@ - Template 2 - name: Add a new site to a schema with Template 1, Template 2 - mso_schema_site: + cisco.mso.mso_schema_site: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -117,7 +117,7 @@ - Template 2 - name: Ensure VRF1 exists on Template1 - mso_schema_template_vrf: + cisco.mso.mso_schema_template_vrf: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -125,7 +125,7 @@ state: present - name: Ensure VRF2 exists on Template2 - mso_schema_template_vrf: + cisco.mso.mso_schema_template_vrf: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 2 @@ -133,7 +133,7 @@ state: present - name: Ensure ANP exists - mso_schema_template_anp: + cisco.mso.mso_schema_template_anp: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -141,7 +141,7 @@ state: present - name: Ensure ANP2 exists - mso_schema_template_anp: + cisco.mso.mso_schema_template_anp: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 2 @@ -149,7 +149,7 @@ state: present - name: Check deployment status of Template 1 - mso_schema_template_deploy_status: + cisco.mso.mso_schema_template_deploy_status: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -157,7 +157,7 @@ register: status1_temp1 - name: Check deployment status of Template 2 - mso_schema_template_deploy_status: + cisco.mso.mso_schema_template_deploy_status: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 2 @@ -165,7 +165,7 @@ register: status1_temp2 - name: Verify status after adding VRFs and ANPs - assert: + ansible.builtin.assert: that: - status1_temp1.current[0].anps[0].state == 'created' - status1_temp1.current[0].vrfs[0].state == 'created' @@ -173,7 +173,7 @@ - status1_temp2.current[0].vrfs[0].state == 'created' - name: Check deployment status by querying site - mso_schema_template_deploy_status: + cisco.mso.mso_schema_template_deploy_status: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -181,7 +181,7 @@ register: status_site - name: Check deployment status by querying site and Template1 - mso_schema_template_deploy_status: + cisco.mso.mso_schema_template_deploy_status: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template1 @@ -190,7 +190,7 @@ register: status_site_temp1 - name: Check deployment status by querying site and Template2 - mso_schema_template_deploy_status: + cisco.mso.mso_schema_template_deploy_status: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template2 @@ -199,7 +199,7 @@ register: status_site_temp2 - name: Verify status after querying site before deployment - assert: + ansible.builtin.assert: that: - status_site.current | length == 2 - status_site_temp1.current.anps[0].state == 'created' @@ -209,7 +209,7 @@ - name: Ensure ansible_test_1 BD exists - mso_schema_template_bd: + cisco.mso.mso_schema_template_bd: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -220,7 +220,7 @@ state: present - name: Ensure ansible_test_2 BD exists - mso_schema_template_bd: + cisco.mso.mso_schema_template_bd: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 2 @@ -231,7 +231,7 @@ state: present - name: Add EPG to Template 1 - mso_schema_template_anp_epg: + cisco.mso.mso_schema_template_anp_epg: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -244,7 +244,7 @@ state: present - name: Add EPG to Template 2 - mso_schema_template_anp_epg: + cisco.mso.mso_schema_template_anp_epg: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 2 @@ -257,7 +257,7 @@ state: present - name: Check deployment status of Template 1 - mso_schema_template_deploy_status: + cisco.mso.mso_schema_template_deploy_status: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -265,7 +265,7 @@ register: status2_temp1 - name: Check deployment status of Template 2 - mso_schema_template_deploy_status: + cisco.mso.mso_schema_template_deploy_status: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 2 @@ -273,7 +273,7 @@ register: status2_temp2 - name: Verify status after adding BDs and EPGs - assert: + ansible.builtin.assert: that: - status2_temp1.current[0].bds[0].state == 'created' - status2_temp1.current[0].anps[0].epgs[0].state == 'created' @@ -281,7 +281,7 @@ - status2_temp2.current[0].anps[0].epgs[0].state == 'created' - name: Add VRF3 exists to Template1 - mso_schema_template_vrf: + cisco.mso.mso_schema_template_vrf: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -289,7 +289,7 @@ state: present - name: Add ansible_test_3 BD - mso_schema_template_bd: + cisco.mso.mso_schema_template_bd: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -300,7 +300,7 @@ state: present - name: Check deployment status of Template 1 - mso_schema_template_deploy_status: + cisco.mso.mso_schema_template_deploy_status: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -308,18 +308,18 @@ register: status3_temp1 - name: Verify status after adding new BD and VRF and changing EPG1 - assert: + ansible.builtin.assert: that: - status3_temp1.current[0].bds[0].state == 'created' - status3_temp1.current[0].vrfs[0].state == 'created' # mso_schema_template_deploy is deprecated in MSO/NDO v4.0+, different api endpoint thus different module -# when new module created, remove block and do execution for each mso_schema_template_deploy tasks +# when new module created, remove block and do execution for each cisco.mso.mso_schema_template_deploy tasks - name: Execute tasks only for MSO version < 4.0 when: version.current.version is version('4.0', '<') block: - name: Deploy templates - mso_schema_template_deploy: + cisco.mso.mso_schema_template_deploy: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: "{{ item }}" @@ -331,7 +331,7 @@ - Template 2 - name: Change EPG - mso_schema_template_anp_epg: + cisco.mso.mso_schema_template_anp_epg: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -344,7 +344,7 @@ state: present - name: Check deployment status of Template 1 - mso_schema_template_deploy_status: + cisco.mso.mso_schema_template_deploy_status: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -352,12 +352,12 @@ register: status_change_temp1 - name: Verify status after changing EPG - assert: + ansible.builtin.assert: that: - status_change_temp1.current[0].anps[0].epgs[0].state == 'modified' - name: Delete ansible_test_1 BD - mso_schema_template_bd: + cisco.mso.mso_schema_template_bd: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -368,7 +368,7 @@ state: absent - name: Delete VRF1 - mso_schema_template_vrf: + cisco.mso.mso_schema_template_vrf: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -376,7 +376,7 @@ state: absent - name: Check deployment status of Template 1 - mso_schema_template_deploy_status: + cisco.mso.mso_schema_template_deploy_status: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -384,7 +384,7 @@ register: status4_temp1 - name: Verify status after deleting VRF1 - assert: + ansible.builtin.assert: that: - status4_temp1.current[0].bds[0].state == 'deleted' - status4_temp1.current[0].vrfs[0].state == 'deleted' @@ -392,7 +392,7 @@ - name: Try deploy and check results block: - name: Deploy templates Template 1 - mso_schema_template_deploy: + cisco.mso.mso_schema_template_deploy: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -400,7 +400,7 @@ state: deploy - name: Check deployment status of Template 1 - mso_schema_template_deploy_status: + cisco.mso.mso_schema_template_deploy_status: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -408,31 +408,31 @@ register: status5_temp1 - name: Increment the retry count - set_fact: + ansible.builtin.set_fact: retry_count: "{{ 0 if retry_count is undefined else retry_count | int + 1 }}" rescue: - - fail: + - ansible.builtin.fail: msg: Status5_temp1 correct value retrieved continuing when: - status5_temp1.current[0] is defined - status5_temp1.current[0].anps == [] - - fail: + - ansible.builtin.fail: msg: Maximum retries of deploy and check group for status5_temp1 reached when: retry_count | int == 10 - - debug: + - ansible.builtin.debug: msg: "Deploy and check group for status5_temp1 failed, let's give it another shot" - name: Reset the retry count - set_fact: + ansible.builtin.set_fact: retry_count: - name: Try deploy and check results block: - name: Deploy templates Template 2 - mso_schema_template_deploy: + cisco.mso.mso_schema_template_deploy: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 2 @@ -440,7 +440,7 @@ state: deploy - name: Check deployment status of Template 2 - mso_schema_template_deploy_status: + cisco.mso.mso_schema_template_deploy_status: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 2 @@ -448,25 +448,25 @@ register: status5_temp2 - name: Increment the retry count - set_fact: + ansible.builtin.set_fact: retry_count: "{{ 0 if retry_count is undefined else retry_count | int + 1 }}" rescue: - - fail: + - ansible.builtin.fail: msg: status5_temp2 correct value retrieved continuing when: - status5_temp2.current[0] is defined - status5_temp2.current[0].anps == [] - - fail: + - ansible.builtin.fail: msg: Maximum retries of deploy and check group for status5_temp2 reached when: retry_count | int == 10 - - debug: + - ansible.builtin.debug: msg: "Deploy and check group for status5_temp2 failed, let's give it another shot" - name: Verify status after deploying Templates to site - assert: + ansible.builtin.assert: that: - status5_temp1.current[0].anps == [] - status5_temp1.current[0].bds == [] @@ -476,19 +476,19 @@ - status5_temp2.current[0].vrfs == [] - name: Check status of all templates - mso_schema_template_deploy_status: + cisco.mso.mso_schema_template_deploy_status: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' state: query register: all_templates - name: Verify all - assert: + ansible.builtin.assert: that: - all_templates.current.policyStates | length == 2 - name: Check deployment status by querying site - mso_schema_template_deploy_status: + cisco.mso.mso_schema_template_deploy_status: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -496,13 +496,13 @@ register: status2_site - name: Reset the retry count - set_fact: + ansible.builtin.set_fact: retry_count: - name: Try deploy and check results for a site and Template1 block: - name: Deploy templates Template1 - mso_schema_template_deploy: + cisco.mso.mso_schema_template_deploy: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template1 @@ -510,7 +510,7 @@ state: deploy - name: Check deployment status by querying site and Template1 - mso_schema_template_deploy_status: + cisco.mso.mso_schema_template_deploy_status: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template1 @@ -519,27 +519,27 @@ register: status2_site_temp1 - name: Increment the retry count - set_fact: + ansible.builtin.set_fact: retry_count: "{{ 0 if retry_count is undefined else retry_count | int + 1 }}" rescue: - - fail: + - ansible.builtin.fail: msg: status2_site_temp1 correct value retrieved continuing when: - status2_site_temp1.current is defined - status2_site_temp1.current.anps == [] - - fail: + - ansible.builtin.fail: msg: Maximum retries of deploy and check group for status2_site_temp1 reached when: retry_count | int == 10 - - debug: + - ansible.builtin.debug: msg: "Deploy and check group for status2_site_temp1 failed, let's give it another shot" - name: Try deploy and check results for a site and Template2 block: - name: Deploy templates Template2 - mso_schema_template_deploy: + cisco.mso.mso_schema_template_deploy: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template2 @@ -547,7 +547,7 @@ state: deploy - name: Check deployment status by querying site and Template2 - mso_schema_template_deploy_status: + cisco.mso.mso_schema_template_deploy_status: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template2 @@ -556,25 +556,25 @@ register: status2_site_temp2 - name: Increment the retry count - set_fact: + ansible.builtin.set_fact: retry_count: "{{ 0 if retry_count is undefined else retry_count | int + 1 }}" rescue: - - fail: + - ansible.builtin.fail: msg: status2_site_temp2 correct value retrieved continuing when: - status2_site_temp2.current is defined - status2_site_temp2.current.anps == [] - - fail: + - ansible.builtin.fail: msg: Maximum retries of deploy and check group for status2_site_temp2 reached when: retry_count | int == 10 - - debug: + - ansible.builtin.debug: msg: "Deploy and check group for status2_site_temp2 failed, let's give it another shot" - name: Verify status after querying site post deployment - assert: + ansible.builtin.assert: that: - status2_site.current | length == 2 - status2_site_temp1.current.anps == [] @@ -585,7 +585,7 @@ - status2_site_temp2.current.vrfs == [] - name: Check deployment status by querying site and non associated Template 1 - mso_schema_template_deploy_status: + cisco.mso.mso_schema_template_deploy_status: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template1 @@ -595,12 +595,12 @@ register: status_site_temp3 - name: Verify status after querying site with non associated Template 1 - assert: + ansible.builtin.assert: that: - status_site_temp3.msg == "Provided Template 'Template1' not associated with Site 'aws_ansible_test'." - name: Check Non-existing schema - mso_schema_template_deploy_status: + cisco.mso.mso_schema_template_deploy_status: <<: *mso_info schema: non-existing-schema state: query @@ -608,12 +608,12 @@ register: non_schema - name: Verify non_existing_schema - assert: + ansible.builtin.assert: that: - non_schema.msg == "Schema 'non-existing-schema' not found." - name: Check deployment status of non-existing-template - mso_schema_template_deploy_status: + cisco.mso.mso_schema_template_deploy_status: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: non-existing-template @@ -622,6 +622,6 @@ register: non_temp - name: Verify non_existing_template - assert: + ansible.builtin.assert: that: - non_temp.msg == "Template 'non-existing-template' not found."
\ No newline at end of file diff --git a/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_external_epg/tasks/main.yml b/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_external_epg/tasks/main.yml index e76869456..e2f094754 100644 --- a/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_external_epg/tasks/main.yml +++ b/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_external_epg/tasks/main.yml @@ -7,14 +7,14 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI MultiSite host, username and password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: mso_hostname, mso_username and mso_password.' when: mso_hostname is not defined or mso_username is not defined or mso_password is not defined # CLEAN ENVIRONMENT - name: Set vars - set_fact: + ansible.builtin.set_fact: mso_info: &mso_info host: '{{ mso_hostname }}' username: '{{ mso_username }}' @@ -25,7 +25,7 @@ output_level: '{{ mso_output_level | default("info") }}' # - name: Ensure site exist -# mso_site: &site_present +# cisco.mso.mso_site: &site_present # host: '{{ mso_hostname }}' # username: '{{ mso_username }}' # password: '{{ mso_password }}' @@ -42,13 +42,13 @@ # state: present - name: Query MSO version - mso_version: + cisco.mso.mso_version: <<: *mso_info state: query register: version - name: Undeploy templates if deployed from previous test case - mso_schema_template_deploy: + cisco.mso.mso_schema_template_deploy: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: "{{ item }}" @@ -60,7 +60,7 @@ - Template 2 - name: Remove schemas - mso_schema: + cisco.mso.mso_schema: <<: *mso_info schema: '{{ item }}' state: absent @@ -69,7 +69,7 @@ - '{{ mso_schema | default("ansible_test") }}' - name: Ensure tenant ansible_test exist - mso_tenant: + cisco.mso.mso_tenant: <<: *mso_info tenant: ansible_test users: @@ -79,7 +79,7 @@ state: present - name: Ensure schema 1 with Template 1 exist - mso_schema_template: + cisco.mso.mso_schema_template: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' tenant: ansible_test @@ -87,7 +87,7 @@ state: present - name: Ensure schema 1 with Template 2 exist - mso_schema_template: + cisco.mso.mso_schema_template: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' tenant: ansible_test @@ -95,7 +95,7 @@ state: present - name: Ensure schema 2 with Template 3 exist - mso_schema_template: + cisco.mso.mso_schema_template: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}_2' tenant: ansible_test @@ -103,7 +103,7 @@ state: present - name: Ensure Filter 1 exist - mso_schema_template_filter_entry: + cisco.mso.mso_schema_template_filter_entry: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -112,7 +112,7 @@ state: present - name: Ensure Contract1 exist - mso_schema_template_contract_filter: &contract_present + cisco.mso.mso_schema_template_contract_filter: &contract_present <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -123,7 +123,7 @@ state: present - name: Ensure Filter 2 exist - mso_schema_template_filter_entry: + cisco.mso.mso_schema_template_filter_entry: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 2 @@ -132,7 +132,7 @@ state: present - name: Ensure Contract2 exist - mso_schema_template_contract_filter: &contract2_present + cisco.mso.mso_schema_template_contract_filter: &contract2_present <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 2 @@ -143,7 +143,7 @@ state: present - name: Ensure VRF exist - mso_schema_template_vrf: + cisco.mso.mso_schema_template_vrf: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -152,7 +152,7 @@ state: present - name: Ensure VRF2 exist - mso_schema_template_vrf: + cisco.mso.mso_schema_template_vrf: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -160,7 +160,7 @@ state: present - name: Ensure VRF3 exist - mso_schema_template_vrf: + cisco.mso.mso_schema_template_vrf: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 2 @@ -168,7 +168,7 @@ state: present - name: Ensure VRF4 exist - mso_schema_template_vrf: + cisco.mso.mso_schema_template_vrf: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}_2' template: Template 3 @@ -176,7 +176,7 @@ state: present - name: Ensure L3out exist - mso_schema_template_l3out: + cisco.mso.mso_schema_template_l3out: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -186,7 +186,7 @@ state: present - name: Ensure L3out2 exist - mso_schema_template_l3out: + cisco.mso.mso_schema_template_l3out: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -196,7 +196,7 @@ state: present - name: Ensure L3out3 exist - mso_schema_template_l3out: + cisco.mso.mso_schema_template_l3out: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 2 @@ -208,7 +208,7 @@ state: present - name: Ensure L3out4 exist - mso_schema_template_l3out: + cisco.mso.mso_schema_template_l3out: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}_2' template: Template 3 @@ -220,7 +220,7 @@ state: present - name: Ensure ANP exists - mso_schema_template_anp: + cisco.mso.mso_schema_template_anp: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -228,7 +228,7 @@ state: present - name: Ensure ANP2 exist - mso_schema_template_anp: + cisco.mso.mso_schema_template_anp: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -236,7 +236,7 @@ state: present - name: Ensure ANP3 exist - mso_schema_template_anp: + cisco.mso.mso_schema_template_anp: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -244,7 +244,7 @@ state: present - name: Ensure ANP4 exist - mso_schema_template_anp: + cisco.mso.mso_schema_template_anp: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}_2' template: Template 3 @@ -252,7 +252,7 @@ state: present - name: Ensure ansible_test_1 external EPG does not exist - mso_schema_template_external_epg: + cisco.mso.mso_schema_template_external_epg: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -260,7 +260,7 @@ state: absent - name: Ensure ansible_test_2 external EPG does not exist - mso_schema_template_external_epg: + cisco.mso.mso_schema_template_external_epg: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 2 @@ -268,7 +268,7 @@ state: absent - name: Ensure ansible_test_3 external EPG does not exist - mso_schema_template_external_epg: + cisco.mso.mso_schema_template_external_epg: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}_2' template: Template 3 @@ -276,7 +276,7 @@ state: absent - name: Ensure ansible_test_4 external EPG does not exist - mso_schema_template_external_epg: + cisco.mso.mso_schema_template_external_epg: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -284,7 +284,7 @@ state: absent - name: Ensure ansible_test_6 external EPG does not exist - mso_schema_template_external_epg: + cisco.mso.mso_schema_template_external_epg: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 2 @@ -292,7 +292,7 @@ state: absent - name: Ensure ansible_test_7 external EPG does not exist - mso_schema_template_external_epg: + cisco.mso.mso_schema_template_external_epg: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 2 @@ -301,7 +301,7 @@ # ADD external EPG - name: Add external EPG (check_mode) - mso_schema_template_external_epg: + cisco.mso.mso_schema_template_external_epg: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -313,7 +313,7 @@ register: cm_add_epg - name: Verify cm_add_epg - assert: + ansible.builtin.assert: that: - cm_add_epg is changed - cm_add_epg.previous == {} @@ -322,7 +322,7 @@ - cm_add_epg.current.vrfRef.vrfName == "VRF" - name: Add external EPG (normal mode) - mso_schema_template_external_epg: + cisco.mso.mso_schema_template_external_epg: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -333,7 +333,7 @@ register: nm_add_epg - name: Verify nm_add_epg - assert: + ansible.builtin.assert: that: - nm_add_epg is changed - nm_add_epg.previous == {} @@ -343,7 +343,7 @@ - cm_add_epg.current.vrfRef.schemaId == nm_add_epg.current.vrfRef.schemaId - name: Add external EPG again (check_mode) - mso_schema_template_external_epg: + cisco.mso.mso_schema_template_external_epg: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -357,7 +357,7 @@ register: cm_add_epg_again - name: Verify cm_add_epg_again - assert: + ansible.builtin.assert: that: - cm_add_epg_again is not changed - cm_add_epg_again.previous.name == "ansible_test_1" @@ -370,7 +370,7 @@ - name: Add epg again (normal mode) - mso_schema_template_external_epg: + cisco.mso.mso_schema_template_external_epg: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -383,7 +383,7 @@ register: nm_add_epg_again - name: Verify nm_add_epg_again - assert: + ansible.builtin.assert: that: - nm_add_epg_again is not changed - nm_add_epg_again.previous.name == "ansible_test_1" @@ -395,7 +395,7 @@ - nm_add_epg_again.previous.vrfRef.schemaId == nm_add_epg_again.current.vrfRef.schemaId - name: Add external EPG 2(normal mode) - mso_schema_template_external_epg: + cisco.mso.mso_schema_template_external_epg: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 2 @@ -412,7 +412,7 @@ register: nm_add_epg_2 - name: Add external EPG 3 (normal mode) - mso_schema_template_external_epg: + cisco.mso.mso_schema_template_external_epg: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}_2' template: Template 3 @@ -429,7 +429,7 @@ register: nm_add_epg_3 - name: Add external EPG 4 (normal mode) - mso_schema_template_external_epg: + cisco.mso.mso_schema_template_external_epg: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -440,7 +440,7 @@ register: nm_add_epg_4 - name: Verify nm_add_epg_2 and nm_add_epg_3 - assert: + ansible.builtin.assert: that: - nm_add_epg_2 is changed - nm_add_epg_3 is changed @@ -454,7 +454,7 @@ - nm_add_epg_3.current.vrfRef.schemaId != nm_add_epg.current.vrfRef.schemaId - name: Add external EPG 5 (normal mode) - mso_schema_template_external_epg: + cisco.mso.mso_schema_template_external_epg: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 2 @@ -471,13 +471,13 @@ register: nm_add_epg_5 - name: Verify nm_add_epg_5 - assert: + ansible.builtin.assert: that: - nm_add_epg_5 is changed - nm_add_epg_5.current.name == "ansible_test_5" - name: Add external EPG 5 again with L3Out (normal mode) - mso_schema_template_external_epg: + cisco.mso.mso_schema_template_external_epg: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 2 @@ -498,13 +498,13 @@ register: nm_add_epg_5_again - name: Verify nm_add_epg_5_again - assert: + ansible.builtin.assert: that: - nm_add_epg_5_again is changed - nm_add_epg_5_again.current.name == "ansible_test_5" - name: Add external EPG 6 with external epg type cloud (normal mode) - mso_schema_template_external_epg: + cisco.mso.mso_schema_template_external_epg: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 2 @@ -522,7 +522,7 @@ register: nm_add_epg_6 - name: Verify nm_add_epg_6 - assert: + ansible.builtin.assert: that: - nm_add_epg_6 is changed - nm_add_epg_6.current.name == "ansible_test_6" @@ -531,7 +531,7 @@ - nm_add_epg_6.current.anpRef.anpName == "ANP1" - name: Add external EPG 6 with external epg type cloud again(normal mode) - mso_schema_template_external_epg: + cisco.mso.mso_schema_template_external_epg: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 2 @@ -549,13 +549,13 @@ register: nm_add_epg_6_again - name: Verify nm_add_epg_6_again - assert: + ansible.builtin.assert: that: - nm_add_epg_6_again is not changed - nm_add_epg_6_again.current.name == "ansible_test_6" - name: Add external EPG 6 with external epg type cloud with modification(normal mode) - mso_schema_template_external_epg: + cisco.mso.mso_schema_template_external_epg: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 2 @@ -573,7 +573,7 @@ register: nm_add_epg_6_again_2 - name: Verify nm_add_epg_6_again - assert: + ansible.builtin.assert: that: - nm_add_epg_6_again_2 is changed - nm_add_epg_6_again_2.current.name == "ansible_test_6" @@ -581,7 +581,7 @@ - nm_add_epg_6_again_2.current.anpRef.anpName == "ANP1" - name: Add external EPG 7 with external epg type on-premise explicitly mentioned again(normal mode) - mso_schema_template_external_epg: + cisco.mso.mso_schema_template_external_epg: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 2 @@ -599,7 +599,7 @@ register: nm_add_epg_7 - name: Verify nm_add_epg_7 - assert: + ansible.builtin.assert: that: - nm_add_epg_7 is changed - nm_add_epg_7.current.name == "ansible_test_7" @@ -607,7 +607,7 @@ - nm_add_epg_7.current.vrfRef.vrfName == "VRF" - name: Add external EPG 7 with external epg type not mentioned again(normal mode) - mso_schema_template_external_epg: + cisco.mso.mso_schema_template_external_epg: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 2 @@ -624,14 +624,14 @@ register: nm_add_epg_7_again - name: Verify nm_add_epg_7_again - assert: + ansible.builtin.assert: that: - nm_add_epg_7_again is not changed - nm_add_epg_7_again.current.name == "ansible_test_7" # CHANGE external EPG - name: Change epg from different template (check_mode) - mso_schema_template_external_epg: &change_epg_template + cisco.mso.mso_schema_template_external_epg: &change_epg_template <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 2 @@ -645,7 +645,7 @@ register: cm_change_epg - name: Verify cm_change_epg from different template to own template - assert: + ansible.builtin.assert: that: - cm_change_epg is changed - cm_change_epg.current.name == 'ansible_test_2' @@ -654,13 +654,13 @@ - cm_change_epg.current.vrfRef.schemaId == cm_change_epg.previous.vrfRef.schemaId - name: Change epg from different template to own template (normal_mode) - mso_schema_template_external_epg: + cisco.mso.mso_schema_template_external_epg: <<: *change_epg_template state: present register: nm_change_epg - name: Verify nm_change_epg from different template to own template - assert: + ansible.builtin.assert: that: - nm_change_epg is changed - nm_change_epg.current.name == 'ansible_test_2' @@ -669,13 +669,13 @@ - nm_change_epg.current.vrfRef.schemaId == nm_change_epg.previous.vrfRef.schemaId - name: Change epg again from different template (check_mode) - mso_schema_template_external_epg: + cisco.mso.mso_schema_template_external_epg: <<: *change_epg_template check_mode: true register: cm_change_epg_again - name: Verify cm_change_epg_again - assert: + ansible.builtin.assert: that: - cm_change_epg_again is not changed - cm_change_epg_again.current.name == 'ansible_test_2' @@ -684,13 +684,13 @@ - cm_change_epg_again.current.vrfRef.schemaId == cm_change_epg_again.previous.vrfRef.schemaId - name: Change epg again from different template (normal_mode) - mso_schema_template_external_epg: + cisco.mso.mso_schema_template_external_epg: <<: *change_epg_template state: present register: nm_change_epg_again - name: Verify nm_change_epg_again from different template to own template - assert: + ansible.builtin.assert: that: - nm_change_epg_again is not changed - nm_change_epg_again.current.name == 'ansible_test_2' @@ -699,7 +699,7 @@ - nm_change_epg_again.current.vrfRef.schemaId == nm_change_epg_again.previous.vrfRef.schemaId - name: Change VRF from different schema (normal mode) - mso_schema_template_external_epg: + cisco.mso.mso_schema_template_external_epg: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}_2' template: Template 3 @@ -712,7 +712,7 @@ register: nm_change_epg_vrf4 - name: Verify nm_change_epg_vrf4 and nm_change_epg_vrf2 - assert: + ansible.builtin.assert: that: - nm_change_epg_vrf4 is changed - nm_change_epg_vrf4.current.name == 'ansible_test_3' @@ -721,7 +721,7 @@ - nm_change_epg_vrf4.current.vrfRef.schemaId != nm_change_epg_vrf4.previous.vrfRef.schemaId - name: Change epg 1 l3out(normal mode) - mso_schema_template_external_epg: &change_l3out + cisco.mso.mso_schema_template_external_epg: &change_l3out <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -738,7 +738,7 @@ register: nm_change_epg_1_l3out - name: Change epg 1 settings(normal mode) - mso_schema_template_external_epg: + cisco.mso.mso_schema_template_external_epg: <<: *change_l3out vrf: name: VRF @@ -748,7 +748,7 @@ register: nm_change_epg_1_settings - name: Verify nm_change_epg_1_settings and nm_change_epg_1_l3out - assert: + ansible.builtin.assert: that: - nm_change_epg_1_settings is changed - nm_change_epg_1_settings.previous.vrfRef.vrfName == 'VRF2' @@ -767,7 +767,7 @@ - nm_change_epg_1_l3out.current.l3outRef.templateName == 'Template1' - name: Change epg 4 preferredGroup(normal mode) - mso_schema_template_external_epg: + cisco.mso.mso_schema_template_external_epg: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -779,7 +779,7 @@ register: nm_change_epg_4_preferred_group - name: Change epg 4 preferredGroup again(normal mode) - mso_schema_template_external_epg: + cisco.mso.mso_schema_template_external_epg: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -791,7 +791,7 @@ register: nm_change_epg_4_preferred_group_again - name: Verify nm_change_epg_4_preferred_group and nm_change_epg_4_preferred_group_again - assert: + ansible.builtin.assert: that: - nm_change_epg_4_preferred_group is changed - nm_change_epg_4_preferred_group_again is changed @@ -800,7 +800,7 @@ # QUERY ALL EPG - name: Query all EPG (check_mode) - mso_schema_template_external_epg: + cisco.mso.mso_schema_template_external_epg: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -809,7 +809,7 @@ register: cm_query_all_epgs - name: Query all EPG (normal mode) - mso_schema_template_external_epg: + cisco.mso.mso_schema_template_external_epg: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -817,7 +817,7 @@ register: nm_query_all_epgs - name: Verify query_all_epgs - assert: + ansible.builtin.assert: that: - cm_query_all_epgs is not changed - nm_query_all_epgs is not changed @@ -825,7 +825,7 @@ # QUERY AN EPG - name: Query epg 1(check_mode) - mso_schema_template_external_epg: + cisco.mso.mso_schema_template_external_epg: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -835,7 +835,7 @@ register: cm_query_epg_1 - name: Query epg 1(normal_mode) - mso_schema_template_external_epg: + cisco.mso.mso_schema_template_external_epg: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -844,7 +844,7 @@ register: nm_query_epg_1 - name: Verify cm_query_epg_1 and nm_query_epg_1 - assert: + ansible.builtin.assert: that: - cm_query_epg_1 is not changed - nm_query_epg_1 is not changed @@ -857,7 +857,7 @@ - nm_query_epg_1.current.l3outRef.schemaId == nm_query_epg_1.current.vrfRef.schemaId - name: Query epg 5(normal_mode) - mso_schema_template_external_epg: + cisco.mso.mso_schema_template_external_epg: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 2 @@ -866,12 +866,12 @@ register: nm_query_epg_5 - name: Verify nm_query_epg_5 - assert: + ansible.builtin.assert: that: - nm_query_epg_5.current.l3outRef.l3outName == 'L3out' - name: Query epg 6(normal_mode) - mso_schema_template_external_epg: + cisco.mso.mso_schema_template_external_epg: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 2 @@ -880,13 +880,13 @@ register: nm_query_epg_6 - name: Verify nm_query_epg_5 - assert: + ansible.builtin.assert: that: - nm_add_epg_6.current.anpRef.anpName == "ANP1" # REMOVE EPG - name: Remove EPG 4 (check_mode) - mso_schema_template_external_epg: + cisco.mso.mso_schema_template_external_epg: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -896,13 +896,13 @@ register: cm_remove_epg_4 - name: Verify cm_remove_epg_4 - assert: + ansible.builtin.assert: that: - cm_remove_epg_4 is changed - cm_remove_epg_4.current == {} - name: Remove EPG 4 (normal_mode) - mso_schema_template_external_epg: + cisco.mso.mso_schema_template_external_epg: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -911,13 +911,13 @@ register: nm_remove_epg_4 - name: Verify nm_remove_epg_4 - assert: + ansible.builtin.assert: that: - nm_remove_epg_4 is changed - nm_remove_epg_4.current == {} - name: Remove EPG 4 again (normal mode) - mso_schema_template_external_epg: + cisco.mso.mso_schema_template_external_epg: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -926,13 +926,13 @@ register: nm_remove_epg_4_again - name: Verify nm_remove_epg_4_again - assert: + ansible.builtin.assert: that: - nm_remove_epg_4_again is not changed - nm_remove_epg_4_again.previous == nm_remove_epg_4_again.current == {} - name: Add external EPG 4 description for version greater than 3.3 - mso_schema_template_external_epg: + cisco.mso.mso_schema_template_external_epg: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -945,7 +945,7 @@ when: version.current.version is version('3.3', '>=') - name: Verify add_epg_4 for version greater than 3.3 - assert: + ansible.builtin.assert: that: - add_epg_4 is changed - add_epg_4.current.name == "ansible_test_4" @@ -958,7 +958,7 @@ # QUERY NON-EXISTING EPG - name: Query non-existing EPG (check_mode) - mso_schema_template_external_epg: + cisco.mso.mso_schema_template_external_epg: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -969,7 +969,7 @@ register: cm_query_non_existing_epg - name: Query non-existing EPG (normal_mode) - mso_schema_template_external_epg: + cisco.mso.mso_schema_template_external_epg: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -979,7 +979,7 @@ register: nm_query_non_existing_epg - name: Verify cm_query_non_existing_epg and nm_query_non_existing_epg - assert: + ansible.builtin.assert: that: - cm_query_non_existing_epg is not changed - nm_query_non_existing_epg is not changed @@ -988,7 +988,7 @@ # USE A NON-EXISTING SCHEMA - name: Non-existing schema for epg (check_mode) - mso_schema_template_external_epg: + cisco.mso.mso_schema_template_external_epg: <<: *mso_info schema: non-existing-schema template: Template 1 @@ -998,7 +998,7 @@ register: cm_non_existing_schema - name: Non-existing schema for epg (normal_mode) - mso_schema_template_external_epg: + cisco.mso.mso_schema_template_external_epg: <<: *mso_info schema: non-existing-schema template: Template 1 @@ -1007,7 +1007,7 @@ register: nm_non_existing_schema - name: Verify non_existing_schema - assert: + ansible.builtin.assert: that: - cm_non_existing_schema is not changed - nm_non_existing_schema is not changed @@ -1016,7 +1016,7 @@ # USE A NON-EXISTING TEMPLATE - name: Non-existing template for epg (check_mode) - mso_schema_template_external_epg: + cisco.mso.mso_schema_template_external_epg: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: non-existing-template @@ -1026,7 +1026,7 @@ register: cm_non_existing_template - name: Non-existing template for epg (normal_mode) - mso_schema_template_external_epg: + cisco.mso.mso_schema_template_external_epg: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: non-existing-template @@ -1035,7 +1035,7 @@ register: nm_non_existing_template - name: Verify non_existing_template - assert: + ansible.builtin.assert: that: - cm_non_existing_template is not changed - nm_non_existing_template is not changed @@ -1044,7 +1044,7 @@ # Checking if contract are removed after re-applying an EPG. (#13 | #62137) - name: Remove EPG 2/5/6/7 to avoid circle errors (normal mode) - mso_schema_template_external_epg: + cisco.mso.mso_schema_template_external_epg: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 2 @@ -1057,7 +1057,7 @@ - ansible_test_7 - name: Add Contracts to EPG 1 - mso_schema_template_external_epg_contract: + cisco.mso.mso_schema_template_external_epg_contract: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -1074,7 +1074,7 @@ - { name: Contract2, template: Template 2, type: provider } - name: Query contract EPG 1(normal mode) - mso_schema_template_external_epg: + cisco.mso.mso_schema_template_external_epg: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -1083,12 +1083,12 @@ register: nm_query_epg1_contract - name: Verify nm_query_epg1_contract - assert: + ansible.builtin.assert: that: - nm_query_epg1_contract.current.contractRelationships | length == 4 - name: Add EPG 1 again (normal_mode) - mso_schema_template_external_epg: + cisco.mso.mso_schema_template_external_epg: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -1103,12 +1103,12 @@ register: nm_add_epg_1_again - name: Verify that EPG 1 didn't change - assert: + ansible.builtin.assert: that: - nm_add_epg_1_again is not changed - name: Query contract EPG 1 again - mso_schema_template_external_epg: + cisco.mso.mso_schema_template_external_epg: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -1117,13 +1117,13 @@ register: nm_query_epg1_contract_again - name: Verify that 4 contracts are in EPG 1 using nm_query_epg1_contract_again - assert: + ansible.builtin.assert: that: - nm_query_epg1_contract_again.current.contractRelationships | length == 4 # Checking if modifying an external EPG with existing contracts throw an MSO error. (#82) - name: Change external EPG 1 VRF (normal_mode) - mso_schema_template_external_epg: + cisco.mso.mso_schema_template_external_epg: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -1136,7 +1136,7 @@ register: nm_change_ext_epg_1_vrf - name: Verify that external EPG 1 did change - assert: + ansible.builtin.assert: that: - nm_change_ext_epg_1_vrf is changed - nm_change_ext_epg_1_vrf.current.vrfRef.templateName == "Template1" @@ -1144,7 +1144,7 @@ - nm_change_ext_epg_1_vrf.current.l3outRef.l3outName == "L3out2" - name: Query EPG 1 - mso_schema_template_external_epg: + cisco.mso.mso_schema_template_external_epg: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -1153,6 +1153,6 @@ register: nm_query_contract_ext_epg_1 - name: Verify that 4 contracts are in external EPG 1 using nm_query_contract_ext_epg_1 - assert: + ansible.builtin.assert: that: - nm_query_contract_ext_epg_1.current.contractRelationships | length == 4
\ No newline at end of file diff --git a/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_external_epg_contract/tasks/main.yml b/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_external_epg_contract/tasks/main.yml index 44eb30623..2a410dcb1 100644 --- a/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_external_epg_contract/tasks/main.yml +++ b/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_external_epg_contract/tasks/main.yml @@ -6,14 +6,14 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI MultiSite host, username and password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: mso_hostname, mso_username and mso_password.' when: mso_hostname is not defined or mso_username is not defined or mso_password is not defined # CLEAN ENVIRONMENT # - name: Ensure site exist -# mso_site: &site_present +# cisco.mso.mso_site: &site_present # host: '{{ mso_hostname }}' # username: '{{ mso_username }}' # password: '{{ mso_password }}' @@ -30,7 +30,7 @@ # state: present - name: Remove schemas - mso_schema: + cisco.mso.mso_schema: host: '{{ mso_hostname }}' username: '{{ mso_username }}' password: '{{ mso_password }}' @@ -45,7 +45,7 @@ - '{{ mso_schema | default("ansible_test") }}' - name: Ensure tenant ansible_test exist - mso_tenant: &tenant_present + cisco.mso.mso_tenant: &tenant_present host: '{{ mso_hostname }}' username: '{{ mso_username }}' password: '{{ mso_password }}' @@ -61,7 +61,7 @@ state: present - name: Ensure schema 1 with Template 1 exist - mso_schema_template: &schema_present + cisco.mso.mso_schema_template: &schema_present host: '{{ mso_hostname }}' username: '{{ mso_username }}' password: '{{ mso_password }}' @@ -75,7 +75,7 @@ state: present - name: Ensure schema 1 with Template 2 exist - mso_schema_template: + cisco.mso.mso_schema_template: <<: *schema_present schema: '{{ mso_schema | default("ansible_test") }}' tenant: ansible_test @@ -83,7 +83,7 @@ state: present - name: Ensure schema 2 with Template 3 exist - mso_schema_template: + cisco.mso.mso_schema_template: <<: *schema_present schema: '{{ mso_schema | default("ansible_test") }}_2' tenant: ansible_test @@ -91,7 +91,7 @@ state: present - name: Ensure VRF exist - mso_schema_template_vrf: + cisco.mso.mso_schema_template_vrf: host: '{{ mso_hostname }}' username: '{{ mso_username }}' password: '{{ mso_password }}' @@ -105,7 +105,7 @@ state: present - name: Ensure Filter 1 exist - mso_schema_template_filter_entry: + cisco.mso.mso_schema_template_filter_entry: host: '{{ mso_hostname }}' username: '{{ mso_username }}' password: '{{ mso_password }}' @@ -120,7 +120,7 @@ state: present - name: Ensure Filter 2 exist - mso_schema_template_filter_entry: + cisco.mso.mso_schema_template_filter_entry: host: '{{ mso_hostname }}' username: '{{ mso_username }}' password: '{{ mso_password }}' @@ -135,7 +135,7 @@ state: present - name: Ensure Contract1 exist - mso_schema_template_contract_filter: &contract_present + cisco.mso.mso_schema_template_contract_filter: &contract_present host: '{{ mso_hostname }}' username: '{{ mso_username }}' password: '{{ mso_password }}' @@ -152,7 +152,7 @@ state: present - name: Ensure Contract2 exist - mso_schema_template_contract_filter: + cisco.mso.mso_schema_template_contract_filter: <<: *contract_present template: Template 2 contract: Contract2 @@ -162,7 +162,7 @@ state: present - name: Ensure external EPGs exist - mso_schema_template_externalepg: + cisco.mso.mso_schema_template_externalepg: host: '{{ mso_hostname }}' username: '{{ mso_username }}' password: '{{ mso_password }}' @@ -184,7 +184,7 @@ # ADD Contract to External EPG - name: Add Contract1 to External EPG (check_mode) - mso_schema_template_external_epg_contract: &contract_ext_epg_present + cisco.mso.mso_schema_template_external_epg_contract: &contract_ext_epg_present host: '{{ mso_hostname }}' username: '{{ mso_username }}' password: '{{ mso_password }}' @@ -203,7 +203,7 @@ register: cm_add_contract_rel - name: Verify cm_add_contract_rel - assert: + ansible.builtin.assert: that: - cm_add_contract_rel is changed - cm_add_contract_rel.previous == {} @@ -212,12 +212,12 @@ - cm_add_contract_rel.current.relationshipType == "consumer" - name: Add Contract to External EPG (normal mode) - mso_schema_template_external_epg_contract: + cisco.mso.mso_schema_template_external_epg_contract: <<: *contract_ext_epg_present register: nm_add_contract_rel - name: Verify nm_add_contract_rel - assert: + ansible.builtin.assert: that: - nm_add_contract_rel is changed - nm_add_contract_rel.previous == {} @@ -227,13 +227,13 @@ - cm_add_contract_rel.current.contractRef.schemaId == nm_add_contract_rel.current.contractRef.schemaId - name: Add Contract to External EPG again (check_mode) - mso_schema_template_external_epg_contract: + cisco.mso.mso_schema_template_external_epg_contract: <<: *contract_ext_epg_present check_mode: true register: cm_add_contract_rel_again - name: Verify cm_add_contract_rel_again - assert: + ansible.builtin.assert: that: - cm_add_contract_rel_again is not changed - cm_add_contract_rel_again.previous.contractRef.templateName == "Template1" @@ -246,12 +246,12 @@ - name: Add Contract to External EPG again (normal mode) - mso_schema_template_external_epg_contract: + cisco.mso.mso_schema_template_external_epg_contract: <<: *contract_ext_epg_present register: nm_add_contract_rel_again - name: Verify nm_add_contract_rel_again - assert: + ansible.builtin.assert: that: - nm_add_contract_rel_again is not changed - nm_add_contract_rel_again.previous.contractRef.templateName == "Template1" @@ -263,7 +263,7 @@ - nm_add_contract_rel_again.previous.contractRef.schemaId == nm_add_contract_rel_again.current.contractRef.schemaId - name: Add Contract1 to External EPG - provider (normal mode) - mso_schema_template_external_epg_contract: + cisco.mso.mso_schema_template_external_epg_contract: <<: *contract_ext_epg_present contract: name: Contract1 @@ -271,7 +271,7 @@ register: nm_add_contract1_rel_provider - name: Add Contract2 to External EPG - consumer (normal mode) - mso_schema_template_external_epg_contract: + cisco.mso.mso_schema_template_external_epg_contract: <<: *contract_ext_epg_present contract: name: Contract2 @@ -280,7 +280,7 @@ register: nm_add_contract2_rel_consumer - name: Add Contract1 to External EPG 3 - provider (normal mode) - mso_schema_template_external_epg_contract: + cisco.mso.mso_schema_template_external_epg_contract: <<: *contract_ext_epg_present schema: '{{ mso_schema | default("ansible_test") }}_2' template: 'Template 3' @@ -293,7 +293,7 @@ register: nm_add_contract3_rel_provider - name: Verify nm_add_contract1_rel_provider, nm_add_contract2_rel_consumer and nm_add_contract3_rel_provider - assert: + ansible.builtin.assert: that: - nm_add_contract1_rel_provider is changed - nm_add_contract2_rel_consumer is changed @@ -310,7 +310,7 @@ # # QUERY ALL Contract to External EPG - name: Query all contract relationship for External EPG (check_mode) - mso_schema_template_external_epg_contract: &contract_ext_epg_query + cisco.mso.mso_schema_template_external_epg_contract: &contract_ext_epg_query host: '{{ mso_hostname }}' username: '{{ mso_username }}' password: '{{ mso_password }}' @@ -326,12 +326,12 @@ register: cm_query_all_contract_rels - name: Query all contract relationship for External EPG (normal mode) - mso_schema_template_external_epg_contract: + cisco.mso.mso_schema_template_external_epg_contract: <<: *contract_ext_epg_query register: nm_query_all_contract_rels - name: Verify query_all_contract_rels - assert: + ansible.builtin.assert: that: - cm_query_all_contract_rels is not changed - nm_query_all_contract_rels is not changed @@ -340,7 +340,7 @@ # QUERY A Contract to External EPG - name: Query Contract1 relationship for External EPG - consumer (check_mode) - mso_schema_template_external_epg_contract: + cisco.mso.mso_schema_template_external_epg_contract: <<: *contract_ext_epg_query contract: name: Contract1 @@ -349,7 +349,7 @@ register: cm_query_contract1_consumer_rel - name: Query Contract1 relationship for External EPG - consumer (normal mode) - mso_schema_template_external_epg_contract: + cisco.mso.mso_schema_template_external_epg_contract: <<: *contract_ext_epg_query contract: name: Contract1 @@ -357,7 +357,7 @@ register: nm_query_contract1_consumer_rel - name: Query Contract1 relationship for External EPG - provider (normal mode) - mso_schema_template_external_epg_contract: + cisco.mso.mso_schema_template_external_epg_contract: <<: *contract_ext_epg_query contract: name: Contract1 @@ -365,7 +365,7 @@ register: nm_query_contract1_provider_rel - name: Query Contract1 relationship for External EPG - consumer (normal mode) - mso_schema_template_external_epg_contract: + cisco.mso.mso_schema_template_external_epg_contract: <<: *contract_ext_epg_query contract: name: Contract2 @@ -374,7 +374,7 @@ register: nm_query_contract2_consumer_rel - name: Query Contract1 relationship for External EPG - provider (normal mode) - mso_schema_template_external_epg_contract: + cisco.mso.mso_schema_template_external_epg_contract: <<: *contract_ext_epg_query schema: '{{ mso_schema | default("ansible_test") }}_2' template: Template 3 @@ -387,7 +387,7 @@ register: nm_query_contract3_provider_rel - name: Verify query_contractX_YYYYY_rel - assert: + ansible.builtin.assert: that: - cm_query_contract1_consumer_rel is not changed - nm_query_contract1_consumer_rel is not changed @@ -408,51 +408,51 @@ # REMOVE Contract to External EPG - name: Remove Contract to External EPG (check_mode) - mso_schema_template_external_epg_contract: + cisco.mso.mso_schema_template_external_epg_contract: <<: *contract_ext_epg_present state: absent check_mode: true register: cm_remove_contract_rel - name: Verify cm_remove_contract_rel - assert: + ansible.builtin.assert: that: - cm_remove_contract_rel is changed - cm_remove_contract_rel.current == {} - name: Remove Contract to External EPG (normal mode) - mso_schema_template_external_epg_contract: + cisco.mso.mso_schema_template_external_epg_contract: <<: *contract_ext_epg_present state: absent register: nm_remove_contract_rel - name: Verify nm_remove_contract_rel - assert: + ansible.builtin.assert: that: - nm_remove_contract_rel is changed - nm_remove_contract_rel.current == {} - name: Remove Contract to External EPG again (check_mode) - mso_schema_template_external_epg_contract: + cisco.mso.mso_schema_template_external_epg_contract: <<: *contract_ext_epg_present state: absent check_mode: true register: cm_remove_contract_rel_again - name: Verify cm_remove_contract_rel_again - assert: + ansible.builtin.assert: that: - cm_remove_contract_rel_again is not changed - cm_remove_contract_rel_again.current == {} - name: Remove Contract to External EPG again (normal mode) - mso_schema_template_external_epg_contract: + cisco.mso.mso_schema_template_external_epg_contract: <<: *contract_ext_epg_present state: absent register: nm_remove_contract_rel_again - name: Verify nm_remove_contract_rel_again - assert: + ansible.builtin.assert: that: - nm_remove_contract_rel_again is not changed - nm_remove_contract_rel_again.current == {} @@ -460,7 +460,7 @@ # QUERY NON-EXISTING Contract to External EPG - name: Query non-existing contract (check_mode) - mso_schema_template_external_epg_contract: + cisco.mso.mso_schema_template_external_epg_contract: <<: *contract_ext_epg_query contract: name: non_existing_contract @@ -470,7 +470,7 @@ register: cm_query_non_contract - name: Query non-existing contract (normal mode) - mso_schema_template_external_epg_contract: + cisco.mso.mso_schema_template_external_epg_contract: <<: *contract_ext_epg_query contract: name: non_existing_contract @@ -479,7 +479,7 @@ register: nm_query_non_contract - name: Verify query_non_contract - assert: + ansible.builtin.assert: that: - cm_query_non_contract is not changed - nm_query_non_contract is not changed @@ -489,7 +489,7 @@ # QUERY NON-EXISTING ExtEPG - name: Query non-existing ExtEPG (check_mode) - mso_schema_template_external_epg_contract: + cisco.mso.mso_schema_template_external_epg_contract: <<: *contract_ext_epg_query external_epg: non_existing_ext_epg check_mode: true @@ -497,14 +497,14 @@ register: cm_query_non_ext_epg - name: Query non-existing ExtEPG (normal mode) - mso_schema_template_external_epg_contract: + cisco.mso.mso_schema_template_external_epg_contract: <<: *contract_ext_epg_query external_epg: non_existing_ext_epg ignore_errors: true register: nm_query_non_ext_epg - name: Verify query_non_ext_epg - assert: + ansible.builtin.assert: that: - cm_query_non_ext_epg is not changed - nm_query_non_ext_epg is not changed @@ -513,7 +513,7 @@ # USE A NON-EXISTING STATE - name: Non-existing state for contract relationship (check_mode) - mso_schema_template_external_epg_contract: + cisco.mso.mso_schema_template_external_epg_contract: <<: *contract_ext_epg_query state: non-existing-state check_mode: true @@ -521,14 +521,14 @@ register: cm_non_existing_state - name: Non-existing state for contract relationship (normal_mode) - mso_schema_template_external_epg_contract: + cisco.mso.mso_schema_template_external_epg_contract: <<: *contract_ext_epg_query state: non-existing-state ignore_errors: true register: nm_non_existing_state - name: Verify non_existing_state - assert: + ansible.builtin.assert: that: - cm_non_existing_state is not changed - nm_non_existing_state is not changed @@ -537,7 +537,7 @@ # USE A NON-EXISTING SCHEMA - name: Non-existing schema for contract relationship (check_mode) - mso_schema_template_external_epg_contract: + cisco.mso.mso_schema_template_external_epg_contract: <<: *contract_ext_epg_query schema: non-existing-schema check_mode: true @@ -545,14 +545,14 @@ register: cm_non_existing_schema - name: Non-existing schema for contract relationship (normal_mode) - mso_schema_template_external_epg_contract: + cisco.mso.mso_schema_template_external_epg_contract: <<: *contract_ext_epg_query schema: non-existing-schema ignore_errors: true register: nm_non_existing_schema - name: Verify non_existing_schema - assert: + ansible.builtin.assert: that: - cm_non_existing_schema is not changed - nm_non_existing_schema is not changed @@ -560,7 +560,7 @@ - cm_non_existing_schema.msg == nm_non_existing_schema.msg == "Provided schema 'non-existing-schema' does not exist." - name: Non-existing contract schema for contract relationship (check_mode) - mso_schema_template_external_epg_contract: + cisco.mso.mso_schema_template_external_epg_contract: <<: *contract_ext_epg_query contract: name: Contract1 @@ -572,7 +572,7 @@ register: cm_non_existing_contract_schema - name: Non-existing contract schema for contract relationship (normal_mode) - mso_schema_template_external_epg_contract: + cisco.mso.mso_schema_template_external_epg_contract: <<: *contract_ext_epg_query contract: name: Contract1 @@ -583,7 +583,7 @@ register: nm_non_existing_contract_schema - name: Verify non_existing_contract_schema - assert: + ansible.builtin.assert: that: - cm_non_existing_contract_schema is not changed - nm_non_existing_contract_schema is not changed @@ -592,7 +592,7 @@ # USE A NON-EXISTING TEMPLATE - name: Non-existing template for contract relationship (check_mode) - mso_schema_template_external_epg_contract: + cisco.mso.mso_schema_template_external_epg_contract: <<: *contract_ext_epg_query template: non-existing-template check_mode: true @@ -600,14 +600,14 @@ register: cm_non_existing_template - name: Non-existing template for contract relationship (normal_mode) - mso_schema_template_external_epg_contract: + cisco.mso.mso_schema_template_external_epg_contract: <<: *contract_ext_epg_query template: non-existing-template ignore_errors: true register: nm_non_existing_template - name: Verify non_existing_template - assert: + ansible.builtin.assert: that: - cm_non_existing_template is not changed - nm_non_existing_template is not changed @@ -615,7 +615,7 @@ - cm_non_existing_template.msg == nm_non_existing_template.msg == "Provided template 'non-existing-template' does not exist. Existing templates{{':'}} Template1, Template2" - name: Non-existing contract template for contract relationship (check_mode) - mso_schema_template_external_epg_contract: + cisco.mso.mso_schema_template_external_epg_contract: <<: *contract_ext_epg_query contract: name: Contract1 @@ -626,7 +626,7 @@ register: cm_non_existing_contract_template - name: Non-existing contract template for contract relationship (normal_mode) - mso_schema_template_external_epg_contract: + cisco.mso.mso_schema_template_external_epg_contract: <<: *contract_ext_epg_query contract: name: Contract1 @@ -636,7 +636,7 @@ register: nm_non_existing_contract_template - name: Verify non_existing_contract_template - assert: + ansible.builtin.assert: that: - cm_non_existing_contract_template is not changed - nm_non_existing_contract_template is not changed diff --git a/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_external_epg_selector/tasks/main.yml b/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_external_epg_selector/tasks/main.yml index 5911f7667..b663cd703 100644 --- a/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_external_epg_selector/tasks/main.yml +++ b/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_external_epg_selector/tasks/main.yml @@ -6,14 +6,14 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI MultiSite host, username and password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: mso_hostname, mso_username and mso_password.' when: mso_hostname is not defined or mso_username is not defined or mso_password is not defined # CLEAN ENVIRONMENT - name: Set vars - set_fact: + ansible.builtin.set_fact: mso_info: &mso_info host: '{{ mso_hostname }}' username: '{{ mso_username }}' @@ -24,7 +24,7 @@ output_level: '{{ mso_output_level | default("info") }}' - name: Remove schemas - mso_schema: + cisco.mso.mso_schema: <<: *mso_info schema: '{{ item }}' state: absent @@ -33,7 +33,7 @@ - '{{ mso_schema | default("ansible_test") }}' - name: Ensure tenant ansible_test exist - mso_tenant: + cisco.mso.mso_tenant: <<: *mso_info tenant: ansible_test users: @@ -43,7 +43,7 @@ state: present - name: Ensure schema 1 with Template 1 exist - mso_schema_template: + cisco.mso.mso_schema_template: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' tenant: ansible_test @@ -51,7 +51,7 @@ state: present - name: Ensure schema 1 with Template 2 exist - mso_schema_template: + cisco.mso.mso_schema_template: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' tenant: ansible_test @@ -59,7 +59,7 @@ state: present - name: Ensure schema 2 with Template 3 exist - mso_schema_template: + cisco.mso.mso_schema_template: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}_2' tenant: ansible_test @@ -67,7 +67,7 @@ state: present - name: Ensure VRF exists - mso_schema_template_vrf: + cisco.mso.mso_schema_template_vrf: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -75,7 +75,7 @@ state: present - name: Ensure VRF2 exists - mso_schema_template_vrf: + cisco.mso.mso_schema_template_vrf: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -83,7 +83,7 @@ state: present - name: Ensure ANP1 exists - mso_schema_template_anp: + cisco.mso.mso_schema_template_anp: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -91,7 +91,7 @@ state: present - name: Ensure ANP2 exists - mso_schema_template_anp: + cisco.mso.mso_schema_template_anp: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -99,7 +99,7 @@ state: present - name: Ensure L3out exist - mso_schema_template_l3out: + cisco.mso.mso_schema_template_l3out: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -109,7 +109,7 @@ state: present - name: Ensure L3out2 exist - mso_schema_template_l3out: + cisco.mso.mso_schema_template_l3out: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -120,7 +120,7 @@ # ADD External EPGs - name: Ensure External EPG1 exists - mso_schema_template_externalepg: + cisco.mso.mso_schema_template_externalepg: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -140,7 +140,7 @@ state: present - name: Ensure External EPG2 exists - mso_schema_template_externalepg: + cisco.mso.mso_schema_template_externalepg: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -161,7 +161,7 @@ # ADD Selector to EPG - name: Add Selector to extEPG1 (check_mode) - mso_schema_template_external_epg_selector: + cisco.mso.mso_schema_template_external_epg_selector: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -172,7 +172,7 @@ register: cm_add_selector_1 - name: Verify cm_add_selector_1 - assert: + ansible.builtin.assert: that: - cm_add_selector_1 is changed - cm_add_selector_1.previous == {} @@ -180,7 +180,7 @@ - cm_add_selector_1.current.expressions == [] - name: Add Selector 1 to extEPG1 (normal_mode) - mso_schema_template_external_epg_selector: + cisco.mso.mso_schema_template_external_epg_selector: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -191,7 +191,7 @@ register: nm_add_selector_1 - name: Verify nm_add_selector_1 - assert: + ansible.builtin.assert: that: - nm_add_selector_1 is changed - nm_add_selector_1.previous == {} @@ -199,7 +199,7 @@ - nm_add_selector_1.current.expressions == [] - name: Add Selector 1 to extEPG1 again(normal_mode) - mso_schema_template_external_epg_selector: + cisco.mso.mso_schema_template_external_epg_selector: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -210,12 +210,12 @@ register: nm_add_selector_1_again - name: Verify nm_add_selector_1_again - assert: + ansible.builtin.assert: that: - nm_add_selector_1_again is not changed - name: Add Selector to extEPG1 again (normal_mode) - mso_schema_template_external_epg_selector: + cisco.mso.mso_schema_template_external_epg_selector: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -225,12 +225,12 @@ register: nm_add_selector_1_again - name: Verify nm_add_selector_1_again - assert: + ansible.builtin.assert: that: - nm_add_selector_1_again is not changed - name: Add Selector 2 to extEPG1 (normal_mode) - mso_schema_template_external_epg_selector: + cisco.mso.mso_schema_template_external_epg_selector: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -244,7 +244,7 @@ register: nm_add_selector_2 - name: Verify nm_add_selector_2 - assert: + ansible.builtin.assert: that: - nm_add_selector_2 is changed - nm_add_selector_2.previous == {} @@ -254,7 +254,7 @@ - nm_add_selector_2.current.expressions[0].value == "10.0.0.0" - name: Add Selector 3 to extEPG1 (normal_mode) - mso_schema_template_external_epg_selector: + cisco.mso.mso_schema_template_external_epg_selector: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -268,7 +268,7 @@ register: nm_add_selector_3 - name: Verify nm_add_selector_3 - assert: + ansible.builtin.assert: that: - nm_add_selector_3 is changed - nm_add_selector_3.previous == {} @@ -276,7 +276,7 @@ - nm_add_selector_3.current.expressions[0].value == "10.1.1.1" - name: Remove slector_1 - mso_schema_template_external_epg_selector: + cisco.mso.mso_schema_template_external_epg_selector: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -286,13 +286,13 @@ register: nm_remove_selector_1 - name: Verify nm_remove_selector_1 - assert: + ansible.builtin.assert: that: - nm_remove_selector_1 is changed # QUERY selectors - name: Query all selectors of extEPG1 - mso_schema_template_external_epg_selector: + cisco.mso.mso_schema_template_external_epg_selector: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -301,12 +301,12 @@ register: nm_query_all - name: Verify nm_query_all - assert: + ansible.builtin.assert: that: - nm_query_all is not changed - name: Query a selector of extEPG1 - mso_schema_template_external_epg_selector: + cisco.mso.mso_schema_template_external_epg_selector: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -316,13 +316,13 @@ register: nm_query_selector_2 - name: Verify nm_query_selector_2 - assert: + ansible.builtin.assert: that: - nm_query_selector_2 is not changed - nm_query_selector_2.current.expressions[0].value == "10.0.0.0" - name: Query a removed selector_1 of extEPG1 - mso_schema_template_external_epg_selector: + cisco.mso.mso_schema_template_external_epg_selector: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -333,13 +333,13 @@ register: nm_query_removed - name: Verify nm_query_removed - assert: + ansible.builtin.assert: that: - nm_query_removed.msg == "Selector 'selector_1' not found" # QUERY NON-EXISTING External EPG - name: Query non-existing EPG (normal mode) - mso_schema_template_external_epg_selector: + cisco.mso.mso_schema_template_external_epg_selector: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -350,14 +350,14 @@ register: nm_query_non_epg - name: Verify query_non_epg - assert: + ansible.builtin.assert: that: - nm_query_non_epg is not changed - nm_query_non_epg.msg == "Provided external epg 'non_extEPG1' does not exist. Existing epgs{{':'}} extEPG1, extEPG2" # USE A NON-EXISTING STATE - name: Non-existing state (check_mode) - mso_schema_template_external_epg_selector: + cisco.mso.mso_schema_template_external_epg_selector: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -369,7 +369,7 @@ register: cm_non_existing_state - name: Non-existing state (normal_mode) - mso_schema_template_external_epg_selector: + cisco.mso.mso_schema_template_external_epg_selector: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -380,7 +380,7 @@ register: nm_non_existing_state - name: Verify non_existing_state - assert: + ansible.builtin.assert: that: - cm_non_existing_state is not changed - nm_non_existing_state is not changed @@ -389,7 +389,7 @@ # USE A NON-EXISTING TEMPLATE - name: Non-existing template (check_mode) - mso_schema_template_external_epg_selector: + cisco.mso.mso_schema_template_external_epg_selector: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: non-existing-template @@ -401,7 +401,7 @@ register: cm_non_existing_template - name: Non-existing template (normal_mode) - mso_schema_template_external_epg_selector: + cisco.mso.mso_schema_template_external_epg_selector: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: non-existing-template @@ -412,7 +412,7 @@ register: nm_non_existing_template - name: Verify non_existing_template - assert: + ansible.builtin.assert: that: - cm_non_existing_template is not changed - nm_non_existing_template is not changed @@ -421,7 +421,7 @@ # USE A NON-EXISTING SCHEMA - name: Non-existing schema (check_mode) - mso_schema_template_external_epg_selector: + cisco.mso.mso_schema_template_external_epg_selector: <<: *mso_info schema: non-existing-schema template: Template 1 @@ -433,7 +433,7 @@ register: cm_non_existing_schema - name: Non-existing schema (normal_mode) - mso_schema_template_external_epg_selector: + cisco.mso.mso_schema_template_external_epg_selector: <<: *mso_info schema: non-existing-schema template: Template 1 @@ -444,7 +444,7 @@ register: nm_non_existing_schema - name: Verify non_existing_schema - assert: + ansible.builtin.assert: that: - cm_non_existing_schema is not changed - nm_non_existing_schema is not changed diff --git a/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_external_epg_subnet/tasks/main.yml b/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_external_epg_subnet/tasks/main.yml index 06b5e65b7..56cd80be1 100644 --- a/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_external_epg_subnet/tasks/main.yml +++ b/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_external_epg_subnet/tasks/main.yml @@ -5,14 +5,14 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI MultiSite host, username and password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: mso_hostname, mso_username and mso_password.' when: mso_hostname is not defined or mso_username is not defined or mso_password is not defined # CLEAN ENVIRONMENT - name: Set vars - set_fact: + ansible.builtin.set_fact: mso_info: &mso_info host: '{{ mso_hostname }}' username: '{{ mso_username }}' @@ -23,13 +23,13 @@ output_level: '{{ mso_output_level | default("info") }}' - name: Query MSO version - mso_version: + cisco.mso.mso_version: <<: *mso_info state: query register: version - name: Undeploy templates if deployed from previous test case - mso_schema_template_deploy: + cisco.mso.mso_schema_template_deploy: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: "{{ item }}" @@ -41,7 +41,7 @@ - Template 2 - name: Remove schemas - mso_schema: + cisco.mso.mso_schema: <<: *mso_info schema: '{{ item }}' state: absent @@ -50,7 +50,7 @@ - '{{ mso_schema | default("ansible_test") }}' - name: Ensure ansible_test_1 external EPG does not exist - mso_schema_template_external_epg: + cisco.mso.mso_schema_template_external_epg: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -59,7 +59,7 @@ ignore_errors: true - name: Ensure tenant ansible_test exist - mso_tenant: + cisco.mso.mso_tenant: <<: *mso_info tenant: ansible_test users: @@ -67,7 +67,7 @@ state: present - name: Ensure schema 1 with Template 1 exist - mso_schema_template: + cisco.mso.mso_schema_template: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' tenant: ansible_test @@ -75,7 +75,7 @@ state: present - name: Ensure VRF exist - mso_schema_template_vrf: + cisco.mso.mso_schema_template_vrf: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -83,7 +83,7 @@ state: present - name: Ensure L3out exist - mso_schema_template_l3out: + cisco.mso.mso_schema_template_l3out: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -93,7 +93,7 @@ state: present - name: Ensure ANP exists - mso_schema_template_anp: + cisco.mso.mso_schema_template_anp: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -101,7 +101,7 @@ state: present - name: Add external EPG - mso_schema_template_external_epg: + cisco.mso.mso_schema_template_external_epg: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -112,7 +112,7 @@ # ADD external EPG subnet - name: Add external EPG subnet (check_mode) - mso_schema_template_external_epg_subnet: + cisco.mso.mso_schema_template_external_epg_subnet: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -123,14 +123,14 @@ register: cm_add_epg_subnet - name: Verify cm_add_epg_subnet - assert: + ansible.builtin.assert: that: - cm_add_epg_subnet is changed - cm_add_epg_subnet.previous == {} - cm_add_epg_subnet.current.ip == "10.0.0.0/24" - name: Add external EPG subnet (normal mode) - mso_schema_template_external_epg_subnet: + cisco.mso.mso_schema_template_external_epg_subnet: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -140,14 +140,14 @@ register: nm_add_epg_subnet - name: Verify nm_add_epg_subnet - assert: + ansible.builtin.assert: that: - nm_add_epg_subnet is changed - nm_add_epg_subnet.previous == {} - nm_add_epg_subnet.current.ip == "10.0.0.0/24" - name: Add external EPG subnet again (check_mode) - mso_schema_template_external_epg_subnet: + cisco.mso.mso_schema_template_external_epg_subnet: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -158,14 +158,14 @@ register: cm_add_epg_subnet_again - name: Verify cm_add_epg_subnet_again - assert: + ansible.builtin.assert: that: - cm_add_epg_subnet_again is not changed - cm_add_epg_subnet_again.previous.ip == "10.0.0.0/24" - cm_add_epg_subnet_again.current.ip == "10.0.0.0/24" - name: Add epg again subnet (normal mode) - mso_schema_template_external_epg_subnet: + cisco.mso.mso_schema_template_external_epg_subnet: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -175,14 +175,14 @@ register: nm_add_epg_subnet_again - name: Verify nm_add_epg_subnet_again - assert: + ansible.builtin.assert: that: - nm_add_epg_subnet_again is not changed - nm_add_epg_subnet_again.previous.ip == "10.0.0.0/24" - nm_add_epg_subnet_again.current.ip == "10.0.0.0/24" - name: Add external EPG subnet 2 - mso_schema_template_external_epg_subnet: + cisco.mso.mso_schema_template_external_epg_subnet: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -192,14 +192,14 @@ register: add_epg_subnet_2 - name: Verify add_epg_subnet_2 - assert: + ansible.builtin.assert: that: - add_epg_subnet_2 is changed - add_epg_subnet_2.current.ip == "10.0.0.2/24" # QUERY ALL EPG Subnets - name: Query all EPG (check_mode) - mso_schema_template_external_epg_subnet: + cisco.mso.mso_schema_template_external_epg_subnet: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -209,7 +209,7 @@ register: cm_query_all_epg_subnets - name: Query all EPG (normal mode) - mso_schema_template_external_epg_subnet: + cisco.mso.mso_schema_template_external_epg_subnet: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -218,7 +218,7 @@ register: nm_query_all_epg_subnets - name: Verify query_all_epg_subnets - assert: + ansible.builtin.assert: that: - cm_query_all_epg_subnets is not changed - nm_query_all_epg_subnets is not changed @@ -226,7 +226,7 @@ # QUERY AN EPG subnet - name: Query epg subnet 1(check_mode) - mso_schema_template_external_epg_subnet: + cisco.mso.mso_schema_template_external_epg_subnet: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -237,7 +237,7 @@ register: cm_query_epg_subnet_1 - name: Query epg subnet 1(normal_mode) - mso_schema_template_external_epg_subnet: + cisco.mso.mso_schema_template_external_epg_subnet: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -247,7 +247,7 @@ register: nm_query_epg_subnet_1 - name: Verify cm_query_epg_subnet_1 and nm_query_epg_subnet_1 - assert: + ansible.builtin.assert: that: - cm_query_epg_subnet_1 is not changed - nm_query_epg_subnet_1 is not changed @@ -255,7 +255,7 @@ # REMOVE EPG - name: Remove EPG subnet 1 (check_mode) - mso_schema_template_external_epg_subnet: + cisco.mso.mso_schema_template_external_epg_subnet: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -266,13 +266,13 @@ register: cm_remove_epg_subnet_1 - name: Verify cm_remove_epg_subnet_1 - assert: + ansible.builtin.assert: that: - cm_remove_epg_subnet_1 is changed - cm_remove_epg_subnet_1.current == {} - name: Remove EPG subnet 1 (normal_mode) - mso_schema_template_external_epg_subnet: + cisco.mso.mso_schema_template_external_epg_subnet: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -282,13 +282,13 @@ register: nm_remove_epg_subnet_1 - name: Verify nm_remove_epg_subnet_1 - assert: + ansible.builtin.assert: that: - nm_remove_epg_subnet_1 is changed - nm_remove_epg_subnet_1.current == {} - name: Remove EPG subnet 1 again (normal mode) - mso_schema_template_external_epg_subnet: + cisco.mso.mso_schema_template_external_epg_subnet: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -298,14 +298,14 @@ register: nm_remove_epg_subnet_1_again - name: Verify nm_remove_epg_subnet_1_again - assert: + ansible.builtin.assert: that: - nm_remove_epg_subnet_1_again is not changed - nm_remove_epg_subnet_1_again.previous == nm_remove_epg_subnet_1_again.current == {} # Chcek aggregate when scope parameter Shared control is absent and present - name: Add aggregate without Shared control scope parameter - mso_schema_template_external_epg_subnet: + cisco.mso.mso_schema_template_external_epg_subnet: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -318,12 +318,12 @@ register: add_epg_subnet_no_ag - name: Verify add_epg_subnet_no_ag - assert: + ansible.builtin.assert: that: - add_epg_subnet_no_ag is changed - name: Verify add_epg_subnet_no_ag (3.1.1g to 3.1.1n) - assert: + ansible.builtin.assert: that: - add_epg_subnet_no_ag.msg == "MSO Error 400{{':'}} Bad Request{{':'}} Patch Failed, Received{{':'}} Aggregate should be enabled only if shared-rtctrl is enabled in Scope exception while trying to update schema" when: @@ -331,14 +331,14 @@ - version.current.version is version('3.2', '<') - name: Verify add_epg_subnet_no_ag (version < 3.1.1g) - assert: + ansible.builtin.assert: that: - add_epg_subnet_no_ag.msg == "MSO Error 400{{':'}} Bad Request{{':'}} Aggregate should be enabled only if shared-rtctrl is enabled in Scope" when: - version.current.version is version('3.1.1g', '<') - name: Verify add_epg_subnet_no_ag (version >= 4.0) - assert: + ansible.builtin.assert: that: - add_epg_subnet_no_ag.msg == "MSO Error 400{{':'}} ExternalEPG{{':'}} ansible_test_1 in Schema{{':'}} ansible_test , Template{{':'}} Template1 External EPG validation error{{':'}} aggregate should be enabled only if shared-rtctrl is enabled in Scope for subnet 10.0.0.2/24" when: @@ -349,7 +349,7 @@ when: version.current.version is version('4.0', '<') block: - name: Get Validation status - mso_schema_validate: + cisco.mso.mso_schema_validate: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' state: query @@ -358,7 +358,7 @@ when: version.current.version is version('3.6', '>=') - name: Verify query_validate for a version that's after 3.6 - assert: + ansible.builtin.assert: that: - query_validate is not changed - query_validate.msg is match ("MSO Error 400{{':'}} Bad Request{{':'}} Patch Failed, Received{{':'}} Aggregate should be enabled only if shared-rtctrl is enabled in Scope exception while trying to update schema") @@ -366,7 +366,7 @@ - version.current.version is version('3.6', '>=') - name: Add aggregate with Shared control scope parameter - mso_schema_template_external_epg_subnet: + cisco.mso.mso_schema_template_external_epg_subnet: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -379,13 +379,13 @@ register: add_epg_subnet_ag - name: Verify add_epg_subnet_ag - assert: + ansible.builtin.assert: that: - add_epg_subnet_ag is changed - add_epg_subnet_ag.current.aggregate[0] == "shared-rtctrl" - name: Change EPG subnet 2 by changing Route Controls - mso_schema_template_external_epg_subnet: + cisco.mso.mso_schema_template_external_epg_subnet: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -401,7 +401,7 @@ register: change_epg_subnet - name: Verify change_epg_subnet - assert: + ansible.builtin.assert: that: - change_epg_subnet is changed - change_epg_subnet.current.ip == "10.0.0.2/24" @@ -409,7 +409,7 @@ # QUERY NON-EXISTING EPG subnet - name: Query non-existing EPG subnet(check_mode) - mso_schema_template_external_epg_subnet: + cisco.mso.mso_schema_template_external_epg_subnet: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -421,7 +421,7 @@ register: cm_query_non_existing_epg_subnet - name: Query non-existing EPG subnet(normal_mode) - mso_schema_template_external_epg_subnet: + cisco.mso.mso_schema_template_external_epg_subnet: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -432,7 +432,7 @@ register: nm_query_non_existing_epg_subnet - name: Verify cm_query_non_existing_epg_subnet and nm_query_non_existing_epg_subnet - assert: + ansible.builtin.assert: that: - cm_query_non_existing_epg_subnet is not changed - nm_query_non_existing_epg_subnet is not changed @@ -441,7 +441,7 @@ # QUERY NON-EXISTING EPG - name: Query non-existing EPG subnet(check_mode) - mso_schema_template_external_epg_subnet: + cisco.mso.mso_schema_template_external_epg_subnet: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -453,7 +453,7 @@ register: cm_query_non_existing_epg - name: Query non-existing EPG subnet(normal_mode) - mso_schema_template_external_epg_subnet: + cisco.mso.mso_schema_template_external_epg_subnet: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -464,7 +464,7 @@ register: nm_query_non_existing_epg - name: Verify cm_query_non_existing_epg and nm_query_non_existing_epg - assert: + ansible.builtin.assert: that: - cm_query_non_existing_epg is not changed - nm_query_non_existing_epg is not changed @@ -473,7 +473,7 @@ # USE A NON-EXISTING SCHEMA - name: Non-existing schema for epg subnet(check_mode) - mso_schema_template_external_epg_subnet: + cisco.mso.mso_schema_template_external_epg_subnet: <<: *mso_info schema: non-existing-schema template: Template 1 @@ -485,7 +485,7 @@ register: cm_non_existing_schema - name: Non-existing schema for epg subnet(normal_mode) - mso_schema_template_external_epg_subnet: + cisco.mso.mso_schema_template_external_epg_subnet: <<: *mso_info schema: non-existing-schema template: Template 1 @@ -496,7 +496,7 @@ register: nm_non_existing_schema - name: Verify non_existing_schema - assert: + ansible.builtin.assert: that: - cm_non_existing_schema is not changed - nm_non_existing_schema is not changed @@ -505,7 +505,7 @@ # USE A NON-EXISTING TEMPLATE - name: Non-existing template for epg subnet(check_mode) - mso_schema_template_external_epg_subnet: + cisco.mso.mso_schema_template_external_epg_subnet: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: non-existing-template @@ -517,7 +517,7 @@ register: cm_non_existing_template - name: Non-existing template for epg subnet(normal_mode) - mso_schema_template_external_epg_subnet: + cisco.mso.mso_schema_template_external_epg_subnet: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: non-existing-template @@ -528,7 +528,7 @@ register: nm_non_existing_template - name: Verify non_existing_template - assert: + ansible.builtin.assert: that: - cm_non_existing_template is not changed - nm_non_existing_template is not changed diff --git a/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_filter_entry/tasks/main.yml b/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_filter_entry/tasks/main.yml index 262a1903d..e2648acd6 100644 --- a/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_filter_entry/tasks/main.yml +++ b/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_filter_entry/tasks/main.yml @@ -3,14 +3,14 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI MultiSite host, username and password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: mso_hostname, mso_username and mso_password.' when: mso_hostname is not defined or mso_username is not defined or mso_password is not defined # CLEAN ENVIRONMENT - name: Set vars - set_fact: + ansible.builtin.set_fact: mso_info: &mso_info host: '{{ mso_hostname }}' username: '{{ mso_username }}' @@ -21,13 +21,13 @@ output_level: '{{ mso_output_level | default("info") }}' - name: Query MSO version - mso_version: + cisco.mso.mso_version: <<: *mso_info state: query register: version - name: Ensure site exist - mso_site: &site_present + cisco.mso.mso_site: &site_present <<: *mso_info site: '{{ mso_site | default("ansible_test") }}' apic_username: '{{ apic_username }}' @@ -38,7 +38,7 @@ state: present - name: Remove schemas - mso_schema: + cisco.mso.mso_schema: <<: *mso_info schema: '{{ item }}' state: absent @@ -47,7 +47,7 @@ - '{{ mso_schema | default("ansible_test") }}' - name: Ensure tenant ansible_test exist - mso_tenant: &tenant_present + cisco.mso.mso_tenant: &tenant_present <<: *mso_info tenant: ansible_test users: @@ -57,7 +57,7 @@ state: present - name: Ensure schema 1 with Template1 exist - mso_schema_template: &schema_present + cisco.mso.mso_schema_template: &schema_present <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' tenant: ansible_test @@ -97,7 +97,7 @@ register: add_filter_again - name: Verify add_filter - assert: + ansible.builtin.assert: that: - cm_add_filter is changed - cm_add_filter.previous == {} @@ -123,13 +123,12 @@ when: version.current.version is version('3.3', '>=') - name: Verify add_filter_only - assert: + ansible.builtin.assert: that: - add_filter_descr is changed - add_filter_descr.current.description == "filter entry description" when: version.current.version is version('3.3', '>=') - - name: Create filter without filter entry cisco.mso.mso_schema_template_filter_entry: <<: *mso_info @@ -141,7 +140,7 @@ register: add_filter_only - name: Verify add_filter_only - assert: + ansible.builtin.assert: that: - add_filter_only is not changed - add_filter_only.msg == "state is present but all of the following are missing{{':'}} entry" @@ -194,7 +193,7 @@ register: query_all - name: Verify query - assert: + ansible.builtin.assert: that: - query_filter is not changed - query_all is not changed @@ -223,7 +222,7 @@ register: query_non_existing_entry - name: Verify query cases - assert: + ansible.builtin.assert: that: - query_non_existing_filter is not changed - query_non_existing_entry is not changed @@ -241,7 +240,7 @@ register: remove_filter - name: Verify delete filter_entry3 - assert: + ansible.builtin.assert: that: - remove_filter is changed - remove_filter.current == {} @@ -259,7 +258,7 @@ register: nm_non_existing_template - name: Verify nm_non_existing_template - assert: + ansible.builtin.assert: that: - nm_non_existing_template is not changed - nm_non_existing_template.msg == "Provided template 'non_existing_template' does not exist. Existing templates{{':'}} Template1" @@ -297,7 +296,7 @@ register: remove_non_existing_entry - name: Verify non_existing - assert: + ansible.builtin.assert: that: - query_non_existing_filter is not changed - query_non_existing_filter.msg == "Filter 'non_existing_filter' not found" @@ -305,7 +304,6 @@ - remove_non_existing_entry is not changed - nm_non_existing_template.msg == "Provided template 'non_existing_template' does not exist. Existing templates{{':'}} Template1" - # Delete filter entries - name: Delete filter entry 3 cisco.mso.mso_schema_template_filter_entry: @@ -321,6 +319,6 @@ - 'filter_entry2' - name: Verify remove_multiple_entries - assert: + ansible.builtin.assert: that: - remove_multiple_entries is changed
\ No newline at end of file diff --git a/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_l3out/tasks/main.yml b/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_l3out/tasks/main.yml index a61752fa6..e6cf75650 100644 --- a/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_l3out/tasks/main.yml +++ b/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_l3out/tasks/main.yml @@ -4,13 +4,13 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI MultiSite host, username and password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: mso_hostname, mso_username and mso_password.' when: mso_hostname is not defined or mso_username is not defined or mso_password is not defined # CLEAN ENVIRONMENT - name: Set vars - set_fact: + ansible.builtin.set_fact: mso_info: &mso_info host: '{{ mso_hostname }}' username: '{{ mso_username }}' @@ -21,13 +21,13 @@ output_level: '{{ mso_output_level | default("info") }}' - name: Query MSO version - mso_version: + cisco.mso.mso_version: <<: *mso_info state: query register: version - name: Remove schemas - mso_schema: + cisco.mso.mso_schema: <<: *mso_info schema: '{{ item }}' state: absent @@ -36,7 +36,7 @@ - '{{ mso_schema | default("ansible_test") }}' - name: Ensure tenant ansible_test exists - mso_tenant: + cisco.mso.mso_tenant: <<: *mso_info tenant: ansible_test users: @@ -46,7 +46,7 @@ state: present - name: Ensure schema 1 with Template1, and Template2 exist - mso_schema_template: + cisco.mso.mso_schema_template: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' tenant: ansible_test @@ -57,7 +57,7 @@ - { template: Template2} - name: Ensure VRF1 exists - mso_schema_template_vrf: + cisco.mso.mso_schema_template_vrf: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template1 @@ -65,7 +65,7 @@ state: present - name: Verify L3Out doesn't exist - mso_schema_template_l3out: + cisco.mso.mso_schema_template_l3out: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template1 @@ -73,7 +73,7 @@ state: absent - name: Add new L3Out (check_mode) - mso_schema_template_l3out: + cisco.mso.mso_schema_template_l3out: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template1 @@ -85,7 +85,7 @@ register: cm_add_l3out - name: Add new L3Out (normal mode) - mso_schema_template_l3out: + cisco.mso.mso_schema_template_l3out: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template1 @@ -96,7 +96,7 @@ register: nm_add_l3out - name: Add L3Out again - mso_schema_template_l3out: + cisco.mso.mso_schema_template_l3out: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template1 @@ -107,7 +107,7 @@ register: add_l3out_again - name: Verify add - assert: + ansible.builtin.assert: that: - cm_add_l3out is changed - cm_add_l3out.previous == {} @@ -124,7 +124,7 @@ - nm_add_l3out.current.vrfRef.schemaId == add_l3out_again.current.vrfRef.schemaId - name: Add new L3Outs - mso_schema_template_l3out: + cisco.mso.mso_schema_template_l3out: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template1 @@ -138,12 +138,12 @@ - { l3out: L3out3} - name: Verify add - assert: + ansible.builtin.assert: that: - new_l3outs is changed - name: Query a specific L3Out - mso_schema_template_l3out: + cisco.mso.mso_schema_template_l3out: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template1 @@ -152,7 +152,7 @@ register: query_l3out - name: Query all L3outs - mso_schema_template_l3out: + cisco.mso.mso_schema_template_l3out: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template1 @@ -160,13 +160,13 @@ register: query_all - name: Verify query - assert: + ansible.builtin.assert: that: - query_l3out is not changed - query_all is not changed - name: Remove an L3Out - mso_schema_template_l3out: + cisco.mso.mso_schema_template_l3out: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template1 @@ -175,7 +175,7 @@ register: delete_l3out - name: Verify delete - assert: + ansible.builtin.assert: that: - delete_l3out is changed - delete_l3out.previous.name == "L3out1" @@ -183,7 +183,7 @@ # USE A NON_EXISTING_TEMPLATE - name: non_existing_template (check_mode) - mso_schema_template_l3out: + cisco.mso.mso_schema_template_l3out: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: non_existing_template @@ -196,7 +196,7 @@ register: cm_non_existing_template - name: non_existing_template (normal_mode) - mso_schema_template_l3out: + cisco.mso.mso_schema_template_l3out: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: non_existing_template @@ -208,7 +208,7 @@ register: nm_non_existing_template - name: Verify cm_non_existing_template and nm_non_existing_template - assert: + ansible.builtin.assert: that: - cm_non_existing_template is not changed - nm_non_existing_template is not changed @@ -216,7 +216,7 @@ # QUERY NON-EXISTING L3Out - name: Query non-existing L3Out (check_mode) - mso_schema_template_l3out: + cisco.mso.mso_schema_template_l3out: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template1 @@ -227,7 +227,7 @@ register: cm_query_non_l3out - name: Query non-existing L3Out (normal_mode) - mso_schema_template_l3out: + cisco.mso.mso_schema_template_l3out: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -237,7 +237,7 @@ register: nm_query_non_l3out - name: Verify cm_query_non_l3out and nm_query_non_l3out - assert: + ansible.builtin.assert: that: - cm_query_non_l3out is not changed - nm_query_non_l3out is not changed @@ -246,7 +246,7 @@ # Add description for version >= 3.3 - name: Add new L3Out - mso_schema_template_l3out: + cisco.mso.mso_schema_template_l3out: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template1 @@ -259,7 +259,7 @@ when: version.current.version is version('3.3', '>=') - name: Verify add description - assert: + ansible.builtin.assert: that: - add_desc is changed when: version.current.version is version('3.3', '>=')
\ No newline at end of file diff --git a/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_migrate/tasks/main.yml b/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_migrate/tasks/main.yml index 44940f0d6..219eb7641 100644 --- a/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_migrate/tasks/main.yml +++ b/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_migrate/tasks/main.yml @@ -5,12 +5,12 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI MultiSite host, username and password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: mso_hostname, mso_username and mso_password.' when: mso_hostname is not defined or mso_username is not defined or mso_password is not defined - name: Set vars - set_fact: + ansible.builtin.set_fact: mso_info: &mso_info host: '{{ mso_hostname }}' username: '{{ mso_username }}' @@ -21,14 +21,14 @@ output_level: '{{ mso_output_level | default("info") }}' - name: Query MSO version - mso_version: + cisco.mso.mso_version: <<: *mso_info state: query register: version # CLEAN ENVIRONMENT - name: Ensure site exist - mso_site: &site_present + cisco.mso.mso_site: &site_present host: '{{ mso_hostname }}' username: '{{ mso_username }}' password: '{{ mso_password }}' @@ -45,7 +45,7 @@ state: present - name: Undeploy a schema 2 template 2 - mso_schema_template_deploy: + cisco.mso.mso_schema_template_deploy: <<: *mso_info template: Template 2 schema: '{{ mso_schema | default("ansible_test") }}_2' @@ -55,7 +55,7 @@ register: undeploy_template2 - name: Undeploy a schema 1 template 1 - mso_schema_template_deploy: + cisco.mso.mso_schema_template_deploy: <<: *mso_info template: Template 1 schema: '{{ mso_schema | default("ansible_test") }}' @@ -65,7 +65,7 @@ register: undeploy_template1 - name: Remove a site from a schema 1 with Template 1 - mso_schema_site: + cisco.mso.mso_schema_site: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -75,7 +75,7 @@ register: rm_site_temp1 - name: Remove a site from a schema 2 with Template 2 - mso_schema_site: + cisco.mso.mso_schema_site: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}_2' site: '{{ mso_site | default("ansible_test") }}' @@ -85,7 +85,7 @@ register: rm_site_temp2 - name: Remove schemas - mso_schema: + cisco.mso.mso_schema: host: '{{ mso_hostname }}' username: '{{ mso_username }}' password: '{{ mso_password }}' @@ -101,7 +101,7 @@ - '{{ mso_schema | default("ansible_test") }}' - name: Ensure tenant ansible_test exist - mso_tenant: &tenant_present + cisco.mso.mso_tenant: &tenant_present host: '{{ mso_hostname }}' username: '{{ mso_username }}' password: '{{ mso_password }}' @@ -117,7 +117,7 @@ state: present - name: Ensure schemas with Template 1 exist - mso_schema_template: &schema_present + cisco.mso.mso_schema_template: &schema_present host: '{{ mso_hostname }}' username: '{{ mso_username }}' password: '{{ mso_password }}' @@ -134,7 +134,7 @@ - '{{ mso_schema | default("ansible_test") }}_2' - name: Ensure schema 2 with Template 2 exist - mso_schema_template: + cisco.mso.mso_schema_template: <<: *schema_present schema: '{{ mso_schema | default("ansible_test") }}_2' tenant: ansible_test @@ -143,7 +143,7 @@ register: schema2_template2 - name: Add a new site to a schema 1 with Template 1 in normal mode - mso_schema_site: + cisco.mso.mso_schema_site: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' @@ -152,7 +152,7 @@ register: add_site_nm1 - name: Add a new site to a schema 2 with Template 2 in normal mode - mso_schema_site: + cisco.mso.mso_schema_site: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}_2' site: '{{ mso_site | default("ansible_test") }}' @@ -161,7 +161,7 @@ register: add_site_nm2 - name: Ensure VRF exist - mso_schema_template_vrf: &vrf_present + cisco.mso.mso_schema_template_vrf: &vrf_present host: '{{ mso_hostname }}' username: '{{ mso_username }}' password: '{{ mso_password }}' @@ -176,7 +176,7 @@ state: present - name: Ensure ANP exist - mso_schema_template_anp: + cisco.mso.mso_schema_template_anp: host: '{{ mso_hostname }}' username: '{{ mso_username }}' password: '{{ mso_password }}' @@ -190,7 +190,7 @@ state: present - name: Ensure ANP2 exist - mso_schema_template_anp: + cisco.mso.mso_schema_template_anp: host: '{{ mso_hostname }}' username: '{{ mso_username }}' password: '{{ mso_password }}' @@ -204,7 +204,7 @@ state: present - name: Ensure ansible_test_1 BD exist - mso_schema_template_bd: + cisco.mso.mso_schema_template_bd: <<: *vrf_present schema: '{{ mso_schema | default("ansible_test") }}_2' template: Template 1 @@ -220,7 +220,7 @@ - '{{ BD_2 | default("ansible_test") }}_2' - name: Ensure EPG exist - mso_schema_template_anp_epg: &epg_present + cisco.mso.mso_schema_template_anp_epg: &epg_present host: '{{ mso_hostname }}' username: '{{ mso_username }}' password: '{{ mso_password }}' @@ -242,7 +242,7 @@ register: cm_add_epg - name: Add EPG 2 (normal mode) - mso_schema_template_anp_epg: + cisco.mso.mso_schema_template_anp_epg: <<: *epg_present anp: ANP2 epg: '{{ item }}' @@ -252,7 +252,7 @@ - '{{ EPG_4 | default("ansible_test") }}_4' - name: Migration of objects between templates - mso_schema_template_migrate: + cisco.mso.mso_schema_template_migrate: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}_2' template: Template 1 @@ -270,7 +270,7 @@ register: object_migrate - name: Deploy a schema 1 template 1 after version 4.0 - ndo_schema_template_deploy: + cisco.mso.ndo_schema_template_deploy: <<: *mso_info template: Template 1 schema: '{{ mso_schema | default("ansible_test") }}' @@ -280,7 +280,7 @@ when: version.current.version is version('4.0', '>=') - name: Migration of BD objects between templates - mso_schema_template_migrate: + cisco.mso.mso_schema_template_migrate: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}_2' template: Template 1 @@ -293,7 +293,7 @@ register: bd_migrate - name: Deploy a schema 2 template 2 after version 4.0 - ndo_schema_template_deploy: + cisco.mso.ndo_schema_template_deploy: <<: *mso_info template: Template 2 schema: '{{ mso_schema | default("ansible_test") }}_2' @@ -303,7 +303,7 @@ when: version.current.version is version('4.0', '>=') - name: Migration of EPG objects between templates - mso_schema_template_migrate: + cisco.mso.mso_schema_template_migrate: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}_2' template: Template 1 @@ -323,7 +323,7 @@ - version.current.version is version('4.0', '<') block: - name: Undeploy a schema 2 template 2 - mso_schema_template_deploy: + cisco.mso.mso_schema_template_deploy: <<: *mso_info template: Template 2 schema: '{{ mso_schema | default("ansible_test") }}_2' @@ -333,7 +333,7 @@ register: undeploy_template2 - name: Undeploy a schema 1 template 1 - mso_schema_template_deploy: + cisco.mso.mso_schema_template_deploy: <<: *mso_info template: Template 1 schema: '{{ mso_schema | default("ansible_test") }}' @@ -347,7 +347,7 @@ - version.current.version is version('4.0', '>=') block: - name: Undeploy a schema 2 template 2 - ndo_schema_template_deploy: + cisco.mso.ndo_schema_template_deploy: <<: *mso_info template: Template 2 schema: '{{ mso_schema | default("ansible_test") }}_2' @@ -356,7 +356,7 @@ state: undeploy - name: Undeploy a schema 1 template 1 - ndo_schema_template_deploy: + cisco.mso.ndo_schema_template_deploy: <<: *mso_info template: Template 1 schema: '{{ mso_schema | default("ansible_test") }}' @@ -365,7 +365,7 @@ state: undeploy - name: Remove a site from a schema 2 with Template 2 - mso_schema_site: + cisco.mso.mso_schema_site: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}_2' site: '{{ mso_site | default("ansible_test") }}' @@ -374,7 +374,7 @@ register: rm_site_temp2 - name: Remove a site from a schema 1 with Template 1 - mso_schema_site: + cisco.mso.mso_schema_site: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' site: '{{ mso_site | default("ansible_test") }}' diff --git a/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_service_graph/tasks/main.yml b/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_service_graph/tasks/main.yml index d11a3f4a2..6cb66c2ca 100644 --- a/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_service_graph/tasks/main.yml +++ b/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_service_graph/tasks/main.yml @@ -4,42 +4,41 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI MultiSite host, username and password - fail: - msg: 'Please define the following variables: mso_hostname, mso_username and mso_password.' + ansible.builtin.fail: + msg: "Please define the following variables: mso_hostname, mso_username and mso_password." when: mso_hostname is not defined or mso_username is not defined or mso_password is not defined - # CLEAN ENVIRONMENT - name: Set vars - set_fact: + ansible.builtin.set_fact: mso_info: &mso_info - host: '{{ mso_hostname }}' - username: '{{ mso_username }}' - password: '{{ mso_password }}' - validate_certs: '{{ mso_validate_certs | default(false) }}' - use_ssl: '{{ mso_use_ssl | default(true) }}' - use_proxy: '{{ mso_use_proxy | default(false) }}' + host: "{{ mso_hostname }}" + username: "{{ mso_username }}" + password: "{{ mso_password }}" + validate_certs: "{{ mso_validate_certs | default(false) }}" + use_ssl: "{{ mso_use_ssl | default(true) }}" + use_proxy: "{{ mso_use_proxy | default(false) }}" output_level: '{{ mso_output_level | default("info") }}' - name: Remove schemas - mso_schema: + cisco.mso.mso_schema: <<: *mso_info - schema: '{{ item }}' + schema: "{{ item }}" state: absent loop: - - '{{ mso_schema | default("ansible_test") }}_2' - - '{{ mso_schema | default("ansible_test") }}' + - '{{ mso_schema | default("ansible_test") }}_2' + - '{{ mso_schema | default("ansible_test") }}' - name: Ensure tenant ansible_test exist - mso_tenant: + cisco.mso.mso_tenant: <<: *mso_info tenant: ansible_test users: - - '{{ mso_username }}' + - "{{ mso_username }}" state: present - name: Ensure schema 1 with Template 1 exist - mso_schema_template: + cisco.mso.mso_schema_template: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' tenant: ansible_test @@ -63,17 +62,17 @@ check_mode: true - name: Verify sg1_cm - assert: + ansible.builtin.assert: that: - - sg1_cm is changed - - sg1_cm.current.name == "SG1" - - sg1_cm.current.displayName == "sg" - - sg1_cm.current.nodeFilter == "allow-all" - - sg1_cm.current.serviceGraphRef.templateName == "Template1" - - sg1_cm.current.serviceNodes | length == 3 - - sg1_cm.current.serviceNodes.0.name == "firewall" - - sg1_cm.current.serviceNodes.1.name == "load-balancer" - - sg1_cm.current.serviceNodes.2.name == "other" + - sg1_cm is changed + - sg1_cm.current.name == "SG1" + - sg1_cm.current.displayName == "sg" + - sg1_cm.current.nodeFilter == "allow-all" + - sg1_cm.current.serviceGraphRef.templateName == "Template1" + - sg1_cm.current.serviceNodes | length == 3 + - sg1_cm.current.serviceNodes.0.name == "node1" + - sg1_cm.current.serviceNodes.1.name == "node2" + - sg1_cm.current.serviceNodes.2.name == "node3" - name: Create a service graph (normal mode) cisco.mso.mso_schema_template_service_graph: @@ -97,7 +96,7 @@ template: Template1 service_graph: SG1 display_name: sg - service_nodes: + service_nodes: - type: firewall - type: load-balancer - type: other @@ -106,26 +105,26 @@ register: sg1_again - name: Verify sg1 and sg1_again - assert: + ansible.builtin.assert: that: - - sg1 is changed - - sg1_again is not changed - - sg1.current.name == "SG1" - - sg1.current.displayName == "sg" - - sg1.current.nodeFilter == "allow-all" - - sg1.current.serviceGraphRef.templateName == "Template1" - - sg1.current.serviceNodes | length == 3 - - sg1.current.serviceNodes.0.name == "firewall" - - sg1.current.serviceNodes.1.name == "load-balancer" - - sg1.current.serviceNodes.2.name == "other" - - sg1_again.current.name == "SG1" - - sg1_again.current.displayName == "sg" - - sg1_again.current.nodeFilter == "allow-all" - - sg1_again.current.serviceGraphRef.templateName == "Template1" - - sg1_again.current.serviceNodes | length == 3 - - sg1_again.current.serviceNodes.0.name == "firewall" - - sg1_again.current.serviceNodes.1.name == "load-balancer" - - sg1_again.current.serviceNodes.2.name == "other" + - sg1 is changed + - sg1_again is not changed + - sg1.current.name == "SG1" + - sg1.current.displayName == "sg" + - sg1.current.nodeFilter == "allow-all" + - sg1.current.serviceGraphRef.templateName == "Template1" + - sg1.current.serviceNodes | length == 3 + - sg1.current.serviceNodes.0.name == "node1" + - sg1.current.serviceNodes.1.name == "node2" + - sg1.current.serviceNodes.2.name == "node3" + - sg1_again.current.name == "SG1" + - sg1_again.current.displayName == "sg" + - sg1_again.current.nodeFilter == "allow-all" + - sg1_again.current.serviceGraphRef.templateName == "Template1" + - sg1_again.current.serviceNodes | length == 3 + - sg1_again.current.serviceNodes.0.name == "node1" + - sg1_again.current.serviceNodes.1.name == "node2" + - sg1_again.current.serviceNodes.2.name == "node3" - name: Create another service graph SG2 cisco.mso.mso_schema_template_service_graph: @@ -134,7 +133,7 @@ template: Template1 service_graph: SG2 display_name: Service_Graph2 - service_nodes: + service_nodes: - type: firewall - type: load-balancer filter_after_first_node: filters_from_contract @@ -142,16 +141,16 @@ register: sg2 - name: Verify sg2 - assert: + ansible.builtin.assert: that: - - sg2 is changed - - sg2.current.name == "SG2" - - sg2.current.displayName == "Service_Graph2" - - sg2.current.nodeFilter == "filters-from-contract" - - sg2.current.serviceGraphRef.templateName == "Template1" - - sg2.current.serviceNodes | length == 2 - - sg2.current.serviceNodes.0.name == "firewall" - - sg2.current.serviceNodes.1.name == "load-balancer" + - sg2 is changed + - sg2.current.name == "SG2" + - sg2.current.displayName == "Service_Graph2" + - sg2.current.nodeFilter == "filters-from-contract" + - sg2.current.serviceGraphRef.templateName == "Template1" + - sg2.current.serviceNodes | length == 2 + - sg2.current.serviceNodes.0.name == "node1" + - sg2.current.serviceNodes.1.name == "node2" - name: Change Service Graph SG2 cisco.mso.mso_schema_template_service_graph: @@ -160,7 +159,7 @@ template: Template1 service_graph: SG2 display_name: Service_Graph_changed - service_nodes: + service_nodes: - type: firewall - type: load-balancer filter_after_first_node: filters_from_contract @@ -168,16 +167,16 @@ register: sg2_change - name: Verify sg2_change - assert: + ansible.builtin.assert: that: - - sg2_change is changed - - sg2_change.current.name == "SG2" - - sg2_change.current.displayName == "Service_Graph_changed" - - sg2_change.current.nodeFilter == "filters-from-contract" - - sg2_change.current.serviceGraphRef.templateName == "Template1" - - sg2_change.current.serviceNodes | length == 2 - - sg2_change.current.serviceNodes.0.name == "firewall" - - sg2_change.current.serviceNodes.1.name == "load-balancer" + - sg2_change is changed + - sg2_change.current.name == "SG2" + - sg2_change.current.displayName == "Service_Graph_changed" + - sg2_change.current.nodeFilter == "filters-from-contract" + - sg2_change.current.serviceGraphRef.templateName == "Template1" + - sg2_change.current.serviceNodes | length == 2 + - sg2_change.current.serviceNodes.0.name == "node1" + - sg2_change.current.serviceNodes.1.name == "node2" - name: Create another service graph with no display name cisco.mso.mso_schema_template_service_graph: @@ -185,22 +184,22 @@ schema: '{{ mso_schema | default("ansible_test") }}' template: Template1 service_graph: SG3 - service_nodes: + service_nodes: - type: firewall filter_after_first_node: filters_from_contract state: present register: sg3 - name: Verify sg3 - assert: + ansible.builtin.assert: that: - - sg3 is changed - - sg3.current.name == "SG3" - - sg3.current.displayName == "SG3" - - sg3.current.nodeFilter == "filters-from-contract" - - sg3.current.serviceGraphRef.templateName == "Template1" - - sg3.current.serviceNodes.0.name == "firewall" - - sg3.current.serviceNodes | length == 1 + - sg3 is changed + - sg3.current.name == "SG3" + - sg3.current.displayName == "SG3" + - sg3.current.nodeFilter == "filters-from-contract" + - sg3.current.serviceGraphRef.templateName == "Template1" + - sg3.current.serviceNodes.0.name == "node1" + - sg3.current.serviceNodes | length == 1 - name: Create service graph SG3 with addition of new service node type cisco.mso.mso_schema_template_service_graph: @@ -208,7 +207,7 @@ schema: '{{ mso_schema | default("ansible_test") }}' template: Template1 service_graph: SG3 - service_nodes: + service_nodes: - type: firewall - type: other filter_after_first_node: filters_from_contract @@ -216,16 +215,16 @@ register: sg3_other - name: Verify sg3_other - assert: + ansible.builtin.assert: that: - - sg3_other is changed - - sg3_other.current.name == "SG3" - - sg3_other.current.displayName == "SG3" - - sg3_other.current.nodeFilter == "filters-from-contract" - - sg3_other.current.serviceGraphRef.templateName == "Template1" - - sg3_other.current.serviceNodes.0.name == "firewall" - - sg3_other.current.serviceNodes.1.name == "other" - - sg3_other.current.serviceNodes | length == 2 + - sg3_other is changed + - sg3_other.current.name == "SG3" + - sg3_other.current.displayName == "SG3" + - sg3_other.current.nodeFilter == "filters-from-contract" + - sg3_other.current.serviceGraphRef.templateName == "Template1" + - sg3_other.current.serviceNodes.0.name == "node1" + - sg3_other.current.serviceNodes.1.name == "node2" + - sg3_other.current.serviceNodes | length == 2 - name: Create service graph SG3 interchanging the index of service node types cisco.mso.mso_schema_template_service_graph: @@ -233,7 +232,7 @@ schema: '{{ mso_schema | default("ansible_test") }}' template: Template1 service_graph: SG3 - service_nodes: + service_nodes: - type: other - type: firewall filter_after_first_node: filters_from_contract @@ -241,16 +240,16 @@ register: sg3_interchange - name: Verify sg3_interchange - assert: + ansible.builtin.assert: that: - - sg3_interchange is changed - - sg3_interchange.current.name == "SG3" - - sg3_interchange.current.displayName == "SG3" - - sg3_interchange.current.nodeFilter == "filters-from-contract" - - sg3_interchange.current.serviceGraphRef.templateName == "Template1" - - sg3_interchange.current.serviceNodes.1.name == "firewall" - - sg3_interchange.current.serviceNodes.0.name == "other" - - sg3_interchange.current.serviceNodes | length == 2 + - sg3_interchange is changed + - sg3_interchange.current.name == "SG3" + - sg3_interchange.current.displayName == "SG3" + - sg3_interchange.current.nodeFilter == "filters-from-contract" + - sg3_interchange.current.serviceGraphRef.templateName == "Template1" + - sg3_interchange.current.serviceNodes.1.name == "node2" + - sg3_interchange.current.serviceNodes.0.name == "node1" + - sg3_interchange.current.serviceNodes | length == 2 - name: Create another service graph with non existing node type cisco.mso.mso_schema_template_service_graph: @@ -258,7 +257,7 @@ schema: '{{ mso_schema | default("ansible_test") }}' template: Template1 service_graph: SG4 - service_nodes: + service_nodes: - type: non_existing_type filter_after_first_node: filters_from_contract state: present @@ -266,9 +265,9 @@ ignore_errors: true - name: Verify sg4 - assert: + ansible.builtin.assert: that: - - sg4.msg == "Provided service node type 'non_existing_type' does not exist. Existing node types include{{':'}} firewall, load-balancer, other", + - sg4.msg == "Provided service node type 'non_existing_type' does not exist. Existing node types include{{':'}} firewall, load-balancer, other", - name: Query service graph SG cisco.mso.mso_schema_template_service_graph: @@ -280,16 +279,16 @@ register: query_sg - name: Verify query_sg - assert: + ansible.builtin.assert: that: - - query_sg is not changed - - query_sg.current.name == "SG1" - - query_sg.current.displayName == "sg" - - query_sg.current.nodeFilter == "allow-all" - - query_sg.current.serviceNodes | length == 3 - - query_sg.current.serviceNodes.0.name == "firewall" - - query_sg.current.serviceNodes.1.name == "load-balancer" - - query_sg.current.serviceNodes.2.name == "other" + - query_sg is not changed + - query_sg.current.name == "SG1" + - query_sg.current.displayName == "sg" + - query_sg.current.nodeFilter == "allow-all" + - query_sg.current.serviceNodes | length == 3 + - query_sg.current.serviceNodes.0.name == "node1" + - query_sg.current.serviceNodes.1.name == "node2" + - query_sg.current.serviceNodes.2.name == "node3" - name: Query all service graphs cisco.mso.mso_schema_template_service_graph: @@ -300,10 +299,10 @@ register: query_all - name: Verify query_all - assert: + ansible.builtin.assert: that: - - query_all is not changed - - query_all.current | length == 3 + - query_all is not changed + - query_all.current | length == 3 - name: Query non_existing service graph cisco.mso.mso_schema_template_service_graph: @@ -316,9 +315,9 @@ register: query_non_existing_sg - name: Verify query_non_existing_sg - assert: + ansible.builtin.assert: that: - - query_non_existing_sg.msg == "Service Graph 'non_existent' not found" + - query_non_existing_sg.msg == "Service Graph 'non_existent' not found" - name: Use non_existing schema cisco.mso.mso_schema_template_service_graph: @@ -341,10 +340,10 @@ register: query_non_existing_template - name: Verify query_non_existing_schema and query_non_existing_template - assert: + ansible.builtin.assert: that: - - query_non_existing_schema.msg == "Provided schema 'non_existing_schema' does not exist." - - query_non_existing_template.msg == "Provided template 'non_existing_template' does not exist. Existing templates{{':'}} Template1" + - query_non_existing_schema.msg == "Provided schema 'non_existing_schema' does not exist." + - query_non_existing_template.msg == "Provided template 'non_existing_template' does not exist. Existing templates{{':'}} Template1" - name: Remove service graph (check mode) cisco.mso.mso_schema_template_service_graph: @@ -357,11 +356,11 @@ check_mode: true - name: Verify rm_sg_cm - assert: + ansible.builtin.assert: that: - - rm_sg_cm is changed - - rm_sg_cm.current == {} - - rm_sg_cm.previous.name == "SG1" + - rm_sg_cm is changed + - rm_sg_cm.current == {} + - rm_sg_cm.previous.name == "SG1" - name: Remove service graph (normal mode) cisco.mso.mso_schema_template_service_graph: @@ -373,11 +372,11 @@ register: rm_sg - name: Verify rm_sg - assert: + ansible.builtin.assert: that: - - rm_sg is changed - - rm_sg.current == {} - - rm_sg.previous.name == "SG1" + - rm_sg is changed + - rm_sg.current == {} + - rm_sg.previous.name == "SG1" - name: Remove service graph again cisco.mso.mso_schema_template_service_graph: @@ -389,8 +388,8 @@ register: rm_sg_again - name: Verify rm_sg_again - assert: + ansible.builtin.assert: that: - - rm_sg_again is not changed - - rm_sg_again.current == {} - - rm_sg_again.previous == {} + - rm_sg_again is not changed + - rm_sg_again.current == {} + - rm_sg_again.previous == {} diff --git a/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_vrf/tasks/main.yml b/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_vrf/tasks/main.yml index 0f25a76b0..ed6a2cdd5 100644 --- a/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_vrf/tasks/main.yml +++ b/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_vrf/tasks/main.yml @@ -8,14 +8,14 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI MultiSite host, username and password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: mso_hostname, mso_username and mso_password.' when: mso_hostname is not defined or mso_username is not defined or mso_password is not defined # CLEAN ENVIRONMENT - name: Set vars - set_fact: + ansible.builtin.set_fact: mso_info: &mso_info host: '{{ mso_hostname }}' username: '{{ mso_username }}' @@ -26,7 +26,7 @@ output_level: '{{ mso_output_level | default("info") }}' # - name: Ensure site exist -# mso_site: &site_present +# cisco.mso.mso_site: &site_present # host: '{{ mso_hostname }}' # username: '{{ mso_username }}' # password: '{{ mso_password }}' @@ -43,7 +43,7 @@ # state: present - name: Remove schemas - mso_schema: + cisco.mso.mso_schema: <<: *mso_info schema: '{{ item }}' state: absent @@ -52,7 +52,7 @@ - '{{ mso_schema | default("ansible_test") }}' - name: Ensure tenant ansible_test exist - mso_tenant: + cisco.mso.mso_tenant: <<: *mso_info tenant: ansible_test users: @@ -62,7 +62,7 @@ state: present - name: Ensure schema 1 with Template 1 exist - mso_schema_template: + cisco.mso.mso_schema_template: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' tenant: ansible_test @@ -70,7 +70,7 @@ state: present - name: Ensure schema 1 with Template 2 exist - mso_schema_template: + cisco.mso.mso_schema_template: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' tenant: ansible_test @@ -78,7 +78,7 @@ state: present - name: Ensure schema 2 with Template 3 exist - mso_schema_template: + cisco.mso.mso_schema_template: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}_2' tenant: ansible_test @@ -86,7 +86,7 @@ state: present - name: Ensure Filter 1 exist - mso_schema_template_filter_entry: + cisco.mso.mso_schema_template_filter_entry: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -95,7 +95,7 @@ state: present - name: Ensure Contract1 exist - mso_schema_template_contract_filter: + cisco.mso.mso_schema_template_contract_filter: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -107,7 +107,7 @@ # ADD VRF1 - name: Add a new VRF1 (check mode) - mso_schema_template_vrf: + cisco.mso.mso_schema_template_vrf: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -117,14 +117,14 @@ register: vrf1_cm - name: Verify vrf1_cm - assert: + ansible.builtin.assert: that: - vrf1_cm is changed - vrf1_cm.current.name == 'VRF1' - vrf1_cm.current.displayName == 'VRF1' - name: Add VRF1 (normal mode) - mso_schema_template_vrf: + cisco.mso.mso_schema_template_vrf: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -133,14 +133,14 @@ register: vrf1_nm - name: Verify vrf1_nm - assert: + ansible.builtin.assert: that: - vrf1_nm is changed - vrf1_nm.current.name == 'VRF1' - vrf1_nm.current.displayName == 'VRF1' - name: Add VRF2 (normal mode) - mso_schema_template_vrf: + cisco.mso.mso_schema_template_vrf: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 2 @@ -151,7 +151,7 @@ register: vrf2_nm - name: Verify vrf2_nm - assert: + ansible.builtin.assert: that: - vrf2_nm is changed - vrf2_nm.current.name == 'VRF2' @@ -160,7 +160,7 @@ - vrf2_nm.current.l3MCast == True - name: Add VRF3 (normal mode) - mso_schema_template_vrf: + cisco.mso.mso_schema_template_vrf: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}_2' template: Template 3 @@ -169,14 +169,14 @@ register: vrf3_nm - name: Verify vrf3_nm - assert: + ansible.builtin.assert: that: - vrf3_nm is changed - vrf3_nm.current.name == 'VRF3' - vrf3_nm.current.displayName == 'VRF3' - name: Add preferred_group to VRF3 (normal mode) - mso_schema_template_vrf: + cisco.mso.mso_schema_template_vrf: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}_2' template: Template 3 @@ -186,7 +186,7 @@ register: vrf3_nm_change - name: Verify vrf3_nm_change - assert: + ansible.builtin.assert: that: - vrf3_nm_change is changed - vrf3_nm_change.current.name == 'VRF3' @@ -194,7 +194,7 @@ # ADD EXISTING VRF - name: Add VRF2 again (normal mode) - mso_schema_template_vrf: + cisco.mso.mso_schema_template_vrf: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 2 @@ -205,13 +205,13 @@ register: vrf2_nm_again - name: Verify vrf2_nm_again - assert: + ansible.builtin.assert: that: - vrf2_nm_again is not changed # CHANGE VRF SETTINGS - name: Change VRF1 settings (check mode) - mso_schema_template_vrf: + cisco.mso.mso_schema_template_vrf: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -223,7 +223,7 @@ register: vrf1_change_cm - name: Change VRF1 settings (normal mode) - mso_schema_template_vrf: + cisco.mso.mso_schema_template_vrf: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -234,7 +234,7 @@ register: vrf1_change_nm - name: Change VRF2 settings (check mode) - mso_schema_template_vrf: + cisco.mso.mso_schema_template_vrf: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 2 @@ -248,7 +248,7 @@ register: vrf2_change_cm - name: Change VRF2 settings (normal mode) - mso_schema_template_vrf: + cisco.mso.mso_schema_template_vrf: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 2 @@ -261,7 +261,7 @@ register: vrf2_change_nm - name: Verify vrf2_nm - assert: + ansible.builtin.assert: that: - vrf1_change_cm is changed - vrf1_change_nm is changed @@ -278,7 +278,7 @@ # ADD VRF4 WITH NO STATE - name: Add VRF4 (normal mode) - mso_schema_template_vrf: + cisco.mso.mso_schema_template_vrf: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 2 @@ -287,13 +287,13 @@ register: vrf4_nm_stateless - name: Verify vrf4_nm_stateless - assert: + ansible.builtin.assert: that: - vrf4_nm_stateless is changed # QUERY A VRF - name: Query VRF2 (normal mode) - mso_schema_template_vrf: + cisco.mso.mso_schema_template_vrf: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 2 @@ -302,13 +302,13 @@ register: vrf2_query - name: Verify vrf2_query - assert: + ansible.builtin.assert: that: - vrf2_query is not changed # QUERY ALL VRFs - name: Query all (normal mode) - mso_schema_template_vrf: + cisco.mso.mso_schema_template_vrf: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -316,13 +316,13 @@ register: vrfs_query - name: Verify vrfs_query - assert: + ansible.builtin.assert: that: - vrfs_query is not changed # REMOVE A VRF - name: Remove VRF3 (normal mode) - mso_schema_template_vrf: + cisco.mso.mso_schema_template_vrf: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}_2' template: Template 3 @@ -331,7 +331,7 @@ register: vrf3_remove - name: Verify vrf3_remove - assert: + ansible.builtin.assert: that: - vrf3_remove is changed - vrf3_remove.previous.name == 'VRF3' @@ -339,7 +339,7 @@ # REMOVE A VRF - name: Remove VRF3 again (normal mode) - mso_schema_template_vrf: + cisco.mso.mso_schema_template_vrf: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}_2' template: Template 3 @@ -348,13 +348,13 @@ register: vrf3_remove_again - name: Verify vrf3_remove_again - assert: + ansible.builtin.assert: that: - vrf3_remove_again is not changed # QUERY REMOVED VRF - name: Query VRF3 (normal mode) - mso_schema_template_vrf: + cisco.mso.mso_schema_template_vrf: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 2 @@ -364,13 +364,13 @@ register: vrf3_query_removed - name: Verify vrf3_query_removed - assert: + ansible.builtin.assert: that: - vrf3_query_removed.msg == "VRF 'VRF3' not found" # Enable vzAny on VRF - name: Ensure VRF exist - mso_schema_template_vrf: + cisco.mso.mso_schema_template_vrf: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -379,7 +379,7 @@ state: present - name: Add Contract1 to VRF with type consumer (normal_mode) - mso_schema_template_vrf_contract: + cisco.mso.mso_schema_template_vrf_contract: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -391,7 +391,7 @@ register: nm_add_contract1_consumer - name: Verify nm_add_contract1_consumer - assert: + ansible.builtin.assert: that: - nm_add_contract1_consumer is changed - nm_add_contract1_consumer.previous == {} @@ -400,7 +400,7 @@ - nm_add_contract1_consumer.current.relationshipType == "consumer" - name: Add Contract1 to VRF with type provider (normal_mode) - mso_schema_template_vrf_contract: + cisco.mso.mso_schema_template_vrf_contract: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -412,7 +412,7 @@ register: nm_add_contract1_provider - name: Verify nm_add_contract1_provider - assert: + ansible.builtin.assert: that: - nm_add_contract1_provider is changed - nm_add_contract1_provider.previous == {} @@ -422,7 +422,7 @@ # USE A NON-EXISTING SCHEMA - name: Non-existing schema for VRF (check_mode) - mso_schema_template_vrf: + cisco.mso.mso_schema_template_vrf: <<: *mso_info schema: non_existing_schema template: Template 1 @@ -432,7 +432,7 @@ register: cm_non_existing_schema - name: Non-existing schema for VRF (normal_mode) - mso_schema_template_vrf: + cisco.mso.mso_schema_template_vrf: <<: *mso_info schema: non_existing_schema template: Template 1 @@ -441,7 +441,7 @@ register: nm_non_existing_schema - name: Verify nm_non_existing_schema - assert: + ansible.builtin.assert: that: - cm_non_existing_schema is not changed - nm_non_existing_schema is not changed @@ -450,7 +450,7 @@ # USE A NON-EXISTING TEMPLATE - name: Non-existing template for vrf (check_mode) - mso_schema_template_vrf: + cisco.mso.mso_schema_template_vrf: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: non_existing_template @@ -460,7 +460,7 @@ register: cm_non_existing_template - name: Non-existing template for vrf (normal_mode) - mso_schema_template_vrf: + cisco.mso.mso_schema_template_vrf: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: non_existing_template @@ -469,7 +469,7 @@ register: nm_non_existing_template - name: Verify non_existing_template - assert: + ansible.builtin.assert: that: - cm_non_existing_template is not changed - nm_non_existing_template is not changed @@ -478,7 +478,7 @@ # Checking if contract are removed after re-applying an VRF. - name: Add VRF again (normal_mode) - mso_schema_template_vrf: + cisco.mso.mso_schema_template_vrf: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -488,12 +488,12 @@ register: nm_add_VRF_again - name: Verify that VRF didn't changed - assert: + ansible.builtin.assert: that: - nm_add_VRF_again is not changed - name: Verify contract VRF again - mso_schema_template_vrf_contract: + cisco.mso.mso_schema_template_vrf_contract: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -502,14 +502,14 @@ register: nm_query_vrf_contract_again - name: Verify 2 contracts are in VRF - assert: + ansible.builtin.assert: that: - nm_query_vrf_contract_again is not changed - nm_query_vrf_contract_again.current | length == 2 # Checking if modifying VRF with existing contracts throw an MSO error. (#82) - name: Change VRF (normal_mode) - mso_schema_template_vrf: + cisco.mso.mso_schema_template_vrf: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -520,14 +520,14 @@ register: nm_change_vrf - name: Verify that VRF did change - assert: + ansible.builtin.assert: that: - nm_change_vrf is changed - nm_change_vrf.current.name == "VRF" - nm_change_vrf.current.l3MCast == True - name: Verify contract VRF again - mso_schema_template_vrf_contract: + cisco.mso.mso_schema_template_vrf_contract: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -536,7 +536,7 @@ register: nm_query_change_vrf_contract_again - name: Verify 2 contracts are in VRF - assert: + ansible.builtin.assert: that: - nm_query_change_vrf_contract_again is not changed - nm_query_change_vrf_contract_again.current | length == 2 diff --git a/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_vrf_contract/tasks/main.yml b/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_vrf_contract/tasks/main.yml index 3a5f816a1..931af593a 100644 --- a/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_vrf_contract/tasks/main.yml +++ b/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_vrf_contract/tasks/main.yml @@ -7,14 +7,14 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI MultiSite host, username and password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: mso_hostname, mso_username and mso_password.' when: mso_hostname is not defined or mso_username is not defined or mso_password is not defined # CLEAN ENVIRONMENT - name: Set vars - set_fact: + ansible.builtin.set_fact: mso_info: &mso_info host: '{{ mso_hostname }}' username: '{{ mso_username }}' @@ -25,7 +25,7 @@ output_level: '{{ mso_output_level | default("info") }}' # - name: Ensure site exist -# mso_site: &site_present +# cisco.mso.mso_site: &site_present # host: '{{ mso_hostname }}' # username: '{{ mso_username }}' # password: '{{ mso_password }}' @@ -42,7 +42,7 @@ # state: present - name: Remove schemas - mso_schema: + cisco.mso.mso_schema: <<: *mso_info schema: '{{ item }}' state: absent @@ -51,7 +51,7 @@ - '{{ mso_schema | default("ansible_test") }}' - name: Ensure tenant ansible_test exist - mso_tenant: + cisco.mso.mso_tenant: <<: *mso_info tenant: ansible_test users: @@ -61,7 +61,7 @@ state: present - name: Ensure schema 1 with Template 1 exist - mso_schema_template: + cisco.mso.mso_schema_template: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' tenant: ansible_test @@ -69,7 +69,7 @@ state: present - name: Ensure schema 1 with Template 2 exist - mso_schema_template: + cisco.mso.mso_schema_template: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' tenant: ansible_test @@ -77,7 +77,7 @@ state: present - name: Ensure schema 2 with Template 3 exist - mso_schema_template: + cisco.mso.mso_schema_template: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}_2' tenant: ansible_test @@ -85,7 +85,7 @@ state: present - name: Ensure VRF exist - mso_schema_template_vrf: + cisco.mso.mso_schema_template_vrf: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -93,7 +93,7 @@ state: present - name: Ensure VRF2 exist - mso_schema_template_vrf: + cisco.mso.mso_schema_template_vrf: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -102,7 +102,7 @@ state: present - name: Ensure VRF3 exist - mso_schema_template_vrf: + cisco.mso.mso_schema_template_vrf: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 2 @@ -111,7 +111,7 @@ state: present - name: Ensure VRF4 exist - mso_schema_template_vrf: + cisco.mso.mso_schema_template_vrf: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}_2' template: Template 3 @@ -120,7 +120,7 @@ state: present - name: Ensure Filter 1 exist - mso_schema_template_filter_entry: + cisco.mso.mso_schema_template_filter_entry: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -129,7 +129,7 @@ state: present - name: Ensure Contract1 exist - mso_schema_template_contract_filter: + cisco.mso.mso_schema_template_contract_filter: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -140,7 +140,7 @@ state: present - name: Ensure Contract4 exist - mso_schema_template_contract_filter: + cisco.mso.mso_schema_template_contract_filter: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -151,7 +151,7 @@ state: present - name: Ensure Contract2 exist - mso_schema_template_contract_filter: + cisco.mso.mso_schema_template_contract_filter: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -162,7 +162,7 @@ state: present - name: Ensure Contract3 exist - mso_schema_template_contract_filter: + cisco.mso.mso_schema_template_contract_filter: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -174,7 +174,7 @@ # ADD Contract to VRF - name: Add Contract1 to VRF with vzany disabled - mso_schema_template_vrf_contract: + cisco.mso.mso_schema_template_vrf_contract: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -187,13 +187,13 @@ register: add_contract1_vrf_vzany_disabled - name: Verify add_contract1_vrf_vzany_disabled - assert: + ansible.builtin.assert: that: - add_contract1_vrf_vzany_disabled.msg == "vzAny attribute on vrf 'VRF' is disabled." # Enable vzAny on VRF - name: Ensure VRF exist - mso_schema_template_vrf: + cisco.mso.mso_schema_template_vrf: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -202,7 +202,7 @@ state: present - name: Add Contract1 to VRF with type consumer (check_mode) - mso_schema_template_vrf_contract: + cisco.mso.mso_schema_template_vrf_contract: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -215,7 +215,7 @@ register: cm_add_contract1_consumer - name: Verify cm_add_contract1_consumer - assert: + ansible.builtin.assert: that: - cm_add_contract1_consumer is changed - cm_add_contract1_consumer.previous == {} @@ -224,7 +224,7 @@ - cm_add_contract1_consumer.current.relationshipType == "consumer" - name: Add Contract1 to VRF with type consumer (normal_mode) - mso_schema_template_vrf_contract: + cisco.mso.mso_schema_template_vrf_contract: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -236,7 +236,7 @@ register: nm_add_contract1_consumer - name: Verify nm_add_contract1_consumer - assert: + ansible.builtin.assert: that: - nm_add_contract1_consumer is changed - nm_add_contract1_consumer.previous == {} @@ -246,7 +246,7 @@ - cm_add_contract1_consumer.current.contractRef.schemaId == nm_add_contract1_consumer.current.contractRef.schemaId - name: Add Contract1 to VRF with type provider (normal_mode) - mso_schema_template_vrf_contract: + cisco.mso.mso_schema_template_vrf_contract: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -258,7 +258,7 @@ register: nm_add_contract1_provider - name: Verify nm_add_contract1_provider - assert: + ansible.builtin.assert: that: - nm_add_contract1_provider is changed - nm_add_contract1_provider.previous == {} @@ -267,7 +267,7 @@ - nm_add_contract1_provider.current.relationshipType == "provider" - name: Add Contract1 to VRF with type consumer again(normal_mode) - mso_schema_template_vrf_contract: + cisco.mso.mso_schema_template_vrf_contract: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -279,7 +279,7 @@ register: nm_add_contract1_consumer_again - name: Verify nm_add_contract1_consumer_again - assert: + ansible.builtin.assert: that: - nm_add_contract1_consumer_again is not changed - nm_add_contract1_consumer_again.current.contractRef.templateName == "Template1" == nm_add_contract1_consumer_again.previous.contractRef.templateName @@ -287,7 +287,7 @@ - nm_add_contract1_consumer_again.current.relationshipType == "consumer" == nm_add_contract1_consumer_again.previous.relationshipType - name: Add Contract1 to VRF with type provider again(normal_mode) - mso_schema_template_vrf_contract: + cisco.mso.mso_schema_template_vrf_contract: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -299,7 +299,7 @@ register: nm_add_contract1_provider_again - name: Verify nm_add_contract1_provider_again - assert: + ansible.builtin.assert: that: - nm_add_contract1_provider_again is not changed - nm_add_contract1_provider_again.current.contractRef.templateName == "Template1" == nm_add_contract1_provider_again.previous.contractRef.templateName @@ -307,7 +307,7 @@ - nm_add_contract1_provider_again.current.relationshipType == "provider" == nm_add_contract1_provider_again.previous.relationshipType - name: Add Contract4 to VRF2 with type consumer (normal_mode) - mso_schema_template_vrf_contract: + cisco.mso.mso_schema_template_vrf_contract: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -321,7 +321,7 @@ register: nm_add_vrf2_consumer - name: Add Contract4 to VRF2 with type provider (normal_mode) - mso_schema_template_vrf_contract: + cisco.mso.mso_schema_template_vrf_contract: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -335,7 +335,7 @@ register: nm_add_vrf2_provider - name: nm_add_vrf2_consumer and nm_add_vrf2_provider - assert: + ansible.builtin.assert: that: - nm_add_vrf2_consumer is changed - nm_add_vrf2_provider is changed @@ -346,7 +346,7 @@ - nm_add_vrf2_provider.current.relationshipType == "provider" - name: Add Contract3 to VRF3 with type consumer (normal_mode) - mso_schema_template_vrf_contract: + cisco.mso.mso_schema_template_vrf_contract: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 2 @@ -360,7 +360,7 @@ register: nm_add_vrf3_consumer - name: Add Contract3 to VRF3 with type provider (normal_mode) - mso_schema_template_vrf_contract: + cisco.mso.mso_schema_template_vrf_contract: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 2 @@ -374,7 +374,7 @@ register: nm_add_vrf3_provider - name: nm_add_vrf3_consumer and nm_add_vrf3_provider - assert: + ansible.builtin.assert: that: - nm_add_vrf3_consumer is changed - nm_add_vrf3_provider is changed @@ -385,7 +385,7 @@ - nm_add_vrf3_provider.current.relationshipType == "provider" - name: Add Contract2 to VRF4 with type consumer (normal_mode) - mso_schema_template_vrf_contract: + cisco.mso.mso_schema_template_vrf_contract: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}_2' template: Template 3 @@ -399,7 +399,7 @@ register: nm_add_vrf4_consumer - name: Add Contract2 to VRF4 with type provider (normal_mode) - mso_schema_template_vrf_contract: + cisco.mso.mso_schema_template_vrf_contract: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}_2' template: Template 3 @@ -413,7 +413,7 @@ register: nm_add_vrf4_provider - name: nm_add_vrf4_consumer and nm_add_vrf4_provider - assert: + ansible.builtin.assert: that: - nm_add_vrf4_consumer is changed - nm_add_vrf4_provider is changed @@ -425,7 +425,7 @@ # REMOVE A Contract to VRF - name: Remove contract4 to VRF2 - provider (check_mode) - mso_schema_template_vrf_contract: + cisco.mso.mso_schema_template_vrf_contract: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -438,7 +438,7 @@ register: cm_remove_contract4_vrf2_provider - name: Remove contract4 to VRF2 - provider (normal_mode) - mso_schema_template_vrf_contract: + cisco.mso.mso_schema_template_vrf_contract: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -450,7 +450,7 @@ register: nm_remove_contract4_vrf2_provider - name: Remove contract4 to VRF2 - consumer (normal_mode) - mso_schema_template_vrf_contract: + cisco.mso.mso_schema_template_vrf_contract: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -462,7 +462,7 @@ register: nm_remove_contract4_vrf2_consumer - name: Verify cm_remove_contract4_vrf2_provider and cm_remove_contract4_vrf2_provider and nm_remove_contract4_vrf2_consumer - assert: + ansible.builtin.assert: that: - cm_remove_contract4_vrf2_provider is changed - nm_remove_contract4_vrf2_provider is changed @@ -478,7 +478,7 @@ - nm_remove_contract4_vrf2_consumer.previous.relationshipType == "consumer" - name: Remove contract4 to VRF2 - provider again (normal_mode) - mso_schema_template_vrf_contract: + cisco.mso.mso_schema_template_vrf_contract: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -490,7 +490,7 @@ register: nm_remove_contract4_vrf2_provider_again - name: Verify nm_remove_contract4_vrf2_provider_again - assert: + ansible.builtin.assert: that: - nm_remove_contract4_vrf2_provider_again is not changed - nm_remove_contract4_vrf2_provider_again.previous == {} @@ -498,7 +498,7 @@ # QUERY A Contract to VRF - name: Query Contract1 relationship for VRF - consumer (check_mode) - mso_schema_template_vrf_contract: + cisco.mso.mso_schema_template_vrf_contract: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -511,7 +511,7 @@ register: cm_query_VRF_contract1_consumer - name: Query Contract1 relationship for VRF - consumer (normal_mode) - mso_schema_template_vrf_contract: + cisco.mso.mso_schema_template_vrf_contract: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -524,7 +524,7 @@ register: nm_query_VRF_contract1_consumer - name: Verify cm_query_VRF_contract1_consumer and nm_query_VRF_contract1_consumer - assert: + ansible.builtin.assert: that: - cm_query_VRF_contract1_consumer is not changed - nm_query_VRF_contract1_consumer is not changed @@ -534,7 +534,7 @@ - cm_query_VRF_contract1_consumer.current.contractRef.templateName == nm_query_VRF_contract1_consumer.current.contractRef.templateName == "Template1" - name: Query Contract1 relationship for VRF - provider (check_mode) - mso_schema_template_vrf_contract: + cisco.mso.mso_schema_template_vrf_contract: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -547,7 +547,7 @@ register: cm_query_VRF_contract1_provider - name: Query Contract1 relationship for VRF - provider (normal_mode) - mso_schema_template_vrf_contract: + cisco.mso.mso_schema_template_vrf_contract: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -560,7 +560,7 @@ register: nm_query_VRF_contract1_provider - name: Verify cm_query_VRF_contract1_provider and nm_query_VRF_contract1_provider - assert: + ansible.builtin.assert: that: - cm_query_VRF_contract1_provider is not changed - nm_query_VRF_contract1_provider is not changed @@ -571,7 +571,7 @@ # QUERY ALL Contract to VRF - name: Query all contracts relationship for VRF (check_mode) - mso_schema_template_vrf_contract: + cisco.mso.mso_schema_template_vrf_contract: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -581,7 +581,7 @@ register: cm_query_all_contract_vrf - name: Query all contracts relationship for VRF (normal_mode) - mso_schema_template_vrf_contract: + cisco.mso.mso_schema_template_vrf_contract: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -590,7 +590,7 @@ register: nm_query_all_contract_vrf - name: Verify cm_query_all_contract_vrf and nm_query_all_contract_vrf - assert: + ansible.builtin.assert: that: - nm_query_all_contract_vrf is not changed - cm_query_all_contract_vrf is not changed @@ -598,7 +598,7 @@ # QUERY ALL Contracts to VRF2 - name: Query all contracts relationship for VRF2 (check_mode) - mso_schema_template_vrf_contract: + cisco.mso.mso_schema_template_vrf_contract: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -608,7 +608,7 @@ register: cm_query_all_contract_vrf2 - name: Query all contracts relationship for VRF2 (normal_mode) - mso_schema_template_vrf_contract: + cisco.mso.mso_schema_template_vrf_contract: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -617,7 +617,7 @@ register: nm_query_all_contract_vrf2 - name: Verify cm_query_all_contract_vrf2 and nm_query_all_contract_vrf2 - assert: + ansible.builtin.assert: that: - nm_query_all_contract_vrf2 is not changed - cm_query_all_contract_vrf2 is not changed @@ -625,7 +625,7 @@ # QUERY NON-EXISTING Contract to VRF - name: Query non-existing contract (check_mode) - mso_schema_template_vrf_contract: + cisco.mso.mso_schema_template_vrf_contract: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -639,7 +639,7 @@ register: cm_query_non_existing_contract - name: Query non-existing contract (normal_mode) - mso_schema_template_vrf_contract: + cisco.mso.mso_schema_template_vrf_contract: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -652,7 +652,7 @@ register: nm_query_non_existing_contract - name: Verify cm_query_non_existing_contract and nm_query_non_existing_contract - assert: + ansible.builtin.assert: that: - cm_query_non_existing_contract is not changed - nm_query_non_existing_contract is not changed @@ -662,7 +662,7 @@ # QUERY NON-EXISTING VRF - name: Query non-existing VRF (check_mode) - mso_schema_template_vrf_contract: + cisco.mso.mso_schema_template_vrf_contract: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -673,7 +673,7 @@ register: cm_query_non_existing_vrf - name: Query non-existing VRF (normal_mode) - mso_schema_template_vrf_contract: + cisco.mso.mso_schema_template_vrf_contract: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -683,7 +683,7 @@ register: nm_query_non_existing_vrf - name: Verify cm_query_non_existing_vrf and nm_query_non_existing_vrf - assert: + ansible.builtin.assert: that: - cm_query_non_existing_vrf is not changed - nm_query_non_existing_vrf is not changed @@ -693,7 +693,7 @@ # USE A NON-EXISTING SCHEMA - name: Non-existing schema for contract relationship (check_mode) - mso_schema_template_vrf_contract: + cisco.mso.mso_schema_template_vrf_contract: <<: *mso_info schema: non_existing_schema template: Template 1 @@ -704,7 +704,7 @@ register: cm_query_non_existing_schema - name: Non-existing schema for contract relationship (normal_mode) - mso_schema_template_vrf_contract: + cisco.mso.mso_schema_template_vrf_contract: <<: *mso_info schema: non_existing_schema template: Template 1 @@ -714,7 +714,7 @@ register: nm_query_non_existing_schema - name: Verify cm_query_non_existing_schema and nm_query_non_existing_schema - assert: + ansible.builtin.assert: that: - cm_query_non_existing_schema is not changed - nm_query_non_existing_schema is not changed @@ -722,7 +722,7 @@ - nm_query_non_existing_schema.msg == "Provided schema 'non_existing_schema' does not exist." - name: Non-existing contract schema for contract relationship (check_mode) - mso_schema_template_vrf_contract: + cisco.mso.mso_schema_template_vrf_contract: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -737,7 +737,7 @@ register: cm_query_non_existing_contract_schema - name: Non-existing schema for contract relationship (normal_mode) - mso_schema_template_vrf_contract: + cisco.mso.mso_schema_template_vrf_contract: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -751,7 +751,7 @@ register: nm_query_non_existing_contract_schema - name: Verify cm_query_non_existing_contract_schema and nm_query_non_existing_contract_schema - assert: + ansible.builtin.assert: that: - cm_query_non_existing_contract_schema is not changed - nm_query_non_existing_contract_schema is not changed @@ -760,7 +760,7 @@ # USE A NON-EXISTING TEMPLATE - name: Non-existing templateName for contract relationship (check_mode) - mso_schema_template_vrf_contract: + cisco.mso.mso_schema_template_vrf_contract: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: non_existing_template @@ -771,7 +771,7 @@ register: cm_query_non_existing_template - name: Non-existing templateName for contract relationship (normal_mode) - mso_schema_template_vrf_contract: + cisco.mso.mso_schema_template_vrf_contract: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: non_existing_template @@ -781,7 +781,7 @@ register: nm_query_non_existing_template - name: Verify cm_query_non_existing_template and nm_query_non_existing_template - assert: + ansible.builtin.assert: that: - cm_query_non_existing_template is not changed - nm_query_non_existing_template is not changed @@ -789,7 +789,7 @@ - nm_query_non_existing_template.msg == "Provided template 'non_existing_template' does not exist. Existing templates{{':'}} Template1, Template2" - name: Non-existing contract templateName for contract relationship (check_mode) - mso_schema_template_vrf_contract: + cisco.mso.mso_schema_template_vrf_contract: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -805,7 +805,7 @@ register: cm_query_non_existing_contract_template - name: Non-existing contract templateName for contract relationship (normal_mode) - mso_schema_template_vrf_contract: + cisco.mso.mso_schema_template_vrf_contract: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -820,7 +820,7 @@ register: nm_query_non_existing_contract_template - name: Verify cm_query_non_existing_contract_template and nm_query_non_existing_contract_template - assert: + ansible.builtin.assert: that: - cm_query_non_existing_contract_template is not changed - nm_query_non_existing_contract_template is not changed @@ -829,7 +829,7 @@ # Checking if contract are removed after re-applying an VRF. - name: Add VRF again (normal_mode) - mso_schema_template_vrf: + cisco.mso.mso_schema_template_vrf: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -839,12 +839,12 @@ register: nm_add_VRF_again - name: Verify that VRF didn't changed - assert: + ansible.builtin.assert: that: - nm_add_VRF_again is not changed - name: Verify contract VRF again - mso_schema_template_vrf_contract: + cisco.mso.mso_schema_template_vrf_contract: <<: *mso_info schema: '{{ mso_schema | default("ansible_test") }}' template: Template 1 @@ -853,7 +853,7 @@ register: nm_query_vrf_contract_again - name: Verify 2 contracts are in VRF - assert: + ansible.builtin.assert: that: - nm_query_vrf_contract_again is not changed - nm_query_vrf_contract_again.current | length == 2
\ No newline at end of file diff --git a/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_validate/tasks/main.yml b/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_validate/tasks/main.yml index 9de7d1fb1..54217c8e6 100644 --- a/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_validate/tasks/main.yml +++ b/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_validate/tasks/main.yml @@ -5,7 +5,7 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI MultiSite host, username and password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: mso_hostname, mso_username and mso_password.' when: mso_hostname is not defined or mso_username is not defined or mso_password is not defined diff --git a/ansible_collections/cisco/mso/tests/integration/targets/mso_service_node_type/tasks/main.yml b/ansible_collections/cisco/mso/tests/integration/targets/mso_service_node_type/tasks/main.yml index d6b25df94..22c497200 100644 --- a/ansible_collections/cisco/mso/tests/integration/targets/mso_service_node_type/tasks/main.yml +++ b/ansible_collections/cisco/mso/tests/integration/targets/mso_service_node_type/tasks/main.yml @@ -4,14 +4,14 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI MultiSite host, username and password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: mso_hostname, mso_username and mso_password.' when: mso_hostname is not defined or mso_username is not defined or mso_password is not defined # CLEAN ENVIRONMENT - name: Set vars - set_fact: + ansible.builtin.set_fact: mso_info: &mso_info host: '{{ mso_hostname }}' username: '{{ mso_username }}' @@ -40,7 +40,7 @@ check_mode: true - name: Verify node_cm - assert: + ansible.builtin.assert: that: - node_cm is changed - node_cm.current.displayName == "test" @@ -55,7 +55,7 @@ register: node1 - name: Verify node1 - assert: + ansible.builtin.assert: that: - node1 is changed - node1.current.displayName == "test" @@ -69,7 +69,7 @@ register: node2 - name: Verify node2 - assert: + ansible.builtin.assert: that: - node2 is changed - node2.current.displayName == "TEST2" @@ -83,7 +83,7 @@ register: node2_again - name: Verify node2_again - assert: + ansible.builtin.assert: that: - node2_again is not changed - node2_again.current.displayName == "TEST2" @@ -99,7 +99,7 @@ ignore_errors: true - name: Verify node2_different_display_name - assert: + ansible.builtin.assert: that: - node2_different_display_name.msg == "Service Node Type 'TEST1' already exists with display name 'test' which is different from provided display name 'change_test'." @@ -111,7 +111,7 @@ register: query_node1 - name: Verify query_node1 - assert: + ansible.builtin.assert: that: - query_node1 is not changed - query_node1.current.displayName == "test" @@ -124,7 +124,7 @@ register: query_all - name: Verify query_all - assert: + ansible.builtin.assert: that: - query_all is not changed - query_all.current | length >= 4 @@ -138,7 +138,7 @@ register: cm_rm - name: Verify cm_rm - assert: + ansible.builtin.assert: that: - cm_rm is changed - cm_rm.previous.name == "TEST1" @@ -151,7 +151,7 @@ register: rm_node1 - name: Verify rm_node1 - assert: + ansible.builtin.assert: that: - rm_node1 is changed - rm_node1.current == {} @@ -166,7 +166,7 @@ ignore_errors: true - name: Verify query_absent - assert: + ansible.builtin.assert: that: - query_absent.msg == "Service Node Type 'TEST1' not found" @@ -178,7 +178,7 @@ register: rm_node2 - name: Verify rm_node2 - assert: + ansible.builtin.assert: that: - rm_node2 is changed - rm_node2.current == {} @@ -192,7 +192,7 @@ register: rm_node2_again - name: Verify rm_node2_again - assert: + ansible.builtin.assert: that: - rm_node2_again is not changed - rm_node2_again.current == {} diff --git a/ansible_collections/cisco/mso/tests/integration/targets/mso_site/tasks/main.yml b/ansible_collections/cisco/mso/tests/integration/targets/mso_site/tasks/main.yml index 9285613cb..0da63e0d0 100644 --- a/ansible_collections/cisco/mso/tests/integration/targets/mso_site/tasks/main.yml +++ b/ansible_collections/cisco/mso/tests/integration/targets/mso_site/tasks/main.yml @@ -4,14 +4,14 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI MultiSite host, username and password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: mso_hostname, mso_username and mso_password.' when: mso_hostname is not defined or mso_username is not defined or mso_password is not defined # CLEAN ENVIRONMENT - name: Set vars - set_fact: + ansible.builtin.set_fact: site_dict: {} mso_info: &mso_info host: '{{ mso_hostname }}' @@ -23,13 +23,13 @@ output_level: '{{ mso_output_level | default("info") }}' - name: Query MSO version - mso_version: + cisco.mso.mso_version: <<: *mso_info state: query register: version - name: Undeploy a schema 1 template 1 - mso_schema_template_deploy: &schema_undeploy + cisco.mso.mso_schema_template_deploy: &schema_undeploy <<: *mso_info schema: ansible_test template: Template 1 @@ -41,7 +41,7 @@ - '{{ mso_site | default("ansible_test") }}_2' - name: Undeploy a schema 1 template 2 - mso_schema_template_deploy: + cisco.mso.mso_schema_template_deploy: <<: *schema_undeploy template: Template 2 site: '{{ item }}' @@ -52,7 +52,7 @@ - '{{ mso_site | default("ansible_test") }}_2' - name: Undeploy a schema 2 template 3 - mso_schema_template_deploy: + cisco.mso.mso_schema_template_deploy: <<: *schema_undeploy schema: ansible_test_2 template: Template 3 @@ -64,7 +64,7 @@ - '{{ mso_site | default("ansible_test") }}_2' - name: Remove schemas - mso_schema: + cisco.mso.mso_schema: <<: *mso_info schema: '{{ item }}' state: absent @@ -75,33 +75,32 @@ - 'Schema2' - name: Remove tenant ansible_test - mso_tenant: &tenant_absent + cisco.mso.mso_tenant: &tenant_absent <<: *mso_info tenant: ansible_test state: absent - name: Remove tenant ansible_test2 - mso_tenant: + cisco.mso.mso_tenant: <<: *tenant_absent tenant: ansible_test2 register: cm_remove_tenant - name: Remove site - mso_site: &site_absent + cisco.mso.mso_site: &site_absent <<: *mso_info site: '{{ mso_site | default("ansible_test") }}' state: absent - name: Remove site 2 - mso_site: + cisco.mso.mso_site: <<: *site_absent site: '{{ mso_site | default("ansible_test") }}_2' register: cm_remove_site - # ADD SITE - name: Add site (check_mode) - mso_site: &site_present + cisco.mso.mso_site: &site_present <<: *mso_info site: '{{ mso_site | default("ansible_test") }}' apic_username: '{{ apic_username }}' @@ -121,101 +120,100 @@ register: cm_add_site - name: Verify cm_add_site - assert: + ansible.builtin.assert: that: - cm_add_site is changed - cm_add_site.previous == {} - name: Verify cm_add_site (MSO) - assert: + ansible.builtin.assert: that: - cm_add_site.current.id is not defined - cm_add_site.current.name == mso_site|default("ansible_test") when: version.current.version is version('3.2', '<') - name: Verify cm_add_site (ND) - assert: + ansible.builtin.assert: that: - cm_add_site.current.id == "" - cm_add_site.current.common.name == mso_site|default("ansible_test") when: version.current.version is version('3.2', '>=') - name: Add site (normal mode) - mso_site: *site_present + cisco.mso.mso_site: *site_present register: nm_add_site - name: Verify nm_add_site - assert: + ansible.builtin.assert: that: - nm_add_site is changed - nm_add_site.previous == {} - name: Verify nm_add_site (MSO) - assert: + ansible.builtin.assert: that: - nm_add_site.current.id is defined - nm_add_site.current.name == mso_site|default("ansible_test") when: version.current.version is version('3.2', '<') - name: Verify nm_add_site (ND) - assert: + ansible.builtin.assert: that: - nm_add_site.current.common.name == mso_site|default("ansible_test") when: version.current.version is version('3.2', '>=') - name: Add site again (check_mode) - mso_site: *site_present + cisco.mso.mso_site: *site_present check_mode: true register: cm_add_site_again - name: Verify cm_add_site_again - assert: + ansible.builtin.assert: that: - cm_add_site_again is not changed - cm_add_site_again.current.id == nm_add_site.current.id - name: Verify cm_add_site_again (MSO) - assert: + ansible.builtin.assert: that: - cm_add_site_again.previous.name == mso_site|default("ansible_test") - cm_add_site_again.current.name == mso_site|default("ansible_test") when: version.current.version is version('3.2', '<') - name: Verify cm_add_site_again (ND) - assert: + ansible.builtin.assert: that: - cm_add_site_again.previous.common.name == mso_site|default("ansible_test") - cm_add_site_again.current.common.name == mso_site|default("ansible_test") when: version.current.version is version('3.2', '>=') - name: Add site again (normal mode) - mso_site: *site_present + cisco.mso.mso_site: *site_present register: nm_add_site_again - name: Verify nm_add_site_again - assert: + ansible.builtin.assert: that: - nm_add_site_again is not changed - nm_add_site_again.current.id == nm_add_site.current.id - name: Verify nm_add_site_again (MSO) - assert: + ansible.builtin.assert: that: - nm_add_site_again.previous.name == mso_site|default("ansible_test") - nm_add_site_again.current.name == mso_site|default("ansible_test") when: version.current.version is version('3.2', '<') - name: Verify nm_add_site_again (ND) - assert: + ansible.builtin.assert: that: - nm_add_site_again.previous.common.name == mso_site|default("ansible_test") - nm_add_site_again.current.common.name == mso_site|default("ansible_test") when: version.current.version is version('3.2', '>=') - # CHANGE SITE - name: Change site (check_mode) - mso_site: + cisco.mso.mso_site: <<: *site_present site: '{{ mso_site | default("ansible_test") }}' apic_login_domain: '{{ apic_login_domain | default("test") }}' @@ -229,12 +227,12 @@ register: cm_change_site - name: Verify cm_change_site - assert: + ansible.builtin.assert: that: - cm_change_site.current.id == nm_add_site.current.id - name: Verify cm_change_site (MSO) - assert: + ansible.builtin.assert: that: - cm_change_site is changed - cm_change_site.current.location.lat == 51.887318 @@ -245,13 +243,13 @@ when: version.current.version is version('3.2', '<') - name: Verify cm_change_site (ND) - assert: + ansible.builtin.assert: that: - cm_change_site.current.common.name == mso_site|default("ansible_test") when: version.current.version is version('3.2', '>=') - name: Change site (normal mode) - mso_site: + cisco.mso.mso_site: <<: *site_present site: '{{ mso_site | default("ansible_test") }}' apic_login_domain: '{{ apic_login_domain | default("test") }}' @@ -265,12 +263,12 @@ register: nm_change_site - name: Verify nm_change_site - assert: + ansible.builtin.assert: that: - nm_change_site.current.id == nm_add_site.current.id - name: Verify nm_change_site (MSO) - assert: + ansible.builtin.assert: that: - nm_change_site is changed - nm_change_site.current.location.lat == 51.887318 @@ -281,13 +279,13 @@ when: version.current.version is version('3.2', '<') - name: Verify nm_change_site (ND) - assert: + ansible.builtin.assert: that: - nm_change_site.current.common.name == mso_site|default("ansible_test") when: version.current.version is version('3.2', '>=') - name: Change site again (check_mode) - mso_site: + cisco.mso.mso_site: <<: *site_present site: '{{ mso_site | default("ansible_test") }}' apic_login_domain: '{{ apic_login_domain | default("test") }}' @@ -301,13 +299,13 @@ register: cm_change_site_again - name: Verify cm_change_site_again - assert: + ansible.builtin.assert: that: - cm_change_site_again is not changed - cm_change_site_again.current.id == nm_add_site.current.id - name: Verify cm_change_site_again (MSO) - assert: + ansible.builtin.assert: that: - cm_change_site_again.current.location.lat == 51.887318 - cm_change_site_again.current.location.long == 5.447084 @@ -317,13 +315,13 @@ when: version.current.version is version('3.2', '<') - name: Verify cm_change_site_again (ND) - assert: + ansible.builtin.assert: that: - cm_change_site_again.current.common.name == mso_site|default("ansible_test") when: version.current.version is version('3.2', '>=') - name: Change site again (normal mode) - mso_site: + cisco.mso.mso_site: <<: *site_present site: '{{ mso_site | default("ansible_test") }}' apic_login_domain: '{{ apic_login_domain | default("test") }}' @@ -337,13 +335,13 @@ register: nm_change_site_again - name: Verify nm_change_site_again - assert: + ansible.builtin.assert: that: - nm_change_site_again is not changed - nm_change_site_again.current.id == nm_add_site.current.id - name: Verify nm_change_site_again (MSO) - assert: + ansible.builtin.assert: that: - nm_change_site_again.current.location.lat == 51.887318 - nm_change_site_again.current.location.long == 5.447084 @@ -353,48 +351,47 @@ when: version.current.version is version('3.2', '<') - name: Verify nm_change_site_again (ND) - assert: + ansible.builtin.assert: that: - nm_change_site_again.current.common.name == mso_site|default("ansible_test") when: version.current.version is version('3.2', '>=') # QUERY ALL SITES - name: Query all sites (check_mode) - mso_site: &site_query + cisco.mso.mso_site: &site_query <<: *mso_info state: query check_mode: true register: cm_query_all_sites - name: Query all sites (normal mode) - mso_site: *site_query + cisco.mso.mso_site: *site_query register: nm_query_all_sites - name: Verify query_all_sites - assert: + ansible.builtin.assert: that: - cm_query_all_sites is not changed - nm_query_all_sites is not changed # NOTE: Order of sites is not stable between calls #- cm_query_all_sites == nm_query_all_sites - # QUERY A SITE - name: Query our site - mso_site: + cisco.mso.mso_site: <<: *site_query site: '{{ mso_site | default("ansible_test") }}' check_mode: true register: cm_query_site - name: Query our site - mso_site: + cisco.mso.mso_site: <<: *site_query site: '{{ mso_site | default("ansible_test") }}' register: nm_query_site - name: Verify query_site - assert: + ansible.builtin.assert: that: - cm_query_site is not changed - cm_query_site.current.id == nm_add_site.current.id @@ -403,14 +400,14 @@ - cm_query_site == nm_query_site - name: Verify query_site (MSO) - assert: + ansible.builtin.assert: that: - cm_query_site.current.name == mso_site|default("ansible_test") - nm_query_site.current.name == mso_site|default("ansible_test") when: version.current.version is version('3.2', '<') - name: Verify query_site (ND) - assert: + ansible.builtin.assert: that: - cm_query_site.current.common.name == mso_site|default("ansible_test") - nm_query_site.current.common.name == mso_site|default("ansible_test") @@ -418,65 +415,64 @@ # REMOVE SITE - name: Remove site (check_mode) - mso_site: *site_absent + cisco.mso.mso_site: *site_absent check_mode: true register: cm_remove_site - name: Verify cm_remove_site - assert: + ansible.builtin.assert: that: - cm_remove_site is changed - cm_remove_site.current == {} - name: Remove site (normal mode) - mso_site: *site_absent + cisco.mso.mso_site: *site_absent register: nm_remove_site - name: Verify nm_remove_site - assert: + ansible.builtin.assert: that: - nm_remove_site is changed - nm_remove_site.current == {} - name: Remove site again (check_mode) - mso_site: *site_absent + cisco.mso.mso_site: *site_absent check_mode: true register: cm_remove_site_again - name: Verify cm_remove_site_again - assert: + ansible.builtin.assert: that: - cm_remove_site_again is not changed - cm_remove_site_again.current == {} - name: Remove site again (normal mode) - mso_site: *site_absent + cisco.mso.mso_site: *site_absent register: nm_remove_site_again - name: Verify nm_remove_site_again - assert: + ansible.builtin.assert: that: - nm_remove_site_again is not changed - nm_remove_site_again.current == {} - # QUERY NON-EXISTING SITE - name: Query non-existing site (check_mode) - mso_site: + cisco.mso.mso_site: <<: *site_query site: '{{ mso_site | default("ansible_test") }}' check_mode: true register: cm_query_non_site - name: Query non-existing site (normal mode) - mso_site: + cisco.mso.mso_site: <<: *site_query site: '{{ mso_site | default("ansible_test") }}' register: nm_query_non_site # TODO: Implement more tests - name: Verify query_non_site - assert: + ansible.builtin.assert: that: - cm_query_non_site is not changed - nm_query_non_site is not changed @@ -484,7 +480,7 @@ # USE A NON-EXISTING STATE - name: Non-existing state for site (check_mode) - mso_site: + cisco.mso.mso_site: <<: *site_query state: non-existing-state check_mode: true @@ -492,14 +488,14 @@ register: cm_non_existing_state - name: Non-existing state for bd (normal_mode) - mso_site: + cisco.mso.mso_site: <<: *site_query state: non-existing-state ignore_errors: true register: nm_non_existing_state - name: Verify non_existing_state - assert: + ansible.builtin.assert: that: - cm_non_existing_state is not changed - nm_non_existing_state is not changed @@ -508,7 +504,7 @@ # ADD SITE - name: Add site (normal_mode) - mso_site: + cisco.mso.mso_site: <<: *mso_info site: '{{ mso_site | default("ansible_test") }}' apic_username: '{{ apic_username }}' @@ -521,20 +517,20 @@ register: nm_add_site_no_location - name: Verify nm_add_site_no_location - assert: + ansible.builtin.assert: that: - nm_add_site_no_location is changed - nm_add_site_no_location.previous == {} - nm_add_site_no_location.current.id is defined - name: Verify nm_add_site_no_location (MSO) - assert: + ansible.builtin.assert: that: - nm_add_site_no_location.current.name == mso_site|default("ansible_test") when: version.current.version is version('3.2', '<') - name: Verify nm_add_site_no_location (ND) - assert: + ansible.builtin.assert: that: - nm_add_site_no_location.current.common.name == mso_site|default("ansible_test") when: version.current.version is version('3.2', '>=') @@ -543,18 +539,18 @@ when: version.current.version is version('4.0', '>=') block: - name: Query all sites (check_mode) - mso_site: + cisco.mso.mso_site: <<: *mso_info state: query register: sites - name: Add sites to dict - set_fact: + ansible.builtin.set_fact: site_dict: "{{ site_dict | combine( { item.common.name : { 'id' : item.id, 'site_group_id' : item.common.siteGroup } } ) }}" loop: "{{ sites.current }}" - name: Render a connectivity jinja2 template - set_fact: + ansible.builtin.set_fact: site_payload: "{{ lookup('template', 'connectivity.j2') }}" - name: Configure site connectivity diff --git a/ansible_collections/cisco/mso/tests/integration/targets/mso_tenant/tasks/main.yml b/ansible_collections/cisco/mso/tests/integration/targets/mso_tenant/tasks/main.yml index e5cc5a0e6..88a12ee95 100644 --- a/ansible_collections/cisco/mso/tests/integration/targets/mso_tenant/tasks/main.yml +++ b/ansible_collections/cisco/mso/tests/integration/targets/mso_tenant/tasks/main.yml @@ -4,14 +4,14 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI MultiSite host, username and password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: mso_hostname, mso_username and mso_password.' when: mso_hostname is not defined or mso_username is not defined or mso_password is not defined # CLEAN ENVIRONMENT - name: Set vars - set_fact: + ansible.builtin.set_fact: mso_info: &mso_info host: '{{ mso_hostname }}' username: '{{ mso_username }}' @@ -22,7 +22,7 @@ output_level: '{{ mso_output_level | default("info") }}' - name: Ensure sites exists - mso_site: + cisco.mso.mso_site: <<: *mso_info site: '{{ item.site }}' apic_username: '{{ item.username }}' @@ -36,7 +36,7 @@ - { site: 'aws_{{ mso_site | default("ansible_test") }}', username: '{{ aws_apic_username }}', password: '{{ aws_apic_password }}', id: '{{ aws_site_id | default(102) }}', urls: '{{ aws_apic_hostname }}' } - name: Undeploy a schema 1 template 1 - mso_schema_template_deploy: &schema_undeploy + cisco.mso.mso_schema_template_deploy: &schema_undeploy <<: *mso_info schema: ansible_test template: Template 1 @@ -48,7 +48,7 @@ - 'aws_{{ mso_site | default("ansible_test") }}' - name: Undeploy a schema 1 template 2 - mso_schema_template_deploy: + cisco.mso.mso_schema_template_deploy: <<: *schema_undeploy template: Template 2 site: '{{ item }}' @@ -59,7 +59,7 @@ - 'aws_{{ mso_site | default("ansible_test") }}' - name: Undeploy a schema 2 template 3 - mso_schema_template_deploy: + cisco.mso.mso_schema_template_deploy: <<: *schema_undeploy schema: ansible_test_2 template: Template 3 @@ -71,7 +71,7 @@ - 'aws_{{ mso_site | default("ansible_test") }}' - name: Remove schemas - mso_schema: + cisco.mso.mso_schema: <<: *mso_info schema: '{{ item }}' state: absent @@ -80,7 +80,7 @@ - '{{ mso_schema | default("ansible_test") }}' - name: Remove tenants - mso_tenant: &tenant_absent + cisco.mso.mso_tenant: &tenant_absent <<: *mso_info tenant: '{{ item }}' state: absent @@ -92,7 +92,7 @@ # ADD TENANT - name: Add tenant (check_mode) - mso_tenant: &tenant_present + cisco.mso.mso_tenant: &tenant_present <<: *mso_info tenant: ansible_test display_name: Ansible test title @@ -102,7 +102,7 @@ register: cm_add_tenant - name: Verify cm_add_tenant - assert: + ansible.builtin.assert: that: - cm_add_tenant is changed - cm_add_tenant.previous == {} @@ -112,11 +112,11 @@ - cm_add_tenant.current.userAssociations | length == 1 - name: Add tenant (normal mode) - mso_tenant: *tenant_present + cisco.mso.mso_tenant: *tenant_present register: nm_add_tenant - name: Verify nm_add_tenant - assert: + ansible.builtin.assert: that: - nm_add_tenant is changed - nm_add_tenant.previous == {} @@ -126,12 +126,12 @@ - nm_add_tenant.current.userAssociations | length == 1 - name: Add tenant again (check_mode) - mso_tenant: *tenant_present + cisco.mso.mso_tenant: *tenant_present check_mode: true register: cm_add_tenant_again - name: Verify cm_add_tenant_again - assert: + ansible.builtin.assert: that: - cm_add_tenant_again is not changed - cm_add_tenant_again.previous.name == 'ansible_test' @@ -142,11 +142,11 @@ - cm_add_tenant_again.current.userAssociations == cm_add_tenant_again.previous.userAssociations - name: Add tenant again (normal mode) - mso_tenant: *tenant_present + cisco.mso.mso_tenant: *tenant_present register: nm_add_tenant_again - name: Verify nm_add_tenant_again - assert: + ansible.builtin.assert: that: - nm_add_tenant_again is not changed - nm_add_tenant_again.previous.name == 'ansible_test' @@ -158,7 +158,7 @@ # ADD TENANT WITH USERS - name: Add tenant 2 (normal mode) - mso_tenant: + cisco.mso.mso_tenant: <<: *tenant_present tenant: ansible_test2 users: @@ -168,24 +168,24 @@ register: nm_add_tenant2 - name: Verify nm_add_tenant2 - assert: + ansible.builtin.assert: that: - nm_add_tenant2 is changed - name: Verify nm_add_tenant2 (when mso_username != admin) - assert: + ansible.builtin.assert: that: - nm_add_tenant2.current.userAssociations | length == 2 when: mso_username != 'admin' - name: Verify nm_add_tenant2 (when mso_username == admin) - assert: + ansible.builtin.assert: that: - nm_add_tenant2.current.userAssociations | length == 1 when: mso_username == 'admin' - name: Add tenant 2 again (normal mode) - mso_tenant: + cisco.mso.mso_tenant: <<: *tenant_present tenant: ansible_test2 users: @@ -195,24 +195,59 @@ register: nm_add_tenant2_again - name: Verify nm_add_tenant2_again - assert: + ansible.builtin.assert: that: - nm_add_tenant2_again is not changed - name: Verify nm_add_tenant2_again (when mso_username != admin) - assert: + ansible.builtin.assert: that: - nm_add_tenant2_again.current.userAssociations | length == 2 when: mso_username != 'admin' - name: Verify nm_add_tenant2_again (when mso_username == admin) - assert: + ansible.builtin.assert: that: - nm_add_tenant2_again.current.userAssociations | length == 1 when: mso_username == 'admin' +# ADD TENANT WITH REMOTE USERS +- name: Add tenant 3 (check_mode) + cisco.mso.mso_tenant: + <<: *tenant_present + tenant: ansible_test3 + display_name: null + remote_users: + - name: ansible_github_ci + login_domain: test + state: present + check_mode: true + register: cm_add_rmt_usr_tenant3 + +- name: Verify cm_add_rmt_usr_tenant3 + ansible.builtin.assert: + that: + - cm_add_rmt_usr_tenant3 is changed + +- name: Add tenant 3 (normal_mode) + cisco.mso.mso_tenant: + <<: *tenant_present + tenant: ansible_test3 + display_name: null + remote_users: + - name: ansible_github_ci + login_domain: test + state: present + register: nm_add_rmt_usr_tenant3 + +- name: Verify cm_add_rmt_usr_tenant3 + ansible.builtin.assert: + that: + - nm_add_rmt_usr_tenant3 is changed + - nm_add_rmt_usr_tenant3.current.name == 'ansible_test3' + - name: Add tenant 3 with duplicate admin user (normal mode) - mso_tenant: + cisco.mso.mso_tenant: <<: *tenant_present tenant: ansible_test3 users: @@ -224,13 +259,13 @@ register: nm_add_tenant3_with_duplicate_admin - name: Verify nm_add_tenant3_with_duplicate_admin - assert: + ansible.builtin.assert: that: - - nm_add_tenant3_with_duplicate_admin is not changed + - nm_add_tenant3_with_duplicate_admin is changed - nm_add_tenant3_with_duplicate_admin.msg == "User 'admin' is duplicate." - name: Add tenant 3 with invalid user (normal mode) - mso_tenant: + cisco.mso.mso_tenant: <<: *tenant_present tenant: ansible_test3 users: @@ -241,41 +276,44 @@ register: nm_add_tenant3_with_invalid_user - name: nm_add_tenant3_with_invalid_user - assert: + ansible.builtin.assert: that: - nm_add_tenant3_with_invalid_user is not changed - nm_add_tenant3_with_invalid_user.msg == "User 'invalid user' is not a valid user name." - name: Add tenant 3 (normal mode) - mso_tenant: + cisco.mso.mso_tenant: <<: *tenant_present tenant: ansible_test3 users: - '{{ mso_username }}' + remote_users: + - name: ansible_github_ci + login_domain: test display_name: null state: present register: nm_add_tenant3 - name: Verify nm_add_tenant3 - assert: + ansible.builtin.assert: that: - nm_add_tenant3 is changed - name: Verify nm_add_tenant3 (when mso_username != admin) - assert: + ansible.builtin.assert: that: - - nm_add_tenant3.current.userAssociations | length == 2 + - nm_add_tenant3.current.userAssociations | length == 3 when: mso_username != 'admin' - name: Verify nm_add_tenant3 (when mso_username == admin) - assert: + ansible.builtin.assert: that: - nm_add_tenant3.current.userAssociations | length == 1 when: mso_username == 'admin' # CHANGE TENANT - name: Change tenant (check_mode) - mso_tenant: + cisco.mso.mso_tenant: <<: *tenant_present tenant: ansible_test description: Ansible test tenant 2 @@ -283,7 +321,7 @@ register: cm_change_tenant - name: Verify cm_change_tenant - assert: + ansible.builtin.assert: that: - cm_change_tenant is changed - cm_change_tenant.current.id == nm_add_tenant.current.id @@ -291,7 +329,7 @@ - cm_change_tenant.current.description == 'Ansible test tenant 2' - name: Change tenant (normal mode) - mso_tenant: + cisco.mso.mso_tenant: <<: *tenant_present tenant: ansible_test description: Ansible test tenant 2 @@ -299,7 +337,7 @@ register: nm_change_tenant - name: Verify nm_change_tenant - assert: + ansible.builtin.assert: that: - nm_change_tenant is changed - nm_change_tenant.current.id == nm_add_tenant.current.id @@ -307,7 +345,7 @@ - nm_change_tenant.current.description == 'Ansible test tenant 2' - name: Change tenant again (check_mode) - mso_tenant: + cisco.mso.mso_tenant: <<: *tenant_present tenant: ansible_test description: Ansible test tenant 2 @@ -315,7 +353,7 @@ register: cm_change_tenant_again - name: Verify cm_change_tenant_again - assert: + ansible.builtin.assert: that: - cm_change_tenant_again is not changed - cm_change_tenant_again.current.id == nm_add_tenant.current.id @@ -323,58 +361,56 @@ - cm_change_tenant_again.current.description == 'Ansible test tenant 2' - name: Change tenant again (normal mode) - mso_tenant: + cisco.mso.mso_tenant: <<: *tenant_present tenant: ansible_test description: Ansible test tenant 2 register: nm_change_tenant_again - name: Verify nm_change_tenant_again - assert: + ansible.builtin.assert: that: - nm_change_tenant_again is not changed - nm_change_tenant_again.current.id == nm_add_tenant.current.id - nm_change_tenant_again.current.name == 'ansible_test' - nm_change_tenant_again.current.description == 'Ansible test tenant 2' - # QUERY ALL TENANTS - name: Query all tenants (check_mode) - mso_tenant: &tenant_query + cisco.mso.mso_tenant: &tenant_query <<: *mso_info state: query check_mode: true register: cm_query_all_tenants - name: Query all tenants (normal mode) - mso_tenant: *tenant_query + cisco.mso.mso_tenant: *tenant_query register: nm_query_all_tenants - name: Verify query_all_tenants - assert: + ansible.builtin.assert: that: - cm_query_all_tenants is not changed - nm_query_all_tenants is not changed # NOTE: Order of tenants is not stable between calls #- cm_query_all_tenants == nm_query_all_tenants - # QUERY A TENANT - name: Query our tenant - mso_tenant: + cisco.mso.mso_tenant: <<: *tenant_query tenant: ansible_test check_mode: true register: cm_query_tenant - name: Query our tenant - mso_tenant: + cisco.mso.mso_tenant: <<: *tenant_query tenant: ansible_test register: nm_query_tenant - name: Verify query_tenant - assert: + ansible.builtin.assert: that: - cm_query_tenant is not changed - cm_query_tenant.current.id == nm_add_tenant.current.id @@ -386,83 +422,81 @@ - nm_query_tenant.current.description == 'Ansible test tenant 2' - cm_query_tenant.current == nm_query_tenant.current - # REMOVE TENANT - name: Remove tenant (check_mode) - mso_tenant: + cisco.mso.mso_tenant: <<: *tenant_absent tenant: ansible_test check_mode: true register: cm_remove_tenant - name: Verify cm_remove_tenant - assert: + ansible.builtin.assert: that: - cm_remove_tenant is changed - cm_remove_tenant.current == {} - name: Remove tenant (normal mode) - mso_tenant: + cisco.mso.mso_tenant: <<: *tenant_absent tenant: ansible_test register: nm_remove_tenant - name: Verify nm_remove_tenant - assert: + ansible.builtin.assert: that: - nm_remove_tenant is changed - nm_remove_tenant.current == {} - name: Remove tenant again (check_mode) - mso_tenant: + cisco.mso.mso_tenant: <<: *tenant_absent tenant: ansible_test check_mode: true register: cm_remove_tenant_again - name: Verify cm_remove_tenant_again - assert: + ansible.builtin.assert: that: - cm_remove_tenant_again is not changed - cm_remove_tenant_again.current == {} - name: Remove tenant again (normal mode) - mso_tenant: + cisco.mso.mso_tenant: <<: *tenant_absent tenant: ansible_test register: nm_remove_tenant_again - name: Verify nm_remove_tenant_again - assert: + ansible.builtin.assert: that: - nm_remove_tenant_again is not changed - nm_remove_tenant_again.current == {} - # QUERY NON-EXISTING TENANT - name: Query non-existing tenant (check_mode) - mso_tenant: + cisco.mso.mso_tenant: <<: *tenant_query tenant: ansible_test check_mode: true register: cm_query_non_tenant - name: Query non-existing tenant (normal mode) - mso_tenant: + cisco.mso.mso_tenant: <<: *tenant_query tenant: ansible_test register: nm_query_non_tenant # TODO: Implement more tests - name: Verify query_non_tenant - assert: + ansible.builtin.assert: that: - cm_query_non_tenant is not changed - nm_query_non_tenant is not changed - cm_query_non_tenant.current == nm_query_non_tenant.current - name: Add common tenant - mso_tenant: + cisco.mso.mso_tenant: <<: *tenant_present tenant: common display_name: common @@ -470,13 +504,13 @@ register: nm_add_common_tenant - name: Verify nm_add_common_tenant - assert: + ansible.builtin.assert: that: - nm_add_common_tenant is changed - nm_add_common_tenant.current.name == "common" - name: Add tenant with site - mso_tenant: + cisco.mso.mso_tenant: <<: *tenant_present tenant: tenant_with_site display_name: tenant_with_site @@ -484,37 +518,37 @@ register: nm_add_tenant_with_site - name: Verify nm_add_tenant_with_site - assert: + ansible.builtin.assert: that: - nm_add_tenant_with_site is changed - nm_add_tenant_with_site.current.name == "tenant_with_site" - name: Remove common tenant - mso_tenant: + cisco.mso.mso_tenant: <<: *tenant_absent tenant: common ignore_errors: true register: rm_common - name: Verify rm_common - assert: + ansible.builtin.assert: that: - rm_common.msg is search("Common [Tt]enant cannot be deleted") - name: Remove tenant_with_site - mso_tenant: + cisco.mso.mso_tenant: <<: *tenant_absent tenant: tenant_with_site register: rm_tenant_with_site - name: Verify rm_tenant_with_site - assert: + ansible.builtin.assert: that: - rm_tenant_with_site is changed - rm_tenant_with_site.current == {} - name: Remove "anstest_imp_tenant" to the MSO if exists - mso_tenant: + cisco.mso.mso_tenant: <<: *mso_info tenant: anstest_imp_tenant display_name: anstest_imp_tenant_display_name @@ -524,7 +558,7 @@ register: pre_test_anstest_imp_tenant_absent - name: Import "anstest_imp_tenant" to the MSO with check mode - mso_tenant: &cm_import_anstest_imp_tenant_present + cisco.mso.mso_tenant: &cm_import_anstest_imp_tenant_present <<: *mso_info tenant: anstest_imp_tenant display_name: anstest_imp_tenant_display_name @@ -535,7 +569,7 @@ register: cm_import_anstest_imp_tenant_present - name: Assertions check for import "anstest_imp_tenant" to the MSO with check mode - assert: + ansible.builtin.assert: that: - cm_import_anstest_imp_tenant_present is changed - cm_import_anstest_imp_tenant_present.current != {} @@ -545,12 +579,12 @@ - cm_import_anstest_imp_tenant_present.current.description == "anstest_imp_tenant_description" - name: Import "anstest_imp_tenant" to the MSO with normal mode - mso_tenant: &nm_import_anstest_imp_tenant_present + cisco.mso.mso_tenant: &nm_import_anstest_imp_tenant_present <<: *cm_import_anstest_imp_tenant_present register: nm_import_anstest_imp_tenant_present - name: Assertions check for import "anstest_imp_tenant" to the MSO with normal mode - assert: + ansible.builtin.assert: that: - nm_import_anstest_imp_tenant_present is changed - nm_import_anstest_imp_tenant_present.current != {} @@ -560,12 +594,12 @@ - nm_import_anstest_imp_tenant_present.current.description == "anstest_imp_tenant_description" - name: Import "anstest_imp_tenant" to the MSO with normal mode - idempotency works - mso_tenant: + cisco.mso.mso_tenant: <<: *nm_import_anstest_imp_tenant_present register: idempotency_nm_import_anstest_imp_tenant_present - name: Idempotency assertions check for import "anstest_imp_tenant" to the MSO with normal mode - assert: + ansible.builtin.assert: that: - idempotency_nm_import_anstest_imp_tenant_present is not changed - idempotency_nm_import_anstest_imp_tenant_present.current != {} @@ -578,14 +612,14 @@ - idempotency_nm_import_anstest_imp_tenant_present.previous.description == "anstest_imp_tenant_description" - name: Query a tenant with name "anstest_imp_tenant" when it is imported to the MSO - mso_tenant: + cisco.mso.mso_tenant: <<: *mso_info tenant: anstest_imp_tenant state: query register: query_anstest_imp_tenant - name: Assertions check for query a tenant with name "anstest_imp_tenant" when it is imported to the MSO - assert: + ansible.builtin.assert: that: - query_anstest_imp_tenant is not changed - query_anstest_imp_tenant.current != {} @@ -594,7 +628,7 @@ - query_anstest_imp_tenant.current.description == "anstest_imp_tenant_description" - name: Remove "anstest_imp_tenant" tenant from MSO and APIC using orchestrator_only flag value yes with check mode - mso_tenant: &cm_anstest_imp_tenant_absent_orchestrator_only_yes + cisco.mso.mso_tenant: &cm_anstest_imp_tenant_absent_orchestrator_only_yes <<: *mso_info tenant: anstest_imp_tenant orchestrator_only: yes @@ -603,7 +637,7 @@ register: cm_anstest_imp_tenant_absent_orchestrator_only_yes - name: Assertions check for remove "anstest_imp_tenant" tenant from MSO and APIC using orchestrator_only flag value yes with check mode - assert: + ansible.builtin.assert: that: - cm_anstest_imp_tenant_absent_orchestrator_only_yes is changed - cm_anstest_imp_tenant_absent_orchestrator_only_yes.current == {} @@ -613,12 +647,12 @@ - cm_anstest_imp_tenant_absent_orchestrator_only_yes.previous.description == "anstest_imp_tenant_description" - name: Remove "anstest_imp_tenant" tenant from MSO and APIC using orchestrator_only flag value yes with normal mode - mso_tenant: &nm_anstest_imp_tenant_absent_orchestrator_only_yes + cisco.mso.mso_tenant: &nm_anstest_imp_tenant_absent_orchestrator_only_yes <<: *cm_anstest_imp_tenant_absent_orchestrator_only_yes register: nm_anstest_imp_tenant_absent_orchestrator_only_yes - name: Assertions check for remove "anstest_imp_tenant" tenant from MSO and APIC using orchestrator_only flag value yes with normal mode - assert: + ansible.builtin.assert: that: - nm_anstest_imp_tenant_absent_orchestrator_only_yes is changed - nm_anstest_imp_tenant_absent_orchestrator_only_yes.current == {} @@ -628,24 +662,24 @@ - nm_anstest_imp_tenant_absent_orchestrator_only_yes.previous.description == "anstest_imp_tenant_description" - name: Remove "anstest_imp_tenant" tenant from MSO and APIC using orchestrator_only flag value yes with normal mode - idempotency works - mso_tenant: + cisco.mso.mso_tenant: <<: *nm_anstest_imp_tenant_absent_orchestrator_only_yes register: idempotency_nm_anstest_imp_tenant_absent_orchestrator_only_yes - name: Idempotency assertions check for remove "anstest_imp_tenant" tenant from MSO and APIC using orchestrator_only flag value yes with normal mode - assert: + ansible.builtin.assert: that: - idempotency_nm_anstest_imp_tenant_absent_orchestrator_only_yes is not changed - idempotency_nm_anstest_imp_tenant_absent_orchestrator_only_yes.current == {} - idempotency_nm_anstest_imp_tenant_absent_orchestrator_only_yes.previous == {} - name: Import "anstest_imp_tenant" to the MSO with normal mode once again - mso_tenant: + cisco.mso.mso_tenant: <<: *nm_import_anstest_imp_tenant_present register: nm_import_tenant_once_again - name: Assertions check for import "anstest_imp_tenant" to the MSO with normal mode once again - assert: + ansible.builtin.assert: that: - nm_import_tenant_once_again is changed - nm_import_tenant_once_again.current != {} @@ -655,14 +689,14 @@ - nm_import_tenant_once_again.current.description == "anstest_imp_tenant_description" - name: Update "anstest_imp_tenant" tenant description with check mode - mso_tenant: &cm_update_anstest_imp_tenant + cisco.mso.mso_tenant: &cm_update_anstest_imp_tenant <<: *nm_import_anstest_imp_tenant_present description: "updated_anstest_imp_tenant_description" check_mode: true register: cm_update_anstest_imp_tenant - name: Assertions check for update "anstest_imp_tenant" tenant description with check mode - assert: + ansible.builtin.assert: that: - cm_update_anstest_imp_tenant is changed - cm_update_anstest_imp_tenant.current != {} @@ -675,12 +709,12 @@ - cm_update_anstest_imp_tenant.previous.description == "anstest_imp_tenant_description" - name: Update "anstest_imp_tenant" tenant description with normal mode - mso_tenant: &nm_update_anstest_imp_tenant + cisco.mso.mso_tenant: &nm_update_anstest_imp_tenant <<: *cm_update_anstest_imp_tenant register: nm_update_anstest_imp_tenant - name: Assertions check for update "anstest_imp_tenant" tenant description with normal mode - assert: + ansible.builtin.assert: that: - nm_update_anstest_imp_tenant is changed - nm_update_anstest_imp_tenant.current != {} @@ -693,12 +727,12 @@ - nm_update_anstest_imp_tenant.previous.description == "anstest_imp_tenant_description" - name: Update "anstest_imp_tenant" tenant description with normal mode - idempotency works - mso_tenant: + cisco.mso.mso_tenant: <<: *nm_update_anstest_imp_tenant register: nm_idempotency_update_anstest_imp_tenant - name: Idempotency assertions check for update "anstest_imp_tenant" tenant description with normal mode - assert: + ansible.builtin.assert: that: - nm_idempotency_update_anstest_imp_tenant is not changed - nm_idempotency_update_anstest_imp_tenant.current != {} @@ -712,7 +746,7 @@ # Orchestrator Only no will remove the tenant from MSO and APIC - name: Remove "anstest_imp_tenant" tenant from MSO and APIC using orchestrator_only flag value no with check mode - mso_tenant: &cm_anstest_imp_tenant_absent_orchestrator_only_no + cisco.mso.mso_tenant: &cm_anstest_imp_tenant_absent_orchestrator_only_no <<: *mso_info tenant: anstest_imp_tenant orchestrator_only: no @@ -721,7 +755,7 @@ register: cm_anstest_imp_tenant_absent_orchestrator_only_no - name: Assertions check for remove "anstest_imp_tenant" tenant from MSO and APIC using orchestrator_only flag value no with check mode - assert: + ansible.builtin.assert: that: - cm_anstest_imp_tenant_absent_orchestrator_only_no is changed - cm_anstest_imp_tenant_absent_orchestrator_only_no.current == {} @@ -731,12 +765,12 @@ - cm_anstest_imp_tenant_absent_orchestrator_only_no.previous.description == "updated_anstest_imp_tenant_description" - name: Remove "anstest_imp_tenant" tenant from MSO and APIC using orchestrator_only flag value no with normal mode - mso_tenant: &nm_anstest_imp_tenant_absent_orchestrator_only_no + cisco.mso.mso_tenant: &nm_anstest_imp_tenant_absent_orchestrator_only_no <<: *cm_anstest_imp_tenant_absent_orchestrator_only_no register: nm_anstest_imp_tenant_absent_orchestrator_only_no - name: Assertions check for remove "anstest_imp_tenant" tenant from MSO and APIC using orchestrator_only flag value no with normal mode - assert: + ansible.builtin.assert: that: - nm_anstest_imp_tenant_absent_orchestrator_only_no is changed - nm_anstest_imp_tenant_absent_orchestrator_only_no.current == {} @@ -746,12 +780,12 @@ - nm_anstest_imp_tenant_absent_orchestrator_only_no.previous.description == "updated_anstest_imp_tenant_description" - name: Remove "anstest_imp_tenant" tenant from MSO and APIC using orchestrator_only flag value no with normal mode - idempotency works - mso_tenant: + cisco.mso.mso_tenant: <<: *nm_anstest_imp_tenant_absent_orchestrator_only_no register: idempotency_nm_anstest_imp_tenant_absent_orchestrator_only_no - name: Idempotency assertions check for remove "anstest_imp_tenant" tenant from MSO and APIC using orchestrator_only flag value no with normal mode - assert: + ansible.builtin.assert: that: - idempotency_nm_anstest_imp_tenant_absent_orchestrator_only_no is not changed - idempotency_nm_anstest_imp_tenant_absent_orchestrator_only_no.current == {} diff --git a/ansible_collections/cisco/mso/tests/integration/targets/mso_tenant_site/tasks/main.yml b/ansible_collections/cisco/mso/tests/integration/targets/mso_tenant_site/tasks/main.yml index 7e3ce378c..0bb711447 100644 --- a/ansible_collections/cisco/mso/tests/integration/targets/mso_tenant_site/tasks/main.yml +++ b/ansible_collections/cisco/mso/tests/integration/targets/mso_tenant_site/tasks/main.yml @@ -6,14 +6,14 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI MultiSite host, username and password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: mso_hostname, mso_username and mso_password.' when: mso_hostname is not defined or mso_username is not defined or mso_password is not defined # CLEAN ENVIRONMENT - name: Set vars - set_fact: + ansible.builtin.set_fact: mso_info: &mso_info host: '{{ mso_hostname }}' username: '{{ mso_username }}' @@ -24,13 +24,13 @@ output_level: '{{ mso_output_level | default("info") }}' - name: Query MSO version - mso_version: + cisco.mso.mso_version: <<: *mso_info state: query register: version - name: Remove schemas - mso_schema: + cisco.mso.mso_schema: <<: *mso_info schema: '{{ item }}' state: absent @@ -39,7 +39,7 @@ - '{{ mso_schema | default("ansible_test") }}' - name: Ensure tenant ansible_test exists to validate the invalid_site_mso_site - mso_tenant: + cisco.mso.mso_tenant: <<: *mso_info tenant: ansible_test users: @@ -48,7 +48,7 @@ register: ansible_test_tenant_present - name: Dissociate clouds that are associated with ansible_tenant - mso_tenant_site: + cisco.mso.mso_tenant_site: <<: *mso_info tenant: ansible_test site: '{{ item }}' @@ -62,7 +62,7 @@ when: ansible_test_tenant_present.current != {} - name: Assertion check for the tenant site dissociation - assert: + ansible.builtin.assert: that: - tenant_site_absent_check.results.0.current == {} - tenant_site_absent_check.warnings.0 == "Site 'invalid_site_ansible_test' is not a valid site name." @@ -72,7 +72,7 @@ when: ansible_test_tenant_present.current != {} - name: Remove tenant ansible_test - mso_tenant: + cisco.mso.mso_tenant: <<: *mso_info tenant: ansible_test users: @@ -80,7 +80,7 @@ state: absent - name: Ensure non-cloud site exists - mso_site: + cisco.mso.mso_site: <<: *mso_info site: '{{ mso_site | default("ansible_test") }}' apic_username: '{{ apic_username }}' @@ -91,7 +91,7 @@ state: present - name: Ensure azure site exists - mso_site: + cisco.mso.mso_site: <<: *mso_info site: 'azure_{{ mso_site | default("ansible_test") }}' apic_username: '{{ azure_apic_username }}' @@ -102,7 +102,7 @@ state: present - name: Ensure aws site exists - mso_site: + cisco.mso.mso_site: <<: *mso_info site: 'aws_{{ mso_site | default("ansible_test") }}' apic_username: '{{ aws_apic_username }}' @@ -113,7 +113,7 @@ state: present - name: Ensure tenant ansible_test exists - mso_tenant: + cisco.mso.mso_tenant: <<: *mso_info tenant: ansible_test users: @@ -121,7 +121,7 @@ state: present - name: Associate non-cloud site with ansible_test in check mode - mso_tenant_site: + cisco.mso.mso_tenant_site: <<: *mso_info tenant: ansible_test site: '{{ mso_site | default("ansible_test") }}' @@ -130,12 +130,12 @@ register: ncs_cm - name: Verify ncs_cm - assert: + ansible.builtin.assert: that: - ncs_cm is changed - name: Associate non-cloud site with ansible_test in normal mode - mso_tenant_site: + cisco.mso.mso_tenant_site: <<: *mso_info tenant: ansible_test site: '{{ mso_site | default("ansible_test") }}' @@ -143,12 +143,12 @@ register: ncs_nm - name: Verify ncs_nm - assert: + ansible.builtin.assert: that: - ncs_nm is changed - name: Associate non-cloud site with ansible_test again in normal mode - mso_tenant_site: + cisco.mso.mso_tenant_site: <<: *mso_info tenant: ansible_test site: '{{ mso_site | default("ansible_test") }}' @@ -156,12 +156,12 @@ register: ncs_nm_again - name: Verify ncs_nm_again - assert: + ansible.builtin.assert: that: - ncs_nm_again is not changed - name: Associate aws site with ansible_test in check mode - mso_tenant_site: + cisco.mso.mso_tenant_site: <<: *mso_info tenant: ansible_test site: 'aws_{{ mso_site | default("ansible_test") }}' @@ -174,7 +174,7 @@ register: aaws_cm - name: Verify aaws_cm - assert: + ansible.builtin.assert: that: - aaws_cm is changed - aaws_cm.current.awsAccount != 'null' @@ -182,7 +182,7 @@ - aaws_cm.current.awsAccount[0].isTrusted == false - name: Associate aws site with ansible_test in normal mode - mso_tenant_site: + cisco.mso.mso_tenant_site: <<: *mso_info tenant: ansible_test site: 'aws_{{ mso_site | default("ansible_test") }}' @@ -194,7 +194,7 @@ register: aaws_nm - name: Verify aaws_nm - assert: + ansible.builtin.assert: that: - aaws_nm is changed - aaws_nm.current.awsAccount != 'null' @@ -202,7 +202,7 @@ - aaws_nm.current.awsAccount[0].isTrusted == false - name: Associate aws site with ansible_test again in normal mode - mso_tenant_site: + cisco.mso.mso_tenant_site: <<: *mso_info tenant: ansible_test site: 'aws_{{ mso_site | default("ansible_test") }}' @@ -214,12 +214,12 @@ register: aaws_nm_again - name: Verify aaws_nm_again - assert: + ansible.builtin.assert: that: - aaws_nm_again is not changed - name: Associate aws site with ansible_test in normal mode when aws_trusted is false and aws_access_key is missing - mso_tenant_site: + cisco.mso.mso_tenant_site: <<: *mso_info tenant: ansible_test site: 'aws_{{ mso_site | default("ansible_test") }}' @@ -231,12 +231,12 @@ register: aaws_nm_ak - name: Verify aaws_nm_ak - assert: + ansible.builtin.assert: that: - aaws_nm_ak.msg is match ("aws_access_key is a required field in untrusted mode.") - name: Associate aws site with ansible_test in normal mode when aws_trusted is true - mso_tenant_site: + cisco.mso.mso_tenant_site: <<: *mso_info tenant: ansible_test site: 'aws_{{ mso_site | default("ansible_test") }}' @@ -246,12 +246,12 @@ register: aws_nm_trusted - name: Verify aws_nm_trusted - assert: + ansible.builtin.assert: that: - aws_nm_trusted is changed - name: Associate aws site with ansible_test in normal mode when aws_trusted is false and secret_key is missing - mso_tenant_site: + cisco.mso.mso_tenant_site: <<: *mso_info tenant: ansible_test site: 'aws_{{ mso_site | default("ansible_test") }}' @@ -263,12 +263,12 @@ register: aaws_nm_sk - name: Verify aaws_nm_sk - assert: + ansible.builtin.assert: that: - aaws_nm_sk.msg is match ("secret_key is a required field in untrusted mode.") - name: Associate aws site with ansible_test, with organization mode true - mso_tenant_site: + cisco.mso.mso_tenant_site: <<: *mso_info tenant: ansible_test site: 'aws_{{ mso_site | default("ansible_test") }}' @@ -281,12 +281,12 @@ register: aaws_nm_om - name: Verify aaws_nm_om - assert: + ansible.builtin.assert: that: - aaws_nm_om.current.awsAccount[0].isAccountInOrg == true - name: Associate azure site with access_type not present, with ansible_test in normal mode - mso_tenant_site: + cisco.mso.mso_tenant_site: <<: *mso_info tenant: ansible_test site: 'azure_{{ mso_site | default("ansible_test") }}' @@ -295,12 +295,12 @@ register: aazure_shared_nm - name: Verify aazure_shared_nm - assert: + ansible.builtin.assert: that: - aazure_shared_nm is changed - name: Associate azure site in shared mode with ansible_test in normal mode - mso_tenant_site: + cisco.mso.mso_tenant_site: <<: *mso_info tenant: ansible_test site: 'azure_{{ mso_site | default("ansible_test") }}' @@ -310,12 +310,12 @@ register: aazure_shared_nm - name: Verify aazure_shared_nm - assert: + ansible.builtin.assert: that: - aazure_shared_nm is not changed - name: Associate azure site with managed mode, with ansible_test in normal mode having no application_id - mso_tenant_site: + cisco.mso.mso_tenant_site: <<: *mso_info tenant: ansible_test site: 'azure_{{ mso_site | default("ansible_test") }}' @@ -327,12 +327,12 @@ register: aazure_managed_nm_app - name: Verify aazure_managed_nm_app - assert: + ansible.builtin.assert: that: - aazure_managed_nm_app.msg is match ("azure_application_id is required when in managed mode.") - name: Associate azure site with managed mode, with ansible_test in normal mode having no subscription_id - mso_tenant_site: + cisco.mso.mso_tenant_site: <<: *mso_info tenant: ansible_test site: 'azure_{{ mso_site | default("ansible_test") }}' @@ -344,12 +344,12 @@ register: aazure_managed_nm_si - name: Verify aazure_managed_nm_si - assert: + ansible.builtin.assert: that: - aazure_managed_nm_si.msg is match ("azure_susbscription_id is required when in managed mode.") - name: Associate azure site with managed mode, with ansible_test in normal mode - mso_tenant_site: + cisco.mso.mso_tenant_site: <<: *mso_info tenant: ansible_test site: 'azure_{{ mso_site | default("ansible_test") }}' @@ -362,7 +362,7 @@ register: aazure_managed_nm - name: Verify aazure_managed_nm - assert: + ansible.builtin.assert: that: - aazure_managed_nm is changed - aazure_managed_nm.current.azureAccount != 'null' @@ -372,7 +372,7 @@ - aazure_managed_nm.current.azureAccount[0].cloudActiveDirectory == [] - name: Associate azure site with credentials mode, with ansible_test in normal mode having no azure_subscription_id - mso_tenant_site: + cisco.mso.mso_tenant_site: <<: *mso_info tenant: ansible_test site: 'azure_{{ mso_site | default("ansible_test") }}' @@ -388,12 +388,12 @@ register: aazure_credentials_nm_si - name: Verify aazure_credentials_nm_si - assert: + ansible.builtin.assert: that: - aazure_credentials_nm_si.msg is match ("azure_subscription_id is required when in unmanaged mode.") - name: Associate azure site with credentials mode, with ansible_test in normal mode having no azure_application_id - mso_tenant_site: + cisco.mso.mso_tenant_site: <<: *mso_info tenant: ansible_test site: 'azure_{{ mso_site | default("ansible_test") }}' @@ -409,12 +409,12 @@ register: aazure_credentials_nm_app - name: Verify aazure_credentials_nm_app - assert: + ansible.builtin.assert: that: - aazure_credentials_nm_app.msg is match ("azure_application_id is required when in unmanaged mode.") - name: Associate azure site with credentials mode, with ansible_test in normal mode having no secret_key - mso_tenant_site: + cisco.mso.mso_tenant_site: <<: *mso_info tenant: ansible_test site: 'azure_{{ mso_site | default("ansible_test") }}' @@ -430,12 +430,12 @@ register: aazure_credentials_nm_secret - name: Verify aazure_credentials_nm_secret - assert: + ansible.builtin.assert: that: - aazure_credentials_nm_secret.msg is match ("secret_key is required when in unmanaged mode.") - name: Associate azure site with credentials mode, with ansible_test in normal mode having no azure_active_directory_id - mso_tenant_site: + cisco.mso.mso_tenant_site: <<: *mso_info tenant: ansible_test site: 'azure_{{ mso_site | default("ansible_test") }}' @@ -451,12 +451,12 @@ register: aazure_credentials_nm_ad - name: Verify aazure_credentials_nm_ad - assert: + ansible.builtin.assert: that: - aazure_credentials_nm_ad.msg is match ("azure_active_directory_id is required when in unmanaged mode.") - name: Associate azure site with credentials mode, with ansible_test in normal mode having no azure_active_directory_name - mso_tenant_site: + cisco.mso.mso_tenant_site: <<: *mso_info tenant: ansible_test site: 'azure_{{ mso_site | default("ansible_test") }}' @@ -472,12 +472,12 @@ register: aazure_credentials_nm_adn - name: Verify aazure_credentials_nm_adn - assert: + ansible.builtin.assert: that: - aazure_credentials_nm_adn.msg is match ("azure_active_directory_name is required when in unmanaged mode.") - name: Associate azure site with credentials mode, with ansible_test in normal mode having no azure_credential_name - mso_tenant_site: + cisco.mso.mso_tenant_site: <<: *mso_info tenant: ansible_test site: 'azure_{{ mso_site | default("ansible_test") }}' @@ -493,12 +493,12 @@ register: aazure_credentials_nm_cdn - name: Verify aazure_credentials_nm_cdn - assert: + ansible.builtin.assert: that: - aazure_credentials_nm_cdn.msg is match ("azure_credential_name is required when in unmanaged mode.") - name: Associate azure site with credentials mode, with ansible_test in normal mode - mso_tenant_site: + cisco.mso.mso_tenant_site: <<: *mso_info tenant: ansible_test site: 'azure_{{ mso_site | default("ansible_test") }}' @@ -514,7 +514,7 @@ register: aazure_credentials_nm - name: Verify aazure_credentials_nm - assert: + ansible.builtin.assert: that: - aazure_credentials_nm is changed - aazure_credentials_nm.current.azureAccount[0].cloudSubscription.cloudApplicationId == '100' @@ -526,7 +526,7 @@ - aazure_credentials_nm.current.azureAccount[0].cloudApplication[0].cloudCredentialName == 'cApicApp' - name: Associate azure site with credentials mode, with ansible_test again in normal mode - mso_tenant_site: + cisco.mso.mso_tenant_site: <<: *mso_info tenant: ansible_test site: 'azure_{{ mso_site | default("ansible_test") }}' @@ -542,12 +542,12 @@ register: aazure_credentials_nm_again - name: Verify aazure_credentials_nm_again - assert: + ansible.builtin.assert: that: - aazure_credentials_nm_again is not changed - name: Query associated non-cloud site of a tenant - mso_tenant_site: + cisco.mso.mso_tenant_site: <<: *mso_info tenant: ansible_test site: '{{ mso_site | default("ansible_test") }}' @@ -555,12 +555,12 @@ register: anc_query - name: Verify anc_query - assert: + ansible.builtin.assert: that: - anc_query is not changed - name: Query associated azure site of a tenant - mso_tenant_site: + cisco.mso.mso_tenant_site: <<: *mso_info tenant: ansible_test site: 'azure_{{ mso_site | default("ansible_test") }}' @@ -576,12 +576,12 @@ register: aazure_query - name: Verify aazure_query - assert: + ansible.builtin.assert: that: - aazure_query is not changed - name: Query associated aws site of a tenant - mso_tenant_site: + cisco.mso.mso_tenant_site: <<: *mso_info tenant: ansible_test site: 'aws_{{ mso_site | default("ansible_test") }}' @@ -589,24 +589,24 @@ register: aaws_query - name: Verify aaws_query - assert: + ansible.builtin.assert: that: - aaws_query is not changed - name: Query all associated sites of a tenant - mso_tenant_site: + cisco.mso.mso_tenant_site: <<: *mso_info tenant: ansible_test state: query register: all_sites_query - name: Verify all_sites_query - assert: + ansible.builtin.assert: that: - all_sites_query is not changed - name: Dissociate non-cloud site with ansible_test - mso_tenant_site: + cisco.mso.mso_tenant_site: <<: *mso_info tenant: ansible_test site: '{{ mso_site | default("ansible_test") }}' @@ -614,12 +614,12 @@ register: dnc - name: Verify dnc - assert: + ansible.builtin.assert: that: - dnc is changed - name: Query dissociated non-cloud site of a tenant - mso_tenant_site: + cisco.mso.mso_tenant_site: <<: *mso_info tenant: ansible_test site: '{{ mso_site | default("ansible_test") }}' @@ -628,12 +628,12 @@ register: dnc_query - name: Verify dnc_query - assert: + ansible.builtin.assert: that: - dnc_query.msg is match ("Site Id [0-9a-zA-Z]* not associated with tenant Id [0-9a-zA-Z]*") - name: Dissociate azure site with ansible_test - mso_tenant_site: + cisco.mso.mso_tenant_site: <<: *mso_info tenant: ansible_test site: 'azure_{{ mso_site | default("ansible_test") }}' @@ -641,12 +641,12 @@ register: dazure - name: Verify dazure - assert: + ansible.builtin.assert: that: - dazure is changed - name: Query dissociated azure site of a tenant - mso_tenant_site: + cisco.mso.mso_tenant_site: <<: *mso_info tenant: ansible_test site: 'azure_{{ mso_site | default("ansible_test") }}' @@ -655,12 +655,12 @@ register: dazure_query - name: Verify dnc_query - assert: + ansible.builtin.assert: that: - dazure_query.msg is match ("Site Id [0-9a-zA-Z]* not associated with tenant Id [0-9a-zA-Z]*") - name: Dissociate aws site with ansible_test - mso_tenant_site: + cisco.mso.mso_tenant_site: <<: *mso_info tenant: ansible_test site: 'aws_{{ mso_site | default("ansible_test") }}' @@ -668,12 +668,12 @@ register: daaws - name: Verify daaws - assert: + ansible.builtin.assert: that: - daaws is changed - name: Query dissociated aws site of a tenant - mso_tenant_site: + cisco.mso.mso_tenant_site: <<: *mso_info tenant: ansible_test site: 'aws_{{ mso_site | default("ansible_test") }}' @@ -682,12 +682,12 @@ register: daaws_query - name: Verify daaws_query - assert: + ansible.builtin.assert: that: - daaws_query.msg is match ("No site associated with tenant Id [0-9a-zA-Z]*") - name: Query all - mso_tenant_site: + cisco.mso.mso_tenant_site: <<: *mso_info tenant: ansible_test state: query @@ -695,6 +695,6 @@ register: query_all - name: Verify query_all - assert: + ansible.builtin.assert: that: - query_all.msg is match ("No site associated with tenant Id [0-9a-zA-Z]*")
\ No newline at end of file diff --git a/ansible_collections/cisco/mso/tests/integration/targets/mso_user/tasks/main.yml b/ansible_collections/cisco/mso/tests/integration/targets/mso_user/tasks/main.yml index 2aa2d2bf6..1a51e8a0e 100644 --- a/ansible_collections/cisco/mso/tests/integration/targets/mso_user/tasks/main.yml +++ b/ansible_collections/cisco/mso/tests/integration/targets/mso_user/tasks/main.yml @@ -4,12 +4,12 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI MultiSite host, username and password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: mso_hostname, mso_username and mso_password.' when: mso_hostname is not defined or mso_username is not defined or mso_password is not defined - name: Set vars - set_fact: + ansible.builtin.set_fact: mso_info: &mso_info host: '{{ mso_hostname }}' username: '{{ mso_username }}' @@ -20,7 +20,7 @@ output_level: '{{ mso_output_level | default("info") }}' - name: Query MSO version - mso_version: + cisco.mso.mso_version: <<: *mso_info state: query register: version @@ -30,7 +30,7 @@ block: # CLEAN ENVIRONMENT - name: Remove user ansible_test - mso_user: &user_absent + cisco.mso.mso_user: &user_absent <<: *mso_info user: '{{ item }}' state: absent @@ -42,7 +42,7 @@ # ADD USER - name: Add user (check_mode) - mso_user: &user_present + cisco.mso.mso_user: &user_present <<: *mso_info user: ansible_test user_password: 'S0m3!1n1t14l!p455w0rd' @@ -61,7 +61,7 @@ register: cm_add_user - name: Verify cm_add_user - assert: + ansible.builtin.assert: that: - cm_add_user is changed - cm_add_user.previous == {} @@ -75,11 +75,11 @@ - cm_add_user.current.roles[0].accessType == 'readWrite' - name: Add user (normal mode) - mso_user: *user_present + cisco.mso.mso_user: *user_present register: nm_add_user - name: Verify nm_add_user - assert: + ansible.builtin.assert: that: - nm_add_user is changed - nm_add_user.previous == {} @@ -93,7 +93,7 @@ - nm_add_user.current.roles[0].accessType == 'readWrite' - name: Add user again (check_mode) - mso_user: + cisco.mso.mso_user: <<: *user_present # NOTE: We need to modify the password for a new user user_password: 'S0m3!n3w!p455w0rd' @@ -101,7 +101,7 @@ register: cm_add_user_again - name: Verify cm_add_user_again - assert: + ansible.builtin.assert: that: - cm_add_user_again is changed - cm_add_user_again.previous.username == 'ansible_test' @@ -109,14 +109,14 @@ - cm_add_user_again.current.username == 'ansible_test' - name: Add user again (normal mode) - mso_user: + cisco.mso.mso_user: <<: *user_present # NOTE: We need to modify the password for a new user user_password: 'S0m3!n3w!p455w0rd' register: nm_add_user_again - name: Verify nm_add_user_again - assert: + ansible.builtin.assert: that: - nm_add_user_again is changed - nm_add_user_again.previous.username == 'ansible_test' @@ -124,7 +124,7 @@ - nm_add_user_again.current.username == 'ansible_test' - name: Add user with read only role (check_mode) - mso_user: &user_present2 + cisco.mso.mso_user: &user_present2 <<: *mso_info user: ansible_test_read user_password: '#123455#123455Aa' @@ -143,7 +143,7 @@ register: cm_add_user2 - name: Verify cm_add_user2 - assert: + ansible.builtin.assert: that: - cm_add_user2 is changed - cm_add_user2.previous == {} @@ -157,11 +157,11 @@ - cm_add_user2.current.roles[0].accessType == 'readOnly' - name: Add user with read only role (normal mode) - mso_user: *user_present2 + cisco.mso.mso_user: *user_present2 register: nm_add_user2 - name: Verify nm_add_user2 - assert: + ansible.builtin.assert: that: - nm_add_user2 is changed - nm_add_user2.current.id is defined @@ -174,18 +174,18 @@ - nm_add_user2.current.roles[0].accessType == 'readOnly' - name: Add user with read only role again (check mode) - mso_user: + cisco.mso.mso_user: <<: *user_present2 user_password: '#123455#123455Aa' check_mode: true register: cm_add_user2_again - name: Add user with read only role again (normal mode) - mso_user: *user_present2 + cisco.mso.mso_user: *user_present2 register: nm_add_user2 - name: Add user3 with read only role and no password (check_mode) - mso_user: &user_present3 + cisco.mso.mso_user: &user_present3 <<: *mso_info user: ansible_test_read_2 # NOTE: First name, last name, phone and email are mandatory on creation @@ -204,18 +204,18 @@ register: nm_add_user3 - name: Verify nm_add_user2 - assert: + ansible.builtin.assert: that: - nm_add_user3.msg == "The user ansible_test_read_2 does not exist. The 'user_password' attribute is required to create a new user." - name: Add user3 with read only role and with password (normal mode) - mso_user: + cisco.mso.mso_user: <<: *user_present3 user_password: '#123455#123455Aa' register: nm_add_user3_again - name: Verify nm_add_user3_again - assert: + ansible.builtin.assert: that: - nm_add_user3_again is changed - nm_add_user3_again.current.id is defined @@ -229,7 +229,7 @@ # CHANGE USER - name: Change user (check_mode) - mso_user: &user_change + cisco.mso.mso_user: &user_change <<: *mso_info user: ansible_test roles: @@ -244,7 +244,7 @@ register: cm_change_user - name: Verify cm_change_user - assert: + ansible.builtin.assert: that: - cm_change_user is changed - cm_change_user.current.id == nm_add_user.current.id @@ -253,13 +253,13 @@ - cm_change_user.current.phoneNumber == '+32 478 436 300' - name: Change user (normal mode) - mso_user: + cisco.mso.mso_user: <<: *user_change output_level: debug register: nm_change_user - name: Verify nm_change_user - assert: + ansible.builtin.assert: that: - nm_change_user is changed - nm_change_user.current.id == nm_add_user.current.id @@ -268,13 +268,13 @@ - nm_change_user.current.phoneNumber == '+32 478 436 300' - name: Change user again (check_mode) - mso_user: + cisco.mso.mso_user: <<: *user_change check_mode: true register: cm_change_user_again - name: Verify cm_change_user_again - assert: + ansible.builtin.assert: that: - cm_change_user_again is not changed - cm_change_user_again.current.id == nm_add_user.current.id @@ -283,12 +283,12 @@ - cm_change_user_again.current.phoneNumber == '+32 478 436 300' - name: Change user again (normal mode) - mso_user: + cisco.mso.mso_user: <<: *user_change register: nm_change_user_again - name: Verify nm_change_user_again - assert: + ansible.builtin.assert: that: - nm_change_user_again is not changed - nm_change_user_again.current.id == nm_add_user.current.id @@ -297,7 +297,7 @@ - nm_change_user_again.current.phoneNumber == '+32 478 436 300' - name: Add second user - mso_user: + cisco.mso.mso_user: <<: *user_change user: ansible_test2 user_password: 'S0m3!1n1t14l!p455w0rd' @@ -309,7 +309,7 @@ register: nm_add_user_2 - name: Change user 2 again (normal mode) - mso_user: + cisco.mso.mso_user: <<: *user_change user: ansible_test2 user_password: null @@ -318,7 +318,7 @@ register: nm_change_user_2_again - name: Verify nm_change_user_2_again - assert: + ansible.builtin.assert: that: - nm_change_user_2_again is not changed - nm_change_user_2_again.current.id == nm_add_user_2.current.id @@ -328,18 +328,18 @@ # QUERY ALL USERS - name: Query all users (check_mode) - mso_user: &user_query + cisco.mso.mso_user: &user_query <<: *mso_info state: query check_mode: true register: cm_query_all_users - name: Query all users (normal mode) - mso_user: *user_query + cisco.mso.mso_user: *user_query register: nm_query_all_users - name: Verify query_all_users - assert: + ansible.builtin.assert: that: - cm_query_all_users is not changed - nm_query_all_users is not changed @@ -349,20 +349,20 @@ # QUERY A USER - name: Query our user - mso_user: + cisco.mso.mso_user: <<: *user_query user: '{{ mso_username }}' check_mode: true register: cm_query_user - name: Query our user - mso_user: + cisco.mso.mso_user: <<: *user_query user: '{{ mso_username }}' register: nm_query_user - name: Verify query_user - assert: + ansible.builtin.assert: that: - cm_query_user is not changed - cm_query_user.current.id is defined @@ -376,20 +376,20 @@ when: version.current.version is version('3.2', '<') block: - name: Query our read-only user - mso_user: + cisco.mso.mso_user: <<: *user_query user: ansible_test_read register: nm_query_user2 - name: Verify query_user2 - assert: + ansible.builtin.assert: that: - nm_query_user2 is not changed - nm_query_user2.current.roles[0].accessType == 'readOnly' # REMOVE USER - name: Remove user (check_mode) - mso_user: + cisco.mso.mso_user: <<: *user_absent user: ansible_test state: absent @@ -397,26 +397,26 @@ register: cm_remove_user - name: Verify cm_remove_user - assert: + ansible.builtin.assert: that: - cm_remove_user is changed - cm_remove_user.current == {} - name: Remove user (normal mode) - mso_user: + cisco.mso.mso_user: <<: *user_absent user: ansible_test state: absent register: nm_remove_user - name: Verify nm_remove_user - assert: + ansible.builtin.assert: that: - nm_remove_user is changed - nm_remove_user.current == {} - name: Remove user again (check_mode) - mso_user: + cisco.mso.mso_user: <<: *user_absent user: ansible_test state: absent @@ -424,41 +424,41 @@ register: cm_remove_user_again - name: Verify cm_remove_user_again - assert: + ansible.builtin.assert: that: - cm_remove_user_again is not changed - cm_remove_user_again.current == {} - name: Remove user again (normal mode) - mso_user: + cisco.mso.mso_user: <<: *user_absent user: ansible_test state: absent register: nm_remove_user_again - name: Verify nm_remove_user_again - assert: + ansible.builtin.assert: that: - nm_remove_user_again is not changed - nm_remove_user_again.current == {} # QUERY NON-EXISTING USER - name: Query non-existing user (check_mode) - mso_user: + cisco.mso.mso_user: <<: *user_query user: ansible_test check_mode: true register: cm_query_non_user - name: Query non-existing user (normal mode) - mso_user: + cisco.mso.mso_user: <<: *user_query user: ansible_test register: nm_query_non_user # TODO: Implement more tests - name: Verify query_non_user - assert: + ansible.builtin.assert: that: - cm_query_non_user is not changed - nm_query_non_user is not changed @@ -468,42 +468,41 @@ when: version.current.version is version('3.2', '<') block: - name: inactive user (check_mode) - mso_user: + cisco.mso.mso_user: <<: *user_present account_status: inactive check_mode: true register: cm_inactive_user - name: inactive user (normal_mode) - mso_user: + cisco.mso.mso_user: <<: *user_present account_status: inactive register: nm_inactive_user - name: Verify cm_inactive_user and nm_inactive_user - assert: + ansible.builtin.assert: that: - cm_inactive_user is changed - nm_inactive_user is changed - cm_inactive_user.current.accountStatus == "inactive" - nm_inactive_user.current.accountStatus == "inactive" - - name: active user (check_mode) - mso_user: + cisco.mso.mso_user: <<: *user_present account_status: active check_mode: true register: cm_active_user - name: active user (normal_mode) - mso_user: + cisco.mso.mso_user: <<: *user_present account_status: active register: nm_active_user - name: Verify cm_active_user and nm_active_user - assert: + ansible.builtin.assert: that: - cm_active_user is changed - nm_active_user is changed diff --git a/ansible_collections/cisco/mso/tests/integration/targets/mso_version/tasks/main.yml b/ansible_collections/cisco/mso/tests/integration/targets/mso_version/tasks/main.yml index fc3eb585e..3c7cb0d08 100644 --- a/ansible_collections/cisco/mso/tests/integration/targets/mso_version/tasks/main.yml +++ b/ansible_collections/cisco/mso/tests/integration/targets/mso_version/tasks/main.yml @@ -4,13 +4,13 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI MultiSite host, username and password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: mso_hostname, mso_username and mso_password.' when: mso_hostname is not defined or mso_username is not defined or mso_password is not defined # CLEAN ENVIRONMENT - name: Set vars - set_fact: + ansible.builtin.set_fact: mso_info: &mso_info host: '{{ mso_hostname }}' username: '{{ mso_username }}' @@ -22,14 +22,14 @@ # QUERY VERSION - name: Query MSO version - mso_version: &mso_query + cisco.mso.mso_version: &mso_query <<: *mso_info state: query check_mode: true register: cm_query_version - name: Verify cm_query_version - assert: + ansible.builtin.assert: that: - cm_query_version is not changed - cm_query_version.current.id is defined @@ -37,12 +37,12 @@ - cm_query_version.current.timestamp is defined - name: Query MSO version (normal mode) - mso_version: + cisco.mso.mso_version: <<: *mso_query register: nm_query_version - name: Verify nm_query_version - assert: + ansible.builtin.assert: that: - nm_query_version is not changed - nm_query_version.current.id is defined @@ -54,7 +54,7 @@ # USE A NON-EXISTING STATE - name: Non-existing state for version (check_mode) - mso_version: + cisco.mso.mso_version: <<: *mso_query state: non-existing-state check_mode: true @@ -62,14 +62,14 @@ register: cm_non_existing_state - name: Non-existing state for version (normal_mode) - mso_version: + cisco.mso.mso_version: <<: *mso_query state: non-existing-state ignore_errors: true register: nm_non_existing_state - name: Verify non_existing_state - assert: + ansible.builtin.assert: that: - cm_non_existing_state is not changed - nm_non_existing_state is not changed @@ -84,7 +84,7 @@ when: ansible_connection != 'local' - name: Verify query_version_global_params - assert: + ansible.builtin.assert: that: - query_version_global_params is not changed - query_version_global_params.current.id is defined diff --git a/ansible_collections/cisco/mso/tests/integration/targets/ndo_schema_template_deploy/tasks/main.yml b/ansible_collections/cisco/mso/tests/integration/targets/ndo_schema_template_deploy/tasks/main.yml index 3af935cfc..ed295450e 100644 --- a/ansible_collections/cisco/mso/tests/integration/targets/ndo_schema_template_deploy/tasks/main.yml +++ b/ansible_collections/cisco/mso/tests/integration/targets/ndo_schema_template_deploy/tasks/main.yml @@ -220,7 +220,7 @@ - Template 2 - name: Verify undeploy_template - assert: + ansible.builtin.assert: that: - item is not changed - '"undeploy" in item.current.reqDetails' |