summaryrefslogtreecommitdiffstats
path: root/collections-debian-merged/ansible_collections/cisco/mso/tests
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-14 20:03:01 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-14 20:03:01 +0000
commita453ac31f3428614cceb99027f8efbdb9258a40b (patch)
treef61f87408f32a8511cbd91799f9cececb53e0374 /collections-debian-merged/ansible_collections/cisco/mso/tests
parentInitial commit. (diff)
downloadansible-a453ac31f3428614cceb99027f8efbdb9258a40b.tar.xz
ansible-a453ac31f3428614cceb99027f8efbdb9258a40b.zip
Adding upstream version 2.10.7+merged+base+2.10.8+dfsg.upstream/2.10.7+merged+base+2.10.8+dfsgupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'collections-debian-merged/ansible_collections/cisco/mso/tests')
-rw-r--r--collections-debian-merged/ansible_collections/cisco/mso/tests/.gitignore1
-rw-r--r--collections-debian-merged/ansible_collections/cisco/mso/tests/integration/inventory.networking20
-rw-r--r--collections-debian-merged/ansible_collections/cisco/mso/tests/integration/network-integration.requirements.txt1
-rw-r--r--collections-debian-merged/ansible_collections/cisco/mso/tests/integration/target-prefixes.network1
-rw-r--r--collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_backup/aliases2
-rw-r--r--collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_backup/tasks/main.yml466
-rw-r--r--collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_dhcp_option_policy/aliases2
-rw-r--r--collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_dhcp_option_policy/tasks/main.yaml227
-rw-r--r--collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_dhcp_option_policy_option/aliases2
-rw-r--r--collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_dhcp_option_policy_option/tasks/main.yaml393
-rw-r--r--collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_dhcp_relay_policy/aliases2
-rw-r--r--collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_dhcp_relay_policy/tasks/main.yaml226
-rw-r--r--collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_dhcp_relay_policy_provider/aliases2
-rw-r--r--collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_dhcp_relay_policy_provider/tasks/main.yaml604
-rw-r--r--collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_label/aliases2
-rw-r--r--collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_label/tasks/main.yml339
-rw-r--r--collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_rest/aliases2
-rw-r--r--collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_rest/tasks/error_handling.yml145
-rw-r--r--collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_rest/tasks/json_inline.yml269
-rw-r--r--collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_rest/tasks/json_string.yml213
-rw-r--r--collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_rest/tasks/json_template.yml67
-rw-r--r--collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_rest/tasks/main.yml28
-rw-r--r--collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_rest/tasks/tenant.json.j210
-rw-r--r--collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_rest/tasks/yaml_inline.yml209
-rw-r--r--collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_rest/tasks/yaml_string.yml209
-rw-r--r--collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_role/aliases2
-rw-r--r--collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_role/tasks/main.yml43
-rw-r--r--collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_role/tasks/role-ro.yml88
-rw-r--r--collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_role/tasks/role-rw.yml275
-rw-r--r--collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema/aliases2
-rw-r--r--collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema/tasks/main.yml117
-rw-r--r--collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site/aliases2
-rw-r--r--collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site/tasks/main.yml253
-rw-r--r--collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_anp_epg_domain/aliases2
-rw-r--r--collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_anp_epg_domain/tasks/main.yml989
-rw-r--r--collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_anp_epg_selector/aliases2
-rw-r--r--collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_anp_epg_selector/tasks/main.yml1089
-rw-r--r--collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_anp_epg_staticport/aliases2
-rw-r--r--collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_anp_epg_staticport/tasks/main.yml859
-rw-r--r--collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_bd/aliases2
-rw-r--r--collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_bd/tasks/main.yml704
-rw-r--r--collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_bd_subnet/aliases2
-rw-r--r--collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_bd_subnet/tasks/main.yml592
-rw-r--r--collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_external_epg_selector/aliases2
-rw-r--r--collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_external_epg_selector/tasks/main.yml523
-rw-r--r--collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_vrf_region/aliases2
-rw-r--r--collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_vrf_region/tasks/main.yml433
-rw-r--r--collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_vrf_region_cidr/aliases2
-rw-r--r--collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_vrf_region_cidr/tasks/main.yml710
-rw-r--r--collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_vrf_region_cidr_subnet/aliases2
-rw-r--r--collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_vrf_region_cidr_subnet/tasks/main.yml676
-rw-r--r--collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_vrf_region_hub_network/aliases2
-rw-r--r--collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_vrf_region_hub_network/tasks/hub_network.yml708
-rw-r--r--collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_site_vrf_region_hub_network/tasks/main.yml32
-rw-r--r--collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template/aliases2
-rw-r--r--collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template/tasks/main.yml280
-rw-r--r--collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_anp/aliases2
-rw-r--r--collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_anp/tasks/main.yml265
-rw-r--r--collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_anp_epg/aliases2
-rw-r--r--collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_anp_epg/tasks/main.yml1192
-rw-r--r--collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_anp_epg_contract/aliases2
-rw-r--r--collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_anp_epg_contract/tasks/main.yml651
-rw-r--r--collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_anp_epg_selector/aliases2
-rw-r--r--collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_anp_epg_selector/tasks/main.yml789
-rw-r--r--collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_bd/aliases2
-rw-r--r--collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_bd/tasks/main.yml1171
-rw-r--r--collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_bd_subnet/aliases2
-rw-r--r--collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_bd_subnet/tasks/main.yml507
-rw-r--r--collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_contract_filter/aliases2
-rw-r--r--collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_contract_filter/tasks/main.yml1043
-rw-r--r--collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_deploy/aliases2
-rw-r--r--collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_deploy/tasks/main.yml199
-rw-r--r--collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_external_epg/aliases2
-rw-r--r--collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_external_epg/tasks/main.yml1110
-rw-r--r--collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_external_epg_contract/aliases2
-rw-r--r--collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_external_epg_contract/tasks/main.yml627
-rw-r--r--collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_external_epg_selector/aliases2
-rw-r--r--collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_external_epg_selector/tasks/main.yml454
-rw-r--r--collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_migrate/aliases2
-rw-r--r--collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_migrate/tasks/main.yml334
-rw-r--r--collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_vrf/aliases2
-rw-r--r--collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_vrf/tasks/main.yml518
-rw-r--r--collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_vrf_contract/aliases2
-rw-r--r--collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_schema_template_vrf_contract/tasks/main.yml859
-rw-r--r--collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_site/aliases2
-rw-r--r--collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_site/tasks/main.yml449
-rw-r--r--collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_tenant/aliases2
-rw-r--r--collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_tenant/tasks/main.yml541
-rw-r--r--collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_tenant_site/aliases2
-rw-r--r--collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_tenant_site/tasks/main.yml661
-rw-r--r--collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_user/aliases2
-rw-r--r--collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_user/tasks/main.yml522
-rw-r--r--collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_version/aliases2
-rw-r--r--collections-debian-merged/ansible_collections/cisco/mso/tests/integration/targets/mso_version/tasks/main.yml77
-rw-r--r--collections-debian-merged/ansible_collections/cisco/mso/tests/sanity/ignore-2.10.txt2
-rw-r--r--collections-debian-merged/ansible_collections/cisco/mso/tests/sanity/ignore-2.9.txt0
-rw-r--r--collections-debian-merged/ansible_collections/cisco/mso/tests/sanity/requirements.txt5
97 files changed, 23855 insertions, 0 deletions
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) <ssrish@cisco.com>
+
+# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- name: Test that we have an ACI MultiSite host, username and password
+ fail:
+ 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) <lhercot@cisco.com>
+# Copyright: (c) 2020, Jorge Gomez (@jgomezve) <jgomezve@cisco.com> (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) <lhercot@cisco.com>
+# Copyright: (c) 2020, Jorge Gomez (@jgomezve) <jgomezve@cisco.com> (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) <jgomezve@cisco.com>
+
+# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- name: Test that we have an ACI MultiSite host, username and password
+ fail:
+ 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) <cizhao@jgomezve.com>
+
+# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- name: Test that we have an ACI MultiSite host, username and password
+ fail:
+ 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) <dag@wieers.com>
+
+# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- name: Test that we have an ACI MultiSite host, username and password
+ fail:
+ 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) <anvjain@cisco.com>
+#
+
+# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- name: Test that we have an ACI MultiSite host, username and password
+ fail:
+ 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) <anvjain@cisco.com>
+#
+
+# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- name: Test that we have an ACI MultiSite host, username and password
+ fail:
+ 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) <anvjain@cisco.com>
+#
+
+# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- name: Test that we have an ACI MultiSite host, username and password
+ fail:
+ 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) <anvjain@cisco.com>
+#
+
+# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- name: Test that we have an ACI MultiSite host, username and password
+ fail:
+ 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) <anvjain@cisco.com>
+#
+
+# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- name: Test that we have an ACI MultiSite host, username and password
+ fail:
+ 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) <anvjain@cisco.com>
+#
+
+# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- name: Test that we have an ACI MultiSite host, username and password
+ fail:
+ 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) <anvjain@cisco.com>
+#
+
+# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- name: Test that we have an ACI MultiSite host, username and password
+ fail:
+ 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) <lhercot@cisco.com>
+
+# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- name: Test that we have an ACI MultiSite host, username and password
+ fail:
+ 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) <dag@wieers.com>
+# Copyright: (c) 2020, Lionel Hercot (@lhercot) <lhercot@cisco.com>
+
+# 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) <dag@wieers.com>
+# Copyright: (c) 2020, Lionel Hercot (@lhercot) <lhercot@cisco.com>
+
+# 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) <cizhao@cisco.com>
+
+# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- name: Test that we have an ACI MultiSite host, username and password
+ fail:
+ 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) <ssrish@cisco.com>
+
+# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- name: Test that we have an ACI MultiSite host, username and password
+ fail:
+ 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) <lhercot@cisco.com>
+# Copyright: (c) 2018, Dag Wieers (@dagwieers) <dag@wieers.com> (based on mso_site test case)
+# Copyright: (c) 2020, Shreyas Srish (@shrsr) <ssrish@cisco.com>
+
+# 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) <cizhao@cisco.com>
+# Copyright: (c) 2020, Lionel Hercot (@lhercot) <lhercot@cisco.com>
+# Copyright: (c) 2018, Dag Wieers (@dagwieers) <dag@wieers.com> (based on mso_site test case)
+
+# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- name: Test that we have an ACI MultiSite host, username and password
+ fail:
+ 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) <lhercot@cisco.com>
+# Copyright: (c) 2018, Dag Wieers (@dagwieers) <dag@wieers.com> (based on mso_site test case)
+# Copyright: (c) 2020, Shreyas Srish (@shrsr) <ssrish@cisco.com>
+
+# 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) <lhercot@cisco.com>
+# Copyright: (c) 2018, Dag Wieers (@dagwieers) <dag@wieers.com> (based on mso_site test case)
+# Copyright: (c) 2020, Shreyas Srish (@shrsr) <ssrish@cisco.com>
+# Copyright: (c) 2020, Cindy Zhao (@cizhao) <cizhao@cisco.com>
+
+# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- name: Test that we have an ACI MultiSite host, username and password
+ fail:
+ 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) <cizhao@cisco.com>
+
+# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- name: Test that we have an ACI MultiSite host, username and password
+ fail:
+ 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) <lhercot@cisco.com>
+# Copyright: (c) 2018, Dag Wieers (@dagwieers) <dag@wieers.com> (based on mso_site test case)
+# Copyright: (c) 2020, Shreyas Srish (@shrsr) <ssrish@cisco.com>
+
+# 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) <cizhao@cisco.com>
+# 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) <lhercot@cisco.com>
+# Copyright: (c) 2020, Shreyas Srish (@shrsr) <ssrish@cisco.com> (based on mso_schema_anp_epg_domain)
+# Copyright: (c) 2018, Dag Wieers (@dagwieers) <dag@wieers.com> (based on mso_site test case)
+
+
+# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- name: Test that we have an ACI MultiSite host, username and password
+ fail:
+ 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) <lhercot@cisco.com>
+# Copyright: (c) 2020, Shreyas Srish (@shrsr) <ssrish@cisco.com> (based on mso_schema_anp_epg_domain)
+# Copyright: (c) 2018, Dag Wieers (@dagwieers) <dag@wieers.com> (based on mso_site test case)
+
+
+# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- name: Test that we have an ACI MultiSite host, username and password
+ fail:
+ 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) <lhercot@cisco.com>
+# Copyright: (c) 2020, Cindy Zhao (@cizhao) <cizhao@cisco.com>
+
+# 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) <lhercot@cisco.com>
+# Copyright: (c) 2020, Cindy Zhao (@cizhao) <cizhao@cisco.com>
+
+# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- name: Test that we have an ACI MultiSite host, username and password
+ fail:
+ 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) <ssrish@cisco.com>
+
+# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- name: Test that we have an ACI MultiSite host, username and password
+ fail:
+ 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) <cizhao@cisco.com>
+
+# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- name: Test that we have an ACI MultiSite host, username and password
+ fail:
+ 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) <lhercot@cisco.com>
+# Copyright: (c) 2018, Dag Wieers (@dagwieers) <dag@wieers.com> (based on mso_site test case)
+#
+
+# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- name: Test that we have an ACI MultiSite host, username and password
+ fail:
+ 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) <lhercot@cisco.com>
+# Copyright: (c) 2018, Dag Wieers (@dagwieers) <dag@wieers.com> (based on mso_site test case)
+#
+
+# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- name: Test that we have an ACI MultiSite host, username and password
+ fail:
+ 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) <lhercot@cisco.com>
+# Copyright: (c) 2018, Dag Wieers (@dagwieers) <dag@wieers.com> (based on mso_site test case)
+#
+
+# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- name: Test that we have an ACI MultiSite host, username and password
+ fail:
+ 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) <lhercot@cisco.com>
+# Copyright: (c) 2018, Dag Wieers (@dagwieers) <dag@wieers.com> (based on mso_site test case)
+#
+
+# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- name: Test that we have an ACI MultiSite host, username and password
+ fail:
+ 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) <lhercot@cisco.com>
+# Copyright: (c) 2018, Dag Wieers (@dagwieers) <dag@wieers.com> (based on mso_site test case)
+#
+
+# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- name: Test that we have an ACI MultiSite host, username and password
+ fail:
+ 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) <cizhao@cisco.com>
+# Copyright: (c) 2020, Lionel Hercot (@lhercot) <lhercot@cisco.com>
+# Copyright: (c) 2018, Dag Wieers (@dagwieers) <dag@wieers.com> (based on mso_site test case)
+#
+
+# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- name: Test that we have an ACI MultiSite host, username and password
+ fail:
+ 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) <cizhao@cisco.com>
+
+# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- name: Test that we have an ACI MultiSite host, username and password
+ fail:
+ 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) <cizhao@cisco.com>
+# Copyright: (c) 2020, Lionel Hercot (@lhercot) <lhercot@cisco.com>
+# Copyright: (c) 2018, Dag Wieers (@dagwieers) <dag@wieers.com> (based on mso_site test case)
+#
+
+# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- name: Test that we have an ACI MultiSite host, username and password
+ fail:
+ 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) <lhercot@cisco.com>
+# Copyright: (c) 2018, Dag Wieers (@dagwieers) <dag@wieers.com> (based on mso_site test case)
+#
+
+# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- name: Test that we have an ACI MultiSite host, username and password
+ fail:
+ 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) <lhercot@cisco.com>
+# Copyright: (c) 2018, Dag Wieers (@dagwieers) <dag@wieers.com> (based on mso_site test case)
+# Copyright: (c) 2020, Shreyas Srish (@shrsr) <ssrish@cisco.com>
+
+# 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) <anvjain@cisco.com>
+#
+
+# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- name: Test that we have an ACI MultiSite host, username and password
+ fail:
+ 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) <cizhao@cisco.com>
+# Copyright: (c) 2020, Lionel Hercot (@lhercot) <lhercot@cisco.com>
+# Copyright: (c) 2018, Dag Wieers (@dagwieers) <dag@wieers.com> (based on mso_site test case)
+#
+
+# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- name: Test that we have an ACI MultiSite host, username and password
+ fail:
+ 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) <cizhao@cisco.com>
+# Copyright: (c) 2020, Lionel Hercot (@lhercot) <lhercot@cisco.com>
+# Copyright: (c) 2018, Dag Wieers (@dagwieers) <dag@wieers.com> (based on mso_site test case)
+#
+
+# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- name: Test that we have an ACI MultiSite host, username and password
+ fail:
+ 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) <dag@wieers.com>
+
+# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- name: Test that we have an ACI MultiSite host, username and password
+ fail:
+ 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) <dag@wieers.com>
+# Copyright: (c) 2020, Cindy Zhao (@cizhao) <cizhao@cisco.com>
+# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- name: Test that we have an ACI MultiSite host, username and password
+ fail:
+ 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) <dag@wieers.com> (based on mso_site test case)
+# Copyright: (c) 2020, Lionel Hercot (@lhercot) <lhercot@cisco.com>
+# Copyright: (c) 2020, Shreyas Srish (@shrsr) <ssrish@cisco.com>
+
+# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- name: Test that we have an ACI MultiSite host, username and password
+ fail:
+ 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) <dag@wieers.com>
+
+# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- name: Test that we have an ACI MultiSite host, username and password
+ fail:
+ 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) <lhercot@cisco.com>
+
+# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- name: Test that we have an ACI MultiSite host, username and password
+ fail:
+ 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
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/cisco/mso/tests/sanity/ignore-2.9.txt
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