From a453ac31f3428614cceb99027f8efbdb9258a40b Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Tue, 14 May 2024 22:03:01 +0200 Subject: Adding upstream version 2.10.7+merged+base+2.10.8+dfsg. Signed-off-by: Daniel Baumann --- .../cisco/mso/.github/workflows/ansible-test.yml | 216 +++ .../mso/.github/workflows/galaxy-importer.cfg | 9 + .../ansible_collections/cisco/mso/.gitignore | 393 +++++ .../ansible_collections/cisco/mso/.python-version | 1 + .../cisco/mso/.vscode/launch.json | 15 + .../cisco/mso/.vscode/settings.json | 3 + .../ansible_collections/cisco/mso/CHANGELOG.rst | 263 +++ .../ansible_collections/cisco/mso/FILES.json | 1818 ++++++++++++++++++++ .../ansible_collections/cisco/mso/LICENSE | 678 ++++++++ .../ansible_collections/cisco/mso/MANIFEST.json | 41 + .../ansible_collections/cisco/mso/README.md | 93 + .../cisco/mso/changelogs/.gitignore | 1 + .../cisco/mso/changelogs/.plugin-cache.yaml | 266 +++ .../cisco/mso/changelogs/changelog.yaml | 224 +++ .../cisco/mso/changelogs/config.yaml | 31 + .../ansible_collections/cisco/mso/codecov.yml | 4 + .../ansible_collections/cisco/mso/meta/runtime.yml | 6 + .../cisco/mso/plugins/doc_fragments/modules.py | 85 + .../cisco/mso/plugins/module_utils/mso.py | 949 ++++++++++ .../cisco/mso/plugins/modules/mso_backup.py | 311 ++++ .../mso/plugins/modules/mso_dhcp_option_policy.py | 167 ++ .../modules/mso_dhcp_option_policy_option.py | 193 +++ .../mso/plugins/modules/mso_dhcp_relay_policy.py | 166 ++ .../modules/mso_dhcp_relay_policy_provider.py | 254 +++ .../cisco/mso/plugins/modules/mso_label.py | 165 ++ .../cisco/mso/plugins/modules/mso_rest.py | 215 +++ .../cisco/mso/plugins/modules/mso_role.py | 277 +++ .../cisco/mso/plugins/modules/mso_schema.py | 133 ++ .../cisco/mso/plugins/modules/mso_schema_site.py | 200 +++ .../mso/plugins/modules/mso_schema_site_anp.py | 214 +++ .../mso/plugins/modules/mso_schema_site_anp_epg.py | 230 +++ .../modules/mso_schema_site_anp_epg_domain.py | 474 +++++ .../modules/mso_schema_site_anp_epg_selector.py | 398 +++++ .../modules/mso_schema_site_anp_epg_staticleaf.py | 264 +++ .../modules/mso_schema_site_anp_epg_staticport.py | 448 +++++ .../modules/mso_schema_site_anp_epg_subnet.py | 293 ++++ .../mso/plugins/modules/mso_schema_site_bd.py | 242 +++ .../plugins/modules/mso_schema_site_bd_l3out.py | 224 +++ .../plugins/modules/mso_schema_site_bd_subnet.py | 301 ++++ .../mso_schema_site_external_epg_selector.py | 295 ++++ .../mso/plugins/modules/mso_schema_site_vrf.py | 213 +++ .../plugins/modules/mso_schema_site_vrf_region.py | 239 +++ .../modules/mso_schema_site_vrf_region_cidr.py | 317 ++++ .../mso_schema_site_vrf_region_cidr_subnet.py | 302 ++++ .../mso_schema_site_vrf_region_hub_network.py | 251 +++ .../mso/plugins/modules/mso_schema_template.py | 244 +++ .../mso/plugins/modules/mso_schema_template_anp.py | 207 +++ .../plugins/modules/mso_schema_template_anp_epg.py | 403 +++++ .../mso_schema_template_anp_epg_contract.py | 266 +++ .../mso_schema_template_anp_epg_selector.py | 281 +++ .../modules/mso_schema_template_anp_epg_subnet.py | 266 +++ .../mso/plugins/modules/mso_schema_template_bd.py | 444 +++++ .../modules/mso_schema_template_bd_subnet.py | 253 +++ .../modules/mso_schema_template_contract_filter.py | 352 ++++ .../plugins/modules/mso_schema_template_deploy.py | 143 ++ .../modules/mso_schema_template_external_epg.py | 332 ++++ .../mso_schema_template_external_epg_contract.py | 250 +++ .../mso_schema_template_external_epg_selector.py | 249 +++ .../mso_schema_template_external_epg_subnet.py | 220 +++ .../modules/mso_schema_template_externalepg.py | 332 ++++ .../modules/mso_schema_template_filter_entry.py | 363 ++++ .../plugins/modules/mso_schema_template_l3out.py | 231 +++ .../plugins/modules/mso_schema_template_migrate.py | 246 +++ .../mso/plugins/modules/mso_schema_template_vrf.py | 214 +++ .../modules/mso_schema_template_vrf_contract.py | 264 +++ .../cisco/mso/plugins/modules/mso_site.py | 252 +++ .../cisco/mso/plugins/modules/mso_tenant.py | 197 +++ .../cisco/mso/plugins/modules/mso_tenant_site.py | 391 +++++ .../cisco/mso/plugins/modules/mso_user.py | 277 +++ .../cisco/mso/plugins/modules/mso_version.py | 71 + .../ansible_collections/cisco/mso/tests/.gitignore | 1 + .../mso/tests/integration/inventory.networking | 20 + .../network-integration.requirements.txt | 1 + .../mso/tests/integration/target-prefixes.network | 1 + .../tests/integration/targets/mso_backup/aliases | 2 + .../integration/targets/mso_backup/tasks/main.yml | 466 +++++ .../targets/mso_dhcp_option_policy/aliases | 2 + .../targets/mso_dhcp_option_policy/tasks/main.yaml | 227 +++ .../targets/mso_dhcp_option_policy_option/aliases | 2 + .../mso_dhcp_option_policy_option/tasks/main.yaml | 393 +++++ .../targets/mso_dhcp_relay_policy/aliases | 2 + .../targets/mso_dhcp_relay_policy/tasks/main.yaml | 226 +++ .../targets/mso_dhcp_relay_policy_provider/aliases | 2 + .../mso_dhcp_relay_policy_provider/tasks/main.yaml | 604 +++++++ .../tests/integration/targets/mso_label/aliases | 2 + .../integration/targets/mso_label/tasks/main.yml | 339 ++++ .../mso/tests/integration/targets/mso_rest/aliases | 2 + .../targets/mso_rest/tasks/error_handling.yml | 145 ++ .../targets/mso_rest/tasks/json_inline.yml | 269 +++ .../targets/mso_rest/tasks/json_string.yml | 213 +++ .../targets/mso_rest/tasks/json_template.yml | 67 + .../integration/targets/mso_rest/tasks/main.yml | 28 + .../targets/mso_rest/tasks/tenant.json.j2 | 10 + .../targets/mso_rest/tasks/yaml_inline.yml | 209 +++ .../targets/mso_rest/tasks/yaml_string.yml | 209 +++ .../mso/tests/integration/targets/mso_role/aliases | 2 + .../integration/targets/mso_role/tasks/main.yml | 43 + .../integration/targets/mso_role/tasks/role-ro.yml | 88 + .../integration/targets/mso_role/tasks/role-rw.yml | 275 +++ .../tests/integration/targets/mso_schema/aliases | 2 + .../integration/targets/mso_schema/tasks/main.yml | 117 ++ .../integration/targets/mso_schema_site/aliases | 2 + .../targets/mso_schema_site/tasks/main.yml | 253 +++ .../targets/mso_schema_site_anp_epg_domain/aliases | 2 + .../mso_schema_site_anp_epg_domain/tasks/main.yml | 989 +++++++++++ .../mso_schema_site_anp_epg_selector/aliases | 2 + .../tasks/main.yml | 1089 ++++++++++++ .../mso_schema_site_anp_epg_staticport/aliases | 2 + .../tasks/main.yml | 859 +++++++++ .../integration/targets/mso_schema_site_bd/aliases | 2 + .../targets/mso_schema_site_bd/tasks/main.yml | 704 ++++++++ .../targets/mso_schema_site_bd_subnet/aliases | 2 + .../mso_schema_site_bd_subnet/tasks/main.yml | 592 +++++++ .../mso_schema_site_external_epg_selector/aliases | 2 + .../tasks/main.yml | 523 ++++++ .../targets/mso_schema_site_vrf_region/aliases | 2 + .../mso_schema_site_vrf_region/tasks/main.yml | 433 +++++ .../mso_schema_site_vrf_region_cidr/aliases | 2 + .../mso_schema_site_vrf_region_cidr/tasks/main.yml | 710 ++++++++ .../mso_schema_site_vrf_region_cidr_subnet/aliases | 2 + .../tasks/main.yml | 676 ++++++++ .../mso_schema_site_vrf_region_hub_network/aliases | 2 + .../tasks/hub_network.yml | 708 ++++++++ .../tasks/main.yml | 32 + .../targets/mso_schema_template/aliases | 2 + .../targets/mso_schema_template/tasks/main.yml | 280 +++ .../targets/mso_schema_template_anp/aliases | 2 + .../targets/mso_schema_template_anp/tasks/main.yml | 265 +++ .../targets/mso_schema_template_anp_epg/aliases | 2 + .../mso_schema_template_anp_epg/tasks/main.yml | 1192 +++++++++++++ .../mso_schema_template_anp_epg_contract/aliases | 2 + .../tasks/main.yml | 651 +++++++ .../mso_schema_template_anp_epg_selector/aliases | 2 + .../tasks/main.yml | 789 +++++++++ .../targets/mso_schema_template_bd/aliases | 2 + .../targets/mso_schema_template_bd/tasks/main.yml | 1171 +++++++++++++ .../targets/mso_schema_template_bd_subnet/aliases | 2 + .../mso_schema_template_bd_subnet/tasks/main.yml | 507 ++++++ .../mso_schema_template_contract_filter/aliases | 2 + .../tasks/main.yml | 1043 +++++++++++ .../targets/mso_schema_template_deploy/aliases | 2 + .../mso_schema_template_deploy/tasks/main.yml | 199 +++ .../mso_schema_template_external_epg/aliases | 2 + .../tasks/main.yml | 1110 ++++++++++++ .../aliases | 2 + .../tasks/main.yml | 627 +++++++ .../aliases | 2 + .../tasks/main.yml | 454 +++++ .../targets/mso_schema_template_migrate/aliases | 2 + .../mso_schema_template_migrate/tasks/main.yml | 334 ++++ .../targets/mso_schema_template_vrf/aliases | 2 + .../targets/mso_schema_template_vrf/tasks/main.yml | 518 ++++++ .../mso_schema_template_vrf_contract/aliases | 2 + .../tasks/main.yml | 859 +++++++++ .../mso/tests/integration/targets/mso_site/aliases | 2 + .../integration/targets/mso_site/tasks/main.yml | 449 +++++ .../tests/integration/targets/mso_tenant/aliases | 2 + .../integration/targets/mso_tenant/tasks/main.yml | 541 ++++++ .../integration/targets/mso_tenant_site/aliases | 2 + .../targets/mso_tenant_site/tasks/main.yml | 661 +++++++ .../mso/tests/integration/targets/mso_user/aliases | 2 + .../integration/targets/mso_user/tasks/main.yml | 522 ++++++ .../tests/integration/targets/mso_version/aliases | 2 + .../integration/targets/mso_version/tasks/main.yml | 77 + .../cisco/mso/tests/sanity/ignore-2.10.txt | 2 + .../cisco/mso/tests/sanity/ignore-2.9.txt | 0 .../cisco/mso/tests/sanity/requirements.txt | 5 + 167 files changed, 42485 insertions(+) create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/.github/workflows/ansible-test.yml create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/.github/workflows/galaxy-importer.cfg create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/.gitignore create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/.python-version create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/.vscode/launch.json create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/.vscode/settings.json create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/CHANGELOG.rst create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/FILES.json create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/LICENSE create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/MANIFEST.json create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/README.md create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/changelogs/.gitignore create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/changelogs/.plugin-cache.yaml create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/changelogs/changelog.yaml create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/changelogs/config.yaml create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/codecov.yml create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/meta/runtime.yml create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/plugins/doc_fragments/modules.py create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/plugins/module_utils/mso.py create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_backup.py create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_dhcp_option_policy.py create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_dhcp_option_policy_option.py create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_dhcp_relay_policy.py create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_dhcp_relay_policy_provider.py create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_label.py create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_rest.py create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_role.py create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema.py create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema_site.py create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_anp.py create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_anp_epg.py create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_anp_epg_domain.py create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_anp_epg_selector.py create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_anp_epg_staticleaf.py create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_anp_epg_staticport.py create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_anp_epg_subnet.py create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_bd.py create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_bd_l3out.py create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_bd_subnet.py create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_external_epg_selector.py create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_vrf.py create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_vrf_region.py create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_vrf_region_cidr.py create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_vrf_region_cidr_subnet.py create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_vrf_region_hub_network.py create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema_template.py create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_anp.py create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_anp_epg.py create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_anp_epg_contract.py create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_anp_epg_selector.py create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_anp_epg_subnet.py create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_bd.py create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_bd_subnet.py create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_contract_filter.py create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_deploy.py create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_external_epg.py create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_external_epg_contract.py create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_external_epg_selector.py create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_external_epg_subnet.py create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_externalepg.py create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_filter_entry.py create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_l3out.py create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_migrate.py create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_vrf.py create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_vrf_contract.py create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_site.py create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_tenant.py create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_tenant_site.py create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_user.py create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_version.py create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/tests/.gitignore create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/tests/integration/inventory.networking create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/tests/integration/network-integration.requirements.txt create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/tests/integration/target-prefixes.network create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_backup/aliases create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_backup/tasks/main.yml create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_dhcp_option_policy/aliases create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_dhcp_option_policy/tasks/main.yaml create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_dhcp_option_policy_option/aliases create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_dhcp_option_policy_option/tasks/main.yaml create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_dhcp_relay_policy/aliases create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_dhcp_relay_policy/tasks/main.yaml create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_dhcp_relay_policy_provider/aliases create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_dhcp_relay_policy_provider/tasks/main.yaml create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_label/aliases create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_label/tasks/main.yml create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_rest/aliases create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_rest/tasks/error_handling.yml create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_rest/tasks/json_inline.yml create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_rest/tasks/json_string.yml create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_rest/tasks/json_template.yml create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_rest/tasks/main.yml create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_rest/tasks/tenant.json.j2 create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_rest/tasks/yaml_inline.yml create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_rest/tasks/yaml_string.yml create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_role/aliases create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_role/tasks/main.yml create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_role/tasks/role-ro.yml create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_role/tasks/role-rw.yml create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema/aliases create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema/tasks/main.yml create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site/aliases create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site/tasks/main.yml create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_anp_epg_domain/aliases create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_anp_epg_domain/tasks/main.yml create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_anp_epg_selector/aliases create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_anp_epg_selector/tasks/main.yml create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_anp_epg_staticport/aliases create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_anp_epg_staticport/tasks/main.yml create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_bd/aliases create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_bd/tasks/main.yml create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_bd_subnet/aliases create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_bd_subnet/tasks/main.yml create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_external_epg_selector/aliases create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_external_epg_selector/tasks/main.yml create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_vrf_region/aliases create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_vrf_region/tasks/main.yml create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_vrf_region_cidr/aliases create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_vrf_region_cidr/tasks/main.yml create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_vrf_region_cidr_subnet/aliases create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_vrf_region_cidr_subnet/tasks/main.yml create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_vrf_region_hub_network/aliases create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_vrf_region_hub_network/tasks/hub_network.yml create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_vrf_region_hub_network/tasks/main.yml create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template/aliases create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template/tasks/main.yml create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_anp/aliases create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_anp/tasks/main.yml create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_anp_epg/aliases create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_anp_epg/tasks/main.yml create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_anp_epg_contract/aliases create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_anp_epg_contract/tasks/main.yml create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_anp_epg_selector/aliases create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_anp_epg_selector/tasks/main.yml create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_bd/aliases create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_bd/tasks/main.yml create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_bd_subnet/aliases create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_bd_subnet/tasks/main.yml create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_contract_filter/aliases create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_contract_filter/tasks/main.yml create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_deploy/aliases create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_deploy/tasks/main.yml create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_external_epg/aliases create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_external_epg/tasks/main.yml create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_external_epg_contract/aliases create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_external_epg_contract/tasks/main.yml create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_external_epg_selector/aliases create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_external_epg_selector/tasks/main.yml create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_migrate/aliases create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_migrate/tasks/main.yml create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_vrf/aliases create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_vrf/tasks/main.yml create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_vrf_contract/aliases create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_vrf_contract/tasks/main.yml create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_site/aliases create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_site/tasks/main.yml create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_tenant/aliases create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_tenant/tasks/main.yml create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_tenant_site/aliases create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_tenant_site/tasks/main.yml create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_user/aliases create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_user/tasks/main.yml create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_version/aliases create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_version/tasks/main.yml create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/tests/sanity/ignore-2.10.txt create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/tests/sanity/ignore-2.9.txt create mode 100644 collections-debian-merged/ansible_collections/cisco/mso/tests/sanity/requirements.txt (limited to 'collections-debian-merged/ansible_collections/cisco/mso') diff --git a/collections-debian-merged/ansible_collections/cisco/mso/.github/workflows/ansible-test.yml b/collections-debian-merged/ansible_collections/cisco/mso/.github/workflows/ansible-test.yml new file mode 100644 index 00000000..16165e32 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/.github/workflows/ansible-test.yml @@ -0,0 +1,216 @@ +name: CI +on: + push: + branches: master + pull_request: + schedule: + # * is a special character in YAML so you have to quote this string + - cron: '0 7 * * *' +jobs: + build: + name: Build collection + runs-on: ubuntu-latest + strategy: + matrix: + ansible: [2.9.12, 2.10.0] + steps: + - name: Check out code + uses: actions/checkout@v2 + + - name: Set up Python 3.7 + uses: actions/setup-python@v1 + with: + python-version: 3.7 + + - name: Install ansible-base (v${{ matrix.ansible }}) + run: pip install https://github.com/ansible/ansible/archive/v${{ matrix.ansible }}.tar.gz --disable-pip-version-check + + - name: Build a collection tarball + run: ansible-galaxy collection build --output-path "${GITHUB_WORKSPACE}/.cache/collection-tarballs" + + - name: Store migrated collection artifacts + uses: actions/upload-artifact@v1 + with: + name: collection + path: .cache/collection-tarballs + + importer: + name: Galaxy-importer check + needs: + - build + runs-on: ubuntu-latest + steps: + - name: Set up Python 3.7 + uses: actions/setup-python@v1 + with: + python-version: 3.7 + + - name: Install ansible-base (v2.9.12) + run: pip install https://github.com/ansible/ansible/archive/v2.9.12.tar.gz --disable-pip-version-check + + - name: Download migrated collection artifacts + uses: actions/download-artifact@v1 + with: + name: collection + path: .cache/collection-tarballs + + - name: Install the collection tarball + run: ansible-galaxy collection install .cache/collection-tarballs/*.tar.gz + + - name: Install galaxy-importer + run: pip install galaxy-importer + + - name: Create galaxy-importer directory + run: sudo mkdir -p /etc/galaxy-importer + + - name: Create galaxy-importer.cfg + run: sudo cp /home/runner/.ansible/collections/ansible_collections/cisco/mso/.github/workflows/galaxy-importer.cfg /etc/galaxy-importer/galaxy-importer.cfg + + - name: Run galaxy-importer check + run: python -m galaxy_importer.main .cache/collection-tarballs/cisco-*.tar.gz | tee .cache/collection-tarballs/log.txt && sudo cp ./importer_result.json .cache/collection-tarballs/importer_result.json + + - name: Check warnings and errors + run: if grep -E 'WARNING|ERROR' .cache/collection-tarballs/log.txt; then exit 1; else exit 0; fi + + - name: Store galaxy_importer check log file + uses: actions/upload-artifact@v1 + with: + name: galaxy-importer-log + path: .cache/collection-tarballs/importer_result.json + + + sanity: + name: Sanity in ubuntu-latest + needs: + - build + runs-on: ubuntu-latest + strategy: + matrix: + ansible: [2.9.12, 2.10.0] + steps: + - name: Set up Python 3.7 + uses: actions/setup-python@v1 + with: + python-version: 3.7 + + - name: Install ansible-base (v${{ matrix.ansible }}) + run: pip install https://github.com/ansible/ansible/archive/v${{ matrix.ansible }}.tar.gz --disable-pip-version-check + + - name: Install coverage (v4.5.4) + run: pip install coverage==4.5.4 + + - name: Download migrated collection artifacts + uses: actions/download-artifact@v1 + with: + name: collection + path: .cache/collection-tarballs + + - name: Install the collection tarball + run: ansible-galaxy collection install .cache/collection-tarballs/*.tar.gz + + - name: Run sanity tests + run: ansible-test sanity --docker -v --color --truncate 0 --coverage + working-directory: /home/runner/.ansible/collections/ansible_collections/cisco/mso + + - name: Generate coverage report + run: ansible-test coverage xml -v --requirements --group-by command --group-by version + working-directory: /home/runner/.ansible/collections/ansible_collections/cisco/mso + + - name: Push coverate report to codecov.io + run: bash <(curl -s https://codecov.io/bash) -s 'tests/output/reports/' -F integration + working-directory: /home/runner/.ansible/collections/ansible_collections/cisco/mso + + units: + name: Units in ubuntu-latest + needs: + - build + runs-on: ubuntu-latest + strategy: + matrix: + ansible: [2.9.12, 2.10.0] + steps: + - name: Set up Python 3.7 + uses: actions/setup-python@v1 + with: + python-version: 3.7 + + - name: Install ansible-base (v${{ matrix.ansible }}) + run: pip install https://github.com/ansible/ansible/archive/v${{ matrix.ansible }}.tar.gz --disable-pip-version-check + + - name: Install coverage (v4.5.4) + run: pip install coverage==4.5.4 + + - name: Download migrated collection artifacts + uses: actions/download-artifact@v1 + with: + name: collection + path: .cache/collection-tarballs + + - name: Install the collection tarball + run: ansible-galaxy collection install .cache/collection-tarballs/*.tar.gz + + #- name: Run unit tests + # run: ansible-test units --docker -v --color --truncate 0 --python 3.7 --coverage + # working-directory: /home/runner/.ansible/collections/ansible_collections/cisco/mso + + #- name: Generate coverage report. + # run: ansible-test coverage xml -v --requirements --group-by command --group-by version + # working-directory: /home/runner/.ansible/collections/ansible_collections/cisco/mso + + #- uses: codecov/codecov-action@v1 + # with: + # fail_ci_if_error: false + # file: /home/runner/.ansible/collections/ansible_collections/cisco/mso/tests/output/reports/coverage.xml + + integration: + name: Integration in ubuntu-latest + needs: + - build + runs-on: ubuntu-latest + steps: + - name: Set up Python 3.7 + uses: actions/setup-python@v1 + with: + python-version: 3.7 + + - name: Install ansible-base (v2.9.12) + run: pip install https://github.com/ansible/ansible/archive/v2.9.12.tar.gz --disable-pip-version-check + + - name: Install coverage (v4.5.4) + run: pip install coverage==4.5.4 + + - name: Download migrated collection artifacts + uses: actions/download-artifact@v1 + with: + name: collection + path: .cache/collection-tarballs + + - name: Install the collection tarball + run: ansible-galaxy collection install .cache/collection-tarballs/*.tar.gz + + - name: Requesting integration mutex + uses: nev7n/wait_for_response@v1 + with: + url: ${{ format('https://8v7s765ibh.execute-api.us-west-1.amazonaws.com/v1/ansible-mso?repo={0}', github.repository) }} + responseCode: 200 + timeout: 2000000 + interval: 5000 + + - name: Run integration tests on Python 3.7 + run: ansible-test network-integration --docker -v --color --retry-on-error --python 3.7 --truncate 0 --continue-on-error --coverage + working-directory: /home/runner/.ansible/collections/ansible_collections/cisco/mso + + - name: Releasing integration mutex + uses: nev7n/wait_for_response@v1 + if: always() + with: + url: ${{ format('https://8v7s765ibh.execute-api.us-west-1.amazonaws.com/v1/ansible-mso/release?repo={0}', github.repository) }} + responseCode: 200 + + - name: Generate coverage report + run: ansible-test coverage xml -v --requirements --group-by command --group-by version + working-directory: /home/runner/.ansible/collections/ansible_collections/cisco/mso + + - name: Push coverate report to codecov.io + run: bash <(curl -s https://codecov.io/bash) -s 'tests/output/reports/' -F integration + working-directory: /home/runner/.ansible/collections/ansible_collections/cisco/mso diff --git a/collections-debian-merged/ansible_collections/cisco/mso/.github/workflows/galaxy-importer.cfg b/collections-debian-merged/ansible_collections/cisco/mso/.github/workflows/galaxy-importer.cfg new file mode 100644 index 00000000..631359cf --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/.github/workflows/galaxy-importer.cfg @@ -0,0 +1,9 @@ +[galaxy-importer] +LOG_LEVEL_MAIN = INFO +RUN_FLAKE8 = True +RUN_ANSIBLE_DOC = True +RUN_ANSIBLE_LINT = True +RUN_ANSIBLE_TEST = False +ANSIBLE_TEST_LOCAL_IMAGE = False +LOCAL_IMAGE_DOCKER = False +INFRA_OSD = False \ No newline at end of file diff --git a/collections-debian-merged/ansible_collections/cisco/mso/.gitignore b/collections-debian-merged/ansible_collections/cisco/mso/.gitignore new file mode 100644 index 00000000..9da35106 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/.gitignore @@ -0,0 +1,393 @@ + +# Created by https://www.gitignore.io/api/git,linux,pydev,python,windows,pycharm+all,jupyternotebook,vim,webstorm,emacs,dotenv +# Edit at https://www.gitignore.io/?templates=git,linux,pydev,python,windows,pycharm+all,jupyternotebook,vim,webstorm,emacs,dotenv + +### dotenv ### +.env + +### Emacs ### +# -*- mode: gitignore; -*- +*~ +\#*\# +/.emacs.desktop +/.emacs.desktop.lock +*.elc +auto-save-list +tramp +.\#* + +# Org-mode +.org-id-locations +*_archive + +# flymake-mode +*_flymake.* + +# eshell files +/eshell/history +/eshell/lastdir + +# elpa packages +/elpa/ + +# reftex files +*.rel + +# AUCTeX auto folder +/auto/ + +# cask packages +.cask/ +dist/ + +# Flycheck +flycheck_*.el + +# server auth directory +/server/ + +# projectiles files +.projectile + +# directory configuration +.dir-locals.el + +# network security +/network-security.data + + +### Git ### +# Created by git for backups. To disable backups in Git: +# $ git config --global mergetool.keepBackup false +*.orig + +# Created by git when using merge tools for conflicts +*.BACKUP.* +*.BASE.* +*.LOCAL.* +*.REMOTE.* +*_BACKUP_*.txt +*_BASE_*.txt +*_LOCAL_*.txt +*_REMOTE_*.txt + +#!! ERROR: jupyternotebook is undefined. Use list command to see defined gitignore types !!# + +### Linux ### + +# temporary files which can be created if a process still has a handle open of a deleted file +.fuse_hidden* + +# KDE directory preferences +.directory + +# Linux trash folder which might appear on any partition or disk +.Trash-* + +# .nfs files are created when an open file is removed but is still being accessed +.nfs* + +### PyCharm+all ### +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm +# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 + +# User-specific stuff +.idea/**/workspace.xml +.idea/**/tasks.xml +.idea/**/usage.statistics.xml +.idea/**/dictionaries +.idea/**/shelf + +# Generated files +.idea/**/contentModel.xml + +# Sensitive or high-churn files +.idea/**/dataSources/ +.idea/**/dataSources.ids +.idea/**/dataSources.local.xml +.idea/**/sqlDataSources.xml +.idea/**/dynamic.xml +.idea/**/uiDesigner.xml +.idea/**/dbnavigator.xml + +# Gradle +.idea/**/gradle.xml +.idea/**/libraries + +# Gradle and Maven with auto-import +# When using Gradle or Maven with auto-import, you should exclude module files, +# since they will be recreated, and may cause churn. Uncomment if using +# auto-import. +# .idea/modules.xml +# .idea/*.iml +# .idea/modules +# *.iml +# *.ipr + +# CMake +cmake-build-*/ + +# Mongo Explorer plugin +.idea/**/mongoSettings.xml + +# File-based project format +*.iws + +# IntelliJ +out/ + +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Cursive Clojure plugin +.idea/replstate.xml + +# Crashlytics plugin (for Android Studio and IntelliJ) +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties +fabric.properties + +# Editor-based Rest Client +.idea/httpRequests + +# Android studio 3.1+ serialized cache file +.idea/caches/build_file_checksums.ser + +### PyCharm+all Patch ### +# Ignores the whole .idea folder and all .iml files +# See https://github.com/joeblau/gitignore.io/issues/186 and https://github.com/joeblau/gitignore.io/issues/360 + +.idea/ + +# Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-249601023 + +*.iml +modules.xml +.idea/misc.xml +*.ipr + +# Sonarlint plugin +.idea/sonarlint + +### pydev ### +.pydevproject + +### Python ### +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +pip-wheel-metadata/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +.hypothesis/ +.pytest_cache/ + +# Translations +*.mo +*.pot + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +target/ + +# pyenv +.python-version + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don't work, or not +# install all needed dependencies. +#Pipfile.lock + +# celery beat schedule file +celerybeat-schedule + +# SageMath parsed files +*.sage.py + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# Mr Developer +.mr.developer.cfg +.project + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ + +### Vim ### +# Swap +[._]*.s[a-v][a-z] +[._]*.sw[a-p] +[._]s[a-rt-v][a-z] +[._]ss[a-gi-z] +[._]sw[a-p] + +# Session +Session.vim +Sessionx.vim + +# Temporary +.netrwhist +# Auto-generated tag files +tags +# Persistent undo +[._]*.un~ + +### WebStorm ### +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm +# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 + +# User-specific stuff + +# Generated files + +# Sensitive or high-churn files + +# Gradle + +# Gradle and Maven with auto-import +# When using Gradle or Maven with auto-import, you should exclude module files, +# since they will be recreated, and may cause churn. Uncomment if using +# auto-import. +# .idea/modules.xml +# .idea/*.iml +# .idea/modules +# *.iml +# *.ipr + +# CMake + +# Mongo Explorer plugin + +# File-based project format + +# IntelliJ + +# mpeltonen/sbt-idea plugin + +# JIRA plugin + +# Cursive Clojure plugin + +# Crashlytics plugin (for Android Studio and IntelliJ) + +# Editor-based Rest Client + +# Android studio 3.1+ serialized cache file + +### WebStorm Patch ### +# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721 + +# *.iml +# modules.xml +# .idea/misc.xml +# *.ipr + +# Sonarlint plugin +.idea/**/sonarlint/ + +# SonarQube Plugin +.idea/**/sonarIssues.xml + +# Markdown Navigator plugin +.idea/**/markdown-navigator.xml +.idea/**/markdown-navigator/ + +### Windows ### +# Windows thumbnail cache files +Thumbs.db +Thumbs.db:encryptable +ehthumbs.db +ehthumbs_vista.db + +# Dump file +*.stackdump + +# Folder config file +[Dd]esktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Windows Installer files +*.cab +*.msi +*.msix +*.msm +*.msp + +# Windows shortcuts +*.lnk + +# End of https://www.gitignore.io/api/git,linux,pydev,python,windows,pycharm+all,jupyternotebook,vim,webstorm,emacs,dotenv + +# vsCode +.vscode + +# Ansible Collection tarball +cisco-mso-*.tar.gz diff --git a/collections-debian-merged/ansible_collections/cisco/mso/.python-version b/collections-debian-merged/ansible_collections/cisco/mso/.python-version new file mode 100644 index 00000000..40c341bd --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/.python-version @@ -0,0 +1 @@ +3.6.0 diff --git a/collections-debian-merged/ansible_collections/cisco/mso/.vscode/launch.json b/collections-debian-merged/ansible_collections/cisco/mso/.vscode/launch.json new file mode 100644 index 00000000..7a9dfa04 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/.vscode/launch.json @@ -0,0 +1,15 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "type": "pwa-chrome", + "request": "launch", + "name": "Launch Chrome against localhost", + "url": "http://localhost:8080", + "webRoot": "${workspaceFolder}" + } + ] +} \ No newline at end of file diff --git a/collections-debian-merged/ansible_collections/cisco/mso/.vscode/settings.json b/collections-debian-merged/ansible_collections/cisco/mso/.vscode/settings.json new file mode 100644 index 00000000..988937c0 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "python.pythonPath": "/usr/local/bin/python3" +} \ No newline at end of file diff --git a/collections-debian-merged/ansible_collections/cisco/mso/CHANGELOG.rst b/collections-debian-merged/ansible_collections/cisco/mso/CHANGELOG.rst new file mode 100644 index 00000000..5981cc81 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/CHANGELOG.rst @@ -0,0 +1,263 @@ +========================================== +Cisco MSO Ansible Collection Release Notes +========================================== + +.. contents:: Topics + +This changelog describes changes after version 0.0.4. + +v1.1.0 +====== + +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. + + +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 + +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 + +v1.0.1 +====== + +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. + + +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 + +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 + +v1.0.0 +====== + +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. + + +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 + +Bugfixes +-------- + +- Fix sanity issues to support 2.10.0 + +v0.0.8 +====== + +Release Summary +--------------- + +New release v0.0.8 + +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 + +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 + +v0.0.7 +====== + +Release Summary +--------------- + +New release v0.0.7 + +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 + +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 + +v0.0.6 +====== + +Release Summary +--------------- + +New release v0.0.6 + +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) + +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 + +v0.0.5 +====== + +Release Summary +--------------- + +New release v0.0.5 diff --git a/collections-debian-merged/ansible_collections/cisco/mso/FILES.json b/collections-debian-merged/ansible_collections/cisco/mso/FILES.json new file mode 100644 index 00000000..9e8f08df --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/FILES.json @@ -0,0 +1,1818 @@ +{ + "files": [ + { + "name": ".", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "codecov.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "e55a41874408d15b899f7df85fa9f4c6c3c476cf4a9e919b9a396c3f1aa1a1f0", + "format": 1 + }, + { + "name": "LICENSE", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "1c38eb11b6b8cd591aed90793ca80bd3c499393f207b96640ddfa571f61f7b4f", + "format": 1 + }, + { + "name": "plugins", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "plugins/doc_fragments", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "plugins/doc_fragments/modules.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "c9bdb9272c7d674da1a8f83bfd5229d4814d2bfd72937d00215470b46aa0c0d8", + "format": 1 + }, + { + "name": "plugins/module_utils", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "plugins/module_utils/mso.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "58c0e72b4b0b739230d56046109b806c2adcbe1c1e65c731c9f7f3e142b35c12", + "format": 1 + }, + { + "name": "plugins/modules", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "plugins/modules/mso_schema_template_contract_filter.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "abb1fe3a4648aecac7248abc627e198abc98fe04f7fc2a5d3f8c50cfff34aabd", + "format": 1 + }, + { + "name": "plugins/modules/mso_schema_site_anp_epg_staticport.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "a471f926c41721d6ebb376779adc98000be8ace30f68076aea05ded5f74e292a", + "format": 1 + }, + { + "name": "plugins/modules/mso_schema_site_anp.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "a7f158b17cda7542b480d2a1db22d882b8f5702571fd1be1262e8e3537cf5c20", + "format": 1 + }, + { + "name": "plugins/modules/mso_dhcp_option_policy_option.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "59dbdebb1af250bdbf47831441faf6a8c702d4b9d302772fc28c88b6961d0c78", + "format": 1 + }, + { + "name": "plugins/modules/mso_schema_site_vrf_region_hub_network.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "fc6e2f6d3413264f473756fea7cbd29fee5443dcd871ecf2ac01810b7ffebb5d", + "format": 1 + }, + { + "name": "plugins/modules/mso_schema_site_external_epg_selector.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "1ab4a7671bf0a7d071db7de003f14670dbfbe9909d991ba4742d2429d4071d37", + "format": 1 + }, + { + "name": "plugins/modules/mso_schema_site_anp_epg.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "771801244904bb8cd38f88c61ff580af8327c03d26b2ed19154baff739307453", + "format": 1 + }, + { + "name": "plugins/modules/mso_schema_site_bd_subnet.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "00396c383da7cb96daf7662a951e01e7046d92fa087ce88765a699eefc6d41b8", + "format": 1 + }, + { + "name": "plugins/modules/mso_schema_template_anp.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "cd0895dc40ce85c4d3799e03db32b0e489e4c99d5112fb4b9b8687f216b15e9d", + "format": 1 + }, + { + "name": "plugins/modules/mso_schema_template_bd_subnet.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "d8d2a8cb6a110d3c5160638bc27cd409611a5fe928c2901b6ad97366307e585e", + "format": 1 + }, + { + "name": "plugins/modules/mso_schema_template_deploy.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "e715c4d210787cc859335e841d2bc6f17a62f0405468689567c9f14f9218fa3c", + "format": 1 + }, + { + "name": "plugins/modules/mso_tenant.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "5cfcab4b87d0d74ea4c6753c93df039f06912482e8a878d637831ff3d9936005", + "format": 1 + }, + { + "name": "plugins/modules/mso_schema_site_vrf_region_cidr_subnet.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "2d139d9cc2b714d5d3a37ab2d63cdb3d1ed98720ce50ba8bbb1f228787731add", + "format": 1 + }, + { + "name": "plugins/modules/mso_schema_site_vrf.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "e72a5f3cb6c25325eb1856a8b91aef725ab653abae749e1c8799075944348b27", + "format": 1 + }, + { + "name": "plugins/modules/mso_schema_site_anp_epg_staticleaf.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "f2af89c469a2ccdfb7bbac70510b0a054e809a5286b78a22621794f316743cd4", + "format": 1 + }, + { + "name": "plugins/modules/mso_schema_template_external_epg_contract.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "167cd6ba76b9781e2dbaa5d39af08d8805a61b4274241f1914f7471a825b2ee2", + "format": 1 + }, + { + "name": "plugins/modules/mso_schema_template_external_epg.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "540303678415605ac4f23551c8512478e7d2c7dcc066d08c685a207ed38655e4", + "format": 1 + }, + { + "name": "plugins/modules/mso_schema_site_vrf_region_cidr.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "400f90764082bcf18c7ca613e8c3a8a0025039536266e726f64e3035c7a4efa6", + "format": 1 + }, + { + "name": "plugins/modules/mso_schema_template_anp_epg.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "8103f521617a8a43f80fcf69921b76eb4f6e1b8bea575b0151e82da6b44eef37", + "format": 1 + }, + { + "name": "plugins/modules/mso_schema_template_anp_epg_contract.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "fa5f73b80d499e386d7e353d983831dc36cecd1959dea8381a73f20d98891896", + "format": 1 + }, + { + "name": "plugins/modules/mso_dhcp_relay_policy_provider.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "8f4f54b34ffd05a558a06832d05f60591f1a4d700a26715ebe64a5e39e392583", + "format": 1 + }, + { + "name": "plugins/modules/mso_tenant_site.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "fae53fbb6c20b9585c7626f8491d8742526f4089510e71bdb0a0cccf44968198", + "format": 1 + }, + { + "name": "plugins/modules/mso_backup.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "689a9f048018c896592e16d7e998cac0954807b5f547b8722c53701e5665e9c3", + "format": 1 + }, + { + "name": "plugins/modules/mso_site.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "5cf15ce9bcf517d820852ed47c2e8119e5a7f90a12d1f3f779aaeb7fdf5e59ed", + "format": 1 + }, + { + "name": "plugins/modules/mso_schema_site_anp_epg_selector.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "09b7884ca381132504650773a09112ece3a22abc07a4a6df860853ca51a7422d", + "format": 1 + }, + { + "name": "plugins/modules/mso_schema_template_vrf.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "4aed9bec4e8e994d4eed4ba00ff17d93fd559d8b2d12019bd4f369442e5ec7eb", + "format": 1 + }, + { + "name": "plugins/modules/mso_schema.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "a8bc48b779a68d8e2a2388f54fbfc18dbee8b98eb205ff895a0f18e0591c7482", + "format": 1 + }, + { + "name": "plugins/modules/mso_schema_site_bd_l3out.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "1197bb89c4fc3b7939e537faf810775fa73e6d03c3a28e92d4f39601a00e7748", + "format": 1 + }, + { + "name": "plugins/modules/mso_schema_site_anp_epg_domain.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "80275ca7986ff83d4bfc543219bf8cd43a0d03d192e961a6060ec285f479c4b6", + "format": 1 + }, + { + "name": "plugins/modules/mso_role.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "adddfabdc9c111f6fe4ace549b632033861f16cb27f0a7fd8da831edf83ac7c1", + "format": 1 + }, + { + "name": "plugins/modules/mso_schema_template_externalepg.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "540303678415605ac4f23551c8512478e7d2c7dcc066d08c685a207ed38655e4", + "format": 1 + }, + { + "name": "plugins/modules/mso_schema_template_external_epg_subnet.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "d20d75a8e106fae376ab425ccf77ab528933997ecc189932a53bddd9dbfe1ea2", + "format": 1 + }, + { + "name": "plugins/modules/mso_schema_template_filter_entry.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "c5a653d73adb0c1dde50f07443f7d42f66d705d6c6889a7383fec174cfc2fd33", + "format": 1 + }, + { + "name": "plugins/modules/mso_schema_site_bd.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "389a7e612598203d8d2a77cf4a8cb45b431c3a88aa5a83c9de46737236e59f4b", + "format": 1 + }, + { + "name": "plugins/modules/mso_schema_site_anp_epg_subnet.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "c23913555cbad93fb706c7922ce8c33ab0adee2afc683649f2d1669360d9c8bb", + "format": 1 + }, + { + "name": "plugins/modules/mso_rest.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "e2732290d96519eba0dff3054d2732960116ff1a1ac448ec6ca9fc75ab5382ed", + "format": 1 + }, + { + "name": "plugins/modules/mso_schema_template_vrf_contract.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "69e2ce77e81a41cf0ff7430104b7169f4493f52dcd521b866d17dcc02e5825db", + "format": 1 + }, + { + "name": "plugins/modules/mso_label.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "4a6a66707900cdd0e251b576232e2f5037ccc4d010a497697943a52c60900368", + "format": 1 + }, + { + "name": "plugins/modules/mso_schema_site_vrf_region.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "40fd18083d1c8d3414d4343932d3ad7d604dc3f7f623793ed8390878ced10699", + "format": 1 + }, + { + "name": "plugins/modules/mso_schema_template_external_epg_selector.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "fc8fdde7bc37626adc7d33130a50aa27d839bad092c712d29a427fe4cf954fbd", + "format": 1 + }, + { + "name": "plugins/modules/mso_schema_template_migrate.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "fb32edc876de806c254581a5c2109e9ff9d51c367de10e2c8f71166fbb407667", + "format": 1 + }, + { + "name": "plugins/modules/mso_version.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "efd9c46d036f626cf8ea0b512f9e431d19cfb635702367283bb6eccc7cb9f75b", + "format": 1 + }, + { + "name": "plugins/modules/mso_schema_template_l3out.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "7dcf4d21e763975aae9d30c5d246d773a6ad89fe56b33cd3aed8f7001adccfab", + "format": 1 + }, + { + "name": "plugins/modules/mso_dhcp_relay_policy.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "0fe6aaf90481f3e58ce8d8a704f2423cf9f93c44ee7b7b2d43714915662a292b", + "format": 1 + }, + { + "name": "plugins/modules/mso_schema_template_anp_epg_subnet.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "5c5dd42baf4df1ca3519c629d210a717ac86a05833285744445b854f05c6f0b3", + "format": 1 + }, + { + "name": "plugins/modules/mso_dhcp_option_policy.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "3ad2d4b91e14ff12e734bc7d70e33e87b89dc7abb4e42545538f0a3459d0e222", + "format": 1 + }, + { + "name": "plugins/modules/mso_schema_template_anp_epg_selector.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "20a19966ed9e8ff9879f327767e7567262f09d86684bd7dd03b2d8936875a4ea", + "format": 1 + }, + { + "name": "plugins/modules/mso_user.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "840a8200388623e4ab70358205945355d5fd242c370929158b2a689b9e711a32", + "format": 1 + }, + { + "name": "plugins/modules/mso_schema_template_bd.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "e4123b686517681e0e2784c46f6c95abd3cd0341731a0f917566bcec044b78e2", + "format": 1 + }, + { + "name": "plugins/modules/mso_schema_site.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "69e0ac1adefcd37ff6a51ae8d0b59af4f9c768ac6c1a149d76168d5811954568", + "format": 1 + }, + { + "name": "plugins/modules/mso_schema_template.py", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "eb69162c4558466a7e1b49bc8d30c554c58989f064ad31f4de38b2f506f9de98", + "format": 1 + }, + { + "name": "tests", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/mso_dhcp_relay_policy", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/mso_dhcp_relay_policy/tasks", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/mso_dhcp_relay_policy/tasks/main.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "78a754bee3a864e80e598727bce869ecd3d6ffb676650b54c255462c430ee4b9", + "format": 1 + }, + { + "name": "tests/integration/targets/mso_dhcp_relay_policy/aliases", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "4e674607496d01ce032bfdbcc3e77ecdcde02f3e9d57080a95682a0cdff6809a", + "format": 1 + }, + { + "name": "tests/integration/targets/mso_schema_template_deploy", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/mso_schema_template_deploy/tasks", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/mso_schema_template_deploy/tasks/main.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "05b9c28ef714e958e1715d0521968545de8536bba5a0d16943047feb11cd06f3", + "format": 1 + }, + { + "name": "tests/integration/targets/mso_schema_template_deploy/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, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/mso_schema_site_vrf_region_cidr_subnet/tasks", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/mso_schema_site_vrf_region_cidr_subnet/tasks/main.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "f2130e64acb090d7387cc2bc7f4fa7ccf31566c1b5608fd0620d56bf2547a55c", + "format": 1 + }, + { + "name": "tests/integration/targets/mso_schema_site_vrf_region_cidr_subnet/aliases", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "4e674607496d01ce032bfdbcc3e77ecdcde02f3e9d57080a95682a0cdff6809a", + "format": 1 + }, + { + "name": "tests/integration/targets/mso_schema_template", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/mso_schema_template/tasks", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/mso_schema_template/tasks/main.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "f2ba1a5dcb11aa29ef94539ee048a34ba238b2e71a0eb492d368b025e4cbc69f", + "format": 1 + }, + { + "name": "tests/integration/targets/mso_schema_template/aliases", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "4e674607496d01ce032bfdbcc3e77ecdcde02f3e9d57080a95682a0cdff6809a", + "format": 1 + }, + { + "name": "tests/integration/targets/mso_rest", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/mso_rest/tasks", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/mso_rest/tasks/json_template.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "0bf0d1ad63cbaf219a1a1ad09eb6f3cf30d705fd90b2ee982df07aa2a5a187fb", + "format": 1 + }, + { + "name": "tests/integration/targets/mso_rest/tasks/tenant.json.j2", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "6636b61fb38e341e4520e1f158bbce619e6b70e6e6d4bd243177ec86069f50dd", + "format": 1 + }, + { + "name": "tests/integration/targets/mso_rest/tasks/json_inline.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "200b1ccceb65da2574e272bfd85d2c86647fe6b66009b6212cd3fc52f9b20fb4", + "format": 1 + }, + { + "name": "tests/integration/targets/mso_rest/tasks/json_string.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "6651fd6245387072f029420d8645435eff75d476ebb5371d76097537ddbe4671", + "format": 1 + }, + { + "name": "tests/integration/targets/mso_rest/tasks/yaml_inline.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "281aa3b5bd0c064a63ca042823c3f3d7ccef8a27c87da29d41a48c18cbd6ae8d", + "format": 1 + }, + { + "name": "tests/integration/targets/mso_rest/tasks/yaml_string.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "411ff084b29637a3a9d78588a09c9632924ce6a37191420d1167538f478706bd", + "format": 1 + }, + { + "name": "tests/integration/targets/mso_rest/tasks/main.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "52f1fb7f60fafa3735b17352ca4e1da195810b0edf3f2680738092e4d52fb1b1", + "format": 1 + }, + { + "name": "tests/integration/targets/mso_rest/tasks/error_handling.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "ff08e84d3317f2e588f5d13551d799c9b45e6b81da361dc68ed45d66405ec57f", + "format": 1 + }, + { + "name": "tests/integration/targets/mso_rest/aliases", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "4e674607496d01ce032bfdbcc3e77ecdcde02f3e9d57080a95682a0cdff6809a", + "format": 1 + }, + { + "name": "tests/integration/targets/mso_schema_site", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/mso_schema_site/tasks", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/mso_schema_site/tasks/main.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "0a19356b0780059327d159709f90f1cbd4ddac0ff930130a18b3e6ae6a6fb373", + "format": 1 + }, + { + "name": "tests/integration/targets/mso_schema_site/aliases", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "4e674607496d01ce032bfdbcc3e77ecdcde02f3e9d57080a95682a0cdff6809a", + "format": 1 + }, + { + "name": "tests/integration/targets/mso_schema", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/mso_schema/tasks", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/mso_schema/tasks/main.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "6028beaf3fe209ed5c0c65679826e31df8b761983e19a077a83047f46caf3fa3", + "format": 1 + }, + { + "name": "tests/integration/targets/mso_schema/aliases", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "4e674607496d01ce032bfdbcc3e77ecdcde02f3e9d57080a95682a0cdff6809a", + "format": 1 + }, + { + "name": "tests/integration/targets/mso_schema_template_migrate", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/mso_schema_template_migrate/tasks", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/mso_schema_template_migrate/tasks/main.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "4cfa881a158049b6d65cfe2e0a6dd773e188f119f131f590c8c588748bea53a2", + "format": 1 + }, + { + "name": "tests/integration/targets/mso_schema_template_migrate/aliases", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "4e674607496d01ce032bfdbcc3e77ecdcde02f3e9d57080a95682a0cdff6809a", + "format": 1 + }, + { + "name": "tests/integration/targets/mso_schema_template_anp", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/mso_schema_template_anp/tasks", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/mso_schema_template_anp/tasks/main.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "bd112b03d6ffaa18c6e685a26b86ce0404cd41cb14bfc0d5b16de8f589dc72a5", + "format": 1 + }, + { + "name": "tests/integration/targets/mso_schema_template_anp/aliases", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "4e674607496d01ce032bfdbcc3e77ecdcde02f3e9d57080a95682a0cdff6809a", + "format": 1 + }, + { + "name": "tests/integration/targets/mso_schema_site_anp_epg_selector", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/mso_schema_site_anp_epg_selector/tasks", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/mso_schema_site_anp_epg_selector/tasks/main.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "55679adb6d3d85776a7f81f16c5a1fa8b023f8c32d7caf88306bcf3b59f27c54", + "format": 1 + }, + { + "name": "tests/integration/targets/mso_schema_site_anp_epg_selector/aliases", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "4e674607496d01ce032bfdbcc3e77ecdcde02f3e9d57080a95682a0cdff6809a", + "format": 1 + }, + { + "name": "tests/integration/targets/mso_schema_template_external_epg_selector", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/mso_schema_template_external_epg_selector/tasks", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/mso_schema_template_external_epg_selector/tasks/main.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "9651b31903da9a54df64d768d5e4b4eafc8727e056cd9a83000fc6f9867d5024", + "format": 1 + }, + { + "name": "tests/integration/targets/mso_schema_template_external_epg_selector/aliases", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "4e674607496d01ce032bfdbcc3e77ecdcde02f3e9d57080a95682a0cdff6809a", + "format": 1 + }, + { + "name": "tests/integration/targets/mso_schema_template_external_epg_contract", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/mso_schema_template_external_epg_contract/tasks", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/mso_schema_template_external_epg_contract/tasks/main.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "07f7f9e17af1f1b5141bf5993a91ef3c6f3d787f5d675c5d24681df97d266eb2", + "format": 1 + }, + { + "name": "tests/integration/targets/mso_schema_template_external_epg_contract/aliases", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "4e674607496d01ce032bfdbcc3e77ecdcde02f3e9d57080a95682a0cdff6809a", + "format": 1 + }, + { + "name": "tests/integration/targets/mso_schema_site_vrf_region", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/mso_schema_site_vrf_region/tasks", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/mso_schema_site_vrf_region/tasks/main.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "7ca7b7487fe50f86042ccf6a27c79d15eb163ec300a4f671e0e209edc195e8cc", + "format": 1 + }, + { + "name": "tests/integration/targets/mso_schema_site_vrf_region/aliases", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "4e674607496d01ce032bfdbcc3e77ecdcde02f3e9d57080a95682a0cdff6809a", + "format": 1 + }, + { + "name": "tests/integration/targets/mso_schema_template_contract_filter", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/mso_schema_template_contract_filter/tasks", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/mso_schema_template_contract_filter/tasks/main.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "fea8388f21eede81f1a49c00b28b5832e63f12679a43a354739f074a230976d3", + "format": 1 + }, + { + "name": "tests/integration/targets/mso_schema_template_contract_filter/aliases", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "4e674607496d01ce032bfdbcc3e77ecdcde02f3e9d57080a95682a0cdff6809a", + "format": 1 + }, + { + "name": "tests/integration/targets/mso_dhcp_option_policy_option", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/mso_dhcp_option_policy_option/tasks", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/mso_dhcp_option_policy_option/tasks/main.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "134b2828319ac23ba07f2cbb5ebf7e14b90e2ce27220946e10d10be2bdc2f568", + "format": 1 + }, + { + "name": "tests/integration/targets/mso_dhcp_option_policy_option/aliases", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "4e674607496d01ce032bfdbcc3e77ecdcde02f3e9d57080a95682a0cdff6809a", + "format": 1 + }, + { + "name": "tests/integration/targets/mso_schema_site_external_epg_selector", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/mso_schema_site_external_epg_selector/tasks", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/mso_schema_site_external_epg_selector/tasks/main.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "8bb806b0368181568d47c3f8dee9a21a3ffe854945247c52cf5f79b233229725", + "format": 1 + }, + { + "name": "tests/integration/targets/mso_schema_site_external_epg_selector/aliases", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "4e674607496d01ce032bfdbcc3e77ecdcde02f3e9d57080a95682a0cdff6809a", + "format": 1 + }, + { + "name": "tests/integration/targets/mso_schema_template_bd", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/mso_schema_template_bd/tasks", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/mso_schema_template_bd/tasks/main.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "1982511fe47280a53549a359cc6c1aa634075c5bad774b45a600a7d762e9cedd", + "format": 1 + }, + { + "name": "tests/integration/targets/mso_schema_template_bd/aliases", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "4e674607496d01ce032bfdbcc3e77ecdcde02f3e9d57080a95682a0cdff6809a", + "format": 1 + }, + { + "name": "tests/integration/targets/mso_schema_site_bd", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/mso_schema_site_bd/tasks", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/mso_schema_site_bd/tasks/main.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "c5a94734c4582dd8472cd53d40bf061b88605bf76bdba1eb6f3ca2d29eb91e9c", + "format": 1 + }, + { + "name": "tests/integration/targets/mso_schema_site_bd/aliases", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "4e674607496d01ce032bfdbcc3e77ecdcde02f3e9d57080a95682a0cdff6809a", + "format": 1 + }, + { + "name": "tests/integration/targets/mso_schema_template_external_epg", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/mso_schema_template_external_epg/tasks", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/mso_schema_template_external_epg/tasks/main.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "7e07b532c4fd924a5d4a80601fbcdcbff008abc5d3d7c8f950029227029eaca7", + "format": 1 + }, + { + "name": "tests/integration/targets/mso_schema_template_external_epg/aliases", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "4e674607496d01ce032bfdbcc3e77ecdcde02f3e9d57080a95682a0cdff6809a", + "format": 1 + }, + { + "name": "tests/integration/targets/mso_site", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/mso_site/tasks", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/mso_site/tasks/main.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "ec5fae6fa73a04337b077fbdcdbbb86b744fdf92a69d7f4c0b29f06b67c278db", + "format": 1 + }, + { + "name": "tests/integration/targets/mso_site/aliases", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "4e674607496d01ce032bfdbcc3e77ecdcde02f3e9d57080a95682a0cdff6809a", + "format": 1 + }, + { + "name": "tests/integration/targets/mso_backup", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/mso_backup/tasks", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/mso_backup/tasks/main.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "4469358f942d49c19a8849f7dedfff99d5a17666e68d120c18bb287de453efbc", + "format": 1 + }, + { + "name": "tests/integration/targets/mso_backup/aliases", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "4e674607496d01ce032bfdbcc3e77ecdcde02f3e9d57080a95682a0cdff6809a", + "format": 1 + }, + { + "name": "tests/integration/targets/mso_schema_template_vrf", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/mso_schema_template_vrf/tasks", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/mso_schema_template_vrf/tasks/main.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "ba14a53fd7361119fb1886aaf0e9e06f86b52dfc2064460bb2cf7177bae9101e", + "format": 1 + }, + { + "name": "tests/integration/targets/mso_schema_template_vrf/aliases", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "4e674607496d01ce032bfdbcc3e77ecdcde02f3e9d57080a95682a0cdff6809a", + "format": 1 + }, + { + "name": "tests/integration/targets/mso_dhcp_relay_policy_provider", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/mso_dhcp_relay_policy_provider/tasks", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/mso_dhcp_relay_policy_provider/tasks/main.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "a8aeebaaa60a2f53998d8d28aacbb90a55b2ca572ad110eaead7ca5d1740c3bf", + "format": 1 + }, + { + "name": "tests/integration/targets/mso_dhcp_relay_policy_provider/aliases", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "4e674607496d01ce032bfdbcc3e77ecdcde02f3e9d57080a95682a0cdff6809a", + "format": 1 + }, + { + "name": "tests/integration/targets/mso_version", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/mso_version/tasks", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/mso_version/tasks/main.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "d6fff962ad77cb90dab75bcebcbac0a0293e59118f7e32d6fa83a6180c14b31a", + "format": 1 + }, + { + "name": "tests/integration/targets/mso_version/aliases", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "4e674607496d01ce032bfdbcc3e77ecdcde02f3e9d57080a95682a0cdff6809a", + "format": 1 + }, + { + "name": "tests/integration/targets/mso_dhcp_option_policy", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/mso_dhcp_option_policy/tasks", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/mso_dhcp_option_policy/tasks/main.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "4e2cd43585c4e107d1066c8ff1938cdca340b948ccaa0c41dbdcc0625b44724c", + "format": 1 + }, + { + "name": "tests/integration/targets/mso_dhcp_option_policy/aliases", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "4e674607496d01ce032bfdbcc3e77ecdcde02f3e9d57080a95682a0cdff6809a", + "format": 1 + }, + { + "name": "tests/integration/targets/mso_schema_site_vrf_region_hub_network", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/mso_schema_site_vrf_region_hub_network/tasks", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/mso_schema_site_vrf_region_hub_network/tasks/hub_network.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "b388af40377112285ac20eb6d5015512099d750c26d35ab2e57d4a0d6104eced", + "format": 1 + }, + { + "name": "tests/integration/targets/mso_schema_site_vrf_region_hub_network/tasks/main.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "7fb4429f19308f52858a44b0a61dea7d564f02793a0cebc307dad6982453937b", + "format": 1 + }, + { + "name": "tests/integration/targets/mso_schema_site_vrf_region_hub_network/aliases", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "4e674607496d01ce032bfdbcc3e77ecdcde02f3e9d57080a95682a0cdff6809a", + "format": 1 + }, + { + "name": "tests/integration/targets/mso_schema_site_anp_epg_staticport", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/mso_schema_site_anp_epg_staticport/tasks", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/mso_schema_site_anp_epg_staticport/tasks/main.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "552753b3d01ca5316d647786f3b90c1350651cf925a267dff089a8ab412e5393", + "format": 1 + }, + { + "name": "tests/integration/targets/mso_schema_site_anp_epg_staticport/aliases", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "4e674607496d01ce032bfdbcc3e77ecdcde02f3e9d57080a95682a0cdff6809a", + "format": 1 + }, + { + "name": "tests/integration/targets/mso_schema_site_vrf_region_cidr", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/mso_schema_site_vrf_region_cidr/tasks", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/mso_schema_site_vrf_region_cidr/tasks/main.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "955cb7d76c5295b4d74daeea37e05c0ac8ea3aaf5ecacdd22d1d9d95bd79beec", + "format": 1 + }, + { + "name": "tests/integration/targets/mso_schema_site_vrf_region_cidr/aliases", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "4e674607496d01ce032bfdbcc3e77ecdcde02f3e9d57080a95682a0cdff6809a", + "format": 1 + }, + { + "name": "tests/integration/targets/mso_schema_site_bd_subnet", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/mso_schema_site_bd_subnet/tasks", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/mso_schema_site_bd_subnet/tasks/main.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "a33e2cde6ec11bdd5c7f8f292ba527f4f8029cfeddeb5c34068092ac582cad98", + "format": 1 + }, + { + "name": "tests/integration/targets/mso_schema_site_bd_subnet/aliases", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "4e674607496d01ce032bfdbcc3e77ecdcde02f3e9d57080a95682a0cdff6809a", + "format": 1 + }, + { + "name": "tests/integration/targets/mso_tenant_site", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/mso_tenant_site/tasks", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/mso_tenant_site/tasks/main.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "a2641573ea2508ec597523e18b1321a24518af39024c24a5614a429379eb9812", + "format": 1 + }, + { + "name": "tests/integration/targets/mso_tenant_site/aliases", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "4e674607496d01ce032bfdbcc3e77ecdcde02f3e9d57080a95682a0cdff6809a", + "format": 1 + }, + { + "name": "tests/integration/targets/mso_schema_template_bd_subnet", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/mso_schema_template_bd_subnet/tasks", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/mso_schema_template_bd_subnet/tasks/main.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "3f326f11f1eca9ce1735bf8821c2906edc5a469532d96002336709419422c8fb", + "format": 1 + }, + { + "name": "tests/integration/targets/mso_schema_template_bd_subnet/aliases", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "4e674607496d01ce032bfdbcc3e77ecdcde02f3e9d57080a95682a0cdff6809a", + "format": 1 + }, + { + "name": "tests/integration/targets/mso_tenant", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/mso_tenant/tasks", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/mso_tenant/tasks/main.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "a17e05edfd0098661ba0c041ca5497fa0f2710d4a7f252d3b11377400ac31159", + "format": 1 + }, + { + "name": "tests/integration/targets/mso_tenant/aliases", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "4e674607496d01ce032bfdbcc3e77ecdcde02f3e9d57080a95682a0cdff6809a", + "format": 1 + }, + { + "name": "tests/integration/targets/mso_user", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/mso_user/tasks", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/mso_user/tasks/main.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "12ac3ecda40bbfab24b4a64b944dd589bde1ddd40e8e4c85396174889e514591", + "format": 1 + }, + { + "name": "tests/integration/targets/mso_user/aliases", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "4e674607496d01ce032bfdbcc3e77ecdcde02f3e9d57080a95682a0cdff6809a", + "format": 1 + }, + { + "name": "tests/integration/targets/mso_label", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/mso_label/tasks", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/mso_label/tasks/main.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "57a585ed8445afaf0906c9aa32fe35cc9723c4fd21a2be0a038a8fa81c68a124", + "format": 1 + }, + { + "name": "tests/integration/targets/mso_label/aliases", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "4e674607496d01ce032bfdbcc3e77ecdcde02f3e9d57080a95682a0cdff6809a", + "format": 1 + }, + { + "name": "tests/integration/targets/mso_schema_template_anp_epg_contract", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/mso_schema_template_anp_epg_contract/tasks", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/mso_schema_template_anp_epg_contract/tasks/main.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "e41ebe5cdc53a56f00920edb4f88347b4de0cfbcd1faaf22df4c68812d7dded0", + "format": 1 + }, + { + "name": "tests/integration/targets/mso_schema_template_anp_epg_contract/aliases", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "4e674607496d01ce032bfdbcc3e77ecdcde02f3e9d57080a95682a0cdff6809a", + "format": 1 + }, + { + "name": "tests/integration/targets/mso_schema_template_anp_epg_selector", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/mso_schema_template_anp_epg_selector/tasks", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/mso_schema_template_anp_epg_selector/tasks/main.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "cfad5f81b9dca819597e7e5f0d8845097737c0f5a71791057c3fe3087543ee62", + "format": 1 + }, + { + "name": "tests/integration/targets/mso_schema_template_anp_epg_selector/aliases", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "4e674607496d01ce032bfdbcc3e77ecdcde02f3e9d57080a95682a0cdff6809a", + "format": 1 + }, + { + "name": "tests/integration/targets/mso_schema_template_anp_epg", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/mso_schema_template_anp_epg/tasks", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/mso_schema_template_anp_epg/tasks/main.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "0168534fdb5e93b59efb004d6d7c0764d9f0296fe0b66748c3e4911a077ebca9", + "format": 1 + }, + { + "name": "tests/integration/targets/mso_schema_template_anp_epg/aliases", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "4e674607496d01ce032bfdbcc3e77ecdcde02f3e9d57080a95682a0cdff6809a", + "format": 1 + }, + { + "name": "tests/integration/targets/mso_schema_site_anp_epg_domain", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/mso_schema_site_anp_epg_domain/tasks", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/mso_schema_site_anp_epg_domain/tasks/main.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "b1a0ae36471c56fdfdbedae2c6b109bd1989e6582fa63c4eb119bc54acfe7c2e", + "format": 1 + }, + { + "name": "tests/integration/targets/mso_schema_site_anp_epg_domain/aliases", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "4e674607496d01ce032bfdbcc3e77ecdcde02f3e9d57080a95682a0cdff6809a", + "format": 1 + }, + { + "name": "tests/integration/targets/mso_schema_template_vrf_contract", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/mso_schema_template_vrf_contract/tasks", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/mso_schema_template_vrf_contract/tasks/main.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "997da0d1772a55f61b8bbd0fd9a42e87da326c9f434f7d6ded6a6dcd6cfab61f", + "format": 1 + }, + { + "name": "tests/integration/targets/mso_schema_template_vrf_contract/aliases", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "4e674607496d01ce032bfdbcc3e77ecdcde02f3e9d57080a95682a0cdff6809a", + "format": 1 + }, + { + "name": "tests/integration/targets/mso_role", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/mso_role/tasks", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/integration/targets/mso_role/tasks/role-ro.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "093e4197d6c56ce5dba6e62bd24c8a0c09e4d9d1c83d8179fe944d37d7427856", + "format": 1 + }, + { + "name": "tests/integration/targets/mso_role/tasks/role-rw.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "0de76ea9425e30addcecd3fba6dfb6ecf1f1df01ec03cba865a25e53f55cb417", + "format": 1 + }, + { + "name": "tests/integration/targets/mso_role/tasks/main.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "846df05740a948dbb1273cd49a0942b39e2e9ec82d389a5d4fdda6f5e3453c72", + "format": 1 + }, + { + "name": "tests/integration/targets/mso_role/aliases", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "4e674607496d01ce032bfdbcc3e77ecdcde02f3e9d57080a95682a0cdff6809a", + "format": 1 + }, + { + "name": "tests/integration/network-integration.requirements.txt", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "26d3ea388bb679036608d912734c5369bb63f362795a62fd5c9e0469c9abaeb8", + "format": 1 + }, + { + "name": "tests/integration/target-prefixes.network", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "f73c1c8e2facc4b6f4cacc8ec891c55c2f7363bb9f84ebd007e7c947d63381f3", + "format": 1 + }, + { + "name": "tests/integration/inventory.networking", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "07f9032e455f7acffdfddeaaf0ed0651e206e8484eb64f5451eb5a038f059c39", + "format": 1 + }, + { + "name": "tests/sanity", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "tests/sanity/requirements.txt", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "99b118eeccecd08f68761335ef6a9ea2ace42095d52512c6e575a1d017362a2d", + "format": 1 + }, + { + "name": "tests/sanity/ignore-2.10.txt", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "3c4527c02ae6954941b8029046aa2e763fa917958a3f36b43633492820aa391a", + "format": 1 + }, + { + "name": "tests/sanity/ignore-2.9.txt", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "format": 1 + }, + { + "name": "tests/.gitignore", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "b5726d3ec9335a09c124469eca039523847a6b0f08a083efaefd002b83326600", + "format": 1 + }, + { + "name": "meta", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "meta/runtime.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "9a8ad79595c324d0703296622061158eff30262f70611afd13a8fc2d74cbc5f9", + "format": 1 + }, + { + "name": "changelogs", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": "changelogs/config.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "43206e71b00b28f61464ff729ee7c096a6babe481924585846dc0ad75f4e5ae0", + "format": 1 + }, + { + "name": "changelogs/.gitignore", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "919ef00776e7d2ff349950ac4b806132aa9faf006e214d5285de54533e443b33", + "format": 1 + }, + { + "name": "changelogs/.plugin-cache.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "4cd7e1932b681e080274baeab2256310024e0454eea250770bf8edb7ed6b1e53", + "format": 1 + }, + { + "name": "changelogs/changelog.yaml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "e12f6483d6dea033a4f88809b4134a4bded3a3feca1f37305300db8a1ce298b5", + "format": 1 + }, + { + "name": "README.md", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "b91c603bfd02d4b7a8bdcc221c505f29630ee01b0c90915816da9dc5bb9bfe02", + "format": 1 + }, + { + "name": ".gitignore", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "38a4680952a5eb9707587cdcc2ea73c8d4de6ed3cf1f054fc08b4f00dc858b02", + "format": 1 + }, + { + "name": ".github", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": ".github/workflows", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": ".github/workflows/galaxy-importer.cfg", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "edc6f2746e7b8c7b94dea479036ba246953cf69234974b89c069c10d614dcaad", + "format": 1 + }, + { + "name": ".github/workflows/ansible-test.yml", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "f5aab3b3602fd76b38870d9fc4d633747864f8bf7af652c27c0c335ad3027c4f", + "format": 1 + }, + { + "name": ".python-version", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "138203e3f604a08fad0c4d0a297efe2c486219820dcdd053e72b7d843504c7a1", + "format": 1 + }, + { + "name": "CHANGELOG.rst", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "5e60a425bc09734693118989796ae18b7e3029c1bc9264470ec18b46e84d1ff3", + "format": 1 + }, + { + "name": ".vscode", + "ftype": "dir", + "chksum_type": null, + "chksum_sha256": null, + "format": 1 + }, + { + "name": ".vscode/settings.json", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "72493737313af87c8524bc614f45f9c0dec4dc228298f5eaacc5c94d859f7e38", + "format": 1 + }, + { + "name": ".vscode/launch.json", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "4b64ba8662f63133c18148530f9f7302e5689ca78e13bd3fbe3150930898b2dd", + "format": 1 + } + ], + "format": 1 +} \ No newline at end of file diff --git a/collections-debian-merged/ansible_collections/cisco/mso/LICENSE b/collections-debian-merged/ansible_collections/cisco/mso/LICENSE new file mode 100644 index 00000000..e09a4143 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/LICENSE @@ -0,0 +1,678 @@ +Copyright (c) 2019, Cisco Systems +All rights reserved. + + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. + diff --git a/collections-debian-merged/ansible_collections/cisco/mso/MANIFEST.json b/collections-debian-merged/ansible_collections/cisco/mso/MANIFEST.json new file mode 100644 index 00000000..26fdf65d --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/MANIFEST.json @@ -0,0 +1,41 @@ +{ + "collection_info": { + "namespace": "cisco", + "name": "mso", + "version": "1.1.0", + "authors": [ + "Dag Wieers (@dagwieers)", + "Nirav Katarmal (@nkatarmal-crest)", + "Lionel Hercot (@lhercot)", + "Cindy Zhao (@cizhao)", + "Shreyas Srish (@shrsr)" + ], + "readme": "README.md", + "tags": [ + "cisco", + "aci", + "cloud", + "collection", + "networking", + "sdn", + "mso", + "multisite" + ], + "description": "An Ansible collection for managing Cisco ACI Multi-Site", + "license": [], + "license_file": "LICENSE", + "dependencies": {}, + "repository": "https://github.com/CiscoDevNet/ansible-mso", + "documentation": "https://docs.ansible.com/ansible/latest/scenario_guides/guide_aci.html", + "homepage": "https://cisco.com/go/aci", + "issues": "https://github.com/CiscoDevNet/ansible-mso/issues" + }, + "file_manifest_file": { + "name": "FILES.json", + "ftype": "file", + "chksum_type": "sha256", + "chksum_sha256": "e838509d1a20973a7a049abc8fa5dac529ed2115a81c1dff31d4578af6d74633", + "format": 1 + }, + "format": 1 +} \ No newline at end of file diff --git a/collections-debian-merged/ansible_collections/cisco/mso/README.md b/collections-debian-merged/ansible_collections/cisco/mso/README.md new file mode 100644 index 00000000..52238108 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/README.md @@ -0,0 +1,93 @@ +# ansible-mso + +The `ansible-mso` project provides an Ansible collection for managing and automating your Cisco ACI Multi-Site environment. +It consists of a set of modules and roles for performing tasks related to ACI Multi-Site. + +This collection has been tested and supports MSO 2.1+. +Modules supporting new features introduced in MSO API in specific MSO versions might not be supported in earlier MSO releases. + +*Note: This collection is not compatible with versions of Ansible before v2.8.* + +## Requirements +- Ansible v2.9 or newer + +## Install +Ansible must be installed +``` +sudo pip install ansible +``` + +Install the collection +``` +ansible-galaxy collection install cisco.mso +``` + +## Use +Once the collection is installed, you can use it in a playbook by specifying the full namespace path to the module, plugin and/or role. +```yaml +- hosts: mso + gather_facts: no + + tasks: + - name: Add a new site EPG + cisco.mso.mso_schema_site_anp_epg: + host: mso_host + username: admin + password: SomeSecretPassword + schema: Schema1 + site: Site1 + template: Template1 + anp: ANP1 + epg: EPG1 + state: present + delegate_to: localhost +``` + +## Update +Getting the latest/nightly collection build + +### First Approach +Clone the ansible-mso repository. +``` +git clone https://github.com/CiscoDevNet/ansible-mso.git +``` + +Go to the ansible-mso directory +``` +cd ansible-mso +``` + +Pull the latest master on your mso +``` +git pull origin master +``` + +Build and Install a collection from source +``` +ansible-galaxy collection build --force +ansible-galaxy collection install cisco-mso-* --force +``` + +### Second Approach +Go to: https://github.com/CiscoDevNet/ansible-mso/actions + +Select the latest CI build + +Under Artifacts download collection and unzip it using Terminal or Console. + +*Note: The collection file is a zip file containing a tar.gz file. We recommend using CLI because some GUI-based unarchiver might unarchive both nested archives in one go.* + +Install the unarchived tar.gz file +``` +ansible-galaxy collection install cisco-mso-1.0.0.tar.gz —-force +``` + +### See Also: + +* [Ansible Using collections](https://docs.ansible.com/ansible/latest/user_guide/collections_using.html) for more details. + +## Contributing to this collection + +Ongoing development efforts and contributions to this collection are tracked as issues in this repository. + +We welcome community contributions to this collection. If you find problems, need an enhancement or need a new module, please open an issue or create a PR against the [Cisco MSO collection repository](https://github.com/CiscoDevNet/ansible-mso/issues). diff --git a/collections-debian-merged/ansible_collections/cisco/mso/changelogs/.gitignore b/collections-debian-merged/ansible_collections/cisco/mso/changelogs/.gitignore new file mode 100644 index 00000000..6be6b533 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/changelogs/.gitignore @@ -0,0 +1 @@ +/.plugin-cache.yaml diff --git a/collections-debian-merged/ansible_collections/cisco/mso/changelogs/.plugin-cache.yaml b/collections-debian-merged/ansible_collections/cisco/mso/changelogs/.plugin-cache.yaml new file mode 100644 index 00000000..072081e7 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/changelogs/.plugin-cache.yaml @@ -0,0 +1,266 @@ +plugins: + become: {} + cache: {} + callback: {} + cliconf: {} + connection: {} + httpapi: {} + inventory: {} + lookup: {} + module: + mso_backup: + description: Manages backups + name: mso_backup + namespace: '' + version_added: null + mso_dhcp_option_policy: + description: Manage DHCP Option policies. + name: mso_dhcp_option_policy + namespace: '' + version_added: null + mso_dhcp_option_policy_option: + description: Manage DHCP options in a DHCP Option policy. + name: mso_dhcp_option_policy_option + namespace: '' + version_added: null + mso_dhcp_relay_policy: + description: Manage DHCP Relay policies. + name: mso_dhcp_relay_policy + namespace: '' + version_added: null + mso_dhcp_relay_policy_provider: + description: Manage DHCP providers in a DHCP Relay policy. + name: mso_dhcp_relay_policy_provider + namespace: '' + version_added: null + mso_label: + description: Manage labels + name: mso_label + namespace: '' + version_added: null + mso_rest: + description: Direct access to the Cisco MSO REST API + name: mso_rest + namespace: '' + version_added: null + mso_role: + description: Manage roles + name: mso_role + namespace: '' + version_added: null + mso_schema: + description: Manage schemas + name: mso_schema + namespace: '' + version_added: null + mso_schema_site: + description: Manage sites in schemas + name: mso_schema_site + namespace: '' + version_added: null + mso_schema_site_anp: + description: Manage site-local Application Network Profiles (ANPs) in schema + template + name: mso_schema_site_anp + namespace: '' + version_added: null + mso_schema_site_anp_epg: + description: Manage site-local Endpoint Groups (EPGs) in schema template + name: mso_schema_site_anp_epg + namespace: '' + version_added: null + mso_schema_site_anp_epg_domain: + description: Manage site-local EPG domains in schema template + name: mso_schema_site_anp_epg_domain + namespace: '' + version_added: null + mso_schema_site_anp_epg_selector: + description: Manage site-local EPG selector in schema templates + name: mso_schema_site_anp_epg_selector + namespace: '' + version_added: null + mso_schema_site_anp_epg_staticleaf: + description: Manage site-local EPG static leafs in schema template + name: mso_schema_site_anp_epg_staticleaf + namespace: '' + version_added: null + mso_schema_site_anp_epg_staticport: + description: Manage site-local EPG static ports in schema template + name: mso_schema_site_anp_epg_staticport + namespace: '' + version_added: null + mso_schema_site_anp_epg_subnet: + description: Manage site-local EPG subnets in schema template + name: mso_schema_site_anp_epg_subnet + namespace: '' + version_added: null + mso_schema_site_bd: + description: Manage site-local Bridge Domains (BDs) in schema template + name: mso_schema_site_bd + namespace: '' + version_added: null + mso_schema_site_bd_l3out: + description: Manage site-local BD l3out's in schema template + name: mso_schema_site_bd_l3out + namespace: '' + version_added: null + mso_schema_site_bd_subnet: + description: Manage site-local BD subnets in schema template + name: mso_schema_site_bd_subnet + namespace: '' + version_added: null + mso_schema_site_external_epg_selector: + description: Manage External EPG selector in schema of cloud sites + name: mso_schema_site_external_epg_selector + namespace: '' + version_added: null + mso_schema_site_vrf: + description: Manage site-local VRFs in schema template + name: mso_schema_site_vrf + namespace: '' + version_added: null + mso_schema_site_vrf_region: + description: Manage site-local VRF regions in schema template + name: mso_schema_site_vrf_region + namespace: '' + version_added: null + mso_schema_site_vrf_region_cidr: + description: Manage site-local VRF region CIDRs in schema template + name: mso_schema_site_vrf_region_cidr + namespace: '' + version_added: null + mso_schema_site_vrf_region_cidr_subnet: + description: Manage site-local VRF regions in schema template + name: mso_schema_site_vrf_region_cidr_subnet + namespace: '' + version_added: null + mso_schema_site_vrf_region_hub_network: + description: Manage site-local VRF region hub network in schema template + name: mso_schema_site_vrf_region_hub_network + namespace: '' + version_added: null + mso_schema_template: + description: Manage templates in schemas + name: mso_schema_template + namespace: '' + version_added: null + mso_schema_template_anp: + description: Manage Application Network Profiles (ANPs) in schema templates + name: mso_schema_template_anp + namespace: '' + version_added: null + mso_schema_template_anp_epg: + description: Manage Endpoint Groups (EPGs) in schema templates + name: mso_schema_template_anp_epg + namespace: '' + version_added: null + mso_schema_template_anp_epg_contract: + description: Manage EPG contracts in schema templates + name: mso_schema_template_anp_epg_contract + namespace: '' + version_added: null + mso_schema_template_anp_epg_selector: + description: Manage EPG selector in schema templates + name: mso_schema_template_anp_epg_selector + namespace: '' + version_added: null + mso_schema_template_anp_epg_subnet: + description: Manage EPG subnets in schema templates + name: mso_schema_template_anp_epg_subnet + namespace: '' + version_added: null + mso_schema_template_bd: + description: Manage Bridge Domains (BDs) in schema templates + name: mso_schema_template_bd + namespace: '' + version_added: null + mso_schema_template_bd_subnet: + description: Manage BD subnets in schema templates + name: mso_schema_template_bd_subnet + namespace: '' + version_added: null + mso_schema_template_contract_filter: + description: Manage contract filters in schema templates + name: mso_schema_template_contract_filter + namespace: '' + version_added: null + mso_schema_template_deploy: + description: Deploy schema templates to sites + name: mso_schema_template_deploy + namespace: '' + version_added: null + mso_schema_template_external_epg: + description: Manage external EPGs in schema templates + name: mso_schema_template_external_epg + namespace: '' + version_added: null + mso_schema_template_external_epg_contract: + description: Manage Extrnal EPG contracts in schema templates + name: mso_schema_template_external_epg_contract + namespace: '' + version_added: 0.0.8 + mso_schema_template_external_epg_selector: + description: Manage External EPG selector in schema templates + name: mso_schema_template_external_epg_selector + namespace: '' + version_added: null + mso_schema_template_external_epg_subnet: + description: Manage External EPG subnets in schema templates + name: mso_schema_template_external_epg_subnet + namespace: '' + version_added: 0.0.8 + mso_schema_template_filter_entry: + description: Manage filter entries in schema templates + name: mso_schema_template_filter_entry + namespace: '' + version_added: null + mso_schema_template_l3out: + description: Manage l3outs in schema templates + name: mso_schema_template_l3out + namespace: '' + version_added: null + mso_schema_template_migrate: + description: Migrate Bridge Domains (BDs) and EPGs between templates + name: mso_schema_template_migrate + namespace: '' + version_added: null + mso_schema_template_vrf: + description: Manage VRFs in schema templates + name: mso_schema_template_vrf + namespace: '' + version_added: null + mso_schema_template_vrf_contract: + description: Manage vrf contracts in schema templates + name: mso_schema_template_vrf_contract + namespace: '' + version_added: 0.0.8 + mso_site: + description: Manage sites + name: mso_site + namespace: '' + version_added: null + mso_tenant: + description: Manage tenants + name: mso_tenant + namespace: '' + version_added: null + mso_tenant_site: + description: Manage tenants with cloud sites. + name: mso_tenant_site + namespace: '' + version_added: null + mso_user: + description: Manage users + name: mso_user + namespace: '' + version_added: null + mso_version: + description: Get version of MSO + name: mso_version + namespace: '' + version_added: null + netconf: {} + shell: {} + strategy: {} + vars: {} +version: 1.1.0 diff --git a/collections-debian-merged/ansible_collections/cisco/mso/changelogs/changelog.yaml b/collections-debian-merged/ansible_collections/cisco/mso/changelogs/changelog.yaml new file mode 100644 index 00000000..d9c41ab0 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/changelogs/changelog.yaml @@ -0,0 +1,224 @@ +ancestor: 0.0.4 +releases: + 0.0.5: + changes: + release_summary: New release v0.0.5 + 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 + 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) + release_summary: New release v0.0.6 + 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 + 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 + release_summary: New release v0.0.7 + 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 + 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 + release_summary: New release v0.0.8 + release_date: '2020-07-21' + 1.0.0: + changes: + bugfixes: + - 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 + 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' + 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 + 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. + + This changelog describes all changes made to the modules and plugins included + in this collection since v1.0.0. + + ' + 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 + 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. + + This changelog describes all changes made to the modules and plugins included + in this collection since v1.0.1. + + ' + release_date: '2021-01-20' diff --git a/collections-debian-merged/ansible_collections/cisco/mso/changelogs/config.yaml b/collections-debian-merged/ansible_collections/cisco/mso/changelogs/config.yaml new file mode 100644 index 00000000..d6a4c94a --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/changelogs/config.yaml @@ -0,0 +1,31 @@ +changelog_filename_template: ../CHANGELOG.rst +changelog_filename_version_depth: 0 +changes_file: changelog.yaml +changes_format: combined +ignore_other_fragment_extensions: true +keep_fragments: false +mention_ancestor: true +new_plugins_after_name: removed_features +notesdir: fragments +prelude_section_name: release_summary +prelude_section_title: Release Summary +sections: +- - major_changes + - Major Changes +- - minor_changes + - Minor Changes +- - breaking_changes + - Breaking Changes / Porting Guide +- - deprecated_features + - Deprecated Features +- - removed_features + - Removed Features (previously deprecated) +- - security_fixes + - Security Fixes +- - bugfixes + - Bugfixes +- - known_issues + - Known Issues +title: Cisco MSO Ansible Collection +trivial_section_name: trivial +use_fqcn: true diff --git a/collections-debian-merged/ansible_collections/cisco/mso/codecov.yml b/collections-debian-merged/ansible_collections/cisco/mso/codecov.yml new file mode 100644 index 00000000..f0f6358e --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/codecov.yml @@ -0,0 +1,4 @@ +coverage: + precision: 2 + round: down + range: "70...100" diff --git a/collections-debian-merged/ansible_collections/cisco/mso/meta/runtime.yml b/collections-debian-merged/ansible_collections/cisco/mso/meta/runtime.yml new file mode 100644 index 00000000..c3f6d266 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/meta/runtime.yml @@ -0,0 +1,6 @@ +--- +requires_ansible: '>=2.9.10' +plugin_routing: + modules: + mso_schema_template_externalepg: + redirect: cisco.mso.mso_schema_template_external_epg \ No newline at end of file diff --git a/collections-debian-merged/ansible_collections/cisco/mso/plugins/doc_fragments/modules.py b/collections-debian-merged/ansible_collections/cisco/mso/plugins/doc_fragments/modules.py new file mode 100644 index 00000000..b4d9924d --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/plugins/doc_fragments/modules.py @@ -0,0 +1,85 @@ +# -*- coding: utf-8 -*- + +# Copyright: (c) 2018, Dag Wieers (@dagwieers) +# 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 + + +class ModuleDocFragment(object): + # Standard files documentation fragment + DOCUMENTATION = r''' +options: + host: + description: + - IP Address or hostname of the ACI Multi Site Orchestrator host. + - If the value is not specified in the task, the value of environment variable C(MSO_HOST) will be used instead. + type: str + required: yes + aliases: [ hostname ] + port: + description: + - Port number to be used for the REST connection. + - The default value depends on parameter `use_ssl`. + - If the value is not specified in the task, the value of environment variable C(MSO_PORT) will be used instead. + type: int + username: + description: + - The username to use for authentication. + - If the value is not specified in the task, the value of environment variables C(MSO_USERNAME) or C(ANSIBLE_NET_USERNAME) will be used instead. + type: str + default: admin + password: + description: + - The password to use for authentication. + - If the value is not specified in the task, the value of environment variables C(MSO_PASSWORD) or C(ANSIBLE_NET_PASSWORD) will be used instead. + type: str + required: yes + output_level: + description: + - Influence the output of this ACI module. + - C(normal) means the standard output, incl. C(current) dict + - C(info) adds informational output, incl. C(previous), C(proposed) and C(sent) dicts + - C(debug) adds debugging output, incl. C(filter_string), C(method), C(response), C(status) and C(url) information + - If the value is not specified in the task, the value of environment variable C(MSO_OUTPUT_LEVEL) will be used instead. + type: str + choices: [ debug, info, normal ] + default: normal + timeout: + description: + - The socket level timeout in seconds. + - If the value is not specified in the task, the value of environment variable C(MSO_TIMEOUT) will be used instead. + type: int + default: 30 + use_proxy: + description: + - If C(no), it will not use a proxy, even if one is defined in an environment variable on the target hosts. + - If the value is not specified in the task, the value of environment variable C(MSO_USE_PROXY) will be used instead. + type: bool + default: yes + use_ssl: + description: + - If C(no), an HTTP connection will be used instead of the default HTTPS connection. + - If the value is not specified in the task, the value of environment variable C(MSO_USE_SSL) will be used instead. + type: bool + default: yes + validate_certs: + description: + - If C(no), SSL certificates will not be validated. + - This should only set to C(no) when used on personally controlled sites using self-signed certificates. + - If the value is not specified in the task, the value of environment variable C(MSO_VALIDATE_CERTS) will be used instead. + type: bool + default: yes + login_domain: + description: + - The login domain name to use for authentication. + - The default value is Local. + - If the value is not specified in the task, the value of environment variable C(MSO_LOGIN_DOMAIN) will be used instead. + type: str +requirements: +- Multi Site Orchestrator v2.1 or newer +notes: +- Please read the :ref:`aci_guide` for more detailed information on how to manage your ACI infrastructure using Ansible. +- This module was written to support ACI Multi Site Orchestrator v2.1 or newer. Some or all functionality may not work on earlier versions. +''' diff --git a/collections-debian-merged/ansible_collections/cisco/mso/plugins/module_utils/mso.py b/collections-debian-merged/ansible_collections/cisco/mso/plugins/module_utils/mso.py new file mode 100644 index 00000000..91485df0 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/plugins/module_utils/mso.py @@ -0,0 +1,949 @@ +# -*- coding: utf-8 -*- + +# Copyright: (c) 2018, Dag Wieers (@dagwieers) +# Simplified BSD License (see licenses/simplified_bsd.txt or https://opensource.org/licenses/BSD-2-Clause) + +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +from copy import deepcopy +import re +import os +import datetime +import shutil +import tempfile +from ansible.module_utils.basic import json +from ansible.module_utils.basic import env_fallback +from ansible.module_utils.six import PY3 +from ansible.module_utils.six.moves import filterfalse +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 +try: + from requests_toolbelt.multipart.encoder import MultipartEncoder + HAS_MULTIPART_ENCODER = True +except ImportError: + HAS_MULTIPART_ENCODER = False + + +if PY3: + def cmp(a, b): + return (a > b) - (a < b) + + +def issubset(subset, superset): + ''' Recurse through nested dictionary and compare entries ''' + + # Both objects are the same object + if subset is superset: + return True + + # Both objects are identical + if subset == superset: + return True + + # Both objects have a different type + if type(subset) != type(superset): + return False + + for key, value in subset.items(): + # Ignore empty values + if value is None: + return True + + # Item from subset is missing from superset + if key not in superset: + return False + + # Item has different types in subset and superset + if type(superset.get(key)) != type(value): + return False + + # Compare if item values are subset + if isinstance(value, dict): + if not issubset(superset.get(key), value): + return False + elif isinstance(value, list): + try: + # NOTE: Fails for lists of dicts + if not set(value) <= set(superset.get(key)): + return False + except TypeError: + # Fall back to exact comparison for lists of dicts + diff = list(filterfalse(lambda i: i in value, superset.get(key))) + list(filterfalse(lambda j: j in superset.get(key), value)) + if diff: + return False + elif isinstance(value, set): + if not value <= superset.get(key): + return False + else: + if not value == superset.get(key): + return False + + return True + + +def update_qs(params): + ''' Append key-value pairs to self.filter_string ''' + accepted_params = dict((k, v) for (k, v) in params.items() if v is not None) + return '?' + urlencode(accepted_params) + + +def mso_argument_spec(): + return dict( + host=dict(type='str', required=True, aliases=['hostname'], fallback=(env_fallback, ['MSO_HOST'])), + port=dict(type='int', required=False, fallback=(env_fallback, ['MSO_PORT'])), + username=dict(type='str', default='admin', fallback=(env_fallback, ['MSO_USERNAME', 'ANSIBLE_NET_USERNAME'])), + password=dict(type='str', required=True, no_log=True, fallback=(env_fallback, ['MSO_PASSWORD', 'ANSIBLE_NET_PASSWORD'])), + output_level=dict(type='str', default='normal', choices=['debug', 'info', 'normal'], fallback=(env_fallback, ['MSO_OUTPUT_LEVEL'])), + timeout=dict(type='int', default=30, fallback=(env_fallback, ['MSO_TIMEOUT'])), + use_proxy=dict(type='bool', default=True, fallback=(env_fallback, ['MSO_USE_PROXY'])), + use_ssl=dict(type='bool', default=True, fallback=(env_fallback, ['MSO_USE_SSL'])), + validate_certs=dict(type='bool', default=True, fallback=(env_fallback, ['MSO_VALIDATE_CERTS'])), + login_domain=dict(type='str', fallback=(env_fallback, ['MSO_LOGIN_DOMAIN'])), + ) + + +def mso_reference_spec(): + return dict( + name=dict(type='str', required=True), + schema=dict(type='str'), + template=dict(type='str'), + ) + + +def mso_subnet_spec(): + return dict( + subnet=dict(type='str', required=True, aliases=['ip']), + description=dict(type='str'), + scope=dict(type='str', default='private', choices=['private', 'public']), + shared=dict(type='bool', default=False), + no_default_gateway=dict(type='bool', default=False), + querier=dict(type='bool', default=False), + ) + + +def mso_dhcp_spec(): + return dict( + dhcp_option_policy=dict(type='dict', option=mso_dhcp_option_spec()), + name=dict(type='str', required=True), + version=dict(type='int', required=True), + ) + + +def mso_dhcp_option_spec(): + return dict( + name=dict(type='str', required=True), + version=dict(type='int', required=True), + ) + + +def mso_contractref_spec(): + return dict( + name=dict(type='str', required=True), + schema=dict(type='str'), + template=dict(type='str'), + type=dict(type='str', required=True, choices=['consumer', 'provider']), + ) + + +def mso_expression_spec(): + return dict( + type=dict(type='str', required=True, aliases=['tag']), + operator=dict(type='str', choices=['not_in', 'in', 'equals', 'not_equals', 'has_key', 'does_not_have_key'], required=True), + value=dict(type='str'), + ) + + +def mso_expression_spec_ext_epg(): + return dict( + type=dict(type='str', choices=['ip_address'], required=True), + operator=dict(type='str', choices=['equals'], required=True), + value=dict(type='str', required=True), + ) + + +def mso_hub_network_spec(): + return dict( + name=dict(type='str', required=True), + tenant=dict(type='str', required=True), + ) + + +def mso_object_migrate_spec(): + return dict( + epg=dict(type='str', required=True), + anp=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): + # create a tempfile with some test content + fd, tmpsrc = tempfile.mkstemp(dir=module.tmpdir) + f = open(tmpsrc, 'wb') + try: + f.write(content) + except Exception as e: + os.remove(tmpsrc) + module.fail_json(msg="Failed to create temporary content file: {0}".format(to_native(e))) + f.close() + + checksum_src = None + checksum_dest = None + + # raise an error if there is no tmpsrc file + if not os.path.exists(tmpsrc): + os.remove(tmpsrc) + module.fail_json(msg="Source '{0}' does not exist".format(tmpsrc)) + if not os.access(tmpsrc, os.R_OK): + os.remove(tmpsrc) + module.fail_json(msg="Source '{0}' is not readable".format(tmpsrc)) + checksum_src = module.sha1(tmpsrc) + + # check if there is no dest file + if os.path.exists(dest): + # raise an error if copy has no permission on dest + if not os.access(dest, os.W_OK): + os.remove(tmpsrc) + module.fail_json(msg="Destination '{0}' not writable".format(dest)) + if not os.access(dest, os.R_OK): + os.remove(tmpsrc) + module.fail_json(msg="Destination '{0}' not readable".format(dest)) + checksum_dest = module.sha1(dest) + else: + if not os.access(os.path.dirname(dest), os.W_OK): + os.remove(tmpsrc) + module.fail_json(msg="Destination dir '{0}' not writable".format(os.path.dirname(dest))) + + if checksum_src != checksum_dest: + try: + shutil.copyfile(tmpsrc, dest) + except Exception as e: + os.remove(tmpsrc) + module.fail_json(msg="failed to copy {0} to {1}: {2}".format(tmpsrc, dest, to_native(e))) + + os.remove(tmpsrc) + + +class MSOModule(object): + + def __init__(self, module): + self.module = module + self.params = module.params + self.result = dict(changed=False) + self.headers = {'Content-Type': 'text/json'} + + # normal output + self.existing = dict() + + # mso_rest output + self.jsondata = None + self.error = dict(code=None, message=None, info=None) + + # info output + self.previous = dict() + self.proposed = dict() + self.sent = dict() + self.stdout = None + + # debug output + self.has_modified = False + self.filter_string = '' + self.method = None + self.path = None + self.response = None + self.status = None + self.url = None + + # Ensure protocol is set + self.params['protocol'] = 'https' if self.params.get('use_ssl', True) else 'http' + + # Set base_uri + if self.params.get('port') is not None: + self.baseuri = '{protocol}://{host}:{port}/api/v1/'.format(**self.params) + else: + self.baseuri = '{protocol}://{host}/api/v1/'.format(**self.params) + + if self.module._debug: + self.module.warn('Enable debug output because ANSIBLE_DEBUG was set.') + self.params['output_level'] = 'debug' + + if self.params.get('password'): + # Perform password-based authentication, log on using password + self.login() + else: + self.module.fail_json(msg="Parameter 'password' is required for authentication") + + def get_login_domain_id(self, domain): + ''' Get a domain and return its id ''' + if domain is None: + return domain + d = self.get_obj('auth/login-domains', key='domains', name=domain) + if not d: + self.module.fail_json(msg="Login domain '%s' is not a valid domain name." % domain) + if 'id' not in d: + self.module.fail_json(msg="Login domain lookup failed for domain '%s': %s" % (domain, d)) + return d['id'] + + def login(self): + ''' Log in to MSO ''' + + # Perform login request + if (self.params.get('login_domain') is not None) and (self.params.get('login_domain') != 'Local'): + domain_id = self.get_login_domain_id(self.params.get('login_domain')) + payload = {'username': self.params.get('username'), 'password': self.params.get('password'), 'domainId': domain_id} + else: + payload = {'username': self.params.get('username'), 'password': self.params.get('password')} + self.url = urljoin(self.baseuri, 'auth/login') + resp, auth = fetch_url(self.module, + self.url, + data=json.dumps(payload), + method='POST', + headers=self.headers, + timeout=self.params.get('timeout'), + use_proxy=self.params.get('use_proxy')) + + # Handle MSO response + if auth.get('status') != 201: + self.response = auth.get('msg') + self.status = auth.get('status') + self.fail_json(msg='Authentication failed: {msg}'.format(**auth)) + + payload = json.loads(resp.read()) + + self.headers['Authorization'] = 'Bearer {token}'.format(**payload) + + def response_json(self, rawoutput): + ''' Handle MSO JSON response output ''' + try: + self.jsondata = json.loads(rawoutput) + except Exception as e: + # Expose RAW output for troubleshooting + self.error = dict(code=-1, message="Unable to parse output as JSON, see 'raw' output. %s" % e) + self.result['raw'] = rawoutput + return + + # Handle possible MSO error information + if self.status not in [200, 201, 202, 204]: + self.error = self.jsondata + + def request_download(self, path, destination=None): + self.url = urljoin(self.baseuri, path) + redirected = False + redir_info = {} + redirect = {} + + src = self.params.get('src') + if src: + try: + self.headers.update({ + 'Content-Length': os.stat(src).st_size + }) + data = open(src, 'rb') + except OSError: + self.module.fail_json(msg='Unable to open source file %s' % src, elapsed=0) + else: + pass + + data = None + + kwargs = {} + if destination is not None: + if os.path.isdir(destination): + # first check if we are redirected to a file download + check, redir_info = fetch_url(self.module, self.url, + headers=self.headers, + method='GET', + timeout=self.params.get('timeout')) + # if we are redirected, update the url with the location header, + # and update dest with the new url filename + if redir_info['status'] in (301, 302, 303, 307): + self.url = redir_info.get('location') + redirected = True + destination = os.path.join(destination, check.headers.get("Content-Disposition").split("filename=")[1]) + # if destination file already exist, only download if file newer + if os.path.exists(destination): + kwargs['last_mod_time'] = datetime.datetime.utcfromtimestamp(os.path.getmtime(destination)) + + resp, info = fetch_url(self.module, self.url, data=data, headers=self.headers, + method='GET', timeout=self.params.get('timeout'), unix_socket=self.params.get('unix_socket'), **kwargs) + + try: + content = resp.read() + except AttributeError: + # there was no content, but the error read() may have been stored in the info as 'body' + content = info.pop('body', '') + + if src: + # Try to close the open file handle + try: + data.close() + except Exception: + pass + + redirect['redirected'] = redirected or info.get('url') != self.url + redirect.update(redir_info) + redirect.update(info) + + write_file(self.module, self.url, destination, content, redirect) + + return redirect, destination + + def request_upload(self, path, fields=None): + ''' Generic HTTP MultiPart POST method for MSO uploads. ''' + self.path = path + self.url = urljoin(self.baseuri, path) + + if not HAS_MULTIPART_ENCODER: + self.fail_json(msg='requests-toolbelt is required for the upload state of this module') + + mp_encoder = MultipartEncoder(fields=fields) + self.headers['Content-Type'] = mp_encoder.content_type + self.headers['Accept-Encoding'] = "gzip, deflate, br" + + resp, info = fetch_url(self.module, + self.url, + headers=self.headers, + data=mp_encoder, + method='POST', + timeout=self.params.get('timeout'), + use_proxy=self.params.get('use_proxy')) + + self.response = info.get('msg') + self.status = info.get('status') + + # Get change status from HTTP headers + if 'modified' in info: + self.has_modified = True + if info.get('modified') == 'false': + self.result['changed'] = False + elif info.get('modified') == 'true': + self.result['changed'] = True + + # 200: OK, 201: Created, 202: Accepted, 204: No Content + if self.status in (200, 201, 202, 204): + output = resp.read() + if output: + return json.loads(output) + + # 400: Bad Request, 401: Unauthorized, 403: Forbidden, + # 405: Method Not Allowed, 406: Not Acceptable + # 500: Internal Server Error, 501: Not Implemented + elif self.status >= 400: + try: + payload = json.loads(resp.read()) + except (ValueError, AttributeError): + try: + payload = json.loads(info.get('body')) + except Exception: + self.fail_json(msg='MSO Error:', info=info) + if 'code' in payload: + self.fail_json(msg='MSO Error {code}: {message}'.format(**payload), info=info, payload=payload) + else: + self.fail_json(msg='MSO Error:'.format(**payload), info=info, payload=payload) + + return {} + + def request(self, path, method=None, data=None, qs=None): + ''' Generic HTTP method for MSO requests. ''' + self.path = path + + if method is not None: + self.method = method + + # If we PATCH with empty operations, return + if method == 'PATCH' and not data: + return {} + + self.url = urljoin(self.baseuri, path) + + if qs is not None: + self.url = self.url + update_qs(qs) + + resp, info = fetch_url(self.module, + self.url, + headers=self.headers, + data=json.dumps(data), + method=self.method, + timeout=self.params.get('timeout'), + use_proxy=self.params.get('use_proxy')) + + self.response = info.get('msg') + self.status = info.get('status') + + # self.result['info'] = info + + # Get change status from HTTP headers + if 'modified' in info: + self.has_modified = True + if info.get('modified') == 'false': + self.result['changed'] = False + elif info.get('modified') == 'true': + self.result['changed'] = True + + # 200: OK, 201: Created, 202: Accepted, 204: No Content + if self.status in (200, 201, 202, 204): + output = resp.read() + if output: + return json.loads(output) + + # 404: Not Found + elif self.method == 'DELETE' and self.status == 404: + return {} + + # 400: Bad Request, 401: Unauthorized, 403: Forbidden, + # 405: Method Not Allowed, 406: Not Acceptable + # 500: Internal Server Error, 501: Not Implemented + elif self.status >= 400: + try: + output = resp.read() + payload = json.loads(output) + except (ValueError, AttributeError): + try: + payload = json.loads(info.get('body')) + except Exception: + self.fail_json(msg='MSO Error:', data=data, info=info) + if 'code' in payload: + self.fail_json(msg='MSO Error {code}: {message}'.format(**payload), data=data, info=info, payload=payload) + else: + self.fail_json(msg='MSO Error:'.format(**payload), data=data, info=info, payload=payload) + + return {} + + def query_objs(self, path, key=None, **kwargs): + ''' Query the MSO REST API for objects in a path ''' + found = [] + objs = self.request(path, method='GET') + + if objs == {}: + return found + + if key is None: + key = path + + if key not in objs: + self.fail_json(msg="Key '%s' missing from data", data=objs) + + for obj in objs.get(key): + for kw_key, kw_value in kwargs.items(): + if kw_value is None: + continue + if obj.get(kw_key) != kw_value: + break + else: + found.append(obj) + return found + + def query_obj(self, path, **kwargs): + ''' Query the MSO REST API for the whole object at a path ''' + obj = self.request(path, method='GET') + if obj == {}: + return {} + for kw_key, kw_value in kwargs.items(): + if kw_value is None: + continue + if obj.get(kw_key) != kw_value: + return {} + return obj + + def get_obj(self, path, **kwargs): + ''' Get a specific object from a set of MSO REST objects ''' + objs = self.query_objs(path, **kwargs) + if len(objs) == 0: + return {} + if len(objs) > 1: + self.fail_json(msg='More than one object matches unique filter: {0}'.format(kwargs)) + return objs[0] + + def lookup_schema(self, schema): + ''' Look up schema and return its id ''' + if schema is None: + return schema + + s = self.get_obj('schemas', displayName=schema) + if not s: + self.module.fail_json(msg="Schema '%s' is not a valid schema name." % schema) + if 'id' not in s: + self.module.fail_json(msg="Schema lookup failed for schema '%s': %s" % (schema, s)) + return s.get('id') + + def lookup_domain(self, domain): + ''' Look up a domain and return its id ''' + if domain is None: + return domain + + d = self.get_obj('auth/domains', key='domains', name=domain) + if not d: + self.module.fail_json(msg="Domain '%s' is not a valid domain name." % domain) + if 'id' not in d: + self.module.fail_json(msg="Domain lookup failed for domain '%s': %s" % (domain, d)) + return d.get('id') + + def lookup_roles(self, roles): + ''' Look up roles and return their ids ''' + if roles is None: + return roles + + ids = [] + for role in roles: + name = role + access_type = "readWrite" + if 'name' in role: + name = role.get('name') + if role.get('access_type') == 'read': + access_type = 'readOnly' + r = self.get_obj('roles', name=name) + if not r: + self.module.fail_json(msg="Role '%s' is not a valid role name." % name) + if 'id' not in r: + self.module.fail_json(msg="Role lookup failed for role '%s': %s" % (name, r)) + ids.append(dict(roleId=r.get('id'), accessType=access_type)) + return ids + + def lookup_site(self, site): + ''' Look up a site and return its id ''' + if site is None: + return site + + s = self.get_obj('sites', name=site) + if not s: + self.module.fail_json(msg="Site '%s' is not a valid site name." % site) + if 'id' not in s: + self.module.fail_json(msg="Site lookup failed for site '%s': %s" % (site, s)) + return s.get('id') + + def lookup_sites(self, sites): + ''' Look up sites and return their ids ''' + if sites is None: + return sites + + ids = [] + for site in sites: + s = self.get_obj('sites', name=site) + if not s: + self.module.fail_json(msg="Site '%s' is not a valid site name." % site) + if 'id' not in s: + self.module.fail_json(msg="Site lookup failed for site '%s': %s" % (site, s)) + ids.append(dict(siteId=s.get('id'), securityDomains=[])) + return ids + + def lookup_tenant(self, tenant): + ''' Look up a tenant and return its id ''' + if tenant is None: + return tenant + + t = self.get_obj('tenants', key='tenants', name=tenant) + if not t: + self.module.fail_json(msg="Tenant '%s' is not valid tenant name." % tenant) + if 'id' not in t: + self.module.fail_json(msg="Tenant lookup failed for tenant '%s': %s" % (tenant, t)) + return t.get('id') + + def lookup_remote_location(self, remote_location): + ''' Look up a remote location and return its path and id ''' + if remote_location is None: + return None + + remote = self.get_obj('platform/remote-locations', key='remoteLocations', name=remote_location) + if 'id' not in remote: + self.module.fail_json(msg="No remote location found for remote '%s'" % (remote_location)) + remote_info = dict(id=remote.get('id'), path=remote.get('credential')['remotePath']) + return remote_info + + def lookup_users(self, users): + ''' Look up users and return their ids ''' + # Ensure tenant has at least admin user + if users is None: + return [dict(userId="0000ffff0000000000000020")] + + ids = [] + for user in users: + u = self.get_obj('users', username=user) + if not u: + self.module.fail_json(msg="User '%s' is not a valid user name." % user) + if 'id' not in u: + self.module.fail_json(msg="User lookup failed for user '%s': %s" % (user, u)) + id = dict(userId=u.get('id')) + if id in ids: + self.module.fail_json(msg="User '%s' is duplicate." % user) + ids.append(id) + + if 'admin' not in users: + ids.append(dict(userId="0000ffff0000000000000020")) + return ids + + def create_label(self, label, label_type): + ''' Create a new label ''' + return self.request('labels', method='POST', data=dict(displayName=label, type=label_type)) + + def lookup_labels(self, labels, label_type): + ''' Look up labels and return their ids (create if necessary) ''' + if labels is None: + return None + + ids = [] + for label in labels: + label_obj = self.get_obj('labels', displayName=label) + if not label_obj: + label_obj = self.create_label(label, label_type) + if 'id' not in label_obj: + self.module.fail_json(msg="Label lookup failed for label '%s': %s" % (label, label_obj)) + ids.append(label_obj.get('id')) + return ids + + def anp_ref(self, **data): + ''' Create anpRef string ''' + return '/schemas/{schema_id}/templates/{template}/anps/{anp}'.format(**data) + + def epg_ref(self, **data): + ''' Create epgRef string ''' + return '/schemas/{schema_id}/templates/{template}/anps/{anp}/epgs/{epg}'.format(**data) + + def bd_ref(self, **data): + ''' Create bdRef string ''' + return '/schemas/{schema_id}/templates/{template}/bds/{bd}'.format(**data) + + def contract_ref(self, **data): + ''' Create contractRef string ''' + # Support the contract argspec + if 'name' in data: + data['contract'] = data.get('name') + return '/schemas/{schema_id}/templates/{template}/contracts/{contract}'.format(**data) + + def filter_ref(self, **data): + ''' Create a filterRef string ''' + return '/schemas/{schema_id}/templates/{template}/filters/{filter}'.format(**data) + + def vrf_ref(self, **data): + ''' Create vrfRef string ''' + return '/schemas/{schema_id}/templates/{template}/vrfs/{vrf}'.format(**data) + + def ext_epg_ref(self, **data): + ''' Create extEpgRef string ''' + return '/schemas/{schema_id}/templates/{template}/externalEpgs/{external_epg}'.format(**data) + + def vrf_dict_from_ref(self, data): + vrf_ref_regex = re.compile(r'\/schemas\/(.*)\/templates\/(.*)\/vrfs\/(.*)') + vrf_dict = vrf_ref_regex.search(data) + return { + 'vrfName': vrf_dict.group(3), + 'schemaId': vrf_dict.group(1), + 'templateName': vrf_dict.group(2), + } + + def dict_from_ref(self, data): + if data and data != '': + ref_regex = re.compile(r'\/schemas\/(.*)\/templates\/(.*)\/(.*)\/(.*)') + dic = ref_regex.search(data) + if dic is not None: + schema_id = dic.group(1) + template_name = dic.group(2) + category = dic.group(3) + name = dic.group(4) + uri_map = { + 'vrfs': ['vrfName', 'schemaId', 'templateName'], + 'bds': ['bdName', 'schemaId', 'templateName'], + 'filters': ['filterName', 'schemaId', 'templateName'], + 'contracts': ['contractName', 'schemaId', 'templateName'], + 'l3outs': ['l3outName', 'schemaId', 'templateName'], + 'anps': ['anpName', 'schemaId', 'templateName'], + } + result = { + uri_map[category][0]: name, + uri_map[category][1]: schema_id, + uri_map[category][2]: template_name, + } + return result + else: + self.module.fail_json(msg="There was no group in search: {data}".format(data=data)) + + def make_reference(self, data, reftype, schema_id, template): + ''' Create a reference from a dictionary ''' + # Removes entry from payload + if data is None: + return None + + if data.get('schema') is not None: + schema_obj = self.get_obj('schemas', displayName=data.get('schema')) + if not schema_obj: + self.fail_json(msg="Referenced schema '{schema}' in {reftype}ref does not exist".format(reftype=reftype, **data)) + schema_id = schema_obj.get('id') + + if data.get('template') is not None: + template = data.get('template') + + refname = '%sName' % reftype + + return { + refname: data.get('name'), + 'schemaId': schema_id, + 'templateName': template, + } + + def make_subnets(self, data): + ''' Create a subnets list from input ''' + if data is None: + return None + + subnets = [] + for subnet in data: + if 'subnet' in subnet: + subnet['ip'] = subnet.get('subnet') + if subnet.get('description') is None: + subnet['description'] = subnet.get('subnet') + subnets.append(dict( + ip=subnet.get('ip'), + description=str(subnet.get('description')), + scope=subnet.get('scope'), + shared=subnet.get('shared'), + noDefaultGateway=subnet.get('no_default_gateway'), + querier=subnet.get('querier'), + )) + + return subnets + + def make_dhcp_label(self, data): + ''' Create a DHCP policy from input ''' + if data is None: + return None + if 'version' in data: + data['version'] = int(data.get('version')) + if data and 'dhcp_option_policy' in data: + dhcp_option_policy = data.get('dhcp_option_policy') + if dhcp_option_policy is not None and 'version' in dhcp_option_policy: + dhcp_option_policy['version'] = int(dhcp_option_policy.get('version')) + data['dhcpOptionLabel'] = dhcp_option_policy + del data['dhcp_option_policy'] + return data + + def sanitize(self, updates, collate=False, required=None, unwanted=None): + ''' Clean up unset keys from a request payload ''' + if required is None: + required = [] + if unwanted is None: + unwanted = [] + self.proposed = deepcopy(self.existing) + self.sent = deepcopy(self.existing) + + for key in self.existing: + # Remove References + if key.endswith('Ref'): + del(self.proposed[key]) + del(self.sent[key]) + continue + + # Removed unwanted keys + elif key in unwanted: + del(self.proposed[key]) + del(self.sent[key]) + continue + + # Clean up self.sent + for key in updates: + # Always retain 'id' + if key in required: + if key in self.existing or updates.get(key) is not None: + self.sent[key] = updates.get(key) + continue + + # Remove unspecified values + elif not collate and updates.get(key) is None: + if key in self.existing: + del(self.sent[key]) + continue + + # Remove identical values + elif not collate and updates.get(key) == self.existing.get(key): + del(self.sent[key]) + continue + + # Add everything else + if updates.get(key) is not None: + self.sent[key] = updates.get(key) + + # Update self.proposed + self.proposed.update(self.sent) + + def exit_json(self, **kwargs): + ''' Custom written method to exit from module. ''' + + if self.params.get('state') in ('absent', 'present', 'upload', 'restore', 'download', 'move'): + if self.params.get('output_level') in ('debug', 'info'): + self.result['previous'] = self.previous + # FIXME: Modified header only works for PATCH + if not self.has_modified and self.previous != self.existing: + self.result['changed'] = True + if self.stdout: + self.result['stdout'] = self.stdout + + # Return the gory details when we need it + if self.params.get('output_level') == 'debug': + self.result['method'] = self.method + self.result['response'] = self.response + self.result['status'] = self.status + self.result['url'] = self.url + + if self.params.get('state') in ('absent', 'present'): + self.result['sent'] = self.sent + self.result['proposed'] = self.proposed + + self.result['current'] = self.existing + + if self.module._diff and self.result.get('changed') is True: + self.result['diff'] = dict( + before=self.previous, + after=self.existing, + ) + + self.result.update(**kwargs) + self.module.exit_json(**self.result) + + def fail_json(self, msg, **kwargs): + ''' Custom written method to return info on failure. ''' + + if self.params.get('state') in ('absent', 'present'): + if self.params.get('output_level') in ('debug', 'info'): + self.result['previous'] = self.previous + # FIXME: Modified header only works for PATCH + if not self.has_modified and self.previous != self.existing: + self.result['changed'] = True + if self.stdout: + self.result['stdout'] = self.stdout + + # Return the gory details when we need it + if self.params.get('output_level') == 'debug': + if self.url is not None: + self.result['method'] = self.method + self.result['response'] = self.response + self.result['status'] = self.status + self.result['url'] = self.url + + if self.params.get('state') in ('absent', 'present'): + self.result['sent'] = self.sent + self.result['proposed'] = self.proposed + + self.result['current'] = self.existing + + self.result.update(**kwargs) + self.module.fail_json(msg=msg, **self.result) + + def check_changed(self): + ''' Check if changed by comparing new values from existing''' + existing = self.existing + if 'password' in existing: + existing['password'] = self.sent.get('password') + return not issubset(self.sent, existing) + + def update_filter_obj(self, contract_obj, filter_obj, filter_type, contract_display_name=None, updateFilterRef=True): + ''' update filter with more information ''' + if updateFilterRef: + filter_obj['filterRef'] = self.dict_from_ref(filter_obj.get('filterRef')) + if contract_display_name: + filter_obj['displayName'] = contract_display_name + else: + filter_obj['displayName'] = contract_obj.get('displayName') + filter_obj['filterType'] = filter_type + filter_obj['contractScope'] = contract_obj.get('scope') + filter_obj['contractFilterType'] = contract_obj.get('filterType') + return filter_obj diff --git a/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_backup.py b/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_backup.py new file mode 100644 index 00000000..8879b253 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_backup.py @@ -0,0 +1,311 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright: (c) 2020, Shreyas Srish (@shrsr) +# 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_backup +short_description: Manages backups +description: +- Manage backups on Cisco ACI Multi-Site. +author: +- Shreyas Srish (@shrsr) +options: + location_type: + description: + - The type of location for the backup to be stored + type: str + choices: [ local, remote] + default: local + backup: + description: + - The name given to the backup + type: str + aliases: [ name ] + remote_location: + description: + - The remote location's name for the backup to be stored + type: str + remote_path: + description: + - This path is relative to the remote location. + - A '/' is automatically added between the remote location folder and this path. + - This folder structure should already exist on the remote location. + type: str + description: + description: + - Brief information about the backup. + type: str + destination: + description: + - Location where to download the backup to + type: str + state: + description: + - Use C(present) or C(absent) for adding or removing. + - Use C(query) for listing an object or multiple objects. + - Use C(upload) for uploading backup. + - Use C(restore) for restoring backup. + - Use C(download) for downloading backup. + - Use C(move) for moving backup from local to remote location. + type: str + choices: [ absent, present, query, upload, restore, download, move ] + default: present +extends_documentation_fragment: cisco.mso.modules +''' + +EXAMPLES = r''' +- name: Create a new local backup + cisco.mso.mso_backup: + host: mso_host + username: admin + password: SomeSecretPassword + backup: Backup + description: via Ansible + location_type: local + state: present + delegate_to: localhost + +- name: Create a new remote backup + cisco.mso.mso_backup: + host: mso_host + username: admin + password: SomeSecretPassword + backup: Backup + description: via Ansible + location_type: remote + remote_location: ansible_test + state: present + delegate_to: localhost + +- name: Move backup to remote location + cisco.mso.mso_backup: + host: mso_host + username: admin + password: SomeSecretPassword + backup: Backup0 + remote_location: ansible_test + remote_path: test + state: move + delegate_to: localhost + +- name: Download a backup + cisco.mso.mso_backup: + host: mso_host + username: admin + password: SomeSecretPassword + backup: Backup + destination: ./ + state: download + delegate_to: localhost + +- name: Upload a backup + cisco.mso.mso_backup: + host: mso_host + username: admin + password: SomeSecretPassword + backup: ./Backup + state: upload + delegate_to: localhost + +- name: Restore a backup + cisco.mso.mso_backup: + host: mso_host + username: admin + password: SomeSecretPassword + backup: Backup + state: restore + delegate_to: localhost + +- name: Remove a Backup + cisco.mso.mso_backup: + host: mso_host + username: admin + password: SomeSecretPassword + backup: Backup + state: absent + delegate_to: localhost + +- name: Query a backup + cisco.mso.mso_backup: + host: mso_host + username: admin + password: SomeSecretPassword + backup: Backup + state: query + delegate_to: localhost + register: query_result + +- name: Query a backup with its complete name + cisco.mso.mso_backup: + host: mso_host + username: admin + password: SomeSecretPassword + backup: Backup_20200721220043 + state: query + delegate_to: localhost + register: query_result + +- name: Query all backups + cisco.mso.mso_backup: + host: mso_host + username: admin + password: SomeSecretPassword + 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 +import os + + +def main(): + argument_spec = mso_argument_spec() + argument_spec.update( + location_type=dict(type='str', default='local', choices=['local', 'remote']), + description=dict(type='str'), + backup=dict(type='str', aliases=['name']), + remote_location=dict(type='str'), + remote_path=dict(type='str'), + state=dict(type='str', default='present', choices=['absent', 'present', 'query', 'upload', 'restore', 'download', 'move']), + destination=dict(type='str') + ) + + module = AnsibleModule( + argument_spec=argument_spec, + supports_check_mode=True, + required_if=[ + ['location_type', 'remote', ['remote_location']], + ['state', 'absent', ['backup']], + ['state', 'present', ['backup']], + ['state', 'upload', ['backup']], + ['state', 'restore', ['backup']], + ['state', 'download', ['backup', 'destination']], + ['state', 'move', ['backup', 'remote_location', 'remote_path']] + ] + ) + + description = module.params.get('description') + location_type = module.params.get('location_type') + state = module.params.get('state') + backup = module.params.get('backup') + remote_location = module.params.get('remote_location') + remote_path = module.params.get('remote_path') + destination = module.params.get('destination') + + mso = MSOModule(module) + + backup_names = [] + mso.existing = mso.query_objs('backups/backupRecords', key='backupRecords') + if backup: + if mso.existing: + data = mso.existing + mso.existing = [] + for backup_info in data: + if backup == backup_info.get('name').split('_')[0] or backup == backup_info.get('name'): + mso.existing.append(backup_info) + backup_names.append(backup_info.get('name')) + + if state == 'query': + mso.exit_json() + + elif state == 'absent': + mso.previous = mso.existing + if len(mso.existing) > 1: + mso.module.fail_json(msg="Multiple backups with same name found. Existing backups with similar names: {0}".format(', '.join(backup_names))) + elif len(mso.existing) == 1: + if module.check_mode: + mso.existing = {} + else: + mso.existing = mso.request('backups/backupRecords/{id}'.format(id=mso.existing[0].get('id')), method='DELETE') + mso.exit_json() + + elif state == 'present': + mso.previous = mso.existing + + payload = dict( + name=backup, + description=description, + locationType=location_type + ) + + if location_type == 'remote': + remote_location_info = mso.lookup_remote_location(remote_location) + payload.update(remoteLocationId=remote_location_info.get('id')) + if remote_path: + remote_path = '{0}/{1}'.format(remote_location_info.get('path'), remote_path) + payload.update(remotePath=remote_path) + + mso.proposed = payload + + if module.check_mode: + mso.existing = mso.proposed + else: + mso.existing = mso.request('backups', method='POST', data=payload) + mso.exit_json() + + elif state == 'upload': + mso.previous = mso.existing + + if module.check_mode: + mso.existing = mso.proposed + else: + try: + payload = dict(name=(os.path.basename(backup), open(backup, 'rb'), 'application/x-gzip')) + mso.existing = mso.request_upload('backups/upload', fields=payload) + except Exception: + mso.module.fail_json(msg="Backup file '{0}' not found!".format(', '.join(backup.split('/')[-1:]))) + mso.exit_json() + + if len(mso.existing) == 0: + mso.module.fail_json(msg="Backup '{0}' does not exist".format(backup)) + elif len(mso.existing) > 1: + mso.module.fail_json(msg="Multiple backups with same name found. Existing backups with similar names: {0}".format(', '.join(backup_names))) + + elif state == 'restore': + mso.previous = mso.existing + if module.check_mode: + mso.existing = mso.proposed + else: + mso.existing = mso.request('backups/{id}/restore'.format(id=mso.existing[0].get('id')), method='PUT') + + elif state == 'download': + mso.previous = mso.existing + if module.check_mode: + mso.existing = mso.proposed + else: + mso.existing = mso.request_download('backups/{id}/download'.format(id=mso.existing[0].get('id')), destination=destination) + + elif state == 'move': + mso.previous = mso.existing + remote_location_info = mso.lookup_remote_location(remote_location) + remote_path = '{0}/{1}'.format(remote_location_info.get('path'), remote_path) + payload = dict( + remoteLocationId=remote_location_info.get('id'), + remotePath=remote_path, + backupRecordId=mso.existing[0].get('id') + ) + if module.check_mode: + mso.existing = mso.proposed + else: + mso.existing = mso.request('backups/remote-location', method='POST', data=payload) + + mso.exit_json() + + +if __name__ == "__main__": + main() diff --git a/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_dhcp_option_policy.py b/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_dhcp_option_policy.py new file mode 100644 index 00000000..843317ec --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_dhcp_option_policy.py @@ -0,0 +1,167 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright: (c) 2020, Lionel Hercot (@lhercot) +# Copyright: (c) 2020, Jorge Gomez (@jgomezve) (based on mso_dhcp_relay_policy module) +# 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_dhcp_option_policy +short_description: Manage DHCP Option policies. +description: +- Manage DHCP Option policies on Cisco Multi-Site Orchestrator. +author: +- Lionel Hercot (@lhercot) +options: + dhcp_option_policy: + description: + - Name of the DHCP Option Policy + type: str + aliases: [ name ] + description: + description: + - Description of the DHCP Option Policy + type: str + tenant: + description: + - Tenant where the DHCP Option Policy is located. + type: 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 +extends_documentation_fragment: cisco.mso.modules +""" + +EXAMPLES = r""" +- name: Add a new DHCP Option Policy + cisco.mso.mso_dhcp_option_policy: + host: mso_host + username: admin + password: SomeSecretPassword + dhcp_option_policy: my_test_dhcp_policy + description: "My Test DHCP Policy" + tenant: ansible_test + state: present + delegate_to: localhost + +- name: Remove DHCP Option Policy + cisco.mso.mso_dhcp_option_policy: + host: mso_host + username: admin + 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: + host: mso_host + username: admin + password: SomeSecretPassword + dhcp_option_policy: my_test_dhcp_policy + state: query + delegate_to: localhost + +- name: Query all DHCP Option Policies + cisco.mso.mso_dhcp_option_policy: + host: mso_host + username: admin + password: SomeSecretPassword + state: query + delegate_to: localhost +""" + +RETURN = r""" +""" + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.cisco.mso.plugins.module_utils.mso import MSOModule, mso_argument_spec + + +def main(): + argument_spec = mso_argument_spec() + argument_spec.update( + dhcp_option_policy=dict(type="str", aliases=['name']), + description=dict(type="str"), + tenant=dict(type="str"), + state=dict(type="str", default="present", choices=["absent", "present", "query"]), + ) + module = AnsibleModule( + argument_spec=argument_spec, + supports_check_mode=True, + required_if=[ + ['state', 'absent', ['dhcp_option_policy']], + ['state', 'present', ['dhcp_option_policy', 'tenant']], + ], + ) + + dhcp_option_policy = module.params.get("dhcp_option_policy") + description = module.params.get("description") + tenant = module.params.get("tenant") + state = module.params.get("state") + + mso = MSOModule(module) + + path = "policies/dhcp/option" + + # Query for existing object(s) + if dhcp_option_policy: + mso.existing = mso.get_obj(path, name=dhcp_option_policy, key="DhcpRelayPolicies") + if mso.existing: + policy_id = mso.existing.get("id") + # If we found an existing object, continue with it + path = '{0}/{1}'.format(path, policy_id) + else: + mso.existing = mso.query_objs(path, key="DhcpRelayPolicies") + + mso.previous = mso.existing + + if state == "absent": + if mso.existing: + if module.check_mode: + mso.existing = {} + else: + mso.existing = mso.request(path, method="DELETE", data=mso.sent) + + elif state == "present": + tenant_id = mso.lookup_tenant(tenant) + payload = dict( + name=dhcp_option_policy, + desc=description, + policyType="dhcp", + policySubtype="option", + tenantId=tenant_id, + ) + mso.sanitize(payload, collate=True) + + if mso.existing: + if mso.check_changed(): + if module.check_mode: + mso.existing = mso.proposed + else: + mso.existing = mso.request(path, method="PUT", data=mso.sent) + else: + if module.check_mode: + mso.existing = mso.proposed + else: + mso.existing = mso.request(path, method="POST", data=mso.sent) + + mso.exit_json() + + +if __name__ == "__main__": + main() diff --git a/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_dhcp_option_policy_option.py b/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_dhcp_option_policy_option.py new file mode 100644 index 00000000..91cf3ad8 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_dhcp_option_policy_option.py @@ -0,0 +1,193 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright: (c) 2020, Lionel Hercot (@lhercot) +# Copyright: (c) 2020, Jorge Gomez (@jgomezve) (based on mso_dhcp_relay_policy module) +# 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_dhcp_option_policy_option +short_description: Manage DHCP options in a DHCP Option policy. +description: +- Manage DHCP options in a DHCP Option policy on Cisco Multi-Site Orchestrator. +author: +- Lionel Hercot (@lhercot) +options: + dhcp_option_policy: + description: + - Name of the DHCP Option Policy + type: str + required: yes + aliases: [ name ] + name: + description: + - Name of the option in the DHCP Option Policy + type: str + aliases: [ option ] + id: + description: + - Id of the option in the DHCP Option Policy + type: int + data: + description: + - Data of the DHCP option in the DHCP Option Policy + type: 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 +extends_documentation_fragment: cisco.mso.modules +""" + +EXAMPLES = r""" +- name: Add a new option to a DHCP Option Policy + cisco.mso.mso_dhcp_option_policy_option: + host: mso_host + username: admin + password: SomeSecretPassword + dhcp_option_policy: my_test_dhcp_policy + name: ansible_test + 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: + host: mso_host + username: admin + password: SomeSecretPassword + 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: + host: mso_host + username: admin + password: SomeSecretPassword + dhcp_option_policy: my_test_dhcp_policy + name: ansible_test + state: query + delegate_to: localhost + +- name: Query all option of a DHCP Option Policy + cisco.mso.mso_dhcp_option_policy_option: + host: mso_host + username: admin + password: SomeSecretPassword + dhcp_option_policy: my_test_dhcp_policy + state: query + delegate_to: localhost +""" + +RETURN = r""" +""" +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.cisco.mso.plugins.module_utils.mso import ( + MSOModule, + mso_argument_spec, +) + + +def main(): + argument_spec = mso_argument_spec() + argument_spec.update( + dhcp_option_policy=dict(type="str", required=True), + name=dict(type="str", aliases=['option']), + id=dict(type="int"), + data=dict(type="str"), + state=dict(type="str", default="present", choices=["absent", "present", "query"]), + ) + module = AnsibleModule( + argument_spec=argument_spec, + supports_check_mode=True, + required_if=[ + ["state", "present", ["name", "id", "data"]], + ["state", "absent", ["name"]], + ], + ) + + dhcp_option_policy = module.params.get("dhcp_option_policy") + option_id = module.params.get("id") + name = module.params.get("name") + data = module.params.get("data") + state = module.params.get("state") + + mso = MSOModule(module) + + path = "policies/dhcp/option" + + option_index = None + previous_option = {} + + # Query for existing object(s) + dhcp_option_obj = mso.get_obj(path, name=dhcp_option_policy, key="DhcpRelayPolicies") + if 'id' not in dhcp_option_obj: + mso.fail_json(msg="DHCP Option Policy '{0}' is not a valid DHCP Option Policy name.".format(dhcp_option_policy)) + policy_id = dhcp_option_obj.get("id") + options = [] + if "dhcpOption" in dhcp_option_obj: + options = dhcp_option_obj.get('dhcpOption') + for index, opt in enumerate(options): + if opt.get('name') == name: + previous_option = opt + option_index = index + + # If we found an existing object, continue with it + path = '{0}/{1}'.format(path, policy_id) + + if state == "query": + mso.existing = options + if name is not None: + mso.existing = previous_option + mso.exit_json() + + mso.previous = previous_option + if state == "absent": + option = {} + if previous_option and option_index is not None: + options.pop(option_index) + + elif state == "present": + option = dict( + id=str(option_id), + name=name, + data=data, + ) + if option_index is not None: + options[option_index] = option + else: + options.append(option) + + if module.check_mode: + mso.existing = option + else: + mso.existing = dhcp_option_obj + dhcp_option_obj["dhcpOption"] = options + mso.sanitize(dhcp_option_obj, collate=True) + new_dhcp_option_obj = mso.request(path, method="PUT", data=mso.sent) + mso.existing = {} + for index, opt in enumerate(new_dhcp_option_obj.get('dhcpOption')): + if opt.get('name') == name: + mso.existing = opt + + mso.exit_json() + + +if __name__ == "__main__": + main() diff --git a/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_dhcp_relay_policy.py b/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_dhcp_relay_policy.py new file mode 100644 index 00000000..d62aa304 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_dhcp_relay_policy.py @@ -0,0 +1,166 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright: (c) 2020, Jorge Gomez Velasquez +# 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_dhcp_relay_policy +short_description: Manage DHCP Relay policies. +description: +- Manage DHCP Relay policies on Cisco Multi-Site Orchestrator. +author: +- Jorge Gomez (@jorgegome2307) +options: + dhcp_relay_policy: + description: + - Name of the DHCP Relay Policy + type: str + aliases: [ name ] + description: + description: + - Description of the DHCP Relay Policy + type: str + tenant: + description: + - Tenant where the DHCP Relay Policy is located. + type: 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 +extends_documentation_fragment: cisco.mso.modules +""" + +EXAMPLES = r""" +- name: Add a new DHCP Relay Policy + cisco.mso.mso_dhcp_relay_policy: + host: mso_host + username: admin + password: SomeSecretPassword + dhcp_relay_policy: my_test_dhcp_policy + description: "My Test DHCP Policy" + tenant: ansible_test + state: present + delegate_to: localhost + +- name: Remove DHCP Relay Policy + cisco.mso.mso_dhcp_relay_policy: + host: mso_host + username: admin + 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: + host: mso_host + username: admin + password: SomeSecretPassword + dhcp_relay_policy: my_test_dhcp_policy + state: query + delegate_to: localhost + +- name: Query all DHCP Relay Policies + cisco.mso.mso_dhcp_relay_policy: + host: mso_host + username: admin + password: SomeSecretPassword + state: query + delegate_to: localhost +""" + +RETURN = r""" +""" + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.cisco.mso.plugins.module_utils.mso import MSOModule, mso_argument_spec + + +def main(): + argument_spec = mso_argument_spec() + argument_spec.update( + dhcp_relay_policy=dict(type="str", aliases=['name']), + description=dict(type="str"), + tenant=dict(type="str"), + state=dict(type="str", default="present", choices=["absent", "present", "query"]), + ) + module = AnsibleModule( + argument_spec=argument_spec, + supports_check_mode=True, + required_if=[ + ['state', 'absent', ['dhcp_relay_policy']], + ['state', 'present', ['dhcp_relay_policy', 'tenant']], + ], + ) + + dhcp_relay_policy = module.params.get("dhcp_relay_policy") + description = module.params.get("description") + tenant = module.params.get("tenant") + state = module.params.get("state") + + mso = MSOModule(module) + + path = "policies/dhcp/relay" + + # Query for existing object(s) + if dhcp_relay_policy: + mso.existing = mso.get_obj(path, name=dhcp_relay_policy, key="DhcpRelayPolicies") + if mso.existing: + policy_id = mso.existing.get("id") + # If we found an existing object, continue with it + path = '{0}/{1}'.format(path, policy_id) + else: + mso.existing = mso.query_objs(path, key="DhcpRelayPolicies") + + mso.previous = mso.existing + + if state == "absent": + if mso.existing: + if module.check_mode: + mso.existing = {} + else: + mso.existing = mso.request(path, method="DELETE", data=mso.sent) + + elif state == "present": + tenant_id = mso.lookup_tenant(tenant) + payload = dict( + name=dhcp_relay_policy, + desc=description, + policyType="dhcp", + policySubtype="relay", + tenantId=tenant_id, + ) + mso.sanitize(payload, collate=True) + + if mso.existing: + if mso.check_changed(): + if module.check_mode: + mso.existing = mso.proposed + else: + mso.existing = mso.request(path, method="PUT", data=mso.sent) + else: + if module.check_mode: + mso.existing = mso.proposed + else: + mso.existing = mso.request(path, method="POST", data=mso.sent) + + mso.exit_json() + + +if __name__ == "__main__": + main() diff --git a/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_dhcp_relay_policy_provider.py b/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_dhcp_relay_policy_provider.py new file mode 100644 index 00000000..8454a50b --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_dhcp_relay_policy_provider.py @@ -0,0 +1,254 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright: (c) 2020, Jorge Gomez Velasquez +# 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_dhcp_relay_policy_provider +short_description: Manage DHCP providers in a DHCP Relay policy. +description: +- Manage DHCP providers in a DHCP Relay policy on Cisco Multi-Site Orchestrator. +author: +- Jorge Gomez (@jorgegome2307) +options: + dhcp_relay_policy: + description: + - Name of the DHCP Relay Policy + type: str + required: yes + aliases: [ name ] + ip: + description: + - IP address of the DHCP Server + type: str + tenant: + description: + - Tenant where the DHCP provider is located. + type: str + schema: + description: + - Schema where the DHCP provider is configured + type: str + template: + description: + - template where the DHCP provider is configured + type: str + application_profile: + description: + - Application Profile where the DHCP provider is configured + type: str + aliases: [ anp ] + endpoint_group: + description: + - EPG where the DHCP provider is configured + type: str + aliases: [ epg ] + external_endpoint_group: + description: + - External EPG where the DHCP provider is configured + type: str + aliases: [ ext_epg, external_epg ] + 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 +extends_documentation_fragment: cisco.mso.modules +""" + +EXAMPLES = r""" +- name: Add a new provider to a DHCP Relay Policy + cisco.mso.mso_dhcp_relay_policy_provider: + host: mso_host + username: admin + password: SomeSecretPassword + dhcp_relay_policy: my_test_dhcp_policy + tenant: ansible_test + schema: ansible_test + template: Template 1 + 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: + host: mso_host + username: admin + password: SomeSecretPassword + dhcp_relay_policy: my_test_dhcp_policy + tenant: ansible_test + schema: ansible_test + template: Template 1 + 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: + host: mso_host + username: admin + password: SomeSecretPassword + dhcp_relay_policy: my_test_dhcp_policy + tenant: ansible_test + schema: ansible_test + template: Template 1 + application_profile: ansible_test + endpoint_group: ansible_test + state: query + delegate_to: localhost + +- name: Query all provider of a DHCP Relay Policy + cisco.mso.mso_dhcp_relay_policy_provider: + host: mso_host + username: admin + password: SomeSecretPassword + dhcp_relay_policy: my_test_dhcp_policy + state: query + delegate_to: localhost +""" + +RETURN = r""" +""" +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.cisco.mso.plugins.module_utils.mso import ( + MSOModule, + mso_argument_spec, +) + + +def main(): + argument_spec = mso_argument_spec() + argument_spec.update( + dhcp_relay_policy=dict(type="str", required=True, aliases=['name']), + ip=dict(type="str"), + tenant=dict(type="str"), + schema=dict(type="str"), + template=dict(type="str"), + application_profile=dict(type="str", aliases=['anp']), + endpoint_group=dict(type="str", aliases=['epg']), + external_endpoint_group=dict(type="str", aliases=['ext_epg', 'external_epg']), + state=dict(type="str", default="present", choices=["absent", "present", "query"]), + ) + module = AnsibleModule( + argument_spec=argument_spec, + supports_check_mode=True, + required_if=[ + ["state", "present", ["ip", "tenant", "schema", "template"]], + ["state", "absent", ["tenant", "schema", "template"]], + ], + ) + + dhcp_relay_policy = module.params.get("dhcp_relay_policy") + ip = module.params.get("ip") + tenant = module.params.get("tenant") + schema = module.params.get("schema") + template = module.params.get("template") + if template is not None: + template = template.replace(' ', '') + application_profile = module.params.get("application_profile") + endpoint_group = module.params.get("endpoint_group") + external_endpoint_group = module.params.get("external_endpoint_group") + state = module.params.get("state") + + mso = MSOModule(module) + + path = "policies/dhcp/relay" + + tenant_id = mso.lookup_tenant(tenant) + schema_id = mso.lookup_schema(schema) + + provider = dict( + addr=ip, + externalEpgRef='', + epgRef='', + l3Ref='', + tenantId=tenant_id, + ) + provider_index = None + previous_provider = {} + + if application_profile is not None and endpoint_group is not None: + provider['epgRef'] = '/schemas/{schemaId}/templates/{templateName}/anps/{app}/epgs/{epg}'.format( + schemaId=schema_id, templateName=template, app=application_profile, epg=endpoint_group, + ) + elif external_endpoint_group is not None: + provider['externalEpgRef'] = '/schemas/{schemaId}/templates/{templateName}/externalEpgs/{ext_epg}'.format( + schemaId=schema_id, templateName=template, ext_epg=external_endpoint_group + ) + + # Query for existing object(s) + dhcp_relay_obj = mso.get_obj(path, name=dhcp_relay_policy, key="DhcpRelayPolicies") + if 'id' not in dhcp_relay_obj: + mso.fail_json(msg="DHCP Relay Policy '{0}' is not a valid DHCP Relay Policy name.".format(dhcp_relay_policy)) + policy_id = dhcp_relay_obj.get("id") + providers = [] + if "provider" in dhcp_relay_obj: + providers = dhcp_relay_obj.get('provider') + for index, prov in enumerate(providers): + if ( + (provider.get('epgRef') != '' and prov.get('epgRef') == provider.get('epgRef')) + or (provider.get('externalEpgRef') != '' and prov.get('externalEpgRef') == provider.get('externalEpgRef')) + ): + previous_provider = prov + provider_index = index + + # If we found an existing object, continue with it + path = '{0}/{1}'.format(path, policy_id) + + if state == "query": + mso.existing = providers + if endpoint_group is not None or external_endpoint_group is not None: + mso.existing = previous_provider + mso.exit_json() + + if endpoint_group is None and external_endpoint_group is None: + mso.fail_json(msg="Missing either endpoint_group or external_endpoint_group required attribute.") + + mso.previous = previous_provider + if state == "absent": + provider = {} + if previous_provider: + if provider_index is not None: + providers.pop(provider_index) + + elif state == "present": + if provider_index is not None: + providers[provider_index] = provider + else: + providers.append(provider) + + if module.check_mode: + mso.existing = provider + else: + mso.existing = dhcp_relay_obj + dhcp_relay_obj["provider"] = providers + mso.sanitize(dhcp_relay_obj, collate=True) + new_dhcp_relay_obj = mso.request(path, method="PUT", data=mso.sent) + mso.existing = {} + for index, prov in enumerate(new_dhcp_relay_obj.get('provider')): + if ( + (provider.get('epgRef') != '' and prov.get('epgRef') == provider.get('epgRef')) + or (provider.get('externalEpgRef') != '' and prov.get('externalEpgRef') == provider.get('externalEpgRef')) + ): + mso.existing = prov + + mso.exit_json() + + +if __name__ == "__main__": + main() diff --git a/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_label.py b/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_label.py new file mode 100644 index 00000000..f2e1fd6d --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_label.py @@ -0,0 +1,165 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright: (c) 2018, Dag Wieers (@dagwieers) +# 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_label +short_description: Manage labels +description: +- Manage labels on Cisco ACI Multi-Site. +author: +- Dag Wieers (@dagwieers) +options: + label: + description: + - The name of the label. + type: str + aliases: [ name ] + type: + description: + - The type of the label. + type: str + choices: [ site ] + default: site + 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 +extends_documentation_fragment: cisco.mso.modules +''' + +EXAMPLES = r''' +- name: Add a new label + cisco.mso.mso_label: + host: mso_host + username: admin + password: SomeSecretPassword + label: Belgium + type: site + state: present + delegate_to: localhost + +- name: Remove a label + cisco.mso.mso_label: + host: mso_host + username: admin + password: SomeSecretPassword + label: Belgium + state: absent + delegate_to: localhost + +- name: Query a label + cisco.mso.mso_label: + host: mso_host + username: admin + password: SomeSecretPassword + label: Belgium + state: query + delegate_to: localhost + register: query_result + +- name: Query all labels + cisco.mso.mso_label: + host: mso_host + username: admin + password: SomeSecretPassword + 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 + + +def main(): + argument_spec = mso_argument_spec() + argument_spec.update( + label=dict(type='str', aliases=['name']), + type=dict(type='str', default='site', choices=['site']), + state=dict(type='str', default='present', choices=['absent', 'present', 'query']), + ) + + module = AnsibleModule( + argument_spec=argument_spec, + supports_check_mode=True, + required_if=[ + ['state', 'absent', ['label']], + ['state', 'present', ['label']], + ], + ) + + label = module.params.get('label') + label_type = module.params.get('type') + state = module.params.get('state') + + mso = MSOModule(module) + + label_id = None + path = 'labels' + + # Query for existing object(s) + if label: + mso.existing = mso.get_obj(path, displayName=label) + if mso.existing: + label_id = mso.existing.get('id') + # If we found an existing object, continue with it + path = 'labels/{id}'.format(id=label_id) + else: + mso.existing = mso.query_objs(path) + + if state == 'query': + pass + + elif state == 'absent': + mso.previous = mso.existing + if mso.existing: + if module.check_mode: + mso.existing = {} + else: + mso.existing = mso.request(path, method='DELETE') + + elif state == 'present': + mso.previous = mso.existing + + payload = dict( + id=label_id, + displayName=label, + type=label_type, + ) + + mso.sanitize(payload, collate=True) + + if mso.existing: + if mso.check_changed(): + if module.check_mode: + mso.existing = mso.proposed + else: + mso.existing = mso.request(path, method='PUT', data=mso.sent) + else: + if module.check_mode: + mso.existing = mso.proposed + else: + mso.existing = mso.request(path, method='POST', data=mso.sent) + + mso.exit_json() + + +if __name__ == "__main__": + main() diff --git a/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_rest.py b/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_rest.py new file mode 100644 index 00000000..51c183c3 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_rest.py @@ -0,0 +1,215 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright: (c) 2020, Anvitha Jain (@anvitha-jain) +# 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_rest +short_description: Direct access to the Cisco MSO REST API +description: +- Enables the management of the Cisco MSO fabric through direct access to the Cisco MSO REST API. +- This module is not idempotent and does not report changes. +options: + method: + description: + - The HTTP method of the request. + - Using C(delete) is typically used for deleting objects. + - Using C(get) is typically used for querying objects. + - Using C(post) is typically used for modifying objects. + - Using C(put) is typically used for modifying existing objects. + - Using C(patch) is typically also used for modifying existing objects. + type: str + choices: [ delete, get, post, put, patch ] + default: get + aliases: [ action ] + path: + description: + - URI being used to execute API calls. + type: str + required: yes + aliases: [ uri ] + content: + description: + - Sets the payload of the API request directly. + - This may be convenient to template simple requests. + - For anything complex use the C(template) lookup plugin (see examples). + type: raw + aliases: [ payload ] +extends_documentation_fragment: +- cisco.mso.modules + +notes: +- Most payloads are known not to be idempotent, so be careful when constructing payloads. +seealso: +- module: cisco.mso.mso_tenant +author: +- Anvitha Jain (@anvitha-jain) +''' + +EXAMPLES = r''' +- name: Add schema (JSON) + cisco.mso.mso_rest: + host: mso + username: admin + password: SomeSecretPassword + path: /mso/api/v1/schemas + method: post + content: + { + "displayName": "{{ mso_schema | default('ansible_test') }}", + "templates": [{ + "name": "Template_1", + "tenantId": "{{ add_tenant.jsondata.id }}", + "displayName": "Template_1", + "templateSubType": [], + "templateType": "stretched-template", + "anps": [], + "contracts": [], + "vrfs": [], + "bds": [], + "filters": [], + "externalEpgs": [], + "serviceGraphs": [], + "intersiteL3outs": [] + }], + "sites": [], + "_updateVersion": 0 + } + delegate_to: localhost + +- name: Query schema + cisco.mso.mso_rest: + host: mso + username: admin + password: SomeSecretPassword + path: /mso/api/v1/schemas + method: get + delegate_to: localhost + +- name: Patch schema (YAML) + cisco.mso.mso_rest: + host: mso + username: admin + password: SomeSecretPassword + path: "/mso/api/v1/schemas/{{ add_schema.jsondata.id }}" + method: patch + content: + - op: add + path: /templates/Template_1/anps/- + value: + name: AP2 + displayName: AP2 + epgs: [] + _updateVersion: 0 + delegate_to: localhost + +- name: Add a tenant from a templated payload file from templates + cisco.mso.mso_rest: + host: mso + username: admin + password: SomeSecretPassword + method: post + path: /api/v1/tenants + content: "{{ lookup('template', 'mso/tenant.json.j2') }}" + delegate_to: localhost +''' + +RETURN = r''' +''' + +import json + +# Optional, only used for YAML validation +try: + import yaml + HAS_YAML = True +except Exception: + HAS_YAML = False + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.cisco.mso.plugins.module_utils.mso import MSOModule, mso_argument_spec +from ansible.module_utils.urls import fetch_url +from ansible.module_utils._text import to_text + + +def main(): + argument_spec = mso_argument_spec() + argument_spec.update( + path=dict(type='str', required=True, aliases=['uri']), + method=dict(type='str', default='get', choices=['delete', 'get', 'post', 'put', 'patch'], aliases=['action']), + content=dict(type='raw', aliases=['payload']), + ) + + module = AnsibleModule( + argument_spec=argument_spec, + ) + + content = module.params.get('content') + path = module.params.get('path') + + mso = MSOModule(module) + mso.result['status'] = -1 # Ensure we always return a status + + # Validate content/payload + if content and (isinstance(content, dict) or isinstance(content, list)): + # Validate inline YAML/JSON + content = json.dumps(content) + elif content and isinstance(content, str) and HAS_YAML: + try: + # Validate YAML/JSON string + content = json.dumps(yaml.safe_load(content)) + except Exception as e: + module.fail_json(msg='Failed to parse provided JSON/YAML payload: %s' % to_text(e), exception=to_text(e), payload=content) + + # Perform actual request using auth cookie (Same as mso.request()) + if 'port' in mso.params and mso.params.get('port') is not None: + mso.url = '%(protocol)s://%(host)s:%(port)s/' % mso.params + path.lstrip('/') + else: + mso.url = '%(protocol)s://%(host)s/' % mso.params + path.lstrip('/') + + mso.method = mso.params.get('method').upper() + + # Perform request + resp, info = fetch_url(module, mso.url, + data=content, + headers=mso.headers, + method=mso.method, + timeout=mso.params.get('timeout'), + use_proxy=mso.params.get('use_proxy')) + + mso.response = info.get('msg') + mso.status = info.get('status', -1) + mso.result['status'] = info.get('status', -1) + + # Report failure + if info.get('status') not in [200, 201, 202, 204]: + try: + # MSO error + mso.response_json(info['body']) + mso.fail_json(msg='MSO Error %(code)s: %(message)s - %(info)s' % mso.error) + except KeyError: + # Connection error + mso.fail_json(msg='Connection failed for %(url)s. %(msg)s' % info) + + mso.response_json(resp.read()) + + if mso.method != 'GET': + mso.result['changed'] = True + + mso.result['jsondata'] = mso.jsondata + + # Report success + mso.exit_json(**mso.result) + + +if __name__ == '__main__': + main() diff --git a/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_role.py b/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_role.py new file mode 100644 index 00000000..69ad4fe7 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_role.py @@ -0,0 +1,277 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright: (c) 2018, Dag Wieers (@dagwieers) +# 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_role +short_description: Manage roles +description: +- Manage roles on Cisco ACI Multi-Site. +author: +- Dag Wieers (@dagwieers) +options: + role: + description: + - The name of the role. + type: str + aliases: [ name ] + display_name: + description: + - The name of the role to be displayed in the web UI. + type: str + description: + description: + - The description of the role. + type: str + read_permissions: + description: + - A list of read permissions tied to this role. + type: list + elements: str + choices: + - backup-db + - manage-audit-records + - manage-labels + - manage-roles + - manage-schemas + - manage-sites + - manage-tenants + - manage-tenant-schemas + - manage-users + - platform-logs + - view-all-audit-records + - view-labels + - view-roles + - view-schemas + - view-sites + - view-tenants + - view-tenant-schemas + - view-users + write_permissions: + description: + - A list of write permissions tied to this role. + type: list + elements: str + aliases: [ permissions ] + choices: + - backup-db + - manage-audit-records + - manage-labels + - manage-roles + - manage-schemas + - manage-sites + - manage-tenants + - manage-tenant-schemas + - manage-users + - platform-logs + - view-all-audit-records + - view-labels + - view-roles + - view-schemas + - view-sites + - view-tenants + - view-tenant-schemas + - view-users + 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 +extends_documentation_fragment: cisco.mso.modules +''' + +EXAMPLES = r''' +- name: Add a new role + cisco.mso.mso_role: + host: mso_host + username: admin + password: SomeSecretPassword + role: readOnly + display_name: Read Only + description: Read-only access for troubleshooting + read_permissions: + - view-roles + - view-schemas + - view-sites + - view-tenants + - view-tenant-schemas + - view-users + write_permissions: + - manage-roles + - manage-schemas + - manage-sites + - manage-tenants + - manage-tenant-schemas + - manage-users + state: present + delegate_to: localhost + +- name: Remove a role + cisco.mso.mso_role: + host: mso_host + username: admin + password: SomeSecretPassword + role: readOnly + state: absent + delegate_to: localhost + +- name: Query a role + cisco.mso.mso_role: + host: mso_host + username: admin + password: SomeSecretPassword + role: readOnly + state: query + delegate_to: localhost + register: query_result + +- name: Query all roles + cisco.mso.mso_role: + host: mso_host + username: admin + password: SomeSecretPassword + 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 + + +def main(): + argument_spec = mso_argument_spec() + argument_spec.update( + role=dict(type='str', aliases=['name']), + display_name=dict(type='str'), + description=dict(type='str'), + read_permissions=dict(type='list', elements='str', choices=[ + 'backup-db', + 'manage-audit-records', + 'manage-labels', + 'manage-roles', + 'manage-schemas', + 'manage-sites', + 'manage-tenants', + 'manage-tenant-schemas', + 'manage-users', + 'platform-logs', + 'view-all-audit-records', + 'view-labels', + 'view-roles', + 'view-schemas', + 'view-sites', + 'view-tenants', + 'view-tenant-schemas', + 'view-users', + ]), + write_permissions=dict(type='list', elements='str', aliases=['permissions'], choices=[ + 'backup-db', + 'manage-audit-records', + 'manage-labels', + 'manage-roles', + 'manage-schemas', + 'manage-sites', + 'manage-tenants', + 'manage-tenant-schemas', + 'manage-users', + 'platform-logs', + 'view-all-audit-records', + 'view-labels', + 'view-roles', + 'view-schemas', + 'view-sites', + 'view-tenants', + 'view-tenant-schemas', + 'view-users', + ]), + state=dict(type='str', default='present', choices=['absent', 'present', 'query']), + ) + + module = AnsibleModule( + argument_spec=argument_spec, + supports_check_mode=True, + required_if=[ + ['state', 'absent', ['role']], + ['state', 'present', ['role']], + ], + ) + + role = module.params.get('role') + description = module.params.get('description') + read_permissions = module.params.get('read_permissions') + write_permissions = module.params.get('write_permissions') + state = module.params.get('state') + + mso = MSOModule(module) + + role_id = None + path = 'roles' + + # Query for existing object(s) + if role: + mso.existing = mso.get_obj(path, name=role) + if mso.existing: + role_id = mso.existing.get('id') + # If we found an existing object, continue with it + path = 'roles/{id}'.format(id=role_id) + else: + mso.existing = mso.query_objs(path) + + if state == 'query': + pass + + elif state == 'absent': + mso.previous = mso.existing + if mso.existing: + if module.check_mode: + mso.existing = {} + else: + mso.existing = mso.request(path, method='DELETE') + + elif state == 'present': + mso.previous = mso.existing + + payload = dict( + id=role_id, + name=role, + displayName=role, + description=description, + readPermissions=read_permissions, + writePermissions=write_permissions, + ) + + mso.sanitize(payload, collate=True) + + if mso.existing: + if mso.check_changed(): + if module.check_mode: + mso.existing = mso.proposed + else: + mso.existing = mso.request(path, method='PUT', data=mso.sent) + else: + if module.check_mode: + mso.existing = mso.proposed + else: + mso.existing = mso.request(path, method='POST', data=mso.sent) + + mso.exit_json() + + +if __name__ == "__main__": + main() diff --git a/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema.py b/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema.py new file mode 100644 index 00000000..5cf03aab --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema.py @@ -0,0 +1,133 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright: (c) 2018, Dag Wieers (@dagwieers) +# 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 +short_description: Manage schemas +description: +- Manage schemas on Cisco ACI Multi-Site. +author: +- Dag Wieers (@dagwieers) +options: + schema: + description: + - The name of the schema. + type: str + aliases: [ name ] + 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, query ] + default: query +notes: +- Due to restrictions of the MSO REST API this module cannot create empty schemas (i.e. schemas without templates). + Use the M(cisco.mso.mso_schema_template) to automatically create schemas with templates. +seealso: +- module: cisco.mso.mso_schema_site +- module: cisco.mso.mso_schema_template +extends_documentation_fragment: cisco.mso.modules +''' + +EXAMPLES = r''' +- name: Remove schemas + cisco.mso.mso_schema: + host: mso_host + username: admin + password: SomeSecretPassword + schema: Schema 1 + state: absent + delegate_to: localhost + +- name: Query a schema + cisco.mso.mso_schema: + host: mso_host + username: admin + password: SomeSecretPassword + schema: Schema 1 + state: query + delegate_to: localhost + register: query_result + +- name: Query all schemas + cisco.mso.mso_schema: + host: mso_host + username: admin + password: SomeSecretPassword + 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 + + +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']), + ) + + module = AnsibleModule( + argument_spec=argument_spec, + supports_check_mode=True, + required_if=[ + ['state', 'absent', ['schema']], + ], + ) + + schema = module.params.get('schema') + 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 mso.existing: + schema_id = mso.existing.get('id') + path = 'schemas/{id}'.format(id=schema_id) + else: + mso.existing = mso.query_objs(path) + + if state == 'query': + pass + + elif state == 'absent': + mso.previous = mso.existing + if mso.existing: + if module.check_mode: + mso.existing = {} + else: + mso.existing = mso.request(path, method='DELETE') + + mso.exit_json() + + +if __name__ == "__main__": + main() diff --git a/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema_site.py b/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema_site.py new file mode 100644 index 00000000..5879c168 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema_site.py @@ -0,0 +1,200 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright: (c) 2018, Dag Wieers (@dagwieers) +# Copyright: (c) 2020, Shreyas Srish (@shrsr) +# 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 +short_description: Manage sites in schemas +description: +- Manage sites on Cisco ACI Multi-Site. +author: +- Dag Wieers (@dagwieers) +- Shreyas Srish (@shrsr) +options: + schema: + description: + - The name of the schema. + type: str + required: yes + site: + description: + - The name of the site to manage. + type: str + template: + description: + - The name of the template. + type: str + aliases: [ name ] + 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 +- module: cisco.mso.mso_site +extends_documentation_fragment: cisco.mso.modules +''' + +EXAMPLES = r''' +- name: Add a new site to a schema + cisco.mso.mso_schema_site: + host: mso_host + username: admin + password: SomeSecretPassword + schema: Schema 1 + site: Site1 + template: Template 1 + state: present + delegate_to: localhost + +- name: Remove a site from a schema + cisco.mso.mso_schema_site: + host: mso_host + username: admin + password: SomeSecretPassword + schema: Schema 1 + site: Site1 + template: Template 1 + state: absent + delegate_to: localhost + +- name: Query a schema site + cisco.mso.mso_schema_site: + host: mso_host + username: admin + password: SomeSecretPassword + schema: Schema 1 + site: Site1 + template: Template 1 + state: query + delegate_to: localhost + register: query_result + +- name: Query all schema sites + cisco.mso.mso_schema_site: + host: mso_host + username: admin + password: SomeSecretPassword + schema: Schema 1 + 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 + + +def main(): + argument_spec = mso_argument_spec() + argument_spec.update( + schema=dict(type='str', required=True), + site=dict(type='str', aliases=['name']), + template=dict(type='str'), + state=dict(type='str', default='present', choices=['absent', 'present', 'query']), + ) + + module = AnsibleModule( + argument_spec=argument_spec, + supports_check_mode=True, + required_if=[ + ['state', 'absent', ['site', 'template']], + ['state', 'present', ['site', 'template']], + ], + ) + + schema = module.params.get('schema') + site = module.params.get('site') + template = module.params.get('template') + if template is not None: + template = template.replace(' ', '') + state = module.params.get('state') + + mso = MSOModule(module) + + # Get schema + schema_obj = mso.get_obj('schemas', displayName=schema) + if not schema_obj: + mso.fail_json(msg="Provided schema '{0}' does not exist".format(schema)) + + # Schema exists + schema_path = 'schemas/{id}'.format(**schema_obj) + + # Get site + site_id = mso.lookup_site(site) + + mso.existing = {} + if 'sites' in schema_obj: + sites = [(s.get('siteId'), s.get('templateName')) for s in schema_obj.get('sites')] + if template: + if (site_id, template) in sites: + site_idx = sites.index((site_id, template)) + site_path = '/sites/{0}'.format(site_idx) + mso.existing = schema_obj.get('sites')[site_idx] + else: + mso.existing = schema_obj.get('sites') + + if state == 'query': + if not mso.existing: + if template: + mso.fail_json(msg="Template '{0}' not found".format(template)) + else: + mso.existing = [] + mso.exit_json() + + sites_path = '/sites' + ops = [] + + mso.previous = mso.existing + if state == 'absent': + if mso.existing: + # Remove existing site + mso.sent = mso.existing = {} + ops.append(dict(op='remove', path=site_path)) + + elif state == 'present': + if not mso.existing: + # Add new site + payload = dict( + siteId=site_id, + templateName=template, + anps=[], + bds=[], + contracts=[], + externalEpgs=[], + intersiteL3outs=[], + serviceGraphs=[], + vrfs=[], + ) + + mso.sanitize(payload, collate=True) + + ops.append(dict(op='add', path=sites_path + '/-', value=mso.sent)) + + mso.existing = mso.proposed + + if not module.check_mode: + mso.request(schema_path, method='PATCH', data=ops) + + mso.exit_json() + + +if __name__ == "__main__": + main() diff --git a/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_anp.py b/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_anp.py new file mode 100644 index 00000000..2752e3d2 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_anp.py @@ -0,0 +1,214 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright: (c) 2019, Dag Wieers (@dagwieers) +# 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_anp +short_description: Manage site-local Application Network Profiles (ANPs) in schema template +description: +- Manage site-local ANPs in schema template on Cisco ACI Multi-Site. +author: +- Dag Wieers (@dagwieers) +options: + schema: + description: + - The name of the schema. + type: str + required: yes + site: + description: + - The name of the site. + type: str + required: yes + template: + description: + - The name of the template. + type: str + required: yes + anp: + description: + - The name of the ANP to manage. + type: str + aliases: [ name ] + 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_site +- module: cisco.mso.mso_schema_site_anp_epg +- module: cisco.mso.mso_schema_template_anp +extends_documentation_fragment: cisco.mso.modules +''' + +EXAMPLES = r''' +- name: Add a new site ANP + cisco.mso.mso_schema_site_anp: + host: mso_host + username: admin + password: SomeSecretPassword + schema: Schema1 + site: Site1 + template: Template1 + anp: ANP1 + state: present + delegate_to: localhost + +- name: Remove a site ANP + cisco.mso.mso_schema_site_anp: + host: mso_host + username: admin + password: SomeSecretPassword + schema: Schema1 + site: Site1 + template: Template1 + anp: ANP1 + state: absent + delegate_to: localhost + +- name: Query a specific site ANP + cisco.mso.mso_schema_site_anp: + host: mso_host + username: admin + password: SomeSecretPassword + schema: Schema1 + site: Site1 + template: Template1 + anp: ANP1 + state: query + delegate_to: localhost + register: query_result + +- name: Query all site ANPs + cisco.mso.mso_schema_site_anp: + host: mso_host + username: admin + password: SomeSecretPassword + schema: Schema1 + site: Site1 + template: Template1 + 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 + + +def main(): + argument_spec = mso_argument_spec() + argument_spec.update( + schema=dict(type='str', required=True), + site=dict(type='str', required=True), + template=dict(type='str', required=True), + anp=dict(type='str', aliases=['name']), # This parameter is not required for querying all objects + state=dict(type='str', default='present', choices=['absent', 'present', 'query']), + ) + + module = AnsibleModule( + argument_spec=argument_spec, + supports_check_mode=True, + required_if=[ + ['state', 'absent', ['anp']], + ['state', 'present', ['anp']], + ], + ) + + schema = module.params.get('schema') + site = module.params.get('site') + template = module.params.get('template').replace(' ', '') + anp = module.params.get('anp') + state = module.params.get('state') + + mso = MSOModule(module) + + # Get schema_id + schema_obj = mso.get_obj('schemas', displayName=schema) + if not schema_obj: + mso.fail_json(msg="Provided schema '{0}' does not exist".format(schema)) + + schema_path = 'schemas/{id}'.format(**schema_obj) + schema_id = schema_obj.get('id') + + # Get site + site_id = mso.lookup_site(site) + + # Get site_idx + if 'sites' not in schema_obj: + 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')] + if (site_id, template) not in sites: + mso.fail_json(msg="Provided site/template '{0}-{1}' does not exist. Existing sites/templates: {2}".format(site, template, ', '.join(sites))) + + # 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) + + # Get ANP + anp_ref = mso.anp_ref(schema_id=schema_id, template=template, anp=anp) + anps = [a.get('anpRef') for a in schema_obj.get('sites')[site_idx]['anps']] + + if anp is not None and anp_ref in anps: + anp_idx = anps.index(anp_ref) + anp_path = '/sites/{0}/anps/{1}'.format(site_template, anp) + mso.existing = schema_obj.get('sites')[site_idx]['anps'][anp_idx] + + if state == 'query': + if anp is None: + mso.existing = schema_obj.get('sites')[site_idx]['anps'] + elif not mso.existing: + mso.fail_json(msg="ANP '{anp}' not found".format(anp=anp)) + mso.exit_json() + + anps_path = '/sites/{0}/anps'.format(site_template) + ops = [] + + mso.previous = mso.existing + if state == 'absent': + if mso.existing: + mso.sent = mso.existing = {} + ops.append(dict(op='remove', path=anp_path)) + + elif state == 'present': + + payload = dict( + anpRef=dict( + schemaId=schema_id, + templateName=template, + anpName=anp, + ), + ) + + mso.sanitize(payload, collate=True) + + if not mso.existing: + ops.append(dict(op='add', path=anps_path + '/-', value=mso.sent)) + + mso.existing = mso.proposed + + if not module.check_mode: + mso.request(schema_path, method='PATCH', data=ops) + + mso.exit_json() + + +if __name__ == "__main__": + main() diff --git a/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_anp_epg.py b/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_anp_epg.py new file mode 100644 index 00000000..b7fe7fbc --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_anp_epg.py @@ -0,0 +1,230 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright: (c) 2019, Dag Wieers (@dagwieers) +# 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_anp_epg +short_description: Manage site-local Endpoint Groups (EPGs) in schema template +description: +- Manage site-local EPGs in schema template on Cisco ACI Multi-Site. +author: +- Dag Wieers (@dagwieers) +options: + schema: + description: + - The name of the schema. + type: str + required: yes + site: + description: + - The name of the site. + type: str + required: yes + template: + description: + - The name of the template. + type: str + required: yes + anp: + description: + - The name of the ANP. + type: str + required: yes + epg: + description: + - The name of the EPG to manage. + type: str + aliases: [ name ] + 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_site_anp +- module: cisco.mso.mso_schema_site_anp_epg_subnet +- module: cisco.mso.mso_schema_template_anp_epg +extends_documentation_fragment: cisco.mso.modules +''' + +EXAMPLES = r''' +- name: Add a new site EPG + cisco.mso.mso_schema_site_anp_epg: + host: mso_host + username: admin + password: SomeSecretPassword + schema: Schema1 + site: Site1 + template: Template1 + anp: ANP1 + epg: EPG1 + state: present + delegate_to: localhost + +- name: Remove a site EPG + cisco.mso.mso_schema_site_anp_epg: + host: mso_host + username: admin + password: SomeSecretPassword + schema: Schema1 + site: Site1 + template: Template1 + anp: ANP1 + epg: EPG1 + state: absent + delegate_to: localhost + +- name: Query a specific site EPGs + cisco.mso.mso_schema_site_anp_epg: + host: mso_host + username: admin + password: SomeSecretPassword + schema: Schema1 + site: Site1 + template: Template1 + anp: ANP1 + epg: EPG1 + state: query + delegate_to: localhost + register: query_result + +- name: Query all site EPGs + cisco.mso.mso_schema_site_anp_epg: + host: mso_host + username: admin + password: SomeSecretPassword + schema: Schema1 + site: Site1 + template: Template1 + anp: ANP1 + 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 + + +def main(): + argument_spec = mso_argument_spec() + argument_spec.update( + schema=dict(type='str', required=True), + site=dict(type='str', required=True), + template=dict(type='str', required=True), + anp=dict(type='str', required=True), + epg=dict(type='str', aliases=['name']), # This parameter is not required for querying all objects + state=dict(type='str', default='present', choices=['absent', 'present', 'query']), + ) + + module = AnsibleModule( + argument_spec=argument_spec, + supports_check_mode=True, + required_if=[ + ['state', 'absent', ['epg']], + ['state', 'present', ['epg']], + ], + ) + + schema = module.params.get('schema') + site = module.params.get('site') + template = module.params.get('template').replace(' ', '') + anp = module.params.get('anp') + epg = module.params.get('epg') + state = module.params.get('state') + + mso = MSOModule(module) + + # Get schema_id + schema_obj = mso.get_obj('schemas', displayName=schema) + if not schema_obj: + mso.fail_json(msg="Provided schema '{0}' does not exist".format(schema)) + + schema_path = 'schemas/{id}'.format(**schema_obj) + schema_id = schema_obj.get('id') + + # Get site + site_id = mso.lookup_site(site) + if 'sites' not in schema_obj: + 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')] + if (site_id, template) not in sites: + mso.fail_json(msg="Provided site/template '{0}-{1}' does not exist. Existing sites/templates: {2}".format(site, template, ', '.join(sites))) + + # 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) + + # Get ANP + anp_ref = mso.anp_ref(schema_id=schema_id, template=template, anp=anp) + anps = [a.get('anpRef') for a in schema_obj.get('sites')[site_idx]['anps']] + if anp_ref 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_ref) + + # Get EPG + epg_ref = mso.epg_ref(schema_id=schema_id, template=template, anp=anp, epg=epg) + epgs = [e.get('epgRef') for e in schema_obj.get('sites')[site_idx]['anps'][anp_idx]['epgs']] + if epg is not None and epg_ref in epgs: + epg_idx = epgs.index(epg_ref) + epg_path = '/sites/{0}/anps/{1}/epgs/{2}'.format(site_template, anp, epg) + mso.existing = schema_obj.get('sites')[site_idx]['anps'][anp_idx]['epgs'][epg_idx] + + if state == 'query': + if epg is None: + mso.existing = schema_obj.get('sites')[site_idx]['anps'][anp_idx]['epgs'] + elif not mso.existing: + mso.fail_json(msg="EPG '{epg}' not found".format(epg=epg)) + mso.exit_json() + + epgs_path = '/sites/{0}/anps/{1}/epgs'.format(site_template, anp) + ops = [] + + mso.previous = mso.existing + if state == 'absent': + if mso.existing: + mso.sent = mso.existing = {} + ops.append(dict(op='remove', path=epg_path)) + + elif state == 'present': + + payload = dict( + epgRef=dict( + schemaId=schema_id, + templateName=template, + anpName=anp, + epgName=epg, + ), + ) + + mso.sanitize(payload, collate=True) + + if not mso.existing: + ops.append(dict(op='add', path=epgs_path + '/-', value=mso.sent)) + + mso.existing = mso.proposed + + if not module.check_mode: + mso.request(schema_path, method='PATCH', data=ops) + + mso.exit_json() + + +if __name__ == "__main__": + main() diff --git a/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_anp_epg_domain.py b/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_anp_epg_domain.py new file mode 100644 index 00000000..52d913ae --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_anp_epg_domain.py @@ -0,0 +1,474 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright: (c) 2019, Nirav Katarmal (@nkatarmal-crest) +# 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_anp_epg_domain +short_description: Manage site-local EPG domains in schema template +description: +- Manage site-local EPG domains in schema template on Cisco ACI Multi-Site. +author: +- Nirav Katarmal (@nkatarmal-crest) +options: + schema: + description: + - The name of the schema. + type: str + required: yes + site: + description: + - The name of the site. + type: str + required: yes + template: + description: + - The name of the template. + type: str + required: yes + anp: + description: + - The name of the ANP. + type: str + required: yes + epg: + description: + - The name of the EPG. + type: str + required: yes + domain_association_type: + description: + - The type of domain to associate. + type: str + choices: [ vmmDomain, l3ExtDomain, l2ExtDomain, physicalDomain, fibreChannelDomain ] + domain_profile: + description: + - The domain profile name. + type: str + deployment_immediacy: + description: + - The deployment immediacy of the domain. + - C(immediate) means B(Deploy immediate). + - C(lazy) means B(deploy on demand). + type: str + choices: [ immediate, lazy ] + resolution_immediacy: + description: + - Determines when the policies should be resolved and available. + - Defaults to C(lazy) when unset during creation. + type: str + 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. + type: str + micro_seg_vlan: + description: + - Virtual LAN for microsegmentation. This attribute can only be used with vmmDomain 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. + type: str + port_encap_vlan: + description: + - Virtual LAN type for port encap. This attribute can only be used with vmmDomain domain association. + type: int + vlan_encap_mode: + description: + - Which VLAN enacap mode to use. This attribute can only be used with vmmDomain 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. + type: bool + switch_type: + description: + - Which switch type to use with this domain association. This attribute can only be used with vmmDomain 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. + type: str + enhanced_lagpolicy_name: + description: + - EPG enhanced lagpolicy name. This attribute can only be used with vmmDomain domain association. + type: str + enhanced_lagpolicy_dn: + description: + - Distinguished name of EPG lagpolicy. This attribute can only be used with vmmDomain domain association. + type: 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 +notes: +- The ACI MultiSite PATCH API has a deficiency requiring some objects to be referenced by index. + This can cause silent corruption on concurrent access when changing/removing on object as + the wrong object may be referenced. This module is affected by this deficiency. +seealso: +- module: cisco.mso.mso_schema_site_anp_epg +- module: cisco.mso.mso_schema_template_anp_epg +extends_documentation_fragment: cisco.mso.modules +''' + +EXAMPLES = r''' +- name: Add a new domain to 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: present + delegate_to: localhost + +- 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 + delegate_to: localhost + +- name: Query a domain associated with a specific 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' + state: query + delegate_to: localhost + register: query_result + +- name: Query all domains associated with 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 + 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 + + +def main(): + argument_spec = mso_argument_spec() + argument_spec.update( + schema=dict(type='str', required=True), + site=dict(type='str', required=True), + template=dict(type='str', required=True), + anp=dict(type='str', required=True), + epg=dict(type='str', required=True), + domain_association_type=dict(type='str', choices=['vmmDomain', 'l3ExtDomain', 'l2ExtDomain', 'physicalDomain', 'fibreChannelDomain']), + domain_profile=dict(type='str'), + 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=dict(type='int'), + port_encap_vlan_type=dict(type='str'), + port_encap_vlan=dict(type='int'), + vlan_encap_mode=dict(type='str', choices=['static', 'dynamic']), + allow_micro_segmentation=dict(type='bool'), + switch_type=dict(type='str'), + switching_mode=dict(type='str'), + enhanced_lagpolicy_name=dict(type='str'), + enhanced_lagpolicy_dn=dict(type='str'), + + ) + + module = AnsibleModule( + argument_spec=argument_spec, + supports_check_mode=True, + required_if=[ + ['state', 'absent', ['domain_association_type', 'domain_profile', 'deployment_immediacy', 'resolution_immediacy']], + ['state', 'present', ['domain_association_type', 'domain_profile', 'deployment_immediacy', 'resolution_immediacy']], + ], + ) + + schema = module.params.get('schema') + site = module.params.get('site') + template = module.params.get('template').replace(' ', '') + anp = module.params.get('anp') + epg = module.params.get('epg') + domain_association_type = module.params.get('domain_association_type') + domain_profile = module.params.get('domain_profile') + deployment_immediacy = module.params.get('deployment_immediacy') + resolution_immediacy = module.params.get('resolution_immediacy') + state = module.params.get('state') + micro_seg_vlan_type = module.params.get('micro_seg_vlan_type') + micro_seg_vlan = module.params.get('micro_seg_vlan') + port_encap_vlan_type = module.params.get('port_encap_vlan_type') + port_encap_vlan = module.params.get('port_encap_vlan') + vlan_encap_mode = module.params.get('vlan_encap_mode') + allow_micro_segmentation = module.params.get('allow_micro_segmentation') + switch_type = module.params.get('switch_type') + 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') + + mso = MSOModule(module) + + # Get schema_id + schema_obj = mso.get_obj('schemas', displayName=schema) + if not schema_obj: + mso.fail_json(msg="Provided schema '{0}' does not exist".format(schema)) + schema_path = 'schemas/{id}'.format(**schema_obj) + schema_id = schema_obj.get('id') + + # 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 'sites' not in schema_obj: + 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) + + 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) + + # Get EPG + epg_ref = mso.epg_ref(schema_id=schema_id, template=template, anp=anp, epg=epg) + + # 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']] + + # 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 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)) + + # EPG at template level but not at site level. Create payload at site level for EPG + else: + + new_epg = dict( + epgRef=dict( + schemaId=schema_id, + templateName=template, + anpName=anp, + epgName=epg, + ) + ) + + # 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 + else: + # If anp in payload, anp exists at site level. Update payload with EPG payload + payload['epgs'] = [new_epg] + + # Update index of EPG at site level + else: + epg_idx = epgs.index(epg_ref) + + if domain_association_type == 'vmmDomain': + domain_dn = 'uni/vmmp-VMware/dom-{0}'.format(domain_profile) + elif domain_association_type == 'l3ExtDomain': + domain_dn = 'uni/l3dom-{0}'.format(domain_profile) + elif domain_association_type == 'l2ExtDomain': + domain_dn = 'uni/l2dom-{0}'.format(domain_profile) + elif domain_association_type == 'physicalDomain': + domain_dn = 'uni/phys-{0}'.format(domain_profile) + elif domain_association_type == 'fibreChannelDomain': + domain_dn = 'uni/fc-{0}'.format(domain_profile) + else: + domain_dn = '' + + # Get Domains + # If anp at site level and epg is at site level + if 'anpRef' not in payload and 'epgRef' not in payload: + domains = [dom.get('dn') for dom in schema_obj['sites'][site_idx]['anps'][anp_idx]['epgs'][epg_idx]['domainAssociations']] + if domain_dn in domains: + domain_idx = domains.index(domain_dn) + domain_path = '/sites/{0}/anps/{1}/epgs/{2}/domainAssociations/{3}'.format(site_template, anp, epg, domain_idx) + mso.existing = schema_obj['sites'][site_idx]['anps'][anp_idx]['epgs'][epg_idx]['domainAssociations'][domain_idx] + + if state == 'query': + if domain_association_type is None or domain_profile is None: + mso.existing = schema_obj.get('sites')[site_idx]['anps'][anp_idx]['epgs'][epg_idx]['domainAssociations'] + elif not mso.existing: + mso.fail_json(msg="Domain association '{domain_association_type}/{domain_profile}' not found".format( + domain_association_type=domain_association_type, + domain_profile=domain_profile)) + mso.exit_json() + + domains_path = '/sites/{0}/anps/{1}/epgs/{2}/domainAssociations'.format(site_template, anp, epg) + ops = [] + new_domain = dict( + dn=domain_dn, + domainType=domain_association_type, + deploymentImmediacy=deployment_immediacy, + resolutionImmediacy=resolution_immediacy, + ) + + 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.") + + 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.") + + if vlan_encap_mode: + vmmDomainProperties['vlanEncapMode'] = vlan_encap_mode + + if allow_micro_segmentation: + 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.") + + if vmmDomainProperties: + new_domain['vmmDomainProperties'] = vmmDomainProperties + + # If payload is empty, anp and EPG already exist at site level + if not payload: + op_path = domains_path + '/-' + payload = new_domain + + # If payload exists + else: + # If anp already exists at site level...(AND payload != epg as well?) + if 'anpRef' not in payload: + payload['domainAssociations'] = [new_domain] + else: + payload['epgs'][0]['domainAssociations'] = [new_domain] + + mso.previous = mso.existing + if state == 'absent': + if mso.existing: + mso.sent = mso.existing = {} + ops.append(dict(op='remove', path=domain_path)) + elif state == 'present': + mso.sanitize(payload, collate=True) + + if mso.existing: + ops.append(dict(op='replace', path=domain_path, value=mso.sent)) + else: + ops.append(dict(op='add', path=op_path, value=mso.sent)) + + mso.existing = new_domain + + if not module.check_mode: + mso.request(schema_path, method='PATCH', data=ops) + + mso.exit_json() + + +if __name__ == "__main__": + main() diff --git a/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_anp_epg_selector.py b/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_anp_epg_selector.py new file mode 100644 index 00000000..4791c448 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_anp_epg_selector.py @@ -0,0 +1,398 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright: (c) 2020, Cindy Zhao (@cizhao) +# 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_anp_epg_selector +short_description: Manage site-local EPG selector in schema templates +description: +- Manage EPG selector in schema template on Cisco ACI Multi-Site. +author: +- Cindy Zhao (@cizhao) +options: + schema: + description: + - The name of the schema. + type: str + required: yes + site: + description: + - The name of the site. + type: str + required: yes + template: + description: + - The name of the template. + type: str + required: yes + anp: + description: + - The name of the ANP. + type: str + required: yes + epg: + description: + - The name of the EPG to manage. + type: str + required: yes + selector: + description: + - The name of the selector. + type: str + expressions: + description: + - Expressions associated to this selector. + type: list + elements: dict + suboptions: + type: + description: + - The type of the expression. + - The type is custom or is one of region, zone and ip_address + - The type can be zone only when the site is AWS. + required: true + type: str + aliases: [ tag ] + operator: + description: + - The operator associated to the expression. + - Operator has_key or does_not_have_key is only available for custom type / tag + required: true + type: str + choices: [ not_in, in, equals, not_equals, has_key, does_not_have_key ] + value: + description: + - The value associated to the expression. + - If the operator is in or not_in, the value should be a comma separated string. + type: 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_site_anp_epg +extends_documentation_fragment: cisco.mso.modules +''' + +EXAMPLES = r''' +- name: Add a selector to a site EPG + cisco.mso.mso_schema_site_anp_epg_selector: + host: mso_host + username: admin + password: SomeSecretPassword + schema: Schema 1 + site: Site 1 + template: Template 1 + anp: ANP 1 + epg: EPG 1 + selector: selector_1 + expressions: + - type: expression_1 + 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: + host: mso_host + username: admin + password: SomeSecretPassword + schema: Schema 1 + site: Site 1 + template: Template 1 + anp: ANP 1 + epg: EPG 1 + selector: selector_1 + state: absent + delegate_to: localhost + +- name: Query a specific Selector + cisco.mso.mso_schema_site_anp_epg_selector: + host: mso_host + username: admin + password: SomeSecretPassword + schema: Schema 1 + site: Site 1 + template: Template 1 + anp: ANP 1 + epg: EPG 1 + selector: selector_1 + state: query + delegate_to: localhost + register: query_result + +- name: Query all Selectors + cisco.mso.mso_schema_site_anp_epg_selector: + host: mso_host + username: admin + password: SomeSecretPassword + schema: Schema 1 + site: Site 1 + template: Template 1 + anp: ANP 1 + epg: EPG 1 + 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_expression_spec + +EXPRESSION_KEYS = { + 'ip_address': 'ipAddress', + 'region': 'region', + 'zone': 'zone', +} + +EXPRESSION_OPERATORS = { + 'not_in': 'notIn', + 'not_equals': 'notEquals', + 'has_key': 'keyExist', + 'does_not_have_key': 'keyNotExist', + 'in': 'in', + 'equals': 'equals', +} + + +def main(): + argument_spec = mso_argument_spec() + argument_spec.update( + schema=dict(type='str', required=True), + site=dict(type='str', required=True), + template=dict(type='str', required=True), + anp=dict(type='str', required=True), + epg=dict(type='str', required=True), + selector=dict(type='str'), + expressions=dict(type='list', elements='dict', options=mso_expression_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', ['selector']], + ['state', 'present', ['selector']], + ], + ) + + schema = module.params.get('schema') + site = module.params.get('site') + template = module.params.get('template').replace(' ', '') + anp = module.params.get('anp') + epg = module.params.get('epg') + selector = module.params.get('selector') + expressions = module.params.get('expressions') + state = module.params.get('state') + + mso = MSOModule(module) + + # Get schema_id + schema_obj = mso.get_obj('schemas', displayName=schema) + if not schema_obj: + mso.fail_json(msg="Provided schema '{0}' does not exist".format(schema)) + schema_path = 'schemas/{id}'.format(**schema_obj) + schema_id = schema_obj.get('id') + + # 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 cloud type + site_type = mso.get_obj('sites', name=site).get("cloudProviders")[0] + + # Get site_idx + if 'sites' not in schema_obj: + 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')] + if (site_id, template) not in sites: + mso.fail_json(msg="Provided site-template association '{0}-{1}' does not exist.".format(site, template)) + + # 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) + + 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_in_temp))) + else: + # Get 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: + # Get anp index at site level + anp_idx = anps.index(anp_ref) + + # Get EPG + epg_ref = mso.epg_ref(schema_id=schema_id, template=template, anp=anp, epg=epg) + + # 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']] + + # 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 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}".format(epg, ', '.join(epgs_in_temp))) + + # EPG at template level but not at site level. Create payload at site level for EPG + else: + + new_epg = dict( + epgRef=dict( + schemaId=schema_id, + templateName=template, + anpName=anp, + epgName=epg, + ) + ) + + # 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 + else: + # If anp in payload, anp exists at site level. Update payload with EPG payload + payload['epgs'] = [new_epg] + + # Get index of EPG at site level + else: + epg_idx = epgs.index(epg_ref) + + # Get selectors + # If anp at site level and epg is at site level + if 'anpRef' not in payload and 'epgRef' not in payload: + if selector and " " in selector: + mso.fail_json(msg="There should not be any space in selector name.") + selectors = [s.get('name') for s in schema_obj.get('sites')[site_idx]['anps'][anp_idx]['epgs'][epg_idx]['selectors']] + if selector in selectors: + selector_idx = selectors.index(selector) + selector_path = '/sites/{0}/anps/{1}/epgs/{2}/selectors/{3}'.format(site_template, anp, epg, selector_idx) + mso.existing = schema_obj['sites'][site_idx]['anps'][anp_idx]['epgs'][epg_idx]['selectors'][selector_idx] + + if state == 'query': + if 'anpRef' in payload: + mso.fail_json(msg="Anp '{anp}' does not exist in site level.".format(anp=anp)) + if 'epgRef' in payload: + mso.fail_json(msg="Epg '{epg}' does not exist in site level.".format(epg=epg)) + if selector is None: + mso.existing = schema_obj['sites'][site_idx]['anps'][anp_idx]['epgs'][epg_idx]['selectors'] + elif not mso.existing: + mso.fail_json(msg="Selector '{selector}' not found".format(selector=selector)) + mso.exit_json() + + mso.previous = mso.existing + if state == 'absent': + if mso.existing: + mso.sent = mso.existing = {} + ops.append(dict(op='remove', path=selector_path)) + elif state == 'present': + # Get expressions + all_expressions = [] + if expressions: + for expression in expressions: + type = expression.get('type') + operator = expression.get('operator') + value = expression.get('value') + if " " in type: + mso.fail_json(msg="There should not be any space in 'type' attribute of expression '{0}'".format(type)) + if operator in ["has_key", "does_not_have_key"] and value: + mso.fail_json( + msg="Attribute 'value' is not supported for operator '{0}' in expression '{1}'".format(operator, type)) + if operator in ["not_in", "in", "equals", "not_equals"] and not value: + mso.fail_json( + msg="Attribute 'value' needed for operator '{0}' in expression '{1}'".format(operator, type)) + if type in ["region", "zone", "ip_address"]: + if type == "zone" and site_type != "aws": + mso.fail_json(msg="Type 'zone' is only supported for aws") + if operator in ["has_key", "does_not_have_key"]: + mso.fail_json(msg="Operator '{0}' is not supported when expression type is '{1}'".format(operator, type)) + type = EXPRESSION_KEYS.get(type) + else: + type = 'Custom:' + type + all_expressions.append(dict( + key=type, + operator=EXPRESSION_OPERATORS.get(operator), + value=value, + )) + new_selector = dict( + name=selector, + expressions=all_expressions, + ) + + selectors_path = '/sites/{0}/anps/{1}/epgs/{2}/selectors/-'.format(site_template, anp, epg) + + # if payload is empty, anp and epg already exist at site level + if not payload: + op_path = selectors_path + payload = new_selector + # if payload exist + else: + # if anp already exists at site level + if 'anpRef' not in payload: + payload['selectors'] = [new_selector] + else: + payload['epgs'][0]['selectors'] = [new_selector] + + mso.sanitize(payload, collate=True) + + if mso.existing: + ops.append(dict(op='replace', path=selector_path, value=mso.sent)) + else: + ops.append(dict(op='add', path=op_path, value=mso.sent)) + + mso.existing = new_selector + + if not module.check_mode and mso.existing != mso.previous: + mso.request(schema_path, method='PATCH', data=ops) + + mso.exit_json() + + +if __name__ == "__main__": + main() diff --git a/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_anp_epg_staticleaf.py b/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_anp_epg_staticleaf.py new file mode 100644 index 00000000..224af40d --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_anp_epg_staticleaf.py @@ -0,0 +1,264 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright: (c) 2019, Dag Wieers (@dagwieers) +# 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_anp_epg_staticleaf +short_description: Manage site-local EPG static leafs in schema template +description: +- Manage site-local EPG static leafs in schema template on Cisco ACI Multi-Site. +author: +- Dag Wieers (@dagwieers) +options: + schema: + description: + - The name of the schema. + type: str + required: yes + site: + description: + - The name of the site. + type: str + required: yes + template: + description: + - The name of the template. + type: str + required: yes + anp: + description: + - The name of the ANP. + type: str + required: yes + epg: + description: + - The name of the EPG. + type: str + required: yes + pod: + description: + - The pod of the static leaf. + type: str + leaf: + description: + - The path of the static leaf. + type: str + aliases: [ name ] + vlan: + description: + - The VLAN id of the static leaf. + type: int + 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 +notes: +- The ACI MultiSite PATCH API has a deficiency requiring some objects to be referenced by index. + This can cause silent corruption on concurrent access when changing/removing on object as + the wrong object may be referenced. This module is affected by this deficiency. +seealso: +- module: cisco.mso.mso_schema_site_anp_epg +- module: cisco.mso.mso_schema_template_anp_epg +extends_documentation_fragment: cisco.mso.modules +''' + +EXAMPLES = r''' +- name: Add a new static leaf to a site EPG + cisco.mso.mso_schema_site_anp_epg_staticleaf: + host: mso_host + username: admin + password: SomeSecretPassword + schema: Schema1 + site: Site1 + template: Template1 + anp: ANP1 + epg: EPG1 + 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: + host: mso_host + username: admin + password: SomeSecretPassword + schema: Schema1 + site: Site1 + template: Template1 + anp: ANP1 + 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: + host: mso_host + username: admin + password: SomeSecretPassword + schema: Schema1 + site: Site1 + template: Template1 + anp: ANP1 + epg: EPG1 + leaf: Leaf1 + state: query + delegate_to: localhost + register: query_result + +- name: Query all site EPG static leafs + cisco.mso.mso_schema_site_anp_epg_staticleaf: + host: mso_host + username: admin + password: SomeSecretPassword + schema: Schema1 + site: Site1 + template: Template1 + anp: ANP1 + 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 + + +def main(): + argument_spec = mso_argument_spec() + argument_spec.update( + schema=dict(type='str', required=True), + site=dict(type='str', required=True), + template=dict(type='str', required=True), + anp=dict(type='str', required=True), + epg=dict(type='str', required=True), + pod=dict(type='str'), # This parameter is not required for querying all objects + leaf=dict(type='str', aliases=['name']), + vlan=dict(type='int'), + state=dict(type='str', default='present', choices=['absent', 'present', 'query']), + ) + + module = AnsibleModule( + argument_spec=argument_spec, + supports_check_mode=True, + required_if=[ + ['state', 'absent', ['pod', 'leaf', 'vlan']], + ['state', 'present', ['pod', 'leaf', 'vlan']], + ], + ) + + schema = module.params.get('schema') + site = module.params.get('site') + template = module.params.get('template').replace(' ', '') + anp = module.params.get('anp') + epg = module.params.get('epg') + pod = module.params.get('pod') + leaf = module.params.get('leaf') + vlan = module.params.get('vlan') + state = module.params.get('state') + + leafpath = 'topology/{0}/node-{1}'.format(pod, leaf) + + mso = MSOModule(module) + + # Get schema_id + schema_obj = mso.get_obj('schemas', displayName=schema) + if not schema_obj: + mso.fail_json(msg="Provided schema '{0}' does not exist".format(schema)) + + schema_path = 'schemas/{id}'.format(**schema_obj) + schema_id = schema_obj.get('id') + + # Get site + site_id = mso.lookup_site(site) + + # Get site_idx + if 'sites' not in schema_obj: + 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')] + if (site_id, template) not in sites: + mso.fail_json(msg="Provided site/template '{0}-{1}' does not exist. Existing sites/templates: {2}".format(site, template, ', '.join(sites))) + + # 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) + + # Get ANP + anp_ref = mso.anp_ref(schema_id=schema_id, template=template, anp=anp) + anps = [a.get('anpRef') for a in schema_obj.get('sites')[site_idx]['anps']] + if anp_ref 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_ref) + + # Get EPG + epg_ref = mso.epg_ref(schema_id=schema_id, template=template, anp=anp, epg=epg) + epgs = [e.get('epgRef') for e in schema_obj.get('sites')[site_idx]['anps'][anp_idx]['epgs']] + if epg_ref not in epgs: + mso.fail_json(msg="Provided epg '{0}' does not exist. Existing epgs: {1}".format(epg, ', '.join(epgs))) + epg_idx = epgs.index(epg_ref) + + # Get Leaf + leafs = [(leaf.get('path'), leaf.get('portEncapVlan')) for leaf in schema_obj.get('sites')[site_idx]['anps'][anp_idx]['epgs'][epg_idx]['staticLeafs']] + if (leafpath, vlan) in leafs: + leaf_idx = leafs.index((leafpath, vlan)) + # FIXME: Changes based on index are DANGEROUS + leaf_path = '/sites/{0}/anps/{1}/epgs/{2}/staticLeafs/{3}'.format(site_template, anp, epg, leaf_idx) + mso.existing = schema_obj.get('sites')[site_idx]['anps'][anp_idx]['epgs'][epg_idx]['staticLeafs'][leaf_idx] + + 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]['staticLeafs'] + elif not mso.existing: + mso.fail_json(msg="Static leaf '{leaf}/{vlan}' not found".format(leaf=leaf, vlan=vlan)) + mso.exit_json() + + leafs_path = '/sites/{0}/anps/{1}/epgs/{2}/staticLeafs'.format(site_template, anp, epg) + ops = [] + + mso.previous = mso.existing + if state == 'absent': + if mso.existing: + mso.sent = mso.existing = {} + ops.append(dict(op='remove', path=leaf_path)) + + elif state == 'present': + payload = dict( + path=leafpath, + portEncapVlan=vlan, + ) + + mso.sanitize(payload, collate=True) + + if mso.existing: + ops.append(dict(op='replace', path=leaf_path, value=mso.sent)) + else: + ops.append(dict(op='add', path=leafs_path + '/-', value=mso.sent)) + + mso.existing = mso.proposed + + if not module.check_mode: + mso.request(schema_path, method='PATCH', data=ops) + + mso.exit_json() + + +if __name__ == "__main__": + main() diff --git a/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_anp_epg_staticport.py b/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_anp_epg_staticport.py new file mode 100644 index 00000000..89485df8 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_anp_epg_staticport.py @@ -0,0 +1,448 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright: (c) 2019, Dag Wieers (@dagwieers) +# 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_anp_epg_staticport +short_description: Manage site-local EPG static ports in schema template +description: +- Manage site-local EPG static ports in schema template on Cisco ACI Multi-Site. +author: +- Dag Wieers (@dagwieers) +options: + schema: + description: + - The name of the schema. + type: str + required: yes + site: + description: + - The name of the site. + type: str + required: yes + template: + description: + - The name of the template. + type: str + required: yes + anp: + description: + - The name of the ANP. + type: str + required: yes + epg: + description: + - The name of the EPG. + type: str + required: yes + 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 + type: str + choices: [ port, vpc, dpc ] + default: port + 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 encap 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 ] + default: 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 ] + default: 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. + - Use C(query) for listing an object or multiple objects. + type: str + choices: [ absent, present, query ] + default: present +notes: +- The ACI MultiSite PATCH API has a deficiency requiring some objects to be referenced by index. + This can cause silent corruption on concurrent access when changing/removing an object as + the wrong object may be referenced. This module is affected by this deficiency. +seealso: +- module: cisco.mso.mso_schema_site_anp_epg +- module: cisco.mso.mso_schema_template_anp_epg +extends_documentation_fragment: cisco.mso.modules +''' + +EXAMPLES = r''' +- name: Add a new static port to 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 + 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: + host: mso_host + username: admin + password: SomeSecretPassword + schema: Schema1 + site: Site1 + template: Template1 + anp: ANP1 + epg: EPG1 + type: port + pod: pod-1 + leaf: 101 + fex: 151 + path: eth1/1 + 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: + host: mso_host + username: admin + password: SomeSecretPassword + schema: Schema1 + site: Site1 + template: Template1 + anp: ANP1 + epg: EPG1 + pod: pod-1 + leaf: 101-102 + path: ansible_polgrp + vlan: 127 + type: vpc + mode: untagged + deployment_immediacy: lazy + state: present + delegate_to: localhost + +- 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 + delegate_to: localhost + +- name: Query a specific site EPG static port + 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: query + delegate_to: localhost + register: query_result + +- name: Query all site EPG 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 + 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 + + +def main(): + argument_spec = mso_argument_spec() + argument_spec.update( + schema=dict(type='str', required=True), + site=dict(type='str', required=True), + template=dict(type='str', required=True), + anp=dict(type='str', required=True), + epg=dict(type='str', required=True), + 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 + deployment_immediacy=dict(type='str', default='lazy', choices=['immediate', 'lazy']), + mode=dict(type='str', default='untagged', choices=['native', 'regular', 'untagged']), + 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') + site = module.params.get('site') + template = module.params.get('template').replace(' ', '') + anp = module.params.get('anp') + epg = module.params.get('epg') + path_type = module.params.get('type') + pod = module.params.get('pod') + leaf = module.params.get('leaf') + fex = module.params.get('fex') + path = module.params.get('path') + vlan = module.params.get('vlan') + primary_micro_segment_vlan = module.params.get('primary_micro_segment_vlan') + deployment_immediacy = module.params.get('deployment_immediacy') + mode = module.params.get('mode') + 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) + + mso = MSOModule(module) + + # Get schema_id + schema_obj = mso.get_obj('schemas', displayName=schema) + if not schema_obj: + mso.fail_json(msg="Provided schema '{0}' does not exist".format(schema)) + schema_path = 'schemas/{id}'.format(**schema_obj) + schema_id = schema_obj.get('id') + + # 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 'sites' not in schema_obj: + 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) + + 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) + + # Get EPG + epg_ref = mso.epg_ref(schema_id=schema_id, template=template, anp=anp, epg=epg) + + # 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']] + + # 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 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)) + + # EPG at template level but not at site level. Create payload at site level for EPG + else: + + new_epg = dict( + epgRef=dict( + schemaId=schema_id, + templateName=template, + anpName=anp, + epgName=epg, + ) + ) + + # 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 + else: + # If anp in payload, anp exists at site level. Update payload with EPG payload + payload['epgs'] = [new_epg] + + # Update index of EPG at site level + else: + epg_idx = epgs.index(epg_ref) + + # 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 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() + + ports_path = '/sites/{0}/anps/{1}/epgs/{2}/staticPorts'.format(site_template, anp, epg) + ops = [] + new_leaf = dict( + deploymentImmediacy=deployment_immediacy, + mode=mode, + path=portpath, + portEncapVlan=vlan, + type=path_type, + microSegVlan=primary_micro_segment_vlan, + ) + + # 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 + 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() + + +if __name__ == "__main__": + main() diff --git a/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_anp_epg_subnet.py b/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_anp_epg_subnet.py new file mode 100644 index 00000000..efc97c1e --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_anp_epg_subnet.py @@ -0,0 +1,293 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright: (c) 2019, Dag Wieers (@dagwieers) +# 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_anp_epg_subnet +short_description: Manage site-local EPG subnets in schema template +description: +- Manage site-local EPG subnets in schema template on Cisco ACI Multi-Site. +author: +- Dag Wieers (@dagwieers) +options: + schema: + description: + - The name of the schema. + type: str + required: yes + site: + description: + - The name of the site. + type: str + required: yes + template: + description: + - The name of the template. + type: str + required: yes + anp: + description: + - The name of the ANP. + type: str + required: yes + epg: + description: + - The name of the EPG. + type: str + required: yes + subnet: + description: + - The IP range in CIDR notation. + type: str + required: true + aliases: [ ip ] + description: + description: + - The description of this subnet. + type: str + scope: + description: + - The scope of the subnet. + type: str + default: private + choices: [ private, public ] + shared: + description: + - Whether this subnet is shared between VRFs. + type: bool + no_default_gateway: + description: + - Whether this subnet has a default gateway. + type: bool + querier: + description: + - Whether this subnet is an IGMP querier. + type: bool + 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 +notes: +- The ACI MultiSite PATCH API has a deficiency requiring some objects to be referenced by index. + This can cause silent corruption on concurrent access when changing/removing on object as + the wrong object may be referenced. This module is affected by this deficiency. +seealso: +- module: cisco.mso.mso_schema_site_anp_epg +- module: cisco.mso.mso_schema_template_anp_epg_subnet +extends_documentation_fragment: cisco.mso.modules +''' + +EXAMPLES = r''' +- name: Add a new subnet to a site EPG + cisco.mso.mso_schema_site_anp_epg_subnet: + host: mso_host + username: admin + password: SomeSecretPassword + schema: Schema1 + site: Site1 + template: Template1 + anp: ANP1 + 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: + host: mso_host + username: admin + password: SomeSecretPassword + schema: Schema1 + site: Site1 + template: Template1 + anp: ANP1 + 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: + host: mso_host + username: admin + password: SomeSecretPassword + schema: Schema1 + site: Site1 + template: Template1 + anp: ANP1 + epg: EPG1 + subnet: 10.0.0.0/24 + state: query + delegate_to: localhost + register: query_result + +- name: Query all site EPG subnets + cisco.mso.mso_schema_site_anp_epg_subnet: + host: mso_host + username: admin + password: SomeSecretPassword + schema: Schema1 + site: Site1 + template: Template1 + anp: ANP1 + 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_subnet_spec + + +def main(): + argument_spec = mso_argument_spec() + argument_spec.update( + schema=dict(type='str', required=True), + site=dict(type='str', required=True), + template=dict(type='str', required=True), + anp=dict(type='str', required=True), + epg=dict(type='str', required=True), + state=dict(type='str', default='present', choices=['absent', 'present', 'query']), + ) + argument_spec.update(mso_subnet_spec()) + + module = AnsibleModule( + argument_spec=argument_spec, + supports_check_mode=True, + required_if=[ + ['state', 'absent', ['subnet']], + ['state', 'present', ['subnet']], + ], + ) + + schema = module.params.get('schema') + site = module.params.get('site') + template = module.params.get('template').replace(' ', '') + anp = module.params.get('anp') + epg = module.params.get('epg') + subnet = module.params.get('subnet') + description = module.params.get('description') + scope = module.params.get('scope') + shared = module.params.get('shared') + no_default_gateway = module.params.get('no_default_gateway') + querier = module.params.get('querier') + state = module.params.get('state') + + mso = MSOModule(module) + + # Get schema_id + schema_obj = mso.get_obj('schemas', displayName=schema) + if not schema_obj: + mso.fail_json(msg="Provided schema '{0}' does not exist".format(schema)) + + schema_path = 'schemas/{id}'.format(**schema_obj) + schema_id = schema_obj.get('id') + + # Get site + site_id = mso.lookup_site(site) + + # Get site_idx + if 'sites' not in schema_obj: + 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')] + if (site_id, template) not in sites: + mso.fail_json(msg="Provided site/template '{0}-{1}' does not exist. Existing sites/templates: {2}".format(site, template, ', '.join(sites))) + + # 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) + + # Get ANP + anp_ref = mso.anp_ref(schema_id=schema_id, template=template, anp=anp) + anps = [a.get('anpRef') for a in schema_obj.get('sites')[site_idx]['anps']] + if anp_ref 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_ref) + + # Get EPG + epg_ref = mso.epg_ref(schema_id=schema_id, template=template, anp=anp, epg=epg) + epgs = [e.get('epgRef') for e in schema_obj.get('sites')[site_idx]['anps'][anp_idx]['epgs']] + if epg_ref not in epgs: + mso.fail_json(msg="Provided epg '{0}' does not exist. Existing epgs: {1}".format(epg, ', '.join(epgs))) + epg_idx = epgs.index(epg_ref) + + # Get Subnet + subnets = [s.get('ip') for s in schema_obj.get('sites')[site_idx]['anps'][anp_idx]['epgs'][epg_idx]['subnets']] + if subnet in subnets: + subnet_idx = subnets.index(subnet) + # FIXME: Changes based on index are DANGEROUS + subnet_path = '/sites/{0}/anps/{1}/epgs/{2}/subnets/{3}'.format(site_template, anp, epg, subnet_idx) + mso.existing = schema_obj.get('sites')[site_idx]['anps'][anp_idx]['epgs'][epg_idx]['subnets'][subnet_idx] + + if state == 'query': + if subnet is None: + mso.existing = schema_obj.get('sites')[site_idx]['anps'][anp_idx]['epgs'][epg_idx]['subnets'] + elif not mso.existing: + mso.fail_json(msg="Subnet '{subnet}' not found".format(subnet=subnet)) + mso.exit_json() + + subnets_path = '/sites/{0}/anps/{1}/epgs/{2}/subnets'.format(site_template, anp, epg) + ops = [] + + mso.previous = mso.existing + if state == 'absent': + if mso.existing: + mso.sent = mso.existing = {} + ops.append(dict(op='remove', path=subnet_path)) + + elif state == 'present': + if not mso.existing: + if description is None: + description = subnet + if scope is None: + scope = 'private' + if shared is None: + shared = False + if no_default_gateway is None: + no_default_gateway = False + if querier is None: + querier = False + + payload = dict( + ip=subnet, + description=description, + scope=scope, + shared=shared, + noDefaultGateway=no_default_gateway, + querier=querier, + ) + + mso.sanitize(payload, collate=True) + + if mso.existing: + ops.append(dict(op='replace', path=subnet_path, value=mso.sent)) + else: + ops.append(dict(op='add', path=subnets_path + '/-', value=mso.sent)) + + mso.existing = mso.proposed + + if not module.check_mode: + mso.request(schema_path, method='PATCH', data=ops) + + mso.exit_json() + + +if __name__ == "__main__": + main() diff --git a/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_bd.py b/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_bd.py new file mode 100644 index 00000000..538e268b --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_bd.py @@ -0,0 +1,242 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright: (c) 2019, Dag Wieers (@dagwieers) +# 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_bd +short_description: Manage site-local Bridge Domains (BDs) in schema template +description: +- Manage site-local BDs in schema template on Cisco ACI Multi-Site. +author: +- Dag Wieers (@dagwieers) +options: + schema: + description: + - The name of the schema. + type: str + required: yes + site: + description: + - The name of the site. + type: str + required: yes + template: + description: + - The name of the template. + type: str + required: yes + bd: + description: + - The name of the BD to manage. + type: str + aliases: [ name ] + host_route: + description: + - Whether host-based routing is enabled. + type: bool + svi_mac: + description: + - SVI MAC Address + type: 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_site +- module: cisco.mso.mso_schema_site_bd_l3out +- module: cisco.mso.mso_schema_site_bd_subnet +- module: cisco.mso.mso_schema_template_bd +extends_documentation_fragment: cisco.mso.modules +''' + +EXAMPLES = r''' +- name: Add a new site BD + cisco.mso.mso_schema_site_bd: + host: mso_host + username: admin + password: SomeSecretPassword + schema: Schema1 + site: Site1 + template: Template1 + bd: BD1 + state: present + delegate_to: localhost + +- name: Remove a site BD + cisco.mso.mso_schema_site_bd: + host: mso_host + username: admin + password: SomeSecretPassword + schema: Schema1 + site: Site1 + template: Template1 + bd: BD1 + state: absent + delegate_to: localhost + +- name: Query a specific site BD + cisco.mso.mso_schema_site_bd: + host: mso_host + username: admin + password: SomeSecretPassword + schema: Schema1 + site: Site1 + template: Template1 + bd: BD1 + state: query + delegate_to: localhost + register: query_result + +- name: Query all site BDs + cisco.mso.mso_schema_site_bd: + host: mso_host + username: admin + password: SomeSecretPassword + schema: Schema1 + site: Site1 + template: Template1 + 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 + + +def main(): + argument_spec = mso_argument_spec() + argument_spec.update( + schema=dict(type='str', required=True), + site=dict(type='str', required=True), + template=dict(type='str', required=True), + bd=dict(type='str', aliases=['name']), # This parameter is not required for querying all objects + host_route=dict(type='bool'), + svi_mac=dict(type='str'), + state=dict(type='str', default='present', choices=['absent', 'present', 'query']), + ) + + module = AnsibleModule( + argument_spec=argument_spec, + supports_check_mode=True, + required_if=[ + ['state', 'absent', ['bd']], + ['state', 'present', ['bd']], + ], + ) + + schema = module.params.get('schema') + site = module.params.get('site') + template = module.params.get('template').replace(' ', '') + bd = module.params.get('bd') + host_route = module.params.get('host_route') + svi_mac = module.params.get('svi_mac') + state = module.params.get('state') + + mso = MSOModule(module) + + # Get schema_id + schema_obj = mso.get_obj('schemas', displayName=schema) + if not schema_obj: + mso.fail_json(msg="Provided schema '{0}' does not exist".format(schema)) + + schema_path = 'schemas/{id}'.format(**schema_obj) + schema_id = schema_obj.get('id') + + # 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))) + + # Get site + site_id = mso.lookup_site(site) + + # Get site_idx + if 'sites' not in schema_obj: + 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')] + if (site_id, template) not in sites: + mso.fail_json(msg="Provided site-template association '{0}-{1}' does not exist.".format(site, template)) + + # 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) + + # Get BD + bd_ref = mso.bd_ref(schema_id=schema_id, template=template, bd=bd) + bds = [v.get('bdRef') for v in schema_obj.get('sites')[site_idx]['bds']] + if bd is not None and bd_ref in bds: + bd_idx = bds.index(bd_ref) + bd_path = '/sites/{0}/bds/{1}'.format(site_template, bd) + mso.existing = schema_obj.get('sites')[site_idx]['bds'][bd_idx] + mso.existing['bdRef'] = mso.dict_from_ref(mso.existing.get('bdRef')) + + if state == 'query': + if bd is None: + mso.existing = schema_obj.get('sites')[site_idx]['bds'] + for bd in mso.existing: + bd['bdRef'] = mso.dict_from_ref(bd.get('bdRef')) + elif not mso.existing: + mso.fail_json(msg="BD '{bd}' not found".format(bd=bd)) + mso.exit_json() + + bds_path = '/sites/{0}/bds'.format(site_template) + ops = [] + + mso.previous = mso.existing + if state == 'absent': + if mso.existing: + mso.sent = mso.existing = {} + ops.append(dict(op='remove', path=bd_path)) + + elif state == 'present': + if not mso.existing: + if host_route is None: + host_route = False + + payload = dict( + bdRef=dict( + schemaId=schema_id, + templateName=template, + bdName=bd, + ), + hostBasedRouting=host_route, + ) + if svi_mac is not None: + payload.update(mac=svi_mac) + + mso.sanitize(payload, collate=True) + + if mso.existing: + ops.append(dict(op='replace', path=bd_path, value=mso.sent)) + else: + ops.append(dict(op='add', path=bds_path + '/-', value=mso.sent)) + + mso.existing = mso.proposed + + if not module.check_mode and mso.existing != mso.previous: + mso.request(schema_path, method='PATCH', data=ops) + + mso.exit_json() + + +if __name__ == "__main__": + main() diff --git a/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_bd_l3out.py b/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_bd_l3out.py new file mode 100644 index 00000000..2a85860f --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_bd_l3out.py @@ -0,0 +1,224 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright: (c) 2019, Dag Wieers (@dagwieers) +# 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_bd_l3out +short_description: Manage site-local BD l3out's in schema template +description: +- Manage site-local BDs l3out's in schema template on Cisco ACI Multi-Site. +author: +- Dag Wieers (@dagwieers) +options: + schema: + description: + - The name of the schema. + type: str + required: yes + site: + description: + - The name of the site. + type: str + required: yes + template: + description: + - The name of the template. + type: str + required: yes + bd: + description: + - The name of the BD. + type: str + required: yes + aliases: [ name ] + l3out: + description: + - The name of the l3out. + type: 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 +notes: +- The ACI MultiSite PATCH API has a deficiency requiring some objects to be referenced by index. + This can cause silent corruption on concurrent access when changing/removing on object as + the wrong object may be referenced. This module is affected by this deficiency. +seealso: +- module: cisco.mso.mso_schema_site_bd +- module: cisco.mso.mso_schema_template_bd +extends_documentation_fragment: cisco.mso.modules +''' + +EXAMPLES = r''' +- name: Add a new site BD l3out + cisco.mso.mso_schema_site_bd_l3out: + host: mso_host + username: admin + password: SomeSecretPassword + schema: Schema1 + site: Site1 + template: Template1 + bd: BD1 + l3out: L3out1 + state: present + delegate_to: localhost + +- name: Remove a site BD l3out + cisco.mso.mso_schema_site_bd_l3out: + host: mso_host + username: admin + password: SomeSecretPassword + schema: Schema1 + site: Site1 + template: Template1 + bd: BD1 + l3out: L3out1 + state: absent + delegate_to: localhost + +- name: Query a specific site BD l3out + cisco.mso.mso_schema_site_bd_l3out: + host: mso_host + username: admin + password: SomeSecretPassword + schema: Schema1 + site: Site1 + template: Template1 + bd: BD1 + l3out: L3out1 + state: query + delegate_to: localhost + register: query_result + +- name: Query all site BD l3outs + cisco.mso.mso_schema_site_bd_l3out: + host: mso_host + username: admin + password: SomeSecretPassword + schema: Schema1 + site: Site1 + template: Template1 + bd: BD1 + 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 + + +def main(): + argument_spec = mso_argument_spec() + argument_spec.update( + schema=dict(type='str', required=True), + site=dict(type='str', required=True), + template=dict(type='str', required=True), + bd=dict(type='str', required=True), + l3out=dict(type='str', aliases=['name']), # This parameter is not required for querying all objects + state=dict(type='str', default='present', choices=['absent', 'present', 'query']), + ) + + module = AnsibleModule( + argument_spec=argument_spec, + supports_check_mode=True, + required_if=[ + ['state', 'absent', ['l3out']], + ['state', 'present', ['l3out']], + ], + ) + + schema = module.params.get('schema') + site = module.params.get('site') + template = module.params.get('template').replace(' ', '') + bd = module.params.get('bd') + l3out = module.params.get('l3out') + state = module.params.get('state') + + mso = MSOModule(module) + + # Get schema_id + schema_obj = mso.get_obj('schemas', displayName=schema) + if not schema_obj: + mso.fail_json(msg="Provided schema '{0}' does not exist".format(schema)) + + schema_path = 'schemas/{id}'.format(**schema_obj) + schema_id = schema_obj.get('id') + + # Get site + site_id = mso.lookup_site(site) + + # Get site_idx + if 'sites' not in schema_obj: + 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')] + if (site_id, template) not in sites: + mso.fail_json(msg="Provided site/template '{0}-{1}' does not exist. Existing sites/templates: {2}".format(site, template, ', '.join(sites))) + + # 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) + + # Get BD + bd_ref = mso.bd_ref(schema_id=schema_id, template=template, bd=bd) + bds = [v.get('bdRef') for v in schema_obj.get('sites')[site_idx]['bds']] + if bd_ref not in bds: + mso.fail_json(msg="Provided BD '{0}' does not exist. Existing BDs: {1}".format(bd, ', '.join(bds))) + bd_idx = bds.index(bd_ref) + + # Get L3out + l3outs = schema_obj.get('sites')[site_idx]['bds'][bd_idx]['l3Outs'] + if l3out is not None and l3out in l3outs: + l3out_idx = l3outs.index(l3out) + # FIXME: Changes based on index are DANGEROUS + l3out_path = '/sites/{0}/bds/{1}/l3Outs/{2}'.format(site_template, bd, l3out_idx) + mso.existing = schema_obj.get('sites')[site_idx]['bds'][bd_idx]['l3Outs'][l3out_idx] + + if state == 'query': + if l3out is None: + mso.existing = schema_obj.get('sites')[site_idx]['bds'][bd_idx]['l3Outs'] + elif not mso.existing: + mso.fail_json(msg="L3out '{l3out}' not found".format(l3out=l3out)) + mso.exit_json() + + l3outs_path = '/sites/{0}/bds/{1}/l3Outs'.format(site_template, bd) + ops = [] + + mso.previous = mso.existing + if state == 'absent': + if mso.existing: + mso.sent = mso.existing = {} + ops.append(dict(op='remove', path=l3out_path)) + + elif state == 'present': + mso.sent = l3out + if not mso.existing: + ops.append(dict(op='add', path=l3outs_path + '/-', value=l3out)) + + mso.existing = mso.sent + + if not module.check_mode: + mso.request(schema_path, method='PATCH', data=ops) + + mso.exit_json() + + +if __name__ == "__main__": + main() diff --git a/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_bd_subnet.py b/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_bd_subnet.py new file mode 100644 index 00000000..002c6d41 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_bd_subnet.py @@ -0,0 +1,301 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright: (c) 2019, Dag Wieers (@dagwieers) +# 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_bd_subnet +short_description: Manage site-local BD subnets in schema template +description: +- Manage site-local BD subnets in schema template on Cisco ACI Multi-Site. +author: +- Dag Wieers (@dagwieers) +options: + schema: + description: + - The name of the schema. + type: str + required: yes + site: + description: + - The name of the site. + type: str + required: yes + template: + description: + - The name of the template. + type: str + required: yes + bd: + description: + - The name of the BD. + type: str + required: true + aliases: [ name ] + subnet: + description: + - The IP range in CIDR notation. + type: str + aliases: [ ip ] + description: + description: + - The description of this subnet. + type: str + scope: + description: + - The scope of the subnet. + type: str + default: private + choices: [ private, public ] + shared: + description: + - Whether this subnet is shared between VRFs. + type: bool + no_default_gateway: + description: + - Whether this subnet has a default gateway. + type: bool + querier: + description: + - Whether this subnet is an IGMP querier. + type: bool + is_virtual_ip: + description: + - Treat as Virtual IP Address + type: bool + default: false + 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 +notes: +- The ACI MultiSite PATCH API has a deficiency requiring some objects to be referenced by index. + This can cause silent corruption on concurrent access when changing/removing on object as + the wrong object may be referenced. This module is affected by this deficiency. +seealso: +- module: cisco.mso.mso_schema_site_bd +- module: cisco.mso.mso_schema_template_bd +extends_documentation_fragment: cisco.mso.modules +''' + +EXAMPLES = r''' +- name: Add a new site BD subnet + cisco.mso.mso_schema_site_bd_subnet: + host: mso_host + username: admin + password: SomeSecretPassword + schema: Schema1 + site: Site1 + template: Template1 + 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: + host: mso_host + username: admin + password: SomeSecretPassword + schema: Schema1 + site: Site1 + template: Template1 + 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: + host: mso_host + username: admin + password: SomeSecretPassword + schema: Schema1 + site: Site1 + template: Template1 + bd: BD1 + subnet: 11.11.11.0/24 + state: query + delegate_to: localhost + register: query_result + +- name: Query all site BD subnets + cisco.mso.mso_schema_site_bd_subnet: + host: mso_host + username: admin + password: SomeSecretPassword + schema: Schema1 + site: Site1 + template: Template1 + bd: BD1 + 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_subnet_spec + + +def main(): + argument_spec = mso_argument_spec() + argument_spec.update(mso_subnet_spec()) + argument_spec.update( + schema=dict(type='str', required=True), + site=dict(type='str', required=True), + template=dict(type='str', required=True), + bd=dict(type='str', aliases=['name'], required=True), + subnet=dict(type='str', aliases=['ip']), + description=dict(type='str'), + scope=dict(type='str', default='private', choices=['private', 'public']), + shared=dict(type='bool', default=False), + no_default_gateway=dict(type='bool', default=False), + querier=dict(type='bool', default=False), + is_virtual_ip=dict(type='bool', default=False), + state=dict(type='str', default='present', choices=['absent', 'present', 'query']), + ) + + module = AnsibleModule( + argument_spec=argument_spec, + supports_check_mode=True, + required_if=[ + ['state', 'absent', ['subnet']], + ['state', 'present', ['subnet']], + ], + ) + + schema = module.params.get('schema') + site = module.params.get('site') + template = module.params.get('template').replace(' ', '') + bd = module.params.get('bd') + subnet = module.params.get('subnet') + description = module.params.get('description') + scope = module.params.get('scope') + shared = module.params.get('shared') + no_default_gateway = module.params.get('no_default_gateway') + querier = module.params.get('querier') + is_virtual_ip = module.params.get('is_virtual_ip') + state = module.params.get('state') + + mso = MSOModule(module) + + # Get schema_id + schema_obj = mso.get_obj('schemas', displayName=schema) + if not schema_obj: + mso.fail_json(msg="Provided schema '{0}' does not exist".format(schema)) + + schema_path = 'schemas/{id}'.format(**schema_obj) + schema_id = schema_obj.get('id') + + # 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 template BDs + template_bds = [b.get('name') for b in schema_obj.get('templates')[template_idx]['bds']] + + # Get template BD + if bd not in template_bds: + mso.fail_json(msg="Provided BD '{0}' does not exist. Existing template BDs: {1}".format(bd, ', '.join(template_bds))) + template_bd_idx = template_bds.index(bd) + template_bd = schema_obj.get('templates')[template_idx]['bds'][template_bd_idx] + if template_bd.get('l2Stretch') is True and state == 'present': + mso.fail_json( + 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" + ) + + # Get site + site_id = mso.lookup_site(site) + + # Get site_idx + if 'sites' not in schema_obj: + 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')] + if (site_id, template) not in sites: + mso.fail_json(msg="Provided site/template '{0}-{1}' does not exist.".format(site, template)) + + # 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) + + # Get BD + bd_ref = mso.bd_ref(schema_id=schema_id, template=template, bd=bd) + bds = [v.get('bdRef') for v in schema_obj.get('sites')[site_idx]['bds']] + if bd_ref not in bds: + mso.fail_json(msg="Provided BD '{0}' does not exist. Existing site BDs: {1}".format(bd, ', '.join(bds))) + bd_idx = bds.index(bd_ref) + + # Get Subnet + subnets = [s.get('ip') for s in schema_obj.get('sites')[site_idx]['bds'][bd_idx]['subnets']] + if subnet in subnets: + subnet_idx = subnets.index(subnet) + # FIXME: Changes based on index are DANGEROUS + subnet_path = '/sites/{0}/bds/{1}/subnets/{2}'.format(site_template, bd, subnet_idx) + mso.existing = schema_obj.get('sites')[site_idx]['bds'][bd_idx]['subnets'][subnet_idx] + + if state == 'query': + if subnet is None: + mso.existing = schema_obj.get('sites')[site_idx]['bds'][bd_idx]['subnets'] + elif not mso.existing: + mso.fail_json(msg="Subnet IP '{subnet}' not found".format(subnet=subnet)) + mso.exit_json() + + subnets_path = '/sites/{0}/bds/{1}/subnets'.format(site_template, bd) + ops = [] + + mso.previous = mso.existing + if state == 'absent': + if mso.existing: + mso.sent = mso.existing = {} + ops.append(dict(op='remove', path=subnet_path)) + + elif state == 'present': + if not mso.existing: + if description is None: + description = subnet + + payload = dict( + ip=subnet, + description=description, + scope=scope, + shared=shared, + noDefaultGateway=no_default_gateway, + virtual=is_virtual_ip, + querier=querier, + ) + + mso.sanitize(payload, collate=True) + + if mso.existing: + ops.append(dict(op='replace', path=subnet_path, value=mso.sent)) + else: + ops.append(dict(op='add', path=subnets_path + '/-', value=mso.sent)) + + mso.existing = mso.proposed + + if not module.check_mode: + mso.request(schema_path, method='PATCH', data=ops) + + mso.exit_json() + + +if __name__ == "__main__": + main() diff --git a/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_external_epg_selector.py b/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_external_epg_selector.py new file mode 100644 index 00000000..ad83c069 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_external_epg_selector.py @@ -0,0 +1,295 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright: (c) 2020, Shreyas Srish (@shrsr) +# 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_external_epg_selector +short_description: Manage External EPG selector in schema of cloud sites +description: +- Manage External EPG selector in schema of cloud sites on Cisco ACI Multi-Site. +author: +- Shreyas Srish (@shrsr) +options: + schema: + description: + - The name of the schema. + type: str + required: yes + template: + description: + - The name of the template to change. + type: str + required: yes + external_epg: + description: + - The name of the External EPG to be managed. + type: str + required: yes + site: + description: + - The name of the cloud site. + type: str + required: yes + selector: + description: + - The name of the selector. + type: str + expressions: + description: + - Expressions associated to this selector. + type: list + elements: dict + suboptions: + type: + description: + - The name of the expression which in this case is always IP address. + required: true + type: str + choices: [ ip_address ] + operator: + description: + - The operator associated with the expression which in this case is always equals. + required: true + type: str + choices: [ equals ] + value: + description: + - The value of the IP Address / Subnet associated with the expression. + required: true + type: 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_external_epg +extends_documentation_fragment: cisco.mso.modules +''' + +EXAMPLES = r''' +- name: Add a selector to an External EPG + cisco.mso.mso_schema_site_external_epg_selector: + host: mso_host + username: admin + password: SomeSecretPassword + schema: ansible_test + template: Template1 + site: azure_ansible_test + external_epg: ext1 + selector: test + expressions: + - type: ip_address + operator: equals + value: 10.0.0.0 + state: present + delegate_to: localhost + +- name: Remove a Selector + cisco.mso.mso_schema_site_external_epg_selector: + host: mso_host + username: admin + password: SomeSecretPassword + schema: ansible_test + template: Template1 + site: azure_ansible_test + external_epg: ext1 + selector: test + state: absent + delegate_to: localhost + +- name: Query a specific Selector + cisco.mso.mso_schema_site_external_epg_selector: + host: mso_host + username: admin + password: SomeSecretPassword + schema: ansible_test + template: Template1 + site: azure_ansible_test + external_epg: ext1 + selector: selector_1 + state: query + delegate_to: localhost + register: query_result + +- name: Query all Selectors + cisco.mso.mso_schema_site_external_epg_selector: + host: mso_host + username: admin + password: SomeSecretPassword + schema: ansible_test + template: Template1 + site: azure_ansible_test + external_epg: ext1 + 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_expression_spec_ext_epg + + +def main(): + argument_spec = mso_argument_spec() + argument_spec.update( + schema=dict(type='str', required=True), + template=dict(type='str', required=True), + site=dict(type='str', required=True), + external_epg=dict(type='str', required=True), + selector=dict(type='str'), + expressions=dict(type='list', elements='dict', options=mso_expression_spec_ext_epg()), + state=dict(type='str', default='present', choices=['absent', 'present', 'query']), + ) + + module = AnsibleModule( + argument_spec=argument_spec, + supports_check_mode=True, + ) + + schema = module.params.get('schema') + template = module.params.get('template').replace(' ', '') + site = module.params.get('site') + external_epg = module.params.get('external_epg') + selector = module.params.get('selector') + expressions = module.params.get('expressions') + state = module.params.get('state') + + mso = MSOModule(module) + + # Get schema_id + schema_obj = mso.get_obj('schemas', displayName=schema) + if not schema_obj: + mso.fail_json(msg="Provided schema '{0}' does not exist".format(schema)) + + schema_path = 'schemas/{id}'.format(**schema_obj) + schema_id = schema_obj.get('id') + + # Get template + templates = [t.get('name') for t in schema_obj.get('templates')] + if template not in templates: + mso.fail_json(msg="Provided template '{template}' does not exist. Existing templates: {templates}".format(template=template, + templates=', '.join(templates))) + + # Get site + site_id = mso.lookup_site(site) + + # Get site_idx + if 'sites' not in schema_obj: + 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) + + payload = dict() + op_path = '' + + # Get External EPG + ext_epg_ref = mso.ext_epg_ref(schema_id=schema_id, template=template, external_epg=external_epg) + external_epgs = [e.get('externalEpgRef') for e in schema_obj.get('sites')[site_idx]['externalEpgs']] + + if ext_epg_ref not in external_epgs: + op_path = '/sites/{0}/externalEpgs/-'.format(site_template) + payload = dict( + externalEpgRef=dict( + schemaId=schema_id, + templateName=template, + externalEpgName=external_epg, + ), + l3outDn='', + ) + + else: + external_epg_idx = external_epgs.index(ext_epg_ref) + + # Get Selector + selectors = [s.get('name') for s in schema_obj['sites'][site_idx]['externalEpgs'][external_epg_idx]['subnets']] + if selector in selectors: + selector_idx = selectors.index(selector) + selector_path = '/sites/{0}/externalEpgs/{1}/subnets/{2}'.format(site_template, external_epg, selector_idx) + mso.existing = schema_obj['sites'][site_idx]['externalEpgs'][external_epg_idx]['subnets'][selector_idx] + + selectors_path = '/sites/{0}/externalEpgs/{1}/subnets/-'.format(site_template, external_epg) + ops = [] + + if state == 'query': + if selector is None: + mso.existing = schema_obj['sites'][site_idx]['externalEpgs'][external_epg_idx]['subnets'] + elif not mso.existing: + mso.fail_json(msg="Selector '{selector}' not found".format(selector=selector)) + mso.exit_json() + + mso.previous = mso.existing + + if state == 'absent': + if mso.existing: + mso.sent = mso.existing = {} + ops.append(dict(op='remove', path=selector_path)) + + elif state == 'present': + # Get expressions + types = dict(ip_address='ipAddress') + all_expressions = [] + if expressions: + for expression in expressions: + type_val = expression.get('type') + operator = expression.get('operator') + value = expression.get('value') + all_expressions.append(dict( + key=types.get(type_val), + operator=operator, + value=value, + )) + else: + mso.fail_json(msg="Missing expressions in selector") + + subnets = dict( + name=selector, + ip=all_expressions[0]['value'] + ) + + if not external_epgs: + payload['subnets'] = [subnets] + else: + payload = subnets + op_path = selectors_path + + mso.sanitize(payload, collate=True) + + if mso.existing: + ops.append(dict(op='replace', path=selector_path, value=mso.sent)) + else: + ops.append(dict(op='add', path=op_path, value=mso.sent)) + + mso.existing = mso.proposed + + if not module.check_mode and mso.proposed != mso.previous: + mso.request(schema_path, method='PATCH', data=ops) + + mso.exit_json() + + +if __name__ == "__main__": + main() diff --git a/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_vrf.py b/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_vrf.py new file mode 100644 index 00000000..8846bc4c --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_vrf.py @@ -0,0 +1,213 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright: (c) 2019, Dag Wieers (@dagwieers) +# 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_vrf +short_description: Manage site-local VRFs in schema template +description: +- Manage site-local VRFs in schema template on Cisco ACI Multi-Site. +author: +- Dag Wieers (@dagwieers) +options: + schema: + description: + - The name of the schema. + type: str + required: yes + site: + description: + - The name of the site. + type: str + required: yes + template: + description: + - The name of the template. + type: str + required: yes + vrf: + description: + - The name of the VRF to manage. + type: str + aliases: [ name ] + 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_site +- module: cisco.mso.mso_schema_template_vrf +extends_documentation_fragment: cisco.mso.modules +''' + +EXAMPLES = r''' +- name: Add a new site VRF + cisco.mso.mso_schema_site_vrf: + host: mso_host + username: admin + password: SomeSecretPassword + schema: Schema1 + site: Site1 + template: Template1 + vrf: VRF1 + state: present + delegate_to: localhost + +- name: Remove a site VRF + cisco.mso.mso_schema_site_vrf: + host: mso_host + username: admin + password: SomeSecretPassword + schema: Schema1 + site: Site1 + template: Template1 + vrf: VRF1 + state: absent + delegate_to: localhost + +- name: Query a specific site VRF + cisco.mso.mso_schema_site_vrf: + host: mso_host + username: admin + password: SomeSecretPassword + schema: Schema1 + site: Site1 + template: Template1 + vrf: VRF1 + state: query + delegate_to: localhost + register: query_result + +- name: Query all site VRFs + cisco.mso.mso_schema_site_vrf: + host: mso_host + username: admin + password: SomeSecretPassword + schema: Schema1 + site: Site1 + template: Template1 + 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 + + +def main(): + argument_spec = mso_argument_spec() + argument_spec.update( + schema=dict(type='str', required=True), + site=dict(type='str', required=True), + template=dict(type='str', required=True), + vrf=dict(type='str', aliases=['name']), # This parameter is not required for querying all objects + state=dict(type='str', default='present', choices=['absent', 'present', 'query']), + ) + + module = AnsibleModule( + argument_spec=argument_spec, + supports_check_mode=True, + required_if=[ + ['state', 'absent', ['vrf']], + ['state', 'present', ['vrf']], + ], + ) + + schema = module.params.get('schema') + site = module.params.get('site') + template = module.params.get('template').replace(' ', '') + vrf = module.params.get('vrf') + state = module.params.get('state') + + mso = MSOModule(module) + + # Get schema_id + schema_obj = mso.get_obj('schemas', displayName=schema) + if not schema_obj: + mso.fail_json(msg="Provided schema '{0}' does not exist".format(schema)) + + schema_path = 'schemas/{id}'.format(**schema_obj) + schema_id = schema_obj.get('id') + + # Get site + site_id = mso.lookup_site(site) + + # Get site_idx + if 'sites' not in schema_obj: + 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')] + if (site_id, template) not in sites: + mso.fail_json(msg="Provided site/template '{0}-{1}' does not exist. Existing sites/templates: {2}".format(site, template, ', '.join(sites))) + + # 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) + + # Get VRF + vrf_ref = mso.vrf_ref(schema_id=schema_id, template=template, vrf=vrf) + vrfs = [v.get('vrfRef') for v in schema_obj.get('sites')[site_idx]['vrfs']] + if vrf is not None and vrf_ref in vrfs: + vrf_idx = vrfs.index(vrf_ref) + vrf_path = '/sites/{0}/vrfs/{1}'.format(site_template, vrf) + mso.existing = schema_obj.get('sites')[site_idx]['vrfs'][vrf_idx] + + if state == 'query': + if vrf is None: + mso.existing = schema_obj.get('sites')[site_idx]['vrfs'] + elif not mso.existing: + mso.fail_json(msg="VRF '{vrf}' not found".format(vrf=vrf)) + mso.exit_json() + + vrfs_path = '/sites/{0}/vrfs'.format(site_template) + ops = [] + + mso.previous = mso.existing + if state == 'absent': + if mso.existing: + mso.sent = mso.existing = {} + ops.append(dict(op='remove', path=vrf_path)) + + elif state == 'present': + payload = dict( + vrfRef=dict( + schemaId=schema_id, + templateName=template, + vrfName=vrf, + ), + ) + + mso.sanitize(payload, collate=True) + + if mso.existing: + ops.append(dict(op='replace', path=vrf_path, value=mso.sent)) + else: + ops.append(dict(op='add', path=vrfs_path + '/-', value=mso.sent)) + + mso.existing = mso.proposed + + if not module.check_mode: + mso.request(schema_path, method='PATCH', data=ops) + + mso.exit_json() + + +if __name__ == "__main__": + main() diff --git a/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_vrf_region.py b/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_vrf_region.py new file mode 100644 index 00000000..dc68a836 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_vrf_region.py @@ -0,0 +1,239 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright: (c) 2019, Dag Wieers (@dagwieers) +# 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_vrf_region +short_description: Manage site-local VRF regions in schema template +description: +- Manage site-local VRF regions in schema template on Cisco ACI Multi-Site. +author: +- Dag Wieers (@dagwieers) +options: + schema: + description: + - The name of the schema. + type: str + required: yes + site: + description: + - The name of the site. + type: str + required: yes + template: + description: + - The name of the template. + type: str + required: yes + vrf: + description: + - The name of the VRF. + type: str + required: yes + region: + description: + - The name of the region to manage. + type: str + aliases: [ name ] + vpn_gateway_router: + description: + - Whether VPN Gateway Router is enabled or not. + type: bool + 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 +notes: +- Due to restrictions of the MSO REST API, this module cannot create empty region (i.e. regions without cidrs) + Use the M(cisco.mso.mso_schema_site_vrf_region_cidr) to automatically create regions with cidrs. +seealso: +- module: cisco.mso.mso_schema_site_vrf +- module: cisco.mso.mso_schema_template_vrf +extends_documentation_fragment: cisco.mso.modules +''' + +EXAMPLES = r''' +- name: Remove VPN Gateway Router at site VRF Region + cisco.mso.mso_schema_site_vrf_region: + host: mso_host + username: admin + password: SomeSecretPassword + schema: Schema1 + site: Site1 + template: Template1 + vrf: VRF1 + 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: + host: mso_host + username: admin + password: SomeSecretPassword + schema: Schema1 + site: Site1 + template: Template1 + 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: + host: mso_host + username: admin + password: SomeSecretPassword + schema: Schema1 + site: Site1 + template: Template1 + vrf: VRF1 + region: us-west-1 + state: query + delegate_to: localhost + register: query_result + +- name: Query all site VRF regions + cisco.mso.mso_schema_site_vrf_region: + host: mso_host + username: admin + password: SomeSecretPassword + schema: Schema1 + site: Site1 + template: Template1 + vrf: VRF1 + 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 + + +def main(): + argument_spec = mso_argument_spec() + argument_spec.update( + schema=dict(type='str', required=True), + site=dict(type='str', required=True), + template=dict(type='str', required=True), + vrf=dict(type='str', required=True), + region=dict(type='str', aliases=['name']), # This parameter is not required for querying all objects + vpn_gateway_router=dict(type='bool'), + state=dict(type='str', default='present', choices=['absent', 'present', 'query']), + ) + + module = AnsibleModule( + argument_spec=argument_spec, + supports_check_mode=True, + required_if=[ + ['state', 'absent', ['region']], + ['state', 'present', ['region']], + ], + ) + + schema = module.params.get('schema') + site = module.params.get('site') + template = module.params.get('template').replace(' ', '') + vrf = module.params.get('vrf') + region = module.params.get('region') + vpn_gateway_router = module.params.get('vpn_gateway_router') + state = module.params.get('state') + + mso = MSOModule(module) + + # Get schema_id + schema_obj = mso.get_obj('schemas', displayName=schema) + if not schema_obj: + mso.fail_json(msg="Provided schema '{0}' does not exist".format(schema)) + + schema_path = 'schemas/{id}'.format(**schema_obj) + schema_id = schema_obj.get('id') + + # Get site + site_id = mso.lookup_site(site) + + # Get site_idx + if 'sites' not in schema_obj: + 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')] + if (site_id, template) not in sites: + mso.fail_json(msg="Provided site-template association '{0}-{1}' does not exist.".format(site, template)) + + # 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) + + # Get VRF + vrf_ref = mso.vrf_ref(schema_id=schema_id, template=template, vrf=vrf) + vrfs = [v.get('vrfRef') for v in schema_obj.get('sites')[site_idx]['vrfs']] + vrfs_name = [mso.dict_from_ref(v).get('vrfName') for v in vrfs] + if vrf_ref not in vrfs: + mso.fail_json(msg="Provided vrf '{0}' does not exist. Existing vrfs: {1}".format(vrf, ', '.join(vrfs_name))) + vrf_idx = vrfs.index(vrf_ref) + + # Get Region + regions = [r.get('name') for r in schema_obj.get('sites')[site_idx]['vrfs'][vrf_idx]['regions']] + if region is not None and region in regions: + region_idx = regions.index(region) + region_path = '/sites/{0}/vrfs/{1}/regions/{2}'.format(site_template, vrf, region) + mso.existing = schema_obj.get('sites')[site_idx]['vrfs'][vrf_idx]['regions'][region_idx] + + if state == 'query': + if region is None: + mso.existing = schema_obj.get('sites')[site_idx]['vrfs'][vrf_idx]['regions'] + elif not mso.existing: + mso.fail_json(msg="Region '{region}' not found".format(region=region)) + mso.exit_json() + + regions_path = '/sites/{0}/vrfs/{1}/regions'.format(site_template, vrf) + ops = [] + + mso.previous = mso.existing + if state == 'absent': + if mso.existing: + mso.sent = mso.existing = {} + ops.append(dict(op='remove', path=region_path)) + + elif state == 'present': + + payload = dict( + name=region, + isVpnGatewayRouter=vpn_gateway_router, + ) + + mso.sanitize(payload, collate=True) + + if mso.existing: + ops.append(dict(op='replace', path=region_path, value=mso.sent)) + else: + ops.append(dict(op='add', path=regions_path + '/-', value=mso.sent)) + + mso.existing = mso.proposed + + if not module.check_mode: + mso.request(schema_path, method='PATCH', data=ops) + + mso.exit_json() + + +if __name__ == "__main__": + main() diff --git a/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_vrf_region_cidr.py b/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_vrf_region_cidr.py new file mode 100644 index 00000000..324209a9 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_vrf_region_cidr.py @@ -0,0 +1,317 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright: (c) 2019, Dag Wieers (@dagwieers) +# Copyright: (c) 2020, Lionel Hercot (@lhercot) +# 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_vrf_region_cidr +short_description: Manage site-local VRF region CIDRs in schema template +description: +- Manage site-local VRF region CIDRs in schema template on Cisco ACI Multi-Site. +author: +- Dag Wieers (@dagwieers) +- Lionel Hercot (@lhercot) +options: + schema: + description: + - The name of the schema. + type: str + required: yes + site: + description: + - The name of the site. + type: str + required: yes + template: + description: + - The name of the template. + type: str + required: yes + vrf: + description: + - The name of the VRF. + type: str + required: yes + region: + description: + - The name of the region. + type: str + required: yes + cidr: + description: + - The name of the region CIDR to manage. + type: str + aliases: [ ip ] + primary: + description: + - Whether this is the primary CIDR. + type: bool + default: true + 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 +notes: +- The ACI MultiSite PATCH API has a deficiency requiring some objects to be referenced by index. + This can cause silent corruption on concurrent access when changing/removing on object as + the wrong object may be referenced. This module is affected by this deficiency. +seealso: +- module: cisco.mso.mso_schema_site_vrf_region +- module: cisco.mso.mso_schema_site_vrf_region_cidr_subnet +- module: cisco.mso.mso_schema_template_vrf +extends_documentation_fragment: cisco.mso.modules +''' + +EXAMPLES = r''' +- name: Add a new site VRF region CIDR + cisco.mso.mso_schema_site_vrf_region_cidr: + host: mso_host + username: admin + password: SomeSecretPassword + schema: Schema1 + site: Site1 + template: Template1 + vrf: VRF1 + 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: + host: mso_host + username: admin + password: SomeSecretPassword + schema: Schema1 + site: Site1 + template: Template1 + vrf: VRF1 + 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: + host: mso_host + username: admin + password: SomeSecretPassword + schema: Schema1 + site: Site1 + template: Template1 + vrf: VRF1 + 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 + cisco.mso.mso_schema_site_vrf_region_cidr: + host: mso_host + username: admin + password: SomeSecretPassword + schema: Schema1 + site: Site1 + template: Template1 + vrf: VRF1 + region: us-west-1 + 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 + + +def main(): + argument_spec = mso_argument_spec() + argument_spec.update( + schema=dict(type='str', required=True), + site=dict(type='str', required=True), + template=dict(type='str', required=True), + vrf=dict(type='str', required=True), + region=dict(type='str', required=True), + cidr=dict(type='str', aliases=['ip']), # This parameter is not required for querying all objects + primary=dict(type='bool', default=True), + state=dict(type='str', default='present', choices=['absent', 'present', 'query']), + ) + + module = AnsibleModule( + argument_spec=argument_spec, + supports_check_mode=True, + required_if=[ + ['state', 'absent', ['cidr']], + ['state', 'present', ['cidr']], + ], + ) + + schema = module.params.get('schema') + site = module.params.get('site') + template = module.params.get('template').replace(' ', '') + vrf = module.params.get('vrf') + region = module.params.get('region') + cidr = module.params.get('cidr') + primary = module.params.get('primary') + state = module.params.get('state') + + mso = MSOModule(module) + + # Get schema_id + schema_obj = mso.get_obj('schemas', displayName=schema) + if not schema_obj: + mso.fail_json(msg="Provided schema '{0}' does not exist".format(schema)) + + schema_path = 'schemas/{id}'.format(**schema_obj) + schema_id = schema_obj.get('id') + + # 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) + + payload = dict() + op_path = '' + new_cidr = dict( + ip=cidr, + primary=primary, + ) + + # Get site + site_id = mso.lookup_site(site) + + # Get site_idx + all_sites = schema_obj.get('sites') + sites = [] + if all_sites is not None: + sites = [(s.get('siteId'), s.get('templateName')) for s in all_sites] + + # Get VRF + vrf_ref = mso.vrf_ref(schema_id=schema_id, template=template, vrf=vrf) + template_vrfs = [a.get('name') for a in schema_obj['templates'][template_idx]['vrfs']] + if vrf not in template_vrfs: + mso.fail_json(msg="Provided vrf '{0}' does not exist. Existing vrfs: {1}".format(vrf, ', '.join(template_vrfs))) + + # if site-template does not exist, create it + if (site_id, template) not in sites: + op_path = '/sites/-' + payload.update( + siteId=site_id, + templateName=template, + vrfs=[dict( + vrfRef=dict( + schemaId=schema_id, + templateName=template, + vrfName=vrf, + ), + regions=[dict( + name=region, + cidrs=[new_cidr] + )] + )] + ) + + else: + # 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) + + # If vrf not at site level but exists at template level + vrfs = [v.get('vrfRef') for v in schema_obj.get('sites')[site_idx]['vrfs']] + if vrf_ref not in vrfs: + op_path = '/sites/{0}/vrfs/-'.format(site_template) + payload.update( + vrfRef=dict( + schemaId=schema_id, + templateName=template, + vrfName=vrf, + ), + regions=[dict( + name=region, + cidrs=[new_cidr] + )] + ) + else: + # Update vrf index at site level + vrf_idx = vrfs.index(vrf_ref) + + # Get Region + regions = [r.get('name') for r in schema_obj.get('sites')[site_idx]['vrfs'][vrf_idx]['regions']] + if region not in regions: + op_path = '/sites/{0}/vrfs/{1}/regions/-'.format(site_template, vrf) + payload.update( + name=region, + cidrs=[new_cidr] + ) + else: + region_idx = regions.index(region) + + # Get CIDR + cidrs = [c.get('ip') for c in schema_obj.get('sites')[site_idx]['vrfs'][vrf_idx]['regions'][region_idx]['cidrs']] + if cidr is not None: + if cidr in cidrs: + cidr_idx = cidrs.index(cidr) + # FIXME: Changes based on index are DANGEROUS + cidr_path = '/sites/{0}/vrfs/{1}/regions/{2}/cidrs/{3}'.format(site_template, vrf, region, cidr_idx) + mso.existing = schema_obj.get('sites')[site_idx]['vrfs'][vrf_idx]['regions'][region_idx]['cidrs'][cidr_idx] + op_path = '/sites/{0}/vrfs/{1}/regions/{2}/cidrs/-'.format(site_template, vrf, region) + payload = new_cidr + + if state == 'query': + if (site_id, template) not in sites: + mso.fail_json(msg="Provided site-template association '{0}-{1}' does not exist.".format(site, template)) + elif vrf_ref not in vrfs: + mso.fail_json(msg="Provided vrf '{0}' does not exist at site level.".format(vrf)) + elif not regions or region not in regions: + mso.fail_json(msg="Provided region '{0}' does not exist. Existing regions: {1}".format(region, ', '.join(regions))) + elif cidr is None and not payload: + mso.existing = schema_obj.get('sites')[site_idx]['vrfs'][vrf_idx]['regions'][region_idx]['cidrs'] + elif not mso.existing: + mso.fail_json(msg="CIDR IP '{cidr}' not found".format(cidr=cidr)) + mso.exit_json() + + ops = [] + + mso.previous = mso.existing + if state == 'absent': + if mso.existing: + mso.sent = mso.existing = {} + ops.append(dict(op='remove', path=cidr_path)) + + elif state == 'present': + mso.sanitize(payload, collate=True) + + if mso.existing: + ops.append(dict(op='replace', path=cidr_path, value=mso.sent)) + else: + ops.append(dict(op='add', path=op_path, value=mso.sent)) + + mso.existing = new_cidr + + if not module.check_mode and mso.previous != mso.existing: + mso.request(schema_path, method='PATCH', data=ops) + + mso.exit_json() + + +if __name__ == "__main__": + main() diff --git a/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_vrf_region_cidr_subnet.py b/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_vrf_region_cidr_subnet.py new file mode 100644 index 00000000..cd019d53 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_vrf_region_cidr_subnet.py @@ -0,0 +1,302 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright: (c) 2019, Dag Wieers (@dagwieers) +# Copyright: (c) 2020, Lionel Hercot (@lhercot) +# 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_vrf_region_cidr_subnet +short_description: Manage site-local VRF regions in schema template +description: +- Manage site-local VRF regions in schema template on Cisco ACI Multi-Site. +author: +- Dag Wieers (@dagwieers) +- Lionel Hercot (@lhercot) +options: + schema: + description: + - The name of the schema. + type: str + required: yes + site: + description: + - The name of the site. + type: str + required: yes + template: + description: + - The name of the template. + type: str + required: yes + vrf: + description: + - The name of the VRF. + type: str + required: yes + region: + description: + - The name of the region. + type: str + required: yes + cidr: + description: + - The IP range of for the region CIDR. + type: str + required: yes + subnet: + description: + - The IP subnet of this region CIDR. + type: str + aliases: [ ip ] + zone: + description: + - The name of the zone for the region CIDR subnet. + - This argument is required for AWS sites. + type: str + aliases: [ name ] + vgw: + description: + - Whether this subnet is used for the Azure Gateway in Azure. + - Whether this subnet is used for the Transit Gateway Attachment in AWS. + type: bool + aliases: [ hub_network ] + 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 +notes: +- The ACI MultiSite PATCH API has a deficiency requiring some objects to be referenced by index. + This can cause silent corruption on concurrent access when changing/removing on object as + the wrong object may be referenced. This module is affected by this deficiency. +seealso: +- module: cisco.mso.mso_schema_site_vrf_region_cidr +- module: cisco.mso.mso_schema_template_vrf +extends_documentation_fragment: cisco.mso.modules +''' + +EXAMPLES = r''' +- name: Add a new site VRF region CIDR subnet + cisco.mso.mso_schema_site_vrf_region_cidr_subnet: + host: mso_host + username: admin + password: SomeSecretPassword + schema: Schema1 + site: Site1 + template: Template1 + vrf: VRF1 + region: us-west-1 + cidr: 14.14.14.1/24 + 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: + host: mso_host + username: admin + password: SomeSecretPassword + schema: Schema1 + site: Site1 + template: Template1 + vrf: VRF1 + region: us-west-1 + 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: + host: mso_host + username: admin + password: SomeSecretPassword + schema: Schema1 + site: Site1 + template: Template1 + vrf: VRF1 + region: us-west-1 + 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 + cisco.mso.mso_schema_site_vrf_region_cidr_subnet: + host: mso_host + username: admin + password: SomeSecretPassword + schema: Schema1 + site: Site1 + template: Template1 + vrf: VRF1 + region: us-west-1 + cidr: 14.14.14.1/24 + 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 + + +def main(): + argument_spec = mso_argument_spec() + argument_spec.update( + schema=dict(type='str', required=True), + site=dict(type='str', required=True), + template=dict(type='str', required=True), + vrf=dict(type='str', required=True), + region=dict(type='str', required=True), + cidr=dict(type='str', required=True), + subnet=dict(type='str', aliases=['ip']), # This parameter is not required for querying all objects + zone=dict(type='str', aliases=['name']), + vgw=dict(type='bool', aliases=['hub_network']), + state=dict(type='str', default='present', choices=['absent', 'present', 'query']), + ) + + module = AnsibleModule( + argument_spec=argument_spec, + supports_check_mode=True, + required_if=[ + ['state', 'absent', ['subnet']], + ['state', 'present', ['subnet']], + ], + ) + + schema = module.params.get('schema') + site = module.params.get('site') + template = module.params.get('template').replace(' ', '') + vrf = module.params.get('vrf') + region = module.params.get('region') + cidr = module.params.get('cidr') + subnet = module.params.get('subnet') + zone = module.params.get('zone') + vgw = module.params.get('vgw') + state = module.params.get('state') + + mso = MSOModule(module) + + # Get schema_id + schema_obj = mso.get_obj('schemas', displayName=schema) + if not schema_obj: + mso.fail_json(msg="Provided schema '{0}' does not exist".format(schema)) + + schema_path = 'schemas/{id}'.format(**schema_obj) + schema_id = schema_obj.get('id') + + # 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))) + + # Get site + site_id = mso.lookup_site(site) + + # Get site_idx + if 'sites' not in schema_obj: + 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) + + # Get VRF + vrf_ref = mso.vrf_ref(schema_id=schema_id, template=template, vrf=vrf) + vrfs = [v.get('vrfRef') for v in schema_obj.get('sites')[site_idx]['vrfs']] + + # If vrf not at site level but exists at template level + if vrf_ref not in vrfs: + mso.fail_json(msg="Provided vrf '{0}' does not exist at site level." + " Use mso_schema_site_vrf_region_cidr to create it.".format(vrf)) + vrf_idx = vrfs.index(vrf_ref) + + # Get Region + regions = [r.get('name') for r in schema_obj.get('sites')[site_idx]['vrfs'][vrf_idx]['regions']] + if region not in regions: + mso.fail_json(msg="Provided region '{0}' does not exist. Existing regions: {1}." + " Use mso_schema_site_vrf_region_cidr to create it.".format(region, ', '.join(regions))) + region_idx = regions.index(region) + + # Get CIDR + cidrs = [c.get('ip') for c in schema_obj.get('sites')[site_idx]['vrfs'][vrf_idx]['regions'][region_idx]['cidrs']] + if cidr not in cidrs: + mso.fail_json(msg="Provided CIDR IP '{0}' does not exist. Existing CIDR IPs: {1}." + " Use mso_schema_site_vrf_region_cidr to create it.".format(cidr, ', '.join(cidrs))) + cidr_idx = cidrs.index(cidr) + + # Get Subnet + subnets = [s.get('ip') for s in schema_obj.get('sites')[site_idx]['vrfs'][vrf_idx]['regions'][region_idx]['cidrs'][cidr_idx]['subnets']] + if subnet is not None and subnet in subnets: + subnet_idx = subnets.index(subnet) + # FIXME: Changes based on index are DANGEROUS + subnet_path = '/sites/{0}/vrfs/{1}/regions/{2}/cidrs/{3}/subnets/{4}'.format(site_template, vrf, region, cidr_idx, subnet_idx) + mso.existing = schema_obj.get('sites')[site_idx]['vrfs'][vrf_idx]['regions'][region_idx]['cidrs'][cidr_idx]['subnets'][subnet_idx] + + if state == 'query': + if subnet is None: + mso.existing = schema_obj.get('sites')[site_idx]['vrfs'][vrf_idx]['regions'][region_idx]['cidrs'][cidr_idx]['subnets'] + elif not mso.existing: + mso.fail_json(msg="Subnet IP '{subnet}' not found".format(subnet=subnet)) + mso.exit_json() + + subnets_path = '/sites/{0}/vrfs/{1}/regions/{2}/cidrs/{3}/subnets'.format(site_template, vrf, region, cidr_idx) + ops = [] + + mso.previous = mso.existing + if state == 'absent': + if mso.existing: + mso.sent = mso.existing = {} + ops.append(dict(op='remove', path=subnet_path)) + + elif state == 'present': + payload = dict( + ip=subnet, + zone="" + ) + + if zone is not None: + payload['zone'] = zone + if vgw is True: + payload['usage'] = 'gateway' + + mso.sanitize(payload, collate=True) + + if mso.existing: + ops.append(dict(op='replace', path=subnet_path, value=mso.sent)) + else: + ops.append(dict(op='add', path=subnets_path + '/-', value=mso.sent)) + + mso.existing = mso.proposed + + if not module.check_mode: + mso.request(schema_path, method='PATCH', data=ops) + + mso.exit_json() + + +if __name__ == "__main__": + main() diff --git a/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_vrf_region_hub_network.py b/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_vrf_region_hub_network.py new file mode 100644 index 00000000..5e5fcc92 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema_site_vrf_region_hub_network.py @@ -0,0 +1,251 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright: (c) 2020, Cindy Zhao (@cizhao) +# 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_vrf_region_hub_network +short_description: Manage site-local VRF region hub network in schema template +description: +- Manage site-local VRF region hub network in schema template on Cisco ACI Multi-Site. +- The 'Hub Network' feature was introduced in Multi-Site Orchestrator (MSO) version 3.0(1) for AWS and version 3.0(2) for Azure. +author: +- Cindy Zhao (@cizhao) +options: + schema: + description: + - The name of the schema. + type: str + required: yes + site: + description: + - The name of the site. + type: str + required: yes + template: + description: + - The name of the template. + type: str + required: yes + vrf: + description: + - The name of the VRF. + type: str + required: yes + region: + description: + - The name of the region. + type: str + required: yes + hub_network: + description: + - The hub network to be managed. + type: dict + suboptions: + name: + description: + - The name of the hub network. + - The hub-default is the default created hub network. + type: str + required: yes + tenant: + description: + - The tenant name of the hub network. + type: str + required: yes + 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 +notes: +- The ACI MultiSite PATCH API has a deficiency requiring some objects to be referenced by index. + This can cause silent corruption on concurrent access when changing/removing on object as + the wrong object may be referenced. This module is affected by this deficiency. +seealso: +- module: cisco.mso.mso_schema_site_vrf_region +- module: cisco.mso.mso_schema_template_vrf +extends_documentation_fragment: cisco.mso.modules +''' + +EXAMPLES = r''' +- name: Add a new site VRF region hub network + cisco.mso.mso_schema_site_vrf_region_hub_network: + host: mso_host + username: admin + password: SomeSecretPassword + schema: Schema1 + site: Site1 + template: Template1 + vrf: VRF1 + region: us-west-1 + hub_network: + 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: + host: mso_host + username: admin + password: SomeSecretPassword + schema: Schema1 + site: Site1 + 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: + host: mso_host + username: admin + password: SomeSecretPassword + schema: Schema1 + site: Site1 + template: Template1 + vrf: VRF1 + region: us-west-1 + 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_hub_network_spec + + +def main(): + argument_spec = mso_argument_spec() + argument_spec.update( + schema=dict(type='str', required=True), + site=dict(type='str', required=True), + template=dict(type='str', required=True), + vrf=dict(type='str', required=True), + region=dict(type='str', required=True), + hub_network=dict(type='dict', options=mso_hub_network_spec()), + state=dict(type='str', default='present', choices=['absent', 'present', 'query']), + ) + + module = AnsibleModule( + argument_spec=argument_spec, + supports_check_mode=True, + required_if=[ + ['state', 'present', ['hub_network']], + ], + ) + + schema = module.params.get('schema') + site = module.params.get('site') + template = module.params.get('template').replace(' ', '') + vrf = module.params.get('vrf') + region = module.params.get('region') + hub_network = module.params.get('hub_network') + state = module.params.get('state') + + mso = MSOModule(module) + + # Get schema_id + schema_obj = mso.get_obj('schemas', displayName=schema) + if not schema_obj: + mso.fail_json(msg="Provided schema '{0}' does not exist".format(schema)) + + schema_path = 'schemas/{id}'.format(**schema_obj) + schema_id = schema_obj.get('id') + + # 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))) + + # Get site + site_id = mso.lookup_site(site) + + # Get site_idx + if 'sites' not in schema_obj: + 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')] + if (site_id, template) not in sites: + mso.fail_json(msg="Provided site-template association '{0}-{1}' does not exist.".format(site, template)) + + # 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) + + # Get VRF + vrf_ref = mso.vrf_ref(schema_id=schema_id, template=template, vrf=vrf) + vrfs = [v.get('vrfRef') for v in schema_obj.get('sites')[site_idx]['vrfs']] + vrfs_name = [mso.dict_from_ref(v).get('vrfName') for v in vrfs] + if vrf_ref not in vrfs: + mso.fail_json(msg="Provided vrf '{0}' does not exist. Existing vrfs: {1}".format(vrf, ', '.join(vrfs_name))) + vrf_idx = vrfs.index(vrf_ref) + + # Get Region + regions = [r.get('name') for r in schema_obj.get('sites')[site_idx]['vrfs'][vrf_idx]['regions']] + if region not in regions: + mso.fail_json(msg="Provided region '{0}' does not exist. Existing regions: {1}".format(region, ', '.join(regions))) + region_idx = regions.index(region) + # Get Region object + region_obj = schema_obj.get('sites')[site_idx]['vrfs'][vrf_idx]['regions'][region_idx] + region_path = '/sites/{0}/vrfs/{1}/regions/{2}'.format(site_template, vrf, region) + + # Get hub network + existing_hub_network = region_obj.get('cloudRsCtxProfileToGatewayRouterP') + if existing_hub_network is not None: + mso.existing = existing_hub_network + + if state == 'query': + if not mso.existing: + mso.fail_json(msg="Hub network not found") + mso.exit_json() + + ops = [] + + mso.previous = mso.existing + if state == 'absent': + if mso.existing: + mso.sent = mso.existing = {} + ops.append(dict(op='remove', path=region_path + '/cloudRsCtxProfileToGatewayRouterP')) + ops.append(dict(op='replace', path=region_path + '/isTGWAttachment', value=False)) + + elif state == 'present': + new_hub_network = dict( + name=hub_network.get('name'), + tenantName=hub_network.get('tenant'), + ) + payload = region_obj + payload.update( + cloudRsCtxProfileToGatewayRouterP=new_hub_network, + isTGWAttachment=True, + ) + + mso.sanitize(payload, collate=True) + + ops.append(dict(op='replace', path=region_path, value=mso.sent)) + + mso.existing = new_hub_network + + if not module.check_mode and mso.previous != mso.existing: + mso.request(schema_path, method='PATCH', data=ops) + + mso.exit_json() + + +if __name__ == "__main__": + main() diff --git a/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema_template.py b/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema_template.py new file mode 100644 index 00000000..62169443 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema_template.py @@ -0,0 +1,244 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright: (c) 2018, Dag Wieers (@dagwieers) +# 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_template +short_description: Manage templates in schemas +description: +- Manage templates on Cisco ACI Multi-Site. +author: +- Dag Wieers (@dagwieers) +options: + tenant: + description: + - The tenant used for this template. + type: str + required: yes + schema: + description: + - The name of the schema. + type: str + required: yes + template: + description: + - The name of the template. + type: str + aliases: [ name ] + display_name: + description: + - The name as displayed on the MSO web interface. + type: 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 +notes: +- Due to restrictions of the MSO REST API this module creates schemas when needed, and removes them when the last template has been removed. +seealso: +- module: cisco.mso.mso_schema +- module: cisco.mso.mso_schema_site +extends_documentation_fragment: cisco.mso.modules +''' + +EXAMPLES = r''' +- name: Add a new template to a schema + cisco.mso.mso_schema_template: + host: mso_host + username: admin + password: SomeSecretPassword + tenant: Tenant 1 + schema: Schema 1 + template: Template 1 + state: present + delegate_to: localhost + +- name: Remove a template from a schema + cisco.mso.mso_schema_template: + host: mso_host + username: admin + password: SomeSecretPassword + tenant: Tenant 1 + schema: Schema 1 + template: Template 1 + state: absent + delegate_to: localhost + +- name: Query a template + cisco.mso.mso_schema_template: + host: mso_host + username: admin + password: SomeSecretPassword + tenant: Tenant 1 + schema: Schema 1 + template: Template 1 + state: query + delegate_to: localhost + register: query_result + +- name: Query all templates + cisco.mso.mso_schema_template: + host: mso_host + username: admin + password: SomeSecretPassword + tenant: Tenant 1 + schema: Schema 1 + 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 + + +def main(): + argument_spec = mso_argument_spec() + argument_spec.update( + tenant=dict(type='str', required=True), + schema=dict(type='str', required=True), + template=dict(type='str', aliases=['name']), + display_name=dict(type='str'), + state=dict(type='str', default='present', choices=['absent', 'present', 'query']), + ) + + module = AnsibleModule( + argument_spec=argument_spec, + supports_check_mode=True, + required_if=[ + ['state', 'absent', ['template']], + ['state', 'present', ['template']], + ], + ) + + tenant = module.params.get('tenant') + schema = module.params.get('schema') + template = module.params.get('template') + if template is not None: + template = template.replace(' ', '') + display_name = module.params.get('display_name') + state = module.params.get('state') + + mso = MSOModule(module) + + # Get schema + schema_obj = mso.get_obj('schemas', displayName=schema) + + mso.existing = {} + if schema_obj: + # Schema exists + schema_path = 'schemas/{id}'.format(**schema_obj) + + # Get template + templates = [t.get('name') for t in schema_obj.get('templates')] + if template: + if template in templates: + template_idx = templates.index(template) + mso.existing = schema_obj.get('templates')[template_idx] + else: + mso.existing = schema_obj.get('templates') + else: + schema_path = 'schemas' + + if state == 'query': + if not mso.existing: + if template: + mso.fail_json(msg="Template '{0}' not found".format(template)) + else: + mso.existing = [] + mso.exit_json() + + template_path = '/templates/{0}'.format(template) + ops = [] + + mso.previous = mso.existing + if state == 'absent': + mso.proposed = mso.sent = {} + if not schema_obj: + # There was no schema to begin with + pass + elif len(templates) == 1 and mso.existing: + # There is only one tenant, remove schema + mso.existing = {} + if not module.check_mode: + mso.request(schema_path, method='DELETE') + elif mso.existing: + # Remove existing template + mso.existing = {} + ops.append(dict(op='remove', path=template_path)) + + elif state == 'present': + tenant_id = mso.lookup_tenant(tenant) + + if display_name is None: + display_name = mso.existing.get('displayName', template) + + if not schema_obj: + # Schema does not exist, so we have to create it + payload = dict( + displayName=schema, + templates=[dict( + name=template, + displayName=display_name, + tenantId=tenant_id, + )], + sites=[], + ) + + mso.existing = payload.get('templates')[0] + + if not module.check_mode: + mso.request(schema_path, method='POST', data=payload) + + elif mso.existing: + # Template exists, so we have to update it + payload = dict( + name=template, + displayName=display_name, + tenantId=tenant_id, + ) + + mso.sanitize(payload, collate=True) + + ops.append(dict(op='replace', path=template_path + '/displayName', value=display_name)) + ops.append(dict(op='replace', path=template_path + '/tenantId', value=tenant_id)) + + mso.existing = mso.proposed + else: + # Template does not exist, so we have to add it + payload = dict( + name=template, + displayName=display_name, + tenantId=tenant_id, + ) + + mso.sanitize(payload, collate=True) + + ops.append(dict(op='add', path='/templates/-', value=payload)) + + mso.existing = mso.proposed + + if not module.check_mode: + mso.request(schema_path, method='PATCH', data=ops) + + mso.exit_json() + + +if __name__ == "__main__": + main() diff --git a/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_anp.py b/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_anp.py new file mode 100644 index 00000000..f2679ce6 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_anp.py @@ -0,0 +1,207 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright: (c) 2018, Dag Wieers (@dagwieers) +# 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_template_anp +short_description: Manage Application Network Profiles (ANPs) in schema templates +description: +- Manage ANPs in schema templates on Cisco ACI Multi-Site. +author: +- Dag Wieers (@dagwieers) +options: + schema: + description: + - The name of the schema. + type: str + required: yes + template: + description: + - The name of the template. + type: str + required: yes + anp: + description: + - The name of the ANP to manage. + type: str + aliases: [ name ] + display_name: + description: + - The name as displayed on the MSO web interface. + type: 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 +- module: cisco.mso.mso_schema_template_anp_epg +extends_documentation_fragment: cisco.mso.modules +''' + +EXAMPLES = r''' +- name: Add a new ANP + cisco.mso.mso_schema_template_anp: + host: mso_host + username: admin + password: SomeSecretPassword + schema: Schema 1 + template: Template 1 + anp: ANP 1 + state: present + delegate_to: localhost + +- name: Remove an ANP + cisco.mso.mso_schema_template_anp: + host: mso_host + username: admin + password: SomeSecretPassword + schema: Schema 1 + template: Template 1 + anp: ANP 1 + state: absent + delegate_to: localhost + +- name: Query a specific ANPs + cisco.mso.mso_schema_template_anp: + host: mso_host + username: admin + password: SomeSecretPassword + schema: Schema 1 + template: Template 1 + state: query + delegate_to: localhost + register: query_result + +- name: Query all ANPs + cisco.mso.mso_schema_template_anp: + host: mso_host + username: admin + password: SomeSecretPassword + schema: Schema 1 + template: Template 1 + 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 + + +def main(): + argument_spec = mso_argument_spec() + argument_spec.update( + schema=dict(type='str', required=True), + template=dict(type='str', required=True), + anp=dict(type='str', aliases=['name']), # This parameter is not required for querying all objects + display_name=dict(type='str'), + state=dict(type='str', default='present', choices=['absent', 'present', 'query']), + ) + + module = AnsibleModule( + argument_spec=argument_spec, + supports_check_mode=True, + required_if=[ + ['state', 'absent', ['anp']], + ['state', 'present', ['anp']], + ], + ) + + schema = module.params.get('schema') + template = module.params.get('template').replace(' ', '') + anp = module.params.get('anp') + display_name = module.params.get('display_name') + state = module.params.get('state') + + mso = MSOModule(module) + + # Get schema_id + schema_obj = mso.get_obj('schemas', displayName=schema) + if not schema_obj: + mso.fail_json(msg="Provided schema '{0}' does not exist".format(schema)) + + schema_path = 'schemas/{id}'.format(**schema_obj) + + # 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 is not None and anp in anps: + anp_idx = anps.index(anp) + mso.existing = schema_obj.get('templates')[template_idx]['anps'][anp_idx] + + if state == 'query': + if anp is None: + mso.existing = schema_obj.get('templates')[template_idx]['anps'] + elif not mso.existing: + mso.fail_json(msg="ANP '{anp}' not found".format(anp=anp)) + mso.exit_json() + + anps_path = '/templates/{0}/anps'.format(template) + anp_path = '/templates/{0}/anps/{1}'.format(template, anp) + ops = [] + + mso.previous = mso.existing + if state == 'absent': + if mso.existing: + mso.sent = mso.existing = {} + ops.append(dict(op='remove', path=anp_path)) + + elif state == 'present': + + if display_name is None and not mso.existing: + display_name = anp + + epgs = [] + if mso.existing: + epgs = None + + payload = dict( + name=anp, + displayName=display_name, + epgs=epgs, + ) + + mso.sanitize(payload, collate=True) + + if mso.existing: + if display_name is not None: + ops.append(dict(op='replace', path=anp_path + '/displayName', value=display_name)) + else: + ops.append(dict(op='add', path=anps_path + '/-', value=mso.sent)) + + mso.existing = mso.proposed + + if 'anpRef' in mso.previous: + del mso.previous['anpRef'] + + if not module.check_mode: + mso.request(schema_path, method='PATCH', data=ops) + + mso.exit_json() + + +if __name__ == "__main__": + main() diff --git a/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_anp_epg.py b/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_anp_epg.py new file mode 100644 index 00000000..6883e4dd --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_anp_epg.py @@ -0,0 +1,403 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright: (c) 2018, Dag Wieers (@dagwieers) +# 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_template_anp_epg +short_description: Manage Endpoint Groups (EPGs) in schema templates +description: +- Manage EPGs in schema templates on Cisco ACI Multi-Site. +author: +- Dag Wieers (@dagwieers) +options: + schema: + description: + - The name of the schema. + type: str + required: yes + template: + description: + - The name of the template. + type: str + required: yes + anp: + description: + - The name of the ANP. + type: str + required: yes + epg: + description: + - The name of the EPG to manage. + type: str + aliases: [ name ] + display_name: + description: + - The name as displayed on the MSO web interface. + type: str +# contracts: +# description: +# - A list of contracts associated to this ANP. +# type: list + bd: + description: + - The BD associated to this ANP. + type: dict + suboptions: + name: + description: + - The name of the BD to associate with. + required: true + type: str + schema: + description: + - The schema that defines the referenced BD. + - If this parameter is unspecified, it defaults to the current schema. + type: str + template: + description: + - The template that defines the referenced BD. + type: str + vrf: + description: + - The VRF associated to this ANP. + type: dict + suboptions: + name: + description: + - The name of the VRF to associate with. + required: true + type: str + schema: + description: + - The schema that defines the referenced VRF. + - If this parameter is unspecified, it defaults to the current schema. + type: str + template: + description: + - The template that defines the referenced VRF. + type: str + subnets: + description: + - The subnets associated to this ANP. + type: list + elements: dict + suboptions: + subnet: + description: + - The IP range in CIDR notation. + type: str + required: true + aliases: [ ip ] + description: + description: + - The description of this subnet. + type: str + scope: + description: + - The scope of the subnet. + type: str + default: private + choices: [ private, public ] + shared: + description: + - Whether this subnet is shared between VRFs. + type: bool + no_default_gateway: + description: + - Whether this subnet has a default gateway. + type: bool + querier: + description: + - Whether this subnet is an IGMP querier. + type: bool + useg_epg: + description: + - Whether this is a USEG EPG. + type: bool +# useg_epg_attributes: +# description: +# - A dictionary consisting of USEG attributes. +# type: dict + intra_epg_isolation: + description: + - Whether intra EPG isolation is enforced. + - When not specified, this parameter defaults to C(unenforced). + type: str + choices: [ enforced, unenforced ] + intersite_multicast_source: + description: + - Whether intersite multicast source is enabled. + - When not specified, this parameter defaults to C(no). + type: bool + proxy_arp: + description: + - Whether proxy arp is enabled. + - When not specified, this parameter defaults to C(no). + type: bool + preferred_group: + description: + - Whether this EPG is added to preferred group or not. + - When not specified, this parameter defaults to C(no). + type: bool + 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_anp +- module: cisco.mso.mso_schema_template_anp_epg_subnet +- module: cisco.mso.mso_schema_template_bd +- module: cisco.mso.mso_schema_template_contract_filter +extends_documentation_fragment: cisco.mso.modules +''' + +EXAMPLES = r''' +- name: Add a new EPG + cisco.mso.mso_schema_template_anp_epg: + host: mso_host + username: admin + password: SomeSecretPassword + schema: Schema 1 + template: Template 1 + anp: ANP 1 + epg: EPG 1 + bd: + name: bd1 + vrf: + name: vrf1 + state: present + delegate_to: localhost + +- name: Add a new EPG with preferred group. + cisco.mso.mso_schema_template_anp_epg: + host: mso_host + username: admin + password: SomeSecretPassword + schema: Schema 1 + template: Template 1 + anp: ANP 1 + epg: EPG 1 + state: present + preferred_group: yes + delegate_to: localhost + +- name: Remove an EPG + cisco.mso.mso_schema_template_anp_epg: + host: mso_host + username: admin + password: SomeSecretPassword + schema: Schema 1 + template: Template 1 + anp: ANP 1 + epg: EPG 1 + bd: + name: bd1 + vrf: + name: vrf1 + state: absent + delegate_to: localhost + +- name: Query a specific EPG + cisco.mso.mso_schema_template_anp_epg: + host: mso_host + username: admin + password: SomeSecretPassword + schema: Schema 1 + template: Template 1 + anp: ANP 1 + epg: EPG 1 + bd: + name: bd1 + vrf: + name: vrf1 + state: query + delegate_to: localhost + register: query_result + +- name: Query all EPGs + cisco.mso.mso_schema_template_anp_epg: + host: mso_host + username: admin + password: SomeSecretPassword + schema: Schema 1 + template: Template 1 + anp: ANP 1 + epg: EPG 1 + bd: + name: bd1 + vrf: + name: vrf1 + 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_reference_spec, mso_subnet_spec + + +def main(): + argument_spec = mso_argument_spec() + argument_spec.update( + schema=dict(type='str', required=True), + template=dict(type='str', required=True), + anp=dict(type='str', required=True), + epg=dict(type='str', aliases=['name']), # This parameter is not required for querying all objects + bd=dict(type='dict', options=mso_reference_spec()), + vrf=dict(type='dict', options=mso_reference_spec()), + display_name=dict(type='str'), + useg_epg=dict(type='bool'), + intra_epg_isolation=dict(type='str', choices=['enforced', 'unenforced']), + intersite_multicast_source=dict(type='bool'), + proxy_arp=dict(type='bool'), + subnets=dict(type='list', elements='dict', options=mso_subnet_spec()), + state=dict(type='str', default='present', choices=['absent', 'present', 'query']), + preferred_group=dict(type='bool'), + ) + + module = AnsibleModule( + argument_spec=argument_spec, + supports_check_mode=True, + required_if=[ + ['state', 'absent', ['epg']], + ['state', 'present', ['epg']], + ], + ) + + schema = module.params.get('schema') + template = module.params.get('template').replace(' ', '') + anp = module.params.get('anp') + epg = module.params.get('epg') + display_name = module.params.get('display_name') + bd = module.params.get('bd') + if bd is not None and bd.get('template') is not None: + bd['template'] = bd.get('template').replace(' ', '') + vrf = module.params.get('vrf') + if vrf is not None and vrf.get('template') is not None: + vrf['template'] = vrf.get('template').replace(' ', '') + useg_epg = module.params.get('useg_epg') + intra_epg_isolation = module.params.get('intra_epg_isolation') + intersite_multicast_source = module.params.get('intersite_multicast_source') + proxy_arp = module.params.get('proxy_arp') + subnets = module.params.get('subnets') + state = module.params.get('state') + preferred_group = module.params.get('preferred_group') + + mso = MSOModule(module) + + # Get schema_id + schema_obj = mso.get_obj('schemas', displayName=schema) + if schema_obj: + schema_id = schema_obj.get('id') + else: + mso.fail_json(msg="Provided schema '{0}' does not exist".format(schema)) + + schema_path = 'schemas/{id}'.format(**schema_obj) + + # 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 is not None and epg in epgs: + epg_idx = epgs.index(epg) + mso.existing = schema_obj.get('templates')[template_idx]['anps'][anp_idx]['epgs'][epg_idx] + + if state == 'query': + if epg is None: + mso.existing = schema_obj.get('templates')[template_idx]['anps'][anp_idx]['epgs'] + elif not mso.existing: + mso.fail_json(msg="EPG '{epg}' not found".format(epg=epg)) + + if 'bdRef' in mso.existing: + mso.existing['bdRef'] = mso.dict_from_ref(mso.existing['bdRef']) + if 'vrfRef' in mso.existing: + mso.existing['vrfRef'] = mso.dict_from_ref(mso.existing['vrfRef']) + mso.exit_json() + + epgs_path = '/templates/{0}/anps/{1}/epgs'.format(template, anp) + epg_path = '/templates/{0}/anps/{1}/epgs/{2}'.format(template, anp, epg) + ops = [] + + mso.previous = mso.existing + if state == 'absent': + if mso.existing: + mso.sent = mso.existing = {} + ops.append(dict(op='remove', path=epg_path)) + + elif state == 'present': + bd_ref = mso.make_reference(bd, 'bd', schema_id, template) + vrf_ref = mso.make_reference(vrf, 'vrf', schema_id, template) + mso.stdout = str(subnets) + subnets = mso.make_subnets(subnets) + + if display_name is None and not mso.existing: + display_name = epg + + payload = dict( + name=epg, + displayName=display_name, + uSegEpg=useg_epg, + intraEpg=intra_epg_isolation, + mCastSource=intersite_multicast_source, + proxyArp=proxy_arp, + # FIXME: Missing functionality + # uSegAttrs=[], + subnets=subnets, + bdRef=bd_ref, + preferredGroup=preferred_group, + vrfRef=vrf_ref, + ) + + mso.sanitize(payload, collate=True) + + if mso.existing: + # Clean contractRef to fix api issue + for contract in mso.sent.get('contractRelationships'): + contract['contractRef'] = mso.dict_from_ref(contract.get('contractRef')) + ops.append(dict(op='replace', path=epg_path, value=mso.sent)) + else: + ops.append(dict(op='add', path=epgs_path + '/-', value=mso.sent)) + + mso.existing = mso.proposed + + if 'epgRef' in mso.previous: + del mso.previous['epgRef'] + if 'bdRef' in mso.previous and mso.previous['bdRef'] != '': + mso.previous['bdRef'] = mso.dict_from_ref(mso.previous['bdRef']) + if 'vrfRef' in mso.previous and mso.previous['bdRef'] != '': + mso.previous['vrfRef'] = mso.dict_from_ref(mso.previous['vrfRef']) + + if not module.check_mode and mso.proposed != mso.previous: + mso.request(schema_path, method='PATCH', data=ops) + + mso.exit_json() + + +if __name__ == "__main__": + main() diff --git a/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_anp_epg_contract.py b/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_anp_epg_contract.py new file mode 100644 index 00000000..cdf9692f --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_anp_epg_contract.py @@ -0,0 +1,266 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright: (c) 2018, Dag Wieers (@dagwieers) +# 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_template_anp_epg_contract +short_description: Manage EPG contracts in schema templates +description: +- Manage EPG contracts in schema templates on Cisco ACI Multi-Site. +author: +- Dag Wieers (@dagwieers) +options: + schema: + description: + - The name of the schema. + type: str + required: yes + template: + description: + - The name of the template to change. + type: str + required: yes + anp: + description: + - The name of the ANP. + type: str + required: yes + epg: + description: + - The name of the EPG to manage. + type: str + required: yes + contract: + description: + - A contract associated to this EPG. + type: dict + suboptions: + name: + description: + - The name of the Contract to associate with. + required: true + type: str + schema: + description: + - The schema that defines the referenced BD. + - If this parameter is unspecified, it defaults to the current schema. + type: str + template: + description: + - The template that defines the referenced BD. + type: str + type: + description: + - The type of contract. + type: str + required: true + choices: [ consumer, provider ] + 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_anp_epg +- module: cisco.mso.mso_schema_template_contract_filter +extends_documentation_fragment: cisco.mso.modules +''' + +EXAMPLES = r''' +- name: Add a contract 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 + contract: + name: Contract 1 + type: consumer + state: present + delegate_to: localhost + +- 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 + delegate_to: localhost + +- name: Query a specific 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: query + delegate_to: localhost + register: query_result + +- name: Query all 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 + 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_contractref_spec + + +def main(): + argument_spec = mso_argument_spec() + argument_spec.update( + schema=dict(type='str', required=True), + template=dict(type='str', required=True), + anp=dict(type='str', required=True), + epg=dict(type='str', required=True), + contract=dict(type='dict', options=mso_contractref_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']], + ], + ) + + schema = module.params.get('schema') + template = module.params.get('template').replace(' ', '') + anp = module.params.get('anp') + epg = module.params.get('epg') + contract = module.params.get('contract') + if contract is not None and contract.get('template') is not None: + contract['template'] = contract.get('template').replace(' ', '') + state = module.params.get('state') + + mso = MSOModule(module) + + 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_id + schema_obj = mso.get_obj('schemas', displayName=schema) + if not schema_obj: + mso.fail_json(msg="Provided schema '{0}' does not exist".format(schema)) + + schema_path = 'schemas/{id}'.format(**schema_obj) + + # 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 + 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] + + if state == 'query': + if not contract: + mso.existing = schema_obj.get('templates')[template_idx]['anps'][anp_idx]['epgs'][epg_idx]['contractRelationships'] + 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.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 = {} + ops.append(dict(op='remove', path=contract_path)) + + elif state == 'present': + payload = dict( + relationshipType=contract.get('type'), + contractRef=dict( + contractName=contract.get('name'), + templateName=contract.get('template'), + schemaId=contract.get('schema_id'), + ), + ) + + 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)) + + 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) + + mso.exit_json() + + +if __name__ == "__main__": + main() diff --git a/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_anp_epg_selector.py b/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_anp_epg_selector.py new file mode 100644 index 00000000..d77c197d --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_anp_epg_selector.py @@ -0,0 +1,281 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright: (c) 2020, Cindy Zhao (@cizhao) +# 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_template_anp_epg_selector +short_description: Manage EPG selector in schema templates +description: +- Manage EPG selector in schema templates on Cisco ACI Multi-Site. +author: +- Cindy Zhao (@cizhao) +options: + schema: + description: + - The name of the schema. + type: str + required: yes + template: + description: + - The name of the template to change. + type: str + required: yes + anp: + description: + - The name of the ANP. + type: str + required: yes + epg: + description: + - The name of the EPG to manage. + type: str + required: yes + selector: + description: + - The name of the selector. + type: str + expressions: + description: + - Expressions associated to this selector. + type: list + elements: dict + suboptions: + type: + description: + - The name of the expression. + required: true + type: str + aliases: [ tag ] + operator: + description: + - The operator associated to the expression. + required: true + type: str + choices: [ not_in, in, equals, not_equals, has_key, does_not_have_key ] + value: + description: + - The value associated to the expression. + - If the operator is in or not_in, the value should be a comma separated str. + type: 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_anp_epg +extends_documentation_fragment: cisco.mso.modules +''' + +EXAMPLES = r''' +- name: Add a selector to an EPG + cisco.mso.mso_schema_template_anp_epg_selector: + host: mso_host + username: admin + password: SomeSecretPassword + schema: Schema 1 + template: Template 1 + anp: ANP 1 + epg: EPG 1 + selector: selector_1 + expressions: + - type: expression_1 + operator: in + value: test + state: present + delegate_to: localhost + +- name: Remove a Selector + cisco.mso.mso_schema_template_anp_epg_selector: + host: mso_host + username: admin + password: SomeSecretPassword + schema: Schema 1 + template: Template 1 + anp: ANP 1 + epg: EPG 1 + selector: selector_1 + state: absent + delegate_to: localhost + +- name: Query a specific Selector + cisco.mso.mso_schema_template_anp_epg_selector: + host: mso_host + username: admin + password: SomeSecretPassword + schema: Schema 1 + template: Template 1 + anp: ANP 1 + epg: EPG 1 + selector: selector_1 + state: query + delegate_to: localhost + register: query_result + +- name: Query all Selectors + cisco.mso.mso_schema_template_anp_epg_selector: + host: mso_host + username: admin + password: SomeSecretPassword + schema: Schema 1 + template: Template 1 + anp: ANP 1 + epg: EPG 1 + 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_expression_spec + +EXPRESSION_KEYS = { + 'not_in': 'notIn', + 'not_equals': 'notEquals', + 'has_key': 'keyExist', + 'does_not_have_key': 'keyNotExist', + 'in': 'in', + 'equals': 'equals', +} + + +def main(): + argument_spec = mso_argument_spec() + argument_spec.update( + schema=dict(type='str', required=True), + template=dict(type='str', required=True), + anp=dict(type='str', required=True), + epg=dict(type='str', required=True), + selector=dict(type='str'), + expressions=dict(type='list', elements='dict', options=mso_expression_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', ['selector']], + ['state', 'present', ['selector']], + ], + ) + + schema = module.params.get('schema') + template = module.params.get('template').replace(' ', '') + anp = module.params.get('anp') + epg = module.params.get('epg') + selector = module.params.get('selector') + expressions = module.params.get('expressions') + state = module.params.get('state') + + mso = MSOModule(module) + + # Get schema_id + schema_obj = mso.get_obj('schemas', displayName=schema) + if not schema_obj: + mso.fail_json(msg="Provided schema '{0}' does not exist".format(schema)) + + schema_path = 'schemas/{id}'.format(**schema_obj) + + # Get template + templates = [t.get('name') for t in schema_obj.get('templates')] + if template not in templates: + mso.fail_json(msg="Provided template '{template}' does not exist. Existing templates: {templates}".format(template=template, + templates=', '.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 '{anp}' does not exist. Existing anps: {anps}".format(anp=anp, anps=', '.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 Selector + if selector and " " in selector: + mso.fail_json(msg="There should not be any space in selector name.") + selectors = [s.get('name') for s in schema_obj.get('templates')[template_idx]['anps'][anp_idx]['epgs'][epg_idx]['selectors']] + if selector in selectors: + selector_idx = selectors.index(selector) + selector_path = '/templates/{0}/anps/{1}/epgs/{2}/selectors/{3}'.format(template, anp, epg, selector_idx) + mso.existing = schema_obj.get('templates')[template_idx]['anps'][anp_idx]['epgs'][epg_idx]['selectors'][selector_idx] + + if state == 'query': + if selector is None: + mso.existing = schema_obj.get('templates')[template_idx]['anps'][anp_idx]['epgs'][epg_idx]['selectors'] + elif not mso.existing: + mso.fail_json(msg="Selector '{selector}' not found".format(selector=selector)) + mso.exit_json() + + selectors_path = '/templates/{0}/anps/{1}/epgs/{2}/selectors/-'.format(template, anp, epg) + ops = [] + + mso.previous = mso.existing + if state == 'absent': + mso.sent = mso.existing = {} + ops.append(dict(op='remove', path=selector_path)) + + elif state == 'present': + # Get expressions + all_expressions = [] + if expressions: + for expression in expressions: + tag = expression.get('type') + operator = expression.get('operator') + value = expression.get('value') + if " " in tag: + mso.fail_json(msg="There should not be any space in 'type' attribute of expression '{0}'".format(tag)) + if operator in ["has_key", "does_not_have_key"] and value: + mso.fail_json( + msg="Attribute 'value' is not supported for operator '{0}' in expression '{1}'".format(operator, tag)) + if operator in ["not_in", "in", "equals", "not_equals"] and not value: + mso.fail_json( + msg="Attribute 'value' needed for operator '{0}' in expression '{1}'".format(operator, tag)) + all_expressions.append(dict( + key='Custom:' + tag, + operator=EXPRESSION_KEYS.get(operator), + value=value, + )) + + payload = dict( + name=selector, + expressions=all_expressions, + ) + + mso.sanitize(payload, collate=True) + + if mso.existing: + ops.append(dict(op='replace', path=selector_path, value=mso.sent)) + else: + ops.append(dict(op='add', path=selectors_path, value=mso.sent)) + + mso.existing = mso.proposed + + if not module.check_mode and mso.existing != mso.previous: + mso.request(schema_path, method='PATCH', data=ops) + + mso.exit_json() + + +if __name__ == "__main__": + main() diff --git a/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_anp_epg_subnet.py b/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_anp_epg_subnet.py new file mode 100644 index 00000000..109827ea --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_anp_epg_subnet.py @@ -0,0 +1,266 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright: (c) 2018, Dag Wieers (@dagwieers) +# 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_template_anp_epg_subnet +short_description: Manage EPG subnets in schema templates +description: +- Manage EPG subnets in schema templates on Cisco ACI Multi-Site. +author: +- Dag Wieers (@dagwieers) +options: + schema: + description: + - The name of the schema. + type: str + required: yes + template: + description: + - The name of the template to change. + type: str + required: yes + anp: + description: + - The name of the ANP. + type: str + required: yes + epg: + description: + - The name of the EPG to manage. + type: str + required: yes + subnet: + description: + - The IP range in CIDR notation. + type: str + required: true + aliases: [ ip ] + description: + description: + - The description of this subnet. + type: str + scope: + description: + - The scope of the subnet. + type: str + default: private + choices: [ private, public ] + shared: + description: + - Whether this subnet is shared between VRFs. + type: bool + no_default_gateway: + description: + - Whether this subnet has a default gateway. + type: bool + querier: + description: + - Whether this subnet is an IGMP querier. + type: bool + 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 +notes: +- Due to restrictions of the MSO REST API concurrent modifications to EPG subnets can be dangerous and corrupt data. +extends_documentation_fragment: cisco.mso.modules +''' + +EXAMPLES = r''' +- name: Add a new subnet to an EPG + cisco.mso.mso_schema_template_anp_epg_subnet: + host: mso_host + username: admin + password: SomeSecretPassword + schema: Schema 1 + template: Template 1 + anp: ANP 1 + 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: + host: mso_host + username: admin + password: SomeSecretPassword + schema: Schema 1 + template: Template 1 + anp: ANP 1 + 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: + host: mso_host + username: admin + password: SomeSecretPassword + schema: Schema 1 + template: Template 1 + anp: ANP 1 + epg: EPG 1 + subnet: 10.0.0.0/24 + state: query + delegate_to: localhost + register: query_result + +- name: Query all EPGs subnets + cisco.mso.mso_schema_template_anp_epg_subnet: + host: mso_host + username: admin + password: SomeSecretPassword + schema: Schema 1 + template: Template 1 + anp: ANP 1 + 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_subnet_spec + + +def main(): + argument_spec = mso_argument_spec() + argument_spec.update( + schema=dict(type='str', required=True), + template=dict(type='str', required=True), + anp=dict(type='str', required=True), + epg=dict(type='str', required=True), + state=dict(type='str', default='present', choices=['absent', 'present', 'query']), + ) + argument_spec.update(mso_subnet_spec()) + + module = AnsibleModule( + argument_spec=argument_spec, + supports_check_mode=True, + required_if=[ + ['state', 'absent', ['subnet']], + ['state', 'present', ['subnet']], + ], + ) + + schema = module.params.get('schema') + template = module.params.get('template').replace(' ', '') + anp = module.params.get('anp') + epg = module.params.get('epg') + subnet = module.params.get('subnet') + description = module.params.get('description') + scope = module.params.get('scope') + shared = module.params.get('shared') + no_default_gateway = module.params.get('no_default_gateway') + querier = module.params.get('querier') + state = module.params.get('state') + + mso = MSOModule(module) + + # Get schema + schema_obj = mso.get_obj('schemas', displayName=schema) + if not schema_obj: + mso.fail_json(msg="Provided schema '{0}' does not exist".format(schema)) + + schema_path = 'schemas/{id}'.format(**schema_obj) + + # Get template + templates = [t.get('name') for t in schema_obj.get('templates')] + if template not in templates: + mso.fail_json(msg="Provided template '{template}' does not exist. Existing templates: {templates}".format(template=template, + templates=', '.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 '{anp}' does not exist. Existing anps: {anps}".format(anp=anp, anps=', '.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 Subnet + subnets = [s.get('ip') for s in schema_obj.get('templates')[template_idx]['anps'][anp_idx]['epgs'][epg_idx]['subnets']] + if subnet in subnets: + subnet_idx = subnets.index(subnet) + # FIXME: Changes based on index are DANGEROUS + subnet_path = '/templates/{0}/anps/{1}/epgs/{2}/subnets/{3}'.format(template, anp, epg, subnet_idx) + mso.existing = schema_obj.get('templates')[template_idx]['anps'][anp_idx]['epgs'][epg_idx]['subnets'][subnet_idx] + + if state == 'query': + if subnet is None: + mso.existing = schema_obj.get('templates')[template_idx]['anps'][anp_idx]['epgs'][epg_idx]['subnets'] + elif not mso.existing: + mso.fail_json(msg="Subnet '{subnet}' not found".format(subnet=subnet)) + mso.exit_json() + + subnets_path = '/templates/{0}/anps/{1}/epgs/{2}/subnets'.format(template, anp, epg) + ops = [] + + mso.previous = mso.existing + if state == 'absent': + if mso.existing: + mso.existing = {} + ops.append(dict(op='remove', path=subnet_path)) + + elif state == 'present': + if not mso.existing: + if description is None: + description = subnet + if scope is None: + scope = 'private' + if shared is None: + shared = False + if no_default_gateway is None: + no_default_gateway = False + if querier is None: + querier = False + + payload = dict( + ip=subnet, + description=description, + scope=scope, + shared=shared, + noDefaultGateway=no_default_gateway, + querier=querier, + ) + + mso.sanitize(payload, collate=True) + + if mso.existing: + ops.append(dict(op='replace', path=subnet_path, value=mso.sent)) + else: + ops.append(dict(op='add', path=subnets_path + '/-', value=mso.sent)) + + mso.existing = mso.proposed + + if not module.check_mode: + mso.request(schema_path, method='PATCH', data=ops) + + mso.exit_json() + + +if __name__ == "__main__": + main() diff --git a/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_bd.py b/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_bd.py new file mode 100644 index 00000000..0e7d0ff0 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_bd.py @@ -0,0 +1,444 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright: (c) 2018, Dag Wieers (@dagwieers) +# Copyright: (c) 2020, Shreyas Srish (@shrsr) +# 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_template_bd +short_description: Manage Bridge Domains (BDs) in schema templates +description: +- Manage BDs in schema templates on Cisco ACI Multi-Site. +author: +- Dag Wieers (@dagwieers) +- Shreyas Srish (@shrsr) +options: + schema: + description: + - The name of the schema. + type: str + required: yes + template: + description: + - The name of the template. + - Display Name of template for operations can only be used in some versions of mso. + - Use the name of template instead of Display Name to avoid discrepency. + type: str + required: yes + bd: + description: + - The name of the BD to manage. + type: str + aliases: [ name ] + display_name: + description: + - The name as displayed on the MSO web interface. + type: str + vrf: + description: + - The VRF associated to this BD. This is required only when creating a new BD. + type: dict + suboptions: + name: + description: + - The name of the VRF to associate with. + required: true + type: str + schema: + description: + - The schema that defines the referenced VRF. + - If this parameter is unspecified, it defaults to the current schema. + type: str + template: + description: + - The template that defines the referenced VRF. + - If this parameter is unspecified, it defaults to the current template. + type: str + dhcp_policy: + description: + - The DHCP Policy + type: dict + suboptions: + name: + description: + - The name of the DHCP Relay Policy + type: str + required: yes + version: + description: + - The version of DHCP Relay Policy + type: int + required: yes + dhcp_option_policy: + description: + - The DHCP Option Policy + type: dict + suboptions: + name: + description: + - The name of the DHCP Option Policy + type: str + version: + description: + - The version of the DHCP Option Policy + type: int + subnets: + description: + - The subnets associated to this BD. + type: list + elements: dict + suboptions: + subnet: + description: + - The IP range in CIDR notation. + type: str + required: true + aliases: [ ip ] + description: + description: + - The description of this subnet. + type: str + scope: + description: + - The scope of the subnet. + type: str + default: private + choices: [ private, public ] + shared: + description: + - Whether this subnet is shared between VRFs. + type: bool + no_default_gateway: + description: + - Whether this subnet has a default gateway. + type: bool + querier: + description: + - Whether this subnet is an IGMP querier. + type: bool + intersite_bum_traffic: + description: + - Whether to allow intersite BUM traffic. + type: bool + optimize_wan_bandwidth: + description: + - Whether to optimize WAN bandwidth. + type: bool + layer2_stretch: + description: + - Whether to enable L2 stretch. + type: bool + default: true + layer2_unknown_unicast: + description: + - Layer2 unknown unicast. + type: str + choices: [ flood, proxy ] + layer3_multicast: + description: + - Whether to enable L3 multicast. + type: bool + unknown_multicast_flooding: + description: + - Unknown Multicast Flooding can either be Flood or Optimized Flooding + type: str + choices: [ flood, optimized_flooding ] + multi_destination_flooding: + description: + - Multi-Destination Flooding can either be Flood in BD or just Drop + type: str + choices: [ flood_in_bd, drop ] + ipv6_unknown_multicast_flooding: + description: + - IPv6 Unknown Multicast Flooding can either be Flood or Optimized Flooding + type: str + choices: [ flood, optimized_flooding ] + arp_flooding: + description: + - ARP Flooding + type: bool + virtual_mac_address: + description: + - Virtual MAC Address + type: 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 +extends_documentation_fragment: cisco.mso.modules +''' + +EXAMPLES = r''' +- name: Add a new BD + cisco.mso.mso_schema_template_bd: + host: mso_host + username: admin + password: SomeSecretPassword + schema: Schema 1 + template: Template 1 + bd: BD 1 + vrf: + name: VRF1 + state: present + delegate_to: localhost + +- name: Add a new BD from another Schema + mso_schema_template_bd: + host: mso_host + username: admin + password: SomeSecretPassword + schema: Schema 1 + template: Template 1 + bd: BD 1 + vrf: + name: VRF1 + 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: + host: mso_host + username: admin + password: SomeSecretPassword + schema: Schema 1 + template: Template 1 + bd: BD 1 + intersite_bum_traffic: true + optimize_wan_bandwidth: false + layer2_stretch: true + layer2_unknown_unicast: flood + layer3_multicast: false + unknown_multicast_flooding: flood + multi_destination_flooding: drop + ipv6_unknown_multicast_flooding: flood + arp_flooding: false + virtual_mac_address: 00:00:5E:00:01:3C + subnets: + - subnet: 10.0.0.128/24 + - subnet: 10.0.1.254/24 + description: 1234567890 + - ip: 192.168.0.254/24 + description: "My description for a subnet" + scope: private + shared: false + no_default_gateway: true + vrf: + name: vrf1 + schema: Test + template: Template1 + dhcp_policy: + name: ansible_test + version: 1 + dhcp_option_policy: + name: ansible_test_option + version: 1 + +- name: Remove an BD + cisco.mso.mso_schema_template_bd: + host: mso_host + username: admin + password: SomeSecretPassword + schema: Schema 1 + template: Template 1 + bd: BD1 + state: absent + delegate_to: localhost + +- name: Query a specific BDs + cisco.mso.mso_schema_template_bd: + host: mso_host + username: admin + password: SomeSecretPassword + schema: Schema 1 + template: Template 1 + bd: BD1 + state: query + delegate_to: localhost + register: query_result + +- name: Query all BDs + cisco.mso.mso_schema_template_bd: + host: mso_host + username: admin + password: SomeSecretPassword + schema: Schema 1 + template: Template 1 + 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_reference_spec, mso_subnet_spec, mso_dhcp_spec + + +def main(): + argument_spec = mso_argument_spec() + argument_spec.update( + schema=dict(type='str', required=True), + template=dict(type='str', required=True), + bd=dict(type='str', aliases=['name']), # This parameter is not required for querying all objects + display_name=dict(type='str'), + intersite_bum_traffic=dict(type='bool'), + optimize_wan_bandwidth=dict(type='bool'), + layer2_stretch=dict(type='bool', default='true'), + layer2_unknown_unicast=dict(type='str', choices=['flood', 'proxy']), + layer3_multicast=dict(type='bool'), + vrf=dict(type='dict', options=mso_reference_spec()), + dhcp_policy=dict(type='dict', options=mso_dhcp_spec()), + subnets=dict(type='list', elements='dict', options=mso_subnet_spec()), + unknown_multicast_flooding=dict(type='str', choices=['optimized_flooding', 'flood']), + multi_destination_flooding=dict(type='str', choices=['flood_in_bd', 'drop']), + ipv6_unknown_multicast_flooding=dict(type='str', choices=['optimized_flooding', 'flood']), + arp_flooding=dict(type='bool'), + virtual_mac_address=dict(type='str'), + state=dict(type='str', default='present', choices=['absent', 'present', 'query']), + ) + + module = AnsibleModule( + argument_spec=argument_spec, + supports_check_mode=True, + required_if=[ + ['state', 'absent', ['bd']], + ['state', 'present', ['bd', 'vrf']], + ], + ) + + schema = module.params.get('schema') + template = module.params.get('template').replace(' ', '') + bd = module.params.get('bd') + display_name = module.params.get('display_name') + intersite_bum_traffic = module.params.get('intersite_bum_traffic') + optimize_wan_bandwidth = module.params.get('optimize_wan_bandwidth') + layer2_stretch = module.params.get('layer2_stretch') + layer2_unknown_unicast = module.params.get('layer2_unknown_unicast') + layer3_multicast = module.params.get('layer3_multicast') + vrf = module.params.get('vrf') + if vrf is not None and vrf.get('template') is not None: + vrf['template'] = vrf.get('template').replace(' ', '') + dhcp_policy = module.params.get('dhcp_policy') + subnets = module.params.get('subnets') + unknown_multicast_flooding = module.params.get('unknown_multicast_flooding') + multi_destination_flooding = module.params.get('multi_destination_flooding') + ipv6_unknown_multicast_flooding = module.params.get('ipv6_unknown_multicast_flooding') + arp_flooding = module.params.get('arp_flooding') + virtual_mac_address = module.params.get('virtual_mac_address') + state = module.params.get('state') + + mso = MSOModule(module) + + # Map choices + if unknown_multicast_flooding == 'optimized_flooding': + unknown_multicast_flooding = 'opt-flood' + if ipv6_unknown_multicast_flooding == 'optimized_flooding': + ipv6_unknown_multicast_flooding = 'opt-flood' + if multi_destination_flooding == 'flood_in_bd': + multi_destination_flooding = 'bd-flood' + + if layer2_unknown_unicast == 'flood': + arp_flooding = True + + # Get schema_id + schema_obj = mso.get_obj('schemas', displayName=schema) + if schema_obj: + schema_id = schema_obj.get('id') + else: + mso.fail_json(msg="Provided schema '{0}' does not exist".format(schema)) + + schema_path = 'schemas/{id}'.format(**schema_obj) + + # 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 BDs + bds = [b.get('name') for b in schema_obj.get('templates')[template_idx]['bds']] + + if bd is not None and bd in bds: + bd_idx = bds.index(bd) + mso.existing = schema_obj.get('templates')[template_idx]['bds'][bd_idx] + + if state == 'query': + if bd is None: + mso.existing = schema_obj.get('templates')[template_idx]['bds'] + elif not mso.existing: + mso.fail_json(msg="BD '{bd}' not found".format(bd=bd)) + mso.exit_json() + + bds_path = '/templates/{0}/bds'.format(template) + bd_path = '/templates/{0}/bds/{1}'.format(template, bd) + ops = [] + + mso.previous = mso.existing + if state == 'absent': + if mso.existing: + mso.sent = mso.existing = {} + ops.append(dict(op='remove', path=bd_path)) + + elif state == 'present': + vrf_ref = mso.make_reference(vrf, 'vrf', schema_id, template) + subnets = mso.make_subnets(subnets) + dhcp_label = mso.make_dhcp_label(dhcp_policy) + + if display_name is None and not mso.existing: + display_name = bd + if subnets is None and not mso.existing: + subnets = [] + + payload = dict( + name=bd, + displayName=display_name, + intersiteBumTrafficAllow=intersite_bum_traffic, + optimizeWanBandwidth=optimize_wan_bandwidth, + l2UnknownUnicast=layer2_unknown_unicast, + l2Stretch=layer2_stretch, + l3MCast=layer3_multicast, + subnets=subnets, + vrfRef=vrf_ref, + dhcpLabel=dhcp_label, + unkMcastAct=unknown_multicast_flooding, + multiDstPktAct=multi_destination_flooding, + v6unkMcastAct=ipv6_unknown_multicast_flooding, + vmac=virtual_mac_address, + arpFlood=arp_flooding, + ) + + mso.sanitize(payload, collate=True, required=['dhcpLabel']) + if mso.existing: + ops.append(dict(op='replace', path=bd_path, value=mso.sent)) + else: + ops.append(dict(op='add', path=bds_path + '/-', value=mso.sent)) + mso.existing = mso.proposed + + if 'bdRef' in mso.previous: + del mso.previous['bdRef'] + if 'vrfRef' in mso.previous: + mso.previous['vrfRef'] = mso.vrf_dict_from_ref(mso.previous.get('vrfRef')) + + if not module.check_mode and mso.proposed != mso.previous: + mso.request(schema_path, method='PATCH', data=ops) + + mso.exit_json() + + +if __name__ == "__main__": + main() diff --git a/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_bd_subnet.py b/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_bd_subnet.py new file mode 100644 index 00000000..fd95c311 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_bd_subnet.py @@ -0,0 +1,253 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright: (c) 2018, Dag Wieers (@dagwieers) +# 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_template_bd_subnet +short_description: Manage BD subnets in schema templates +description: +- Manage BD subnets in schema templates on Cisco ACI Multi-Site. +author: +- Dag Wieers (@dagwieers) +options: + schema: + description: + - The name of the schema. + type: str + required: yes + template: + description: + - The name of the template to change. + type: str + required: yes + bd: + description: + - The name of the BD to manage. + type: str + required: yes + subnet: + description: + - The IP range in CIDR notation. + type: str + aliases: [ ip ] + description: + description: + - The description of this subnet. + type: str + is_virtual_ip: + description: + - Treat as Virtual IP Address + type: bool + default: false + scope: + description: + - The scope of the subnet. + type: str + default: private + choices: [ private, public ] + shared: + description: + - Whether this subnet is shared between VRFs. + type: bool + no_default_gateway: + description: + - Whether this subnet has a default gateway. + type: bool + querier: + description: + - Whether this subnet is an IGMP querier. + type: bool + 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 +notes: +- Due to restrictions of the MSO REST API concurrent modifications to BD subnets can be dangerous and corrupt data. +extends_documentation_fragment: cisco.mso.modules +''' + +EXAMPLES = r''' +- name: Add a new subnet to a BD + cisco.mso.mso_schema_template_bd_subnet: + host: mso_host + username: admin + password: SomeSecretPassword + schema: Schema 1 + template: Template 1 + 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: + host: mso_host + username: admin + password: SomeSecretPassword + schema: Schema 1 + template: Template 1 + 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: + host: mso_host + username: admin + password: SomeSecretPassword + schema: Schema 1 + template: Template 1 + bd: BD 1 + subnet: 10.0.0.0/24 + state: query + delegate_to: localhost + register: query_result + +- name: Query all BD subnets + cisco.mso.mso_schema_template_bd_subnet: + host: mso_host + username: admin + password: SomeSecretPassword + schema: Schema 1 + template: Template 1 + bd: BD 1 + 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 + + +def main(): + argument_spec = mso_argument_spec() + argument_spec.update( + schema=dict(type='str', required=True), + template=dict(type='str', required=True), + bd=dict(type='str', required=True), + subnet=dict(type='str', aliases=['ip']), + description=dict(type='str'), + is_virtual_ip=dict(type='bool', default=False), + scope=dict(type='str', default='private', choices=['private', 'public']), + shared=dict(type='bool', default=False), + no_default_gateway=dict(type='bool', default=False), + querier=dict(type='bool', default=False), + state=dict(type='str', default='present', choices=['absent', 'present', 'query']), + ) + + module = AnsibleModule( + argument_spec=argument_spec, + supports_check_mode=True, + required_if=[ + ['state', 'absent', ['subnet']], + ['state', 'present', ['subnet']], + ], + ) + + schema = module.params.get('schema') + template = module.params.get('template').replace(' ', '') + bd = module.params.get('bd') + subnet = module.params.get('subnet') + description = module.params.get('description') + is_virtual_ip = module.params.get('is_virtual_ip') + scope = module.params.get('scope') + shared = module.params.get('shared') + no_default_gateway = module.params.get('no_default_gateway') + querier = module.params.get('querier') + state = module.params.get('state') + + mso = MSOModule(module) + + # Get schema + schema_obj = mso.get_obj('schemas', displayName=schema) + if not schema_obj: + mso.fail_json(msg="Provided schema '{0}' does not exist".format(schema)) + + schema_path = 'schemas/{id}'.format(**schema_obj) + + # 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 BD + bds = [b.get('name') for b in schema_obj.get('templates')[template_idx]['bds']] + if bd not in bds: + mso.fail_json(msg="Provided BD '{0}' does not exist. Existing BDs: {1}".format(bd, ', '.join(bds))) + bd_idx = bds.index(bd) + + # Get Subnet + subnets = [s.get('ip') for s in schema_obj.get('templates')[template_idx]['bds'][bd_idx]['subnets']] + if subnet in subnets: + subnet_idx = subnets.index(subnet) + # FIXME: Changes based on index are DANGEROUS + subnet_path = '/templates/{0}/bds/{1}/subnets/{2}'.format(template, bd, subnet_idx) + mso.existing = schema_obj.get('templates')[template_idx]['bds'][bd_idx]['subnets'][subnet_idx] + + if state == 'query': + if subnet is None: + mso.existing = schema_obj.get('templates')[template_idx]['bds'][bd_idx]['subnets'] + elif not mso.existing: + mso.fail_json(msg="Subnet IP '{subnet}' not found".format(subnet=subnet)) + mso.exit_json() + + subnets_path = '/templates/{0}/bds/{1}/subnets'.format(template, bd) + ops = [] + + mso.previous = mso.existing + if state == 'absent': + if mso.existing: + mso.sent = mso.existing = {} + ops.append(dict(op='remove', path=subnet_path)) + + elif state == 'present': + if not mso.existing: + if description is None: + description = subnet + + payload = dict( + ip=subnet, + description=description, + virtual=is_virtual_ip, + scope=scope, + shared=shared, + noDefaultGateway=no_default_gateway, + querier=querier, + ) + + mso.sanitize(payload, collate=True) + + if mso.existing: + ops.append(dict(op='replace', path=subnet_path, value=mso.sent)) + else: + ops.append(dict(op='add', path=subnets_path + '/-', value=mso.sent)) + + mso.existing = mso.proposed + + if not module.check_mode: + mso.request(schema_path, method='PATCH', data=ops) + + mso.exit_json() + + +if __name__ == "__main__": + main() diff --git a/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_contract_filter.py b/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_contract_filter.py new file mode 100644 index 00000000..ab5d0466 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_contract_filter.py @@ -0,0 +1,352 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright: (c) 2018, Dag Wieers (@dagwieers) +# 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_template_contract_filter +short_description: Manage contract filters in schema templates +description: +- Manage contract filters in schema templates on Cisco ACI Multi-Site. +author: +- Dag Wieers (@dagwieers) +options: + schema: + description: + - The name of the schema. + type: str + required: yes + template: + description: + - The name of the template. + type: str + required: yes + contract: + description: + - The name of the contract to manage. + type: str + required: yes + contract_display_name: + description: + - The name as displayed on the MSO web interface. + - This defaults to the contract name when unset on creation. + type: str + contract_filter_type: + description: + - The type of filters defined in this contract. + - This defaults to C(both-way) when unset on creation. + default: both-way + type: str + choices: [ both-way, one-way ] + contract_scope: + description: + - The scope of the contract. + - This defaults to C(vrf) when unset on creation. + type: str + choices: [ application-profile, global, tenant, vrf ] + filter: + description: + - The filter to associate with this contract. + type: str + aliases: [ name ] + filter_template: + description: + - The template name in which the filter is located. + type: str + filter_schema: + description: + - The schema name in which the filter is located. + type: str + filter_type: + description: + - The type of filter to manage. + type: str + choices: [ both-way, consumer-to-provider, provider-to-consumer ] + default: both-way + aliases: [ type ] + filter_directives: + description: + - A list of filter directives. + type: list + elements: str + choices: [ log, none, policy_compression ] + 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_filter_entry +notes: +- Due to restrictions of the MSO REST API this module creates contracts when needed, and removes them when the last filter has been removed. +- Due to restrictions of the MSO REST API concurrent modifications to contract filters can be dangerous and corrupt data. +extends_documentation_fragment: cisco.mso.modules +''' + +EXAMPLES = r''' +- name: Add a new contract filter + cisco.mso.mso_schema_template_contract_filter: + host: mso_host + username: admin + password: SomeSecretPassword + schema: Schema 1 + template: Template 1 + contract: Contract 1 + contract_scope: global + filter: Filter 1 + state: present + delegate_to: localhost + +- name: Remove a contract filter + cisco.mso.mso_schema_template_contract_filter: + host: mso_host + username: admin + password: SomeSecretPassword + schema: Schema 1 + template: Template 1 + contract: Contract 1 + filter: Filter 1 + state: absent + delegate_to: localhost + +- name: Query a specific contract filter + cisco.mso.mso_schema_template_contract_filter: + host: mso_host + username: admin + password: SomeSecretPassword + schema: Schema 1 + template: Template 1 + contract: Contract 1 + filter: Filter 1 + state: query + delegate_to: localhost + register: query_result + +- name: Query all contract filters + cisco.mso.mso_schema_template_contract_filter: + host: mso_host + username: admin + password: SomeSecretPassword + schema: Schema 1 + template: Template 1 + contract: Contract 1 + 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 + +FILTER_KEYS = { + 'both-way': 'filterRelationships', + 'consumer-to-provider': 'filterRelationshipsConsumerToProvider', + 'provider-to-consumer': 'filterRelationshipsProviderToConsumer', +} + + +def main(): + + argument_spec = mso_argument_spec() + argument_spec.update( + schema=dict(type='str', required=True), + template=dict(type='str', required=True), + contract=dict(type='str', required=True), + contract_display_name=dict(type='str'), + contract_scope=dict(type='str', choices=['application-profile', 'global', 'tenant', 'vrf']), + contract_filter_type=dict(type='str', default='both-way', choices=['both-way', 'one-way']), + filter=dict(type='str', aliases=['name']), # This parameter is not required for querying all objects + filter_directives=dict(type='list', elements='str', choices=['log', 'none', 'policy_compression']), + filter_template=dict(type='str'), + filter_schema=dict(type='str'), + filter_type=dict(type='str', default='both-way', choices=list(FILTER_KEYS), aliases=['type']), + state=dict(type='str', default='present', choices=['absent', 'present', 'query']), + ) + + module = AnsibleModule( + argument_spec=argument_spec, + supports_check_mode=True, + required_if=[ + ['state', 'absent', ['filter']], + ['state', 'present', ['filter']], + ], + ) + + schema = module.params.get('schema') + template = module.params.get('template').replace(' ', '') + contract = module.params.get('contract') + contract_display_name = module.params.get('contract_display_name') + contract_filter_type = module.params.get('contract_filter_type') + contract_scope = module.params.get('contract_scope') + filter_name = module.params.get('filter') + filter_directives = module.params.get('filter_directives') + filter_template = module.params.get('filter_template') + if filter_template is not None: + filter_template = filter_template.replace(' ', '') + filter_schema = module.params.get('filter_schema') + filter_type = module.params.get('filter_type') + state = module.params.get('state') + + mso = MSOModule(module) + + contract_ftype = 'bothWay' if contract_filter_type == 'both-way' else 'oneWay' + + if contract_filter_type == 'both-way' and filter_type != 'both-way': + mso.fail_json(msg="You are adding 'one-way' filters to a 'both-way' contract") + elif contract_filter_type != 'both-way' and filter_type == 'both-way': + mso.fail_json(msg="You are adding 'both-way' filters to a 'one-way' contract") + if filter_template is None: + filter_template = template + + if filter_schema is None: + filter_schema = schema + + filter_key = FILTER_KEYS.get(filter_type) + + # Get schema object + schema_obj = mso.get_obj('schemas', displayName=schema) + if not schema_obj: + mso.fail_json(msg="Provided schema '{0}' does not exist".format(schema)) + + schema_path = 'schemas/{id}'.format(**schema_obj) + + # 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) + + filter_schema_id = mso.lookup_schema(filter_schema) + # Get contracts + + mso.existing = {} + contract_idx = None + filter_idx = None + contracts = [c.get('name') for c in schema_obj.get('templates')[template_idx]['contracts']] + + if contract in contracts: + contract_idx = contracts.index(contract) + contract_obj = schema_obj.get('templates')[template_idx]['contracts'][contract_idx] + + filters = [f.get('filterRef') for f in schema_obj.get('templates')[template_idx]['contracts'][contract_idx][filter_key]] + filter_ref = mso.filter_ref(schema_id=filter_schema_id, template=filter_template, filter=filter_name) + if filter_ref in filters: + filter_idx = filters.index(filter_ref) + filter_path = '/templates/{0}/contracts/{1}/{2}/{3}'.format(template, contract, filter_key, filter_name) + filter = contract_obj.get(filter_key)[filter_idx] + mso.existing = mso.update_filter_obj(contract_obj, filter, filter_type) + + if state == 'query': + if contract_idx is None: + mso.fail_json(msg="Provided contract '{0}' does not exist. Existing contracts: {1}".format(contract, ', '.join(contracts))) + + if filter_name is None: + mso.existing = contract_obj.get(filter_key) + for filter in mso.existing: + filter = mso.update_filter_obj(contract_obj, filter, filter_type) + + elif not mso.existing: + mso.fail_json(msg="FilterRef '{filter_ref}' not found".format(filter_ref=filter_ref)) + mso.exit_json() + + ops = [] + contract_path = '/templates/{0}/contracts/{1}'.format(template, contract) + filters_path = '/templates/{0}/contracts/{1}/{2}'.format(template, contract, filter_key) + mso.previous = mso.existing + + if state == 'absent': + mso.proposed = mso.sent = {} + + if contract_idx is None: + # There was no contract to begin with + pass + elif filter_idx is None: + # There was no filter to begin with + pass + elif len(filters) == 1: + # There is only one filter, remove contract + mso.existing = {} + ops.append(dict(op='remove', path=contract_path)) + else: + # Remove filter + mso.existing = {} + ops.append(dict(op='remove', path=filter_path)) + + elif state == 'present': + if filter_directives is None: + filter_directives = ['none'] + + if 'policy_compression' in filter_directives: + filter_directives.remove('policy_compression') + filter_directives.append('no_stats') + + payload = dict( + filterRef=dict( + filterName=filter_name, + templateName=filter_template, + schemaId=filter_schema_id, + ), + directives=filter_directives, + ) + + mso.sanitize(payload, collate=True, unwanted=['filterType', 'contractScope', 'contractFilterType']) + mso.existing = mso.sent + if contract_scope is None or contract_scope == 'vrf': + contract_scope = 'context' + if contract_idx is None: + # Contract does not exist, so we have to create it + if contract_display_name is None: + contract_display_name = contract + payload = { + 'name': contract, + 'displayName': contract_display_name, + 'filterType': contract_ftype, + 'scope': contract_scope, + } + ops.append(dict(op='add', path='/templates/{0}/contracts/-'.format(template), value=payload)) + + else: + # Contract exists, but may require an update + if contract_display_name is not None: + ops.append(dict(op='replace', path=contract_path + '/displayName', value=contract_display_name)) + ops.append(dict(op='replace', path=contract_path + '/filterType', value=contract_ftype)) + ops.append(dict(op='replace', path=contract_path + '/scope', value=contract_scope)) + + if contract_display_name: + mso.existing['displayName'] = contract_display_name + else: + mso.existing['displayName'] = contract_obj.get('displayName') + mso.existing['filterType'] = filter_type + mso.existing['contractScope'] = contract_scope + mso.existing['contractFilterType'] = contract_ftype + + if filter_idx is None: + # Filter does not exist, so we have to add it + ops.append(dict(op='add', path=filters_path + '/-', value=mso.sent)) + + else: + # Filter exists, we have to update it + ops.append(dict(op='replace', path=filter_path, value=mso.sent)) + + if not module.check_mode and mso.existing != mso.previous: + mso.request(schema_path, method='PATCH', data=ops) + + mso.exit_json() + + +if __name__ == "__main__": + main() diff --git a/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_deploy.py b/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_deploy.py new file mode 100644 index 00000000..a05c618f --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_deploy.py @@ -0,0 +1,143 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright: (c) 2018, Dag Wieers (@dagwieers) +# 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_template_deploy +short_description: Deploy schema templates to sites +description: +- Deploy schema templates to sites. +author: +- Dag Wieers (@dagwieers) +options: + schema: + description: + - The name of the schema. + type: str + required: yes + template: + description: + - The name of the template. + type: str + required: yes + aliases: [ name ] + site: + description: + - The name of the site B(to undeploy). + type: str + state: + description: + - Use C(deploy) to deploy schema template. + - Use C(status) to get deployment status. + - Use C(undeploy) to deploy schema template from a site. + type: str + choices: [ deploy, status, undeploy ] + default: deploy +seealso: +- module: cisco.mso.mso_schema_site +- module: cisco.mso.mso_schema_template +extends_documentation_fragment: cisco.mso.modules +''' + +EXAMPLES = r''' +- name: Deploy a schema template + cisco.mso.mso_schema_template_deploy: + host: mso_host + username: admin + password: SomeSecretPassword + schema: Schema 1 + template: Template 1 + state: deploy + delegate_to: localhost + +- name: Undeploy a schema template + cisco.mso.mso_schema_template_deploy: + host: mso_host + username: admin + password: SomeSecretPassword + schema: Schema 1 + template: Template 1 + site: Site 1 + state: undeploy + delegate_to: localhost + +- name: Get deployment status + cisco.mso.mso_schema: + host: mso_host + username: admin + password: SomeSecretPassword + schema: Schema 1 + template: Template 1 + state: status + delegate_to: localhost + register: status_result +''' + +RETURN = r''' +''' + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.cisco.mso.plugins.module_utils.mso import MSOModule, mso_argument_spec + + +def main(): + argument_spec = mso_argument_spec() + argument_spec.update( + schema=dict(type='str', required=True), + template=dict(type='str', required=True, aliases=['name']), + site=dict(type='str'), + state=dict(type='str', default='deploy', choices=['deploy', 'status', 'undeploy']), + ) + + module = AnsibleModule( + argument_spec=argument_spec, + supports_check_mode=True, + required_if=[ + ['state', 'undeploy', ['site']], + ], + ) + + schema = module.params.get('schema') + template = module.params.get('template').replace(' ', '') + site = module.params.get('site') + state = module.params.get('state') + + mso = MSOModule(module) + + # Get schema + schema_id = mso.lookup_schema(schema) + + payload = dict( + schemaId=schema_id, + templateName=template, + ) + + qs = None + if state == 'deploy': + path = 'execute/schema/{0}/template/{1}'.format(schema_id, template) + elif state == 'status': + path = 'status/schema/{0}/template/{1}'.format(schema_id, template) + elif state == 'undeploy': + path = 'execute/schema/{0}/template/{1}'.format(schema_id, template) + site_id = mso.lookup_site(site) + qs = dict(undeploy=site_id) + + if not module.check_mode: + status = mso.request(path, method='GET', data=payload, qs=qs) + mso.exit_json(**status) + else: + mso.exit_json() + + +if __name__ == "__main__": + main() diff --git a/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_external_epg.py b/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_external_epg.py new file mode 100644 index 00000000..1831cb85 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_external_epg.py @@ -0,0 +1,332 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright: (c) 2018, Dag Wieers (@dagwieers) +# 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_template_external_epg +short_description: Manage external EPGs in schema templates +description: +- Manage external EPGs in schema templates on Cisco ACI Multi-Site. +author: +- Dag Wieers (@dagwieers) +options: + schema: + description: + - The name of the schema. + type: str + required: yes + template: + description: + - The name of the template. + type: str + required: yes + external_epg: + description: + - The name of the external EPG to manage. + type: str + aliases: [ name, externalepg ] + type: + description: + - The type of external epg. + - anp needs to be associated with external epg when the type is cloud. + - l3out can be associated with external epg when the type is on-premise. + type: str + choices: [ on-premise, cloud ] + default: on-premise + display_name: + description: + - The name as displayed on the MSO web interface. + type: str + vrf: + description: + - The VRF associated with the external epg. + type: dict + suboptions: + name: + description: + - The name of the VRF to associate with. + required: true + type: str + schema: + description: + - The schema that defines the referenced VRF. + - If this parameter is unspecified, it defaults to the current schema. + type: str + template: + description: + - The template that defines the referenced VRF. + - If this parameter is unspecified, it defaults to the current template. + type: str + l3out: + description: + - The L3Out associated with the external epg. + type: dict + suboptions: + name: + description: + - The name of the L3Out to associate with. + required: true + type: str + schema: + description: + - The schema that defines the referenced L3Out. + - If this parameter is unspecified, it defaults to the current schema. + type: str + template: + description: + - The template that defines the referenced L3Out. + - If this parameter is unspecified, it defaults to the current template. + type: str + anp: + description: + - The anp associated with the external epg. + type: dict + suboptions: + name: + description: + - The name of the anp to associate with. + required: true + type: str + schema: + description: + - The schema that defines the referenced anp. + - If this parameter is unspecified, it defaults to the current schema. + type: str + template: + description: + - The template that defines the referenced anp. + - If this parameter is unspecified, it defaults to the current template. + type: str + preferred_group: + description: + - Preferred Group is enabled for this External EPG or not. + type: bool + 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 +extends_documentation_fragment: cisco.mso.modules +''' + +EXAMPLES = r''' +- name: Add a new external EPG + cisco.mso.mso_schema_template_external_epg: + host: mso_host + username: admin + password: SomeSecretPassword + schema: Schema 1 + template: Template 1 + external_epg: External EPG 1 + vrf: + name: VRF + 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: + host: mso_host + username: admin + password: SomeSecretPassword + schema: Schema 1 + template: Template 1 + external_epg: External EPG 1 + type: cloud + vrf: + name: VRF + schema: Schema 1 + template: Template 1 + anp: + name: ANP1 + schema: Schema 1 + template: Template 1 + state: present + delegate_to: localhost + +- name: Remove an external EPG + cisco.mso.mso_schema_template_external_epg: + host: mso_host + username: admin + password: SomeSecretPassword + schema: Schema 1 + 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: + host: mso_host + username: admin + password: SomeSecretPassword + schema: Schema 1 + template: Template 1 + external_epg: external EPG1 + state: query + delegate_to: localhost + register: query_result + +- name: Query all external EPGs + cisco.mso.mso_schema_template_external_epg: + host: mso_host + username: admin + password: SomeSecretPassword + schema: Schema 1 + template: Template 1 + 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_reference_spec + + +def main(): + argument_spec = mso_argument_spec() + argument_spec.update( + schema=dict(type='str', required=True), + template=dict(type='str', required=True), + external_epg=dict(type='str', aliases=['name', 'externalepg']), # This parameter is not required for querying all objects + display_name=dict(type='str'), + vrf=dict(type='dict', options=mso_reference_spec()), + l3out=dict(type='dict', options=mso_reference_spec()), + anp=dict(type='dict', options=mso_reference_spec()), + preferred_group=dict(type='bool'), + type=dict(type='str', default='on-premise', choices=['on-premise', 'cloud']), + state=dict(type='str', default='present', choices=['absent', 'present', 'query']), + ) + + module = AnsibleModule( + argument_spec=argument_spec, + supports_check_mode=True, + required_if=[ + ['state', 'absent', ['external_epg']], + ['state', 'present', ['external_epg', 'vrf']], + ['type', 'cloud', ['anp']], + ], + ) + + schema = module.params.get('schema') + template = module.params.get('template').replace(' ', '') + external_epg = module.params.get('external_epg') + display_name = module.params.get('display_name') + vrf = module.params.get('vrf') + if vrf is not None and vrf.get('template') is not None: + vrf['template'] = vrf.get('template').replace(' ', '') + l3out = module.params.get('l3out') + if l3out is not None and l3out.get('template') is not None: + l3out['template'] = l3out.get('template').replace(' ', '') + anp = module.params.get('anp') + if anp is not None and anp.get('template') is not None: + anp['template'] = anp.get('template').replace(' ', '') + preferred_group = module.params.get('preferred_group') + type_ext_epg = module.params.get('type') + state = module.params.get('state') + + mso = MSOModule(module) + + # Get schema_id + schema_obj = mso.get_obj('schemas', displayName=schema) + if schema_obj: + schema_id = schema_obj.get('id') + else: + mso.fail_json(msg="Provided schema '{0}' does not exist".format(schema)) + + schema_path = 'schemas/{id}'.format(**schema_obj) + + # 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 external EPGs + external_epgs = [e.get('name') for e in schema_obj.get('templates')[template_idx]['externalEpgs']] + + if external_epg is not None and external_epg in external_epgs: + external_epg_idx = external_epgs.index(external_epg) + mso.existing = schema_obj.get('templates')[template_idx]['externalEpgs'][external_epg_idx] + if 'externalEpgRef' in mso.existing: + del mso.existing['externalEpgRef'] + if 'vrfRef' in mso.existing: + mso.existing['vrfRef'] = mso.dict_from_ref(mso.existing.get('vrfRef')) + if 'l3outRef' in mso.existing: + mso.existing['l3outRef'] = mso.dict_from_ref(mso.existing.get('l3outRef')) + if 'anpRef' in mso.existing: + mso.existing['anpRef'] = mso.dict_from_ref(mso.existing.get('anpRef')) + + if state == 'query': + if external_epg is None: + mso.existing = schema_obj.get('templates')[template_idx]['externalEpgs'] + elif not mso.existing: + mso.fail_json(msg="External EPG '{external_epg}' not found".format(external_epg=external_epg)) + mso.exit_json() + + eepgs_path = '/templates/{0}/externalEpgs'.format(template) + eepg_path = '/templates/{0}/externalEpgs/{1}'.format(template, external_epg) + ops = [] + + mso.previous = mso.existing + if state == 'absent': + if mso.existing: + mso.sent = mso.existing = {} + ops.append(dict(op='remove', path=eepg_path)) + + elif state == 'present': + vrf_ref = mso.make_reference(vrf, 'vrf', schema_id, template) + l3out_ref = mso.make_reference(l3out, 'l3out', schema_id, template) + anp_ref = mso.make_reference(anp, 'anp', schema_id, template) + if display_name is None and not mso.existing: + display_name = external_epg + + payload = dict( + name=external_epg, + displayName=display_name, + vrfRef=vrf_ref, + preferredGroup=preferred_group, + ) + + if type_ext_epg == 'cloud': + payload['extEpgType'] = 'cloud' + payload['anpRef'] = anp_ref + else: + payload['l3outRef'] = l3out_ref + + mso.sanitize(payload, collate=True) + + if mso.existing: + # clean contractRef to fix api issue + for contract in mso.sent.get('contractRelationships'): + contract['contractRef'] = mso.dict_from_ref(contract.get('contractRef')) + ops.append(dict(op='replace', path=eepg_path, value=mso.sent)) + else: + ops.append(dict(op='add', path=eepgs_path + '/-', value=mso.sent)) + + mso.existing = mso.proposed + + if not module.check_mode: + mso.request(schema_path, method='PATCH', data=ops) + + mso.exit_json() + + +if __name__ == "__main__": + main() diff --git a/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_external_epg_contract.py b/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_external_epg_contract.py new file mode 100644 index 00000000..9db905bd --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_external_epg_contract.py @@ -0,0 +1,250 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +from __future__ import absolute_import, division, print_function +__metaclass__ = type + +ANSIBLE_METADATA = {'metadata_version': '1.1', + 'status': ['preview'], + 'supported_by': 'community'} + +DOCUMENTATION = r''' +--- +module: mso_schema_template_external_epg_contract +short_description: Manage Extrnal EPG contracts in schema templates +description: +- Manage External EPG contracts in schema templates on Cisco ACI Multi-Site. +author: +- Devarshi Shah (@devarshishah3) +version_added: '0.0.8' +options: + schema: + description: + - The name of the schema. + type: str + required: yes + template: + description: + - The name of the template to change. + type: str + required: yes + external_epg: + description: + - The name of the EPG to manage. + type: str + required: yes + contract: + description: + - A contract associated to this EPG. + type: dict + suboptions: + name: + description: + - The name of the Contract to associate with. + required: true + type: str + schema: + description: + - The schema that defines the referenced BD. + - If this parameter is unspecified, it defaults to the current schema. + type: str + template: + description: + - The template that defines the referenced BD. + type: str + type: + description: + - The type of contract. + type: str + required: true + choices: [ consumer, provider ] + 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_external_epg +- module: cisco.mso.mso_schema_template_contract_filter +extends_documentation_fragment: cisco.mso.modules +''' + +EXAMPLES = r''' +- name: Add a contract to an EPG + cisco.mso.mso_schema_template_external_epg_contract: + host: mso_host + username: admin + password: SomeSecretPassword + schema: Schema 1 + template: Template 1 + epg: EPG 1 + contract: + name: Contract 1 + type: consumer + state: present + delegate_to: localhost + +- name: Remove a Contract + cisco.mso.mso_schema_template_external_epg_contract: + host: mso_host + username: admin + password: SomeSecretPassword + schema: Schema 1 + template: Template 1 + epg: EPG 1 + contract: + name: Contract 1 + state: absent + delegate_to: localhost + +- name: Query a specific Contract + cisco.mso.mso_schema_template_external_epg_contract: + host: mso_host + username: admin + password: SomeSecretPassword + schema: Schema 1 + template: Template 1 + epg: EPG 1 + contract: + name: Contract 1 + state: query + delegate_to: localhost + register: query_result + +- name: Query all Contracts + cisco.mso.mso_schema_template_external_epg_contract: + host: mso_host + username: admin + password: SomeSecretPassword + schema: Schema 1 + template: Template 1 + 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_contractref_spec + + +def main(): + argument_spec = mso_argument_spec() + argument_spec.update( + schema=dict(type='str', required=True), + template=dict(type='str', required=True), + external_epg=dict(type='str', required=True), + contract=dict(type='dict', options=mso_contractref_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']], + ], + ) + + schema = module.params.get('schema') + template = module.params.get('template').replace(' ', '') + external_epg = module.params.get('external_epg') + contract = module.params.get('contract') + if contract is not None and contract.get('template') is not None: + contract['template'] = contract.get('template').replace(' ', '') + state = module.params.get('state') + + mso = MSOModule(module) + + 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_id + schema_obj = mso.get_obj('schemas', displayName=schema) + if not schema_obj: + mso.fail_json(msg="Provided schema '{0}' does not exist".format(schema)) + + schema_path = 'schemas/{id}'.format(**schema_obj) + + # 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 EPG + epgs = [e.get('name') for e in schema_obj.get('templates')[template_idx]['externalEpgs']] + if external_epg not in epgs: + mso.fail_json(msg="Provided epg '{epg}' does not exist. Existing epgs: {epgs}".format(epg=external_epg, epgs=', '.join(epgs))) + epg_idx = epgs.index(external_epg) + + # Get Contract + if contract: + contracts = [(c.get('contractRef'), + c.get('relationshipType')) for c in schema_obj.get('templates')[template_idx]['externalEpgs'][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}/externalEpgs/{1}/contractRelationships/{2}'.format(template, external_epg, contract_idx) + mso.existing = schema_obj.get('templates')[template_idx]['externalEpgs'][epg_idx]['contractRelationships'][contract_idx] + + if state == 'query': + if not contract: + mso.existing = schema_obj.get('templates')[template_idx]['externalEpgs'][epg_idx]['contractRelationships'] + 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.exit_json() + + contracts_path = '/templates/{0}/externalEpgs/{1}/contractRelationships'.format(template, external_epg) + ops = [] + + mso.previous = mso.existing + if state == 'absent': + if mso.existing: + mso.sent = mso.existing = {} + ops.append(dict(op='remove', path=contract_path)) + + elif state == 'present': + payload = dict( + relationshipType=contract.get('type'), + contractRef=dict( + contractName=contract.get('name'), + templateName=contract.get('template'), + schemaId=contract.get('schema_id'), + ), + ) + + 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)) + + 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) + + mso.exit_json() + + +if __name__ == "__main__": + main() diff --git a/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_external_epg_selector.py b/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_external_epg_selector.py new file mode 100644 index 00000000..0ed2cc3d --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_external_epg_selector.py @@ -0,0 +1,249 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright: (c) 2020, Shreyas Srish (@shrsr) +# Copyright: (c) 2020, Cindy Zhao (@cizhao) +# 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_template_external_epg_selector +short_description: Manage External EPG selector in schema templates +description: +- Manage External EPG selector in schema templates on Cisco ACI Multi-Site. +author: +- Shreyas Srish (@shrsr) +- Cindy Zhao (@cizhao) +options: + schema: + description: + - The name of the schema. + type: str + required: yes + template: + description: + - The name of the template to change. + type: str + required: yes + external_epg: + description: + - The name of the External EPG to be managed. + type: str + required: yes + selector: + description: + - The name of the selector. + type: str + expressions: + description: + - Expressions associated to this selector. + type: list + elements: dict + suboptions: + type: + description: + - The name of the expression which in this case is always IP address. + required: true + type: str + choices: [ ip_address ] + operator: + description: + - The operator associated with the expression which in this case is always equals. + required: true + type: str + choices: [ equals ] + value: + description: + - The value of the IP Address / Subnet associated with the expression. + required: true + type: 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_external_epg +extends_documentation_fragment: cisco.mso.modules +''' + +EXAMPLES = r''' +- name: Add a selector to an External EPG + cisco.mso.mso_schema_template_external_epg_selector: + host: mso_host + username: admin + password: SomeSecretPassword + schema: Schema 1 + template: Template 1 + external_epg: extEPG 1 + selector: selector_1 + expressions: + - type: ip_address + operator: equals + value: 10.0.0.0 + state: present + delegate_to: localhost + +- name: Remove a Selector + cisco.mso.mso_schema_template_external_epg_selector: + host: mso_host + username: admin + password: SomeSecretPassword + schema: Schema 1 + template: Template 1 + 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: + host: mso_host + username: admin + password: SomeSecretPassword + schema: Schema 1 + template: Template 1 + external_epg: extEPG 1 + selector: selector_1 + state: query + delegate_to: localhost + register: query_result + +- name: Query all Selectors + cisco.mso.mso_schema_template_external_epg_selector: + host: mso_host + username: admin + password: SomeSecretPassword + schema: Schema 1 + template: Template 1 + external_epg: extEPG 1 + 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_expression_spec_ext_epg + + +def main(): + argument_spec = mso_argument_spec() + argument_spec.update( + schema=dict(type='str', required=True), + template=dict(type='str', required=True), + external_epg=dict(type='str', required=True), + selector=dict(type='str'), + expressions=dict(type='list', elements='dict', options=mso_expression_spec_ext_epg()), + state=dict(type='str', default='present', choices=['absent', 'present', 'query']), + ) + + module = AnsibleModule( + argument_spec=argument_spec, + supports_check_mode=True, + required_if=[ + ['state', 'absent', ['selector']], + ['state', 'present', ['selector']], + ], + ) + + schema = module.params.get('schema') + template = module.params.get('template').replace(' ', '') + external_epg = module.params.get('external_epg') + selector = module.params.get('selector') + expressions = module.params.get('expressions') + state = module.params.get('state') + + mso = MSOModule(module) + + # Get schema_id + schema_obj = mso.get_obj('schemas', displayName=schema) + if not schema_obj: + mso.fail_json(msg="Provided schema '{0}' does not exist".format(schema)) + + schema_path = 'schemas/{id}'.format(**schema_obj) + + # Get template + templates = [t.get('name') for t in schema_obj.get('templates')] + if template not in templates: + mso.fail_json(msg="Provided template '{template}' does not exist. Existing templates: {templates}".format(template=template, + templates=', '.join(templates))) + template_idx = templates.index(template) + + # Get External EPG + external_epgs = [e.get('name') for e in schema_obj.get('templates')[template_idx]['externalEpgs']] + if external_epg not in external_epgs: + mso.fail_json(msg="Provided external epg '{external_epg}' does not exist. Existing epgs: {external_epgs}" + .format(external_epg=external_epg, external_epgs=', '.join(external_epgs))) + external_epg_idx = external_epgs.index(external_epg) + + # Get Selector + selectors = [s.get('name') for s in schema_obj.get('templates')[template_idx]['externalEpgs'][external_epg_idx]['selectors']] + if selector in selectors: + selector_idx = selectors.index(selector) + selector_path = '/templates/{0}/externalEpgs/{1}/selectors/{2}'.format(template, external_epg, selector_idx) + mso.existing = schema_obj.get('templates')[template_idx]['externalEpgs'][external_epg_idx]['selectors'][selector_idx] + + if state == 'query': + if selector is None: + mso.existing = schema_obj.get('templates')[template_idx]['externalEpgs'][external_epg_idx]['selectors'] + elif not mso.existing: + mso.fail_json(msg="Selector '{selector}' not found".format(selector=selector)) + mso.exit_json() + + selectors_path = '/templates/{0}/externalEpgs/{1}/selectors/-'.format(template, external_epg) + ops = [] + + mso.previous = mso.existing + if state == 'absent': + mso.sent = mso.existing = {} + ops.append(dict(op='remove', path=selector_path)) + + elif state == 'present': + # Get expressions + types = dict(ip_address='ipAddress') + all_expressions = [] + if expressions: + for expression in expressions: + type_val = expression.get('type') + operator = expression.get('operator') + value = expression.get('value') + all_expressions.append(dict( + key=types.get(type_val), + operator=operator, + value=value, + )) + + payload = dict( + name=selector, + expressions=all_expressions, + ) + + mso.sanitize(payload, collate=True) + + if mso.existing: + ops.append(dict(op='replace', path=selector_path, value=mso.sent)) + else: + ops.append(dict(op='add', path=selectors_path, value=mso.sent)) + + mso.existing = mso.proposed + + if not module.check_mode and mso.existing != mso.previous: + mso.request(schema_path, method='PATCH', data=ops) + + mso.exit_json() + + +if __name__ == "__main__": + main() diff --git a/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_external_epg_subnet.py b/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_external_epg_subnet.py new file mode 100644 index 00000000..17829011 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_external_epg_subnet.py @@ -0,0 +1,220 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# 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_template_external_epg_subnet +short_description: Manage External EPG subnets in schema templates +description: +- Manage External EPG subnets in schema templates on Cisco ACI Multi-Site. +author: +- Devarshi Shah (@devarshishah3) +version_added: '0.0.8' +options: + schema: + description: + - The name of the schema. + type: str + required: yes + template: + description: + - The name of the template to change. + type: str + required: yes + external_epg: + description: + - The name of the External EPG to manage. + type: str + required: yes + subnet: + description: + - The IP range in CIDR notation. + type: str + required: true + scope: + description: + - The scope of the subnet. + type: list + elements: str + aggregate: + description: + - The aggregate option for the subnet. + 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 +notes: +- Due to restrictions of the MSO REST API concurrent modifications to EPG subnets can be dangerous and corrupt data. +extends_documentation_fragment: cisco.mso.modules +''' + +EXAMPLES = r''' +- name: Add a new subnet to an External EPG + cisco.mso.mso_schema_template_external_epg_subnet: + host: mso_host + username: admin + password: SomeSecretPassword + schema: Schema 1 + template: Template 1 + 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: + host: mso_host + username: admin + password: SomeSecretPassword + schema: Schema 1 + template: Template 1 + 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: + host: mso_host + username: admin + password: SomeSecretPassword + schema: Schema 1 + template: Template 1 + external_epg: EPG 1 + subnet: 10.0.0.0/24 + state: query + delegate_to: localhost + register: query_result + +- name: Query all External EPGs subnets + cisco.mso.mso_schema_template_external_epg_subnet: + host: mso_host + username: admin + password: SomeSecretPassword + schema: Schema 1 + template: Template 1 + 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 + + +def main(): + argument_spec = mso_argument_spec() + argument_spec.update( + schema=dict(type='str', required=True), + template=dict(type='str', required=True), + external_epg=dict(type='str', required=True), + state=dict(type='str', default='present', choices=['absent', 'present', 'query']), + subnet=dict(type='str', required=True), + scope=dict(type='list', elements='str', default=[]), + aggregate=dict(type='list', elements='str', default=[]), + ) + + module = AnsibleModule( + argument_spec=argument_spec, + supports_check_mode=True, + required_if=[ + ['state', 'absent', ['subnet']], + ['state', 'present', ['subnet']], + ], + ) + + schema = module.params.get('schema') + template = module.params.get('template').replace(' ', '') + external_epg = module.params.get('external_epg') + subnet = module.params.get('subnet') + scope = module.params.get('scope') + aggregate = module.params.get('aggregate') + state = module.params.get('state') + + mso = MSOModule(module) + + # Get schema + schema_obj = mso.get_obj('schemas', displayName=schema) + if not schema_obj: + mso.fail_json(msg="Provided schema '{0}' does not exist".format(schema)) + + schema_path = 'schemas/{id}'.format(**schema_obj) + + # Get template + templates = [t.get('name') for t in schema_obj.get('templates')] + if template not in templates: + mso.fail_json(msg="Provided template '{template}' does not exist. Existing templates: {templates}".format(template=template, + templates=', '.join(templates))) + template_idx = templates.index(template) + + # Get EPG + external_epgs = [e.get('name') for e in schema_obj.get('templates')[template_idx]['externalEpgs']] + if external_epg not in external_epgs: + mso.fail_json(msg="Provided External EPG '{epg}' does not exist. Existing epgs: {epgs}".format(epg=external_epg, epgs=', '.join(external_epgs))) + epg_idx = external_epgs.index(external_epg) + + # Get Subnet + subnets = [s.get('ip') for s in schema_obj.get('templates')[template_idx]['externalEpgs'][epg_idx]['subnets']] + if subnet in subnets: + subnet_idx = subnets.index(subnet) + # FIXME: Changes based on index are DANGEROUS + subnet_path = '/templates/{0}/externalEpgs/{1}/subnets/{2}'.format(template, external_epg, subnet_idx) + mso.existing = schema_obj.get('templates')[template_idx]['externalEpgs'][epg_idx]['subnets'][subnet_idx] + + if state == 'query': + if subnet is None: + mso.existing = schema_obj.get('templates')[template_idx]['externalEpgs'][epg_idx]['subnets'] + elif not mso.existing: + mso.fail_json(msg="Subnet '{subnet}' not found".format(subnet=subnet)) + mso.exit_json() + + subnets_path = '/templates/{0}/externalEpgs/{1}/subnets'.format(template, external_epg) + ops = [] + + mso.previous = mso.existing + if state == 'absent': + if mso.existing: + mso.existing = {} + ops.append(dict(op='remove', path=subnet_path)) + + elif state == 'present': + payload = dict( + ip=subnet, + scope=scope, + aggregate=aggregate, + ) + + mso.sanitize(payload, collate=True) + + if mso.existing: + ops.append(dict(op='replace', path=subnet_path, value=mso.sent)) + else: + ops.append(dict(op='add', path=subnets_path + '/-', value=mso.sent)) + + mso.existing = mso.proposed + + if not module.check_mode: + mso.request(schema_path, method='PATCH', data=ops) + + mso.exit_json() + + +if __name__ == "__main__": + main() diff --git a/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_externalepg.py b/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_externalepg.py new file mode 100644 index 00000000..1831cb85 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_externalepg.py @@ -0,0 +1,332 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright: (c) 2018, Dag Wieers (@dagwieers) +# 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_template_external_epg +short_description: Manage external EPGs in schema templates +description: +- Manage external EPGs in schema templates on Cisco ACI Multi-Site. +author: +- Dag Wieers (@dagwieers) +options: + schema: + description: + - The name of the schema. + type: str + required: yes + template: + description: + - The name of the template. + type: str + required: yes + external_epg: + description: + - The name of the external EPG to manage. + type: str + aliases: [ name, externalepg ] + type: + description: + - The type of external epg. + - anp needs to be associated with external epg when the type is cloud. + - l3out can be associated with external epg when the type is on-premise. + type: str + choices: [ on-premise, cloud ] + default: on-premise + display_name: + description: + - The name as displayed on the MSO web interface. + type: str + vrf: + description: + - The VRF associated with the external epg. + type: dict + suboptions: + name: + description: + - The name of the VRF to associate with. + required: true + type: str + schema: + description: + - The schema that defines the referenced VRF. + - If this parameter is unspecified, it defaults to the current schema. + type: str + template: + description: + - The template that defines the referenced VRF. + - If this parameter is unspecified, it defaults to the current template. + type: str + l3out: + description: + - The L3Out associated with the external epg. + type: dict + suboptions: + name: + description: + - The name of the L3Out to associate with. + required: true + type: str + schema: + description: + - The schema that defines the referenced L3Out. + - If this parameter is unspecified, it defaults to the current schema. + type: str + template: + description: + - The template that defines the referenced L3Out. + - If this parameter is unspecified, it defaults to the current template. + type: str + anp: + description: + - The anp associated with the external epg. + type: dict + suboptions: + name: + description: + - The name of the anp to associate with. + required: true + type: str + schema: + description: + - The schema that defines the referenced anp. + - If this parameter is unspecified, it defaults to the current schema. + type: str + template: + description: + - The template that defines the referenced anp. + - If this parameter is unspecified, it defaults to the current template. + type: str + preferred_group: + description: + - Preferred Group is enabled for this External EPG or not. + type: bool + 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 +extends_documentation_fragment: cisco.mso.modules +''' + +EXAMPLES = r''' +- name: Add a new external EPG + cisco.mso.mso_schema_template_external_epg: + host: mso_host + username: admin + password: SomeSecretPassword + schema: Schema 1 + template: Template 1 + external_epg: External EPG 1 + vrf: + name: VRF + 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: + host: mso_host + username: admin + password: SomeSecretPassword + schema: Schema 1 + template: Template 1 + external_epg: External EPG 1 + type: cloud + vrf: + name: VRF + schema: Schema 1 + template: Template 1 + anp: + name: ANP1 + schema: Schema 1 + template: Template 1 + state: present + delegate_to: localhost + +- name: Remove an external EPG + cisco.mso.mso_schema_template_external_epg: + host: mso_host + username: admin + password: SomeSecretPassword + schema: Schema 1 + 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: + host: mso_host + username: admin + password: SomeSecretPassword + schema: Schema 1 + template: Template 1 + external_epg: external EPG1 + state: query + delegate_to: localhost + register: query_result + +- name: Query all external EPGs + cisco.mso.mso_schema_template_external_epg: + host: mso_host + username: admin + password: SomeSecretPassword + schema: Schema 1 + template: Template 1 + 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_reference_spec + + +def main(): + argument_spec = mso_argument_spec() + argument_spec.update( + schema=dict(type='str', required=True), + template=dict(type='str', required=True), + external_epg=dict(type='str', aliases=['name', 'externalepg']), # This parameter is not required for querying all objects + display_name=dict(type='str'), + vrf=dict(type='dict', options=mso_reference_spec()), + l3out=dict(type='dict', options=mso_reference_spec()), + anp=dict(type='dict', options=mso_reference_spec()), + preferred_group=dict(type='bool'), + type=dict(type='str', default='on-premise', choices=['on-premise', 'cloud']), + state=dict(type='str', default='present', choices=['absent', 'present', 'query']), + ) + + module = AnsibleModule( + argument_spec=argument_spec, + supports_check_mode=True, + required_if=[ + ['state', 'absent', ['external_epg']], + ['state', 'present', ['external_epg', 'vrf']], + ['type', 'cloud', ['anp']], + ], + ) + + schema = module.params.get('schema') + template = module.params.get('template').replace(' ', '') + external_epg = module.params.get('external_epg') + display_name = module.params.get('display_name') + vrf = module.params.get('vrf') + if vrf is not None and vrf.get('template') is not None: + vrf['template'] = vrf.get('template').replace(' ', '') + l3out = module.params.get('l3out') + if l3out is not None and l3out.get('template') is not None: + l3out['template'] = l3out.get('template').replace(' ', '') + anp = module.params.get('anp') + if anp is not None and anp.get('template') is not None: + anp['template'] = anp.get('template').replace(' ', '') + preferred_group = module.params.get('preferred_group') + type_ext_epg = module.params.get('type') + state = module.params.get('state') + + mso = MSOModule(module) + + # Get schema_id + schema_obj = mso.get_obj('schemas', displayName=schema) + if schema_obj: + schema_id = schema_obj.get('id') + else: + mso.fail_json(msg="Provided schema '{0}' does not exist".format(schema)) + + schema_path = 'schemas/{id}'.format(**schema_obj) + + # 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 external EPGs + external_epgs = [e.get('name') for e in schema_obj.get('templates')[template_idx]['externalEpgs']] + + if external_epg is not None and external_epg in external_epgs: + external_epg_idx = external_epgs.index(external_epg) + mso.existing = schema_obj.get('templates')[template_idx]['externalEpgs'][external_epg_idx] + if 'externalEpgRef' in mso.existing: + del mso.existing['externalEpgRef'] + if 'vrfRef' in mso.existing: + mso.existing['vrfRef'] = mso.dict_from_ref(mso.existing.get('vrfRef')) + if 'l3outRef' in mso.existing: + mso.existing['l3outRef'] = mso.dict_from_ref(mso.existing.get('l3outRef')) + if 'anpRef' in mso.existing: + mso.existing['anpRef'] = mso.dict_from_ref(mso.existing.get('anpRef')) + + if state == 'query': + if external_epg is None: + mso.existing = schema_obj.get('templates')[template_idx]['externalEpgs'] + elif not mso.existing: + mso.fail_json(msg="External EPG '{external_epg}' not found".format(external_epg=external_epg)) + mso.exit_json() + + eepgs_path = '/templates/{0}/externalEpgs'.format(template) + eepg_path = '/templates/{0}/externalEpgs/{1}'.format(template, external_epg) + ops = [] + + mso.previous = mso.existing + if state == 'absent': + if mso.existing: + mso.sent = mso.existing = {} + ops.append(dict(op='remove', path=eepg_path)) + + elif state == 'present': + vrf_ref = mso.make_reference(vrf, 'vrf', schema_id, template) + l3out_ref = mso.make_reference(l3out, 'l3out', schema_id, template) + anp_ref = mso.make_reference(anp, 'anp', schema_id, template) + if display_name is None and not mso.existing: + display_name = external_epg + + payload = dict( + name=external_epg, + displayName=display_name, + vrfRef=vrf_ref, + preferredGroup=preferred_group, + ) + + if type_ext_epg == 'cloud': + payload['extEpgType'] = 'cloud' + payload['anpRef'] = anp_ref + else: + payload['l3outRef'] = l3out_ref + + mso.sanitize(payload, collate=True) + + if mso.existing: + # clean contractRef to fix api issue + for contract in mso.sent.get('contractRelationships'): + contract['contractRef'] = mso.dict_from_ref(contract.get('contractRef')) + ops.append(dict(op='replace', path=eepg_path, value=mso.sent)) + else: + ops.append(dict(op='add', path=eepgs_path + '/-', value=mso.sent)) + + mso.existing = mso.proposed + + if not module.check_mode: + mso.request(schema_path, method='PATCH', data=ops) + + mso.exit_json() + + +if __name__ == "__main__": + main() diff --git a/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_filter_entry.py b/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_filter_entry.py new file mode 100644 index 00000000..3a85ce09 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_filter_entry.py @@ -0,0 +1,363 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright: (c) 2018, Dag Wieers (@dagwieers) +# 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_template_filter_entry +short_description: Manage filter entries in schema templates +description: +- Manage filter entries in schema templates on Cisco ACI Multi-Site. +author: +- Dag Wieers (@dagwieers) +options: + schema: + description: + - The name of the schema. + type: str + required: yes + template: + description: + - The name of the template. + type: str + required: yes + filter: + description: + - The name of the filter to manage. + type: str + required: yes + filter_display_name: + description: + - The name as displayed on the MSO web interface. + type: str + entry: + description: + - The filter entry name to manage. + type: str + aliases: [ name ] + display_name: + description: + - The name as displayed on the MSO web interface. + type: str + aliases: [ entry_display_name ] + description: + description: + - The description of this filer entry. + type: str + aliases: [ entry_description ] + ethertype: + description: + - The ethernet type to use for this filter entry. + type: str + choices: [ arp, fcoe, ip, ipv4, ipv6, mac-security, mpls-unicast, trill, unspecified ] + ip_protocol: + description: + - The IP protocol to use for this filter entry. + type: str + choices: [ eigrp, egp, icmp, icmpv6, igmp, igp, l2tp, ospfigp, pim, tcp, udp, unspecified ] + tcp_session_rules: + description: + - A list of TCP session rules. + type: list + elements: str + choices: [ acknowledgement, established, finish, synchronize, reset, unspecified ] + source_from: + description: + - The source port range from. + type: str + source_to: + description: + - The source port range to. + type: str + destination_from: + description: + - The destination port range from. + type: str + destination_to: + description: + - The destination port range to. + type: str + arp_flag: + description: + - The ARP flag to use for this filter entry. + type: str + choices: [ reply, request, unspecified ] + stateful: + description: + - Whether this filter entry is stateful. + type: bool + default: no + fragments_only: + description: + - Whether this filter entry only matches fragments. + type: bool + default: no + 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_filter +notes: +- Due to restrictions of the MSO REST API this module creates filters when needed, and removes them when the last entry has been removed. +extends_documentation_fragment: cisco.mso.modules +''' + +EXAMPLES = r''' +- name: Add a new filter entry + cisco.mso.mso_schema_template_filter_entry: + host: mso_host + username: admin + password: SomeSecretPassword + schema: Schema 1 + template: Template 1 + filter: Filter 1 + state: present + delegate_to: localhost + +- name: Remove a filter entry + cisco.mso.mso_schema_template_filter_entry: + host: mso_host + username: admin + password: SomeSecretPassword + schema: Schema 1 + template: Template 1 + filter: Filter 1 + state: absent + delegate_to: localhost + +- name: Query a specific filter entry + cisco.mso.mso_schema_template_filter_entry: + host: mso_host + username: admin + password: SomeSecretPassword + schema: Schema 1 + template: Template 1 + filter: Filter 1 + state: query + delegate_to: localhost + register: query_result + +- name: Query all filter entries + cisco.mso.mso_schema_template_filter_entry: + host: mso_host + username: admin + password: SomeSecretPassword + schema: Schema 1 + template: Template 1 + 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 + + +def main(): + argument_spec = mso_argument_spec() + argument_spec.update( + schema=dict(type='str', required=True), + template=dict(type='str', required=True), + filter=dict(type='str', required=True), + filter_display_name=dict(type='str'), + entry=dict(type='str', aliases=['name']), # This parameter is not required for querying all objects + description=dict(type='str', aliases=['entry_description']), + display_name=dict(type='str', aliases=['entry_display_name']), + ethertype=dict(type='str', choices=['arp', 'fcoe', 'ip', 'ipv4', 'ipv6', 'mac-security', 'mpls-unicast', 'trill', 'unspecified']), + ip_protocol=dict(type='str', choices=['eigrp', 'egp', 'icmp', 'icmpv6', 'igmp', 'igp', 'l2tp', 'ospfigp', 'pim', 'tcp', 'udp', 'unspecified']), + tcp_session_rules=dict(type='list', elements='str', choices=['acknowledgement', 'established', 'finish', 'synchronize', 'reset', 'unspecified']), + source_from=dict(type='str'), + source_to=dict(type='str'), + destination_from=dict(type='str'), + destination_to=dict(type='str'), + arp_flag=dict(type='str', choices=['reply', 'request', 'unspecified']), + stateful=dict(type='bool'), + fragments_only=dict(type='bool'), + state=dict(type='str', default='present', choices=['absent', 'present', 'query']), + ) + + module = AnsibleModule( + argument_spec=argument_spec, + supports_check_mode=True, + required_if=[ + ['state', 'absent', ['entry']], + ['state', 'present', ['entry']], + ], + ) + + schema = module.params.get('schema') + template = module.params.get('template').replace(' ', '') + filter_name = module.params.get('filter') + filter_display_name = module.params.get('filter_display_name') + entry = module.params.get('entry') + display_name = module.params.get('display_name') + description = module.params.get('description') + ethertype = module.params.get('ethertype') + ip_protocol = module.params.get('ip_protocol') + tcp_session_rules = module.params.get('tcp_session_rules') + source_from = module.params.get('source_from') + source_to = module.params.get('source_to') + destination_from = module.params.get('destination_from') + destination_to = module.params.get('destination_to') + arp_flag = module.params.get('arp_flag') + stateful = module.params.get('stateful') + fragments_only = module.params.get('fragments_only') + state = module.params.get('state') + + mso = MSOModule(module) + + # Get schema + schema_obj = mso.get_obj('schemas', displayName=schema) + if not schema_obj: + mso.fail_json(msg="Provided schema '{0}' does not exist".format(schema)) + + schema_path = 'schemas/{id}'.format(**schema_obj) + + # Get template + templates = [t.get('name') for t in schema_obj.get('templates')] + if template not in templates: + mso.fail_json(msg="Provided template '{template}' does not exist. Existing templates: {templates}".format(template=template, + templates=', '.join(templates))) + template_idx = templates.index(template) + + # Get filters + mso.existing = {} + filter_idx = None + entry_idx = None + filters = [f.get('name') for f in schema_obj.get('templates')[template_idx]['filters']] + if filter_name in filters: + filter_idx = filters.index(filter_name) + + entries = [f.get('name') for f in schema_obj.get('templates')[template_idx]['filters'][filter_idx]['entries']] + if entry in entries: + entry_idx = entries.index(entry) + mso.existing = schema_obj.get('templates')[template_idx]['filters'][filter_idx]['entries'][entry_idx] + + if state == 'query': + if entry is None: + if filter_idx is None: + mso.fail_json(msg="Filter '{filter}' not found".format(filter=filter_name)) + mso.existing = schema_obj.get('templates')[template_idx]['filters'][filter_idx]['entries'] + elif not mso.existing: + mso.fail_json(msg="Entry '{entry}' not found".format(entry=entry)) + mso.exit_json() + + filters_path = '/templates/{0}/filters'.format(template) + filter_path = '/templates/{0}/filters/{1}'.format(template, filter_name) + entries_path = '/templates/{0}/filters/{1}/entries'.format(template, filter_name) + entry_path = '/templates/{0}/filters/{1}/entries/{2}'.format(template, filter_name, entry) + ops = [] + + mso.previous = mso.existing + if state == 'absent': + mso.proposed = mso.sent = {} + + if filter_idx is None: + # There was no filter to begin with + pass + elif entry_idx is None: + # There was no entry to begin with + pass + elif len(entries) == 1: + # There is only one entry, remove filter + mso.existing = {} + ops.append(dict(op='remove', path=filter_path)) + + else: + mso.existing = {} + ops.append(dict(op='remove', path=entry_path)) + + elif state == 'present': + + if not mso.existing: + if display_name is None: + display_name = entry + if description is None: + description = '' + if ethertype is None: + ethertype = 'unspecified' + if ip_protocol is None: + ip_protocol = 'unspecified' + if tcp_session_rules is None: + tcp_session_rules = ['unspecified'] + if source_from is None: + source_from = 'unspecified' + if source_to is None: + source_to = 'unspecified' + if destination_from is None: + destination_from = 'unspecified' + if destination_to is None: + destination_to = 'unspecified' + if arp_flag is None: + arp_flag = 'unspecified' + if stateful is None: + stateful = False + if fragments_only is None: + fragments_only = False + + payload = dict( + name=entry, + displayName=display_name, + description=description, + etherType=ethertype, + ipProtocol=ip_protocol, + tcpSessionRules=tcp_session_rules, + sourceFrom=source_from, + sourceTo=source_to, + destinationFrom=destination_from, + destinationTo=destination_to, + arpFlag=arp_flag, + stateful=stateful, + matchOnlyFragments=fragments_only, + ) + + mso.sanitize(payload, collate=True) + + if filter_idx is None: + # Filter does not exist, so we have to create it + if filter_display_name is None: + filter_display_name = filter_name + + payload = dict( + name=filter_name, + displayName=filter_display_name, + entries=[mso.sent], + ) + + ops.append(dict(op='add', path=filters_path + '/-', value=payload)) + + elif entry_idx is None: + # Entry does not exist, so we have to add it + ops.append(dict(op='add', path=entries_path + '/-', value=mso.sent)) + + else: + # Entry exists, we have to update it + for (key, value) in mso.sent.items(): + ops.append(dict(op='replace', path=entry_path + '/' + key, value=value)) + + mso.existing = mso.proposed + + if not module.check_mode: + mso.request(schema_path, method='PATCH', data=ops) + + mso.exit_json() + + +if __name__ == "__main__": + main() diff --git a/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_l3out.py b/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_l3out.py new file mode 100644 index 00000000..5aa4e557 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_l3out.py @@ -0,0 +1,231 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright: (c) 2018, Dag Wieers (@dagwieers) +# 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_template_l3out +short_description: Manage l3outs in schema templates +description: +- Manage l3outs in schema templates on Cisco ACI Multi-Site. +author: +- Dag Wieers (@dagwieers) +options: + schema: + description: + - The name of the schema. + type: str + required: yes + template: + description: + - The name of the template. + type: str + required: yes + l3out: + description: + - The name of the l3out to manage. + type: str + aliases: [ name ] + display_name: + description: + - The name as displayed on the MSO web interface. + type: str + vrf: + description: + - The VRF associated to this L3out. + type: dict + suboptions: + name: + description: + - The name of the VRF to associate with. + required: true + type: str + schema: + description: + - The schema that defines the referenced VRF. + - If this parameter is unspecified, it defaults to the current schema. + type: str + template: + description: + - The template that defines the referenced VRF. + - If this parameter is unspecified, it defaults to the current schema. + type: 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 +extends_documentation_fragment: cisco.mso.modules +''' + +EXAMPLES = r''' +- name: Add a new L3out + cisco.mso.mso_schema_template_l3out: + host: mso_host + username: admin + password: SomeSecretPassword + validate_certs: false + schema: Schema 1 + template: Template 1 + l3out: L3out 1 + vrf: + name: vrfName + schema: vrfSchema + template: vrfTemplate + state: present + delegate_to: localhost + +- name: Remove an L3out + cisco.mso.mso_schema_template_l3out: + host: mso_host + username: admin + password: SomeSecretPassword + schema: Schema 1 + template: Template 1 + l3out: L3out 1 + state: absent + delegate_to: localhost + +- name: Query a specific L3outs + cisco.mso.mso_schema_template_l3out: + host: mso_host + username: admin + password: SomeSecretPassword + validate_certs: false + schema: Schema 1 + template: Template 1 + l3out: L3out 1 + state: query + delegate_to: localhost + register: query_result + +- name: Query all L3outs + cisco.mso.mso_schema_template_l3out: + host: mso_host + username: admin + password: SomeSecretPassword + validate_certs: false + schema: Schema 1 + template: Template 1 + 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_reference_spec + + +def main(): + argument_spec = mso_argument_spec() + argument_spec.update( + schema=dict(type='str', required=True), + template=dict(type='str', required=True), + l3out=dict(type='str', aliases=['name']), # This parameter is not required for querying all objects + display_name=dict(type='str'), + vrf=dict(type='dict', options=mso_reference_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', ['l3out']], + ['state', 'present', ['l3out', 'vrf']], + ], + ) + + schema = module.params.get('schema') + template = module.params.get('template').replace(' ', '') + l3out = module.params.get('l3out') + display_name = module.params.get('display_name') + vrf = module.params.get('vrf') + if vrf is not None and vrf.get('template') is not None: + vrf['template'] = vrf.get('template').replace(' ', '') + state = module.params.get('state') + + mso = MSOModule(module) + + # Get schema_id + schema_obj = mso.get_obj('schemas', displayName=schema) + if schema_obj: + schema_id = schema_obj.get('id') + else: + mso.fail_json(msg="Provided schema '{0}' does not exist".format(schema)) + + schema_path = 'schemas/{id}'.format(**schema_obj) + + # 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 L3out + l3outs = [l3.get('name') for l3 in schema_obj.get('templates')[template_idx]['intersiteL3outs']] + + if l3out is not None and l3out in l3outs: + l3out_idx = l3outs.index(l3out) + mso.existing = schema_obj.get('templates')[template_idx]['intersiteL3outs'][l3out_idx] + + if state == 'query': + if l3out is None: + mso.existing = schema_obj.get('templates')[template_idx]['intersiteL3outs'] + elif not mso.existing: + mso.fail_json(msg="L3out '{l3out}' not found".format(l3out=l3out)) + mso.exit_json() + + l3outs_path = '/templates/{0}/intersiteL3outs'.format(template) + l3out_path = '/templates/{0}/intersiteL3outs/{1}'.format(template, l3out) + ops = [] + + mso.previous = mso.existing + if state == 'absent': + if mso.existing: + mso.sent = mso.existing = {} + ops.append(dict(op='remove', path=l3out_path)) + + elif state == 'present': + vrf_ref = mso.make_reference(vrf, 'vrf', schema_id, template) + + if display_name is None and not mso.existing: + display_name = l3out + + payload = dict( + name=l3out, + displayName=display_name, + vrfRef=vrf_ref, + ) + + mso.sanitize(payload, collate=True) + + if mso.existing: + ops.append(dict(op='replace', path=l3out_path, value=mso.sent)) + else: + ops.append(dict(op='add', path=l3outs_path + '/-', value=mso.sent)) + + mso.existing = mso.proposed + + if not module.check_mode: + mso.request(schema_path, method='PATCH', data=ops) + + mso.exit_json() + + +if __name__ == "__main__": + main() diff --git a/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_migrate.py b/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_migrate.py new file mode 100644 index 00000000..c31fbecf --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_migrate.py @@ -0,0 +1,246 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright: (c) 2020, Anvitha Jain (@anvitha-jain) +# 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_template_migrate +short_description: Migrate Bridge Domains (BDs) and EPGs between templates +description: +- Migrate BDs and EPGs between templates of same and different schemas. +author: +- Anvitha Jain (@anvitha-jain) +options: + schema: + description: + - The name of the schema. + type: str + required: yes + template: + description: + - The name of the template. + type: str + required: yes + bds: + description: + - The name of the BDs to migrate. + type: list + elements: str + epgs: + description: + - The name of the EPGs and the ANP it is in to migrate. + type: list + elements: dict + suboptions: + epg: + description: + - The name of the EPG to migrate. + type: str + required: yes + anp: + description: + - The name of the anp to migrate. + type: str + required: yes + target_schema: + description: + - The name of the target_schema. + type: str + required: yes + target_template: + description: + - The name of the target_template. + type: str + required: yes + state: + description: + - Use C(present) for adding. + type: str + default: present +extends_documentation_fragment: cisco.mso.modules +''' + +EXAMPLES = r''' +- name: Migration of objects between templates of same schema + mso_schema_template_migrate: + host: mso_host + username: admin + password: SomeSecretPassword + schema: Schema 1 + template: Template 1 + target_schema: Schema 1 + target_template: Template 2 + bds: + - BD + epgs: + - epg: EPG1 + anp: ANP + state: present + delegate_to: localhost + +- name: Migration of objects between templates of different schema + mso_schema_template_migrate: + host: mso_host + username: admin + password: SomeSecretPassword + schema: Schema 1 + template: Template 1 + target_schema: Schema 2 + target_template: Template 2 + bds: + - BD + epgs: + - epg: EPG1 + anp: ANP + state: present + delegate_to: localhost + +- name: Migration of BD object between templates of same schema + mso_schema_template_migrate: + host: mso_host + username: admin + password: SomeSecretPassword + schema: Schema 1 + template: Template 1 + target_schema: Schema 1 + target_template: Template 2 + bds: + - BD + - BD1 + state: present + delegate_to: localhost + +- name: Migration of BD object between templates of different schema + mso_schema_template_migrate: + host: mso_host + username: admin + password: SomeSecretPassword + schema: Schema 1 + template: Template 1 + target_schema: Schema 2 + target_template: Template 2 + bds: + - BD + - BD1 + state: present + delegate_to: localhost + +- name: Migration of EPG objects between templates of same schema + mso_schema_template_migrate: + host: mso_host + username: admin + password: SomeSecretPassword + schema: Schema 1 + template: Template 1 + target_schema: Schema 2 + target_template: Template 2 + epgs: + - epg: EPG1 + anp: ANP + - epg: EPG2 + anp: ANP2 + state: present + delegate_to: localhost + +- name: Migration of EPG objects between templates of different schema + mso_schema_template_migrate: + host: mso_host + username: admin + password: SomeSecretPassword + schema: Schema 1 + template: Template 1 + target_schema: Schema 2 + target_template: Template 2 + epgs: + - epg: EPG1 + anp: ANP + - epg: EPG2 + anp: ANP2 + state: present + delegate_to: localhost +''' + +RETURN = r''' +''' + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.cisco.mso.plugins.module_utils.mso import MSOModule, mso_argument_spec, mso_object_migrate_spec + + +def main(): + argument_spec = mso_argument_spec() + argument_spec.update( + schema=dict(type='str', required=True), + template=dict(type='str', required=True), + bds=dict(type='list', elements='str'), + epgs=dict(type='list', elements='dict', options=mso_object_migrate_spec()), + target_schema=dict(type='str', required=True), + target_template=dict(type='str', required=True), + state=dict(type='str', default='present'), + ) + + module = AnsibleModule( + argument_spec=argument_spec, + supports_check_mode=True, + ) + + schema = module.params.get('schema') + template = module.params.get('template').replace(' ', '') + target_schema = module.params.get('target_schema') + target_template = module.params.get('target_template').replace(' ', '') + bds = module.params.get('bds') + epgs = module.params.get('epgs') + state = module.params.get('state') + + mso = MSOModule(module) + + schema_id = mso.get_obj('schemas', displayName=schema).get('id') + + target_schema_id = mso.get_obj('schemas', displayName=target_schema).get('id') + + if state == 'present': + if schema_id is not None: + bds_payload = [] + if bds is not None: + for bd in bds: + bds_payload.append(dict(name=bd)) + + anp_dict = {} + if epgs is not None: + for epg in epgs: + if epg.get('anp') in anp_dict: + anp_dict[epg.get('anp')].append(dict(name=epg.get('epg'))) + else: + anp_dict[epg.get('anp')] = [dict(name=epg.get('epg'))] + + anps_payload = [] + for anp, epgs_payload in anp_dict.items(): + anps_payload.append(dict(name=anp, epgs=epgs_payload)) + + payload = dict( + targetSchemaId=target_schema_id, + targetTemplateName=target_template, + bds=bds_payload, + anps=anps_payload, + ) + + template = template.replace(' ', '%20') + + target_template = target_template.replace(' ', '%20') # removes API error for extra space + + mso.existing = mso.request(path='/api/v1/migrate/schema/{0}/template/{1}'.format(schema_id, template), method='POST', data=payload) + + mso.exit_json() + + +if __name__ == "__main__": + main() diff --git a/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_vrf.py b/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_vrf.py new file mode 100644 index 00000000..65a918e9 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_vrf.py @@ -0,0 +1,214 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright: (c) 2018, Dag Wieers (@dagwieers) +# 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_template_vrf +short_description: Manage VRFs in schema templates +description: +- Manage VRFs in schema templates on Cisco ACI Multi-Site. +author: +- Dag Wieers (@dagwieers) +options: + schema: + description: + - The name of the schema. + type: str + required: yes + template: + description: + - The name of the template. + type: str + required: yes + vrf: + description: + - The name of the VRF to manage. + type: str + aliases: [ name ] + display_name: + description: + - The name as displayed on the MSO web interface. + type: str + layer3_multicast: + description: + - Whether to enable L3 multicast. + type: bool + vzany: + description: + - Whether to enable vzAny. + type: bool + 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 +extends_documentation_fragment: cisco.mso.modules +''' + +EXAMPLES = r''' +- name: Add a new VRF + cisco.mso.mso_schema_template_vrf: + host: mso_host + username: admin + password: SomeSecretPassword + schema: Schema 1 + template: Template 1 + vrf: VRF 1 + state: present + delegate_to: localhost + +- name: Remove an VRF + cisco.mso.mso_schema_template_vrf: + host: mso_host + username: admin + password: SomeSecretPassword + schema: Schema 1 + template: Template 1 + vrf: VRF1 + state: absent + delegate_to: localhost + +- name: Query a specific VRFs + cisco.mso.mso_schema_template_vrf: + host: mso_host + username: admin + password: SomeSecretPassword + schema: Schema 1 + template: Template 1 + vrf: VRF1 + state: query + delegate_to: localhost + register: query_result + +- name: Query all VRFs + cisco.mso.mso_schema_template_vrf: + host: mso_host + username: admin + password: SomeSecretPassword + schema: Schema 1 + template: Template 1 + 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 + + +def main(): + argument_spec = mso_argument_spec() + argument_spec.update( + schema=dict(type='str', required=True), + template=dict(type='str', required=True), + vrf=dict(type='str', aliases=['name']), # This parameter is not required for querying all objects + display_name=dict(type='str'), + layer3_multicast=dict(type='bool'), + vzany=dict(type='bool'), + state=dict(type='str', default='present', choices=['absent', 'present', 'query']), + ) + + module = AnsibleModule( + argument_spec=argument_spec, + supports_check_mode=True, + required_if=[ + ['state', 'absent', ['vrf']], + ['state', 'present', ['vrf']], + ], + ) + + schema = module.params.get('schema') + template = module.params.get('template').replace(' ', '') + vrf = module.params.get('vrf') + display_name = module.params.get('display_name') + layer3_multicast = module.params.get('layer3_multicast') + vzany = module.params.get('vzany') + state = module.params.get('state') + + mso = MSOModule(module) + + # Get schema_id + schema_obj = mso.get_obj('schemas', displayName=schema) + if not schema_obj: + mso.fail_json(msg="Provided schema '{0}' does not exist".format(schema)) + + schema_path = 'schemas/{id}'.format(**schema_obj) + + # 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 + vrfs = [v.get('name') for v in schema_obj.get('templates')[template_idx]['vrfs']] + + if vrf is not None and vrf in vrfs: + vrf_idx = vrfs.index(vrf) + mso.existing = schema_obj.get('templates')[template_idx]['vrfs'][vrf_idx] + + if state == 'query': + if vrf is None: + mso.existing = schema_obj.get('templates')[template_idx]['vrfs'] + elif not mso.existing: + mso.fail_json(msg="VRF '{vrf}' not found".format(vrf=vrf)) + mso.exit_json() + + vrfs_path = '/templates/{0}/vrfs'.format(template) + vrf_path = '/templates/{0}/vrfs/{1}'.format(template, vrf) + ops = [] + + mso.previous = mso.existing + if state == 'absent': + if mso.existing: + mso.sent = mso.existing = {} + ops.append(dict(op='remove', path=vrf_path)) + + elif state == 'present': + if display_name is None and not mso.existing: + display_name = vrf + + payload = dict( + name=vrf, + displayName=display_name, + l3MCast=layer3_multicast, + vzAnyEnabled=vzany + ) + + mso.sanitize(payload, collate=True) + + if mso.existing: + # clean contractRef to fix api issue + for contract in mso.sent.get('vzAnyConsumerContracts'): + contract['contractRef'] = mso.dict_from_ref(contract.get('contractRef')) + for contract in mso.sent.get('vzAnyProviderContracts'): + contract['contractRef'] = mso.dict_from_ref(contract.get('contractRef')) + ops.append(dict(op='replace', path=vrf_path, value=mso.sent)) + else: + ops.append(dict(op='add', path=vrfs_path + '/-', value=mso.sent)) + + mso.existing = mso.proposed + + if not module.check_mode: + mso.request(schema_path, method='PATCH', data=ops) + + mso.exit_json() + + +if __name__ == "__main__": + main() diff --git a/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_vrf_contract.py b/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_vrf_contract.py new file mode 100644 index 00000000..22f96f0d --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_schema_template_vrf_contract.py @@ -0,0 +1,264 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +from __future__ import absolute_import, division, print_function +__metaclass__ = type + +ANSIBLE_METADATA = {'metadata_version': '1.1', + 'status': ['preview'], + 'supported_by': 'community'} + +DOCUMENTATION = r''' +--- +module: mso_schema_template_vrf_contract +short_description: Manage vrf contracts in schema templates +description: +- Manage vrf contracts in schema templates on Cisco ACI Multi-Site. +author: +- Cindy Zhao (@cizhao) +version_added: '0.0.8' +options: + schema: + description: + - The name of the schema. + type: str + required: yes + template: + description: + - The name of the template to change. + type: str + required: yes + vrf: + description: + - The name of the VRF. + type: str + required: yes + contract: + description: + - A contract associated to this VRF. + type: dict + suboptions: + name: + description: + - The name of the Contract to associate with. + required: true + type: str + schema: + description: + - 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 contract. + type: str + type: + description: + - The type of contract. + type: str + required: true + choices: [ consumer, provider ] + 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_vrf +extends_documentation_fragment: cisco.mso.modules +''' + +EXAMPLES = r''' +- name: Add a contract to a VRF + cisco.mso.mso_schema_template_vrf_contract: + host: mso_host + username: admin + password: SomeSecretPassword + schema: Schema 1 + template: Template 1 + vrf: VRF 1 + contract: + name: Contract 1 + type: consumer + state: present + delegate_to: localhost + +- name: Remove a Contract + cisco.mso.mso_schema_template_vrf_contract: + host: mso_host + username: admin + password: SomeSecretPassword + schema: Schema 1 + template: Template 1 + vrf: VRF 1 + contract: + name: Contract 1 + type: consumer + state: absent + delegate_to: localhost + +- name: Query a specific Contract + cisco.mso.mso_schema_template_vrf_contract: + host: mso_host + username: admin + password: SomeSecretPassword + schema: Schema 1 + template: Template 1 + vrf: VRF 1 + contract: + name: Contract 1 + type: consumer + state: query + delegate_to: localhost + register: query_result + +- name: Query all Contracts + cisco.mso.mso_schema_template_vrf_contract: + host: mso_host + username: admin + password: SomeSecretPassword + schema: Schema 1 + template: Template 1 + vrf: VRF 1 + 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_contractref_spec + + +def main(): + argument_spec = mso_argument_spec() + argument_spec.update( + schema=dict(type='str', required=True), + template=dict(type='str', required=True), + vrf=dict(type='str', required=True), + contract=dict(type='dict', options=mso_contractref_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']], + ], + ) + + schema = module.params.get('schema') + template = module.params.get('template').replace(' ', '') + vrf = module.params.get('vrf') + contract = module.params.get('contract') + if contract is not None and contract.get('template') is not None: + contract['template'] = contract.get('template').replace(' ', '') + state = module.params.get('state') + + mso = MSOModule(module) + 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_id + schema_obj = mso.get_obj('schemas', displayName=schema) + if not schema_obj: + mso.fail_json(msg="Provided schema '{0}' does not exist".format(schema)) + + schema_path = 'schemas/{id}'.format(**schema_obj) + + # 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 VRF + vrfs = [e.get('name') for e in schema_obj.get('templates')[template_idx]['vrfs']] + if vrf not in vrfs: + mso.fail_json(msg="Provided vrf '{vrf}' does not exist. Existing vrfs: {vrfs}".format(vrf=vrf, vrfs=', '.join(vrfs))) + vrf_idx = vrfs.index(vrf) + vrf_obj = schema_obj.get('templates')[template_idx]['vrfs'][vrf_idx] + + if not vrf_obj.get('vzAnyEnabled'): + mso.fail_json(msg="vzAny attribute on vrf '{0}' is disabled.".format(vrf)) + + # Get Contract + if contract: + provider_contracts = [c.get('contractRef') for c in schema_obj.get('templates')[template_idx]['vrfs'][vrf_idx]['vzAnyProviderContracts']] + consumer_contracts = [c.get('contractRef') for c in schema_obj.get('templates')[template_idx]['vrfs'][vrf_idx]['vzAnyConsumerContracts']] + contract_ref = mso.contract_ref(**contract) + if contract_ref in provider_contracts and contract.get('type') == 'provider': + contract_idx = provider_contracts.index(contract_ref) + contract_path = '/templates/{0}/vrfs/{1}/vzAnyProviderContracts/{2}'.format(template, vrf, contract_idx) + mso.existing = schema_obj.get('templates')[template_idx]['vrfs'][vrf_idx]['vzAnyProviderContracts'][contract_idx] + if contract_ref in consumer_contracts and contract.get('type') == 'consumer': + contract_idx = consumer_contracts.index(contract_ref) + contract_path = '/templates/{0}/vrfs/{1}/vzAnyConsumerContracts/{2}'.format(template, vrf, contract_idx) + mso.existing = schema_obj.get('templates')[template_idx]['vrfs'][vrf_idx]['vzAnyConsumerContracts'][contract_idx] + if mso.existing.get('contractRef'): + mso.existing['contractRef'] = mso.dict_from_ref(mso.existing.get('contractRef')) + mso.existing['relationshipType'] = contract.get('type') + + if state == 'query': + if not contract: + provider_contracts = [dict(contractRef=mso.dict_from_ref(c.get('contractRef')), + relationshipType='provider') for c in schema_obj.get('templates')[template_idx]['vrfs'][vrf_idx]['vzAnyProviderContracts']] + consumer_contracts = [dict(contractRef=mso.dict_from_ref(c.get('contractRef')), + relationshipType='consumer') for c in schema_obj.get('templates')[template_idx]['vrfs'][vrf_idx]['vzAnyConsumerContracts']] + mso.existing = provider_contracts + consumer_contracts + elif not mso.existing: + mso.fail_json(msg="Contract '{0}' not found".format(contract.get('name'))) + + mso.exit_json() + + if contract.get('type') == 'provider': + contracts_path = '/templates/{0}/vrfs/{1}/vzAnyProviderContracts/-'.format(template, vrf) + if contract.get('type') == 'consumer': + contracts_path = '/templates/{0}/vrfs/{1}/vzAnyConsumerContracts/-'.format(template, vrf) + ops = [] + + mso.previous = mso.existing + if state == 'absent': + if mso.existing: + mso.sent = mso.existing = {} + ops.append(dict(op='remove', path=contract_path)) + + elif state == 'present': + payload = dict( + contractRef=dict( + contractName=contract.get('name'), + templateName=contract.get('template'), + schemaId=contract.get('schema_id'), + ), + ) + + 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)) + + mso.existing = mso.proposed + mso.existing['relationshipType'] = contract.get('type') + + if not module.check_mode and mso.proposed != mso.previous: + mso.request(schema_path, method='PATCH', data=ops) + + mso.exit_json() + + +if __name__ == "__main__": + main() diff --git a/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_site.py b/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_site.py new file mode 100644 index 00000000..2b6cf82f --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_site.py @@ -0,0 +1,252 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright: (c) 2018, Dag Wieers (@dagwieers) +# 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_site +short_description: Manage sites +description: +- Manage sites on Cisco ACI Multi-Site. +author: +- Dag Wieers (@dagwieers) +options: + apic_password: + description: + - The password for the APICs. + type: str + apic_site_id: + description: + - The site ID of the APICs. + type: str + apic_username: + description: + - The username for the APICs. + type: str + default: admin + apic_login_domain: + description: + - The AAA login domain for the username for the APICs. + type: str + site: + description: + - The name of the site. + type: str + aliases: [ name ] + labels: + description: + - The labels for this site. + - Labels that do not already exist will be automatically created. + type: list + elements: str + location: + description: + - Location of the site. + type: dict + suboptions: + latitude: + description: + - The latitude of the location of the site. + type: float + longitude: + description: + - The longitude of the location of the site. + type: float + urls: + description: + - A list of URLs to reference the APICs. + 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 +extends_documentation_fragment: cisco.mso.modules +''' + +EXAMPLES = r''' +- name: Add a new site + cisco.mso.mso_site: + host: mso_host + username: admin + password: SomeSecretPassword + site: north_europe + description: North European Datacenter + apic_username: mso_admin + apic_password: AnotherSecretPassword + apic_site_id: 12 + urls: + - 10.2.3.4 + - 10.2.4.5 + - 10.3.5.6 + labels: + - NEDC + - Europe + - Diegem + location: + latitude: 50.887318 + longitude: 4.447084 + state: present + delegate_to: localhost + +- name: Remove a site + cisco.mso.mso_site: + host: mso_host + username: admin + password: SomeSecretPassword + site: north_europe + state: absent + delegate_to: localhost + +- name: Query a site + cisco.mso.mso_site: + host: mso_host + username: admin + password: SomeSecretPassword + site: north_europe + state: query + delegate_to: localhost + register: query_result + +- name: Query all sites + cisco.mso.mso_site: + host: mso_host + username: admin + password: SomeSecretPassword + 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 + + +def main(): + location_arg_spec = dict( + latitude=dict(type='float'), + longitude=dict(type='float'), + ) + + argument_spec = mso_argument_spec() + argument_spec.update( + apic_password=dict(type='str', no_log=True), + apic_site_id=dict(type='str'), + apic_username=dict(type='str', default='admin'), + apic_login_domain=dict(type='str'), + labels=dict(type='list', elements='str'), + location=dict(type='dict', options=location_arg_spec), + site=dict(type='str', aliases=['name']), + state=dict(type='str', default='present', choices=['absent', 'present', 'query']), + urls=dict(type='list', elements='str'), + ) + + module = AnsibleModule( + argument_spec=argument_spec, + supports_check_mode=True, + required_if=[ + ['state', 'absent', ['site']], + ['state', 'present', ['apic_site_id', 'site']], + ], + ) + + apic_username = module.params.get('apic_username') + apic_password = module.params.get('apic_password') + apic_site_id = module.params.get('apic_site_id') + site = module.params.get('site') + location = module.params.get('location') + if location is not None: + latitude = module.params.get('location')['latitude'] + longitude = module.params.get('location')['longitude'] + state = module.params.get('state') + urls = module.params.get('urls') + apic_login_domain = module.params.get('apic_login_domain') + + mso = MSOModule(module) + + site_id = None + path = 'sites' + + # Convert labels + labels = mso.lookup_labels(module.params.get('labels'), 'site') + + # Query for mso.existing object(s) + if site: + mso.existing = mso.get_obj(path, name=site) + if mso.existing: + site_id = mso.existing.get('id') + # If we found an existing object, continue with it + path = 'sites/{id}'.format(id=site_id) + else: + mso.existing = mso.query_objs(path) + + if state == 'query': + pass + + elif state == 'absent': + mso.previous = mso.existing + if mso.existing: + if module.check_mode: + mso.existing = {} + else: + mso.existing = mso.request(path, method='DELETE', qs=dict(force='true')) + + elif state == 'present': + mso.previous = mso.existing + + payload = dict( + apicSiteId=apic_site_id, + id=site_id, + name=site, + urls=urls, + labels=labels, + username=apic_username, + password=apic_password, + ) + + if location is not None: + payload['location'] = dict( + lat=latitude, + long=longitude, + ) + + if apic_login_domain is not None and apic_login_domain not in ['', 'local', 'Local']: + payload['username'] = 'apic#{0}\\{1}'.format(apic_login_domain, apic_username) + + mso.sanitize(payload, collate=True) + + if mso.existing: + if mso.check_changed(): + if module.check_mode: + mso.existing = mso.proposed + else: + mso.existing = mso.request(path, method='PUT', data=mso.sent) + else: + if module.check_mode: + mso.existing = mso.proposed + else: + mso.existing = mso.request(path, method='POST', data=mso.sent) + + if 'password' in mso.existing: + mso.existing['password'] = '******' + + mso.exit_json() + + +if __name__ == "__main__": + main() diff --git a/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_tenant.py b/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_tenant.py new file mode 100644 index 00000000..68f54290 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_tenant.py @@ -0,0 +1,197 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright: (c) 2018, Dag Wieers (@dagwieers) +# Copyright: (c) 2020, Cindy Zhao (@cizhao) +# 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_tenant +short_description: Manage tenants +description: +- Manage tenants on Cisco ACI Multi-Site. +author: +- Dag Wieers (@dagwieers) +options: + tenant: + description: + - The name of the tenant. + type: str + aliases: [ name ] + display_name: + description: + - The name of the tenant to be displayed in the web UI. + type: str + description: + description: + - The description for this tenant. + type: str + users: + description: + - A list of associated users for this tenant. + - Using this property will replace any existing associated users. + - Admin user is always added to the associated user list irrespective of this parameter being used. + type: list + elements: str + sites: + description: + - A list of associated sites for this tenant. + - Using this property will replace any existing associated sites. + 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 +extends_documentation_fragment: cisco.mso.modules +''' + +EXAMPLES = r''' +- name: Add a new tenant + cisco.mso.mso_tenant: + host: mso_host + username: admin + password: SomeSecretPassword + tenant: north_europe + display_name: North European Datacenter + description: This tenant manages the NEDC environment. + state: present + delegate_to: localhost + +- name: Remove a tenant + cisco.mso.mso_tenant: + host: mso_host + username: admin + password: SomeSecretPassword + tenant: north_europe + state: absent + delegate_to: localhost + +- name: Query a tenant + cisco.mso.mso_tenant: + host: mso_host + username: admin + password: SomeSecretPassword + tenant: north_europe + state: query + delegate_to: localhost + register: query_result + +- name: Query all tenants + cisco.mso.mso_tenant: + host: mso_host + username: admin + password: SomeSecretPassword + 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 + + +def main(): + argument_spec = mso_argument_spec() + argument_spec.update( + description=dict(type='str'), + display_name=dict(type='str'), + tenant=dict(type='str', aliases=['name']), + users=dict(type='list', elements='str'), + sites=dict(type='list', elements='str'), + state=dict(type='str', default='present', choices=['absent', 'present', 'query']), + ) + + module = AnsibleModule( + argument_spec=argument_spec, + supports_check_mode=True, + required_if=[ + ['state', 'absent', ['tenant']], + ['state', 'present', ['tenant']], + ], + ) + + description = module.params.get('description') + display_name = module.params.get('display_name') + tenant = module.params.get('tenant') + state = module.params.get('state') + + 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' + + # Query for existing object(s) + if tenant: + mso.existing = mso.get_obj(path, name=tenant) + if mso.existing: + tenant_id = mso.existing.get('id') + # If we found an existing object, continue with it + path = 'tenants/{id}'.format(id=tenant_id) + else: + mso.existing = mso.query_objs(path) + + if state == 'query': + pass + + elif state == 'absent': + mso.previous = mso.existing + if mso.existing: + if module.check_mode: + mso.existing = {} + else: + mso.existing = mso.request(path, method='DELETE') + + elif state == 'present': + mso.previous = mso.existing + + payload = dict( + description=description, + id=tenant_id, + name=tenant, + displayName=display_name, + siteAssociations=sites, + userAssociations=users, + ) + + mso.sanitize(payload, collate=True) + + # Ensure displayName is not undefined + if mso.sent.get('displayName') is None: + mso.sent['displayName'] = tenant + + if mso.existing: + if mso.check_changed(): + if module.check_mode: + mso.existing = mso.proposed + else: + mso.existing = mso.request(path, method='PUT', data=mso.sent) + else: + if module.check_mode: + mso.existing = mso.proposed + else: + mso.existing = mso.request(path, method='POST', data=mso.sent) + + mso.exit_json() + + +if __name__ == "__main__": + main() diff --git a/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_tenant_site.py b/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_tenant_site.py new file mode 100644 index 00000000..bb65b3fe --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_tenant_site.py @@ -0,0 +1,391 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright: (c) 2018, Dag Wieers (@dagwieers) +# Copyright: (c) 2020, Shreyas Srish (@shrsr) +# 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_tenant_site +short_description: Manage tenants with cloud sites. +description: +- Manage tenants with cloud sites on Cisco ACI Multi-Site. +author: +- Shreyas Srish (@shrsr) +options: + tenant: + description: + - The name of the tenant. + type: str + required: yes + site: + description: + - The name of the site. + - This can either be cloud site or non-cloud site. + type: str + aliases: [ name ] + cloud_account: + description: + - Required for cloud site. + - Account id of AWS in the form '000000000000'. + - Account id of Azure in the form 'uni/tn-(tenant_name)/act-[(subscription_id)]-azure_vendor-azure'. + - Example values inside account id of Azure '(tenant_name)=tenant_test and (subscription_id)=10'. + type: str + security_domains: + description: + - List of security domains for cloud sites. + type: list + elements: str + default: [] + aws_account_org: + description: + - AWS account for organization. + default: false + type: bool + aws_trusted: + description: + - AWS account's access in trusted mode. Credentials are required, when set to false. + type: bool + aws_access_key: + description: + - AWS account's access key id. This is required when aws_trusted is set to false. + type: str + azure_access_type: + description: + - Managed mode for Azure. + - Unmanaged mode for Azure. + - Shared mode if the attribute is not specified. + choices: [ managed, unmanaged, shared ] + default: shared + type: str + azure_active_directory_id: + description: + - Azure account's active directory id. + - This attribute is required when azure_access_type is in unmanaged mode. + type: str + azure_active_directory_name: + description: + - Azure account's active directory name. Example being 'CiscoINSBUAd' as active directory name. + - This attribute is required when azure_access_type is in unmanaged mode. + type: str + azure_subscription_id: + description: + - Azure account's subscription id. + - This attribute is required when azure_access_type is either in managed mode or unmanaged mode. + type: str + azure_application_id: + description: + - Azure account's application id. + - This attribute is required when azure_access_type is either in managed mode or unmanaged mode. + type: str + azure_credential_name: + description: + - Azure account's credential name. + - This attribute is required when azure_access_type is in unmanaged mode. + type: str + secret_key: + description: + - secret key of AWS for untrusted account. Required when aws_trusted is set to false. + - secret key of Azure account for unmanaged identity. Required in unmanaged mode of Azure account. + type: 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 +extends_documentation_fragment: cisco.mso.modules +''' + +EXAMPLES = r''' +- name: Associate a non-cloud site with a tenant + cisco.mso.mso_tenant_site: + host: mso_host + username: admin + password: SomeSecretPassword + 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: + host: mso_host + username: admin + password: SomeSecretPassword + tenant: tenant_name + site: site_name + 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: + host: mso_host + username: admin + password: SomeSecretPassword + tenant: tenant_name + site: AWS + cloud_account: '000000000000' + aws_trusted: false + aws_access_key: '1' + secret_key: '0' + aws_account_org: false + state: present + delegate_to: localhost + +- name: Associate Azure site in managed mode + mso.cisco.mso_tenant_site: + host: mso_host + username: admin + password: SomeSecretPassword + tenant: tenant_name + site: site_name + cloud_account: uni/tn-ansible_test/act-[9]-azure_vendor-azure + azure_access_type: managed + 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: + host: mso_host + username: admin + password: SomeSecretPassword + tenant: tenant_name + site: site_name + cloud_account: uni/tn-ansible_test/act-[9]-azure_vendor-azure + azure_access_type: unmanaged + azure_subscription_id: '9' + azure_application_id: '100' + azure_credential_name: cApicApp + secret_key: iins + azure_active_directory_id: '32' + azure_active_directory_name: CiscoINSBUAd + state: present + delegate_to: localhost + +- name: Dissociate a site + cisco.mso.mso_tenant_site: + host: mso_host + username: admin + password: SomeSecretPassword + tenant: tenant_name + site: site_name + state: absent + delegate_to: localhost + +- name: Query a site + cisco.mso.mso_tenant_site: + host: mso_host + username: admin + password: SomeSecretPassword + tenant: tenant_name + site: site_name + state: query + delegate_to: localhost + +- name: Query all sites of a tenant + cisco.mso.mso_tenant_site: + host: mso_host + username: admin + password: SomeSecretPassword + tenant: tenant_name + 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 + + +def main(): + argument_spec = mso_argument_spec() + argument_spec.update( + tenant=dict(type='str', aliases=['name'], required=True), + site=dict(type='str', aliases=['name']), + cloud_account=dict(type='str'), + security_domains=dict(type='list', elements='str', default=[]), + aws_trusted=dict(type='bool'), + azure_access_type=dict(type='str', default='shared', choices=['managed', 'unmanaged', 'shared']), + azure_active_directory_id=dict(type='str'), + aws_access_key=dict(type='str'), + aws_account_org=dict(type='bool', default='false'), + azure_active_directory_name=dict(type='str'), + azure_subscription_id=dict(type='str'), + azure_application_id=dict(type='str'), + azure_credential_name=dict(type='str'), + secret_key=dict(type='str'), + state=dict(type='str', default='present', choices=['absent', 'present', 'query']), + ) + + module = AnsibleModule( + argument_spec=argument_spec, + supports_check_mode=True, + required_if=[ + ['state', 'absent', ['tenant', 'site']], + ['state', 'present', ['tenant', 'site']], + ], + ) + + state = module.params.get('state') + security_domains = module.params.get('security_domains') + cloud_account = module.params.get('cloud_account') + azure_access_type = module.params.get('azure_access_type') + azure_credential_name = module.params.get('azure_credential_name') + azure_application_id = module.params.get('azure_application_id') + azure_active_directory_id = module.params.get('azure_active_directory_id') + azure_active_directory_name = module.params.get('azure_active_directory_name') + azure_subscription_id = module.params.get('azure_subscription_id') + secret_key = module.params.get('secret_key') + aws_account_org = module.params.get('aws_account_org') + aws_access_key = module.params.get('aws_access_key') + aws_trusted = module.params.get('aws_trusted') + + mso = MSOModule(module) + + # Get tenant_id and site_id + tenant_id = mso.lookup_tenant(module.params.get('tenant')) + site_id = mso.lookup_site(module.params.get('site')) + tenants = [(t.get('id')) for t in mso.query_objs('tenants')] + tenant_idx = tenants.index((tenant_id)) + + # set tenent and port paths + tenant_path = 'tenants/{0}'.format(tenant_id) + ops = [] + ports_path = '/siteAssociations/-' + port_path = '/siteAssociations/{0}'.format(site_id) + + payload = dict( + siteId=site_id, + securityDomains=security_domains, + cloudAccount=cloud_account, + ) + + if cloud_account: + if 'azure' in cloud_account: + azure_account = dict( + accessType=azure_access_type, + securityDomains=security_domains, + vendor='azure', + ) + + payload['azureAccount'] = [azure_account] + + cloudSubscription = dict( + cloudSubscriptionId=azure_subscription_id, + cloudApplicationId=azure_application_id, + ) + + payload['azureAccount'][0]['cloudSubscription'] = cloudSubscription + + if azure_access_type == 'shared': + payload['azureAccount'] = [] + + if azure_access_type == 'managed': + if not azure_subscription_id: + mso.fail_json(msg="azure_susbscription_id is required when in managed mode.") + if not azure_application_id: + mso.fail_json(msg="azure_application_id is required when in managed mode.") + payload['azureAccount'][0]['cloudApplication'] = [] + payload['azureAccount'][0]['cloudActiveDirectory'] = [] + + if azure_access_type == 'unmanaged': + if not azure_subscription_id: + mso.fail_json(msg="azure_subscription_id is required when in unmanaged mode.") + if not azure_application_id: + mso.fail_json(msg="azure_application_id is required when in unmanaged mode.") + if not secret_key: + mso.fail_json(msg="secret_key is required when in unmanaged mode.") + if not azure_active_directory_id: + mso.fail_json(msg="azure_active_directory_id is required when in unmanaged mode.") + if not azure_active_directory_name: + mso.fail_json(msg="azure_active_directory_name is required when in unmanaged mode.") + if not azure_credential_name: + mso.fail_json(msg="azure_credential_name is required when in unmanaged mode.") + azure_account.update( + accessType='credentials', + ) + cloudApplication = dict( + cloudApplicationId=azure_application_id, + cloudCredentialName=azure_credential_name, + secretKey=secret_key, + cloudActiveDirectoryId=azure_active_directory_id + ) + cloudActiveDirectory = dict( + cloudActiveDirectoryId=azure_active_directory_id, + cloudActiveDirectoryName=azure_active_directory_name + ) + payload['azureAccount'][0]['cloudApplication'] = [cloudApplication] + payload['azureAccount'][0]['cloudActiveDirectory'] = [cloudActiveDirectory] + + else: + aws_account = dict( + accountId=cloud_account, + isTrusted=aws_trusted, + accessKeyId=aws_access_key, + secretKey=secret_key, + isAccountInOrg=aws_account_org, + ) + + if not aws_trusted: + if not aws_access_key: + mso.fail_json(msg="aws_access_key is a required field in untrusted mode.") + if not secret_key: + mso.fail_json(msg="secret_key is a required field in untrusted mode.") + payload['awsAccount'] = [aws_account] + + sites = [(s.get('siteId')) for s in mso.query_objs('tenants')[tenant_idx]['siteAssociations']] + + if site_id in sites: + site_idx = sites.index((site_id)) + mso.existing = mso.query_objs('tenants')[tenant_idx]['siteAssociations'][site_idx] + + if state == 'query': + if len(sites) == 0: + mso.fail_json(msg="No site associated with tenant Id {0}".format(tenant_id)) + elif site_id not in sites and site_id is not None: + mso.fail_json(msg="Site Id {0} not associated with tenant Id {1}".format(site_id, tenant_id)) + elif site_id is None: + mso.existing = mso.query_objs('tenants')[tenant_idx]['siteAssociations'] + mso.exit_json() + + mso.previous = mso.existing + + if state == 'absent': + if mso.existing: + mso.sent = mso.existing = {} + ops.append(dict(op='remove', path=port_path)) + if 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=ports_path, value=mso.sent)) + + mso.existing = mso.proposed + + if not module.check_mode and mso.proposed != mso.previous: + mso.request(tenant_path, method='PATCH', data=ops) + + mso.exit_json() + + +if __name__ == "__main__": + main() diff --git a/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_user.py b/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_user.py new file mode 100644 index 00000000..560063f8 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_user.py @@ -0,0 +1,277 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright: (c) 2018, Dag Wieers (@dagwieers) +# 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_user +short_description: Manage users +description: +- Manage users on Cisco ACI Multi-Site. +author: +- Dag Wieers (@dagwieers) +options: + user: + description: + - The name of the user. + type: str + aliases: [ name ] + user_password: + description: + - The password of the user. + type: str + first_name: + description: + - The first name of the user. + - This parameter is required when creating new users. + type: str + last_name: + description: + - The last name of the user. + - This parameter is required when creating new users. + type: str + email: + description: + - The email address of the user. + - This parameter is required when creating new users. + type: str + phone: + description: + - The phone number of the user. + - This parameter is required when creating new users. + type: str + account_status: + description: + - The status of the user account. + type: str + choices: [ active, inactive ] + domain: + description: + - The domain this user belongs to. + - When creating new users, this defaults to C(Local). + type: str + roles: + description: + - The roles for this user and their access types (read or write). + - Access type defaults to C(write). + type: list + 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 +notes: +- A default installation of ACI Multi-Site ships with admin password 'we1come!' which requires a password change on first login. + See the examples of how to change the 'admin' password using Ansible. +extends_documentation_fragment: cisco.mso.modules +''' + +EXAMPLES = r''' +- name: Update initial admin password + cisco.mso.mso_user: + host: mso_host + username: admin + password: initialPassword + validate_certs: false + user: admin + user_password: newPassword + state: present + delegate_to: localhost + +- name: Add a new user + cisco.mso.mso_user: + host: mso_host + username: admin + password: SomeSecretPassword + validate_certs: false + user: dag + user_password: userPassword + first_name: Dag + last_name: Wieers + email: dag@wieers.com + phone: +32 478 436 299 + roles: + - name: siteManager + access_type: write + - name: schemaManager + access_type: read + state: present + delegate_to: localhost + +- name: Add a new user + cisco.mso.mso_user: + host: mso_host + username: admin + password: SomeSecretPassword + validate_certs: false + user: dag + first_name: Dag + last_name: Wieers + email: dag@wieers.com + phone: +32 478 436 299 + roles: + - powerUser + delegate_to: localhost + +- name: Remove a user + cisco.mso.mso_user: + host: mso_host + username: admin + password: SomeSecretPassword + validate_certs: false + user: dag + state: absent + delegate_to: localhost + +- name: Query a user + cisco.mso.mso_user: + host: mso_host + username: admin + password: SomeSecretPassword + validate_certs: false + user: dag + state: query + delegate_to: localhost + register: query_result + +- name: Query all users + cisco.mso.mso_user: + host: mso_host + username: admin + password: SomeSecretPassword + validate_certs: false + 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, issubset + + +def main(): + argument_spec = mso_argument_spec() + argument_spec.update( + user=dict(type='str', aliases=['name']), + user_password=dict(type='str', no_log=True), + first_name=dict(type='str'), + last_name=dict(type='str'), + email=dict(type='str'), + phone=dict(type='str'), + # TODO: What possible options do we have ? + account_status=dict(type='str', choices=['active', 'inactive']), + domain=dict(type='str'), + roles=dict(type='list'), + state=dict(type='str', default='present', choices=['absent', 'present', 'query']), + ) + + module = AnsibleModule( + argument_spec=argument_spec, + supports_check_mode=True, + required_if=[ + ['state', 'absent', ['user']], + ['state', 'present', ['user']], + ], + ) + + user_name = module.params.get('user') + user_password = module.params.get('user_password') + first_name = module.params.get('first_name') + last_name = module.params.get('last_name') + email = module.params.get('email') + phone = module.params.get('phone') + account_status = module.params.get('account_status') + state = module.params.get('state') + + mso = MSOModule(module) + + roles = mso.lookup_roles(module.params.get('roles')) + domain = mso.lookup_domain(module.params.get('domain')) + + user_id = None + path = 'users' + + # Query for existing object(s) + if user_name: + mso.existing = mso.get_obj(path, username=user_name) + if mso.existing: + user_id = mso.existing.get('id') + # If we found an existing object, continue with it + path = 'users/{id}'.format(id=user_id) + else: + mso.existing = mso.query_objs(path) + + if state == 'query': + pass + + elif state == 'absent': + mso.previous = mso.existing + if mso.existing: + if module.check_mode: + mso.existing = {} + else: + mso.existing = mso.request(path, method='DELETE') + + elif state == 'present': + mso.previous = mso.existing + + payload = dict( + id=user_id, + username=user_name, + firstName=first_name, + lastName=last_name, + emailAddress=email, + phoneNumber=phone, + accountStatus=account_status, + domainId=domain, + roles=roles, + # active=True, + # remote=True, + ) + + if user_password is not None: + payload.update(password=user_password) + + mso.sanitize(payload, collate=True) + + if mso.sent.get('accountStatus') is None: + mso.sent['accountStatus'] = 'active' + + if mso.existing: + if not issubset(mso.sent, mso.existing): + # NOTE: Since MSO always returns '******' as password, we need to assume a change + if 'password' in mso.proposed: + mso.module.warn("A password change is assumed, as the MSO REST API does not return passwords we do not know.") + mso.result['changed'] = True + + if module.check_mode: + mso.existing = mso.proposed + else: + mso.existing = mso.request(path, method='PUT', data=mso.sent) + + else: + if user_password is None: + mso.fail_json("The user {0} does not exist. The 'user_password' attribute is required to create a new user.".format(user_name)) + if module.check_mode: + mso.existing = mso.proposed + else: + mso.existing = mso.request(path, method='POST', data=mso.sent) + + mso.exit_json() + + +if __name__ == "__main__": + main() diff --git a/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_version.py b/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_version.py new file mode 100644 index 00000000..33259826 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/plugins/modules/mso_version.py @@ -0,0 +1,71 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright: (c) 2020, Lionel Hercot (@lhercot) +# 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_version +short_description: Get version of MSO +description: +- Retrieve the code version of Cisco Multi-Site Orchestrator. +author: +- Lionel Hercot (@lhercot) +options: + state: + description: + - Use C(query) for retrieving the version object. + type: str + choices: [ query ] + default: query +extends_documentation_fragment: cisco.mso.modules +''' + +EXAMPLES = r''' +- name: Get MSO version + cisco.mso.mso_version: + host: mso_host + username: admin + password: SomeSecretPassword + 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 + + +def main(): + argument_spec = mso_argument_spec() + argument_spec.update( + state=dict(type='str', default='query', choices=['query']) + ) + + module = AnsibleModule( + argument_spec=argument_spec, + supports_check_mode=True + ) + + mso = MSOModule(module) + + path = 'platform/version' + + # Query for mso.existing object + mso.existing = mso.query_obj(path) + mso.exit_json() + + +if __name__ == "__main__": + main() diff --git a/collections-debian-merged/ansible_collections/cisco/mso/tests/.gitignore b/collections-debian-merged/ansible_collections/cisco/mso/tests/.gitignore new file mode 100644 index 00000000..ea1472ec --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/tests/.gitignore @@ -0,0 +1 @@ +output/ diff --git a/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/inventory.networking b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/inventory.networking new file mode 100644 index 00000000..4ed384db --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/inventory.networking @@ -0,0 +1,20 @@ +[mso] +lh-dmz1-pod1-mso-v223 ansible_host=173.36.219.11 ansible_connection=local mso_hostname=173.36.219.11 mso_username=ansible_github_ci mso_password="sJ94G92#8dq2hx*K4qh" +lh-dmz1-pod1-mso-v224 ansible_host=173.36.219.29 ansible_connection=local mso_hostname=173.36.219.29 mso_username=ansible_github_ci mso_password="sJ94G92#8dq2hx*K4qh" +lh-dmz1-pod1-mso-v302 ansible_host=173.36.219.30 ansible_connection=local mso_hostname=173.36.219.30 mso_username=ansible_github_ci mso_password="sJ94G92#8dq2hx*K4qh" + +[mso:vars] +apic_hostname=173.36.219.25 +apic_username=ansible_github_ci +apic_password="sJ94G92#8dq2hx*K4qh" +apic_site_id=101 +aws_apic_hostname=54.176.140.90 +aws_apic_username=ansible_github_ci +aws_apic_password="sJ94G92#8dq2hx*K4qh" +aws_site_id=20 +azure_apic_hostname=104.42.26.226 +azure_apic_username=ansible_github_ci +azure_apic_password="sJ94G92#8dq2hx*K4qh" +azure_site_id=10 +ansible_connection=local +ansible_python_interpreter=/usr/bin/python3.7 \ No newline at end of file diff --git a/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/network-integration.requirements.txt b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/network-integration.requirements.txt new file mode 100644 index 00000000..1ecd96b2 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/network-integration.requirements.txt @@ -0,0 +1 @@ +requests-toolbelt \ No newline at end of file diff --git a/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/target-prefixes.network b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/target-prefixes.network new file mode 100644 index 00000000..4cb8de95 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/target-prefixes.network @@ -0,0 +1 @@ +mso \ No newline at end of file diff --git a/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_backup/aliases b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_backup/aliases new file mode 100644 index 00000000..5042c9c0 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_backup/aliases @@ -0,0 +1,2 @@ +# No ACI MultiSite infrastructure, so not enabled +# unsupported diff --git a/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_backup/tasks/main.yml b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_backup/tasks/main.yml new file mode 100644 index 00000000..f6542cd6 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_backup/tasks/main.yml @@ -0,0 +1,466 @@ +# Test code for the MSO modules +# Copyright: (c) 2020, Shreyas Srish (@shrsr) + +# 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.' + 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: + 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(true) }}' + output_level: '{{ mso_output_level | default("info") }}' + +- name: Query MSO version + mso_version: + <<: *mso_info + state: query + register: version + +- name: Clear tenant + mso_tenant: + <<: *mso_info + tenant: Tenant1 + display_name: Test_Tenant + state: absent + +- name: Query all backups + mso_backup: + <<: *mso_info + state: query + register: query_ansibleBackup_for_delete + +- name: Remove backups starting with name ansibleBackup + mso_backup: + <<: *mso_info + backup: '{{ item.name }}' + state: absent + loop: '{{ query_ansibleBackup_for_delete.current | selectattr("name", "match", "^ansibleBackup.*") | list }}' + +# Create Backups +- name: Create ansibleBackup1 in check mode + mso_backup: + <<: *mso_info + backup: ansibleBackup1 + description: via Ansible + location_type: local + state: present + register: cm_add_ansibleBackup1 + check_mode: yes + +- name: Verify cm_add_ansibleBackup1 + assert: + that: + - cm_add_ansibleBackup1 is changed + +- name: Create ansibleBackup1 in normal mode + mso_backup: + <<: *mso_info + backup: ansibleBackup1 + description: via Ansible + location_type: local + state: present + register: nm_add_ansibleBackup1 + +- name: Verify nm_add_ansibleBackup1 + assert: + that: + - nm_add_ansibleBackup1.current.backupEntry.metadata.name is match("ansibleBackup1_[0-9a-zA-Z]*") + +- name: Create ansibleBackup2 in normal mode + mso_backup: + <<: *mso_info + backup: ansibleBackup2 + description: via Ansible + location_type: local + state: present + register: nm_add_ansibleBackup2 + +- name: Verify nm_add_ansibleBackup2 + assert: + that: + - nm_add_ansibleBackup2.current.backupEntry.metadata.name is match ("ansibleBackup2_[0-9a-zA-Z]*") + +- name: Create ansibleBackup3 in normal mode + mso_backup: + <<: *mso_info + backup: ansibleBackup3 + description: via Ansible + location_type: local + state: present + register: nm_add_ansibleBackup3 + +- name: Verify nm_add_ansibleBackup3 + assert: + that: + - nm_add_ansibleBackup3.current.backupEntry.metadata.name is match ("ansibleBackup3_[0-9a-zA-Z]*") + +- name: Create ansibleBackup3 in normal mode again + mso_backup: + <<: *mso_info + backup: ansibleBackup3 + description: via Ansible + location_type: local + state: present + register: nm_add_ansibleBackup3_again + +- name: Verify nm_add_ansibleBackup3_again + assert: + that: + - nm_add_ansibleBackup3_again.current.backupEntry.metadata.name is match ("ansibleBackup3_[0-9a-zA-Z]*") + +- name: Create ansibleBackupRemote1 in normal mode + mso_backup: + <<: *mso_info + backup: ansibleBackupRemote1 + description: Remote via Ansible + location_type: remote + remote_location: ansible_test + state: present + register: nm_add_ansibleBackupRemote1 + +- name: Verify nm_add_ansibleBackupRemote1 + assert: + that: + - nm_add_ansibleBackupRemote1.current.backupEntry.metadata.name is match ("ansibleBackupRemote1_[0-9a-zA-Z]*") + +- name: Verify nm_add_ansibleBackupRemote1 + assert: + that: + - nm_add_ansibleBackupRemote1.current.backupEntry.metadata.name is match ("ansibleBackupRemote1_[0-9a-zA-Z]*") + +- name: Create ansibleBackupRemote2 in normal mode in a known path + mso_backup: + <<: *mso_info + backup: ansibleBackupRemote2 + description: Remote via Ansible + location_type: remote + remote_location: ansible_test + remote_path: test + state: present + register: nm_add_ansibleBackupRemote2_known_path + +- name: Verify nm_add_ansibleBackupRemote2_known_path + assert: + that: + - nm_add_ansibleBackupRemote2_known_path.current.backupEntry.metadata.name is match ("ansibleBackupRemote2_[0-9a-zA-Z]*") + +- name: Create ansibleBackupMove in normal mode + mso_backup: + <<: *mso_info + backup: ansibleBackupMove + description: Local to Remote via Ansible + location_type: local + state: present + +# Move Backup test +- name: Move backup from local to remote location in check mode + mso_backup: + <<: *mso_info + remote_location: ansible_test + remote_path: test + backup: ansibleBackupMove + description: Local to Remote via Ansible + state: move + check_mode: yes + register: move_backup_cm + +- name: Move backup from local to remote location in normal mode + mso_backup: + <<: *mso_info + remote_location: ansible_test + remote_path: test + backup: ansibleBackupMove + description: Local to Remote via Ansible + state: move + register: move_backup_nm + +- name: Move a non existent backup from local location to remote + mso_backup: + <<: *mso_info + backup: non_existent_backup + remote_location: ansible_test + remote_path: test + state: move + register: move_non_existent_backup + ignore_errors: yes + +- name: Move a ansibleBackup3 from local location to remote + mso_backup: + <<: *mso_info + backup: ansibleBackup3 + remote_location: ansible_test + remote_path: test + state: move + register: move_ansibleBackup3 + ignore_errors: yes + +- name: Verify move function of backup + assert: + that: + - move_backup_cm is changed + - move_backup_nm is changed + - move_non_existent_backup.msg is match ("Backup 'non_existent_backup' does not exist") + - move_ansibleBackup3.msg is match ("Multiple backups with same name found. Existing backups with similar names{{':'}} ansibleBackup3_[0-9]*, ansibleBackup3_[0-9]*") + +# Download Backup +- name: Download backup in check mode + mso_backup: + <<: *mso_info + backup: ansibleBackup2 + destination: ./ + state: download + register: download_ansibleBackup2_cm + check_mode: yes + +- name: Download backup + mso_backup: + <<: *mso_info + backup: ansibleBackup2 + destination: ./ + state: download + register: download_ansibleBackup2 + +- name: Download non existent backup + mso_backup: + <<: *mso_info + backup: non_existent_backup + destination: ./ + state: download + ignore_errors: yes + register: download_non_existent_backup + +- name: Download backup ansibleBackup3 + mso_backup: + <<: *mso_info + backup: ansibleBackup3 + destination: ./ + state: download + ignore_errors: yes + register: download_ansibleBackup3 + +- name: Verify download of backup + assert: + that: + - download_ansibleBackup2_cm is changed + - download_ansibleBackup2 is changed + - download_non_existent_backup.msg is match ("Backup 'non_existent_backup' does not exist") + - download_ansibleBackup3.msg is match ("Multiple backups with same name found. Existing backups with similar names{{':'}} ansibleBackup3_[0-9]*, ansibleBackup3_[0-9]*") + +- name: Remove backup ansibleBackup2 for testing purpose + mso_backup: + <<: *mso_info + backup: ansibleBackup2 + state: absent + +# Find Backup +- name: Find backup + find: + paths: ./ + patterns: "*.tar.gz" + register: backup_match + +# Upload Backup +- name: Upload a backup from local location in check mode + mso_backup: + <<: *mso_info + backup: "{{ backup_match.files[0].path }}" + state: upload + register: upload_backup_cm + check_mode: yes + +- name: Upload a backup from local location + mso_backup: + <<: *mso_info + backup: "{{ backup_match.files[0].path }}" + state: upload + register: upload_backup + +- name: Upload a non existent backup from local location + mso_backup: + <<: *mso_info + backup: non_existent_backup + state: upload + register: upload_non_existent_backup + ignore_errors: yes + +- name: Verify upload of backup + assert: + that: + - upload_backup is changed + - upload_backup_cm is changed + - upload_non_existent_backup.msg is match ("Backup file 'non_existent_backup' not found!") + +# Restore Backup +- name: Restore non existent backup + mso_backup: + <<: *mso_info + backup: non_existent_backup + state: restore + ignore_errors: yes + when: version.current.version is version('2.2.4e', '!=') + register: restore_non_existent_backup + +- name: Restore backup ansibleBackup3 + mso_backup: + <<: *mso_info + backup: ansibleBackup3 + state: restore + ignore_errors: yes + when: version.current.version is version('2.2.4e', '!=') + register: restore_ansibleBackup3 + +- name: Verify restore of backup + assert: + that: + - restore_non_existent_backup.msg is match ("Backup 'non_existent_backup' does not exist") + - restore_ansibleBackup3.msg is match ("Multiple backups with same name found. Existing backups with similar names{{':'}} ansibleBackup3_[0-9]*, ansibleBackup3_[0-9]*") + when: version.current.version is version('2.2.4e', '!=') + +- name: Add a new tenant + mso_tenant: + <<: *mso_info + tenant: Tenant1 + display_name: Test_Tenant + state: present + when: version.current.version is version('2.2.4e', '!=') + +- name: Restore backup in check mode + mso_backup: + <<: *mso_info + backup: ansibleBackup1 + state: restore + check_mode: yes + when: version.current.version is version('2.2.4e', '!=') + register: restore_cm + +- name: Verify retore in check mode + assert: + that: + - restore_cm is changed + when: version.current.version is version('2.2.4e', '!=') + +- name: Restore backup + mso_backup: + <<: *mso_info + backup: ansibleBackup1 + state: restore + when: version.current.version is version('2.2.4e', '!=') + +- name: Pause for 6 minutes after restore + pause: + minutes: 6 + +- name: Query Tenant1 + mso_tenant: + <<: *mso_info + tenant: Tenant1 + state: query + when: version.current.version is version('2.2.4e', '!=') + register: query_non_existent_tenant + +- name: Verify non existent Tenant + assert: + that: + - query_non_existent_tenant is not changed + - query_non_existent_tenant.current == {} + when: version.current.version is version('2.2.4e', '!=') + +# Query a Backup +- name: Query ansibleBackup3 + mso_backup: + <<: *mso_info + backup: ansibleBackup3 + state: query + register: query_ansibleBackup3 + +- name: Verify query_ansibleBackup3 + assert: + that: + - query_ansibleBackup3 is not changed + - query_ansibleBackup3.current | length == 2 + +# Query All +- name: Query All + mso_backup: + <<: *mso_info + state: query + register: query_all_backups + +- name: Verify query_all_backups + assert: + that: + - query_all_backups is not changed + - query_all_backups.current | selectattr("name", "match", "^ansibleBackup.*") | list | length == 7 + +# Remove Backup +- name: Remove ansibleBackup1 in check mode + mso_backup: + <<: *mso_info + backup: ansibleBackup1 + state: absent + check_mode: yes + register: cm_remove_ansibleBackup1 + +- name: Verify cm_remove_ansibleBackup1 + assert: + that: + - cm_remove_ansibleBackup1 is changed + +- name: Remove ansibleBackup1 in normal mode + mso_backup: + <<: *mso_info + backup: ansibleBackup1 + state: absent + register: nm_remove_ansibleBackup1 + +- name: Verify nm_remove_ansibleBackup1 + assert: + that: + - nm_remove_ansibleBackup1 is changed + +- name: Remove ansibleBackup1 in normal mode again + mso_backup: + <<: *mso_info + backup: ansibleBackup1 + state: absent + register: nm_remove_ansibleBackup1_2 + +- name: Verify nm_remove_ansibleBackup1_2 + assert: + that: + - nm_remove_ansibleBackup1_2 is not changed + +- name: Remove ansibleBackup3 in normal mode + mso_backup: + <<: *mso_info + backup: ansibleBackup3 + state: absent + ignore_errors: yes + register: nm_remove_ansibleBackup3 + +- name: Verify nm_remove_ansibleBackup3 + assert: + that: + - nm_remove_ansibleBackup3.msg is match ("Multiple backups with same name found. Existing backups with similar names{{':'}} ansibleBackup3_[0-9]*, ansibleBackup3_[0-9]*") + +- name: Query non_existent_backup + mso_backup: + <<: *mso_info + backup: nonExistentBackup + state: query + register: query_non_existent_backup + +- name: Verify query_non_existent_backup + assert: + that: + - query_non_existent_backup is not changed \ No newline at end of file diff --git a/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_dhcp_option_policy/aliases b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_dhcp_option_policy/aliases new file mode 100644 index 00000000..5042c9c0 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_dhcp_option_policy/aliases @@ -0,0 +1,2 @@ +# No ACI MultiSite infrastructure, so not enabled +# unsupported diff --git a/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_dhcp_option_policy/tasks/main.yaml b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_dhcp_option_policy/tasks/main.yaml new file mode 100644 index 00000000..b9871436 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_dhcp_option_policy/tasks/main.yaml @@ -0,0 +1,227 @@ +# Test code for the MSO modules +# Copyright: (c) 2020, Lionel Hercot (@lhercot) +# Copyright: (c) 2020, Jorge Gomez (@jgomezve) (based on mso_dhcp_relay_policy 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: + 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: + 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(true) }}' + output_level: '{{ mso_output_level | default("info") }}' + +- name: Ensure tenant ansible_test exist + mso_tenant: + <<: *mso_info + tenant: ansible_test + users: + - '{{ mso_username }}' + state: present + register: ansible_tenant + +- name: Remove DHCP Option Policies + mso_dhcp_option_policy: + <<: *mso_info + dhcp_option_policy: '{{ item }}' + state: absent + loop: + - ansible_dhcp_option_1 + - ansible_dhcp_option_2 + +# ADD DHCP Policy +- name: Add a new DHCP Option Policy 1 (check mode) + mso_dhcp_option_policy: &create_dhcp + <<: *mso_info + dhcp_option_policy: ansible_dhcp_option_1 + description: "My Test DHCP Policy 1" + tenant: ansible_test + state: present + check_mode: yes + register: dhcp_pol1_cm + +- name: Add a new DHCP Option Policy 1 (normal mode) + mso_dhcp_option_policy: + <<: *create_dhcp + register: dhcp_pol1_nm + +- name: Verify dhcp_pol1_cm and dhcp_pol1_nm + assert: + that: + - dhcp_pol1_cm is changed + - dhcp_pol1_nm is changed + - dhcp_pol1_cm.current.name == dhcp_pol1_nm.current.name == 'ansible_dhcp_option_1' + - dhcp_pol1_cm.current.desc == dhcp_pol1_nm.current.desc == 'My Test DHCP Policy 1' + - dhcp_pol1_cm.current.policySubtype == dhcp_pol1_nm.current.policySubtype == 'option' + - dhcp_pol1_cm.current.policyType == dhcp_pol1_nm.current.policyType == 'dhcp' + - 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: + <<: *create_dhcp + check_mode: yes + register: dhcp_pol1_again_cm + +- name: Add a new DHCP Option Policy 1 again (normal mode) + mso_dhcp_option_policy: + <<: *create_dhcp + register: dhcp_pol1_again_nm + +- name: Verify dhcp_pol1_again_cm and dhcp_pol1_again_nm + assert: + that: + - dhcp_pol1_again_cm is not changed + - dhcp_pol1_again_nm is not changed + - dhcp_pol1_again_cm.current.name == dhcp_pol1_again_nm.current.name == 'ansible_dhcp_option_1' + - dhcp_pol1_again_cm.current.desc == dhcp_pol1_again_nm.current.desc == 'My Test DHCP Policy 1' + - dhcp_pol1_again_cm.current.policySubtype == dhcp_pol1_again_nm.current.policySubtype == 'option' + - dhcp_pol1_again_cm.current.policyType == dhcp_pol1_again_nm.current.policyType == 'dhcp' + - 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: + <<: *create_dhcp + dhcp_option_policy: ansible_dhcp_option_2 + +- name: Change DHCP Option Policy 1 description (check mode) + mso_dhcp_option_policy: + <<: *create_dhcp + description: "My Changed Test DHCP Policy 1" + check_mode: yes + register: change_dhcp_pol1_cm + +- name: Change DHCP Option Policy 1 description (normal mode) + 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: + that: + - change_dhcp_pol1_cm is changed + - change_dhcp_pol1_nm is changed + - change_dhcp_pol1_cm.current.name == change_dhcp_pol1_nm.current.name == 'ansible_dhcp_option_1' + - change_dhcp_pol1_cm.current.desc == change_dhcp_pol1_nm.current.desc == 'My Changed Test DHCP Policy 1' + - change_dhcp_pol1_cm.current.policySubtype == change_dhcp_pol1_nm.current.policySubtype == 'option' + - change_dhcp_pol1_cm.current.policyType == change_dhcp_pol1_nm.current.policyType == 'dhcp' + - change_dhcp_pol1_cm.current.tenantId == change_dhcp_pol1_nm.current.tenantId == ansible_tenant.current.id + +# QUERY A DHCP OPTION POLICY +- name: Query DHCP Option Policy 1 (check mode) + mso_dhcp_option_policy: &query_dhcp + <<: *mso_info + dhcp_option_policy: ansible_dhcp_option_1 + state: query + check_mode: yes + register: dhcp_pol1_query_cm + +- name: Query DHCP Option Policy 1 (normal mode) + mso_dhcp_option_policy: + <<: *query_dhcp + register: dhcp_pol1_query_nm + +- name: Verify dhcp_pol1_query + assert: + that: + - dhcp_pol1_query_cm is not changed + - dhcp_pol1_query_nm is not changed + - dhcp_pol1_query_cm.current.name == dhcp_pol1_query_nm.current.name == 'ansible_dhcp_option_1' + - dhcp_pol1_query_cm.current.desc == dhcp_pol1_query_nm.current.desc == 'My Changed Test DHCP Policy 1' + - dhcp_pol1_query_cm.current.policySubtype == dhcp_pol1_query_nm.current.policySubtype == 'option' + - dhcp_pol1_query_cm.current.policyType == dhcp_pol1_query_nm.current.policyType == 'dhcp' + +# QUERY A NON-EXISTING DHCP OPTION POLICY +- name: Query non-existing DHCP Option Policy (normal mode) + 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: + 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: + <<: *mso_info + state: query + register: dhcp_policies_query + +- name: Verify dhcp_policies_query + 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 + <<: *mso_info + dhcp_option_policy: ansible_dhcp_option_1 + state: absent + check_mode: yes + register: dhcp_pol1_removed_cm + +- name: Remove DHCP Option Policy 1 (normal mode) + mso_dhcp_option_policy: + <<: *remove_dhcp + register: dhcp_pol1_removed_nm + +- name: Verify dhcp_policies_removed + assert: + that: + - dhcp_pol1_removed_cm is changed + - dhcp_pol1_removed_nm is changed + - dhcp_pol1_removed_cm.current == dhcp_pol1_removed_nm.current == {} + +# REMOVE DHCP POLICY AGAIN +- name: Remove DHCP Option Policy 1 again (check mode) + mso_dhcp_option_policy: + <<: *remove_dhcp + check_mode: yes + register: dhcp_pol1_removed_again_cm + +- name: Remove DHCP Option Policy 1 again (normal mode) + mso_dhcp_option_policy: + <<: *remove_dhcp + register: dhcp_pol1_removed_again_nm + +- name: Verify dhcp_pol1_removed_again + assert: + that: + - dhcp_pol1_removed_again_cm is not changed + - dhcp_pol1_removed_again_nm is not changed + - dhcp_pol1_removed_again_cm.current == dhcp_pol1_removed_again_nm.current == {} + - dhcp_pol1_removed_again_cm.previous == dhcp_pol1_removed_again_nm.previous == {} + + +# USE A NON-EXISTING TENANT +- name: Non Existing Tenant for DHCP Option Policy 3 (normal mode) + mso_dhcp_option_policy: + <<: *mso_info + dhcp_option_policy: ansible_dhcp_option_3 + description: "My Test DHCP Policy 3" + tenant: non_existing + state: present + ignore_errors: yes + register: nm_non_existing_tenant + +- name: Verify nm_non_existing_tenant + assert: + that: + - nm_non_existing_tenant is not changed + - nm_non_existing_tenant.msg == "Tenant 'non_existing' is not valid tenant name." \ No newline at end of file diff --git a/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_dhcp_option_policy_option/aliases b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_dhcp_option_policy_option/aliases new file mode 100644 index 00000000..5042c9c0 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_dhcp_option_policy_option/aliases @@ -0,0 +1,2 @@ +# No ACI MultiSite infrastructure, so not enabled +# unsupported diff --git a/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_dhcp_option_policy_option/tasks/main.yaml b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_dhcp_option_policy_option/tasks/main.yaml new file mode 100644 index 00000000..509f7fa6 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_dhcp_option_policy_option/tasks/main.yaml @@ -0,0 +1,393 @@ +# Test code for the MSO modules +# Copyright: (c) 2020, Lionel Hercot (@lhercot) +# Copyright: (c) 2020, Jorge Gomez (@jgomezve) (based on mso_dhcp_relay_policy 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: + 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: + 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(true) }}' + output_level: '{{ mso_output_level | default("info") }}' + +- name: Remove options from DHCP Option Policy + mso_dhcp_option_policy_option: + <<: *mso_info + dhcp_option_policy: ansible_dhcp_option_1 + name: "{{ item }}" + state: absent + loop: + - ansible_test + - ansible_test_2 + ignore_errors: yes + +- name: Stop consuming DHCP Policy + mso_schema_template_bd: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + bd: CLIENT_BD + vrf: + name: VRF_1 + state: present + ignore_errors: yes + +- name: Remove DHCP Relay Policy 1 + mso_dhcp_relay_policy: + <<: *mso_info + dhcp_relay_policy: '{{ item }}' + state: absent + loop: + - ansible_dhcp_relay_1 + - ansible_dhcp_relay_2 + +- name: Remove DHCP Option Policies + mso_dhcp_option_policy: + <<: *mso_info + dhcp_option_policy: '{{ item }}' + state: absent + ignore_errors: yes + loop: + - ansible_dhcp_option_1 + - ansible_dhcp_option_2 + +- name: Undeploy sites in schema 1 template 1 + mso_schema_template_deploy: + <<: *mso_info + template: Template 1 + schema: '{{ mso_schema | default("ansible_test") }}' + site: '{{ item }}' + state: undeploy + ignore_errors: yes + loop: + - '{{ mso_site | default("ansible_test") }}' + - '{{ mso_site | default("ansible_test") }}_2' + - 'aws_{{ mso_site | default("ansible_test") }}' + - 'azure_{{ mso_site | default("ansible_test") }}' + +- name: Undeploy sites in schema 1 template 2 + mso_schema_template_deploy: + <<: *mso_info + template: Template 2 + schema: '{{ mso_schema | default("ansible_test") }}' + site: '{{ item }}' + state: undeploy + ignore_errors: yes + loop: + - '{{ mso_site | default("ansible_test") }}' + - '{{ mso_site | default("ansible_test") }}_2' + - 'aws_{{ mso_site | default("ansible_test") }}' + - 'azure_{{ mso_site | default("ansible_test") }}' + +- name: Remove schemas + mso_schema: + <<: *mso_info + schema: '{{ item }}' + state: absent + loop: + - '{{ mso_schema | default("ansible_test") }}_2' + - '{{ mso_schema | default("ansible_test") }}' + +- name: Ensure tenant ansible_test exist + mso_tenant: + <<: *mso_info + tenant: ansible_test + users: + - '{{ mso_username }}' + state: present + register: tenant_ansible + +- name: Ensure schema 1 with Template 1 exist + mso_schema_template: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + tenant: ansible_test + template: Template 1 + state: present + +- name: Add a new VRF + mso_schema_template_vrf: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + vrf: VRF_1 + state: present + +- name: Add BD + mso_schema_template_bd: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + bd: CLIENT_BD + vrf: + name: VRF_1 + state: present + +# ADD DHCP RELAY AND OPTION POLICY +- name: Add a new DHCP Option Policy 1 (Normal mode) + mso_dhcp_option_policy: + <<: *mso_info + dhcp_option_policy: ansible_dhcp_option_1 + description: "My Test DHCP Policy 1" + tenant: ansible_test + state: present + +- name: Add a new DHCP Relay Policy 1 (Normal mode) + mso_dhcp_relay_policy: + <<: *mso_info + dhcp_relay_policy: ansible_dhcp_relay_1 + description: "My Test DHCP Policy 1" + tenant: ansible_test + state: present + +# ADD OPTION TO DHCP OPTION POLICY +- name: Add Option to DHCP Option Policy (check mode) + mso_dhcp_option_policy_option: &create_option + <<: *mso_info + dhcp_option_policy: ansible_dhcp_option_1 + name: ansible_test + id: 1 + data: DHCP Data + state: present + check_mode: yes + register: dhcp_pol1_opt1_cm + +- name: Add Option to DHCP Option Policy (normal mode) + mso_dhcp_option_policy_option: + <<: *create_option + register: dhcp_pol1_opt1_nm + +- name: Verify dhcp_pol1_opt1 + assert: + that: + - dhcp_pol1_opt1_cm is changed + - dhcp_pol1_opt1_nm is changed + - dhcp_pol1_opt1_cm.current.name == dhcp_pol1_opt1_nm.current.name == 'ansible_test' + - dhcp_pol1_opt1_cm.current.id == dhcp_pol1_opt1_nm.current.id == '1' + - 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: + <<: *create_option + check_mode: yes + register: dhcp_pol1_opt1_again_cm + +- name: Add Option to DHCP Option Policy again (normal mode) + mso_dhcp_option_policy_option: + <<: *create_option + register: dhcp_pol1_opt1_again_nm + +- name: Verify dhcp_pol1_opt1_again + assert: + that: + - dhcp_pol1_opt1_again_cm is not changed + - dhcp_pol1_opt1_again_nm is not changed + - dhcp_pol1_opt1_again_cm.current.name == dhcp_pol1_opt1_again_nm.current.name == 'ansible_test' + - dhcp_pol1_opt1_again_cm.current.id == dhcp_pol1_opt1_again_nm.current.id == '1' + - 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: + <<: *create_option + data: Changed DHCP Data + check_mode: yes + register: dhcp_pol1_opt1_change_cm + +- name: Change Option IP to DHCP Option Policy (normal mode) + mso_dhcp_option_policy_option: + <<: *create_option + data: Changed DHCP Data + register: dhcp_pol1_opt1_change_nm + +- name: Verify dhcp_pol1_opt1_change + assert: + that: + - dhcp_pol1_opt1_change_cm is changed + - dhcp_pol1_opt1_change_nm is changed + - dhcp_pol1_opt1_change_cm.current.name == dhcp_pol1_opt1_change_nm.current.name == 'ansible_test' + - dhcp_pol1_opt1_change_cm.current.id == dhcp_pol1_opt1_change_nm.current.id == '1' + - 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: + <<: *create_option + name: ansible_test_2 + check_mode: yes + register: dhcp_pol1_opt2_cm + +- name: Add 2nd Option to DHCP Option Policy (normal mode) + mso_dhcp_option_policy_option: + <<: *create_option + name: ansible_test_2 + register: dhcp_pol1_opt2_nm + +- name: Verify dhcp_pol1_opt2 + assert: + that: + - dhcp_pol1_opt2_cm is changed + - dhcp_pol1_opt2_nm is changed + - dhcp_pol1_opt2_cm.current.name == dhcp_pol1_opt2_nm.current.name == 'ansible_test_2' + - dhcp_pol1_opt2_cm.current.id == dhcp_pol1_opt2_nm.current.id == '1' + - dhcp_pol1_opt2_cm.current.data == dhcp_pol1_opt2_nm.current.data == 'DHCP Data' + +# QUERY OPTION FROM DHCP OPTION POLICY +- name: Query Option from DHCP Option Policy (check mode) + mso_dhcp_option_policy_option: &query_option + <<: *mso_info + dhcp_option_policy: ansible_dhcp_option_1 + name: ansible_test + state: query + register: dhcp_pol1_opt1_query_cm + +- name: Query Option from DHCP Option Policy (normal mode) + mso_dhcp_option_policy_option: + <<: *query_option + register: dhcp_pol1_opt1_query_nm + +- name: Query non_existing Option from DHCP Option Policy + mso_dhcp_option_policy_option: + <<: *query_option + name: non_existing + state: query + register: dhcp_pol1_opt1_query_non_existing + +- name: Query all Options from a DHCP Option Policy + 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: + that: + - dhcp_pol1_opt1_query_cm is not changed + - dhcp_pol1_opt1_query_nm is not changed + - dhcp_pol1_opt1_query_non_existing is not changed + - dhcp_pol1_query_all is not changed + - dhcp_pol1_opt1_query_cm.current.name == dhcp_pol1_opt1_query_nm.current.name == 'ansible_test' + - dhcp_pol1_opt1_query_cm.current.id == dhcp_pol1_opt1_query_nm.current.id == '1' + - dhcp_pol1_opt1_query_cm.current.data == dhcp_pol1_opt1_query_nm.current.data == 'Changed DHCP Data' + - dhcp_pol1_opt1_query_non_existing.current == {} + - dhcp_pol1_query_all.current | length == 2 + +# REMOVE OPTION FROM DHCP OPTION POLICY +- name: Remove Option from DHCP Option Policy (check mode) + mso_dhcp_option_policy_option: &delete_option + <<: *mso_info + dhcp_option_policy: ansible_dhcp_option_1 + name: ansible_test + state: absent + check_mode: yes + register: dhcp_pol1_opt1_del_cm + +- name: Remove Option from DHCP Option Policy (normal mode) + mso_dhcp_option_policy_option: + <<: *delete_option + register: dhcp_pol1_opt1_del_nm + +- name: Verify dhcp_pol1_opt1_del + 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: + <<: *delete_option + check_mode: yes + register: dhcp_pol1_opt1_del_again_cm + +- name: Remove Option from DHCP Option Policy again (normal mode) + mso_dhcp_option_policy_option: + <<: *delete_option + register: dhcp_pol1_opt1_del_again_nm + +- name: Verify dhcp_pol1_opt1_again_del + 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: + <<: *delete_option + name: non_existing + register: dhcp_pol1_opt1_del_nm_non_existing + +- name: Verify dhcp_pol1_opt1_del_nm_non_existing + 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: + <<: *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: + <<: *mso_info + dhcp_option_policy: ansible_dhcp_option_1 + state: query + register: dhcp_option_policy_version + +- name: Consume DHCP Policy + mso_schema_template_bd: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + bd: CLIENT_BD + vrf: + name: VRF_1 + dhcp_policy: + name: "{{ dhcp_relay_policy_version.current.name }}" + version: "{{ dhcp_relay_policy_version.current.version | int }}" + dhcp_option_policy: + name: "{{ dhcp_option_policy_version.current.name }}" + version: "{{ dhcp_option_policy_version.current.version | int }}" + state: present + register: bd_dhcp_policy + +- name: Stop consuming DHCP Policy + mso_schema_template_bd: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + bd: CLIENT_BD + vrf: + name: VRF_1 + state: present + register: bd_dhcp_policy + +# QUERY OPTION FROM non_existing DHCP OPTION POLICY +- name: Query Option from DHCP Option Policy (check mode) + mso_dhcp_option_policy_option: + <<: *mso_info + dhcp_option_policy: non_existing + state: query + ignore_errors: yes + register: dhcp_non_existing + +- name: Verify dhcp_non_existing + assert: + that: + - dhcp_non_existing is not changed + - dhcp_non_existing.msg == "DHCP Option Policy 'non_existing' is not a valid DHCP Option Policy name." \ No newline at end of file diff --git a/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_dhcp_relay_policy/aliases b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_dhcp_relay_policy/aliases new file mode 100644 index 00000000..5042c9c0 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_dhcp_relay_policy/aliases @@ -0,0 +1,2 @@ +# No ACI MultiSite infrastructure, so not enabled +# unsupported diff --git a/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_dhcp_relay_policy/tasks/main.yaml b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_dhcp_relay_policy/tasks/main.yaml new file mode 100644 index 00000000..90f49f74 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_dhcp_relay_policy/tasks/main.yaml @@ -0,0 +1,226 @@ +# Test code for the MSO modules +# Copyright: (c) 2020, Jorge Gomez (@jgomezve) + +# 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.' + 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: + 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(true) }}' + output_level: '{{ mso_output_level | default("info") }}' + +- name: Ensure tenant ansible_test exist + mso_tenant: + <<: *mso_info + tenant: ansible_test + users: + - '{{ mso_username }}' + state: present + register: ansible_tenant + +- name: Remove DHCP Relay Policy 1 + mso_dhcp_relay_policy: + <<: *mso_info + dhcp_relay_policy: '{{ item }}' + state: absent + loop: + - ansible_dhcp_relay_1 + - ansible_dhcp_relay_2 + +# ADD DHCP Policy +- name: Add a new DHCP Relay Policy 1 (check mode) + mso_dhcp_relay_policy: &create_dhcp + <<: *mso_info + dhcp_relay_policy: ansible_dhcp_relay_1 + description: "My Test DHCP Policy 1" + tenant: ansible_test + state: present + check_mode: yes + register: dhcp_pol1_cm + +- name: Add a new DHCP Relay Policy 1 (normal mode) + mso_dhcp_relay_policy: + <<: *create_dhcp + register: dhcp_pol1_nm + +- name: Verify dhcp_pol1_cm and dhcp_pol1_nm + assert: + that: + - dhcp_pol1_cm is changed + - dhcp_pol1_nm is changed + - dhcp_pol1_cm.current.name == dhcp_pol1_nm.current.name == 'ansible_dhcp_relay_1' + - dhcp_pol1_cm.current.desc == dhcp_pol1_nm.current.desc == 'My Test DHCP Policy 1' + - dhcp_pol1_cm.current.policySubtype == dhcp_pol1_nm.current.policySubtype == 'relay' + - dhcp_pol1_cm.current.policyType == dhcp_pol1_nm.current.policyType == 'dhcp' + - 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: + <<: *create_dhcp + check_mode: yes + register: dhcp_pol1_again_cm + +- name: Add a new DHCP Relay Policy 1 again (normal mode) + mso_dhcp_relay_policy: + <<: *create_dhcp + register: dhcp_pol1_again_nm + +- name: Verify dhcp_pol1_again_cm and dhcp_pol1_again_nm + assert: + that: + - dhcp_pol1_again_cm is not changed + - dhcp_pol1_again_nm is not changed + - dhcp_pol1_again_cm.current.name == dhcp_pol1_again_nm.current.name == 'ansible_dhcp_relay_1' + - dhcp_pol1_again_cm.current.desc == dhcp_pol1_again_nm.current.desc == 'My Test DHCP Policy 1' + - dhcp_pol1_again_cm.current.policySubtype == dhcp_pol1_again_nm.current.policySubtype == 'relay' + - dhcp_pol1_again_cm.current.policyType == dhcp_pol1_again_nm.current.policyType == 'dhcp' + - 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: + <<: *create_dhcp + dhcp_relay_policy: ansible_dhcp_relay_2 + +- name: Change DHCP Relay Policy 1 description (check mode) + mso_dhcp_relay_policy: + <<: *create_dhcp + description: "My Changed Test DHCP Policy 1" + check_mode: yes + register: change_dhcp_pol1_cm + +- name: Change DHCP Relay Policy 1 description (normal mode) + 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: + that: + - change_dhcp_pol1_cm is changed + - change_dhcp_pol1_nm is changed + - change_dhcp_pol1_cm.current.name == change_dhcp_pol1_nm.current.name == 'ansible_dhcp_relay_1' + - change_dhcp_pol1_cm.current.desc == change_dhcp_pol1_nm.current.desc == 'My Changed Test DHCP Policy 1' + - change_dhcp_pol1_cm.current.policySubtype == change_dhcp_pol1_nm.current.policySubtype == 'relay' + - change_dhcp_pol1_cm.current.policyType == change_dhcp_pol1_nm.current.policyType == 'dhcp' + - change_dhcp_pol1_cm.current.tenantId == change_dhcp_pol1_nm.current.tenantId == ansible_tenant.current.id + +# QUERY A DHCP RELAY POLICY +- name: Query DHCP Relay Policy 1 (check mode) + mso_dhcp_relay_policy: &query_dhcp + <<: *mso_info + dhcp_relay_policy: ansible_dhcp_relay_1 + state: query + check_mode: yes + register: dhcp_pol1_query_cm + +- name: Query DHCP Relay Policy 1 (normal mode) + mso_dhcp_relay_policy: + <<: *query_dhcp + register: dhcp_pol1_query_nm + +- name: Verify dhcp_pol1_query + assert: + that: + - dhcp_pol1_query_cm is not changed + - dhcp_pol1_query_nm is not changed + - dhcp_pol1_query_cm.current.name == dhcp_pol1_query_nm.current.name == 'ansible_dhcp_relay_1' + - dhcp_pol1_query_cm.current.desc == dhcp_pol1_query_nm.current.desc == 'My Changed Test DHCP Policy 1' + - dhcp_pol1_query_cm.current.policySubtype == dhcp_pol1_query_nm.current.policySubtype == 'relay' + - dhcp_pol1_query_cm.current.policyType == dhcp_pol1_query_nm.current.policyType == 'dhcp' + +# QUERY A NON-EXISTING DHCP RELAY POLICY +- name: Query non-existing DHCP Relay Policy (normal mode) + 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: + 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: + <<: *mso_info + state: query + register: dhcp_policies_query + +- name: Verify dhcp_policies_query + 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 + <<: *mso_info + dhcp_relay_policy: ansible_dhcp_relay_1 + state: absent + check_mode: yes + register: dhcp_pol1_removed_cm + +- name: Remove DHCP Relay Policy 1 (normal mode) + mso_dhcp_relay_policy: + <<: *remove_dhcp + register: dhcp_pol1_removed_nm + +- name: Verify dhcp_policies_removed + assert: + that: + - dhcp_pol1_removed_cm is changed + - dhcp_pol1_removed_nm is changed + - dhcp_pol1_removed_cm.current == dhcp_pol1_removed_nm.current == {} + +# REMOVE DHCP POLICY AGAIN +- name: Remove DHCP Relay Policy 1 again (check mode) + mso_dhcp_relay_policy: + <<: *remove_dhcp + check_mode: yes + register: dhcp_pol1_removed_again_cm + +- name: Remove DHCP Relay Policy 1 again (normal mode) + mso_dhcp_relay_policy: + <<: *remove_dhcp + register: dhcp_pol1_removed_again_nm + +- name: Verify dhcp_pol1_removed_again + assert: + that: + - dhcp_pol1_removed_again_cm is not changed + - dhcp_pol1_removed_again_nm is not changed + - dhcp_pol1_removed_again_cm.current == dhcp_pol1_removed_again_nm.current == {} + - dhcp_pol1_removed_again_cm.previous == dhcp_pol1_removed_again_nm.previous == {} + + +# USE A NON-EXISTING TENANT +- name: Non Existing Tenant for DHCP Relay Policy 3 (normal mode) + mso_dhcp_relay_policy: + <<: *mso_info + dhcp_relay_policy: ansible_dhcp_relay_3 + description: "My Test DHCP Policy 3" + tenant: non_existing + state: present + ignore_errors: yes + register: nm_non_existing_tenant + +- name: Verify nm_non_existing_tenant + assert: + that: + - nm_non_existing_tenant is not changed + - nm_non_existing_tenant.msg == "Tenant 'non_existing' is not valid tenant name." \ No newline at end of file diff --git a/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_dhcp_relay_policy_provider/aliases b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_dhcp_relay_policy_provider/aliases new file mode 100644 index 00000000..5042c9c0 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_dhcp_relay_policy_provider/aliases @@ -0,0 +1,2 @@ +# No ACI MultiSite infrastructure, so not enabled +# unsupported diff --git a/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_dhcp_relay_policy_provider/tasks/main.yaml b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_dhcp_relay_policy_provider/tasks/main.yaml new file mode 100644 index 00000000..a6751b50 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_dhcp_relay_policy_provider/tasks/main.yaml @@ -0,0 +1,604 @@ +# Test code for the MSO modules +# Copyright: (c) 2020, Jorge Gomez (@jgomezve) + +# 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.' + 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: + 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(true) }}' + output_level: '{{ mso_output_level | default("info") }}' + +- name: Remove EXT_EPGs Providers from DHCP Relay Policy + mso_dhcp_relay_policy_provider: + <<: *mso_info + dhcp_relay_policy: ansible_dhcp_relay_1 + tenant: ansible_test + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + external_endpoint_group: "{{ item }}" + state: absent + ignore_errors: yes + loop: + - EXT_EPG_1 + - EXT_EPG_2 + +- name: Remove EXT_EPGs Providers from DHCP Relay Policy + mso_dhcp_relay_policy_provider: + <<: *mso_info + dhcp_relay_policy: ansible_dhcp_relay_1 + tenant: ansible_test + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + endpoint_group: "{{ item }}" + application_profile: "ANP_1" + state: absent + ignore_errors: yes + loop: + - EPG_1 + - EPG_2 + +- name: Stop consuming DHCP Policy + mso_schema_template_bd: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + bd: CLIENT_BD + vrf: + name: VRF_1 + state: present + ignore_errors: yes + +- name: Remove DHCP Relay Policies + mso_dhcp_relay_policy: + <<: *mso_info + dhcp_relay_policy: '{{ item }}' + state: absent + ignore_errors: yes + loop: + - ansible_dhcp_relay_1 + - ansible_dhcp_relay_2 + +- name: Undeploy sites in schema 1 template 1 + mso_schema_template_deploy: + <<: *mso_info + template: Template 1 + schema: '{{ mso_schema | default("ansible_test") }}' + site: '{{ item }}' + state: undeploy + ignore_errors: yes + loop: + - '{{ mso_site | default("ansible_test") }}' + - '{{ mso_site | default("ansible_test") }}_2' + - 'aws_{{ mso_site | default("ansible_test") }}' + - 'azure_{{ mso_site | default("ansible_test") }}' + +- name: Undeploy sites in schema 1 template 2 + mso_schema_template_deploy: + <<: *mso_info + template: Template 2 + schema: '{{ mso_schema | default("ansible_test") }}' + site: '{{ item }}' + state: undeploy + ignore_errors: yes + loop: + - '{{ mso_site | default("ansible_test") }}' + - '{{ mso_site | default("ansible_test") }}_2' + - 'aws_{{ mso_site | default("ansible_test") }}' + - 'azure_{{ mso_site | default("ansible_test") }}' + +- name: Remove schemas + mso_schema: + <<: *mso_info + schema: '{{ item }}' + state: absent + loop: + - '{{ mso_schema | default("ansible_test") }}_2' + - '{{ mso_schema | default("ansible_test") }}' + +- name: Ensure tenant ansible_test exist + mso_tenant: + <<: *mso_info + tenant: ansible_test + users: + - '{{ mso_username }}' + state: present + register: tenant_ansible + +- name: Ensure schema 1 with Template 1 exist + mso_schema_template: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + tenant: ansible_test + template: Template 1 + state: present + +# CREATE EPG PROVIDER +- name: Add a new VRF + mso_schema_template_vrf: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + vrf: VRF_1 + state: present + +- name: Add a new BD + mso_schema_template_bd: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + bd: BD_1 + vrf: + name: VRF_1 + state: present + +- name: Add 2nd BD + mso_schema_template_bd: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + bd: CLIENT_BD + vrf: + name: VRF_1 + state: present + +- name: Add a new ANP + mso_schema_template_anp: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + anp: ANP_1 + state: present + +- name: Add a new EPG + mso_schema_template_anp_epg: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + anp: ANP_1 + epg: EPG_1 + bd: + name: BD_1 + vrf: + name: VRF_1 + state: present + +- name: Add 2nd EPG + mso_schema_template_anp_epg: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + anp: ANP_1 + epg: EPG_2 + bd: + name: BD_1 + vrf: + name: VRF_1 + state: present + +- name: Add a new L3out + mso_schema_template_l3out: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + l3out: L3OUT_1 + vrf: + name: VRF_1 + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + state: present + +- name: Add a new external EPG + cisco.mso.mso_schema_template_external_epg: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + external_epg: EXT_EPG_1 + vrf: + name: VRF_1 + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + l3out: + name: L3OUT_1 + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + state: present + +- name: Add 2nd external EPG + cisco.mso.mso_schema_template_external_epg: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + external_epg: EXT_EPG_2 + vrf: + name: VRF_1 + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + l3out: + name: L3OUT_1 + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + state: present + +# ADD DHCP RELAY POLICY +- name: Add a new DHCP Relay Policy 1 (Normal mode) + mso_dhcp_relay_policy: + <<: *mso_info + dhcp_relay_policy: ansible_dhcp_relay_1 + description: "My Test DHCP Policy 1" + tenant: ansible_test + state: present + +# ADD PROVIDER TO DHCP RELAY POLICY +- name: Add Provider to DHCP Relay Policy (check mode) + mso_dhcp_relay_policy_provider: &create_provider + <<: *mso_info + dhcp_relay_policy: ansible_dhcp_relay_1 + ip: "1.1.1.1" + tenant: ansible_test + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + application_profile: ANP_1 + endpoint_group: EPG_1 + state: present + check_mode: yes + register: dhcp_pol1_prov1_cm + +- name: Add Provider to DHCP Relay Policy (normal mode) + mso_dhcp_relay_policy_provider: + <<: *create_provider + register: dhcp_pol1_prov1_nm + +- name: Verify dhcp_pol1_prov1 + assert: + that: + - dhcp_pol1_prov1_cm is changed + - dhcp_pol1_prov1_nm is changed + - dhcp_pol1_prov1_cm.current.addr == dhcp_pol1_prov1_nm.current.addr == '1.1.1.1' + - "'EPG_1' in dhcp_pol1_prov1_cm.current.epgRef" + - "'EPG_1' in dhcp_pol1_prov1_nm.current.epgRef" + - "'ANP_1' in dhcp_pol1_prov1_cm.current.epgRef" + - "'ANP_1' in dhcp_pol1_prov1_nm.current.epgRef" + - "'Template1' in dhcp_pol1_prov1_cm.current.epgRef" + - "'Template1' in dhcp_pol1_prov1_nm.current.epgRef" + - dhcp_pol1_prov1_cm.current.tenantId == tenant_ansible.current.id + - 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: + <<: *create_provider + check_mode: yes + register: dhcp_pol1_prov1_again_cm + +- name: Add Provider to DHCP Relay Policy again (normal mode) + mso_dhcp_relay_policy_provider: + <<: *create_provider + register: dhcp_pol1_prov1_again_nm + +- name: Verify dhcp_pol1_prov1_again + assert: + that: + - dhcp_pol1_prov1_again_cm is not changed + - dhcp_pol1_prov1_again_nm is not changed + - dhcp_pol1_prov1_again_cm.current.addr == dhcp_pol1_prov1_again_nm.current.addr == '1.1.1.1' + - "'EPG_1' in dhcp_pol1_prov1_again_cm.current.epgRef" + - "'EPG_1' in dhcp_pol1_prov1_again_nm.current.epgRef" + - "'ANP_1' in dhcp_pol1_prov1_again_cm.current.epgRef" + - "'ANP_1' in dhcp_pol1_prov1_again_nm.current.epgRef" + - "'Template1' in dhcp_pol1_prov1_again_cm.current.epgRef" + - "'Template1' in dhcp_pol1_prov1_again_nm.current.epgRef" + - dhcp_pol1_prov1_again_cm.current.tenantId == tenant_ansible.current.id + - 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: + <<: *create_provider + ip: "2.2.2.2" + check_mode: yes + register: dhcp_pol1_prov1_change_cm + +- name: Change Provider IP to DHCP Relay Policy (normal mode) + 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: + that: + - dhcp_pol1_prov1_change_cm is changed + - dhcp_pol1_prov1_change_nm is changed + - dhcp_pol1_prov1_change_cm.current.addr == dhcp_pol1_prov1_change_nm.current.addr == '2.2.2.2' + - "'EPG_1' in dhcp_pol1_prov1_change_cm.current.epgRef" + - "'EPG_1' in dhcp_pol1_prov1_change_nm.current.epgRef" + - "'ANP_1' in dhcp_pol1_prov1_change_cm.current.epgRef" + - "'ANP_1' in dhcp_pol1_prov1_change_nm.current.epgRef" + - "'Template1' in dhcp_pol1_prov1_change_cm.current.epgRef" + - "'Template1' in dhcp_pol1_prov1_change_nm.current.epgRef" + - dhcp_pol1_prov1_change_cm.current.tenantId == tenant_ansible.current.id + - 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: + <<: *create_provider + ip: "2.2.2.2" + endpoint_group: EPG_2 + check_mode: yes + register: dhcp_pol1_prov2_cm + +- name: Add 2nd Provider (EPG_2) to DHCP Relay Policy (normal mode) + 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 + <<: *create_provider + ip: "2.2.2.2" + external_endpoint_group: EXT_EPG_1 + application_profile: null + endpoint_group: null + check_mode: yes + register: dhcp_pol1_prov3_cm + +- name: Add 3rd Provider (EXT_EPG_1) to DHCP Relay Policy (normal mode) + 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: + <<: *create_provider_external_epg + external_endpoint_group: EXT_EPG_2 + check_mode: yes + register: dhcp_pol1_prov4_cm + +- name: Add 4th Provider (EXT_EPG_2) to DHCP Relay Policy (normal mode) + 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: + that: + - dhcp_pol1_prov2_cm is changed + - dhcp_pol1_prov2_nm is changed + - dhcp_pol1_prov3_cm is changed + - dhcp_pol1_prov3_nm is changed + - dhcp_pol1_prov4_cm is changed + - dhcp_pol1_prov4_nm is changed + - dhcp_pol1_prov2_cm.current.addr == dhcp_pol1_prov2_nm.current.addr == '2.2.2.2' + - dhcp_pol1_prov3_cm.current.addr == dhcp_pol1_prov3_nm.current.addr == '2.2.2.2' + - dhcp_pol1_prov4_cm.current.addr == dhcp_pol1_prov4_nm.current.addr == '2.2.2.2' + - "'EPG_2' in dhcp_pol1_prov2_cm.current.epgRef" + - "'EPG_2' in dhcp_pol1_prov2_nm.current.epgRef" + - "'ANP_1' in dhcp_pol1_prov2_cm.current.epgRef" + - "'ANP_1' in dhcp_pol1_prov2_nm.current.epgRef" + - "'Template1' in dhcp_pol1_prov2_cm.current.epgRef" + - "'Template1' in dhcp_pol1_prov2_nm.current.epgRef" + - "'EXT_EPG_1' in dhcp_pol1_prov3_cm.current.externalEpgRef" + - "'EXT_EPG_1' in dhcp_pol1_prov3_nm.current.externalEpgRef" + - "'EXT_EPG_2' in dhcp_pol1_prov4_cm.current.externalEpgRef" + - "'EXT_EPG_2' in dhcp_pol1_prov4_nm.current.externalEpgRef" + - dhcp_pol1_prov3_cm.current.tenantId == tenant_ansible.current.id + - dhcp_pol1_prov3_nm.current.tenantId == tenant_ansible.current.id + - dhcp_pol1_prov4_cm.current.tenantId == tenant_ansible.current.id + - dhcp_pol1_prov4_nm.current.tenantId == tenant_ansible.current.id + +# ADD DHCP RELAY PROVIDER WITH WRONG Attributes +- name: Add Provider to DHCP Relay Policy - wrong tenant (Normal mode) + mso_dhcp_relay_policy_provider: + <<: *mso_info + dhcp_relay_policy: ansible_dhcp_relay_1 + ip: "2.2.2.2" + tenant: ansible_test_wrong + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + application_profile: ANP_1 + endpoint_group: EPG_1 + state: present + ignore_errors: yes + register: dhcp_pol1_prov2_nm_ten_wrong + +- name: Add Provider to DHCP Relay Policy - wrong Schema (Normal mode) + mso_dhcp_relay_policy_provider: + <<: *mso_info + dhcp_relay_policy: ansible_dhcp_relay_1 + ip: "2.2.2.2" + tenant: ansible_test + schema: schema_wrong + template: Template 1 + application_profile: ANP_1 + endpoint_group: EPG_1 + state: present + ignore_errors: yes + 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: + 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." + - dhcp_pol1_prov2_nm_sch_wrong is not changed + - dhcp_pol1_prov2_nm_sch_wrong.msg == "Schema 'schema_wrong' is not a valid schema name." + # MSO API allows to create provider in non-existing/wrong templates/epgs/ext_epgs + +# QUERY PROVIDER FROM DHCP RELAY POLICY +- name: Query Provider from DHCP Relay Policy (check mode) + mso_dhcp_relay_policy_provider: &query_provider + <<: *mso_info + dhcp_relay_policy: ansible_dhcp_relay_1 + tenant: ansible_test + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + application_profile: ANP_1 + endpoint_group: EPG_1 + state: query + register: dhcp_pol1_prov1_query_cm + +- name: Query Provider from DHCP Relay Policy (normal mode) + 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: + <<: *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: + <<: *mso_info + dhcp_relay_policy: ansible_dhcp_relay_1 + state: query + register: dhcp_pol1_query_all + +- name: Verify all query variables + assert: + that: + - dhcp_pol1_prov1_query_cm is not changed + - dhcp_pol1_prov1_query_nm is not changed + - dhcp_pol1_prov1_query_non_existing is not changed + - dhcp_pol1_query_all is not changed + - dhcp_pol1_prov1_query_cm.current.addr == dhcp_pol1_prov1_query_nm.current.addr == '2.2.2.2' + - "'EPG_1' in dhcp_pol1_prov1_query_cm.current.epgRef" + - "'EPG_1' in dhcp_pol1_prov1_query_nm.current.epgRef" + - "'ANP_1' in dhcp_pol1_prov1_query_cm.current.epgRef" + - "'ANP_1' in dhcp_pol1_prov1_query_nm.current.epgRef" + - "'Template1' in dhcp_pol1_prov1_query_cm.current.epgRef" + - "'Template1' in dhcp_pol1_prov1_query_nm.current.epgRef" + - dhcp_pol1_prov1_query_non_existing.current == {} + - dhcp_pol1_query_all.current | length == 4 + +# REMOVE PROVIDER FROM DHCP RELAY POLICY +- name: Remove Provider (EXT_EPG) from DHCP Relay Policy (check mode) + mso_dhcp_relay_policy_provider: &delete_provider + <<: *mso_info + dhcp_relay_policy: ansible_dhcp_relay_1 + tenant: ansible_test + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + external_endpoint_group: EXT_EPG_1 + state: absent + check_mode: yes + register: dhcp_pol1_prov1_del_cm + +- name: Remove Provider (EXT_EPG) from DHCP Relay Policy (normal mode) + mso_dhcp_relay_policy_provider: + <<: *delete_provider + register: dhcp_pol1_prov1_del_nm + +- name: Verify dhcp_pol1_prov1_del + 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: + <<: *delete_provider + check_mode: yes + register: dhcp_pol1_prov1_del_again_cm + +- name: Remove Provider (EXT_EPG) from DHCP Relay Policy again (normal mode) + mso_dhcp_relay_policy_provider: + <<: *delete_provider + register: dhcp_pol1_prov1_del_again_nm + +- name: Verify dhcp_pol1_prov1_again_del + 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: + <<: *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: + <<: *mso_info + dhcp_relay_policy: ansible_dhcp_relay_1 + tenant: ansible_test + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + state: absent + ignore_errors: yes + register: dhcp_pol1_prov1_del_none + +- name: Verify dhcp_pol1_prov1_del_nm_non_existing + assert: + that: + - dhcp_pol1_prov1_del_nm_non_existing is not changed + - dhcp_pol1_prov1_del_none is not changed + - dhcp_pol1_prov1_del_nm_non_existing.current == {} + - dhcp_pol1_prov1_del_none.msg == 'Missing either endpoint_group or external_endpoint_group required attribute.' + +# CONSUME DHCP POLICIES +- name: Get DHCP Relay Policy version + 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: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + bd: CLIENT_BD + vrf: + name: VRF_1 + dhcp_policy: + name: "{{ dhcp_relay_policy_version.current.name }}" + version: "{{ dhcp_relay_policy_version.current.version | int }}" + state: present + register: bd_dhcp_policy + +- name: Stop consuming DHCP Policy + mso_schema_template_bd: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + bd: CLIENT_BD + vrf: + name: VRF_1 + state: present + register: bd_dhcp_policy + +# QUERY PROVIDER FROM non_existing DHCP RELAY POLICY +- name: Query Provider from DHCP Relay Policy (check mode) + mso_dhcp_relay_policy_provider: + <<: *mso_info + dhcp_relay_policy: non_existing + state: query + ignore_errors: yes + register: dhcp_non_existing + +- name: Verify dhcp_non_existing + 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." \ No newline at end of file diff --git a/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_label/aliases b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_label/aliases new file mode 100644 index 00000000..5042c9c0 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_label/aliases @@ -0,0 +1,2 @@ +# No ACI MultiSite infrastructure, so not enabled +# unsupported diff --git a/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_label/tasks/main.yml b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_label/tasks/main.yml new file mode 100644 index 00000000..6b28de16 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_label/tasks/main.yml @@ -0,0 +1,339 @@ +# Test code for the MSO modules +# Copyright: (c) 2018, Dag Wieers (@dagwieers) + +# 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.' + when: mso_hostname is not defined or mso_username is not defined or mso_password is not defined + + +# CLEAN ENVIRONMENT +- name: Remove label ansible_test + mso_label: &label_absent + 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(true) }}' + output_level: '{{ mso_output_level | default("info") }}' + label: ansible_test + state: absent + +- name: Remove label ansible_test2 + mso_label: + <<: *label_absent + label: ansible_test2 + register: cm_remove_label + +- name: Remove label ansible_test3 + mso_label: &domain_label_absent + 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(true) }}' + output_level: '{{ mso_output_level | default("info") }}' + state: absent + label: ansible_test3 + login_domain: Local + register: nm_remove_label3 + +- name: Remove label ansible_test4 + 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 + 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(true) }}' + output_level: '{{ mso_output_level | default("info") }}' + label: ansible_test + state: present + check_mode: yes + register: cm_add_label + +- name: Verify cm_add_label + assert: + that: + - cm_add_label is changed + - cm_add_label.previous == {} + - cm_add_label.current.displayName == 'ansible_test' + - cm_add_label.current.id is not defined + - cm_add_label.current.type == 'site' + +- name: Add label (normal mode) + mso_label: *label_present + register: nm_add_label + +- name: Verify nm_add_label + assert: + that: + - nm_add_label is changed + - nm_add_label.previous == {} + - nm_add_label.current.displayName == 'ansible_test' + - nm_add_label.current.id is defined + - nm_add_label.current.type == 'site' + +- name: Add label again (check_mode) + mso_label: *label_present + check_mode: yes + register: cm_add_label_again + +- name: Verify cm_add_label_again + assert: + that: + - cm_add_label_again is not changed + - cm_add_label_again.previous.displayName == 'ansible_test' + - cm_add_label_again.previous.type == 'site' + - cm_add_label_again.current.displayName == 'ansible_test' + - cm_add_label_again.current.id == nm_add_label.current.id + - cm_add_label_again.current.type == 'site' + +- name: Add label again (normal mode) + mso_label: *label_present + register: nm_add_label_again + +- name: Verify nm_add_label_again + assert: + that: + - nm_add_label_again is not changed + - nm_add_label_again.previous.displayName == 'ansible_test' + - nm_add_label_again.previous.type == 'site' + - nm_add_label_again.current.displayName == 'ansible_test' + - nm_add_label_again.current.id == nm_add_label.current.id + - nm_add_label_again.current.type == 'site' + + +# CHANGE LABEL +# - name: Change label (check_mode) +# mso_label: +# <<: *label_present +# label_id: '{{ nm_add_label.current.id }}' +# label: ansible_test2 +# check_mode: yes +# register: cm_change_label + +# - name: Verify cm_change_label +# assert: +# that: +# - cm_change_label is changed +# - cm_change_label.current.displayName == 'ansible_test2' +# - cm_change_label.current.id == nm_add_label.current.id +# - cm_change_label.current.type == 'site' + +# - name: Change label (normal mode) +# mso_label: +# <<: *label_present +# label_id: '{{ nm_add_label.current.id }}' +# label: ansible_test2 +# output_level: debug +# register: nm_change_label + +# - name: Verify nm_change_label +# assert: +# that: +# - nm_change_label is changed +# - cm_change_label.current.displayName == 'ansible_test2' +# - nm_change_label.current.id == nm_add_label.current.id +# - nm_change_label.current.type == 'site' + +# - name: Change label again (check_mode) +# mso_label: +# <<: *label_present +# label_id: '{{ nm_add_label.current.id }}' +# label: ansible_test2 +# check_mode: yes +# register: cm_change_label_again + +# - name: Verify cm_change_label_again +# assert: +# that: +# - cm_change_label_again is not changed +# - cm_change_label_again.current.displayName == 'ansible_test2' +# - cm_change_label_again.current.id == nm_add_label.current.id +# - cm_change_label_again.current.type == 'site' + +# - name: Change label again (normal mode) +# 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: +# that: +# - nm_change_label_again is not changed +# - nm_change_label_again.current.displayName == 'ansible_test2' +# - nm_change_label_again.current.id == nm_add_label.current.id +# - nm_change_label_again.current.type == 'site' + + +# QUERY ALL LABELS +- name: Query all labels (check_mode) + mso_label: &label_query + 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(true) }}' + output_level: '{{ mso_output_level | default("info") }}' + state: query + check_mode: yes + register: cm_query_all_labels + +- name: Query all labels (normal mode) + mso_label: *label_query + register: nm_query_all_labels + +- name: Verify query_all_labels + assert: + that: + - cm_query_all_labels is not changed + - nm_query_all_labels is not changed + # NOTE: Order of labels is not stable between calls + # FIXME: + #- cm_query_all_labels == nm_query_all_labels + + +# QUERY A LABEL +- name: Query our label + mso_label: + <<: *label_query + label: ansible_test + check_mode: yes + register: cm_query_label + +- name: Query our label + mso_label: + <<: *label_query + label: ansible_test + register: nm_query_label + +- name: Verify query_label + assert: + that: + - cm_query_label is not changed + - cm_query_label.current.displayName == 'ansible_test' + - cm_query_label.current.id == nm_add_label.current.id + - cm_query_label.current.type == 'site' + - nm_query_label is not changed + - nm_query_label.current.displayName == 'ansible_test' + - nm_query_label.current.id == nm_add_label.current.id + - nm_query_label.current.type == 'site' + - cm_query_label == nm_query_label + + +# REMOVE LABEL +- name: Remove label (check_mode) + mso_label: *label_absent + check_mode: yes + register: cm_remove_label + +- name: Verify cm_remove_label + assert: + that: + - cm_remove_label is changed + - cm_remove_label.current == {} + +- name: Remove label (normal mode) + mso_label: *label_absent + register: nm_remove_label + +- name: Verify nm_remove_label + assert: + that: + - nm_remove_label is changed + - nm_remove_label.current == {} + +- name: Remove label again (check_mode) + mso_label: *label_absent + check_mode: yes + register: cm_remove_label_again + +- name: Verify cm_remove_label_again + assert: + that: + - cm_remove_label_again is not changed + - cm_remove_label_again.current == {} + +- name: Remove label again (normal mode) + mso_label: *label_absent + register: nm_remove_label_again + +- name: Verify nm_remove_label_again + assert: + that: + - nm_remove_label_again is not changed + - nm_remove_label_again.current == {} + + +# QUERY NON-EXISTING LABEL +- name: Query non-existing label (check_mode) + mso_label: + <<: *label_query + label: ansible_test + check_mode: yes + register: cm_query_non_label + +- name: Query non-existing label (normal mode) + mso_label: + <<: *label_query + label: ansible_test + register: nm_query_non_label + +# TODO: Implement more tests +- name: Verify query_non_label + assert: + that: + - cm_query_non_label is not changed + - nm_query_non_label is not changed + - cm_query_non_label == nm_query_non_label + +# add label with login domain +- name: Add label local domain(normal mode) + mso_label: &domain_label_present + 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(true) }}' + output_level: '{{ mso_output_level | default("info") }}' + state: present + label: ansible_test3 + login_domain: Local + register: label_local_domain + +- name: Verify label_local_domain + 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: + <<: *domain_label_present + label: ansible_test4 + login_domain: '{{ mso_login_domain | default("test") }}' + register: label_test_domain + +- name: Verify label_test_domain + assert: + that: + - label_test_domain is changed + - label_test_domain.current.displayName == 'ansible_test4' + - label_test_domain.current.type == 'site' \ No newline at end of file diff --git a/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_rest/aliases b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_rest/aliases new file mode 100644 index 00000000..5042c9c0 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_rest/aliases @@ -0,0 +1,2 @@ +# No ACI MultiSite infrastructure, so not enabled +# unsupported diff --git a/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_rest/tasks/error_handling.yml b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_rest/tasks/error_handling.yml new file mode 100644 index 00000000..8ae27ce6 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_rest/tasks/error_handling.yml @@ -0,0 +1,145 @@ +# Test code for the MSO modules +# Copyright: (c) 2020, Anvitha Jain (@anvitha-jain) +# + +# 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.' + 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: + 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(true) }}' + output_level: '{{ mso_output_level | default("info") }}' + +- name: Query MSO version + mso_version: + <<: *mso_info + state: query + register: version + +# PROVOKE ERRORS +- name: Error when required parameter is missing + cisco.mso.mso_rest: + <<: *mso_info + output_level: debug + method: post + content: + displayName: mso_tenant + name: mso_tenant + description: MSO tenant + siteAssociations: [] + userAssociations: [] + _updateVersion: 0 + ignore_errors: yes + register: error_on_missing_required_param + +- name: Verify error_on_missing_required_param + assert: + that: + - error_on_missing_required_param is failed + - 'error_on_missing_required_param.msg == "missing required arguments: path"' + +- name: Error on name resolution + cisco.mso.mso_rest: + host: foo.bar.cisco.com + 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(true) }}' + output_level: '{{ mso_output_level | default("info") }}' + path: /mso/api/v1/tenants + method: post + content: + fvFoobar: + displayName: mso_tenant + name: mso_tenant + description: This is description + siteAssociations: [] + userAssociations: [] + _updateVersion: 0 + ignore_errors: yes + register: error_on_name_resolution + +- name: Verify error_on_name_resolution + assert: + that: + - error_on_name_resolution is failed + - error_on_name_resolution.msg.startswith("Authentication failed{{':'}} Request failed:") + +- name: Error on invalid path + mso_rest: + <<: *mso_info + path: /mso/api/v1/tenant + method: post + content: + displayName: mso_tenant + name: mso_tenant + description: MSO tenant + siteAssociations: [] + userAssociations: [] + _updateVersion: 0 + ignore_errors: yes + register: error_on_invalid_path + +- name: Verify error_on_invalid_path + assert: + that: + - error_on_invalid_path is failed + - error_on_invalid_path.status == 404 + when: version.current.version is version('3.0.0a', '<') + +- name: Verify error_on_invalid_path + assert: + that: + - error_on_invalid_path is failed + - error_on_invalid_path.status == 405 + when: version.current.version is version('3.0.0a', '>=') + +- name: Error when attributes are missing + cisco.mso.mso_rest: + <<: *mso_info + path: /mso/api/v1/tenants + method: post + content: + children: + ignore_errors: yes + register: error_on_missing_attributes + +- name: Verify error_on_missing_attributes + assert: + that: + - error_on_missing_attributes is failed + - error_on_missing_attributes.status == 400 + +- name: Error when input does not validate + cisco.mso.mso_rest: + <<: *mso_info + path: /mso/api/v1/tenants + method: post + content: + displayName: 0 + name: 0 + descr: This is an [invalid] description + siteAssociations: [] + userAssociations: [] + _updateVersion: 0 + ignore_errors: yes + register: error_on_input_validation + +- name: Verify error_on_input_validation + assert: + that: + - error_on_input_validation is failed + - error_on_input_validation.status == 400 diff --git a/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_rest/tasks/json_inline.yml b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_rest/tasks/json_inline.yml new file mode 100644 index 00000000..7079687c --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_rest/tasks/json_inline.yml @@ -0,0 +1,269 @@ +# Test code for the MSO modules +# Copyright: (c) 2020, Anvitha Jain (@anvitha-jain) +# + +# 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.' + 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: + 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(true) }}' + output_level: '{{ mso_output_level | default("info") }}' + +- name: Remove EXT_EPGs Providers from DHCP Relay Policy + mso_dhcp_relay_policy_provider: + <<: *mso_info + dhcp_relay_policy: ansible_dhcp_relay_1 + tenant: ansible_test + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + external_endpoint_group: "{{ item }}" + state: absent + ignore_errors: yes + loop: + - EXT_EPG_1 + - EXT_EPG_2 + +- name: Remove EXT_EPGs Providers from DHCP Relay Policy + mso_dhcp_relay_policy_provider: + <<: *mso_info + dhcp_relay_policy: ansible_dhcp_relay_1 + tenant: ansible_test + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + endpoint_group: "{{ item }}" + application_profile: "ANP_1" + state: absent + ignore_errors: yes + loop: + - EPG_1 + - EPG_2 + +- name: Stop consuming DHCP Policy + mso_schema_template_bd: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + bd: CLIENT_BD + vrf: + name: VRF_1 + state: present + ignore_errors: yes + +- name: Remove DHCP Relay Policies + mso_dhcp_relay_policy: + <<: *mso_info + dhcp_relay_policy: '{{ item }}' + state: absent + loop: + - ansible_dhcp_relay_1 + - ansible_dhcp_relay_2 + +- 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") }}' + +- name: Remove tenant ansible_test + mso_tenant: + <<: *mso_info + tenant: ansible_test + state: absent + +# QUERY SCHEMAS +- name: Query schema + mso_rest: + <<: *mso_info + path: /mso/api/v1/schemas + method: get + delegate_to: localhost + register: query_all_schema + +- name: Verify query_all_schema in json_inline + assert: + that: + - query_all_schema is not changed + +# QUERY A USER +- name: Query our user + mso_user: + <<: *mso_info + state: query + user: ansible_github_ci + check_mode: yes + register: query_user_id + +- name: Verify query_user_id + assert: + that: + - query_user_id is not changed + - query_user_id.current.username == 'ansible_github_ci' + +# ADD tenant +- name: Add tenant + mso_rest: + <<: *mso_info + path: /api/v1/tenants + method: post + content: + { + "displayName": "ansible_test", + "name": "ansible_test", + "description": "", + "siteAssociations": [], + "userAssociations": [{ + "userId": "{{ query_user_id.current.id }}" + }], + "_updateVersion": 0, + } + delegate_to: localhost + register: add_tenant + +- name: Verify add_tenant in json_inline + assert: + that: + - add_tenant is changed + - add_tenant.jsondata.displayName == 'ansible_test' + +# ADD schema +- name: Add schema + mso_rest: + <<: *mso_info + path: /mso/api/v1/schemas + method: post + content: + { + "displayName": "{{ mso_schema | default('ansible_test') }}", + "templates": [{ + "name": "Template_1", + "tenantId": "{{ add_tenant.jsondata.id }}", + "displayName": "Template_1", + "templateSubType": [], + "templateType": "stretched-template", + "anps": [], + "contracts": [], + "vrfs": [], + "bds": [], + "filters": [], + "externalEpgs": [], + "serviceGraphs": [], + "intersiteL3outs": [] + }], + "sites": [], + "_updateVersion": 0 + } + delegate_to: localhost + register: add_schema + +- name: Verify add_schema in json_inline + assert: + that: + - add_schema is changed + - add_schema.jsondata.displayName == 'ansible_test' + +# PUT schema +- name: Put schema + mso_rest: + <<: *mso_info + port: 443 + path: "/mso/api/v1/schemas/{{ add_schema.jsondata.id }}" + method: put + content: + { + "displayName": "ansible_test_2", + "templates": [{ + "name": "Template_1", + "tenantId": "{{ add_tenant.jsondata.id }}", + "displayName": "Template_1", + "templateSubType": [], + "templateType": "stretched-template", + "anps": [], + "contracts": [], + "vrfs": [], + "bds": [], + "filters": [], + "externalEpgs": [], + "serviceGraphs": [], + "intersiteL3outs": [] + }], + "sites": [], + "_updateVersion": 0 + } + delegate_to: localhost + register: put_schema + +- name: Verify put_schema in json_inline + assert: + that: + - put_schema is changed + - put_schema.jsondata.displayName == 'ansible_test_2' + +# PATCH schema +- name: Patch schema + mso_rest: + <<: *mso_info + path: "/mso/api/v1/schemas/{{ add_schema.jsondata.id }}" + method: patch + content: + [ + { + "op": "add", + "path": "/templates/Template_1/anps/-", + "value": { "name": "AP2", "displayName": "AP2", "epgs": [] }, + "_updateVersion": 0 + } + ] + delegate_to: localhost + register: patch_schema + +- name: Verify patch_schema in json_inline + assert: + that: + - patch_schema is changed + - patch_schema.jsondata.templates[0].anps[0].displayName == 'AP2' + +# DELETE the schema +- name: Delete the schema + mso_rest: + <<: *mso_info + path: "/mso/api/v1/schemas/{{ add_schema.jsondata.id }}" + method: delete + delegate_to: localhost + register: delete_schema + +- name: Verify delete_schema in json_inline + assert: + that: + - delete_schema is changed + - delete_schema.jsondata == None + +# DELETE TENANT +- name: Delete the tenant + mso_rest: + <<: *mso_info + path: "/mso/api/v1/tenants/{{ add_tenant.jsondata.id }}" + method: delete + delegate_to: localhost + register: delete_tenant + +- name: Verify delete_tenant in json_inline + assert: + that: + - delete_tenant is changed + - delete_tenant.jsondata == None \ No newline at end of file diff --git a/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_rest/tasks/json_string.yml b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_rest/tasks/json_string.yml new file mode 100644 index 00000000..86c3ea97 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_rest/tasks/json_string.yml @@ -0,0 +1,213 @@ +# Test code for the MSO modules +# Copyright: (c) 2020, Anvitha Jain (@anvitha-jain) +# + +# 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.' + 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: + 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(true) }}' + output_level: '{{ mso_output_level | default("info") }}' + +- 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") }}' + +- name: Remove tenant ansible_test + mso_tenant: + <<: *mso_info + tenant: ansible_test + state: absent + +# QUERY SCHEMAS +- name: Query schema + mso_rest: + <<: *mso_info + path: /mso/api/v1/schemas + method: get + register: query_all_schema + +- name: Verify query_all_schema + assert: + that: + - query_all_schema is not changed + +# QUERY A USER +- name: Query our user + mso_user: + <<: *mso_info + state: query + user: ansible_github_ci + check_mode: yes + register: query_user_id + +- name: Verify query_user_id + assert: + that: + - query_user_id is not changed + - query_user_id.current.username == 'ansible_github_ci' + +# ADD tenant +- name: Add tenant + mso_rest: + <<: *mso_info + path: /api/v1/tenants + method: post + content: + { + "displayName": "ansible_test", + "name": "ansible_test", + "description": "", + "siteAssociations": [], + "userAssociations": [{ + "userId": "{{ query_user_id.current.id }}" + }], + "_updateVersion": 0, + } + delegate_to: localhost + register: add_tenant + +- name: Verify add_tenant in json_string + assert: + that: + - add_tenant is changed + - add_tenant.jsondata.displayName == 'ansible_test' + +# ADD schema +- name: Add schema + mso_rest: + <<: *mso_info + path: /mso/api/v1/schemas + method: post + content: | + { + "displayName": "{{ mso_schema | default('ansible_test') }}", + "templates": [{ + "name": "Template_1", + "tenantId": "{{ add_tenant.jsondata.id }}", + "displayName": "Template_1", + "templateSubType": [], + "templateType": "stretched-template", + "anps": [], + "contracts": [], + "vrfs": [], + "bds": [], + "filters": [], + "externalEpgs": [], + "serviceGraphs": [], + "intersiteL3outs": [] + }], + "sites": [], + "_updateVersion": 0 + } + register: add_schema + +- name: Verify add_schema in json_string + assert: + that: + - add_schema is changed + - add_schema.jsondata.displayName == 'ansible_test' + +# PUT schema +- name: Put schema + mso_rest: + <<: *mso_info + path: "/mso/api/v1/schemas/{{ add_schema.jsondata.id }}" + method: put + content: | + { + "displayName": "ansible_test_2", + "templates": [{ + "name": "Template_1", + "tenantId": "{{ add_tenant.jsondata.id }}", + "displayName": "Template_1", + "templateSubType": [], + "templateType": "stretched-template", + "anps": [], + "contracts": [], + "vrfs": [], + "bds": [], + "filters": [], + "externalEpgs": [], + "serviceGraphs": [], + "intersiteL3outs": [] + }], + "sites": [], + "_updateVersion": 0 + } + register: put_schema + +- name: Verify put_schema in json_string + assert: + that: + - put_schema is changed + - put_schema.jsondata.displayName == 'ansible_test_2' + +# PATCH schema +- name: Patch schema + mso_rest: + <<: *mso_info + path: "/mso/api/v1/schemas/{{ add_schema.jsondata.id }}" + method: patch + content: | + [ + { + "op": "add", + "path": "/templates/Template_1/anps/-", + "value": { "name": "AP2", "displayName": "AP2", "epgs": [] }, + "_updateVersion": 0 + } + ] + register: patch_schema + +- name: Verify patch_schema in json_string + assert: + that: + - patch_schema is changed + - patch_schema.jsondata.templates[0].anps[0].displayName == 'AP2' + +# DELETE the schema +- name: Delete the schema + 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: + that: + - delete_schema is changed + - delete_schema.jsondata == None + +# DELETE TENANT +- name: Delete the tenant + 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: + that: + - delete_tenant is changed + - delete_tenant.jsondata == None \ No newline at end of file diff --git a/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_rest/tasks/json_template.yml b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_rest/tasks/json_template.yml new file mode 100644 index 00000000..830b49cb --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_rest/tasks/json_template.yml @@ -0,0 +1,67 @@ +# Test code for the MSO modules +# Copyright: (c) 2020, Anvitha Jain (@anvitha-jain) +# + +# 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.' + 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: + 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(true) }}' + output_level: '{{ mso_output_level | default("info") }}' + +- name: Remove schemas + cisco.mso.mso_schema: + <<: *mso_info + schema: '{{ item }}' + state: absent + loop: + - '{{ mso_schema | default("ansible_test") }}_1' + - '{{ mso_schema | default("ansible_test") }}' + +- name: Remove tenant ansible_test + mso_tenant: + <<: *mso_info + tenant: ansible_test + state: absent + +# QUERY A USER +- name: Query our user + mso_user: + <<: *mso_info + state: query + user: ansible_github_ci + check_mode: yes + register: query_user_id + +- name: Verify query_user_id + assert: + that: + - query_user_id is not changed + - query_user_id.current.username == 'ansible_github_ci' + +- name: Add a tenant from a templated payload file from templates + mso_rest: + <<: *mso_info + path: /api/v1/tenants + method: post + content: "{{ lookup('template', 'tenant.json.j2') }}" + register: add_tenant + +- name: Verify add_tenant in json_string + assert: + that: + - add_tenant is changed + - add_tenant.jsondata.displayName == 'ansible_test' \ No newline at end of file diff --git a/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_rest/tasks/main.yml b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_rest/tasks/main.yml new file mode 100644 index 00000000..22851bf7 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_rest/tasks/main.yml @@ -0,0 +1,28 @@ +# Test code for the MSO modules +# Copyright: (c) 2020, Anvitha Jain (@anvitha-jain) +# + +# 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.' + when: mso_hostname is not defined or mso_username is not defined or mso_password is not defined + +- include_tasks: json_inline.yml + tags: json_inline + +- include_tasks: json_string.yml + tags: json_string + +- include_tasks: json_template.yml + tags: json_template + +- include_tasks: yaml_inline.yml + tags: yaml_inline + +- include_tasks: yaml_string.yml + tags: yaml_string + +- include_tasks: error_handling.yml + tags: error_handling diff --git a/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_rest/tasks/tenant.json.j2 b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_rest/tasks/tenant.json.j2 new file mode 100644 index 00000000..2d91ee76 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_rest/tasks/tenant.json.j2 @@ -0,0 +1,10 @@ +{ + "displayName": "ansible_test", + "name": "ansible_test", + "description": "", + "siteAssociations": [], + "userAssociations": [{ + "userId": "{{ query_user_id.current.id }}" + }], + "_updateVersion": 0, +} \ No newline at end of file diff --git a/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_rest/tasks/yaml_inline.yml b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_rest/tasks/yaml_inline.yml new file mode 100644 index 00000000..da2246fd --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_rest/tasks/yaml_inline.yml @@ -0,0 +1,209 @@ +# Test code for the MSO modules +# Copyright: (c) 2020, Anvitha Jain (@anvitha-jain) +# + +# 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.' + 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: + 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(true) }}' + output_level: '{{ mso_output_level | default("info") }}' + +- 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") }}' + +- name: Remove tenant ansible_test + mso_tenant: + <<: *mso_info + tenant: ansible_test + state: absent + +# QUERY SCHEMAS +- name: Query schema + mso_rest: + <<: *mso_info + path: /mso/api/v1/schemas + method: get + delegate_to: localhost + register: query_all_schema + +- name: Verify query_all_schema + assert: + that: + - query_all_schema is not changed + +# QUERY A USER +- name: Query our user + mso_user: + <<: *mso_info + state: query + user: ansible_github_ci + check_mode: yes + register: query_user_id + +- name: Verify query_user_id + assert: + that: + - query_user_id is not changed + - query_user_id.current.username == 'ansible_github_ci' + +# ADD tenant +- name: Add tenant + mso_rest: + <<: *mso_info + path: /mso/api/v1/tenants + method: post + content: + displayName: ansible_test + name: ansible_test + description: MSO tenant + siteAssociations: [] + userAssociations: + - userId: '{{ query_user_id.current.id }}' + _updateVersion: 0 + delegate_to: localhost + register: add_tenant + +- name: Verify add_tenant in yaml_inline + assert: + that: + - add_tenant is changed + - add_tenant.jsondata.displayName == 'ansible_test' + +# ADD schema +- name: Add schema + mso_rest: + <<: *mso_info + path: /mso/api/v1/schemas + method: post + content: + displayName: '{{ mso_schema | default("ansible_test") }}' + templates: + - name: Template_1 + tenantId: '{{ add_tenant.jsondata.id }}' + displayName: Template_1 + templateSubType: [] + templateType: stretched-template + anps: [] + contracts: [] + vrfs: [] + bds: [] + filters: [] + externalEpgs: [] + serviceGraphs: [] + intersiteL3outs: [] + sites: [] + _updateVersion: 0 + delegate_to: localhost + register: add_schema + +- name: Verify add_schema in yaml_inline + assert: + that: + - add_schema is changed + - add_schema.jsondata.displayName == 'ansible_test' + +# PUT schema +- name: Put schema + mso_rest: + <<: *mso_info + path: "/mso/api/v1/schemas/{{ add_schema.jsondata.id }}" + method: put + content: + displayName: ansible_test_2 + templates: + - name: Template_1 + tenantId: '{{ add_tenant.jsondata.id }}' + displayName: Template_1 + templateSubType: [] + templateType: stretched-template + anps: [] + contracts: [] + vrfs: [] + bds: [] + filters: [] + externalEpgs: [] + serviceGraphs: [] + intersiteL3outs: [] + sites: [] + _updateVersion: 0 + delegate_to: localhost + register: put_schema + +- name: Verify put_schema in yaml_inline + assert: + that: + - put_schema is changed + - put_schema.jsondata.displayName == 'ansible_test_2' + +# PATCH schema +- name: Patch schema + mso_rest: + <<: *mso_info + path: "/mso/api/v1/schemas/{{ add_schema.jsondata.id }}" + method: patch + content: + - op: add + path: /templates/Template_1/anps/- + value: + name: AP2 + displayName: AP2 + epgs: [] + _updateVersion: 0 + delegate_to: localhost + register: patch_schema + +- name: Verify patch_schema in yaml_inline + assert: + that: + - patch_schema is changed + - patch_schema.jsondata.templates[0].anps[0].displayName == 'AP2' + +# DELETE the schema +- name: Delete the schema + mso_rest: + <<: *mso_info + path: "/mso/api/v1/schemas/{{ add_schema.jsondata.id }}" + method: delete + delegate_to: localhost + register: delete_schema + +- name: Verify delete_schema in yaml_inline + assert: + that: + - delete_schema is changed + - delete_schema.jsondata == None + +# DELETE TENANT +- name: Delete the tenant + mso_rest: + <<: *mso_info + path: "/mso/api/v1/tenants/{{ add_tenant.jsondata.id }}" + method: delete + delegate_to: localhost + register: delete_tenant + +- name: Verify delete_tenant in yaml_inline + assert: + that: + - delete_tenant is changed + - delete_tenant.jsondata == None \ No newline at end of file diff --git a/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_rest/tasks/yaml_string.yml b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_rest/tasks/yaml_string.yml new file mode 100644 index 00000000..1224206c --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_rest/tasks/yaml_string.yml @@ -0,0 +1,209 @@ +# Test code for the MSO modules +# Copyright: (c) 2020, Anvitha Jain (@anvitha-jain) +# + +# 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.' + 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: + 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(true) }}' + output_level: '{{ mso_output_level | default("info") }}' + +- 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") }}' + +- name: Remove tenant ansible_test + mso_tenant: + <<: *mso_info + tenant: ansible_test + state: absent + +# QUERY SCHEMAS +- name: Query schema + mso_rest: + <<: *mso_info + path: /mso/api/v1/schemas + method: get + delegate_to: localhost + register: query_all_schema + +- name: Verify query_all_schema + assert: + that: + - query_all_schema is not changed + +# QUERY A USER +- name: Query our user + mso_user: + <<: *mso_info + state: query + user: ansible_github_ci + check_mode: yes + register: query_user_id + +- name: Verify query_user_id + assert: + that: + - query_user_id is not changed + - query_user_id.current.username == 'ansible_github_ci' + +# ADD tenant +- name: Add tenant + mso_rest: + <<: *mso_info + path: /mso/api/v1/tenants + method: post + content: + displayName: ansible_test + name: ansible_test + description: MSO tenant + siteAssociations: [] + userAssociations: + - userId: '{{ query_user_id.current.id }}' + _updateVersion: 0 + delegate_to: localhost + register: add_tenant + +- name: Verify add_tenant in yaml_string + assert: + that: + - add_tenant is changed + - add_tenant.jsondata.displayName == 'ansible_test' + +# ADD schema +- name: Add schema + mso_rest: + <<: *mso_info + path: /mso/api/v1/schemas + method: post + content: + displayName: '{{ mso_schema | default("ansible_test") }}' + templates: + - name: Template_1 + tenantId: '{{ add_tenant.jsondata.id }}' + displayName: Template_1 + templateSubType: [] + templateType: stretched-template + anps: [] + contracts: [] + vrfs: [] + bds: [] + filters: [] + externalEpgs: [] + serviceGraphs: [] + intersiteL3outs: [] + sites: [] + _updateVersion: 0 + delegate_to: localhost + register: add_schema + +- name: Verify add_schema in yaml_string + assert: + that: + - add_schema is changed + - add_schema.jsondata.displayName == 'ansible_test' + +# PUT schema +- name: Put schema + mso_rest: + <<: *mso_info + path: "/mso/api/v1/schemas/{{ add_schema.jsondata.id }}" + method: put + content: + displayName: ansible_test_2 + templates: + - name: Template_1 + tenantId: '{{ add_tenant.jsondata.id }}' + displayName: Template_1 + templateSubType: [] + templateType: stretched-template + anps: [] + contracts: [] + vrfs: [] + bds: [] + filters: [] + externalEpgs: [] + serviceGraphs: [] + intersiteL3outs: [] + sites: [] + _updateVersion: 0 + delegate_to: localhost + register: put_schema + +- name: Verify put_schema in yaml_string + assert: + that: + - put_schema is changed + - put_schema.jsondata.displayName == 'ansible_test_2' + +# PATCH schema +- name: Patch schema + mso_rest: + <<: *mso_info + path: "/mso/api/v1/schemas/{{ add_schema.jsondata.id }}" + method: patch + content: + - op: add + path: /templates/Template_1/anps/- + value: + name: AP2 + displayName: AP2 + epgs: [] + _updateVersion: 0 + delegate_to: localhost + register: patch_schema + +- name: Verify patch_schema in yaml_string + assert: + that: + - patch_schema is changed + - patch_schema.jsondata.templates[0].anps[0].displayName == 'AP2' + +# DELETE the schema +- name: Delete the schema + mso_rest: + <<: *mso_info + path: "/mso/api/v1/schemas/{{ add_schema.jsondata.id }}" + method: delete + delegate_to: localhost + register: delete_schema + +- name: Verify delete_schema in yaml_string + assert: + that: + - delete_schema is changed + - delete_schema.jsondata == None + +# DELETE TENANT +- name: Delete the tenant + mso_rest: + <<: *mso_info + path: "/mso/api/v1/tenants/{{ add_tenant.jsondata.id }}" + method: delete + delegate_to: localhost + register: delete_tenant + +- name: Verify delete_tenant in yaml_string + assert: + that: + - delete_tenant is changed + - delete_tenant.jsondata == None \ No newline at end of file diff --git a/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_role/aliases b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_role/aliases new file mode 100644 index 00000000..5042c9c0 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_role/aliases @@ -0,0 +1,2 @@ +# No ACI MultiSite infrastructure, so not enabled +# unsupported diff --git a/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_role/tasks/main.yml b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_role/tasks/main.yml new file mode 100644 index 00000000..cf2397da --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_role/tasks/main.yml @@ -0,0 +1,43 @@ +# Test code for the MSO modules +# Copyright: (c) 2020, Lionel Hercot (@lhercot) + +# 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.' + 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: + 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(true) }}' + output_level: '{{ mso_output_level | default("info") }}' + +- name: Query MSO version + mso_version: + <<: *mso_info + state: query + register: version + +- name: Set version vars + set_fact: + mso_rw: true + when: + - version.current.version[0] | int <= 2 + - version.current.version[:5] != '2.2.4' + +- name: Import tasks if RW of role in this MSO version + 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 + when: mso_rw is not defined \ No newline at end of file diff --git a/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_role/tasks/role-ro.yml b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_role/tasks/role-ro.yml new file mode 100644 index 00000000..e9a36a48 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_role/tasks/role-ro.yml @@ -0,0 +1,88 @@ +# Test code for the MSO modules +# Copyright: (c) 2018, Dag Wieers (@dagwieers) +# Copyright: (c) 2020, Lionel Hercot (@lhercot) + +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + + +# CLEAN ENVIRONMENT +- name: Set vars + 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(true) }}' + output_level: '{{ mso_output_level | default("info") }}' + + +# QUERY ALL ROLES +- name: Query all roles (check_mode) + mso_role: &role_query + <<: *mso_info + state: query + check_mode: yes + register: cm_query_all_roles + +- name: Query all roles (normal mode) + mso_role: *role_query + register: nm_query_all_roles + +- name: Verify query_all_roles + assert: + that: + - cm_query_all_roles is not changed + - nm_query_all_roles is not changed + # NOTE: Order of roles is not stable between calls + #- cm_query_all_roles == nm_query_all_roles + + +# QUERY A ROLE +- name: Query our role + mso_role: + <<: *role_query + role: powerUser + check_mode: yes + register: cm_query_role + +- name: Query our role + mso_role: + <<: *role_query + role: powerUser + register: nm_query_role + +- name: Verify query_role + assert: + that: + - cm_query_role is not changed + - cm_query_role.current.description == 'Elevates this user to \"admin\"' + - cm_query_role.current.displayName == 'Power User' + - nm_query_role is not changed + - nm_query_role.current.description == 'Elevates this user to \"admin\"' + - nm_query_role.current.displayName == 'Power User' + - cm_query_role == nm_query_role + + +# QUERY NON-EXISTING ROLE +- name: Query non-existing role (check_mode) + mso_role: + <<: *role_query + role: non-existing-role + check_mode: yes + register: cm_query_non_role + +- name: Query non-existing role (normal mode) + mso_role: + <<: *role_query + role: non-existing-role + register: nm_query_non_role + +# TODO: Implement more tests +- name: Verify query_non_role + assert: + that: + - cm_query_non_role is not changed + - nm_query_non_role is not changed + - cm_query_non_role == nm_query_non_role diff --git a/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_role/tasks/role-rw.yml b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_role/tasks/role-rw.yml new file mode 100644 index 00000000..44a9ba51 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_role/tasks/role-rw.yml @@ -0,0 +1,275 @@ +# Test code for the MSO modules +# Copyright: (c) 2018, Dag Wieers (@dagwieers) +# Copyright: (c) 2020, Lionel Hercot (@lhercot) + +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + + +# CLEAN ENVIRONMENT +- name: Set vars + 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(true) }}' + output_level: '{{ mso_output_level | default("info") }}' + +- name: Remove role ansible_test + mso_role: &role_absent + <<: *mso_info + role: ansible_test + state: absent + +- name: Remove role ansible_test2 + mso_role: + <<: *role_absent + role: ansible_test2 + register: cm_remove_role + + +# ADD ROLE +- name: Add role (check_mode) + mso_role: &role_present + <<: *mso_info + role: ansible_test + description: Ansible test role + read_permissions: view-sites + write_permissions: manage-sites + state: present + check_mode: yes + register: cm_add_role + +- name: Verify cm_add_role + assert: + that: + - cm_add_role is changed + - cm_add_role.previous == {} + - cm_add_role.current.description == 'Ansible test role' + - cm_add_role.current.displayName == 'ansible_test' + - cm_add_role.current.id is not defined + +- name: Add role (normal mode) + mso_role: *role_present + register: nm_add_role + +- name: Verify nm_add_role + assert: + that: + - nm_add_role is changed + - nm_add_role.previous == {} + - nm_add_role.current.description == 'Ansible test role' + - nm_add_role.current.displayName == 'ansible_test' + - nm_add_role.current.id is defined + +- name: Add role again (check_mode) + mso_role: *role_present + check_mode: yes + register: cm_add_role_again + +- name: Verify cm_add_role_again + assert: + that: + - cm_add_role_again is not changed + - cm_add_role_again.previous.description == 'Ansible test role' + - cm_add_role_again.previous.displayName == 'ansible_test' + - cm_add_role_again.current.description == 'Ansible test role' + - cm_add_role_again.current.displayName == 'ansible_test' + - cm_add_role_again.current.id == nm_add_role.current.id + +- name: Add role again (normal mode) + mso_role: *role_present + register: nm_add_role_again + +- name: Verify nm_add_role_again + assert: + that: + - nm_add_role_again is not changed + - nm_add_role_again.previous.description == 'Ansible test role' + - nm_add_role_again.previous.displayName == 'ansible_test' + - nm_add_role_again.current.description == 'Ansible test role' + - nm_add_role_again.current.displayName == 'ansible_test' + - nm_add_role_again.current.id == nm_add_role.current.id + + +# CHANGE ROLE +- name: Change role (check_mode) + mso_role: + <<: *role_present + role: ansible_test + description: Ansible test role 2 + check_mode: yes + register: cm_change_role + +- name: Verify cm_change_role + assert: + that: + - cm_change_role is changed + - cm_change_role.current.description == 'Ansible test role 2' + - cm_change_role.current.displayName == 'ansible_test' + - cm_change_role.current.id == nm_add_role.current.id + +- name: Change role (normal mode) + mso_role: + <<: *role_present + role: ansible_test + description: Ansible test role 2 + output_level: debug + register: nm_change_role + +- name: Verify nm_change_role + assert: + that: + - nm_change_role is changed + - nm_change_role.current.description == 'Ansible test role 2' + #- nm_change_role.current.displayName == 'ansible_test2' + - nm_change_role.current.id == nm_add_role.current.id + +- name: Change role again (check_mode) + mso_role: + <<: *role_present + role: ansible_test + description: Ansible test role 2 + check_mode: yes + register: cm_change_role_again + +- name: Verify cm_change_role_again + assert: + that: + - cm_change_role_again is not changed + - cm_change_role_again.current.description == 'Ansible test role 2' + - cm_change_role_again.current.displayName == 'ansible_test' + - cm_change_role_again.current.id == nm_add_role.current.id + +- name: Change role again (normal mode) + mso_role: + <<: *role_present + role: ansible_test + description: Ansible test role 2 + register: nm_change_role_again + +- name: Verify nm_change_role_again + assert: + that: + - nm_change_role_again is not changed + - nm_change_role_again.current.description == 'Ansible test role 2' + - nm_change_role_again.current.displayName == 'ansible_test' + - nm_change_role_again.current.id == nm_add_role.current.id + + +# QUERY ALL ROLES +- name: Query all roles (check_mode) + mso_role: &role_query + <<: *mso_info + state: query + check_mode: yes + register: cm_query_all_roles + +- name: Query all roles (normal mode) + mso_role: *role_query + register: nm_query_all_roles + +- name: Verify query_all_roles + assert: + that: + - cm_query_all_roles is not changed + - nm_query_all_roles is not changed + # NOTE: Order of roles is not stable between calls + #- cm_query_all_roles == nm_query_all_roles + + +# QUERY A ROLE +- name: Query our role + mso_role: + <<: *role_query + role: ansible_test + check_mode: yes + register: cm_query_role + +- name: Query our role + mso_role: + <<: *role_query + role: ansible_test + register: nm_query_role + +- name: Verify query_role + assert: + that: + - cm_query_role is not changed + - cm_query_role.current.description == 'Ansible test role 2' + - cm_query_role.current.displayName == 'ansible_test' + - cm_query_role.current.id == nm_add_role.current.id + - nm_query_role is not changed + - nm_query_role.current.description == 'Ansible test role 2' + - nm_query_role.current.displayName == 'ansible_test' + - nm_query_role.current.id == nm_add_role.current.id + - cm_query_role == nm_query_role + + +# REMOVE ROLE +- name: Remove role (check_mode) + mso_role: *role_absent + check_mode: yes + register: cm_remove_role + +- name: Verify cm_remove_role + assert: + that: + - cm_remove_role is changed + - cm_remove_role.current == {} + +- name: Remove role (normal mode) + mso_role: *role_absent + register: nm_remove_role + +- name: Verify nm_remove_role + assert: + that: + - nm_remove_role is changed + - nm_remove_role.current == {} + +- name: Remove role again (check_mode) + mso_role: *role_absent + check_mode: yes + register: cm_remove_role_again + +- name: Verify cm_remove_role_again + assert: + that: + - cm_remove_role_again is not changed + - cm_remove_role_again.current == {} + +- name: Remove role again (normal mode) + mso_role: *role_absent + register: nm_remove_role_again + +- name: Verify nm_remove_role_again + assert: + that: + - nm_remove_role_again is not changed + - nm_remove_role_again.current == {} + + +# QUERY NON-EXISTING ROLE +- name: Query non-existing role (check_mode) + mso_role: + <<: *role_query + role: non-existing-role + check_mode: yes + register: cm_query_non_role + +- name: Query non-existing role (normal mode) + mso_role: + <<: *role_query + role: non-existing-role + register: nm_query_non_role + +# TODO: Implement more tests +- name: Verify query_non_role + assert: + that: + - cm_query_non_role is not changed + - nm_query_non_role is not changed + - cm_query_non_role == nm_query_non_role diff --git a/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema/aliases b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema/aliases new file mode 100644 index 00000000..5042c9c0 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema/aliases @@ -0,0 +1,2 @@ +# No ACI MultiSite infrastructure, so not enabled +# unsupported diff --git a/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema/tasks/main.yml b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema/tasks/main.yml new file mode 100644 index 00000000..dc0613fe --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema/tasks/main.yml @@ -0,0 +1,117 @@ +# Test code for the MSO modules +# Copyright: (c) 2020, Cindy Zhao (@cizhao) + +# 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.' + 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: + 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(true) }}' + output_level: '{{ mso_output_level | default("info") }}' + +- 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") }}' + +- name: Ensure tenant ansible_test exists + cisco.mso.mso_tenant: + <<: *mso_info + tenant: ansible_test + users: + - '{{ mso_username }}' + state: present + +- name: Create schema 1 with Template 1, and Template 2, Template 3 exist + cisco.mso.mso_schema_template: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + tenant: ansible_test + template: '{{item.template}}' + state: present + loop: + - { template: Template 1} + - { template: Template 2} + - { template: Template 3} + +- name: Create schema 2 with Template 4 + cisco.mso.mso_schema_template: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}_2' + tenant: ansible_test + template: Template 4 + state: present + +- name: Query for all schemas + cisco.mso.mso_schema: + <<: *mso_info + state: query + register: query_all + +- name: Query a schema + cisco.mso.mso_schema: + <<: *mso_info + schema: ansible_test + state: query + register: query_one + +- name: Verify query_all and query_one + assert: + that: + - query_all is not changed + - query_one is not changed + - query_all.current | length >= 2 + - query_one.current.displayName == "ansible_test" + +- name: Remove schema (check_mode) + cisco.mso.mso_schema: + <<: *mso_info + schema: ansible_test + state: absent + check_mode: yes + register: cm_rm_schema + +- name: Remove schema (normal_mode) + cisco.mso.mso_schema: + <<: *mso_info + schema: ansible_test + state: absent + register: nm_rm_schema + +- name: Verify rm_schema + assert: + that: + - cm_rm_schema is changed + - cm_rm_schema.previous.displayName == "ansible_test" + - cm_rm_schema.current == {} + - nm_rm_schema is changed + - nm_rm_schema.current == {} + - nm_rm_schema.previous.displayName == "ansible_test" + +- name: Query non_existing schema + cisco.mso.mso_schema: + <<: *mso_info + schema: non_existing + state: query + register: query_non_existing + +- name: Verify query_non_existing + assert: + that: + - query_non_existing is not changed + - query_non_existing.current == {} diff --git a/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site/aliases b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site/aliases new file mode 100644 index 00000000..5042c9c0 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site/aliases @@ -0,0 +1,2 @@ +# No ACI MultiSite infrastructure, so not enabled +# unsupported diff --git a/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site/tasks/main.yml b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site/tasks/main.yml new file mode 100644 index 00000000..e9784ca9 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site/tasks/main.yml @@ -0,0 +1,253 @@ +# Test code for the MSO modules +# Copyright: (c) 2020, Shreyas Srish (@shrsr) + +# 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.' + 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: + 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(true) }}' + output_level: '{{ mso_output_level | default("info") }}' + +- name: Ensure site exists + 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: yes + +- name: Remove schemas + mso_schema: + <<: *mso_info + schema: '{{ item }}' + state: absent + loop: + - '{{ mso_schema | default("ansible_test") }}_2' + - '{{ mso_schema | default("ansible_test") }}' + +- name: Ensure tenant ansible_test exists + mso_tenant: + <<: *mso_info + tenant: ansible_test + users: + - '{{ mso_username }}' + sites: + - '{{ mso_site | default("ansible_test") }}' + state: present + +- name: Ensure schema 1 with Template 1 and Template 2 exists + mso_schema_template: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + tenant: ansible_test + template: '{{item.template}}' + state: present + loop: + - { template: Template 1} + - { template: Template 2} + +- name: Add a new site to a schema with Template 1 in check mode + mso_schema_site: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: '{{ mso_site | default("ansible_test") }}' + template: Template 1 + state: present + check_mode: yes + register: add_site_cm + +- name: Verify add_site_cm + 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: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: '{{ mso_site | default("ansible_test") }}' + template: Template 1 + state: present + register: add_site_nm + +- name: Verify add_site_nm + 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: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: '{{ mso_site | default("ansible_test") }}' + template: Template 1 + state: present + register: add_site_nm_again + +- name: Verify add_site_nm_again + 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: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: '{{ mso_site | default("ansible_test") }}' + template: Template 2 + state: present + register: add_site_temp2_nm + +- name: Verify add_site_temp2_nm + assert: + that: + - add_site_temp2_nm.current.siteId is match ("[0-9a-zA-Z]*") + - add_site_temp2_nm.current.templateName == "Template2" + +- name: Query a schema site + mso_schema_site: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: '{{ mso_site | default("ansible_test") }}' + template: Template 1 + state: query + register: query_site + +- name: Query all schema sites + 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: + 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: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: '{{ mso_site | default("ansible_test") }}' + template: Template 1 + state: absent + register: rm_site_temp1 + +- name: Remove a site from a schema with Template2 + mso_schema_site: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: '{{ mso_site | default("ansible_test") }}' + template: Template 2 + state: absent + register: rm_site_temp2 + +- name: Verify rm_site_temp1 and rm_site_temp2 + assert: + that: + - rm_site_temp1 is changed + - rm_site_temp1.current == {} + - rm_site_temp2 is changed + - rm_site_temp2.current == {} + +- name: Remove a site from a schema with Template2 again + mso_schema_site: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: '{{ mso_site | default("ansible_test") }}' + template: Template 2 + state: absent + register: rm_site_again + +- name: Verify rm_site_again + assert: + that: + - rm_site_again is not changed + +# USE NON-EXISTING STATE +- name: non_existing_state state + mso_schema_site: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: '{{ mso_site | default("ansible_test") }}' + template: Template 1 + state: non_existing_state + ignore_errors: yes + register: non_existing_state + +- name: Verify non_existing_state + 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: + <<: *mso_info + schema: non_existing_schema + site: '{{ mso_site | default("ansible_test") }}' + template: Template 1 + state: query + ignore_errors: yes + register: non_existing_schema + +- name: Verify non_existing_schema + 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: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: '{{ mso_site | default("ansible_test") }}' + template: non_existing_template + state: query + ignore_errors: yes + register: non_existing_template + +- name: Verify non_existing_template + 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: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: '{{ mso_site | default("ansible_test") }}' + state: query + ignore_errors: yes + register: absent_template + +- name: Verify absent_template + assert: + that: + - absent_template is not changed + - absent_template.current == [] \ No newline at end of file diff --git a/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_anp_epg_domain/aliases b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_anp_epg_domain/aliases new file mode 100644 index 00000000..5042c9c0 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_anp_epg_domain/aliases @@ -0,0 +1,2 @@ +# No ACI MultiSite infrastructure, so not enabled +# unsupported diff --git a/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_anp_epg_domain/tasks/main.yml b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_anp_epg_domain/tasks/main.yml new file mode 100644 index 00000000..ac0c9494 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_anp_epg_domain/tasks/main.yml @@ -0,0 +1,989 @@ +# Test code for the MSO modules +# Copyright: (c) 2020, Lionel Hercot (@lhercot) +# Copyright: (c) 2018, Dag Wieers (@dagwieers) (based on mso_site test case) +# Copyright: (c) 2020, Shreyas Srish (@shrsr) + +# 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.' + 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: + 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(true) }}' + output_level: '{{ mso_output_level | default("info") }}' + +- name: Remove Schemas + mso_schema: + <<: *mso_info + schema: '{{ item }}' + state: absent + loop: + - '{{ mso_schema | default("ansible_test") }}_2' + - '{{ mso_schema | default("ansible_test") }}' + +- name: Ensure site exists + 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 + +- name: Ensure tenant ansible_test exist + mso_tenant: + <<: *mso_info + tenant: ansible_test + users: + - '{{ mso_username }}' + sites: + - '{{ mso_site | default("ansible_test") }}' + state: present + +- name: Ensure schema 1 with Template 1 and 2 exists + mso_schema_template: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + tenant: ansible_test + template: '{{ item }}' + state: present + loop: + - Template 1 + - Template 2 + +- name: Ensure schema 2 with Template 3 exists + mso_schema_template: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}_2' + tenant: ansible_test + template: Template 3 + state: present + +- name: Add a new site to a schema + mso_schema_site: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: '{{ mso_site | default("ansible_test") }}' + template: Template 1 + state: present + +- name: Ensure VRF1 exists + mso_schema_template_vrf: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + vrf: VRF1 + state: present + +- name: Add BD1 + mso_schema_template_bd: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + bd: BD1 + vrf: + name: VRF1 + state: present + +- name: Ensure Template 1 with AP1 exists + mso_schema_template_anp: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + anp: AP1 + state: present + +- name: Ensure Template 1 and AP1 with EPG1 exists + mso_schema_template_anp_epg: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + anp: AP1 + epg: EPG1 + bd: + name: BD1 + vrf: + name: VRF1 + state: present + +- name: Ensure Template 1 and AP1 with EPG3 exists + mso_schema_template_anp_epg: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + anp: AP1 + epg: EPG3 + bd: + name: BD1 + vrf: + name: VRF1 + state: present + +- name: Ensure Template 1 with AP2 exists + mso_schema_template_anp: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + anp: AP2 + state: present + +- name: Ensure Template 1 and AP2 with EPG2 exists + mso_schema_template_anp_epg: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + anp: AP2 + epg: EPG2 + bd: + name: BD1 + vrf: + name: VRF1 + state: present + +- name: Ensure Template 1 and AP2 with EPG4 exists + mso_schema_template_anp_epg: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + anp: AP2 + epg: EPG4 + bd: + name: BD1 + vrf: + name: VRF1 + state: present + +# ADD DOMAINS +- name: Add domain 1 to site EPG1 with AP1 (check mode) + mso_schema_site_anp_epg_domain: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: '{{ mso_site | default("ansible_test") }}' + template: Template 1 + anp: AP1 + epg: EPG1 + domain_association_type: vmmDomain + domain_profile: VMware-VMM + deployment_immediacy: lazy + resolution_immediacy: pre-provision + state: present + check_mode: yes + register: cm_add_dom1e1 + +- name: Verify cm_add_dom1e1 + assert: + that: + - cm_add_dom1e1 is changed + - cm_add_dom1e1.previous == {} + - cm_add_dom1e1.current.deploymentImmediacy == 'lazy' + - cm_add_dom1e1.current.domainType == 'vmmDomain' + - cm_add_dom1e1.current.dn == 'uni/vmmp-VMware/dom-VMware-VMM' + - cm_add_dom1e1.current.resolutionImmediacy == 'pre-provision' + +- name: Add domain 1 to site EPG1 with AP1 (normal mode) + mso_schema_site_anp_epg_domain: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: '{{ mso_site | default("ansible_test") }}' + template: Template 1 + anp: AP1 + epg: EPG1 + domain_association_type: vmmDomain + domain_profile: 'VMware-VMM' + deployment_immediacy: lazy + resolution_immediacy: pre-provision + state: present + register: nm_add_dom1e1 + +- name: Verify nm_add_dom1e1 + assert: + that: + - nm_add_dom1e1 is changed + - nm_add_dom1e1.previous == {} + - nm_add_dom1e1.current.deploymentImmediacy == 'lazy' + - nm_add_dom1e1.current.domainType == 'vmmDomain' + - nm_add_dom1e1.current.dn == 'uni/vmmp-VMware/dom-VMware-VMM' + - nm_add_dom1e1.current.resolutionImmediacy == 'pre-provision' + +- name: Add domain 2 to site EPG1 with AP1 (normal mode) + mso_schema_site_anp_epg_domain: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: '{{ mso_site | default("ansible_test") }}' + template: Template 1 + anp: AP1 + epg: EPG1 + domain_association_type: physicalDomain + domain_profile: phys + deployment_immediacy: lazy + resolution_immediacy: pre-provision + state: present + register: nm_add_dom2e1 + +- name: Verify nm_add_dom2e1 + assert: + that: + - nm_add_dom2e1 is changed + - nm_add_dom2e1.previous == {} + - nm_add_dom2e1.current.deploymentImmediacy == 'lazy' + - nm_add_dom2e1.current.domainType == 'physicalDomain' + - nm_add_dom2e1.current.dn == 'uni/phys-phys' + - nm_add_dom2e1.current.resolutionImmediacy == 'pre-provision' + +- name: Add domain 3 to site EPG1 with AP1 (normal mode) + mso_schema_site_anp_epg_domain: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: '{{ mso_site | default("ansible_test") }}' + template: Template 1 + anp: AP1 + epg: EPG1 + domain_association_type: physicalDomain + domain_profile: phys + deployment_immediacy: lazy + resolution_immediacy: lazy + state: present + register: nm_add_dom3e1 + +- name: Verify nm_add_dom3e1 + assert: + that: + - nm_add_dom3e1 is changed + - nm_add_dom3e1.previous != {} + - nm_add_dom3e1.current.deploymentImmediacy == 'lazy' + - nm_add_dom3e1.current.domainType == 'physicalDomain' + - nm_add_dom3e1.current.dn == 'uni/phys-phys' + - nm_add_dom3e1.current.resolutionImmediacy == 'lazy' + +- name: Add domain1 to site EPG3 with AP1 (normal mode) + mso_schema_site_anp_epg_domain: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: '{{ mso_site | default("ansible_test") }}' + template: Template 1 + anp: AP1 + epg: EPG3 + domain_association_type: vmmDomain + domain_profile: 'VMware-VMM' + deployment_immediacy: lazy + resolution_immediacy: lazy + state: present + register: nm_add_dom1e3 + +- name: Verify nm_add_dom1e2 + assert: + that: + - nm_add_dom1e3 is changed + - nm_add_dom1e3.previous == {} + - nm_add_dom1e3.current.deploymentImmediacy == 'lazy' + - nm_add_dom1e3.current.domainType == 'vmmDomain' + - nm_add_dom1e3.current.dn == 'uni/vmmp-VMware/dom-VMware-VMM' + - nm_add_dom1e3.current.resolutionImmediacy == 'lazy' + +- name: Add domain 2 to EPG2 (check mode) + 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: EPG2 + domain_association_type: physicalDomain + domain_profile: phys + deployment_immediacy: lazy + resolution_immediacy: pre-provision + state: present + check_mode: yes + register: cm_add_dom2e2 + +- name: Verify cm_add_dom2e2 + assert: + that: + - cm_add_dom2e2 is changed + - cm_add_dom2e2.previous == {} + - cm_add_dom2e2.current.deploymentImmediacy == 'lazy' + - cm_add_dom2e2.current.domainType == 'physicalDomain' + - cm_add_dom2e2.current.dn == 'uni/phys-phys' + - cm_add_dom2e2.current.resolutionImmediacy == 'pre-provision' + +# QUERY DOMAINS +- name: Query domains of site EPG1 with AP1 (normal mode) + mso_schema_site_anp_epg_domain: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: '{{ mso_site | default("ansible_test") }}' + template: Template 1 + anp: AP1 + epg: EPG1 + state: query + register: nm_query_domse1 + +- name: Verify nm_query_domse1 + 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: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: '{{ mso_site | default("ansible_test") }}' + template: Template 1 + anp: AP1 + epg: EPG1 + domain_association_type: physicalDomain + domain_profile: phys + deployment_immediacy: lazy + resolution_immediacy: pre-provision + state: query + register: nm_query_dom3e1 + +- name: Verify nm_query_dom3e1 + 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: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: '{{ mso_site | default("ansible_test") }}' + template: Template 1 + anp: AP2 + epg: EPG2 + domain_association_type: physicalDomain + domain_profile: phys + deployment_immediacy: lazy + resolution_immediacy: pre-provision + state: present + register: nm_add_dom2e2 + +- name: Verify nm_add_dom2e2 + assert: + that: + - nm_add_dom2e2 is changed + - nm_add_dom2e2.previous == {} + - nm_add_dom2e2.current.deploymentImmediacy == 'lazy' + - nm_add_dom2e2.current.domainType == 'physicalDomain' + - nm_add_dom2e2.current.dn == 'uni/phys-phys' + - nm_add_dom2e2.current.resolutionImmediacy == 'pre-provision' + +- name: Remove domain2 from EPG2 (normal mode) + 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: EPG2 + domain_association_type: physicalDomain + domain_profile: phys + deployment_immediacy: lazy + resolution_immediacy: pre-provision + state: absent + register: nm_remove_dom2e2 + +- name: Verify nm_remove_dom2e2 + assert: + that: + - nm_remove_dom2e2 is changed + +- name: Query removed domain2 from EPG2 (normal mode) + 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: EPG2 + domain_association_type: physicalDomain + domain_profile: phys + deployment_immediacy: lazy + resolution_immediacy: pre-provision + state: query + ignore_errors: yes + register: nm_non_existent_dom2e2 + +- name: Verify non_existing_domain + 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: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: '{{ mso_site | default("ansible_test") }}' + template: Template 1 + anp: AP2 + epg: EPG2 + domain_association_type: physicalDomain + domain_profile: phys + deployment_immediacy: lazy + resolution_immediacy: pre-provision + state: absent + ignore_errors: yes + register: nm_remove_again_dom2e2 + +- name: Verify nm_remove_again_dom2e2 + 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: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: '{{ mso_site | default("ansible_test") }}' + template: Template 1 + anp: AP1 + epg: EPG1 + domain_association_type: vmmDomain + domain_profile: 'VMware-VMM' + deployment_immediacy: lazy + resolution_immediacy: pre-provision + state: present + register: nm_add_dom1e1_2 + +- name: Verify nm_add_dom1e1_2 + 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: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: '{{ mso_site | default("ansible_test") }}' + template: Template 1 + anp: AP1 + epg: EPG1 + domain_association_type: vmmDomain + domain_profile: 'VMware-VMM' + deployment_immediacy: lazy + resolution_immediacy: pre-provision + ignore_errors: yes + register: nm_add_stateless_dom1e1_2 + +- name: Verify nm_add_stateless_dom1e1_2 + 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: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: '{{ mso_site | default("ansible_test") }}' + template: Template 1 + anp: AP1 + epg: EPG1 + domain_association_type: l3ExtDomain + domain_profile: 'ansible_l3domain' + deployment_immediacy: lazy + resolution_immediacy: lazy + state: present + register: nm_add_doml3 + +- name: Verify nm_add_doml3 + assert: + that: + - nm_add_doml3 is changed + - nm_add_doml3.previous == {} + - nm_add_doml3.current.deploymentImmediacy == 'lazy' + - nm_add_doml3.current.domainType == 'l3ExtDomain' + - nm_add_doml3.current.dn =='uni/l3dom-ansible_l3domain' + - nm_add_doml3.current.resolutionImmediacy == 'lazy' + +- name: Add domain l2ExtDomain to site EPG1 with AP1 (normal mode) + mso_schema_site_anp_epg_domain: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: '{{ mso_site | default("ansible_test") }}' + template: Template 1 + anp: AP1 + epg: EPG1 + domain_association_type: l2ExtDomain + domain_profile: 'ansible_l2domain' + deployment_immediacy: lazy + resolution_immediacy: lazy + state: present + ignore_errors: yes + register: nm_add_doml2 + +- name: Verify nm_add_doml2 + assert: + that: + - nm_add_doml2 is changed + - nm_add_doml2.previous == {} + - nm_add_doml2.current.deploymentImmediacy == 'lazy' + - nm_add_doml2.current.domainType == 'l2ExtDomain' + - nm_add_doml2.current.dn =='uni/l2dom-ansible_l2domain' + - nm_add_doml2.current.resolutionImmediacy == 'lazy' + +- name: Add domain fibreChannel to site EPG1 with AP1 (normal mode) + mso_schema_site_anp_epg_domain: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: '{{ mso_site | default("ansible_test") }}' + template: Template 1 + anp: AP1 + epg: EPG1 + domain_association_type: fibreChannelDomain + domain_profile: 'ansible_fibreChanneldomain' + deployment_immediacy: lazy + resolution_immediacy: lazy + state: present + register: nm_add_domfc + +- name: Verify nm_add_domfc + assert: + that: + - nm_add_domfc is changed + - nm_add_domfc.previous == {} + - nm_add_domfc.current.domainType == 'fibreChannelDomain' + - nm_add_domfc.current.dn =='uni/fc-ansible_fibreChanneldomain' + - nm_add_domfc.current.resolutionImmediacy == 'lazy' + - nm_add_domfc.current.deploymentImmediacy == 'lazy' + +# USE OTHER ATTRIBUTES OF VMM DOMAIN +- name: Add domain vmm to site EPG2 with AP1 (normal mode) + 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: EPG2 + domain_association_type: vmmDomain + 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: yes + switch_type: 'default' + switching_mode: native + enhanced_lagpolicy_name: 'ansible_check' + enhanced_lagpolicy_dn: 'ansible_check' + state: present + ignore_errors: yes + register: nm_add_domvmprop + +- name: Verify nm_add_domvmprop + assert: + that: + - nm_add_domvmprop is changed + - nm_add_domvmprop.previous == {} + +- name: Add domain vmm to site EPG4 with AP2 (normal mode) + 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 + port_encap_vlan_type: 'vlan' + port_encap_vlan: 100 + vlan_encap_mode: static + allow_micro_segmentation: yes + switch_type: 'default' + switching_mode: native + enhanced_lagpolicy_name: 'ansible_check' + enhanced_lagpolicy_dn: 'ansible_check' + state: present + ignore_errors: yes + register: nm_add_domvmprop1 + +- name: Verify nm_add_domvmprop1 + 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." + +- name: Add domain vmm to site EPG4 with AP2 (normal mode) + 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_type: 'vlan' + port_encap_vlan_type: 'vlan' + port_encap_vlan: 100 + vlan_encap_mode: static + allow_micro_segmentation: yes + switch_type: 'default' + switching_mode: native + enhanced_lagpolicy_name: 'ansible_check' + enhanced_lagpolicy_dn: 'ansible_check' + state: present + ignore_errors: yes + register: nm_add_domvmprop2 + +- name: Verify nm_add_domvmprop2 + assert: + that: + - nm_add_domvmprop2 is not changed + - nm_add_domvmprop2.msg == "micro_seg_vlan is required when micro_seg_vlan_type is provided." + +- name: Add domain vmm to site EPG4 with AP2 (normal mode) + 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_type: 'vlan' + micro_seg_vlan: 100 + port_encap_vlan: 100 + vlan_encap_mode: static + allow_micro_segmentation: yes + switch_type: 'default' + switching_mode: native + enhanced_lagpolicy_name: 'ansible_check' + enhanced_lagpolicy_dn: '' + state: present + ignore_errors: yes + register: nm_add_domvmprop3 + +- 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: + <<: *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_type: 'vlan' + micro_seg_vlan: 100 + port_encap_vlan_type: 'vlan' + vlan_encap_mode: static + allow_micro_segmentation: yes + switch_type: 'default' + switching_mode: native + enhanced_lagpolicy_name: 'ansible_check' + enhanced_lagpolicy_dn: 'ansible_check' + state: present + ignore_errors: yes + register: nm_add_domvmprop4 + +- name: Verify nm_add_domvmprop4 + assert: + that: + - nm_add_domvmprop4 is not changed + - nm_add_domvmprop4.msg == "port_encap_vlan is required when port_encap_vlan_type is provided." + +- name: Add domain vmm to site EPG4 with AP2 (normal mode) + 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_type: 'vlan' + micro_seg_vlan: 100 + port_encap_vlan_type: 'vlan' + port_encap_vlan: 100 + vlan_encap_mode: static + allow_micro_segmentation: yes + switch_type: 'default' + switching_mode: native + enhanced_lagpolicy_dn: 'ansible_check' + state: present + ignore_errors: yes + 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." + +- name: Add domain vmm to site EPG4 with AP2 (normal mode) + 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_type: 'vlan' + micro_seg_vlan: 100 + port_encap_vlan_type: 'vlan' + port_encap_vlan: 100 + vlan_encap_mode: static + allow_micro_segmentation: yes + switch_type: 'default' + switching_mode: native + enhanced_lagpolicy_name: 'ansible_check' + state: present + ignore_errors: yes + register: nm_add_domvmprop6 + +- name: Verify nm_add_domvmprop6 + assert: + that: + - nm_add_domvmprop6 is not changed + - nm_add_domvmprop6.msg == "enhanced_lagpolicy_dn is required when enhanced_lagpolicy_name is provided." + +# 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: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: '{{ mso_site | default("ansible_test") }}' + template: Template 1 + anp: AP5 + epg: EPG5 + domain_association_type: vmmDomain + domain_profile: 'VMware-VMM' + deployment_immediacy: lazy + resolution_immediacy: pre-provision + state: present + ignore_errors: yes + register: nm_add_dom1e5 + +- name: Verify nm_add_dom1e5 + 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: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: '{{ mso_site | default("ansible_test") }}' + template: Template 1 + anp: AP1 + epg: EPG6 + domain_association_type: vmmDomain + domain_profile: 'VMware-VMM' + deployment_immediacy: lazy + resolution_immediacy: pre-provision + state: present + ignore_errors: yes + register: nm_add_dom1e6 + +- name: Verify nm_add_dom1e6 + 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: + <<: *mso_info + schema: non_existing_schema + site: '{{ mso_site | default("ansible_test") }}' + template: Template 1 + anp: AP1 + epg: EPG1 + domain_association_type: vmmDomain + domain_profile: 'VMware-VMM' + deployment_immediacy: lazy + resolution_immediacy: pre-provision + check_mode: yes + ignore_errors: yes + register: cm_non_existing_schema + +- name: Non-existing schema for domain (normal_mode) + mso_schema_site_anp_epg_domain: + <<: *mso_info + schema: non_existing_schema + site: '{{ mso_site | default("ansible_test") }}' + template: Template 1 + anp: AP1 + epg: EPG1 + domain_association_type: vmmDomain + domain_profile: 'VMware-VMM' + deployment_immediacy: lazy + resolution_immediacy: pre-provision + ignore_errors: yes + register: nm_non_existing_schema + +- name: Verify non_existing_schema + assert: + that: + - cm_non_existing_schema is not changed + - nm_non_existing_schema is not changed + - cm_non_existing_schema == nm_non_existing_schema + - cm_non_existing_schema.msg == nm_non_existing_schema.msg == "Provided schema 'non_existing_schema' does not exist" + +# USE A NON-EXISTING TEMPLATE +- name: Non-existing template for domain (check_mode) + mso_schema_site_anp_epg_domain: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: '{{ mso_site | default("ansible_test") }}' + template: non_existing_template + anp: AP1 + epg: EPG1 + domain_association_type: vmmDomain + domain_profile: 'VMware-VMM' + deployment_immediacy: lazy + resolution_immediacy: pre-provision + check_mode: yes + ignore_errors: yes + register: cm_non_existing_template + +- name: Non-existing template for domain (normal_mode) + mso_schema_site_anp_epg_domain: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: '{{ mso_site | default("ansible_test") }}' + template: non_existing_template + anp: AP1 + epg: EPG1 + domain_association_type: vmmDomain + domain_profile: 'VMware-VMM' + deployment_immediacy: lazy + resolution_immediacy: pre-provision + ignore_errors: yes + register: nm_non_existing_template + +- name: Verify non_existing_template + 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" + +# USE A NON-EXISTING SITE +- name: Non-existing site for domain (check_mode) + mso_schema_site_anp_epg_domain: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: '{{ mso_site | default("ansible_test") }}' + template: Template 2 + anp: AP1 + epg: EPG1 + domain_association_type: vmmDomain + domain_profile: 'VMware-VMM' + deployment_immediacy: lazy + resolution_immediacy: pre-provision + check_mode: yes + ignore_errors: yes + register: cm_non_existing_site + +- name: Non-existing site for domain (normal_mode) + mso_schema_site_anp_epg_domain: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: '{{ mso_site | default("ansible_test") }}' + template: Template 2 + anp: AP1 + epg: EPG1 + domain_association_type: vmmDomain + domain_profile: 'VMware-VMM' + deployment_immediacy: lazy + resolution_immediacy: pre-provision + ignore_errors: yes + register: nm_non_existing_site + +- name: Verify non_existing_site + 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") + +# 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: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}_2' + site: '{{ mso_site | default("ansible_test") }}' + template: Template 3 + anp: AP1 + epg: EPG1 + domain_association_type: vmmDomain + domain_profile: 'VMware-VMM' + deployment_immediacy: lazy + resolution_immediacy: pre-provision + ignore_errors: yes + check_mode: yes + 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: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}_2' + site: '{{ mso_site | default("ansible_test") }}' + template: Template 3 + anp: AP1 + epg: EPG1 + domain_association_type: vmmDomain + domain_profile: 'VMware-VMM' + deployment_immediacy: lazy + resolution_immediacy: pre-provision + ignore_errors: yes + register: nm_no_site_associated + +- name: Verify cm_no_site_associated and nm_no_site_associated + 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 diff --git a/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_anp_epg_selector/aliases b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_anp_epg_selector/aliases new file mode 100644 index 00000000..5042c9c0 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_anp_epg_selector/aliases @@ -0,0 +1,2 @@ +# No ACI MultiSite infrastructure, so not enabled +# unsupported diff --git a/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_anp_epg_selector/tasks/main.yml b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_anp_epg_selector/tasks/main.yml new file mode 100644 index 00000000..a89bf355 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_anp_epg_selector/tasks/main.yml @@ -0,0 +1,1089 @@ +# Test code for the MSO modules +# Copyright: (c) 2020, Cindy Zhao (@cizhao) +# Copyright: (c) 2020, Lionel Hercot (@lhercot) +# Copyright: (c) 2018, Dag Wieers (@dagwieers) (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: + 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: + 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(true) }}' + output_level: '{{ mso_output_level | default("info") }}' + +- name: Query MSO version + mso_version: + <<: *mso_info + state: query + register: version + +- name: Remove schemas + mso_schema: + <<: *mso_info + schema: '{{ item }}' + state: absent + loop: + - '{{ mso_schema | default("ansible_test") }}_2' + - '{{ mso_schema | default("ansible_test") }}' + +- name: Ensure azure site exists + mso_site: + <<: *mso_info + site: 'azure_{{ mso_site | default("ansible_test") }}' + apic_username: '{{ azure_apic_username }}' + apic_password: '{{ azure_apic_password }}' + apic_site_id: '{{ azure_site_id }}' + urls: + - https://{{ azure_apic_hostname }} + state: present + +- name: Ensure aws site exists + mso_site: + <<: *mso_info + site: 'aws_{{ mso_site | default("ansible_test") }}' + apic_username: '{{ aws_apic_username }}' + apic_password: '{{ aws_apic_password }}' + apic_site_id: '{{ aws_site_id }}' + urls: + - https://{{ aws_apic_hostname }} + state: present + +- name: Ensure tenant ansible_test exists + mso_tenant: + <<: *mso_info + tenant: ansible_test + users: + - '{{ mso_username }}' + # sites: + # - '{{ mso_site | default("ansible_test") }}' + state: present + +- name: Associate aws site with ansible_test in normal mode + mso_tenant_site: + <<: *mso_info + tenant: ansible_test + site: 'aws_{{ mso_site | default("ansible_test") }}' + cloud_account: "000000000000" + aws_trusted: false + aws_access_key: "1" + secret_key: "0" + state: present + register: aaws_nm + +- name: Associate azure site with access_type not present, with ansible_test in normal mode + mso_tenant_site: + <<: *mso_info + tenant: ansible_test + site: 'azure_{{ mso_site | default("ansible_test") }}' + cloud_account: uni/tn-ansible_test/act-[100]-vendor-azure + state: present + register: aazure_shared_nm + +- name: Ensure schema 1 with Template 1, and Template 2, Template 3 exist + mso_schema_template: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + tenant: ansible_test + template: '{{item.template}}' + state: present + loop: + - { template: Template 1} + - { template: Template 2} + - { template: Template 3} + +- name: Ensure schema 2 with Template 3 exist + mso_schema_template: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}_2' + tenant: ansible_test + template: Template 3 + state: present + +- name: Add aws site to a schema + mso_schema_site: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: 'aws_{{ mso_site | default("ansible_test") }}' + template: '{{item.template}}' + state: present + loop: + - { template: Template 1} + - { template: Template 2} + when: version.current.version[0] | int < 3 + +- name: Add azure site to a schema + mso_schema_site: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: 'azure_{{ mso_site | default("ansible_test") }}' + template: '{{item.template}}' + state: present + loop: + - { template: Template 1} + - { template: Template 2} + when: version.current.version[0] | int < 3 + +- name: Ensure VRF1 exists + mso_schema_template_vrf: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + vrf: VRF1 + state: present + +- name: Ensure ANP exist + mso_schema_template_anp: + <<: *mso_info + schema: '{{ item.schema }}' + template: '{{ item.template }}' + anp: ANP + state: present + loop: + - { schema: '{{ mso_schema | default("ansible_test") }}', template: 'Template 1' } + - { 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 + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + site: '{{ item }}' + vrf: VRF1 + region: us-west-1 + cidr: 10.0.0.0/16 + primary: true + state: present + loop: + - 'aws_{{ mso_site | default("ansible_test") }}' + - 'azure_{{ mso_site | default("ansible_test") }}' + +# ADD EPGs +- name: Ensure EPGs exist + mso_schema_template_anp_epg: + <<: *mso_info + schema: '{{ item.schema }}' + template: '{{ item.template }}' + anp: ANP + epg: '{{ item.epg }}' + vrf: + name: VRF1 + schema: ansible_test + template: Template 1 + state: present + loop: + - { schema: '{{ mso_schema | default("ansible_test") }}', template: 'Template 1', epg: 'ansible_test_1' } + - { 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: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + anp: ANP + epg: ansible_test_1 + selector: selector_1 + state: present + register: nm_add_selector_1 + +- name: Verify nm_add_selector_1 + assert: + that: + - nm_add_selector_1 is changed + - nm_add_selector_1.previous == {} + - nm_add_selector_1.current.name == "selector_1" + - nm_add_selector_1.current.expressions == [] + +- name: Add Selector 2 to EPG (normal_mode) + mso_schema_template_anp_epg_selector: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + anp: ANP + epg: ansible_test_1 + selector: selector_2 + expressions: + - type: expression_2_template + operator: in + value: test + state: present + register: nm_add_selector_2 + +- name: Verify nm_add_selector_2 + assert: + that: + - nm_add_selector_2 is changed + - nm_add_selector_2.previous == {} + - nm_add_selector_2.current.name == "selector_2" + - nm_add_selector_2.current.expressions[0].key == "Custom:expression_2_template" + - nm_add_selector_2.current.expressions[0].operator == "in" + - nm_add_selector_2.current.expressions[0].value == "test" + +# 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: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: 'aws_{{ mso_site | default("ansible_test") }}' + template: Template 1 + anp: ANP + epg: ansible_test_1 + selector: site_selector_1 + state: present + check_mode: yes + register: cm_add_site_selector_1 + +- name: Verify cm_add_site_selector_1 + assert: + that: + - cm_add_site_selector_1 is changed + - cm_add_site_selector_1.previous == {} + - cm_add_site_selector_1.current.name == "site_selector_1" + - cm_add_site_selector_1.current.expressions == [] + +- name: Add selector site_selector_1 to site EPG ansible_test_1 with ANP (normal_mode) + mso_schema_site_anp_epg_selector: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: 'aws_{{ mso_site | default("ansible_test") }}' + template: Template 1 + anp: ANP + epg: ansible_test_1 + selector: site_selector_1 + state: present + register: nm_add_site_selector_1 + +- name: Verify nm_add_site_selector_1 + assert: + that: + - nm_add_site_selector_1 is changed + - nm_add_site_selector_1.previous == {} + - nm_add_site_selector_1.current.name == "site_selector_1" + - nm_add_site_selector_1.current.expressions == [] + +# 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: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: 'aws_{{ mso_site | default("ansible_test") }}' + template: Template 1 + anp: ANP + epg: ansible_test_1 + selector: site_selector_1 + state: present + register: nm_add_site_selector_1_again + +- name: Verify nm_add_site_selector_1_again + 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: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: 'aws_{{ mso_site | default("ansible_test") }}' + template: Template 1 + anp: ANP + epg: ansible_test_1 + selector: selector 1 + state: present + ignore_errors: yes + register: nm_add_selector1_with_space_in_name + +- name: Verify nm_add_selector1_with_space_in_name + 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: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: 'aws_{{ mso_site | default("ansible_test") }}' + template: Template 1 + anp: ANP + epg: ansible_test_1 + selector: selector_2 + expressions: + - type: expression 2 + operator: in + value: test + state: present + ignore_errors: yes + register: nm_add_selector2_with_space_in_expression_type + +- name: Verify nm_add_selector2_with_space_in_expression_type + 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: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: 'aws_{{ mso_site | default("ansible_test") }}' + template: Template 1 + anp: ANP + epg: ansible_test_1 + selector: site_selector_2 + expressions: + - type: expression_2 + operator: in + value: test + state: present + check_mode: yes + register: cm_add_site_selector_2 + +- name: Verify cm_add_selector_2 + assert: + that: + - cm_add_site_selector_2 is changed + - cm_add_site_selector_2.previous == {} + - cm_add_site_selector_2.current.name == "site_selector_2" + - cm_add_site_selector_2.current.expressions[0].key == "Custom:expression_2" + - cm_add_site_selector_2.current.expressions[0].operator == "in" + - 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: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: 'aws_{{ mso_site | default("ansible_test") }}' + template: Template 1 + anp: ANP + epg: ansible_test_1 + selector: site_selector_2 + expressions: + - type: expression_2 + operator: in + value: test + state: present + register: nm_add_site_selector_2 + +- name: Verify nm_add_site_selector_2 + assert: + that: + - nm_add_site_selector_2 is changed + - nm_add_site_selector_2.previous == {} + - nm_add_site_selector_2.current.name == "site_selector_2" + - nm_add_site_selector_2.current.expressions[0].key == "Custom:expression_2" + - nm_add_site_selector_2.current.expressions[0].operator == "in" + - nm_add_site_selector_2.current.expressions[0].value == "test" + +- name: Change Selector 2 - keyExist(normal_mode) + mso_schema_site_anp_epg_selector: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: 'aws_{{ mso_site | default("ansible_test") }}' + template: Template 1 + anp: ANP + epg: ansible_test_1 + selector: site_selector_2 + expressions: + - type: expression_5 + operator: has_key + value: test + state: present + ignore_errors: yes + register: nm_change_site_selector_2_key_exist + +- name: Verify nm_change_site_selector_2_key_exist + 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: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: 'aws_{{ mso_site | default("ansible_test") }}' + template: Template 1 + anp: ANP + epg: ansible_test_1 + selector: site_selector_2 + expressions: + - type: expression_6 + operator: does_not_have_key + value: test + state: present + ignore_errors: yes + register: nm_change_site_selector_2_key_not_exist + +- name: Verify nm_change_site_selector_2_key_not_exist + 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: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: 'aws_{{ mso_site | default("ansible_test") }}' + template: Template 1 + anp: ANP + epg: ansible_test_1 + selector: site_selector_2 + expressions: + - type: expression_6 + operator: equals + state: present + ignore_errors: yes + register: nm_change_site_selector_2_equals + +- name: Verify nm_change_site_selector_2_equals + 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: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: 'aws_{{ mso_site | default("ansible_test") }}' + template: Template 1 + anp: ANP + state: absent + +- name: Query site ANP + mso_schema_site_anp: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: 'aws_{{ mso_site | default("ansible_test") }}' + template: Template 1 + anp: ANP + state: query + ignore_errors: yes + register: query_site_ANP + +- name: Verify query_site_ANP + assert: + that: + - query_site_ANP.msg == "ANP 'ANP' not found" + +# Query without site ANP +- name: Query site_selectors without site ANP + mso_schema_site_anp_epg_selector: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: 'aws_{{ mso_site | default("ansible_test") }}' + template: Template 1 + anp: ANP + epg: ansible_test_1 + state: query + ignore_errors: yes + register: query_without_site_ANP + +- name: Verify query_without_site_ANP + assert: + that: + - query_without_site_ANP is not changed + - query_without_site_ANP.msg == "Anp 'ANP' does not exist in site level." + +# - 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: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: 'aws_{{ mso_site | default("ansible_test") }}' + template: Template 1 + anp: ANP + epg: ansible_test_1 + selector: site_selector_3 + expressions: + - type: expression_3 + operator: in + value: test + state: present + register: nm_add_site_selector_3_without_anp + +- name: Verify nm_add_site_selector_3_without_anp + assert: + that: + - nm_add_site_selector_3_without_anp is changed + - nm_add_site_selector_3_without_anp.previous == {} + - nm_add_site_selector_3_without_anp.current.name == "site_selector_3" + - nm_add_site_selector_3_without_anp.current.expressions[0].key == "Custom:expression_3" + - nm_add_site_selector_3_without_anp.current.expressions[0].operator == "in" + - nm_add_site_selector_3_without_anp.current.expressions[0].value == "test" + +# Remove site level EPG +- name: Remove site EPG + mso_schema_site_anp_epg: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: 'aws_{{ mso_site | default("ansible_test") }}' + template: Template 1 + anp: ANP + epg: ansible_test_1 + state: absent + +# Query without site level EPG +- name: Query site_selectors without site EPG + mso_schema_site_anp_epg_selector: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: 'aws_{{ mso_site | default("ansible_test") }}' + template: Template 1 + anp: ANP + epg: ansible_test_1 + state: query + ignore_errors: yes + register: query_without_site_EPG + +- name: Verify query_without_site_EPG + assert: + that: + - query_without_site_EPG is not changed + - query_without_site_EPG.msg == "Epg 'ansible_test_1' does not exist in site level." + +- name: Add site selector 1 without site EPG exist (normal_mode) + mso_schema_site_anp_epg_selector: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: 'aws_{{ mso_site | default("ansible_test") }}' + template: Template 1 + anp: ANP + epg: ansible_test_1 + selector: site_selector_1 + state: present + register: nm_add_site_selector_1_without_epg + +- name: Verify nm_add_site_selector_1_without_epg + assert: + that: + - nm_add_site_selector_1_without_epg is changed + - nm_add_site_selector_1_without_epg.previous == {} + - nm_add_site_selector_1_without_epg.current.name == "site_selector_1" + - 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: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: 'aws_{{ mso_site | default("ansible_test") }}' + template: Template 1 + anp: ANP + epg: ansible_test_1 + selector: '{{ item.selector }}' + expressions: + - type: '{{ item.type }}' + operator: in + value: test + state: present + loop: + - {selector: 'site_selector_1', type: 'expression_1'} + - {selector: 'site_selector_2', type: 'expression_2'} + - {selector: 'site_selector_3', type: 'expression_3'} + register: nm_add_site_selectors_again + +- name: Verify nm_add_site_selectors_again + assert: + that: + - nm_add_site_selectors_again is changed + +# Query all selectors +- name: Query selectors to site EPG + mso_schema_site_anp_epg_selector: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: 'aws_{{ mso_site | default("ansible_test") }}' + template: Template 1 + anp: ANP + epg: ansible_test_1 + state: query + register: query_all_site_selectors + +- name: Verify query_all_site_selectors + assert: + that: + - query_all_site_selectors is not changed + - query_all_site_selectors.current | length == 3 + - query_all_site_selectors.current[0].name == "site_selector_1" + - query_all_site_selectors.current[0].expressions[0].key == "Custom:expression_1" + - query_all_site_selectors.current[0].expressions[0].operator == "in" + - query_all_site_selectors.current[0].expressions[0].value == "test" + - query_all_site_selectors.current[1].name == "site_selector_2" + - query_all_site_selectors.current[1].expressions[0].key == "Custom:expression_2" + - query_all_site_selectors.current[1].expressions[0].operator == "in" + - query_all_site_selectors.current[1].expressions[0].value == "test" + - query_all_site_selectors.current[2].name == "site_selector_3" + - query_all_site_selectors.current[2].expressions[0].key == "Custom:expression_3" + - query_all_site_selectors.current[2].expressions[0].operator == "in" + - query_all_site_selectors.current[2].expressions[0].value == "test" + +# Query sepecific seletor to site EPG +- name: Query selector to site EPG + mso_schema_site_anp_epg_selector: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: 'aws_{{ mso_site | default("ansible_test") }}' + template: Template 1 + anp: ANP + epg: ansible_test_1 + selector: site_selector_1 + state: query + register: query_site_selector_1 + +- name: Verify query_site_selector_1 + assert: + that: + - query_site_selector_1 is not changed + - query_site_selector_1.current.name == "site_selector_1" + - query_site_selector_1.current.expressions[0].key == "Custom:expression_1" + - query_site_selector_1.current.expressions[0].operator == "in" + - query_site_selector_1.current.expressions[0].value == "test" + +- name: Remove site selector 3 (normal_mode) + mso_schema_site_anp_epg_selector: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: 'aws_{{ mso_site | default("ansible_test") }}' + template: Template 1 + anp: ANP + epg: ansible_test_1 + selector: site_selector_3 + state: absent + register: nm_remove_site_selector_3 + +- name: Verify nm_remove_site_selector_3 + 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: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: 'aws_{{ mso_site | default("ansible_test") }}' + template: Template 1 + anp: ANP + epg: ansible_test_1 + selector: site_selector_3 + state: absent + register: nm_remove_site_selector_3_again + +- name: Verify nm_remove_site_selector_3_again + 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: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: 'aws_{{ mso_site | default("ansible_test") }}' + template: Template 1 + anp: ANP + epg: ansible_test_1 + selector: non_existing_selector + state: query + check_mode: yes + ignore_errors: yes + register: cm_query_non_selector + +- name: Query non-existing selector (normal mode) + mso_schema_site_anp_epg_selector: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: 'aws_{{ mso_site | default("ansible_test") }}' + template: Template 1 + anp: ANP + epg: ansible_test_1 + selector: non_existing_selector + state: query + ignore_errors: yes + register: nm_query_non_selector + +- name: Verify cm_query_non_selector and nm_query_non_selector + assert: + that: + - cm_query_non_selector is not changed + - nm_query_non_selector is not changed + - cm_query_non_selector == nm_query_non_selector + - cm_query_non_selector.msg == "Selector 'non_existing_selector' not found" + - nm_query_non_selector.msg == "Selector 'non_existing_selector' not found" + +# QUERY NON-EXISTING EPG +- name: Query non-existing EPG (check_mode) + mso_schema_site_anp_epg_selector: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: 'aws_{{ mso_site | default("ansible_test") }}' + template: Template 1 + anp: ANP + epg: non_existing_epg + selector: site_selector_1 + state: query + check_mode: yes + ignore_errors: yes + register: cm_query_non_epg + +- name: Query non-existing EPG (normal mode) + mso_schema_site_anp_epg_selector: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: 'aws_{{ mso_site | default("ansible_test") }}' + template: Template 1 + anp: ANP + epg: non_existing_epg + selector: site_selector_1 + state: query + ignore_errors: yes + register: nm_query_non_epg + +- name: Verify query_non_epg + 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, ansible_test_2" + +# QUERY NON-EXISTING ANP +- name: Query non-existing ANP (check_mode) + mso_schema_site_anp_epg_selector: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: 'aws_{{ mso_site | default("ansible_test") }}' + template: Template 1 + anp: non_existing_anp + epg: ansible_test_1 + selector: site_selector_1 + state: query + check_mode: yes + ignore_errors: yes + register: cm_query_non_anp + +- name: Query non-existing ANP (normal mode) + mso_schema_site_anp_epg_selector: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: 'aws_{{ mso_site | default("ansible_test") }}' + template: Template 1 + anp: non_existing_anp + epg: ansible_test_1 + selector: site_selector_1 + state: query + ignore_errors: yes + register: nm_query_non_anp + +- name: Verify query_non_anp + 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" + +# USE A NON-EXISTING STATE +- name: Non-existing state (check_mode) + mso_schema_site_anp_epg_selector: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: 'aws_{{ mso_site | default("ansible_test") }}' + template: Template 1 + anp: ANP + epg: ansible_test_1 + selector: site_selector_1 + state: non-existing-state + check_mode: yes + ignore_errors: yes + register: cm_non_existing_state + +- name: Non-existing state (normal_mode) + mso_schema_site_anp_epg_selector: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: 'aws_{{ mso_site | default("ansible_test") }}' + template: Template 1 + anp: ANP + epg: ansible_test_1 + selector: site_selector_1 + state: non-existing-state + ignore_errors: yes + register: nm_non_existing_state + +- name: Verify non_existing_state + assert: + that: + - cm_non_existing_state is not changed + - nm_non_existing_state is not changed + - cm_non_existing_state == nm_non_existing_state + - cm_non_existing_state.msg == 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 (check_mode) + mso_schema_site_anp_epg_selector: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: 'aws_{{ mso_site | default("ansible_test") }}' + template: non-existing-template + anp: ANP + epg: ansible_test_1 + selector: site_selector_1 + state: query + check_mode: yes + ignore_errors: yes + register: cm_non_existing_template + +- name: Non-existing template (normal_mode) + mso_schema_site_anp_epg_selector: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: 'aws_{{ mso_site | default("ansible_test") }}' + template: non-existing-template + anp: ANP + epg: ansible_test_1 + selector: site_selector_1 + state: query + ignore_errors: yes + register: nm_non_existing_template + +- name: Verify non_existing_template + 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, Template3" + +# USE A NON-EXISTING SCHEMA +- name: Non-existing schema (check_mode) + mso_schema_site_anp_epg_selector: + <<: *mso_info + schema: non-existing-schema + site: 'aws_{{ mso_site | default("ansible_test") }}' + template: Template 1 + anp: ANP + epg: ansible_test_1 + selector: site_selector_1 + state: query + check_mode: yes + ignore_errors: yes + register: cm_non_existing_schema + +- name: Non-existing schema (normal_mode) + mso_schema_site_anp_epg_selector: + <<: *mso_info + schema: non-existing-schema + site: 'aws_{{ mso_site | default("ansible_test") }}' + template: Template 1 + anp: ANP + epg: ansible_test_1 + selector: site_selector_1 + state: query + ignore_errors: yes + register: nm_non_existing_schema + +- name: Verify non_existing_schema + assert: + that: + - cm_non_existing_schema is not changed + - nm_non_existing_schema is not changed + - cm_non_existing_schema == nm_non_existing_schema + - cm_non_existing_schema.msg == nm_non_existing_schema.msg == "Provided schema 'non-existing-schema' does not exist" + +# USE A NON-EXISTING SITE +- name: Non-existing site (check_mode) + mso_schema_site_anp_epg_selector: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: non-existing-site + template: Template 1 + anp: ANP + epg: ansible_test_1 + selector: site_selector_1 + state: query + check_mode: yes + ignore_errors: yes + register: cm_non_existing_site + +- name: Non-existing site (normal_mode) + mso_schema_site_anp_epg_selector: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: non-existing-site + template: Template 1 + anp: ANP + epg: ansible_test_1 + selector: site_selector_1 + state: query + ignore_errors: yes + register: nm_non_existing_site + +- name: Verify non_existing_site + 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 == 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 (check_mode) + mso_schema_site_anp_epg_selector: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: 'aws_{{ mso_site | default("ansible_test") }}' + template: Template 3 + anp: ANP + epg: ansible_test_1 + selector: site_selector_1 + state: query + check_mode: yes + ignore_errors: yes + register: cm_non_existing_site_template + +- name: Non-existing site-template (normal_mode) + mso_schema_site_anp_epg_selector: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: 'aws_{{ mso_site | default("ansible_test") }}' + template: Template 3 + anp: ANP + epg: ansible_test_1 + selector: site_selector_1 + state: query + ignore_errors: yes + register: nm_non_existing_site_template + +- name: Verify non_existing_site_template + assert: + that: + - cm_non_existing_site_template is not changed + - nm_non_existing_site_template is not changed + - cm_non_existing_site_template == nm_non_existing_site_template + - 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: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: 'aws_{{ mso_site | default("ansible_test") }}' + template: Template 1 + anp: ANP + epg: ansible_test_1 + selector: site_selector_4 + expressions: + - type: ip_address + operator: has_key + state: present + ignore_errors: yes + register: nm_add_site_selector_4 + +- name: Verify nm_add_site_selector_4 + 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: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: 'aws_{{ mso_site | default("ansible_test") }}' + template: Template 1 + anp: ANP + epg: ansible_test_1 + selector: site_selector_4 + expressions: + - type: ip_address + operator: in + value: test + state: present + register: nm_add_site_selector_4_again + +- name: Verify nm_add_site_selector_4 + 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: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: 'azure_{{ mso_site | default("ansible_test") }}' + template: Template 1 + anp: ANP + epg: ansible_test_1 + selector: site_selector_1 + expressions: + - type: zone + operator: in + value: test + state: present + ignore_errors: yes + register: nm_add_azure_site_selector_1 + +- name: Verify nm_add_azure_site_selector_1 + 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: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}_2' + site: 'azure_{{ mso_site | default("ansible_test") }}' + template: Template 3 + anp: ANP + epg: ansible_test_1 + selector: site_selector_1 + expressions: + - type: zone + operator: in + value: test + state: present + ignore_errors: yes + check_mode: yes + 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: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}_2' + site: 'azure_{{ mso_site | default("ansible_test") }}' + template: Template 3 + anp: ANP + epg: ansible_test_1 + selector: site_selector_1 + expressions: + - type: zone + operator: in + value: test + state: present + ignore_errors: yes + register: nm_no_site_associated + +- name: Verify cm_no_site_associated and nm_no_site_associated + 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 diff --git a/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_anp_epg_staticport/aliases b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_anp_epg_staticport/aliases new file mode 100644 index 00000000..5042c9c0 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_anp_epg_staticport/aliases @@ -0,0 +1,2 @@ +# No ACI MultiSite infrastructure, so not enabled +# unsupported diff --git a/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_anp_epg_staticport/tasks/main.yml b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_anp_epg_staticport/tasks/main.yml new file mode 100644 index 00000000..998b3b7f --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_anp_epg_staticport/tasks/main.yml @@ -0,0 +1,859 @@ +# Test code for the MSO modules +# Copyright: (c) 2020, Lionel Hercot (@lhercot) +# Copyright: (c) 2018, Dag Wieers (@dagwieers) (based on mso_site test case) +# Copyright: (c) 2020, Shreyas Srish (@shrsr) + +# 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.' + 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: + 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(true) }}' + output_level: '{{ mso_output_level | default("info") }}' + +- name: Remove Schemas + mso_schema: + <<: *mso_info + schema: '{{ item }}' + state: absent + loop: + - '{{ mso_schema | default("ansible_test") }}_2' + - '{{ mso_schema | default("ansible_test") }}' + +- name: Ensure site exists + 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 + +- name: Ensure tenant ansible_test exist + mso_tenant: + <<: *mso_info + tenant: ansible_test + users: + - '{{ mso_username }}' + sites: + - '{{ mso_site | default("ansible_test") }}' + state: present + +- name: Ensure schema 1 with Template 1 and 2 exists + mso_schema_template: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + tenant: ansible_test + template: '{{ item }}' + state: present + loop: + - Template 1 + - Template 2 + +- name: Ensure schema 2 with Template 3 exists + mso_schema_template: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}_2' + tenant: ansible_test + template: Template 3 + state: present + +- name: Add a new site to a schema + mso_schema_site: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: '{{ mso_site | default("ansible_test") }}' + template: Template 1 + state: present + +- name: Ensure VRF1 exists + mso_schema_template_vrf: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + vrf: VRF1 + state: present + +- name: Add BD1 + mso_schema_template_bd: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + bd: BD1 + vrf: + name: VRF1 + state: present + +- name: Ensure Template 1 with AP1 exists + mso_schema_template_anp: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + anp: AP1 + state: present + +- name: Ensure Template 1 and AP1 with EPG1 exists + mso_schema_template_anp_epg: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + anp: AP1 + epg: EPG1 + bd: + name: BD1 + vrf: + name: VRF1 + state: present + +- name: Ensure Template 1 and AP1 with EPG3 exists + mso_schema_template_anp_epg: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + anp: AP1 + epg: EPG3 + bd: + name: BD1 + vrf: + name: VRF1 + state: present + +- name: Ensure Template 1 with AP2 exists + mso_schema_template_anp: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + anp: AP2 + state: present + +- name: Ensure Template 1 and AP2 with EPG2 exists + mso_schema_template_anp_epg: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + anp: AP2 + epg: EPG2 + bd: + name: BD1 + vrf: + name: VRF1 + state: present + +- name: Ensure Template 1 and AP2 with EPG4 exists + mso_schema_template_anp_epg: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + anp: AP2 + epg: EPG4 + bd: + name: BD1 + vrf: + name: VRF1 + state: present + +- name: Ensure Template 1 and AP2 with EPG6 exists + mso_schema_template_anp_epg: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + anp: AP2 + epg: EPG6 + bd: + name: BD1 + vrf: + name: VRF1 + state: present + +# ADD STATIC PORTS +- name: Add static port 1 to site EPG1 of AP1 (check mode) + mso_schema_site_anp_epg_staticport: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: '{{ mso_site | default("ansible_test") }}' + template: Template 1 + anp: AP1 + epg: EPG1 + pod: pod-1 + leaf: 101 + path: eth1/1 + vlan: 126 + mode: 'native' + type: port + deployment_immediacy: immediate + state: present + check_mode: yes + register: cm_add_stat1e1 + +- name: Verify cm_add_stat1e1 + assert: + that: + - cm_add_stat1e1 is changed + - cm_add_stat1e1.previous == {} + - cm_add_stat1e1.current.deploymentImmediacy == 'immediate' + - cm_add_stat1e1.current.portEncapVlan == 126 + - cm_add_stat1e1.current.path == 'topology/pod-1/paths-101/pathep-[eth1/1]' + - cm_add_stat1e1.current.mode == 'native' + - cm_add_stat1e1.current.type == 'port' + +- name: Add static port 1 to site EPG1 of AP1 (normal mode) + mso_schema_site_anp_epg_staticport: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: '{{ mso_site | default("ansible_test") }}' + template: Template 1 + anp: AP1 + epg: EPG1 + pod: pod-1 + leaf: 101 + path: eth1/1 + vlan: 126 + mode: 'native' + deployment_immediacy: immediate + state: present + register: nm_add_stat1e1 + +- name: Verify nm_add_stat1e1 + assert: + that: + - nm_add_stat1e1 is changed + - nm_add_stat1e1.previous == {} + - nm_add_stat1e1.current.deploymentImmediacy == 'immediate' + - nm_add_stat1e1.current.portEncapVlan == 126 + - nm_add_stat1e1.current.path == 'topology/pod-1/paths-101/pathep-[eth1/1]' + - nm_add_stat1e1.current.mode == 'native' + - nm_add_stat1e1.current.type == 'port' + +- name: Add static port 2 to site EPG1 of AP1 (normal mode) + mso_schema_site_anp_epg_staticport: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: '{{ mso_site | default("ansible_test") }}' + template: Template 1 + anp: AP1 + epg: EPG1 + pod: pod-2 + leaf: 102 + path: eth1/2 + vlan: 100 + mode: 'regular' + type: port + primary_micro_segment_vlan: 199 + deployment_immediacy: immediate + state: present + register: nm_add_stat2e1 + +- name: Verify nm_add_stat2e1 + assert: + that: + - nm_add_stat2e1 is changed + - nm_add_stat2e1.previous == {} + - nm_add_stat2e1.current.deploymentImmediacy == 'immediate' + - nm_add_stat2e1.current.portEncapVlan == 100 + - nm_add_stat2e1.current.path == 'topology/pod-2/paths-102/pathep-[eth1/2]' + - nm_add_stat2e1.current.mode == 'regular' + - nm_add_stat2e1.current.type == 'port' + + +- name: Add static port 3 (vpc) to site EPG1 of AP1 (normal mode) + mso_schema_site_anp_epg_staticport: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: '{{ mso_site | default("ansible_test") }}' + template: Template 1 + anp: AP1 + epg: EPG1 + pod: pod-3 + leaf: 103-104 + path: ansible_polgrp + vlan: 101 + type: vpc + mode: untagged + deployment_immediacy: lazy + state: present + register: nm_add_stat3e1 + +- name: Verify nm_add_stat3e1 + assert: + that: + - nm_add_stat3e1 is changed + - nm_add_stat3e1.previous == {} + - nm_add_stat3e1.current.deploymentImmediacy == 'lazy' + - nm_add_stat3e1.current.portEncapVlan == 101 + - nm_add_stat3e1.current.path == 'topology/pod-3/protpaths-103-104/pathep-[ansible_polgrp]' + - nm_add_stat3e1.current.mode == 'untagged' + - nm_add_stat3e1.current.type == 'vpc' + +- name: Add static port 1 to site EPG3 of AP1 (normal mode) + mso_schema_site_anp_epg_staticport: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: '{{ mso_site | default("ansible_test") }}' + template: Template 1 + anp: AP1 + epg: EPG3 + pod: pod-1 + leaf: 101 + path: eth1/1 + vlan: 126 + mode: 'native' + type: port + deployment_immediacy: immediate + state: present + register: nm_add_stat1e3 + +- name: Verify nm_add_stat1e3 + assert: + that: + - nm_add_stat1e3 is changed + - nm_add_stat1e3.previous == {} + - nm_add_stat1e3.current.deploymentImmediacy == 'immediate' + - nm_add_stat1e3.current.portEncapVlan == 126 + - nm_add_stat1e3.current.path == 'topology/pod-1/paths-101/pathep-[eth1/1]' + - nm_add_stat1e3.current.mode == 'native' + - nm_add_stat1e3.current.type == 'port' + +- name: Add static port 2 (dpc) to EPG6 of AP2 (normal mode) + mso_schema_site_anp_epg_staticport: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: '{{ mso_site | default("ansible_test") }}' + template: Template 1 + anp: AP2 + epg: EPG6 + pod: pod-2 + leaf: 102 + path: eth1/2 + vlan: 100 + deployment_immediacy: lazy + mode: regular + type: dpc + primary_micro_segment_vlan: 199 + state: present + register: nm_add_stat2e6 + +- name: Verify nm_add_stat2e6 + assert: + that: + - nm_add_stat2e6 is changed + - nm_add_stat2e6.previous == {} + - nm_add_stat2e6.current.deploymentImmediacy == 'lazy' + - nm_add_stat2e6.current.portEncapVlan == 100 + - nm_add_stat2e6.current.microSegVlan == 199 + - nm_add_stat2e6.current.path == 'topology/pod-2/paths-102/pathep-[eth1/2]' + - nm_add_stat2e6.current.mode == 'regular' + - nm_add_stat2e6.current.type == 'dpc' + +# QUERY STATIC PORTS +- name: Query STATIC PORTS of site EPG1 with AP1 (normal mode) + mso_schema_site_anp_epg_staticport: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: '{{ mso_site | default("ansible_test") }}' + template: Template 1 + anp: AP1 + epg: EPG1 + state: query + register: nm_query_statse1 + +- name: Verify nm_query_statse1 + 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: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: '{{ mso_site | default("ansible_test") }}' + template: Template 1 + anp: AP1 + epg: EPG1 + pod: pod-3 + leaf: 103-104 + path: ansible_polgrp + vlan: 101 + mode: untagged + type: vpc + deployment_immediacy: immediate + state: query + register: nm_query_stat3e1 + +- name: Verify nm_query_stat3e1 + 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: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: '{{ mso_site | default("ansible_test") }}' + template: Template 1 + anp: AP2 + epg: EPG2 + pod: pod-2 + leaf: 102 + path: eth1/2 + vlan: 100 + mode: regular + type: port + deployment_immediacy: immediate + state: present + register: nm_add_stat2e2 + +- name: Verify nm_add_stat2e2 + assert: + that: + - nm_add_stat2e2 is changed + - nm_add_stat2e2.previous == {} + - nm_add_stat2e2.current.deploymentImmediacy == 'immediate' + - nm_add_stat2e2.current.portEncapVlan == 100 + - nm_add_stat2e2.current.path == 'topology/pod-2/paths-102/pathep-[eth1/2]' + - nm_add_stat2e2.current.mode == 'regular' + - nm_add_stat2e2.current.type == 'port' + +- name: Remove static port 2 from EPG2 (normal mode) + mso_schema_site_anp_epg_staticport: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: '{{ mso_site | default("ansible_test") }}' + template: Template 1 + anp: AP2 + epg: EPG2 + pod: pod-2 + leaf: 102 + path: eth1/2 + vlan: 100 + mode: regular + type: port + deployment_immediacy: immediate + state: absent + register: nm_remove_stat2e2 + +- name: Verify nm_remove_stat2e2 + assert: + that: + - nm_remove_stat2e2 is changed + +- name: Query removed static port 2 from EPG2 (normal mode) + mso_schema_site_anp_epg_staticport: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: '{{ mso_site | default("ansible_test") }}' + template: Template 1 + anp: AP2 + epg: EPG2 + pod: pod-2 + leaf: 102 + path: eth1/2 + vlan: 100 + mode: regular + type: port + deployment_immediacy: immediate + state: query + ignore_errors: yes + register: nm_non_existent_dom2e2 + +- name: Verify non_existing_domain + 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" + +- name: Remove static port 2 from EPG2 again(normal mode) + mso_schema_site_anp_epg_staticport: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: '{{ mso_site | default("ansible_test") }}' + template: Template 1 + anp: AP2 + epg: EPG2 + pod: pod-2 + leaf: 101 + path: eth1/2 + vlan: 100 + mode: regular + type: port + deployment_immediacy: immediate + state: absent + ignore_errors: yes + register: nm_remove_again_stat2e2 + +- name: Verify nm_remove_again_stat2e2 + 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: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: '{{ mso_site | default("ansible_test") }}' + template: Template 1 + anp: AP1 + epg: EPG1 + pod: pod-1 + leaf: 101 + path: eth1/1 + vlan: 126 + mode: 'native' + type: port + deployment_immediacy: immediate + state: present + register: nm_add_stat1e1_2 + +- name: Verify nm_add_stat1e1_2 + 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: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: '{{ mso_site | default("ansible_test") }}' + template: Template 1 + anp: AP1 + epg: EPG1 + pod: pod-1 + leaf: 101 + path: eth1/1 + vlan: 126 + mode: native + type: port + deployment_immediacy: immediate + ignore_errors: yes + register: nm_add_stateless_stat1e1_2 + +- name: Verify nm_add_stateless_stat1e1_2 + 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: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: '{{ mso_site | default("ansible_test") }}' + template: Template 1 + anp: AP1 + epg: EPG1 + pod: pod-4 + leaf: 101 + path: eth1/1 + vlan: 126 + fex: 151 + type: port + mode: native + deployment_immediacy: lazy + state: present + register: nm_add_statfex + +- name: Verify nm_add_statfex + assert: + that: + - nm_add_statfex is changed + - nm_add_statfex.previous == {} + - nm_add_statfex.current.deploymentImmediacy == 'lazy' + - nm_add_statfex.current.portEncapVlan == 126 + - nm_add_statfex.current.path == 'topology/pod-4/paths-101/extpaths-151/pathep-[eth1/1]' + - nm_add_statfex.current.mode == 'native' + - nm_add_statfex.current.type == 'port' + +# 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: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: '{{ mso_site | default("ansible_test") }}' + template: Template 1 + anp: AP2 + epg: EPG4 + pod: pod-4 + leaf: 101 + path: eth1/1 + vlan: 126 + type: port + mode: native + state: present + register: nm_add_stat_di + +- name: Verify nm_add_stat_di + 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: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: '{{ mso_site | default("ansible_test") }}' + template: Template 1 + anp: AP2 + epg: EPG4 + pod: pod-4 + leaf: 101 + path: eth1/1 + vlan: 126 + type: port + deployment_immediacy: lazy + state: present + register: nm_add_stat_mode + +- name: Verify nm_add_stat_mode + 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: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: '{{ mso_site | default("ansible_test") }}' + template: Template 1 + anp: AP5 + epg: EPG5 + pod: pod-1 + leaf: 101 + path: eth1/1 + vlan: 126 + mode: native + type: port + deployment_immediacy: immediate + state: present + ignore_errors: yes + register: nm_add_stat1e5 + +- name: Verify nm_add_stat1e5 + 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: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: '{{ mso_site | default("ansible_test") }}' + template: Template 1 + anp: AP1 + epg: EPG6 + pod: pod-1 + leaf: 101 + path: eth1/1 + vlan: 126 + mode: native + deployment_immediacy: immediate + state: present + ignore_errors: yes + register: nm_add_stat1e6 + +- name: Verify nm_add_stat1e6 + 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: + <<: *mso_info + schema: non_existing_schema + site: '{{ mso_site | default("ansible_test") }}' + template: Template 1 + anp: AP1 + epg: EPG1 + pod: pod-1 + leaf: 101 + path: eth1/1 + vlan: 126 + mode: native + type: port + deployment_immediacy: immediate + check_mode: yes + ignore_errors: yes + register: cm_non_existing_schema + +- name: Non-existing schema for static port (normal_mode) + mso_schema_site_anp_epg_staticport: + <<: *mso_info + schema: non_existing_schema + site: '{{ mso_site | default("ansible_test") }}' + template: Template 1 + anp: AP1 + epg: EPG1 + pod: pod-1 + leaf: 101 + path: eth1/1 + vlan: 126 + type: port + mode: native + deployment_immediacy: immediate + ignore_errors: yes + register: nm_non_existing_schema + +- name: Verify non_existing_schema + assert: + that: + - cm_non_existing_schema is not changed + - nm_non_existing_schema is not changed + - cm_non_existing_schema == nm_non_existing_schema + - cm_non_existing_schema.msg == 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 (check_mode) + mso_schema_site_anp_epg_staticport: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: '{{ mso_site | default("ansible_test") }}' + template: non_existing_template + anp: AP1 + epg: EPG1 + pod: pod-1 + leaf: 101 + path: eth1/1 + vlan: 126 + type: port + mode: native + deployment_immediacy: immediate + check_mode: yes + ignore_errors: yes + register: cm_non_existing_template + +- name: Non-existing template for static port (normal_mode) + mso_schema_site_anp_epg_staticport: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: '{{ mso_site | default("ansible_test") }}' + template: non_existing_template + anp: AP1 + epg: EPG1 + pod: pod-1 + leaf: 101 + path: eth1/1 + vlan: 126 + type: port + mode: native + deployment_immediacy: immediate + ignore_errors: yes + register: nm_non_existing_template + +- name: Verify non_existing_template + 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" + +# USE A NON-EXISTING SITE +- name: Non-existing site for static port (check_mode) + mso_schema_site_anp_epg_staticport: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: '{{ mso_site | default("ansible_test") }}' + template: Template 2 + anp: AP1 + epg: EPG1 + pod: pod-1 + leaf: 101 + path: eth1/1 + vlan: 126 + type: port + mode: native + deployment_immediacy: immediate + check_mode: yes + ignore_errors: yes + register: cm_non_existing_site + +- name: Non-existing site for static port (normal_mode) + mso_schema_site_anp_epg_staticport: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: '{{ mso_site | default("ansible_test") }}' + template: Template 2 + anp: AP1 + epg: EPG1 + pod: pod-1 + leaf: 101 + path: eth1/1 + vlan: 126 + type: port + mode: native + deployment_immediacy: immediate + ignore_errors: yes + register: nm_non_existing_site + +- name: Verify non_existing_site + 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") + +# 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: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}_2' + site: '{{ mso_site | default("ansible_test") }}' + template: Template 3 + anp: AP1 + epg: EPG1 + pod: pod-1 + leaf: 101 + path: eth1/1 + vlan: 126 + type: port + mode: native + deployment_immediacy: immediate + ignore_errors: yes + check_mode: yes + 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: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}_2' + site: '{{ mso_site | default("ansible_test") }}' + template: Template 3 + anp: AP1 + epg: EPG1 + pod: pod-1 + leaf: 101 + path: eth1/1 + vlan: 126 + type: port + mode: native + deployment_immediacy: immediate + ignore_errors: yes + register: nm_no_site_associated + +- name: Verify cm_no_site_associated and nm_no_site_associated + 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 diff --git a/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_bd/aliases b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_bd/aliases new file mode 100644 index 00000000..5042c9c0 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_bd/aliases @@ -0,0 +1,2 @@ +# No ACI MultiSite infrastructure, so not enabled +# unsupported diff --git a/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_bd/tasks/main.yml b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_bd/tasks/main.yml new file mode 100644 index 00000000..7fc18575 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_bd/tasks/main.yml @@ -0,0 +1,704 @@ +# Test code for the MSO modules +# Copyright: (c) 2020, Lionel Hercot (@lhercot) +# Copyright: (c) 2018, Dag Wieers (@dagwieers) (based on mso_site test case) +# Copyright: (c) 2020, Shreyas Srish (@shrsr) +# Copyright: (c) 2020, Cindy Zhao (@cizhao) + +# 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.' + 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: + 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(true) }}' + output_level: '{{ mso_output_level | default("info") }}' + +- name: Ensure site exists + 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: yes + +- name: Remove schemas + mso_schema: + <<: *mso_info + schema: '{{ item }}' + state: absent + loop: + - '{{ mso_schema | default("ansible_test") }}_2' + - '{{ mso_schema | default("ansible_test") }}' + +- name: Ensure tenant ansible_test exists + mso_tenant: + <<: *mso_info + tenant: ansible_test + users: + - '{{ mso_username }}' + sites: + - '{{ mso_site | default("ansible_test") }}' + state: present + +- name: Ensure schema 1 with Template 1, and Template 2, Template 3 exist + mso_schema_template: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + tenant: ansible_test + template: '{{item.template}}' + state: present + loop: + - { template: Template 1} + - { template: Template 2} + - { template: Template 3} + +- name: Ensure schema 2 with Template 3 exist + mso_schema_template: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}_2' + tenant: ansible_test + template: Template 3 + state: present + +- name: Add physical site to a schema + mso_schema_site: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: '{{ mso_site | default("ansible_test") }}' + template: '{{item.template}}' + state: present + loop: + - { template: Template 1} + - { template: Template 2} + +- name: Ensure VRF1 exists + mso_schema_template_vrf: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + vrf: VRF1 + layer3_multicast: true + state: present + +- name: Ensure ansible_test_1 BD does not exist + mso_schema_template_bd: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + bd: ansible_test_1 + vrf: + name: VRF1 + state: absent + +- name: Add template BD + mso_schema_template_bd: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + bd: ansible_test_1 + vrf: + name: VRF1 + state: present + register: nm_add_bd + +- name: Verify nm_add_bd + assert: + that: + - nm_add_bd is changed + - nm_add_bd.previous == {} + - nm_add_bd.current.name == "ansible_test_1" + - nm_add_bd.current.vrfRef.templateName == "Template1" + - nm_add_bd.current.vrfRef.vrfName == "VRF1" + +- name: Add template BD 2 + mso_schema_template_bd: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 2 + bd: ansible_test_2 + vrf: + name: VRF1 + template: Template 1 + state: present + register: nm_add_bd_2 + +- name: Verify nm_add_bd_2 + assert: + that: + - nm_add_bd_2 is changed + - nm_add_bd_2.previous == {} + - nm_add_bd_2.current.name == "ansible_test_2" + - nm_add_bd_2.current.vrfRef.templateName == "Template1" + - nm_add_bd_2.current.vrfRef.vrfName == "VRF1" + +- name: Add template BD 3 + mso_schema_template_bd: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + bd: ansible_test_3 + vrf: + name: VRF1 + template: Template 1 + state: present + register: nm_add_bd_3 + +- name: Verify nm_add_bd_3 + assert: + that: + - nm_add_bd_3 is changed + - nm_add_bd_3.previous == {} + - nm_add_bd_3.current.name == "ansible_test_3" + - nm_add_bd_3.current.vrfRef.templateName == "Template1" + - nm_add_bd_3.current.vrfRef.vrfName == "VRF1" + +- name: Add template BD 4 + mso_schema_template_bd: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + bd: ansible_test_4 + vrf: + name: VRF1 + template: Template 1 + state: present + register: nm_add_bd_4 + +- name: Verify nm_add_bd_4 + assert: + that: + - nm_add_bd_4 is changed + - nm_add_bd_4.previous == {} + - nm_add_bd_4.current.name == "ansible_test_4" + - nm_add_bd_4.current.vrfRef.templateName == "Template1" + - nm_add_bd_4.current.vrfRef.vrfName == "VRF1" + +- name: Add site BD (check_mode) + mso_schema_site_bd: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: '{{ mso_site | default("ansible_test") }}' + template: Template 1 + bd: ansible_test_1 + state: present + check_mode: yes + register: cm_add_site_bd + +- name: Verify cm_add_site_bd + assert: + that: + - cm_add_site_bd is changed + - cm_add_site_bd.previous == {} + - 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: Add site BD (normal_mode) + mso_schema_site_bd: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: '{{ mso_site | default("ansible_test") }}' + template: Template 1 + bd: ansible_test_1 + state: present + register: nm_add_site_bd + +- name: Verify nm_add_site_bd + assert: + that: + - nm_add_site_bd is changed + - nm_add_site_bd.previous == {} + - 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 + - cm_add_site_bd.current.bdRef.schemaId == nm_add_site_bd.current.bdRef.schemaId + +- name: Add site BD again (check_mode) + mso_schema_site_bd: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: '{{ mso_site | default("ansible_test") }}' + template: Template 1 + bd: ansible_test_1 + state: present + check_mode: yes + register: cm_add_site_bd_again + +- name: Add site BD again (normal_mode) + mso_schema_site_bd: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: '{{ mso_site | default("ansible_test") }}' + template: Template 1 + bd: ansible_test_1 + state: present + register: nm_add_site_bd_again + +- name: Verify cm_add_site_bd_again and nm_add_site_bd_again + 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: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: '{{ mso_site | default("ansible_test") }}' + template: Template 1 + bd: ansible_test_1 + host_route: true + state: present + check_mode: yes + register: cm_change_site_bd + +- name: Change site BD (normal_mode) + mso_schema_site_bd: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: '{{ mso_site | default("ansible_test") }}' + template: Template 1 + bd: ansible_test_1 + host_route: true + state: present + register: nm_change_site_bd + +- name: Verify cm_change_site_bd and nm_change_site_bd + assert: + that: + - cm_change_site_bd is changed + - nm_change_site_bd is changed + - cm_change_site_bd.previous.bdRef == cm_change_site_bd.current.bdRef + - nm_change_site_bd.previous.bdRef == nm_change_site_bd.current.bdRef + - cm_change_site_bd.previous.hostBasedRouting == false + - cm_change_site_bd.current.hostBasedRouting == true + - nm_change_site_bd.previous.hostBasedRouting == false + - nm_change_site_bd.current.hostBasedRouting == true + +- name: Add site BD with host_route (check_mode) + mso_schema_site_bd: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: '{{ mso_site | default("ansible_test") }}' + template: Template 2 + bd: ansible_test_2 + host_route: true + state: present + check_mode: yes + register: cm_add_site_bd_with_host_route + +- name: Add site BD with host_route (normal_mode) + mso_schema_site_bd: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: '{{ mso_site | default("ansible_test") }}' + template: Template 2 + bd: ansible_test_2 + host_route: true + state: present + 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: + that: + - cm_add_site_bd_with_host_route is changed + - nm_add_site_bd_with_host_route is changed + - cm_add_site_bd_with_host_route.previous == {} + - nm_add_site_bd_with_host_route.previous == {} + - cm_add_site_bd_with_host_route.current.hostBasedRouting == true + - nm_add_site_bd_with_host_route.current.hostBasedRouting == true + +- name: Add site BD 3 (normal_mode) + mso_schema_site_bd: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: '{{ mso_site | default("ansible_test") }}' + template: Template 1 + bd: ansible_test_3 + host_route: true + state: present + register: nm_add_site_bd_3 + +- name: Verify nm_add_site_bd_3 + assert: + that: + - nm_add_site_bd_3 is changed + - nm_add_site_bd_3.previous == {} + - nm_add_site_bd_3.current.hostBasedRouting == true + - nm_add_site_bd_3.current.bdRef.bdName == "ansible_test_3" + - nm_add_site_bd_3.current.bdRef.templateName == "Template1" + +- name: Add site BD 4 (normal_mode) + mso_schema_site_bd: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: '{{ mso_site | default("ansible_test") }}' + template: Template 1 + bd: ansible_test_4 + svi_mac: 00:22:23:F1:21:F9 + state: present + register: nm_add_site_bd_4 + +- name: Verify nm_add_site_bd_4 + assert: + that: + - nm_add_site_bd_4 is changed + - nm_add_site_bd_4.previous == {} + - nm_add_site_bd_4.current.mac == "00:22:23:F1:21:F9" + - nm_add_site_bd_4.current.bdRef.bdName == "ansible_test_4" + - nm_add_site_bd_4.current.bdRef.templateName == "Template1" + +- name: Query a specific BD (check_mode) + mso_schema_site_bd: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: '{{ mso_site | default("ansible_test") }}' + template: Template 2 + bd: ansible_test_2 + state: query + check_mode: yes + register: cm_query_bd_2 + +- name: Query a specific BD (normal_mode) + mso_schema_site_bd: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: '{{ mso_site | default("ansible_test") }}' + template: Template 2 + bd: ansible_test_2 + state: query + register: nm_query_bd_2 + +- name: Verify cm_query_bd_2 and nm_query_bd_2 + assert: + that: + - cm_query_bd_2 is not changed + - nm_query_bd_2 is not changed + - cm_query_bd_2.current.bdRef.bdName == "ansible_test_2" == nm_query_bd_2.current.bdRef.bdName + - cm_query_bd_2.current.bdRef.schemaId == nm_query_bd_2.current.bdRef.schemaId + - cm_query_bd_2.current.bdRef.templateName == nm_query_bd_2.current.bdRef.templateName == "Template2" + - cm_query_bd_2.current.hostBasedRouting == nm_query_bd_2.current.hostBasedRouting == true + +- name: Query all BDs (check_mode) + mso_schema_site_bd: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: '{{ mso_site | default("ansible_test") }}' + template: Template 1 + state: query + check_mode: yes + register: cm_query_all_bd + +- name: Query all BDs (normal_mode) + mso_schema_site_bd: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: '{{ mso_site | default("ansible_test") }}' + template: Template 1 + state: query + register: nm_query_all_bd + +- name: Verify cm_query_all_bd and cm_query_all_bd + assert: + that: + - cm_query_all_bd is not changed + - nm_query_all_bd is not changed + - cm_query_all_bd.current[0].bdRef.bdName == nm_query_all_bd.current[0].bdRef.bdName == "ansible_test_1" + - cm_query_all_bd.current[0].bdRef.schemaId == nm_query_all_bd.current[0].bdRef.schemaId + - cm_query_all_bd.current[0].bdRef.templateName == nm_query_all_bd.current[0].bdRef.templateName == "Template1" + - cm_query_all_bd.current[1].bdRef.bdName == nm_query_all_bd.current[1].bdRef.bdName == "ansible_test_3" + - cm_query_all_bd.current[1].bdRef.schemaId == nm_query_all_bd.current[1].bdRef.schemaId + - 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: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: '{{ mso_site | default("ansible_test") }}' + template: Template 2 + bd: ansible_test_2 + state: absent + check_mode: yes + register: cm_remove_site_bd_2 + +- name: Remove BD 2 (normal_mode) + mso_schema_site_bd: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: '{{ mso_site | default("ansible_test") }}' + template: Template 2 + bd: ansible_test_2 + state: absent + register: nm_remove_site_bd_2 + +- name: Verify cm_remove_site_bd_2 and nm_remove_site_bd_2 + assert: + that: + - cm_remove_site_bd_2 is changed + - nm_remove_site_bd_2 is changed + - cm_remove_site_bd_2.previous.bdRef.bdName == nm_remove_site_bd_2.previous.bdRef.bdName == "ansible_test_2" + - cm_remove_site_bd_2.previous.bdRef.schemaId == nm_remove_site_bd_2.previous.bdRef.schemaId + - cm_remove_site_bd_2.previous.bdRef.templateName == nm_remove_site_bd_2.previous.bdRef.templateName == "Template2" + - cm_remove_site_bd_2.current == nm_remove_site_bd_2.current == {} + +- name: Remove BD 2 again(normal_mode) + mso_schema_site_bd: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: '{{ mso_site | default("ansible_test") }}' + template: Template 2 + bd: ansible_test_2 + state: absent + register: nm_remove_site_bd_2_again + +- name: Verify nm_remove_site_bd_2_again + 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 == {} + +- name: Query site without BD (normal_mode) + mso_schema_site_bd: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: '{{ mso_site | default("ansible_test") }}' + template: Template 2 + state: query + register: nm_query_without_bd + +- name: Verify nm_query_without_bd + assert: + that: + - nm_query_without_bd is not changed + - nm_query_without_bd.current == [] + +# QUERY NON-EXISTING BD +- name: Query non-existing BD (check_mode) + mso_schema_site_bd: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: '{{ mso_site | default("ansible_test") }}' + template: Template 1 + bd: non_existing_bd + state: query + check_mode: yes + ignore_errors: yes + register: cm_query_non_bd + +- name: Query non-existing BD (normal_mode) + mso_schema_site_bd: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: '{{ mso_site | default("ansible_test") }}' + template: Template 1 + bd: non_existing_bd + state: query + ignore_errors: yes + register: nm_query_non_bd + +- name: Verify cm_query_non_bd and nm_query_non_bd + assert: + that: + - cm_query_non_bd is not changed + - nm_query_non_bd is not changed + - cm_query_non_bd.msg == nm_query_non_bd.msg == "BD 'non_existing_bd' not found" + +# USE NON-EXISTING STATE +- name: non_existing_state state (check_mode) + mso_schema_site_bd: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: '{{ mso_site | default("ansible_test") }}' + template: Template 1 + bd: ansible_test_1 + state: non_existing_state + ignore_errors: yes + register: cm_non_existing_state + +- name: non_existing_state state (normal_mode) + mso_schema_site_bd: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: '{{ mso_site | default("ansible_test") }}' + template: Template 1 + bd: ansible_test_1 + state: non_existing_state + ignore_errors: yes + register: nm_non_existing_state + +- name: Verify cm_non_existing_state and nm_non_existing_state + assert: + that: + - cm_non_existing_state is not changed + - nm_non_existing_state is not changed + - cm_non_existing_state.msg == 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 (check_mode) + mso_schema_site_bd: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: '{{ mso_site | default("ansible_test") }}' + template: non_existing_template + bd: ansible_test_1 + state: query + check_mode: yes + ignore_errors: yes + register: cm_non_existing_template + +- name: non_existing_template (normal_mode) + mso_schema_site_bd: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: '{{ mso_site | default("ansible_test") }}' + template: non_existing_template + bd: ansible_test_1 + state: query + ignore_errors: yes + register: nm_non_existing_template + +- name: Verify cm_non_existing_template and nm_non_existing_template + 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' does not exist. Existing templates{{':'}} Template1, Template2, Template3" + +# USE A NON_EXISTING_SCHEMA +- name: non_existing_schema (check_mode) + mso_schema_site_bd: + <<: *mso_info + schema: non_existing_schema + site: '{{ mso_site | default("ansible_test") }}' + template: Template 1 + bd: ansible_test_1 + state: query + check_mode: yes + ignore_errors: yes + register: cm_non_existing_schema + +- name: non_existing_schema (normal_mode) + mso_schema_site_bd: + <<: *mso_info + schema: non_existing_schema + site: '{{ mso_site | default("ansible_test") }}' + template: Template 1 + bd: ansible_test_1 + state: query + ignore_errors: yes + register: nm_non_existing_schema + +- name: Verify cm_non_existing_schema and nm_non_existing_schema + assert: + that: + - cm_non_existing_schema is not changed + - nm_non_existing_schema is not changed + - cm_non_existing_schema.msg == nm_non_existing_schema.msg == "Provided schema 'non_existing_schema' does not exist" + +# USE A NON_EXISTING_SITE +- name: non_existing_site (check_mode) + mso_schema_site_bd: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: non_existing_site + template: Template 1 + bd: ansible_test_1 + state: query + check_mode: yes + ignore_errors: yes + register: cm_non_existing_site + +- name: non_existing_site (normal_mode) + mso_schema_site_bd: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: non_existing_site + template: Template 1 + bd: ansible_test_1 + state: query + ignore_errors: yes + register: nm_non_existing_site + +- name: Verify cm_non_existing_site and nm_non_existing_site + assert: + that: + - cm_non_existing_site is not changed + - nm_non_existing_site is not changed + - cm_non_existing_site.msg == 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 (check_mode) + mso_schema_site_bd: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: '{{ mso_site | default("ansible_test") }}' + template: Template 3 + bd: ansible_test_1 + state: query + check_mode: yes + ignore_errors: yes + register: cm_non_existing_site_template + +- name: non_existing_site_template (normal_mode) + mso_schema_site_bd: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: '{{ mso_site | default("ansible_test") }}' + template: Template 3 + bd: ansible_test_1 + state: query + ignore_errors: yes + register: nm_non_existing_site_template + +- name: Verify cm_non_existing_site_template and nm_non_existing_site_template + 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-template association 'ansible_test-Template3' does not exist." + +# 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: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}_2' + site: '{{ mso_site | default("ansible_test") }}' + template: Template 3 + bd: ansible_test_1 + state: present + check_mode: yes + ignore_errors: yes + register: cm_no_site_associated + +- name: Add site BD to Template 3 without any site associated (normal mode) + mso_schema_site_bd: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}_2' + site: '{{ mso_site | default("ansible_test") }}' + template: Template 3 + bd: ansible_test_1 + state: present + ignore_errors: yes + register: nm_no_site_associated + +- name: Verify cm_no_site_associated and nm_no_site_associated + 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 diff --git a/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_bd_subnet/aliases b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_bd_subnet/aliases new file mode 100644 index 00000000..5042c9c0 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_bd_subnet/aliases @@ -0,0 +1,2 @@ +# No ACI MultiSite infrastructure, so not enabled +# unsupported diff --git a/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_bd_subnet/tasks/main.yml b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_bd_subnet/tasks/main.yml new file mode 100644 index 00000000..fdac1c19 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_bd_subnet/tasks/main.yml @@ -0,0 +1,592 @@ +# Test code for the MSO modules +# Copyright: (c) 2020, Cindy Zhao (@cizhao) + +# 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.' + 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: + 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(true) }}' + output_level: '{{ mso_output_level | default("info") }}' + +- name: Query MSO version + mso_version: + <<: *mso_info + state: query + register: version + +- name: Remove schemas + mso_schema: + <<: *mso_info + schema: '{{ item }}' + state: absent + loop: + - '{{ mso_schema | default("ansible_test") }}_2' + - '{{ mso_schema | default("ansible_test") }}' + +- name: Ensure site exists + 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 + +- name: Ensure tenant ansible_test exists + mso_tenant: + <<: *mso_info + tenant: ansible_test + users: + - '{{ mso_username }}' + sites: + - '{{ mso_site | default("ansible_test") }}' + state: present + +- name: Ensure schema 1 with Template1, Template2, Template4 and Template5 + mso_schema_template: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + tenant: ansible_test + template: '{{ item }}' + state: present + loop: + - Template1 + - Template2 + - Template4 + - Template5 + +- name: Ensure schema 2 with Template3 exist + mso_schema_template: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}_2' + tenant: ansible_test + template: Template3 + state: present + +- name: Add physical site to templates + mso_schema_site: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: '{{ mso_site | default("ansible_test") }}' + template: '{{ item }}' + state: present + loop: + - Template1 + - Template2 + - Template5 + +- name: Ensure VRF1 exists + mso_schema_template_vrf: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template1 + vrf: VRF1 + layer3_multicast: true + state: present + +- name: Add template BD to Template3 + mso_schema_template_bd: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}_2' + template: Template3 + bd: ansible_test_3 + vrf: + name: VRF1 + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template1 + state: present + register: nm_add_bd_template_3 + +- name: Add template BD to Template2 + mso_schema_template_bd: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template2 + bd: ansible_test_2 + vrf: + name: VRF1 + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template1 + state: present + register: nm_add_bd_template_2 + +- name: Add template BD to Template4 + mso_schema_template_bd: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template4 + bd: ansible_test_4 + vrf: + name: VRF1 + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template1 + state: present + register: nm_add_bd_template_4 + +- name: Add template BD to Template1 without disabling layer2_stretch + mso_schema_template_bd: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template1 + bd: ansible_test_1 + vrf: + name: VRF1 + state: present + register: nm_add_bd + +- name: Add site BD + mso_schema_site_bd: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: '{{ mso_site | default("ansible_test") }}' + template: Template1 + bd: ansible_test_1 + state: present + register: nm_add_site_bd + +- name: Add site BD subnet with layer2_stretch enabled + mso_schema_site_bd_subnet: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: '{{ mso_site | default("ansible_test") }}' + template: Template1 + bd: ansible_test_1 + subnet: 10.1.0.1/16 + state: present + ignore_errors: yes + register: add_site_bd_subnet_with_l2Stretch_enabled + +- name: Verify add_site_bd_subnet_with_l2Stretch_enabled + 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: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template1 + bd: ansible_test_1 + layer2_stretch: false + vrf: + name: VRF1 + state: present + register: nm_add_bd + +- name: Add site BD subnet with layer2_stretch disabled (check_mode) + mso_schema_site_bd_subnet: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: '{{ mso_site | default("ansible_test") }}' + template: Template1 + bd: ansible_test_1 + subnet: 10.1.0.1/16 + state: present + check_mode: yes + register: cm_add_site_bd_subnet + +- name: Verify cm_add_site_bd_subnet + assert: + that: + - cm_add_site_bd_subnet is changed + - cm_add_site_bd_subnet.previous == {} + - cm_add_site_bd_subnet.current.ip == "10.1.0.1/16" + - cm_add_site_bd_subnet.current.scope == "private" + - cm_add_site_bd_subnet.current.description == "10.1.0.1/16" + - cm_add_site_bd_subnet.current.shared == False + - cm_add_site_bd_subnet.current.noDefaultGateway == False + - cm_add_site_bd_subnet.current.querier == False + +- name: Add site BD subnet with layer2_stretch disabled (normal_mode) + mso_schema_site_bd_subnet: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: '{{ mso_site | default("ansible_test") }}' + template: Template1 + bd: ansible_test_1 + subnet: 10.1.0.1/16 + state: present + register: nm_add_site_bd_subnet + +- name: Verify nm_add_site_bd_subnet + assert: + that: + - nm_add_site_bd_subnet is changed + - nm_add_site_bd_subnet.previous == {} + - nm_add_site_bd_subnet.current.ip == "10.1.0.1/16" + - nm_add_site_bd_subnet.current.scope == "private" + - nm_add_site_bd_subnet.current.description == "10.1.0.1/16" + - nm_add_site_bd_subnet.current.shared == False + - nm_add_site_bd_subnet.current.noDefaultGateway == False + - nm_add_site_bd_subnet.current.querier == False + +- name: Add site BD subnet again + mso_schema_site_bd_subnet: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: '{{ mso_site | default("ansible_test") }}' + template: Template1 + bd: ansible_test_1 + subnet: 10.1.0.1/16 + state: present + register: nm_add_site_bd_subnet_again + +- name: Verify nm_add_site_bd_subnet_again + assert: + that: + - nm_add_site_bd_subnet_again is not changed + +- name: Add another site BD subnet + mso_schema_site_bd_subnet: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: '{{ mso_site | default("ansible_test") }}' + template: Template1 + bd: ansible_test_1 + subnet: 10.10.10.1/16 + description: another subnet + scope: public + shared: true + no_default_gateway: true + querier: true + state: present + register: nm_add_another_site_bd_subnet + +- name: Verify nm_add_another_site_bd_subnet + assert: + that: + - nm_add_another_site_bd_subnet is changed + - nm_add_another_site_bd_subnet.previous == {} + - nm_add_another_site_bd_subnet.current.description == "another subnet" + - nm_add_another_site_bd_subnet.current.scope == "public" + - nm_add_another_site_bd_subnet.current.shared == true + - nm_add_another_site_bd_subnet.current.noDefaultGateway == true + - nm_add_another_site_bd_subnet.current.querier == true + +- name: Add BD ansible_test_5 to Schema1, template5 + mso_schema_template_bd: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template5 + bd: ansible_test_5 + layer2_stretch: false + vrf: + name: VRF1 + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template1 + state: present + +- name: Add site BD5 + mso_schema_site_bd: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: '{{ mso_site | default("ansible_test") }}' + template: Template5 + bd: ansible_test_5 + state: present + +- name: Add site BD5 subnet with layer2_stretch disabled (normal_mode) + mso_schema_site_bd_subnet: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: '{{ mso_site | default("ansible_test") }}' + template: Template5 + bd: ansible_test_5 + subnet: 10.1.0.5/16 + is_virtual_ip: true + scope: public + shared: true + no_default_gateway: true + querier: true + state: present + register: nm_add_site_bd_subnet5 + +- name: Verify nm_add_site_bd_subnet5 for a version that's not 3.1 + assert: + that: + - nm_add_site_bd_subnet5 is changed + - nm_add_site_bd_subnet5.previous == {} + - nm_add_site_bd_subnet5.current.ip == "10.1.0.5/16" + - nm_add_site_bd_subnet5.current.scope == "public" + - nm_add_site_bd_subnet5.current.description == "10.1.0.5/16" + - nm_add_site_bd_subnet5.current.shared == True + - nm_add_site_bd_subnet5.current.noDefaultGateway == True + - nm_add_site_bd_subnet5.current.querier == True + when: version.current.version is version('3.1.1g', '!=') + +- name: Verify nm_add_site_bd_subnet5 for a version that's 3.1 + assert: + that: + - nm_add_site_bd_subnet5 is changed + - nm_add_site_bd_subnet5.previous == {} + - nm_add_site_bd_subnet5.current.ip == "10.1.0.5/16" + - nm_add_site_bd_subnet5.current.scope == "public" + - nm_add_site_bd_subnet5.current.description == "10.1.0.5/16" + - nm_add_site_bd_subnet5.current.shared == True + - nm_add_site_bd_subnet5.current.noDefaultGateway == True + - nm_add_site_bd_subnet5.current.querier == True + - nm_add_site_bd_subnet5.current.virtual == True + when: version.current.version is version('3.1.1g', '==') + +- name: Query all subnets + mso_schema_site_bd_subnet: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: '{{ mso_site | default("ansible_test") }}' + template: Template1 + bd: ansible_test_1 + state: query + register: query_all + +- name: Verify query_all + assert: + that: + - query_all is not changed + - query_all.current | length == 2 + - query_all.current.0.ip == "10.1.0.1/16" + - query_all.current.1.ip == "10.10.10.1/16" + +- name: Query a specific site BD subnet + mso_schema_site_bd_subnet: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: '{{ mso_site | default("ansible_test") }}' + template: Template1 + bd: ansible_test_1 + subnet: 10.1.0.1/16 + state: query + register: query_subnet + +- name: Verify query_subnet + 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: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: '{{ mso_site | default("ansible_test") }}' + template: Template5 + bd: ansible_test_5 + subnet: 10.1.0.5/16 + state: query + register: query_subnet5 + +- name: Verify query_subnet5 for no 3.1 version + 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 + assert: + that: + - query_subnet5 is not changed + - query_subnet5.current.ip == "10.1.0.5/16" + - query_subnet5.current.virtual == true + when: version.current.version is version('3.1.1g', '==') + +- name: Remove a site BD subnet + mso_schema_site_bd_subnet: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: '{{ mso_site | default("ansible_test") }}' + template: Template1 + bd: ansible_test_1 + subnet: 10.1.0.1/16 + state: absent + register: rm_subnet + +- name: Verify rm_subnet + 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: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: '{{ mso_site | default("ansible_test") }}' + template: Template1 + bd: ansible_test_1 + subnet: 10.1.0.1/16 + state: absent + register: rm_subnet_again + +- name: Verify rm_subnet_again + 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: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: '{{ mso_site | default("ansible_test") }}' + template: Template5 + bd: ansible_test_5 + subnet: 10.1.0.5/16 + state: absent + register: rm_subnet5 + +- name: Verify rm_subnet5 + assert: + that: + - rm_subnet5 is changed + - rm_subnet5.current == {} + - rm_subnet5.previous.ip == "10.1.0.5/16" + +# Use non_existing_schema +- name: Query subnet by non_existing_schema + mso_schema_site_bd_subnet: + <<: *mso_info + schema: non_existing_schema + site: '{{ mso_site | default("ansible_test") }}' + template: Template1 + bd: ansible_test_1 + subnet: 10.1.0.1/16 + state: query + ignore_errors: yes + register: non_existing_schema + +- name: Verify non_existing_schema + 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: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: '{{ mso_site | default("ansible_test") }}' + template: non_existing_template + bd: ansible_test_1 + subnet: 10.1.0.1/16 + state: query + ignore_errors: yes + register: non_existing_template + +- name: Verify non_existing_template + assert: + that: + - non_existing_template.msg == "Provided template 'non_existing_template' does not exist. Existing templates{{':'}} Template1, Template2, Template4, Template5" + +# Use non_existing_template_bd +- name: Query subnet by non_existing_template_bd + mso_schema_site_bd_subnet: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: '{{ mso_site | default("ansible_test") }}' + template: Template1 + bd: non_existing_template_bd + subnet: 10.1.0.1/16 + state: query + ignore_errors: yes + register: non_existing_template_bd + +- name: Verify non_existing_template_bd + assert: + that: + - non_existing_template_bd.msg == "Provided BD 'non_existing_template_bd' does not exist. Existing template BDs{{':'}} ansible_test_1" + +# Use template without site associated +- name: Query with no site associated to template + mso_schema_site_bd_subnet: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}_2' + site: '{{ mso_site | default("ansible_test") }}' + template: Template3 + bd: ansible_test_3 + subnet: 10.1.0.1/16 + state: query + ignore_errors: yes + register: template_without_sites + +- name: Verify template_without_sites + assert: + that: + - template_without_sites.msg == "No site associated with template 'Template3'. Associate the site with the template using mso_schema_site." + +# Use non_existing_subnet +- name: Query with non_existing_site + mso_schema_site_bd_subnet: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: '{{ mso_site | default("ansible_test") }}' + template: Template1 + bd: ansible_test_1 + subnet: non_existing_subnet + state: query + ignore_errors: yes + register: non_existing_subnet + +- name: Verify non_existing_subnet + assert: + that: + - non_existing_subnet.msg == "Subnet IP 'non_existing_subnet' not found" + +# Use non_existing_site_template_association +- name: Query with non_existing_site_template_association + mso_schema_site_bd_subnet: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: '{{ mso_site | default("ansible_test") }}' + template: Template4 + bd: ansible_test_4 + subnet: 10.1.0.1/16 + state: query + ignore_errors: yes + register: non_existing_site_template_association + +- name: Verify non_existing_site_template_association + assert: + that: + - non_existing_site_template_association.msg == "Provided site/template 'ansible_test-Template4' does not exist." + +# Use BD at template level but not at site level +- name: Query with non_existing_site_bd + mso_schema_site_bd_subnet: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: '{{ mso_site | default("ansible_test") }}' + template: Template2 + bd: ansible_test_2 + subnet: 10.1.0.1/16 + state: query + ignore_errors: yes + register: non_existing_site_bd + +- name: Verify non_existing_site_bd + assert: + that: + - non_existing_site_bd.msg == "Provided BD 'ansible_test_2' does not exist. Existing site BDs{{':'}} " + +- name: Remove schemas for next ci test case + mso_schema: + <<: *mso_info + schema: '{{ item }}' + state: absent + loop: + - '{{ mso_schema | default("ansible_test") }}_2' + - '{{ mso_schema | default("ansible_test") }}' \ No newline at end of file diff --git a/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_external_epg_selector/aliases b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_external_epg_selector/aliases new file mode 100644 index 00000000..5042c9c0 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_external_epg_selector/aliases @@ -0,0 +1,2 @@ +# No ACI MultiSite infrastructure, so not enabled +# unsupported diff --git a/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_external_epg_selector/tasks/main.yml b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_external_epg_selector/tasks/main.yml new file mode 100644 index 00000000..84d9a6dd --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_external_epg_selector/tasks/main.yml @@ -0,0 +1,523 @@ +# Test code for the MSO modules +# Copyright: (c) 2020, Lionel Hercot (@lhercot) +# Copyright: (c) 2018, Dag Wieers (@dagwieers) (based on mso_site test case) +# Copyright: (c) 2020, Shreyas Srish (@shrsr) + +# 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.' + 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: + 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(true) }}' + output_level: '{{ mso_output_level | default("info") }}' + +- name: Query MSO version + mso_version: + <<: *mso_info + state: query + register: version + +- name: Ensure azure site exists + mso_site: + <<: *mso_info + site: 'azure_{{ mso_site | default("ansible_test") }}' + apic_username: '{{ azure_apic_username }}' + apic_password: '{{ azure_apic_password }}' + apic_site_id: '{{ azure_site_id }}' + urls: + - https://{{ azure_apic_hostname }} + state: present + +- name: Ensure aws site exists + mso_site: + <<: *mso_info + site: 'aws_{{ mso_site | default("ansible_test") }}' + apic_username: '{{ aws_apic_username }}' + apic_password: '{{ aws_apic_password }}' + apic_site_id: '{{ aws_site_id }}' + urls: + - https://{{ aws_apic_hostname }} + state: present + +- name: Remove schemas + mso_schema: + <<: *mso_info + schema: '{{ item }}' + state: absent + loop: + - '{{ mso_schema | default("ansible_test") }}_2' + - '{{ mso_schema | default("ansible_test") }}' + +- name: Ensure tenant ansible_test exist + mso_tenant: + <<: *mso_info + tenant: ansible_test + users: + - '{{ mso_username }}' + sites: + - '{{ mso_site | default("ansible_test") }}' + state: present + +- name: Associate aws site with ansible_test + mso_tenant_site: + <<: *mso_info + tenant: ansible_test + site: 'aws_{{ mso_site | default("ansible_test") }}' + cloud_account: "000000000000" + aws_trusted: false + aws_access_key: "1" + secret_key: "0" + state: present + +- name: Associate azure site with ansible_test + mso_tenant_site: + <<: *mso_info + tenant: ansible_test + site: 'azure_{{ mso_site | default("ansible_test") }}' + cloud_account: uni/tn-ansible_test/act-[100]-vendor-azure + state: present + +- name: Ensure schema 1 with Template 1 and 2 exists + mso_schema_template: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + tenant: ansible_test + template: '{{ item }}' + state: present + loop: + - Template 1 + - Template 2 + +- name: Ensure schema 2 with Template 3 exists + mso_schema_template: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}_2' + tenant: ansible_test + template: Template 3 + state: present + +- name: Ensure VRF1 exists + mso_schema_template_vrf: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + vrf: VRF1 + state: present + +- name: Ensure Template 1 with AP1 exists + mso_schema_template_anp: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + anp: AP1 + state: present + +- name: Ensure L3Out Exists + mso_schema_template_l3out: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + vrf: + name: VRF1 + template: Template 1 + schema: '{{ mso_schema | default("ansible_test") }}' + l3out: L3out1 + state: present + +- name: Ensure External EPG1 exists + mso_schema_template_externalepg: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + externalepg: extEPG1 + vrf: + name: VRF1 + template: Template 1 + schema: '{{ mso_schema | default("ansible_test") }}' + l3out: + name: L3out1 + template: Template 1 + schema: '{{ mso_schema | default("ansible_test") }}' + anp: + name: AP1 + template: Template 1 + schema: '{{ mso_schema | default("ansible_test") }}' + state: present + +- name: Ensure External EPG2 exists + mso_schema_template_externalepg: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + externalepg: extEPG2 + vrf: + name: VRF1 + template: Template 1 + schema: '{{ mso_schema | default("ansible_test") }}' + l3out: + name: L3out1 + template: Template 1 + schema: '{{ mso_schema | default("ansible_test") }}' + anp: + name: AP1 + template: Template 1 + schema: '{{ mso_schema | default("ansible_test") }}' + state: present + +- name: Add Azure site to a schema + mso_schema_site: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: 'azure_{{ mso_site | default("ansible_test") }}' + template: Template 1 + state: present + when: version.current.version[0] | int < 3 + +- name: Add AWS site to a schema + mso_schema_site: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: 'aws_{{ mso_site | default("ansible_test") }}' + template: Template 1 + state: present + when: version.current.version[0] | int < 3 + +- name: Add a new CIDR in VRF1 at site level + mso_schema_site_vrf_region_cidr: &mso_present + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + site: '{{ item }}' + vrf: VRF1 + region: us-west-1 + cidr: 10.0.0.0/16 + primary: true + state: present + loop: + - 'aws_{{ mso_site | default("ansible_test") }}' + - 'azure_{{ mso_site | default("ansible_test") }}' + +# ADD SELECTORS +- name: Add a selector to Azure in check mode + mso_schema_site_external_epg_selector: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + site: 'azure_{{ mso_site | default("ansible_test") }}' + external_epg: extEPG1 + selector: e1 + expressions: + - type: ip_address + operator: equals + value: 10.0.0.0 + state: present + check_mode: yes + register: cm_azure_e1 + +- name: Verify cm_azure_e1 + assert: + that: + - cm_azure_e1 is changed + - cm_azure_e1.previous == {} + - cm_azure_e1.current.subnets[0].ip == '10.0.0.0' + - cm_azure_e1.current.subnets[0].name == 'e1' + +- name: Add a selector to Azure in normal mode + mso_schema_site_external_epg_selector: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + site: 'azure_{{ mso_site | default("ansible_test") }}' + external_epg: extEPG1 + selector: e1 + expressions: + - type: ip_address + operator: equals + value: 10.0.0.0 + state: present + register: nm_azure_e1 + +- name: Verify nm_azure_e1 + assert: + that: + - nm_azure_e1 is changed + - nm_azure_e1.previous == {} + - nm_azure_e1.current.subnets[0].ip == '10.0.0.0' + - nm_azure_e1.current.subnets[0].name == 'e1' + +- name: Add a selector to AWS in normal mode + mso_schema_site_external_epg_selector: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + site: 'aws_{{ mso_site | default("ansible_test") }}' + external_epg: extEPG2 + selector: e2 + expressions: + - type: ip_address + operator: equals + value: 10.1.1.1 + state: present + register: nm_aws_e2 + +- name: Verify nm_aws_e2 + assert: + that: + - nm_aws_e2 is changed + - nm_aws_e2.previous == {} + - nm_aws_e2.current.subnets[0].ip == '10.1.1.1' + - nm_aws_e2.current.subnets[0].name == 'e2' + +- name: Add a selector to AWS in normal mode again + mso_schema_site_external_epg_selector: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + site: 'aws_{{ mso_site | default("ansible_test") }}' + external_epg: extEPG2 + selector: e2 + expressions: + - type: ip_address + operator: equals + value: 10.1.1.1 + state: present + register: nm_aws_e1_again + +- name: Verify nm_aws_e1_again + 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: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + site: 'aws_{{ mso_site | default("ansible_test") }}' + external_epg: extEPG2 + selector: e2 + state: present + ignore_errors: yes + register: nm_aws_e1_again_noexp + +- name: Verify nm_aws_e1_again_noexp + 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: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + site: 'azure_{{ mso_site | default("ansible_test") }}' + external_epg: extEPG1 + selector: e1 + state: query + register: query_azure_e1 + +- name: Verify query_azure_e1 + assert: + that: + - query_azure_e1 is not changed + +# QUERY ALL +- name: Query all selectors of Azure + mso_schema_site_external_epg_selector: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + site: 'azure_{{ mso_site | default("ansible_test") }}' + external_epg: extEPG1 + state: query + register: query_all + +- name: Verify query_all + assert: + that: + - query_all is not changed + +# REMOVE A SELECTOR +- name: Remove a selector of Azure + mso_schema_site_external_epg_selector: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + site: 'azure_{{ mso_site | default("ansible_test") }}' + external_epg: extEPG1 + selector: e1 + state: absent + register: remove_azure_e1 + +- name: Verify remove_azure_e1 + assert: + that: + - remove_azure_e1 is changed + +- name: Remove a selector of Azure again + mso_schema_site_external_epg_selector: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + site: 'azure_{{ mso_site | default("ansible_test") }}' + external_epg: extEPG1 + selector: e1 + state: absent + ignore_errors: yes + register: remove_azure_e1_again + +- name: Verify remove_azure_e1_again + 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: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + site: 'azure_{{ mso_site | default("ansible_test") }}' + external_epg: extEPG1 + selector: e1 + state: query + ignore_errors: yes + register: query_removed_azure_e1 + +- name: Verify query_removed_azure_e1 + 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: + <<: *mso_info + schema: non_existing_schema + site: 'aws_{{ mso_site | default("ansible_test") }}' + template: Template 1 + external_epg: extEPG2 + check_mode: yes + ignore_errors: yes + register: cm_non_existing_schema + +- name: Non-existing schema for selector (normal_mode) + mso_schema_site_external_epg_selector: + <<: *mso_info + schema: non_existing_schema + site: 'aws_{{ mso_site | default("ansible_test") }}' + template: Template 1 + external_epg: extEPG2 + ignore_errors: yes + register: nm_non_existing_schema + +- name: Verify non_existing_schema + assert: + that: + - cm_non_existing_schema is not changed + - nm_non_existing_schema is not changed + - cm_non_existing_schema == nm_non_existing_schema + - cm_non_existing_schema.msg == nm_non_existing_schema.msg == "Provided schema 'non_existing_schema' does not exist" + +# USE A NON-EXISTING TEMPLATE +- name: Non-existing template for selector (check_mode) + mso_schema_site_external_epg_selector: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: 'aws_{{ mso_site | default("ansible_test") }}' + template: non_existing_template + external_epg: extEPG2 + check_mode: yes + ignore_errors: yes + register: cm_non_existing_template + +- name: Non-existing template for selector (normal_mode) + mso_schema_site_external_epg_selector: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: 'aws_{{ mso_site | default("ansible_test") }}' + template: non_existing_template + external_epg: extEPG2 + ignore_errors: yes + register: nm_non_existing_template + +- name: Verify non_existing_template + 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" + +# USE A NON-EXISTING SITE +- name: Non-existing site for static port (check_mode) + mso_schema_site_external_epg_selector: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: 'azure_{{ mso_site | default("ansible_test") }}' + template: Template 2 + external_epg: extEPG3 + check_mode: yes + ignore_errors: yes + register: cm_non_existing_site + +- name: Non-existing site for static port (normal_mode) + mso_schema_site_external_epg_selector: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: 'azure_{{ mso_site | default("ansible_test") }}' + template: Template 2 + external_epg: extEPG3 + ignore_errors: yes + register: nm_non_existing_site + +- name: Verify non_existing_site + 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 'azure_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 'azure_ansible_test/[0-9a-zA-Z]*/Template2' does not exist. Existing siteIds/templates{{':'}} [0-9a-zA-Z]*/Template1") + +# 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: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}_2' + site: 'azure_{{ mso_site | default("ansible_test") }}' + template: Template 3 + external_epg: extEPG3 + ignore_errors: yes + check_mode: yes + 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: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}_2' + site: 'azure_{{ mso_site | default("ansible_test") }}' + template: Template 3 + external_epg: extEPG3 + ignore_errors: yes + register: nm_no_site_associated + +- name: Verify cm_no_site_associated and nm_no_site_associated + 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 diff --git a/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_vrf_region/aliases b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_vrf_region/aliases new file mode 100644 index 00000000..5042c9c0 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_vrf_region/aliases @@ -0,0 +1,2 @@ +# No ACI MultiSite infrastructure, so not enabled +# unsupported diff --git a/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_vrf_region/tasks/main.yml b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_vrf_region/tasks/main.yml new file mode 100644 index 00000000..68507069 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_vrf_region/tasks/main.yml @@ -0,0 +1,433 @@ +# Test code for the MSO modules +# Copyright: (c) 2020, Cindy Zhao (@cizhao) +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +# CLEAN ENVIRONMENT +- name: Set vars + 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(true) }}' + output_level: '{{ mso_output_level | default("info") }}' + sites: "['aws_{{ mso_site | default(\"ansible_test\") }}', + 'azure_{{ mso_site | default(\"ansible_test\") }}', + '{{ mso_site | default(\"ansible_test\") }}']" + +- name: Ensure aws site exists + mso_site: + <<: *mso_info + site: 'aws_{{ mso_site | default("ansible_test") }}' + apic_username: '{{ aws_apic_username }}' + apic_password: '{{ aws_apic_password }}' + apic_site_id: '{{ aws_site_id | default(102) }}' + urls: + - https://{{ aws_apic_hostname }} + state: present + +- name: Ensure azure site exists + mso_site: + <<: *mso_info + site: 'azure_{{ mso_site | default("ansible_test") }}' + apic_username: '{{ azure_apic_username }}' + apic_password: '{{ azure_apic_password }}' + apic_site_id: '{{ azure_site_id | default(103) }}' + urls: + - https://{{ azure_apic_hostname }} + state: present + +- name: Remove Schemas + mso_schema: + <<: *mso_info + schema: '{{ item }}' + state: absent + loop: + - '{{ mso_schema | default("ansible_test") }}_2' + - '{{ mso_schema | default("ansible_test") }}' + +- name: Ensure tenant ansible_test exist + mso_tenant: + <<: *mso_info + tenant: ansible_test + users: + - '{{ mso_username }}' + state: present + +- name: Ensure AWS site is present under tenant ansible_test + mso_tenant_site: + <<: *mso_info + tenant: ansible_test + site: 'aws_{{ mso_site | default("ansible_test") }}' + cloud_account: '000000000000' + aws_access_key: 1 + secret_key: 0 + state: present + +- name: Ensure Azure site is present under tenant ansible_test + mso_tenant_site: + <<: *mso_info + tenant: ansible_test + site: 'azure_{{ mso_site | default("ansible_test") }}' + cloud_account: uni/tn-ansible_test/act-[9]-vendor-azure + state: present + +- name: Ensure schema 1 with Template 1 and 2 exists + mso_schema_template: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + tenant: ansible_test + template: '{{ item }}' + state: present + loop: + - Template 1 + - Template 2 + +- name: Ensure schema 2 with Template 3 exists + mso_schema_template: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}_2' + tenant: ansible_test + template: Template 3 + state: present + +- name: Ensure VRF1 exists + mso_schema_template_vrf: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + vrf: VRF1 + state: present + +- name: Add region and cidr in VRF1 at AWS site level + mso_schema_site_vrf_region_cidr: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + site: 'aws_{{ mso_site | default("ansible_test") }}' + vrf: VRF1 + region: us-west-1 + cidr: 10.0.0.0/16 + primary: true + state: present + register: aws_add_region_cidr + +- name: Add region and cidr in VRF1 at Azure site level + mso_schema_site_vrf_region_cidr: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + site: 'azure_{{ mso_site | default("ansible_test") }}' + vrf: VRF1 + region: us-west-1 + cidr: 10.0.0.0/16 + primary: true + state: present + register: azure_add_region_cidr + +- name: Add another region and cidr in VRF1 at AWS site level + mso_schema_site_vrf_region_cidr: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + site: 'aws_{{ mso_site | default("ansible_test") }}' + vrf: VRF1 + region: us-east-1 + cidr: 10.10.0.0/16 + primary: true + state: present + register: aws_add_another_region_cidr + +- name: Add another region and cidr in VRF1 at Azure site level + mso_schema_site_vrf_region_cidr: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + site: 'azure_{{ mso_site | default("ansible_test") }}' + vrf: VRF1 + region: us-east-1 + cidr: 10.10.0.0/16 + primary: true + state: present + register: azure_add_another_region_cidr + +- name: Query all aws regions + mso_schema_site_vrf_region: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + site: 'aws_{{ mso_site | default("ansible_test") }}' + vrf: VRF1 + state: query + register: aws_query_all + +- name: Query all azure regions + mso_schema_site_vrf_region: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + site: 'azure_{{ mso_site | default("ansible_test") }}' + vrf: VRF1 + state: query + register: azure_query_all + +- name: Query specific aws region + mso_schema_site_vrf_region: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + site: 'aws_{{ mso_site | default("ansible_test") }}' + vrf: VRF1 + region: us-west-1 + state: query + register: aws_query_region + +- name: Query specific azure region + mso_schema_site_vrf_region: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + site: 'azure_{{ mso_site | default("ansible_test") }}' + vrf: VRF1 + region: us-west-1 + state: query + register: azure_query_region + +- name: Verify query + assert: + that: + - aws_query_all is not changed + - azure_query_all is not changed + - aws_query_region is not changed + - azure_query_region is not changed + - aws_query_all.current | length == 2 + - azure_query_all.current | length == 2 + - aws_query_region.current.name == "us-west-1" + - aws_query_region.current.cidrs.0.ip == "10.0.0.0/16" + - aws_query_region.current.cidrs.0.primary == true + - aws_query_region.current.cidrs.0.subnets == [] + - azure_query_region.current.name == "us-west-1" + - azure_query_region.current.cidrs.0.ip == "10.0.0.0/16" + - azure_query_region.current.cidrs.0.primary == true + - azure_query_region.current.cidrs.0.subnets == [] + +- name: Remove aws VRF region (check mode) + mso_schema_site_vrf_region: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + site: 'aws_{{ mso_site | default("ansible_test") }}' + vrf: VRF1 + region: us-west-1 + state: absent + check_mode: yes + register: cm_rm_aws_region + +- name: Remove aws VRF region (normal mode) + mso_schema_site_vrf_region: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + site: 'aws_{{ mso_site | default("ansible_test") }}' + vrf: VRF1 + region: us-west-1 + state: absent + register: nm_rm_aws_region + +- name: Remove azure VRF region (check mode) + mso_schema_site_vrf_region: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + site: 'azure_{{ mso_site | default("ansible_test") }}' + vrf: VRF1 + region: us-west-1 + state: absent + check_mode: yes + register: cm_rm_azure_region + +- name: Remove azure VRF region (normal mode) + mso_schema_site_vrf_region: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + site: 'azure_{{ mso_site | default("ansible_test") }}' + vrf: VRF1 + region: us-west-1 + state: absent + register: nm_rm_azure_region + +- name: Verify deletion + assert: + that: + - cm_rm_aws_region is changed + - nm_rm_aws_region is changed + - cm_rm_azure_region is changed + - nm_rm_azure_region is changed + - cm_rm_aws_region == nm_rm_aws_region + - cm_rm_azure_region == nm_rm_azure_region + - cm_rm_aws_region.current == nm_rm_aws_region.current == {} + - cm_rm_azure_region.current == nm_rm_azure_region.current == {} + - cm_rm_aws_region.previous.name == nm_rm_aws_region.previous.name == "us-west-1" + - cm_rm_azure_region.previous.name == nm_rm_azure_region.previous.name == "us-west-1" + +- name: Query MSO version + mso_version: + <<: *mso_info + state: query + register: version + +- name: Remove VPN Gateway Router at Region for AWS (check mode) + cisco.mso.mso_schema_site_vrf_region: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + site: 'aws_{{ mso_site | default("ansible_test") }}' + vrf: VRF1 + region: us-east-1 + vpn_gateway_router: false + state: present + check_mode: yes + when: version.current.version is version('3.0.0a', '>=') + register: cm_rm_vpn_gateway_router_aws + +- name: Remove VPN Gateway Router at Region for AWS (normal mode) + cisco.mso.mso_schema_site_vrf_region: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + site: 'aws_{{ mso_site | default("ansible_test") }}' + vrf: VRF1 + region: us-east-1 + vpn_gateway_router: false + state: present + when: version.current.version is version('3.0.0a', '>=') + register: nm_rm_vpn_gateway_router_aws + +- name: Remove VPN Gateway Router at Region for Azure (check mode) + cisco.mso.mso_schema_site_vrf_region: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + site: 'azure_{{ mso_site | default("ansible_test") }}' + vrf: VRF1 + region: us-east-1 + vpn_gateway_router: false + state: present + check_mode: yes + when: version.current.version is version('3.0.0a', '>=') + register: cm_rm_vpn_gateway_router_azure + +- name: Remove VPN Gateway Router at Region for Azure (normal mode) + cisco.mso.mso_schema_site_vrf_region: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + site: 'azure_{{ mso_site | default("ansible_test") }}' + vrf: VRF1 + region: us-east-1 + vpn_gateway_router: false + state: present + when: version.current.version is version('3.0.0a', '>=') + register: nm_rm_vpn_gateway_router_azure + +- name: Verify removing VPN Gateway Router + assert: + that: + - cm_rm_vpn_gateway_router_aws is changed + - nm_rm_vpn_gateway_router_aws is changed + - cm_rm_vpn_gateway_router_azure is changed + - nm_rm_vpn_gateway_router_azure is changed + - cm_rm_vpn_gateway_router_aws.previous.isVpnGatewayRouter == nm_rm_vpn_gateway_router_aws.previous.isVpnGatewayRouter == true + - cm_rm_vpn_gateway_router_azure.previous.isVpnGatewayRouter == nm_rm_vpn_gateway_router_azure.previous.isVpnGatewayRouter == true + - cm_rm_vpn_gateway_router_aws.current.isVpnGatewayRouter == nm_rm_vpn_gateway_router_aws.current.isVpnGatewayRouter == false + - cm_rm_vpn_gateway_router_azure.current.isVpnGatewayRouter == nm_rm_vpn_gateway_router_azure.current.isVpnGatewayRouter == false + when: version.current.version is version('3.0.0a', '>=') + +- name: Use non_existing schema + mso_schema_site_vrf_region: + <<: *mso_info + schema: non_existing + template: Template 1 + site: 'aws_{{ mso_site | default("ansible_test") }}' + vrf: VRF1 + region: us-west-1 + state: query + register: non_existing_schema + ignore_errors: yes + +- name: Use non_existing site + mso_schema_site_vrf_region: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + site: non_existing + vrf: VRF1 + region: us-west-1 + state: query + register: non_existing_site + ignore_errors: yes + +- name: Use non_existing site/template association + mso_schema_site_vrf_region: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 2 + site: 'aws_{{ mso_site | default("ansible_test") }}' + vrf: VRF1 + region: us-west-1 + state: query + register: non_existing_site_template + ignore_errors: yes + +- name: Use non_existing VRF + mso_schema_site_vrf_region: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + site: 'aws_{{ mso_site | default("ansible_test") }}' + vrf: non_existing + region: us-west-1 + state: query + register: non_existing_vrf + ignore_errors: yes + +- name: Use non_existing region + mso_schema_site_vrf_region: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + site: 'aws_{{ mso_site | default("ansible_test") }}' + vrf: VRF1 + region: non_existing + state: query + register: non_existing_region + ignore_errors: yes + +- name: Verify non_existing + 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." + - non_existing_site_template.msg == "Provided site-template association 'aws_ansible_test-Template2' does not exist." + - non_existing_vrf.msg == "Provided vrf 'non_existing' does not exist. Existing vrfs{{':'}} VRF1" + - non_existing_region.msg == "Region 'non_existing' not found" + +- name: Delete non_existing region + mso_schema_site_vrf_region: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + site: 'aws_{{ mso_site | default("ansible_test") }}' + vrf: VRF1 + region: non_existing + state: absent + register: rm_non_existing_region + +- name: Verify rm_non_existing_region + assert: + that: + - rm_non_existing_region is not changed + - rm_non_existing_region.previous == rm_non_existing_region.current == {} diff --git a/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_vrf_region_cidr/aliases b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_vrf_region_cidr/aliases new file mode 100644 index 00000000..5042c9c0 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_vrf_region_cidr/aliases @@ -0,0 +1,2 @@ +# No ACI MultiSite infrastructure, so not enabled +# unsupported diff --git a/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_vrf_region_cidr/tasks/main.yml b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_vrf_region_cidr/tasks/main.yml new file mode 100644 index 00000000..e6497bd8 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_vrf_region_cidr/tasks/main.yml @@ -0,0 +1,710 @@ +# Test code for the MSO modules +# Copyright: (c) 2020, Lionel Hercot (@lhercot) +# Copyright: (c) 2020, Shreyas Srish (@shrsr) (based on mso_schema_anp_epg_domain) +# Copyright: (c) 2018, Dag Wieers (@dagwieers) (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: + 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: + 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(true) }}' + output_level: '{{ mso_output_level | default("info") }}' + sites: "['aws_{{ mso_site | default(\"ansible_test\") }}', + 'azure_{{ mso_site | default(\"ansible_test\") }}', + '{{ mso_site | default(\"ansible_test\") }}']" + +- name: Query MSO version + mso_version: + <<: *mso_info + state: query + register: version + +- name: Ensure site exists + 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 + +- name: Ensure site exists + mso_site: + <<: *mso_info + site: 'aws_{{ mso_site | default("ansible_test") }}' + apic_username: '{{ aws_apic_username }}' + apic_password: '{{ aws_apic_password }}' + apic_site_id: '{{ aws_site_id | default(102) }}' + urls: + - https://{{ aws_apic_hostname }} + state: present + +- name: Ensure site exists + mso_site: + <<: *mso_info + site: 'azure_{{ mso_site | default("ansible_test") }}' + apic_username: '{{ azure_apic_username }}' + apic_password: '{{ azure_apic_password }}' + apic_site_id: '{{ azure_site_id | default(103) }}' + urls: + - https://{{ azure_apic_hostname }} + state: present + +- name: Remove Schemas + mso_schema: + <<: *mso_info + schema: '{{ item }}' + state: absent + loop: + - '{{ mso_schema | default("ansible_test") }}_2' + - '{{ mso_schema | default("ansible_test") }}' + +- name: Ensure tenant ansible_test exist + mso_tenant: + <<: *mso_info + tenant: ansible_test + sites: + - '{{ mso_site | default("ansible_test") }}' + users: + - '{{ mso_username }}' + state: present + +- name: Ensure AWS site is present under tenant ansible_test + mso_tenant_site: + <<: *mso_info + tenant: ansible_test + site: 'aws_{{ mso_site | default("ansible_test") }}' + cloud_account: '000000000000' + aws_access_key: 1 + secret_key: 0 + state: present + +- name: Ensure Azure site is present under tenant ansible_test + mso_tenant_site: + <<: *mso_info + tenant: ansible_test + site: 'azure_{{ mso_site | default("ansible_test") }}' + cloud_account: uni/tn-ansible_test/act-[9]-vendor-azure + state: present + +- name: Ensure schema 1 with Template 1 and 2 exists + mso_schema_template: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + tenant: ansible_test + template: '{{ item }}' + state: present + loop: + - Template 1 + - Template 2 + +- name: Ensure schema 2 with Template 3 exists + mso_schema_template: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}_2' + tenant: ansible_test + template: Template 3 + state: present + +- name: Add physical site to Template 1 + mso_schema_site: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: '{{ mso_site | default("ansible_test") }}' + template: Template 1 + state: present + +- name: Ensure VRF1 exists + mso_schema_template_vrf: + <<: *mso_info + schema: '{{ item.schema }}' + template: '{{ item.template }}' + vrf: VRF1 + state: present + loop: + - { schema: '{{ mso_schema | default("ansible_test") }}', template: 'Template 1' } + - { schema: '{{ mso_schema | default("ansible_test") }}', template: 'Template 2' } + - { schema: '{{ mso_schema | default("ansible_test") }}_2', template: 'Template 3' } + +- name: Ensure VRF2 exists + mso_schema_template_vrf: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + vrf: VRF2 + state: present + when: version.current.version[0] | int < 3 + +- name: Ensure VRF1 exists at Site level for the physical site + mso_schema_site_vrf: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + site: '{{ mso_site | default("ansible_test") }}' + vrf: VRF1 + state: present + +# ADD SUBNET +- name: Add a new CIDR in VRF1 at AWS site level (check mode) + mso_schema_site_vrf_region_cidr: &mso_present + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + site: 'aws_{{ mso_site | default("ansible_test") }}' + vrf: VRF1 + region: us-west-1 + cidr: 10.0.0.0/16 + primary: true + state: present + check_mode: yes + register: cm_add_cidr + +- name: Verify cm_add_cidr + assert: + that: + - cm_add_cidr is changed + - cm_add_cidr.previous == {} + - cm_add_cidr.current.ip == '10.0.0.0/16' + - 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: + <<: *mso_present + register: nm_add_cidr + +- name: Verify nm_add_cidr + assert: + that: + - nm_add_cidr is changed + - nm_add_cidr.previous == {} + - nm_add_cidr.current.ip == '10.0.0.0/16' + - nm_add_cidr.current.primary == true + +- name: Add same CIDR in VRF1 at AWS site level (check mode) + mso_schema_site_vrf_region_cidr: + <<: *mso_present + register: cm_add_cidr_again + +- name: Verify cm_add_cidr_again + 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: + <<: *mso_present + register: nm_add_cidr_again + +- name: Verify nm_add_cidr_again + 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: + <<: *mso_present + site: 'azure_{{ mso_site | default("ansible_test") }}' + region: westus + cidr: 10.1.0.0/16 + primary: true + check_mode: yes + register: cm_add_cidr_2 + +- name: Verify cm_add_cidr_2 + assert: + that: + - cm_add_cidr_2 is changed + - cm_add_cidr_2.previous == {} + - cm_add_cidr_2.current.ip == '10.1.0.0/16' + - 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: + <<: *mso_present + site: 'azure_{{ mso_site | default("ansible_test") }}' + region: westus + cidr: 10.1.0.0/16 + primary: true + register: nm_add_cidr_2 + +- name: Verify nm_add_cidr_2 + assert: + that: + - nm_add_cidr_2 is changed + - nm_add_cidr_2.previous == {} + - nm_add_cidr_2.current.ip == '10.1.0.0/16' + - 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 + <<: *mso_present + site: 'aws_{{ mso_site | default("ansible_test") }}' + region: us-west-1 + cidr: 10.2.0.0/16 + primary: false + check_mode: yes + register: cm_add_cidr_3 + +- name: Verify cm_add_cidr_3 + assert: + that: + - cm_add_cidr_3 is changed + - cm_add_cidr_3.previous == {} + - cm_add_cidr_3.current.ip == '10.2.0.0/16' + - 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: + <<: *mso_present_2 + register: nm_add_cidr_3 + +- name: Verify nm_add_cidr_3 + assert: + that: + - nm_add_cidr_3 is changed + - nm_add_cidr_3.previous == {} + - nm_add_cidr_3.current.ip == '10.2.0.0/16' + - 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: + <<: *mso_present + site: 'azure_{{ mso_site | default("ansible_test") }}' + region: westus + cidr: 10.3.0.0/16 + primary: false + check_mode: yes + register: cm_add_cidr_4 + +- name: Verify cm_add_cidr_4 + assert: + that: + - cm_add_cidr_4 is changed + - cm_add_cidr_4.previous == {} + - cm_add_cidr_4.current.ip == '10.3.0.0/16' + - 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: + <<: *mso_present + site: 'azure_{{ mso_site | default("ansible_test") }}' + region: westus + cidr: 10.3.0.0/16 + primary: false + register: nm_add_cidr_4 + +- name: Verify nm_add_cidr_4 + assert: + that: + - nm_add_cidr_4 is changed + - nm_add_cidr_4.previous == {} + - nm_add_cidr_4.current.ip == '10.3.0.0/16' + - nm_add_cidr_4.current.primary == false + +# QUERY CIDR +- name: Query CIDR in VRF1 at AWS site level (check mode) + mso_schema_site_vrf_region_cidr: &mso_query + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + site: 'aws_{{ mso_site | default("ansible_test") }}' + vrf: VRF1 + region: us-west-1 + cidr: 10.0.0.0/16 + state: query + check_mode: yes + register: cm_query_cidr + +- name: Verify cm_query_cidr + 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: + <<: *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 + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + site: 'azure_{{ mso_site | default("ansible_test") }}' + vrf: VRF1 + region: westus + cidr: 10.1.0.0/16 + state: query + check_mode: yes + register: cm_query_cidr_2 + +- name: Verify cm_query_cidr_2 + 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: + <<: *mso_query_2 + register: nm_query_cidr_2 + +- name: Verify nm_query_cidr_2 + assert: + that: + - nm_query_cidr_2 is not changed + - nm_query_cidr_2.current.ip == '10.1.0.0/16' + - nm_query_cidr_2.current.primary == true + +# QUERY ALL CIDR +- name: Query all CIDR in VRF1 at AWS site level (check mode) + mso_schema_site_vrf_region_cidr: &mso_query_all + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + site: 'aws_{{ mso_site | default("ansible_test") }}' + vrf: VRF1 + region: us-west-1 + state: query + check_mode: yes + register: cm_query_cidr_all_aws + +- name: Query CIDR in VRF1 at Azure site level (check mode) + mso_schema_site_vrf_region_cidr: + <<: *mso_query_all + site: 'azure_{{ mso_site | default("ansible_test") }}' + region: westus + state: query + check_mode: yes + register: cm_query_cidr_all_azure + +- name: Verify cm_query_cidr_all_aws and cm_query_cidr_all_azure + assert: + that: + - cm_query_cidr_all_aws is not changed + - cm_query_cidr_all_aws.current[0].ip == '10.0.0.0/16' + - cm_query_cidr_all_aws.current[0].primary == true + - cm_query_cidr_all_aws.current[1].ip == '10.2.0.0/16' + - cm_query_cidr_all_aws.current[1].primary == false + - cm_query_cidr_all_azure is not changed + - cm_query_cidr_all_azure.current[0].ip == '10.1.0.0/16' + - cm_query_cidr_all_azure.current[0].primary == true + - cm_query_cidr_all_azure.current[1].ip == '10.3.0.0/16' + - 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: + <<: *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: + <<: *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: + that: + - nm_query_cidr_all_aws is not changed + - nm_query_cidr_all_aws.current[0].ip == '10.0.0.0/16' + - nm_query_cidr_all_aws.current[0].primary == true + - nm_query_cidr_all_aws.current[1].ip == '10.2.0.0/16' + - nm_query_cidr_all_aws.current[1].primary == false + - nm_query_cidr_all_azure is not changed + - nm_query_cidr_all_azure.current[0].ip == '10.1.0.0/16' + - nm_query_cidr_all_azure.current[0].primary == true + - nm_query_cidr_all_azure.current[1].ip == '10.3.0.0/16' + - 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: + <<: *mso_query_all + vrf: VRF2 + ignore_errors: yes + 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: + <<: *mso_query_all + site: '{{ mso_site | default("ansible_test") }}' + vrf: VRF1 + ignore_errors: yes + register: nm_query_cidr_all_aws_3 + +- name: Verify nm_query_cidr_all_aws_2 and nm_query_cidr_all_aws_3 + 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{{':'}} " + when: version.current.version[0] | int < 3 + +# REMOVE CIDR +- name: Remove CIDR (check_mode) + mso_schema_site_vrf_region_cidr: + <<: *mso_present_2 + state: absent + check_mode: yes + register: cm_remove_cidr + +- name: Verify cm_remove_cidr + assert: + that: + - cm_remove_cidr is changed + - cm_remove_cidr.current == {} + +- name: Remove CIDR (normal mode) + mso_schema_site_vrf_region_cidr: + <<: *mso_present_2 + state: absent + register: nm_remove_cidr + +- name: Verify nm_remove_cidr + assert: + that: + - nm_remove_cidr is changed + - nm_remove_cidr.current == {} + +- name: Remove CIDR again (check_mode) + mso_schema_site_vrf_region_cidr: + <<: *mso_present_2 + state: absent + check_mode: yes + register: cm_remove_cidr_again + +- name: Verify cm_remove_cidr_again + 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: + <<: *mso_present_2 + state: absent + register: nm_remove_cidr_again + +- name: Verify nm_remove_cidr_again + 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: + <<: *mso_query + cidr: non_existing_cidr + check_mode: yes + ignore_errors: yes + register: cm_query_non_cidr + +- name: Query non-existing CIDR (normal mode) + mso_schema_site_vrf_region_cidr: + <<: *mso_query + cidr: non_existing_cidr + ignore_errors: yes + register: nm_query_non_cidr + +- name: Verify query_non_cidr + assert: + that: + - cm_query_non_cidr is not changed + - nm_query_non_cidr is not changed + - cm_query_non_cidr == nm_query_non_cidr + - cm_query_non_cidr.msg == nm_query_non_cidr.msg == "CIDR IP 'non_existing_cidr' not found" + +# QUERY NON-EXISTING region +- name: Query non-existing region (check_mode) + mso_schema_site_vrf_region_cidr: + <<: *mso_query + region: non_existing_region + check_mode: yes + ignore_errors: yes + register: cm_query_non_region + +- name: Query non-existing region (normal mode) + mso_schema_site_vrf_region_cidr: + <<: *mso_query + region: non_existing_region + ignore_errors: yes + register: nm_query_non_region + +- name: Verify query_non_region + assert: + that: + - cm_query_non_region is not changed + - nm_query_non_region is not changed + - cm_query_non_region == nm_query_non_region + - cm_query_non_region.msg == nm_query_non_region.msg == "Provided region 'non_existing_region' does not exist. Existing regions{{':'}} us-west-1" + +# QUERY NON-EXISTING VRF +- name: Query non-existing VRF (check_mode) + mso_schema_site_vrf_region_cidr: + <<: *mso_query + vrf: non_existing_vrf + check_mode: yes + ignore_errors: yes + register: cm_query_non_vrf + +- name: Query non-existing VRF (normal mode) + mso_schema_site_vrf_region_cidr: + <<: *mso_query + vrf: non_existing_vrf + ignore_errors: yes + register: nm_query_non_vrf + +- name: Verify query_non_vrf + 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: + 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[0] | int < 3 + +# USE A NON-EXISTING STATE +- name: Non-existing state for site cidr (check_mode) + mso_schema_site_vrf_region_cidr: + <<: *mso_query + state: non-existing-state + check_mode: yes + ignore_errors: yes + register: cm_non_existing_state + +- name: Non-existing state for site cidr (normal_mode) + mso_schema_site_vrf_region_cidr: + <<: *mso_query + state: non-existing-state + ignore_errors: yes + register: nm_non_existing_state + +- name: Verify non_existing_state + assert: + that: + - cm_non_existing_state is not changed + - nm_non_existing_state is not changed + - cm_non_existing_state == nm_non_existing_state + - cm_non_existing_state.msg == 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 for site cidr (check_mode) + mso_schema_site_vrf_region_cidr: + <<: *mso_query + schema: non-existing-schema + check_mode: yes + ignore_errors: yes + register: cm_non_existing_schema + +- name: Non-existing schema for site cidr (normal_mode) + mso_schema_site_vrf_region_cidr: + <<: *mso_query + schema: non-existing-schema + ignore_errors: yes + register: nm_non_existing_schema + +- name: Verify non_existing_schema + assert: + that: + - cm_non_existing_schema is not changed + - nm_non_existing_schema is not changed + - cm_non_existing_schema == nm_non_existing_schema + - cm_non_existing_schema.msg == nm_non_existing_schema.msg == "Provided schema 'non-existing-schema' does not exist" + +# USE A NON-EXISTING TEMPLATE +- name: Non-existing template for site cidr (check_mode) + mso_schema_site_vrf_region_cidr: + <<: *mso_query + template: non-existing-template + check_mode: yes + ignore_errors: yes + register: cm_non_existing_template + +- name: Non-existing template for site cidr (normal_mode) + mso_schema_site_vrf_region_cidr: + <<: *mso_query + template: non-existing-template + ignore_errors: yes + register: nm_non_existing_template + +- name: Verify non_existing_template + 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" + +# USE A NON-ASSOCIATED TEMPLATE +- name: Non-associated template for site cidr (check_mode) + mso_schema_site_vrf_region_cidr: + <<: *mso_query + template: Template 2 + check_mode: yes + ignore_errors: yes + register: cm_non_associated_template + +- name: Non-associated template for site cidr (normal_mode) + mso_schema_site_vrf_region_cidr: + <<: *mso_query + template: Template 2 + ignore_errors: yes + register: nm_non_associated_template + +- name: Verify non_associated_template + assert: + that: + - cm_non_associated_template is not changed + - nm_non_associated_template is not changed + - cm_non_associated_template == nm_non_associated_template + - cm_non_associated_template.msg == "Provided site-template association 'aws_{{ mso_site | default("ansible_test") }}-Template2' does not exist." + - nm_non_associated_template.msg == "Provided site-template association 'aws_{{ mso_site | default("ansible_test") }}-Template2' does not exist." + +# 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: + <<: *mso_present + schema: '{{ mso_schema | default("ansible_test") }}_2' + template: Template 3 + check_mode: yes + 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: + <<: *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: + that: + - cm_no_site_associated is changed + - nm_no_site_associated is changed \ No newline at end of file diff --git a/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_vrf_region_cidr_subnet/aliases b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_vrf_region_cidr_subnet/aliases new file mode 100644 index 00000000..5042c9c0 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_vrf_region_cidr_subnet/aliases @@ -0,0 +1,2 @@ +# No ACI MultiSite infrastructure, so not enabled +# unsupported diff --git a/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_vrf_region_cidr_subnet/tasks/main.yml b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_vrf_region_cidr_subnet/tasks/main.yml new file mode 100644 index 00000000..1673a6a2 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_vrf_region_cidr_subnet/tasks/main.yml @@ -0,0 +1,676 @@ +# Test code for the MSO modules +# Copyright: (c) 2020, Lionel Hercot (@lhercot) +# Copyright: (c) 2020, Shreyas Srish (@shrsr) (based on mso_schema_anp_epg_domain) +# Copyright: (c) 2018, Dag Wieers (@dagwieers) (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: + 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: + 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(true) }}' + output_level: '{{ mso_output_level | default("info") }}' + sites: "[ { 'site': 'aws_{{ mso_site | default(\"ansible_test\") }}', 'region': 'us-west-1', 'cidr': '10.0.0.0/16'}, + { 'site': 'azure_{{ mso_site | default(\"ansible_test\") }}', 'region': 'westus', 'cidr': '10.1.0.0/16'}]" + +- name: Query MSO version + mso_version: + <<: *mso_info + state: query + register: version + +- name: Ensure site exists + mso_site: + <<: *mso_info + site: 'aws_{{ mso_site | default("ansible_test") }}' + apic_username: '{{ aws_apic_username }}' + apic_password: '{{ aws_apic_password }}' + apic_site_id: '{{ aws_site_id | default(102) }}' + urls: + - https://{{ aws_apic_hostname }} + state: present + +- name: Ensure site exists + mso_site: + <<: *mso_info + site: 'azure_{{ mso_site | default("ansible_test") }}' + apic_username: '{{ azure_apic_username }}' + apic_password: '{{ azure_apic_password }}' + apic_site_id: '{{ azure_site_id | default(103) }}' + urls: + - https://{{ azure_apic_hostname }} + state: present + +- name: Remove Schemas + mso_schema: + <<: *mso_info + schema: '{{ item }}' + state: absent + loop: + - '{{ mso_schema | default("ansible_test") }}_2' + - '{{ mso_schema | default("ansible_test") }}' + +- name: Ensure tenant ansible_test exist + mso_tenant: + <<: *mso_info + tenant: ansible_test + users: + - '{{ mso_username }}' + state: present + +- name: Ensure AWS site is present under tenant ansible_test + mso_tenant_site: + <<: *mso_info + tenant: ansible_test + site: 'aws_{{ mso_site | default("ansible_test") }}' + cloud_account: '000000000000' + aws_access_key: 1 + secret_key: 0 + state: present + +- name: Ensure Azure site is present under tenant ansible_test + mso_tenant_site: + <<: *mso_info + tenant: ansible_test + site: 'azure_{{ mso_site | default("ansible_test") }}' + cloud_account: uni/tn-ansible_test/act-[9]-vendor-azure + state: present + +- name: Ensure schema 1 with Template 1 and 2 exists + mso_schema_template: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + tenant: ansible_test + template: '{{ item }}' + state: present + loop: + - Template 1 + - Template 2 + +- name: Ensure schema 2 with Template 3 exists + mso_schema_template: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}_2' + tenant: ansible_test + template: Template 3 + state: present + +- name: Add a new sites to a Template 1 + mso_schema_site: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: '{{ item.site }}' + template: Template 1 + state: present + loop: '{{ sites }}' + when: version.current.version[0] | int < 3 + +- name: Ensure VRF1 exists + mso_schema_template_vrf: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + vrf: VRF1 + state: present + +- name: Ensure region for VRF1 at site level exists + mso_schema_site_vrf_region_cidr: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + site: '{{ item.site }}' + vrf: VRF1 + region: '{{ item.region }}' + cidr: '{{ item.cidr }}' + state: present + loop: '{{ sites }}' + +# 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 + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + site: 'aws_{{ mso_site | default("ansible_test") }}' + vrf: VRF1 + region: us-west-1 + cidr: 10.0.0.0/16 + subnet: 10.0.0.0/24 + zone: us-west-1a + state: present + check_mode: yes + register: cm_add_subnet + +- name: Verify cm_add_subnet + assert: + that: + - cm_add_subnet is changed + - cm_add_subnet.previous == {} + - cm_add_subnet.current.ip == '10.0.0.0/24' + - 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: + <<: *mso_present + register: nm_add_subnet + +- name: Verify nm_add_subnet + assert: + that: + - nm_add_subnet is changed + - nm_add_subnet.previous == {} + - nm_add_subnet.current.ip == '10.0.0.0/24' + - 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: + <<: *mso_present + register: cm_add_subnet_again + +- name: Verify cm_add_subnet_again + 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: + <<: *mso_present + register: nm_add_subnet_again + +- name: Verify nm_add_subnet_again + 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: + <<: *mso_present + site: 'azure_{{ mso_site | default("ansible_test") }}' + region: westus + cidr: 10.1.0.0/16 + subnet: 10.1.0.0/24 + zone: null + check_mode: yes + register: cm_add_subnet_2 + +- name: Verify cm_add_subnet_2 + assert: + that: + - cm_add_subnet_2 is changed + - cm_add_subnet_2.previous == {} + - cm_add_subnet_2.current.ip == '10.1.0.0/24' + - 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: + <<: *mso_present + site: 'azure_{{ mso_site | default("ansible_test") }}' + region: westus + cidr: 10.1.0.0/16 + subnet: 10.1.0.0/24 + zone: null + register: nm_add_subnet_2 + +- name: Verify nm_add_subnet_2 + assert: + that: + - nm_add_subnet_2 is changed + - nm_add_subnet_2.previous == {} + - nm_add_subnet_2.current.ip == '10.1.0.0/24' + - 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: + <<: *mso_present + site: 'azure_{{ mso_site | default("ansible_test") }}' + region: westus + cidr: 10.1.0.0/16 + subnet: 10.1.1.0/24 + zone: null + vgw: true + check_mode: yes + register: cm_add_subnet_3 + +- name: Verify cm_add_subnet_3 + assert: + that: + - cm_add_subnet_3 is changed + - cm_add_subnet_3.previous == {} + - cm_add_subnet_3.current.ip == '10.1.1.0/24' + - cm_add_subnet_3.current.zone == '' + - cm_add_subnet_3.current.usage == 'gateway' + +- name: Add a second subnet to Azure CIDR in VRF1 at site level for VGW (normal mode) + mso_schema_site_vrf_region_cidr_subnet: + <<: *mso_present + site: 'azure_{{ mso_site | default("ansible_test") }}' + region: westus + cidr: 10.1.0.0/16 + subnet: 10.1.1.0/24 + zone: null + vgw: true + register: nm_add_subnet_3 + +- name: Verify nm_add_subnet_3 + assert: + that: + - nm_add_subnet_3 is changed + - nm_add_subnet_3.previous == {} + - nm_add_subnet_3.current.ip == '10.1.1.0/24' + - nm_add_subnet_3.current.zone == '' + - nm_add_subnet_3.current.usage == 'gateway' + +# QUERY SUBNETS +- name: Query subnet to AWS CIDR in VRF1 at site level (check mode) + mso_schema_site_vrf_region_cidr_subnet: &mso_query + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + site: 'aws_{{ mso_site | default("ansible_test") }}' + vrf: VRF1 + region: us-west-1 + cidr: 10.0.0.0/16 + subnet: 10.0.0.0/24 + state: query + check_mode: yes + register: cm_query_subnet + +- name: Verify cm_query_subnet + 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: + <<: *mso_query + register: nm_query_subnet + +- name: Verify nm_query_subnet + 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 + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + site: 'aws_{{ mso_site | default("ansible_test") }}' + vrf: VRF1 + region: us-west-1 + cidr: 10.0.0.0/16 + state: query + check_mode: yes + 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: + <<: *mso_query_all + site: 'azure_{{ mso_site | default("ansible_test") }}' + region: westus + cidr: 10.1.0.0/16 + state: query + check_mode: yes + register: cm_query_subnet_all_azure + +- name: Verify cm_query_subnet_all_aws and cm_query_subnet_all_azure + assert: + that: + - cm_query_subnet_all_aws is not changed + - cm_query_subnet_all_aws.current[0].ip == '10.0.0.0/24' + - cm_query_subnet_all_aws.current[0].zone == 'us-west-1a' + - cm_query_subnet_all_azure is not changed + - cm_query_subnet_all_azure.current[0].ip == '10.1.0.0/24' + - cm_query_subnet_all_azure.current[0].zone == '' + - cm_query_subnet_all_azure.current[1].ip == '10.1.1.0/24' + - cm_query_subnet_all_azure.current[1].zone == '' + +- name: Query subnet to AWS CIDR in VRF1 at site level (normal mode) + 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: + <<: *mso_query_all + site: 'azure_{{ mso_site | default("ansible_test") }}' + region: westus + cidr: 10.1.0.0/16 + state: query + register: nm_query_subnet_all_azure + +- name: Verify nm_query_subnet_all_aws and nm_query_subnet_all_azure + assert: + that: + - nm_query_subnet_all_aws is not changed + - nm_query_subnet_all_aws.current[0].ip == '10.0.0.0/24' + - nm_query_subnet_all_aws.current[0].zone == 'us-west-1a' + - nm_query_subnet_all_azure is not changed + - nm_query_subnet_all_azure.current[0].ip == '10.1.0.0/24' + - nm_query_subnet_all_azure.current[0].zone == '' + - nm_query_subnet_all_azure.current[1].ip == '10.1.1.0/24' + - nm_query_subnet_all_azure.current[1].zone == '' + +# REMOVE SUBNETS +- name: Remove Subnet from CIDR (check_mode) + mso_schema_site_vrf_region_cidr_subnet: + <<: *mso_present + state: absent + check_mode: yes + register: cm_remove_subnet + +- name: Verify cm_remove_subnet + 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: + <<: *mso_present + state: absent + register: nm_remove_subnet + +- name: Verify nm_remove_subnet + 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: + <<: *mso_present + state: absent + check_mode: yes + register: cm_remove_subnet_again + +- name: Verify cm_remove_subnet_again + 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: + <<: *mso_present + state: absent + register: nm_remove_subnet_again + +- name: Verify nm_remove_subnet_again + assert: + that: + - nm_remove_subnet_again is not changed + - nm_remove_subnet_again.current == {} + +# QUERY NON-EXISTING subnet in CIDR +- name: Query non-existing subnet (check_mode) + mso_schema_site_vrf_region_cidr_subnet: + <<: *mso_query + subnet: non_existing_subnet + check_mode: yes + ignore_errors: yes + register: cm_query_non_subnet + +- name: Query non-existing subnet (normal mode) + mso_schema_site_vrf_region_cidr_subnet: + <<: *mso_query + subnet: non_existing_subnet + ignore_errors: yes + register: nm_query_non_subnet + +- name: Verify query_non_subnet + assert: + that: + - cm_query_non_subnet is not changed + - nm_query_non_subnet is not changed + - cm_query_non_subnet == nm_query_non_subnet + - cm_query_non_subnet.msg is match("Subnet IP 'non_existing_subnet' not found") + - nm_query_non_subnet.msg is match("Subnet IP 'non_existing_subnet' not found") + +# QUERY NON-EXISTING CIDR +- name: Query non-existing CIDR (check_mode) + mso_schema_site_vrf_region_cidr_subnet: + <<: *mso_query + cidr: non_existing_cidr + check_mode: yes + ignore_errors: yes + register: cm_query_non_cidr + +- name: Query non-existing CIDR (normal mode) + mso_schema_site_vrf_region_cidr_subnet: + <<: *mso_query + cidr: non_existing_cidr + ignore_errors: yes + register: nm_query_non_cidr + +- name: Verify query_non_cidr + assert: + that: + - cm_query_non_cidr is not changed + - nm_query_non_cidr is not changed + - cm_query_non_cidr == nm_query_non_cidr + - 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." + +# QUERY NON-EXISTING region +- name: Query non-existing region (check_mode) + mso_schema_site_vrf_region_cidr_subnet: + <<: *mso_query + region: non_existing_region + check_mode: yes + ignore_errors: yes + register: cm_query_non_region + +- name: Query non-existing region (normal mode) + mso_schema_site_vrf_region_cidr_subnet: + <<: *mso_query + region: non_existing_region + ignore_errors: yes + register: nm_query_non_region + +- name: Verify query_non_region + assert: + that: + - cm_query_non_region is not changed + - nm_query_non_region is not changed + - cm_query_non_region == nm_query_non_region + - cm_query_non_region.msg == nm_query_non_region.msg == "Provided region 'non_existing_region' does not exist. Existing regions{{':'}} us-west-1. Use mso_schema_site_vrf_region_cidr to create it." + +# QUERY NON-EXISTING VRF +- name: Query non-existing VRF (check_mode) + mso_schema_site_vrf_region_cidr_subnet: + <<: *mso_query + vrf: non_existing_vrf + check_mode: yes + ignore_errors: yes + register: cm_query_non_vrf + +- name: Query non-existing VRF (normal mode) + mso_schema_site_vrf_region_cidr_subnet: + <<: *mso_query + vrf: non_existing_vrf + ignore_errors: yes + register: nm_query_non_vrf + +- name: Verify query_non_vrf + assert: + that: + - cm_query_non_vrf is not changed + - nm_query_non_vrf is not changed + - cm_query_non_vrf == nm_query_non_vrf + - cm_query_non_vrf.msg == nm_query_non_vrf.msg == "Provided vrf 'non_existing_vrf' does not exist at site level. Use mso_schema_site_vrf_region_cidr to create it." + +# USE A NON-EXISTING STATE +- name: Non-existing state for site cidr subnet (check_mode) + mso_schema_site_vrf_region_cidr_subnet: + <<: *mso_query + state: non-existing-state + check_mode: yes + ignore_errors: yes + register: cm_non_existing_state + +- name: Non-existing state for site cidr subnet (normal_mode) + mso_schema_site_vrf_region_cidr_subnet: + <<: *mso_query + state: non-existing-state + ignore_errors: yes + register: nm_non_existing_state + +- name: Verify non_existing_state + assert: + that: + - cm_non_existing_state is not changed + - nm_non_existing_state is not changed + - cm_non_existing_state == nm_non_existing_state + - cm_non_existing_state.msg == 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 for site cidr subnet (check_mode) + mso_schema_site_vrf_region_cidr_subnet: + <<: *mso_query + schema: non-existing-schema + check_mode: yes + ignore_errors: yes + register: cm_non_existing_schema + +- name: Non-existing schema for site cidr subnet (normal_mode) + mso_schema_site_vrf_region_cidr_subnet: + <<: *mso_query + schema: non-existing-schema + ignore_errors: yes + register: nm_non_existing_schema + +- name: Verify non_existing_schema + assert: + that: + - cm_non_existing_schema is not changed + - nm_non_existing_schema is not changed + - cm_non_existing_schema == nm_non_existing_schema + - cm_non_existing_schema.msg == nm_non_existing_schema.msg == "Provided schema 'non-existing-schema' does not exist" + +# USE A NON-EXISTING TEMPLATE +- name: Non-existing template for site cidr subnet (check_mode) + mso_schema_site_vrf_region_cidr_subnet: + <<: *mso_query + template: non-existing-template + check_mode: yes + ignore_errors: yes + register: cm_non_existing_template + +- name: Non-existing template for site cidr subnet (normal_mode) + mso_schema_site_vrf_region_cidr_subnet: + <<: *mso_query + template: non-existing-template + ignore_errors: yes + register: nm_non_existing_template + +- name: Verify non_existing_template + 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" + +# USE A NON-ASSOCIATED TEMPLATE +- name: Non-associated template for site cidr subnet (check_mode) + mso_schema_site_vrf_region_cidr_subnet: + <<: *mso_query + template: Template 2 + check_mode: yes + ignore_errors: yes + register: cm_non_associated_template + +- name: Non-associated template for site cidr subnet (normal_mode) + mso_schema_site_vrf_region_cidr_subnet: + <<: *mso_query + template: Template 2 + ignore_errors: yes + register: nm_non_associated_template + +- name: Verify non_associated_template + assert: + that: + - cm_non_associated_template is not changed + - nm_non_associated_template is not changed + - cm_non_associated_template == nm_non_associated_template + - cm_non_associated_template.msg is match("Provided site/siteId/template 'aws_ansible_test/[0-9a-zA-Z]*/Template2' does not exist. Existing siteIds/templates{{':'}} [0-9a-zA-Z]*/Template1") + - nm_non_associated_template.msg is match("Provided site/siteId/template 'aws_ansible_test/[0-9a-zA-Z]*/Template2' does not exist. Existing siteIds/templates{{':'}} [0-9a-zA-Z]*/Template1") + +# 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: + <<: *mso_query + schema: '{{ mso_schema | default("ansible_test") }}_2' + template: Template 3 + check_mode: yes + ignore_errors: yes + 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: + <<: *mso_query + schema: '{{ mso_schema | default("ansible_test") }}_2' + template: Template 3 + ignore_errors: yes + register: nm_no_site_associated + +- name: Verify cm_no_site_associated and nm_no_site_associated + 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." + +# 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: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + site: 'aws_{{ mso_site | default("ansible_test") }}' + vrf: VRF1 + region: us-west-1 + hub_network: + name: hub-test + tenant: infra + state: present + +- name: Add a new subnet to AWS CIDR in VRF1 at site level + mso_schema_site_vrf_region_cidr_subnet: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + site: 'aws_{{ mso_site | default("ansible_test") }}' + vrf: VRF1 + region: us-west-1 + cidr: 10.0.0.0/16 + subnet: 10.0.0.0/24 + zone: us-west-1a + hub_network: true + state: present + register: nm_add_subnet_hub_network + +- name: Verify nm_add_subnet_hub_network + 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/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_vrf_region_hub_network/aliases b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_vrf_region_hub_network/aliases new file mode 100644 index 00000000..5042c9c0 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_vrf_region_hub_network/aliases @@ -0,0 +1,2 @@ +# No ACI MultiSite infrastructure, so not enabled +# unsupported diff --git a/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_vrf_region_hub_network/tasks/hub_network.yml b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_vrf_region_hub_network/tasks/hub_network.yml new file mode 100644 index 00000000..ecf934c4 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_vrf_region_hub_network/tasks/hub_network.yml @@ -0,0 +1,708 @@ +# Test code for the MSO modules +# Copyright: (c) 2020, Lionel Hercot (@lhercot) +# Copyright: (c) 2020, Cindy Zhao (@cizhao) + +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +# CLEAN ENVIRONMENT +- name: Set vars + 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(true) }}' + output_level: '{{ mso_output_level | default("info") }}' + sites: "['aws_{{ mso_site | default(\"ansible_test\") }}', + 'azure_{{ mso_site | default(\"ansible_test\") }}', + '{{ mso_site | default(\"ansible_test\") }}']" + +- name: Ensure site exists + mso_site: + <<: *mso_info + site: 'aws_{{ mso_site | default("ansible_test") }}' + apic_username: '{{ aws_apic_username }}' + apic_password: '{{ aws_apic_password }}' + apic_site_id: '{{ aws_site_id | default(102) }}' + urls: + - https://{{ aws_apic_hostname }} + state: present + +- name: Ensure site exists + mso_site: + <<: *mso_info + site: 'azure_{{ mso_site | default("ansible_test") }}' + apic_username: '{{ azure_apic_username }}' + apic_password: '{{ azure_apic_password }}' + apic_site_id: '{{ azure_site_id | default(103) }}' + urls: + - https://{{ azure_apic_hostname }} + state: present + +- name: Remove Schemas + mso_schema: + <<: *mso_info + schema: '{{ item }}' + state: absent + loop: + - '{{ mso_schema | default("ansible_test") }}_2' + - '{{ mso_schema | default("ansible_test") }}' + +- name: Ensure tenant ansible_test exist + mso_tenant: + <<: *mso_info + tenant: ansible_test + # sites: + # - '{{ mso_site | default("ansible_test") }}' + users: + - '{{ mso_username }}' + state: present + +- name: Ensure AWS site is present under tenant ansible_test + mso_tenant_site: + <<: *mso_info + tenant: ansible_test + site: 'aws_{{ mso_site | default("ansible_test") }}' + cloud_account: '000000000000' + aws_access_key: 1 + secret_key: 0 + state: present + +- name: Ensure Azure site is present under tenant ansible_test + mso_tenant_site: + <<: *mso_info + tenant: ansible_test + site: 'azure_{{ mso_site | default("ansible_test") }}' + cloud_account: uni/tn-ansible_test/act-[9]-vendor-azure + state: present + +- name: Ensure schema 1 with Template 1 and 2 exists + mso_schema_template: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + tenant: ansible_test + template: '{{ item }}' + state: present + loop: + - Template 1 + - Template 2 + +- name: Ensure schema 2 with Template 3 exists + mso_schema_template: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}_2' + tenant: ansible_test + template: Template 3 + state: present + +- name: Ensure VRF1 exists + mso_schema_template_vrf: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + vrf: VRF1 + state: present + +- name: Add a new CIDR in VRF1 at AWS site level (check mode) + mso_schema_site_vrf_region_cidr: &mso_present + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + site: 'aws_{{ mso_site | default("ansible_test") }}' + vrf: VRF1 + region: us-west-1 + cidr: 10.0.0.0/16 + primary: true + state: present + check_mode: yes + register: cm_add_cidr + +- name: Verify cm_add_cidr + assert: + that: + - cm_add_cidr is changed + - cm_add_cidr.previous == {} + - cm_add_cidr.current.ip == '10.0.0.0/16' + - 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: + <<: *mso_present + register: nm_add_cidr + +- name: Verify nm_add_cidr + assert: + that: + - nm_add_cidr is changed + - nm_add_cidr.previous == {} + - nm_add_cidr.current.ip == '10.0.0.0/16' + - nm_add_cidr.current.primary == true + +# 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: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + site: 'aws_{{ mso_site | default("ansible_test") }}' + vrf: VRF1 + region: us-west-1 + hub_network: + name: hub-test + tenant: infra + state: present + check_mode: yes + 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: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + site: 'aws_{{ mso_site | default("ansible_test") }}' + vrf: VRF1 + region: us-west-1 + hub_network: + name: hub-test + tenant: infra + state: present + register: nm_add_hub_network + +- name: Verify cm_add_hub_network and nm_add_hub_network + assert: + that: + - cm_add_hub_network is changed + - nm_add_hub_network is changed + - cm_add_hub_network.previous == {} + - nm_add_hub_network.previous == {} + - cm_add_hub_network.current.name == "hub-test" + - cm_add_hub_network.current.tenantName == "infra" + - nm_add_hub_network.current.name == "hub-test" + - nm_add_hub_network.current.tenantName == "infra" + +# 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: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + site: 'aws_{{ mso_site | default("ansible_test") }}' + vrf: VRF1 + region: us-west-1 + hub_network: + name: hub-test + tenant: infra + state: present + register: nm_add_hub_network_again + +- name: Verify nm_add_hub_network_again + 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" + - nm_add_hub_network_again.previous.tenantName == nm_add_hub_network_again.current.tenantName == "infra" + +# 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: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + site: 'aws_{{ mso_site | default("ansible_test") }}' + vrf: VRF1 + region: us-west-1 + hub_network: + name: hub-default + tenant: infra + state: present + check_mode: yes + 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: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + site: 'aws_{{ mso_site | default("ansible_test") }}' + vrf: VRF1 + region: us-west-1 + hub_network: + name: hub-default + tenant: infra + state: present + register: nm_update_hub_network + +- name: Verify cm_update_hub_network and nm_update_hub_network + assert: + that: + - cm_update_hub_network is changed + - nm_update_hub_network is changed + - cm_update_hub_network.previous.name == "hub-test" + - cm_update_hub_network.previous.tenantName == "infra" + - cm_update_hub_network.current.name == "hub-default" + - cm_update_hub_network.current.tenantName == "infra" + - nm_update_hub_network.previous.name == "hub-test" + - nm_update_hub_network.previous.tenantName == "infra" + - nm_update_hub_network.current.name == "hub-default" + - nm_update_hub_network.current.tenantName == "infra" + +# Query Hub Network +- name: Query hub network in VRF1 region us-west-1 at AWS site level + mso_schema_site_vrf_region_hub_network: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + site: 'aws_{{ mso_site | default("ansible_test") }}' + vrf: VRF1 + region: us-west-1 + state: query + check_mode: yes + register: cm_query_hub_network + +- name: Verify cm_query_hub_network + assert: + that: + - cm_query_hub_network is not changed + - cm_query_hub_network.current.name == "hub-default" + - cm_query_hub_network.current.tenantName == "infra" + +# 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: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + site: 'aws_{{ mso_site | default("ansible_test") }}' + vrf: VRF1 + region: us-west-1 + state: absent + check_mode: yes + 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: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + site: 'aws_{{ mso_site | default("ansible_test") }}' + vrf: VRF1 + region: us-west-1 + state: absent + register: nm_remove_hub_network + +- name: Verify cm_remove_hub_network and nm_remove_hub_network + assert: + that: + - cm_remove_hub_network is changed + - cm_remove_hub_network.current == {} + - cm_remove_hub_network.previous.name == "hub-default" + - cm_remove_hub_network.previous.tenantName == "infra" + - nm_remove_hub_network is changed + - nm_remove_hub_network.current == {} + - nm_remove_hub_network.previous.name == "hub-default" + - nm_remove_hub_network.previous.tenantName == "infra" + +# 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: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + site: 'aws_{{ mso_site | default("ansible_test") }}' + vrf: VRF1 + region: us-west-1 + state: absent + check_mode: yes + 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: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + site: 'aws_{{ mso_site | default("ansible_test") }}' + vrf: VRF1 + region: us-west-1 + state: absent + register: nm_remove_hub_network_again + +- name: Verify cm_remove_hub_network_again and nm_remove_hub_network_again + assert: + that: + - cm_remove_hub_network_again is not changed + - nm_remove_hub_network_again is not changed + - cm_remove_hub_network_again.previous == cm_remove_hub_network_again.current == {} + - nm_remove_hub_network_again.previous == nm_remove_hub_network_again.current == {} + +# query when hub network does not exist +- name: Query non_existing_hub_network + mso_schema_site_vrf_region_hub_network: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + site: 'aws_{{ mso_site | default("ansible_test") }}' + vrf: VRF1 + region: us-west-1 + state: query + ignore_errors: yes + register: query_non_existing_hub_network + +- name: Verify query_non_existing_hub_network + 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: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + site: 'aws_{{ mso_site | default("ansible_test") }}' + vrf: VRF1 + region: us-west-1 + hub_network: + name: hub-test + tenant: infra + state: present + register: re_add_hub_network + +- name: Verify re_add_hub_network + assert: + that: + - re_add_hub_network is changed + - re_add_hub_network.previous == {} + - re_add_hub_network.current.name == "hub-test" + - re_add_hub_network.current.tenantName == "infra" + +# QUERY NON-EXISTING region +- name: Query non-existing region (check_mode) + mso_schema_site_vrf_region_hub_network: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + site: 'aws_{{ mso_site | default("ansible_test") }}' + vrf: VRF1 + region: non_existing_region + state: query + ignore_errors: yes + check_mode: yes + register: cm_query_non_region + +- name: Query non-existing region (normal mode) + mso_schema_site_vrf_region_hub_network: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + site: 'aws_{{ mso_site | default("ansible_test") }}' + vrf: VRF1 + region: non_existing_region + state: query + ignore_errors: yes + register: nm_query_non_region + +- name: Verify query_non_region + assert: + that: + - cm_query_non_region is not changed + - nm_query_non_region is not changed + - cm_query_non_region == nm_query_non_region + - cm_query_non_region.msg == nm_query_non_region.msg == "Provided region 'non_existing_region' does not exist. Existing regions{{':'}} us-west-1" + +# QUERY NON-EXISTING VRF +- name: Query non-existing VRF (check_mode) + mso_schema_site_vrf_region_hub_network: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + site: 'aws_{{ mso_site | default("ansible_test") }}' + vrf: non_existing_vrf + region: us-west-1 + state: query + check_mode: yes + ignore_errors: yes + register: cm_query_non_vrf + +- name: Query non-existing VRF (normal mode) + mso_schema_site_vrf_region_hub_network: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + site: 'aws_{{ mso_site | default("ansible_test") }}' + vrf: non_existing_vrf + region: us-west-1 + state: query + ignore_errors: yes + register: nm_query_non_vrf + +- name: Verify query_non_vrf + assert: + that: + - cm_query_non_vrf is not changed + - nm_query_non_vrf is not changed + - cm_query_non_vrf == nm_query_non_vrf + - cm_query_non_vrf.msg == nm_query_non_vrf.msg == "Provided vrf 'non_existing_vrf' does not exist. Existing vrfs{{':'}} VRF1" + +# USE A NON-EXISTING STATE +- name: Non-existing state for site hub network (check_mode) + mso_schema_site_vrf_region_hub_network: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + site: 'aws_{{ mso_site | default("ansible_test") }}' + vrf: VRF1 + region: us-west-1 + state: non-existing-state + check_mode: yes + ignore_errors: yes + register: cm_non_existing_state + +- name: Non-existing state for hub network (normal_mode) + mso_schema_site_vrf_region_hub_network: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + site: 'aws_{{ mso_site | default("ansible_test") }}' + vrf: VRF1 + region: us-west-1 + state: non-existing-state + ignore_errors: yes + register: nm_non_existing_state + +- name: Verify non_existing_state + assert: + that: + - cm_non_existing_state is not changed + - nm_non_existing_state is not changed + - cm_non_existing_state == nm_non_existing_state + - cm_non_existing_state.msg == 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 for site hub network (check_mode) + mso_schema_site_vrf_region_hub_network: + <<: *mso_info + schema: non-existing-schema + template: Template 1 + site: 'aws_{{ mso_site | default("ansible_test") }}' + vrf: VRF1 + region: us-west-1 + state: query + check_mode: yes + ignore_errors: yes + register: cm_non_existing_schema + +- name: Non-existing schema for site hub network (normal_mode) + mso_schema_site_vrf_region_hub_network: + <<: *mso_info + schema: non-existing-schema + template: Template 1 + site: 'aws_{{ mso_site | default("ansible_test") }}' + vrf: VRF1 + region: us-west-1 + state: query + ignore_errors: yes + register: nm_non_existing_schema + +- name: Verify non_existing_schema + assert: + that: + - cm_non_existing_schema is not changed + - nm_non_existing_schema is not changed + - cm_non_existing_schema == nm_non_existing_schema + - cm_non_existing_schema.msg == nm_non_existing_schema.msg == "Provided schema 'non-existing-schema' does not exist" + +# USE A NON-EXISTING TEMPLATE +- name: Non-existing template for site hub network (check_mode) + mso_schema_site_vrf_region_hub_network: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: non-existing-template + site: 'aws_{{ mso_site | default("ansible_test") }}' + vrf: VRF1 + region: us-west-1 + state: query + check_mode: yes + ignore_errors: yes + register: cm_non_existing_template + +- name: Non-existing template for site hub network (normal_mode) + mso_schema_site_vrf_region_hub_network: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: non-existing-template + site: 'aws_{{ mso_site | default("ansible_test") }}' + vrf: VRF1 + region: us-west-1 + state: query + ignore_errors: yes + register: nm_non_existing_template + +- name: Verify non_existing_template + 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" + +# USE A NON_EXISTING_SITE_TEMPLATE +- name: non_existing_site_template (check_mode) + mso_schema_site_vrf_region_hub_network: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 2 + site: 'aws_{{ mso_site | default("ansible_test") }}' + vrf: VRF1 + region: us-west-1 + state: query + check_mode: yes + ignore_errors: yes + register: cm_non_existing_site_template + +- name: non_existing_site_template (normal_mode) + mso_schema_site_vrf_region_hub_network: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 2 + site: 'aws_{{ mso_site | default("ansible_test") }}' + vrf: VRF1 + region: us-west-1 + state: query + ignore_errors: yes + register: nm_non_existing_site_template + +- name: Verify cm_non_existing_site_template and nm_non_existing_site_template + 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-template association 'aws_ansible_test-Template2' does not exist." + +# USE A NON_EXISTING_SITE +- name: non_existing_site (check_mode) + mso_schema_site_vrf_region_hub_network: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + site: non_existing_site + vrf: VRF1 + region: us-west-1 + state: query + check_mode: yes + ignore_errors: yes + register: cm_non_existing_site + +- name: non_existing_site (normal_mode) + mso_schema_site_vrf_region_hub_network: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + site: non_existing_site + vrf: VRF1 + region: us-west-1 + state: query + ignore_errors: yes + register: nm_non_existing_site + +- name: Verify cm_non_existing_site and nm_non_existing_site + assert: + that: + - cm_non_existing_site is not changed + - nm_non_existing_site is not changed + - cm_non_existing_site.msg == nm_non_existing_site.msg == "Site 'non_existing_site' is not a valid site name." + +# 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 + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + site: 'aws_{{ mso_site | default("ansible_test") }}' + vrf: VRF1 + region: us-west-1 + cidr: 10.1.0.0/16 + primary: false + state: present + check_mode: yes + register: cm_add_cidr + +- name: Verify cm_add_cidr + assert: + that: + - cm_add_cidr is changed + - cm_add_cidr.previous == {} + - cm_add_cidr.current.ip == '10.1.0.0/16' + - 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: + <<: *cidr_present + register: nm_add_cidr + +- name: Verify nm_add_cidr + assert: + that: + - nm_add_cidr is changed + - nm_add_cidr.previous == {} + - nm_add_cidr.current.ip == '10.1.0.0/16' + - nm_add_cidr.current.primary == false + +# 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: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + site: 'aws_{{ mso_site | default("ansible_test") }}' + vrf: VRF1 + region: us-west-1 + state: query + register: query_after_region_update + +- name: Verify query_after_region_update + assert: + that: + - query_after_region_update is not changed + - query_after_region_update.current.name == "hub-test" + - query_after_region_update.current.tenantName == "infra" + +# 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: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}_2' + template: Template 3 + site: 'aws_{{ mso_site | default("ansible_test") }}' + vrf: VRF1 + region: us-west-1 + hub_network: + name: hub-test + tenant: infra + state: present + ignore_errors: yes + check_mode: yes + 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: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}_2' + template: Template 3 + site: 'aws_{{ mso_site | default("ansible_test") }}' + vrf: VRF1 + region: us-west-1 + hub_network: + name: hub-test + tenant: infra + state: present + ignore_errors: yes + register: nm_no_site_associated + +- name: Verify cm_no_site_associated and nm_no_site_associated + 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 diff --git a/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_vrf_region_hub_network/tasks/main.yml b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_vrf_region_hub_network/tasks/main.yml new file mode 100644 index 00000000..371643d8 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_vrf_region_hub_network/tasks/main.yml @@ -0,0 +1,32 @@ +# Test code for the MSO modules +# Copyright: (c) 2020, Lionel Hercot (@lhercot) +# Copyright: (c) 2020, Cindy Zhao (@cizhao) + +# 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.' + 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: + 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(true) }}' + output_level: '{{ mso_output_level | default("info") }}' + +- name: Query MSO version + mso_version: + <<: *mso_info + state: query + register: version + +- name: Import hub_network tasks if MSO version is higher than 3.0 + import_tasks: hub_network.yml + when: version.current.version[0] | int >= 3 \ No newline at end of file diff --git a/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template/aliases b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template/aliases new file mode 100644 index 00000000..5042c9c0 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template/aliases @@ -0,0 +1,2 @@ +# No ACI MultiSite infrastructure, so not enabled +# unsupported diff --git a/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template/tasks/main.yml b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template/tasks/main.yml new file mode 100644 index 00000000..e8f6fecd --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template/tasks/main.yml @@ -0,0 +1,280 @@ +# Test code for the MSO modules +# Copyright: (c) 2020, Shreyas Srish (@shrsr) + +# 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.' + 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: + 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(true) }}' + output_level: '{{ mso_output_level | default("info") }}' + +- name: Ensure site exists + 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: yes + +- name: Remove schemas + mso_schema: + <<: *mso_info + schema: '{{ item }}' + state: absent + loop: + - '{{ mso_schema | default("ansible_test") }}_2' + - '{{ mso_schema | default("ansible_test") }}' + +- name: Ensure tenant ansible_test exists + mso_tenant: + <<: *mso_info + tenant: ansible_test + users: + - '{{ mso_username }}' + sites: + - '{{ mso_site | default("ansible_test") }}' + state: present + +- name: Ensure schema 1 with Template 1 exists in check mode + mso_schema_template: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + tenant: ansible_test + template: Template 1 + state: present + check_mode: yes + register: add_template1_schema1_cm + +- name: Ensure schema 1 with Template 1 exists + mso_schema_template: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + tenant: ansible_test + template: Template 1 + state: present + register: add_template1_schema1 + +- name: Ensure schema 1 with Template 2 exists + mso_schema_template: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + tenant: ansible_test + template: Template 2 + state: present + register: add_template2_schema1 + +- name: Ensure schema 2 with Template 3 exists + mso_schema_template: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}_2' + tenant: ansible_test + template: Template 3 + state: present + register: add_template3_schema2 + +- name: Ensure schema 2 with Template 3 exists again + mso_schema_template: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}_2' + tenant: ansible_test + template: Template 3 + state: present + register: add_template3_schema2_again + +- name: Update display name of Template 3 in schema 2 + mso_schema_template: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}_2' + tenant: ansible_test + template: Template 3 + display_name: Temp 3 + state: present + register: update_template3_schema2 + +- name: Verify add + assert: + that: + - add_template1_schema1_cm is changed + - add_template1_schema1_cm.current.name == 'Template1' + - add_template1_schema1 is changed + - add_template1_schema1.current.name == 'Template1' + - add_template2_schema1 is changed + - add_template2_schema1.current.name == 'Template2' + - add_template3_schema2 is changed + - add_template3_schema2.current.name == 'Template3' + - update_template3_schema2 is changed + - add_template3_schema2_again is not changed + - update_template3_schema2.current.displayName == 'Temp 3' + +- name: Query Template 1 in Schema 1 + mso_schema_template: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + tenant: ansible_test + template: Template 1 + state: query + register: query_template1_schema1 + +- name: Query all Templates in Schema 1 + mso_schema_template: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + tenant: ansible_test + state: query + register: query_all_templates_schema1 + +- name: Verify query + assert: + that: + - query_template1_schema1 is not changed + - query_template1_schema1.current.name == 'Template1' + - query_all_templates_schema1 is not changed + - query_all_templates_schema1.current | length == 2 + +- name: Remove Template 1 of Schema 1 + mso_schema_template: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + tenant: ansible_test + template: Template 1 + state: absent + ignore_errors: yes + register: remove_template1_schema1 + +- name: Remove Template 2 of Schema 1 + mso_schema_template: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + tenant: ansible_test + template: Template 2 + state: absent + register: remove_template2_schema1 + + +- name: Remove non_existing_template + mso_schema_template: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}_2' + tenant: ansible_test + template: non_existing_template + state: absent + ignore_errors: yes + register: remove_template_non_existing_template + +- name: Remove Template 3 in schema 2 in check mode + mso_schema_template: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}_2' + tenant: ansible_test + template: Template 3 + state: absent + check_mode: yes + register: remove_template3_schema2_cm + +- name: Remove Template 3 in schema 2 in normal mode + mso_schema_template: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}_2' + tenant: ansible_test + template: Template 3 + state: absent + register: remove_template3_schema2_nm + +- name: Remove Template 3 in schema 2 again + mso_schema_template: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}_2' + tenant: ansible_test + template: Template 3 + state: absent + register: remove_template3_schema2_nm_again + +- name: non_existing_schema + mso_schema_template: + <<: *mso_info + schema: non_schema + tenant: ansible_test + template: Template 4 + state: absent + ignore_errors: yes + register: remove_template_non_existing_schema + +- name: Verify remove + assert: + that: + - remove_template1_schema1.current == {} + - remove_template1_schema1.previous.name == 'Template1' + - remove_template2_schema1.current == {} + - remove_template2_schema1.previous.name == 'Template2' + - remove_template3_schema2_cm.current == {} + - remove_template3_schema2_cm.previous.name == 'Template3' + - remove_template3_schema2_nm.current == {} + - remove_template3_schema2_nm.previous.name == 'Template3' + - remove_template3_schema2_nm_again is not changed + - remove_template_non_existing_schema is not changed + - remove_template_non_existing_template is not changed + +# USE NON-EXISTING STATE +- name: non_existing_state state + mso_schema_template: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + tenant: ansible_test + template: Template 2 + state: non_existing_state + ignore_errors: yes + register: non_existing_state + +- name: Verify non_existing_state + 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: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + tenant: ansible_test + template: non_existing_template + state: query + ignore_errors: yes + register: non_existing_template + +- name: Verify non_existing_template + 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: + <<: *mso_info + schema: non_schema + tenant: ansible_test + state: query + ignore_errors: yes + register: absent_template + +- name: Verify absent_template + assert: + that: + - absent_template is not changed + - absent_template.current == [] \ No newline at end of file diff --git a/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_anp/aliases b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_anp/aliases new file mode 100644 index 00000000..5042c9c0 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_anp/aliases @@ -0,0 +1,2 @@ +# No ACI MultiSite infrastructure, so not enabled +# unsupported diff --git a/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_anp/tasks/main.yml b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_anp/tasks/main.yml new file mode 100644 index 00000000..075f0f6c --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_anp/tasks/main.yml @@ -0,0 +1,265 @@ +# Test code for the MSO modules +# Copyright: (c) 2020, Cindy Zhao (@cizhao) + +# 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.' + 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: + 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") }}' + +- name: Remove schemas + mso_schema: + <<: *mso_info + schema: '{{ item }}' + state: absent + loop: + - '{{ mso_schema | default("ansible_test") }}_2' + - '{{ mso_schema | default("ansible_test") }}' + +- name: Ensure tenant ansible_test exist + mso_tenant: + <<: *mso_info + tenant: ansible_test + users: + - '{{ mso_username }}' + state: present + +- name: Ensure schema 1 with Template 1 exist + mso_schema_template: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + tenant: ansible_test + template: Template 1 + state: present + +- name: Ensure schema 1 with Template 2 exist + mso_schema_template: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + tenant: ansible_test + template: Template 2 + state: present + +- name: Ensure schema 2 with Template 3 exist + mso_schema_template: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}_2' + tenant: ansible_test + template: Template 3 + state: present + +- name: Ensure ANP exist (check_mode) + mso_schema_template_anp: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + anp: ANP + state: present + check_mode: yes + register: cm_create_anp + +- name: Ensure ANP exist (normal_mode) + mso_schema_template_anp: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + anp: ANP + state: present + register: nm_create_anp + +- name: Create ANP again (normal_mode) + mso_schema_template_anp: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + anp: ANP + state: present + register: nm_create_anp_again + +- name: Verify cm_create_anp, nm_create_anp and nm_create_anp_again + assert: + that: + - cm_create_anp is changed + - nm_create_anp is changed + - nm_create_anp_again is not changed + - cm_create_anp.previous == {} + - cm_create_anp.current.displayName == "ANP" + - cm_create_anp.current.name == "ANP" + - cm_create_anp.current.epgs == [] + - nm_create_anp.previous == {} + - nm_create_anp.current.displayName == "ANP" + - nm_create_anp.current.name == "ANP" + - nm_create_anp.current.epgs == [] + - nm_create_anp_again.previous == nm_create_anp_again.current + - nm_create_anp_again.current.displayName == "ANP" + - nm_create_anp_again.current.name == "ANP" + - nm_create_anp_again.current.epgs == [] + +- name: Create another anp (normal_mode) + mso_schema_template_anp: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + anp: ANP_2 + display_name: another anp + state: present + register: nm_create_another_anp + +- name: Verify nm_create_another_anp + assert: + that: + - nm_create_another_anp is changed + - nm_create_another_anp.previous == {} + - nm_create_another_anp.current.displayName == "another anp" + - nm_create_another_anp.current.name == "ANP_2" + - nm_create_another_anp.current.epgs == [] + +- name: Change anp (normal_mode) + mso_schema_template_anp: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + anp: ANP + display_name: displayName for ANP + state: present + register: nm_change_anp + +- name: Verify nm_change_anp + assert: + that: + - nm_change_anp is changed + - nm_change_anp.previous.name == nm_change_anp.current.name == "ANP" + - nm_change_anp.previous.displayName == "ANP" + - nm_change_anp.current.displayName == "displayName for ANP" + - nm_change_anp.previous.epgs == nm_change_anp.current.epgs == [] + +- name: Query anp + mso_schema_template_anp: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + anp: ANP + state: query + register: query_anp + +- name: Verify query_anp + assert: + that: + - query_anp is not changed + - query_anp.current.name == "ANP" + - query_anp.current.epgs == [] + - query_anp.current.displayName == "displayName for ANP" + +- name: Query all + mso_schema_template_anp: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + state: query + register: query_all + +- name: Verify query_all + assert: + that: + - query_all is not changed + - query_all.current | length == 2 + +- name: Query non_existing anp + mso_schema_template_anp: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + anp: non_existing_anp + state: query + ignore_errors: yes + register: query_non_existing_anp + +- name: Verify query_non_existing_anp + assert: + that: + - query_non_existing_anp.msg == "ANP 'non_existing_anp' not found" + +- name: Use non_existing schema + mso_schema_template_anp: + <<: *mso_info + schema: non_existing_schema + template: Template 1 + anp: ANP + state: query + ignore_errors: yes + register: query_non_existing_schema + +- name: Use non_existing template + mso_schema_template_anp: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: non_existing_template + anp: ANP + state: query + ignore_errors: yes + register: query_non_existing_template + +- name: Verify query_non_existing_schema and query_non_existing_template + 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: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + anp: ANP + state: absent + check_mode: yes + register: cm_rm_anp + +- name: Remove anp (normal_mode) + mso_schema_template_anp: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + anp: ANP + state: absent + register: nm_rm_anp + +- name: Verify cm_rm_anp and nm_rm_anp + assert: + that: + - cm_rm_anp is changed + - nm_rm_anp is changed + - nm_rm_anp.previous == cm_rm_anp.previous + - nm_rm_anp.current == cm_rm_anp.current == {} + - nm_rm_anp.previous.name == cm_rm_anp.previous.name == "ANP" + - nm_rm_anp.previous.displayName == cm_rm_anp.previous.displayName == "displayName for ANP" + - nm_rm_anp.previous.epgs == cm_rm_anp.previous.epgs == [] + +- name: Remove anp again + mso_schema_template_anp: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + anp: ANP + state: absent + register: nm_rm_anp_again + +- name: Verify nm_rm_anp_again + assert: + that: + - nm_rm_anp_again is not changed + - nm_rm_anp_again.previous == nm_rm_anp_again.current == {} diff --git a/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_anp_epg/aliases b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_anp_epg/aliases new file mode 100644 index 00000000..5042c9c0 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_anp_epg/aliases @@ -0,0 +1,2 @@ +# No ACI MultiSite infrastructure, so not enabled +# unsupported diff --git a/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_anp_epg/tasks/main.yml b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_anp_epg/tasks/main.yml new file mode 100644 index 00000000..d64ca266 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_anp_epg/tasks/main.yml @@ -0,0 +1,1192 @@ +# Test code for the MSO modules +# Copyright: (c) 2020, Lionel Hercot (@lhercot) +# Copyright: (c) 2018, Dag Wieers (@dagwieers) (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: + 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 +# 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(true) }}' +# output_level: '{{ mso_output_level | default("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 + +- name: Remove schemas + mso_schema: + 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(true) }}' + output_level: '{{ mso_output_level | default("info") }}' + schema: '{{ item }}' + state: absent + loop: + - '{{ mso_schema | default("ansible_test") }}_2' + - '{{ mso_schema | default("ansible_test") }}' + +- name: Ensure tenant ansible_test exist + mso_tenant: &tenant_present + 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(true) }}' + output_level: '{{ mso_output_level | default("info") }}' + tenant: ansible_test + users: + - '{{ mso_username }}' + # sites: + # - '{{ mso_site | default("ansible_test") }}' + state: present + +- name: Ensure schema 1 with Template 1 exist + mso_schema_template: &schema_present + 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(true) }}' + output_level: '{{ mso_output_level | default("info") }}' + schema: '{{ mso_schema | default("ansible_test") }}' + tenant: ansible_test + template: Template 1 + state: present + +- name: Ensure schema 1 with Template 2 exist + mso_schema_template: + <<: *schema_present + schema: '{{ mso_schema | default("ansible_test") }}' + tenant: ansible_test + template: Template 2 + state: present + +- name: Ensure schema 2 with Template 3 exist + mso_schema_template: + <<: *schema_present + schema: '{{ mso_schema | default("ansible_test") }}_2' + tenant: ansible_test + template: Template 3 + state: present + +- name: Ensure VRF exist + mso_schema_template_vrf: &vrf_present + 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(true) }}' + output_level: '{{ mso_output_level | default("info") }}' + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + vrf: VRF + layer3_multicast: true + state: present + +- name: Ensure VRF2 exist + mso_schema_template_vrf: + <<: *vrf_present + vrf: VRF2 + state: present + +- name: Ensure VRF3 exist + mso_schema_template_vrf: + <<: *vrf_present + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 2 + vrf: VRF3 + state: present + +- name: Ensure VRF4 exist + mso_schema_template_vrf: + <<: *vrf_present + schema: '{{ mso_schema | default("ansible_test") }}_2' + template: Template 3 + vrf: VRF4 + state: present + +- name: Ensure ANP exist + mso_schema_template_anp: + 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(true) }}' + output_level: '{{ mso_output_level | default("info") }}' + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + anp: ANP + state: present + +- name: Ensure ANP2 exist + mso_schema_template_anp: + 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(true) }}' + output_level: '{{ mso_output_level | default("info") }}' + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 2 + anp: ANP2 + state: present + +- name: Ensure ANP3 exist + mso_schema_template_anp: + 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(true) }}' + output_level: '{{ mso_output_level | default("info") }}' + schema: '{{ mso_schema | default("ansible_test") }}_2' + template: Template 3 + anp: ANP3 + state: present + +- name: Ensure Filter 1 exist + mso_schema_template_filter_entry: + 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(true) }}' + output_level: '{{ mso_output_level | default("info") }}' + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + filter: Filter1 + entry: Filter1-Entry + state: present + +- name: Ensure Contract1 exist + mso_schema_template_contract_filter: &contract_present + 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(true) }}' + output_level: '{{ mso_output_level | default("info") }}' + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + contract: Contract1 + filter: Filter1 + filter_schema: '{{ mso_schema | default("ansible_test") }}' + filter_template: Template 1 + state: present + +- name: Ensure Contract2 exist + mso_schema_template_contract_filter: + <<: *contract_present + template: Template 2 + contract: Contract2 + state: present + +- name: Ensure ansible_test_1 BD exist + mso_schema_template_bd: + <<: *vrf_present + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + bd: ansible_test_1 + vrf: + name: VRF + layer3_multicast: true + state: present + +- name: Ensure ansible_test_2 BD exist + mso_schema_template_bd: + <<: *vrf_present + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + bd: ansible_test_2 + vrf: + name: VRF2 + template: Template 1 + layer3_multicast: true + state: present + +- name: Ensure ansible_test_3 BD exist + mso_schema_template_bd: + <<: *vrf_present + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 2 + bd: ansible_test_3 + vrf: + name: VRF3 + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 2 + layer3_multicast: true + state: present + +- name: Ensure ansible_test_4 BD exist + mso_schema_template_bd: + <<: *vrf_present + schema: '{{ mso_schema | default("ansible_test") }}_2' + template: Template 3 + bd: ansible_test_4 + vrf: + name: VRF4 + schema: '{{ mso_schema | default("ansible_test") }}_2' + template: Template 3 + layer3_multicast: true + state: present + +# ADD EPG +- name: Add EPG (check_mode) + mso_schema_template_anp_epg: &epg_present + 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(true) }}' + output_level: '{{ mso_output_level | default("info") }}' + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + anp: ANP + epg: ansible_test_1 + bd: + name: ansible_test_1 + vrf: + name: VRF + state: present + check_mode: yes + register: cm_add_epg + +- name: Verify cm_add_epg + assert: + that: + - cm_add_epg is changed + - cm_add_epg.previous == {} + - cm_add_epg.current.name == "ansible_test_1" + - cm_add_epg.current.vrfRef.templateName == "Template1" + - cm_add_epg.current.vrfRef.vrfName == "VRF" + - cm_add_epg.current.bdRef.templateName == "Template1" + - cm_add_epg.current.bdRef.bdName == "ansible_test_1" + +- name: Add EPG (normal mode) + mso_schema_template_anp_epg: + <<: *epg_present + register: nm_add_epg + +- name: Verify nm_add_epg + assert: + that: + - nm_add_epg is changed + - nm_add_epg.previous == {} + - nm_add_epg.current.name == "ansible_test_1" + - nm_add_epg.current.vrfRef.templateName == "Template1" + - nm_add_epg.current.vrfRef.vrfName == "VRF" + - nm_add_epg.current.bdRef.templateName == "Template1" + - nm_add_epg.current.bdRef.bdName == "ansible_test_1" + - cm_add_epg.current.vrfRef.schemaId == nm_add_epg.current.vrfRef.schemaId + - cm_add_epg.current.bdRef.schemaId == nm_add_epg.current.bdRef.schemaId + +- name: Add EPG again (check_mode) + mso_schema_template_anp_epg: + <<: *epg_present + check_mode: yes + register: cm_add_epg_again + +- name: Verify cm_add_epg_again + assert: + that: + - cm_add_epg_again is not changed + - cm_add_epg_again.current.name == cm_add_epg_again.previous.name == "ansible_test_1" + - cm_add_epg_again.current.vrfRef.templateName == cm_add_epg_again.previous.vrfRef.templateName == "Template1" + - cm_add_epg_again.current.vrfRef.vrfName == cm_add_epg_again.previous.vrfRef.vrfName == "VRF" + - cm_add_epg_again.current.bdRef.templateName == cm_add_epg_again.previous.bdRef.templateName == "Template1" + - cm_add_epg_again.current.bdRef.bdName == cm_add_epg_again.previous.bdRef.bdName == "ansible_test_1" + - cm_add_epg_again.previous.vrfRef.schemaId == cm_add_epg_again.current.vrfRef.schemaId + - cm_add_epg_again.previous.bdRef.schemaId == cm_add_epg_again.current.bdRef.schemaId + + +- name: Add EPG again (normal mode) + mso_schema_template_anp_epg: + <<: *epg_present + register: nm_add_epg_again + +- name: Verify nm_add_epg_again + assert: + that: + - nm_add_epg_again is not changed + - nm_add_epg_again.current.name == nm_add_epg_again.previous.name == "ansible_test_1" + - nm_add_epg_again.current.vrfRef.templateName == nm_add_epg_again.previous.vrfRef.templateName == "Template1" + - nm_add_epg_again.current.vrfRef.vrfName == nm_add_epg_again.previous.vrfRef.vrfName == "VRF" + - nm_add_epg_again.current.bdRef.templateName == nm_add_epg_again.previous.bdRef.templateName == "Template1" + - nm_add_epg_again.current.bdRef.bdName == nm_add_epg_again.previous.bdRef.bdName == "ansible_test_1" + - nm_add_epg_again.previous.vrfRef.schemaId == nm_add_epg_again.current.vrfRef.schemaId + - 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: + <<: *epg_present + schema: '{{ mso_schema | default("ansible_test") }}' + epg: ansible_test_2 + +- name: Add EPG 3 (normal mode) + mso_schema_template_anp_epg: + <<: *epg_present + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 2 + anp: ANP2 + epg: ansible_test_3 + bd: + name: ansible_test_1 + template: Template 1 + vrf: + name: VRF + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + useg_epg: true + intra_epg_isolation: enforced + intersite_multicast_source: true + proxy_arp: true + preferred_group: true + subnets: + - subnet: 10.0.0.128/24 + - subnet: 10.0.1.254/24 + description: 1234567890 + - subnet: 172.16.0.1/24 + description: "My description for a subnet" + scope: public + shared: true + no_default_gateway: false + querier: true + - ip: 192.168.0.254/24 + description: "My description for a subnet" + scope: private + shared: false + no_default_gateway: true + register: nm_add_epg_3 + +- name: Add EPG 4 (normal mode) + mso_schema_template_anp_epg: + <<: *epg_present + schema: '{{ mso_schema | default("ansible_test") }}_2' + template: Template 3 + anp: ANP3 + epg: ansible_test_4 + bd: + name: ansible_test_1 + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + vrf: + name: VRF + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + register: nm_add_epg_4 + +- name: Verify nm_add_epg_3 and nm_add_epg_4 + assert: + that: + - nm_add_epg_3 is changed + - nm_add_epg_4 is changed + - nm_add_epg_3.current.name == "ansible_test_3" + - nm_add_epg_4.current.name == "ansible_test_4" + - nm_add_epg_3.current.vrfRef.templateName == nm_add_epg_4.current.vrfRef.templateName == "Template1" + - nm_add_epg_3.current.vrfRef.vrfName == nm_add_epg_4.current.vrfRef.vrfName == "VRF" + - nm_add_epg_3.current.vrfRef.schemaId == nm_add_epg.current.bdRef.schemaId + - nm_add_epg_3.current.bdRef.templateName == nm_add_epg_4.current.bdRef.templateName == "Template1" + - nm_add_epg_3.current.bdRef.bdName == nm_add_epg_4.current.bdRef.bdName == "ansible_test_1" + - nm_add_epg_3.current.bdRef.schemaId == nm_add_epg.current.bdRef.schemaId + - nm_add_epg_3.current.uSegEpg == true + - nm_add_epg_3.current.intraEpg == 'enforced' + - nm_add_epg_3.current.mCastSource == true + - nm_add_epg_3.current.proxyArp == true + - nm_add_epg_3.current.preferredGroup == true + - nm_add_epg_3.current.subnets[0].description == "10.0.0.128/24" + - nm_add_epg_3.current.subnets[0].ip == "10.0.0.128/24" + - nm_add_epg_3.current.subnets[0].noDefaultGateway == false + - nm_add_epg_3.current.subnets[0].scope == "private" + - nm_add_epg_3.current.subnets[0].shared == false + - nm_add_epg_3.current.subnets[0].querier == false + - nm_add_epg_3.current.subnets[1].description == "1234567890" + - nm_add_epg_3.current.subnets[1].ip == "10.0.1.254/24" + - nm_add_epg_3.current.subnets[1].noDefaultGateway == false + - nm_add_epg_3.current.subnets[1].scope == "private" + - nm_add_epg_3.current.subnets[1].shared == false + - nm_add_epg_3.current.subnets[1].querier == false + - nm_add_epg_3.current.subnets[2].description == "My description for a subnet" + - nm_add_epg_3.current.subnets[2].ip == "172.16.0.1/24" + - nm_add_epg_3.current.subnets[2].noDefaultGateway == false + - nm_add_epg_3.current.subnets[2].scope == "public" + - nm_add_epg_3.current.subnets[2].shared == true + - nm_add_epg_3.current.subnets[2].querier == true + - nm_add_epg_3.current.subnets[3].description == "My description for a subnet" + - nm_add_epg_3.current.subnets[3].ip == "192.168.0.254/24" + - nm_add_epg_3.current.subnets[3].noDefaultGateway == true + - nm_add_epg_3.current.subnets[3].scope == "private" + - nm_add_epg_3.current.subnets[3].shared == false + - nm_add_epg_3.current.subnets[3].querier == false + +# CHANGE EPG +- name: Change EPG (check_mode) + mso_schema_template_anp_epg: + <<: *epg_present + vrf: + name: VRF2 + bd: + name: ansible_test_2 + check_mode: yes + register: cm_change_epg + +- name: Verify cm_change_epg + assert: + that: + - cm_change_epg is changed + - cm_change_epg.current.name == 'ansible_test_1' + - cm_change_epg.current.vrfRef.vrfName == 'VRF2' + - cm_change_epg.current.bdRef.templateName == cm_change_epg.current.vrfRef.templateName == "Template1" + - cm_change_epg.current.vrfRef.schemaId == cm_change_epg.previous.vrfRef.schemaId + - cm_change_epg.current.bdRef.bdName == 'ansible_test_2' + - cm_change_epg.current.bdRef.schemaId == cm_change_epg.previous.bdRef.schemaId + +- name: Change EPG (normal mode) + mso_schema_template_anp_epg: + <<: *epg_present + vrf: + name: VRF2 + bd: + name: ansible_test_2 + output_level: debug + register: nm_change_epg + +- name: Verify nm_change_epg + assert: + that: + - nm_change_epg is changed + - nm_change_epg.current.name == 'ansible_test_1' + - nm_change_epg.current.vrfRef.vrfName == 'VRF2' + - nm_change_epg.current.bdRef.templateName == nm_change_epg.current.vrfRef.templateName == "Template1" + - nm_change_epg.current.vrfRef.schemaId == nm_change_epg.previous.vrfRef.schemaId + - nm_change_epg.current.bdRef.bdName == 'ansible_test_2' + - nm_change_epg.current.bdRef.schemaId == nm_change_epg.previous.bdRef.schemaId + +- name: Change EPG again (check_mode) + mso_schema_template_anp_epg: + <<: *epg_present + vrf: + name: VRF2 + bd: + name: ansible_test_2 + check_mode: yes + register: cm_change_epg_again + +- name: Verify cm_change_epg_again + assert: + that: + - cm_change_epg_again is not changed + - cm_change_epg_again.current.name == 'ansible_test_1' + - cm_change_epg_again.current.vrfRef.vrfName == 'VRF2' + - cm_change_epg_again.current.vrfRef.templateName == cm_change_epg_again.current.bdRef.templateName == "Template1" + - cm_change_epg_again.current.vrfRef.schemaId == cm_change_epg_again.previous.vrfRef.schemaId + - cm_change_epg_again.current.bdRef.bdName == 'ansible_test_2' + - 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: + <<: *epg_present + vrf: + name: VRF2 + bd: + name: ansible_test_2 + register: nm_change_epg_again + +- name: Verify nm_change_epg_again + assert: + that: + - nm_change_epg_again is not changed + - nm_change_epg_again.current.name == 'ansible_test_1' + - nm_change_epg_again.current.vrfRef.vrfName == 'VRF2' + - nm_change_epg_again.current.vrfRef.templateName == nm_change_epg_again.current.bdRef.templateName == "Template1" + - nm_change_epg_again.current.vrfRef.schemaId == nm_change_epg_again.previous.vrfRef.schemaId + - nm_change_epg_again.current.bdRef.bdName == 'ansible_test_2' + - nm_change_epg_again.current.bdRef.schemaId == nm_change_epg_again.previous.bdRef.schemaId + +- name: Change EPG to VRF3 (normal mode) + mso_schema_template_anp_epg: + <<: *epg_present + vrf: + name: VRF3 + template: Template 2 + bd: + name: ansible_test_3 + template: Template 2 + register: nm_change_epg_vrf3 + +- name: Change EPG 4 to VRF (normal mode) + mso_schema_template_anp_epg: + <<: *epg_present + schema: '{{ mso_schema | default("ansible_test") }}_2' + template: Template 3 + anp: ANP3 + epg: ansible_test_4 + vrf: + name: VRF + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + bd: + name: ansible_test_1 + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + register: nm_change_epg_vrf4 + +- name: Verify nm_change_epg_vrf3 and nm_change_epg_vrf4 + assert: + that: + - nm_change_epg_vrf3 is changed + - nm_change_epg_vrf3.current.name == 'ansible_test_1' + - nm_change_epg_vrf4.current.name == 'ansible_test_4' + - nm_change_epg_vrf3.current.vrfRef.vrfName == 'VRF3' + - nm_change_epg_vrf3.current.bdRef.bdName == 'ansible_test_3' + - nm_change_epg_vrf3.current.vrfRef.templateName == nm_change_epg_vrf3.current.bdRef.templateName == "Template2" + - nm_change_epg_vrf4.current.vrfRef.vrfName == 'VRF' + - nm_change_epg_vrf4.current.bdRef.bdName == 'ansible_test_1' + - 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: + <<: *epg_present + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + useg_epg: true + intra_epg_isolation: enforced + intersite_multicast_source: true + proxy_arp: true + preferred_group: true + subnets: + - subnet: 10.1.0.128/24 + - subnet: 10.1.1.254/24 + description: 1234567890 + - subnet: 172.17.0.1/24 + description: "My description for a subnet" + scope: public + shared: true + no_default_gateway: false + querier: true + - ip: 192.168.1.254/24 + description: "My description for a subnet" + scope: private + shared: false + no_default_gateway: true + register: nm_change_epg_1_settings + +- name: Change EPG 1 subnets (normal mode) + mso_schema_template_anp_epg: + <<: *epg_present + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + useg_epg: true + intra_epg_isolation: enforced + intersite_multicast_source: true + proxy_arp: true + preferred_group: true + subnets: + - subnet: 10.1.0.127/24 + - subnet: 172.17.0.1/24 + description: "New description for a subnet" + scope: private + shared: false + no_default_gateway: false + querier: false + - ip: 192.168.1.254/24 + description: "My description for a subnet" + scope: private + shared: false + no_default_gateway: false + querier: true + register: nm_change_epg_1_subnets + +- name: Verify nm_change_epg_1_subnets + assert: + that: + - nm_change_epg_1_settings is changed + - nm_change_epg_1_settings.current.name == "ansible_test_1" + - nm_change_epg_1_settings.current.vrfRef.templateName == nm_change_epg_1_settings.current.bdRef.templateName == "Template1" + - nm_change_epg_1_settings.current.vrfRef.vrfName == "VRF" + - nm_change_epg_1_settings.current.bdRef.bdName == "ansible_test_1" + - nm_change_epg_1_settings.current.uSegEpg == true + - nm_change_epg_1_settings.current.intraEpg == 'enforced' + - nm_change_epg_1_settings.current.mCastSource == true + - nm_change_epg_1_settings.current.proxyArp == true + - nm_change_epg_1_settings.current.preferredGroup == true + - nm_change_epg_1_settings.current.subnets[0].description == "10.1.0.128/24" + - nm_change_epg_1_settings.current.subnets[0].ip == "10.1.0.128/24" + - nm_change_epg_1_settings.current.subnets[0].noDefaultGateway == false + - nm_change_epg_1_settings.current.subnets[0].scope == "private" + - nm_change_epg_1_settings.current.subnets[0].shared == false + - nm_change_epg_1_settings.current.subnets[0].querier == false + - nm_change_epg_1_settings.current.subnets[1].description == "1234567890" + - nm_change_epg_1_settings.current.subnets[1].ip == "10.1.1.254/24" + - nm_change_epg_1_settings.current.subnets[1].noDefaultGateway == false + - nm_change_epg_1_settings.current.subnets[1].scope == "private" + - nm_change_epg_1_settings.current.subnets[1].shared == false + - nm_change_epg_1_settings.current.subnets[1].querier == false + - nm_change_epg_1_settings.current.subnets[2].description == "My description for a subnet" + - nm_change_epg_1_settings.current.subnets[2].ip == "172.17.0.1/24" + - nm_change_epg_1_settings.current.subnets[2].noDefaultGateway == false + - nm_change_epg_1_settings.current.subnets[2].scope == "public" + - nm_change_epg_1_settings.current.subnets[2].shared == true + - nm_change_epg_1_settings.current.subnets[2].querier == true + - nm_change_epg_1_settings.current.subnets[3].description == "My description for a subnet" + - nm_change_epg_1_settings.current.subnets[3].ip == "192.168.1.254/24" + - nm_change_epg_1_settings.current.subnets[3].noDefaultGateway == true + - nm_change_epg_1_settings.current.subnets[3].scope == "private" + - nm_change_epg_1_settings.current.subnets[3].shared == false + - nm_change_epg_1_settings.current.subnets[3].querier == false + - nm_change_epg_1_subnets is changed + - nm_change_epg_1_subnets.current.subnets | length == 3 + - nm_change_epg_1_subnets.current.name == "ansible_test_1" + - nm_change_epg_1_subnets.current.vrfRef.templateName == nm_change_epg_1_subnets.current.bdRef.templateName == "Template1" + - nm_change_epg_1_subnets.current.vrfRef.vrfName == "VRF" + - nm_change_epg_1_subnets.current.bdRef.bdName == "ansible_test_1" + - nm_change_epg_1_subnets.current.uSegEpg == true + - nm_change_epg_1_subnets.current.intraEpg == 'enforced' + - nm_change_epg_1_subnets.current.mCastSource == true + - nm_change_epg_1_subnets.current.proxyArp == true + - nm_change_epg_1_subnets.current.preferredGroup == true + - nm_change_epg_1_subnets.current.subnets[0].description == "10.1.0.127/24" + - nm_change_epg_1_subnets.current.subnets[0].ip == "10.1.0.127/24" + - nm_change_epg_1_subnets.current.subnets[0].noDefaultGateway == false + - nm_change_epg_1_subnets.current.subnets[0].scope == "private" + - nm_change_epg_1_subnets.current.subnets[0].shared == false + - nm_change_epg_1_subnets.current.subnets[0].querier == false + - nm_change_epg_1_subnets.current.subnets[1].description == "New description for a subnet" + - nm_change_epg_1_subnets.current.subnets[1].ip == "172.17.0.1/24" + - nm_change_epg_1_subnets.current.subnets[1].noDefaultGateway == false + - nm_change_epg_1_subnets.current.subnets[1].scope == "private" + - nm_change_epg_1_subnets.current.subnets[1].shared == false + - nm_change_epg_1_subnets.current.subnets[1].querier == false + - nm_change_epg_1_subnets.current.subnets[2].description == "My description for a subnet" + - nm_change_epg_1_subnets.current.subnets[2].ip == "192.168.1.254/24" + - nm_change_epg_1_subnets.current.subnets[2].noDefaultGateway == false + - nm_change_epg_1_subnets.current.subnets[2].scope == "private" + - nm_change_epg_1_subnets.current.subnets[2].shared == false + - nm_change_epg_1_subnets.current.subnets[2].querier == true + + +# # QUERY ALL EPGs +- name: Query all EPGs in an ANP (check_mode) + mso_schema_template_anp_epg: &epg_query + 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(true) }}' + output_level: '{{ mso_output_level | default("info") }}' + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + anp: ANP + state: query + check_mode: yes + register: cm_query_all_epgs + +- name: Query all EPGs (normal mode) + mso_schema_template_anp_epg: + <<: *epg_query + register: nm_query_all_epgs + +- name: Verify query_all_epgs + assert: + that: + - cm_query_all_epgs is not changed + - nm_query_all_epgs is not changed + - cm_query_all_epgs.current | length == nm_query_all_epgs.current | length == 2 + + +# QUERY AN EPG +- name: Query EPG 1 (check_mode) + mso_schema_template_anp_epg: + <<: *epg_query + epg: ansible_test_1 + check_mode: yes + register: cm_query_epg_1 + +- name: Query EPG 1 (normal mode) + 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: + <<: *epg_query + template: Template 2 + anp: ANP2 + epg: ansible_test_3 + register: nm_query_epg_3 + +- name: Query EPG 4 (normal mode) + mso_schema_template_anp_epg: + <<: *epg_query + schema: '{{ mso_schema | default("ansible_test") }}_2' + template: Template 3 + anp: ANP3 + epg: ansible_test_4 + register: nm_query_epg_4 + +- name: Verify query_epg_x + assert: + that: + - cm_query_epg_1 is not changed + - nm_query_epg_1 is not changed + - nm_query_epg_3 is not changed + - nm_query_epg_4 is not changed + - nm_query_epg_1.current.subnets | length == 3 + - nm_query_epg_1.current.name == "ansible_test_1" + - nm_query_epg_1.current.vrfRef.templateName == nm_query_epg_1.current.bdRef.templateName == "Template1" + - nm_query_epg_1.current.vrfRef.vrfName == "VRF" + - nm_query_epg_1.current.bdRef.bdName == "ansible_test_1" + - nm_query_epg_1.current.uSegEpg == true + - nm_query_epg_1.current.intraEpg == 'enforced' + - nm_query_epg_1.current.mCastSource == true + - nm_query_epg_1.current.proxyArp == true + - nm_query_epg_1.current.preferredGroup == true + - nm_query_epg_1.current.subnets[0].description == "10.1.0.127/24" + - nm_query_epg_1.current.subnets[0].ip == "10.1.0.127/24" + - nm_query_epg_1.current.subnets[0].noDefaultGateway == false + - nm_query_epg_1.current.subnets[0].scope == "private" + - nm_query_epg_1.current.subnets[0].shared == false + - nm_query_epg_1.current.subnets[0].querier == false + - nm_query_epg_1.current.subnets[1].description == "New description for a subnet" + - nm_query_epg_1.current.subnets[1].ip == "172.17.0.1/24" + - nm_query_epg_1.current.subnets[1].noDefaultGateway == false + - nm_query_epg_1.current.subnets[1].scope == "private" + - nm_query_epg_1.current.subnets[1].shared == false + - nm_query_epg_1.current.subnets[1].querier == false + - nm_query_epg_1.current.subnets[2].description == "My description for a subnet" + - nm_query_epg_1.current.subnets[2].ip == "192.168.1.254/24" + - nm_query_epg_1.current.subnets[2].noDefaultGateway == false + - nm_query_epg_1.current.subnets[2].scope == "private" + - nm_query_epg_1.current.subnets[2].shared == false + - nm_query_epg_1.current.subnets[2].querier == true + - nm_query_epg_3.current.name == "ansible_test_3" + - nm_query_epg_4.current.name == "ansible_test_4" + - nm_query_epg_3.current.vrfRef.templateName == nm_query_epg_4.current.vrfRef.templateName == "Template1" + - nm_query_epg_3.current.vrfRef.vrfName == nm_query_epg_4.current.vrfRef.vrfName == "VRF" + - nm_query_epg_3.current.bdRef.templateName == nm_query_epg_4.current.bdRef.templateName == "Template1" + - nm_query_epg_3.current.bdRef.bdName == nm_query_epg_4.current.bdRef.bdName == "ansible_test_1" + - nm_query_epg_3.current.uSegEpg == true + - nm_query_epg_3.current.intraEpg == 'enforced' + - nm_query_epg_3.current.mCastSource == true + - nm_query_epg_3.current.proxyArp == true + - nm_query_epg_3.current.preferredGroup == true + - nm_query_epg_3.current.subnets[0].description == "10.0.0.128/24" + - nm_query_epg_3.current.subnets[0].ip == "10.0.0.128/24" + - nm_query_epg_3.current.subnets[0].noDefaultGateway == false + - nm_query_epg_3.current.subnets[0].scope == "private" + - nm_query_epg_3.current.subnets[0].shared == false + - nm_query_epg_3.current.subnets[0].querier == false + - nm_query_epg_3.current.subnets[1].description == "1234567890" + - nm_query_epg_3.current.subnets[1].ip == "10.0.1.254/24" + - nm_query_epg_3.current.subnets[1].noDefaultGateway == false + - nm_query_epg_3.current.subnets[1].scope == "private" + - nm_query_epg_3.current.subnets[1].shared == false + - nm_query_epg_3.current.subnets[1].querier == false + - nm_query_epg_3.current.subnets[2].description == "My description for a subnet" + - nm_query_epg_3.current.subnets[2].ip == "172.16.0.1/24" + - nm_query_epg_3.current.subnets[2].noDefaultGateway == false + - nm_query_epg_3.current.subnets[2].scope == "public" + - nm_query_epg_3.current.subnets[2].shared == true + - nm_query_epg_3.current.subnets[2].querier == true + - nm_query_epg_3.current.subnets[3].description == "My description for a subnet" + - nm_query_epg_3.current.subnets[3].ip == "192.168.0.254/24" + - nm_query_epg_3.current.subnets[3].noDefaultGateway == true + - nm_query_epg_3.current.subnets[3].scope == "private" + - nm_query_epg_3.current.subnets[3].shared == false + - nm_query_epg_3.current.subnets[3].querier == false + + +# REMOVE EPG +- name: Remove EPG (check_mode) + mso_schema_template_anp_epg: + <<: *epg_present + state: absent + check_mode: yes + register: cm_remove_epg + +- name: Verify cm_remove_epg + assert: + that: + - cm_remove_epg is changed + - cm_remove_epg.current == {} + +- name: Remove EPG (normal mode) + mso_schema_template_anp_epg: + <<: *epg_present + state: absent + register: nm_remove_epg + +- name: Verify nm_remove_epg + assert: + that: + - nm_remove_epg is changed + - nm_remove_epg.current == {} + +- name: Remove EPG again (check_mode) + mso_schema_template_anp_epg: + <<: *epg_present + state: absent + check_mode: yes + register: cm_remove_epg_again + +- name: Verify cm_remove_epg_again + 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: + <<: *epg_present + state: absent + register: nm_remove_epg_again + +- name: Verify nm_remove_epg_again + assert: + that: + - nm_remove_epg_again is not changed + - nm_remove_epg_again.current == {} + + +# QUERY NON-EXISTING EPG +- name: Query non-existing EPG (check_mode) + mso_schema_template_anp_epg: + <<: *epg_query + epg: non_existing_epg + check_mode: yes + ignore_errors: yes + register: cm_query_non_epg + +- name: Query non-existing EPG (normal mode) + mso_schema_template_anp_epg: + <<: *epg_query + epg: non_existing_epg + ignore_errors: yes + register: nm_query_non_epg + +- name: Verify query_non_epg + 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 == "EPG 'non_existing_epg' not found" + +# QUERY NON-EXISTING ANP +- name: Query non-existing ANP (check_mode) + mso_schema_template_anp_epg: + <<: *epg_query + anp: non_existing_anp + check_mode: yes + ignore_errors: yes + register: cm_query_non_anp + +- name: Query non-existing ANP (normal mode) + mso_schema_template_anp_epg: + <<: *epg_query + anp: non_existing_anp + ignore_errors: yes + register: nm_query_non_anp + +- name: Verify query_non_anp + 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" + +# USE A NON-EXISTING STATE +- name: Non-existing state for EPG (check_mode) + mso_schema_template_anp_epg: + <<: *epg_query + epg: ansible_test_2 + state: non-existing-state + check_mode: yes + ignore_errors: yes + register: cm_non_existing_state + +- name: Non-existing state for EPG (normal_mode) + mso_schema_template_anp_epg: + <<: *epg_query + epg: ansible_test_2 + state: non-existing-state + ignore_errors: yes + register: nm_non_existing_state + +- name: Verify non_existing_state + assert: + that: + - cm_non_existing_state is not changed + - nm_non_existing_state is not changed + - cm_non_existing_state == nm_non_existing_state + - cm_non_existing_state.msg == 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 for EPG (check_mode) + mso_schema_template_anp_epg: + <<: *epg_present + schema: non-existing-schema + epg: ansible_test_2 + check_mode: yes + ignore_errors: yes + register: cm_non_existing_schema + +- name: Non-existing schema for EPG (normal_mode) + mso_schema_template_anp_epg: + <<: *epg_present + schema: non-existing-schema + epg: ansible_test_2 + ignore_errors: yes + register: nm_non_existing_schema + +- name: Verify non_existing_schema + assert: + that: + - cm_non_existing_schema is not changed + - nm_non_existing_schema is not changed + - cm_non_existing_schema == nm_non_existing_schema + - 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: + <<: *epg_present + epg: ansible_test_2 + bd: + name: ansible_test_1 + schema: non-existing-schema + template: Template 1 + check_mode: yes + ignore_errors: yes + register: cm_non_existing_bd_schema + +- name: Non-existing BD schema for EPG (normal_mode) + mso_schema_template_anp_epg: + <<: *epg_present + epg: ansible_test_2 + bd: + name: ansible_test_1 + schema: non-existing-schema + template: Template 1 + ignore_errors: yes + register: nm_non_existing_bd_schema + +- name: Verify non_existing_bd_schema + assert: + that: + - cm_non_existing_bd_schema is not changed + - nm_non_existing_bd_schema is not changed + - cm_non_existing_bd_schema == nm_non_existing_bd_schema + - 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: + <<: *epg_present + epg: ansible_test_2 + vrf: + name: VRF + schema: non-existing-schema + template: Template 1 + check_mode: yes + ignore_errors: yes + register: cm_non_existing_vrf_schema + +- name: Non-existing VRF schema for EPG (normal_mode) + mso_schema_template_anp_epg: + <<: *epg_present + epg: ansible_test_2 + vrf: + name: VRF + schema: non-existing-schema + template: Template 1 + ignore_errors: yes + register: nm_non_existing_vrf_schema + +- name: Verify non_existing_vrf_schema + assert: + that: + - cm_non_existing_vrf_schema is not changed + - nm_non_existing_vrf_schema is not changed + - cm_non_existing_vrf_schema == nm_non_existing_vrf_schema + - cm_non_existing_vrf_schema.msg == nm_non_existing_vrf_schema.msg == "Referenced schema 'non-existing-schema' in vrfref does not exist" + +# USE A NON-EXISTING TEMPLATE +- name: Non-existing template for EPG (check_mode) + mso_schema_template_anp_epg: + <<: *epg_present + template: non-existing-template + epg: ansible_test_2 + check_mode: yes + ignore_errors: yes + register: cm_non_existing_template + +- name: Non-existing template for EPG (normal_mode) + mso_schema_template_anp_epg: + <<: *epg_present + template: non-existing-template + epg: ansible_test_2 + ignore_errors: yes + register: nm_non_existing_template + +- name: Verify non_existing_template + 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" + +# Checking if contract are removed after re-applying an EPG. (#13 | #62137) +- name: Add Contracts to EPG 2 + mso_schema_template_anp_epg_contract: + 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(true) }}' + output_level: '{{ mso_output_level | default("info") }}' + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + anp: ANP + epg: ansible_test_2 + contract: + name: '{{ item.name }}' + template: '{{ item.template }}' + type: '{{ item.type }}' + state: present + loop: + - { name: Contract1, template: Template 1, type: consumer } + - { name: Contract1, template: Template 1, type: provider } + - { name: Contract2, template: Template 2, type: consumer } + - { name: Contract2, template: Template 2, type: provider } + +- name: Query EPG 2 + 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: + that: + - nm_query_contract_epg.current.contractRelationships | length == 4 + + +- name: Add EPG 2 again (normal_mode) + 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: + that: + - nm_add_epg_2_again is not changed + +- name: Query EPG 2 + 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: + 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 + 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(true) }}' + output_level: '{{ mso_output_level | default("info") }}' + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + anp: ANP + epg: ansible_test_3 + bd: + name: ansible_test_1 + register: nm_add_epg_3 + +- name: Verify nm_add_epg_3 + 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: + <<: *epg_present_2 + register: nm_query_epg_3 + +- name: Verify nm_query_epg_3 + assert: + that: + - nm_query_epg_3 is not changed + - nm_query_epg_3.current.name == 'ansible_test_3' + - "'vrfRef' not in nm_query_epg_3.current" + +# 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: + <<: *epg_present + epg: ansible_test_2 + vrf: + name: VRF2 + bd: + name: ansible_test_2 + register: nm_change_epg_2_vrf + +- name: Verify that EPG 2 did change + assert: + that: + - nm_change_epg_2_vrf is changed + - nm_change_epg_2_vrf.current.vrfRef.templateName == "Template1" + - nm_change_epg_2_vrf.current.vrfRef.vrfName == "VRF2" + - nm_change_epg_2_vrf.current.bdRef.bdName == "ansible_test_2" + +- name: Query EPG 2 + 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: + that: + - nm_query_contract_epg_2.current.contractRelationships | length == 4 \ No newline at end of file diff --git a/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_anp_epg_contract/aliases b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_anp_epg_contract/aliases new file mode 100644 index 00000000..5042c9c0 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_anp_epg_contract/aliases @@ -0,0 +1,2 @@ +# No ACI MultiSite infrastructure, so not enabled +# unsupported diff --git a/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_anp_epg_contract/tasks/main.yml b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_anp_epg_contract/tasks/main.yml new file mode 100644 index 00000000..24bdead0 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_anp_epg_contract/tasks/main.yml @@ -0,0 +1,651 @@ +# Test code for the MSO modules +# Copyright: (c) 2020, Lionel Hercot (@lhercot) +# Copyright: (c) 2018, Dag Wieers (@dagwieers) (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: + 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 +# 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(true) }}' +# output_level: '{{ mso_output_level | default("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 + +- name: Remove schemas + mso_schema: + 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(true) }}' + output_level: '{{ mso_output_level | default("info") }}' + schema: '{{ item }}' + state: absent + loop: + - '{{ mso_schema | default("ansible_test") }}_2' + - '{{ mso_schema | default("ansible_test") }}' + +- name: Ensure tenant ansible_test exist + mso_tenant: &tenant_present + 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(true) }}' + output_level: '{{ mso_output_level | default("info") }}' + tenant: ansible_test + users: + - '{{ mso_username }}' + # sites: + # - '{{ mso_site | default("ansible_test") }}' + state: present + +- name: Ensure schema 1 with Template 1 exist + mso_schema_template: &schema_present + 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(true) }}' + output_level: '{{ mso_output_level | default("info") }}' + schema: '{{ mso_schema | default("ansible_test") }}' + tenant: ansible_test + template: Template 1 + state: present + +- name: Ensure schema 1 with Template 2 exist + mso_schema_template: + <<: *schema_present + schema: '{{ mso_schema | default("ansible_test") }}' + tenant: ansible_test + template: Template 2 + state: present + +- name: Ensure schema 2 with Template 3 exist + mso_schema_template: + <<: *schema_present + schema: '{{ mso_schema | default("ansible_test") }}_2' + tenant: ansible_test + template: Template 3 + state: present + +- name: Ensure ANP exist + mso_schema_template_anp: + 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(true) }}' + output_level: '{{ mso_output_level | default("info") }}' + schema: '{{ item.schema }}' + template: '{{ item.template }}' + anp: ANP + state: present + loop: + - { schema: '{{ mso_schema | default("ansible_test") }}', template: 'Template 1' } + - { schema: '{{ mso_schema | default("ansible_test") }}_2', template: 'Template 3' } + +- name: Ensure Filter 1 exist + mso_schema_template_filter_entry: + 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(true) }}' + output_level: '{{ mso_output_level | default("info") }}' + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + filter: Filter1 + entry: Filter1-Entry + state: present + +- name: Ensure Contract1 exist + mso_schema_template_contract_filter: &contract_present + 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(true) }}' + output_level: '{{ mso_output_level | default("info") }}' + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + contract: Contract1 + filter: Filter1 + filter_schema: '{{ mso_schema | default("ansible_test") }}' + filter_template: Template 1 + state: present + +- name: Ensure Contract2 exist + mso_schema_template_contract_filter: + <<: *contract_present + template: Template 2 + contract: Contract2 + state: present + +- name: Ensure EPGs exist + mso_schema_template_anp_epg: + 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(true) }}' + output_level: '{{ mso_output_level | default("info") }}' + schema: '{{ item.schema }}' + template: '{{ item.template }}' + anp: ANP + epg: '{{ item.epg }}' + state: present + loop: + - { schema: '{{ mso_schema | default("ansible_test") }}', template: 'Template 1', epg: 'ansible_test_1' } + - { schema: '{{ mso_schema | default("ansible_test") }}_2', template: 'Template 3', epg: 'ansible_test_3' } + +# ADD Contract to EPG +- name: Add Contract1 to EPG (check_mode) + mso_schema_template_anp_epg_contract: &contract_epg_present + 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(true) }}' + output_level: '{{ mso_output_level | default("info") }}' + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + anp: ANP + epg: ansible_test_1 + contract: + name: Contract1 + type: consumer + state: present + check_mode: yes + register: cm_add_contract_rel + +- name: Verify cm_add_contract_rel + assert: + that: + - cm_add_contract_rel is changed + - cm_add_contract_rel.previous == {} + - cm_add_contract_rel.current.contractRef.templateName == "Template1" + - cm_add_contract_rel.current.contractRef.contractName == "Contract1" + - cm_add_contract_rel.current.relationshipType == "consumer" + +- name: Add Contract to EPG (normal mode) + mso_schema_template_anp_epg_contract: + <<: *contract_epg_present + register: nm_add_contract_rel + +- name: Verify nm_add_contract_rel + assert: + that: + - nm_add_contract_rel is changed + - nm_add_contract_rel.previous == {} + - nm_add_contract_rel.current.contractRef.templateName == "Template1" + - nm_add_contract_rel.current.contractRef.contractName == "Contract1" + - nm_add_contract_rel.current.relationshipType == "consumer" + - 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: + <<: *contract_epg_present + check_mode: yes + register: cm_add_contract_rel_again + +- name: Verify cm_add_contract_rel_again + assert: + that: + - cm_add_contract_rel_again is not changed + - cm_add_contract_rel_again.previous.contractRef.templateName == "Template1" + - cm_add_contract_rel_again.current.contractRef.templateName == "Template1" + - cm_add_contract_rel_again.previous.contractRef.contractName == "Contract1" + - cm_add_contract_rel_again.current.contractRef.contractName == "Contract1" + - cm_add_contract_rel_again.previous.relationshipType == "consumer" + - cm_add_contract_rel_again.current.relationshipType == "consumer" + - cm_add_contract_rel_again.previous.contractRef.schemaId == cm_add_contract_rel_again.current.contractRef.schemaId + + +- name: Add Contract to EPG again (normal mode) + mso_schema_template_anp_epg_contract: + <<: *contract_epg_present + register: nm_add_contract_rel_again + +- name: Verify nm_add_contract_rel_again + assert: + that: + - nm_add_contract_rel_again is not changed + - nm_add_contract_rel_again.previous.contractRef.templateName == "Template1" + - nm_add_contract_rel_again.current.contractRef.templateName == "Template1" + - nm_add_contract_rel_again.previous.contractRef.contractName == "Contract1" + - nm_add_contract_rel_again.current.contractRef.contractName == "Contract1" + - nm_add_contract_rel_again.previous.relationshipType == "consumer" + - nm_add_contract_rel_again.current.relationshipType == "consumer" + - 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: + <<: *contract_epg_present + contract: + name: Contract1 + type: provider + register: nm_add_contract1_rel_provider + +- name: Add Contract2 to EPG - consumer (normal mode) + mso_schema_template_anp_epg_contract: + <<: *contract_epg_present + contract: + name: Contract2 + template: Template 2 + type: consumer + register: nm_add_contract2_rel_consumer + +- name: Add Contract1 to EPG 3 - provider (normal mode) + mso_schema_template_anp_epg_contract: + <<: *contract_epg_present + schema: '{{ mso_schema | default("ansible_test") }}_2' + template: Template 3 + anp: ANP + epg: ansible_test_3 + contract: + name: Contract1 + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + type: provider + 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: + that: + - nm_add_contract1_rel_provider is changed + - nm_add_contract2_rel_consumer is changed + - nm_add_contract3_rel_provider is changed + - nm_add_contract1_rel_provider.current.contractRef.contractName == nm_add_contract3_rel_provider.current.contractRef.contractName == "Contract1" + - nm_add_contract2_rel_consumer.current.contractRef.contractName == "Contract2" + - nm_add_contract1_rel_provider.current.contractRef.templateName == nm_add_contract3_rel_provider.current.contractRef.templateName == "Template1" + - nm_add_contract2_rel_consumer.current.contractRef.templateName == "Template2" + - nm_add_contract1_rel_provider.current.contractRef.schemaId == nm_add_contract2_rel_consumer.current.contractRef.schemaId == nm_add_contract3_rel_provider.current.contractRef.schemaId + - nm_add_contract2_rel_consumer.current.relationshipType == "consumer" + - nm_add_contract1_rel_provider.current.relationshipType == nm_add_contract3_rel_provider.current.relationshipType == "provider" + +# # QUERY ALL Contract to EPG +- name: Query all contract relationship for EPG (check_mode) + mso_schema_template_anp_epg_contract: &contract_epg_query + 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(true) }}' + output_level: '{{ mso_output_level | default("info") }}' + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + anp: ANP + epg: ansible_test_1 + state: query + check_mode: yes + register: cm_query_all_contract_rels + +- name: Query all contract relationship for EPG (normal mode) + mso_schema_template_anp_epg_contract: + <<: *contract_epg_query + register: nm_query_all_contract_rels + +- name: Verify query_all_contract_rels + assert: + that: + - cm_query_all_contract_rels is not changed + - nm_query_all_contract_rels is not changed + - cm_query_all_contract_rels.current | length == nm_query_all_contract_rels.current | length == 3 + + +# QUERY A Contract to EPG +- name: Query Contract1 relationship for EPG - consumer (check_mode) + mso_schema_template_anp_epg_contract: + <<: *contract_epg_query + contract: + name: Contract1 + type: consumer + check_mode: yes + register: cm_query_contract1_consumer_rel + +- name: Query Contract1 relationship for EPG - consumer (normal mode) + mso_schema_template_anp_epg_contract: + <<: *contract_epg_query + contract: + name: Contract1 + type: consumer + register: nm_query_contract1_consumer_rel + +- name: Query Contract1 relationship for EPG - provider (normal mode) + mso_schema_template_anp_epg_contract: + <<: *contract_epg_query + contract: + name: Contract1 + type: provider + register: nm_query_contract1_provider_rel + +- name: Query Contract1 relationship for EPG - consumer (normal mode) + mso_schema_template_anp_epg_contract: + <<: *contract_epg_query + contract: + name: Contract2 + template: Template 2 + type: consumer + register: nm_query_contract2_consumer_rel + +- name: Query Contract1 relationship for EPG - provider (normal mode) + mso_schema_template_anp_epg_contract: + <<: *contract_epg_query + schema: '{{ mso_schema | default("ansible_test") }}_2' + template: Template 3 + anp: ANP + epg: ansible_test_3 + contract: + name: Contract1 + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + type: provider + register: nm_query_contract3_provider_rel + +- name: Verify query_contractX_YYYYY_rel + assert: + that: + - cm_query_contract1_consumer_rel is not changed + - nm_query_contract1_consumer_rel is not changed + - nm_query_contract1_provider_rel is not changed + - nm_query_contract2_consumer_rel is not changed + - nm_query_contract3_provider_rel is not changed + - cm_query_contract1_consumer_rel == nm_query_contract1_consumer_rel + - cm_query_contract1_consumer_rel.current.contractRef.contractName == nm_query_contract1_consumer_rel.current.contractRef.contractName == nm_query_contract1_provider_rel.current.contractRef.contractName == nm_query_contract3_provider_rel.current.contractRef.contractName == "Contract1" + - nm_query_contract2_consumer_rel.current.contractRef.contractName == "Contract2" + - cm_query_contract1_consumer_rel.current.contractRef.templateName == nm_query_contract1_consumer_rel.current.contractRef.templateName == nm_query_contract1_provider_rel.current.contractRef.templateName == nm_query_contract3_provider_rel.current.contractRef.templateName == "Template1" + - nm_query_contract2_consumer_rel.current.contractRef.templateName == "Template2" + - cm_query_contract1_consumer_rel.current.contractRef.schemaId == nm_query_contract1_consumer_rel.current.contractRef.schemaId == nm_query_contract1_provider_rel.current.contractRef.schemaId == nm_query_contract2_consumer_rel.current.contractRef.schemaId == nm_query_contract3_provider_rel.current.contractRef.schemaId + - cm_query_contract1_consumer_rel.current.relationshipType == nm_query_contract1_consumer_rel.current.relationshipType == nm_query_contract2_consumer_rel.current.relationshipType == "consumer" + - nm_query_contract1_provider_rel.current.relationshipType == nm_query_contract3_provider_rel.current.relationshipType == "provider" + + +# REMOVE Contract to EPG +- name: Remove Contract to EPG (check_mode) + mso_schema_template_anp_epg_contract: + <<: *contract_epg_present + state: absent + check_mode: yes + register: cm_remove_contract_rel + +- name: Verify cm_remove_contract_rel + 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: + <<: *contract_epg_present + state: absent + register: nm_remove_contract_rel + +- name: Verify nm_remove_contract_rel + 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: + <<: *contract_epg_present + state: absent + check_mode: yes + register: cm_remove_contract_rel_again + +- name: Verify cm_remove_contract_rel_again + 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: + <<: *contract_epg_present + state: absent + register: nm_remove_contract_rel_again + +- name: Verify nm_remove_contract_rel_again + assert: + that: + - nm_remove_contract_rel_again is not changed + - nm_remove_contract_rel_again.current == {} + + +# QUERY NON-EXISTING Contract to EPG +- name: Query non-existing contract (check_mode) + mso_schema_template_anp_epg_contract: + <<: *contract_epg_query + contract: + name: non_existing_contract + type: provider + check_mode: yes + ignore_errors: yes + register: cm_query_non_contract + +- name: Query non-existing contract (normal mode) + mso_schema_template_anp_epg_contract: + <<: *contract_epg_query + contract: + name: non_existing_contract + type: provider + ignore_errors: yes + register: nm_query_non_contract + +- name: Verify query_non_contract + 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") + +# QUERY NON-EXISTING EPG +- name: Query non-existing EPG (check_mode) + mso_schema_template_anp_epg_contract: + <<: *contract_epg_query + epg: non_existing_epg + check_mode: yes + ignore_errors: yes + register: cm_query_non_epg + +- name: Query non-existing EPG (normal mode) + mso_schema_template_anp_epg_contract: + <<: *contract_epg_query + epg: non_existing_epg + ignore_errors: yes + register: nm_query_non_epg + +- name: Verify query_non_epg + 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" + +# QUERY NON-EXISTING ANP +- name: Query non-existing ANP (check_mode) + mso_schema_template_anp_epg_contract: + <<: *contract_epg_query + anp: non_existing_anp + check_mode: yes + ignore_errors: yes + register: cm_query_non_anp + +- name: Query non-existing ANP (normal mode) + mso_schema_template_anp_epg_contract: + <<: *contract_epg_query + anp: non_existing_anp + ignore_errors: yes + register: nm_query_non_anp + +- name: Verify query_non_anp + 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" + +# USE A NON-EXISTING STATE +- name: Non-existing state for contract relationship (check_mode) + mso_schema_template_anp_epg_contract: + <<: *contract_epg_query + state: non-existing-state + check_mode: yes + ignore_errors: yes + register: cm_non_existing_state + +- name: Non-existing state for contract relationship (normal_mode) + mso_schema_template_anp_epg_contract: + <<: *contract_epg_query + state: non-existing-state + ignore_errors: yes + register: nm_non_existing_state + +- name: Verify non_existing_state + assert: + that: + - cm_non_existing_state is not changed + - nm_non_existing_state is not changed + - cm_non_existing_state == nm_non_existing_state + - cm_non_existing_state.msg == 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 for contract relationship (check_mode) + mso_schema_template_anp_epg_contract: + <<: *contract_epg_query + schema: non-existing-schema + check_mode: yes + ignore_errors: yes + register: cm_non_existing_schema + +- name: Non-existing schema for contract relationship (normal_mode) + mso_schema_template_anp_epg_contract: + <<: *contract_epg_query + schema: non-existing-schema + ignore_errors: yes + register: nm_non_existing_schema + +- name: Verify non_existing_schema + assert: + that: + - cm_non_existing_schema is not changed + - nm_non_existing_schema is not changed + - cm_non_existing_schema == nm_non_existing_schema + - 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: + <<: *contract_epg_query + contract: + name: Contract1 + schema: non-existing-schema + template: Template 1 + type: provider + check_mode: yes + ignore_errors: yes + register: cm_non_existing_contract_schema + +- name: Non-existing contract schema for contract relationship (normal_mode) + mso_schema_template_anp_epg_contract: + <<: *contract_epg_query + contract: + name: Contract1 + schema: non-existing-schema + template: Template 1 + type: provider + ignore_errors: yes + register: nm_non_existing_contract_schema + +- name: Verify non_existing_contract_schema + assert: + that: + - cm_non_existing_contract_schema is not changed + - nm_non_existing_contract_schema is not changed + - cm_non_existing_contract_schema == nm_non_existing_contract_schema + - cm_non_existing_contract_schema.msg == nm_non_existing_contract_schema.msg == "Schema 'non-existing-schema' is not a valid schema name." + +# USE A NON-EXISTING TEMPLATE +- name: Non-existing template for contract relationship (check_mode) + mso_schema_template_anp_epg_contract: + <<: *contract_epg_query + template: non-existing-template + check_mode: yes + ignore_errors: yes + register: cm_non_existing_template + +- name: Non-existing template for contract relationship (normal_mode) + mso_schema_template_anp_epg_contract: + <<: *contract_epg_query + template: non-existing-template + ignore_errors: yes + register: nm_non_existing_template + +- name: Verify non_existing_template + 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" + +- name: Non-existing contract template for contract relationship (check_mode) + mso_schema_template_anp_epg_contract: + <<: *contract_epg_query + contract: + name: Contract1 + template: non-existing-template + type: provider + check_mode: yes + ignore_errors: yes + register: cm_non_existing_contract_template + +- name: Non-existing contract template for contract relationship (normal_mode) + mso_schema_template_anp_epg_contract: + <<: *contract_epg_query + contract: + name: Contract1 + template: non-existing-template + type: provider + ignore_errors: yes + register: nm_non_existing_contract_template + +- name: Verify non_existing_contract_template + 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 diff --git a/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_anp_epg_selector/aliases b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_anp_epg_selector/aliases new file mode 100644 index 00000000..5042c9c0 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_anp_epg_selector/aliases @@ -0,0 +1,2 @@ +# No ACI MultiSite infrastructure, so not enabled +# unsupported diff --git a/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_anp_epg_selector/tasks/main.yml b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_anp_epg_selector/tasks/main.yml new file mode 100644 index 00000000..586f7c9d --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_anp_epg_selector/tasks/main.yml @@ -0,0 +1,789 @@ +# Test code for the MSO modules +# Copyright: (c) 2020, Lionel Hercot (@lhercot) +# Copyright: (c) 2018, Dag Wieers (@dagwieers) (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: + 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: + 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(true) }}' + output_level: '{{ mso_output_level | default("info") }}' + + +# - name: Ensure site exist +# mso_site: &site_present +# 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(true) }}' +# output_level: '{{ mso_output_level | default("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 + +- name: Remove schemas + mso_schema: + <<: *mso_info + schema: '{{ item }}' + state: absent + loop: + - '{{ mso_schema | default("ansible_test") }}_2' + - '{{ mso_schema | default("ansible_test") }}' + +- name: Ensure tenant ansible_test exist + mso_tenant: + <<: *mso_info + tenant: ansible_test + users: + - '{{ mso_username }}' + # sites: + # - '{{ mso_site | default("ansible_test") }}' + state: present + +- name: Ensure schema 1 with Template 1 exist + mso_schema_template: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + tenant: ansible_test + template: Template 1 + state: present + +- name: Ensure schema 1 with Template 2 exist + mso_schema_template: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + tenant: ansible_test + template: Template 2 + state: present + +- name: Ensure schema 2 with Template 3 exist + mso_schema_template: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}_2' + tenant: ansible_test + template: Template 3 + state: present + +- name: Ensure ANP exist + mso_schema_template_anp: + <<: *mso_info + schema: '{{ item.schema }}' + template: '{{ item.template }}' + anp: ANP + state: present + loop: + - { schema: '{{ mso_schema | default("ansible_test") }}', template: 'Template 1' } + - { schema: '{{ mso_schema | default("ansible_test") }}_2', template: 'Template 3' } + +# ADD EPGs +- name: Ensure EPGs exist + mso_schema_template_anp_epg: + <<: *mso_info + schema: '{{ item.schema }}' + template: '{{ item.template }}' + anp: ANP + epg: '{{ item.epg }}' + state: present + loop: + - { schema: '{{ mso_schema | default("ansible_test") }}', template: 'Template 1', epg: 'ansible_test_1' } + - { schema: '{{ mso_schema | default("ansible_test") }}_2', template: 'Template 3', epg: 'ansible_test_3' } + +# ADD Selector to EPG +- name: Add Selector to EPG (check_mode) + mso_schema_template_anp_epg_selector: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + anp: ANP + epg: ansible_test_1 + selector: selector_1 + state: present + check_mode: yes + register: cm_add_selector_1 + +- name: Verify cm_add_selector_1 + assert: + that: + - cm_add_selector_1 is changed + - cm_add_selector_1.previous == {} + - cm_add_selector_1.current.name == "selector_1" + - 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: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + anp: ANP + epg: ansible_test_1 + selector: selector 1 + state: present + ignore_errors: yes + register: nm_add_selector1_with_space_in_name + +- name: Verify nm_add_selector1_with_space_in_name + 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: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + anp: ANP + epg: ansible_test_1 + selector: selector_1 + state: present + register: nm_add_selector_1 + +- name: Verify nm_add_selector_1 + assert: + that: + - nm_add_selector_1 is changed + - nm_add_selector_1.previous == {} + - nm_add_selector_1.current.name == "selector_1" + - nm_add_selector_1.current.expressions == [] + +- name: Add Selector to EPG again (check_mode) + mso_schema_template_anp_epg_selector: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + anp: ANP + epg: ansible_test_1 + selector: selector_1 + state: present + check_mode: yes + register: cm_add_selector_1_again + +- name: Verify cm_add_selector_1_again + assert: + that: + - cm_add_selector_1_again is not changed + - cm_add_selector_1_again.previous.name == "selector_1" + - cm_add_selector_1_again.previous.expressions == [] + - cm_add_selector_1_again.current.name == "selector_1" + - cm_add_selector_1_again.current.expressions == [] + +- name: Add Selector to EPG again (normal_mode) + mso_schema_template_anp_epg_selector: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + anp: ANP + epg: ansible_test_1 + selector: selector_1 + state: present + register: nm_add_selector_1_again + +- name: Verify nm_add_selector_1_again + assert: + that: + - nm_add_selector_1_again is not changed + - nm_add_selector_1_again.previous.name == "selector_1" + - nm_add_selector_1_again.previous.expressions == [] + - nm_add_selector_1_again.current.name == "selector_1" + - nm_add_selector_1_again.current.expressions == [] + +- name: Add Selector 2 to EPG (check_mode) + mso_schema_template_anp_epg_selector: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + anp: ANP + epg: ansible_test_1 + selector: selector_2 + expressions: + - type: expression_1 + operator: in + value: test + state: present + check_mode: yes + register: cm_add_selector_2 + +- name: Verify cm_add_selector_2 + assert: + that: + - cm_add_selector_2 is changed + - cm_add_selector_2.previous == {} + - cm_add_selector_2.current.name == "selector_2" + - cm_add_selector_2.current.expressions[0].key == "Custom:expression_1" + - cm_add_selector_2.current.expressions[0].operator == "in" + - cm_add_selector_2.current.expressions[0].value == "test" + +- name: Add Selector 2 to EPG (normal_mode) + mso_schema_template_anp_epg_selector: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + anp: ANP + epg: ansible_test_1 + selector: selector_2 + expressions: + - type: expression_1 + operator: in + value: test + state: present + register: nm_add_selector_2 + +- name: Verify nm_add_selector_2 + assert: + that: + - nm_add_selector_2 is changed + - nm_add_selector_2.previous == {} + - nm_add_selector_2.current.name == "selector_2" + - nm_add_selector_2.current.expressions[0].key == "Custom:expression_1" + - nm_add_selector_2.current.expressions[0].operator == "in" + - 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: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + anp: ANP + epg: ansible_test_1 + selector: selector_2 + expressions: + - type: expression 1 + operator: in + value: test + state: present + ignore_errors: yes + register: nm_add_selector2_with_space_in_expression_type + +- name: Verify nm_add_selector2_with_space_in_expression_type + 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: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + anp: ANP + epg: ansible_test_1 + selector: selector_2 + expressions: + - type: expression_5 + operator: has_key + value: test + state: present + ignore_errors: yes + register: nm_change_selector_2_key_exist + +- name: Verify nm_change_selector_2_key_exist + 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: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + anp: ANP + epg: ansible_test_1 + selector: selector_2 + expressions: + - type: expression_6 + operator: does_not_have_key + value: test + state: present + ignore_errors: yes + register: nm_change_selector_2_key_not_exist + +- name: Verify nm_change_selector_2_key_not_exist + 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: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + anp: ANP + epg: ansible_test_1 + selector: selector_2 + expressions: + - type: expression_6 + operator: equals + state: present + ignore_errors: yes + register: nm_change_selector_2_equals + +- name: Verify nm_change_selector_2_equals + 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: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + anp: ANP + epg: ansible_test_1 + selector: selector_2 + expressions: + - type: expression_1 + operator: in + value: test + - type: expression_2 + operator: not_in + value: test + - type: expression_3 + operator: equals + value: test + - type: expression_4 + operator: not_equals + value: test + - type: expression_5 + operator: has_key + value: + - type: expression_6 + operator: does_not_have_key + state: present + register: nm_change_selector_2 + +- name: Verify nm_change_selector_2 + 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: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + anp: ANP + epg: ansible_test_1 + selector: selector_2 + expressions: + - type: expression_1 + operator: in + value: test + - type: expression_2 + operator: not_in + value: test + - type: expression_3 + operator: equals + value: test + - type: expression_4 + operator: not_equals + value: test + - type: expression_5 + operator: has_key + value: + - type: expression_6 + operator: does_not_have_key + state: present + register: nm_change_selector_2_again + +- name: Verify nm_change_selector_2_again + 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: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + anp: ANP + epg: ansible_test_1 + state: query + check_mode: yes + register: cm_query_all_selectors + +- name: Verify cm_query_all_selectors + assert: + that: + - cm_query_all_selectors is not changed + - cm_query_all_selectors.current | length == 2 + - cm_query_all_selectors.current[0].name == "selector_1" + - cm_query_all_selectors.current[1].name == "selector_2" + - cm_query_all_selectors.current[0].expressions == [] + - cm_query_all_selectors.current[1].expressions | length == 6 + +- name: Query all selectors (normal_mode) + mso_schema_template_anp_epg_selector: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + anp: ANP + epg: ansible_test_1 + state: query + register: nm_query_all_selectors + +- name: Verify nm_query_all_selectors + assert: + that: + - nm_query_all_selectors is not changed + - nm_query_all_selectors.current | length == 2 + - nm_query_all_selectors.current[0].name == "selector_1" + - nm_query_all_selectors.current[1].name == "selector_2" + - nm_query_all_selectors.current[0].expressions == [] + - nm_query_all_selectors.current[1].expressions | length == 6 + +- name: Query specific selector (check_mode) + mso_schema_template_anp_epg_selector: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + anp: ANP + epg: ansible_test_1 + selector: selector_1 + state: query + check_mode: yes + register: cm_query_selector1 + +- name: Verify cm_query_selector1 + 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: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + anp: ANP + epg: ansible_test_1 + selector: selector_1 + state: query + register: nm_query_selector1 + +- name: Verify nm_query_selector1 + 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: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + anp: ANP + epg: ansible_test_1 + selector: selector_2 + state: query + register: nm_query_selector2 + +- name: Verify nm_query_selector2 + assert: + that: + - nm_query_selector2 is not changed + - nm_query_selector2.current.name == "selector_2" + - nm_query_selector2.current.expressions | length == 6 + - nm_query_selector2.current.expressions[0].key == "Custom:expression_1" + - nm_query_selector2.current.expressions[0].operator == "in" + - nm_query_selector2.current.expressions[0].value == "test" + - nm_query_selector2.current.expressions[1].key == "Custom:expression_2" + - nm_query_selector2.current.expressions[1].operator == "notIn" + - nm_query_selector2.current.expressions[1].value == "test" + - nm_query_selector2.current.expressions[2].key == "Custom:expression_3" + - nm_query_selector2.current.expressions[2].operator == "equals" + - nm_query_selector2.current.expressions[2].value == "test" + - nm_query_selector2.current.expressions[3].key == "Custom:expression_4" + - nm_query_selector2.current.expressions[3].operator == "notEquals" + - nm_query_selector2.current.expressions[3].value == "test" + - nm_query_selector2.current.expressions[4].key == "Custom:expression_5" + - nm_query_selector2.current.expressions[4].operator == "keyExist" + - nm_query_selector2.current.expressions[4].value == "" + - nm_query_selector2.current.expressions[5].key == "Custom:expression_6" + - nm_query_selector2.current.expressions[5].operator == "keyNotExist" + - nm_query_selector2.current.expressions[5].value == "" + +# - name: Remove selector 1 (check_mode) +# mso_schema_template_anp_epg_selector: +# <<: *mso_info +# schema: '{{ mso_schema | default("ansible_test") }}' +# template: Template 1 +# anp: ANP +# epg: ansible_test_1 +# selector: selector 1 +# state: absent +# check_mode: yes +# register: cm_remove_selector_1 + +# - name: Verify cm_remove_selector_1 +# 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: +# <<: *mso_info +# schema: '{{ mso_schema | default("ansible_test") }}' +# template: Template 1 +# anp: ANP +# epg: ansible_test_1 +# selector: selector 1 +# state: absent +# register: nm_remove_selector_1 + +# - name: Verify nm_remove_selector_1 +# 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: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + anp: ANP + epg: ansible_test_1 + selector: selector_2 + state: absent + register: nm_remove_selector_2 + +- name: Verify nm_remove_selector_2 + 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: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + anp: ANP + epg: ansible_test_1 + selector: non_existing_selector + state: query + check_mode: yes + ignore_errors: yes + register: cm_query_non_selector + +- name: Query non-existing selector (normal mode) + mso_schema_template_anp_epg_selector: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + anp: ANP + epg: ansible_test_1 + selector: non_existing_selector + state: query + ignore_errors: yes + register: nm_query_non_selector + +- name: Verify cm_query_non_selector and nm_query_non_selector + assert: + that: + - cm_query_non_selector is not changed + - nm_query_non_selector is not changed + - cm_query_non_selector == nm_query_non_selector + - cm_query_non_selector.msg == "Selector 'non_existing_selector' not found" + - nm_query_non_selector.msg == "Selector 'non_existing_selector' not found" + +# QUERY NON-EXISTING EPG +- name: Query non-existing EPG (check_mode) + mso_schema_template_anp_epg_selector: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + anp: ANP + epg: non_existing_epg + selector: selector_1 + state: query + check_mode: yes + ignore_errors: yes + register: cm_query_non_epg + +- name: Query non-existing EPG (normal mode) + mso_schema_template_anp_epg_selector: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + anp: ANP + epg: non_existing_epg + selector: selector_1 + state: query + ignore_errors: yes + register: nm_query_non_epg + +- name: Verify query_non_epg + 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" + +# QUERY NON-EXISTING ANP +- name: Query non-existing ANP (check_mode) + mso_schema_template_anp_epg_selector: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + anp: non_existing_anp + epg: ansible_test_1 + selector: selector_1 + state: query + check_mode: yes + ignore_errors: yes + register: cm_query_non_anp + +- name: Query non-existing ANP (normal mode) + mso_schema_template_anp_epg_selector: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + anp: non_existing_anp + epg: ansible_test_1 + selector: selector_1 + state: query + ignore_errors: yes + register: nm_query_non_anp + +- name: Verify query_non_anp + 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" + +# USE A NON-EXISTING STATE +- name: Non-existing state (check_mode) + mso_schema_template_anp_epg_selector: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + anp: ANP + epg: ansible_test_1 + selector: selector_1 + state: non-existing-state + check_mode: yes + ignore_errors: yes + register: cm_non_existing_state + +- name: Non-existing state (normal_mode) + mso_schema_template_anp_epg_selector: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + anp: ANP + epg: ansible_test_1 + selector: selector_1 + state: non-existing-state + ignore_errors: yes + register: nm_non_existing_state + +- name: Verify non_existing_state + assert: + that: + - cm_non_existing_state is not changed + - nm_non_existing_state is not changed + - cm_non_existing_state == nm_non_existing_state + - cm_non_existing_state.msg == 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 (check_mode) + mso_schema_template_anp_epg_selector: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: non-existing-template + anp: ANP + epg: ansible_test_1 + selector: selector_1 + state: query + check_mode: yes + ignore_errors: yes + register: cm_non_existing_template + +- name: Non-existing template (normal_mode) + mso_schema_template_anp_epg_selector: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: non-existing-template + anp: ANP + epg: ansible_test_1 + selector: selector_1 + state: query + ignore_errors: yes + register: nm_non_existing_template + +- name: Verify non_existing_template + 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" + +# USE A NON-EXISTING SCHEMA +- name: Non-existing schema (check_mode) + mso_schema_template_anp_epg_selector: + <<: *mso_info + schema: non-existing-schema + template: Template 1 + anp: ANP + epg: ansible_test_1 + selector: selector_1 + state: query + check_mode: yes + ignore_errors: yes + register: cm_non_existing_schema + +- name: Non-existing schema (normal_mode) + mso_schema_template_anp_epg_selector: + <<: *mso_info + schema: non-existing-schema + template: Template 1 + anp: ANP + epg: ansible_test_1 + selector: selector_1 + state: query + ignore_errors: yes + register: nm_non_existing_schema + +- name: Verify non_existing_schema + assert: + that: + - cm_non_existing_schema is not changed + - nm_non_existing_schema is not changed + - cm_non_existing_schema == nm_non_existing_schema + - cm_non_existing_schema.msg == nm_non_existing_schema.msg == "Provided schema 'non-existing-schema' does not exist" \ No newline at end of file diff --git a/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_bd/aliases b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_bd/aliases new file mode 100644 index 00000000..5042c9c0 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_bd/aliases @@ -0,0 +1,2 @@ +# No ACI MultiSite infrastructure, so not enabled +# unsupported diff --git a/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_bd/tasks/main.yml b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_bd/tasks/main.yml new file mode 100644 index 00000000..9b3a2e31 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_bd/tasks/main.yml @@ -0,0 +1,1171 @@ +# Test code for the MSO modules +# Copyright: (c) 2020, Lionel Hercot (@lhercot) +# Copyright: (c) 2018, Dag Wieers (@dagwieers) (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: + 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: + 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(true) }}' + output_level: '{{ mso_output_level | default("info") }}' + +- name: Query MSO version + mso_version: + <<: *mso_info + state: query + register: version + +- name: Set version vars + set_fact: + mso_l3mcast: false + when: version.current.version[:5] == '2.2.4' + +- name: Ensure site exist + mso_site: &site_present + <<: *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 + +- name: Remove schemas + mso_schema: + <<: *mso_info + schema: '{{ item }}' + state: absent + loop: + - '{{ mso_schema | default("ansible_test") }}_2' + - '{{ mso_schema | default("ansible_test") }}' + +- name: Ensure tenant ansible_test exist + mso_tenant: &tenant_present + <<: *mso_info + tenant: ansible_test + users: + - '{{ mso_username }}' + sites: + - '{{ mso_site | default("ansible_test") }}' + state: present + +- name: Ensure schema 1 with exist + mso_schema_template: &schema_present + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + tenant: ansible_test + template: Template1 + state: present + +- name: Ensure schema 1 with Template2 exists + 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: + <<: *schema_present + schema: '{{ mso_schema | default("ansible_test") }}_2' + tenant: ansible_test + template: Template3 + +- name: Ensure schema 2 with Template5 exists + 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 + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template1 + vrf: VRF + layer3_multicast: true + state: present + +- name: Ensure VRF2 exist + mso_schema_template_vrf: + <<: *vrf_present + vrf: VRF2 + +- name: Ensure VRF3 exist + mso_schema_template_vrf: + <<: *vrf_present + template: Template2 + vrf: VRF3 + +- name: Ensure VRF4 exist + 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: + <<: *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: + <<: *vrf_present + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template1 + bd: ansible_test_1 + vrf: + name: VRF + state: absent + +- name: Ensure ansible_test_2 BD does not exist + mso_schema_template_bd: + <<: *vrf_present + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template2 + bd: ansible_test_2 + vrf: + name: VRF + state: absent + +- name: Ensure ansible_test_3 BD does not exist + mso_schema_template_bd: + <<: *vrf_present + schema: '{{ mso_schema | default("ansible_test") }}_2' + template: Template3 + bd: ansible_test_3 + vrf: + name: VRF + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template1 + state: absent + +- name: Ensure ansible_test_4 BD does not exist + mso_schema_template_bd: + <<: *vrf_present + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template1 + bd: ansible_test_4 + vrf: + name: VRF + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template1 + state: absent + +# ADD BD +- name: Add bd (check_mode) + mso_schema_template_bd: &bd_present + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template1 + bd: ansible_test_1 + vrf: + name: VRF + state: present + check_mode: yes + register: cm_add_bd + +- name: Verify cm_add_bd + assert: + that: + - cm_add_bd is changed + - cm_add_bd.previous == {} + - cm_add_bd.current.name == "ansible_test_1" + - cm_add_bd.current.vrfRef.templateName == "Template1" + - cm_add_bd.current.vrfRef.vrfName == "VRF" + +- name: Add bd (normal mode) + mso_schema_template_bd: + <<: *bd_present + register: nm_add_bd + +- name: Verify nm_add_bd + assert: + that: + - nm_add_bd is changed + - nm_add_bd.previous == {} + - nm_add_bd.current.name == "ansible_test_1" + - nm_add_bd.current.vrfRef.templateName == "Template1" + - nm_add_bd.current.vrfRef.vrfName == "VRF" + - cm_add_bd.current.vrfRef.schemaId == nm_add_bd.current.vrfRef.schemaId + +- name: Add bd again (check_mode) + mso_schema_template_bd: + <<: *bd_present + check_mode: yes + register: cm_add_bd_again + +- name: Verify cm_add_bd_again + assert: + that: + - cm_add_bd_again is not changed + - cm_add_bd_again.previous.name == "ansible_test_1" + - cm_add_bd_again.current.name == "ansible_test_1" + - cm_add_bd_again.previous.vrfRef.templateName == "Template1" + - cm_add_bd_again.current.vrfRef.templateName == "Template1" + - cm_add_bd_again.previous.vrfRef.vrfName == "VRF" + - cm_add_bd_again.current.vrfRef.vrfName == "VRF" + - cm_add_bd_again.previous.vrfRef.schemaId == cm_add_bd_again.current.vrfRef.schemaId + + +- name: Add bd again (normal mode) + mso_schema_template_bd: + <<: *bd_present + register: nm_add_bd_again + +- name: Verify nm_add_bd_again + assert: + that: + - nm_add_bd_again is not changed + - nm_add_bd_again.previous.name == "ansible_test_1" + - nm_add_bd_again.current.name == "ansible_test_1" + - nm_add_bd_again.previous.vrfRef.templateName == "Template1" + - nm_add_bd_again.current.vrfRef.templateName == "Template1" + - nm_add_bd_again.previous.vrfRef.vrfName == "VRF" + - nm_add_bd_again.current.vrfRef.vrfName == "VRF" + - nm_add_bd_again.previous.vrfRef.schemaId == nm_add_bd_again.current.vrfRef.schemaId + +- name: Add bd 2 (normal mode) + mso_schema_template_bd: + <<: *bd_present + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template2 + bd: ansible_test_2 + intersite_bum_traffic: true + optimize_wan_bandwidth: true + layer2_stretch: true + layer2_unknown_unicast: flood + layer3_multicast: true + subnets: + - subnet: 10.0.0.128/24 + - subnet: 10.0.1.254/24 + description: 1234567890 + - subnet: 172.16.0.1/24 + description: "My description for a subnet" + scope: public + shared: true + no_default_gateway: false + querier: true + - ip: 192.168.0.254/24 + description: "My description for a subnet" + scope: private + shared: false + no_default_gateway: true + vrf: + name: VRF + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template1 + dhcp_policy: + name: ansible_test + version: 1 + dhcp_option_policy: + name: ansible_test_option + version: 1 + register: nm_add_bd_2 + +- name: Add bd 3 (normal mode) + mso_schema_template_bd: + <<: *bd_present + schema: '{{ mso_schema | default("ansible_test") }}_2' + template: Template3 + bd: ansible_test_3 + vrf: + name: VRF4 + schema: '{{ mso_schema | default("ansible_test") }}_2' + template: Template3 + register: nm_add_bd_3 + +- name: Add bd 4 (normal mode) + mso_schema_template_bd: + <<: *bd_present + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template1 + bd: ansible_test_4 + vrf: + name: VRF + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template1 + register: nm_add_bd_4 + +- name: Verify nm_add_bd_2 and nm_add_bd_3 + assert: + that: + - nm_add_bd_2 is changed + - nm_add_bd_3 is changed + - nm_add_bd_2.current.name == "ansible_test_2" + - nm_add_bd_3.current.name == "ansible_test_3" + - nm_add_bd_2.current.vrfRef.templateName == "Template1" + - nm_add_bd_3.current.vrfRef.templateName == "Template3" + - nm_add_bd_2.current.vrfRef.vrfName == "VRF" + - nm_add_bd_3.current.vrfRef.vrfName == "VRF4" + - nm_add_bd_2.current.vrfRef.schemaId == nm_add_bd.current.vrfRef.schemaId + - nm_add_bd_2.current.intersiteBumTrafficAllow == true + - nm_add_bd_2.current.optimizeWanBandwidth == true + - nm_add_bd_2.current.l2Stretch == true + - nm_add_bd_2.current.l2UnknownUnicast == "flood" + - nm_add_bd_2.current.l3MCast == true + - nm_add_bd_2.current.subnets[0].description == "10.0.0.128/24" + - nm_add_bd_2.current.subnets[0].ip == "10.0.0.128/24" + - nm_add_bd_2.current.subnets[0].noDefaultGateway == false + - nm_add_bd_2.current.subnets[0].scope == "private" + - nm_add_bd_2.current.subnets[0].shared == false + - nm_add_bd_2.current.subnets[0].querier == false + - nm_add_bd_2.current.subnets[1].description == "1234567890" + - nm_add_bd_2.current.subnets[1].ip == "10.0.1.254/24" + - nm_add_bd_2.current.subnets[1].noDefaultGateway == false + - nm_add_bd_2.current.subnets[1].scope == "private" + - nm_add_bd_2.current.subnets[1].shared == false + - nm_add_bd_2.current.subnets[1].querier == false + - nm_add_bd_2.current.subnets[2].description == "My description for a subnet" + - nm_add_bd_2.current.subnets[2].ip == "172.16.0.1/24" + - nm_add_bd_2.current.subnets[2].noDefaultGateway == false + - nm_add_bd_2.current.subnets[2].scope == "public" + - nm_add_bd_2.current.subnets[2].shared == true + - nm_add_bd_2.current.subnets[2].querier == true + - nm_add_bd_2.current.subnets[3].description == "My description for a subnet" + - nm_add_bd_2.current.subnets[3].ip == "192.168.0.254/24" + - nm_add_bd_2.current.subnets[3].noDefaultGateway == true + - nm_add_bd_2.current.subnets[3].scope == "private" + - nm_add_bd_2.current.subnets[3].shared == false + - nm_add_bd_2.current.subnets[3].querier == false + +- name: Add bd 5 (normal mode) + mso_schema_template_bd: + <<: *bd_present + schema: '{{ mso_schema | default("ansible_test") }}_2' + template: Template5 + bd: ansible_test_5 + intersite_bum_traffic: true + optimize_wan_bandwidth: true + layer2_stretch: true + layer2_unknown_unicast: flood + layer3_multicast: false + unknown_multicast_flooding: flood + multi_destination_flooding: drop + ipv6_unknown_multicast_flooding: flood + arp_flooding: true + virtual_mac_address: 00:00:5E:00:01:3C + vrf: + name: VRF5 + schema: '{{ mso_schema | default("ansible_test") }}_2' + template: Template5 + dhcp_policy: + name: ansible_test + version: 1 + dhcp_option_policy: + name: ansible_test_option + version: 1 + register: nm_add_bd_5 + +- name: Verify nm_add_bd_5 for a version that's not 3.1 + assert: + that: + - nm_add_bd_5 is changed + - nm_add_bd_5.current.name == "ansible_test_5" + - nm_add_bd_5.current.vrfRef.templateName == "Template5" + - nm_add_bd_5.current.vrfRef.vrfName == "VRF5" + - nm_add_bd_5.current.intersiteBumTrafficAllow == true + - nm_add_bd_5.current.optimizeWanBandwidth == true + - nm_add_bd_5.current.l2Stretch == true + - nm_add_bd_5.current.l2UnknownUnicast == "flood" + - nm_add_bd_5.current.l3MCast == false + when: version.current.version is version('3.1.1g', '!=') + +- name: Verify nm_add_bd_5 for a version that's 3.1 + assert: + that: + - nm_add_bd_5 is changed + - nm_add_bd_5.current.name == "ansible_test_5" + - nm_add_bd_5.current.vrfRef.templateName == "Template5" + - nm_add_bd_5.current.vrfRef.vrfName == "VRF5" + - nm_add_bd_5.current.intersiteBumTrafficAllow == true + - nm_add_bd_5.current.optimizeWanBandwidth == true + - nm_add_bd_5.current.l2Stretch == true + - nm_add_bd_5.current.l2UnknownUnicast == "flood" + - nm_add_bd_5.current.l3MCast == false + - nm_add_bd_5.current.unkMcastAct == "flood" + - nm_add_bd_5.current.v6unkMcastAct == "flood" + - nm_add_bd_5.current.vmac == "00:00:5E:00:01:3C" + - nm_add_bd_5.current.multiDstPktAct == "drop" + - nm_add_bd_5.current.arpFlood == true + when: version.current.version is version('3.1.1g', '==') + +- name: Add bd 5 again (normal mode) + mso_schema_template_bd: + <<: *bd_present + schema: '{{ mso_schema | default("ansible_test") }}_2' + template: Template5 + bd: ansible_test_5 + intersite_bum_traffic: true + optimize_wan_bandwidth: true + layer2_stretch: true + layer2_unknown_unicast: flood + layer3_multicast: false + unknown_multicast_flooding: flood + multi_destination_flooding: drop + ipv6_unknown_multicast_flooding: flood + arp_flooding: true + virtual_mac_address: 00:00:5E:00:01:3C + vrf: + name: VRF5 + schema: '{{ mso_schema | default("ansible_test") }}_2' + template: Template5 + dhcp_policy: + name: ansible_test + version: 1 + dhcp_option_policy: + name: ansible_test_option + version: 1 + register: nm_add_again_bd_5 + +- name: Verify nm_add_again_bd_5 for a version that's not 3.1 + 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 3.1 + 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: + <<: *bd_present + schema: '{{ mso_schema | default("ansible_test") }}_2' + template: Template5 + bd: ansible_test_5 + intersite_bum_traffic: true + optimize_wan_bandwidth: true + layer2_stretch: true + layer2_unknown_unicast: flood + layer3_multicast: false + unknown_multicast_flooding: optimized_flooding + multi_destination_flooding: flood_in_bd + ipv6_unknown_multicast_flooding: optimized_flooding + arp_flooding: true + virtual_mac_address: 00:00:5E:00:02:3C + vrf: + name: VRF5 + schema: '{{ mso_schema | default("ansible_test") }}_2' + template: Template5 + dhcp_policy: + name: ansible_test + version: 1 + dhcp_option_policy: + name: ansible_test_option + version: 1 + register: nm_bd_5_options + +- name: Verify nm_bd_5_options for a version that's not 3.1 + 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: + that: + - nm_bd_5_options is changed + - nm_bd_5_options.current.unkMcastAct == "opt-flood" + - nm_bd_5_options.current.v6unkMcastAct == "opt-flood" + - nm_bd_5_options.current.multiDstPktAct == "bd-flood" + - nm_bd_5_options.current.vmac == "00:00:5E:00:02:3C" + when: version.current.version is version('3.1.1g', '==') + +- name: Change bd 5_1 (normal mode) + mso_schema_template_bd: + <<: *bd_present + schema: '{{ mso_schema | default("ansible_test") }}_2' + template: Template5 + bd: ansible_test_5 + intersite_bum_traffic: true + optimize_wan_bandwidth: true + layer2_stretch: true + layer2_unknown_unicast: proxy + layer3_multicast: false + unknown_multicast_flooding: flood + multi_destination_flooding: drop + ipv6_unknown_multicast_flooding: flood + arp_flooding: true + virtual_mac_address: 00:00:5E:00:01:3C + vrf: + name: VRF5 + schema: '{{ mso_schema | default("ansible_test") }}_2' + template: Template5 + dhcp_policy: + name: ansible_test + version: 1 + dhcp_option_policy: + name: ansible_test_option + version: 1 + register: nm_change_bd_5_1 + +- name: Verify nm_change_bd_5_1 for a version that's not 3.1 + 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: + 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: + <<: *bd_present + schema: '{{ mso_schema | default("ansible_test") }}_2' + template: Template5 + bd: ansible_test_5 + intersite_bum_traffic: true + optimize_wan_bandwidth: true + layer2_stretch: true + layer2_unknown_unicast: flood + layer3_multicast: false + unknown_multicast_flooding: flood + multi_destination_flooding: drop + ipv6_unknown_multicast_flooding: flood + arp_flooding: false + virtual_mac_address: 00:00:5E:00:01:3C + vrf: + name: VRF5 + schema: '{{ mso_schema | default("ansible_test") }}_2' + template: Template5 + dhcp_policy: + name: ansible_test + version: 1 + dhcp_option_policy: + name: ansible_test_option + version: 1 + ignore_errors: yes + register: nm_change_bd_5_2 + +- name: Verify nm_change_bd_5_2 for a version that's not 3.1 + 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 3.1 + 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: + <<: *bd_present + schema: '{{ mso_schema | default("ansible_test") }}_2' + template: Template5 + bd: ansible_test_5 + intersite_bum_traffic: false + optimize_wan_bandwidth: true + layer2_stretch: true + layer2_unknown_unicast: flood + layer3_multicast: false + unknown_multicast_flooding: flood + multi_destination_flooding: drop + ipv6_unknown_multicast_flooding: flood + arp_flooding: false + virtual_mac_address: 00:00:5E:00:01:3C + vrf: + name: VRF5 + schema: '{{ mso_schema | default("ansible_test") }}_2' + template: Template5 + dhcp_policy: + name: ansible_test + version: 1 + dhcp_option_policy: + name: ansible_test_option + version: 1 + ignore_errors: yes + register: nm_change_bd_5_3 + +- name: Verify nm_change_bd_5_3 for a version that's not 3.1 + 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 3.1 + assert: + that: + - nm_change_bd_5_3 is changed + - nm_change_bd_5_3.msg is match ("MSO Error 400{{':'}} Bad Request{{':'}} Patch Failed, Received{{':'}} BD 'ansible_test_5' l2UnknownUnicast cannot be flood when intersiteBumTrafficAllow is off exception while trying to update schema") + when: version.current.version is version('3.1.1g', '==') + +- name: Change bd 5 for query (normal mode) + mso_schema_template_bd: + <<: *bd_present + schema: '{{ mso_schema | default("ansible_test") }}_2' + template: Template5 + bd: ansible_test_5 + intersite_bum_traffic: true + optimize_wan_bandwidth: true + layer2_stretch: true + layer2_unknown_unicast: flood + layer3_multicast: false + unknown_multicast_flooding: flood + multi_destination_flooding: drop + ipv6_unknown_multicast_flooding: flood + arp_flooding: true + virtual_mac_address: 00:00:5E:00:01:3C + vrf: + name: VRF5 + schema: '{{ mso_schema | default("ansible_test") }}_2' + template: Template5 + dhcp_policy: + name: ansible_test + version: 1 + dhcp_option_policy: + name: ansible_test_option + version: 1 + +# CHANGE BD +- name: Change bd (check_mode) + mso_schema_template_bd: + <<: *bd_present + vrf: + name: VRF2 + check_mode: yes + register: cm_change_bd + +- name: Verify cm_change_bd + assert: + that: + - cm_change_bd is changed + - cm_change_bd.current.name == 'ansible_test_1' + - cm_change_bd.current.vrfRef.vrfName == 'VRF2' + - cm_change_bd.current.vrfRef.templateName == "Template1" + - cm_change_bd.current.vrfRef.schemaId == cm_change_bd.previous.vrfRef.schemaId + +- name: Change bd (normal mode) + mso_schema_template_bd: + <<: *bd_present + vrf: + name: VRF2 + output_level: debug + register: nm_change_bd + +- name: Verify nm_change_bd + assert: + that: + - nm_change_bd is changed + - nm_change_bd.current.name == 'ansible_test_1' + - nm_change_bd.current.vrfRef.vrfName == 'VRF2' + - nm_change_bd.current.vrfRef.templateName == "Template1" + - nm_change_bd.current.vrfRef.schemaId == nm_change_bd.previous.vrfRef.schemaId + +- name: Change bd again (check_mode) + mso_schema_template_bd: + <<: *bd_present + vrf: + name: VRF2 + check_mode: yes + register: cm_change_bd_again + +- name: Verify cm_change_bd_again + assert: + that: + - cm_change_bd_again is not changed + - cm_change_bd_again.current.name == 'ansible_test_1' + - cm_change_bd_again.current.vrfRef.vrfName == 'VRF2' + - cm_change_bd_again.current.vrfRef.templateName == "Template1" + - cm_change_bd_again.current.vrfRef.schemaId == cm_change_bd_again.previous.vrfRef.schemaId + +- name: Change bd again (normal mode) + mso_schema_template_bd: + <<: *bd_present + vrf: + name: VRF2 + register: nm_change_bd_again + +- name: Verify nm_change_bd_again + assert: + that: + - nm_change_bd_again is not changed + - nm_change_bd_again.current.name == 'ansible_test_1' + - nm_change_bd_again.current.vrfRef.vrfName == 'VRF2' + - nm_change_bd_again.current.vrfRef.templateName == "Template1" + - nm_change_bd_again.current.vrfRef.schemaId == nm_change_bd_again.previous.vrfRef.schemaId + +- name: Change bd to VRF3 (normal mode) + mso_schema_template_bd: + <<: *bd_present + vrf: + name: VRF3 + template: Template2 + register: nm_change_bd_vrf3 + +- name: Change bd to VRF4 (normal mode) + mso_schema_template_bd: + <<: *bd_present + vrf: + name: VRF4 + schema: '{{ mso_schema | default("ansible_test") }}_2' + template: Template3 + register: nm_change_bd_vrf4 + +- name: Verify nm_change_bd_vrf3 and nm_change_bd_vrf4 + assert: + that: + - nm_change_bd_vrf3 is changed + - nm_change_bd_vrf3.current.name == nm_change_bd_vrf4.current.name == 'ansible_test_1' + - nm_change_bd_vrf3.current.vrfRef.vrfName == 'VRF3' + - nm_change_bd_vrf3.current.vrfRef.templateName == "Template2" + - nm_change_bd_vrf4.current.vrfRef.vrfName == 'VRF4' + - nm_change_bd_vrf4.current.vrfRef.templateName == "Template3" + +- name: Change bd 1 settings(normal mode) + mso_schema_template_bd: + <<: *bd_present + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template1 + bd: ansible_test_1 + intersite_bum_traffic: true + optimize_wan_bandwidth: true + layer2_stretch: true + layer2_unknown_unicast: flood + layer3_multicast: '{{ mso_l3mcast | default(true) }}' + subnets: + - subnet: 10.1.0.128/24 + - subnet: 10.1.1.254/24 + description: 1234567890 + - subnet: 172.17.0.1/24 + description: "My description for a subnet" + scope: public + shared: true + no_default_gateway: false + querier: true + - ip: 192.168.1.254/24 + description: "My description for a subnet" + scope: private + shared: false + no_default_gateway: true + vrf: + name: VRF3 + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template2 + register: nm_change_bd_1_settings + +- name: Change bd 1 subnets (normal mode) + mso_schema_template_bd: + <<: *bd_present + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template1 + bd: ansible_test_1 + intersite_bum_traffic: true + optimize_wan_bandwidth: true + layer2_stretch: true + layer2_unknown_unicast: flood + layer3_multicast: '{{ mso_l3mcast | default(true) }}' + subnets: + - subnet: 10.1.0.127/24 + - subnet: 172.17.0.1/24 + description: "New description for a subnet" + scope: private + shared: false + no_default_gateway: false + querier: false + - ip: 192.168.1.254/24 + description: "My description for a subnet" + scope: private + shared: false + no_default_gateway: false + querier: true + vrf: + name: VRF3 + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template2 + register: nm_change_bd_1_subnets + +- name: Verify nm_change_bd_1_subnets + assert: + that: + - nm_change_bd_1_settings is changed + - nm_change_bd_1_settings.current.name == "ansible_test_1" + - nm_change_bd_1_settings.current.vrfRef.templateName == "Template2" + - nm_change_bd_1_settings.current.vrfRef.vrfName == "VRF3" + - nm_change_bd_1_settings.current.intersiteBumTrafficAllow == true + - nm_change_bd_1_settings.current.optimizeWanBandwidth == true + - nm_change_bd_1_settings.current.l2Stretch == true + - nm_change_bd_1_settings.current.l2UnknownUnicast == "flood" + - nm_change_bd_1_settings.current.subnets[0].description == "10.1.0.128/24" + - nm_change_bd_1_settings.current.subnets[0].ip == "10.1.0.128/24" + - nm_change_bd_1_settings.current.subnets[0].noDefaultGateway == false + - nm_change_bd_1_settings.current.subnets[0].scope == "private" + - nm_change_bd_1_settings.current.subnets[0].shared == false + - nm_change_bd_1_settings.current.subnets[0].querier == false + - nm_change_bd_1_settings.current.subnets[1].description == "1234567890" + - nm_change_bd_1_settings.current.subnets[1].ip == "10.1.1.254/24" + - nm_change_bd_1_settings.current.subnets[1].noDefaultGateway == false + - nm_change_bd_1_settings.current.subnets[1].scope == "private" + - nm_change_bd_1_settings.current.subnets[1].shared == false + - nm_change_bd_1_settings.current.subnets[1].querier == false + - nm_change_bd_1_settings.current.subnets[2].description == "My description for a subnet" + - nm_change_bd_1_settings.current.subnets[2].ip == "172.17.0.1/24" + - nm_change_bd_1_settings.current.subnets[2].noDefaultGateway == false + - nm_change_bd_1_settings.current.subnets[2].scope == "public" + - nm_change_bd_1_settings.current.subnets[2].shared == true + - nm_change_bd_1_settings.current.subnets[2].querier == true + - nm_change_bd_1_settings.current.subnets[3].description == "My description for a subnet" + - nm_change_bd_1_settings.current.subnets[3].ip == "192.168.1.254/24" + - nm_change_bd_1_settings.current.subnets[3].noDefaultGateway == true + - nm_change_bd_1_settings.current.subnets[3].scope == "private" + - nm_change_bd_1_settings.current.subnets[3].shared == false + - nm_change_bd_1_settings.current.subnets[3].querier == false + - nm_change_bd_1_settings is changed + - nm_change_bd_1_subnets.current.subnets | length == 3 + - nm_change_bd_1_subnets.current.name == "ansible_test_1" + - nm_change_bd_1_subnets.current.vrfRef.templateName == "Template2" + - nm_change_bd_1_subnets.current.vrfRef.vrfName == "VRF3" + - nm_change_bd_1_subnets.current.intersiteBumTrafficAllow == true + - nm_change_bd_1_subnets.current.optimizeWanBandwidth == true + - nm_change_bd_1_subnets.current.l2Stretch == true + - nm_change_bd_1_subnets.current.l2UnknownUnicast == "flood" + - nm_change_bd_1_subnets.current.subnets[0].description == "10.1.0.127/24" + - nm_change_bd_1_subnets.current.subnets[0].ip == "10.1.0.127/24" + - nm_change_bd_1_subnets.current.subnets[0].noDefaultGateway == false + - nm_change_bd_1_subnets.current.subnets[0].scope == "private" + - nm_change_bd_1_subnets.current.subnets[0].shared == false + - nm_change_bd_1_subnets.current.subnets[0].querier == false + - nm_change_bd_1_subnets.current.subnets[1].description == "New description for a subnet" + - nm_change_bd_1_subnets.current.subnets[1].ip == "172.17.0.1/24" + - nm_change_bd_1_subnets.current.subnets[1].noDefaultGateway == false + - nm_change_bd_1_subnets.current.subnets[1].scope == "private" + - nm_change_bd_1_subnets.current.subnets[1].shared == false + - nm_change_bd_1_subnets.current.subnets[1].querier == false + - nm_change_bd_1_subnets.current.subnets[2].description == "My description for a subnet" + - nm_change_bd_1_subnets.current.subnets[2].ip == "192.168.1.254/24" + - nm_change_bd_1_subnets.current.subnets[2].noDefaultGateway == false + - nm_change_bd_1_subnets.current.subnets[2].scope == "private" + - nm_change_bd_1_subnets.current.subnets[2].shared == false + - nm_change_bd_1_subnets.current.subnets[2].querier == true + +- name: Verify l3MCast nm_change_bd_1_subnets (version == 2.2.4) + assert: + that: + - nm_change_bd_1_settings.current.l3MCast == false + - nm_change_bd_1_subnets.current.l3MCast == false + when: version.current.version[:5] == '2.2.4' + +- name: Verify l3MCast nm_change_bd_1_subnets (version != 2.2.4) + assert: + that: + - nm_change_bd_1_settings.current.l3MCast == true + - nm_change_bd_1_subnets.current.l3MCast == true + when: version.current.version[:5] != '2.2.4' + +# FIXME: Add missing DHCP Policy changes and checks (missing DHCP Policy module to make sure it is there.) + +# QUERY ALL BD +- name: Query all bd (check_mode) + mso_schema_template_bd: &bd_query + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template1 + state: query + check_mode: yes + register: cm_query_all_bds + +- name: Query all bd (normal mode) + mso_schema_template_bd: + <<: *bd_query + register: nm_query_all_bds + +- name: Verify query_all_bds + assert: + that: + - cm_query_all_bds is not changed + - nm_query_all_bds is not changed + - cm_query_all_bds.current | length == cm_query_all_bds.current | length == 2 + + +# QUERY A BD +- name: Query bd 1 + mso_schema_template_bd: + <<: *bd_query + bd: ansible_test_1 + check_mode: yes + register: cm_query_bd + +- name: Query bd 1 + mso_schema_template_bd: + <<: *bd_query + bd: ansible_test_1 + register: nm_query_bd + +- name: Query bd 2 + 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: + <<: *bd_query + schema: '{{ mso_schema | default("ansible_test") }}_2' + template: Template3 + bd: ansible_test_3 + register: nm_query_bd_3 + +- name: Query bd 5 + mso_schema_template_bd: + <<: *bd_query + schema: '{{ mso_schema | default("ansible_test") }}_2' + template: Template5 + bd: ansible_test_5 + register: nm_query_bd_5 + +- name: Verify query_bd + assert: + that: + - cm_query_bd is not changed + - nm_query_bd is not changed + - cm_query_bd.current.name == nm_query_bd.current.name == "ansible_test_1" + - cm_query_bd == nm_query_bd + - nm_query_bd_2.current.name == "ansible_test_2" + - nm_query_bd_3.current.name == "ansible_test_3" + - nm_query_bd_2.current.intersiteBumTrafficAllow == true + - nm_query_bd_2.current.optimizeWanBandwidth == true + - nm_query_bd_2.current.l2Stretch == true + - nm_query_bd_2.current.l2UnknownUnicast == "flood" + - nm_query_bd_2.current.l3MCast == true + - nm_query_bd_2.current.subnets[0].description == "10.0.0.128/24" + - nm_query_bd_2.current.subnets[0].ip == "10.0.0.128/24" + - nm_query_bd_2.current.subnets[0].noDefaultGateway == false + - nm_query_bd_2.current.subnets[0].scope == "private" + - nm_query_bd_2.current.subnets[0].shared == false + - nm_query_bd_2.current.subnets[1].description == "1234567890" + - nm_query_bd_2.current.subnets[1].ip == "10.0.1.254/24" + - nm_query_bd_2.current.subnets[1].noDefaultGateway == false + - nm_query_bd_2.current.subnets[1].scope == "private" + - nm_query_bd_2.current.subnets[1].shared == false + - nm_query_bd_2.current.subnets[2].description == "My description for a subnet" + - nm_query_bd_2.current.subnets[2].ip == "172.16.0.1/24" + - nm_query_bd_2.current.subnets[2].noDefaultGateway == false + - nm_query_bd_2.current.subnets[2].scope == "public" + - nm_query_bd_2.current.subnets[2].shared == true + - nm_query_bd_2.current.subnets[3].description == "My description for a subnet" + - nm_query_bd_2.current.subnets[3].ip == "192.168.0.254/24" + - nm_query_bd_2.current.subnets[3].noDefaultGateway == true + - nm_query_bd_2.current.subnets[3].scope == "private" + - nm_query_bd_2.current.subnets[3].shared == false + +- name: Verify nm_query_bd_5 for a version that's not 3.1 + assert: + that: + - nm_query_bd_5 is not changed + - nm_query_bd_5.current.name == "ansible_test_5" + - nm_query_bd_5.current.intersiteBumTrafficAllow == true + - nm_query_bd_5.current.optimizeWanBandwidth == true + - nm_query_bd_5.current.l2Stretch == true + - nm_query_bd_5.current.l2UnknownUnicast == "flood" + - nm_query_bd_5.current.l3MCast == false + when: version.current.version is version('3.1.1g', '!=') + +- name: Verify nm_query_bd_5 for a version that's 3.1 + assert: + that: + - nm_query_bd_5 is not changed + - nm_query_bd_5.current.name == "ansible_test_5" + - nm_query_bd_5.current.intersiteBumTrafficAllow == true + - nm_query_bd_5.current.optimizeWanBandwidth == true + - nm_query_bd_5.current.l2Stretch == true + - nm_query_bd_5.current.l2UnknownUnicast == "flood" + - nm_query_bd_5.current.l3MCast == false + - nm_query_bd_5.current.unkMcastAct == "flood" + - nm_query_bd_5.current.v6unkMcastAct == "flood" + - nm_query_bd_5.current.vmac == "00:00:5E:00:01:3C" + - nm_query_bd_5.current.multiDstPktAct == "drop" + - nm_query_bd_5.current.arpFlood == true + when: version.current.version is version('3.1.1g', '==') + +# REMOVE BD +- name: Remove bd (check_mode) + mso_schema_template_bd: &bd_absent + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template1 + bd: ansible_test_1 + state: absent + check_mode: yes + register: cm_remove_bd + +- name: Verify cm_remove_bd + assert: + that: + - cm_remove_bd is changed + - cm_remove_bd.current == {} + +- name: Remove bd (normal mode) + mso_schema_template_bd: + <<: *bd_absent + register: nm_remove_bd + +- name: Verify nm_remove_bd + assert: + that: + - nm_remove_bd is changed + - nm_remove_bd.current == {} + +- name: Remove bd again (check_mode) + mso_schema_template_bd: + <<: *bd_absent + check_mode: yes + register: cm_remove_bd_again + +- name: Verify cm_remove_bd_again + assert: + that: + - cm_remove_bd_again is not changed + - cm_remove_bd_again.current == {} + +- name: Remove bd again (normal mode) + mso_schema_template_bd: + <<: *bd_absent + register: nm_remove_bd_again + +- name: Verify nm_remove_bd_again + assert: + that: + - nm_remove_bd_again is not changed + - nm_remove_bd_again.current == {} + +- name: Remove bd 5 (normal mode) + mso_schema_template_bd: + <<: *bd_absent + schema: '{{ mso_schema | default("ansible_test") }}_2' + template: Template5 + bd: ansible_test_5 + register: nm_remove_bd_5 + +- name: Verify nm_remove_bd_5 + assert: + that: + - nm_remove_bd_5 is changed + - nm_remove_bd_5.current == {} + +# QUERY NON-EXISTING BD +- name: Query non-existing bd (check_mode) + mso_schema_template_bd: + <<: *bd_query + bd: ansible_test_1 + check_mode: yes + ignore_errors: yes + register: cm_query_non_bd + +- name: Query non-existing bd (normal mode) + mso_schema_template_bd: + <<: *bd_query + bd: ansible_test_1 + ignore_errors: yes + register: nm_query_non_bd + +- name: Verify query_non_bd + assert: + that: + - cm_query_non_bd is not changed + - nm_query_non_bd is not changed + - cm_query_non_bd == nm_query_non_bd + - cm_query_non_bd.msg == nm_query_non_bd.msg == "BD 'ansible_test_1' not found" + + +# USE A NON-EXISTING STATE +- name: Non-existing state for bd (check_mode) + mso_schema_template_bd: + <<: *bd_query + state: non-existing-state + check_mode: yes + ignore_errors: yes + register: cm_non_existing_state + +- name: Non-existing state for bd (normal_mode) + mso_schema_template_bd: + <<: *bd_query + state: non-existing-state + ignore_errors: yes + register: nm_non_existing_state + +- name: Verify non_existing_state + assert: + that: + - cm_non_existing_state is not changed + - nm_non_existing_state is not changed + - cm_non_existing_state == nm_non_existing_state + - cm_non_existing_state.msg == 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 for bd (check_mode) + mso_schema_template_bd: + <<: *bd_query + schema: non-existing-schema + check_mode: yes + ignore_errors: yes + register: cm_non_existing_schema + +- name: Non-existing schema for bd (normal_mode) + mso_schema_template_bd: + <<: *bd_query + schema: non-existing-schema + ignore_errors: yes + register: nm_non_existing_schema + +- name: Verify non_existing_schema + assert: + that: + - cm_non_existing_schema is not changed + - nm_non_existing_schema is not changed + - cm_non_existing_schema == nm_non_existing_schema + - cm_non_existing_schema.msg == nm_non_existing_schema.msg == "Provided schema 'non-existing-schema' does not exist" + +# USE A NON-EXISTING TEMPLATE +- name: Non-existing template for bd (check_mode) + mso_schema_template_bd: + <<: *bd_query + template: non-existing-template + check_mode: yes + ignore_errors: yes + register: cm_non_existing_template + +- name: Non-existing template for bd (normal_mode) + mso_schema_template_bd: + <<: *bd_query + template: non-existing-template + ignore_errors: yes + register: nm_non_existing_template + +- name: Verify non_existing_template + 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" diff --git a/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_bd_subnet/aliases b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_bd_subnet/aliases new file mode 100644 index 00000000..5042c9c0 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_bd_subnet/aliases @@ -0,0 +1,2 @@ +# No ACI MultiSite infrastructure, so not enabled +# unsupported diff --git a/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_bd_subnet/tasks/main.yml b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_bd_subnet/tasks/main.yml new file mode 100644 index 00000000..c85f9bbc --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_bd_subnet/tasks/main.yml @@ -0,0 +1,507 @@ +# Test code for the MSO modules +# Copyright: (c) 2020, Lionel Hercot (@lhercot) +# Copyright: (c) 2018, Dag Wieers (@dagwieers) (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: + 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: + 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(true) }}' + output_level: '{{ mso_output_level | default("info") }}' + +- name: Query MSO version + mso_version: + <<: *mso_info + state: query + register: version + +- name: Set version vars + set_fact: + mso_l3mcast: false + when: version.current.version[:5] == '2.2.4' + +- name: Ensure site exist + mso_site: &site_present + <<: *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 + +- name: Remove schemas + mso_schema: + <<: *mso_info + schema: '{{ item }}' + state: absent + loop: + - '{{ mso_schema | default("ansible_test") }}_2' + - '{{ mso_schema | default("ansible_test") }}' + +- name: Ensure tenant ansible_test exist + mso_tenant: &tenant_present + <<: *mso_info + tenant: ansible_test + users: + - '{{ mso_username }}' + sites: + - '{{ mso_site | default("ansible_test") }}' + state: present + +- name: Ensure schema 1 with Template1 exist + mso_schema_template: &schema_present + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + tenant: ansible_test + template: Template1 + state: present + +- name: Ensure schema 2 with Template2 exists + mso_schema_template: + <<: *schema_present + schema: '{{ mso_schema | default("ansible_test") }}_2' + tenant: ansible_test + template: Template2 + state: present + +- name: Ensure VRF exists + mso_schema_template_vrf: &vrf_present + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template1 + vrf: VRF + layer3_multicast: true + state: present + +- name: Ensure VRF2 exists + mso_schema_template_vrf: + <<: *vrf_present + schema: '{{ mso_schema | default("ansible_test") }}_2' + template: Template2 + vrf: VRF2 + +# ADD BD +- name: Add bd + mso_schema_template_bd: &bd_present + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template1 + bd: ansible_test_1 + intersite_bum_traffic: true + optimize_wan_bandwidth: true + layer2_stretch: true + layer2_unknown_unicast: proxy + vrf: + name: VRF + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template1 + dhcp_policy: + name: ansible_test + version: 1 + dhcp_option_policy: + name: ansible_test_option + version: 1 + state: present + +- name: Add bd 2 + mso_schema_template_bd: + <<: *bd_present + schema: '{{ mso_schema | default("ansible_test") }}_2' + template: Template2 + bd: ansible_test_2 + intersite_bum_traffic: true + optimize_wan_bandwidth: true + layer2_stretch: true + layer2_unknown_unicast: proxy + vrf: + name: VRF2 + schema: '{{ mso_schema | default("ansible_test") }}_2' + template: Template2 + dhcp_policy: + name: ansible_test + version: 1 + dhcp_option_policy: + name: ansible_test_option + version: 1 + +- name: Add bd + mso_schema_template_bd: + <<: *bd_present + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template1 + bd: ansible_test_3 + intersite_bum_traffic: true + optimize_wan_bandwidth: true + layer2_stretch: true + layer2_unknown_unicast: proxy + vrf: + name: VRF + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template1 + dhcp_policy: + name: ansible_test + version: 1 + dhcp_option_policy: + name: ansible_test_option + version: 1 + state: present + +# Add subnet +- name: Add subnet in check mode + mso_schema_template_bd_subnet: &subnet_present + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template1 + bd: ansible_test_1 + subnet: 172.16.0.1/24 + description: "My description for a subnet" + scope: public + shared: true + no_default_gateway: false + querier: true + state: present + register: cm_add_subnet + check_mode: yes + +- name: Add subnet (normal mode) + mso_schema_template_bd_subnet: + <<: *subnet_present + register: nm_add_subnet + +- name: Add subnet again (normal mode) + 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: + <<: *subnet_present + subnet: 2.16.0.1/24 + +- name: Verify cm_add_subnet and nm_add_subnet + assert: + that: + - cm_add_subnet is changed + - nm_add_subnet is changed + - nm_add_subnet_again is not changed + - cm_add_subnet.current.description == "My description for a subnet" + - cm_add_subnet.current.ip == "172.16.0.1/24" + - cm_add_subnet.current.noDefaultGateway == false + - cm_add_subnet.current.scope == "public" + - cm_add_subnet.current.shared == true + - cm_add_subnet.current.querier == true + - nm_add_subnet.current.description == "My description for a subnet" + - nm_add_subnet.current.ip == "172.16.0.1/24" + - nm_add_subnet.current.noDefaultGateway == false + - nm_add_subnet.current.scope == "public" + - nm_add_subnet.current.shared == true + - nm_add_subnet.current.querier == true + +- name: Add subnet 2 (normal mode) + mso_schema_template_bd_subnet: + <<: *subnet_present + schema: '{{ mso_schema | default("ansible_test") }}_2' + template: Template2 + bd: ansible_test_2 + subnet: 10.1.1.1/24 + description: "My description for a subnet with virtual ip" + scope: public + shared: true + no_default_gateway: false + querier: true + is_virtual_ip: true + register: nm_add_subnet_2 + +- name: Verify nm_bd_2 for a version that's not 3.1 + assert: + that: + - nm_add_subnet_2.current.ip == "10.1.1.1/24" + - nm_add_subnet_2.current.noDefaultGateway == false + - nm_add_subnet_2.current.scope == "public" + - nm_add_subnet_2.current.shared == true + - nm_add_subnet_2.current.querier == true + when: version.current.version is version('3.1.1g', '!=') + +- name: Verify nm_bd_2 for a version that's 3.1 + assert: + that: + - nm_add_subnet_2.current.ip == "10.1.1.1/24" + - nm_add_subnet_2.current.noDefaultGateway == false + - nm_add_subnet_2.current.scope == "public" + - nm_add_subnet_2.current.shared == true + - nm_add_subnet_2.current.querier == true + - nm_add_subnet_2.current.virtual == true + when: version.current.version is version('3.1.1g', '==') + +# CHANGE Subnet +- name: Change subnet 2 (normal mode) + mso_schema_template_bd_subnet: + <<: *subnet_present + schema: '{{ mso_schema | default("ansible_test") }}_2' + template: Template2 + bd: ansible_test_2 + subnet: 10.1.1.1/24 + description: "My description for a subnet with virtual ip" + scope: public + shared: true + no_default_gateway: false + querier: true + is_virtual_ip: false + register: nm_change_subnet2 + +- name: Verify nm_change_subnet2 for a version that's not 3.1 + assert: + that: + - nm_change_subnet2 is not changed + - nm_change_subnet2.current.ip == "10.1.1.1/24" + - nm_change_subnet2.current.noDefaultGateway == false + - nm_change_subnet2.current.scope == "public" + - nm_change_subnet2.current.shared == true + - nm_change_subnet2.current.querier == true + when: version.current.version is version('3.1.1g', '!=') + +- name: Verify nm_change_subnet2 for a version that's 3.1 + assert: + that: + - nm_change_subnet2 is changed + - nm_change_subnet2.current.ip == "10.1.1.1/24" + - nm_change_subnet2.current.noDefaultGateway == false + - nm_change_subnet2.current.scope == "public" + - nm_change_subnet2.current.shared == true + - nm_change_subnet2.current.querier == true + - nm_change_subnet2.current.virtual == false + when: version.current.version is version('3.1.1g', '==') + +- name: Change subnet2 again (normal mode) + mso_schema_template_bd_subnet: + <<: *subnet_present + schema: '{{ mso_schema | default("ansible_test") }}_2' + template: Template2 + bd: ansible_test_2 + subnet: 10.1.1.1/24 + description: "My description for a subnet with virtual ip" + scope: public + shared: true + no_default_gateway: false + querier: true + is_virtual_ip: false + register: nm_change_subnet2_again + +- name: Verify nm_change_subnet2_again for a version that's not 3.1 + assert: + that: + - nm_change_subnet2_again is not changed + - nm_change_subnet2_again.current.ip == "10.1.1.1/24" + - nm_change_subnet2_again.current.noDefaultGateway == false + - nm_change_subnet2_again.current.scope == "public" + - nm_change_subnet2_again.current.shared == true + - nm_change_subnet2_again.current.querier == true + when: version.current.version is version('3.1.1g', '!=') + +- name: Verify cm_change_subnet2 for a version that's 3.1 + assert: + that: + - nm_change_subnet2_again is not changed + - nm_change_subnet2_again.current.ip == "10.1.1.1/24" + - nm_change_subnet2_again.current.noDefaultGateway == false + - nm_change_subnet2_again.current.scope == "public" + - nm_change_subnet2_again.current.shared == true + - nm_change_subnet2_again.current.querier == true + - nm_change_subnet2_again.current.virtual == false + when: version.current.version is version('3.1.1g', '==') + +# QUERY ALL Subnets +- name: Query all subnet (check_mode) + mso_schema_template_bd_subnet: &subnet_query + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template1 + bd: ansible_test_1 + state: query + check_mode: yes + register: cm_query_all_subnet + +- name: Query all subnet (normal mode) + mso_schema_template_bd_subnet: + <<: *subnet_query + register: nm_query_all_subnet + +- name: Verify query_all_subnet + assert: + that: + - cm_query_all_subnet is not changed + - nm_query_all_subnet is not changed + - cm_query_all_subnet.current | length == nm_query_all_subnet.current | length == 2 + +# QUERY A subnet +- name: Query subnet2 + mso_schema_template_bd_subnet: + <<: *subnet_query + schema: '{{ mso_schema | default("ansible_test") }}_2' + template: Template2 + bd: ansible_test_2 + subnet: 10.1.1.1/24 + register: nm_query_subnet2 + +- name: Verify nm_query_subnet2 for a version that's not 3.1 + assert: + that: + - nm_query_subnet2 is not changed + - nm_query_subnet2.current.ip == "10.1.1.1/24" + - nm_query_subnet2.current.noDefaultGateway == false + - nm_query_subnet2.current.scope == "public" + - nm_query_subnet2.current.shared == true + - nm_query_subnet2.current.querier == true + when: version.current.version is version('3.1.1g', '!=') + +- name: Verify nm_query_subnet2 for a version that's 3.1 + assert: + that: + - nm_query_subnet2 is not changed + - nm_query_subnet2.current.ip == "10.1.1.1/24" + - nm_query_subnet2.current.noDefaultGateway == false + - nm_query_subnet2.current.scope == "public" + - nm_query_subnet2.current.shared == true + - nm_query_subnet2.current.querier == true + - nm_query_subnet2.current.virtual == false + when: version.current.version is version('3.1.1g', '==') + +# REMOVE Subnet +- name: Remove subnet + mso_schema_template_bd_subnet: &subnet_absent + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template1 + bd: ansible_test_1 + subnet: 172.16.0.1/24 + state: absent + register: nm_remove_subnet + +- name: Verify nm_remove_subnet + assert: + that: + - nm_remove_subnet is changed + - nm_remove_subnet.current == {} + +- name: Remove subnet again (check_mode) + mso_schema_template_bd_subnet: + <<: *subnet_absent + register: nm_remove_subnet_again + +- name: Verify nm_remove_subnet_again + 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: + <<: *subnet_query + bd: ansible_test_1 + subnet: 172.16.0.3/24 + ignore_errors: yes + register: nm_query_non_subnet + +- name: Verify nm_query_non_subnet + 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: + <<: *subnet_query + state: non-existing-state + ignore_errors: yes + register: nm_non_existing_state + +- name: Verify non_existing_state + 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: + <<: *subnet_query + schema: non-existing-schema + ignore_errors: yes + register: nm_non_existing_schema + +- name: Verify non_existing_schema + 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: + <<: *subnet_query + template: non-existing-template + ignore_errors: yes + register: nm_non_existing_template + +- name: Verify non_existing_template + 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: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template1 + bd: ansible_test_3 + subnet: 172.16.0.5/24 + state: present + register: nm_add_subnet_no_desc + +- name: Verify nm_add_subnet_no_desc + 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: + <<: *subnet_query + bd: non-existing-bd + ignore_errors: yes + register: nm_non_existing_bd + +- name: Verify non_existing_bd + 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: + <<: *mso_info + schema: '{{ item }}' + state: absent + loop: + - '{{ mso_schema | default("ansible_test") }}_2' + - '{{ mso_schema | default("ansible_test") }}' \ No newline at end of file diff --git a/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_contract_filter/aliases b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_contract_filter/aliases new file mode 100644 index 00000000..5042c9c0 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_contract_filter/aliases @@ -0,0 +1,2 @@ +# No ACI MultiSite infrastructure, so not enabled +# unsupported diff --git a/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_contract_filter/tasks/main.yml b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_contract_filter/tasks/main.yml new file mode 100644 index 00000000..abfd6715 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_contract_filter/tasks/main.yml @@ -0,0 +1,1043 @@ +# Test code for the MSO modules +# Copyright: (c) 2020, Cindy Zhao (@cizhao) +# Copyright: (c) 2020, Lionel Hercot (@lhercot) +# Copyright: (c) 2018, Dag Wieers (@dagwieers) (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: + 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 +# 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(true) }}' +# output_level: '{{ mso_output_level | default("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 + +- name: Remove schema 2 + mso_schema: + host: '{{ mso_hostname }}' + username: '{{ mso_username }}' + password: '{{ mso_password }}' + schema: '{{ mso_schema | default("ansible_test") }}_2' + validate_certs: false + state: absent + +- name: Remove schema 1 + mso_schema: + host: '{{ mso_hostname }}' + username: '{{ mso_username }}' + password: '{{ mso_password }}' + schema: '{{ mso_schema | default("ansible_test") }}' + validate_certs: false + state: absent + +- name: Ensure tenant ansible_test exist + mso_tenant: &tenant_present + 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(true) }}' + output_level: '{{ mso_output_level | default("info") }}' + tenant: ansible_test + users: + - '{{ mso_username }}' + # sites: + # - '{{ mso_site | default("ansible_test") }}' + state: present + +- name: Ensure schema 1 with Template 1 exist + mso_schema_template: &schema_present + 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(true) }}' + output_level: '{{ mso_output_level | default("info") }}' + schema: '{{ mso_schema | default("ansible_test") }}' + tenant: ansible_test + template: Template 1 + state: present + +- name: Ensure schema 1 with Template 2 exist + mso_schema_template: + <<: *schema_present + template: Template 2 + state: present + + +- name: Ensure schema 2 with Template 3 exist + mso_schema_template: + <<: *schema_present + schema: '{{ mso_schema | default("ansible_test") }}_2' + tenant: ansible_test + template: Template 3 + state: present + + +- name: Ensure Filter 1 exist + cisco.mso.mso_schema_template_filter_entry: &filter_present + 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(true) }}' + output_level: '{{ mso_output_level | default("info") }}' + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + filter: Filter 1 + #add filter entry + entry: Filter 1 entry + state: present + +- name: Ensure Filter 2 exist + mso_schema_template_filter_entry: + <<: *filter_present + template: Template 2 + filter: Filter 2 + entry: Filter 2 entry + state: present + +- name: Ensure Filter 3 exist + mso_schema_template_filter_entry: + <<: *filter_present + schema: '{{ mso_schema | default("ansible_test") }}_2' + template: Template 3 + filter: Filter 3 + entry: Filter 3 entry + state: present + +- name: Ensure Filter 4 exist + mso_schema_template_filter_entry: + <<: *filter_present + filter: Filter 4 + entry: Filter 4 entry + state: present + +- name: Ensure Filter 5 exist + mso_schema_template_filter_entry: + <<: *filter_present + filter: Filter 5 + entry: Filter 5 entry + state: present + +- name: Ensure Filter 6 exist + mso_schema_template_filter_entry: + <<: *filter_present + filter: Filter 6 + entry: Filter 6 entry + state: present + +- name: Ensure Contract_1 contract does not exist + mso_schema_template_contract_filter: &contract_present + 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(true) }}' + output_level: '{{ mso_output_level | default("info") }}' + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + contract: Contract 1 + filter: Filter 1 + filter_schema: '{{ mso_schema | default("ansible_test") }}' + filter_template: Template 1 + state: absent + +- name: Ensure Contract_2 contract does not exist + mso_schema_template_contract_filter: + <<: *contract_present + template: Template 2 + contract: Contract 2 + state: absent + +- name: Ensure Contract_3 contract does not exist + mso_schema_template_contract_filter: + <<: *contract_present + schema: '{{ mso_schema | default("ansible_test") }}_2' + template: Template 3 + contract: Contract 3 + state: absent + +- name: Ensure Contract_4 contract does not exist + mso_schema_template_contract_filter: + <<: *contract_present + contract: Contract 4 + state: absent + +- name: Ensure Contract_5 contract does not exist + mso_schema_template_contract_filter: + <<: *contract_present + contract: Contract 5 + state: absent + +- name: Ensure Contract_6 contract does not exist + mso_schema_template_contract_filter: + <<: *contract_present + contract: Contract 6 + state: absent + +# ADD CONTRACT +- name: Add contract (check_mode) + mso_schema_template_contract_filter: + <<: *contract_present + contract: Contract 1 + #contract_scope: global + #contract_filter_type: both-way + filter: Filter 1 + state: present + check_mode: yes + register: cm_add_contract + +- name: Verify cm_add_contract + assert: + that: + - cm_add_contract is changed + - cm_add_contract.previous == {} + - cm_add_contract.current.filterRef.filterName == "Filter 1" + - cm_add_contract.current.filterRef.templateName == "Template1" + +- name: Add contract (normal mode) + mso_schema_template_contract_filter: + <<: *contract_present + contract: Contract 1 + #contract_scope: global + #contract_filter_type: both-way + filter: Filter 1 + state: present + register: nm_add_contract + +- name: Verify nm_add_contract + assert: + that: + - nm_add_contract is changed + - nm_add_contract.previous == {} + - nm_add_contract.current.filterRef.filterName == "Filter 1" + - nm_add_contract.current.filterRef.templateName == "Template1" + - cm_add_contract.current.filterRef.schemaId == nm_add_contract.current.filterRef.schemaId + +- name: Add contract again (check_mode) + mso_schema_template_contract_filter: + <<: *contract_present + contract: Contract 1 + #contract_scope: global + filter: Filter 1 + state: present + check_mode: yes + register: cm_add_contract_again + +- name: Verify cm_add_contract_again + assert: + that: + - cm_add_contract_again is not changed + - cm_add_contract_again.current.filterRef.filterName == "Filter 1" + - cm_add_contract_again.current.filterRef.templateName == "Template1" + - cm_add_contract_again.previous.filterRef.filterName == "Filter 1" + - cm_add_contract_again.previous.filterRef.templateName == "Template1" + - 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: + <<: *contract_present + contract: Contract 1 + #contract_scope: global + filter: Filter 1 + state: present + register: nm_add_contract_again + +- name: Verify nm_add_contract_again + assert: + that: + - nm_add_contract_again is not changed + - nm_add_contract_again.current.filterRef.filterName == "Filter 1" + - nm_add_contract_again.current.filterRef.templateName == "Template1" + - nm_add_contract_again.current.filterRef.templateName == "Template1" + - nm_add_contract_again.previous.filterRef.filterName == "Filter 1" + - nm_add_contract_again.previous.filterRef.templateName == "Template1" + - nm_add_contract_again.previous.filterRef.schemaId == nm_add_contract_again.current.filterRef.schemaId + +- name: Add contract 2 (check_mode) + mso_schema_template_contract_filter: + <<: *contract_present + template: Template 2 + contract: Contract 2 + filter: Filter 1 + filter_template: Template 1 + state: present + check_mode: yes + register: cm_add_contract_2 + +- name: Verify cm_add_contract_2 + assert: + that: + - cm_add_contract_2 is changed + - cm_add_contract_2.current.filterRef.filterName == "Filter 1" + - cm_add_contract_2.current.filterRef.templateName == "Template1" + +- name: Add contract 2 (nomal mode) + mso_schema_template_contract_filter: + <<: *contract_present + template: Template 2 + contract: Contract 2 + filter: Filter 1 + filter_template: Template 1 + state: present + register: nm_add_contract_2 + +- name: Verify nm_add_contract_2 + assert: + that: + - nm_add_contract_2 is changed + - nm_add_contract_2.current.filterRef.filterName == "Filter 1" + - nm_add_contract_2.current.filterRef.templateName == "Template1" + - cm_add_contract_2.current.filterRef.schemaId == nm_add_contract_2.current.filterRef.schemaId + +- name: Add contract 3 (nomal mode) + mso_schema_template_contract_filter: + <<: *contract_present + schema: '{{ mso_schema | default("ansible_test") }}_2' + template: Template 3 + contract: Contract 3 + filter: Filter 1 + filter_template: Template 1 + filter_schema: '{{ mso_schema | default("ansible_test") }}' + state: present + register: nm_add_contract_3 + +- name: Verify nm_add_contract_3 + assert: + that: + - nm_add_contract_3 is changed + - nm_add_contract_3.current.filterRef.filterName == "Filter 1" + - nm_add_contract_3.current.filterRef.templateName == "Template1" + +- name: Add contract 4 (nomal mode) + mso_schema_template_contract_filter: + <<: *contract_present + contract: Contract 4 + filter: Filter 1 + contract_display_name: display name name for contract 4 + state: present + register: nm_add_contract_4 + +- name: Verify nm_add_contract_4 + assert: + that: + - nm_add_contract_4 is changed + - nm_add_contract_4.current.filterRef.filterName == "Filter 1" + - nm_add_contract_4.current.filterRef.templateName == "Template1" + - nm_add_contract_3.current.filterRef.schemaId == nm_add_contract_4.current.filterRef.schemaId == nm_add_contract_2.current.filterRef.schemaId == nm_add_contract.current.filterRef.schemaId + +# create CONTRACT FILTER with diff options +- name: Add Contract filter to both-way(check_mode) + mso_schema_template_contract_filter: + <<: *contract_present + contract: Contract 1 + contract_filter_type: both-way + filter: Filter 4 + filter_type: both-way + state: present + check_mode: yes + register: cm_add_contract_filter_both_way + +- name: Add Contract filter to both-way(normal_mode) + mso_schema_template_contract_filter: + <<: *contract_present + contract: Contract 1 + contract_filter_type: both-way + filter: Filter 4 + filter_type: both-way + state: present + register: nm_add_contract_filter_both_way + +- name: Verify cm_change_contract_filter_both_way + assert: + that: + - cm_add_contract_filter_both_way is changed + - nm_add_contract_filter_both_way is changed + - cm_add_contract_filter_both_way.previous == {} + - nm_add_contract_filter_both_way.previous == {} + - cm_add_contract_filter_both_way.current.filterRef.filterName == "Filter 4" + - cm_add_contract_filter_both_way.current.filterRef.templateName == "Template1" + - nm_add_contract_filter_both_way.current.filterRef.filterName == "Filter 4" + - nm_add_contract_filter_both_way.current.filterRef.templateName == "Template1" + - cm_add_contract_filter_both_way.current.filterRef.schemaId == nm_add_contract_filter_both_way.current.filterRef.schemaId + - cm_add_contract_filter_both_way.current.contractFilterType == "bothWay" + - cm_add_contract_filter_both_way.current.contractScope == "context" + - cm_add_contract_filter_both_way.current.displayName == "Contract 1" + - cm_add_contract_filter_both_way.current.filterType == "both-way" + +- name: Change Contract type both_way Filter type consumer-to-provider(normal_mode) + mso_schema_template_contract_filter: + <<: *contract_present + contract: Contract 1 + contract_filter_type: both-way + filter: Filter 4 + filter_type: consumer-to-provider + state: present + ignore_errors: yes + register: nm_both_way_and_consumer_to_provider + +- name: Verify nm_both_way_and_consumer_to_provider + assert: + that: + - nm_both_way_and_consumer_to_provider is not changed + - nm_both_way_and_consumer_to_provider.msg == "You are adding 'one-way' filters to a 'both-way' contract" + +- name: Change Contract type both_way Filter type provider-to-consumer(normal_mode) + mso_schema_template_contract_filter: + <<: *contract_present + contract: Contract 1 + contract_filter_type: both-way + filter: Filter 4 + filter_type: provider-to-consumer + state: present + ignore_errors: yes + register: nm_both_way_and_provider_to_consumer + +- name: Verify nm_both_way_and_provider_to_consumer + assert: + that: + - nm_both_way_and_provider_to_consumer is not changed + - nm_both_way_and_provider_to_consumer.msg == "You are adding 'one-way' filters to a 'both-way' contract" + +- name: Change Contract type one_way Filter type both way(normal_mode) + mso_schema_template_contract_filter: + <<: *contract_present + contract: Contract 1 + contract_filter_type: one-way + filter: Filter 4 + filter_type: both-way + state: present + ignore_errors: yes + register: nm_one_way_and_both_way + +- name: Verify nm_one_way_and_both_way + assert: + that: + - nm_one_way_and_both_way is not changed + - nm_one_way_and_both_way.msg == "You are adding 'both-way' filters to a 'one-way' contract" + +- name: Change Contract type one_way Filter type consumer-to-provider(normal_mode) + mso_schema_template_contract_filter: + <<: *contract_present + contract: Contract 5 + contract_filter_type: one-way + filter: Filter 5 + filter_type: consumer-to-provider + state: present + register: nm_one_way_and_consumer_to_provider + +- name: Verify nm_one_way_and_consumer_to_provider + assert: + that: + - nm_one_way_and_consumer_to_provider is changed + - nm_one_way_and_consumer_to_provider.previous == {} + - nm_one_way_and_consumer_to_provider.current.contractFilterType == "oneWay" + - nm_one_way_and_consumer_to_provider.current.contractScope == "context" + - nm_one_way_and_consumer_to_provider.current.displayName == "Contract 5" + - 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: + <<: *contract_present + contract: Contract 6 + contract_filter_type: one-way + filter: Filter 6 + filter_type: provider-to-consumer + state: present + register: nm_one_way_and_provider_to_consumer + +- name: Verify nm create contract filter with different type + assert: + that: + - nm_one_way_and_provider_to_consumer is changed + - nm_one_way_and_provider_to_consumer.current.contractFilterType == "oneWay" + - nm_one_way_and_provider_to_consumer.current.contractScope == "context" + - nm_one_way_and_provider_to_consumer.current.displayName == "Contract 6" + - nm_one_way_and_provider_to_consumer.current.filterType == "provider-to-consumer" + +# change contract display name +- name: change contract display name + mso_schema_template_contract_filter: + <<: *contract_present + contract: Contract 4 + filter: Filter 1 + contract_display_name: new display name for contract 4 + state: present + register: nm_change_display_name + +- name: Verify nm_change_display_name + assert: + that: + - nm_change_display_name is changed + - nm_change_display_name.current.displayName == "new display name for contract 4" + - nm_change_display_name.previous.displayName == "display name name for contract 4" + +# change contract filter_directives to log +- name: change contract filter_directives to log(check_mode) + mso_schema_template_contract_filter: + <<: *contract_present + contract: Contract 4 + filter: Filter 1 + filter_directives: log + state: present + check_mode: yes + register: cm_change_filter_directives_log + +- name: change contract filter_directives to log(normal_mode) + mso_schema_template_contract_filter: + <<: *contract_present + contract: Contract 4 + filter: Filter 1 + filter_directives: log + state: present + register: nm_change_filter_directives_log + +- name: Verify change_contract_filter_directives to log + assert: + that: + - cm_change_filter_directives_log is changed + - nm_change_filter_directives_log is changed + - cm_change_filter_directives_log.previous.directives[0] == "none" + - nm_change_filter_directives_log.previous.directives[0] == "none" + - cm_change_filter_directives_log.current.directives[0] == "log" + - 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: + <<: *contract_present + contract: Contract 4 + filter: Filter 1 + filter_directives: ['log', 'none'] + state: present + register: nm_change_filter_directives_log_and_none + +- name: Verify nm_change_filter_directives_log_and_none + assert: + that: + - nm_change_filter_directives_log_and_none is changed + - nm_change_filter_directives_log_and_none.previous.directives[0] == "log" + - nm_change_filter_directives_log_and_none.current.directives == ['log', 'none'] + +# change contract filter_directives to policy_compression +- name: change contract filter_directives to policy_compression (check_mode) + mso_schema_template_contract_filter: + <<: *contract_present + contract: Contract 4 + filter: Filter 1 + filter_directives: policy_compression + state: present + check_mode: yes + register: cm_change_filter_directives_pc + +- name: change contract filter_directives to policy_compression (normal_mode) + mso_schema_template_contract_filter: + <<: *contract_present + contract: Contract 4 + filter: Filter 1 + filter_directives: policy_compression + state: present + register: nm_change_filter_directives_pc + +- name: Verify change_contract_filter_directives to pc + assert: + that: + - cm_change_filter_directives_pc is changed + - nm_change_filter_directives_pc is changed + - cm_change_filter_directives_pc.previous.directives == ['log', 'none'] + - nm_change_filter_directives_pc.previous.directives == ['log', 'none'] + - cm_change_filter_directives_pc.current.directives[0] == "no_stats" + - 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: + <<: *contract_present + contract: Contract 4 + filter: Filter 1 + filter_directives: ['log', 'none', 'policy_compression'] + state: present + register: nm_change_filter_directives_log_and_none_pc + +- name: Verify nm_change_filter_directives_log_and_none_pc + 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 contract 1 scope to global (normal mode) + mso_schema_template_contract_filter: + <<: *contract_present + contract: Contract 1 + contract_scope: global + state: present + register: nm_change_contract_scope_global + +- name: Verify nm_change_contract_scope_global + 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 contract 1 scope to tenant(normal mode) + mso_schema_template_contract_filter: + <<: *contract_present + contract: Contract 1 + contract_scope: tenant + state: present + register: nm_change_contract_scope_tenant + +- name: Verify nm_change_contract_scope_tenant + 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 contract 1 scope application_profile(normal mode) + mso_schema_template_contract_filter: + <<: *contract_present + contract: Contract 1 + contract_scope: application-profile + state: present + register: nm_change_contract_scope_application_profile + +- name: Verify nm_change_contract_scope_application_profile + 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 contract 1 scope to vrf(normal mode) + mso_schema_template_contract_filter: + <<: *contract_present + contract: Contract 1 + contract_scope: vrf + state: present + register: nm_change_contract_scope_vrf + +- name: Verify nm_change_contract_scope_vrf + 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 contract 1 scope to default(normal mode) + mso_schema_template_contract_filter: + <<: *contract_present + contract: Contract 1 + state: present + register: nm_change_contract_scope_default + +- name: Verify nm_change_contract_scope_default + 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" + +# QUERY ALL CONTRACT +- name: Query contract 1 filters (check_mode) + mso_schema_template_contract_filter: &Contract_query + 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(true) }}' + output_level: '{{ mso_output_level | default("info") }}' + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + contract: Contract 1 + state: query + check_mode: yes + register: cm_contract1_query_result + +- name: Query contract 1 filters (normal_mode) + mso_schema_template_contract_filter: + <<: *Contract_query + register: nm_contract1_query_result + +- name: Verify query_contract_1 + 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 contract 2 filters (normal_mode) + mso_schema_template_contract_filter: + <<: *Contract_query + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 2 + contract: Contract 2 + state: query + register: nm_contract2_query_result + +- name: Query contract 3 filters (normal_mode) + mso_schema_template_contract_filter: + <<: *Contract_query + schema: '{{ mso_schema | default("ansible_test") }}_2' + template: Template 3 + contract: Contract 3 + register: nm_contract3_query_result + +- name: Query contract 4 filters (normal_mode) + mso_schema_template_contract_filter: + <<: *Contract_query + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + contract: Contract 4 + register: nm_contract4_query_result + +- name: Query contract 5 filters (normal_mode) + mso_schema_template_contract_filter: + <<: *Contract_query + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + contract: Contract 5 + contract_filter_type: one-way + filter_type: consumer-to-provider + register: nm_contract5_query_result + +- name: Query contract 6 filters (normal_mode) + mso_schema_template_contract_filter: + <<: *Contract_query + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + contract: Contract 6 + contract_filter_type: one-way + filter_type: provider-to-consumer + register: nm_contract6_query_result + +- name: Verify query_contract + assert: + that: + - nm_contract2_query_result is not changed + - nm_contract3_query_result is not changed + - nm_contract4_query_result is not changed + - nm_contract2_query_result.current | length == nm_contract3_query_result.current | length == nm_contract4_query_result.current | length == 1 + - nm_contract5_query_result is not changed + - nm_contract6_query_result is not changed + - nm_contract5_query_result.current | length == 1 + - nm_contract6_query_result.current | length == 1 + +# QUERY A SPECIFIC CONTRACT FILTER +- name: Query contract 1 filter 1 (check_mode) + mso_schema_template_contract_filter: &Contract_filter_query + 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(true) }}' + output_level: '{{ mso_output_level | default("info") }}' + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + contract: Contract 1 + filter: Filter 1 + state: query + check_mode: yes + register: cm_contract1_filter1_query_result + +- name: Query contract 1 filter 4 (normal_mode) + mso_schema_template_contract_filter: + <<: *Contract_filter_query + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + contract: Contract 1 + filter: Filter 4 + state: query + register: nm_contract1_filter4_query_result + +- name: Query contract 2 filter 1 (normal_mode) + mso_schema_template_contract_filter: + <<: *Contract_filter_query + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 2 + contract: Contract 2 + filter_template: Template 1 + filter: Filter 1 + state: query + register: nm_contract2_filter1_query_result + +- name: Query contract 3 filter 1 (normal_mode) + mso_schema_template_contract_filter: + <<: *Contract_filter_query + schema: '{{ mso_schema | default("ansible_test") }}_2' + template: Template 3 + contract: Contract 3 + filter: Filter 1 + filter_template: Template 1 + filter_schema: '{{ mso_schema | default("ansible_test") }}' + state: query + register: nm_contract3_filter1_query_result + +- name: Query contract 4 filter 1 (normal_mode) + mso_schema_template_contract_filter: + <<: *Contract_filter_query + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + contract: Contract 4 + filter: Filter 1 + state: query + register: nm_contract4_filter1_query_result + +- name: Query contract 5 filter 5 (normal_mode) + mso_schema_template_contract_filter: + <<: *Contract_filter_query + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + contract: Contract 5 + filter: Filter 5 + contract_filter_type: one-way + filter_type: consumer-to-provider + state: query + register: nm_contract5_filter5_query_result + +- name: Query contract 6 filter 6 (normal_mode) + mso_schema_template_contract_filter: + <<: *Contract_filter_query + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + contract: Contract 6 + filter: Filter 6 + contract_filter_type: one-way + filter_type: provider-to-consumer + state: query + register: nm_contract6_filter6_query_result + +- name: Verify contract1_filter1_query_result + assert: + that: + - cm_contract1_filter1_query_result is not changed +# #- contract1_filter1_query_result.current.filterRef. + - nm_contract1_filter4_query_result is not changed + - nm_contract2_filter1_query_result is not changed + - nm_contract3_filter1_query_result is not changed + - nm_contract4_filter1_query_result is not changed + - nm_contract5_filter5_query_result is not changed + - nm_contract6_filter6_query_result is not changed + +# REMOVE CONTRACT Filter +- name: Remove contract1 filter1 (check_mode) + mso_schema_template_contract_filter: &contract1_filter1_absent + 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(true) }}' + output_level: '{{ mso_output_level | default("info") }}' + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + contract: Contract 1 + filter: Filter 1 + state: absent + check_mode: yes + register: cm_remove_contract1_filter1 + +- name: Verify cm_remove_contract1_filter1 + assert: + that: + - cm_remove_contract1_filter1 is changed + - cm_remove_contract1_filter1.current == {} + - cm_remove_contract1_filter1.previous.filterRef.filterName == "Filter 1" + - cm_remove_contract1_filter1.previous.filterRef.templateName == "Template1" +- name: Remove contract1 filter1 (normal_mode) + mso_schema_template_contract_filter: + <<: *contract1_filter1_absent + register: nm_remove_contract1_filter1 + +- name: Verify nm_remove_contract1_filter1 + assert: + that: + - nm_remove_contract1_filter1 is changed + - nm_remove_contract1_filter1.current == {} + - nm_remove_contract1_filter1.previous.filterRef.filterName == "Filter 1" + - nm_remove_contract1_filter1.previous.filterRef.templateName == "Template1" + +- name: Remove contract1 filter1 again (check_mode) + mso_schema_template_contract_filter: + <<: *contract1_filter1_absent + check_mode: yes + register: cm_remove_contract1_filter1_again + +- name: Verify cm_remove_contract1_filter1_again + 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: + <<: *contract1_filter1_absent + register: nm_remove_contract1_filter1_again + +- name: Verify nm_remove_contract1_filter1_again + 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: + <<: *contract1_filter1_absent + filter: Filter 4 + register: nm_remove_contract1_filter4 + +- name: Verify nm_remove_contract1_filter4 + assert: + that: + - nm_remove_contract1_filter4 is changed + - nm_remove_contract1_filter4.current == {} + - nm_remove_contract1_filter4.previous.filterRef.filterName == "Filter 4" + - nm_remove_contract1_filter4.previous.filterRef.templateName == "Template1" + +- name: Remove contract1 filter4 again (normal_mode) + mso_schema_template_contract_filter: + <<: *contract1_filter1_absent + filter: Filter 4 + register: nm_remove_contract1_filter4_again + +- name: Verify nm_remove_contract1_filter4_again + 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: + <<: *Contract_query + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + contract: Contract 4 + filter: non-existing-filter + check_mode: yes + ignore_errors: yes + register: cm_query_non_filter + +- name: Query non-existing filter (normal_mode) + mso_schema_template_contract_filter: + <<: *Contract_query + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + contract: Contract 4 + filter: non-existing-filter + ignore_errors: yes + register: nm_query_non_filter + +- name: Verify query_non_filter + assert: + that: + - cm_query_non_filter is not changed + - nm_query_non_filter is not changed + +# # QUERY NON-EXISTING CONTRACT +- name: Query non-existing contract (check_mode) + mso_schema_template_contract_filter: + <<: *Contract_query + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + contract: non-existing-contract + check_mode: yes + ignore_errors: yes + register: cm_query_non_contract + +- name: Query non-existing contract (normal_mode) + mso_schema_template_contract_filter: + <<: *Contract_query + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + contract: non-existing-contract + ignore_errors: yes + register: nm_query_non_contract + +- name: Verify query_non_contract + assert: + that: + - cm_query_non_contract is not changed + - nm_query_non_contract is not changed + - nm_query_non_contract == cm_query_non_contract + - cm_query_non_contract.msg == nm_query_non_contract.msg == "Provided contract 'non-existing-contract' does not exist. Existing contracts{{':'}} Contract 4, Contract 5, Contract 6" + +# USE A NON-EXISTING SCHEMA +- name: Non-existing schema for contrct (check_mode) + mso_schema_template_contract_filter: + <<: *Contract_query + template: Template 1 + schema: non-existing-schema + check_mode: yes + ignore_errors: yes + register: cm_query_non_schema + +- name: Non-existing schema for contrct (normal_mode) + mso_schema_template_contract_filter: + <<: *Contract_query + template: Template 1 + schema: non-existing-schema + ignore_errors: yes + register: nm_query_non_schema + + +- name: Verify non_existing_schema + assert: + that: + - cm_query_non_schema is not changed + - nm_query_non_schema is not changed + - cm_query_non_schema == nm_query_non_schema + - cm_query_non_schema.msg == nm_query_non_schema.msg == "Provided schema 'non-existing-schema' does not exist" + +# USE A NON-EXISTING TEMPLATE +- name: Non-existing template for contract (check_mode) + mso_schema_template_contract_filter: + <<: *Contract_query + schema: '{{ mso_schema | default("ansible_test") }}' + template: non-existing-template + check_mode: yes + ignore_errors: yes + register: cm_query_non_template + +- name: Non-existing template for contract (normal_mode) + mso_schema_template_contract_filter: + <<: *Contract_query + schema: '{{ mso_schema | default("ansible_test") }}' + template: non-existing-template + ignore_errors: yes + register: nm_query_non_template + +- name: Verify non_existing_template + assert: + that: + - cm_query_non_template is not changed + - nm_query_non_template is not changed + - cm_query_non_template == nm_query_non_template + - cm_query_non_template.msg == nm_query_non_template.msg == "Provided template 'non-existing-template' does not exist. Existing templates{{':'}} Template1, Template2" \ No newline at end of file diff --git a/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_deploy/aliases b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_deploy/aliases new file mode 100644 index 00000000..5042c9c0 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_deploy/aliases @@ -0,0 +1,2 @@ +# No ACI MultiSite infrastructure, so not enabled +# unsupported diff --git a/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_deploy/tasks/main.yml b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_deploy/tasks/main.yml new file mode 100644 index 00000000..494564b3 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_deploy/tasks/main.yml @@ -0,0 +1,199 @@ +# Test code for the MSO modules +# Copyright: (c) 2020, Cindy Zhao (@cizhao) + +# 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.' + 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: + 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(true) }}' + output_level: '{{ mso_output_level | default("info") }}' + +- name: Query MSO version + mso_version: + <<: *mso_info + state: query + register: version + +- name: Ensure site exist + mso_site: &site_present + <<: *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 + +- name: Undeploy template + mso_schema_template_deploy: + <<: *mso_info + schema: ansible_test + template: "{{ item }}" + site: '{{ mso_site | default("ansible_test") }}' + state: undeploy + ignore_errors: yes + loop: + - Template 1 + - Template 2 + - Template 3 + - Template 4 + - Template_5 + - Template 5 + - Template5 + +- name: Remove schemas + mso_schema: + <<: *mso_info + schema: '{{ item }}' + state: absent + loop: + - '{{ mso_schema | default("ansible_test") }}_2' + - '{{ mso_schema | default("ansible_test") }}' + +- name: Ensure tenant ansible_test exists + mso_tenant: + <<: *mso_info + tenant: ansible_test + users: + - '{{ mso_username }}' + sites: + - '{{ mso_site | default("ansible_test") }}' + state: present + +- name: Ensure schema 1 with Template 1, and Template 2, Template 3 exist + mso_schema_template: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + tenant: ansible_test + template: '{{ item }}' + state: present + loop: + - Template 1 + - Template 2 + - Template 3 + - Template 4 + - Template_5 + +- name: Add physical site to a schema + mso_schema_site: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: '{{ mso_site | default("ansible_test") }}' + template: '{{ item }}' + state: present + loop: + - Template 1 + - Template 2 + - Template 3 + - Template 4 + - Template_5 + +- name: Deploy templates (check_mode) + mso_schema_template_deploy: &schema_deploy + <<: *mso_info + schema: ansible_test + template: "{{ item }}" + site: '{{ mso_site | default("ansible_test") }}' + state: deploy + check_mode: yes + register: cm_deploy_template + loop: + - Template 1 + - Template 2 + - Template 3 + - Template 4 + - Template_5 + +- name: Verify cm_deploy_template + assert: + that: + - item is not changed + loop: "{{ cm_deploy_template.results }}" + +- name: Deploy templates (normal_mode) + mso_schema_template_deploy: + <<: *schema_deploy + schema: ansible_test + template: "{{ item }}" + site: '{{ mso_site | default("ansible_test") }}' + state: deploy + register: nm_deploy_template + loop: + - Template 1 + - Template 2 + - Template 3 + - Template 4 + - Template_5 + +- name: Verify nm_deploy_template + assert: + that: + - item is not changed + - item.msg == "Successfully deployed" + loop: "{{ nm_deploy_template.results }}" + +- name: Get deployment status + mso_schema_template_deploy: + <<: *schema_deploy + schema: ansible_test + template: "{{ item }}" + state: status + register: query_deploy_status + loop: + - Template 1 + - Template 2 + - Template 3 + - Template 4 + - Template_5 + +- name: Verify query_deploy_status + assert: + that: + - item is not changed + - item.status.0.status.siteStatus == "Succeeded" + loop: "{{ query_deploy_status.results }}" + +- name: Undeploy templates + mso_schema_template_deploy: + <<: *schema_deploy + schema: ansible_test + template: '{{ item }}' + site: '{{ mso_site | default("ansible_test") }}' + state: undeploy + register: undeploy_template + loop: + - Template 1 + - Template 2 + - Template 3 + - Template 4 + - Template_5 + +- name: Verify undeploy_template + assert: + that: + - item is not changed + - item.msg == "Successfully Un-deployed" + loop: "{{ undeploy_template.results }}" + when: version.current.version is version('3.1', '>=') + +- name: Verify undeploy_template + assert: + that: + - item is not changed + - item.msg == "Successfully deployed" + loop: "{{ undeploy_template.results }}" + when: version.current.version is version('3.1', '<') \ No newline at end of file diff --git a/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_external_epg/aliases b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_external_epg/aliases new file mode 100644 index 00000000..5042c9c0 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_external_epg/aliases @@ -0,0 +1,2 @@ +# No ACI MultiSite infrastructure, so not enabled +# unsupported diff --git a/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_external_epg/tasks/main.yml b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_external_epg/tasks/main.yml new file mode 100644 index 00000000..d614ce97 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_external_epg/tasks/main.yml @@ -0,0 +1,1110 @@ +# Test code for the MSO modules +# Copyright: (c) 2020, Cindy Zhao (@cizhao) +# Copyright: (c) 2020, Lionel Hercot (@lhercot) +# Copyright: (c) 2018, Dag Wieers (@dagwieers) (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: + 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: + 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(true) }}' + output_level: '{{ mso_output_level | default("info") }}' + +# - name: Ensure site exist +# mso_site: &site_present +# 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(true) }}' +# output_level: '{{ mso_output_level | default("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 + +- name: Remove schemas + mso_schema: + <<: *mso_info + schema: '{{ item }}' + state: absent + loop: + - '{{ mso_schema | default("ansible_test") }}_2' + - '{{ mso_schema | default("ansible_test") }}' + +- name: Ensure tenant ansible_test exist + mso_tenant: + <<: *mso_info + tenant: ansible_test + users: + - '{{ mso_username }}' + # sites: + # - '{{ mso_site | default("ansible_test") }}' + state: present + +- name: Ensure schema 1 with Template 1 exist + mso_schema_template: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + tenant: ansible_test + template: Template 1 + state: present + +- name: Ensure schema 1 with Template 2 exist + mso_schema_template: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + tenant: ansible_test + template: Template 2 + state: present + +- name: Ensure schema 2 with Template 3 exist + mso_schema_template: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}_2' + tenant: ansible_test + template: Template 3 + state: present + +- name: Ensure VRF exist + mso_schema_template_vrf: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + vrf: VRF + #layer3_multicast: true + state: present + +- name: Ensure VRF2 exist + mso_schema_template_vrf: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + vrf: VRF2 + state: present + +- name: Ensure VRF3 exist + mso_schema_template_vrf: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 2 + vrf: VRF3 + state: present + +- name: Ensure VRF4 exist + mso_schema_template_vrf: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}_2' + template: Template 3 + vrf: VRF4 + state: present + +- name: Ensure L3out exist + mso_schema_template_l3out: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + l3out: L3out + vrf: + name: VRF + state: present + +- name: Ensure L3out2 exist + mso_schema_template_l3out: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + l3out: L3out2 + vrf: + name: VRF2 + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + state: present + +- name: Ensure L3out3 exist + mso_schema_template_l3out: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + l3out: L3out3 + vrf: + name: VRF3 + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 2 + state: present + +- name: Ensure L3out4 exist + mso_schema_template_l3out: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}_2' + template: Template 3 + l3out: L3out4 + vrf: + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + name: VRF + state: present + +- name: Ensure ANP exists + mso_schema_template_anp: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + anp: ANP1 + state: present + +- name: Ensure ANP2 exist + mso_schema_template_anp: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + anp: ANP2 + state: present + +- name: Ensure ANP3 exist + mso_schema_template_anp: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + anp: ANP3 + state: present + +- name: Ensure ANP4 exist + mso_schema_template_anp: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}_2' + template: Template 3 + anp: ANP4 + state: present + +- name: Ensure ansible_test_1 external EPG does not exist + mso_schema_template_external_epg: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + external_epg: ansible_test_1 + state: absent + +- name: Ensure ansible_test_2 external EPG does not exist + mso_schema_template_external_epg: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 2 + external_epg: ansible_test_2 + state: absent + +- name: Ensure ansible_test_3 external EPG does not exist + mso_schema_template_external_epg: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}_2' + template: Template 3 + external_epg: ansible_test_3 + state: absent + +- name: Ensure ansible_test_4 external EPG does not exist + mso_schema_template_external_epg: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + external_epg: ansible_test_4 + state: absent + +- name: Ensure ansible_test_6 external EPG does not exist + mso_schema_template_external_epg: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 2 + external_epg: ansible_test_6 + state: absent + +- name: Ensure ansible_test_7 external EPG does not exist + mso_schema_template_external_epg: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 2 + external_epg: ansible_test_7 + state: absent + +# ADD external EPG +- name: Add external EPG (check_mode) + mso_schema_template_external_epg: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + external_epg: ansible_test_1 + vrf: + name: VRF + state: present + check_mode: yes + register: cm_add_epg + +- name: Verify cm_add_epg + assert: + that: + - cm_add_epg is changed + - cm_add_epg.previous == {} + - cm_add_epg.current.name == "ansible_test_1" + - cm_add_epg.current.vrfRef.templateName == "Template1" + - cm_add_epg.current.vrfRef.vrfName == "VRF" + +- name: Add external EPG (normal mode) + mso_schema_template_external_epg: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + external_epg: ansible_test_1 + vrf: + name: VRF + state: present + register: nm_add_epg + +- name: Verify nm_add_epg + assert: + that: + - nm_add_epg is changed + - nm_add_epg.previous == {} + - nm_add_epg.current.name == "ansible_test_1" + - nm_add_epg.current.vrfRef.templateName == "Template1" + - nm_add_epg.current.vrfRef.vrfName == "VRF" + - cm_add_epg.current.vrfRef.schemaId == nm_add_epg.current.vrfRef.schemaId + +- name: Add external EPG again (check_mode) + mso_schema_template_external_epg: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + external_epg: ansible_test_1 + vrf: + name: VRF + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + state: present + check_mode: yes + register: cm_add_epg_again + +- name: Verify cm_add_epg_again + assert: + that: + - cm_add_epg_again is not changed + - cm_add_epg_again.previous.name == "ansible_test_1" + - cm_add_epg_again.current.name == "ansible_test_1" + - cm_add_epg_again.previous.vrfRef.templateName == "Template1" + - cm_add_epg_again.current.vrfRef.templateName == "Template1" + - cm_add_epg_again.previous.vrfRef.vrfName == "VRF" + - cm_add_epg_again.current.vrfRef.vrfName == "VRF" + - cm_add_epg_again.previous.vrfRef.schemaId == cm_add_epg_again.current.vrfRef.schemaId + + +- name: Add epg again (normal mode) + mso_schema_template_external_epg: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + external_epg: ansible_test_1 + vrf: + name: VRF + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + state: present + register: nm_add_epg_again + +- name: Verify nm_add_epg_again + assert: + that: + - nm_add_epg_again is not changed + - nm_add_epg_again.previous.name == "ansible_test_1" + - nm_add_epg_again.current.name == "ansible_test_1" + - nm_add_epg_again.previous.vrfRef.templateName == "Template1" + - nm_add_epg_again.current.vrfRef.templateName == "Template1" + - nm_add_epg_again.previous.vrfRef.vrfName == "VRF" + - nm_add_epg_again.current.vrfRef.vrfName == "VRF" + - nm_add_epg_again.previous.vrfRef.schemaId == nm_add_epg_again.current.vrfRef.schemaId + +- name: Add external EPG (normal mode) + mso_schema_template_external_epg: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + external_epg: ansible_test_1 + state: present + ignore_errors: yes + register: ok + +- name: Add external EPG 2 (normal mode) + mso_schema_template_external_epg: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 2 + external_epg: ansible_test_2 + vrf: + name: VRF + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + l3out: + name: L3out + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + state: present + register: nm_add_epg_2 + +- name: Add external EPG 3 (normal mode) + mso_schema_template_external_epg: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}_2' + template: Template 3 + external_epg: ansible_test_3 + vrf: + name: VRF + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + l3out: + name: L3out + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + state: present + register: nm_add_epg_3 + +- name: Add external EPG 4 (normal mode) + mso_schema_template_external_epg: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + external_epg: ansible_test_4 + vrf: + name: VRF + state: present + register: nm_add_epg_4 + +- name: Verify nm_add_epg_2 and nm_add_epg_3 + assert: + that: + - nm_add_epg_2 is changed + - nm_add_epg_3 is changed + - nm_add_epg_2.current.name == "ansible_test_2" + - nm_add_epg_3.current.name == "ansible_test_3" + - nm_add_epg_2.current.vrfRef.templateName == nm_add_epg_3.current.vrfRef.templateName == "Template1" + - nm_add_epg_2.current.vrfRef.vrfName == nm_add_epg_3.current.vrfRef.vrfName == "VRF" + - nm_add_epg_2.current.vrfRef.schemaId == 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: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 2 + external_epg: ansible_test_5 + vrf: + name: VRF + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + anp: + name: ANP1 + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + state: present + register: nm_add_epg_5 + +- name: Verify nm_add_epg_5 + 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: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 2 + external_epg: ansible_test_5 + vrf: + name: VRF + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + l3out: + name: L3out + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + anp: + name: ANP1 + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + state: present + register: nm_add_epg_5_again + +- name: Verify nm_add_epg_5_again + 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: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 2 + external_epg: ansible_test_6 + type: cloud + vrf: + name: VRF + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + anp: + name: ANP1 + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + state: present + register: nm_add_epg_6 + +- name: Verify nm_add_epg_6 + assert: + that: + - nm_add_epg_6 is changed + - nm_add_epg_6.current.name == "ansible_test_6" + - nm_add_epg_6.current.vrfRef.templateName == "Template1" + - nm_add_epg_6.current.vrfRef.vrfName == "VRF" + - 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: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 2 + external_epg: ansible_test_6 + type: cloud + vrf: + name: VRF + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + anp: + name: ANP1 + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + state: present + register: nm_add_epg_6_again + +- name: Verify nm_add_epg_6_again + 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: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 2 + external_epg: ansible_test_6 + type: cloud + vrf: + name: VRF2 + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + anp: + name: ANP1 + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + state: present + register: nm_add_epg_6_again_2 + +- name: Verify nm_add_epg_6_again + assert: + that: + - nm_add_epg_6_again_2 is changed + - nm_add_epg_6_again_2.current.name == "ansible_test_6" + - nm_add_epg_6_again_2.current.vrfRef.vrfName == "VRF2" + - 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: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 2 + external_epg: ansible_test_7 + type: on-premise + vrf: + name: VRF + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + l3out: + name: L3out + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + state: present + register: nm_add_epg_7 + +- name: Verify nm_add_epg_7 + assert: + that: + - nm_add_epg_7 is changed + - nm_add_epg_7.current.name == "ansible_test_7" + - nm_add_epg_7.current.vrfRef.templateName == "Template1" + - 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: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 2 + external_epg: ansible_test_7 + vrf: + name: VRF + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + l3out: + name: L3out + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + state: present + register: nm_add_epg_7_again + +- name: Verify nm_add_epg_7_again + 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 (check_mode) + mso_schema_template_external_epg: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + external_epg: ansible_test_1 + vrf: + name: VRF3 + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 2 + state: present + check_mode: yes + register: cm_change_epg + +- name: Verify cm_change_epg + assert: + that: + - cm_change_epg is changed + - cm_change_epg.current.name == 'ansible_test_1' + - cm_change_epg.current.vrfRef.vrfName == 'VRF3' + - cm_change_epg.current.vrfRef.templateName == "Template2" + - cm_change_epg.current.vrfRef.schemaId == cm_change_epg.previous.vrfRef.schemaId + +- name: Change epg (normal_mode) + mso_schema_template_external_epg: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + external_epg: ansible_test_1 + vrf: + name: VRF3 + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 2 + state: present + register: nm_change_epg + +- name: Verify nm_change_epg + assert: + that: + - nm_change_epg is changed + - nm_change_epg.current.name == 'ansible_test_1' + - nm_change_epg.current.vrfRef.vrfName == 'VRF3' + - nm_change_epg.current.vrfRef.templateName == "Template2" + - nm_change_epg.current.vrfRef.schemaId == nm_change_epg.previous.vrfRef.schemaId + +- name: Change epg again (check_mode) + mso_schema_template_external_epg: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + external_epg: ansible_test_1 + vrf: + name: VRF3 + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 2 + state: present + check_mode: yes + register: cm_change_epg_again + +- name: Verify cm_change_epg_again + assert: + that: + - cm_change_epg_again is not changed + - cm_change_epg_again.current.name == 'ansible_test_1' + - cm_change_epg_again.current.vrfRef.vrfName == 'VRF3' + - cm_change_epg_again.current.vrfRef.templateName == "Template2" + - cm_change_epg_again.current.vrfRef.schemaId == cm_change_epg_again.previous.vrfRef.schemaId + +- name: Change epg again (normal_mode) + mso_schema_template_external_epg: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + external_epg: ansible_test_1 + vrf: + name: VRF3 + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 2 + state: present + register: nm_change_epg_again + +- name: Verify nm_change_epg_again + assert: + that: + - nm_change_epg_again is not changed + - nm_change_epg_again.current.name == 'ansible_test_1' + - nm_change_epg_again.current.vrfRef.vrfName == 'VRF3' + - nm_change_epg_again.current.vrfRef.templateName == "Template2" + - nm_change_epg_again.current.vrfRef.schemaId == nm_change_epg_again.previous.vrfRef.schemaId + +- name: Change epg to VRF4 (normal mode) + mso_schema_template_external_epg: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + external_epg: ansible_test_1 + vrf: + name: VRF4 + schema: '{{ mso_schema | default("ansible_test") }}_2' + template: Template 3 + state: present + register: nm_change_epg_vrf4 + +- name: Change epg to VRF2 (normal mode) + mso_schema_template_external_epg: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + external_epg: ansible_test_1 + vrf: + name: VRF2 + state: present + register: nm_change_epg_vrf2 + +- name: Verify nm_change_epg_vrf4 and nm_change_epg_vrf2 + assert: + that: + - nm_change_epg_vrf4 is changed + - nm_change_epg_vrf4.current.name == nm_change_epg_vrf2.current.name == 'ansible_test_1' + - nm_change_epg_vrf4.current.vrfRef.vrfName == 'VRF4' + - nm_change_epg_vrf4.current.vrfRef.templateName == "Template3" + - nm_change_epg_vrf2 is changed + - nm_change_epg_vrf2.current.vrfRef.vrfName == 'VRF2' + - nm_change_epg_vrf2.current.vrfRef.templateName == "Template1" + - nm_change_epg_vrf4.current.vrfRef.schemaId != nm_change_epg_vrf2.current.vrfRef.schemaId + +- name: Change epg 1 l3out(normal mode) + mso_schema_template_external_epg: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + external_epg: ansible_test_1 + vrf: + name: VRF + l3out: + name: L3out4 + schema: '{{ mso_schema | default("ansible_test") }}_2' + template: Template 3 + state: present + register: nm_change_epg_1_l3out + +- name: Change epg 1 settings(normal mode) + mso_schema_template_external_epg: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + external_epg: ansible_test_1 + vrf: + name: VRF + l3out: + name: L3out + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + state: present + register: nm_change_epg_1_settings + +- name: Verify nm_change_epg_1_settings and nm_change_epg_1_l3out + assert: + that: + - nm_change_epg_1_settings is changed + - nm_change_epg_1_settings.previous.vrfRef.vrfName == 'VRF' + - nm_change_epg_1_settings.previous.vrfRef.templateName == 'Template1' + - nm_change_epg_1_settings.current.vrfRef.vrfName == 'VRF' + - nm_change_epg_1_settings.current.vrfRef.templateName == 'Template1' + - nm_change_epg_1_settings.current.l3outRef.l3outName == 'L3out' + - nm_change_epg_1_settings.current.l3outRef.templateName == 'Template1' + - nm_change_epg_1_settings.previous.l3outRef.schemaId != nm_change_epg_1_settings.current.l3outRef.schemaId + - nm_change_epg_1_l3out is changed + - nm_change_epg_1_l3out.previous.vrfRef.vrfName == 'VRF2' + - nm_change_epg_1_l3out.previous.vrfRef.templateName == 'Template1' + - nm_change_epg_1_l3out.current.vrfRef.vrfName == 'VRF' + - nm_change_epg_1_l3out.current.vrfRef.templateName == 'Template1' + - nm_change_epg_1_l3out.current.l3outRef.l3outName == 'L3out4' + - nm_change_epg_1_l3out.current.l3outRef.templateName == 'Template3' + +- name: Change epg 4 preferredGroup(normal mode) + mso_schema_template_external_epg: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + external_epg: ansible_test_4 + vrf: + name: VRF + preferred_group: true + state: present + register: nm_change_epg_4_preferred_group + +- name: Change epg 4 preferredGroup again(normal mode) + mso_schema_template_external_epg: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + external_epg: ansible_test_4 + vrf: + name: VRF + preferred_group: false + state: present + 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: + that: + - nm_change_epg_4_preferred_group is changed + - nm_change_epg_4_preferred_group_again is changed + - nm_change_epg_4_preferred_group.current.preferredGroup == true + - nm_change_epg_4_preferred_group_again.current.preferredGroup == false + +# QUERY ALL EPG +- name: Query all EPG (check_mode) + mso_schema_template_external_epg: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + state: query + check_mode: yes + register: cm_query_all_epgs + +- name: Query all EPG (normal mode) + mso_schema_template_external_epg: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + state: query + register: nm_query_all_epgs + +- name: Verify query_all_epgs + assert: + that: + - cm_query_all_epgs is not changed + - nm_query_all_epgs is not changed + - cm_query_all_epgs.current | length == nm_query_all_epgs.current | length == 2 + +# QUERY AN EPG +- name: Query epg 1(check_mode) + mso_schema_template_external_epg: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + external_epg: ansible_test_1 + state: query + check_mode: yes + register: cm_query_epg_1 + +- name: Query epg 1(normal_mode) + mso_schema_template_external_epg: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + external_epg: ansible_test_1 + state: query + register: nm_query_epg_1 + +- name: Verify cm_query_epg_1 and nm_query_epg_1 + assert: + that: + - cm_query_epg_1 is not changed + - nm_query_epg_1 is not changed + - cm_query_epg_1.current.l3outRef.l3outName == 'L3out' == nm_query_epg_1.current.l3outRef.l3outName + - cm_query_epg_1.current.l3outRef.templateName == nm_query_epg_1.current.l3outRef.templateName == 'Template1' + - cm_query_epg_1.current.l3outRef.schemaId == nm_query_epg_1.current.l3outRef.schemaId + - cm_query_epg_1.current.vrfRef.vrfName == nm_query_epg_1.current.vrfRef.vrfName == 'VRF' + - cm_query_epg_1.current.vrfRef.templateName == nm_query_epg_1.current.vrfRef.templateName == 'Template1' + - cm_query_epg_1.current.vrfRef.schemaId == nm_query_epg_1.current.vrfRef.schemaId + - 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: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 2 + external_epg: ansible_test_5 + state: query + register: nm_query_epg_5 + +- name: Verify nm_query_epg_5 + assert: + that: + - nm_query_epg_5.current.l3outRef.l3outName == 'L3out' + +- name: Query epg 6(normal_mode) + mso_schema_template_external_epg: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 2 + external_epg: ansible_test_6 + state: query + register: nm_query_epg_6 + +- name: Verify nm_query_epg_5 + assert: + that: + - nm_add_epg_6.current.anpRef.anpName == "ANP1" + +# REMOVE EPG +- name: Remove EPG 4 (check_mode) + mso_schema_template_external_epg: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + external_epg: ansible_test_4 + state: absent + check_mode: yes + register: cm_remove_epg_4 + +- name: Verify cm_remove_epg_4 + assert: + that: + - cm_remove_epg_4 is changed + - cm_remove_epg_4.current == {} + +- name: Remove EPG 4 (normal_mode) + mso_schema_template_external_epg: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + external_epg: ansible_test_4 + state: absent + register: nm_remove_epg_4 + +- name: Verify nm_remove_epg_4 + 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: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + external_epg: ansible_test_4 + state: absent + register: nm_remove_epg_4_again + +- name: Verify nm_remove_epg_4_again + assert: + that: + - nm_remove_epg_4_again is not changed + - nm_remove_epg_4_again.previous == nm_remove_epg_4_again.current == {} + +# QUERY NON-EXISTING EPG +- name: Query non-existing EPG (check_mode) + mso_schema_template_external_epg: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + external_epg: non-existing-epg + state: query + ignore_errors: yes + check_mode: yes + register: cm_query_non_existing_epg + +- name: Query non-existing EPG (normal_mode) + mso_schema_template_external_epg: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + external_epg: non-existing-epg + state: query + ignore_errors: yes + register: nm_query_non_existing_epg + +- name: Verify cm_query_non_existing_epg and nm_query_non_existing_epg + assert: + that: + - cm_query_non_existing_epg is not changed + - nm_query_non_existing_epg is not changed + - cm_query_non_existing_epg == nm_query_non_existing_epg + - cm_query_non_existing_epg.msg == nm_query_non_existing_epg.msg == "External EPG 'non-existing-epg' not found" + +# USE A NON-EXISTING SCHEMA +- name: Non-existing schema for epg (check_mode) + mso_schema_template_external_epg: + <<: *mso_info + schema: non-existing-schema + template: Template 1 + state: query + check_mode: yes + ignore_errors: yes + register: cm_non_existing_schema + +- name: Non-existing schema for epg (normal_mode) + mso_schema_template_external_epg: + <<: *mso_info + schema: non-existing-schema + template: Template 1 + state: query + ignore_errors: yes + register: nm_non_existing_schema + +- name: Verify non_existing_schema + assert: + that: + - cm_non_existing_schema is not changed + - nm_non_existing_schema is not changed + - cm_non_existing_schema == nm_non_existing_schema + - cm_non_existing_schema.msg == nm_non_existing_schema.msg == "Provided schema 'non-existing-schema' does not exist" + +# USE A NON-EXISTING TEMPLATE +- name: Non-existing template for epg (check_mode) + mso_schema_template_external_epg: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: non-existing-template + state: query + check_mode: yes + ignore_errors: yes + register: cm_non_existing_template + +- name: Non-existing template for epg (normal_mode) + mso_schema_template_external_epg: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: non-existing-template + state: query + ignore_errors: yes + register: nm_non_existing_template + +- name: Verify non_existing_template + 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" + +# Checking if contract are removed after re-applying an EPG. (#13 | #62137) +- name: Add Contracts to EPG 1 + mso_schema_template_external_epg_contract: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + external_epg: ansible_test_1 + contract: + name: '{{ item.name }}' + template: '{{ item.template }}' + type: '{{ item.type }}' + state: present + loop: + - { name: Contract1, template: Template 1, type: consumer } + - { name: Contract1, template: Template 1, type: provider } + - { name: Contract2, template: Template 2, type: consumer } + - { name: Contract2, template: Template 2, type: provider } + +- name: Query contract EPG 1(normal mode) + mso_schema_template_external_epg: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + external_epg: ansible_test_1 + state: query + register: nm_query_epg1_contract + +- name: Verify nm_query_epg1_contract + assert: + that: + - nm_query_epg1_contract.current.contractRelationships | length == 4 + +- name: Add EPG 1 again (normal_mode) + mso_schema_template_external_epg: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + external_epg: ansible_test_1 + vrf: + name: VRF + l3out: + name: L3out + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + state: present + register: nm_add_epg_1_again + +- name: Verify that EPG 1 didn't change + assert: + that: + - nm_add_epg_1_again is not changed + +- name: Query contract EPG 1 again + mso_schema_template_external_epg: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + external_epg: ansible_test_1 + state: query + register: nm_query_epg1_contract_again + +- name: Verify that 4 contracts are in EPG 1 using nm_query_epg1_contract_again + 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: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + external_epg: ansible_test_1 + vrf: + name: VRF2 + l3out: + name: L3out2 + state: present + register: nm_change_ext_epg_1_vrf + +- name: Verify that external EPG 1 did change + assert: + that: + - nm_change_ext_epg_1_vrf is changed + - nm_change_ext_epg_1_vrf.current.vrfRef.templateName == "Template1" + - nm_change_ext_epg_1_vrf.current.vrfRef.vrfName == "VRF2" + - nm_change_ext_epg_1_vrf.current.l3outRef.l3outName == "L3out2" + +- name: Query EPG 1 + mso_schema_template_external_epg: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + external_epg: ansible_test_1 + state: query + 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: + that: + - nm_query_contract_ext_epg_1.current.contractRelationships | length == 4 \ No newline at end of file diff --git a/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_external_epg_contract/aliases b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_external_epg_contract/aliases new file mode 100644 index 00000000..5042c9c0 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_external_epg_contract/aliases @@ -0,0 +1,2 @@ +# No ACI MultiSite infrastructure, so not enabled +# unsupported diff --git a/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_external_epg_contract/tasks/main.yml b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_external_epg_contract/tasks/main.yml new file mode 100644 index 00000000..a5101186 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_external_epg_contract/tasks/main.yml @@ -0,0 +1,627 @@ +# Test code for the MSO modules +# Copyright: (c) 2020, Lionel Hercot (@lhercot) +# Copyright: (c) 2018, Dag Wieers (@dagwieers) (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: + 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 +# 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(true) }}' +# output_level: '{{ mso_output_level | default("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 + +- name: Remove schemas + mso_schema: + 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(true) }}' + output_level: '{{ mso_output_level | default("info") }}' + schema: '{{ item }}' + state: absent + loop: + - '{{ mso_schema | default("ansible_test") }}_2' + - '{{ mso_schema | default("ansible_test") }}' + +- name: Ensure tenant ansible_test exist + mso_tenant: &tenant_present + 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(true) }}' + output_level: '{{ mso_output_level | default("info") }}' + tenant: ansible_test + users: + - '{{ mso_username }}' + # sites: + # - '{{ mso_site | default("ansible_test") }}' + state: present + +- name: Ensure schema 1 with Template 1 exist + mso_schema_template: &schema_present + 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(true) }}' + output_level: '{{ mso_output_level | default("info") }}' + schema: '{{ mso_schema | default("ansible_test") }}' + tenant: ansible_test + template: Template 1 + state: present + +- name: Ensure schema 1 with Template 2 exist + mso_schema_template: + <<: *schema_present + schema: '{{ mso_schema | default("ansible_test") }}' + tenant: ansible_test + template: Template 2 + state: present + +- name: Ensure schema 2 with Template 3 exist + mso_schema_template: + <<: *schema_present + schema: '{{ mso_schema | default("ansible_test") }}_2' + tenant: ansible_test + template: Template 3 + state: present + +- name: Ensure VRF exist + mso_schema_template_vrf: + 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(true) }}' + output_level: '{{ mso_output_level | default("info") }}' + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + vrf: VRF + state: present + +- name: Ensure Filter 1 exist + mso_schema_template_filter_entry: + 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(true) }}' + output_level: '{{ mso_output_level | default("info") }}' + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + filter: Filter1 + entry: Filter1-Entry + state: present + +- name: Ensure Contract1 exist + mso_schema_template_contract_filter: &contract_present + 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(true) }}' + output_level: '{{ mso_output_level | default("info") }}' + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + contract: Contract1 + filter: Filter1 + filter_schema: '{{ mso_schema | default("ansible_test") }}' + filter_template: Template 1 + state: present + +- name: Ensure Contract2 exist + mso_schema_template_contract_filter: + <<: *contract_present + template: Template 2 + contract: Contract2 + state: present + +- name: Ensure external EPGs exist + mso_schema_template_externalepg: + 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(true) }}' + output_level: '{{ mso_output_level | default("info") }}' + state: present + schema: '{{ item.schema }}' + template: '{{ item.template }}' + externalepg: '{{ item.externalepg }}' + vrf: + name: VRF + template: Template 1 + schema: '{{ mso_schema | default("ansible_test") }}' + loop: + - { schema: '{{ mso_schema | default("ansible_test") }}', template: 'Template 1', externalepg: 'ansible_test_1' } + - { schema: '{{ mso_schema | default("ansible_test") }}_2', template: 'Template 3', externalepg: 'ansible_test_3' } + +# ADD Contract to External EPG +- name: Add Contract1 to External EPG (check_mode) + mso_schema_template_external_epg_contract: &contract_ext_epg_present + 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(true) }}' + output_level: '{{ mso_output_level | default("info") }}' + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + external_epg: ansible_test_1 + contract: + name: Contract1 + type: consumer + state: present + check_mode: yes + register: cm_add_contract_rel + +- name: Verify cm_add_contract_rel + assert: + that: + - cm_add_contract_rel is changed + - cm_add_contract_rel.previous == {} + - cm_add_contract_rel.current.contractRef.templateName == "Template1" + - cm_add_contract_rel.current.contractRef.contractName == "Contract1" + - cm_add_contract_rel.current.relationshipType == "consumer" + +- name: Add Contract to External EPG (normal mode) + mso_schema_template_external_epg_contract: + <<: *contract_ext_epg_present + register: nm_add_contract_rel + +- name: Verify nm_add_contract_rel + assert: + that: + - nm_add_contract_rel is changed + - nm_add_contract_rel.previous == {} + - nm_add_contract_rel.current.contractRef.templateName == "Template1" + - nm_add_contract_rel.current.contractRef.contractName == "Contract1" + - nm_add_contract_rel.current.relationshipType == "consumer" + - 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: + <<: *contract_ext_epg_present + check_mode: yes + register: cm_add_contract_rel_again + +- name: Verify cm_add_contract_rel_again + assert: + that: + - cm_add_contract_rel_again is not changed + - cm_add_contract_rel_again.previous.contractRef.templateName == "Template1" + - cm_add_contract_rel_again.current.contractRef.templateName == "Template1" + - cm_add_contract_rel_again.previous.contractRef.contractName == "Contract1" + - cm_add_contract_rel_again.current.contractRef.contractName == "Contract1" + - cm_add_contract_rel_again.previous.relationshipType == "consumer" + - cm_add_contract_rel_again.current.relationshipType == "consumer" + - cm_add_contract_rel_again.previous.contractRef.schemaId == cm_add_contract_rel_again.current.contractRef.schemaId + + +- name: Add Contract to External EPG again (normal mode) + mso_schema_template_external_epg_contract: + <<: *contract_ext_epg_present + register: nm_add_contract_rel_again + +- name: Verify nm_add_contract_rel_again + assert: + that: + - nm_add_contract_rel_again is not changed + - nm_add_contract_rel_again.previous.contractRef.templateName == "Template1" + - nm_add_contract_rel_again.current.contractRef.templateName == "Template1" + - nm_add_contract_rel_again.previous.contractRef.contractName == "Contract1" + - nm_add_contract_rel_again.current.contractRef.contractName == "Contract1" + - nm_add_contract_rel_again.previous.relationshipType == "consumer" + - nm_add_contract_rel_again.current.relationshipType == "consumer" + - 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: + <<: *contract_ext_epg_present + contract: + name: Contract1 + type: provider + register: nm_add_contract1_rel_provider + +- name: Add Contract2 to External EPG - consumer (normal mode) + mso_schema_template_external_epg_contract: + <<: *contract_ext_epg_present + contract: + name: Contract2 + template: Template 2 + type: consumer + register: nm_add_contract2_rel_consumer + +- name: Add Contract1 to External EPG 3 - provider (normal mode) + mso_schema_template_external_epg_contract: + <<: *contract_ext_epg_present + schema: '{{ mso_schema | default("ansible_test") }}_2' + template: 'Template 3' + external_epg: ansible_test_3 + contract: + name: Contract1 + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + type: provider + 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: + that: + - nm_add_contract1_rel_provider is changed + - nm_add_contract2_rel_consumer is changed + - nm_add_contract3_rel_provider is changed + - nm_add_contract1_rel_provider.current.contractRef.contractName == "Contract1" + - nm_add_contract2_rel_consumer.current.contractRef.contractName == "Contract2" + - nm_add_contract3_rel_provider.current.contractRef.contractName == "Contract1" + - nm_add_contract1_rel_provider.current.contractRef.templateName == "Template1" + - nm_add_contract2_rel_consumer.current.contractRef.templateName == "Template2" + - nm_add_contract3_rel_provider.current.contractRef.templateName == "Template1" + - nm_add_contract1_rel_provider.current.contractRef.schemaId == nm_add_contract2_rel_consumer.current.contractRef.schemaId == nm_add_contract3_rel_provider.current.contractRef.schemaId + - nm_add_contract2_rel_consumer.current.relationshipType == "consumer" + - nm_add_contract1_rel_provider.current.relationshipType == nm_add_contract3_rel_provider.current.relationshipType == "provider" + +# # 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 + 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(true) }}' + output_level: '{{ mso_output_level | default("info") }}' + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + external_epg: ansible_test_1 + state: query + check_mode: yes + register: cm_query_all_contract_rels + +- name: Query all contract relationship for External EPG (normal mode) + mso_schema_template_external_epg_contract: + <<: *contract_ext_epg_query + register: nm_query_all_contract_rels + +- name: Verify query_all_contract_rels + assert: + that: + - cm_query_all_contract_rels is not changed + - nm_query_all_contract_rels is not changed + - cm_query_all_contract_rels.current | length == nm_query_all_contract_rels.current | length == 3 + + +# QUERY A Contract to External EPG +- name: Query Contract1 relationship for External EPG - consumer (check_mode) + mso_schema_template_external_epg_contract: + <<: *contract_ext_epg_query + contract: + name: Contract1 + type: consumer + check_mode: yes + register: cm_query_contract1_consumer_rel + +- name: Query Contract1 relationship for External EPG - consumer (normal mode) + mso_schema_template_external_epg_contract: + <<: *contract_ext_epg_query + contract: + name: Contract1 + type: consumer + register: nm_query_contract1_consumer_rel + +- name: Query Contract1 relationship for External EPG - provider (normal mode) + mso_schema_template_external_epg_contract: + <<: *contract_ext_epg_query + contract: + name: Contract1 + type: provider + register: nm_query_contract1_provider_rel + +- name: Query Contract1 relationship for External EPG - consumer (normal mode) + mso_schema_template_external_epg_contract: + <<: *contract_ext_epg_query + contract: + name: Contract2 + template: Template 2 + type: consumer + register: nm_query_contract2_consumer_rel + +- name: Query Contract1 relationship for External EPG - provider (normal mode) + mso_schema_template_external_epg_contract: + <<: *contract_ext_epg_query + schema: '{{ mso_schema | default("ansible_test") }}_2' + template: Template 3 + external_epg: ansible_test_3 + contract: + name: Contract1 + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + type: provider + register: nm_query_contract3_provider_rel + +- name: Verify query_contractX_YYYYY_rel + assert: + that: + - cm_query_contract1_consumer_rel is not changed + - nm_query_contract1_consumer_rel is not changed + - nm_query_contract1_provider_rel is not changed + - nm_query_contract2_consumer_rel is not changed + - nm_query_contract3_provider_rel is not changed + - cm_query_contract1_consumer_rel == nm_query_contract1_consumer_rel + - cm_query_contract1_consumer_rel.current.contractRef.contractName == nm_query_contract1_consumer_rel.current.contractRef.contractName == nm_query_contract1_provider_rel.current.contractRef.contractName == "Contract1" + - nm_query_contract2_consumer_rel.current.contractRef.contractName == "Contract2" + - nm_query_contract3_provider_rel.current.contractRef.contractName == "Contract1" + - cm_query_contract1_consumer_rel.current.contractRef.templateName == nm_query_contract1_consumer_rel.current.contractRef.templateName == nm_query_contract1_provider_rel.current.contractRef.templateName == "Template1" + - nm_query_contract2_consumer_rel.current.contractRef.templateName == "Template2" + - nm_query_contract3_provider_rel.current.contractRef.templateName == "Template1" + - cm_query_contract1_consumer_rel.current.contractRef.schemaId == nm_query_contract1_consumer_rel.current.contractRef.schemaId == nm_query_contract1_provider_rel.current.contractRef.schemaId == nm_query_contract2_consumer_rel.current.contractRef.schemaId == nm_query_contract3_provider_rel.current.contractRef.schemaId + - cm_query_contract1_consumer_rel.current.relationshipType == nm_query_contract1_consumer_rel.current.relationshipType == nm_query_contract2_consumer_rel.current.relationshipType == "consumer" + - nm_query_contract1_provider_rel.current.relationshipType == nm_query_contract3_provider_rel.current.relationshipType == "provider" + + +# REMOVE Contract to External EPG +- name: Remove Contract to External EPG (check_mode) + mso_schema_template_external_epg_contract: + <<: *contract_ext_epg_present + state: absent + check_mode: yes + register: cm_remove_contract_rel + +- name: Verify cm_remove_contract_rel + 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: + <<: *contract_ext_epg_present + state: absent + register: nm_remove_contract_rel + +- name: Verify nm_remove_contract_rel + 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: + <<: *contract_ext_epg_present + state: absent + check_mode: yes + register: cm_remove_contract_rel_again + +- name: Verify cm_remove_contract_rel_again + 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: + <<: *contract_ext_epg_present + state: absent + register: nm_remove_contract_rel_again + +- name: Verify nm_remove_contract_rel_again + assert: + that: + - nm_remove_contract_rel_again is not changed + - nm_remove_contract_rel_again.current == {} + + +# QUERY NON-EXISTING Contract to External EPG +- name: Query non-existing contract (check_mode) + mso_schema_template_external_epg_contract: + <<: *contract_ext_epg_query + contract: + name: non_existing_contract + type: provider + check_mode: yes + ignore_errors: yes + register: cm_query_non_contract + +- name: Query non-existing contract (normal mode) + mso_schema_template_external_epg_contract: + <<: *contract_ext_epg_query + contract: + name: non_existing_contract + type: provider + ignore_errors: yes + register: nm_query_non_contract + +- name: Verify query_non_contract + 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") + +# QUERY NON-EXISTING ExtEPG +- name: Query non-existing ExtEPG (check_mode) + mso_schema_template_external_epg_contract: + <<: *contract_ext_epg_query + external_epg: non_existing_ext_epg + check_mode: yes + ignore_errors: yes + register: cm_query_non_ext_epg + +- name: Query non-existing ExtEPG (normal mode) + mso_schema_template_external_epg_contract: + <<: *contract_ext_epg_query + external_epg: non_existing_ext_epg + ignore_errors: yes + register: nm_query_non_ext_epg + +- name: Verify query_non_ext_epg + assert: + that: + - cm_query_non_ext_epg is not changed + - nm_query_non_ext_epg is not changed + - cm_query_non_ext_epg == nm_query_non_ext_epg + - cm_query_non_ext_epg.msg == nm_query_non_ext_epg.msg == "Provided epg 'non_existing_ext_epg' does not exist. Existing epgs{{':'}} ansible_test_1" + +# USE A NON-EXISTING STATE +- name: Non-existing state for contract relationship (check_mode) + mso_schema_template_external_epg_contract: + <<: *contract_ext_epg_query + state: non-existing-state + check_mode: yes + ignore_errors: yes + register: cm_non_existing_state + +- name: Non-existing state for contract relationship (normal_mode) + mso_schema_template_external_epg_contract: + <<: *contract_ext_epg_query + state: non-existing-state + ignore_errors: yes + register: nm_non_existing_state + +- name: Verify non_existing_state + assert: + that: + - cm_non_existing_state is not changed + - nm_non_existing_state is not changed + - cm_non_existing_state == nm_non_existing_state + - cm_non_existing_state.msg == 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 for contract relationship (check_mode) + mso_schema_template_external_epg_contract: + <<: *contract_ext_epg_query + schema: non-existing-schema + check_mode: yes + ignore_errors: yes + register: cm_non_existing_schema + +- name: Non-existing schema for contract relationship (normal_mode) + mso_schema_template_external_epg_contract: + <<: *contract_ext_epg_query + schema: non-existing-schema + ignore_errors: yes + register: nm_non_existing_schema + +- name: Verify non_existing_schema + assert: + that: + - cm_non_existing_schema is not changed + - nm_non_existing_schema is not changed + - cm_non_existing_schema == nm_non_existing_schema + - 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: + <<: *contract_ext_epg_query + contract: + name: Contract1 + schema: non-existing-schema + template: Template 1 + type: provider + check_mode: yes + ignore_errors: yes + register: cm_non_existing_contract_schema + +- name: Non-existing contract schema for contract relationship (normal_mode) + mso_schema_template_external_epg_contract: + <<: *contract_ext_epg_query + contract: + name: Contract1 + schema: non-existing-schema + template: Template 1 + type: provider + ignore_errors: yes + register: nm_non_existing_contract_schema + +- name: Verify non_existing_contract_schema + assert: + that: + - cm_non_existing_contract_schema is not changed + - nm_non_existing_contract_schema is not changed + - cm_non_existing_contract_schema == nm_non_existing_contract_schema + - cm_non_existing_contract_schema.msg == nm_non_existing_contract_schema.msg == "Schema 'non-existing-schema' is not a valid schema name." + +# USE A NON-EXISTING TEMPLATE +- name: Non-existing template for contract relationship (check_mode) + mso_schema_template_external_epg_contract: + <<: *contract_ext_epg_query + template: non-existing-template + check_mode: yes + ignore_errors: yes + register: cm_non_existing_template + +- name: Non-existing template for contract relationship (normal_mode) + mso_schema_template_external_epg_contract: + <<: *contract_ext_epg_query + template: non-existing-template + ignore_errors: yes + register: nm_non_existing_template + +- name: Verify non_existing_template + 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" + +- name: Non-existing contract template for contract relationship (check_mode) + mso_schema_template_external_epg_contract: + <<: *contract_ext_epg_query + contract: + name: Contract1 + template: non-existing-template + type: provider + check_mode: yes + ignore_errors: yes + register: cm_non_existing_contract_template + +- name: Non-existing contract template for contract relationship (normal_mode) + mso_schema_template_external_epg_contract: + <<: *contract_ext_epg_query + contract: + name: Contract1 + template: non-existing-template + type: provider + ignore_errors: yes + register: nm_non_existing_contract_template + +- name: Verify non_existing_contract_template + 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 diff --git a/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_external_epg_selector/aliases b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_external_epg_selector/aliases new file mode 100644 index 00000000..5042c9c0 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_external_epg_selector/aliases @@ -0,0 +1,2 @@ +# No ACI MultiSite infrastructure, so not enabled +# unsupported diff --git a/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_external_epg_selector/tasks/main.yml b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_external_epg_selector/tasks/main.yml new file mode 100644 index 00000000..c0e7b500 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_external_epg_selector/tasks/main.yml @@ -0,0 +1,454 @@ +# Test code for the MSO modules +# Copyright: (c) 2020, Lionel Hercot (@lhercot) +# Copyright: (c) 2018, Dag Wieers (@dagwieers) (based on mso_site test case) +# Copyright: (c) 2020, Shreyas Srish (@shrsr) + +# 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.' + 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: + 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(true) }}' + output_level: '{{ mso_output_level | default("info") }}' + +- name: Remove schemas + mso_schema: + <<: *mso_info + schema: '{{ item }}' + state: absent + loop: + - '{{ mso_schema | default("ansible_test") }}_2' + - '{{ mso_schema | default("ansible_test") }}' + +- name: Ensure tenant ansible_test exist + mso_tenant: + <<: *mso_info + tenant: ansible_test + users: + - '{{ mso_username }}' + # sites: + # - '{{ mso_site | default("ansible_test") }}' + state: present + +- name: Ensure schema 1 with Template 1 exist + mso_schema_template: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + tenant: ansible_test + template: Template 1 + state: present + +- name: Ensure schema 1 with Template 2 exist + mso_schema_template: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + tenant: ansible_test + template: Template 2 + state: present + +- name: Ensure schema 2 with Template 3 exist + mso_schema_template: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}_2' + tenant: ansible_test + template: Template 3 + state: present + +- name: Ensure VRF exists + mso_schema_template_vrf: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + vrf: VRF + state: present + +- name: Ensure VRF2 exists + mso_schema_template_vrf: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + vrf: VRF2 + state: present + +- name: Ensure ANP1 exists + mso_schema_template_anp: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + anp: ANP + state: present + +- name: Ensure ANP2 exists + mso_schema_template_anp: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + anp: ANP2 + state: present + +- name: Ensure L3out exist + mso_schema_template_l3out: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + l3out: L3out + vrf: + name: VRF + state: present + +- name: Ensure L3out2 exist + mso_schema_template_l3out: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + l3out: L3out2 + vrf: + name: VRF2 + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + state: present + +# ADD External EPGs +- name: Ensure External EPG1 exists + mso_schema_template_externalepg: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + externalepg: extEPG1 + vrf: + name: VRF + template: Template 1 + schema: '{{ mso_schema | default("ansible_test") }}' + l3out: + name: L3out + template: Template 1 + schema: '{{ mso_schema | default("ansible_test") }}' + anp: + name: ANP + template: Template 1 + schema: '{{ mso_schema | default("ansible_test") }}' + state: present + +- name: Ensure External EPG2 exists + mso_schema_template_externalepg: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + externalepg: extEPG2 + vrf: + name: VRF2 + template: Template 1 + schema: '{{ mso_schema | default("ansible_test") }}' + l3out: + name: L3out2 + template: Template 1 + schema: '{{ mso_schema | default("ansible_test") }}' + anp: + name: ANP2 + template: Template 1 + schema: '{{ mso_schema | default("ansible_test") }}' + state: present + +# ADD Selector to EPG +- name: Add Selector to extEPG1 (check_mode) + mso_schema_template_external_epg_selector: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + external_epg: extEPG1 + selector: selector_1 + state: present + check_mode: yes + register: cm_add_selector_1 + +- name: Verify cm_add_selector_1 + assert: + that: + - cm_add_selector_1 is changed + - cm_add_selector_1.previous == {} + - cm_add_selector_1.current.name == "selector_1" + - cm_add_selector_1.current.expressions == [] + +- name: Add Selector 1 to extEPG1 (normal_mode) + mso_schema_template_external_epg_selector: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + external_epg: extEPG1 + selector: selector_1 + state: present + ignore_errors: yes + register: nm_add_selector_1 + +- name: Verify nm_add_selector_1 + assert: + that: + - nm_add_selector_1 is changed + - nm_add_selector_1.previous == {} + - nm_add_selector_1.current.name == "selector_1" + - nm_add_selector_1.current.expressions == [] + +- name: Add Selector 1 to extEPG1 again(normal_mode) + mso_schema_template_external_epg_selector: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + external_epg: extEPG1 + selector: selector_1 + state: present + ignore_errors: yes + register: nm_add_selector_1_again + +- name: Verify nm_add_selector_1_again + assert: + that: + - nm_add_selector_1_again is not changed + +- name: Add Selector to extEPG1 again (normal_mode) + mso_schema_template_external_epg_selector: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + external_epg: extEPG1 + selector: selector_1 + state: present + register: nm_add_selector_1_again + +- name: Verify nm_add_selector_1_again + assert: + that: + - nm_add_selector_1_again is not changed + +- name: Add Selector 2 to extEPG1 (normal_mode) + mso_schema_template_external_epg_selector: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + external_epg: extEPG1 + selector: selector_2 + expressions: + - type: ip_address + operator: equals + value: 10.0.0.0 + state: present + register: nm_add_selector_2 + +- name: Verify nm_add_selector_2 + assert: + that: + - nm_add_selector_2 is changed + - nm_add_selector_2.previous == {} + - nm_add_selector_2.current.name == "selector_2" + - nm_add_selector_2.current.expressions[0].key == "ipAddress" + - nm_add_selector_2.current.expressions[0].operator == "equals" + - 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: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + external_epg: extEPG1 + selector: selector_3 + expressions: + - type: ip_address + operator: equals + value: 10.1.1.1 + state: present + register: nm_add_selector_3 + +- name: Verify nm_add_selector_3 + assert: + that: + - nm_add_selector_3 is changed + - nm_add_selector_3.previous == {} + - nm_add_selector_3.current.name == "selector_3" + - nm_add_selector_3.current.expressions[0].value == "10.1.1.1" + +- name: Remove slector_1 + mso_schema_template_external_epg_selector: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + external_epg: extEPG1 + selector: selector_1 + state: absent + register: nm_remove_selector_1 + +- name: Verify nm_remove_selector_1 + assert: + that: + - nm_remove_selector_1 is changed + +# QUERY selectors +- name: Query all selectors of extEPG1 + mso_schema_template_external_epg_selector: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + external_epg: extEPG1 + state: query + register: nm_query_all + +- name: Verify nm_query_all + assert: + that: + - nm_query_all is not changed + +- name: Query a selector of extEPG1 + mso_schema_template_external_epg_selector: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + external_epg: extEPG1 + selector: selector_2 + state: query + register: nm_query_selector_2 + +- name: Verify nm_query_selector_2 + 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: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + external_epg: extEPG1 + selector: selector_1 + state: query + ignore_errors: yes + register: nm_query_removed + +- name: Verify nm_query_removed + 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: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + external_epg: non_extEPG1 + selector: selector_1 + state: query + ignore_errors: yes + register: nm_query_non_epg + +- name: Verify query_non_epg + 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: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + external_epg: extEPG1 + selector: selector_1 + state: non-existing-state + check_mode: yes + ignore_errors: yes + register: cm_non_existing_state + +- name: Non-existing state (normal_mode) + mso_schema_template_external_epg_selector: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + external_epg: extEPG1 + selector: selector_1 + state: non-existing-state + ignore_errors: yes + register: nm_non_existing_state + +- name: Verify non_existing_state + assert: + that: + - cm_non_existing_state is not changed + - nm_non_existing_state is not changed + - cm_non_existing_state == nm_non_existing_state + - cm_non_existing_state.msg == 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 (check_mode) + mso_schema_template_external_epg_selector: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: non-existing-template + external_epg: extEPG1 + selector: selector_1 + state: query + check_mode: yes + ignore_errors: yes + register: cm_non_existing_template + +- name: Non-existing template (normal_mode) + mso_schema_template_external_epg_selector: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: non-existing-template + external_epg: extEPG1 + selector: selector_1 + state: query + ignore_errors: yes + register: nm_non_existing_template + +- name: Verify non_existing_template + 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" + +# USE A NON-EXISTING SCHEMA +- name: Non-existing schema (check_mode) + mso_schema_template_external_epg_selector: + <<: *mso_info + schema: non-existing-schema + template: Template 1 + external_epg: extEPG1 + selector: selector_1 + state: query + check_mode: yes + ignore_errors: yes + register: cm_non_existing_schema + +- name: Non-existing schema (normal_mode) + mso_schema_template_external_epg_selector: + <<: *mso_info + schema: non-existing-schema + template: Template 1 + external_epg: extEPG1 + selector: selector_1 + state: query + ignore_errors: yes + register: nm_non_existing_schema + +- name: Verify non_existing_schema + assert: + that: + - cm_non_existing_schema is not changed + - nm_non_existing_schema is not changed + - cm_non_existing_schema == nm_non_existing_schema + - cm_non_existing_schema.msg == nm_non_existing_schema.msg == "Provided schema 'non-existing-schema' does not exist" \ No newline at end of file diff --git a/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_migrate/aliases b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_migrate/aliases new file mode 100644 index 00000000..5042c9c0 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_migrate/aliases @@ -0,0 +1,2 @@ +# No ACI MultiSite infrastructure, so not enabled +# unsupported diff --git a/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_migrate/tasks/main.yml b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_migrate/tasks/main.yml new file mode 100644 index 00000000..d723fbdc --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_migrate/tasks/main.yml @@ -0,0 +1,334 @@ +# Test code for the MSO modules +# Copyright: (c) 2020, Anvitha Jain (@anvitha-jain) +# + +# 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.' + when: mso_hostname is not defined or mso_username is not defined or mso_password is not defined + +- name: Set vars + 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(true) }}' + output_level: '{{ mso_output_level | default("info") }}' + +- name: Query MSO version + mso_version: + <<: *mso_info + state: query + register: version + +# CLEAN ENVIRONMENT +- name: Ensure site exist + mso_site: &site_present + 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(true) }}' + output_level: '{{ mso_output_level | default("info") }}' + site: '{{ mso_site | default("ansible_test") }}' + apic_username: '{{ apic_username }}' + apic_password: '{{ apic_password }}' + apic_site_id: '{{ apic_site_id | default(102) }}' + urls: + - https://{{ apic_hostname }} + state: present + +- name: Undeploy a schema 2 template 2 + mso_schema_template_deploy: + <<: *mso_info + template: Template 2 + schema: '{{ mso_schema | default("ansible_test") }}_2' + site: '{{ mso_site | default("ansible_test") }}' + state: undeploy + ignore_errors: yes + register: undeploy_template2 + +- name: Undeploy a schema 1 template 1 + mso_schema_template_deploy: + <<: *mso_info + template: Template 1 + schema: '{{ mso_schema | default("ansible_test") }}' + site: '{{ mso_site | default("ansible_test") }}' + state: undeploy + ignore_errors: yes + register: undeploy_template1 + +- name: Remove a site from a schema 1 with Template 1 + mso_schema_site: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: '{{ mso_site | default("ansible_test") }}' + template: Template 1 + state: absent + register: rm_site_temp1 + +- name: Remove a site from a schema 2 with Template 2 + mso_schema_site: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}_2' + site: '{{ mso_site | default("ansible_test") }}' + template: Template 2 + state: absent + register: rm_site_temp2 + +- name: Remove schemas + mso_schema: + 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(true) }}' + output_level: '{{ mso_output_level | default("info") }}' + schema: '{{ item }}' + state: absent + loop: + - '{{ mso_schema | default("ansible_test") }}_2' + - '{{ mso_schema | default("ansible_test") }}' + +- name: Ensure tenant ansible_test exist + mso_tenant: &tenant_present + 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(true) }}' + output_level: '{{ mso_output_level | default("info") }}' + tenant: ansible_test + users: + - '{{ mso_username }}' + sites: + - '{{ mso_site | default("ansible_test") }}' + state: present + +- name: Ensure schemas with Template 1 exist + mso_schema_template: &schema_present + 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(true) }}' + output_level: '{{ mso_output_level | default("info") }}' + schema: '{{ item }}' + tenant: ansible_test + template: Template 1 + state: present + loop: + - '{{ mso_schema | default("ansible_test") }}' + - '{{ mso_schema | default("ansible_test") }}_2' + +- name: Ensure schema 2 with Template 2 exist + mso_schema_template: + <<: *schema_present + schema: '{{ mso_schema | default("ansible_test") }}_2' + tenant: ansible_test + template: Template 2 + state: present + register: schema2_template2 + +- name: Add a new site to a schema 1 with Template 1 in normal mode + mso_schema_site: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: '{{ mso_site | default("ansible_test") }}' + template: Template 1 + state: present + register: add_site_nm1 + +- name: Add a new site to a schema 2 with Template 2 in normal mode + mso_schema_site: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}_2' + site: '{{ mso_site | default("ansible_test") }}' + template: Template 2 + state: present + register: add_site_nm2 + +- name: Ensure VRF exist + mso_schema_template_vrf: &vrf_present + 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(true) }}' + output_level: '{{ mso_output_level | default("info") }}' + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + vrf: VRF + layer3_multicast: true + state: present + +- name: Ensure ANP exist + mso_schema_template_anp: + 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(true) }}' + output_level: '{{ mso_output_level | default("info") }}' + schema: '{{ mso_schema | default("ansible_test") }}_2' + template: Template 1 + anp: ANP + state: present + +- name: Ensure ANP2 exist + mso_schema_template_anp: + 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(true) }}' + output_level: '{{ mso_output_level | default("info") }}' + schema: '{{ mso_schema | default("ansible_test") }}_2' + template: Template 1 + anp: ANP2 + state: present + +- name: Ensure ansible_test_1 BD exist + mso_schema_template_bd: + <<: *vrf_present + schema: '{{ mso_schema | default("ansible_test") }}_2' + template: Template 1 + bd: '{{ item }}' + vrf: + name: VRF + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + state: present + when: version.current.version is version('2.2.4e', '!=') + loop: + - '{{ BD_1 | default("ansible_test") }}_1' + - '{{ BD_2 | default("ansible_test") }}_2' + +- name: Ensure EPG exist + mso_schema_template_anp_epg: &epg_present + 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(true) }}' + output_level: '{{ mso_output_level | default("info") }}' + schema: '{{ mso_schema | default("ansible_test") }}_2' + template: Template 1 + anp: ANP + epg: ansible_test_1 + bd: + name: ansible_test_1 + vrf: + name: VRF + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + state: present + register: cm_add_epg + +- name: Add EPG 2 (normal mode) + mso_schema_template_anp_epg: + <<: *epg_present + anp: ANP2 + epg: '{{ item }}' + loop: + - '{{ EPG_2 | default("ansible_test") }}_2' + - '{{ EPG_3 | default("ansible_test") }}_3' + - '{{ EPG_4 | default("ansible_test") }}_4' + +- name: Migration of objects between templates + mso_schema_template_migrate: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}_2' + template: Template 1 + target_schema: '{{ mso_schema | default("ansible_test") }}' + target_template: Template 1 + bds: + - ansible_test_1 + epgs: + - epg: ansible_test_1 + anp: ANP + - epg: ansible_test_2 + anp: ANP2 + state: present + when: version.current.version is version('2.2.4e', '!=') + register: object_migrate + +- name: Migration of BD objects between templates + mso_schema_template_migrate: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}_2' + template: Template 1 + target_schema: '{{ mso_schema | default("ansible_test") }}_2' + target_template: Template 2 + bds: + - ansible_test_2 + state: present + when: version.current.version is version('2.2.4e', '!=') + register: bd_migrate + +- name: Migration of EPG objects between templates + mso_schema_template_migrate: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}_2' + template: Template 1 + target_schema: '{{ mso_schema | default("ansible_test") }}_2' + target_template: Template 2 + epgs: + - epg: ansible_test_3 + anp: ANP2 + - epg: ansible_test_4 + anp: ANP2 + state: present + when: version.current.version is version('2.2.4e', '!=') + register: epg_migrate + +- name: Undeploy a schema 2 template 2 + mso_schema_template_deploy: + <<: *mso_info + template: Template 2 + schema: '{{ mso_schema | default("ansible_test") }}_2' + site: '{{ mso_site | default("ansible_test") }}' + state: undeploy + ignore_errors: yes + register: undeploy_template2 + +- name: Undeploy a schema 1 template 1 + mso_schema_template_deploy: + <<: *mso_info + template: Template 1 + schema: '{{ mso_schema | default("ansible_test") }}' + site: '{{ mso_site | default("ansible_test") }}' + state: undeploy + ignore_errors: yes + register: undeploy_template1 + +- name: Remove a site from a schema 1 with Template 1 + mso_schema_site: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + site: '{{ mso_site | default("ansible_test") }}' + template: Template 1 + state: absent + register: rm_site_temp1 + +- name: Remove a site from a schema 2 with Template 2 + mso_schema_site: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}_2' + site: '{{ mso_site | default("ansible_test") }}' + template: Template 2 + state: absent + register: rm_site_temp2 \ No newline at end of file diff --git a/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_vrf/aliases b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_vrf/aliases new file mode 100644 index 00000000..5042c9c0 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_vrf/aliases @@ -0,0 +1,2 @@ +# No ACI MultiSite infrastructure, so not enabled +# unsupported diff --git a/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_vrf/tasks/main.yml b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_vrf/tasks/main.yml new file mode 100644 index 00000000..b77d1fad --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_vrf/tasks/main.yml @@ -0,0 +1,518 @@ +# Test code for the MSO modules +# Copyright: (c) 2020, Cindy Zhao (@cizhao) +# Copyright: (c) 2020, Lionel Hercot (@lhercot) +# Copyright: (c) 2018, Dag Wieers (@dagwieers) (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: + 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: + 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(true) }}' + output_level: '{{ mso_output_level | default("info") }}' + +# - name: Ensure site exist +# mso_site: &site_present +# 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(true) }}' +# output_level: '{{ mso_output_level | default("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 + +- name: Remove schemas + mso_schema: + <<: *mso_info + schema: '{{ item }}' + state: absent + loop: + - '{{ mso_schema | default("ansible_test") }}_2' + - '{{ mso_schema | default("ansible_test") }}' + +- name: Ensure tenant ansible_test exist + mso_tenant: + <<: *mso_info + tenant: ansible_test + users: + - '{{ mso_username }}' + # sites: + # - '{{ mso_site | default("ansible_test") }}' + state: present + +- name: Ensure schema 1 with Template 1 exist + mso_schema_template: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + tenant: ansible_test + template: Template 1 + state: present + +- name: Ensure schema 1 with Template 2 exist + mso_schema_template: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + tenant: ansible_test + template: Template 2 + state: present + +- name: Ensure schema 2 with Template 3 exist + mso_schema_template: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}_2' + tenant: ansible_test + template: Template 3 + state: present + +- name: Ensure Filter 1 exist + mso_schema_template_filter_entry: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + filter: Filter1 + entry: Filter1-Entry + state: present + +- name: Ensure Contract1 exist + mso_schema_template_contract_filter: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + contract: Contract1 + filter: Filter1 + filter_schema: '{{ mso_schema | default("ansible_test") }}' + filter_template: Template 1 + state: present + +# ADD VRF1 +- name: Add a new VRF1 (check mode) + mso_schema_template_vrf: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + vrf: VRF1 + state: present + check_mode: yes + register: vrf1_cm + +- name: Verify vrf1_cm + 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: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + vrf: VRF1 + state: present + register: vrf1_nm + +- name: Verify vrf1_nm + 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: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 2 + vrf: VRF2 + layer3_multicast: true + vzany: true + state: present + register: vrf2_nm + +- name: Verify vrf2_nm + assert: + that: + - vrf2_nm is changed + - vrf2_nm.current.name == 'VRF2' + - vrf2_nm.current.displayName == 'VRF2' + - vrf2_nm.current.vzAnyEnabled == True + - vrf2_nm.current.l3MCast == True + +- name: Add VRF3 (normal mode) + mso_schema_template_vrf: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}_2' + template: Template 3 + vrf: VRF3 + state: present + register: vrf3_nm + +- name: Verify vrf3_nm + assert: + that: + - vrf3_nm is changed + - vrf3_nm.current.name == 'VRF3' + - vrf3_nm.current.displayName == 'VRF3' + +# ADD EXISTING VRF +- name: Add VRF2 again (normal mode) + mso_schema_template_vrf: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 2 + vrf: VRF2 + layer3_multicast: true + vzany: true + state: present + register: vrf2_nm_again + +- name: Verify vrf2_nm_again + assert: + that: + - vrf2_nm_again is not changed + +# ADD VRF4 WITH NO STATE +- name: Add VRF4 (normal mode) + mso_schema_template_vrf: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 2 + vrf: VRF4 + ignore_errors: yes + register: vrf4_nm_stateless + +- name: Verify vrf4_nm_stateless + assert: + that: + - vrf4_nm_stateless is changed + +# CHANGE VRF SETTINGS +- name: Change VRF1 settings (check mode) + mso_schema_template_vrf: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + vrf: VRF1 + layer3_multicast: true + vzany: true + state: present + check_mode: yes + register: vrf1_change_cm + +- name: Change VRF1 settings (normal mode) + mso_schema_template_vrf: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + vrf: VRF1 + layer3_multicast: true + vzany: true + state: present + register: vrf1_change_nm + +- name: Change VRF2 settings (check mode) + mso_schema_template_vrf: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 2 + vrf: VRF2 + layer3_multicast: false + vzany: false + state: present + check_mode: yes + register: vrf2_change_cm + +- name: Change VRF2 settings (normal mode) + mso_schema_template_vrf: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 2 + vrf: VRF2 + layer3_multicast: false + vzany: false + state: present + register: vrf2_change_nm + +- name: Verify vrf2_nm + assert: + that: + - vrf1_change_cm is changed + - vrf1_change_nm is changed + - vrf2_change_cm is changed + - vrf2_change_nm is changed + - vrf1_change_cm.current.name == vrf1_change_nm.current.name == 'VRF1' + - vrf2_change_cm.current.name == vrf2_change_nm.current.name == 'VRF2' + - vrf1_change_cm.current.vzAnyEnabled == vrf1_change_nm.current.vzAnyEnabled == True + - vrf1_change_cm.current.vzAnyEnabled == vrf1_change_nm.current.l3MCast == True + - vrf2_change_cm.current.vzAnyEnabled == vrf2_change_nm.current.vzAnyEnabled == False + - vrf2_change_cm.current.vzAnyEnabled == vrf2_change_nm.current.l3MCast == False + +# QUERY A VRF +- name: Query VRF2 (normal mode) + mso_schema_template_vrf: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 2 + vrf: VRF2 + state: query + register: vrf2_query + +- name: Verify vrf2_query + assert: + that: + - vrf2_query is not changed + +# QUERY ALL VRFs +- name: Query all (normal mode) + mso_schema_template_vrf: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + state: query + register: vrfs_query + +- name: Verify vrfs_query + assert: + that: + - vrfs_query is not changed + +# REMOVE A VRF +- name: Remove VRF3 (normal mode) + mso_schema_template_vrf: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}_2' + template: Template 3 + vrf: VRF3 + state: absent + register: vrf3_remove + +- name: Verify vrf3_remove + assert: + that: + - vrf3_remove is changed + - vrf3_remove.previous.name == 'VRF3' + - vrf3_remove.previous.displayName == 'VRF3' + +# REMOVE A VRF +- name: Remove VRF3 again (normal mode) + mso_schema_template_vrf: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}_2' + template: Template 3 + vrf: VRF3 + state: absent + register: vrf3_remove_again + +- name: Verify vrf3_remove_again + assert: + that: + - vrf3_remove_again is not changed + +# QUERY REMOVED VRF +- name: Query VRF3 (normal mode) + mso_schema_template_vrf: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 2 + vrf: VRF3 + state: query + ignore_errors: yes + register: vrf3_query_removed + +- name: Verify vrf3_query_removed + assert: + that: + - vrf3_query_removed.msg == "VRF 'VRF3' not found" + +# Enable vzAny on VRF +- name: Ensure VRF exist + mso_schema_template_vrf: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + vrf: VRF + vzany: true + state: present + +- name: Add Contract1 to VRF with type consumer (normal_mode) + mso_schema_template_vrf_contract: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + vrf: VRF + contract: + name: Contract1 + type: consumer + state: present + register: nm_add_contract1_consumer + +- name: Verify nm_add_contract1_consumer + assert: + that: + - nm_add_contract1_consumer is changed + - nm_add_contract1_consumer.previous == {} + - nm_add_contract1_consumer.current.contractRef.templateName == "Template1" + - nm_add_contract1_consumer.current.contractRef.contractName == "Contract1" + - nm_add_contract1_consumer.current.relationshipType == "consumer" + +- name: Add Contract1 to VRF with type provider (normal_mode) + mso_schema_template_vrf_contract: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + vrf: VRF + contract: + name: Contract1 + type: provider + state: present + register: nm_add_contract1_provider + +- name: Verify nm_add_contract1_provider + assert: + that: + - nm_add_contract1_provider is changed + - nm_add_contract1_provider.previous == {} + - nm_add_contract1_provider.current.contractRef.templateName == "Template1" + - nm_add_contract1_provider.current.contractRef.contractName == "Contract1" + - nm_add_contract1_provider.current.relationshipType == "provider" + +# USE A NON-EXISTING SCHEMA +- name: Non-existing schema for VRF (check_mode) + mso_schema_template_vrf: + <<: *mso_info + schema: non_existing_schema + template: Template 1 + vrf: VRF5 + check_mode: yes + ignore_errors: yes + register: cm_non_existing_schema + +- name: Non-existing schema for VRF (normal_mode) + mso_schema_template_vrf: + <<: *mso_info + schema: non_existing_schema + template: Template 1 + vrf: VRF5 + ignore_errors: yes + register: nm_non_existing_schema + +- name: Verify nm_non_existing_schema + assert: + that: + - cm_non_existing_schema is not changed + - nm_non_existing_schema is not changed + - cm_non_existing_schema == nm_non_existing_schema + - cm_non_existing_schema.msg == nm_non_existing_schema.msg == "Provided schema 'non_existing_schema' does not exist" + +# USE A NON-EXISTING TEMPLATE +- name: Non-existing template for vrf (check_mode) + mso_schema_template_vrf: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: non_existing_template + vrf: VRF5 + check_mode: yes + ignore_errors: yes + register: cm_non_existing_template + +- name: Non-existing template for vrf (normal_mode) + mso_schema_template_vrf: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: non_existing_template + vrf: VRF5 + ignore_errors: yes + register: nm_non_existing_template + +- name: Verify non_existing_template + 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" + +# Checking if contract are removed after re-applying an VRF. +- name: Add VRF again (normal_mode) + mso_schema_template_vrf: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + vrf: VRF + vzany: true + state: present + register: nm_add_VRF_again + +- name: Verify that VRF didn't changed + assert: + that: + - nm_add_VRF_again is not changed + +- name: Verify contract VRF again + mso_schema_template_vrf_contract: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + vrf: VRF + state: query + register: nm_query_vrf_contract_again + +- name: Verify 2 contracts are in VRF + 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: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + vrf: VRF + vzany: true + layer3_multicast: true + state: present + register: nm_change_vrf + +- name: Verify that VRF did change + 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: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + vrf: VRF + state: query + register: nm_query_change_vrf_contract_again + +- name: Verify 2 contracts are in VRF + assert: + that: + - nm_query_change_vrf_contract_again is not changed + - nm_query_change_vrf_contract_again.current | length == 2 \ No newline at end of file diff --git a/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_vrf_contract/aliases b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_vrf_contract/aliases new file mode 100644 index 00000000..5042c9c0 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_vrf_contract/aliases @@ -0,0 +1,2 @@ +# No ACI MultiSite infrastructure, so not enabled +# unsupported diff --git a/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_vrf_contract/tasks/main.yml b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_vrf_contract/tasks/main.yml new file mode 100644 index 00000000..a1fa2c7e --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_vrf_contract/tasks/main.yml @@ -0,0 +1,859 @@ +# Test code for the MSO modules +# Copyright: (c) 2020, Cindy Zhao (@cizhao) +# Copyright: (c) 2020, Lionel Hercot (@lhercot) +# Copyright: (c) 2018, Dag Wieers (@dagwieers) (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: + 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: + 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(true) }}' + output_level: '{{ mso_output_level | default("info") }}' + +# - name: Ensure site exist +# mso_site: &site_present +# 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(true) }}' +# output_level: '{{ mso_output_level | default("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 + +- name: Remove schemas + mso_schema: + <<: *mso_info + schema: '{{ item }}' + state: absent + loop: + - '{{ mso_schema | default("ansible_test") }}_2' + - '{{ mso_schema | default("ansible_test") }}' + +- name: Ensure tenant ansible_test exist + mso_tenant: + <<: *mso_info + tenant: ansible_test + users: + - '{{ mso_username }}' + # sites: + # - '{{ mso_site | default("ansible_test") }}' + state: present + +- name: Ensure schema 1 with Template 1 exist + mso_schema_template: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + tenant: ansible_test + template: Template 1 + state: present + +- name: Ensure schema 1 with Template 2 exist + mso_schema_template: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + tenant: ansible_test + template: Template 2 + state: present + +- name: Ensure schema 2 with Template 3 exist + mso_schema_template: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}_2' + tenant: ansible_test + template: Template 3 + state: present + +- name: Ensure VRF exist + mso_schema_template_vrf: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + vrf: VRF + state: present + +- name: Ensure VRF2 exist + mso_schema_template_vrf: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + vrf: VRF2 + vzany: true + state: present + +- name: Ensure VRF3 exist + mso_schema_template_vrf: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 2 + vrf: VRF3 + vzany: true + state: present + +- name: Ensure VRF4 exist + mso_schema_template_vrf: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}_2' + template: Template 3 + vrf: VRF4 + vzany: true + state: present + +- name: Ensure Filter 1 exist + mso_schema_template_filter_entry: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + filter: Filter1 + entry: Filter1-Entry + state: present + +- name: Ensure Contract1 exist + mso_schema_template_contract_filter: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + contract: Contract1 + filter: Filter1 + filter_schema: '{{ mso_schema | default("ansible_test") }}' + filter_template: Template 1 + state: present + +- name: Ensure Contract4 exist + mso_schema_template_contract_filter: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + contract: Contract4 + filter: Filter1 + filter_schema: '{{ mso_schema | default("ansible_test") }}' + filter_template: Template 1 + state: present + +- name: Ensure Contract2 exist + mso_schema_template_contract_filter: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + contract: Contract2 + filter: Filter1 + filter_schema: '{{ mso_schema | default("ansible_test") }}' + filter_template: Template 1 + state: present + +- name: Ensure Contract3 exist + mso_schema_template_contract_filter: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + contract: Contract3 + filter: Filter1 + filter_schema: '{{ mso_schema | default("ansible_test") }}' + filter_template: Template 1 + state: present + +# ADD Contract to VRF +- name: Add Contract1 to VRF with vzany disabled + mso_schema_template_vrf_contract: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + vrf: VRF + contract: + name: Contract1 + type: consumer + state: present + ignore_errors: yes + register: add_contract1_vrf_vzany_disabled + +- name: Verify add_contract1_vrf_vzany_disabled + 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: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + vrf: VRF + vzany: true + state: present + +- name: Add Contract1 to VRF with type consumer (check_mode) + mso_schema_template_vrf_contract: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + vrf: VRF + contract: + name: Contract1 + type: consumer + state: present + check_mode: yes + register: cm_add_contract1_consumer + +- name: Verify cm_add_contract1_consumer + assert: + that: + - cm_add_contract1_consumer is changed + - cm_add_contract1_consumer.previous == {} + - cm_add_contract1_consumer.current.contractRef.templateName == "Template1" + - cm_add_contract1_consumer.current.contractRef.contractName == "Contract1" + - cm_add_contract1_consumer.current.relationshipType == "consumer" + +- name: Add Contract1 to VRF with type consumer (normal_mode) + mso_schema_template_vrf_contract: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + vrf: VRF + contract: + name: Contract1 + type: consumer + state: present + register: nm_add_contract1_consumer + +- name: Verify nm_add_contract1_consumer + assert: + that: + - nm_add_contract1_consumer is changed + - nm_add_contract1_consumer.previous == {} + - nm_add_contract1_consumer.current.contractRef.templateName == "Template1" + - nm_add_contract1_consumer.current.contractRef.contractName == "Contract1" + - nm_add_contract1_consumer.current.relationshipType == "consumer" + - 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: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + vrf: VRF + contract: + name: Contract1 + type: provider + state: present + register: nm_add_contract1_provider + +- name: Verify nm_add_contract1_provider + assert: + that: + - nm_add_contract1_provider is changed + - nm_add_contract1_provider.previous == {} + - nm_add_contract1_provider.current.contractRef.templateName == "Template1" + - nm_add_contract1_provider.current.contractRef.contractName == "Contract1" + - nm_add_contract1_provider.current.relationshipType == "provider" + +- name: Add Contract1 to VRF with type consumer again(normal_mode) + mso_schema_template_vrf_contract: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + vrf: VRF + contract: + name: Contract1 + type: consumer + state: present + register: nm_add_contract1_consumer_again + +- name: Verify nm_add_contract1_consumer_again + 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 + - nm_add_contract1_consumer_again.current.contractRef.contractName == "Contract1" == nm_add_contract1_consumer_again.previous.contractRef.contractName + - 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: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + vrf: VRF + contract: + name: Contract1 + type: provider + state: present + register: nm_add_contract1_provider_again + +- name: Verify nm_add_contract1_provider_again + 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 + - nm_add_contract1_provider_again.current.contractRef.contractName == "Contract1" == nm_add_contract1_provider_again.previous.contractRef.contractName + - 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: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + vrf: VRF2 + contract: + name: Contract4 + type: consumer + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + state: present + register: nm_add_vrf2_consumer + +- name: Add Contract4 to VRF2 with type provider (normal_mode) + mso_schema_template_vrf_contract: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + vrf: VRF2 + contract: + name: Contract4 + type: provider + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + state: present + register: nm_add_vrf2_provider + +- name: nm_add_vrf2_consumer and nm_add_vrf2_provider + assert: + that: + - nm_add_vrf2_consumer is changed + - nm_add_vrf2_provider is changed + - nm_add_vrf2_consumer.previous == {} == nm_add_vrf2_provider.previous + - nm_add_vrf2_consumer.current.contractRef.templateName == "Template1" == nm_add_vrf2_provider.current.contractRef.templateName + - nm_add_vrf2_consumer.current.contractRef.contractName == "Contract4" == nm_add_vrf2_provider.current.contractRef.contractName + - nm_add_vrf2_consumer.current.relationshipType == "consumer" + - nm_add_vrf2_provider.current.relationshipType == "provider" + +- name: Add Contract3 to VRF3 with type consumer (normal_mode) + mso_schema_template_vrf_contract: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 2 + vrf: VRF3 + contract: + name: Contract3 + type: consumer + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + state: present + register: nm_add_vrf3_consumer + +- name: Add Contract3 to VRF3 with type provider (normal_mode) + mso_schema_template_vrf_contract: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 2 + vrf: VRF3 + contract: + name: Contract3 + type: provider + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + state: present + register: nm_add_vrf3_provider + +- name: nm_add_vrf3_consumer and nm_add_vrf3_provider + assert: + that: + - nm_add_vrf3_consumer is changed + - nm_add_vrf3_provider is changed + - nm_add_vrf3_consumer.previous == {} == nm_add_vrf3_provider.previous + - nm_add_vrf3_consumer.current.contractRef.templateName == "Template1" == nm_add_vrf3_provider.current.contractRef.templateName + - nm_add_vrf3_consumer.current.contractRef.contractName == "Contract3" == nm_add_vrf3_provider.current.contractRef.contractName + - nm_add_vrf3_consumer.current.relationshipType == "consumer" + - nm_add_vrf3_provider.current.relationshipType == "provider" + +- name: Add Contract2 to VRF4 with type consumer (normal_mode) + mso_schema_template_vrf_contract: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}_2' + template: Template 3 + vrf: VRF4 + contract: + name: Contract2 + type: consumer + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + state: present + register: nm_add_vrf4_consumer + +- name: Add Contract2 to VRF4 with type provider (normal_mode) + mso_schema_template_vrf_contract: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}_2' + template: Template 3 + vrf: VRF4 + contract: + name: Contract2 + type: provider + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + state: present + register: nm_add_vrf4_provider + +- name: nm_add_vrf4_consumer and nm_add_vrf4_provider + assert: + that: + - nm_add_vrf4_consumer is changed + - nm_add_vrf4_provider is changed + - nm_add_vrf4_consumer.previous == {} == nm_add_vrf4_provider.previous + - nm_add_vrf4_consumer.current.contractRef.templateName == "Template1" == nm_add_vrf4_provider.current.contractRef.templateName + - nm_add_vrf4_consumer.current.contractRef.contractName == "Contract2" == nm_add_vrf4_provider.current.contractRef.contractName + - nm_add_vrf4_consumer.current.relationshipType == "consumer" + - nm_add_vrf4_provider.current.relationshipType == "provider" + +# REMOVE A Contract to VRF +- name: Remove contract4 to VRF2 - provider (check_mode) + mso_schema_template_vrf_contract: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + vrf: VRF2 + contract: + name: Contract4 + type: provider + state: absent + check_mode: yes + register: cm_remove_contract4_vrf2_provider + +- name: Remove contract4 to VRF2 - provider (normal_mode) + mso_schema_template_vrf_contract: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + vrf: VRF2 + contract: + name: Contract4 + type: provider + state: absent + register: nm_remove_contract4_vrf2_provider + +- name: Remove contract4 to VRF2 - consumer (normal_mode) + mso_schema_template_vrf_contract: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + vrf: VRF2 + contract: + name: Contract4 + type: consumer + state: absent + 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: + that: + - cm_remove_contract4_vrf2_provider is changed + - nm_remove_contract4_vrf2_provider is changed + - cm_remove_contract4_vrf2_provider.current == {} + - nm_remove_contract4_vrf2_provider.current == {} + - nm_remove_contract4_vrf2_consumer.current == {} + - cm_remove_contract4_vrf2_provider.previous.contractRef.contractName == nm_remove_contract4_vrf2_provider.previous.contractRef.contractName == nm_remove_contract4_vrf2_consumer.previous.contractRef.contractName == "Contract4" + - cm_remove_contract4_vrf2_provider.previous.contractRef.templateName == nm_remove_contract4_vrf2_provider.previous.contractRef.templateName == nm_remove_contract4_vrf2_consumer.previous.contractRef.templateName == "Template1" + - cm_remove_contract4_vrf2_provider.previous.contractRef.schemaId == nm_remove_contract4_vrf2_provider.previous.contractRef.schemaId == nm_remove_contract4_vrf2_consumer.previous.contractRef.schemaId + - cm_remove_contract4_vrf2_provider.previous.relationshipType == "provider" + - nm_remove_contract4_vrf2_provider.previous.relationshipType == "provider" + - nm_remove_contract4_vrf2_consumer is changed + - nm_remove_contract4_vrf2_consumer.previous.relationshipType == "consumer" + +- name: Remove contract4 to VRF2 - provider again (normal_mode) + mso_schema_template_vrf_contract: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + vrf: VRF2 + contract: + name: Contract4 + type: provider + state: absent + register: nm_remove_contract4_vrf2_provider_again + +- name: Verify nm_remove_contract4_vrf2_provider_again + assert: + that: + - nm_remove_contract4_vrf2_provider_again is not changed + - nm_remove_contract4_vrf2_provider_again.previous == {} + - nm_remove_contract4_vrf2_provider_again.current == {} + +# QUERY A Contract to VRF +- name: Query Contract1 relationship for VRF - consumer (check_mode) + mso_schema_template_vrf_contract: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + vrf: VRF + contract: + name: Contract1 + type: consumer + state: query + check_mode: yes + register: cm_query_VRF_contract1_consumer + +- name: Query Contract1 relationship for VRF - consumer (normal_mode) + mso_schema_template_vrf_contract: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + vrf: VRF + contract: + name: Contract1 + type: consumer + state: query + check_mode: yes + register: nm_query_VRF_contract1_consumer + +- name: Verify cm_query_VRF_contract1_consumer and nm_query_VRF_contract1_consumer + assert: + that: + - cm_query_VRF_contract1_consumer is not changed + - nm_query_VRF_contract1_consumer is not changed + - cm_query_VRF_contract1_consumer.current.relationshipType == nm_query_VRF_contract1_consumer.current.relationshipType == "consumer" + - cm_query_VRF_contract1_consumer.current.contractRef.contractName == nm_query_VRF_contract1_consumer.current.contractRef.contractName == "Contract1" + - cm_query_VRF_contract1_consumer.current.contractRef.schemaId == nm_query_VRF_contract1_consumer.current.contractRef.schemaId + - 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: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + vrf: VRF + contract: + name: Contract1 + type: provider + state: query + check_mode: yes + register: cm_query_VRF_contract1_provider + +- name: Query Contract1 relationship for VRF - provider (normal_mode) + mso_schema_template_vrf_contract: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + vrf: VRF + contract: + name: Contract1 + type: provider + state: query + check_mode: yes + register: nm_query_VRF_contract1_provider + +- name: Verify cm_query_VRF_contract1_provider and nm_query_VRF_contract1_provider + assert: + that: + - cm_query_VRF_contract1_provider is not changed + - nm_query_VRF_contract1_provider is not changed + - cm_query_VRF_contract1_provider.current.relationshipType == nm_query_VRF_contract1_provider.current.relationshipType == "provider" + - cm_query_VRF_contract1_provider.current.contractRef.contractName == nm_query_VRF_contract1_provider.current.contractRef.contractName == "Contract1" + - cm_query_VRF_contract1_provider.current.contractRef.schemaId == nm_query_VRF_contract1_provider.current.contractRef.schemaId + - cm_query_VRF_contract1_provider.current.contractRef.templateName == nm_query_VRF_contract1_provider.current.contractRef.templateName == "Template1" + +# QUERY ALL Contract to VRF +- name: Query all contracts relationship for VRF (check_mode) + mso_schema_template_vrf_contract: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + vrf: VRF + state: query + check_mode: yes + register: cm_query_all_contract_vrf + +- name: Query all contracts relationship for VRF (normal_mode) + mso_schema_template_vrf_contract: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + vrf: VRF + state: query + register: nm_query_all_contract_vrf + +- name: Verify cm_query_all_contract_vrf and nm_query_all_contract_vrf + assert: + that: + - nm_query_all_contract_vrf is not changed + - cm_query_all_contract_vrf is not changed + - cm_query_all_contract_vrf.current | length == nm_query_all_contract_vrf.current | length == 2 + +# QUERY ALL Contracts to VRF2 +- name: Query all contracts relationship for VRF2 (check_mode) + mso_schema_template_vrf_contract: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + vrf: VRF2 + state: query + check_mode: yes + register: cm_query_all_contract_vrf2 + +- name: Query all contracts relationship for VRF2 (normal_mode) + mso_schema_template_vrf_contract: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + vrf: VRF2 + state: query + register: nm_query_all_contract_vrf2 + +- name: Verify cm_query_all_contract_vrf2 and nm_query_all_contract_vrf2 + assert: + that: + - nm_query_all_contract_vrf2 is not changed + - cm_query_all_contract_vrf2 is not changed + - cm_query_all_contract_vrf2.current == nm_query_all_contract_vrf2.current == [] + +# QUERY NON-EXISTING Contract to VRF +- name: Query non-existing contract (check_mode) + mso_schema_template_vrf_contract: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + vrf: VRF + contract: + name: non_existing_contract + type: provider + state: query + check_mode: yes + ignore_errors: yes + register: cm_query_non_existing_contract + +- name: Query non-existing contract (normal_mode) + mso_schema_template_vrf_contract: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + vrf: VRF + contract: + name: non_existing_contract + type: provider + state: query + ignore_errors: yes + register: nm_query_non_existing_contract + +- name: Verify cm_query_non_existing_contract and nm_query_non_existing_contract + assert: + that: + - cm_query_non_existing_contract is not changed + - nm_query_non_existing_contract is not changed + - cm_query_non_existing_contract == nm_query_non_existing_contract + - cm_query_non_existing_contract.msg == "Contract 'non_existing_contract' not found" + - nm_query_non_existing_contract.msg == "Contract 'non_existing_contract' not found" + +# QUERY NON-EXISTING VRF +- name: Query non-existing VRF (check_mode) + mso_schema_template_vrf_contract: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + vrf: non_existing_vrf + state: query + check_mode: yes + ignore_errors: yes + register: cm_query_non_existing_vrf + +- name: Query non-existing VRF (normal_mode) + mso_schema_template_vrf_contract: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + vrf: non_existing_vrf + state: query + ignore_errors: yes + register: nm_query_non_existing_vrf + +- name: Verify cm_query_non_existing_vrf and nm_query_non_existing_vrf + assert: + that: + - cm_query_non_existing_vrf is not changed + - nm_query_non_existing_vrf is not changed + - cm_query_non_existing_vrf == nm_query_non_existing_vrf + - cm_query_non_existing_vrf.msg == "Provided vrf 'non_existing_vrf' does not exist. Existing vrfs{{':'}} VRF, VRF2" + - nm_query_non_existing_vrf.msg == "Provided vrf 'non_existing_vrf' does not exist. Existing vrfs{{':'}} VRF, VRF2" + +# USE A NON-EXISTING SCHEMA +- name: Non-existing schema for contract relationship (check_mode) + mso_schema_template_vrf_contract: + <<: *mso_info + schema: non_existing_schema + template: Template 1 + vrf: VRF + state: query + check_mode: yes + ignore_errors: yes + register: cm_query_non_existing_schema + +- name: Non-existing schema for contract relationship (normal_mode) + mso_schema_template_vrf_contract: + <<: *mso_info + schema: non_existing_schema + template: Template 1 + vrf: VRF + state: query + ignore_errors: yes + register: nm_query_non_existing_schema + +- name: Verify cm_query_non_existing_schema and nm_query_non_existing_schema + assert: + that: + - cm_query_non_existing_schema is not changed + - nm_query_non_existing_schema is not changed + - cm_query_non_existing_schema.msg == "Provided schema 'non_existing_schema' does not exist" + - 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: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + vrf: VRF + contract: + name: Contract1 + type: provider + schema: non_existing_schema + state: query + check_mode: yes + ignore_errors: yes + register: cm_query_non_existing_contract_schema + +- name: Non-existing schema for contract relationship (normal_mode) + mso_schema_template_vrf_contract: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + vrf: VRF + contract: + name: Contract1 + type: provider + schema: non_existing_schema + state: query + ignore_errors: yes + register: nm_query_non_existing_contract_schema + +- name: Verify cm_query_non_existing_contract_schema and nm_query_non_existing_contract_schema + assert: + that: + - cm_query_non_existing_contract_schema is not changed + - nm_query_non_existing_contract_schema is not changed + - cm_query_non_existing_contract_schema.msg == "Schema 'non_existing_schema' is not a valid schema name." + - nm_query_non_existing_contract_schema.msg == "Schema 'non_existing_schema' is not a valid schema name." + +# USE A NON-EXISTING TEMPLATE +- name: Non-existing templateName for contract relationship (check_mode) + mso_schema_template_vrf_contract: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: non_existing_template + vrf: VRF + state: query + check_mode: yes + ignore_errors: yes + register: cm_query_non_existing_template + +- name: Non-existing templateName for contract relationship (normal_mode) + mso_schema_template_vrf_contract: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: non_existing_template + vrf: VRF + state: query + ignore_errors: yes + register: nm_query_non_existing_template + +- name: Verify cm_query_non_existing_template and nm_query_non_existing_template + assert: + that: + - cm_query_non_existing_template is not changed + - nm_query_non_existing_template is not changed + - cm_query_non_existing_template.msg == "Provided template 'non_existing_template' does not exist. Existing templates{{':'}} Template1, Template2" + - 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: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + vrf: VRF + contract: + name: Contract1 + type: provider + schema: '{{ mso_schema | default("ansible_test") }}' + template: non_existing_template + state: query + check_mode: yes + ignore_errors: yes + register: cm_query_non_existing_contract_template + +- name: Non-existing contract templateName for contract relationship (normal_mode) + mso_schema_template_vrf_contract: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + vrf: VRF + contract: + name: Contract1 + type: provider + schema: '{{ mso_schema | default("ansible_test") }}' + template: non_existing_template + state: query + ignore_errors: yes + register: nm_query_non_existing_contract_template + +- name: Verify cm_query_non_existing_contract_template and nm_query_non_existing_contract_template + assert: + that: + - cm_query_non_existing_contract_template is not changed + - nm_query_non_existing_contract_template is not changed + - cm_query_non_existing_contract_template.msg == "Contract 'Contract1' not found" + - nm_query_non_existing_contract_template.msg == "Contract 'Contract1' not found" + +# Checking if contract are removed after re-applying an VRF. +- name: Add VRF again (normal_mode) + mso_schema_template_vrf: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + vrf: VRF + vzany: true + state: present + register: nm_add_VRF_again + +- name: Verify that VRF didn't changed + assert: + that: + - nm_add_VRF_again is not changed + +- name: Verify contract VRF again + mso_schema_template_vrf_contract: + <<: *mso_info + schema: '{{ mso_schema | default("ansible_test") }}' + template: Template 1 + vrf: VRF + state: query + register: nm_query_vrf_contract_again + +- name: Verify 2 contracts are in VRF + 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/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_site/aliases b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_site/aliases new file mode 100644 index 00000000..5042c9c0 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_site/aliases @@ -0,0 +1,2 @@ +# No ACI MultiSite infrastructure, so not enabled +# unsupported diff --git a/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_site/tasks/main.yml b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_site/tasks/main.yml new file mode 100644 index 00000000..d3ed3981 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_site/tasks/main.yml @@ -0,0 +1,449 @@ +# Test code for the MSO modules +# Copyright: (c) 2018, Dag Wieers (@dagwieers) + +# 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.' + when: mso_hostname is not defined or mso_username is not defined or mso_password is not defined + + +# CLEAN ENVIRONMENT +- name: Undeploy a schema 1 template 1 + mso_schema_template_deploy: &schema_undeploy + 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(true) }}' + output_level: '{{ mso_output_level | default("info") }}' + schema: ansible_test + template: Template 1 + site: '{{ item }}' + state: undeploy + ignore_errors: yes + loop: + - '{{ mso_site | default("ansible_test") }}' + - '{{ mso_site | default("ansible_test") }}_2' + +- name: Undeploy a schema 1 template 2 + mso_schema_template_deploy: + <<: *schema_undeploy + template: Template 2 + site: '{{ item }}' + state: undeploy + ignore_errors: yes + loop: + - '{{ mso_site | default("ansible_test") }}' + - '{{ mso_site | default("ansible_test") }}_2' + +- name: Undeploy a schema 2 template 3 + mso_schema_template_deploy: + <<: *schema_undeploy + schema: ansible_test_2 + template: Template 3 + site: '{{ item }}' + state: undeploy + ignore_errors: yes + loop: + - '{{ mso_site | default("ansible_test") }}' + - '{{ mso_site | default("ansible_test") }}_2' + +- name: Remove schemas + mso_schema: + 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(true) }}' + output_level: '{{ mso_output_level | default("info") }}' + schema: '{{ item }}' + state: absent + loop: + - '{{ mso_schema | default("ansible_test") }}_2' + - '{{ mso_schema | default("ansible_test") }}' + +- name: Remove tenant ansible_test + mso_tenant: &tenant_absent + 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(true) }}' + output_level: '{{ mso_output_level | default("info") }}' + tenant: ansible_test + state: absent + +- name: Remove tenant ansible_test2 + mso_tenant: + <<: *tenant_absent + tenant: ansible_test2 + register: cm_remove_tenant + +- name: Remove site + mso_site: &site_absent + 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(true) }}' + output_level: '{{ mso_output_level | default("info") }}' + site: '{{ mso_site | default("ansible_test") }}' + state: absent + +- name: Remove site 2 + 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 + 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(true) }}' + output_level: '{{ mso_output_level | default("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 }} + location: + latitude: 50.887318 + longitude: 4.447084 + labels: + - Diegem + - EMEA + - POD51 + state: present + check_mode: yes + register: cm_add_site + +- name: Verify cm_add_site + assert: + that: + - cm_add_site is changed + - cm_add_site.previous == {} + - cm_add_site.current.id is not defined + - cm_add_site.current.name == mso_site|default("ansible_test") + +- name: Add site (normal mode) + mso_site: *site_present + register: nm_add_site + +- name: Verify nm_add_site + assert: + that: + - nm_add_site is changed + - nm_add_site.previous == {} + - nm_add_site.current.id is defined + - nm_add_site.current.name == mso_site|default("ansible_test") + +- name: Add site again (check_mode) + mso_site: *site_present + check_mode: yes + register: cm_add_site_again + +- name: Verify cm_add_site_again + assert: + that: + - cm_add_site_again is not changed + - cm_add_site_again.previous.name == mso_site|default("ansible_test") + - cm_add_site_again.current.id == nm_add_site.current.id + - cm_add_site_again.current.name == mso_site|default("ansible_test") + +- name: Add site again (normal mode) + mso_site: *site_present + register: nm_add_site_again + +- name: Verify nm_add_site_again + assert: + that: + - nm_add_site_again is not changed + - nm_add_site_again.previous.name == mso_site|default("ansible_test") + - nm_add_site_again.current.id == nm_add_site.current.id + - nm_add_site_again.current.name == mso_site|default("ansible_test") + + +# CHANGE SITE +- name: Change site (check_mode) + mso_site: + <<: *site_present + site: '{{ mso_site | default("ansible_test") }}' + apic_login_domain: '{{ apic_login_domain | default("test") }}' + location: + latitude: 51.887318 + longitude: 5.447084 + labels: + - Charleroi + - EMEA + check_mode: yes + register: cm_change_site + +- name: Verify cm_change_site + assert: + that: + - cm_change_site is changed + - cm_change_site.current.id == nm_add_site.current.id + - cm_change_site.current.name == '{{ mso_site | default("ansible_test") }}' + - cm_change_site.current.location.lat == 51.887318 + - cm_change_site.current.location.long == 5.447084 + - cm_change_site.current.labels[0] != nm_add_site.current.labels[0] + - cm_change_site.current.labels[1] == nm_add_site.current.labels[1] + +- name: Change site (normal mode) + mso_site: + <<: *site_present + site: '{{ mso_site | default("ansible_test") }}' + apic_login_domain: '{{ apic_login_domain | default("test") }}' + location: + latitude: 51.887318 + longitude: 5.447084 + labels: + - Charleroi + - EMEA + output_level: debug + register: nm_change_site + +- name: Verify nm_change_site + assert: + that: + - nm_change_site is changed + - nm_change_site.current.id == nm_add_site.current.id + - nm_change_site.current.name == '{{ mso_site | default("ansible_test") }}' + - nm_change_site.current.location.lat == 51.887318 + - nm_change_site.current.location.long == 5.447084 + - nm_change_site.current.labels[0] != nm_add_site.current.labels[0] + - nm_change_site.current.labels[1] == nm_add_site.current.labels[1] + +- name: Change site again (check_mode) + mso_site: + <<: *site_present + site: '{{ mso_site | default("ansible_test") }}' + apic_login_domain: '{{ apic_login_domain | default("test") }}' + location: + latitude: 51.887318 + longitude: 5.447084 + labels: + - Charleroi + - EMEA + check_mode: yes + register: cm_change_site_again + +- name: Verify cm_change_site_again + assert: + that: + - cm_change_site_again is not changed + - cm_change_site_again.current.id == nm_add_site.current.id + - cm_change_site_again.current.name == '{{ mso_site | default("ansible_test") }}' + - cm_change_site_again.current.location.lat == 51.887318 + - cm_change_site_again.current.location.long == 5.447084 + - cm_change_site_again.current.labels[0] == nm_change_site.current.labels[0] + - cm_change_site_again.current.labels[1] == nm_change_site.current.labels[1] + +- name: Change site again (normal mode) + mso_site: + <<: *site_present + site: '{{ mso_site | default("ansible_test") }}' + apic_login_domain: '{{ apic_login_domain | default("test") }}' + location: + latitude: 51.887318 + longitude: 5.447084 + labels: + - Charleroi + - EMEA + output_level: debug + register: nm_change_site_again + +- name: Verify nm_change_site_again + assert: + that: + - nm_change_site_again is not changed + - nm_change_site_again.current.id == nm_add_site.current.id + - nm_change_site_again.current.name == '{{ mso_site | default("ansible_test") }}' + - nm_change_site_again.current.location.lat == 51.887318 + - nm_change_site_again.current.location.long == 5.447084 + - nm_change_site_again.current.labels[0] == nm_change_site.current.labels[0] + - nm_change_site_again.current.labels[1] == nm_change_site.current.labels[1] + +# QUERY ALL SITES +- name: Query all sites (check_mode) + mso_site: &site_query + 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(true) }}' + output_level: '{{ mso_output_level | default("info") }}' + state: query + check_mode: yes + register: cm_query_all_sites + +- name: Query all sites (normal mode) + mso_site: *site_query + register: nm_query_all_sites + +- name: Verify query_all_sites + 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: + <<: *site_query + site: '{{ mso_site | default("ansible_test") }}' + check_mode: yes + register: cm_query_site + +- name: Query our site + mso_site: + <<: *site_query + site: '{{ mso_site | default("ansible_test") }}' + register: nm_query_site + +- name: Verify query_site + assert: + that: + - cm_query_site is not changed + - cm_query_site.current.id == nm_add_site.current.id + - cm_query_site.current.name == '{{ mso_site | default("ansible_test") }}' + - nm_query_site is not changed + - nm_query_site.current.id == nm_add_site.current.id + - nm_query_site.current.name == '{{ mso_site | default("ansible_test") }}' + - cm_query_site == nm_query_site + + +# REMOVE SITE +- name: Remove site (check_mode) + mso_site: *site_absent + check_mode: yes + register: cm_remove_site + +- name: Verify cm_remove_site + assert: + that: + - cm_remove_site is changed + - cm_remove_site.current == {} + +- name: Remove site (normal mode) + mso_site: *site_absent + register: nm_remove_site + +- name: Verify nm_remove_site + assert: + that: + - nm_remove_site is changed + - nm_remove_site.current == {} + +- name: Remove site again (check_mode) + mso_site: *site_absent + check_mode: yes + register: cm_remove_site_again + +- name: Verify cm_remove_site_again + assert: + that: + - cm_remove_site_again is not changed + - cm_remove_site_again.current == {} + +- name: Remove site again (normal mode) + mso_site: *site_absent + register: nm_remove_site_again + +- name: Verify nm_remove_site_again + 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: + <<: *site_query + site: '{{ mso_site | default("ansible_test") }}' + check_mode: yes + register: cm_query_non_site + +- name: Query non-existing site (normal mode) + 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: + that: + - cm_query_non_site is not changed + - nm_query_non_site is not changed + - cm_query_non_site == nm_query_non_site + +# USE A NON-EXISTING STATE +- name: Non-existing state for site (check_mode) + mso_site: + <<: *site_query + state: non-existing-state + check_mode: yes + ignore_errors: yes + register: cm_non_existing_state + +- name: Non-existing state for bd (normal_mode) + mso_site: + <<: *site_query + state: non-existing-state + ignore_errors: yes + register: nm_non_existing_state + +- name: Verify non_existing_state + assert: + that: + - cm_non_existing_state is not changed + - nm_non_existing_state is not changed + - cm_non_existing_state == nm_non_existing_state + - cm_non_existing_state.msg == nm_non_existing_state.msg == "value of state must be one of{{':'}} absent, present, query, got{{':'}} non-existing-state" + +# ADD SITE +- name: Add site (normal_mode) + mso_site: + 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(true) }}' + output_level: '{{ mso_output_level | default("info") }}' + site: '{{ mso_site | default("ansible_test") }}' + apic_username: '{{ apic_username }}' + apic_password: '{{ apic_password }}' + apic_site_id: '{{ apic_site_id | default(101) }}' + apic_login_domain: '{{ apic_login_domain | default("test") }}' + urls: + - https://{{ apic_hostname }} + state: present + register: nm_add_site_no_location + +- name: Verify cm_add_site + assert: + that: + - nm_add_site_no_location is changed + - nm_add_site_no_location.previous == {} + - nm_add_site_no_location.current.id is defined + - nm_add_site_no_location.current.name == mso_site|default("ansible_test") \ No newline at end of file diff --git a/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_tenant/aliases b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_tenant/aliases new file mode 100644 index 00000000..5042c9c0 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_tenant/aliases @@ -0,0 +1,2 @@ +# No ACI MultiSite infrastructure, so not enabled +# unsupported diff --git a/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_tenant/tasks/main.yml b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_tenant/tasks/main.yml new file mode 100644 index 00000000..44b996f6 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_tenant/tasks/main.yml @@ -0,0 +1,541 @@ +# Test code for the MSO modules +# Copyright: (c) 2018, Dag Wieers (@dagwieers) +# Copyright: (c) 2020, Cindy Zhao (@cizhao) +# 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.' + 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: + 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(true) }}' + output_level: '{{ mso_output_level | default("info") }}' + apic_hostname_2: 173.36.219.123 + apic_username_2: admin + apic_password_2: ins3965! + apic_site_id_2: 102 + +- name: Ensure sites exists + mso_site: + <<: *mso_info + site: '{{ item.site }}' + apic_username: '{{ item.username }}' + apic_password: '{{ item.password }}' + apic_site_id: '{{ item.id }}' + urls: + - https://{{ item.urls }} + state: present + loop: + - { site: '{{ mso_site | default("ansible_test") }}', username: '{{ apic_username }}', password: '{{ apic_password }}', id: '{{ apic_site_id | default(101) }}', urls: '{{ apic_hostname }}' } + - { site: '{{ mso_site | default("ansible_test") }}_2', username: '{{ apic_username_2 }}', password: '{{ apic_password_2 }}', id: '{{ apic_site_id_2 | default(101) }}', urls: '{{ apic_hostname_2 }}' } + +- name: Undeploy a schema 1 template 1 + mso_schema_template_deploy: &schema_undeploy + <<: *mso_info + schema: ansible_test + template: Template 1 + site: '{{ item }}' + state: undeploy + ignore_errors: yes + loop: + - '{{ mso_site | default("ansible_test") }}' + - '{{ mso_site | default("ansible_test") }}_2' + +- name: Undeploy a schema 1 template 2 + mso_schema_template_deploy: + <<: *schema_undeploy + template: Template 2 + site: '{{ item }}' + state: undeploy + ignore_errors: yes + loop: + - '{{ mso_site | default("ansible_test") }}' + - '{{ mso_site | default("ansible_test") }}_2' + +- name: Undeploy a schema 2 template 3 + mso_schema_template_deploy: + <<: *schema_undeploy + schema: ansible_test_2 + template: Template 3 + site: '{{ item }}' + state: undeploy + ignore_errors: yes + loop: + - '{{ mso_site | default("ansible_test") }}' + - '{{ mso_site | default("ansible_test") }}_2' + +- name: Remove schemas + mso_schema: + 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(true) }}' + output_level: '{{ mso_output_level | default("info") }}' + schema: '{{ item }}' + state: absent + loop: + - '{{ mso_schema | default("ansible_test") }}_2' + - '{{ mso_schema | default("ansible_test") }}' + +- name: Remove tenant ansible_test + mso_tenant: &tenant_absent + 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(true) }}' + output_level: '{{ mso_output_level | default("info") }}' + tenant: ansible_test + state: absent + +- name: Remove tenant ansible_test2 + mso_tenant: + <<: *tenant_absent + tenant: ansible_test2 + register: cm_remove_tenant2 + +- name: Remove tenant ansible_test3 + mso_tenant: + <<: *tenant_absent + tenant: ansible_test3 + register: cm_remove_tenant3 + +# ADD TENANT +- name: Add tenant (check_mode) + mso_tenant: &tenant_present + 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(true) }}' + output_level: '{{ mso_output_level | default("info") }}' + tenant: ansible_test + display_name: Ansible test title + description: Ansible test tenant + state: present + check_mode: yes + register: cm_add_tenant + +- name: Verify cm_add_tenant + assert: + that: + - cm_add_tenant is changed + - cm_add_tenant.previous == {} + - cm_add_tenant.current.id is not defined + - cm_add_tenant.current.name == 'ansible_test' + - cm_add_tenant.current.description == 'Ansible test tenant' + - cm_add_tenant.current.userAssociations | length == 1 + +- name: Add tenant (normal mode) + mso_tenant: *tenant_present + register: nm_add_tenant + +- name: Verify nm_add_tenant + assert: + that: + - nm_add_tenant is changed + - nm_add_tenant.previous == {} + - nm_add_tenant.current.id is defined + - nm_add_tenant.current.name == 'ansible_test' + - nm_add_tenant.current.description == 'Ansible test tenant' + - nm_add_tenant.current.userAssociations | length == 1 + +- name: Add tenant again (check_mode) + mso_tenant: *tenant_present + check_mode: yes + register: cm_add_tenant_again + +- name: Verify cm_add_tenant_again + assert: + that: + - cm_add_tenant_again is not changed + - cm_add_tenant_again.previous.name == 'ansible_test' + - cm_add_tenant_again.previous.description == 'Ansible test tenant' + - cm_add_tenant_again.current.id == nm_add_tenant.current.id + - cm_add_tenant_again.current.name == 'ansible_test' + - cm_add_tenant_again.current.description == 'Ansible test tenant' + - cm_add_tenant_again.current.userAssociations == cm_add_tenant_again.previous.userAssociations + +- name: Add tenant again (normal mode) + mso_tenant: *tenant_present + register: nm_add_tenant_again + +- name: Verify nm_add_tenant_again + assert: + that: + - nm_add_tenant_again is not changed + - nm_add_tenant_again.previous.name == 'ansible_test' + - nm_add_tenant_again.previous.description == 'Ansible test tenant' + - nm_add_tenant_again.current.id == nm_add_tenant.current.id + - nm_add_tenant_again.current.name == 'ansible_test' + - nm_add_tenant_again.current.description == 'Ansible test tenant' + - nm_add_tenant_again.current.userAssociations == nm_add_tenant_again.previous.userAssociations + +# ADD TENANT WITH USERS +- name: Add tenant 2 (normal mode) + mso_tenant: + <<: *tenant_present + tenant: ansible_test2 + users: + - '{{ mso_username }}' + display_name: null + state: present + register: nm_add_tenant2 + +- name: Verify nm_add_tenant2 + assert: + that: + - nm_add_tenant2 is changed + +- name: Verify nm_add_tenant2 (when mso_username != admin) + assert: + that: + - nm_add_tenant2.current.userAssociations | length == 2 + when: mso_username != 'admin' + +- name: Verify nm_add_tenant2 (when mso_username == admin) + assert: + that: + - nm_add_tenant2.current.userAssociations | length == 1 + when: mso_username == 'admin' + +- name: Add tenant 2 again (normal mode) + mso_tenant: + <<: *tenant_present + tenant: ansible_test2 + users: + - '{{ mso_username }}' + display_name: null + state: present + register: nm_add_tenant2_again + +- name: Verify nm_add_tenant2_again + assert: + that: + - nm_add_tenant2_again is not changed + +- name: Verify nm_add_tenant2_again (when mso_username != admin) + 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: + that: + - nm_add_tenant2_again.current.userAssociations | length == 1 + when: mso_username == 'admin' + +- name: Add tenant 3 with duplicate admin user (normal mode) + mso_tenant: + <<: *tenant_present + tenant: ansible_test3 + users: + - admin + - admin + display_name: null + state: present + ignore_errors: yes + register: nm_add_tenant3_with_duplicate_admin + +- name: Verify nm_add_tenant3_with_duplicate_admin + assert: + that: + - nm_add_tenant3_with_duplicate_admin is not changed + - nm_add_tenant3_with_duplicate_admin.msg == "User 'admin' is duplicate." + +- name: Add tenant 3 with invalid user (normal mode) + mso_tenant: + <<: *tenant_present + tenant: ansible_test3 + users: + - invalid user + display_name: null + state: present + ignore_errors: yes + register: nm_add_tenant3_with_invalid_user + +- name: nm_add_tenant3_with_invalid_user + 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: + <<: *tenant_present + tenant: ansible_test3 + users: + - '{{ mso_username }}' + display_name: null + state: present + register: nm_add_tenant3 + +- name: Verify nm_add_tenant3 + assert: + that: + - nm_add_tenant3 is changed + +- name: Verify nm_add_tenant3 (when mso_username != admin) + assert: + that: + - nm_add_tenant3.current.userAssociations | length == 2 + when: mso_username != 'admin' + +- name: Verify nm_add_tenant3 (when mso_username == admin) + assert: + that: + - nm_add_tenant3.current.userAssociations | length == 1 + when: mso_username == 'admin' + +# CHANGE TENANT +- name: Change tenant (check_mode) + mso_tenant: + <<: *tenant_present + tenant: ansible_test + description: Ansible test tenant 2 + check_mode: yes + register: cm_change_tenant + +- name: Verify cm_change_tenant + assert: + that: + - cm_change_tenant is changed + - cm_change_tenant.current.id == nm_add_tenant.current.id + - cm_change_tenant.current.name == 'ansible_test' + - cm_change_tenant.current.description == 'Ansible test tenant 2' + +- name: Change tenant (normal mode) + mso_tenant: + <<: *tenant_present + tenant: ansible_test + description: Ansible test tenant 2 + output_level: debug + register: nm_change_tenant + +- name: Verify nm_change_tenant + assert: + that: + - nm_change_tenant is changed + - nm_change_tenant.current.id == nm_add_tenant.current.id + - nm_change_tenant.current.name == 'ansible_test' + - nm_change_tenant.current.description == 'Ansible test tenant 2' + +- name: Change tenant again (check_mode) + mso_tenant: + <<: *tenant_present + tenant: ansible_test + description: Ansible test tenant 2 + check_mode: yes + register: cm_change_tenant_again + +- name: Verify cm_change_tenant_again + assert: + that: + - cm_change_tenant_again is not changed + - cm_change_tenant_again.current.id == nm_add_tenant.current.id + - cm_change_tenant_again.current.name == 'ansible_test' + - cm_change_tenant_again.current.description == 'Ansible test tenant 2' + +- name: Change tenant again (normal mode) + mso_tenant: + <<: *tenant_present + tenant: ansible_test + description: Ansible test tenant 2 + register: nm_change_tenant_again + +- name: Verify nm_change_tenant_again + 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 + 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(true) }}' + output_level: '{{ mso_output_level | default("info") }}' + state: query + check_mode: yes + register: cm_query_all_tenants + +- name: Query all tenants (normal mode) + mso_tenant: *tenant_query + register: nm_query_all_tenants + +- name: Verify query_all_tenants + 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: + <<: *tenant_query + tenant: ansible_test + check_mode: yes + register: cm_query_tenant + +- name: Query our tenant + mso_tenant: + <<: *tenant_query + tenant: ansible_test + register: nm_query_tenant + +- name: Verify query_tenant + assert: + that: + - cm_query_tenant is not changed + - cm_query_tenant.current.id == nm_add_tenant.current.id + - cm_query_tenant.current.name == 'ansible_test' + - cm_query_tenant.current.description == 'Ansible test tenant 2' + - nm_query_tenant is not changed + - nm_query_tenant.current.id == nm_add_tenant.current.id + - nm_query_tenant.current.name == 'ansible_test' + - nm_query_tenant.current.description == 'Ansible test tenant 2' + - cm_query_tenant == nm_query_tenant + + +# REMOVE TENANT +- name: Remove tenant (check_mode) + mso_tenant: *tenant_absent + check_mode: yes + register: cm_remove_tenant + +- name: Verify cm_remove_tenant + assert: + that: + - cm_remove_tenant is changed + - cm_remove_tenant.current == {} + +- name: Remove tenant (normal mode) + mso_tenant: *tenant_absent + register: nm_remove_tenant + +- name: Verify nm_remove_tenant + assert: + that: + - nm_remove_tenant is changed + - nm_remove_tenant.current == {} + +- name: Remove tenant again (check_mode) + mso_tenant: *tenant_absent + check_mode: yes + register: cm_remove_tenant_again + +- name: Verify cm_remove_tenant_again + assert: + that: + - cm_remove_tenant_again is not changed + - cm_remove_tenant_again.current == {} + +- name: Remove tenant again (normal mode) + mso_tenant: *tenant_absent + register: nm_remove_tenant_again + +- name: Verify nm_remove_tenant_again + 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: + <<: *tenant_query + tenant: ansible_test + check_mode: yes + register: cm_query_non_tenant + +- name: Query non-existing tenant (normal mode) + mso_tenant: + <<: *tenant_query + tenant: ansible_test + register: nm_query_non_tenant + +# TODO: Implement more tests +- name: Verify query_non_tenant + assert: + that: + - cm_query_non_tenant is not changed + - nm_query_non_tenant is not changed + - cm_query_non_tenant == nm_query_non_tenant + +- name: Add common tenant + mso_tenant: + <<: *tenant_present + tenant: common + display_name: common + sites: [ansible_test, ansible_test_2] + register: nm_add_common_tenant + +- name: Verify nm_add_common_tenant + assert: + that: + - nm_add_common_tenant is changed + - nm_add_common_tenant.current.name == "common" + +- name: Add tenant with site + mso_tenant: + <<: *tenant_present + tenant: tenant_with_site + display_name: tenant_with_site + sites: ansible_test + register: nm_add_tenant_with_site + +- name: Verify nm_add_tenant_with_site + 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: + <<: *tenant_absent + tenant: common + ignore_errors: yes + register: rm_common + +- name: Verify rm_common + assert: + that: + - rm_common.msg == "MSO Error 400{{':'}} Bad Request{{':'}} Common Tenant cannot be deleted." + +- name: Remove tenant_with_site + mso_tenant: + <<: *tenant_absent + tenant: tenant_with_site + register: rm_tenant_with_site + +- name: Verify rm_tenant_with_site + assert: + that: + - rm_tenant_with_site is changed + - rm_tenant_with_site.current == {} \ No newline at end of file diff --git a/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_tenant_site/aliases b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_tenant_site/aliases new file mode 100644 index 00000000..5042c9c0 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_tenant_site/aliases @@ -0,0 +1,2 @@ +# No ACI MultiSite infrastructure, so not enabled +# unsupported diff --git a/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_tenant_site/tasks/main.yml b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_tenant_site/tasks/main.yml new file mode 100644 index 00000000..f39db0b5 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_tenant_site/tasks/main.yml @@ -0,0 +1,661 @@ +# Test code for the MSO modules +# Copyright: (c) 2018, Dag Wieers (@dagwieers) (based on mso_site test case) +# Copyright: (c) 2020, Lionel Hercot (@lhercot) +# Copyright: (c) 2020, Shreyas Srish (@shrsr) + +# 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.' + 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: + 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(true) }}' + output_level: '{{ mso_output_level | default("info") }}' + +- name: Remove schemas + mso_schema: + <<: *mso_info + schema: '{{ item }}' + state: absent + loop: + - '{{ mso_schema | default("ansible_test") }}_2' + - '{{ mso_schema | default("ansible_test") }}' + +- name: Dissociate clouds that are associated with ansible_tenant + 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") }}' + ignore_errors: yes + +- name: Remove tenant ansible_test + mso_tenant: + <<: *mso_info + tenant: ansible_test + users: + - '{{ mso_username }}' + state: absent + +- name: Ensure non-cloud site exists + mso_site: + <<: *mso_info + site: '{{ mso_site | default("ansible_test") }}' + apic_username: '{{ apic_username }}' + apic_password: '{{ apic_password }}' + apic_site_id: '{{ apic_site_id }}' + urls: + - https://{{ apic_hostname }} + state: present + +- name: Ensure azure site exists + mso_site: + <<: *mso_info + site: 'azure_{{ mso_site | default("ansible_test") }}' + apic_username: '{{ azure_apic_username }}' + apic_password: '{{ azure_apic_password }}' + apic_site_id: '{{ azure_site_id }}' + urls: + - https://{{ azure_apic_hostname }} + state: present + +- name: Ensure aws site exists + mso_site: + <<: *mso_info + site: 'aws_{{ mso_site | default("ansible_test") }}' + apic_username: '{{ aws_apic_username }}' + apic_password: '{{ aws_apic_password }}' + apic_site_id: '{{ aws_site_id }}' + urls: + - https://{{ aws_apic_hostname }} + state: present + +- name: Ensure tenant ansible_test exists + mso_tenant: + <<: *mso_info + tenant: ansible_test + users: + - '{{ mso_username }}' + state: present + +- name: Associate non-cloud site with ansible_test in check mode + mso_tenant_site: + <<: *mso_info + tenant: ansible_test + site: '{{ mso_site | default("ansible_test") }}' + state: present + check_mode: yes + register: ncs_cm + +- name: Verify ncs_cm + assert: + that: + - ncs_cm is changed + +- name: Associate non-cloud site with ansible_test in normal mode + mso_tenant_site: + <<: *mso_info + tenant: ansible_test + site: '{{ mso_site | default("ansible_test") }}' + state: present + register: ncs_nm + +- name: Verify ncs_nm + assert: + that: + - ncs_nm is changed + +- name: Associate non-cloud site with ansible_test again in normal mode + mso_tenant_site: + <<: *mso_info + tenant: ansible_test + site: '{{ mso_site | default("ansible_test") }}' + state: present + register: ncs_nm_again + +- name: Verify ncs_nm_again + assert: + that: + - ncs_nm_again is not changed + +- name: Associate aws site with ansible_test in check mode + mso_tenant_site: + <<: *mso_info + tenant: ansible_test + site: 'aws_{{ mso_site | default("ansible_test") }}' + cloud_account: "000000000000" + aws_trusted: false + aws_access_key: "1" + secret_key: "0" + state: present + check_mode: yes + register: aaws_cm + +- name: Verify aaws_cm + assert: + that: + - aaws_cm is changed + - aaws_cm.current.awsAccount != 'null' + - aaws_cm.current.awsAccount[0].accessKeyId == '1' + - aaws_cm.current.awsAccount[0].secretKey == '0' + - aaws_cm.current.awsAccount[0].accountId == '000000000000' + +- name: Associate aws site with ansible_test in normal mode + mso_tenant_site: + <<: *mso_info + tenant: ansible_test + site: 'aws_{{ mso_site | default("ansible_test") }}' + cloud_account: "000000000000" + aws_trusted: false + aws_access_key: "1" + secret_key: "0" + state: present + register: aaws_nm + +- name: Verify aaws_nm + assert: + that: + - aaws_nm is changed + - aaws_nm.current.awsAccount != 'null' + - aaws_nm.current.awsAccount[0].accessKeyId == '1' + - aaws_nm.current.awsAccount[0].secretKey == '0' + - aaws_nm.current.awsAccount[0].accountId == '000000000000' + +- name: Associate aws site with ansible_test again in normal mode + mso_tenant_site: + <<: *mso_info + tenant: ansible_test + site: 'aws_{{ mso_site | default("ansible_test") }}' + cloud_account: "000000000000" + aws_trusted: false + aws_access_key: "1" + secret_key: "0" + state: present + register: aaws_nm_again + +- name: Verify aaws_nm_again + 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: + <<: *mso_info + tenant: ansible_test + site: 'aws_{{ mso_site | default("ansible_test") }}' + cloud_account: "000000000000" + aws_trusted: false + secret_key: "0" + state: present + ignore_errors: yes + register: aaws_nm_ak + +- name: Verify aaws_nm_ak + 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 false and secret_key is missing + mso_tenant_site: + <<: *mso_info + tenant: ansible_test + site: 'aws_{{ mso_site | default("ansible_test") }}' + cloud_account: "000000000000" + aws_trusted: false + aws_access_key: "1" + state: present + ignore_errors: yes + register: aaws_nm_sk + +- name: Verify aaws_nm_sk + 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: + <<: *mso_info + tenant: ansible_test + site: 'aws_{{ mso_site | default("ansible_test") }}' + aws_account_org: true + cloud_account: "000000000000" + secret_key: "0" + aws_access_key: "1" + state: present + ignore_errors: yes + register: aaws_nm_om + +- name: Verify aaws_nm_om + 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: + <<: *mso_info + tenant: ansible_test + site: 'azure_{{ mso_site | default("ansible_test") }}' + cloud_account: uni/tn-ansible_test/act-[100]-vendor-azure + state: present + register: aazure_shared_nm + +- name: Verify aazure_shared_nm + assert: + that: + - aazure_shared_nm is changed + +- name: Associate azure site in shared mode with ansible_test in normal mode + mso_tenant_site: + <<: *mso_info + tenant: ansible_test + site: 'azure_{{ mso_site | default("ansible_test") }}' + cloud_account: uni/tn-ansible_test/act-[100]-vendor-azure + azure_access_type: shared + state: present + register: aazure_shared_nm + +- name: Verify aazure_shared_nm + 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: + <<: *mso_info + tenant: ansible_test + site: 'azure_{{ mso_site | default("ansible_test") }}' + azure_subscription_id: "9" + cloud_account: uni/tn-ansible_test/act-[9]-vendor-azure + azure_access_type: managed + state: present + ignore_errors: yes + register: aazure_managed_nm_app + +- name: Verify aazure_managed_nm_app + 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: + <<: *mso_info + tenant: ansible_test + site: 'azure_{{ mso_site | default("ansible_test") }}' + azure_application_id: "100" + cloud_account: uni/tn-ansible_test/act-[9]-vendor-azure + azure_access_type: managed + state: present + ignore_errors: yes + register: aazure_managed_nm_si + +- name: Verify aazure_managed_nm_si + 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: + <<: *mso_info + tenant: ansible_test + site: 'azure_{{ mso_site | default("ansible_test") }}' + azure_subscription_id: "9" + azure_application_id: "100" + cloud_account: uni/tn-ansible_test/act-[9]-vendor-azure + azure_access_type: managed + state: present + ignore_errors: yes + register: aazure_managed_nm + +- name: Verify aazure_managed_nm + assert: + that: + - aazure_managed_nm is changed + - aazure_managed_nm.current.azureAccount != 'null' + - aazure_managed_nm.current.azureAccount[0].cloudSubscription.cloudApplicationId == '100' + - aazure_managed_nm.current.azureAccount[0].cloudSubscription.cloudSubscriptionId == '9' + - aazure_managed_nm.current.azureAccount[0].cloudApplication == [] + - 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: + <<: *mso_info + tenant: ansible_test + site: 'azure_{{ mso_site | default("ansible_test") }}' + azure_application_id: "100" + azure_credential_name: cApicApp + secret_key: iins + azure_active_directory_id: "32" + azure_active_directory_name: CiscoINSBUAd + cloud_account: uni/tn-ansible_test/act-[9]-vendor-azure + azure_access_type: unmanaged + state: present + ignore_errors: yes + register: aazure_credentials_nm_si + +- name: Verify aazure_credentials_nm_si + 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: + <<: *mso_info + tenant: ansible_test + site: 'azure_{{ mso_site | default("ansible_test") }}' + azure_subscription_id: "9" + azure_credential_name: cApicApp + secret_key: iins + azure_active_directory_id: "32" + azure_active_directory_name: CiscoINSBUAd + cloud_account: uni/tn-ansible_test/act-[9]-vendor-azure + azure_access_type: unmanaged + state: present + ignore_errors: yes + register: aazure_credentials_nm_app + +- name: Verify aazure_credentials_nm_app + 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: + <<: *mso_info + tenant: ansible_test + site: 'azure_{{ mso_site | default("ansible_test") }}' + azure_subscription_id: "9" + azure_credential_name: cApicApp + azure_active_directory_id: "32" + azure_active_directory_name: CiscoINSBUAd + azure_application_id: "100" + cloud_account: uni/tn-ansible_test/act-[9]-vendor-azure + azure_access_type: unmanaged + state: present + ignore_errors: yes + register: aazure_credentials_nm_secret + +- name: Verify aazure_credentials_nm_secret + 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: + <<: *mso_info + tenant: ansible_test + site: 'azure_{{ mso_site | default("ansible_test") }}' + azure_subscription_id: "9" + azure_credential_name: cApicApp + azure_active_directory_name: CiscoINSBUAd + azure_application_id: "100" + secret_key: iins + cloud_account: uni/tn-ansible_test/act-[9]-vendor-azure + azure_access_type: unmanaged + state: present + ignore_errors: yes + register: aazure_credentials_nm_ad + +- name: Verify aazure_credentials_nm_ad + 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: + <<: *mso_info + tenant: ansible_test + site: 'azure_{{ mso_site | default("ansible_test") }}' + azure_subscription_id: "9" + azure_credential_name: cApicApp + secret_key: iins + azure_active_directory_id: "32" + azure_application_id: "100" + cloud_account: uni/tn-ansible_test/act-[9]-vendor-azure + azure_access_type: unmanaged + state: present + ignore_errors: yes + register: aazure_credentials_nm_adn + +- name: Verify aazure_credentials_nm_adn + 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: + <<: *mso_info + tenant: ansible_test + site: 'azure_{{ mso_site | default("ansible_test") }}' + azure_subscription_id: "9" + secret_key: iins + azure_active_directory_name: CiscoINSBUAd + azure_active_directory_id: "32" + azure_application_id: "100" + cloud_account: uni/tn-ansible_test/act-[9]-vendor-azure + azure_access_type: unmanaged + state: present + ignore_errors: yes + register: aazure_credentials_nm_cdn + +- name: Verify aazure_credentials_nm_cdn + 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: + <<: *mso_info + tenant: ansible_test + site: 'azure_{{ mso_site | default("ansible_test") }}' + azure_subscription_id: "9" + azure_application_id: "100" + azure_credential_name: cApicApp + secret_key: iins + azure_active_directory_id: "32" + azure_active_directory_name: CiscoINSBUAd + cloud_account: uni/tn-ansible_test/act-[9]-vendor-azure + azure_access_type: unmanaged + state: present + register: aazure_credentials_nm + +- name: Verify aazure_credentials_nm + assert: + that: + - aazure_credentials_nm is changed + - aazure_credentials_nm.current.azureAccount[0].cloudSubscription.cloudApplicationId == '100' + - aazure_credentials_nm.current.azureAccount[0].cloudSubscription.cloudSubscriptionId == '9' + - aazure_credentials_nm.current.azureAccount[0].cloudActiveDirectory[0].cloudActiveDirectoryId == '32' + - aazure_credentials_nm.current.azureAccount[0].cloudActiveDirectory[0].cloudActiveDirectoryName == 'CiscoINSBUAd' + - aazure_credentials_nm.current.azureAccount[0].cloudApplication[0].cloudApplicationId == '100' + - aazure_credentials_nm.current.azureAccount[0].cloudApplication[0].cloudActiveDirectoryId == '32' + - aazure_credentials_nm.current.azureAccount[0].cloudApplication[0].cloudCredentialName == 'cApicApp' + - aazure_credentials_nm.current.azureAccount[0].cloudApplication[0].secretKey == 'iins' + +- name: Associate azure site with credentials mode, with ansible_test again in normal mode + mso_tenant_site: + <<: *mso_info + tenant: ansible_test + site: 'azure_{{ mso_site | default("ansible_test") }}' + azure_subscription_id: "9" + azure_application_id: "100" + azure_credential_name: cApicApp + secret_key: iins + azure_active_directory_id: "32" + azure_active_directory_name: CiscoINSBUAd + cloud_account: uni/tn-ansible_test/act-[9]-vendor-azure + azure_access_type: unmanaged + state: present + register: aazure_credentials_nm_again + +- name: Verify aazure_credentials_nm_again + assert: + that: + - aazure_credentials_nm_again is not changed + +- name: Query associated non-cloud site of a tenant + mso_tenant_site: + <<: *mso_info + tenant: ansible_test + site: '{{ mso_site | default("ansible_test") }}' + state: query + register: anc_query + +- name: Verify anc_query + assert: + that: + - anc_query is not changed + +- name: Query associated azure site of a tenant + mso_tenant_site: + <<: *mso_info + tenant: ansible_test + site: 'azure_{{ mso_site | default("ansible_test") }}' + azure_subscription_id: "9" + azure_application_id: "100" + azure_credential_name: cApicApp + secret_key: iins + azure_active_directory_id: "32" + azure_active_directory_name: CiscoINSBUAd + cloud_account: uni/tn-ansible_test/act-[9]-vendor-azure + azure_access_type: unmanaged + state: query + register: aazure_query + +- name: Verify aazure_query + assert: + that: + - aazure_query is not changed + +- name: Query associated aws site of a tenant + mso_tenant_site: + <<: *mso_info + tenant: ansible_test + site: 'aws_{{ mso_site | default("ansible_test") }}' + state: query + register: aaws_query + +- name: Verify aaws_query + assert: + that: + - aaws_query is not changed + +- name: Query all associated sites of a tenant + mso_tenant_site: + <<: *mso_info + tenant: ansible_test + state: query + register: all_sites_query + +- name: Verify all_sites_query + assert: + that: + - all_sites_query is not changed + +- name: Dissociate non-cloud site with ansible_test + mso_tenant_site: + <<: *mso_info + tenant: ansible_test + site: '{{ mso_site | default("ansible_test") }}' + state: absent + register: dnc + +- name: Verify dnc + assert: + that: + - dnc is changed + +- name: Query dissociated non-cloud site of a tenant + mso_tenant_site: + <<: *mso_info + tenant: ansible_test + site: '{{ mso_site | default("ansible_test") }}' + state: query + ignore_errors: yes + register: dnc_query + +- name: Verify dnc_query + 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: + <<: *mso_info + tenant: ansible_test + site: 'azure_{{ mso_site | default("ansible_test") }}' + state: absent + register: dazure + +- name: Verify dazure + assert: + that: + - dazure is changed + +- name: Query dissociated azure site of a tenant + mso_tenant_site: + <<: *mso_info + tenant: ansible_test + site: 'azure_{{ mso_site | default("ansible_test") }}' + state: query + ignore_errors: yes + register: dazure_query + +- name: Verify dnc_query + 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: + <<: *mso_info + tenant: ansible_test + site: 'aws_{{ mso_site | default("ansible_test") }}' + state: absent + register: daaws + +- name: Verify daaws + assert: + that: + - daaws is changed + +- name: Query dissociated aws site of a tenant + mso_tenant_site: + <<: *mso_info + tenant: ansible_test + site: 'aws_{{ mso_site | default("ansible_test") }}' + state: query + ignore_errors: yes + register: daaws_query + +- name: Verify daaws_query + assert: + that: + - daaws_query.msg is match ("No site associated with tenant Id [0-9a-zA-Z]*") + +- name: Query all + mso_tenant_site: + <<: *mso_info + tenant: ansible_test + state: query + ignore_errors: yes + register: query_all + +- name: Verify query_all + 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/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_user/aliases b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_user/aliases new file mode 100644 index 00000000..5042c9c0 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_user/aliases @@ -0,0 +1,2 @@ +# No ACI MultiSite infrastructure, so not enabled +# unsupported diff --git a/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_user/tasks/main.yml b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_user/tasks/main.yml new file mode 100644 index 00000000..8bead661 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_user/tasks/main.yml @@ -0,0 +1,522 @@ +# Test code for the MSO modules +# Copyright: (c) 2018, Dag Wieers (@dagwieers) + +# 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.' + when: mso_hostname is not defined or mso_username is not defined or mso_password is not defined + + +# CLEAN ENVIRONMENT +- name: Remove user ansible_test + mso_user: &user_absent + 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(true) }}' + output_level: '{{ mso_output_level | default("info") }}' + user: '{{ item }}' + state: absent + loop: + - ansible_test + - ansible_test2 + - ansible_test_read + - ansible_test_read_2 + +# ADD USER +- name: Add user (check_mode) + mso_user: &user_present + 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(true) }}' + output_level: '{{ mso_output_level | default("info") }}' + user: ansible_test + user_password: 'S0m3!1n1t14l!p455w0rd' + # NOTE: First name, last name, phone and email are mandatory on creation + first_name: Ansible + last_name: Test + email: mso@cisco.com + phone: +32 478 436 299 + account_status: active + roles: + - name: powerUser + access_type: write + domain: Local + state: present + check_mode: yes + register: cm_add_user + +- name: Verify cm_add_user + assert: + that: + - cm_add_user is changed + - cm_add_user.previous == {} + - cm_add_user.current.id is not defined + - cm_add_user.current.username == 'ansible_test' + - cm_add_user.current.lastName == 'Test' + - cm_add_user.current.firstName == 'Ansible' + - cm_add_user.current.emailAddress == 'mso@cisco.com' + - cm_add_user.current.phoneNumber == '+32 478 436 299' + - cm_add_user.current.accountStatus == 'active' + - cm_add_user.current.roles[0].accessType == 'readWrite' + +- name: Add user (normal mode) + mso_user: *user_present + register: nm_add_user + +- name: Verify nm_add_user + assert: + that: + - nm_add_user is changed + - nm_add_user.previous == {} + - nm_add_user.current.id is defined + - nm_add_user.current.username == 'ansible_test' + - nm_add_user.current.lastName == 'Test' + - nm_add_user.current.firstName == 'Ansible' + - nm_add_user.current.emailAddress == 'mso@cisco.com' + - nm_add_user.current.phoneNumber == '+32 478 436 299' + - nm_add_user.current.accountStatus == 'active' + - nm_add_user.current.roles[0].accessType == 'readWrite' + +- name: Add user again (check_mode) + mso_user: + <<: *user_present + # NOTE: We need to modify the password for a new user + user_password: 'S0m3!n3w!p455w0rd' + check_mode: yes + register: cm_add_user_again + +- name: Verify cm_add_user_again + assert: + that: + - cm_add_user_again is changed + - cm_add_user_again.previous.username == 'ansible_test' + - cm_add_user_again.current.id == nm_add_user.current.id + - cm_add_user_again.current.username == 'ansible_test' + +- name: Add user again (normal mode) + 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: + that: + - nm_add_user_again is changed + - nm_add_user_again.previous.username == 'ansible_test' + - nm_add_user_again.current.id == nm_add_user.current.id + - nm_add_user_again.current.username == 'ansible_test' + +- name: Add user with read only role (check_mode) + mso_user: &user_present2 + 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(true) }}' + output_level: '{{ mso_output_level | default("info") }}' + user: ansible_test_read + user_password: '#123455#123455Aa' + # NOTE: First name, last name, phone and email are mandatory on creation + first_name: Ansible2 + last_name: Test2 + email: mso3@cisco.com + phone: +32 478 436 299 + account_status: active + roles: + - name: powerUser + access_type: read + domain: Local + state: present + check_mode: yes + register: cm_add_user2 + +- name: Verify cm_add_user2 + assert: + that: + - cm_add_user2 is changed + - cm_add_user2.previous == {} + - cm_add_user2.current.id is not defined + - cm_add_user2.current.username == 'ansible_test_read' + - cm_add_user2.current.lastName == 'Test2' + - cm_add_user2.current.firstName == 'Ansible2' + - cm_add_user2.current.emailAddress == 'mso3@cisco.com' + - cm_add_user2.current.phoneNumber == '+32 478 436 299' + - cm_add_user2.current.accountStatus == 'active' + - cm_add_user2.current.roles[0].accessType == 'readOnly' + +- name: Add user with read only role (normal mode) + mso_user: *user_present2 + register: nm_add_user2 + +- name: Verify nm_add_user2 + assert: + that: + - nm_add_user2 is changed + - nm_add_user2.current.id is defined + - nm_add_user2.current.username == 'ansible_test_read' + - nm_add_user2.current.lastName == 'Test2' + - nm_add_user2.current.firstName == 'Ansible2' + - nm_add_user2.current.emailAddress == 'mso3@cisco.com' + - nm_add_user2.current.phoneNumber == '+32 478 436 299' + - nm_add_user2.current.accountStatus == 'active' + - nm_add_user2.current.roles[0].accessType == 'readOnly' + +- name: Add user with read only role again (check mode) + mso_user: + <<: *user_present2 + user_password: '#123455#123455Aa' + check_mode: yes + register: cm_add_user2_again + +- name: Add user with read only role again (normal mode) + mso_user: *user_present2 + register: nm_add_user2 + +- name: Add user3 with read only role and no password (check_mode) + mso_user: &user_present3 + 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(true) }}' + output_level: '{{ mso_output_level | default("info") }}' + user: ansible_test_read_2 + # NOTE: First name, last name, phone and email are mandatory on creation + first_name: Ansible3 + #user_password: '#123455#123455Aa' + last_name: Test3 + email: mso4@cisco.com + phone: +32 478 436 299 + account_status: active + roles: + - name: powerUser + access_type: read + domain: Local + state: present + ignore_errors: yes + register: nm_add_user3 + +- name: Verify nm_add_user2 + 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: + <<: *user_present3 + user_password: '#123455#123455Aa' + register: nm_add_user3_again + +- name: Verify nm_add_user3_again + assert: + that: + - nm_add_user3_again is changed + - nm_add_user3_again.current.id is defined + - nm_add_user3_again.current.username == 'ansible_test_read_2' + - nm_add_user3_again.current.lastName == 'Test3' + - nm_add_user3_again.current.firstName == 'Ansible3' + - nm_add_user3_again.current.emailAddress == 'mso4@cisco.com' + - nm_add_user3_again.current.phoneNumber == '+32 478 436 299' + - nm_add_user3_again.current.accountStatus == 'active' + - nm_add_user3_again.current.roles[0].accessType == 'readOnly' + +# CHANGE USER +- name: Change user (check_mode) + mso_user: &user_change + 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(true) }}' + output_level: '{{ mso_output_level | default("info") }}' + user: ansible_test + roles: + - name: powerUser + access_type: write + domain: Local + state: present + # FIXME: Add support for name change + email: mso2@cisco.com + phone: +32 478 436 300 + check_mode: yes + register: cm_change_user + +- name: Verify cm_change_user + assert: + that: + - cm_change_user is changed + - cm_change_user.current.id == nm_add_user.current.id + - cm_change_user.current.username == 'ansible_test' + - cm_change_user.current.emailAddress == 'mso2@cisco.com' + - cm_change_user.current.phoneNumber == '+32 478 436 300' + +- name: Change user (normal mode) + mso_user: + <<: *user_change + output_level: debug + register: nm_change_user + +- name: Verify nm_change_user + assert: + that: + - nm_change_user is changed + - nm_change_user.current.id == nm_add_user.current.id + - nm_change_user.current.username == 'ansible_test' + - nm_change_user.current.emailAddress == 'mso2@cisco.com' + - nm_change_user.current.phoneNumber == '+32 478 436 300' + +- name: Change user again (check_mode) + mso_user: + <<: *user_change + check_mode: yes + register: cm_change_user_again + +- name: Verify cm_change_user_again + assert: + that: + - cm_change_user_again is not changed + - cm_change_user_again.current.id == nm_add_user.current.id + - cm_change_user_again.current.username == 'ansible_test' + - cm_change_user_again.current.emailAddress == 'mso2@cisco.com' + - cm_change_user_again.current.phoneNumber == '+32 478 436 300' + +- name: Change user again (normal mode) + mso_user: + <<: *user_change + register: nm_change_user_again + +- name: Verify nm_change_user_again + assert: + that: + - nm_change_user_again is not changed + - nm_change_user_again.current.id == nm_add_user.current.id + - nm_change_user_again.current.username == 'ansible_test' + - nm_change_user_again.current.emailAddress == 'mso2@cisco.com' + - nm_change_user_again.current.phoneNumber == '+32 478 436 300' + +- name: Add second user + mso_user: + <<: *user_change + user: ansible_test2 + user_password: 'S0m3!1n1t14l!p455w0rd' + first_name: Ansible + last_name: Test + roles: + - powerUser + state: present + register: nm_add_user_2 + +- name: Change user 2 again (normal mode) + mso_user: + <<: *user_change + user: ansible_test2 + user_password: null + first_name: Ansible + last_name: Test + register: nm_change_user_2_again + +- name: Verify nm_change_user_2_again + assert: + that: + - nm_change_user_2_again is not changed + - nm_change_user_2_again.current.id == nm_add_user_2.current.id + - nm_change_user_2_again.current.username == 'ansible_test2' + +# TODO: Add query with user ansible_test2 to try if user can login. + +# QUERY ALL USERS +- name: Query all users (check_mode) + mso_user: &user_query + 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(true) }}' + output_level: '{{ mso_output_level | default("info") }}' + state: query + check_mode: yes + register: cm_query_all_users + +- name: Query all users (normal mode) + mso_user: *user_query + register: nm_query_all_users + +- name: Verify query_all_users + assert: + that: + - cm_query_all_users is not changed + - nm_query_all_users is not changed + # NOTE: Order of users is not stable between calls + #- cm_query_all_users == nm_query_all_users + + +# QUERY A USER +- name: Query our user + mso_user: + <<: *user_query + user: ansible_test + check_mode: yes + register: cm_query_user + +- name: Query our user + mso_user: + <<: *user_query + user: ansible_test + register: nm_query_user + +- name: Verify query_user + assert: + that: + - cm_query_user is not changed + - cm_query_user.current.id == nm_add_user.current.id + - cm_query_user.current.username == 'ansible_test' + - nm_query_user is not changed + - nm_query_user.current.id == nm_add_user.current.id + - nm_query_user.current.username == 'ansible_test' + - cm_query_user == nm_query_user + +- name: Query our read-only user + mso_user: + <<: *user_query + user: ansible_test_read + register: nm_query_user2 + +- name: Verify query_user2 + 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: + <<: *user_absent + user: ansible_test + state: absent + check_mode: yes + register: cm_remove_user + +- name: Verify cm_remove_user + assert: + that: + - cm_remove_user is changed + - cm_remove_user.current == {} + +- name: Remove user (normal mode) + mso_user: + <<: *user_absent + user: ansible_test + state: absent + register: nm_remove_user + +- name: Verify nm_remove_user + assert: + that: + - nm_remove_user is changed + - nm_remove_user.current == {} + +- name: Remove user again (check_mode) + mso_user: + <<: *user_absent + user: ansible_test + state: absent + check_mode: yes + register: cm_remove_user_again + +- name: Verify cm_remove_user_again + assert: + that: + - cm_remove_user_again is not changed + - cm_remove_user_again.current == {} + +- name: Remove user again (normal mode) + mso_user: + <<: *user_absent + user: ansible_test + state: absent + register: nm_remove_user_again + +- name: Verify nm_remove_user_again + 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: + <<: *user_query + user: ansible_test + check_mode: yes + register: cm_query_non_user + +- name: Query non-existing user (normal mode) + mso_user: + <<: *user_query + user: ansible_test + register: nm_query_non_user + +# TODO: Implement more tests +- name: Verify query_non_user + assert: + that: + - cm_query_non_user is not changed + - nm_query_non_user is not changed + - cm_query_non_user == nm_query_non_user + +- name: inactive user (check_mode) + mso_user: + <<: *user_present + account_status: inactive + check_mode: yes + register: cm_inactive_user + +- name: inactive user (normal_mode) + mso_user: + <<: *user_present + account_status: inactive + register: nm_inactive_user + +- name: Verify cm_inactive_user and nm_inactive_user + 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: + <<: *user_present + account_status: active + check_mode: yes + register: cm_active_user + +- name: active user (normal_mode) + mso_user: + <<: *user_present + account_status: active + register: nm_active_user + +- name: Verify cm_active_user and nm_active_user + assert: + that: + - cm_active_user is changed + - nm_active_user is changed + - cm_active_user.previous.accountStatus == nm_active_user.previous.accountStatus == "inactive" + - cm_active_user.current.accountStatus == nm_active_user.current.accountStatus == "active" \ No newline at end of file diff --git a/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_version/aliases b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_version/aliases new file mode 100644 index 00000000..5042c9c0 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_version/aliases @@ -0,0 +1,2 @@ +# No ACI MultiSite infrastructure, so not enabled +# unsupported diff --git a/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_version/tasks/main.yml b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_version/tasks/main.yml new file mode 100644 index 00000000..5276c75e --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_version/tasks/main.yml @@ -0,0 +1,77 @@ +# Test code for the MSO modules +# Copyright: (c) 2020, Lionel Hercot (@lhercot) + +# 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.' + 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: + 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(true) }}' + output_level: '{{ mso_output_level | default("info") }}' + +# QUERY VERSION +- name: Query MSO version + mso_version: &mso_query + <<: *mso_info + state: query + check_mode: yes + register: cm_query_version + +- name: Verify cm_query_version + assert: + that: + - cm_query_version is not changed + - cm_query_version.current.id is defined + - cm_query_version.current.version is defined + - cm_query_version.current.timestamp is defined + +- name: Query MSO version (normal mode) + mso_version: + <<: *mso_query + register: nm_query_version + +- name: Verify nm_query_version + assert: + that: + - nm_query_version is not changed + - nm_query_version.current.id is defined + - nm_query_version.current.version is defined + - nm_query_version.current.timestamp is defined + - nm_query_version.current.id == cm_query_version.current.id + - nm_query_version.current.version == cm_query_version.current.version + - nm_query_version.current.timestamp == cm_query_version.current.timestamp + +# USE A NON-EXISTING STATE +- name: Non-existing state for version (check_mode) + mso_version: + <<: *mso_query + state: non-existing-state + check_mode: yes + ignore_errors: yes + register: cm_non_existing_state + +- name: Non-existing state for version (normal_mode) + mso_version: + <<: *mso_query + state: non-existing-state + ignore_errors: yes + register: nm_non_existing_state + +- name: Verify non_existing_state + assert: + that: + - cm_non_existing_state is not changed + - nm_non_existing_state is not changed + - cm_non_existing_state == nm_non_existing_state + - cm_non_existing_state.msg == nm_non_existing_state.msg == "value of state must be one of{{':'}} query, got{{':'}} non-existing-state" \ No newline at end of file diff --git a/collections-debian-merged/ansible_collections/cisco/mso/tests/sanity/ignore-2.10.txt b/collections-debian-merged/ansible_collections/cisco/mso/tests/sanity/ignore-2.10.txt new file mode 100644 index 00000000..1326ec6a --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/tests/sanity/ignore-2.10.txt @@ -0,0 +1,2 @@ +plugins/modules/mso_schema_template_bd.py validate-modules:invalid-ansiblemodule-schema +plugins/modules/mso_user.py validate-modules:parameter-list-no-elements \ No newline at end of file diff --git a/collections-debian-merged/ansible_collections/cisco/mso/tests/sanity/ignore-2.9.txt b/collections-debian-merged/ansible_collections/cisco/mso/tests/sanity/ignore-2.9.txt new file mode 100644 index 00000000..e69de29b diff --git a/collections-debian-merged/ansible_collections/cisco/mso/tests/sanity/requirements.txt b/collections-debian-merged/ansible_collections/cisco/mso/tests/sanity/requirements.txt new file mode 100644 index 00000000..66ac0c81 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/mso/tests/sanity/requirements.txt @@ -0,0 +1,5 @@ +packaging # needed for update-bundled and changelog +sphinx ; python_version >= '3.5' # docs build requires python 3+ +sphinx-notfound-page ; python_version >= '3.5' # docs build requires python 3+ +straight.plugin ; python_version >= '3.5' # needed for hacking/build-ansible.py which will host changelog generation and requires python 3+ +requests-toolbelt \ No newline at end of file -- cgit v1.2.3