diff options
Diffstat (limited to 'ansible_collections/cisco/aci/tests')
356 files changed, 22468 insertions, 3340 deletions
diff --git a/ansible_collections/cisco/aci/tests/integration/inventory.networking b/ansible_collections/cisco/aci/tests/integration/inventory.networking index 357f58758..9e17071d0 100644 --- a/ansible_collections/cisco/aci/tests/integration/inventory.networking +++ b/ansible_collections/cisco/aci/tests/integration/inventory.networking @@ -1,13 +1,13 @@ [aci] cn-dmz-apic-m1-02-v42 ansible_host=173.36.219.68 aci_hostname=173.36.219.68 cn-dmz-apic-m1-03-v52 ansible_host=173.36.219.69 aci_hostname=173.36.219.69 -cn-dmz-apic-m1-04-v60 ansible_host=173.36.219.70 aci_hostname=173.36.219.70 -cn-dmz-apic-m1-07-v32 ansible_host=173.36.219.73 aci_hostname=173.36.219.73 +cn-dmz-apic-m1-04-v602h ansible_host=173.36.219.70 aci_hostname=173.36.219.70 aws_cloud ansible_host=52.52.20.121 aci_hostname=52.52.20.121 cloud_type=aws region=us-east-1 region_2=us-west-1 availability_zone=us-west-1a -azure_cloud ansible_host=20.245.236.136 aci_hostname=20.245.236.136 cloud_type=azure region=westus region_2=westus2 vnet_gateway=true +azure_cloud ansible_host=20.245.236.136 aci_hostname=20.245.236.136 cloud_type=azure region=westus region_2=westus2 vnet_gateway=true az_region=westus2 [aci:vars] aci_username=ansible_github_ci +aci_remote_username="apic:test\\r_ansible_github_ci" aci_password="sJ94G92#8dq2hx*K4qh" ansible_network_os=cisco.aci.aci ansible_connection=local diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_aaa_certificate_authority/aliases b/ansible_collections/cisco/aci/tests/integration/targets/aci_aaa_certificate_authority/aliases new file mode 100644 index 000000000..209b793f9 --- /dev/null +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_aaa_certificate_authority/aliases @@ -0,0 +1,2 @@ +# No ACI simulator yet, so not enabled +# unsupported diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_aaa_certificate_authority/pki/admin.crt b/ansible_collections/cisco/aci/tests/integration/targets/aci_aaa_certificate_authority/pki/admin.crt new file mode 100644 index 000000000..cfac5531e --- /dev/null +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_aaa_certificate_authority/pki/admin.crt @@ -0,0 +1,14 @@ +-----BEGIN CERTIFICATE----- +MIICODCCAaGgAwIBAgIJAIt8XMntue0VMA0GCSqGSIb3DQEBCwUAMDQxDjAMBgNV +BAMMBUFkbWluMRUwEwYDVQQKDAxZb3VyIENvbXBhbnkxCzAJBgNVBAYTAlVTMCAX +DTE4MDEwOTAwNTk0NFoYDzIxMTcxMjE2MDA1OTQ0WjA0MQ4wDAYDVQQDDAVBZG1p +bjEVMBMGA1UECgwMWW91ciBDb21wYW55MQswCQYDVQQGEwJVUzCBnzANBgkqhkiG +9w0BAQEFAAOBjQAwgYkCgYEAohG/7axtt7CbSaMP7r+2mhTKbNgh0Ww36C7Ta14i +v+VmLyKkQHnXinKGhp6uy3Nug+15a+eIu7CrgpBVMQeCiWfsnwRocKcQJWIYDrWl +XHxGQn31yYKR6mylE7Dcj3rMFybnyhezr5D8GcP85YRPmwG9H2hO/0Y1FUnWu9Iw +AQkCAwEAAaNQME4wHQYDVR0OBBYEFD0jLXfpkrU/ChzRvfruRs/fy1VXMB8GA1Ud +IwQYMBaAFD0jLXfpkrU/ChzRvfruRs/fy1VXMAwGA1UdEwQFMAMBAf8wDQYJKoZI +hvcNAQELBQADgYEAOmvre+5tgZ0+F3DgsfxNQqLTrGiBgGCIymPkP/cBXXkNuJyl +3ac7tArHQc7WEA4U2R2rZbEq8FC3UJJm4nUVtCPvEh3G9OhN2xwYev79yt6pIn/l +KU0Td2OpVyo0eLqjoX5u2G90IBWzhyjFbo+CcKMrSVKj1YOdG0E3OuiJf00= +-----END CERTIFICATE----- diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_aaa_certificate_authority/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_aaa_certificate_authority/tasks/main.yml new file mode 100644 index 000000000..15cdeeb60 --- /dev/null +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_aaa_certificate_authority/tasks/main.yml @@ -0,0 +1,305 @@ +# Test code for the ACI modules +# Copyright: (c) 2024, Akini Ross (@akinross) <akinross@cisco.com> +# +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +- name: Test that we have an ACI APIC host, ACI username and ACI password + ansible.builtin.fail: + msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' + when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined + +- name: Set vars + ansible.builtin.set_fact: + aci_info: &aci_info + host: "{{ aci_hostname }}" + username: "{{ aci_username }}" + password: "{{ aci_password }}" + validate_certs: '{{ aci_validate_certs | default(false) }}' + use_ssl: '{{ aci_use_ssl | default(true) }}' + use_proxy: '{{ aci_use_proxy | default(true) }}' + output_level: '{{ aci_use_proxy | default("debug") }}' + +- name: Verify Cloud and Non-Cloud Sites in use. + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + +# CLEAN ENVIRONMENT +- name: Clean certificate_authority_1 + cisco.aci.aci_aaa_certificate_authority: &certificate_authority_1_absent + <<: *aci_info + name: certificate_authority_1 + state: absent + +- name: Clean certificate_authority_2 + cisco.aci.aci_aaa_certificate_authority: &certificate_authority_2_absent + <<: *aci_info + name: certificate_authority_2 + state: absent + register: result + until: result is not failed + delay: 2 + retries: 4 + +# CREATE +- name: Create a certificate authority (check_mode) + cisco.aci.aci_aaa_certificate_authority: &certificate_authority_1_present + <<: *certificate_authority_1_absent + certificate_chain: "{{ lookup('file', 'pki/admin.crt') }}" + state: present + check_mode: true + register: cm_create_certificate_authority_1 + +- name: Create a certificate authority + cisco.aci.aci_aaa_certificate_authority: + <<: *certificate_authority_1_present + register: nm_create_certificate_authority_1 + until: nm_create_certificate_authority_1 is not failed + delay: 2 + retries: 4 + +- name: Create a certificate authority again + cisco.aci.aci_aaa_certificate_authority: + <<: *certificate_authority_1_present + register: nm_create_certificate_authority_1_again + until: nm_create_certificate_authority_1_again is not failed + delay: 2 + retries: 4 + +- name: Assertions for creating a certificate authority + ansible.builtin.assert: + that: + - cm_create_certificate_authority_1 is changed + - cm_create_certificate_authority_1.previous == [] + - cm_create_certificate_authority_1.current == [] + - cm_create_certificate_authority_1.proposed.pkiTP.attributes.name == "certificate_authority_1" + - nm_create_certificate_authority_1 is changed + - nm_create_certificate_authority_1.previous == [] + - nm_create_certificate_authority_1.current.0.pkiTP.attributes.name == "certificate_authority_1" + - nm_create_certificate_authority_1.current.0.pkiTP.attributes.descr == "" + - nm_create_certificate_authority_1_again is not changed + - nm_create_certificate_authority_1_again.previous.0.pkiTP.attributes.name == "certificate_authority_1" + - nm_create_certificate_authority_1_again.previous.0.pkiTP.attributes.descr == "" + - nm_create_certificate_authority_1_again.current.0.pkiTP.attributes.name == "certificate_authority_1" + - nm_create_certificate_authority_1_again.current.0.pkiTP.attributes.descr == "" + +# UPDATE +- name: Update an existing certificate authority + cisco.aci.aci_aaa_certificate_authority: + <<: *certificate_authority_1_present + description: "This is a changed description." + register: nm_update_certificate_authority_1 + until: nm_update_certificate_authority_1 is not failed + delay: 2 + retries: 4 + +- name: Assertions for updating a certificate authority + ansible.builtin.assert: + that: + - nm_update_certificate_authority_1 is changed + - nm_update_certificate_authority_1.previous.0.pkiTP.attributes.name == "certificate_authority_1" + - nm_update_certificate_authority_1.previous.0.pkiTP.attributes.descr == "" + - nm_update_certificate_authority_1.current.0.pkiTP.attributes.name == "certificate_authority_1" + - nm_update_certificate_authority_1.current.0.pkiTP.attributes.descr == "This is a changed description." + +- name: Execute tasks only for cloud sites + when: query_cloud.current != [] # This condition will execute only non-cloud sites + block: # block specifies execution of tasks within, based on conditions + - name: Delete certificate authority for cloud site tenant + cisco.aci.aci_aaa_certificate_authority: &certificate_authority_cloud_absent + <<: *certificate_authority_1_present + cloud_tenant: cloud_tenant + name: certificate_authority_cloud + state: absent + register: nm_delete_certificate_authority_1_cloud + until: nm_delete_certificate_authority_1_cloud is not failed + delay: 2 + retries: 4 + + - name: Create tenant for cloud site + cisco.aci.aci_tenant: &cloud_tenant + <<: *aci_info + name: cloud_tenant + register: cloud_tenant + until: cloud_tenant is not failed + delay: 2 + retries: 4 + + - name: Create certificate authority for cloud site tenant (check_mode) + cisco.aci.aci_aaa_certificate_authority: &certificate_authority_cloud_present + <<: *certificate_authority_cloud_absent + state: present + check_mode: true + register: cm_create_certificate_authority_1_cloud + until: cm_create_certificate_authority_1_cloud is not failed + delay: 2 + retries: 4 + + - name: Create certificate authority for cloud site tenant + cisco.aci.aci_aaa_certificate_authority: + <<: *certificate_authority_cloud_present + register: nm_create_certificate_authority_1_cloud + until: nm_create_certificate_authority_1_cloud is not failed + delay: 2 + retries: 4 + + - name: Create certificate authority for cloud site tenant again + cisco.aci.aci_aaa_certificate_authority: + <<: *certificate_authority_cloud_present + register: nm_create_certificate_authority_1_cloud_again + until: nm_create_certificate_authority_1_cloud is not failed + delay: 2 + retries: 4 + + - name: Verify certificate authority is created in cloud tenant + ansible.builtin.assert: + that: + - cm_create_certificate_authority_1_cloud is changed + - cm_create_certificate_authority_1_cloud.previous == [] + - cm_create_certificate_authority_1_cloud.current == [] + - cm_create_certificate_authority_1_cloud.proposed.pkiTP.attributes.name == "certificate_authority_cloud" + - '"tn-cloud_tenant/certstore/tp-certificate_authority_cloud" in cm_create_certificate_authority_1_cloud.url' + - nm_create_certificate_authority_1_cloud is changed + - nm_create_certificate_authority_1_cloud.previous == [] + - nm_create_certificate_authority_1_cloud.current.0.pkiTP.attributes.name == "certificate_authority_cloud" + - nm_create_certificate_authority_1_cloud.current.0.pkiTP.attributes.descr == "" + - '"tn-cloud_tenant/certstore/tp-certificate_authority_cloud" in nm_create_certificate_authority_1_cloud.url' + - nm_create_certificate_authority_1_cloud_again is not changed + - nm_create_certificate_authority_1_cloud_again.previous.0.pkiTP.attributes.name == "certificate_authority_cloud" + - nm_create_certificate_authority_1_cloud_again.previous.0.pkiTP.attributes.descr == "" + - nm_create_certificate_authority_1_cloud_again.current.0.pkiTP.attributes.name == "certificate_authority_cloud" + - nm_create_certificate_authority_1_cloud_again.current.0.pkiTP.attributes.descr == "" + - '"tn-cloud_tenant/certstore/tp-certificate_authority_cloud" in nm_create_certificate_authority_1_cloud_again.url' + + - name: Delete certificate authority for cloud site tenant (check_mode) + cisco.aci.aci_aaa_certificate_authority: + <<: *certificate_authority_cloud_absent + check_mode: true + register: cm_delete_certificate_authority_1_cloud + until: cm_delete_certificate_authority_1_cloud is not failed + delay: 2 + retries: 4 + + - name: Delete certificate authority for cloud site tenant + cisco.aci.aci_aaa_certificate_authority: + <<: *certificate_authority_cloud_absent + register: nm_delete_certificate_authority_1_cloud + until: nm_delete_certificate_authority_1_cloud is not failed + delay: 2 + retries: 4 + + - name: Delete certificate authority for cloud site tenant again + cisco.aci.aci_aaa_certificate_authority: + <<: *certificate_authority_cloud_absent + register: nm_delete_certificate_authority_1_cloud_again + until: nm_delete_certificate_authority_1_cloud_again is not failed + delay: 2 + retries: 4 + + - name: Verify certificate authority is deleted in cloud tenant + ansible.builtin.assert: + that: + - cm_delete_certificate_authority_1_cloud is changed + - cm_delete_certificate_authority_1_cloud.proposed == {} + - cm_delete_certificate_authority_1_cloud.previous.0.pkiTP.attributes.name == "certificate_authority_cloud" + - cm_delete_certificate_authority_1_cloud.previous.0.pkiTP.attributes.descr == "" + - cm_delete_certificate_authority_1_cloud.current.0.pkiTP.attributes.name == "certificate_authority_cloud" + - cm_delete_certificate_authority_1_cloud.current.0.pkiTP.attributes.descr == "" + - '"tn-cloud_tenant/certstore/tp-certificate_authority_cloud" in cm_delete_certificate_authority_1_cloud.url' + - nm_delete_certificate_authority_1_cloud is changed + - nm_delete_certificate_authority_1_cloud.previous.0.pkiTP.attributes.name == "certificate_authority_cloud" + - nm_delete_certificate_authority_1_cloud.previous.0.pkiTP.attributes.descr == "" + - nm_delete_certificate_authority_1_cloud.current == [] + - '"tn-cloud_tenant/certstore/tp-certificate_authority_cloud" in nm_delete_certificate_authority_1_cloud.url' + - nm_delete_certificate_authority_1_cloud_again is not changed + - nm_delete_certificate_authority_1_cloud_again.previous == [] + - nm_delete_certificate_authority_1_cloud_again.current == [] + - '"tn-cloud_tenant/certstore/tp-certificate_authority_cloud" in nm_delete_certificate_authority_1_cloud_again.url' + + - name: Delete tenant for cloud site + cisco.aci.aci_tenant: + <<: *cloud_tenant + state: absent + register: cloud_tenant + until: cloud_tenant is not failed + delay: 2 + retries: 4 + +# QUERY +- name: Create another certificate authority + cisco.aci.aci_aaa_certificate_authority: + <<: *certificate_authority_2_absent + certificate_chain: "{{ lookup('file', 'pki/admin.crt') }}" + state: present + register: nm_create_certificate_authority_2 + until: nm_create_certificate_authority_2 is not failed + delay: 2 + retries: 4 + +- name: Query a certificate authority + cisco.aci.aci_aaa_certificate_authority: + <<: *certificate_authority_1_present + state: query + register: query_certificate_authority_1 + until: query_certificate_authority_1 is not failed + delay: 2 + retries: 4 + +- name: Query all fabric management access policies + cisco.aci.aci_aaa_certificate_authority: + <<: *aci_info + state: query + register: query_all + +- name: Assertions for querying fabric management access policies + ansible.builtin.assert: + that: + - query_certificate_authority_1 is not changed + - query_certificate_authority_1.current.0.pkiTP.attributes.name == "certificate_authority_1" + - query_certificate_authority_1.current.0.pkiTP.attributes.descr == "This is a changed description." + - query_certificate_authority_1.current | length == 1 + - query_all is not changed + - query_all.current | length >= 2 + +# DELETE +- name: Delete a certificate authority (check_mode) + cisco.aci.aci_aaa_certificate_authority: + <<: *certificate_authority_1_absent + check_mode: true + register: cm_delete_certificate_authority_1 + +- name: Delete a certificate authority + cisco.aci.aci_aaa_certificate_authority: + <<: *certificate_authority_1_absent + register: nm_delete_certificate_authority_1 + until: nm_delete_certificate_authority_1 is not failed + delay: 2 + retries: 4 + +- name: Delete a certificate authority again + cisco.aci.aci_aaa_certificate_authority: + <<: *certificate_authority_1_absent + register: nm_delete_certificate_authority_1_again + until: nm_delete_certificate_authority_1_again is not failed + delay: 2 + retries: 4 + +- name: Assertions for deleting a certificate authority + ansible.builtin.assert: + that: + - cm_delete_certificate_authority_1 is changed + - cm_delete_certificate_authority_1.proposed == {} + - cm_delete_certificate_authority_1.previous.0.pkiTP.attributes.name == "certificate_authority_1" + - cm_delete_certificate_authority_1.previous.0.pkiTP.attributes.descr == "This is a changed description." + - cm_delete_certificate_authority_1.current.0.pkiTP.attributes.name == "certificate_authority_1" + - cm_delete_certificate_authority_1.current.0.pkiTP.attributes.descr == "This is a changed description." + - nm_delete_certificate_authority_1 is changed + - nm_delete_certificate_authority_1.previous.0.pkiTP.attributes.name == "certificate_authority_1" + - nm_delete_certificate_authority_1.previous.0.pkiTP.attributes.descr == "This is a changed description." + - nm_delete_certificate_authority_1.current == [] + - nm_delete_certificate_authority_1_again is not changed + - nm_delete_certificate_authority_1_again.previous == [] + - nm_delete_certificate_authority_1_again.current == [] + +# CLEAN ENVIRONMENT +- name: Delete another certificate authority + cisco.aci.aci_aaa_certificate_authority: + <<: *certificate_authority_2_absent diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_aaa_custom_privilege/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_aaa_custom_privilege/tasks/main.yml index 04b7070e2..907d21772 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_aaa_custom_privilege/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_aaa_custom_privilege/tasks/main.yml @@ -4,13 +4,13 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined # SET VARS - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: '{{ aci_hostname }}' username: '{{ aci_username }}' @@ -47,7 +47,7 @@ register: cm_cp_present - name: Assertions check for add a custom privilege with check mode - assert: + ansible.builtin.assert: that: - cm_cp_present is changed - cm_cp_present.current | length == 0 @@ -63,7 +63,7 @@ register: nm_cp_present - name: Assertions check for add a custom privilege with normal mode - assert: + ansible.builtin.assert: that: - nm_cp_present is changed - nm_cp_present.current | length == 1 @@ -79,7 +79,7 @@ register: idempotency_cp_present - name: Idempotency assertions check for add a custom privilege with normal mode - assert: + ansible.builtin.assert: that: - idempotency_cp_present is not changed - idempotency_cp_present.current | length == 1 @@ -106,7 +106,7 @@ register: cp_with_none_priv - name: Assertions check for add a custom privilege with none privileges - assert: + ansible.builtin.assert: that: - cp_with_none_priv is changed - cp_with_none_priv.current | length == 1 @@ -123,7 +123,7 @@ register: update_cp_with_priv - name: Assertions check for update fv_tenant_present custom privilege with 'custom-privilege-2' privilege - assert: + ansible.builtin.assert: that: - update_cp_with_priv is changed - update_cp_with_priv.current | length == 1 @@ -141,7 +141,7 @@ register: update_cp_w_priv_check - name: Assertions check for update fv_tenant_present - write_privilege to 'custom-privilege-3' privilege - assert: + ansible.builtin.assert: that: - update_cp_w_priv_check is changed - update_cp_w_priv_check.current | length == 1 @@ -161,7 +161,7 @@ register: query_a_cp_with_name - name: Assertions check for query a custom privilege with name - assert: + ansible.builtin.assert: that: - query_a_cp_with_name is not changed - query_a_cp_with_name.current | length == 1 @@ -176,7 +176,7 @@ register: query_all_cp - name: Assertions check for query all custom privileges - assert: + ansible.builtin.assert: that: - query_all_cp is not changed - query_all_cp.current | length >= 2 @@ -190,7 +190,7 @@ register: cm_cp_absent - name: Assertions check for remove a custom privilege with check mode - assert: + ansible.builtin.assert: that: - cm_cp_absent is changed - cm_cp_absent.current | length == 1 @@ -204,7 +204,7 @@ register: nm_cp_absent - name: Assertions check for remove a custom privilege with normal mode - assert: + ansible.builtin.assert: that: - nm_cp_absent is changed - nm_cp_absent.current == [] @@ -217,7 +217,7 @@ register: idempotency_cp_absent - name: Idempotency assertions check for remove a custom privilege with normal mode - assert: + ansible.builtin.assert: that: - idempotency_cp_absent is not changed - idempotency_cp_absent.current == [] @@ -231,7 +231,7 @@ register: removed_cp_query_result - name: Assertions check for Removed custom privilege with name - assert: + ansible.builtin.assert: that: - removed_cp_query_result is not changed - removed_cp_query_result.current == [] diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_aaa_domain/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_aaa_domain/tasks/main.yml index 55eaaff79..06bd25d78 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_aaa_domain/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_aaa_domain/tasks/main.yml @@ -4,13 +4,13 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined # SET VARS - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: '{{ aci_hostname }}' username: '{{ aci_username }}' @@ -42,7 +42,7 @@ register: cm_sec_domain_present - name: Assertions check for add anstest_sec_domain security domain with check mode - assert: + ansible.builtin.assert: that: - cm_sec_domain_present is changed - cm_sec_domain_present.current | length == 0 @@ -55,7 +55,7 @@ register: nm_sec_domain_present - name: Assertions check for add anstest_sec_domain security domain with normal mode - assert: + ansible.builtin.assert: that: - nm_sec_domain_present is changed - nm_sec_domain_present.current | length == 1 @@ -63,7 +63,7 @@ - nm_sec_domain_present.current.0.aaaDomain.attributes.name == 'anstest_sec_domain' - name: Assertions check for nm_sec_domain_present in v5.0+ - assert: + ansible.builtin.assert: that: - nm_sec_domain_present.current.0.aaaDomain.attributes.restrictedRbacDomain == 'no' when: version.current.0.topSystem.attributes.version is version('5', '>=') @@ -74,7 +74,7 @@ register: idempotency_sec_domain_present - name: Idempotency assertions check for add anstest_sec_domain security domain with normal mode - assert: + ansible.builtin.assert: that: - idempotency_sec_domain_present is not changed - idempotency_sec_domain_present.current | length == 1 @@ -83,7 +83,7 @@ - idempotency_sec_domain_present.previous.0.aaaDomain.attributes.name == 'anstest_sec_domain' - name: Assertions check for idempotency_sec_domain_present in v5.0+ - assert: + ansible.builtin.assert: that: - idempotency_sec_domain_present.current.0.aaaDomain.attributes.restrictedRbacDomain == 'no' - idempotency_sec_domain_present.previous.0.aaaDomain.attributes.restrictedRbacDomain == 'no' @@ -99,7 +99,7 @@ register: update_sec_domain_present_true - name: Assertions check for update anstest_sec_domain security domain restricted_rbac_domain state to true - assert: + ansible.builtin.assert: that: - update_sec_domain_present_true is changed - update_sec_domain_present_true.current | length == 1 @@ -116,7 +116,7 @@ register: update_sec_domain_present_false - name: Assertions check for update anstest_sec_domain security domain restricted_rbac_domain state to false - assert: + ansible.builtin.assert: that: - update_sec_domain_present_false is changed - update_sec_domain_present_false.current | length == 1 @@ -134,7 +134,7 @@ register: query_sec_domain_with_name - name: Assertions check for query a security domain with name - assert: + ansible.builtin.assert: that: - query_sec_domain_with_name is not changed - query_sec_domain_with_name.current | length == 1 @@ -142,7 +142,7 @@ - query_sec_domain_with_name.current.0.aaaDomain.attributes.descr == 'Anstest Sec Domain Descr' - name: Assertions check for query_sec_domain_with_name in v5.0+ - assert: + ansible.builtin.assert: that: - query_sec_domain_with_name.current.0.aaaDomain.attributes.restrictedRbacDomain == 'no' when: version.current.0.topSystem.attributes.version is version('5', '>=') @@ -154,7 +154,7 @@ register: query_all_sec_domains - name: Assertions check for query all security domains - assert: + ansible.builtin.assert: that: - query_all_sec_domains is not changed - query_all_sec_domains.current | length >= 1 @@ -167,7 +167,7 @@ register: cm_sec_domain_absent - name: Assertions check for remove anstest_sec_domain security domain with check mode - assert: + ansible.builtin.assert: that: - cm_sec_domain_absent is changed - cm_sec_domain_absent.current | length == 1 @@ -176,7 +176,7 @@ - cm_sec_domain_absent.previous.0.aaaDomain.attributes.name == 'anstest_sec_domain' - name: Assertions check for cm_sec_domain_absent in v5.0+ - assert: + ansible.builtin.assert: that: - cm_sec_domain_absent.current.0.aaaDomain.attributes.restrictedRbacDomain == 'no' - cm_sec_domain_absent.previous.0.aaaDomain.attributes.restrictedRbacDomain == 'no' @@ -188,7 +188,7 @@ register: nm_sec_domain_absent - name: Assertions check for remove anstest_sec_domain security domain with normal mode - assert: + ansible.builtin.assert: that: - nm_sec_domain_absent is changed - nm_sec_domain_absent.current | length == 0 @@ -196,7 +196,7 @@ - nm_sec_domain_absent.previous.0.aaaDomain.attributes.name == 'anstest_sec_domain' - name: Assertions check for nm_sec_domain_absent in v5.0+ - assert: + ansible.builtin.assert: that: - nm_sec_domain_absent.previous.0.aaaDomain.attributes.restrictedRbacDomain == 'no' when: version.current.0.topSystem.attributes.version is version('5', '>=') @@ -207,7 +207,7 @@ register: idempotency_sec_domain_absent - name: Idempotency assertions check for remove anstest_sec_domain security domain with normal mode - assert: + ansible.builtin.assert: that: - idempotency_sec_domain_absent is not changed - idempotency_sec_domain_absent.current | length == 0 @@ -221,7 +221,7 @@ register: removed_sec_domain_with_name - name: Assertions check for query a removed security domain with name - assert: + ansible.builtin.assert: that: - removed_sec_domain_with_name is not changed - removed_sec_domain_with_name.current | length == 0 diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_aaa_key_ring/aliases b/ansible_collections/cisco/aci/tests/integration/targets/aci_aaa_key_ring/aliases new file mode 100644 index 000000000..209b793f9 --- /dev/null +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_aaa_key_ring/aliases @@ -0,0 +1,2 @@ +# No ACI simulator yet, so not enabled +# unsupported diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_aaa_key_ring/pki/admin.crt b/ansible_collections/cisco/aci/tests/integration/targets/aci_aaa_key_ring/pki/admin.crt new file mode 100644 index 000000000..cfac5531e --- /dev/null +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_aaa_key_ring/pki/admin.crt @@ -0,0 +1,14 @@ +-----BEGIN CERTIFICATE----- +MIICODCCAaGgAwIBAgIJAIt8XMntue0VMA0GCSqGSIb3DQEBCwUAMDQxDjAMBgNV +BAMMBUFkbWluMRUwEwYDVQQKDAxZb3VyIENvbXBhbnkxCzAJBgNVBAYTAlVTMCAX +DTE4MDEwOTAwNTk0NFoYDzIxMTcxMjE2MDA1OTQ0WjA0MQ4wDAYDVQQDDAVBZG1p +bjEVMBMGA1UECgwMWW91ciBDb21wYW55MQswCQYDVQQGEwJVUzCBnzANBgkqhkiG +9w0BAQEFAAOBjQAwgYkCgYEAohG/7axtt7CbSaMP7r+2mhTKbNgh0Ww36C7Ta14i +v+VmLyKkQHnXinKGhp6uy3Nug+15a+eIu7CrgpBVMQeCiWfsnwRocKcQJWIYDrWl +XHxGQn31yYKR6mylE7Dcj3rMFybnyhezr5D8GcP85YRPmwG9H2hO/0Y1FUnWu9Iw +AQkCAwEAAaNQME4wHQYDVR0OBBYEFD0jLXfpkrU/ChzRvfruRs/fy1VXMB8GA1Ud +IwQYMBaAFD0jLXfpkrU/ChzRvfruRs/fy1VXMAwGA1UdEwQFMAMBAf8wDQYJKoZI +hvcNAQELBQADgYEAOmvre+5tgZ0+F3DgsfxNQqLTrGiBgGCIymPkP/cBXXkNuJyl +3ac7tArHQc7WEA4U2R2rZbEq8FC3UJJm4nUVtCPvEh3G9OhN2xwYev79yt6pIn/l +KU0Td2OpVyo0eLqjoX5u2G90IBWzhyjFbo+CcKMrSVKj1YOdG0E3OuiJf00= +-----END CERTIFICATE----- diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_aaa_key_ring/pki/admin.key b/ansible_collections/cisco/aci/tests/integration/targets/aci_aaa_key_ring/pki/admin.key new file mode 100644 index 000000000..63bb00cc0 --- /dev/null +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_aaa_key_ring/pki/admin.key @@ -0,0 +1,16 @@ +-----BEGIN PRIVATE KEY----- +MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBAKIRv+2sbbewm0mj +D+6/tpoUymzYIdFsN+gu02teIr/lZi8ipEB514pyhoaerstzboPteWvniLuwq4KQ +VTEHgoln7J8EaHCnECViGA61pVx8RkJ99cmCkepspROw3I96zBcm58oXs6+Q/BnD +/OWET5sBvR9oTv9GNRVJ1rvSMAEJAgMBAAECgYByu3QO0qF9h7X3JEu0Ld4cKBnB +giQ2uJC/et7KxIJ/LOvw9GopBthyt27KwG1ntBkJpkTuAaQHkyNns7vLkNB0S0IR ++owVFEcKYq9VCHTaiQU8TDp24gN+yPTrpRuH8YhDVq5SfVdVuTMgHVQdj4ya4VlF +Gj+a7+ipxtGiLsVGrQJBAM7p0Fm0xmzi+tBOASUAcVrPLcteFIaTBFwfq16dm/ON +00Khla8Et5kMBttTbqbukl8mxFjBEEBlhQqb6EdQQ0sCQQDIhHx1a9diG7y/4DQA +4KvR3FCYwP8PBORlSamegzCo+P1OzxiEo0amX7yQMA5UyiP/kUsZrme2JBZgna8S +p4R7AkEAr7rMhSOPUnMD6V4WgsJ5g1Jp5kqkzBaYoVUUSms5RASz4+cwJVCwTX91 +Y1jcpVIBZmaaY3a0wrx13ajEAa0dOQJBAIpjnb4wqpsEh7VpmJqOdSdGxb1XXfFQ +sA0T1OQYqQnFppWwqrxIL+d9pZdiA1ITnNqyvUFBNETqDSOrUHwwb2cCQGArE+vu +ffPUWQ0j+fiK+covFG8NL7H+26NSGB5+Xsn9uwOGLj7K/YT6CbBtr9hJiuWjM1Al +0V4ltlTuu2mTMaw= +-----END PRIVATE KEY----- diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_aaa_key_ring/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_aaa_key_ring/tasks/main.yml new file mode 100644 index 000000000..be3a14763 --- /dev/null +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_aaa_key_ring/tasks/main.yml @@ -0,0 +1,364 @@ +# Test code for the ACI modules +# Copyright: (c) 2024, Akini Ross (@akinross) <akinross@cisco.com> +# +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +- name: Test that we have an ACI APIC host, ACI username and ACI password + ansible.builtin.fail: + msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' + when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined + +- name: Verify Cloud and Non-Cloud Sites in use. + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + +- name: Set vars + ansible.builtin.set_fact: + aci_info: &aci_info + host: "{{ aci_hostname }}" + username: "{{ aci_username }}" + password: "{{ aci_password }}" + validate_certs: '{{ aci_validate_certs | default(false) }}' + use_ssl: '{{ aci_use_ssl | default(true) }}' + use_proxy: '{{ aci_use_proxy | default(true) }}' + output_level: '{{ aci_use_proxy | default("info") }}' + +- name: Query system information to fetch version + cisco.aci.aci_system: + <<: *aci_info + id: 1 + state: query + register: version + +# CLEAN ENVIRONMENT +- name: Ensure certificate_authority_1 exists + cisco.aci.aci_aaa_certificate_authority: &certificate_authority_1 + <<: *aci_info + name: certificate_authority_1 + certificate_chain: "{{ lookup('file', 'pki/admin.crt') }}" + state: present + +- name: Delete key_ring_1 + cisco.aci.aci_aaa_key_ring: &key_ring_1_absent + <<: *aci_info + name: key_ring_1 + state: absent + register: delete_key_ring_1 + until: delete_key_ring_1 is not failed + delay: 2 + retries: 4 + +# CREATE +- name: Create a key ring (check_mode) + cisco.aci.aci_aaa_key_ring: &key_ring_1_present + <<: *key_ring_1_absent + name: key_ring_1 + modulus: 1024 + state: present + check_mode: true + register: cm_create_key_ring_1 + +- name: Create a key ring + cisco.aci.aci_aaa_key_ring: + <<: *key_ring_1_present + register: nm_create_key_ring_1 + +- name: Create a key ring again + cisco.aci.aci_aaa_key_ring: + <<: *key_ring_1_present + register: nm_create_key_ring_1_again + +- name: Assertions for creating a key ring + ansible.builtin.assert: + that: + - cm_create_key_ring_1 is changed + - cm_create_key_ring_1.previous == [] + - cm_create_key_ring_1.current == [] + - cm_create_key_ring_1.proposed.pkiKeyRing.attributes.name == "key_ring_1" + - cm_create_key_ring_1.proposed.pkiKeyRing.attributes.modulus == "mod1024" + - nm_create_key_ring_1 is changed + - nm_create_key_ring_1.previous == [] + - nm_create_key_ring_1.current.0.pkiKeyRing.attributes.name == "key_ring_1" + - nm_create_key_ring_1.current.0.pkiKeyRing.attributes.descr == "" + - nm_create_key_ring_1.current.0.pkiKeyRing.attributes.modulus == "mod1024" + - nm_create_key_ring_1.current.0.pkiKeyRing.attributes.tp == "" + - nm_create_key_ring_1_again is not changed + - nm_create_key_ring_1_again.previous.0.pkiKeyRing.attributes.name == "key_ring_1" + - nm_create_key_ring_1_again.previous.0.pkiKeyRing.attributes.descr == "" + - nm_create_key_ring_1_again.previous.0.pkiKeyRing.attributes.modulus == "mod1024" + - nm_create_key_ring_1_again.previous.0.pkiKeyRing.attributes.tp == "" + - nm_create_key_ring_1_again.current.0.pkiKeyRing.attributes.name == "key_ring_1" + - nm_create_key_ring_1_again.current.0.pkiKeyRing.attributes.descr == "" + - nm_create_key_ring_1_again.current.0.pkiKeyRing.attributes.modulus == "mod1024" + - nm_create_key_ring_1_again.current.0.pkiKeyRing.attributes.tp == "" + +# UPDATE +- name: Update an existing key ring + cisco.aci.aci_aaa_key_ring: + <<: *key_ring_1_present + description: "This is a changed description." + modulus: 2048 + certificate: "{{ lookup('file', 'pki/admin.crt') }}" + certificate_authority: certificate_authority_1 + key: "{{ lookup('file', 'pki/admin.key') }}" + register: nm_update_key_ring_1 + +- name: Assertions for updating a key ring + ansible.builtin.assert: + that: + - nm_update_key_ring_1 is changed + - nm_update_key_ring_1.previous.0.pkiKeyRing.attributes.name == "key_ring_1" + - nm_update_key_ring_1.previous.0.pkiKeyRing.attributes.descr == "" + - nm_update_key_ring_1.previous.0.pkiKeyRing.attributes.modulus == "mod1024" + - nm_update_key_ring_1.current.0.pkiKeyRing.attributes.name == "key_ring_1" + - nm_update_key_ring_1.current.0.pkiKeyRing.attributes.descr == "This is a changed description." + - nm_update_key_ring_1.current.0.pkiKeyRing.attributes.modulus == "mod2048" + - nm_update_key_ring_1.current.0.pkiKeyRing.attributes.tp == "certificate_authority_1" + +# VERSION SPECIFIC TESTS +- name: Test updating a key ring with key_type + when: version.current.0.topSystem.attributes.version is version('6.0', '>=') and query_cloud.current == [] + block: + - name: Update an existing key ring with key type >= 6.0 + cisco.aci.aci_aaa_key_ring: &key_ring_2_present + <<: *key_ring_1_present + name: key_ring_2 + key_type: ecc + ecc_curve: P521 + register: nm_create_key_ring_2_key_type + + - name: Assertions for updating a key ring with key_type + ansible.builtin.assert: + that: + - nm_update_key_ring_1.current.0.pkiKeyRing.attributes.keyType == "RSA" + - nm_update_key_ring_1.current.0.pkiKeyRing.attributes.eccCurve == "none" + - nm_create_key_ring_2_key_type is changed + - nm_create_key_ring_2_key_type.current.0.pkiKeyRing.attributes.keyType == "ECC" + - nm_create_key_ring_2_key_type.current.0.pkiKeyRing.attributes.eccCurve == "secp521r1" + + - name: Delete key_ring_2 + cisco.aci.aci_aaa_key_ring: + <<: *key_ring_2_present + state: absent + +# CLOUD SPECIFIC TESTS +- name: Execute tasks only for cloud sites + when: query_cloud.current != [] # This condition will execute only non-cloud sites + block: # block specifies execution of tasks within, based on conditions + + - name: Delete a key ring in cloud with tenant (check_mode) + cisco.aci.aci_aaa_key_ring: &key_ring_cloud_tenant_absent + <<: *aci_info + name: key_ring_cloud_tenant + cloud_tenant: cloud_tenant + certificate_authority: certificate_authority_cloud + state: absent + + - name: Delete certificate authority for cloud site tenant + cisco.aci.aci_aaa_certificate_authority: &certificate_authority_cloud_absent + <<: *aci_info + cloud_tenant: cloud_tenant + name: certificate_authority_cloud + certificate_chain: "{{ lookup('file', 'pki/admin.crt') }}" + state: absent + + - name: Delete tenant for key ring + cisco.aci.aci_tenant: &cloud_tenant_absent + <<: *aci_info + name: cloud_tenant + state: absent + register: cloud_tenant + until: cloud_tenant is not failed + delay: 2 + retries: 4 + + - name: Create tenant for key ring + cisco.aci.aci_tenant: + <<: *cloud_tenant_absent + state: present + + - name: Create certificate authority for cloud site tenant + cisco.aci.aci_aaa_certificate_authority: + <<: *certificate_authority_cloud_absent + state: present + + - name: Create a key ring in cloud with tenant (check_mode) + cisco.aci.aci_aaa_key_ring: &key_ring_cloud_tenant_present + <<: *key_ring_cloud_tenant_absent + state: present + check_mode: true + register: cm_create_key_ring_cloud_tenant + until: cm_create_key_ring_cloud_tenant is not failed + delay: 2 + retries: 4 + + - name: Create a key ring in cloud with tenant + cisco.aci.aci_aaa_key_ring: + <<: *key_ring_cloud_tenant_present + register: nm_create_key_ring_cloud_tenant + + - name: Create a key ring in cloud with tenant again + cisco.aci.aci_aaa_key_ring: + <<: *key_ring_cloud_tenant_present + register: nm_create_key_ring_cloud_tenant_again + + - name: Assertions for creating a key ring in cloud with tenant + ansible.builtin.assert: + that: + - cm_create_key_ring_cloud_tenant is changed + - cm_create_key_ring_cloud_tenant.previous == [] + - cm_create_key_ring_cloud_tenant.current == [] + - cm_create_key_ring_cloud_tenant.proposed.pkiKeyRing.attributes.name == "key_ring_cloud_tenant" + - cm_create_key_ring_cloud_tenant.proposed.pkiKeyRing.attributes.tp == "certificate_authority_cloud" + - nm_create_key_ring_cloud_tenant is changed + - nm_create_key_ring_cloud_tenant.previous == [] + - nm_create_key_ring_cloud_tenant.current != [] + - nm_create_key_ring_cloud_tenant.current.0.pkiKeyRing.attributes.name == "key_ring_cloud_tenant" + - nm_create_key_ring_cloud_tenant.current.0.pkiKeyRing.attributes.tp == "certificate_authority_cloud" + - nm_create_key_ring_cloud_tenant.current.0.pkiKeyRing.attributes.descr == "" + - nm_create_key_ring_cloud_tenant_again is not changed + - nm_create_key_ring_cloud_tenant_again.previous.0.pkiKeyRing.attributes.name == "key_ring_cloud_tenant" + - nm_create_key_ring_cloud_tenant_again.previous.0.pkiKeyRing.attributes.tp == "certificate_authority_cloud" + - nm_create_key_ring_cloud_tenant_again.previous.0.pkiKeyRing.attributes.descr == "" + - nm_create_key_ring_cloud_tenant_again.current.0.pkiKeyRing.attributes.name == "key_ring_cloud_tenant" + - nm_create_key_ring_cloud_tenant_again.current.0.pkiKeyRing.attributes.tp == "certificate_authority_cloud" + - nm_create_key_ring_cloud_tenant_again.current.0.pkiKeyRing.attributes.descr == "" + + + - name: Update an existing key ring in cloud with tenant + cisco.aci.aci_aaa_key_ring: + <<: *key_ring_cloud_tenant_present + description: "This is a changed description." + certificate: "{{ lookup('file', 'pki/admin.crt') }}" + certificate_authority: certificate_authority_cloud + key: "{{ lookup('file', 'pki/admin.key') }}" + register: nm_update_key_ring_cloud_tenant + + - name: Assertions for updating a key ring in cloud with tenant + ansible.builtin.assert: + that: + - nm_update_key_ring_cloud_tenant is changed + - nm_update_key_ring_cloud_tenant.previous.0.pkiKeyRing.attributes.name == "key_ring_cloud_tenant" + - nm_update_key_ring_cloud_tenant.previous.0.pkiKeyRing.attributes.descr == "" + - nm_update_key_ring_cloud_tenant.previous.0.pkiKeyRing.attributes.tp == "certificate_authority_cloud" + - nm_update_key_ring_cloud_tenant.current.0.pkiKeyRing.attributes.name == "key_ring_cloud_tenant" + - nm_update_key_ring_cloud_tenant.current.0.pkiKeyRing.attributes.descr == "This is a changed description." + - nm_update_key_ring_cloud_tenant.current.0.pkiKeyRing.attributes.tp == "certificate_authority_cloud" + + - name: Delete a key ring in cloud with tenant (check_mode) + cisco.aci.aci_aaa_key_ring: + <<: *key_ring_cloud_tenant_absent + check_mode: true + register: cm_delete_key_ring_cloud_tenant + + - name: Delete a key ring in cloud with tenant + cisco.aci.aci_aaa_key_ring: + <<: *key_ring_cloud_tenant_absent + register: nm_delete_key_ring_cloud_tenant + + - name: Delete a key ring in cloud with tenant again + cisco.aci.aci_aaa_key_ring: + <<: *key_ring_cloud_tenant_absent + register: nm_delete_key_ring_cloud_tenant_again + + - name: Assertions for deleting a key ring in cloud with tenant + ansible.builtin.assert: + that: + - cm_delete_key_ring_cloud_tenant is changed + - cm_delete_key_ring_cloud_tenant.previous.0.pkiKeyRing.attributes.name == "key_ring_cloud_tenant" + - cm_delete_key_ring_cloud_tenant.previous.0.pkiKeyRing.attributes.descr == "This is a changed description." + - cm_delete_key_ring_cloud_tenant.previous.0.pkiKeyRing.attributes.tp == "certificate_authority_cloud" + - cm_delete_key_ring_cloud_tenant.current.0.pkiKeyRing.attributes.name == "key_ring_cloud_tenant" + - cm_delete_key_ring_cloud_tenant.current.0.pkiKeyRing.attributes.descr == "This is a changed description." + - cm_delete_key_ring_cloud_tenant.current.0.pkiKeyRing.attributes.tp == "certificate_authority_cloud" + - cm_delete_key_ring_cloud_tenant.proposed == {} + - nm_delete_key_ring_cloud_tenant is changed + - nm_delete_key_ring_cloud_tenant.previous.0.pkiKeyRing.attributes.name == "key_ring_cloud_tenant" + - nm_delete_key_ring_cloud_tenant.previous.0.pkiKeyRing.attributes.descr == "This is a changed description." + - nm_delete_key_ring_cloud_tenant.previous.0.pkiKeyRing.attributes.tp == "certificate_authority_cloud" + - nm_delete_key_ring_cloud_tenant.current == [] + - nm_delete_key_ring_cloud_tenant_again is not changed + - nm_delete_key_ring_cloud_tenant_again.previous == [] + - nm_delete_key_ring_cloud_tenant_again.current == [] + + - name: Delete certificate authority for cloud site tenant + cisco.aci.aci_aaa_certificate_authority: + <<: *certificate_authority_cloud_absent + + - name: Delete tenant for key ring + cisco.aci.aci_tenant: + <<: *cloud_tenant_absent + register: cloud_tenant + until: cloud_tenant is not failed + delay: 2 + retries: 4 + +# QUERY +- name: Query a key ring + cisco.aci.aci_aaa_key_ring: + <<: *key_ring_1_present + state: query + register: query_key_ring_1 + +- name: Query all fabric management access policies + cisco.aci.aci_aaa_key_ring: + <<: *aci_info + state: query + register: query_all + +- name: Assertions for querying fabric management access policies + ansible.builtin.assert: + that: + - query_key_ring_1 is not changed + - query_key_ring_1.current.0.pkiKeyRing.attributes.name == "key_ring_1" + - query_key_ring_1.current.0.pkiKeyRing.attributes.descr == "This is a changed description." + - query_key_ring_1.current.0.pkiKeyRing.attributes.modulus == "mod2048" + - query_key_ring_1.current.0.pkiKeyRing.attributes.tp == "certificate_authority_1" + - query_key_ring_1.current | length == 1 + - query_all is not changed + - query_all.current | length >= 2 + +# DELETE +- name: Delete a key ring (check_mode) + cisco.aci.aci_aaa_key_ring: + <<: *key_ring_1_absent + check_mode: true + register: cm_delete_key_ring_1 + +- name: Delete a key ring + cisco.aci.aci_aaa_key_ring: + <<: *key_ring_1_absent + register: nm_delete_key_ring_1 + +- name: Delete a key ring again + cisco.aci.aci_aaa_key_ring: + <<: *key_ring_1_absent + register: nm_delete_key_ring_1_again + +- name: Assertions for deleting a key ring + ansible.builtin.assert: + that: + - cm_delete_key_ring_1 is changed + - cm_delete_key_ring_1.proposed == {} + - cm_delete_key_ring_1.previous.0.pkiKeyRing.attributes.name == "key_ring_1" + - cm_delete_key_ring_1.previous.0.pkiKeyRing.attributes.descr == "This is a changed description." + - cm_delete_key_ring_1.previous.0.pkiKeyRing.attributes.modulus == "mod2048" + - cm_delete_key_ring_1.previous.0.pkiKeyRing.attributes.tp == "certificate_authority_1" + - cm_delete_key_ring_1.current.0.pkiKeyRing.attributes.name == "key_ring_1" + - cm_delete_key_ring_1.current.0.pkiKeyRing.attributes.descr == "This is a changed description." + - cm_delete_key_ring_1.current.0.pkiKeyRing.attributes.modulus == "mod2048" + - cm_delete_key_ring_1.current.0.pkiKeyRing.attributes.tp == "certificate_authority_1" + - nm_delete_key_ring_1 is changed + - nm_delete_key_ring_1.previous.0.pkiKeyRing.attributes.name == "key_ring_1" + - nm_delete_key_ring_1.previous.0.pkiKeyRing.attributes.descr == "This is a changed description." + - nm_delete_key_ring_1.previous.0.pkiKeyRing.attributes.modulus == "mod2048" + - nm_delete_key_ring_1.previous.0.pkiKeyRing.attributes.tp == "certificate_authority_1" + - nm_delete_key_ring_1.current == [] + - nm_delete_key_ring_1_again is not changed + - nm_delete_key_ring_1_again.previous == [] + - nm_delete_key_ring_1_again.current == [] + +# CLEAN ENVIRONMENT +- name: Delete certificate_authority_1 + cisco.aci.aci_aaa_certificate_authority: + <<: *certificate_authority_1 + state: absent diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_aaa_role/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_aaa_role/tasks/main.yml index dce0fd4c6..f7735bc11 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_aaa_role/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_aaa_role/tasks/main.yml @@ -4,13 +4,13 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined # SET VARS - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: '{{ aci_hostname }}' username: '{{ aci_username }}' @@ -42,7 +42,7 @@ register: cm_anstest_role_present - name: Assertions check for add an anstest_role aaa role with check mode - assert: + ansible.builtin.assert: that: - cm_anstest_role_present is changed - cm_anstest_role_present.current | length == 0 @@ -56,7 +56,7 @@ register: nm_anstest_role_present - name: Assertions check for add an anstest_role aaa role with normal mode - assert: + ansible.builtin.assert: that: - nm_anstest_role_present is changed - nm_anstest_role_present.current | length == 1 @@ -70,7 +70,7 @@ register: idempotency_anstest_role_present - name: Idempotency assertions check for add an anstest_role aaa role with normal mode - assert: + ansible.builtin.assert: that: - idempotency_anstest_role_present is not changed - idempotency_anstest_role_present.current | length == 1 @@ -87,7 +87,7 @@ register: anstest_role_with_list_priv - name: Assertions check for update an anstest_role with list of privileges - assert: + ansible.builtin.assert: that: - anstest_role_with_list_priv is changed - anstest_role_with_list_priv.current | length == 1 @@ -97,13 +97,13 @@ - anstest_role_with_list_priv.previous.0.aaaRole.attributes.priv == 'aaa' - name: Assertions check for anstest_role_with_list_priv on v4.2 or earlier - assert: + ansible.builtin.assert: that: - anstest_role_with_list_priv.current.0.aaaRole.attributes.priv == 'aaa,admin' when: version.current.0.topSystem.attributes.version is version('5', '<') - name: Assertions check for anstest_role_with_list_priv on v5+ - assert: + ansible.builtin.assert: that: - anstest_role_with_list_priv.current.0.aaaRole.attributes.priv == 'aaa,admin,tenant-connectivity' when: version.current.0.topSystem.attributes.version is version('5', '>=') @@ -116,7 +116,7 @@ register: anstest_role_with_valid_priv - name: Assertions check for update an anstest_role with admin privilege - assert: + ansible.builtin.assert: that: - anstest_role_with_valid_priv is changed - anstest_role_with_valid_priv.current | length == 1 @@ -126,13 +126,13 @@ - anstest_role_with_valid_priv.current.0.aaaRole.attributes.priv == 'admin' - name: Assertions check for anstest_role_with_valid_priv on v4.2 or earlier - assert: + ansible.builtin.assert: that: - anstest_role_with_valid_priv.previous.0.aaaRole.attributes.priv == 'aaa,admin' when: version.current.0.topSystem.attributes.version is version('5', '<') - name: Assertions check for anstest_role_with_valid_priv on v5+ - assert: + ansible.builtin.assert: that: - anstest_role_with_valid_priv.previous.0.aaaRole.attributes.priv == 'aaa,admin,tenant-connectivity' when: version.current.0.topSystem.attributes.version is version('5', '>=') @@ -152,7 +152,7 @@ ignore_errors: true - name: Assertions check for query a aaa role with name - assert: + ansible.builtin.assert: that: - anstest_role_with_invalid_list_priv.msg.startswith("value of privileges must be one or more of") - anstest_role_with_invalid_priv.msg.startswith("value of privileges must be one or more of") @@ -165,7 +165,7 @@ register: anstest_role_query_result - name: Assertions check for query a aaa role with name - assert: + ansible.builtin.assert: that: - anstest_role_query_result is not changed - anstest_role_query_result.current | length == 1 @@ -179,7 +179,7 @@ register: query_all_roles - name: Assertions check for query all aaa roles - assert: + ansible.builtin.assert: that: - query_all_roles is not changed - query_all_roles.current | length >= 1 @@ -192,7 +192,7 @@ register: cm_anstest_role_absent - name: Assertions check for remove an anstest_role aaa role with check mode - assert: + ansible.builtin.assert: that: - cm_anstest_role_absent is changed - cm_anstest_role_absent.current | length == 1 @@ -208,7 +208,7 @@ register: nm_anstest_role_absent - name: Assertions check for remove an anstest_role aaa role with normal mode - assert: + ansible.builtin.assert: that: - nm_anstest_role_absent is changed - nm_anstest_role_absent.current | length == 0 @@ -222,7 +222,7 @@ register: idempotency_anstest_role_absent - name: Idempotency assertions check for remove an anstest_role aaa role with normal mode - assert: + ansible.builtin.assert: that: - idempotency_anstest_role_absent is not changed - idempotency_anstest_role_absent.current | length == 0 diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_aaa_security_default_settings/aliases b/ansible_collections/cisco/aci/tests/integration/targets/aci_aaa_security_default_settings/aliases new file mode 100644 index 000000000..209b793f9 --- /dev/null +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_aaa_security_default_settings/aliases @@ -0,0 +1,2 @@ +# No ACI simulator yet, so not enabled +# unsupported diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_aaa_security_default_settings/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_aaa_security_default_settings/tasks/main.yml new file mode 100644 index 000000000..24b63693e --- /dev/null +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_aaa_security_default_settings/tasks/main.yml @@ -0,0 +1,235 @@ +# Test code for the ACI modules +# Copyright: (c) 2024, Akini Ross (@akinross) + +# 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 APIC host, ACI username and ACI password + ansible.builtin.fail: + msg: "Please define the following variables: aci_hostname, aci_username and aci_password." + when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined + +- name: Verify Cloud and Non-Cloud Sites in use. + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + +# SET VARS +- name: Set vars + ansible.builtin.set_fact: + aci_info: &aci_info + host: "{{ aci_hostname }}" + username: "{{ aci_remote_username }}" + password: "{{ aci_password }}" + validate_certs: "{{ aci_validate_certs | default(false) }}" + use_ssl: "{{ aci_use_ssl | default(true) }}" + use_proxy: "{{ aci_use_proxy | default(true) }}" + output_level: "{{ aci_output_level | default('info') }}" + +- name: Always set aaa_password_update_required to false and security settings back to defaults + when: query_cloud.current == [] # This condition will execute only non-cloud sites + block: + # CLEAN + - name: Set AAA Security Default Settings to Default Values + cisco.aci.aci_aaa_security_default_settings: &security_settings_defaults + <<: *aci_info + password_strength_check: true + password_strength_profile: + enable: false + password_change: + enable: false + interval: 48 + allowed_changes: 2 + minimum_period_between_password_changes: 24 + history_storage_amount: 5 + lockout: + enable: false + max_attempts: 5 + window: 5 + duration: 60 + web_token: + timeout: 600 + idle_timeout: 1200 + validity_period: 24 + refresh: false + state: present + + # QUERY + - name: Query AAA security default settings + cisco.aci.aci_aaa_security_default_settings: + <<: *aci_info + state: query + register: query_security_settings + + - name: Assertions for enabling a AAA security default settings + ansible.builtin.assert: + that: + - query_security_settings is not changed + - query_security_settings.current.0.aaaUserEp.attributes.pwdStrengthCheck == "yes" + - query_security_settings.current.0.aaaUserEp.children.0.aaaBlockLoginProfile.attributes.blockDuration == "60" + - query_security_settings.current.0.aaaUserEp.children.0.aaaBlockLoginProfile.attributes.enableLoginBlock == "disable" + - query_security_settings.current.0.aaaUserEp.children.0.aaaBlockLoginProfile.attributes.maxFailedAttempts == "5" + - query_security_settings.current.0.aaaUserEp.children.0.aaaBlockLoginProfile.attributes.maxFailedAttemptsWindow == "5" + - query_security_settings.current.0.aaaUserEp.children.1.aaaPwdProfile.attributes.changeCount == "2" + - query_security_settings.current.0.aaaUserEp.children.1.aaaPwdProfile.attributes.changeInterval == "48" + - query_security_settings.current.0.aaaUserEp.children.1.aaaPwdProfile.attributes.historyCount == "5" + - query_security_settings.current.0.aaaUserEp.children.1.aaaPwdProfile.attributes.noChangeInterval == "24" + - query_security_settings.current.0.aaaUserEp.children.2.pkiEp.children.0.pkiWebTokenData.attributes.maximumValidityPeriod == "24" + - query_security_settings.current.0.aaaUserEp.children.2.pkiEp.children.0.pkiWebTokenData.attributes.sessionRecordFlags == "login,logout" + - query_security_settings.current.0.aaaUserEp.children.2.pkiEp.children.0.pkiWebTokenData.attributes.uiIdleTimeoutSeconds == "1200" + - query_security_settings.current.0.aaaUserEp.children.2.pkiEp.children.0.pkiWebTokenData.attributes.webtokenTimeoutSeconds == "600" + + # UPDATE + - name: Update AAA security default settings password_strength_check + cisco.aci.aci_aaa_security_default_settings: + <<: *aci_info + password_strength_check: false + + - name: Update AAA security default settings (check_mode) + cisco.aci.aci_aaa_security_default_settings: &security_settings + <<: *aci_info + password_strength_check: true + password_strength_profile: + enable: true # do not test with true as it will for for password change and locks out the user + type: custom + min_length: 9 + max_length: 25 + class_flags: + - digits + - lowercase + - uppercase + password_change: + enable: true # do not test with true as it will for for password change and locks out the user + interval: 60 + allowed_changes: 3 + minimum_period_between_password_changes: 25 + history_storage_amount: 6 + lockout: + enable: true + max_attempts: 6 + window: 6 + duration: 30 + web_token: + timeout: 601 + idle_timeout: 1201 + validity_period: 23 + refresh: true + check_mode: true + register: cm_update_security_settings + + - name: Update AAA security default settings + cisco.aci.aci_aaa_security_default_settings: + <<: *security_settings + register: nm_update_security_settings + + - name: Update AAA security default settings again + cisco.aci.aci_aaa_security_default_settings: + <<: *security_settings + register: nm_update_security_settings_again + + - name: Assertions for enabling a AAA security default settings + ansible.builtin.assert: + that: + - cm_update_security_settings is changed + - cm_update_security_settings.current.0.aaaUserEp.attributes.pwdStrengthCheck == "no" + - cm_update_security_settings.current.0.aaaUserEp.children.0.aaaBlockLoginProfile.attributes.blockDuration == "60" + - cm_update_security_settings.current.0.aaaUserEp.children.0.aaaBlockLoginProfile.attributes.enableLoginBlock == "disable" + - cm_update_security_settings.current.0.aaaUserEp.children.0.aaaBlockLoginProfile.attributes.maxFailedAttempts == "5" + - cm_update_security_settings.current.0.aaaUserEp.children.0.aaaBlockLoginProfile.attributes.maxFailedAttemptsWindow == "5" + - cm_update_security_settings.current.0.aaaUserEp.children.1.aaaPwdProfile.attributes.changeCount == "2" + - cm_update_security_settings.current.0.aaaUserEp.children.1.aaaPwdProfile.attributes.changeInterval == "48" + - cm_update_security_settings.current.0.aaaUserEp.children.1.aaaPwdProfile.attributes.historyCount == "5" + - cm_update_security_settings.current.0.aaaUserEp.children.1.aaaPwdProfile.attributes.noChangeInterval == "24" + - cm_update_security_settings.current.0.aaaUserEp.children.2.pkiEp.children.0.pkiWebTokenData.attributes.maximumValidityPeriod == "24" + - cm_update_security_settings.current.0.aaaUserEp.children.2.pkiEp.children.0.pkiWebTokenData.attributes.sessionRecordFlags == "login,logout" + - cm_update_security_settings.current.0.aaaUserEp.children.2.pkiEp.children.0.pkiWebTokenData.attributes.uiIdleTimeoutSeconds == "1200" + - cm_update_security_settings.current.0.aaaUserEp.children.2.pkiEp.children.0.pkiWebTokenData.attributes.webtokenTimeoutSeconds == "600" + - cm_update_security_settings.proposed.aaaUserEp.attributes.pwdStrengthCheck == "yes" + - cm_update_security_settings.proposed.aaaUserEp.children.0.aaaPwdStrengthProfile.attributes.pwdClassFlags == "digits,lowercase,uppercase" + - cm_update_security_settings.proposed.aaaUserEp.children.0.aaaPwdStrengthProfile.attributes.pwdMaxLength == "25" + - cm_update_security_settings.proposed.aaaUserEp.children.0.aaaPwdStrengthProfile.attributes.pwdMinLength == "9" + - cm_update_security_settings.proposed.aaaUserEp.children.0.aaaPwdStrengthProfile.attributes.pwdStrengthTestType == "custom" + - cm_update_security_settings.proposed.aaaUserEp.children.2.aaaBlockLoginProfile.attributes.blockDuration == "30" + - cm_update_security_settings.proposed.aaaUserEp.children.2.aaaBlockLoginProfile.attributes.enableLoginBlock == "enable" + - cm_update_security_settings.proposed.aaaUserEp.children.2.aaaBlockLoginProfile.attributes.maxFailedAttempts == "6" + - cm_update_security_settings.proposed.aaaUserEp.children.2.aaaBlockLoginProfile.attributes.maxFailedAttemptsWindow == "6" + - cm_update_security_settings.proposed.aaaUserEp.children.1.aaaPwdProfile.attributes.changeCount == "3" + - cm_update_security_settings.proposed.aaaUserEp.children.1.aaaPwdProfile.attributes.changeInterval == "60" + - cm_update_security_settings.proposed.aaaUserEp.children.1.aaaPwdProfile.attributes.historyCount == "6" + - cm_update_security_settings.proposed.aaaUserEp.children.1.aaaPwdProfile.attributes.noChangeInterval == "25" + - cm_update_security_settings.proposed.aaaUserEp.children.3.pkiEp.children.0.pkiWebTokenData.attributes.maximumValidityPeriod == "23" + - cm_update_security_settings.proposed.aaaUserEp.children.3.pkiEp.children.0.pkiWebTokenData.attributes.sessionRecordFlags == "login,logout,refresh" + - cm_update_security_settings.proposed.aaaUserEp.children.3.pkiEp.children.0.pkiWebTokenData.attributes.uiIdleTimeoutSeconds == "1201" + - cm_update_security_settings.proposed.aaaUserEp.children.3.pkiEp.children.0.pkiWebTokenData.attributes.webtokenTimeoutSeconds == "601" + - nm_update_security_settings is changed + - nm_update_security_settings.previous.0.aaaUserEp.attributes.pwdStrengthCheck == "no" + - nm_update_security_settings.previous.0.aaaUserEp.children.0.aaaBlockLoginProfile.attributes.blockDuration == "60" + - nm_update_security_settings.previous.0.aaaUserEp.children.0.aaaBlockLoginProfile.attributes.enableLoginBlock == "disable" + - nm_update_security_settings.previous.0.aaaUserEp.children.0.aaaBlockLoginProfile.attributes.maxFailedAttempts == "5" + - nm_update_security_settings.previous.0.aaaUserEp.children.0.aaaBlockLoginProfile.attributes.maxFailedAttemptsWindow == "5" + - nm_update_security_settings.previous.0.aaaUserEp.children.1.aaaPwdProfile.attributes.changeCount == "2" + - nm_update_security_settings.previous.0.aaaUserEp.children.1.aaaPwdProfile.attributes.changeInterval == "48" + - nm_update_security_settings.previous.0.aaaUserEp.children.1.aaaPwdProfile.attributes.historyCount == "5" + - nm_update_security_settings.previous.0.aaaUserEp.children.1.aaaPwdProfile.attributes.noChangeInterval == "24" + - nm_update_security_settings.previous.0.aaaUserEp.children.2.pkiEp.children.0.pkiWebTokenData.attributes.maximumValidityPeriod == "24" + - nm_update_security_settings.previous.0.aaaUserEp.children.2.pkiEp.children.0.pkiWebTokenData.attributes.sessionRecordFlags == "login,logout" + - nm_update_security_settings.previous.0.aaaUserEp.children.2.pkiEp.children.0.pkiWebTokenData.attributes.uiIdleTimeoutSeconds == "1200" + - nm_update_security_settings.previous.0.aaaUserEp.children.2.pkiEp.children.0.pkiWebTokenData.attributes.webtokenTimeoutSeconds == "600" + - nm_update_security_settings.current.0.aaaUserEp.attributes.pwdStrengthCheck == "yes" + - nm_update_security_settings.current.0.aaaUserEp.children.0.aaaBlockLoginProfile.attributes.blockDuration == "30" + - nm_update_security_settings.current.0.aaaUserEp.children.0.aaaBlockLoginProfile.attributes.enableLoginBlock == "enable" + - nm_update_security_settings.current.0.aaaUserEp.children.0.aaaBlockLoginProfile.attributes.maxFailedAttempts == "6" + - nm_update_security_settings.current.0.aaaUserEp.children.0.aaaBlockLoginProfile.attributes.maxFailedAttemptsWindow == "6" + - nm_update_security_settings.current.0.aaaUserEp.children.1.aaaPwdStrengthProfile.attributes.pwdClassFlags == "digits,lowercase,uppercase" + - nm_update_security_settings.current.0.aaaUserEp.children.1.aaaPwdStrengthProfile.attributes.pwdMaxLength == "25" + - nm_update_security_settings.current.0.aaaUserEp.children.1.aaaPwdStrengthProfile.attributes.pwdMinLength == "9" + - nm_update_security_settings.current.0.aaaUserEp.children.1.aaaPwdStrengthProfile.attributes.pwdStrengthTestType == "custom" + - nm_update_security_settings.current.0.aaaUserEp.children.2.aaaPwdProfile.attributes.changeCount == "3" + - nm_update_security_settings.current.0.aaaUserEp.children.2.aaaPwdProfile.attributes.changeInterval == "60" + - nm_update_security_settings.current.0.aaaUserEp.children.2.aaaPwdProfile.attributes.historyCount == "6" + - nm_update_security_settings.current.0.aaaUserEp.children.2.aaaPwdProfile.attributes.noChangeInterval == "25" + - nm_update_security_settings.current.0.aaaUserEp.children.3.pkiEp.children.0.pkiWebTokenData.attributes.maximumValidityPeriod == "23" + - nm_update_security_settings.current.0.aaaUserEp.children.3.pkiEp.children.0.pkiWebTokenData.attributes.sessionRecordFlags == "login,logout,refresh" + - nm_update_security_settings.current.0.aaaUserEp.children.3.pkiEp.children.0.pkiWebTokenData.attributes.uiIdleTimeoutSeconds == "1201" + - nm_update_security_settings.current.0.aaaUserEp.children.3.pkiEp.children.0.pkiWebTokenData.attributes.webtokenTimeoutSeconds == "601" + - nm_update_security_settings_again is not changed + - nm_update_security_settings_again.previous.0.aaaUserEp.children.0.aaaBlockLoginProfile.attributes.blockDuration == "30" + - nm_update_security_settings_again.previous.0.aaaUserEp.children.0.aaaBlockLoginProfile.attributes.enableLoginBlock == "enable" + - nm_update_security_settings_again.previous.0.aaaUserEp.children.0.aaaBlockLoginProfile.attributes.maxFailedAttempts == "6" + - nm_update_security_settings_again.previous.0.aaaUserEp.children.0.aaaBlockLoginProfile.attributes.maxFailedAttemptsWindow == "6" + - nm_update_security_settings_again.previous.0.aaaUserEp.children.1.aaaPwdStrengthProfile.attributes.pwdClassFlags == "digits,lowercase,uppercase" + - nm_update_security_settings_again.previous.0.aaaUserEp.children.1.aaaPwdStrengthProfile.attributes.pwdMaxLength == "25" + - nm_update_security_settings_again.previous.0.aaaUserEp.children.1.aaaPwdStrengthProfile.attributes.pwdMinLength == "9" + - nm_update_security_settings_again.previous.0.aaaUserEp.children.1.aaaPwdStrengthProfile.attributes.pwdStrengthTestType == "custom" + - nm_update_security_settings_again.previous.0.aaaUserEp.children.2.aaaPwdProfile.attributes.changeCount == "3" + - nm_update_security_settings_again.previous.0.aaaUserEp.children.2.aaaPwdProfile.attributes.changeInterval == "60" + - nm_update_security_settings_again.previous.0.aaaUserEp.children.2.aaaPwdProfile.attributes.historyCount == "6" + - nm_update_security_settings_again.previous.0.aaaUserEp.children.2.aaaPwdProfile.attributes.noChangeInterval == "25" + - nm_update_security_settings_again.previous.0.aaaUserEp.children.3.pkiEp.children.0.pkiWebTokenData.attributes.maximumValidityPeriod == "23" + - nm_update_security_settings_again.previous.0.aaaUserEp.children.3.pkiEp.children.0.pkiWebTokenData.attributes.sessionRecordFlags == "login,logout,refresh" + - nm_update_security_settings_again.previous.0.aaaUserEp.children.3.pkiEp.children.0.pkiWebTokenData.attributes.uiIdleTimeoutSeconds == "1201" + - nm_update_security_settings_again.previous.0.aaaUserEp.children.3.pkiEp.children.0.pkiWebTokenData.attributes.webtokenTimeoutSeconds == "601" + - nm_update_security_settings_again.current.0.aaaUserEp.children.0.aaaBlockLoginProfile.attributes.blockDuration == "30" + - nm_update_security_settings_again.current.0.aaaUserEp.children.0.aaaBlockLoginProfile.attributes.enableLoginBlock == "enable" + - nm_update_security_settings_again.current.0.aaaUserEp.children.0.aaaBlockLoginProfile.attributes.maxFailedAttempts == "6" + - nm_update_security_settings_again.current.0.aaaUserEp.children.0.aaaBlockLoginProfile.attributes.maxFailedAttemptsWindow == "6" + - nm_update_security_settings_again.current.0.aaaUserEp.children.1.aaaPwdStrengthProfile.attributes.pwdClassFlags == "digits,lowercase,uppercase" + - nm_update_security_settings_again.current.0.aaaUserEp.children.1.aaaPwdStrengthProfile.attributes.pwdMaxLength == "25" + - nm_update_security_settings_again.current.0.aaaUserEp.children.1.aaaPwdStrengthProfile.attributes.pwdMinLength == "9" + - nm_update_security_settings_again.current.0.aaaUserEp.children.1.aaaPwdStrengthProfile.attributes.pwdStrengthTestType == "custom" + - nm_update_security_settings_again.current.0.aaaUserEp.children.2.aaaPwdProfile.attributes.changeCount == "3" + - nm_update_security_settings_again.current.0.aaaUserEp.children.2.aaaPwdProfile.attributes.changeInterval == "60" + - nm_update_security_settings_again.current.0.aaaUserEp.children.2.aaaPwdProfile.attributes.historyCount == "6" + - nm_update_security_settings_again.current.0.aaaUserEp.children.2.aaaPwdProfile.attributes.noChangeInterval == "25" + - nm_update_security_settings_again.current.0.aaaUserEp.children.3.pkiEp.children.0.pkiWebTokenData.attributes.maximumValidityPeriod == "23" + - nm_update_security_settings_again.current.0.aaaUserEp.children.3.pkiEp.children.0.pkiWebTokenData.attributes.sessionRecordFlags == "login,logout,refresh" + - nm_update_security_settings_again.current.0.aaaUserEp.children.3.pkiEp.children.0.pkiWebTokenData.attributes.uiIdleTimeoutSeconds == "1201" + - nm_update_security_settings_again.current.0.aaaUserEp.children.3.pkiEp.children.0.pkiWebTokenData.attributes.webtokenTimeoutSeconds == "601" + + always: + - name: Set aaa_password_update_required back to false + cisco.aci.aci_aaa_user: + <<: *aci_info + aaa_user: "{{ aci_username }}" + aaa_password_update_required: false + + - name: Set AAA Security Default Settings to Default Values + cisco.aci.aci_aaa_security_default_settings: + <<: *security_settings_defaults diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_aaa_ssh_auth/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_aaa_ssh_auth/tasks/main.yml index 46113c0f9..9c2462bb4 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_aaa_ssh_auth/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_aaa_ssh_auth/tasks/main.yml @@ -5,12 +5,12 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: "{{ aci_hostname }}" username: "{{ aci_username }}" @@ -64,7 +64,7 @@ register: nm_add_ssh_key_again - name: Verify add SSH key - assert: + ansible.builtin.assert: that: - cm_add_ssh_key is changed - nm_add_ssh_key is changed @@ -92,7 +92,7 @@ register: nm_query_all_ssh_keys - name: Verify query_all_ssh_keys - assert: + ansible.builtin.assert: that: - cm_query_all_ssh_keys is not changed - nm_query_all_ssh_keys is not changed @@ -111,7 +111,7 @@ register: nm_query_ssh_key - name: Verify query_ssh_key - assert: + ansible.builtin.assert: that: - cm_query_ssh_key is not changed - nm_query_ssh_key is not changed @@ -148,7 +148,7 @@ register: nm_remove_ssh_key_again - name: Verify remove_user - assert: + ansible.builtin.assert: that: - cm_remove_ssh_key is changed - nm_remove_ssh_key is changed diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_aaa_user/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_aaa_user/tasks/main.yml index 52f3ed0fb..8c25cef4c 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_aaa_user/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_aaa_user/tasks/main.yml @@ -4,7 +4,7 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined @@ -84,7 +84,7 @@ register: nm_add_user_again - name: Verify add user - assert: + ansible.builtin.assert: that: - cm_add_user is changed - nm_add_user is changed @@ -134,7 +134,7 @@ register: nm_modify_user_again - name: Verify modify user - assert: + ansible.builtin.assert: that: - cm_modify_user is changed - err_modify_user_expiration.msg == "Failed to parse date format 'wrong_expiration', Unknown string format{{":"}} wrong_expiration" @@ -174,7 +174,7 @@ register: nm_clear_password_history_again - name: Verify clear password history - assert: + ansible.builtin.assert: that: # NOTE: Clearing password history is a changing action, everytime - cm_clear_password_history is changed @@ -203,7 +203,7 @@ register: nm_query_all_users - name: Verify query_all_users - assert: + ansible.builtin.assert: that: - cm_query_all_users is not changed - nm_query_all_users is not changed @@ -224,7 +224,7 @@ register: nm_query_user - name: Verify query_user - assert: + ansible.builtin.assert: that: - cm_query_user is not changed - nm_query_user is not changed @@ -257,7 +257,7 @@ register: nm_remove_user_again - name: Verify remove_user - assert: + ansible.builtin.assert: that: - cm_remove_user is changed - nm_remove_user is changed diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_aaa_user_certificate/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_aaa_user_certificate/tasks/main.yml index 3140816e0..7d21d5c27 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_aaa_user_certificate/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_aaa_user_certificate/tasks/main.yml @@ -4,12 +4,12 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: "{{ aci_hostname }}" username: "{{ aci_username }}" @@ -82,7 +82,7 @@ register: nm_add_cert_again - name: Verify add_cert - assert: + ansible.builtin.assert: that: - cm_add_cert is changed - nm_add_cert is change @@ -127,7 +127,7 @@ register: nm_query_all_certs - name: Verify query_all_certs - assert: + ansible.builtin.assert: that: - cm_query_all_certs is not changed - nm_query_all_certs is not changed @@ -142,7 +142,7 @@ register: nm_query_all_rsa - name: Verify nm_query_all_rsa - assert: + ansible.builtin.assert: that: - nm_query_all_rsa is not changed - nm_query_all_rsa.current.0.aaaUser.children | length >= 4 @@ -184,7 +184,7 @@ register: nm_query_cert - name: Verify query_cert - assert: + ansible.builtin.assert: that: - cm_query_cert is not changed - nm_query_cert is not changed @@ -283,7 +283,7 @@ register: nm_remove_cert_again - name: Verify remove_cert - assert: + ansible.builtin.assert: that: - cm_remove_cert is changed - nm_remove_cert is changed @@ -292,7 +292,7 @@ # Checking if changing certification_name to name throws an error. (#82) - name: Making sure current user has correct cert - aci_aaa_user_certificate: + cisco.aci.aci_aaa_user_certificate: <<: *aci_info aaa_user: '{{ aci_username }}' name: admin @@ -377,7 +377,7 @@ register: query_test_pk_content - name: Verify query_test - assert: + ansible.builtin.assert: that: - query_test is not changed - query_test_pk_file is not changed diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_aaa_user_domain/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_aaa_user_domain/tasks/main.yml index ac0d1d0f2..5bc3968bc 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_aaa_user_domain/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_aaa_user_domain/tasks/main.yml @@ -6,13 +6,13 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined # SET VARS - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: '{{ aci_hostname }}' username: '{{ aci_username }}' @@ -70,7 +70,7 @@ register: cm_sec_domain_present - name: Assertions check for add user domain to aaa_user with check mode - assert: + ansible.builtin.assert: that: - cm_sec_domain_present is changed - cm_sec_domain_present.current | length == 0 @@ -83,7 +83,7 @@ register: nm_sec_domain_present - name: Assertions check for add user domain to aaa_user with normal mode - assert: + ansible.builtin.assert: that: - nm_sec_domain_present is changed - nm_sec_domain_present.current | length == 1 @@ -97,7 +97,7 @@ register: cm_idempotency_sec_domain_present - name: Idempotency assertions check for add user domain to aaa_user with check mode - assert: + ansible.builtin.assert: that: - cm_idempotency_sec_domain_present is not changed - cm_idempotency_sec_domain_present.current | length == 1 @@ -111,7 +111,7 @@ register: idempotency_sec_domain_present - name: Idempotency assertions check for add user domain to aaa_user with normal mode - assert: + ansible.builtin.assert: that: - idempotency_sec_domain_present is not changed - idempotency_sec_domain_present.current | length == 1 @@ -139,7 +139,7 @@ register: query_anstest_sec_domain - name: Assertions check for query a user domain from a aaa_user - assert: + ansible.builtin.assert: that: - query_anstest_sec_domain is not changed - query_anstest_sec_domain.current | length == 1 @@ -154,7 +154,7 @@ register: query_aaa_user_domains - name: Assertions check for query all user domains from a aaa_user - assert: + ansible.builtin.assert: that: - query_aaa_user_domains is not changed - query_aaa_user_domains.current | length == 1 @@ -167,7 +167,7 @@ register: query_all_aaa_user_domains - name: Assertions check for query all user domains - assert: + ansible.builtin.assert: that: - query_all_aaa_user_domains is not changed - query_all_aaa_user_domains.current | length >= 3 @@ -181,7 +181,7 @@ register: cm_sec_domain_absent - name: Assertions check for removing user domain from a aaa_user with check mode - assert: + ansible.builtin.assert: that: - cm_sec_domain_absent is changed - cm_sec_domain_absent.current | length == 1 @@ -196,7 +196,7 @@ register: nm_sec_domain_absent - name: Assertions check for removing user domain from a aaa_user with normal mode - assert: + ansible.builtin.assert: that: - nm_sec_domain_absent is changed - nm_sec_domain_absent.current == [] @@ -211,7 +211,7 @@ register: idempotency_sec_domain_absent - name: Idempotency assertions check for removing user domain - assert: + ansible.builtin.assert: that: - idempotency_sec_domain_absent is not changed - idempotency_sec_domain_absent.current == [] diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_aaa_user_role/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_aaa_user_role/tasks/main.yml index 4a4d34017..6aaaafbec 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_aaa_user_role/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_aaa_user_role/tasks/main.yml @@ -6,13 +6,13 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined # SET VARS - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: '{{ aci_hostname }}' username: '{{ aci_username }}' @@ -87,7 +87,7 @@ register: cm_user_role_present - name: Assertions check for add user role to "anstest-security-domain" with check mode - assert: + ansible.builtin.assert: that: - cm_user_role_present is changed - cm_user_role_present.current | length == 0 @@ -101,7 +101,7 @@ register: nm_user_role_present - name: Assertions check for add user role to "anstest-security-domain" with normal mode - assert: + ansible.builtin.assert: that: - nm_user_role_present is changed - nm_user_role_present.current | length == 1 @@ -116,7 +116,7 @@ register: cm_idempotency_user_role_present - name: Idempotency assertions check for add user role to "anstest-security-domain" check mode - assert: + ansible.builtin.assert: that: - cm_idempotency_user_role_present is not changed - cm_idempotency_user_role_present.previous | length == 1 @@ -132,7 +132,7 @@ register: idempotency_user_role_present - name: Idempotency assertions check for add user role to "anstest-security-domain" - assert: + ansible.builtin.assert: that: - idempotency_user_role_present is not changed - idempotency_user_role_present.previous | length == 1 @@ -152,7 +152,7 @@ register: user_role_present_sec_domain1 - name: Assertions check for add a user role to "anstest-security-domain-1" - assert: + ansible.builtin.assert: that: - user_role_present_sec_domain1 is changed - user_role_present_sec_domain1.current | length == 1 @@ -169,7 +169,7 @@ register: cm_update_user_role_present - name: Assertions check for update user role to "anstest-security-domain" with check mode - assert: + ansible.builtin.assert: that: - cm_update_user_role_present is changed - cm_update_user_role_present.current | length == 1 @@ -183,7 +183,7 @@ register: update_user_role_present - name: Assertions check for update user role to "anstest-security-domain" with normal mode - assert: + ansible.builtin.assert: that: - update_user_role_present is changed - update_user_role_present.current | length == 1 @@ -217,7 +217,7 @@ register: query_user_role_from_sec_domain - name: Assertions check for query a user role from "anstest-security-domain-1" user domain - assert: + ansible.builtin.assert: that: - query_user_role_from_sec_domain is not changed - query_user_role_from_sec_domain.current | length == 1 @@ -235,7 +235,7 @@ register: query_all_user_roles_of_sec_domain - name: Assertions check for query all user roles from "anstest-security-domain" user domain - assert: + ansible.builtin.assert: that: - query_all_user_roles_of_sec_domain is not changed - query_all_user_roles_of_sec_domain.current | length == 1 @@ -250,7 +250,7 @@ register: query_all_user_roles_from_a_user - name: Assertions check for query all user roles from a user - assert: + ansible.builtin.assert: that: - query_all_user_roles_from_a_user is not changed - query_all_user_roles_from_a_user.current | length == 1 @@ -264,7 +264,7 @@ register: query_all_user_roles - name: Assertions check for query all user roles - assert: + ansible.builtin.assert: that: - query_all_user_roles is not changed - query_all_user_roles.current | length >= 6 # count of user roles including common sec domain user role @@ -281,7 +281,7 @@ register: cm_user_role_absent - name: Assertions check for removing a user role from "anstest-security-domain-1" with check mode - assert: + ansible.builtin.assert: that: - cm_user_role_absent is changed - cm_user_role_absent.current | length == 1 @@ -297,7 +297,7 @@ register: nm_user_role_absent - name: Assertions check for removing a user role from "anstest-security-domain-1" with normal mode - assert: + ansible.builtin.assert: that: - nm_user_role_absent is changed - nm_user_role_absent.current == [] @@ -311,7 +311,7 @@ register: idempotency_user_role_absent - name: Idempotency assertions check for removing a user role from "anstest-security-domain-1" - assert: + ansible.builtin.assert: that: - idempotency_user_role_absent is not changed - idempotency_user_role_absent.current == [] diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_access_port_block_to_access_port/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_access_port_block_to_access_port/tasks/main.yml index 38bda95c8..ad838725f 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_access_port_block_to_access_port/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_access_port_block_to_access_port/tasks/main.yml @@ -1,39 +1,54 @@ # Test code for the ACI modules # Copyright: (c) 2020, Shreyas Srish <ssrish@cisco.com> # Copyright: (c) 2017, Bruno Calogero <brunocalogero@hotmail.com> +# Copyright: (c) 2024, Gaspard Micol (@gmicol) <gmicol@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 APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined +- name: Set vars + ansible.builtin.set_fact: + aci_info: &aci_info + host: "{{ aci_hostname }}" + username: "{{ aci_username }}" + password: "{{ aci_password }}" + validate_certs: '{{ aci_validate_certs | default(false) }}' + use_ssl: '{{ aci_use_ssl | default(true) }}' + use_proxy: '{{ aci_use_proxy | default(true) }}' + output_level: '{{ aci_output_level | default("info") }}' + - name: Verify Cloud and Non-Cloud Sites in use. - include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml - name: Execute tasks only for non-cloud sites when: query_cloud.current == [] # This condition will execute only non-cloud sites block: # block specifies execution of tasks within, based on conditions + + # CLEAN ENVIRONMENT - name: Ensuring Interface Policy Leaf profile does not exist cisco.aci.aci_interface_policy_leaf_profile: &aci_interface_policy_leaf_profile_absent - host: "{{ aci_hostname }}" - username: "{{ aci_username }}" - password: "{{ aci_password }}" - validate_certs: '{{ aci_validate_certs | default(false) }}' - use_ssl: '{{ aci_use_ssl | default(true) }}' - use_proxy: '{{ aci_use_proxy | default(true) }}' - output_level: debug - state: absent + <<: *aci_info leaf_interface_profile: leafintprftest + state: absent register: leaf_profile_present - + - name: Ensuring Interface Policy Leaf profile does not exist on fex cisco.aci.aci_interface_policy_leaf_profile: <<: *aci_interface_policy_leaf_profile_absent type: fex leaf_interface_profile: leafintprftest_fex + - name: Ensuring Interface Policy Spine profile does not exist + cisco.aci.aci_access_spine_interface_profile: &aci_interface_policy_spine_profile_absent + <<: *aci_info + spine_interface_profile: spineintprftest + state: absent + + # CREATE PARENT CLASS OBJECT - name: Ensuring Interface Policy Leaf profile exists for kick off cisco.aci.aci_interface_policy_leaf_profile: <<: *aci_interface_policy_leaf_profile_absent @@ -47,6 +62,11 @@ leaf_interface_profile: leafintprftest_fex state: present + - name: Ensuring Interface Policy Spine profile exists for kick off + cisco.aci.aci_access_spine_interface_profile: + <<: *aci_interface_policy_spine_profile_absent + state: present + - name: Ensure Interface Access Port Selector exists for kick of cisco.aci.aci_access_port_to_interface_policy_leaf_profile: &aci_access_port_to_interface_policy_leaf_profile_present <<: *aci_interface_policy_leaf_profile_absent @@ -60,14 +80,14 @@ leaf_interface_profile: leafintprftest_fex access_port_selector: anstest_accessportselector_fex - # TODO: Ensure that leaf Policy Group Exists (module missing) (infra:AccPortGrp) - # Ensure block does not exist. - - name: Bind an Access Port Block to an Interface Access Port Selector - check mode works - cisco.aci.aci_access_port_block_to_access_port: - <<: *aci_access_port_to_interface_policy_leaf_profile_present - leaf_port_blk: anstest_leafportblkname - state: absent + - name: Ensure Spine Interface Access Port Selector exists for kick of + cisco.aci.aci_access_spine_interface_selector: &aci_access_spine_interface_selector_present + <<: *aci_interface_policy_spine_profile_absent + access_port_selector: anstest_spineaccessportselector + state: present + # CREATION TASKS + # LEAF PORT BLOCK CREATION - name: Bind an Access Port Block to an Interface Access Port Selector - check mode works cisco.aci.aci_access_port_block_to_access_port: &aci_access_port_block_to_access_port_present <<: *aci_access_port_to_interface_policy_leaf_profile_present @@ -103,6 +123,7 @@ toPort: 15 register: accessportblock_to_accessport_update + # LEAF FEX PORT BLOCK CREATION - name: Associate an access port block (single port) to an interface selector on a fex - creation works cisco.aci.aci_access_port_block_to_access_port: <<: *aci_access_port_block_to_access_port_present @@ -152,9 +173,39 @@ toPort: 24 register: accessportblock_to_accessport_present_fex_update + # SPINE PORT BLOCK CREATION + - name: Bind an access port block to an access spine interface selector -check mode works + cisco.aci.aci_access_port_block_to_access_port: &aci_access_port_block_to_spine_access_port_present + <<: *aci_access_spine_interface_selector_present + port_blk: anstest_spineportblkname + port_blk_description: anstest_spineportblkdesc + fromPort: 10 + toPort: 15 + type: spine + state: present + check_mode: true + register: accessportblock_to_spineaccessport_check_mode_present + + - name: Bind an access port block to an access spine interface selector - creation works + cisco.aci.aci_access_port_block_to_access_port: + <<: *aci_access_port_block_to_spine_access_port_present + register: accessportblock_to_spineaccessport_present + + - name: Bind an access port block to an access spine interface selector - idempotency works + cisco.aci.aci_access_port_block_to_access_port: + <<: *aci_access_port_block_to_spine_access_port_present + register: accessportblock_to_spineaccessport_present_idempotent + + - name: Bind an access port block to an access spine interface selector - update works + cisco.aci.aci_access_port_block_to_access_port: + <<: *aci_access_port_block_to_spine_access_port_present + fromPort: 11 + toPort: 16 + register: accessportblock_to_spineaccessport_present_update + # TODO: also test for errors - name: present assertions - create / indempotency / update works - assert: + ansible.builtin.assert: that: - accessportblock_to_accessport_check_mode_present is changed - accessportblock_to_accessport_present is changed @@ -174,6 +225,31 @@ - accessportblock_to_accessport_present_fex.sent.infraPortBlk.attributes.fromPort == '14' - accessportblock_to_accessport_present_fex.sent.infraPortBlk.attributes.toPort == '17' - accessportblock_to_accessport_present_fex_update.sent.infraPortBlk.attributes.toPort == '24' + - accessportblock_to_spineaccessport_check_mode_present is changed + - accessportblock_to_spineaccessport_check_mode_present.previous == [] + - accessportblock_to_spineaccessport_check_mode_present.current == [] + - accessportblock_to_spineaccessport_check_mode_present.proposed.infraPortBlk.attributes.name == "anstest_spineportblkname" + - accessportblock_to_spineaccessport_check_mode_present.proposed.infraPortBlk.attributes.descr == "anstest_spineportblkdesc" + - accessportblock_to_spineaccessport_check_mode_present.proposed.infraPortBlk.attributes.fromPort == "10" + - accessportblock_to_spineaccessport_check_mode_present.proposed.infraPortBlk.attributes.toPort == "15" + - accessportblock_to_spineaccessport_present is changed + - accessportblock_to_spineaccessport_present.previous == [] + - accessportblock_to_spineaccessport_present.current.0.infraPortBlk.attributes.name == "anstest_spineportblkname" + - accessportblock_to_spineaccessport_present.current.0.infraPortBlk.attributes.descr == "anstest_spineportblkdesc" + - accessportblock_to_spineaccessport_present.current.0.infraPortBlk.attributes.fromPort == "10" + - accessportblock_to_spineaccessport_present.current.0.infraPortBlk.attributes.toPort == "15" + - accessportblock_to_spineaccessport_present_idempotent is not changed + - accessportblock_to_spineaccessport_present_idempotent.current == accessportblock_to_spineaccessport_present.current + - accessportblock_to_spineaccessport_present_update is changed + - accessportblock_to_spineaccessport_present_update.current.0.infraPortBlk.attributes.fromPort == "11" + - accessportblock_to_spineaccessport_present_update.current.0.infraPortBlk.attributes.toPort == "16" + + # QUEY TASKS + - name: Query all port block and access_port_selector bindings + cisco.aci.aci_access_port_block_to_access_port: + <<: *aci_info + state: query + register: binding_query_all - name: Query Specific port block and access_port_selector binding cisco.aci.aci_access_port_block_to_access_port: @@ -191,15 +267,30 @@ state: query register: binding_query_fex + - name: Query Specific port block and access_port_selector binding spine + cisco.aci.aci_access_port_block_to_access_port: + <<: *aci_access_spine_interface_selector_present + type: spine + port_blk: anstest_spineportblkname + state: query + register: binding_query_spine + - name: query assertions - assert: + ansible.builtin.assert: that: + - binding_query_all is not changed + - binding_query_all.current | length >= 3 - binding_query is not changed - binding_query_fex is not changed - binding_query_fex.current | length >= 1 - binding_query.current | length >= 1 - - '"api/mo/uni/infra/accportprof-leafintprftest/hports-anstest_accessportselector-typ-range/portblk-anstest_leafportblkname.json" in binding_query.url' + - binding_query_spine is not changed + - binding_query_spine.current.0.infraPortBlk.attributes.name == "anstest_spineportblkname" + - binding_query_spine.current.0.infraPortBlk.attributes.descr == "anstest_spineportblkdesc" + - binding_query_spine.current.0.infraPortBlk.attributes.fromPort == "11" + - binding_query_spine.current.0.infraPortBlk.attributes.toPort == "16" + # DELETE TASKS - name: Remove binding of Access Port Block and Interface Access Port Selector - check mode cisco.aci.aci_access_port_block_to_access_port: &aci_access_port_block_to_access_port_absent <<: *aci_access_port_block_to_access_port_present @@ -217,7 +308,7 @@ <<: *aci_access_port_block_to_access_port_absent register: accessportblock_to_accessport_absent_idempotent - - name: Remove binding of Access Port Block and Interface Access Port Selector - check mode + - name: Remove binding of Access Port Block and Interface Access Port Selector - missing parameter cisco.aci.aci_access_port_block_to_access_port: <<: *aci_access_port_to_interface_policy_leaf_profile_present #leaf_port_blk: anstest_leafportblkname @@ -235,9 +326,14 @@ state: absent register: accessportblock_to_accessport_absent_fex + - name: Remove binding of Access Port Block and Spine Interface Access Port Selector - delete works + cisco.aci.aci_access_port_block_to_access_port: + <<: *aci_access_port_block_to_spine_access_port_present + state: absent + register: accessportblock_to_accessport_absent_spine - name: absent assertions - assert: + ansible.builtin.assert: that: - accessportblock_to_accessport_check_mode_absent is changed - accessportblock_to_accessport_check_mode_absent.previous != [] @@ -248,6 +344,10 @@ - accessportblock_to_accessport_absent_missing_param is failed - 'accessportblock_to_accessport_absent_missing_param.msg == "state is absent but all of the following are missing: port_blk"' - accessportblock_to_accessport_absent_fex is changed + - accessportblock_to_accessport_absent_spine is changed + - accessportblock_to_accessport_absent_spine.previous != [] + - accessportblock_to_accessport_absent_spine.proposed == {} + - accessportblock_to_accessport_absent_spine.current == [] - name: Ensuring Interface Policy Leaf profile does not exist cisco.aci.aci_interface_policy_leaf_profile: @@ -258,4 +358,8 @@ cisco.aci.aci_interface_policy_leaf_profile: <<: *aci_interface_policy_leaf_profile_absent type: fex - leaf_interface_profile: leafintprftest_fex
\ No newline at end of file + leaf_interface_profile: leafintprftest_fex + + - name: Ensuring Interface Policy Spine profile does not exist + cisco.aci.aci_access_spine_interface_profile: + <<: *aci_interface_policy_spine_profile_absent diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_access_port_to_interface_policy_leaf_profile/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_access_port_to_interface_policy_leaf_profile/tasks/main.yml index 2244e0b16..a3005fbd7 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_access_port_to_interface_policy_leaf_profile/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_access_port_to_interface_policy_leaf_profile/tasks/main.yml @@ -5,13 +5,13 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: "Please define the following variables: aci_hostname, aci_username and aci_password." when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined # SET VARS - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: "{{ aci_hostname }}" username: "{{ aci_username }}" @@ -22,7 +22,7 @@ output_level: '{{ aci_output_level | default("info") }}' - name: Verify Cloud and Non-Cloud Sites in use. - include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml - name: Execute tasks only for non-cloud sites when: query_cloud.current == [] # This condition will execute only non-cloud sites @@ -80,7 +80,7 @@ register: fexintprftest_policy_group_present - name: Assertions check for remove fex policy group from the fexintprftest fex profile - assert: + ansible.builtin.assert: that: - fexintprftest_policy_group_present is changed - fexintprftest_policy_group_present.current | length == 1 @@ -141,7 +141,7 @@ # TODO: also test for errors - name: present assertions - assert: + ansible.builtin.assert: that: - accessport_to_intf_check_mode_present is changed - accessport_to_intf_present is changed @@ -180,7 +180,7 @@ register: binding_query_fex - name: present assertions - assert: + ansible.builtin.assert: that: - binding_query is not changed - binding_query_fex is not changed @@ -203,7 +203,7 @@ register: bind_fexintprftest_policy_group - name: Assertions check for bind anstest_fex_accessportselector with fexintprftest - Fex Profile Policy Group - assert: + ansible.builtin.assert: that: - bind_fexintprftest_policy_group is changed - bind_fexintprftest_policy_group.previous | length == 0 @@ -226,7 +226,7 @@ register: bind_fexintprftest_policy_group_2 - name: Assertions check for bind anstest_fex_accessportselector with fexintprftest - Fex Profile Policy Group - assert: + ansible.builtin.assert: that: - bind_fexintprftest_policy_group_2 is changed - bind_fexintprftest_policy_group_2.previous | length == 0 @@ -241,7 +241,7 @@ register: fexintprftest_policy_group_absent - name: Assertions check for remove fex policy group from the fexintprftest fex profile - assert: + ansible.builtin.assert: that: - fexintprftest_policy_group_absent is changed - fexintprftest_policy_group_absent.current | length == 0 @@ -275,7 +275,7 @@ register: accessport_to_intf_absent_fex - name: absent assertions - assert: + ansible.builtin.assert: that: - accessport_to_intf_check_mode_absent is changed - accessport_to_intf_absent_fex is changed @@ -318,7 +318,7 @@ register: cm_fpc_present - name: Assertion check for bind anstest_fex_port_channel Access Port Selector with policygroupname_link_fpc Policy Group - check mode - assert: + ansible.builtin.assert: that: - cm_fpc_present.current | length == 0 - cm_fpc_present.previous | length == 0 @@ -331,7 +331,7 @@ register: nm_fpc_present - name: Assertion check for bind anstest_fex_port_channel Access Port Selector with policygroupname_link_fpc Policy Group - normal mode - assert: + ansible.builtin.assert: that: - nm_fpc_present.current | length == 1 - nm_fpc_present.previous | length == 0 @@ -347,7 +347,7 @@ register: cm_fpc_absent - name: Assertion check for remove anstest_fex_port_channel Access Port Selector with policygroupname_link_fpc Policy Group - check mode - assert: + ansible.builtin.assert: that: - cm_fpc_absent.current | length == 1 - cm_fpc_absent.previous | length == 1 @@ -364,7 +364,7 @@ register: nm_fpc_absent - name: Assertion check for remove anstest_fex_port_channel Access Port Selector with policygroupname_link_fpc Policy Group - normal mode - assert: + ansible.builtin.assert: that: - nm_fpc_absent.current | length == 0 - nm_fpc_absent.previous | length == 1 @@ -380,7 +380,7 @@ register: anstest_fex_vpc_present - name: Assertion check for add anstest_fex_vpc - Interface Policy Leaf Profile with type Fex - assert: + ansible.builtin.assert: that: - anstest_fex_vpc_present.current | length == 1 - anstest_fex_vpc_present.current.0.infraFexP.attributes.name == "anstest_fex_vpc" @@ -397,7 +397,7 @@ register: policygroupname_node_fvpc_present - name: Assertion check for add policygroupname_node_fvpc - Policy Group with lag type node - assert: + ansible.builtin.assert: that: - policygroupname_node_fvpc_present.current | length == 1 - policygroupname_node_fvpc_present.current.0.infraAccBndlGrp.attributes.name == "policygroupname_node_fvpc" @@ -414,7 +414,7 @@ register: cm_fex_vpc_present - name: Assertion check for bind anstest_fex_vpc Access Port Selector with policygroupname_node_fvpc Policy Group - check mode - assert: + ansible.builtin.assert: that: - cm_fex_vpc_present.current | length == 0 - cm_fex_vpc_present.previous | length == 0 @@ -427,7 +427,7 @@ register: nm_fex_vpc_present - name: Assertion check for bind anstest_fex_vpc Access Port Selector with policygroupname_node_fvpc Policy Group - normal mode - assert: + ansible.builtin.assert: that: - nm_fex_vpc_present.current | length == 1 - nm_fex_vpc_present.previous | length == 0 @@ -443,7 +443,7 @@ register: cm_fex_vpc_absent - name: Assertion check for remove anstest_fex_vpc Access Port Selector with policygroupname_node_fvpc Policy Group - check mode - assert: + ansible.builtin.assert: that: - cm_fex_vpc_absent.current | length == 1 - cm_fex_vpc_absent.previous | length == 1 @@ -460,7 +460,7 @@ register: nm_fex_vpc_absent - name: Assertion check for remove anstest_fex_vpc Access Port Selector with policygroupname_node_fvpc Policy Group - normal mode - assert: + ansible.builtin.assert: that: - nm_fex_vpc_absent.current | length == 0 - nm_fex_vpc_absent.previous | length == 1 @@ -476,7 +476,7 @@ register: anstest_fex_vpc_absent - name: Assertion check for remove anstest_fex_vpc - Interface Policy Leaf Profile with type Fex - assert: + ansible.builtin.assert: that: - anstest_fex_vpc_absent.current | length == 0 - anstest_fex_vpc_absent.previous | length == 1 @@ -489,7 +489,7 @@ register: anstest_fex_port_channel_absent - name: Assertion check for remove anstest_fex_port_channel - Interface Policy Leaf Profile with type Fex - assert: + ansible.builtin.assert: that: - anstest_fex_port_channel_absent.current | length == 0 - anstest_fex_port_channel_absent.previous | length == 1 @@ -504,7 +504,7 @@ register: anstest_leaf_profile_absent - name: Assertion check for ensure anstest_leaf_profile interface does not exists - assert: + ansible.builtin.assert: that: - anstest_leaf_profile_absent.current | length == 0 @@ -517,7 +517,7 @@ register: anstest_fex_profile_absent - name: Assertion check for ensure anstest_fex_profile interface does not exists - assert: + ansible.builtin.assert: that: - anstest_fex_profile_absent.current | length == 0 @@ -530,7 +530,7 @@ register: temp_anstest_fex_profile_absent - name: Assertion check for ensure temp_anstest_fex_profile interface does not exists - assert: + ansible.builtin.assert: that: - temp_anstest_fex_profile_absent.current | length == 0 @@ -541,7 +541,7 @@ register: anstest_leaf_profile_present - name: Assertion check for add a new anstest_leaf_profile with profile type leaf - assert: + ansible.builtin.assert: that: - anstest_leaf_profile_present is changed - anstest_leaf_profile_present.current | length == 1 @@ -556,7 +556,7 @@ register: anstest_fex_profile_present - name: Assertion check for add a new anstest_fex_profile with profile type fex - assert: + ansible.builtin.assert: that: - anstest_fex_profile_present is changed - anstest_fex_profile_present.current | length == 1 @@ -571,7 +571,7 @@ register: temp_anstest_fex_profile_present - name: Assertion check for add a new temp_anstest_fex_profile with profile type fex - assert: + ansible.builtin.assert: that: - temp_anstest_fex_profile_present is changed - temp_anstest_fex_profile_present.current | length == 1 @@ -589,7 +589,7 @@ register: temp_anstest_fex_profile_policy_group_present - name: Assertion check for add a new policy_group with the same name of interface profile - temp_anstest_fex_profile - assert: + ansible.builtin.assert: that: - temp_anstest_fex_profile_policy_group_present is changed - temp_anstest_fex_profile_policy_group_present.current | length == 1 @@ -611,7 +611,7 @@ ignore_errors: true - name: Assertion check for bind temp_anstest_fex_profile with anstest_fex_profile - Fex Profile Policy Group - assert: + ansible.builtin.assert: that: - temp_anstest_fex_profile_access_port_present.msg == "Invalid Configuration - interface_type fex_profile can not be configured with a profile of type fex" @@ -621,7 +621,7 @@ register: remove_anstest_fex_profile_absent - name: Assertion check for remove temp_anstest_fex_profile - assert: + ansible.builtin.assert: that: - remove_anstest_fex_profile_absent is changed - remove_anstest_fex_profile_absent.current | length == 0 @@ -637,7 +637,7 @@ register: anstest_fex_profile_policy_group_present - name: Assertion check for add a new policy_group with the same name of interface profile - anstest_fex_profile - assert: + ansible.builtin.assert: that: - anstest_fex_profile_policy_group_present is changed - anstest_fex_profile_policy_group_present.current | length == 1 @@ -659,7 +659,7 @@ register: anstest_leaf_profile_access_port_present - name: Assertion check for bind anstest_leaf_profile with anstest_fex_profile - Fex Profile Policy Group - assert: + ansible.builtin.assert: that: - anstest_leaf_profile_access_port_present is changed - anstest_leaf_profile_access_port_present.current | length == 1 @@ -682,7 +682,7 @@ register: anstest_leaf_profile_access_port_wrong_fex_id - name: Assertion check for bind anstest_leaf_profile with wrong fex_id - assert: + ansible.builtin.assert: that: - anstest_leaf_profile_access_port_wrong_fex_id.msg == "A valid FEX ID is between 101 to 199" @@ -699,7 +699,7 @@ register: anstest_leaf_profile_access_port_no_fex_id - name: Assertion check for bind anstest_leaf_profile with no fex_id - assert: + ansible.builtin.assert: that: - anstest_leaf_profile_access_port_no_fex_id.msg == "The fex_id must not be None, when interface_type is fex_profile" @@ -709,7 +709,7 @@ register: anstest_leaf_profile_cleanup - name: Assertion check for remove anstest_leaf_profile - assert: + ansible.builtin.assert: that: - anstest_leaf_profile_cleanup is changed - anstest_leaf_profile_cleanup.previous | length == 1 @@ -721,7 +721,7 @@ register: anstest_fex_profile_cleanup - name: Assertion check for remove anstest_fex_profile - assert: + ansible.builtin.assert: that: - anstest_fex_profile_cleanup is changed - anstest_fex_profile_cleanup.previous | length == 1 diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_access_span_dst_group/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_access_span_dst_group/tasks/main.yml index 03c2e92c2..1c4329f4b 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_access_span_dst_group/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_access_span_dst_group/tasks/main.yml @@ -4,7 +4,7 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_access_span_filter_group/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_access_span_filter_group/tasks/main.yml index c071f747a..4f04e42ed 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_access_span_filter_group/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_access_span_filter_group/tasks/main.yml @@ -4,7 +4,7 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined @@ -20,7 +20,7 @@ output_level: '{{ aci_output_level | default("info") }}' - name: Verify Cloud and Non-Cloud Sites in use. - include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml - name: Execute tasks only for non-cloud sites when: diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_access_span_filter_group_entry/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_access_span_filter_group_entry/tasks/main.yml index 788658f13..421956534 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_access_span_filter_group_entry/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_access_span_filter_group_entry/tasks/main.yml @@ -4,7 +4,7 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined @@ -20,7 +20,7 @@ output_level: '{{ aci_output_level | default("info") }}' - name: Verify Cloud and Non-Cloud Sites in use. - include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml - name: Execute tasks only for non-cloud sites when: diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_access_span_src_group/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_access_span_src_group/tasks/main.yml index e2d00e525..b55d5ced0 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_access_span_src_group/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_access_span_src_group/tasks/main.yml @@ -4,12 +4,12 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: "{{ aci_hostname }}" username: "{{ aci_username }}" @@ -20,7 +20,7 @@ output_level: '{{ aci_output_level | default("info") }}' - name: Verify Cloud and Non-Cloud Sites in use. - include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml # CLEAN TEST ENVIRONMENT BEFORE TESTS diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_access_span_src_group_src/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_access_span_src_group_src/tasks/main.yml index a0fe48f08..ce033f911 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_access_span_src_group_src/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_access_span_src_group_src/tasks/main.yml @@ -4,12 +4,12 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: "{{ aci_hostname }}" username: "{{ aci_username }}" @@ -20,7 +20,7 @@ output_level: '{{ aci_output_level | default("info") }}' - name: Verify Cloud and Non-Cloud Sites in use. - include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml # CLEAN TEST ENVIRONMENT BEFORE TESTS diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_access_span_src_group_src_path/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_access_span_src_group_src_path/tasks/main.yml index f370b1323..3196e78de 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_access_span_src_group_src_path/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_access_span_src_group_src_path/tasks/main.yml @@ -4,12 +4,12 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: "{{ aci_hostname }}" username: "{{ aci_username }}" diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_access_spine_interface_profile/aliases b/ansible_collections/cisco/aci/tests/integration/targets/aci_access_spine_interface_profile/aliases new file mode 100644 index 000000000..209b793f9 --- /dev/null +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_access_spine_interface_profile/aliases @@ -0,0 +1,2 @@ +# No ACI simulator yet, so not enabled +# unsupported diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_access_spine_interface_profile/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_access_spine_interface_profile/tasks/main.yml new file mode 100644 index 000000000..9f43513f0 --- /dev/null +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_access_spine_interface_profile/tasks/main.yml @@ -0,0 +1,183 @@ +# Test code for the ACI modules +# Copyright: (c) 2023, Eric Girard <@netgirard> +# Copyright: (c) 2024, Gaspard Micol (@gmicol) <gmicol@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 APIC host, ACI username and ACI password + ansible.builtin.fail: + msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' + when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined + +- name: Set vars + ansible.builtin.set_fact: + aci_info: &aci_info + host: "{{ aci_hostname }}" + username: "{{ aci_username }}" + password: "{{ aci_password }}" + validate_certs: '{{ aci_validate_certs | default(false) }}' + use_ssl: '{{ aci_use_ssl | default(true) }}' + use_proxy: '{{ aci_use_proxy | default(true) }}' + output_level: '{{ aci_output_level | default("info") }}' + +- name: Verify Cloud and Non-Cloud Sites in use. + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + +- name: Execute tasks only for non-cloud sites + when: query_cloud.current == [] # This condition will execute only non-cloud sites + block: # block specifies execution of tasks within, based on conditions + # CLEAN ENVIRONMENT + - name: Remove all Access Spine Interface profiles + cisco.aci.aci_access_spine_interface_profile: &aci_access_spine_interface_profile_all_absent + <<: *aci_info + spine_interface_profile: "{{ item }}" + state: absent + loop: + - ansible_access_spine_interface_profile_1 + - ansible_access_spine_interface_profile_2 + + # CREATE ACCESS SPINE INTERFACE PROFILE + - name: Add a new Access Spine Interface Profile (check_mode) + cisco.aci.aci_access_spine_interface_profile: &aci_access_spine_interface_profile_present + <<: *aci_info + spine_interface_profile: ansible_access_spine_interface_profile_1 + description: Access Spine Interface Profile 1 + state: present + check_mode: true + register: cm_add_spine_interface_profile + + - name: Add a new Access Spine Interface Profile (normal_mode) + cisco.aci.aci_access_spine_interface_profile: + <<: *aci_access_spine_interface_profile_present + register: nm_add_spine_interface_profile + + - name: Add the first Access Spine Interface Profile again - testing idempotency + cisco.aci.aci_access_spine_interface_profile: + <<: *aci_access_spine_interface_profile_present + register: nm_add_spine_interface_profile_idempotency + + - name: Add a second Access Spine Interface Profile (normal_mode) + cisco.aci.aci_access_spine_interface_profile: &aci_access_spine_interface_profile_2_present + <<: *aci_info + spine_interface_profile: ansible_access_spine_interface_profile_2 + description: Access Spine Interface Profile 2 + state: present + register: nm_add_spine_interface_profile_2 + + - name: Asserts for Access Spine Interface Profile creation tasks + ansible.builtin.assert: + that: + - cm_add_spine_interface_profile is changed + - cm_add_spine_interface_profile.previous == [] + - cm_add_spine_interface_profile.current == [] + - cm_add_spine_interface_profile.proposed.infraSpAccPortP.attributes.name == "ansible_access_spine_interface_profile_1" + - cm_add_spine_interface_profile.proposed.infraSpAccPortP.attributes.descr == "Access Spine Interface Profile 1" + - nm_add_spine_interface_profile is changed + - nm_add_spine_interface_profile.previous == [] + - nm_add_spine_interface_profile.current.0.infraSpAccPortP.attributes.name == "ansible_access_spine_interface_profile_1" + - nm_add_spine_interface_profile.current.0.infraSpAccPortP.attributes.descr == "Access Spine Interface Profile 1" + - nm_add_spine_interface_profile.current.0.infraSpAccPortP.attributes.dn == "uni/infra/spaccportprof-ansible_access_spine_interface_profile_1" + - nm_add_spine_interface_profile_idempotency is not changed + - nm_add_spine_interface_profile_idempotency.current.0.infraSpAccPortP.attributes.name == "ansible_access_spine_interface_profile_1" + - nm_add_spine_interface_profile_idempotency.current.0.infraSpAccPortP.attributes.descr == "Access Spine Interface Profile 1" + - nm_add_spine_interface_profile_idempotency.current.0.infraSpAccPortP.attributes.dn == "uni/infra/spaccportprof-ansible_access_spine_interface_profile_1" + - nm_add_spine_interface_profile_2 is changed + - nm_add_spine_interface_profile_2.previous == [] + - nm_add_spine_interface_profile_2.current.0.infraSpAccPortP.attributes.name == "ansible_access_spine_interface_profile_2" + - nm_add_spine_interface_profile_2.current.0.infraSpAccPortP.attributes.descr == "Access Spine Interface Profile 2" + - nm_add_spine_interface_profile_2.current.0.infraSpAccPortP.attributes.dn == "uni/infra/spaccportprof-ansible_access_spine_interface_profile_2" + + # QUERY ACCESS SPINE INTERFACE PROFILE + - name: Query all Access Spine Interface Profiles + cisco.aci.aci_access_spine_interface_profile: + <<: *aci_info + state: query + register: query_all_spine_interface_profile + + - name: Query ansible_access_spine_interface_profile_1 + cisco.aci.aci_access_spine_interface_profile: + <<: *aci_access_spine_interface_profile_present + state: query + register: query_ansible_access_spine_interface_profile_1 + + - name: Asserts query tasks + ansible.builtin.assert: + that: + - query_all_spine_interface_profile is not changed + - query_all_spine_interface_profile.current|length >= 2 + - query_ansible_access_spine_interface_profile_1 is not changed + - query_ansible_access_spine_interface_profile_1.current|length == 1 + - query_ansible_access_spine_interface_profile_1.current.0.infraSpAccPortP.attributes.name == "ansible_access_spine_interface_profile_1" + - query_ansible_access_spine_interface_profile_1.current.0.infraSpAccPortP.attributes.descr == "Access Spine Interface Profile 1" + - query_ansible_access_spine_interface_profile_1.current.0.infraSpAccPortP.attributes.dn == "uni/infra/spaccportprof-ansible_access_spine_interface_profile_1" + + # UPDATE ACCESS SPINE INTERFACE PROFILE + - name: Update first Access Spine Interface Profile (check_mode) + cisco.aci.aci_access_spine_interface_profile: &aci_access_spine_interface_profile_update + <<: *aci_access_spine_interface_profile_present + description: Updated description for first ansible Access Spine Interface Profile + check_mode: true + register: cm_update_spine_interface_profile + + - name: Update first Access Spine Interface Profile (normal_mode) + cisco.aci.aci_access_spine_interface_profile: + <<: *aci_access_spine_interface_profile_update + register: nm_update_spine_interface_profile + + - name: Update first Access Spine Interface Profile again - testing idempotency + cisco.aci.aci_access_spine_interface_profile: + <<: *aci_access_spine_interface_profile_update + register: nm_udpate_spine_interface_profile_idempotency + + - name: Asserts for Access Spine Interface Profile update tasks + ansible.builtin.assert: + that: + - cm_update_spine_interface_profile is changed + - cm_update_spine_interface_profile.previous == cm_update_spine_interface_profile.current + - cm_update_spine_interface_profile.proposed.infraSpAccPortP.attributes.descr == "Updated description for first ansible Access Spine Interface Profile" + - nm_update_spine_interface_profile is changed + - nm_update_spine_interface_profile.current.0.infraSpAccPortP.attributes.name == "ansible_access_spine_interface_profile_1" + - nm_update_spine_interface_profile.current.0.infraSpAccPortP.attributes.descr == "Updated description for first ansible Access Spine Interface Profile" + - nm_udpate_spine_interface_profile_idempotency is not changed + - nm_udpate_spine_interface_profile_idempotency.current.0.infraSpAccPortP.attributes.name == "ansible_access_spine_interface_profile_1" + - nm_udpate_spine_interface_profile_idempotency.current.0.infraSpAccPortP.attributes.descr == "Updated description for first ansible Access Spine Interface Profile" + + # DELETE ACCESS SPINE INTERFACE PROFILE + - name: Remove Access Spine Interface Profile (check_mode) + cisco.aci.aci_access_spine_interface_profile: &aci_access_spine_interface_profile_absent + <<: *aci_access_spine_interface_profile_update + state: absent + check_mode: true + register: cm_remove_spine_interface_profile + + - name: Remove Access Spine Interface Profile (normal_mode) + cisco.aci.aci_access_spine_interface_profile: + <<: *aci_access_spine_interface_profile_absent + register: nm_remove_spine_interface_profile + + - name: Remove Access Spine Interface Profile - testing idempotency + cisco.aci.aci_access_spine_interface_profile: + <<: *aci_access_spine_interface_profile_absent + register: nm_remove_spine_interface_profile_idempotency + + - name: Asserts deletion tasks + ansible.builtin.assert: + that: + - cm_remove_spine_interface_profile is changed + - cm_remove_spine_interface_profile.current == cm_remove_spine_interface_profile.previous + - cm_remove_spine_interface_profile.proposed == {} + - nm_remove_spine_interface_profile is changed + - nm_remove_spine_interface_profile.previous != [] + - nm_remove_spine_interface_profile.proposed == {} + - nm_remove_spine_interface_profile.current == [] + - nm_remove_spine_interface_profile_idempotency is not changed + - nm_remove_spine_interface_profile_idempotency.previous == [] + - nm_remove_spine_interface_profile_idempotency.current == [] + + # CLEAN ENVIRONMENT BEFORE ENDING TESTS + - name: Remove all Access Spine Interface profiles - cleanup before ending tests + cisco.aci.aci_access_spine_interface_profile: + <<: *aci_access_spine_interface_profile_all_absent + loop: + - ansible_access_spine_interface_profile_1 + - ansible_access_spine_interface_profile_2 diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_access_spine_interface_profile_to_spine_switch_profile/aliases b/ansible_collections/cisco/aci/tests/integration/targets/aci_access_spine_interface_profile_to_spine_switch_profile/aliases new file mode 100644 index 000000000..209b793f9 --- /dev/null +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_access_spine_interface_profile_to_spine_switch_profile/aliases @@ -0,0 +1,2 @@ +# No ACI simulator yet, so not enabled +# unsupported diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_access_spine_interface_profile_to_spine_switch_profile/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_access_spine_interface_profile_to_spine_switch_profile/tasks/main.yml new file mode 100644 index 000000000..00f3b48fe --- /dev/null +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_access_spine_interface_profile_to_spine_switch_profile/tasks/main.yml @@ -0,0 +1,176 @@ +# Test code for the ACI modules +# Copyright: (c) 2023, Eric Girard <@netgirard> +# Copyright: (c) 2024, Gaspard Micol (@gmicol) <gmicol@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 APIC host, ACI username and ACI password + ansible.builtin.fail: + msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' + when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined + +- name: Set vars + ansible.builtin.set_fact: + aci_info: &aci_info + host: "{{ aci_hostname }}" + username: "{{ aci_username }}" + password: "{{ aci_password }}" + validate_certs: '{{ aci_validate_certs | default(false) }}' + use_ssl: '{{ aci_use_ssl | default(true) }}' + use_proxy: '{{ aci_use_proxy | default(true) }}' + output_level: '{{ aci_output_level | default("info") }}' + +- name: Verify Cloud and Non-Cloud Sites in use. + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + +- name: Execute tasks only for non-cloud sites + when: query_cloud.current == [] # This condition will execute only non-cloud sites + block: # block specifies execution of tasks within, based on conditions + # CLEAN ENVIRONMENT + - name: Remove Access Spine Switch profile + cisco.aci.aci_access_spine_switch_profile: &aci_access_spine_switch_profile_absent + <<: *aci_info + spine_switch_profile: ansible_access_spine_switch_profile + state: absent + + - name: Remove all Access Spine Interface Profiles + cisco.aci.aci_access_spine_interface_profile: &aci_access_spine_interface_profile_all_absent + <<: *aci_info + spine_interface_profile: "{{ item }}" + state: absent + loop: + - ansible_access_spine_interface_profile_1 + - ansible_access_spine_interface_profile_2 + + # CREATE ACCESS SPINE SWITCH AND INTERFACE PROFILES + - name: Add Access Spine Switch profile + cisco.aci.aci_access_spine_switch_profile: + <<: *aci_access_spine_switch_profile_absent + state: present + + - name: Add Access Spine Interface Profiles + cisco.aci.aci_access_spine_interface_profile: + <<: *aci_access_spine_interface_profile_all_absent + state: present + loop: + - ansible_access_spine_interface_profile_1 + - ansible_access_spine_interface_profile_2 + + # CREATE BINDING BETWEEN SPINE INTERFACE AND SWITCH PROFILES + - name: Add a new Binding between Spine Interface and Switch Profiles (check_mode) + cisco.aci.aci_access_spine_interface_profile_to_spine_switch_profile: &aci_access_spine_interface_profile_to_spine_switch_profile_present + <<: *aci_info + spine_switch_profile: ansible_access_spine_switch_profile + spine_interface_profile: ansible_access_spine_interface_profile_1 + state: present + check_mode: true + register: cm_add_binding_spine_interface_to_switch + + - name: Add a new Binding between Spine Interface and Switch Profiles (normal_mode) + cisco.aci.aci_access_spine_interface_profile_to_spine_switch_profile: + <<: *aci_access_spine_interface_profile_to_spine_switch_profile_present + register: nm_add_binding_spine_interface_to_switch + + - name: Add the first Binding between Spine Interface and Switch Profiles again - testing idempotency + cisco.aci.aci_access_spine_interface_profile_to_spine_switch_profile: + <<: *aci_access_spine_interface_profile_to_spine_switch_profile_present + register: nm_add_binding_spine_interface_to_switch_idempotency + + - name: Add a second Binding between Spine Interface and Switch Profiles (normal_mode) + cisco.aci.aci_access_spine_interface_profile_to_spine_switch_profile: &aci_access_spine_interface_profile_to_spine_switch_profile_2_present + <<: *aci_info + spine_switch_profile: ansible_access_spine_switch_profile + spine_interface_profile: ansible_access_spine_interface_profile_2 + state: present + register: nm_add_binding_spine_interface_to_switch_2 + + - name: Asserts for Binding between Spine Interface and Switch Profiles creation tasks + ansible.builtin.assert: + that: + - cm_add_binding_spine_interface_to_switch is changed + - cm_add_binding_spine_interface_to_switch.previous == [] + - cm_add_binding_spine_interface_to_switch.current == [] + - cm_add_binding_spine_interface_to_switch.proposed.infraRsSpAccPortP.attributes.dn == "uni/infra/spprof-ansible_access_spine_switch_profile/rsspAccPortP-[uni/infra/spaccportprof-ansible_access_spine_interface_profile_1]" + - cm_add_binding_spine_interface_to_switch.proposed.infraRsSpAccPortP.attributes.tDn == "uni/infra/spaccportprof-ansible_access_spine_interface_profile_1" + - nm_add_binding_spine_interface_to_switch is changed + - nm_add_binding_spine_interface_to_switch.previous == [] + - nm_add_binding_spine_interface_to_switch.current.0.infraRsSpAccPortP.attributes.dn == "uni/infra/spprof-ansible_access_spine_switch_profile/rsspAccPortP-[uni/infra/spaccportprof-ansible_access_spine_interface_profile_1]" + - nm_add_binding_spine_interface_to_switch.current.0.infraRsSpAccPortP.attributes.tDn == "uni/infra/spaccportprof-ansible_access_spine_interface_profile_1" + - nm_add_binding_spine_interface_to_switch_idempotency is not changed + - nm_add_binding_spine_interface_to_switch_idempotency.current.0.infraRsSpAccPortP.attributes.dn == "uni/infra/spprof-ansible_access_spine_switch_profile/rsspAccPortP-[uni/infra/spaccportprof-ansible_access_spine_interface_profile_1]" + - nm_add_binding_spine_interface_to_switch_idempotency.current.0.infraRsSpAccPortP.attributes.tDn == "uni/infra/spaccportprof-ansible_access_spine_interface_profile_1" + - nm_add_binding_spine_interface_to_switch_2 is changed + - nm_add_binding_spine_interface_to_switch_2.previous == [] + - nm_add_binding_spine_interface_to_switch_2.proposed.infraRsSpAccPortP.attributes.dn == "uni/infra/spprof-ansible_access_spine_switch_profile/rsspAccPortP-[uni/infra/spaccportprof-ansible_access_spine_interface_profile_2]" + - nm_add_binding_spine_interface_to_switch_2.proposed.infraRsSpAccPortP.attributes.tDn == "uni/infra/spaccportprof-ansible_access_spine_interface_profile_2" + - nm_add_binding_spine_interface_to_switch_2.current.0.infraRsSpAccPortP.attributes.dn == "uni/infra/spprof-ansible_access_spine_switch_profile/rsspAccPortP-[uni/infra/spaccportprof-ansible_access_spine_interface_profile_2]" + - nm_add_binding_spine_interface_to_switch_2.current.0.infraRsSpAccPortP.attributes.tDn == "uni/infra/spaccportprof-ansible_access_spine_interface_profile_2" + + # QUERY BINDING BETWEEN SPINE INTERFACE AND SWITCH PROFILES + - name: Query all Binding between Spine Interface Profiles and ansible_access_spine_switch_profile + cisco.aci.aci_access_spine_interface_profile_to_spine_switch_profile: + <<: *aci_info + spine_switch_profile: ansible_access_spine_switch_profile + state: query + register: query_all_binding_spine_interface_to_switch + + - name: Query Binding ansible_access_spine_interface_profile_1 to ansible_access_spine_switch_profile + cisco.aci.aci_access_spine_interface_profile_to_spine_switch_profile: + <<: *aci_access_spine_interface_profile_to_spine_switch_profile_present + state: query + register: query_binding_spine_interface_to_switch + + - name: Asserts query tasks + ansible.builtin.assert: + that: + - query_all_binding_spine_interface_to_switch is not changed + - query_all_binding_spine_interface_to_switch.current.0.infraSpineP.children|length >= 2 + - query_binding_spine_interface_to_switch is not changed + - query_binding_spine_interface_to_switch.current.0.infraSpineP.children|length == 1 + - query_binding_spine_interface_to_switch.current.0.infraSpineP.children.0.infraRsSpAccPortP.attributes.rn == "rsspAccPortP-[uni/infra/spaccportprof-ansible_access_spine_interface_profile_1]" + - query_binding_spine_interface_to_switch.current.0.infraSpineP.children.0.infraRsSpAccPortP.attributes.tDn == "uni/infra/spaccportprof-ansible_access_spine_interface_profile_1" + - query_binding_spine_interface_to_switch.current.0.infraSpineP.children.0.infraRsSpAccPortP.attributes.state == "formed" + + # DELETE BINDING BETWEEN SPINE INTERFACE AND SWITCH PROFILES + - name: Remove Binding between Spine Interface and Switch Profiles (check_mode) + cisco.aci.aci_access_spine_interface_profile_to_spine_switch_profile: &aci_access_spine_interface_profile_to_spine_switch_profile_absent + <<: *aci_access_spine_interface_profile_to_spine_switch_profile_present + state: absent + check_mode: true + register: cm_remove_binding_spine_interface_to_switch + + - name: Remove Binding between Spine Interface and Switch Profiles (normal_mode) + cisco.aci.aci_access_spine_interface_profile_to_spine_switch_profile: + <<: *aci_access_spine_interface_profile_to_spine_switch_profile_absent + register: nm_remove_binding_spine_interface_to_switch + + - name: Remove Binding between Spine Interface and Switch Profiles - testing idempotency + cisco.aci.aci_access_spine_interface_profile_to_spine_switch_profile: + <<: *aci_access_spine_interface_profile_to_spine_switch_profile_absent + register: nm_remove_binding_spine_interface_to_switch_idempotency + + - name: Asserts deletion tasks + ansible.builtin.assert: + that: + - cm_remove_binding_spine_interface_to_switch is changed + - cm_remove_binding_spine_interface_to_switch.current == cm_remove_binding_spine_interface_to_switch.previous + - cm_remove_binding_spine_interface_to_switch.proposed == {} + - nm_remove_binding_spine_interface_to_switch is changed + - nm_remove_binding_spine_interface_to_switch.previous != [] + - nm_remove_binding_spine_interface_to_switch.proposed == {} + - nm_remove_binding_spine_interface_to_switch.current == [] + - nm_remove_binding_spine_interface_to_switch_idempotency is not changed + - nm_remove_binding_spine_interface_to_switch_idempotency.previous == [] + - nm_remove_binding_spine_interface_to_switch_idempotency.current == [] + + # CLEAN ENVIRONMENT BEFORE ENDING TESTS + - name: Remove Access Spine Switch profile - cleanup before ending tests + cisco.aci.aci_access_spine_interface_profile: + <<: *aci_access_spine_interface_profile_all_absent + loop: + - ansible_access_spine_interface_profile_1 + - ansible_access_spine_interface_profile_2 + + - name: Remove all Access Spine Interface Profiles - cleanup before ending tests + cisco.aci.aci_access_spine_switch_profile: + <<: *aci_access_spine_switch_profile_absent diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_access_spine_interface_selector/aliases b/ansible_collections/cisco/aci/tests/integration/targets/aci_access_spine_interface_selector/aliases new file mode 100644 index 000000000..209b793f9 --- /dev/null +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_access_spine_interface_selector/aliases @@ -0,0 +1,2 @@ +# No ACI simulator yet, so not enabled +# unsupported diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_access_spine_interface_selector/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_access_spine_interface_selector/tasks/main.yml new file mode 100644 index 000000000..255357168 --- /dev/null +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_access_spine_interface_selector/tasks/main.yml @@ -0,0 +1,204 @@ +# Test code for the ACI modules +# Copyright: (c) 2024, Gaspard Micol (@gmicol) <gmicol@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 APIC host, ACI username and ACI password + ansible.builtin.fail: + msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' + when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined + +- name: Set vars + ansible.builtin.set_fact: + aci_info: &aci_info + host: "{{ aci_hostname }}" + username: "{{ aci_username }}" + password: "{{ aci_password }}" + validate_certs: '{{ aci_validate_certs | default(false) }}' + use_ssl: '{{ aci_use_ssl | default(true) }}' + use_proxy: '{{ aci_use_proxy | default(true) }}' + output_level: '{{ aci_output_level | default("info") }}' + +- name: Verify Cloud and Non-Cloud Sites in use. + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + +- name: Execute tasks only for non-cloud sites + when: query_cloud.current == [] # This condition will execute only non-cloud sites + block: # block specifies execution of tasks within, based on conditions + # CLEAN ENVIRONMENT + - name: Remove the ansible_access_spine_interface_profile + cisco.aci.aci_access_spine_interface_profile: &aci_access_spine_interface_profile_absent + <<: *aci_info + spine_interface_profile: ansible_access_spine_interface_profile + description: Ansible Access Spine Interface Profile + state: absent + + - name: Add a new Access Spine Interface profile + cisco.aci.aci_access_spine_interface_profile: &aci_access_spine_interface_profile_present + <<: *aci_access_spine_interface_profile_absent + state: present + + # CREATE ACCESS SPINE INTERFACE SELECTOR + - name: Add a new Access Spine Interface Selector (check_mode) + cisco.aci.aci_access_spine_interface_selector: &aci_access_spine_interface_selector_present + <<: *aci_info + spine_interface_profile: ansible_access_spine_interface_profile + spine_interface_selector: ansible_access_spine_interface_selector_1 + description: Access Spine Interface Selector 1 + selector_type: range + state: present + check_mode: true + register: cm_add_spine_interface_selector + + - name: Add a new Access Spine Interface Selector (normal_mode) + cisco.aci.aci_access_spine_interface_selector: + <<: *aci_access_spine_interface_selector_present + register: nm_add_spine_interface_selector + + - name: Add the first Access Spine Interface Selector again - testing idempotency + cisco.aci.aci_access_spine_interface_selector: + <<: *aci_access_spine_interface_selector_present + register: nm_add_spine_interface_selector_idempotency + + - name: Add a second Access Spine Interface Selector (normal_mode) + cisco.aci.aci_access_spine_interface_selector: &aci_access_spine_interface_selector_2_present + <<: *aci_info + spine_interface_profile: ansible_access_spine_interface_profile + spine_interface_selector: ansible_access_spine_interface_selector_2 + description: Access Spine Interface Selector 2 + selector_type: range + state: present + register: nm_add_spine_interface_selector_2 + + - name: Asserts for Access Spine Interface Selector creation tasks + ansible.builtin.assert: + that: + - cm_add_spine_interface_selector is changed + - cm_add_spine_interface_selector.previous == [] + - cm_add_spine_interface_selector.current == [] + - cm_add_spine_interface_selector.proposed.infraSHPortS.attributes.name == "ansible_access_spine_interface_selector_1" + - cm_add_spine_interface_selector.proposed.infraSHPortS.attributes.descr == "Access Spine Interface Selector 1" + - cm_add_spine_interface_selector.proposed.infraSHPortS.attributes.type == "range" + - nm_add_spine_interface_selector is changed + - nm_add_spine_interface_selector.previous == [] + - nm_add_spine_interface_selector.current.0.infraSHPortS.attributes.name == "ansible_access_spine_interface_selector_1" + - nm_add_spine_interface_selector.current.0.infraSHPortS.attributes.descr == "Access Spine Interface Selector 1" + - nm_add_spine_interface_selector.current.0.infraSHPortS.attributes.type == "range" + - nm_add_spine_interface_selector_idempotency is not changed + - nm_add_spine_interface_selector_idempotency.current.0.infraSHPortS.attributes.name == "ansible_access_spine_interface_selector_1" + - nm_add_spine_interface_selector_idempotency.current.0.infraSHPortS.attributes.descr == "Access Spine Interface Selector 1" + - nm_add_spine_interface_selector_idempotency.current.0.infraSHPortS.attributes.type == "range" + - nm_add_spine_interface_selector_2 is changed + - nm_add_spine_interface_selector_2.previous == [] + - nm_add_spine_interface_selector_2.current.0.infraSHPortS.attributes.name == "ansible_access_spine_interface_selector_2" + - nm_add_spine_interface_selector_2.current.0.infraSHPortS.attributes.descr == "Access Spine Interface Selector 2" + - nm_add_spine_interface_selector_2.current.0.infraSHPortS.attributes.type == "range" + + # QUERY ACCESS SPINE INTERFACE SELECTOR + - name: Query all Access Spine Interface Selectors + cisco.aci.aci_access_spine_interface_selector: + <<: *aci_info + state: query + register: query_all_spine_interface_selector + + - name: Query ansible_access_spine_interface_selector_1 + cisco.aci.aci_access_spine_interface_selector: + <<: *aci_access_spine_interface_selector_present + state: query + register: query_ansible_access_spine_interface_selector_1 + + - name: Asserts query tasks + ansible.builtin.assert: + that: + - query_all_spine_interface_selector is not changed + - query_all_spine_interface_selector.current|length >= 2 + - query_ansible_access_spine_interface_selector_1 is not changed + - query_ansible_access_spine_interface_selector_1.current|length == 1 + - query_ansible_access_spine_interface_selector_1.current.0.infraSpAccPortP.children.0.infraSHPortS.attributes.name == "ansible_access_spine_interface_selector_1" + - query_ansible_access_spine_interface_selector_1.current.0.infraSpAccPortP.children.0.infraSHPortS.attributes.descr == "Access Spine Interface Selector 1" + - query_ansible_access_spine_interface_selector_1.current.0.infraSpAccPortP.children.0.infraSHPortS.attributes.type == "range" + + # UPDATE ACCESS SPINE INTERFACE SELECTOR + - name: Add a new Access Spine Interface policy Group + cisco.aci.aci_interface_policy_spine_policy_group: &aci_interface_policy_spine_policy_group_present + <<: *aci_info + policy_group: ansible_access_spine_interface_policy_group + description: Ansible Access Spine Interface Policy Group + state: present + + - name: Update first Access Spine Interface Selector by adding a Policy Group (check_mode) + cisco.aci.aci_access_spine_interface_selector: &aci_access_spine_interface_selector_update + <<: *aci_access_spine_interface_selector_present + description: Updated description for first ansible Access Spine Interface Selector + policy_group: ansible_access_spine_interface_policy_group + check_mode: true + register: cm_update_spine_interface_selector + + - name: Update first Access Spine Interface Selector by adding a Policy Group (normal_mode) + cisco.aci.aci_access_spine_interface_selector: + <<: *aci_access_spine_interface_selector_update + register: nm_update_spine_interface_selector + + - name: Update first Access Spine Interface Selector by adding a Policy Group again - testing idempotency + cisco.aci.aci_access_spine_interface_selector: + <<: *aci_access_spine_interface_selector_update + register: nm_udpate_spine_interface_selector_idempotency + + - name: Asserts for Access Spine Interface Selector update tasks + ansible.builtin.assert: + that: + - cm_update_spine_interface_selector is changed + - cm_update_spine_interface_selector.previous == cm_update_spine_interface_selector.current + - cm_update_spine_interface_selector.proposed.infraSHPortS.attributes.descr == "Updated description for first ansible Access Spine Interface Selector" + - cm_update_spine_interface_selector.proposed.infraSHPortS.children.0.infraRsSpAccGrp.attributes.tDn == "uni/infra/funcprof/spaccportgrp-ansible_access_spine_interface_policy_group" + - nm_update_spine_interface_selector is changed + - nm_update_spine_interface_selector.current.0.infraSHPortS.attributes.name == "ansible_access_spine_interface_selector_1" + - nm_update_spine_interface_selector.current.0.infraSHPortS.attributes.descr == "Updated description for first ansible Access Spine Interface Selector" + - nm_update_spine_interface_selector.current.0.infraSHPortS.children.0.infraRsSpAccGrp.attributes.tDn == "uni/infra/funcprof/spaccportgrp-ansible_access_spine_interface_policy_group" + - nm_udpate_spine_interface_selector_idempotency is not changed + - nm_udpate_spine_interface_selector_idempotency.current.0.infraSHPortS.attributes.name == "ansible_access_spine_interface_selector_1" + - nm_udpate_spine_interface_selector_idempotency.current.0.infraSHPortS.attributes.descr == "Updated description for first ansible Access Spine Interface Selector" + - nm_udpate_spine_interface_selector_idempotency.current.0.infraSHPortS.children.0.infraRsSpAccGrp.attributes.tDn == "uni/infra/funcprof/spaccportgrp-ansible_access_spine_interface_policy_group" + + # DELETE ACCESS SPINE INTERFACE SELECTOR + - name: Remove Access Spine Interface Selector (check_mode) + cisco.aci.aci_access_spine_interface_selector: &spine_interface_selector_absent + <<: *aci_access_spine_interface_selector_update + state: absent + check_mode: true + register: cm_remove_spine_interface_selector + + - name: Remove Access Spine Interface Selector (normal_mode) + cisco.aci.aci_access_spine_interface_selector: + <<: *spine_interface_selector_absent + register: nm_remove_spine_interface_selector + + - name: Remove Access Spine Interface Selector - testing idempotency + cisco.aci.aci_access_spine_interface_selector: + <<: *spine_interface_selector_absent + register: nm_remove_spine_interface_selector_idempotency + + - name: Asserts deletion tasks + ansible.builtin.assert: + that: + - cm_remove_spine_interface_selector is changed + - cm_remove_spine_interface_selector.current == cm_remove_spine_interface_selector.previous + - cm_remove_spine_interface_selector.proposed == {} + - nm_remove_spine_interface_selector is changed + - nm_remove_spine_interface_selector.previous != [] + - nm_remove_spine_interface_selector.proposed == {} + - nm_remove_spine_interface_selector.current == [] + - nm_remove_spine_interface_selector_idempotency is not changed + - nm_remove_spine_interface_selector_idempotency.previous == [] + - nm_remove_spine_interface_selector_idempotency.current == [] + + # CLEAN ENVIRONMENT BEFORE ENDING TESTS + - name: Remove the Access Spine Interface profile - cleanup before ending tests + cisco.aci.aci_access_spine_interface_profile: + <<: *aci_access_spine_interface_profile_present + state: absent + + - name: Remove the Spine Interface policy Group - cleanup before ending tests + cisco.aci.aci_interface_policy_spine_policy_group: + <<: *aci_interface_policy_spine_policy_group_present + state: absent diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_access_spine_switch_profile/aliases b/ansible_collections/cisco/aci/tests/integration/targets/aci_access_spine_switch_profile/aliases new file mode 100644 index 000000000..209b793f9 --- /dev/null +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_access_spine_switch_profile/aliases @@ -0,0 +1,2 @@ +# No ACI simulator yet, so not enabled +# unsupported diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_access_spine_switch_profile/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_access_spine_switch_profile/tasks/main.yml new file mode 100644 index 000000000..cf940fcbb --- /dev/null +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_access_spine_switch_profile/tasks/main.yml @@ -0,0 +1,183 @@ +# Test code for the ACI modules +# Copyright: (c) 2023, Eric Girard <@netgirard> +# Copyright: (c) 2024, Gaspard Micol (@gmicol) <gmicol@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 APIC host, ACI username and ACI password + ansible.builtin.fail: + msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' + when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined + +- name: Set vars + ansible.builtin.set_fact: + aci_info: &aci_info + host: "{{ aci_hostname }}" + username: "{{ aci_username }}" + password: "{{ aci_password }}" + validate_certs: '{{ aci_validate_certs | default(false) }}' + use_ssl: '{{ aci_use_ssl | default(true) }}' + use_proxy: '{{ aci_use_proxy | default(true) }}' + output_level: '{{ aci_output_level | default("info") }}' + +- name: Verify Cloud and Non-Cloud Sites in use. + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + +- name: Execute tasks only for non-cloud sites + when: query_cloud.current == [] # This condition will execute only non-cloud sites + block: # block specifies execution of tasks within, based on conditions + # CLEAN ENVIRONMENT + - name: Remove all Access Spine Switch profiles + cisco.aci.aci_access_spine_switch_profile: &aci_access_spine_switch_profile_all_absent + <<: *aci_info + spine_switch_profile: "{{ item }}" + state: absent + loop: + - ansible_access_spine_switch_profile_1 + - ansible_access_spine_switch_profile_2 + + # CREATE ACCESS SPINE SWITCH PROFILE + - name: Add a new Access Spine Switch Profile (check_mode) + cisco.aci.aci_access_spine_switch_profile: &aci_access_spine_switch_profile_present + <<: *aci_info + spine_switch_profile: ansible_access_spine_switch_profile_1 + description: Access Spine Switch Profile 1 + state: present + check_mode: true + register: cm_add_spine_switch_profile + + - name: Add a new Access Spine Switch Profile (normal_mode) + cisco.aci.aci_access_spine_switch_profile: + <<: *aci_access_spine_switch_profile_present + register: nm_add_spine_switch_profile + + - name: Add the first Access Spine Switch Profile again - testing idempotency + cisco.aci.aci_access_spine_switch_profile: + <<: *aci_access_spine_switch_profile_present + register: nm_add_spine_switch_profile_idempotency + + - name: Add a second Access Spine Switch Profile (normal_mode) + cisco.aci.aci_access_spine_switch_profile: &aci_access_spine_switch_profile_2_present + <<: *aci_info + spine_switch_profile: ansible_access_spine_switch_profile_2 + description: Access Spine Switch Profile 2 + state: present + register: nm_add_spine_switch_profile_2 + + - name: Asserts for Access Spine Switch Profile creation tasks + ansible.builtin.assert: + that: + - cm_add_spine_switch_profile is changed + - cm_add_spine_switch_profile.previous == [] + - cm_add_spine_switch_profile.current == [] + - cm_add_spine_switch_profile.proposed.infraSpineP.attributes.name == "ansible_access_spine_switch_profile_1" + - cm_add_spine_switch_profile.proposed.infraSpineP.attributes.descr == "Access Spine Switch Profile 1" + - nm_add_spine_switch_profile is changed + - nm_add_spine_switch_profile.previous == [] + - nm_add_spine_switch_profile.current.0.infraSpineP.attributes.name == "ansible_access_spine_switch_profile_1" + - nm_add_spine_switch_profile.current.0.infraSpineP.attributes.descr == "Access Spine Switch Profile 1" + - nm_add_spine_switch_profile.current.0.infraSpineP.attributes.dn == "uni/infra/spprof-ansible_access_spine_switch_profile_1" + - nm_add_spine_switch_profile_idempotency is not changed + - nm_add_spine_switch_profile_idempotency.current.0.infraSpineP.attributes.name == "ansible_access_spine_switch_profile_1" + - nm_add_spine_switch_profile_idempotency.current.0.infraSpineP.attributes.descr == "Access Spine Switch Profile 1" + - nm_add_spine_switch_profile_idempotency.current.0.infraSpineP.attributes.dn == "uni/infra/spprof-ansible_access_spine_switch_profile_1" + - nm_add_spine_switch_profile_2 is changed + - nm_add_spine_switch_profile_2.previous == [] + - nm_add_spine_switch_profile_2.current.0.infraSpineP.attributes.name == "ansible_access_spine_switch_profile_2" + - nm_add_spine_switch_profile_2.current.0.infraSpineP.attributes.descr == "Access Spine Switch Profile 2" + - nm_add_spine_switch_profile_2.current.0.infraSpineP.attributes.dn == "uni/infra/spprof-ansible_access_spine_switch_profile_2" + + # QUERY ACCESS SPINE SWITCH PROFILE + - name: Query all Access Spine Switch Profiles + cisco.aci.aci_access_spine_switch_profile: + <<: *aci_info + state: query + register: query_all_spine_switch_profile + + - name: Query ansible_access_spine_switch_profile_1 + cisco.aci.aci_access_spine_switch_profile: + <<: *aci_access_spine_switch_profile_present + state: query + register: query_ansible_access_spine_switch_profile_1 + + - name: Asserts query tasks + ansible.builtin.assert: + that: + - query_all_spine_switch_profile is not changed + - query_all_spine_switch_profile.current|length >= 2 + - query_ansible_access_spine_switch_profile_1 is not changed + - query_ansible_access_spine_switch_profile_1.current|length == 1 + - query_ansible_access_spine_switch_profile_1.current.0.infraSpineP.attributes.name == "ansible_access_spine_switch_profile_1" + - query_ansible_access_spine_switch_profile_1.current.0.infraSpineP.attributes.descr == "Access Spine Switch Profile 1" + - query_ansible_access_spine_switch_profile_1.current.0.infraSpineP.attributes.dn == "uni/infra/spprof-ansible_access_spine_switch_profile_1" + + # UPDATE ACCESS SPINE SWITCH PROFILE + - name: Update first Access Spine Switch Profile (check_mode) + cisco.aci.aci_access_spine_switch_profile: &aci_access_spine_switch_profile_update + <<: *aci_access_spine_switch_profile_present + description: Updated description for first ansible Access Spine Switch Profile + check_mode: true + register: cm_update_spine_switch_profile + + - name: Update first Access Spine Switch Profile (normal_mode) + cisco.aci.aci_access_spine_switch_profile: + <<: *aci_access_spine_switch_profile_update + register: nm_update_spine_switch_profile + + - name: Update first Access Spine Switch Profile again - testing idempotency + cisco.aci.aci_access_spine_switch_profile: + <<: *aci_access_spine_switch_profile_update + register: nm_udpate_spine_switch_profile_idempotency + + - name: Asserts for Access Spine Switch Profile update tasks + ansible.builtin.assert: + that: + - cm_update_spine_switch_profile is changed + - cm_update_spine_switch_profile.previous == cm_update_spine_switch_profile.current + - cm_update_spine_switch_profile.proposed.infraSpineP.attributes.descr == "Updated description for first ansible Access Spine Switch Profile" + - nm_update_spine_switch_profile is changed + - nm_update_spine_switch_profile.current.0.infraSpineP.attributes.name == "ansible_access_spine_switch_profile_1" + - nm_update_spine_switch_profile.current.0.infraSpineP.attributes.descr == "Updated description for first ansible Access Spine Switch Profile" + - nm_udpate_spine_switch_profile_idempotency is not changed + - nm_udpate_spine_switch_profile_idempotency.current.0.infraSpineP.attributes.name == "ansible_access_spine_switch_profile_1" + - nm_udpate_spine_switch_profile_idempotency.current.0.infraSpineP.attributes.descr == "Updated description for first ansible Access Spine Switch Profile" + + # DELETE ACCESS SPINE SWITCH PROFILE + - name: Remove Access Spine Switch Profile (check_mode) + cisco.aci.aci_access_spine_switch_profile: &aci_access_spine_switch_profile_absent + <<: *aci_access_spine_switch_profile_update + state: absent + check_mode: true + register: cm_remove_spine_switch_profile + + - name: Remove Access Spine Switch Profile (normal_mode) + cisco.aci.aci_access_spine_switch_profile: + <<: *aci_access_spine_switch_profile_absent + register: nm_remove_spine_switch_profile + + - name: Remove Access Spine Switch Profile - testing idempotency + cisco.aci.aci_access_spine_switch_profile: + <<: *aci_access_spine_switch_profile_absent + register: nm_remove_spine_switch_profile_idempotency + + - name: Asserts deletion tasks + ansible.builtin.assert: + that: + - cm_remove_spine_switch_profile is changed + - cm_remove_spine_switch_profile.current == cm_remove_spine_switch_profile.previous + - cm_remove_spine_switch_profile.proposed == {} + - nm_remove_spine_switch_profile is changed + - nm_remove_spine_switch_profile.previous != [] + - nm_remove_spine_switch_profile.proposed == {} + - nm_remove_spine_switch_profile.current == [] + - nm_remove_spine_switch_profile_idempotency is not changed + - nm_remove_spine_switch_profile_idempotency.previous == [] + - nm_remove_spine_switch_profile_idempotency.current == [] + + # CLEAN ENVIRONMENT BEFORE ENDING TESTS + - name: Remove all Access Spine Switch profiles - cleanup before ending tests + cisco.aci.aci_access_spine_switch_profile: + <<: *aci_access_spine_switch_profile_all_absent + loop: + - ansible_access_spine_switch_profile_1 + - ansible_access_spine_switch_profile_2 diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_access_spine_switch_selector/aliases b/ansible_collections/cisco/aci/tests/integration/targets/aci_access_spine_switch_selector/aliases new file mode 100644 index 000000000..209b793f9 --- /dev/null +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_access_spine_switch_selector/aliases @@ -0,0 +1,2 @@ +# No ACI simulator yet, so not enabled +# unsupported diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_access_spine_switch_selector/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_access_spine_switch_selector/tasks/main.yml new file mode 100644 index 000000000..1d314ec0e --- /dev/null +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_access_spine_switch_selector/tasks/main.yml @@ -0,0 +1,193 @@ +# Test code for the ACI modules +# Copyright: (c) 2023, Eric Girard <@netgirard> +# Copyright: (c) 2024, Gaspard Micol (@gmicol) <gmicol@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 APIC host, ACI username and ACI password + ansible.builtin.fail: + msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' + when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined + +- name: Set vars + ansible.builtin.set_fact: + aci_info: &aci_info + host: "{{ aci_hostname }}" + username: "{{ aci_username }}" + password: "{{ aci_password }}" + validate_certs: '{{ aci_validate_certs | default(false) }}' + use_ssl: '{{ aci_use_ssl | default(true) }}' + use_proxy: '{{ aci_use_proxy | default(true) }}' + output_level: '{{ aci_output_level | default("info") }}' + +- name: Verify Cloud and Non-Cloud Sites in use. + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + +- name: Execute tasks only for non-cloud sites + when: query_cloud.current == [] # This condition will execute only non-cloud sites + block: # block specifies execution of tasks within, based on conditions + # CLEAN ENVIRONMENT + - name: Remove the ansible_access_spine_switch_profile + cisco.aci.aci_access_spine_switch_profile: &aci_access_spine_switch_profile_absent + <<: *aci_info + spine_switch_profile: ansible_access_spine_switch_profile + description: Ansible Access Spine Switch Profile + state: absent + + - name: Add a new Access Spine Switch profile + cisco.aci.aci_access_spine_switch_profile: &aci_access_spine_switch_profile_present + <<: *aci_access_spine_switch_profile_absent + state: present + + # CREATE ACCESS SPINE SWITCH SELECTOR + - name: Add a new Access Spine Switch Selector (check_mode) + cisco.aci.aci_access_spine_switch_selector: &aci_access_spine_switch_selector_present + <<: *aci_info + spine_switch_profile: ansible_access_spine_switch_profile + spine_switch_selector: ansible_access_spine_switch_selector_1 + description: Access Spine Switch Selector 1 + selector_type: range + state: present + check_mode: true + register: cm_add_spine_switch_selector + + - name: Add a new Access Spine Switch Selector (normal_mode) + cisco.aci.aci_access_spine_switch_selector: + <<: *aci_access_spine_switch_selector_present + register: nm_add_spine_switch_selector + + - name: Add the first Access Spine Switch Selector again - testing idempotency + cisco.aci.aci_access_spine_switch_selector: + <<: *aci_access_spine_switch_selector_present + register: nm_add_spine_switch_selector_idempotency + + - name: Add a second Access Spine Switch Selector (normal_mode) + cisco.aci.aci_access_spine_switch_selector: &aci_access_spine_switch_selector_2_present + <<: *aci_info + spine_switch_profile: ansible_access_spine_switch_profile + spine_switch_selector: ansible_access_spine_switch_selector_2 + description: Access Spine Switch Selector 2 + selector_type: range + state: present + register: nm_add_spine_switch_selector_2 + + - name: Asserts for Access Spine Switch Selector creation tasks + ansible.builtin.assert: + that: + - cm_add_spine_switch_selector is changed + - cm_add_spine_switch_selector.previous == [] + - cm_add_spine_switch_selector.current == [] + - cm_add_spine_switch_selector.proposed.infraSpineS.attributes.name == "ansible_access_spine_switch_selector_1" + - cm_add_spine_switch_selector.proposed.infraSpineS.attributes.descr == "Access Spine Switch Selector 1" + - cm_add_spine_switch_selector.proposed.infraSpineS.attributes.type == "range" + - nm_add_spine_switch_selector is changed + - nm_add_spine_switch_selector.previous == [] + - nm_add_spine_switch_selector.current.0.infraSpineS.attributes.name == "ansible_access_spine_switch_selector_1" + - nm_add_spine_switch_selector.current.0.infraSpineS.attributes.descr == "Access Spine Switch Selector 1" + - nm_add_spine_switch_selector.current.0.infraSpineS.attributes.type == "range" + - nm_add_spine_switch_selector_idempotency is not changed + - nm_add_spine_switch_selector_idempotency.current.0.infraSpineS.attributes.name == "ansible_access_spine_switch_selector_1" + - nm_add_spine_switch_selector_idempotency.current.0.infraSpineS.attributes.descr == "Access Spine Switch Selector 1" + - nm_add_spine_switch_selector_idempotency.current.0.infraSpineS.attributes.type == "range" + - nm_add_spine_switch_selector_2 is changed + - nm_add_spine_switch_selector_2.previous == [] + - nm_add_spine_switch_selector_2.current.0.infraSpineS.attributes.name == "ansible_access_spine_switch_selector_2" + - nm_add_spine_switch_selector_2.current.0.infraSpineS.attributes.descr == "Access Spine Switch Selector 2" + - nm_add_spine_switch_selector_2.current.0.infraSpineS.attributes.type == "range" + + # QUERY ACCESS SPINE SWITCH SELECTOR + - name: Query all Access Spine Switch Selectors + cisco.aci.aci_access_spine_switch_selector: + <<: *aci_info + state: query + register: query_all_spine_switch_selector + + - name: Query ansible_access_spine_switch_selector_1 + cisco.aci.aci_access_spine_switch_selector: + <<: *aci_access_spine_switch_selector_present + state: query + register: query_ansible_access_spine_switch_selector_1 + + - name: Asserts query tasks + ansible.builtin.assert: + that: + - query_all_spine_switch_selector is not changed + - query_all_spine_switch_selector.current|length >= 2 + - query_ansible_access_spine_switch_selector_1 is not changed + - query_ansible_access_spine_switch_selector_1.current|length == 1 + - query_ansible_access_spine_switch_selector_1.current.0.infraSpineP.children.0.infraSpineS.attributes.name == "ansible_access_spine_switch_selector_1" + - query_ansible_access_spine_switch_selector_1.current.0.infraSpineP.children.0.infraSpineS.attributes.descr == "Access Spine Switch Selector 1" + - query_ansible_access_spine_switch_selector_1.current.0.infraSpineP.children.0.infraSpineS.attributes.type == "range" + + # UPDATE ACCESS SPINE SWITCH SELECTOR + - name: Update first Access Spine Switch Selector by adding a Policy Group (check_mode) + cisco.aci.aci_access_spine_switch_selector: &aci_access_spine_switch_selector_update + <<: *aci_access_spine_switch_selector_present + description: Updated description for first ansible Access Spine Switch Selector + policy_group: ansible_access_spine_switch_policy_group + check_mode: true + register: cm_update_spine_switch_selector + + - name: Update first Access Spine Switch Selector by adding a Policy Group (normal_mode) + cisco.aci.aci_access_spine_switch_selector: + <<: *aci_access_spine_switch_selector_update + register: nm_update_spine_switch_selector + + - name: Update first Access Spine Switch Selector by adding a Policy Group again - testing idempotency + cisco.aci.aci_access_spine_switch_selector: + <<: *aci_access_spine_switch_selector_update + register: nm_udpate_spine_switch_selector_idempotency + + - name: Asserts for Access Spine Switch Selector update tasks + ansible.builtin.assert: + that: + - cm_update_spine_switch_selector is changed + - cm_update_spine_switch_selector.previous == cm_update_spine_switch_selector.current + - cm_update_spine_switch_selector.proposed.infraSpineS.attributes.descr == "Updated description for first ansible Access Spine Switch Selector" + - cm_update_spine_switch_selector.proposed.infraSpineS.children.0.infraRsSpineAccNodePGrp.attributes.tDn == "uni/infra/funcprof/spaccnodepgrp-ansible_access_spine_switch_policy_group" + - nm_update_spine_switch_selector is changed + - nm_update_spine_switch_selector.current.0.infraSpineS.attributes.name == "ansible_access_spine_switch_selector_1" + - nm_update_spine_switch_selector.current.0.infraSpineS.attributes.descr == "Updated description for first ansible Access Spine Switch Selector" + - nm_update_spine_switch_selector.current.0.infraSpineS.children.0.infraRsSpineAccNodePGrp.attributes.tDn == "uni/infra/funcprof/spaccnodepgrp-ansible_access_spine_switch_policy_group" + - nm_udpate_spine_switch_selector_idempotency is not changed + - nm_udpate_spine_switch_selector_idempotency.current.0.infraSpineS.attributes.name == "ansible_access_spine_switch_selector_1" + - nm_udpate_spine_switch_selector_idempotency.current.0.infraSpineS.attributes.descr == "Updated description for first ansible Access Spine Switch Selector" + - nm_udpate_spine_switch_selector_idempotency.current.0.infraSpineS.children.0.infraRsSpineAccNodePGrp.attributes.tDn == "uni/infra/funcprof/spaccnodepgrp-ansible_access_spine_switch_policy_group" + + # DELETE ACCESS SPINE SWITCH SELECTOR + - name: Remove Access Spine Switch Selector (check_mode) + cisco.aci.aci_access_spine_switch_selector: &spine_switch_selector_absent + <<: *aci_access_spine_switch_selector_update + state: absent + check_mode: true + register: cm_remove_spine_switch_selector + + - name: Remove Access Spine Switch Selector (normal_mode) + cisco.aci.aci_access_spine_switch_selector: + <<: *spine_switch_selector_absent + register: nm_remove_spine_switch_selector + + - name: Remove Access Spine Switch Selector - testing idempotency + cisco.aci.aci_access_spine_switch_selector: + <<: *spine_switch_selector_absent + register: nm_remove_spine_switch_selector_idempotency + + - name: Asserts deletion tasks + ansible.builtin.assert: + that: + - cm_remove_spine_switch_selector is changed + - cm_remove_spine_switch_selector.current == cm_remove_spine_switch_selector.previous + - cm_remove_spine_switch_selector.proposed == {} + - nm_remove_spine_switch_selector is changed + - nm_remove_spine_switch_selector.previous != [] + - nm_remove_spine_switch_selector.proposed == {} + - nm_remove_spine_switch_selector.current == [] + - nm_remove_spine_switch_selector_idempotency is not changed + - nm_remove_spine_switch_selector_idempotency.previous == [] + - nm_remove_spine_switch_selector_idempotency.current == [] + + # CLEAN ENVIRONMENT BEFORE ENDING TESTS + - name: Remove the Access Spine Switch profile - cleanup before ending tests + cisco.aci.aci_access_spine_switch_profile: + <<: *aci_access_spine_switch_profile_present + state: absent diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_access_sub_port_block_to_access_port/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_access_sub_port_block_to_access_port/tasks/main.yml index b986f5762..69326320a 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_access_sub_port_block_to_access_port/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_access_sub_port_block_to_access_port/tasks/main.yml @@ -4,12 +4,12 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined - name: Verify Cloud and Non-Cloud Sites in use. - include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml - name: Execute tasks only for non-cloud sites when: query_cloud.current == [] # This condition will execute only non-cloud sites @@ -64,7 +64,7 @@ # TODO: also test for errors - name: present assertions - assert: + ansible.builtin.assert: that: - accesssubportblock_to_accessport_check_mode_present is changed - accesssubportblock_to_accessport_present is changed @@ -88,7 +88,7 @@ register: binding_query - name: present assertions - assert: + ansible.builtin.assert: that: - binding_query is not changed - binding_query.current | length >= 1 @@ -120,7 +120,7 @@ register: accesssubportblock_to_accessport_absent_missing_param - name: absent assertions - assert: + ansible.builtin.assert: that: - accesssubportblock_to_accessport_check_mode_absent is changed - accesssubportblock_to_accessport_check_mode_absent.previous != [] diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_access_switch_policy_group/aliases b/ansible_collections/cisco/aci/tests/integration/targets/aci_access_switch_policy_group/aliases new file mode 100644 index 000000000..209b793f9 --- /dev/null +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_access_switch_policy_group/aliases @@ -0,0 +1,2 @@ +# No ACI simulator yet, so not enabled +# unsupported diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_access_switch_policy_group/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_access_switch_policy_group/tasks/main.yml new file mode 100644 index 000000000..70a144a8e --- /dev/null +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_access_switch_policy_group/tasks/main.yml @@ -0,0 +1,1122 @@ +# Test code for the ACI modules +# Copyright: (c) 2023, Tim Cragg (@timcragg) +# Copyright: (c) 2023, Akini Ross (@akinross) + +# 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 APIC host, ACI username and ACI password + ansible.builtin.fail: + msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' + when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined + +- name: Set vars + ansible.builtin.set_fact: + aci_info: &aci_info + host: "{{ aci_hostname }}" + port: "{{ aci_port | default(omit) }}" + username: "{{ aci_username }}" + password: "{{ aci_password }}" + validate_certs: '{{ aci_validate_certs | default(false) }}' + use_ssl: '{{ aci_use_ssl | default(true) }}' + use_proxy: '{{ aci_use_proxy | default(true) }}' + output_level: '{{ aci_output_level | default("info") }}' + +- name: Query system information + cisco.aci.aci_system: + <<: *aci_info + id: 1 + state: query + register: version + +- name: Verify Cloud and Non-Cloud Sites in use. + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + +- name: Execute tasks only for non-cloud sites + when: query_cloud.current == [] + block: # block specifies execution of tasks within, based on conditions + + # CLEAN ENVIRONMENT + - name: Remove the ansible access switch policy groups + cisco.aci.aci_access_switch_policy_group: + <<: *aci_info + switch_type: "{{ item.type }}" + name: "{{ item.name }}" + state: absent + loop: + - {name: ansible_access_switch_leaf_pol_grp, type: leaf} + - {name: ansible_access_switch_leaf_pol_grp_2, type: leaf} + - {name: ansible_access_switch_spine_pol_grp, type: spine} + - {name: ansible_access_switch_spine_pol_grp_2, type: spine} + + # ACCESS SWITCH LEAF POLICY GROUP + - name: Create the ansible access switch leaf policy group (check mode) + cisco.aci.aci_access_switch_policy_group: &aci_create_leaf_policy_group + <<: *aci_info + switch_type: leaf + name: ansible_access_switch_leaf_pol_grp + state: present + check_mode: yes + register: cm_create_leaf_policy_group + + - name: Create the ansible access switch leaf policy group + cisco.aci.aci_access_switch_policy_group: + <<: *aci_create_leaf_policy_group + register: nm_create_leaf_policy_group + + - name: Create the ansible access switch leaf policy group again + cisco.aci.aci_access_switch_policy_group: + <<: *aci_create_leaf_policy_group + register: nm_create_leaf_policy_group_again + + # TODO investigate simplify test assertion because apic returns order that deviates for each version + # Possibly by leveraging https://docs.ansible.com/ansible/latest/collections/community/general/docsite/filter_guide_selecting_json_data.html + - name: Verify creation of access switch leaf policy group for version 4.2(7s) + ansible.builtin.assert: + that: + - cm_create_leaf_policy_group is changed + - cm_create_leaf_policy_group.previous == [] + - cm_create_leaf_policy_group.current == [] + - cm_create_leaf_policy_group.proposed.infraAccNodePGrp.attributes.annotation == "orchestrator:ansible" + - cm_create_leaf_policy_group.proposed.infraAccNodePGrp.attributes.dn == "uni/infra/funcprof/accnodepgrp-ansible_access_switch_leaf_pol_grp" + - nm_create_leaf_policy_group is changed + - nm_create_leaf_policy_group.previous == [] + - nm_create_leaf_policy_group.current.0.infraAccNodePGrp.children.0.infraRsTopoctrlFwdScaleProfPol.attributes.tnTopoctrlFwdScaleProfilePolName == "" + - nm_create_leaf_policy_group.current.0.infraAccNodePGrp.children.1.infraRsPoeInstPol.attributes.tnPoeInstPolName == "" + - nm_create_leaf_policy_group.current.0.infraAccNodePGrp.children.2.infraRsBfdIpv6InstPol.attributes.tnBfdIpv6InstPolName == "" + - nm_create_leaf_policy_group.current.0.infraAccNodePGrp.children.3.infraRsEquipmentFlashConfigPol.attributes.tnEquipmentFlashConfigPolName == "" + - nm_create_leaf_policy_group.current.0.infraAccNodePGrp.children.4.infraRsMonNodeInfraPol.attributes.tnMonInfraPolName == "" + - nm_create_leaf_policy_group.current.0.infraAccNodePGrp.children.5.infraRsFcInstPol.attributes.tnFcInstPolName == "" + - nm_create_leaf_policy_group.current.0.infraAccNodePGrp.children.6.infraRsBfdIpv4InstPol.attributes.tnBfdIpv4InstPolName == "" + - nm_create_leaf_policy_group.current.0.infraAccNodePGrp.children.7.infraRsL2NodeAuthPol.attributes.tnL2NodeAuthPolName == "" + - nm_create_leaf_policy_group.current.0.infraAccNodePGrp.children.8.infraRsTopoctrlFastLinkFailoverInstPol.attributes.tnTopoctrlFastLinkFailoverInstPolName == "" + - nm_create_leaf_policy_group.current.0.infraAccNodePGrp.children.9.infraRsMstInstPol.attributes.tnStpInstPolName == "" + - nm_create_leaf_policy_group.current.0.infraAccNodePGrp.children.10.infraRsFcFabricPol.attributes.tnFcFabricPolName == "" + - nm_create_leaf_policy_group.current.0.infraAccNodePGrp.children.11.infraRsIaclLeafProfile.attributes.tnIaclLeafProfileName == "" + - nm_create_leaf_policy_group.current.0.infraAccNodePGrp.children.12.infraRsLeafCoppProfile.attributes.tnCoppLeafProfileName == "" + - nm_create_leaf_policy_group.current.0.infraAccNodePGrp.children.13.infraRsLeafPGrpToCdpIfPol.attributes.tnCdpIfPolName == "" + - nm_create_leaf_policy_group.current.0.infraAccNodePGrp.children.14.infraRsLeafPGrpToLldpIfPol.attributes.tnLldpIfPolName == "" + - nm_create_leaf_policy_group_again is not changed + - nm_create_leaf_policy_group_again.current.0.infraAccNodePGrp.children.0.infraRsTopoctrlFwdScaleProfPol.attributes.tnTopoctrlFwdScaleProfilePolName == "" + - nm_create_leaf_policy_group_again.current.0.infraAccNodePGrp.children.1.infraRsPoeInstPol.attributes.tnPoeInstPolName == "" + - nm_create_leaf_policy_group_again.current.0.infraAccNodePGrp.children.2.infraRsBfdIpv6InstPol.attributes.tnBfdIpv6InstPolName == "" + - nm_create_leaf_policy_group_again.current.0.infraAccNodePGrp.children.3.infraRsEquipmentFlashConfigPol.attributes.tnEquipmentFlashConfigPolName == "" + - nm_create_leaf_policy_group_again.current.0.infraAccNodePGrp.children.4.infraRsMonNodeInfraPol.attributes.tnMonInfraPolName == "" + - nm_create_leaf_policy_group_again.current.0.infraAccNodePGrp.children.5.infraRsFcInstPol.attributes.tnFcInstPolName == "" + - nm_create_leaf_policy_group_again.current.0.infraAccNodePGrp.children.6.infraRsBfdIpv4InstPol.attributes.tnBfdIpv4InstPolName == "" + - nm_create_leaf_policy_group_again.current.0.infraAccNodePGrp.children.7.infraRsL2NodeAuthPol.attributes.tnL2NodeAuthPolName == "" + - nm_create_leaf_policy_group_again.current.0.infraAccNodePGrp.children.8.infraRsTopoctrlFastLinkFailoverInstPol.attributes.tnTopoctrlFastLinkFailoverInstPolName == "" + - nm_create_leaf_policy_group_again.current.0.infraAccNodePGrp.children.9.infraRsMstInstPol.attributes.tnStpInstPolName == "" + - nm_create_leaf_policy_group_again.current.0.infraAccNodePGrp.children.10.infraRsFcFabricPol.attributes.tnFcFabricPolName == "" + - nm_create_leaf_policy_group_again.current.0.infraAccNodePGrp.children.11.infraRsIaclLeafProfile.attributes.tnIaclLeafProfileName == "" + - nm_create_leaf_policy_group_again.current.0.infraAccNodePGrp.children.12.infraRsLeafCoppProfile.attributes.tnCoppLeafProfileName == "" + - nm_create_leaf_policy_group_again.current.0.infraAccNodePGrp.children.13.infraRsLeafPGrpToCdpIfPol.attributes.tnCdpIfPolName == "" + - nm_create_leaf_policy_group_again.current.0.infraAccNodePGrp.children.14.infraRsLeafPGrpToLldpIfPol.attributes.tnLldpIfPolName == "" + - nm_create_leaf_policy_group_again.previous.0.infraAccNodePGrp.children.0.infraRsTopoctrlFwdScaleProfPol.attributes.tnTopoctrlFwdScaleProfilePolName == "" + - nm_create_leaf_policy_group_again.previous.0.infraAccNodePGrp.children.1.infraRsPoeInstPol.attributes.tnPoeInstPolName == "" + - nm_create_leaf_policy_group_again.previous.0.infraAccNodePGrp.children.2.infraRsBfdIpv6InstPol.attributes.tnBfdIpv6InstPolName == "" + - nm_create_leaf_policy_group_again.previous.0.infraAccNodePGrp.children.3.infraRsEquipmentFlashConfigPol.attributes.tnEquipmentFlashConfigPolName == "" + - nm_create_leaf_policy_group_again.previous.0.infraAccNodePGrp.children.4.infraRsMonNodeInfraPol.attributes.tnMonInfraPolName == "" + - nm_create_leaf_policy_group_again.previous.0.infraAccNodePGrp.children.5.infraRsFcInstPol.attributes.tnFcInstPolName == "" + - nm_create_leaf_policy_group_again.previous.0.infraAccNodePGrp.children.6.infraRsBfdIpv4InstPol.attributes.tnBfdIpv4InstPolName == "" + - nm_create_leaf_policy_group_again.previous.0.infraAccNodePGrp.children.7.infraRsL2NodeAuthPol.attributes.tnL2NodeAuthPolName == "" + - nm_create_leaf_policy_group_again.previous.0.infraAccNodePGrp.children.8.infraRsTopoctrlFastLinkFailoverInstPol.attributes.tnTopoctrlFastLinkFailoverInstPolName == "" + - nm_create_leaf_policy_group_again.previous.0.infraAccNodePGrp.children.9.infraRsMstInstPol.attributes.tnStpInstPolName == "" + - nm_create_leaf_policy_group_again.previous.0.infraAccNodePGrp.children.10.infraRsFcFabricPol.attributes.tnFcFabricPolName == "" + - nm_create_leaf_policy_group_again.previous.0.infraAccNodePGrp.children.11.infraRsIaclLeafProfile.attributes.tnIaclLeafProfileName == "" + - nm_create_leaf_policy_group_again.previous.0.infraAccNodePGrp.children.12.infraRsLeafCoppProfile.attributes.tnCoppLeafProfileName == "" + - nm_create_leaf_policy_group_again.previous.0.infraAccNodePGrp.children.13.infraRsLeafPGrpToCdpIfPol.attributes.tnCdpIfPolName == "" + - nm_create_leaf_policy_group_again.previous.0.infraAccNodePGrp.children.14.infraRsLeafPGrpToLldpIfPol.attributes.tnLldpIfPolName == "" + when: version.current.0.topSystem.attributes.version == "4.2(7s)" + + - name: Verify creation of access switch leaf policy group for version 5.2(5c) + ansible.builtin.assert: + that: + - cm_create_leaf_policy_group is changed + - cm_create_leaf_policy_group.previous == [] + - cm_create_leaf_policy_group.current == [] + - cm_create_leaf_policy_group.proposed.infraAccNodePGrp.attributes.annotation == "orchestrator:ansible" + - cm_create_leaf_policy_group.proposed.infraAccNodePGrp.attributes.dn == "uni/infra/funcprof/accnodepgrp-ansible_access_switch_leaf_pol_grp" + - nm_create_leaf_policy_group is changed + - nm_create_leaf_policy_group.previous == [] + - nm_create_leaf_policy_group.current.0.infraAccNodePGrp.children.0.infraRsTopoctrlFwdScaleProfPol.attributes.tnTopoctrlFwdScaleProfilePolName == "" + - nm_create_leaf_policy_group.current.0.infraAccNodePGrp.children.1.infraRsLeafTopoctrlUsbConfigProfilePol.attributes.tnTopoctrlUsbConfigProfilePolName == "" + - nm_create_leaf_policy_group.current.0.infraAccNodePGrp.children.2.infraRsLeafPGrpToLldpIfPol.attributes.tnLldpIfPolName == "" + - nm_create_leaf_policy_group.current.0.infraAccNodePGrp.children.3.infraRsLeafPGrpToCdpIfPol.attributes.tnCdpIfPolName == "" + - nm_create_leaf_policy_group.current.0.infraAccNodePGrp.children.4.infraRsBfdIpv6InstPol.attributes.tnBfdIpv6InstPolName == "" + - nm_create_leaf_policy_group.current.0.infraAccNodePGrp.children.5.infraRsSynceInstPol.attributes.tnSynceInstPolName == "" + - nm_create_leaf_policy_group.current.0.infraAccNodePGrp.children.6.infraRsPoeInstPol.attributes.tnPoeInstPolName == "" + - nm_create_leaf_policy_group.current.0.infraAccNodePGrp.children.7.infraRsBfdMhIpv4InstPol.attributes.tnBfdMhIpv4InstPolName == "" + - nm_create_leaf_policy_group.current.0.infraAccNodePGrp.children.8.infraRsBfdMhIpv6InstPol.attributes.tnBfdMhIpv6InstPolName == "" + - nm_create_leaf_policy_group.current.0.infraAccNodePGrp.children.9.infraRsEquipmentFlashConfigPol.attributes.tnEquipmentFlashConfigPolName == "" + - nm_create_leaf_policy_group.current.0.infraAccNodePGrp.children.10.infraRsMonNodeInfraPol.attributes.tnMonInfraPolName == "" + - nm_create_leaf_policy_group.current.0.infraAccNodePGrp.children.11.infraRsFcInstPol.attributes.tnFcInstPolName == "" + - nm_create_leaf_policy_group.current.0.infraAccNodePGrp.children.12.infraRsTopoctrlFastLinkFailoverInstPol.attributes.tnTopoctrlFastLinkFailoverInstPolName == "" + - nm_create_leaf_policy_group.current.0.infraAccNodePGrp.children.13.infraRsMstInstPol.attributes.tnStpInstPolName == "" + - nm_create_leaf_policy_group.current.0.infraAccNodePGrp.children.14.infraRsFcFabricPol.attributes.tnFcFabricPolName == "" + - nm_create_leaf_policy_group.current.0.infraAccNodePGrp.children.15.infraRsLeafCoppProfile.attributes.tnCoppLeafProfileName == "" + - nm_create_leaf_policy_group.current.0.infraAccNodePGrp.children.16.infraRsIaclLeafProfile.attributes.tnIaclLeafProfileName == "" + - nm_create_leaf_policy_group.current.0.infraAccNodePGrp.children.17.infraRsBfdIpv4InstPol.attributes.tnBfdIpv4InstPolName == "" + - nm_create_leaf_policy_group.current.0.infraAccNodePGrp.children.18.infraRsL2NodeAuthPol.attributes.tnL2NodeAuthPolName == "" + - nm_create_leaf_policy_group_again is not changed + - nm_create_leaf_policy_group_again.current.0.infraAccNodePGrp.children.0.infraRsTopoctrlFwdScaleProfPol.attributes.tnTopoctrlFwdScaleProfilePolName == "" + - nm_create_leaf_policy_group_again.current.0.infraAccNodePGrp.children.1.infraRsLeafTopoctrlUsbConfigProfilePol.attributes.tnTopoctrlUsbConfigProfilePolName == "" + - nm_create_leaf_policy_group_again.current.0.infraAccNodePGrp.children.2.infraRsLeafPGrpToLldpIfPol.attributes.tnLldpIfPolName == "" + - nm_create_leaf_policy_group_again.current.0.infraAccNodePGrp.children.3.infraRsLeafPGrpToCdpIfPol.attributes.tnCdpIfPolName == "" + - nm_create_leaf_policy_group_again.current.0.infraAccNodePGrp.children.4.infraRsBfdIpv6InstPol.attributes.tnBfdIpv6InstPolName == "" + - nm_create_leaf_policy_group_again.current.0.infraAccNodePGrp.children.5.infraRsSynceInstPol.attributes.tnSynceInstPolName == "" + - nm_create_leaf_policy_group_again.current.0.infraAccNodePGrp.children.6.infraRsPoeInstPol.attributes.tnPoeInstPolName == "" + - nm_create_leaf_policy_group_again.current.0.infraAccNodePGrp.children.7.infraRsBfdMhIpv4InstPol.attributes.tnBfdMhIpv4InstPolName == "" + - nm_create_leaf_policy_group_again.current.0.infraAccNodePGrp.children.8.infraRsBfdMhIpv6InstPol.attributes.tnBfdMhIpv6InstPolName == "" + - nm_create_leaf_policy_group_again.current.0.infraAccNodePGrp.children.9.infraRsEquipmentFlashConfigPol.attributes.tnEquipmentFlashConfigPolName == "" + - nm_create_leaf_policy_group_again.current.0.infraAccNodePGrp.children.10.infraRsMonNodeInfraPol.attributes.tnMonInfraPolName == "" + - nm_create_leaf_policy_group_again.current.0.infraAccNodePGrp.children.11.infraRsFcInstPol.attributes.tnFcInstPolName == "" + - nm_create_leaf_policy_group_again.current.0.infraAccNodePGrp.children.12.infraRsTopoctrlFastLinkFailoverInstPol.attributes.tnTopoctrlFastLinkFailoverInstPolName == "" + - nm_create_leaf_policy_group_again.current.0.infraAccNodePGrp.children.13.infraRsMstInstPol.attributes.tnStpInstPolName == "" + - nm_create_leaf_policy_group_again.current.0.infraAccNodePGrp.children.14.infraRsFcFabricPol.attributes.tnFcFabricPolName == "" + - nm_create_leaf_policy_group_again.current.0.infraAccNodePGrp.children.15.infraRsLeafCoppProfile.attributes.tnCoppLeafProfileName == "" + - nm_create_leaf_policy_group_again.current.0.infraAccNodePGrp.children.16.infraRsIaclLeafProfile.attributes.tnIaclLeafProfileName == "" + - nm_create_leaf_policy_group_again.current.0.infraAccNodePGrp.children.17.infraRsBfdIpv4InstPol.attributes.tnBfdIpv4InstPolName == "" + - nm_create_leaf_policy_group_again.current.0.infraAccNodePGrp.children.18.infraRsL2NodeAuthPol.attributes.tnL2NodeAuthPolName == "" + - nm_create_leaf_policy_group_again.previous.0.infraAccNodePGrp.children.0.infraRsTopoctrlFwdScaleProfPol.attributes.tnTopoctrlFwdScaleProfilePolName == "" + - nm_create_leaf_policy_group_again.previous.0.infraAccNodePGrp.children.1.infraRsLeafTopoctrlUsbConfigProfilePol.attributes.tnTopoctrlUsbConfigProfilePolName == "" + - nm_create_leaf_policy_group_again.previous.0.infraAccNodePGrp.children.2.infraRsLeafPGrpToLldpIfPol.attributes.tnLldpIfPolName == "" + - nm_create_leaf_policy_group_again.previous.0.infraAccNodePGrp.children.3.infraRsLeafPGrpToCdpIfPol.attributes.tnCdpIfPolName == "" + - nm_create_leaf_policy_group_again.previous.0.infraAccNodePGrp.children.4.infraRsBfdIpv6InstPol.attributes.tnBfdIpv6InstPolName == "" + - nm_create_leaf_policy_group_again.previous.0.infraAccNodePGrp.children.5.infraRsSynceInstPol.attributes.tnSynceInstPolName == "" + - nm_create_leaf_policy_group_again.previous.0.infraAccNodePGrp.children.6.infraRsPoeInstPol.attributes.tnPoeInstPolName == "" + - nm_create_leaf_policy_group_again.previous.0.infraAccNodePGrp.children.7.infraRsBfdMhIpv4InstPol.attributes.tnBfdMhIpv4InstPolName == "" + - nm_create_leaf_policy_group_again.previous.0.infraAccNodePGrp.children.8.infraRsBfdMhIpv6InstPol.attributes.tnBfdMhIpv6InstPolName == "" + - nm_create_leaf_policy_group_again.previous.0.infraAccNodePGrp.children.9.infraRsEquipmentFlashConfigPol.attributes.tnEquipmentFlashConfigPolName == "" + - nm_create_leaf_policy_group_again.previous.0.infraAccNodePGrp.children.10.infraRsMonNodeInfraPol.attributes.tnMonInfraPolName == "" + - nm_create_leaf_policy_group_again.previous.0.infraAccNodePGrp.children.11.infraRsFcInstPol.attributes.tnFcInstPolName == "" + - nm_create_leaf_policy_group_again.previous.0.infraAccNodePGrp.children.12.infraRsTopoctrlFastLinkFailoverInstPol.attributes.tnTopoctrlFastLinkFailoverInstPolName == "" + - nm_create_leaf_policy_group_again.previous.0.infraAccNodePGrp.children.13.infraRsMstInstPol.attributes.tnStpInstPolName == "" + - nm_create_leaf_policy_group_again.previous.0.infraAccNodePGrp.children.14.infraRsFcFabricPol.attributes.tnFcFabricPolName == "" + - nm_create_leaf_policy_group_again.previous.0.infraAccNodePGrp.children.15.infraRsLeafCoppProfile.attributes.tnCoppLeafProfileName == "" + - nm_create_leaf_policy_group_again.previous.0.infraAccNodePGrp.children.16.infraRsIaclLeafProfile.attributes.tnIaclLeafProfileName == "" + - nm_create_leaf_policy_group_again.previous.0.infraAccNodePGrp.children.17.infraRsBfdIpv4InstPol.attributes.tnBfdIpv4InstPolName == "" + - nm_create_leaf_policy_group_again.previous.0.infraAccNodePGrp.children.18.infraRsL2NodeAuthPol.attributes.tnL2NodeAuthPolName == "" + when: version.current.0.topSystem.attributes.version == "5.2(5c)" + + - name: Verify creation of access switch leaf policy group for version 6.0(2h) + ansible.builtin.assert: + that: + - cm_create_leaf_policy_group is changed + - cm_create_leaf_policy_group.previous == [] + - cm_create_leaf_policy_group.current == [] + - cm_create_leaf_policy_group.proposed.infraAccNodePGrp.attributes.annotation == "orchestrator:ansible" + - cm_create_leaf_policy_group.proposed.infraAccNodePGrp.attributes.dn == "uni/infra/funcprof/accnodepgrp-ansible_access_switch_leaf_pol_grp" + - nm_create_leaf_policy_group is changed + - nm_create_leaf_policy_group.previous == [] + - nm_create_leaf_policy_group.current.0.infraAccNodePGrp.children.0.infraRsTopoctrlFwdScaleProfPol.attributes.tnTopoctrlFwdScaleProfilePolName == "" + - nm_create_leaf_policy_group.current.0.infraAccNodePGrp.children.1.infraRsLeafTopoctrlUsbConfigProfilePol.attributes.tnTopoctrlUsbConfigProfilePolName == "" + - nm_create_leaf_policy_group.current.0.infraAccNodePGrp.children.2.infraRsLeafPGrpToLldpIfPol.attributes.tnLldpIfPolName == "" + - nm_create_leaf_policy_group.current.0.infraAccNodePGrp.children.3.infraRsBfdIpv6InstPol.attributes.tnBfdIpv6InstPolName == "" + - nm_create_leaf_policy_group.current.0.infraAccNodePGrp.children.4.infraRsSynceInstPol.attributes.tnSynceInstPolName == "" + - nm_create_leaf_policy_group.current.0.infraAccNodePGrp.children.5.infraRsPoeInstPol.attributes.tnPoeInstPolName == "" + - nm_create_leaf_policy_group.current.0.infraAccNodePGrp.children.6.infraRsBfdMhIpv4InstPol.attributes.tnBfdMhIpv4InstPolName == "" + - nm_create_leaf_policy_group.current.0.infraAccNodePGrp.children.7.infraRsBfdMhIpv6InstPol.attributes.tnBfdMhIpv6InstPolName == "" + - nm_create_leaf_policy_group.current.0.infraAccNodePGrp.children.8.infraRsEquipmentFlashConfigPol.attributes.tnEquipmentFlashConfigPolName == "" + - nm_create_leaf_policy_group.current.0.infraAccNodePGrp.children.9.infraRsMonNodeInfraPol.attributes.tnMonInfraPolName == "" + - nm_create_leaf_policy_group.current.0.infraAccNodePGrp.children.10.infraRsFcInstPol.attributes.tnFcInstPolName == "" + - nm_create_leaf_policy_group.current.0.infraAccNodePGrp.children.11.infraRsTopoctrlFastLinkFailoverInstPol.attributes.tnTopoctrlFastLinkFailoverInstPolName == "" + - nm_create_leaf_policy_group.current.0.infraAccNodePGrp.children.12.infraRsMstInstPol.attributes.tnStpInstPolName == "" + - nm_create_leaf_policy_group.current.0.infraAccNodePGrp.children.13.infraRsFcFabricPol.attributes.tnFcFabricPolName == "" + - nm_create_leaf_policy_group.current.0.infraAccNodePGrp.children.14.infraRsLeafCoppProfile.attributes.tnCoppLeafProfileName == "" + - nm_create_leaf_policy_group.current.0.infraAccNodePGrp.children.15.infraRsIaclLeafProfile.attributes.tnIaclLeafProfileName == "" + - nm_create_leaf_policy_group.current.0.infraAccNodePGrp.children.16.infraRsBfdIpv4InstPol.attributes.tnBfdIpv4InstPolName == "" + - nm_create_leaf_policy_group.current.0.infraAccNodePGrp.children.17.infraRsL2NodeAuthPol.attributes.tnL2NodeAuthPolName == "" + - nm_create_leaf_policy_group.current.0.infraAccNodePGrp.children.18.infraRsLeafPGrpToCdpIfPol.attributes.tnCdpIfPolName == "" + - nm_create_leaf_policy_group_again is not changed + - nm_create_leaf_policy_group_again.current.0.infraAccNodePGrp.children.0.infraRsTopoctrlFwdScaleProfPol.attributes.tnTopoctrlFwdScaleProfilePolName == "" + - nm_create_leaf_policy_group_again.current.0.infraAccNodePGrp.children.1.infraRsLeafTopoctrlUsbConfigProfilePol.attributes.tnTopoctrlUsbConfigProfilePolName == "" + - nm_create_leaf_policy_group_again.current.0.infraAccNodePGrp.children.2.infraRsLeafPGrpToLldpIfPol.attributes.tnLldpIfPolName == "" + - nm_create_leaf_policy_group_again.current.0.infraAccNodePGrp.children.3.infraRsBfdIpv6InstPol.attributes.tnBfdIpv6InstPolName == "" + - nm_create_leaf_policy_group_again.current.0.infraAccNodePGrp.children.4.infraRsSynceInstPol.attributes.tnSynceInstPolName == "" + - nm_create_leaf_policy_group_again.current.0.infraAccNodePGrp.children.5.infraRsPoeInstPol.attributes.tnPoeInstPolName == "" + - nm_create_leaf_policy_group_again.current.0.infraAccNodePGrp.children.6.infraRsBfdMhIpv4InstPol.attributes.tnBfdMhIpv4InstPolName == "" + - nm_create_leaf_policy_group_again.current.0.infraAccNodePGrp.children.7.infraRsBfdMhIpv6InstPol.attributes.tnBfdMhIpv6InstPolName == "" + - nm_create_leaf_policy_group_again.current.0.infraAccNodePGrp.children.8.infraRsEquipmentFlashConfigPol.attributes.tnEquipmentFlashConfigPolName == "" + - nm_create_leaf_policy_group_again.current.0.infraAccNodePGrp.children.9.infraRsMonNodeInfraPol.attributes.tnMonInfraPolName == "" + - nm_create_leaf_policy_group_again.current.0.infraAccNodePGrp.children.10.infraRsFcInstPol.attributes.tnFcInstPolName == "" + - nm_create_leaf_policy_group_again.current.0.infraAccNodePGrp.children.11.infraRsTopoctrlFastLinkFailoverInstPol.attributes.tnTopoctrlFastLinkFailoverInstPolName == "" + - nm_create_leaf_policy_group_again.current.0.infraAccNodePGrp.children.12.infraRsMstInstPol.attributes.tnStpInstPolName == "" + - nm_create_leaf_policy_group_again.current.0.infraAccNodePGrp.children.13.infraRsFcFabricPol.attributes.tnFcFabricPolName == "" + - nm_create_leaf_policy_group_again.current.0.infraAccNodePGrp.children.14.infraRsLeafCoppProfile.attributes.tnCoppLeafProfileName == "" + - nm_create_leaf_policy_group_again.current.0.infraAccNodePGrp.children.15.infraRsIaclLeafProfile.attributes.tnIaclLeafProfileName == "" + - nm_create_leaf_policy_group_again.current.0.infraAccNodePGrp.children.16.infraRsBfdIpv4InstPol.attributes.tnBfdIpv4InstPolName == "" + - nm_create_leaf_policy_group_again.current.0.infraAccNodePGrp.children.17.infraRsL2NodeAuthPol.attributes.tnL2NodeAuthPolName == "" + - nm_create_leaf_policy_group_again.current.0.infraAccNodePGrp.children.18.infraRsLeafPGrpToCdpIfPol.attributes.tnCdpIfPolName == "" + - nm_create_leaf_policy_group_again.previous.0.infraAccNodePGrp.children.0.infraRsTopoctrlFwdScaleProfPol.attributes.tnTopoctrlFwdScaleProfilePolName == "" + - nm_create_leaf_policy_group_again.previous.0.infraAccNodePGrp.children.1.infraRsLeafTopoctrlUsbConfigProfilePol.attributes.tnTopoctrlUsbConfigProfilePolName == "" + - nm_create_leaf_policy_group_again.previous.0.infraAccNodePGrp.children.2.infraRsLeafPGrpToLldpIfPol.attributes.tnLldpIfPolName == "" + - nm_create_leaf_policy_group_again.previous.0.infraAccNodePGrp.children.3.infraRsBfdIpv6InstPol.attributes.tnBfdIpv6InstPolName == "" + - nm_create_leaf_policy_group_again.previous.0.infraAccNodePGrp.children.4.infraRsSynceInstPol.attributes.tnSynceInstPolName == "" + - nm_create_leaf_policy_group_again.previous.0.infraAccNodePGrp.children.5.infraRsPoeInstPol.attributes.tnPoeInstPolName == "" + - nm_create_leaf_policy_group_again.previous.0.infraAccNodePGrp.children.6.infraRsBfdMhIpv4InstPol.attributes.tnBfdMhIpv4InstPolName == "" + - nm_create_leaf_policy_group_again.previous.0.infraAccNodePGrp.children.7.infraRsBfdMhIpv6InstPol.attributes.tnBfdMhIpv6InstPolName == "" + - nm_create_leaf_policy_group_again.previous.0.infraAccNodePGrp.children.8.infraRsEquipmentFlashConfigPol.attributes.tnEquipmentFlashConfigPolName == "" + - nm_create_leaf_policy_group_again.previous.0.infraAccNodePGrp.children.9.infraRsMonNodeInfraPol.attributes.tnMonInfraPolName == "" + - nm_create_leaf_policy_group_again.previous.0.infraAccNodePGrp.children.10.infraRsFcInstPol.attributes.tnFcInstPolName == "" + - nm_create_leaf_policy_group_again.previous.0.infraAccNodePGrp.children.11.infraRsTopoctrlFastLinkFailoverInstPol.attributes.tnTopoctrlFastLinkFailoverInstPolName == "" + - nm_create_leaf_policy_group_again.previous.0.infraAccNodePGrp.children.12.infraRsMstInstPol.attributes.tnStpInstPolName == "" + - nm_create_leaf_policy_group_again.previous.0.infraAccNodePGrp.children.13.infraRsFcFabricPol.attributes.tnFcFabricPolName == "" + - nm_create_leaf_policy_group_again.previous.0.infraAccNodePGrp.children.14.infraRsLeafCoppProfile.attributes.tnCoppLeafProfileName == "" + - nm_create_leaf_policy_group_again.previous.0.infraAccNodePGrp.children.15.infraRsIaclLeafProfile.attributes.tnIaclLeafProfileName == "" + - nm_create_leaf_policy_group_again.previous.0.infraAccNodePGrp.children.16.infraRsBfdIpv4InstPol.attributes.tnBfdIpv4InstPolName == "" + - nm_create_leaf_policy_group_again.previous.0.infraAccNodePGrp.children.17.infraRsL2NodeAuthPol.attributes.tnL2NodeAuthPolName == "" + - nm_create_leaf_policy_group_again.previous.0.infraAccNodePGrp.children.18.infraRsLeafPGrpToCdpIfPol.attributes.tnCdpIfPolName == "" + when: version.current.0.topSystem.attributes.version == "6.0(2h)" + + - name: Verify creation of access switch leaf policy group for 6.0(1g) + ansible.builtin.assert: + that: + - cm_create_leaf_policy_group is changed + - cm_create_leaf_policy_group.previous == [] + - cm_create_leaf_policy_group.current == [] + - cm_create_leaf_policy_group.proposed.infraAccNodePGrp.attributes.annotation == "orchestrator:ansible" + - cm_create_leaf_policy_group.proposed.infraAccNodePGrp.attributes.dn == "uni/infra/funcprof/accnodepgrp-ansible_access_switch_leaf_pol_grp" + - nm_create_leaf_policy_group is changed + - nm_create_leaf_policy_group.previous == [] + - nm_create_leaf_policy_group.current.0.infraAccNodePGrp.children.0.infraRsTopoctrlFwdScaleProfPol.attributes.tnTopoctrlFwdScaleProfilePolName == "" + - nm_create_leaf_policy_group.current.0.infraAccNodePGrp.children.1.infraRsLeafTopoctrlUsbConfigProfilePol.attributes.tnTopoctrlUsbConfigProfilePolName == "" + - nm_create_leaf_policy_group.current.0.infraAccNodePGrp.children.2.infraRsLeafPGrpToLldpIfPol.attributes.tnLldpIfPolName == "" + - nm_create_leaf_policy_group.current.0.infraAccNodePGrp.children.3.infraRsLeafPGrpToCdpIfPol.attributes.tnCdpIfPolName == "" + - nm_create_leaf_policy_group.current.0.infraAccNodePGrp.children.4.infraRsBfdIpv6InstPol.attributes.tnBfdIpv6InstPolName == "" + - nm_create_leaf_policy_group.current.0.infraAccNodePGrp.children.5.infraRsSynceInstPol.attributes.tnSynceInstPolName == "" + - nm_create_leaf_policy_group.current.0.infraAccNodePGrp.children.6.infraRsPoeInstPol.attributes.tnPoeInstPolName == "" + - nm_create_leaf_policy_group.current.0.infraAccNodePGrp.children.7.infraRsBfdMhIpv4InstPol.attributes.tnBfdMhIpv4InstPolName == "" + - nm_create_leaf_policy_group.current.0.infraAccNodePGrp.children.8.infraRsBfdMhIpv6InstPol.attributes.tnBfdMhIpv6InstPolName == "" + - nm_create_leaf_policy_group.current.0.infraAccNodePGrp.children.9.infraRsEquipmentFlashConfigPol.attributes.tnEquipmentFlashConfigPolName == "" + - nm_create_leaf_policy_group.current.0.infraAccNodePGrp.children.10.infraRsMonNodeInfraPol.attributes.tnMonInfraPolName == "" + - nm_create_leaf_policy_group.current.0.infraAccNodePGrp.children.11.infraRsFcInstPol.attributes.tnFcInstPolName == "" + - nm_create_leaf_policy_group.current.0.infraAccNodePGrp.children.12.infraRsTopoctrlFastLinkFailoverInstPol.attributes.tnTopoctrlFastLinkFailoverInstPolName == "" + - nm_create_leaf_policy_group.current.0.infraAccNodePGrp.children.13.infraRsMstInstPol.attributes.tnStpInstPolName == "" + - nm_create_leaf_policy_group.current.0.infraAccNodePGrp.children.14.infraRsFcFabricPol.attributes.tnFcFabricPolName == "" + - nm_create_leaf_policy_group.current.0.infraAccNodePGrp.children.15.infraRsLeafCoppProfile.attributes.tnCoppLeafProfileName == "" + - nm_create_leaf_policy_group.current.0.infraAccNodePGrp.children.16.infraRsIaclLeafProfile.attributes.tnIaclLeafProfileName == "" + - nm_create_leaf_policy_group.current.0.infraAccNodePGrp.children.17.infraRsBfdIpv4InstPol.attributes.tnBfdIpv4InstPolName == "" + - nm_create_leaf_policy_group.current.0.infraAccNodePGrp.children.18.infraRsL2NodeAuthPol.attributes.tnL2NodeAuthPolName == "" + - nm_create_leaf_policy_group_again is not changed + - nm_create_leaf_policy_group_again.current.0.infraAccNodePGrp.children.0.infraRsTopoctrlFwdScaleProfPol.attributes.tnTopoctrlFwdScaleProfilePolName == "" + - nm_create_leaf_policy_group_again.current.0.infraAccNodePGrp.children.1.infraRsLeafTopoctrlUsbConfigProfilePol.attributes.tnTopoctrlUsbConfigProfilePolName == "" + - nm_create_leaf_policy_group_again.current.0.infraAccNodePGrp.children.2.infraRsLeafPGrpToLldpIfPol.attributes.tnLldpIfPolName == "" + - nm_create_leaf_policy_group_again.current.0.infraAccNodePGrp.children.3.infraRsLeafPGrpToCdpIfPol.attributes.tnCdpIfPolName == "" + - nm_create_leaf_policy_group_again.current.0.infraAccNodePGrp.children.4.infraRsBfdIpv6InstPol.attributes.tnBfdIpv6InstPolName == "" + - nm_create_leaf_policy_group_again.current.0.infraAccNodePGrp.children.5.infraRsSynceInstPol.attributes.tnSynceInstPolName == "" + - nm_create_leaf_policy_group_again.current.0.infraAccNodePGrp.children.6.infraRsPoeInstPol.attributes.tnPoeInstPolName == "" + - nm_create_leaf_policy_group_again.current.0.infraAccNodePGrp.children.7.infraRsBfdMhIpv4InstPol.attributes.tnBfdMhIpv4InstPolName == "" + - nm_create_leaf_policy_group_again.current.0.infraAccNodePGrp.children.8.infraRsBfdMhIpv6InstPol.attributes.tnBfdMhIpv6InstPolName == "" + - nm_create_leaf_policy_group_again.current.0.infraAccNodePGrp.children.9.infraRsEquipmentFlashConfigPol.attributes.tnEquipmentFlashConfigPolName == "" + - nm_create_leaf_policy_group_again.current.0.infraAccNodePGrp.children.10.infraRsMonNodeInfraPol.attributes.tnMonInfraPolName == "" + - nm_create_leaf_policy_group_again.current.0.infraAccNodePGrp.children.11.infraRsFcInstPol.attributes.tnFcInstPolName == "" + - nm_create_leaf_policy_group_again.current.0.infraAccNodePGrp.children.12.infraRsTopoctrlFastLinkFailoverInstPol.attributes.tnTopoctrlFastLinkFailoverInstPolName == "" + - nm_create_leaf_policy_group_again.current.0.infraAccNodePGrp.children.13.infraRsMstInstPol.attributes.tnStpInstPolName == "" + - nm_create_leaf_policy_group_again.current.0.infraAccNodePGrp.children.14.infraRsFcFabricPol.attributes.tnFcFabricPolName == "" + - nm_create_leaf_policy_group_again.current.0.infraAccNodePGrp.children.15.infraRsLeafCoppProfile.attributes.tnCoppLeafProfileName == "" + - nm_create_leaf_policy_group_again.current.0.infraAccNodePGrp.children.16.infraRsIaclLeafProfile.attributes.tnIaclLeafProfileName == "" + - nm_create_leaf_policy_group_again.current.0.infraAccNodePGrp.children.17.infraRsBfdIpv4InstPol.attributes.tnBfdIpv4InstPolName == "" + - nm_create_leaf_policy_group_again.current.0.infraAccNodePGrp.children.18.infraRsL2NodeAuthPol.attributes.tnL2NodeAuthPolName == "" + - nm_create_leaf_policy_group_again.previous.0.infraAccNodePGrp.children.0.infraRsTopoctrlFwdScaleProfPol.attributes.tnTopoctrlFwdScaleProfilePolName == "" + - nm_create_leaf_policy_group_again.previous.0.infraAccNodePGrp.children.1.infraRsLeafTopoctrlUsbConfigProfilePol.attributes.tnTopoctrlUsbConfigProfilePolName == "" + - nm_create_leaf_policy_group_again.previous.0.infraAccNodePGrp.children.2.infraRsLeafPGrpToLldpIfPol.attributes.tnLldpIfPolName == "" + - nm_create_leaf_policy_group_again.previous.0.infraAccNodePGrp.children.3.infraRsLeafPGrpToCdpIfPol.attributes.tnCdpIfPolName == "" + - nm_create_leaf_policy_group_again.previous.0.infraAccNodePGrp.children.4.infraRsBfdIpv6InstPol.attributes.tnBfdIpv6InstPolName == "" + - nm_create_leaf_policy_group_again.previous.0.infraAccNodePGrp.children.5.infraRsSynceInstPol.attributes.tnSynceInstPolName == "" + - nm_create_leaf_policy_group_again.previous.0.infraAccNodePGrp.children.6.infraRsPoeInstPol.attributes.tnPoeInstPolName == "" + - nm_create_leaf_policy_group_again.previous.0.infraAccNodePGrp.children.7.infraRsBfdMhIpv4InstPol.attributes.tnBfdMhIpv4InstPolName == "" + - nm_create_leaf_policy_group_again.previous.0.infraAccNodePGrp.children.8.infraRsBfdMhIpv6InstPol.attributes.tnBfdMhIpv6InstPolName == "" + - nm_create_leaf_policy_group_again.previous.0.infraAccNodePGrp.children.9.infraRsEquipmentFlashConfigPol.attributes.tnEquipmentFlashConfigPolName == "" + - nm_create_leaf_policy_group_again.previous.0.infraAccNodePGrp.children.10.infraRsMonNodeInfraPol.attributes.tnMonInfraPolName == "" + - nm_create_leaf_policy_group_again.previous.0.infraAccNodePGrp.children.11.infraRsFcInstPol.attributes.tnFcInstPolName == "" + - nm_create_leaf_policy_group_again.previous.0.infraAccNodePGrp.children.12.infraRsTopoctrlFastLinkFailoverInstPol.attributes.tnTopoctrlFastLinkFailoverInstPolName == "" + - nm_create_leaf_policy_group_again.previous.0.infraAccNodePGrp.children.13.infraRsMstInstPol.attributes.tnStpInstPolName == "" + - nm_create_leaf_policy_group_again.previous.0.infraAccNodePGrp.children.14.infraRsFcFabricPol.attributes.tnFcFabricPolName == "" + - nm_create_leaf_policy_group_again.previous.0.infraAccNodePGrp.children.15.infraRsLeafCoppProfile.attributes.tnCoppLeafProfileName == "" + - nm_create_leaf_policy_group_again.previous.0.infraAccNodePGrp.children.16.infraRsIaclLeafProfile.attributes.tnIaclLeafProfileName == "" + - nm_create_leaf_policy_group_again.previous.0.infraAccNodePGrp.children.17.infraRsBfdIpv4InstPol.attributes.tnBfdIpv4InstPolName == "" + - nm_create_leaf_policy_group_again.previous.0.infraAccNodePGrp.children.18.infraRsL2NodeAuthPol.attributes.tnL2NodeAuthPolName == "" + when: version.current.0.topSystem.attributes.version == "6.0(1g)" + + - name: Change the ansible access switch leaf policy group < 5.0 + cisco.aci.aci_access_switch_policy_group: + <<: *aci_create_leaf_policy_group + spanning_tree_policy: changed_spanning_tree_policy + bfd_ipv4_policy: changed_bfd_ipv4_policy + bfd_ipv6_policy: changed_bfd_ipv6_policy + fibre_channel_node_policy: changed_fibre_channel_node_policy + poe_node_policy: changed_poe_node_policy + fibre_channel_san_policy: changed_fibre_channel_san_policy + monitoring_policy: changed_monitoring_policy + copp_policy: changed_copp_policy + forward_scale_profile_policy: changed_forward_scale_profile_policy + fast_link_failover_policy: changed_fast_link_failover_policy + node_802_1x_authentication_policy: changed_node_802_1x_authentication_policy + copp_pre_filter_policy: changed_copp_pre_filter_policy + equipment_flash_policy: changed_equipment_flash_policy + cdp_policy: changed_cdp_policy + lldp_policy: changed_lldp_policy + register: nm_change_leaf_policy_group_5_2 + when: version.current.0.topSystem.attributes.version is version('5.2', '<') + + - name: Change the ansible access switch leaf policy group + cisco.aci.aci_access_switch_policy_group: + <<: *aci_create_leaf_policy_group + spanning_tree_policy: changed_spanning_tree_policy + bfd_ipv4_policy: changed_bfd_ipv4_policy + bfd_ipv6_policy: changed_bfd_ipv6_policy + bfd_multihop_ipv4_policy: changed_bfd_multihop_ipv4_policy + bfd_multihop_ipv6_policy: changed_bfd_multihop_ipv6_policy + fibre_channel_node_policy: changed_fibre_channel_node_policy + poe_node_policy: changed_poe_node_policy + fibre_channel_san_policy: changed_fibre_channel_san_policy + monitoring_policy: changed_monitoring_policy + copp_policy: changed_copp_policy + forward_scale_profile_policy: changed_forward_scale_profile_policy + fast_link_failover_policy: changed_fast_link_failover_policy + node_802_1x_authentication_policy: changed_node_802_1x_authentication_policy + copp_pre_filter_policy: changed_copp_pre_filter_policy + equipment_flash_policy: changed_equipment_flash_policy + cdp_policy: changed_cdp_policy + lldp_policy: changed_lldp_policy + sync_e_node_policy: changed_sync_e_node_policy + usb_configuration_policy: changed_usb_configuration_policy + register: nm_change_leaf_policy_group + when: version.current.0.topSystem.attributes.version is version('5.2', '>=') + + - name: Verify change of access switch leaf policy group for version 4.2(7s) + ansible.builtin.assert: + that: + - nm_change_leaf_policy_group_5_2 is changed + - nm_change_leaf_policy_group_5_2.current.0.infraAccNodePGrp.children.0.infraRsTopoctrlFwdScaleProfPol.attributes.tnTopoctrlFwdScaleProfilePolName == "changed_forward_scale_profile_policy" + - nm_change_leaf_policy_group_5_2.current.0.infraAccNodePGrp.children.1.infraRsPoeInstPol.attributes.tnPoeInstPolName == "changed_poe_node_policy" + - nm_change_leaf_policy_group_5_2.current.0.infraAccNodePGrp.children.2.infraRsBfdIpv6InstPol.attributes.tnBfdIpv6InstPolName == "changed_bfd_ipv6_policy" + - nm_change_leaf_policy_group_5_2.current.0.infraAccNodePGrp.children.3.infraRsEquipmentFlashConfigPol.attributes.tnEquipmentFlashConfigPolName == "changed_equipment_flash_policy" + - nm_change_leaf_policy_group_5_2.current.0.infraAccNodePGrp.children.4.infraRsMonNodeInfraPol.attributes.tnMonInfraPolName == "changed_monitoring_policy" + - nm_change_leaf_policy_group_5_2.current.0.infraAccNodePGrp.children.5.infraRsFcInstPol.attributes.tnFcInstPolName == "changed_fibre_channel_node_policy" + - nm_change_leaf_policy_group_5_2.current.0.infraAccNodePGrp.children.6.infraRsBfdIpv4InstPol.attributes.tnBfdIpv4InstPolName == "changed_bfd_ipv4_policy" + - nm_change_leaf_policy_group_5_2.current.0.infraAccNodePGrp.children.7.infraRsL2NodeAuthPol.attributes.tnL2NodeAuthPolName == "changed_node_802_1x_authentication_policy" + - nm_change_leaf_policy_group_5_2.current.0.infraAccNodePGrp.children.8.infraRsTopoctrlFastLinkFailoverInstPol.attributes.tnTopoctrlFastLinkFailoverInstPolName == "changed_fast_link_failover_policy" + - nm_change_leaf_policy_group_5_2.current.0.infraAccNodePGrp.children.9.infraRsMstInstPol.attributes.tnStpInstPolName == "changed_spanning_tree_policy" + - nm_change_leaf_policy_group_5_2.current.0.infraAccNodePGrp.children.10.infraRsFcFabricPol.attributes.tnFcFabricPolName == "changed_fibre_channel_san_policy" + - nm_change_leaf_policy_group_5_2.current.0.infraAccNodePGrp.children.11.infraRsIaclLeafProfile.attributes.tnIaclLeafProfileName == "changed_copp_pre_filter_policy" + - nm_change_leaf_policy_group_5_2.current.0.infraAccNodePGrp.children.12.infraRsLeafCoppProfile.attributes.tnCoppLeafProfileName == "changed_copp_policy" + - nm_change_leaf_policy_group_5_2.current.0.infraAccNodePGrp.children.13.infraRsLeafPGrpToCdpIfPol.attributes.tnCdpIfPolName == "changed_cdp_policy" + - nm_change_leaf_policy_group_5_2.current.0.infraAccNodePGrp.children.14.infraRsLeafPGrpToLldpIfPol.attributes.tnLldpIfPolName == "changed_lldp_policy" + - nm_change_leaf_policy_group_5_2.previous.0.infraAccNodePGrp.children.0.infraRsTopoctrlFwdScaleProfPol.attributes.tnTopoctrlFwdScaleProfilePolName == "" + - nm_change_leaf_policy_group_5_2.previous.0.infraAccNodePGrp.children.1.infraRsPoeInstPol.attributes.tnPoeInstPolName == "" + - nm_change_leaf_policy_group_5_2.previous.0.infraAccNodePGrp.children.2.infraRsBfdIpv6InstPol.attributes.tnBfdIpv6InstPolName == "" + - nm_change_leaf_policy_group_5_2.previous.0.infraAccNodePGrp.children.3.infraRsEquipmentFlashConfigPol.attributes.tnEquipmentFlashConfigPolName == "" + - nm_change_leaf_policy_group_5_2.previous.0.infraAccNodePGrp.children.4.infraRsMonNodeInfraPol.attributes.tnMonInfraPolName == "" + - nm_change_leaf_policy_group_5_2.previous.0.infraAccNodePGrp.children.5.infraRsFcInstPol.attributes.tnFcInstPolName == "" + - nm_change_leaf_policy_group_5_2.previous.0.infraAccNodePGrp.children.6.infraRsBfdIpv4InstPol.attributes.tnBfdIpv4InstPolName == "" + - nm_change_leaf_policy_group_5_2.previous.0.infraAccNodePGrp.children.7.infraRsL2NodeAuthPol.attributes.tnL2NodeAuthPolName == "" + - nm_change_leaf_policy_group_5_2.previous.0.infraAccNodePGrp.children.8.infraRsTopoctrlFastLinkFailoverInstPol.attributes.tnTopoctrlFastLinkFailoverInstPolName == "" + - nm_change_leaf_policy_group_5_2.previous.0.infraAccNodePGrp.children.9.infraRsMstInstPol.attributes.tnStpInstPolName == "" + - nm_change_leaf_policy_group_5_2.previous.0.infraAccNodePGrp.children.10.infraRsFcFabricPol.attributes.tnFcFabricPolName == "" + - nm_change_leaf_policy_group_5_2.previous.0.infraAccNodePGrp.children.11.infraRsIaclLeafProfile.attributes.tnIaclLeafProfileName == "" + - nm_change_leaf_policy_group_5_2.previous.0.infraAccNodePGrp.children.12.infraRsLeafCoppProfile.attributes.tnCoppLeafProfileName == "" + - nm_change_leaf_policy_group_5_2.previous.0.infraAccNodePGrp.children.13.infraRsLeafPGrpToCdpIfPol.attributes.tnCdpIfPolName == "" + - nm_change_leaf_policy_group_5_2.previous.0.infraAccNodePGrp.children.14.infraRsLeafPGrpToLldpIfPol.attributes.tnLldpIfPolName == "" + when: version.current.0.topSystem.attributes.version == "4.2(7s)" + + - name: Verify change of access switch leaf policy group for version 5.2(5c) + ansible.builtin.assert: + that: + - nm_change_leaf_policy_group is changed + - nm_change_leaf_policy_group.current.0.infraAccNodePGrp.children.0.infraRsTopoctrlFwdScaleProfPol.attributes.tnTopoctrlFwdScaleProfilePolName == "changed_forward_scale_profile_policy" + - nm_change_leaf_policy_group.current.0.infraAccNodePGrp.children.1.infraRsLeafTopoctrlUsbConfigProfilePol.attributes.tnTopoctrlUsbConfigProfilePolName == "changed_usb_configuration_policy" + - nm_change_leaf_policy_group.current.0.infraAccNodePGrp.children.2.infraRsLeafPGrpToLldpIfPol.attributes.tnLldpIfPolName == "changed_lldp_policy" + - nm_change_leaf_policy_group.current.0.infraAccNodePGrp.children.3.infraRsLeafPGrpToCdpIfPol.attributes.tnCdpIfPolName == "changed_cdp_policy" + - nm_change_leaf_policy_group.current.0.infraAccNodePGrp.children.4.infraRsBfdIpv6InstPol.attributes.tnBfdIpv6InstPolName == "changed_bfd_ipv6_policy" + - nm_change_leaf_policy_group.current.0.infraAccNodePGrp.children.5.infraRsSynceInstPol.attributes.tnSynceInstPolName == "changed_sync_e_node_policy" + - nm_change_leaf_policy_group.current.0.infraAccNodePGrp.children.6.infraRsPoeInstPol.attributes.tnPoeInstPolName == "changed_poe_node_policy" + - nm_change_leaf_policy_group.current.0.infraAccNodePGrp.children.7.infraRsBfdMhIpv4InstPol.attributes.tnBfdMhIpv4InstPolName == "changed_bfd_multihop_ipv4_policy" + - nm_change_leaf_policy_group.current.0.infraAccNodePGrp.children.8.infraRsBfdMhIpv6InstPol.attributes.tnBfdMhIpv6InstPolName == "changed_bfd_multihop_ipv6_policy" + - nm_change_leaf_policy_group.current.0.infraAccNodePGrp.children.9.infraRsEquipmentFlashConfigPol.attributes.tnEquipmentFlashConfigPolName == "changed_equipment_flash_policy" + - nm_change_leaf_policy_group.current.0.infraAccNodePGrp.children.10.infraRsMonNodeInfraPol.attributes.tnMonInfraPolName == "changed_monitoring_policy" + - nm_change_leaf_policy_group.current.0.infraAccNodePGrp.children.11.infraRsFcInstPol.attributes.tnFcInstPolName == "changed_fibre_channel_node_policy" + - nm_change_leaf_policy_group.current.0.infraAccNodePGrp.children.12.infraRsTopoctrlFastLinkFailoverInstPol.attributes.tnTopoctrlFastLinkFailoverInstPolName == "changed_fast_link_failover_policy" + - nm_change_leaf_policy_group.current.0.infraAccNodePGrp.children.13.infraRsMstInstPol.attributes.tnStpInstPolName == "changed_spanning_tree_policy" + - nm_change_leaf_policy_group.current.0.infraAccNodePGrp.children.14.infraRsFcFabricPol.attributes.tnFcFabricPolName == "changed_fibre_channel_san_policy" + - nm_change_leaf_policy_group.current.0.infraAccNodePGrp.children.15.infraRsLeafCoppProfile.attributes.tnCoppLeafProfileName == "changed_copp_policy" + - nm_change_leaf_policy_group.current.0.infraAccNodePGrp.children.16.infraRsIaclLeafProfile.attributes.tnIaclLeafProfileName == "changed_copp_pre_filter_policy" + - nm_change_leaf_policy_group.current.0.infraAccNodePGrp.children.17.infraRsBfdIpv4InstPol.attributes.tnBfdIpv4InstPolName == "changed_bfd_ipv4_policy" + - nm_change_leaf_policy_group.current.0.infraAccNodePGrp.children.18.infraRsL2NodeAuthPol.attributes.tnL2NodeAuthPolName == "changed_node_802_1x_authentication_policy" + - nm_change_leaf_policy_group.previous.0.infraAccNodePGrp.children.0.infraRsTopoctrlFwdScaleProfPol.attributes.tnTopoctrlFwdScaleProfilePolName == "" + - nm_change_leaf_policy_group.previous.0.infraAccNodePGrp.children.1.infraRsLeafTopoctrlUsbConfigProfilePol.attributes.tnTopoctrlUsbConfigProfilePolName == "" + - nm_change_leaf_policy_group.previous.0.infraAccNodePGrp.children.2.infraRsLeafPGrpToLldpIfPol.attributes.tnLldpIfPolName == "" + - nm_change_leaf_policy_group.previous.0.infraAccNodePGrp.children.3.infraRsLeafPGrpToCdpIfPol.attributes.tnCdpIfPolName == "" + - nm_change_leaf_policy_group.previous.0.infraAccNodePGrp.children.4.infraRsBfdIpv6InstPol.attributes.tnBfdIpv6InstPolName == "" + - nm_change_leaf_policy_group.previous.0.infraAccNodePGrp.children.5.infraRsSynceInstPol.attributes.tnSynceInstPolName == "" + - nm_change_leaf_policy_group.previous.0.infraAccNodePGrp.children.6.infraRsPoeInstPol.attributes.tnPoeInstPolName == "" + - nm_change_leaf_policy_group.previous.0.infraAccNodePGrp.children.7.infraRsBfdMhIpv4InstPol.attributes.tnBfdMhIpv4InstPolName == "" + - nm_change_leaf_policy_group.previous.0.infraAccNodePGrp.children.8.infraRsBfdMhIpv6InstPol.attributes.tnBfdMhIpv6InstPolName == "" + - nm_change_leaf_policy_group.previous.0.infraAccNodePGrp.children.9.infraRsEquipmentFlashConfigPol.attributes.tnEquipmentFlashConfigPolName == "" + - nm_change_leaf_policy_group.previous.0.infraAccNodePGrp.children.10.infraRsMonNodeInfraPol.attributes.tnMonInfraPolName == "" + - nm_change_leaf_policy_group.previous.0.infraAccNodePGrp.children.11.infraRsFcInstPol.attributes.tnFcInstPolName == "" + - nm_change_leaf_policy_group.previous.0.infraAccNodePGrp.children.12.infraRsTopoctrlFastLinkFailoverInstPol.attributes.tnTopoctrlFastLinkFailoverInstPolName == "" + - nm_change_leaf_policy_group.previous.0.infraAccNodePGrp.children.13.infraRsMstInstPol.attributes.tnStpInstPolName == "" + - nm_change_leaf_policy_group.previous.0.infraAccNodePGrp.children.14.infraRsFcFabricPol.attributes.tnFcFabricPolName == "" + - nm_change_leaf_policy_group.previous.0.infraAccNodePGrp.children.15.infraRsLeafCoppProfile.attributes.tnCoppLeafProfileName == "" + - nm_change_leaf_policy_group.previous.0.infraAccNodePGrp.children.16.infraRsIaclLeafProfile.attributes.tnIaclLeafProfileName == "" + - nm_change_leaf_policy_group.previous.0.infraAccNodePGrp.children.17.infraRsBfdIpv4InstPol.attributes.tnBfdIpv4InstPolName == "" + - nm_change_leaf_policy_group.previous.0.infraAccNodePGrp.children.18.infraRsL2NodeAuthPol.attributes.tnL2NodeAuthPolName == "" + when: version.current.0.topSystem.attributes.version == "5.2(5c)" + + - name: Verify change of access switch leaf policy group for version 6.0(2h) + ansible.builtin.assert: + that: + - nm_change_leaf_policy_group is changed + - nm_change_leaf_policy_group.current.0.infraAccNodePGrp.children.0.infraRsTopoctrlFwdScaleProfPol.attributes.tnTopoctrlFwdScaleProfilePolName == "changed_forward_scale_profile_policy" + - nm_change_leaf_policy_group.current.0.infraAccNodePGrp.children.1.infraRsLeafTopoctrlUsbConfigProfilePol.attributes.tnTopoctrlUsbConfigProfilePolName == "changed_usb_configuration_policy" + - nm_change_leaf_policy_group.current.0.infraAccNodePGrp.children.2.infraRsLeafPGrpToLldpIfPol.attributes.tnLldpIfPolName == "changed_lldp_policy" + - nm_change_leaf_policy_group.current.0.infraAccNodePGrp.children.3.infraRsBfdIpv6InstPol.attributes.tnBfdIpv6InstPolName == "changed_bfd_ipv6_policy" + - nm_change_leaf_policy_group.current.0.infraAccNodePGrp.children.4.infraRsSynceInstPol.attributes.tnSynceInstPolName == "changed_sync_e_node_policy" + - nm_change_leaf_policy_group.current.0.infraAccNodePGrp.children.5.infraRsPoeInstPol.attributes.tnPoeInstPolName == "changed_poe_node_policy" + - nm_change_leaf_policy_group.current.0.infraAccNodePGrp.children.6.infraRsBfdMhIpv4InstPol.attributes.tnBfdMhIpv4InstPolName == "changed_bfd_multihop_ipv4_policy" + - nm_change_leaf_policy_group.current.0.infraAccNodePGrp.children.7.infraRsBfdMhIpv6InstPol.attributes.tnBfdMhIpv6InstPolName == "changed_bfd_multihop_ipv6_policy" + - nm_change_leaf_policy_group.current.0.infraAccNodePGrp.children.8.infraRsEquipmentFlashConfigPol.attributes.tnEquipmentFlashConfigPolName == "changed_equipment_flash_policy" + - nm_change_leaf_policy_group.current.0.infraAccNodePGrp.children.9.infraRsMonNodeInfraPol.attributes.tnMonInfraPolName == "changed_monitoring_policy" + - nm_change_leaf_policy_group.current.0.infraAccNodePGrp.children.10.infraRsFcInstPol.attributes.tnFcInstPolName == "changed_fibre_channel_node_policy" + - nm_change_leaf_policy_group.current.0.infraAccNodePGrp.children.11.infraRsTopoctrlFastLinkFailoverInstPol.attributes.tnTopoctrlFastLinkFailoverInstPolName == "changed_fast_link_failover_policy" + - nm_change_leaf_policy_group.current.0.infraAccNodePGrp.children.12.infraRsMstInstPol.attributes.tnStpInstPolName == "changed_spanning_tree_policy" + - nm_change_leaf_policy_group.current.0.infraAccNodePGrp.children.13.infraRsFcFabricPol.attributes.tnFcFabricPolName == "changed_fibre_channel_san_policy" + - nm_change_leaf_policy_group.current.0.infraAccNodePGrp.children.14.infraRsLeafCoppProfile.attributes.tnCoppLeafProfileName == "changed_copp_policy" + - nm_change_leaf_policy_group.current.0.infraAccNodePGrp.children.15.infraRsIaclLeafProfile.attributes.tnIaclLeafProfileName == "changed_copp_pre_filter_policy" + - nm_change_leaf_policy_group.current.0.infraAccNodePGrp.children.16.infraRsBfdIpv4InstPol.attributes.tnBfdIpv4InstPolName == "changed_bfd_ipv4_policy" + - nm_change_leaf_policy_group.current.0.infraAccNodePGrp.children.17.infraRsL2NodeAuthPol.attributes.tnL2NodeAuthPolName == "changed_node_802_1x_authentication_policy" + - nm_change_leaf_policy_group.current.0.infraAccNodePGrp.children.18.infraRsLeafPGrpToCdpIfPol.attributes.tnCdpIfPolName == "changed_cdp_policy" + - nm_change_leaf_policy_group.previous.0.infraAccNodePGrp.children.0.infraRsTopoctrlFwdScaleProfPol.attributes.tnTopoctrlFwdScaleProfilePolName == "" + - nm_change_leaf_policy_group.previous.0.infraAccNodePGrp.children.1.infraRsLeafTopoctrlUsbConfigProfilePol.attributes.tnTopoctrlUsbConfigProfilePolName == "" + - nm_change_leaf_policy_group.previous.0.infraAccNodePGrp.children.2.infraRsLeafPGrpToLldpIfPol.attributes.tnLldpIfPolName == "" + - nm_change_leaf_policy_group.previous.0.infraAccNodePGrp.children.3.infraRsBfdIpv6InstPol.attributes.tnBfdIpv6InstPolName == "" + - nm_change_leaf_policy_group.previous.0.infraAccNodePGrp.children.4.infraRsSynceInstPol.attributes.tnSynceInstPolName == "" + - nm_change_leaf_policy_group.previous.0.infraAccNodePGrp.children.5.infraRsPoeInstPol.attributes.tnPoeInstPolName == "" + - nm_change_leaf_policy_group.previous.0.infraAccNodePGrp.children.6.infraRsBfdMhIpv4InstPol.attributes.tnBfdMhIpv4InstPolName == "" + - nm_change_leaf_policy_group.previous.0.infraAccNodePGrp.children.7.infraRsBfdMhIpv6InstPol.attributes.tnBfdMhIpv6InstPolName == "" + - nm_change_leaf_policy_group.previous.0.infraAccNodePGrp.children.8.infraRsEquipmentFlashConfigPol.attributes.tnEquipmentFlashConfigPolName == "" + - nm_change_leaf_policy_group.previous.0.infraAccNodePGrp.children.9.infraRsMonNodeInfraPol.attributes.tnMonInfraPolName == "" + - nm_change_leaf_policy_group.previous.0.infraAccNodePGrp.children.10.infraRsFcInstPol.attributes.tnFcInstPolName == "" + - nm_change_leaf_policy_group.previous.0.infraAccNodePGrp.children.11.infraRsTopoctrlFastLinkFailoverInstPol.attributes.tnTopoctrlFastLinkFailoverInstPolName == "" + - nm_change_leaf_policy_group.previous.0.infraAccNodePGrp.children.12.infraRsMstInstPol.attributes.tnStpInstPolName == "" + - nm_change_leaf_policy_group.previous.0.infraAccNodePGrp.children.13.infraRsFcFabricPol.attributes.tnFcFabricPolName == "" + - nm_change_leaf_policy_group.previous.0.infraAccNodePGrp.children.14.infraRsLeafCoppProfile.attributes.tnCoppLeafProfileName == "" + - nm_change_leaf_policy_group.previous.0.infraAccNodePGrp.children.15.infraRsIaclLeafProfile.attributes.tnIaclLeafProfileName == "" + - nm_change_leaf_policy_group.previous.0.infraAccNodePGrp.children.16.infraRsBfdIpv4InstPol.attributes.tnBfdIpv4InstPolName == "" + - nm_change_leaf_policy_group.previous.0.infraAccNodePGrp.children.17.infraRsL2NodeAuthPol.attributes.tnL2NodeAuthPolName == "" + - nm_change_leaf_policy_group.previous.0.infraAccNodePGrp.children.18.infraRsLeafPGrpToCdpIfPol.attributes.tnCdpIfPolName == "" + when: version.current.0.topSystem.attributes.version == "6.0(2h)" + + - name: Verify change of access switch leaf policy group for version 6.0(1g) + ansible.builtin.assert: + that: + - nm_change_leaf_policy_group is changed + - nm_change_leaf_policy_group.current.0.infraAccNodePGrp.children.0.infraRsTopoctrlFwdScaleProfPol.attributes.tnTopoctrlFwdScaleProfilePolName == "changed_forward_scale_profile_policy" + - nm_change_leaf_policy_group.current.0.infraAccNodePGrp.children.1.infraRsLeafTopoctrlUsbConfigProfilePol.attributes.tnTopoctrlUsbConfigProfilePolName == "changed_usb_configuration_policy" + - nm_change_leaf_policy_group.current.0.infraAccNodePGrp.children.2.infraRsLeafPGrpToLldpIfPol.attributes.tnLldpIfPolName == "changed_lldp_policy" + - nm_change_leaf_policy_group.current.0.infraAccNodePGrp.children.3.infraRsLeafPGrpToCdpIfPol.attributes.tnCdpIfPolName == "changed_cdp_policy" + - nm_change_leaf_policy_group.current.0.infraAccNodePGrp.children.4.infraRsBfdIpv6InstPol.attributes.tnBfdIpv6InstPolName == "changed_bfd_ipv6_policy" + - nm_change_leaf_policy_group.current.0.infraAccNodePGrp.children.5.infraRsSynceInstPol.attributes.tnSynceInstPolName == "changed_sync_e_node_policy" + - nm_change_leaf_policy_group.current.0.infraAccNodePGrp.children.6.infraRsPoeInstPol.attributes.tnPoeInstPolName == "changed_poe_node_policy" + - nm_change_leaf_policy_group.current.0.infraAccNodePGrp.children.7.infraRsBfdMhIpv4InstPol.attributes.tnBfdMhIpv4InstPolName == "changed_bfd_multihop_ipv4_policy" + - nm_change_leaf_policy_group.current.0.infraAccNodePGrp.children.8.infraRsBfdMhIpv6InstPol.attributes.tnBfdMhIpv6InstPolName == "changed_bfd_multihop_ipv6_policy" + - nm_change_leaf_policy_group.current.0.infraAccNodePGrp.children.9.infraRsEquipmentFlashConfigPol.attributes.tnEquipmentFlashConfigPolName == "changed_equipment_flash_policy" + - nm_change_leaf_policy_group.current.0.infraAccNodePGrp.children.10.infraRsMonNodeInfraPol.attributes.tnMonInfraPolName == "changed_monitoring_policy" + - nm_change_leaf_policy_group.current.0.infraAccNodePGrp.children.11.infraRsFcInstPol.attributes.tnFcInstPolName == "changed_fibre_channel_node_policy" + - nm_change_leaf_policy_group.current.0.infraAccNodePGrp.children.12.infraRsTopoctrlFastLinkFailoverInstPol.attributes.tnTopoctrlFastLinkFailoverInstPolName == "changed_fast_link_failover_policy" + - nm_change_leaf_policy_group.current.0.infraAccNodePGrp.children.13.infraRsMstInstPol.attributes.tnStpInstPolName == "changed_spanning_tree_policy" + - nm_change_leaf_policy_group.current.0.infraAccNodePGrp.children.14.infraRsFcFabricPol.attributes.tnFcFabricPolName == "changed_fibre_channel_san_policy" + - nm_change_leaf_policy_group.current.0.infraAccNodePGrp.children.15.infraRsLeafCoppProfile.attributes.tnCoppLeafProfileName == "changed_copp_policy" + - nm_change_leaf_policy_group.current.0.infraAccNodePGrp.children.16.infraRsIaclLeafProfile.attributes.tnIaclLeafProfileName == "changed_copp_pre_filter_policy" + - nm_change_leaf_policy_group.current.0.infraAccNodePGrp.children.17.infraRsBfdIpv4InstPol.attributes.tnBfdIpv4InstPolName == "changed_bfd_ipv4_policy" + - nm_change_leaf_policy_group.current.0.infraAccNodePGrp.children.18.infraRsL2NodeAuthPol.attributes.tnL2NodeAuthPolName == "changed_node_802_1x_authentication_policy" + - nm_change_leaf_policy_group.previous.0.infraAccNodePGrp.children.0.infraRsTopoctrlFwdScaleProfPol.attributes.tnTopoctrlFwdScaleProfilePolName == "" + - nm_change_leaf_policy_group.previous.0.infraAccNodePGrp.children.1.infraRsLeafTopoctrlUsbConfigProfilePol.attributes.tnTopoctrlUsbConfigProfilePolName == "" + - nm_change_leaf_policy_group.previous.0.infraAccNodePGrp.children.2.infraRsLeafPGrpToLldpIfPol.attributes.tnLldpIfPolName == "" + - nm_change_leaf_policy_group.previous.0.infraAccNodePGrp.children.3.infraRsLeafPGrpToCdpIfPol.attributes.tnCdpIfPolName == "" + - nm_change_leaf_policy_group.previous.0.infraAccNodePGrp.children.4.infraRsBfdIpv6InstPol.attributes.tnBfdIpv6InstPolName == "" + - nm_change_leaf_policy_group.previous.0.infraAccNodePGrp.children.5.infraRsSynceInstPol.attributes.tnSynceInstPolName == "" + - nm_change_leaf_policy_group.previous.0.infraAccNodePGrp.children.6.infraRsPoeInstPol.attributes.tnPoeInstPolName == "" + - nm_change_leaf_policy_group.previous.0.infraAccNodePGrp.children.7.infraRsBfdMhIpv4InstPol.attributes.tnBfdMhIpv4InstPolName == "" + - nm_change_leaf_policy_group.previous.0.infraAccNodePGrp.children.8.infraRsBfdMhIpv6InstPol.attributes.tnBfdMhIpv6InstPolName == "" + - nm_change_leaf_policy_group.previous.0.infraAccNodePGrp.children.9.infraRsEquipmentFlashConfigPol.attributes.tnEquipmentFlashConfigPolName == "" + - nm_change_leaf_policy_group.previous.0.infraAccNodePGrp.children.10.infraRsMonNodeInfraPol.attributes.tnMonInfraPolName == "" + - nm_change_leaf_policy_group.previous.0.infraAccNodePGrp.children.11.infraRsFcInstPol.attributes.tnFcInstPolName == "" + - nm_change_leaf_policy_group.previous.0.infraAccNodePGrp.children.12.infraRsTopoctrlFastLinkFailoverInstPol.attributes.tnTopoctrlFastLinkFailoverInstPolName == "" + - nm_change_leaf_policy_group.previous.0.infraAccNodePGrp.children.13.infraRsMstInstPol.attributes.tnStpInstPolName == "" + - nm_change_leaf_policy_group.previous.0.infraAccNodePGrp.children.14.infraRsFcFabricPol.attributes.tnFcFabricPolName == "" + - nm_change_leaf_policy_group.previous.0.infraAccNodePGrp.children.15.infraRsLeafCoppProfile.attributes.tnCoppLeafProfileName == "" + - nm_change_leaf_policy_group.previous.0.infraAccNodePGrp.children.16.infraRsIaclLeafProfile.attributes.tnIaclLeafProfileName == "" + - nm_change_leaf_policy_group.previous.0.infraAccNodePGrp.children.17.infraRsBfdIpv4InstPol.attributes.tnBfdIpv4InstPolName == "" + - nm_change_leaf_policy_group.previous.0.infraAccNodePGrp.children.18.infraRsL2NodeAuthPol.attributes.tnL2NodeAuthPolName == "" + when: version.current.0.topSystem.attributes.version == "6.0(1g)" + + - name: Create netflow_node_policy in the ansible access switch leaf policy group 2 + cisco.aci.aci_access_switch_policy_group: &aci_create_leaf_policy_group_2 + <<: *aci_create_leaf_policy_group + name: ansible_access_switch_leaf_pol_grp_2 + netflow_node_policy: create_netflow_node_policy + register: nm_netflow_create + + - name: Change netflow_node_policy in the ansible access switch leaf policy group 2 + cisco.aci.aci_access_switch_policy_group: + <<: *aci_create_leaf_policy_group_2 + netflow_node_policy: changed_netflow_node_policy + register: nm_netflow_change + + - name: Create ptp_node_policy in the ansible access switch leaf policy group 2 for version >= 5.2 + cisco.aci.aci_access_switch_policy_group: + <<: *aci_create_leaf_policy_group_2 + ptp_node_policy: create_ptp_node_policy + register: nm_ptp_create + when: version.current.0.topSystem.attributes.version is version('5.2', '>=') + + - name: Change ptp_node_policy in the ansible access switch leaf policy group 2 for version >= 5.2 + cisco.aci.aci_access_switch_policy_group: + <<: *aci_create_leaf_policy_group_2 + ptp_node_policy: changed_ptp_node_policy + register: nm_ptp_change + when: version.current.0.topSystem.attributes.version is version('5.2', '>=') + + - name: Verify netflow_node_policy leaf policy group for version 4.2(7s) + ansible.builtin.assert: + that: + - nm_netflow_create is changed + - nm_netflow_create.current.0.infraAccNodePGrp.children.2.infraRsNetflowNodePol.attributes.tnNetflowNodePolName == "create_netflow_node_policy" + - nm_netflow_change is changed + - nm_netflow_change.current.0.infraAccNodePGrp.children.2.infraRsNetflowNodePol.attributes.tnNetflowNodePolName == "changed_netflow_node_policy" + when: version.current.0.topSystem.attributes.version == "4.2(7s)" + + - name: Verify netflow_node_policy and ptp_node_policy leaf policy group for version 5.2(5c) + ansible.builtin.assert: + that: + - nm_netflow_create is changed + - nm_netflow_create.current.0.infraAccNodePGrp.children.1.infraRsNetflowNodePol.attributes.tnNetflowNodePolName == "create_netflow_node_policy" + - nm_netflow_change is changed + - nm_netflow_change.current.0.infraAccNodePGrp.children.1.infraRsNetflowNodePol.attributes.tnNetflowNodePolName == "changed_netflow_node_policy" + - nm_ptp_create is changed + - nm_ptp_create.current.0.infraAccNodePGrp.children.10.infraRsPtpInstPol.attributes.tnPtpInstPolName == "create_ptp_node_policy" + - nm_ptp_change is changed + - nm_ptp_change.current.0.infraAccNodePGrp.children.10.infraRsPtpInstPol.attributes.tnPtpInstPolName == "changed_ptp_node_policy" + when: version.current.0.topSystem.attributes.version == "5.2(5c)" + + - name: Verify netflow_node_policy and ptp_node_policy leaf policy group for version 6.0(2h) + ansible.builtin.assert: + that: + - nm_netflow_create is changed + - nm_netflow_create.current.0.infraAccNodePGrp.children.1.infraRsNetflowNodePol.attributes.tnNetflowNodePolName == "create_netflow_node_policy" + - nm_netflow_change is changed + - nm_netflow_change.current.0.infraAccNodePGrp.children.1.infraRsNetflowNodePol.attributes.tnNetflowNodePolName == "changed_netflow_node_policy" + - nm_ptp_create is changed + - nm_ptp_create.current.0.infraAccNodePGrp.children.9.infraRsPtpInstPol.attributes.tnPtpInstPolName == "create_ptp_node_policy" + - nm_ptp_change is changed + - nm_ptp_change.current.0.infraAccNodePGrp.children.9.infraRsPtpInstPol.attributes.tnPtpInstPolName == "changed_ptp_node_policy" + when: version.current.0.topSystem.attributes.version == "6.0(2h)" + + - name: Verify netflow_node_policy and ptp_node_policy leaf policy group for version 6.0(1g) + ansible.builtin.assert: + that: + - nm_netflow_create is changed + - nm_netflow_create.current.0.infraAccNodePGrp.children.1.infraRsNetflowNodePol.attributes.tnNetflowNodePolName == "create_netflow_node_policy" + - nm_netflow_change is changed + - nm_netflow_change.current.0.infraAccNodePGrp.children.1.infraRsNetflowNodePol.attributes.tnNetflowNodePolName == "changed_netflow_node_policy" + - nm_ptp_create is changed + - nm_ptp_create.current.0.infraAccNodePGrp.children.10.infraRsPtpInstPol.attributes.tnPtpInstPolName == "create_ptp_node_policy" + - nm_ptp_change is changed + - nm_ptp_change.current.0.infraAccNodePGrp.children.10.infraRsPtpInstPol.attributes.tnPtpInstPolName == "changed_ptp_node_policy" + when: version.current.0.topSystem.attributes.version == "6.0(1g)" + + - name: Query the ansible access switch leaf policy group 2 + cisco.aci.aci_access_switch_policy_group: + <<: *aci_create_leaf_policy_group_2 + state: query + register: query_one + + - name: Query all the ansible access switch leaf policy groups + cisco.aci.aci_access_switch_policy_group: + <<: *aci_info + switch_type: leaf + state: query + register: query_all + + - name: Verify remove of access switch policy + ansible.builtin.assert: + that: + - query_one is not changed + - query_one.current | length == 1 + - query_all is not changed + - query_all.current | length > 1 + + - name: Remove the ansible access switch leaf policy group (check mode) + cisco.aci.aci_access_switch_policy_group: &aci_remove_leaf_policy_group + <<: *aci_info + switch_type: leaf + name: ansible_access_switch_leaf_pol_grp + state: absent + check_mode: true + register: cm_remove_leaf_policy_group + + - name: Remove the ansible access switch leaf policy group + cisco.aci.aci_access_switch_policy_group: + <<: *aci_remove_leaf_policy_group + register: nm_remove_leaf_policy_group + + - name: Remove the ansible access switch leaf policy group again + cisco.aci.aci_access_switch_policy_group: + <<: *aci_remove_leaf_policy_group + register: nm_remove_leaf_policy_group_again + + - name: Verify remove of access switch leaf policy group + ansible.builtin.assert: + that: + - cm_remove_leaf_policy_group is changed + - nm_remove_leaf_policy_group.previous != [] + - nm_remove_leaf_policy_group.proposed == {} + - nm_remove_leaf_policy_group is changed + - nm_remove_leaf_policy_group.previous != [] + - nm_remove_leaf_policy_group.current == [] + - nm_remove_leaf_policy_group_again is not changed + - nm_remove_leaf_policy_group_again.previous == [] + - nm_remove_leaf_policy_group_again.current == [] + + # ACCESS SWITCH SPINE POLICY GROUP + - name: Create the ansible access switch spine policy group (check mode) + cisco.aci.aci_access_switch_policy_group: &aci_create_spine_policy_group + <<: *aci_info + switch_type: spine + name: ansible_access_switch_spine_pol_grp + state: present + check_mode: yes + register: cm_create_spine_policy_group + + - name: Create the ansible access switch spine policy group + cisco.aci.aci_access_switch_policy_group: + <<: *aci_create_spine_policy_group + register: nm_create_spine_policy_group + + - name: Create the ansible access switch spine policy group again + cisco.aci.aci_access_switch_policy_group: + <<: *aci_create_spine_policy_group + register: nm_create_spine_policy_group_again + + - name: Verify creation of access switch spine policy group for version >= 5.2 + ansible.builtin.assert: + that: + - cm_create_spine_policy_group is changed + - cm_create_spine_policy_group.proposed.infraSpineAccNodePGrp.attributes.annotation == "orchestrator:ansible" + - cm_create_spine_policy_group.proposed.infraSpineAccNodePGrp.attributes.dn == "uni/infra/funcprof/spaccnodepgrp-ansible_access_switch_spine_pol_grp" + - cm_create_spine_policy_group.previous == [] + - cm_create_spine_policy_group.current == [] + - nm_create_spine_policy_group is changed + - nm_create_spine_policy_group.previous == [] + - nm_create_spine_policy_group.current.0.infraSpineAccNodePGrp.attributes.annotation == "orchestrator:ansible" + - nm_create_spine_policy_group.current.0.infraSpineAccNodePGrp.attributes.dn == "uni/infra/funcprof/spaccnodepgrp-ansible_access_switch_spine_pol_grp" + - nm_create_spine_policy_group.current.0.infraSpineAccNodePGrp.attributes.name == "ansible_access_switch_spine_pol_grp" + - nm_create_spine_policy_group.current.0.infraSpineAccNodePGrp.children.0.infraRsSpineTopoctrlUsbConfigProfilePol.attributes.tnTopoctrlUsbConfigProfilePolName == "" + - nm_create_spine_policy_group.current.0.infraSpineAccNodePGrp.children.1.infraRsSpinePGrpToLldpIfPol.attributes.tnLldpIfPolName == "" + - nm_create_spine_policy_group.current.0.infraSpineAccNodePGrp.children.2.infraRsSpinePGrpToCdpIfPol.attributes.tnCdpIfPolName == "" + - nm_create_spine_policy_group.current.0.infraSpineAccNodePGrp.children.3.infraRsSpineCoppProfile.attributes.tnCoppSpineProfileName == "" + - nm_create_spine_policy_group.current.0.infraSpineAccNodePGrp.children.4.infraRsSpineBfdIpv6InstPol.attributes.tnBfdIpv6InstPolName == "" + - nm_create_spine_policy_group.current.0.infraSpineAccNodePGrp.children.5.infraRsSpineBfdIpv4InstPol.attributes.tnBfdIpv4InstPolName == "" + - nm_create_spine_policy_group.current.0.infraSpineAccNodePGrp.children.6.infraRsIaclSpineProfile.attributes.tnIaclSpineProfileName == "" + - nm_create_spine_policy_group.previous == [] + - nm_create_spine_policy_group_again is not changed + - nm_create_spine_policy_group_again.current.0.infraSpineAccNodePGrp.attributes.annotation == "orchestrator:ansible" + - nm_create_spine_policy_group_again.current.0.infraSpineAccNodePGrp.attributes.dn == "uni/infra/funcprof/spaccnodepgrp-ansible_access_switch_spine_pol_grp" + - nm_create_spine_policy_group_again.current.0.infraSpineAccNodePGrp.attributes.name == "ansible_access_switch_spine_pol_grp" + - nm_create_spine_policy_group_again.current.0.infraSpineAccNodePGrp.children.0.infraRsSpineTopoctrlUsbConfigProfilePol.attributes.tnTopoctrlUsbConfigProfilePolName == "" + - nm_create_spine_policy_group_again.current.0.infraSpineAccNodePGrp.children.1.infraRsSpinePGrpToLldpIfPol.attributes.tnLldpIfPolName == "" + - nm_create_spine_policy_group_again.current.0.infraSpineAccNodePGrp.children.2.infraRsSpinePGrpToCdpIfPol.attributes.tnCdpIfPolName == "" + - nm_create_spine_policy_group_again.current.0.infraSpineAccNodePGrp.children.3.infraRsSpineCoppProfile.attributes.tnCoppSpineProfileName == "" + - nm_create_spine_policy_group_again.current.0.infraSpineAccNodePGrp.children.4.infraRsSpineBfdIpv6InstPol.attributes.tnBfdIpv6InstPolName == "" + - nm_create_spine_policy_group_again.current.0.infraSpineAccNodePGrp.children.5.infraRsSpineBfdIpv4InstPol.attributes.tnBfdIpv4InstPolName == "" + - nm_create_spine_policy_group_again.current.0.infraSpineAccNodePGrp.children.6.infraRsIaclSpineProfile.attributes.tnIaclSpineProfileName == "" + - nm_create_spine_policy_group_again.previous.0.infraSpineAccNodePGrp.attributes.annotation == "orchestrator:ansible" + - nm_create_spine_policy_group_again.previous.0.infraSpineAccNodePGrp.attributes.dn == "uni/infra/funcprof/spaccnodepgrp-ansible_access_switch_spine_pol_grp" + - nm_create_spine_policy_group_again.previous.0.infraSpineAccNodePGrp.attributes.name == "ansible_access_switch_spine_pol_grp" + - nm_create_spine_policy_group_again.previous.0.infraSpineAccNodePGrp.children.0.infraRsSpineTopoctrlUsbConfigProfilePol.attributes.tnTopoctrlUsbConfigProfilePolName == "" + - nm_create_spine_policy_group_again.previous.0.infraSpineAccNodePGrp.children.1.infraRsSpinePGrpToLldpIfPol.attributes.tnLldpIfPolName == "" + - nm_create_spine_policy_group_again.previous.0.infraSpineAccNodePGrp.children.2.infraRsSpinePGrpToCdpIfPol.attributes.tnCdpIfPolName == "" + - nm_create_spine_policy_group_again.previous.0.infraSpineAccNodePGrp.children.3.infraRsSpineCoppProfile.attributes.tnCoppSpineProfileName == "" + - nm_create_spine_policy_group_again.previous.0.infraSpineAccNodePGrp.children.4.infraRsSpineBfdIpv6InstPol.attributes.tnBfdIpv6InstPolName == "" + - nm_create_spine_policy_group_again.previous.0.infraSpineAccNodePGrp.children.5.infraRsSpineBfdIpv4InstPol.attributes.tnBfdIpv4InstPolName == "" + - nm_create_spine_policy_group_again.previous.0.infraSpineAccNodePGrp.children.6.infraRsIaclSpineProfile.attributes.tnIaclSpineProfileName == "" + when: version.current.0.topSystem.attributes.version is version('5.2', '>=') + + - name: Verify creation of access switch spine policy group for version < "5" + ansible.builtin.assert: + that: + - cm_create_spine_policy_group is changed + - cm_create_spine_policy_group.proposed.infraSpineAccNodePGrp.attributes.annotation == "orchestrator:ansible" + - cm_create_spine_policy_group.proposed.infraSpineAccNodePGrp.attributes.dn == "uni/infra/funcprof/spaccnodepgrp-ansible_access_switch_spine_pol_grp" + - cm_create_spine_policy_group.previous == [] + - cm_create_spine_policy_group.current == [] + - nm_create_spine_policy_group is changed + - nm_create_spine_policy_group.previous == [] + - nm_create_spine_policy_group.current.0.infraSpineAccNodePGrp.attributes.annotation == "orchestrator:ansible" + - nm_create_spine_policy_group.current.0.infraSpineAccNodePGrp.attributes.dn == "uni/infra/funcprof/spaccnodepgrp-ansible_access_switch_spine_pol_grp" + - nm_create_spine_policy_group.current.0.infraSpineAccNodePGrp.attributes.name == "ansible_access_switch_spine_pol_grp" + - nm_create_spine_policy_group.current.0.infraSpineAccNodePGrp.children.0.infraRsSpinePGrpToLldpIfPol.attributes.tnLldpIfPolName == "" + - nm_create_spine_policy_group.current.0.infraSpineAccNodePGrp.children.1.infraRsSpinePGrpToCdpIfPol.attributes.tnCdpIfPolName == "" + - nm_create_spine_policy_group.current.0.infraSpineAccNodePGrp.children.2.infraRsSpineCoppProfile.attributes.tnCoppSpineProfileName == "" + - nm_create_spine_policy_group.current.0.infraSpineAccNodePGrp.children.3.infraRsSpineBfdIpv6InstPol.attributes.tnBfdIpv6InstPolName == "" + - nm_create_spine_policy_group.current.0.infraSpineAccNodePGrp.children.4.infraRsSpineBfdIpv4InstPol.attributes.tnBfdIpv4InstPolName == "" + - nm_create_spine_policy_group.current.0.infraSpineAccNodePGrp.children.5.infraRsIaclSpineProfile.attributes.tnIaclSpineProfileName == "" + - nm_create_spine_policy_group.previous == [] + - nm_create_spine_policy_group_again is not changed + - nm_create_spine_policy_group_again.current.0.infraSpineAccNodePGrp.attributes.annotation == "orchestrator:ansible" + - nm_create_spine_policy_group_again.current.0.infraSpineAccNodePGrp.attributes.dn == "uni/infra/funcprof/spaccnodepgrp-ansible_access_switch_spine_pol_grp" + - nm_create_spine_policy_group_again.current.0.infraSpineAccNodePGrp.attributes.name == "ansible_access_switch_spine_pol_grp" + - nm_create_spine_policy_group_again.current.0.infraSpineAccNodePGrp.children.0.infraRsSpinePGrpToLldpIfPol.attributes.tnLldpIfPolName == "" + - nm_create_spine_policy_group_again.current.0.infraSpineAccNodePGrp.children.1.infraRsSpinePGrpToCdpIfPol.attributes.tnCdpIfPolName == "" + - nm_create_spine_policy_group_again.current.0.infraSpineAccNodePGrp.children.2.infraRsSpineCoppProfile.attributes.tnCoppSpineProfileName == "" + - nm_create_spine_policy_group_again.current.0.infraSpineAccNodePGrp.children.3.infraRsSpineBfdIpv6InstPol.attributes.tnBfdIpv6InstPolName == "" + - nm_create_spine_policy_group_again.current.0.infraSpineAccNodePGrp.children.4.infraRsSpineBfdIpv4InstPol.attributes.tnBfdIpv4InstPolName == "" + - nm_create_spine_policy_group_again.current.0.infraSpineAccNodePGrp.children.5.infraRsIaclSpineProfile.attributes.tnIaclSpineProfileName == "" + - nm_create_spine_policy_group_again.previous.0.infraSpineAccNodePGrp.attributes.annotation == "orchestrator:ansible" + - nm_create_spine_policy_group_again.previous.0.infraSpineAccNodePGrp.attributes.dn == "uni/infra/funcprof/spaccnodepgrp-ansible_access_switch_spine_pol_grp" + - nm_create_spine_policy_group_again.previous.0.infraSpineAccNodePGrp.attributes.name == "ansible_access_switch_spine_pol_grp" + - nm_create_spine_policy_group_again.previous.0.infraSpineAccNodePGrp.children.0.infraRsSpinePGrpToLldpIfPol.attributes.tnLldpIfPolName == "" + - nm_create_spine_policy_group_again.previous.0.infraSpineAccNodePGrp.children.1.infraRsSpinePGrpToCdpIfPol.attributes.tnCdpIfPolName == "" + - nm_create_spine_policy_group_again.previous.0.infraSpineAccNodePGrp.children.2.infraRsSpineCoppProfile.attributes.tnCoppSpineProfileName == "" + - nm_create_spine_policy_group_again.previous.0.infraSpineAccNodePGrp.children.3.infraRsSpineBfdIpv6InstPol.attributes.tnBfdIpv6InstPolName == "" + - nm_create_spine_policy_group_again.previous.0.infraSpineAccNodePGrp.children.4.infraRsSpineBfdIpv4InstPol.attributes.tnBfdIpv4InstPolName == "" + - nm_create_spine_policy_group_again.previous.0.infraSpineAccNodePGrp.children.5.infraRsIaclSpineProfile.attributes.tnIaclSpineProfileName == "" + when: version.current.0.topSystem.attributes.version is version('5.0', '<') + + - name: Change the ansible access switch spine policy group for version >= 5.2 + cisco.aci.aci_access_switch_policy_group: + <<: *aci_create_spine_policy_group + bfd_ipv4_policy: changed_bfd_ipv4_policy + bfd_ipv6_policy: changed_bfd_ipv6_policy + copp_policy: changed_copp_policy + copp_pre_filter_policy: changed_copp_pre_filter_policy + cdp_policy: changed_cdp_policy + lldp_policy: changed_lldp_policy + usb_configuration_policy: changed_usb_configuration_policy + register: nm_change_spine_policy_group + when: version.current.0.topSystem.attributes.version is version('5.2', '>=') + + - name: Verify change of access switch spine policy group for version >= 5.2 + ansible.builtin.assert: + that: + - nm_change_spine_policy_group is changed + - nm_change_spine_policy_group.current.0.infraSpineAccNodePGrp.attributes.annotation == "orchestrator:ansible" + - nm_change_spine_policy_group.current.0.infraSpineAccNodePGrp.attributes.dn == "uni/infra/funcprof/spaccnodepgrp-ansible_access_switch_spine_pol_grp" + - nm_change_spine_policy_group.current.0.infraSpineAccNodePGrp.attributes.name == "ansible_access_switch_spine_pol_grp" + - nm_change_spine_policy_group.current.0.infraSpineAccNodePGrp.children.0.infraRsSpineTopoctrlUsbConfigProfilePol.attributes.tnTopoctrlUsbConfigProfilePolName == "changed_usb_configuration_policy" + - nm_change_spine_policy_group.current.0.infraSpineAccNodePGrp.children.1.infraRsSpinePGrpToLldpIfPol.attributes.tnLldpIfPolName == "changed_lldp_policy" + - nm_change_spine_policy_group.current.0.infraSpineAccNodePGrp.children.2.infraRsSpinePGrpToCdpIfPol.attributes.tnCdpIfPolName == "changed_cdp_policy" + - nm_change_spine_policy_group.current.0.infraSpineAccNodePGrp.children.3.infraRsSpineCoppProfile.attributes.tnCoppSpineProfileName == "changed_copp_policy" + - nm_change_spine_policy_group.current.0.infraSpineAccNodePGrp.children.4.infraRsSpineBfdIpv6InstPol.attributes.tnBfdIpv6InstPolName == "changed_bfd_ipv6_policy" + - nm_change_spine_policy_group.current.0.infraSpineAccNodePGrp.children.5.infraRsSpineBfdIpv4InstPol.attributes.tnBfdIpv4InstPolName == "changed_bfd_ipv4_policy" + - nm_change_spine_policy_group.current.0.infraSpineAccNodePGrp.children.6.infraRsIaclSpineProfile.attributes.tnIaclSpineProfileName == "changed_copp_pre_filter_policy" + - nm_change_spine_policy_group.previous.0.infraSpineAccNodePGrp.attributes.annotation == "orchestrator:ansible" + - nm_change_spine_policy_group.previous.0.infraSpineAccNodePGrp.attributes.dn == "uni/infra/funcprof/spaccnodepgrp-ansible_access_switch_spine_pol_grp" + - nm_change_spine_policy_group.previous.0.infraSpineAccNodePGrp.attributes.name == "ansible_access_switch_spine_pol_grp" + - nm_change_spine_policy_group.previous.0.infraSpineAccNodePGrp.children.0.infraRsSpineTopoctrlUsbConfigProfilePol.attributes.tnTopoctrlUsbConfigProfilePolName == "" + - nm_change_spine_policy_group.previous.0.infraSpineAccNodePGrp.children.1.infraRsSpinePGrpToLldpIfPol.attributes.tnLldpIfPolName == "" + - nm_change_spine_policy_group.previous.0.infraSpineAccNodePGrp.children.2.infraRsSpinePGrpToCdpIfPol.attributes.tnCdpIfPolName == "" + - nm_change_spine_policy_group.previous.0.infraSpineAccNodePGrp.children.3.infraRsSpineCoppProfile.attributes.tnCoppSpineProfileName == "" + - nm_change_spine_policy_group.previous.0.infraSpineAccNodePGrp.children.4.infraRsSpineBfdIpv6InstPol.attributes.tnBfdIpv6InstPolName == "" + - nm_change_spine_policy_group.previous.0.infraSpineAccNodePGrp.children.5.infraRsSpineBfdIpv4InstPol.attributes.tnBfdIpv4InstPolName == "" + - nm_change_spine_policy_group.previous.0.infraSpineAccNodePGrp.children.6.infraRsIaclSpineProfile.attributes.tnIaclSpineProfileName == "" + when: version.current.0.topSystem.attributes.version is version('5.2', '>=') + + - name: Change the ansible access switch spine policy group for version < 5.0 + cisco.aci.aci_access_switch_policy_group: + <<: *aci_create_spine_policy_group + bfd_ipv4_policy: changed_bfd_ipv4_policy + bfd_ipv6_policy: changed_bfd_ipv6_policy + copp_policy: changed_copp_policy + copp_pre_filter_policy: changed_copp_pre_filter_policy + cdp_policy: changed_cdp_policy + lldp_policy: changed_lldp_policy + register: nm_change_spine_policy_group + when: version.current.0.topSystem.attributes.version is version('5.0', '<') + + - name: Verify change of access switch spine policy group for version < "5" + ansible.builtin.assert: + that: + - nm_change_spine_policy_group is changed + - nm_change_spine_policy_group.current.0.infraSpineAccNodePGrp.attributes.annotation == "orchestrator:ansible" + - nm_change_spine_policy_group.current.0.infraSpineAccNodePGrp.attributes.dn == "uni/infra/funcprof/spaccnodepgrp-ansible_access_switch_spine_pol_grp" + - nm_change_spine_policy_group.current.0.infraSpineAccNodePGrp.attributes.name == "ansible_access_switch_spine_pol_grp" + - nm_change_spine_policy_group.current.0.infraSpineAccNodePGrp.children.0.infraRsSpinePGrpToLldpIfPol.attributes.tnLldpIfPolName == "changed_lldp_policy" + - nm_change_spine_policy_group.current.0.infraSpineAccNodePGrp.children.1.infraRsSpinePGrpToCdpIfPol.attributes.tnCdpIfPolName == "changed_cdp_policy" + - nm_change_spine_policy_group.current.0.infraSpineAccNodePGrp.children.2.infraRsSpineCoppProfile.attributes.tnCoppSpineProfileName == "changed_copp_policy" + - nm_change_spine_policy_group.current.0.infraSpineAccNodePGrp.children.3.infraRsSpineBfdIpv6InstPol.attributes.tnBfdIpv6InstPolName == "changed_bfd_ipv6_policy" + - nm_change_spine_policy_group.current.0.infraSpineAccNodePGrp.children.4.infraRsSpineBfdIpv4InstPol.attributes.tnBfdIpv4InstPolName == "changed_bfd_ipv4_policy" + - nm_change_spine_policy_group.current.0.infraSpineAccNodePGrp.children.5.infraRsIaclSpineProfile.attributes.tnIaclSpineProfileName == "changed_copp_pre_filter_policy" + - nm_change_spine_policy_group.previous.0.infraSpineAccNodePGrp.attributes.annotation == "orchestrator:ansible" + - nm_change_spine_policy_group.previous.0.infraSpineAccNodePGrp.attributes.dn == "uni/infra/funcprof/spaccnodepgrp-ansible_access_switch_spine_pol_grp" + - nm_change_spine_policy_group.previous.0.infraSpineAccNodePGrp.attributes.name == "ansible_access_switch_spine_pol_grp" + - nm_change_spine_policy_group.previous.0.infraSpineAccNodePGrp.children.0.infraRsSpinePGrpToLldpIfPol.attributes.tnLldpIfPolName == "" + - nm_change_spine_policy_group.previous.0.infraSpineAccNodePGrp.children.1.infraRsSpinePGrpToCdpIfPol.attributes.tnCdpIfPolName == "" + - nm_change_spine_policy_group.previous.0.infraSpineAccNodePGrp.children.2.infraRsSpineCoppProfile.attributes.tnCoppSpineProfileName == "" + - nm_change_spine_policy_group.previous.0.infraSpineAccNodePGrp.children.3.infraRsSpineBfdIpv6InstPol.attributes.tnBfdIpv6InstPolName == "" + - nm_change_spine_policy_group.previous.0.infraSpineAccNodePGrp.children.4.infraRsSpineBfdIpv4InstPol.attributes.tnBfdIpv4InstPolName == "" + - nm_change_spine_policy_group.previous.0.infraSpineAccNodePGrp.children.5.infraRsIaclSpineProfile.attributes.tnIaclSpineProfileName == "" + when: version.current.0.topSystem.attributes.version is version('5.0', '<') + + - name: Create another ansible access switch spine policy group 2 + cisco.aci.aci_access_switch_policy_group: &aci_create_spine_policy_group_2 + <<: *aci_create_spine_policy_group + name: ansible_access_switch_leaf_pol_grp_2 + + - name: Query the ansible access switch spine policy group 2 + cisco.aci.aci_access_switch_policy_group: + <<: *aci_create_spine_policy_group_2 + state: query + register: query_one + + - name: Query all the ansible access switch spine policy groups + cisco.aci.aci_access_switch_policy_group: + <<: *aci_info + switch_type: spine + state: query + register: query_all + + - name: Verify remove of access switch policy + ansible.builtin.assert: + that: + - query_one is not changed + - query_one.current | length == 1 + - query_all is not changed + - query_all.current | length > 1 + + - name: Remove the ansible access switch spine policy group (check mode) + cisco.aci.aci_access_switch_policy_group: &aci_remove_spine_policy_group + <<: *aci_info + switch_type: spine + name: ansible_access_switch_spine_pol_grp + state: absent + check_mode: true + register: cm_remove_spine_policy_group + + - name: Remove the ansible access switch spine policy group + cisco.aci.aci_access_switch_policy_group: + <<: *aci_remove_spine_policy_group + register: nm_remove_spine_policy_group + + - name: Remove the ansible access switch spine policy group again + cisco.aci.aci_access_switch_policy_group: + <<: *aci_remove_spine_policy_group + register: nm_remove_spine_policy_group_again + + - name: Verify remove of access switch spine policy group + ansible.builtin.assert: + that: + - cm_remove_spine_policy_group is changed + - nm_remove_spine_policy_group.previous != [] + - nm_remove_spine_policy_group.proposed == {} + - nm_remove_spine_policy_group is changed + - nm_remove_spine_policy_group.previous != [] + - nm_remove_spine_policy_group.current == [] + - nm_remove_spine_policy_group_again is not changed + - nm_remove_spine_policy_group_again.previous == [] + - nm_remove_spine_policy_group_again.current == [] + + # WRONG CONFIGURATION FOR SPINE SWITCH TYPE + - name: Create the ansible access switch spine policy group with spanning_tree_policy (error) + cisco.aci.aci_access_switch_policy_group: + <<: *aci_info + switch_type: spine + name: ansible_access_switch_leaf_pol_grp + spanning_tree_policy: invalid_spanning_tree_policy + state: present + ignore_errors: true + register: err_create_spine_policy_group_with_spanning_tree_policy + + - name: Create the ansible access switch spine policy group with bfd_multihop_ipv4_policy (error) + cisco.aci.aci_access_switch_policy_group: + <<: *aci_info + switch_type: spine + name: ansible_access_switch_leaf_pol_grp + bfd_multihop_ipv4_policy: invalid_bfd_multihop_ipv4_policy + state: present + ignore_errors: true + register: err_create_spine_policy_group_with_bfd_multihop_ipv4_policy + + - name: Create the ansible access switch spine policy group with bfd_multihop_ipv6_policy (error) + cisco.aci.aci_access_switch_policy_group: + <<: *aci_info + switch_type: spine + name: ansible_access_switch_leaf_pol_grp + bfd_multihop_ipv6_policy: invalid_bfd_multihop_ipv6_policy + state: present + ignore_errors: true + register: err_create_spine_policy_group_with_bfd_multihop_ipv6_policy + + - name: Create the ansible access switch spine policy group with fibre_channel_node_policy (error) + cisco.aci.aci_access_switch_policy_group: + <<: *aci_info + switch_type: spine + name: ansible_access_switch_leaf_pol_grp + fibre_channel_node_policy: invalid_fibre_channel_node_policy + state: present + ignore_errors: true + register: err_create_spine_policy_group_with_fibre_channel_node_policy + + - name: Create the ansible access switch spine policy group with poe_node_policy (error) + cisco.aci.aci_access_switch_policy_group: + <<: *aci_info + switch_type: spine + name: ansible_access_switch_leaf_pol_grp + poe_node_policy: invalid_poe_node_policy + state: present + ignore_errors: true + register: err_create_spine_policy_group_with_poe_node_policy + + - name: Create the ansible access switch spine policy group with fibre_channel_san_policy (error) + cisco.aci.aci_access_switch_policy_group: + <<: *aci_info + switch_type: spine + name: ansible_access_switch_leaf_pol_grp + fibre_channel_san_policy: invalid_fibre_channel_san_policy + state: present + ignore_errors: true + register: err_create_spine_policy_group_with_fibre_channel_san_policy + + - name: Create the ansible access switch spine policy group with monitoring_policy (error) + cisco.aci.aci_access_switch_policy_group: + <<: *aci_info + switch_type: spine + name: ansible_access_switch_leaf_pol_grp + monitoring_policy: invalid_monitoring_policy + state: present + ignore_errors: true + register: err_create_spine_policy_group_with_monitoring_policy + + - name: Create the ansible access switch spine policy group with netflow_node_policy (error) + cisco.aci.aci_access_switch_policy_group: + <<: *aci_info + switch_type: spine + name: ansible_access_switch_leaf_pol_grp + netflow_node_policy: invalid_netflow_node_policy + state: present + ignore_errors: true + register: err_create_spine_policy_group_with_netflow_node_policy + + - name: Create the ansible access switch spine policy group with forward_scale_profile_policy (error) + cisco.aci.aci_access_switch_policy_group: + <<: *aci_info + switch_type: spine + name: ansible_access_switch_leaf_pol_grp + forward_scale_profile_policy: invalid_forward_scale_profile_policy + state: present + ignore_errors: true + register: err_create_spine_policy_group_with_forward_scale_profile_policy + + - name: Create the ansible access switch spine policy group with fast_link_failover_policy (error) + cisco.aci.aci_access_switch_policy_group: + <<: *aci_info + switch_type: spine + name: ansible_access_switch_leaf_pol_grp + fast_link_failover_policy: invalid_fast_link_failover_policy + state: present + ignore_errors: true + register: err_create_spine_policy_group_with_fast_link_failover_policy + + - name: Create the ansible access switch spine policy group with node_802_1x_authentication_policy (error) + cisco.aci.aci_access_switch_policy_group: + <<: *aci_info + switch_type: spine + name: ansible_access_switch_leaf_pol_grp + node_802_1x_authentication_policy: invalid_node_802_1x_authentication_policy + state: present + ignore_errors: true + register: err_create_spine_policy_group_with_node_802_1x_authentication_policy + + - name: Create the ansible access switch spine policy group with equipment_flash_policy (error) + cisco.aci.aci_access_switch_policy_group: + <<: *aci_info + switch_type: spine + name: ansible_access_switch_leaf_pol_grp + equipment_flash_policy: invalid_equipment_flash_policy + state: present + ignore_errors: true + register: err_create_spine_policy_group_with_equipment_flash_policy + + - name: Create the ansible access switch spine policy group with sync_e_node_policy (error) + cisco.aci.aci_access_switch_policy_group: + <<: *aci_info + switch_type: spine + name: ansible_access_switch_leaf_pol_grp + sync_e_node_policy: invalid_sync_e_node_policy + state: present + ignore_errors: true + register: err_create_spine_policy_group_with_sync_e_node_policy + + - name: Create the ansible access switch spine policy group with ptp_node_policy (error) + cisco.aci.aci_access_switch_policy_group: + <<: *aci_info + switch_type: spine + name: ansible_access_switch_leaf_pol_grp + ptp_node_policy: invalid_ptp_node_policy + state: present + ignore_errors: true + register: err_create_spine_policy_group_with_ptp_node_policy + + - name: Create the ansible access switch spine policy group with all (error) + cisco.aci.aci_access_switch_policy_group: + <<: *aci_info + switch_type: spine + name: ansible_access_switch_leaf_pol_grp + bfd_ipv4_policy: valid_bfd_ipv4_policy + bfd_ipv6_policy: valid_bfd_ipv6_policy + copp_policy: valid_copp_policy + copp_pre_filter_policy: valid_copp_pre_filter_policy + cdp_policy: valid_cdp_policy + lldp_policy: valid_lldp_policy + usb_configuration_policy: valid_usb_configuration_policy + spanning_tree_policy: invalid_spanning_tree_policy + bfd_multihop_ipv4_policy: invalid_bfd_multihop_ipv4_policy + bfd_multihop_ipv6_policy: invalid_bfd_multihop_ipv6_policy + fibre_channel_node_policy: invalid_fibre_channel_node_policy + poe_node_policy: invalid_poe_node_policy + fibre_channel_san_policy: invalid_fibre_channel_san_policy + monitoring_policy: invalid_monitoring_policy + netflow_node_policy: invalid_netflow_node_policy + forward_scale_profile_policy: invalid_forward_scale_profile_policy + fast_link_failover_policy: invalid_fast_link_failover_policy + node_802_1x_authentication_policy: invalid_node_802_1x_authentication_policy + equipment_flash_policy: invalid_equipment_flash_policy + sync_e_node_policy: invalid_sync_e_node_policy + ptp_node_policy: invalid_ptp_node_policy + state: present + ignore_errors: true + register: err_create_spine_policy_group_with_all + + - name: Verify errors of access switch spine policy group + ansible.builtin.assert: + that: + - err_create_spine_policy_group_with_spanning_tree_policy is failed + - err_create_spine_policy_group_with_spanning_tree_policy.msg == "Unsupported policy provided for spine switch type." + - err_create_spine_policy_group_with_bfd_multihop_ipv6_policy is failed + - err_create_spine_policy_group_with_bfd_multihop_ipv6_policy.msg == "Unsupported policy provided for spine switch type." + - err_create_spine_policy_group_with_fibre_channel_node_policy is failed + - err_create_spine_policy_group_with_fibre_channel_node_policy.msg == "Unsupported policy provided for spine switch type." + - err_create_spine_policy_group_with_poe_node_policy is failed + - err_create_spine_policy_group_with_poe_node_policy.msg == "Unsupported policy provided for spine switch type." + - err_create_spine_policy_group_with_fibre_channel_san_policy is failed + - err_create_spine_policy_group_with_fibre_channel_san_policy.msg == "Unsupported policy provided for spine switch type." + - err_create_spine_policy_group_with_monitoring_policy is failed + - err_create_spine_policy_group_with_monitoring_policy.msg == "Unsupported policy provided for spine switch type." + - err_create_spine_policy_group_with_netflow_node_policy is failed + - err_create_spine_policy_group_with_netflow_node_policy.msg == "Unsupported policy provided for spine switch type." + - err_create_spine_policy_group_with_forward_scale_profile_policy is failed + - err_create_spine_policy_group_with_forward_scale_profile_policy.msg == "Unsupported policy provided for spine switch type." + - err_create_spine_policy_group_with_fast_link_failover_policy is failed + - err_create_spine_policy_group_with_fast_link_failover_policy.msg == "Unsupported policy provided for spine switch type." + - err_create_spine_policy_group_with_node_802_1x_authentication_policy is failed + - err_create_spine_policy_group_with_node_802_1x_authentication_policy.msg == "Unsupported policy provided for spine switch type." + - err_create_spine_policy_group_with_equipment_flash_policy is failed + - err_create_spine_policy_group_with_equipment_flash_policy.msg == "Unsupported policy provided for spine switch type." + - err_create_spine_policy_group_with_sync_e_node_policy is failed + - err_create_spine_policy_group_with_sync_e_node_policy.msg == "Unsupported policy provided for spine switch type." + - err_create_spine_policy_group_with_ptp_node_policy is failed + - err_create_spine_policy_group_with_ptp_node_policy.msg == "Unsupported policy provided for spine switch type." + - err_create_spine_policy_group_with_all is failed + - err_create_spine_policy_group_with_all.msg == "Unsupported policy provided for spine switch type." diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_action_rule_additional_communities/aliases b/ansible_collections/cisco/aci/tests/integration/targets/aci_action_rule_additional_communities/aliases new file mode 100644 index 000000000..209b793f9 --- /dev/null +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_action_rule_additional_communities/aliases @@ -0,0 +1,2 @@ +# No ACI simulator yet, so not enabled +# unsupported diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_action_rule_additional_communities/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_action_rule_additional_communities/tasks/main.yml new file mode 100644 index 000000000..f08bcf5c0 --- /dev/null +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_action_rule_additional_communities/tasks/main.yml @@ -0,0 +1,147 @@ +# Test code for the ACI modules +# Copyright: (c) 2023, Gaspard Micol (@gmicol) <gmicol@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 APIC host, ACI username and ACI password + ansible.builtin.fail: + msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' + when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined + +- name: Set vars + ansible.builtin.set_fact: + aci_info: &aci_info + host: "{{ aci_hostname }}" + username: "{{ aci_username }}" + password: "{{ aci_password }}" + validate_certs: '{{ aci_validate_certs | default(false) }}' + use_ssl: '{{ aci_use_ssl | default(true) }}' + use_proxy: '{{ aci_use_proxy | default(true) }}' + output_level: debug + +# CLEAN ENVIRONMENT +- name: Remove the ansible_tenant + cisco.aci.aci_tenant: &aci_tenant_absent + <<: *aci_info + tenant: ansible_tenant + state: absent + +- name: Verify Cloud and Non-Cloud Sites in use. + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + +- name: Execute tasks only for non-cloud sites + when: query_cloud.current == [] # This condition will execute only non-cloud sites + block: # block specifies execution of tasks within, based on conditions + - name: Add a new tenant + cisco.aci.aci_tenant: &aci_tenant_present + <<: *aci_info + tenant: ansible_tenant + description: Ansible tenant + state: present + + - name: Add a new action rule profile + cisco.aci.aci_tenant_action_rule_profile: &aci_action_rule_present + <<: *aci_info + tenant: ansible_tenant + action_rule: ansible_action_rule + description: Ansible action rule profile for ansible_tenant tenant + state: present + + - name: Add an additional communities action rule (check_mode) + cisco.aci.aci_action_rule_additional_communities: &aci_action_rule_additional_communities_present + <<: *aci_info + tenant: ansible_tenant + action_rule: ansible_action_rule + community: regular:as2-nn2:4:15 + criteria: append + state: present + check_mode: true + register: cm_add_action_rule_add_comm + + - name: Add an additional communities action rule again (normal_mode) + cisco.aci.aci_action_rule_additional_communities: + <<: *aci_action_rule_additional_communities_present + register: nm_add_action_rule_add_comm + + - name: Add an additional communities action rule again - testing idempotency + cisco.aci.aci_action_rule_additional_communities: + <<: *aci_action_rule_additional_communities_present + register: nm_add_action_rule_add_comm_idempotency + + - name: Add an additional communities action rule + cisco.aci.aci_action_rule_additional_communities: + <<: *aci_info + tenant: ansible_tenant + action_rule: ansible_action_rule + community: extended:as4-nn2:5:16 + state: present + register: nm_add_action_rule_add_comm_2 + + - name: Asserts for additional communities action rules creation tasks + ansible.builtin.assert: + that: + - cm_add_action_rule_add_comm is changed + - cm_add_action_rule_add_comm.previous == [] + - cm_add_action_rule_add_comm.current == [] + - nm_add_action_rule_add_comm is changed + - nm_add_action_rule_add_comm.current.0.rtctrlSetAddComm.attributes.community == "regular:as2-nn2:4:15" + - nm_add_action_rule_add_comm.current.0.rtctrlSetAddComm.attributes.setCriteria == "append" + - nm_add_action_rule_add_comm_idempotency is not changed + - nm_add_action_rule_add_comm_2 is changed + - nm_add_action_rule_add_comm_2.previous == [] + - nm_add_action_rule_add_comm_2.current.0.rtctrlSetAddComm.attributes.community == "extended:as4-nn2:5:16" + - nm_add_action_rule_add_comm_2.current.0.rtctrlSetAddComm.attributes.setCriteria == "append" + + - name: Query all additional communities action rules + cisco.aci.aci_action_rule_additional_communities: + <<: *aci_info + state: query + register: query_all_action_rule_add_comm + + - name: Query ansible_action_rule_add_comm additional communities action rule + cisco.aci.aci_action_rule_additional_communities: + <<: *aci_action_rule_additional_communities_present + state: query + register: query_action_rule_add_comm + + - name: Asserts query tasks + ansible.builtin.assert: + that: + - query_all_action_rule_add_comm is not changed + - query_all_action_rule_add_comm.current|length >= 2 + - query_action_rule_add_comm is not changed + - query_action_rule_add_comm.current.0.rtctrlSetAddComm.attributes.community == "regular:as2-nn2:4:15" + - query_action_rule_add_comm.current.0.rtctrlSetAddComm.attributes.setCriteria == "append" + + - name: Remove additional communities action rule (check_mode) + cisco.aci.aci_action_rule_additional_communities: &aci_action_rule_additional_communities_absent + <<: *aci_action_rule_additional_communities_present + state: absent + check_mode: true + register: cm_remove_action_rule_add_comm + + - name: Remove additional communities action rule (normal_mode) + cisco.aci.aci_action_rule_additional_communities: + <<: *aci_action_rule_additional_communities_absent + register: nm_remove_remove_action_rule_add_comm + + - name: Remove additional communities action rule again - testing previous Removal + cisco.aci.aci_action_rule_additional_communities: + <<: *aci_action_rule_additional_communities_absent + register: nm_remove_action_rule_add_comm_idempotency + + - name: Asserts deletion tasks + ansible.builtin.assert: + that: + - cm_remove_action_rule_add_comm is changed + - cm_remove_action_rule_add_comm.proposed == {} + - nm_remove_remove_action_rule_add_comm is changed + - nm_remove_remove_action_rule_add_comm.previous != [] + - nm_remove_remove_action_rule_add_comm.method == "DELETE" + - nm_remove_action_rule_add_comm_idempotency is not changed + - nm_remove_action_rule_add_comm_idempotency.previous == [] + + - name: Remove the ansible_tenant - cleanup before ending tests + cisco.aci.aci_tenant: + <<: *aci_tenant_present + state: absent diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_action_rule_set_as_path/aliases b/ansible_collections/cisco/aci/tests/integration/targets/aci_action_rule_set_as_path/aliases new file mode 100644 index 000000000..209b793f9 --- /dev/null +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_action_rule_set_as_path/aliases @@ -0,0 +1,2 @@ +# No ACI simulator yet, so not enabled +# unsupported diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_action_rule_set_as_path/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_action_rule_set_as_path/tasks/main.yml new file mode 100644 index 000000000..2ce0aadf0 --- /dev/null +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_action_rule_set_as_path/tasks/main.yml @@ -0,0 +1,148 @@ +# Test code for the ACI modules +# Copyright: (c) 2023, Gaspard Micol (@gmicol) <gmicol@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 APIC host, ACI username and ACI password + ansible.builtin.fail: + msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' + when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined + +- name: Set vars + ansible.builtin.set_fact: + aci_info: &aci_info + host: "{{ aci_hostname }}" + username: "{{ aci_username }}" + password: "{{ aci_password }}" + validate_certs: '{{ aci_validate_certs | default(false) }}' + use_ssl: '{{ aci_use_ssl | default(true) }}' + use_proxy: '{{ aci_use_proxy | default(true) }}' + output_level: debug + +# CLEAN ENVIRONMENT +- name: Remove the ansible_tenant + cisco.aci.aci_tenant: &aci_tenant_absent + <<: *aci_info + tenant: ansible_tenant + state: absent + +- name: Verify Cloud and Non-Cloud Sites in use. + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + +- name: Execute tasks only for non-cloud sites + when: query_cloud.current == [] # This condition will execute only non-cloud sites + block: # block specifies execution of tasks within, based on conditions + - name: Add a new tenant + cisco.aci.aci_tenant: &aci_tenant_present + <<: *aci_info + tenant: ansible_tenant + description: Ansible tenant + state: present + + - name: Add a new action rule profile + cisco.aci.aci_tenant_action_rule_profile: &aci_action_rule_present + <<: *aci_info + tenant: ansible_tenant + action_rule: ansible_action_rule + description: Ansible action rule profile for ansible_tenant tenant + state: present + + - name: Add a set AS path action rule (check_mode) + cisco.aci.aci_action_rule_set_as_path: &aci_action_rule_set_as_path_present + <<: *aci_info + tenant: ansible_tenant + action_rule: ansible_action_rule + last_as_number: 0 + criteria: prepend + state: present + check_mode: true + register: cm_add_action_rule_set_as_path + + - name: Add a set AS path action rule again (normal_mode) + cisco.aci.aci_action_rule_set_as_path: + <<: *aci_action_rule_set_as_path_present + register: nm_add_action_rule_set_as_path + + - name: Add a set AS path action rule again - testing idempotency + cisco.aci.aci_action_rule_set_as_path: + <<: *aci_action_rule_set_as_path_present + register: nm_add_action_rule_set_as_path_idempotency + + - name: Add a set AS path action rule + cisco.aci.aci_action_rule_set_as_path: + <<: *aci_info + tenant: ansible_tenant + action_rule: ansible_action_rule + last_as_number: 2 + criteria: prepend-last-as + state: present + register: nm_add_action_rule_set_as_path_2 + + - name: Asserts for set AS path action rule creation tasks + ansible.builtin.assert: + that: + - cm_add_action_rule_set_as_path is changed + - cm_add_action_rule_set_as_path.previous == [] + - cm_add_action_rule_set_as_path.current == [] + - nm_add_action_rule_set_as_path is changed + - nm_add_action_rule_set_as_path.current.0.rtctrlSetASPath.attributes.lastnum == "0" + - nm_add_action_rule_set_as_path.current.0.rtctrlSetASPath.attributes.criteria == "prepend" + - nm_add_action_rule_set_as_path_idempotency is not changed + - nm_add_action_rule_set_as_path_2 is changed + - nm_add_action_rule_set_as_path_2.previous == [] + - nm_add_action_rule_set_as_path_2.current.0.rtctrlSetASPath.attributes.lastnum == "2" + - nm_add_action_rule_set_as_path_2.current.0.rtctrlSetASPath.attributes.criteria == "prepend-last-as" + + - name: Query all set AS path action rules + cisco.aci.aci_action_rule_set_as_path: + <<: *aci_info + state: query + register: query_all_action_rule_set_as_path + + - name: Query ansible_action_rule_set_as_path set AS path action rule + cisco.aci.aci_action_rule_set_as_path: + <<: *aci_action_rule_set_as_path_present + state: query + register: query_action_rule_set_as_path + + - name: Asserts query tasks + ansible.builtin.assert: + that: + - query_all_action_rule_set_as_path is not changed + - query_all_action_rule_set_as_path.current|length >= 2 + - query_action_rule_set_as_path is not changed + - query_action_rule_set_as_path.current.0.rtctrlSetASPath.attributes.lastnum == "0" + - query_action_rule_set_as_path.current.0.rtctrlSetASPath.attributes.criteria == "prepend" + + - name: Remove set AS path action rule (check_mode) + cisco.aci.aci_action_rule_set_as_path: &aci_action_rule_set_as_path_absent + <<: *aci_action_rule_set_as_path_present + state: absent + check_mode: true + register: cm_remove_action_rule_set_as_path + + - name: Remove set AS path action rule (normal_mode) + cisco.aci.aci_action_rule_set_as_path: + <<: *aci_action_rule_set_as_path_absent + register: nm_remove_remove_action_rule_set_as_path + + - name: Remove set AS path action rule again - testing previous Removal + cisco.aci.aci_action_rule_set_as_path: + <<: *aci_action_rule_set_as_path_absent + register: nm_remove_action_rule_set_as_path_idempotency + + - name: Asserts deletion tasks + ansible.builtin.assert: + that: + - cm_remove_action_rule_set_as_path is changed + - cm_remove_action_rule_set_as_path.proposed == {} + - nm_remove_remove_action_rule_set_as_path is changed + - nm_remove_remove_action_rule_set_as_path.previous != [] + - nm_remove_remove_action_rule_set_as_path.method == "DELETE" + - nm_remove_action_rule_set_as_path_idempotency is not changed + - nm_remove_action_rule_set_as_path_idempotency.previous == [] + + - name: Remove the ansible_tenant - cleanup before ending tests + cisco.aci.aci_tenant: + <<: *aci_tenant_present + state: absent diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_action_rule_set_as_path_asn/aliases b/ansible_collections/cisco/aci/tests/integration/targets/aci_action_rule_set_as_path_asn/aliases new file mode 100644 index 000000000..209b793f9 --- /dev/null +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_action_rule_set_as_path_asn/aliases @@ -0,0 +1,2 @@ +# No ACI simulator yet, so not enabled +# unsupported diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_action_rule_set_as_path_asn/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_action_rule_set_as_path_asn/tasks/main.yml new file mode 100644 index 000000000..f17ed2f23 --- /dev/null +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_action_rule_set_as_path_asn/tasks/main.yml @@ -0,0 +1,156 @@ +# Test code for the ACI modules +# Copyright: (c) 2023, Gaspard Micol (@gmicol) <gmicol@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 APIC host, ACI username and ACI password + ansible.builtin.fail: + msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' + when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined + +- name: Set vars + ansible.builtin.set_fact: + aci_info: &aci_info + host: "{{ aci_hostname }}" + username: "{{ aci_username }}" + password: "{{ aci_password }}" + validate_certs: '{{ aci_validate_certs | default(false) }}' + use_ssl: '{{ aci_use_ssl | default(true) }}' + use_proxy: '{{ aci_use_proxy | default(true) }}' + output_level: debug + +# CLEAN ENVIRONMENT +- name: Remove the ansible_tenant + cisco.aci.aci_tenant: &aci_tenant_absent + <<: *aci_info + tenant: ansible_tenant + state: absent + +- name: Verify Cloud and Non-Cloud Sites in use. + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + +- name: Execute tasks only for non-cloud sites + when: query_cloud.current == [] # This condition will execute only non-cloud sites + block: # block specifies execution of tasks within, based on conditions + - name: Add a new tenant + cisco.aci.aci_tenant: &aci_tenant_present + <<: *aci_info + tenant: ansible_tenant + description: Ansible tenant + state: present + + - name: Add a new action rule profile + cisco.aci.aci_tenant_action_rule_profile: &aci_action_rule_present + <<: *aci_info + tenant: ansible_tenant + action_rule: ansible_action_rule + description: Ansible action rule profile for ansible_tenant tenant + state: present + + - name: Add a set AS path action rule + cisco.aci.aci_action_rule_set_as_path: &aci_action_rule_set_as_path_present + <<: *aci_info + tenant: ansible_tenant + action_rule: ansible_action_rule + criteria: prepend + state: present + + - name: Add a set AS path ASN action rule (check_mode) + cisco.aci.aci_action_rule_set_as_path_asn: &aci_action_rule_set_as_path_asn_present + <<: *aci_info + tenant: ansible_tenant + action_rule: ansible_action_rule + asn: 1 + order: 1 + state: present + check_mode: true + register: cm_add_action_rule_set_as_path_asn + + - name: Add a set AS path ASN action rule again (normal_mode) + cisco.aci.aci_action_rule_set_as_path_asn: + <<: *aci_action_rule_set_as_path_asn_present + register: nm_add_action_rule_set_as_path_asn + + - name: Add a set AS path ASN action rule again - testing idempotency + cisco.aci.aci_action_rule_set_as_path_asn: + <<: *aci_action_rule_set_as_path_asn_present + register: nm_add_action_rule_set_as_path_asn_idempotency + + - name: Add a set AS path ASN action rule + cisco.aci.aci_action_rule_set_as_path_asn: + <<: *aci_info + tenant: ansible_tenant + action_rule: ansible_action_rule + asn: 2 + order: 2 + state: present + register: nm_add_action_rule_set_as_path_asn_2 + + - name: Asserts for Set AS Path ASN action rule creation tasks + ansible.builtin.assert: + that: + - cm_add_action_rule_set_as_path_asn is changed + - cm_add_action_rule_set_as_path_asn.previous == [] + - cm_add_action_rule_set_as_path_asn.current == [] + - nm_add_action_rule_set_as_path_asn is changed + - nm_add_action_rule_set_as_path_asn.current.0.rtctrlSetASPathASN.attributes.asn == "1" + - nm_add_action_rule_set_as_path_asn.current.0.rtctrlSetASPathASN.attributes.order == "1" + - nm_add_action_rule_set_as_path_asn_idempotency is not changed + - nm_add_action_rule_set_as_path_asn_2 is changed + - nm_add_action_rule_set_as_path_asn_2.previous == [] + - nm_add_action_rule_set_as_path_asn_2.current.0.rtctrlSetASPathASN.attributes.asn == "2" + - nm_add_action_rule_set_as_path_asn_2.current.0.rtctrlSetASPathASN.attributes.order == "2" + + - name: Query all set AS path ASN action rules + cisco.aci.aci_action_rule_set_as_path_asn: + <<: *aci_info + state: query + register: query_all_action_rule_set_as_path_asn + + - name: Query ansible_action_rule_set_as_path_asn set AS path ASN action rule + cisco.aci.aci_action_rule_set_as_path_asn: + <<: *aci_action_rule_set_as_path_asn_present + state: query + register: query_action_rule_set_as_path_asn + + - name: Asserts query tasks + ansible.builtin.assert: + that: + - query_all_action_rule_set_as_path_asn is not changed + - query_all_action_rule_set_as_path_asn.current|length >= 2 + - query_action_rule_set_as_path_asn is not changed + - query_action_rule_set_as_path_asn.current.0.rtctrlSetASPathASN.attributes.asn == "1" + - query_action_rule_set_as_path_asn.current.0.rtctrlSetASPathASN.attributes.order == "1" + + - name: Remove set AS path ASN action rule (check_mode) + cisco.aci.aci_action_rule_set_as_path_asn: &aci_action_rule_set_as_path_asn_absent + <<: *aci_action_rule_set_as_path_asn_present + state: absent + check_mode: true + register: cm_remove_action_rule_set_as_path_asn + + - name: Remove set AS path ASN action rule (normal_mode) + cisco.aci.aci_action_rule_set_as_path_asn: + <<: *aci_action_rule_set_as_path_asn_absent + register: nm_remove_remove_action_rule_set_as_path_asn + + - name: Remove set AS path ASN action rule again - testing previous Removal + cisco.aci.aci_action_rule_set_as_path_asn: + <<: *aci_action_rule_set_as_path_asn_absent + register: nm_remove_action_rule_set_as_path_asn_idempotency + + - name: Asserts deletion tasks + ansible.builtin.assert: + that: + - cm_remove_action_rule_set_as_path_asn is changed + - cm_remove_action_rule_set_as_path_asn.proposed == {} + - nm_remove_remove_action_rule_set_as_path_asn is changed + - nm_remove_remove_action_rule_set_as_path_asn.previous != [] + - nm_remove_remove_action_rule_set_as_path_asn.method == "DELETE" + - nm_remove_action_rule_set_as_path_asn_idempotency is not changed + - nm_remove_action_rule_set_as_path_asn_idempotency.previous == [] + + - name: Remove the ansible_tenant - cleanup before ending tests + cisco.aci.aci_tenant: + <<: *aci_tenant_present + state: absent diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_aep/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_aep/tasks/main.yml index 1a389a9fc..81ff17663 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_aep/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_aep/tasks/main.yml @@ -1,15 +1,16 @@ # Test code for the ACI modules # Copyright: (c) 2018, Dag Wieers (@dagwieers) <dag@wieers.com> +# Copyright: (c) 2024, Samita Bhattacharjee (@samiib) <samitab@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 APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined - name: Verify Cloud and Non-Cloud Sites in use. - include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml - name: Execute tasks only for non-cloud sites when: query_cloud.current == [] # This condition will execute only non-cloud sites @@ -66,7 +67,7 @@ register: nm_add_aep3 - name: Verify add_aep - assert: + ansible.builtin.assert: that: - cm_add_aep is changed - nm_add_aep is changed @@ -106,7 +107,7 @@ register: nm_add_aep_again - name: Verify add_aep_again - assert: + ansible.builtin.assert: that: - cm_add_aep_again is not changed - nm_add_aep_again is not changed @@ -132,7 +133,7 @@ register: nm_add_aep_descr - name: Verify add_aep_descr - assert: + ansible.builtin.assert: that: - cm_add_aep_descr is changed - nm_add_aep_descr is changed @@ -159,7 +160,7 @@ register: nm_add_aep_descr_again - name: Verify add_aep_descr_again - assert: + ansible.builtin.assert: that: - cm_add_aep_descr_again is not changed - nm_add_aep_descr_again is not changed @@ -182,7 +183,7 @@ register: nm_add_aep_again_no_descr - name: Verify add_aep_again_no_descr - assert: + ansible.builtin.assert: that: - cm_add_aep_again_no_descr is not changed - nm_add_aep_again_no_descr is not changed @@ -192,6 +193,75 @@ - cm_add_aep_again_no_descr.previous[0].infraAttEntityP.attributes.dn == nm_add_aep_again_no_descr.previous[0].infraAttEntityP.attributes.dn == cm_add_aep_again_no_descr.current[0].infraAttEntityP.attributes.dn == nm_add_aep_again_no_descr.current[0].infraAttEntityP.attributes.dn == 'uni/infra/attentp-ansible_test' - cm_add_aep_again_no_descr.previous[0].infraAttEntityP.attributes.name == nm_add_aep_again_no_descr.previous[0].infraAttEntityP.attributes.name == cm_add_aep_again_no_descr.current[0].infraAttEntityP.attributes.name == nm_add_aep_again_no_descr.current[0].infraAttEntityP.attributes.name == 'ansible_test' + # TEST NO VERIFICATION + - name: Create aep with no verification (check mode) + cisco.aci.aci_aep: &aci_aep_no_verify + <<: *aep_present + aep: anstest-no-verify + description: Ansible Test + no_verification: true + check_mode: true + register: aep_present_no_verify_cm + + - name: Create aep with no verification + cisco.aci.aci_aep: + <<: *aci_aep_no_verify + register: aep_present_no_verify + + - name: Create aep with no verification again + cisco.aci.aci_aep: + <<: *aci_aep_no_verify + register: aep_present_no_verify_again + + - name: Update aep with no verification + cisco.aci.aci_aep: + <<: *aci_aep_no_verify + description: Ansible Test No Verify + register: update_aep_present_no_verify + + - name: Delete aep with no verification + cisco.aci.aci_aep: + <<: *aci_aep_no_verify + state: absent + register: delete_aep_present_no_verify + + - name: Delete aep with no verification again + cisco.aci.aci_aep: + <<: *aci_aep_no_verify + state: absent + register: delete_aep_present_no_verify_again + + - name: No verification asserts + ansible.builtin.assert: + that: + - aep_present_no_verify_cm is changed + - aep_present_no_verify_cm.current_verified == false + - aep_present_no_verify_cm.current.0 == aep_present_no_verify_cm.proposed + - aep_present_no_verify is changed + - aep_present_no_verify.current_verified == false + - aep_present_no_verify.current.0 == aep_present_no_verify.proposed + - aep_present_no_verify.previous == [] + - aep_present_no_verify_again is not changed + - aep_present_no_verify_again.current_verified == true + - aep_present_no_verify_again.current.0.infraAttEntityP.attributes.name == "anstest-no-verify" + - aep_present_no_verify_again.current.0.infraAttEntityP.attributes.descr == "Ansible Test" + - aep_present_no_verify_again.previous.0.infraAttEntityP.attributes.name == "anstest-no-verify" + - aep_present_no_verify_again.previous.0.infraAttEntityP.attributes.descr == "Ansible Test" + - update_aep_present_no_verify is changed + - update_aep_present_no_verify.current_verified == false + - update_aep_present_no_verify.current.0 == update_aep_present_no_verify.proposed + - update_aep_present_no_verify.previous.0.infraAttEntityP.attributes.name == "anstest-no-verify" + - update_aep_present_no_verify.previous.0.infraAttEntityP.attributes.descr == "Ansible Test" + - delete_aep_present_no_verify is changed + - delete_aep_present_no_verify.current_verified == false + - delete_aep_present_no_verify.current.0 == delete_aep_present_no_verify.proposed + - delete_aep_present_no_verify.previous.0.infraAttEntityP.attributes.name == "anstest-no-verify" + - delete_aep_present_no_verify.previous.0.infraAttEntityP.attributes.descr == "Ansible Test No Verify" + - delete_aep_present_no_verify_again is not changed + - delete_aep_present_no_verify_again.current_verified == true + - delete_aep_present_no_verify_again.current == [] + - delete_aep_present_no_verify_again.previous == [] + - delete_aep_present_no_verify_again.proposed == {} # QUERY ALL AEPS - name: Query all AEPs (check_mode) @@ -212,7 +282,7 @@ register: nm_query_all_aeps - name: Verify query_all_aeps - assert: + ansible.builtin.assert: that: - cm_query_all_aeps is not changed - nm_query_all_aeps is not changed @@ -235,7 +305,7 @@ register: nm_query_aep - name: Verify query_aep - assert: + ansible.builtin.assert: that: - cm_query_aep is not changed - nm_query_aep is not changed @@ -260,7 +330,7 @@ register: nm_remove_aep - name: Verify remove_aep - assert: + ansible.builtin.assert: that: - cm_remove_aep is changed - nm_remove_aep is changed @@ -285,7 +355,7 @@ register: nm_remove_aep_again - name: Verify remove_aep_again - assert: + ansible.builtin.assert: that: - cm_remove_aep_again is not changed - nm_remove_aep_again is not changed @@ -309,7 +379,7 @@ register: nm_query_non_aep - name: Verify query_non_aep - assert: + ansible.builtin.assert: that: - cm_query_non_aep is not changed - nm_query_non_aep is not changed @@ -332,7 +402,7 @@ register: error_on_missing_required_param - name: Verify error_on_missing_required_param - assert: + ansible.builtin.assert: that: - error_on_missing_required_param is failed - 'error_on_missing_required_param.msg == "state is present but all of the following are missing: aep"' diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_aep_to_domain/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_aep_to_domain/tasks/main.yml index 2a4f6f23e..2cd820811 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_aep_to_domain/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_aep_to_domain/tasks/main.yml @@ -4,7 +4,7 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined @@ -21,7 +21,7 @@ - name: Verify Cloud and Non-Cloud Sites in use. - include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml - name: Execute tasks only for non-cloud sites when: query_cloud.current == [] # This condition will execute only non-cloud sites @@ -78,7 +78,7 @@ register: nm_add_binding - name: Verify add_binding - assert: + ansible.builtin.assert: that: - cm_add_binding is changed - nm_add_binding is changed @@ -99,7 +99,7 @@ register: nm_add_binding_again - name: Verify add_binding_again - assert: + ansible.builtin.assert: that: - cm_add_binding_again is not changed - nm_add_binding_again is not changed @@ -148,7 +148,7 @@ register: nm_vmm_type - name: Verify bindings with domain types - assert: + ansible.builtin.assert: that: - err_not_vmm_with_vm_provider is not changed - err_not_vmm_with_vm_provider.msg == "Domain type 'phys' cannot have a 'vm_provider'" @@ -174,7 +174,7 @@ register: nm_query_all_bindings - name: Verify query_all_bindings - assert: + ansible.builtin.assert: that: - cm_query_all_bindings is not changed - nm_query_all_bindings is not changed @@ -201,7 +201,7 @@ register: nm_query_binding - name: Verify query_binding - assert: + ansible.builtin.assert: that: - cm_query_binding is not changed - nm_query_binding is not changed @@ -222,7 +222,7 @@ register: nm_remove_binding - name: Verify remove_binding - assert: + ansible.builtin.assert: that: - cm_remove_binding is changed - nm_remove_binding is changed @@ -240,7 +240,7 @@ register: nm_remove_binding_again - name: Verify remove_binding_again - assert: + ansible.builtin.assert: that: - cm_remove_binding_again is not changed - nm_remove_binding_again is not changed @@ -265,7 +265,7 @@ register: nm_query_non_binding - name: Verify query_non_binding - assert: + ansible.builtin.assert: that: - cm_query_non_binding is not changed - nm_query_non_binding is not changed diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_aep_to_epg/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_aep_to_epg/tasks/main.yml index 86ee212bd..6d3430519 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_aep_to_epg/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_aep_to_epg/tasks/main.yml @@ -4,7 +4,7 @@ # SET VARS - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: '{{ aci_hostname }}' username: '{{ aci_username }}' @@ -15,7 +15,7 @@ output_level: '{{ aci_output_level | default("info") }}' - name: Verify Cloud and Non-Cloud Sites in use. - include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml - name: Execute tasks only for non-cloud sites when: query_cloud.current == [] # This condition will execute only non-cloud sites @@ -84,7 +84,7 @@ register: nm_add_assoc - name: Verify add_assoc - assert: + ansible.builtin.assert: that: - cm_add_assoc is changed - nm_add_assoc is changed @@ -106,7 +106,7 @@ register: nm_add_assoc_again - name: Verify add_assoc_again - assert: + ansible.builtin.assert: that: - cm_add_assoc_again is not changed - nm_add_assoc_again is not changed @@ -126,7 +126,7 @@ register: nm_update_assoc - name: Verify update_assoc - assert: + ansible.builtin.assert: that: - cm_update_assoc is changed - nm_update_assoc is changed @@ -149,7 +149,7 @@ register: query_all_assocs - name: Verify query_all_assocs - assert: + ansible.builtin.assert: that: - query_all_assocs is not changed - query_all_assocs.current|length >= 1 @@ -162,7 +162,7 @@ register: query_spec_assoc - name: Verify query_spec_assoc - assert: + ansible.builtin.assert: that: - query_spec_assoc is not changed - query_spec_assoc.current|length == 1 @@ -181,7 +181,7 @@ register: nm_remove_spec_assoc - name: Verify remove_spec_assoc - assert: + ansible.builtin.assert: that: - cm_remove_spec_assoc is changed - nm_remove_spec_assoc is changed @@ -193,7 +193,7 @@ register: nm_remove_spec_assoc_again - name: Verify remove_spec_assoc_again - assert: + ansible.builtin.assert: that: - nm_remove_spec_assoc_again is not changed @@ -206,7 +206,7 @@ register: query_existing_assoc - name: Verify query_existing_assoc - assert: + ansible.builtin.assert: that: - query_existing_assoc is not changed - query_existing_assoc.current|length == 1 @@ -219,7 +219,7 @@ register: nm_query_non_exist - name: Verify nm_query_non_exist - assert: + ansible.builtin.assert: that: - nm_query_non_exist is not changed - nm_query_non_exist.current == [] diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_ap/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_ap/tasks/main.yml index c527a9059..94db7989e 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_ap/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_ap/tasks/main.yml @@ -1,16 +1,17 @@ # Test code for the ACI modules # Copyright: (c) 2017, Jacob McGill (@jmcgill298) # Copyright: (c) 2020, Shreyas Srish (@shrsr) +# Copyright: (c) 2024, Samita Bhattacharjee (@samiib) <samitab@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 APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined - name: Verify Cloud and Non-Cloud Sites in use. - include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml - name: ensure tenant does not exists cisco.aci.aci_tenant: &aci_tenant_absent @@ -88,7 +89,7 @@ register: ap_present_missing_param - name: present asserts - assert: + ansible.builtin.assert: that: - ap_present_check_mode is changed - ap_present is changed @@ -106,6 +107,75 @@ - ap_present_missing_param is failed - 'ap_present_missing_param.msg == "state is present but all of the following are missing: ap"' + # TEST NO VERIFICATION + - name: create ap with no verification (check mode) + cisco.aci.aci_ap: &aci_ap_no_verify + <<: *aci_ap_present + ap: anstest-no-verify + no_verification: true + check_mode: true + register: ap_present_no_verify_cm + + - name: create ap with no verification + cisco.aci.aci_ap: + <<: *aci_ap_no_verify + register: ap_present_no_verify + + - name: create ap with no verification again + cisco.aci.aci_ap: + <<: *aci_ap_no_verify + register: ap_present_no_verify_again + + - name: update ap with no verification + cisco.aci.aci_ap: + <<: *aci_ap_no_verify + description: Ansible Test No Verify + register: update_ap_present_no_verify + + - name: delete ap with no verification + cisco.aci.aci_ap: + <<: *aci_ap_no_verify + state: absent + register: delete_ap_present_no_verify + + - name: delete ap with no verification again + cisco.aci.aci_ap: + <<: *aci_ap_no_verify + state: absent + register: delete_ap_present_no_verify_again + + - name: no verification asserts + ansible.builtin.assert: + that: + - ap_present_no_verify_cm is changed + - ap_present_no_verify_cm.current_verified == false + - ap_present_no_verify_cm.current.0 == ap_present_no_verify_cm.proposed + - ap_present_no_verify is changed + - ap_present_no_verify.current_verified == false + - ap_present_no_verify.current.0 == ap_present_no_verify.proposed + - ap_present_no_verify.previous == [] + - ap_present_no_verify_again is not changed + - ap_present_no_verify_again.current_verified == true + - ap_present_no_verify_again.current.0.fvAp.attributes.name == "anstest-no-verify" + - ap_present_no_verify_again.current.0.fvAp.attributes.descr == "Ansible Test" + - ap_present_no_verify_again.previous.0.fvAp.attributes.name == "anstest-no-verify" + - ap_present_no_verify_again.previous.0.fvAp.attributes.descr == "Ansible Test" + - update_ap_present_no_verify is changed + - update_ap_present_no_verify.current_verified == false + - update_ap_present_no_verify.current.0 == update_ap_present_no_verify.proposed + - update_ap_present_no_verify.previous.0.fvAp.attributes.name == "anstest-no-verify" + - update_ap_present_no_verify.previous.0.fvAp.attributes.descr == "Ansible Test" + - delete_ap_present_no_verify is changed + - delete_ap_present_no_verify.current_verified == false + - delete_ap_present_no_verify.current.0 == delete_ap_present_no_verify.proposed + - delete_ap_present_no_verify.previous.0.fvAp.attributes.name == "anstest-no-verify" + - delete_ap_present_no_verify.previous.0.fvAp.attributes.descr == "Ansible Test No Verify" + - delete_ap_present_no_verify_again is not changed + - delete_ap_present_no_verify_again.current_verified == true + - delete_ap_present_no_verify_again.current == [] + - delete_ap_present_no_verify_again.previous == [] + - delete_ap_present_no_verify_again.proposed == {} + - name: get ap - query specific ap cisco.aci.aci_ap: &aci_ap_query <<: *aci_ap_present @@ -132,7 +202,7 @@ register: query_all - name: query assertions - assert: + ansible.builtin.assert: that: - query_ap is not changed - query_ap.current | length == 1 @@ -183,7 +253,7 @@ ap: anstest2 - name: absent assertions - assert: + ansible.builtin.assert: that: - ap_delete_check_mode is changed - ap_delete_check_mode.previous != [] diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_bd/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_bd/tasks/main.yml index 3af05fd0f..4bb951c69 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_bd/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_bd/tasks/main.yml @@ -1,15 +1,16 @@ # Test code for the ACI modules # Copyright: (c) 2017, Jacob McGill (@jmcgill298) +# Copyright: (c) 2024, Samita Bhattacharjee (@samiib) <samitab@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 APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: "{{ aci_hostname }}" username: "{{ aci_username }}" @@ -20,14 +21,14 @@ output_level: debug - name: Query system information - aci_system: + cisco.aci.aci_system: <<: *aci_info id: 1 state: query register: version - name: Verify Cloud and Non-Cloud Sites in use. - include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml - name: ensure tenant does not exists cisco.aci.aci_tenant: &aci_tenant_absent @@ -73,11 +74,63 @@ l3protocol: ospf state: present + - name: ensure IGMP Interface Policy exists + cisco.aci.aci_igmp_interface_policy: &aci_igmp_policy_present + <<: *aci_tenant_present + name: ansible_igmp_pol + state: present + + - name: ensure Monitoring Policy exists + cisco.aci.aci_epg_monitoring_policy: &aci_monitoring_policy_present + <<: *aci_tenant_present + name: ansible_monitoring_pol + state: present + + - name: ensure PIM Route Map Policy exists + cisco.aci.aci_pim_route_map_policy: &aci_route_map_policy_present + <<: *aci_tenant_present + name: ansible_route_map_pol + state: present + when: version.current.0.topSystem.attributes.version is version('5.2', '>=') + + - name: ensure IGMP Snoop Policy exists + cisco.aci.aci_rest: + <<: *aci_info + path: /api/mo/uni/tn-ansible_test.json + method: post + content: + igmpSnoopPol: + attributes: + name: ansible_igmp_snoop + + - name: ensure MLD Snoop Policy exists + cisco.aci.aci_rest: + <<: *aci_info + path: /api/mo/uni/tn-ansible_test.json + method: post + content: + mldSnoopPol: + attributes: + name: ansible_mld_snoop + + - name: ensure FHS policy exists + cisco.aci.aci_rest: + <<: *aci_info + path: /api/mo/uni/tn-ansible_test.json + method: post + content: + fhsBDPol: + attributes: + name: ansible_fhs + - name: create bd - check mode works cisco.aci.aci_bd: &aci_bd_present <<: *aci_tenant_present bd: anstest description: Ansible Test + mld_snoop_policy: ansible_mld_snoop + first_hop_security_policy: ansible_fhs + igmp_policy: ansible_igmp_pol check_mode: true register: bd_present_check_mode @@ -91,6 +144,7 @@ <<: *aci_bd_present register: bd_present_idempotent + # UPDATE BD - name: update bd - update works cisco.aci.aci_bd: <<: *aci_bd_present @@ -98,6 +152,25 @@ description: Ansible Test Update register: bd_update + - name: Update bd to remove child config (check_mode) + cisco.aci.aci_bd: &aci_bd_update + <<: *aci_bd_present + mld_snoop_policy: "" + first_hop_security_policy: "" + igmp_policy: "" + check_mode: true + register: cm_update_bd_2 + + - name: Update bd to remove child config (normal_mode) + cisco.aci.aci_bd: + <<: *aci_bd_update + register: nm_update_bd_2 + + - name: Update bd again to remove child config (testing idempotency) + cisco.aci.aci_bd: + <<: *aci_bd_update + register: nm_update_bd_2_again + - name: create another bd - check more params cisco.aci.aci_bd: <<: *aci_bd_present @@ -115,7 +188,7 @@ register: bd_present_2 when: version.current.0.topSystem.attributes.version is version('4.2', '<') - - name: create another bd - check more params (>v4.2) + - name: create another bd - check more params (>=v4.2 & <6.0) cisco.aci.aci_bd: <<: *aci_bd_present bd: anstest2 @@ -126,12 +199,61 @@ l3_unknown_multicast: opt-flood ipv6_l3_unknown_multicast: opt-flood multi_dest: drop - enable_routing: "no" + enable_routing: "yes" arp_flooding: "yes" route_profile_l3out: ansible_l3out route_profile: ansible_l3out_route + host_based_routing: true + allow_intersite_bum_traffic: true + allow_intersite_l2_stretch: true + allow_ipv6_mcast: true + ll_addr: "fe80::1322:33ff:fe44:5566" + vmac: "00:AA:BB:CC:DD:03" + optimize_wan_bandwidth: true + vlan: vlan-101 + igmp_policy: ansible_igmp_pol + monitoring_policy: ansible_monitoring_pol + igmp_snoop_policy: ansible_igmp_snoop + mld_snoop_policy: ansible_mld_snoop + first_hop_security_policy: ansible_fhs register: bd_present_2b - when: version.current.0.topSystem.attributes.version is version('4.2', '>=') + when: version.current.0.topSystem.attributes.version is version('4.2', '>=') and + version.current.0.topSystem.attributes.version is version('6.0', '<') + + - name: create another bd - check more params (>=v6.0) + cisco.aci.aci_bd: + <<: *aci_bd_present + bd: anstest2 + bd_type: ethernet + endpoint_move_detect: default + ip_learning: "no" + l2_unknown_unicast: flood + l3_unknown_multicast: opt-flood + ipv6_l3_unknown_multicast: opt-flood + multi_dest: drop + enable_routing: "yes" + arp_flooding: "yes" + route_profile_l3out: ansible_l3out + route_profile: ansible_l3out_route + host_based_routing: true + enable_rogue_except_mac: true + allow_intersite_bum_traffic: true + allow_intersite_l2_stretch: true + allow_ipv6_mcast: true + ll_addr: "fe80::1322:33ff:fe44:5566" + mcast_arp_drop: true + vmac: "00:AA:BB:CC:DD:03" + optimize_wan_bandwidth: true + vlan: vlan-101 + igmp_policy: ansible_igmp_pol + monitoring_policy: ansible_monitoring_pol + igmp_snoop_policy: ansible_igmp_snoop + mld_snoop_policy: ansible_mld_snoop + pim_source_filter: ansible_route_map_pol + pim_destination_filter: ansible_route_map_pol + first_hop_security_policy: ansible_fhs + register: bd_present_2c + when: version.current.0.topSystem.attributes.version is version('6.0', '>=') - name: create bd without all necessary params - failure message works cisco.aci.aci_bd: @@ -140,8 +262,27 @@ ignore_errors: true register: bd_present_missing_param + - name: present asserts for removing children + ansible.builtin.assert: + that: + - cm_update_bd_2 is changed + - cm_update_bd_2.previous == cm_update_bd_2.current + - cm_update_bd_2.proposed.fvBD.children | length == 3 + - cm_update_bd_2.proposed.fvBD.children.0.fvRsMldsn.attributes.tnMldSnoopPolName == '' + - cm_update_bd_2.proposed.fvBD.children.1.fvRsBDToFhs.attributes.tnFhsBDPolName == '' + - cm_update_bd_2.proposed.fvBD.children.2.igmpIfP.children.0.igmpRsIfPol.attributes.tDn == '' + - nm_update_bd_2 is changed + - nm_update_bd_2.previous.0.fvBD.children.0.fvRsMldsn.attributes.tnMldSnoopPolName == 'ansible_mld_snoop' + - nm_update_bd_2.previous.0.fvBD.children.1.fvRsBDToFhs.attributes.tnFhsBDPolName == 'ansible_fhs' + - nm_update_bd_2.previous.0.fvBD.children.2.igmpIfP.children.0.igmpRsIfPol.attributes.tDn == 'uni/tn-ansible_test/igmpIfPol-ansible_igmp_pol' + - nm_update_bd_2.current.0.fvBD.children.0.fvRsMldsn.attributes.tnMldSnoopPolName == '' + - nm_update_bd_2.current.0.fvBD.children.1.fvRsBDToFhs.attributes.tnFhsBDPolName == '' + - nm_update_bd_2.current.0.fvBD.children.2.igmpIfP.children.0.igmpRsIfPol.attributes.tDn == '' + - nm_update_bd_2_again is not changed + - nm_update_bd_2_again.previous == nm_update_bd_2_again.current + - name: present asserts (<v4.2) - assert: + ansible.builtin.assert: that: - bd_present_check_mode is changed - bd_present_check_mode.sent.fvBD.attributes.descr == 'Ansible Test' @@ -172,8 +313,8 @@ - 'bd_present_missing_param.msg == "state is present but all of the following are missing: tenant"' when: version.current.0.topSystem.attributes.version is version('4.2', '<') - - name: present asserts (>v4.2) - assert: + - name: present asserts (>=v4.2 & <v6.0) + ansible.builtin.assert: that: - bd_present_check_mode is changed - bd_present_check_mode.sent.fvBD.attributes.descr == 'Ansible Test' @@ -193,16 +334,243 @@ - bd_present_2b.sent.fvBD.attributes.ipLearning == 'no' - bd_present_2b.sent.fvBD.attributes.multiDstPktAct == 'drop' - bd_present_2b.sent.fvBD.attributes.name == 'anstest2' - - bd_present_2b.sent.fvBD.attributes.unicastRoute == 'no' + - bd_present_2b.sent.fvBD.attributes.unicastRoute == 'yes' - bd_present_2b.sent.fvBD.attributes.unkMacUcastAct == 'flood' - bd_present_2b.sent.fvBD.attributes.unkMcastAct == 'opt-flood' - bd_present_2b.sent.fvBD.attributes.v6unkMcastAct == 'opt-flood' - bd_present_2b.sent.fvBD.attributes.type == 'regular' - - bd_present_2b.sent.fvBD.children.0.fvRsBDToProfile.attributes.tnL3extOutName == 'ansible_l3out' - - bd_present_2b.sent.fvBD.children.0.fvRsBDToProfile.attributes.tnRtctrlProfileName == 'ansible_l3out_route' + - bd_present_2b.sent.fvBD.attributes.hostBasedRouting == 'yes' + - bd_present_2b.sent.fvBD.attributes.intersiteBumTrafficAllow == 'yes' + - bd_present_2b.sent.fvBD.attributes.intersiteL2Stretch == 'yes' + - bd_present_2b.sent.fvBD.attributes.ipv6McastAllow == 'yes' + - bd_present_2b.sent.fvBD.attributes.llAddr == 'fe80::1322:33ff:fe44:5566' + - bd_present_2b.sent.fvBD.attributes.vmac == '00:AA:BB:CC:DD:03' + - bd_present_2b.sent.fvBD.attributes.OptimizeWanBandwidth == 'yes' + - bd_present_2b.sent.fvBD.children.0.fvRsIgmpsn.attributes.tnIgmpSnoopPolName == 'ansible_igmp_snoop' + - bd_present_2b.sent.fvBD.children.1.fvRsMldsn.attributes.tnMldSnoopPolName == 'ansible_mld_snoop' + - bd_present_2b.sent.fvBD.children.2.fvRsBDToProfile.attributes.tnL3extOutName == 'ansible_l3out' + - bd_present_2b.sent.fvBD.children.2.fvRsBDToProfile.attributes.tnRtctrlProfileName == 'ansible_l3out_route' + - bd_present_2b.sent.fvBD.children.3.fvRsBDToFhs.attributes.tnFhsBDPolName == 'ansible_fhs' + - bd_present_2b.sent.fvBD.children.4.fvAccP.attributes.encap == 'vlan-101' + - bd_present_2b.sent.fvBD.children.5.fvRsABDPolMonPol.attributes.tnMonEPGPolName == 'ansible_monitoring_pol' + - bd_present_2b.sent.fvBD.children.6.igmpIfP.children.0.igmpRsIfPol.attributes.tDn == 'uni/tn-ansible_test/igmpIfPol-ansible_igmp_pol' - bd_present_missing_param is failed - 'bd_present_missing_param.msg == "state is present but all of the following are missing: tenant"' - when: version.current.0.topSystem.attributes.version is version('4.2', '>=') + when: version.current.0.topSystem.attributes.version is version('4.2', '>=') and + version.current.0.topSystem.attributes.version is version('6.0', '<') + + - name: present asserts (>=v6.0) + ansible.builtin.assert: + that: + - bd_present_check_mode is changed + - bd_present_check_mode.sent.fvBD.attributes.descr == 'Ansible Test' + - bd_present_check_mode.sent.fvBD.attributes.name == 'anstest' + - bd_present is changed + - bd_present.sent == bd_present_check_mode.sent + - bd_present.previous == [] + - bd_present_idempotent is not changed + - bd_present_idempotent.previous != [] + - bd_update is changed + - bd_update.previous != [] + - bd_update.sent != bd_update.proposed + - bd_update.sent.fvBD.attributes.descr == 'Ansible Test Update' + - bd_update.sent.fvBD.children.0.fvRsCtx.attributes.tnFvCtxName == 'anstest' + - bd_present_2c.sent.fvBD.attributes.arpFlood == 'yes' + - bd_present_2c.sent.fvBD.attributes.descr == 'Ansible Test' + - bd_present_2c.sent.fvBD.attributes.ipLearning == 'no' + - bd_present_2c.sent.fvBD.attributes.multiDstPktAct == 'drop' + - bd_present_2c.sent.fvBD.attributes.name == 'anstest2' + - bd_present_2c.sent.fvBD.attributes.unicastRoute == 'yes' + - bd_present_2c.sent.fvBD.attributes.unkMacUcastAct == 'flood' + - bd_present_2c.sent.fvBD.attributes.unkMcastAct == 'opt-flood' + - bd_present_2c.sent.fvBD.attributes.v6unkMcastAct == 'opt-flood' + - bd_present_2c.sent.fvBD.attributes.type == 'regular' + - bd_present_2c.sent.fvBD.attributes.hostBasedRouting == 'yes' + - bd_present_2c.sent.fvBD.attributes.intersiteBumTrafficAllow == 'yes' + - bd_present_2c.sent.fvBD.attributes.intersiteL2Stretch == 'yes' + - bd_present_2c.sent.fvBD.attributes.ipv6McastAllow == 'yes' + - bd_present_2c.sent.fvBD.attributes.llAddr == 'fe80::1322:33ff:fe44:5566' + - bd_present_2c.sent.fvBD.attributes.mcastARPDrop == 'yes' + - bd_present_2c.sent.fvBD.attributes.enableRogueExceptMac == 'yes' + - bd_present_2c.sent.fvBD.attributes.vmac == '00:AA:BB:CC:DD:03' + - bd_present_2c.sent.fvBD.attributes.OptimizeWanBandwidth == 'yes' + - bd_present_2c.sent.fvBD.children.0.fvRsIgmpsn.attributes.tnIgmpSnoopPolName == 'ansible_igmp_snoop' + - bd_present_2c.sent.fvBD.children.1.fvRsMldsn.attributes.tnMldSnoopPolName == 'ansible_mld_snoop' + - bd_present_2c.sent.fvBD.children.2.fvRsBDToProfile.attributes.tnRtctrlProfileName == 'ansible_l3out_route' + - bd_present_2c.sent.fvBD.children.2.fvRsBDToProfile.attributes.tnL3extOutName == 'ansible_l3out' + - bd_present_2c.sent.fvBD.children.3.fvRsBDToFhs.attributes.tnFhsBDPolName == 'ansible_fhs' + - bd_present_2c.sent.fvBD.children.4.fvAccP.attributes.encap == 'vlan-101' + - bd_present_2c.sent.fvBD.children.5.fvRsABDPolMonPol.attributes.tnMonEPGPolName == 'ansible_monitoring_pol' + - bd_present_2c.sent.fvBD.children.6.igmpIfP.children.0.igmpRsIfPol.attributes.tDn == 'uni/tn-ansible_test/igmpIfPol-ansible_igmp_pol' + - bd_present_2c.sent.fvBD.children.7.pimBDP.children.0.pimBDFilterPol.children.0.pimBDSrcFilterPol.children.0.rtdmcRsFilterToRtMapPol.attributes.tDn == 'uni/tn-ansible_test/rtmap-ansible_route_map_pol' + - bd_present_2c.sent.fvBD.children.7.pimBDP.children.0.pimBDFilterPol.children.1.pimBDDestFilterPol.children.0.rtdmcRsFilterToRtMapPol.attributes.tDn == 'uni/tn-ansible_test/rtmap-ansible_route_map_pol' + - bd_present_missing_param is failed + - 'bd_present_missing_param.msg == "state is present but all of the following are missing: tenant"' + when: version.current.0.topSystem.attributes.version is version('6.0', '>=') + + - name: execute tasks for pim source filter & pim destination filter (>=v5.2) + when: version.current.0.topSystem.attributes.version is version('5.2', '>=') + block: + + - name: create another bd - check pim source filter (check_mode) + cisco.aci.aci_bd: &aci_bd_pim_s + <<: *aci_bd_present + bd: anstest_pim_s + pim_source_filter: ansible_route_map_pol + check_mode: true + register: cm_bd_pim_s + + - name: create another bd - check pim source filter (normal_mode) + cisco.aci.aci_bd: + <<: *aci_bd_pim_s + register: nm_bd_pim_s + + - name: create another bd - check pim source filter (testing idempotency) + cisco.aci.aci_bd: + <<: *aci_bd_pim_s + register: nm_bd_pim_s_again + + - name: update bd - remove pim source filter + cisco.aci.aci_bd: + <<: *aci_bd_pim_s + pim_source_filter: "" + register: nm_bd_pim_s_remove + + - name: create another bd - check pim destination filter (check_mode) + cisco.aci.aci_bd: &aci_bd_pim_d + <<: *aci_bd_present + bd: anstest_pim_d + pim_destination_filter: ansible_route_map_pol + check_mode: true + register: cm_bd_pim_d + + - name: create another bd - check pim destination filter (normal_mode) + cisco.aci.aci_bd: + <<: *aci_bd_pim_d + register: nm_bd_pim_d + + - name: create another bd - check pim destination filter (testing idempotency) + cisco.aci.aci_bd: + <<: *aci_bd_pim_d + register: nm_bd_pim_d_again + + - name: update bd - remove pim destination filter + cisco.aci.aci_bd: + <<: *aci_bd_pim_d + pim_destination_filter: "" + register: nm_bd_pim_d_remove + + - name: cleanup pim_s and pim_d BDs + cisco.aci.aci_bd: + <<: *aci_bd_present + bd: "{{ item }}" + state: absent + loop: + - anstest_pim_s + - anstest_pim_d + + - name: asserts for pim source filter and pim destination filter + ansible.builtin.assert: + that: + - cm_bd_pim_s is changed + - cm_bd_pim_s.current == [] + - cm_bd_pim_s.previous == [] + - cm_bd_pim_s.proposed.fvBD.children.3.pimBDP.children.0.pimBDFilterPol.children | length == 1 + - cm_bd_pim_s.proposed.fvBD.children.3.pimBDP.children.0.pimBDFilterPol.children.0.pimBDSrcFilterPol.children.0.rtdmcRsFilterToRtMapPol.attributes.tDn == 'uni/tn-ansible_test/rtmap-ansible_route_map_pol' + - nm_bd_pim_s is changed + - nm_bd_pim_s.previous == [] + - nm_bd_pim_s.current.0.fvBD.children.5.pimBDP.children.0.pimBDFilterPol.children | length == 1 + - nm_bd_pim_s.current.0.fvBD.children.5.pimBDP.children.0.pimBDFilterPol.children.0.pimBDSrcFilterPol.children.0.rtdmcRsFilterToRtMapPol.attributes.tDn == 'uni/tn-ansible_test/rtmap-ansible_route_map_pol' + - nm_bd_pim_s_again.current.0.fvBD.children.5.pimBDP.children.0.pimBDFilterPol.children | length == 1 + - nm_bd_pim_s_again.current.0.fvBD.children.5.pimBDP.children.0.pimBDFilterPol.children.0.pimBDSrcFilterPol.children.0.rtdmcRsFilterToRtMapPol.attributes.tDn == 'uni/tn-ansible_test/rtmap-ansible_route_map_pol' + - nm_bd_pim_s_again.previous.0.fvBD.children.5.pimBDP.children.0.pimBDFilterPol.children | length == 1 + - nm_bd_pim_s_again.previous.0.fvBD.children.5.pimBDP.children.0.pimBDFilterPol.children.0.pimBDSrcFilterPol.children.0.rtdmcRsFilterToRtMapPol.attributes.tDn == 'uni/tn-ansible_test/rtmap-ansible_route_map_pol' + - nm_bd_pim_s_remove.previous == nm_bd_pim_s.current + - nm_bd_pim_s_remove.current.0.fvBD.children.5.pimBDP.children.0.pimBDFilterPol.children.0.pimBDSrcFilterPol.children.0.rtdmcRsFilterToRtMapPol.attributes.tDn == '' + - cm_bd_pim_d is changed + - cm_bd_pim_d.current == [] + - cm_bd_pim_d.previous == [] + - cm_bd_pim_d.proposed.fvBD.children.3.pimBDP.children.0.pimBDFilterPol.children | length == 1 + - cm_bd_pim_d.proposed.fvBD.children.3.pimBDP.children.0.pimBDFilterPol.children.0.pimBDDestFilterPol.children.0.rtdmcRsFilterToRtMapPol.attributes.tDn == 'uni/tn-ansible_test/rtmap-ansible_route_map_pol' + - nm_bd_pim_d is changed + - nm_bd_pim_d.previous == [] + - nm_bd_pim_d.current.0.fvBD.children.5.pimBDP.children.0.pimBDFilterPol.children | length == 1 + - nm_bd_pim_d.current.0.fvBD.children.5.pimBDP.children.0.pimBDFilterPol.children.0.pimBDDestFilterPol.children.0.rtdmcRsFilterToRtMapPol.attributes.tDn == 'uni/tn-ansible_test/rtmap-ansible_route_map_pol' + - nm_bd_pim_d_again.current.0.fvBD.children.5.pimBDP.children.0.pimBDFilterPol.children | length == 1 + - nm_bd_pim_d_again.current.0.fvBD.children.5.pimBDP.children.0.pimBDFilterPol.children.0.pimBDDestFilterPol.children.0.rtdmcRsFilterToRtMapPol.attributes.tDn == 'uni/tn-ansible_test/rtmap-ansible_route_map_pol' + - nm_bd_pim_d_again.previous.0.fvBD.children.5.pimBDP.children.0.pimBDFilterPol.children | length == 1 + - nm_bd_pim_d_again.previous.0.fvBD.children.5.pimBDP.children.0.pimBDFilterPol.children.0.pimBDDestFilterPol.children.0.rtdmcRsFilterToRtMapPol.attributes.tDn == 'uni/tn-ansible_test/rtmap-ansible_route_map_pol' + - nm_bd_pim_d_remove.previous == nm_bd_pim_d.current + - nm_bd_pim_d_remove.current.0.fvBD.children.5.pimBDP.children.0.pimBDFilterPol.children.0.pimBDDestFilterPol.children.0.rtdmcRsFilterToRtMapPol.attributes.tDn == '' + + # TEST NO VERIFICATION + - name: create bd with no verification (check mode) + cisco.aci.aci_bd: &aci_bd_no_verify + <<: *aci_bd_present + bd: anstest-no-verify + no_verification: true + check_mode: true + register: bd_present_no_verify_cm + + - name: create bd with no verification + cisco.aci.aci_bd: + <<: *aci_bd_no_verify + register: bd_present_no_verify + + - name: create bd with no verification again + cisco.aci.aci_bd: + <<: *aci_bd_no_verify + register: bd_present_no_verify_again + + - name: update bd with no verification + cisco.aci.aci_bd: + <<: *aci_bd_no_verify + description: Ansible Test No Verify + register: update_bd_present_no_verify + + - name: delete bd with no verification + cisco.aci.aci_bd: + <<: *aci_bd_no_verify + state: absent + register: delete_bd_present_no_verify + + - name: delete bd with no verification again + cisco.aci.aci_bd: + <<: *aci_bd_no_verify + state: absent + register: delete_bd_present_no_verify_again + + - name: no verification asserts + ansible.builtin.assert: + that: + - bd_present_no_verify_cm is changed + - bd_present_no_verify_cm.current_verified == false + - bd_present_no_verify_cm.current.0 == bd_present_no_verify_cm.proposed + - bd_present_no_verify is changed + - bd_present_no_verify.current_verified == false + - bd_present_no_verify.current.0 == bd_present_no_verify.proposed + - bd_present_no_verify.previous == [] + - bd_present_no_verify_again is not changed + - bd_present_no_verify_again.current_verified == true + - bd_present_no_verify_again.current.0.fvBD.attributes.name == "anstest-no-verify" + - bd_present_no_verify_again.current.0.fvBD.attributes.descr == "Ansible Test" + - bd_present_no_verify_again.previous.0.fvBD.attributes.name == "anstest-no-verify" + - bd_present_no_verify_again.previous.0.fvBD.attributes.descr == "Ansible Test" + - update_bd_present_no_verify is changed + - update_bd_present_no_verify.current_verified == false + - update_bd_present_no_verify.current.0 == update_bd_present_no_verify.proposed + - update_bd_present_no_verify.previous.0.fvBD.attributes.name == "anstest-no-verify" + - update_bd_present_no_verify.previous.0.fvBD.attributes.descr == "Ansible Test" + - delete_bd_present_no_verify is changed + - delete_bd_present_no_verify.current_verified == false + - delete_bd_present_no_verify.current.0 == delete_bd_present_no_verify.proposed + - delete_bd_present_no_verify.previous.0.fvBD.attributes.name == "anstest-no-verify" + - delete_bd_present_no_verify.previous.0.fvBD.attributes.descr == "Ansible Test No Verify" + - delete_bd_present_no_verify_again is not changed + - delete_bd_present_no_verify_again.current_verified == true + - delete_bd_present_no_verify_again.current == [] + - delete_bd_present_no_verify_again.previous == [] + - delete_bd_present_no_verify_again.proposed == {} - name: get all bd cisco.aci.aci_bd: &aci_query @@ -230,27 +598,27 @@ register: query_bd - name: query asserts - assert: + ansible.builtin.assert: that: - query_all is not changed - query_all.current | length > 1 - query_all.current.0.fvBD is defined - - '"rsp-subtree-class=fvRsBDToNdP,fvRsBDToProfile,fvRsBdToEpRet,fvRsCtx,fvRsIgmpsn" in query_all.filter_string' + - '"rsp-subtree-class=fvAccP,fvRsABDPolMonPol,fvRsBDToFhs,fvRsBDToNdP,fvRsBDToProfile,fvRsBdToEpRet,fvRsCtx,fvRsIgmpsn,fvRsMldsn,igmpIfP,igmpRsIfPol" in query_all.filter_string' - '"class/fvBD.json" in query_all.url' - query_tenant is not changed - query_tenant.current | length == 1 - query_tenant.current.0.fvTenant.children | length == 2 - - '"rsp-subtree-class=fvBD,fvRsBDToNdP,fvRsBDToProfile,fvRsBdToEpRet,fvRsCtx,fvRsIgmpsn" in query_tenant.filter_string' + - '"rsp-subtree-class=fvAccP,fvBD,fvRsABDPolMonPol,fvRsBDToFhs,fvRsBDToNdP,fvRsBDToProfile,fvRsBdToEpRet,fvRsCtx,fvRsIgmpsn,fvRsMldsn,igmpIfP,igmpRsIfPol" in query_tenant.filter_string' - '"tn-ansible_test.json" in query_tenant.url' - query_bd_bd is not changed - query_bd_bd.current != [] - '"query-target-filter=eq(fvBD.name,\"anstest\")" in query_bd_bd.filter_string' - - '"rsp-subtree-class=fvRsBDToNdP,fvRsBDToProfile,fvRsBdToEpRet,fvRsCtx,fvRsIgmpsn" in query_bd_bd.filter_string' + - '"rsp-subtree-class=fvAccP,fvRsABDPolMonPol,fvRsBDToFhs,fvRsBDToNdP,fvRsBDToProfile,fvRsBdToEpRet,fvRsCtx,fvRsIgmpsn,fvRsMldsn,igmpIfP,igmpRsIfPol" in query_bd_bd.filter_string' - '"class/fvBD.json" in query_bd_bd.url' - query_bd is not changed - query_bd.current | length == 1 - query_bd.current.0.fvBD.attributes.name == "anstest" - - '"rsp-subtree-class=fvRsBDToNdP,fvRsBDToProfile,fvRsBdToEpRet,fvRsCtx,fvRsIgmpsn" in query_bd.filter_string' + - '"rsp-subtree-class=fvAccP,fvRsABDPolMonPol,fvRsBDToFhs,fvRsBDToNdP,fvRsBDToProfile,fvRsBdToEpRet,fvRsCtx,fvRsIgmpsn,fvRsMldsn,igmpIfP,igmpRsIfPol" in query_bd.filter_string' - '"tn-ansible_test/BD-anstest.json" in query_bd.url' - name: delete bd - check mode works @@ -283,7 +651,7 @@ register: bd_absent_missing_param - name: asserts for deletion task - assert: + ansible.builtin.assert: that: - bd_absent_check_mode is changed - bd_absent_check_mode.proposed == {} @@ -294,6 +662,40 @@ - bd_absent_missing_param is failed - 'bd_absent_missing_param.msg == "state is absent but all of the following are missing: bd"' + - name: delete FHS - cleanup before ending tests + cisco.aci.aci_rest: + <<: *aci_info + path: /api/mo/uni/tn-ansible_test/bdpol-ansible_fhs.json + method: delete + + - name: delete IGMP Snoop Policy - cleanup before ending tests + cisco.aci.aci_rest: + <<: *aci_info + path: /api/mo/uni/tn-ansible_test/snPol-ansible_igmp_snoop.json + method: delete + + - name: delete MLD Snoop Policy - cleanup before ending tests + cisco.aci.aci_rest: + <<: *aci_info + path: /api/mo/uni/tn-ansible_test/mldsnoopPol-ansible_mld_snoop.json + method: delete + + - name: delete IGMP Interface Policy - cleanup before ending tests + cisco.aci.aci_igmp_interface_policy: + <<: *aci_igmp_policy_present + state: absent + + - name: delete Monitoring Policy - cleanup before ending tests + cisco.aci.aci_epg_monitoring_policy: + <<: *aci_monitoring_policy_present + state: absent + + - name: delete PIM Route Map Policy - cleanup before ending tests + cisco.aci.aci_pim_route_map_policy: + <<: *aci_route_map_policy_present + state: absent + when: version.current.0.topSystem.attributes.version is version('5.2', '>=') + - name: delete vrf - cleanup before ending tests cisco.aci.aci_vrf: <<: *aci_vrf_present diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_bd_dhcp_label/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_bd_dhcp_label/tasks/main.yml index 937ea80a3..c7641b7b0 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_bd_dhcp_label/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_bd_dhcp_label/tasks/main.yml @@ -4,12 +4,12 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: "{{ aci_hostname }}" username: "{{ aci_username }}" @@ -21,26 +21,26 @@ # CLEAN ENVIRONMENT - name: Remove the ansible_tenant - aci_tenant: + cisco.aci.aci_tenant: <<: *aci_info tenant: ansible_tenant state: absent - name: Verify Cloud and Non-Cloud Sites in use. - include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml - name: Execute tasks only for non-cloud sites when: query_cloud.current == [] # This condition will execute only non-cloud sites block: # block specifies execution of tasks within, based on conditions - name: Add a new tenant - aci_tenant: + cisco.aci.aci_tenant: <<: *aci_info tenant: ansible_tenant description: Ansible tenant state: present - name: create bd - creation works - aci_bd: + cisco.aci.aci_bd: <<: *aci_info tenant: ansible_tenant bd: database @@ -48,7 +48,7 @@ #CREATE LABELS - name: Create a new DHCP Relay Label to a Bridge Domain - check mode - aci_bd_dhcp_label: + cisco.aci.aci_bd_dhcp_label: <<: *aci_info tenant: ansible_tenant bd: database @@ -59,13 +59,13 @@ register: cm_dhcp_label1 - name: Verify creation of label1 in check mode - assert: + ansible.builtin.assert: that: - cm_dhcp_label1 is changed - cm_dhcp_label1.sent.dhcpLbl.attributes.name == 'label1' - name: Create a new DHCP Relay Label to a Bridge Domain - normal mode - aci_bd_dhcp_label: + cisco.aci.aci_bd_dhcp_label: <<: *aci_info tenant: ansible_tenant bd: database @@ -75,7 +75,7 @@ register: nm_dhcp_label1 - name: Verify creation of label1 - assert: + ansible.builtin.assert: that: - nm_dhcp_label1 is changed - nm_dhcp_label1.current.0.dhcpLbl.attributes.dn == 'uni/tn-ansible_tenant/BD-database/dhcplbl-label1' @@ -83,7 +83,7 @@ - nm_dhcp_label1.current.0.dhcpLbl.attributes.annotation == 'orchestrator:ansible' - name: Create another DHCP Relay Label to a Bridge Domain - normal mode - aci_bd_dhcp_label: + cisco.aci.aci_bd_dhcp_label: <<: *aci_info tenant: ansible_tenant bd: database @@ -93,7 +93,7 @@ register: nm_dhcp_label2 - name: Verify creation of label2 - assert: + ansible.builtin.assert: that: - nm_dhcp_label2 is changed - nm_dhcp_label2.current.0.dhcpLbl.attributes.dn == 'uni/tn-ansible_tenant/BD-database/dhcplbl-label2' @@ -101,7 +101,7 @@ #QUERY LABELS - name: Query a DHCP Relay Label of a Bridge Domain - aci_bd_dhcp_label: + cisco.aci.aci_bd_dhcp_label: <<: *aci_info tenant: ansible_tenant bd: database @@ -111,13 +111,13 @@ register: query_dhcp_label1 - name: Verify query of label - assert: + ansible.builtin.assert: that: - query_dhcp_label1 is not changed - query_dhcp_label1.current.0.dhcpLbl.attributes.dn == 'uni/tn-ansible_tenant/BD-database/dhcplbl-label1' - name: Query all DHCP Relay Labels of a Bridge Domain - aci_bd_dhcp_label: + cisco.aci.aci_bd_dhcp_label: <<: *aci_info tenant: ansible_tenant bd: database @@ -125,13 +125,13 @@ register: query_all_labels - name: Verify query all of labels - assert: + ansible.builtin.assert: that: - query_all_labels is not changed #REMOVE LABELS - name: Remove a DHCP Relay Label for a Bridge Domain - aci_bd_dhcp_label: + cisco.aci.aci_bd_dhcp_label: <<: *aci_info tenant: ansible_tenant bd: database @@ -141,14 +141,14 @@ register: delete_dhcp_label - name: Verify deletion of label - assert: + ansible.builtin.assert: that: - delete_dhcp_label is changed - delete_dhcp_label.current == [] # CLEAN ENVIRONMENT AGAIN - name: Remove the ansible_tenant - aci_tenant: + cisco.aci.aci_tenant: <<: *aci_info tenant: ansible_tenant state: absent
\ No newline at end of file diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_bd_rogue_exception_mac/aliases b/ansible_collections/cisco/aci/tests/integration/targets/aci_bd_rogue_exception_mac/aliases new file mode 100644 index 000000000..209b793f9 --- /dev/null +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_bd_rogue_exception_mac/aliases @@ -0,0 +1,2 @@ +# No ACI simulator yet, so not enabled +# unsupported diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_bd_rogue_exception_mac/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_bd_rogue_exception_mac/tasks/main.yml new file mode 100644 index 000000000..7aebbb44d --- /dev/null +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_bd_rogue_exception_mac/tasks/main.yml @@ -0,0 +1,186 @@ +# Test code for the ACI modules +# Copyright: (c) 2024, Samita Bhattacharjee (@samitab) <samitab@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 APIC host, ACI username and ACI password + ansible.builtin.fail: + msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' + when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined + +- name: Set vars + ansible.builtin.set_fact: + aci_info: &aci_info + host: "{{ aci_hostname }}" + username: "{{ aci_username }}" + password: "{{ aci_password }}" + validate_certs: '{{ aci_validate_certs | default(false) }}' + use_ssl: '{{ aci_use_ssl | default(true) }}' + use_proxy: '{{ aci_use_proxy | default(true) }}' + output_level: '{{ aci_output_level | default("info") }}' + +- name: Query system information + cisco.aci.aci_system: + <<: *aci_info + id: 1 + state: query + register: version + +# CLEAN ENVIRONMENT +- name: Remove the ansible_tenant + cisco.aci.aci_tenant: &aci_tenant_absent + <<: *aci_info + state: absent + tenant: ansible_test + +- name: Verify Cloud and Non-Cloud Sites in use. + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + +- name: Execute tasks only for non-cloud sites and APIC version >= 5.2 + when: query_cloud.current == [] and version.current.0.topSystem.attributes.version is version('5.2', '>=') + block: + - name: Create tenant + cisco.aci.aci_tenant: &aci_tenant_present + <<: *aci_tenant_absent + state: present + register: tenant_present + + - name: Ensure bd exists for tests to kick off + cisco.aci.aci_bd: &aci_bd_present + <<: *aci_tenant_present + bd: anstest + register: bd_present + + - name: Ensure rogue exception mac does not exist for tests to kick off + cisco.aci.aci_bd_rogue_exception_mac: &aci_rogue_exception_mac_absent + <<: *aci_bd_present + state: absent + mac: "AA:BB:CC:DD:EE:11" + description: 1st MAC + + - name: Ensure second rogue exception mac does not exist for tests to kick off + cisco.aci.aci_bd_rogue_exception_mac: &aci_rogue_exception_mac_absent_2 + <<: *aci_rogue_exception_mac_absent + mac: "AA-BB-CC-DD-EE-22" + description: 2nd MAC + + + - name: Create first rogue exception mac in bd (check_mode) + cisco.aci.aci_bd_rogue_exception_mac: &aci_bd_rogue_exception_mac_present + <<: *aci_rogue_exception_mac_absent + state: present + check_mode: true + register: cm_bd_rogue_exception_mac + + - name: Create first rogue exception mac in bd (normal_mode) + cisco.aci.aci_bd_rogue_exception_mac: + <<: *aci_bd_rogue_exception_mac_present + register: nm_bd_rogue_exception_mac + + - name: Create first rogue exception mac in bd again - testing idempotency + cisco.aci.aci_bd_rogue_exception_mac: + <<: *aci_bd_rogue_exception_mac_present + register: bd_rogue_exception_mac_idempotency + + - name: Create second rogue exception mac in bd + cisco.aci.aci_bd_rogue_exception_mac: &aci_bd_rogue_exception_mac_present_2 + <<: *aci_rogue_exception_mac_absent_2 + state: present + register: nm_bd_rogue_exception_mac_2 + + - name: Asserts for creation tasks + ansible.builtin.assert: + that: + - cm_bd_rogue_exception_mac is changed + - cm_bd_rogue_exception_mac.previous == [] + - cm_bd_rogue_exception_mac.current == [] + - cm_bd_rogue_exception_mac.proposed.fvRogueExceptionMac.attributes.dn == "uni/tn-ansible_test/BD-anstest/rgexpmac-AA:BB:CC:DD:EE:11" + - cm_bd_rogue_exception_mac.proposed.fvRogueExceptionMac.attributes.mac == "AA:BB:CC:DD:EE:11" + - cm_bd_rogue_exception_mac.proposed.fvRogueExceptionMac.attributes.descr == "1st MAC" + - nm_bd_rogue_exception_mac is changed + - nm_bd_rogue_exception_mac.current.0.fvRogueExceptionMac.attributes.dn == "uni/tn-ansible_test/BD-anstest/rgexpmac-AA:BB:CC:DD:EE:11" + - nm_bd_rogue_exception_mac.current.0.fvRogueExceptionMac.attributes.mac == "AA:BB:CC:DD:EE:11" + - nm_bd_rogue_exception_mac.current.0.fvRogueExceptionMac.attributes.descr == "1st MAC" + - bd_rogue_exception_mac_idempotency is not changed + - bd_rogue_exception_mac_idempotency.current == bd_rogue_exception_mac_idempotency.previous + - bd_rogue_exception_mac_idempotency.sent == {} + - nm_bd_rogue_exception_mac_2 is changed + - nm_bd_rogue_exception_mac_2.current.0.fvRogueExceptionMac.attributes.dn == "uni/tn-ansible_test/BD-anstest/rgexpmac-AA:BB:CC:DD:EE:22" + - nm_bd_rogue_exception_mac_2.current.0.fvRogueExceptionMac.attributes.mac == "AA:BB:CC:DD:EE:22" + - nm_bd_rogue_exception_mac_2.current.0.fvRogueExceptionMac.attributes.descr == "2nd MAC" + + - name: Query all bds bound to rogue exception mac + cisco.aci.aci_bd_rogue_exception_mac: + <<: *aci_tenant_present + state: query + output_level: debug + register: query_all_bd_to_rogue_exception_mac + + - name: Query first bd with first rogue exception mac + cisco.aci.aci_bd_rogue_exception_mac: + <<: *aci_bd_rogue_exception_mac_present + state: query + output_level: debug + register: query_first_bd_to_rogue_exception_mac + + - name: Asserts query tasks + ansible.builtin.assert: + that: + - query_all_bd_to_rogue_exception_mac is not changed + - '"fvRogueExceptionMac" in query_all_bd_to_rogue_exception_mac.filter_string' + - query_all_bd_to_rogue_exception_mac.current.0.fvTenant.children.0.fvBD.children | length == 2 + - query_all_bd_to_rogue_exception_mac.current.0.fvTenant.children.0.fvBD.attributes.name == "anstest" + - query_all_bd_to_rogue_exception_mac.current.0.fvTenant.children.0.fvBD.children.0.fvRogueExceptionMac.attributes.rn == "rgexpmac-AA:BB:CC:DD:EE:22" + - query_all_bd_to_rogue_exception_mac.current.0.fvTenant.children.0.fvBD.children.1.fvRogueExceptionMac.attributes.rn == "rgexpmac-AA:BB:CC:DD:EE:11" + - query_first_bd_to_rogue_exception_mac is not changed + - '"tn-ansible_test/BD-anstest/rgexpmac-AA:BB:CC:DD:EE:11.json" in query_first_bd_to_rogue_exception_mac.url' + + - name: Delete first rogue exception mac (check_mode) + cisco.aci.aci_bd_rogue_exception_mac: + <<: *aci_bd_rogue_exception_mac_present + state: absent + check_mode: true + register: cm_unbind_bd_to_rogue_exception_mac + + - name: Delete first rogue exception mac (normal_mode) + cisco.aci.aci_bd_rogue_exception_mac: + <<: *aci_bd_rogue_exception_mac_present + state: absent + register: nm_unbind_bd_to_rogue_exception_mac + + - name: Delete first rogue exception mac again - testing idempotency + cisco.aci.aci_bd_rogue_exception_mac: + <<: *aci_bd_rogue_exception_mac_present + state: absent + register: unbind_bd_to_rogue_exception_mac_idempotency + + - name: Delete second rogue exception mac + cisco.aci.aci_bd_rogue_exception_mac: + <<: *aci_bd_rogue_exception_mac_present_2 + state: absent + register: nm_unbind_bd_to_rogue_exception_mac_2 + + - name: Asserts for deletion tasks + ansible.builtin.assert: + that: + - cm_unbind_bd_to_rogue_exception_mac is changed + - cm_unbind_bd_to_rogue_exception_mac.current == cm_unbind_bd_to_rogue_exception_mac.previous + - cm_unbind_bd_to_rogue_exception_mac.proposed == {} + - nm_unbind_bd_to_rogue_exception_mac is changed + - nm_unbind_bd_to_rogue_exception_mac.previous != [] + - nm_unbind_bd_to_rogue_exception_mac.proposed == {} + - nm_unbind_bd_to_rogue_exception_mac.current == [] + - nm_unbind_bd_to_rogue_exception_mac.previous == cm_unbind_bd_to_rogue_exception_mac.current + - unbind_bd_to_rogue_exception_mac_idempotency is not changed + - unbind_bd_to_rogue_exception_mac_idempotency.previous == [] + - unbind_bd_to_rogue_exception_mac_idempotency.current == [] + - unbind_bd_to_rogue_exception_mac_idempotency.previous == [] + - nm_unbind_bd_to_rogue_exception_mac_2 is changed + - nm_unbind_bd_to_rogue_exception_mac_2.previous != [] + - nm_unbind_bd_to_rogue_exception_mac_2.current == [] + + - name: Delete tenant - cleanup before ending tests + cisco.aci.aci_tenant: + <<: *aci_tenant_present + state: absent + when: tenant_present is changed diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_bd_subnet/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_bd_subnet/tasks/main.yml index 4bc8e26c4..8d05b2e16 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_bd_subnet/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_bd_subnet/tasks/main.yml @@ -4,12 +4,12 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: "{{ aci_hostname }}" username: "{{ aci_username }}" @@ -27,7 +27,7 @@ register: version - name: Verify Cloud and Non-Cloud Sites in use. - include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml - name: Execute tasks only for non-cloud sites when: query_cloud.current == [] # This condition will execute only non-cloud sites @@ -128,7 +128,7 @@ ignore_errors: true - name: assert for subnet creation tasks - assert: + ansible.builtin.assert: that: - create_check_mode is changed - create_check_mode.sent.fvSubnet.attributes.descr == create_subnet.sent.fvSubnet.attributes.descr == 'Ansible Test' @@ -150,7 +150,7 @@ - 'create_incomplete_data.msg == "state is present but all of the following are missing: bd"' - name: assert for subnet for task with version < 5 - assert: + ansible.builtin.assert: that: - create_subnet2 is changed - create_subnet2.sent == create_subnet2.proposed @@ -160,7 +160,7 @@ when: version.current.0.topSystem.attributes.version is version('5', '<') - name: assert for subnet ip_data_learning for task with version >=5 - assert: + ansible.builtin.assert: that: - create_subnet.current.0.fvSubnet.attributes.ipDPLearning == 'enabled' - create_subnet2_5 is changed @@ -225,7 +225,7 @@ register: get_subnets_gateway - name: asserts for query tasks - assert: + ansible.builtin.assert: that: - get_all is not changed - get_all.current | length > 1 @@ -268,7 +268,7 @@ register: error_mask_ipv6 - name: asserts for mask error handling - assert: + ansible.builtin.assert: that: - error_mask_ipv4.msg == "Valid Subnet Masks are 0 to 32 for IPv4 Addresses" - error_mask_ipv6.msg == "Valid Subnet Masks are 0 to 128 for IPv6 Addresses" @@ -294,7 +294,7 @@ register: delete_idempotency - name: asserts for deletion task - assert: + ansible.builtin.assert: that: - delete_check_mode is changed - delete_check_mode.proposed == {} diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_bd_to_l3out/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_bd_to_l3out/tasks/main.yml index 7d1313fb2..94e7b6db4 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_bd_to_l3out/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_bd_to_l3out/tasks/main.yml @@ -4,12 +4,12 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: "{{ aci_hostname }}" username: "{{ aci_username }}" @@ -27,7 +27,7 @@ tenant: ansible_test - name: Verify Cloud and Non-Cloud Sites in use. - include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml - name: Execute tasks only for non-cloud sites when: query_cloud.current == [] # This condition will execute only non-cloud sites @@ -104,7 +104,7 @@ register: nm_bd_to_l3out_2 - name: asserts for creation tasks - assert: + ansible.builtin.assert: that: - cm_bd_to_l3out is changed - cm_bd_to_l3out.previous == [] @@ -130,7 +130,7 @@ register: query_first_bd_to_l3out - name: asserts query tasks - assert: + ansible.builtin.assert: that: - query_all_bd_to_l3out is not changed - '"fvRsBDToOut" in query_all_bd_to_l3out.filter_string' @@ -168,7 +168,7 @@ register: nm_unbind_bd_to_l3out_2 - name: asserts for deletion tasks - assert: + ansible.builtin.assert: that: - cm_unbind_bd_to_l3out is changed - cm_unbind_bd_to_l3out.proposed == {} @@ -186,11 +186,21 @@ <<: *aci_bd_present state: absent + - name: delete bd_2 - cleanup before ending tests + cisco.aci.aci_bd: + <<: *aci_bd_present_2 + state: absent + - name: delete l3out - cleanup before ending tests cisco.aci.aci_l3out: <<: *aci_l3_out_present state: absent + - name: delete l3out_2 - cleanup before ending tests + cisco.aci.aci_l3out: + <<: *aci_l3_out_present_2 + state: absent + - name: delete vrf - cleanup before ending tests cisco.aci.aci_vrf: <<: *aci_vrf_present diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_bd_to_netflow_monitor_policy/aliases b/ansible_collections/cisco/aci/tests/integration/targets/aci_bd_to_netflow_monitor_policy/aliases new file mode 100644 index 000000000..209b793f9 --- /dev/null +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_bd_to_netflow_monitor_policy/aliases @@ -0,0 +1,2 @@ +# No ACI simulator yet, so not enabled +# unsupported diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_bd_to_netflow_monitor_policy/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_bd_to_netflow_monitor_policy/tasks/main.yml new file mode 100644 index 000000000..9a7a44d16 --- /dev/null +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_bd_to_netflow_monitor_policy/tasks/main.yml @@ -0,0 +1,191 @@ +# Test code for the ACI modules +# Copyright: (c) 2024, Samita Bhattacharjee (@samitab) <samitab@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 APIC host, ACI username and ACI password + ansible.builtin.fail: + msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' + when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined + +- name: Set vars + ansible.builtin.set_fact: + aci_info: &aci_info + host: "{{ aci_hostname }}" + username: "{{ aci_username }}" + password: "{{ aci_password }}" + validate_certs: '{{ aci_validate_certs | default(false) }}' + use_ssl: '{{ aci_use_ssl | default(true) }}' + use_proxy: '{{ aci_use_proxy | default(true) }}' + output_level: '{{ aci_output_level | default("info") }}' + +# CLEAN ENVIRONMENT +- name: Remove the ansible_tenant + cisco.aci.aci_tenant: &aci_tenant_absent + <<: *aci_info + state: absent + tenant: ansible_test + +- name: Verify Cloud and Non-Cloud Sites in use. + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + +- name: Execute tasks only for non-cloud sites + when: query_cloud.current == [] # This condition will execute only non-cloud sites + block: # block specifies execution of tasks within, based on conditions + - name: Create tenant + cisco.aci.aci_tenant: &aci_tenant_present + <<: *aci_tenant_absent + state: present + + - name: Create first netflow monitor policy + cisco.aci.aci_netflow_monitor_policy: + <<: *aci_tenant_absent + netflow_monitor_policy: ansible_netflow_monitor_policy + state: present + + - name: Create second netflow monitor policy + cisco.aci.aci_netflow_monitor_policy: + <<: *aci_tenant_absent + netflow_monitor_policy: ansible_netflow_monitor_policy_2 + state: present + + - name: Create first bd + cisco.aci.aci_bd: &aci_bd_present + <<: *aci_tenant_present + bd: anstest + + - name: Create second bd + cisco.aci.aci_bd: &aci_bd_present_2 + <<: *aci_tenant_present + bd: anstest_2 + + - name: Ensure first binding bd to netflow monitor policy does not exist + cisco.aci.aci_bd_to_netflow_monitor_policy: &aci_bd_to_netflow_monitor_policy_absent + <<: *aci_bd_present + netflow_monitor_policy: ansible_netflow_monitor_policy + filter_type: ipv4 + state: absent + + - name: Ensure second binding bd to netflow monitor policy does not exist + cisco.aci.aci_bd_to_netflow_monitor_policy: &aci_bd_to_netflow_monitor_policy_absent_2 + <<: *aci_bd_present_2 + netflow_monitor_policy: ansible_netflow_monitor_policy_2 + filter_type: ipv6 + state: absent + + - name: Bind bd to netflow monitor policy - first binding (check_mode) + cisco.aci.aci_bd_to_netflow_monitor_policy: &aci_bd_to_netflow_monitor_policy_present + <<: *aci_bd_to_netflow_monitor_policy_absent + state: present + check_mode: true + register: cm_bd_to_netflow_monitor_policy + + - name: Bind bd to netflow monitor policy - first binding (normal_mode) + cisco.aci.aci_bd_to_netflow_monitor_policy: + <<: *aci_bd_to_netflow_monitor_policy_present + register: nm_bd_to_netflow_monitor_policy + + - name: Bind bd to netflow monitor policy again - testing idempotency + cisco.aci.aci_bd_to_netflow_monitor_policy: + <<: *aci_bd_to_netflow_monitor_policy_present + register: bd_to_netflow_monitor_policy_idempotency + + - name: Bind bd to netflow monitor policy again - second binding + cisco.aci.aci_bd_to_netflow_monitor_policy: &aci_bd_to_netflow_monitor_policy_present_2 + <<: *aci_bd_to_netflow_monitor_policy_absent_2 + state: present + register: nm_bd_to_netflow_monitor_policy_2 + + - name: Asserts for creation tasks + ansible.builtin.assert: + that: + - cm_bd_to_netflow_monitor_policy is changed + - cm_bd_to_netflow_monitor_policy.previous == [] + - cm_bd_to_netflow_monitor_policy.current == [] + - cm_bd_to_netflow_monitor_policy.proposed.fvRsBDToNetflowMonitorPol.attributes.dn == "uni/tn-ansible_test/BD-anstest/rsBDToNetflowMonitorPol-[ansible_netflow_monitor_policy]-ipv4" + - cm_bd_to_netflow_monitor_policy.proposed.fvRsBDToNetflowMonitorPol.attributes.tnNetflowMonitorPolName == "ansible_netflow_monitor_policy" + - nm_bd_to_netflow_monitor_policy is changed + - nm_bd_to_netflow_monitor_policy.current.0.fvRsBDToNetflowMonitorPol.attributes.dn == "uni/tn-ansible_test/BD-anstest/rsBDToNetflowMonitorPol-[ansible_netflow_monitor_policy]-ipv4" + - nm_bd_to_netflow_monitor_policy.current.0.fvRsBDToNetflowMonitorPol.attributes.tnNetflowMonitorPolName == "ansible_netflow_monitor_policy" + - bd_to_netflow_monitor_policy_idempotency is not changed + - bd_to_netflow_monitor_policy_idempotency.current == bd_to_netflow_monitor_policy_idempotency.previous + - bd_to_netflow_monitor_policy_idempotency.sent == {} + - nm_bd_to_netflow_monitor_policy_2 is changed + - nm_bd_to_netflow_monitor_policy_2.current.0.fvRsBDToNetflowMonitorPol.attributes.dn == "uni/tn-ansible_test/BD-anstest_2/rsBDToNetflowMonitorPol-[ansible_netflow_monitor_policy_2]-ipv6" + - nm_bd_to_netflow_monitor_policy_2.current.0.fvRsBDToNetflowMonitorPol.attributes.tnNetflowMonitorPolName == "ansible_netflow_monitor_policy_2" + + - name: Query all bds bound to netflow monitor policies + cisco.aci.aci_bd_to_netflow_monitor_policy: + <<: *aci_tenant_present + state: query + output_level: debug + register: query_all_bd_to_netflow_monitor_policy + + - name: Query first bd bound to first netflow monitor policy + cisco.aci.aci_bd_to_netflow_monitor_policy: + <<: *aci_bd_to_netflow_monitor_policy_present + state: query + output_level: debug + register: query_first_bd_to_netflow_monitor_policy + + - name: Asserts query tasks + ansible.builtin.assert: + that: + - query_all_bd_to_netflow_monitor_policy is not changed + - '"fvRsBDToNetflowMonitorPol" in query_all_bd_to_netflow_monitor_policy.filter_string' + - query_all_bd_to_netflow_monitor_policy.current.0.fvTenant.children | length >= 2 + - query_all_bd_to_netflow_monitor_policy.current.0.fvTenant.children.0.fvBD.attributes.name == "anstest_2" + - query_all_bd_to_netflow_monitor_policy.current.0.fvTenant.children.0.fvBD.children.0.fvRsBDToNetflowMonitorPol.attributes.tRn == "monitorpol-ansible_netflow_monitor_policy_2" + - query_all_bd_to_netflow_monitor_policy.current.0.fvTenant.children.1.fvBD.attributes.name == "anstest" + - query_all_bd_to_netflow_monitor_policy.current.0.fvTenant.children.1.fvBD.children.0.fvRsBDToNetflowMonitorPol.attributes.tRn == "monitorpol-ansible_netflow_monitor_policy" + - query_first_bd_to_netflow_monitor_policy is not changed + - '"tn-ansible_test/BD-anstest/rsBDToNetflowMonitorPol-[ansible_netflow_monitor_policy]-ipv4.json" in query_first_bd_to_netflow_monitor_policy.url' + + - name: Unbind bd to netflow monitor policy - first binding (check_mode) + cisco.aci.aci_bd_to_netflow_monitor_policy: + <<: *aci_bd_to_netflow_monitor_policy_present + state: absent + check_mode: true + register: cm_unbind_bd_to_netflow_monitor_policy + + - name: Unbind bd to netflow_monitor_policy - first binding (normal_mode) + cisco.aci.aci_bd_to_netflow_monitor_policy: + <<: *aci_bd_to_netflow_monitor_policy_present + state: absent + register: nm_unbind_bd_to_netflow_monitor_policy + + - name: Unbind bd to netflow_monitor_policy again - testing idempotency + cisco.aci.aci_bd_to_netflow_monitor_policy: + <<: *aci_bd_to_netflow_monitor_policy_present + state: absent + register: unbind_bd_to_netflow_monitor_policy_idempotency + + - name: Unbind bd to netflow_monitor_policy - second binding + cisco.aci.aci_bd_to_netflow_monitor_policy: + <<: *aci_bd_to_netflow_monitor_policy_present_2 + state: absent + register: nm_unbind_bd_to_netflow_monitor_policy_2 + + - name: Asserts for deletion tasks + ansible.builtin.assert: + that: + - cm_unbind_bd_to_netflow_monitor_policy is changed + - cm_unbind_bd_to_netflow_monitor_policy.current == cm_unbind_bd_to_netflow_monitor_policy.previous + - cm_unbind_bd_to_netflow_monitor_policy.proposed == {} + - nm_unbind_bd_to_netflow_monitor_policy is changed + - nm_unbind_bd_to_netflow_monitor_policy.previous != [] + - nm_unbind_bd_to_netflow_monitor_policy.proposed == {} + - nm_unbind_bd_to_netflow_monitor_policy.current == [] + - nm_unbind_bd_to_netflow_monitor_policy.previous == cm_unbind_bd_to_netflow_monitor_policy.current + - unbind_bd_to_netflow_monitor_policy_idempotency is not changed + - unbind_bd_to_netflow_monitor_policy_idempotency.proposed == {} + - unbind_bd_to_netflow_monitor_policy_idempotency.current == [] + - unbind_bd_to_netflow_monitor_policy_idempotency.previous == [] + - nm_unbind_bd_to_netflow_monitor_policy_2 is changed + - nm_unbind_bd_to_netflow_monitor_policy_2.previous != [] + - nm_unbind_bd_to_netflow_monitor_policy_2.current == [] + + - name: Delete tenant - cleanup before ending tests + cisco.aci.aci_tenant: + <<: *aci_tenant_present + state: absent diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_bfd_multihop_node_policy/aliases b/ansible_collections/cisco/aci/tests/integration/targets/aci_bfd_multihop_node_policy/aliases new file mode 100644 index 000000000..209b793f9 --- /dev/null +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_bfd_multihop_node_policy/aliases @@ -0,0 +1,2 @@ +# No ACI simulator yet, so not enabled +# unsupported diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_bfd_multihop_node_policy/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_bfd_multihop_node_policy/tasks/main.yml new file mode 100644 index 000000000..99f853680 --- /dev/null +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_bfd_multihop_node_policy/tasks/main.yml @@ -0,0 +1,245 @@ +# Test code for the ACI modules +# Copyright: (c) 2023, Anvitha Jain (@anvjain) + +# 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 APIC host, ACI username and ACI password + fail: + msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' + when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined + +- name: Set vars + ansible.builtin.set_fact: + aci_info: &aci_info + host: "{{ aci_hostname }}" + username: "{{ aci_username }}" + password: "{{ aci_password }}" + validate_certs: '{{ aci_validate_certs | default(false) }}' + use_ssl: '{{ aci_use_ssl | default(true) }}' + use_proxy: '{{ aci_use_proxy | default(true) }}' + output_level: debug + +- name: Query system information + cisco.aci.aci_system: + <<: *aci_info + id: 1 + state: query + register: version + +- name: Execute tasks only for non-cloud sites + when: version.current.0.topSystem.attributes.version is version('5.2', '>=') # This condition will execute only when APIC version >= 5.2 + block: # block specifies execution of tasks within, based on conditions + + # CLEAN ENVIRONMENT + - name: Remove the ansible_tenant + aci_tenant: + <<: *aci_info + tenant: ansible_tenant + state: absent + + - name: Add a new tenant + aci_tenant: + <<: *aci_info + tenant: ansible_tenant + description: Ansible tenant + state: present + + # CREATE BFD Multihop Node policy + - name: Add a new BFD Multihop Node policy - check mode + cisco.aci.aci_bfd_multihop_node_policy: &add_bfd_multihop_node_pol + <<: *aci_info + tenant: ansible_tenant + name: ansible_bfd_multihop_node_policy + description: Ansible BFD Multihop Node Policy + state: present + check_mode: true + register: cm_add_bfd_multihop_node_pol + + - name: Add a new BFD Multihop Node policy - normal mode + cisco.aci.aci_bfd_multihop_node_policy: + <<: *add_bfd_multihop_node_pol + state: present + register: nm_add_bfd_multihop_node_pol + + - name: Verify BFD Multihop Node Policy creation + assert: + that: + - cm_add_bfd_multihop_node_pol is changed + - nm_add_bfd_multihop_node_pol is changed + - cm_add_bfd_multihop_node_pol.previous == nm_add_bfd_multihop_node_pol.previous == [] + - cm_add_bfd_multihop_node_pol.proposed.bfdMhNodePol.attributes.dn == nm_add_bfd_multihop_node_pol.current.0.bfdMhNodePol.attributes.dn == "uni/tn-ansible_tenant/bfdMhNodePol-ansible_bfd_multihop_node_policy" + - cm_add_bfd_multihop_node_pol.proposed.bfdMhNodePol.attributes.name == nm_add_bfd_multihop_node_pol.current.0.bfdMhNodePol.attributes.name == "ansible_bfd_multihop_node_policy" + - cm_add_bfd_multihop_node_pol.proposed.bfdMhNodePol.attributes.descr == nm_add_bfd_multihop_node_pol.current.0.bfdMhNodePol.attributes.descr == "Ansible BFD Multihop Node Policy" + + - name: Add a new BFD Multihop Node policy again - idempotency + cisco.aci.aci_bfd_multihop_node_policy: + <<: *add_bfd_multihop_node_pol + state: present + register: add_bfd_multihop_node_pol_again + + - name: Verify BFD Multihop Node Policy creation again - idempotency + assert: + that: + - add_bfd_multihop_node_pol_again is not changed + - add_bfd_multihop_node_pol_again.previous != [] + - add_bfd_multihop_node_pol_again.current | length == 1 + - add_bfd_multihop_node_pol_again.previous | length == 1 + + - name: Modify a BFD Multihop Node policy + cisco.aci.aci_bfd_multihop_node_policy: + <<: *add_bfd_multihop_node_pol + admin_state: disabled + detection_multiplier: 5 + min_transmit_interval: 270 + min_receive_interval: 500 + state: present + register: update_bfd_multihop_node_pol + + - name: Verify modifying BFD Multihop Node Policy + assert: + that: + - update_bfd_multihop_node_pol is changed + - update_bfd_multihop_node_pol.previous != update_bfd_multihop_node_pol.current + - update_bfd_multihop_node_pol.current.0.bfdMhNodePol.attributes.dn == "uni/tn-ansible_tenant/bfdMhNodePol-ansible_bfd_multihop_node_policy" + - update_bfd_multihop_node_pol.current.0.bfdMhNodePol.attributes.name == "ansible_bfd_multihop_node_policy" + - update_bfd_multihop_node_pol.current.0.bfdMhNodePol.attributes.descr == "Ansible BFD Multihop Node Policy" + - update_bfd_multihop_node_pol.current.0.bfdMhNodePol.attributes.adminSt == "disabled" + - update_bfd_multihop_node_pol.current.0.bfdMhNodePol.attributes.detectMult == "5" + - update_bfd_multihop_node_pol.current.0.bfdMhNodePol.attributes.minRxIntvl == "500" + - update_bfd_multihop_node_pol.current.0.bfdMhNodePol.attributes.minTxIntvl == "270" + + # Added another BFD Multihop Node policy + - name: Add a new BFD Multihop Node policy - normal mode + cisco.aci.aci_bfd_multihop_node_policy: + <<: *add_bfd_multihop_node_pol + name: ansible_bfd_multihop_node_policy_2 + state: present + register: add_bfd_multihop_node_pol_2 + + - name: Verify BFD Multihop Node Policy creation + assert: + that: + - add_bfd_multihop_node_pol_2 is changed + - add_bfd_multihop_node_pol_2.previous == [] + - add_bfd_multihop_node_pol_2.current.0.bfdMhNodePol.attributes.dn == "uni/tn-ansible_tenant/bfdMhNodePol-ansible_bfd_multihop_node_policy_2" + - add_bfd_multihop_node_pol_2.current.0.bfdMhNodePol.attributes.name == "ansible_bfd_multihop_node_policy_2" + - add_bfd_multihop_node_pol_2.current.0.bfdMhNodePol.attributes.descr == "Ansible BFD Multihop Node Policy" + - add_bfd_multihop_node_pol_2.current.0.bfdMhNodePol.attributes.adminSt == "enabled" + - add_bfd_multihop_node_pol_2.current.0.bfdMhNodePol.attributes.detectMult == "3" + - add_bfd_multihop_node_pol_2.current.0.bfdMhNodePol.attributes.minRxIntvl == "250" + - add_bfd_multihop_node_pol_2.current.0.bfdMhNodePol.attributes.minTxIntvl == "250" + + - name: Query all BFD Multihop Node policies in a specific tenant + cisco.aci.aci_bfd_multihop_node_policy: + <<: *aci_info + tenant: ansible_tenant + state: query + register: query_all_result + + - name: Verify querying all BFD Multihop Node Policies + assert: + that: + - query_all_result is not changed + - query_all_result.current.0.fvTenant.children | length == 2 + - query_all_result.current.0.fvTenant.children[0].bfdMhNodePol.attributes.name == "ansible_bfd_multihop_node_policy_2" + - query_all_result.current.0.fvTenant.children[1].bfdMhNodePol.attributes.name == "ansible_bfd_multihop_node_policy" + + - name: Query 'ansible_bfd_multihop_node_policy' BFD Multihop Node policies in a specific tenant + cisco.aci.aci_bfd_multihop_node_policy: + <<: *aci_info + tenant: ansible_tenant + name: ansible_bfd_multihop_node_policy + state: query + register: query_result + + - name: Verify querying'ansible_bfd_multihop_node_policy BFD' Multihop Node Policy + assert: + that: + - query_result is not changed + - query_result.current.0.bfdMhNodePol.attributes.dn == "uni/tn-ansible_tenant/bfdMhNodePol-ansible_bfd_multihop_node_policy" + - query_result.current.0.bfdMhNodePol.attributes.name == "ansible_bfd_multihop_node_policy" + + - name: Remove a BFD Multihop Node policy - check mode + cisco.aci.aci_bfd_multihop_node_policy: + <<: *aci_info + tenant: ansible_tenant + name: ansible_bfd_multihop_node_policy + state: absent + check_mode: true + register: cm_remove_bfd_multihop_node_pol + + - name: Remove a BFD Multihop Node policy - normal mode + cisco.aci.aci_bfd_multihop_node_policy: + <<: *aci_info + tenant: ansible_tenant + name: ansible_bfd_multihop_node_policy + state: absent + register: nm_remove_bfd_multihop_node_pol + + - name: Remove a BFD Multihop Node policy again + cisco.aci.aci_bfd_multihop_node_policy: + <<: *aci_info + tenant: ansible_tenant + name: ansible_bfd_multihop_node_policy + state: absent + register: remove_bfd_multihop_node_pol_again + + - name: Verify removing BFD Multihop Node Policies + assert: + that: + - nm_remove_bfd_multihop_node_pol is changed + - cm_remove_bfd_multihop_node_pol is changed + - cm_remove_bfd_multihop_node_pol.proposed == {} + - nm_remove_bfd_multihop_node_pol.previous != [] + - remove_bfd_multihop_node_pol_again is not changed + - remove_bfd_multihop_node_pol_again.current == nm_remove_bfd_multihop_node_pol.current == [] + +# Validating out of rage parameters. + +# Added BFD Multihop Node policy with out of the range detection_multiplier + - name: Add a new BFD Multihop Node policy - out of the range detection_multiplier + cisco.aci.aci_bfd_multihop_node_policy: + <<: *add_bfd_multihop_node_pol + name: ansible_bfd_multihop_node_policy_3 + detection_multiplier: 256 + state: present + ignore_errors: true + register: add_bfd_multihop_node_pol_3 + + - name: Verify BFD Multihop Node Policy creation + assert: + that: + - add_bfd_multihop_node_pol_3 is not changed + - add_bfd_multihop_node_pol_3.msg == "The \"detection_multiplier\" must be a value between 1 and 50" + +# Added BFD Multihop Node policy with out of the range min_transmit_interval + - name: Add a new BFD Multihop Node policy - out of the range min_transmit_interval + cisco.aci.aci_bfd_multihop_node_policy: + <<: *add_bfd_multihop_node_pol + name: ansible_bfd_multihop_node_policy_3 + min_transmit_interval: 50 + state: present + ignore_errors: true + register: add_bfd_multihop_node_pol_3 + + - name: Verify BFD Multihop Node Policy creation + assert: + that: + - add_bfd_multihop_node_pol_3 is not changed + - add_bfd_multihop_node_pol_3.msg == "The \"min_transmit_interval\" must be a value between 250 and 999" + +# Added BFD Multihop Node policy with out of the range min_receive_interval + - name: Add a new BFD Multihop Node policy - out of the range min_receive_interval + cisco.aci.aci_bfd_multihop_node_policy: + <<: *add_bfd_multihop_node_pol + name: ansible_bfd_multihop_node_policy_3 + min_receive_interval: 1000 + state: present + ignore_errors: true + register: add_bfd_multihop_node_pol_3 + + - name: Verify BFD Multihop Node Policy creation + assert: + that: + - add_bfd_multihop_node_pol_3 is not changed + - add_bfd_multihop_node_pol_3.msg == "The \"min_receive_interval\" must be a value between 250 and 999" diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_bgp_address_family_context_policy/aliases b/ansible_collections/cisco/aci/tests/integration/targets/aci_bgp_address_family_context_policy/aliases new file mode 100644 index 000000000..209b793f9 --- /dev/null +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_bgp_address_family_context_policy/aliases @@ -0,0 +1,2 @@ +# No ACI simulator yet, so not enabled +# unsupported diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_bgp_address_family_context_policy/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_bgp_address_family_context_policy/tasks/main.yml new file mode 100644 index 000000000..17164af12 --- /dev/null +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_bgp_address_family_context_policy/tasks/main.yml @@ -0,0 +1,244 @@ +# Test code for the ACI modules +# Copyright: (c) 2023, Gaspard Micol (@gmicol) <gmicol@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 APIC host, ACI username and ACI password + ansible.builtin.fail: + msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' + when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined + +- name: Set vars + ansible.builtin.set_fact: + aci_info: &aci_info + host: "{{ aci_hostname }}" + username: "{{ aci_username }}" + password: "{{ aci_password }}" + validate_certs: '{{ aci_validate_certs | default(false) }}' + use_ssl: '{{ aci_use_ssl | default(true) }}' + use_proxy: '{{ aci_use_proxy | default(true) }}' + output_level: debug + +# CLEAN ENVIRONMENT +- name: Remove the ansible_tenant + cisco.aci.aci_tenant: &aci_tenant_absent + <<: *aci_info + tenant: ansible_tenant + state: absent + +- name: Verify Cloud and Non-Cloud Sites in use. + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + +- name: Execute tasks only for non-cloud sites + when: query_cloud.current == [] # This condition will execute only non-cloud sites + block: # block specifies execution of tasks within, based on conditions + - name: Add a new tenant + cisco.aci.aci_tenant: &aci_tenant_present + <<: *aci_info + tenant: ansible_tenant + description: Ansible tenant + state: present + + - name: Add a BGP address family context policy (check_mode) + cisco.aci.aci_bgp_address_family_context_policy: &aci_bgp_address_family_context_policy_present + <<: *aci_info + tenant: ansible_tenant + address_family_context_policy: ansible_bgp_address_family_context_policy_1 + description: BGP address family context policy 1 for ansible_tenant tenant + host_route_leak: true + ebgp_distance: 40 + ibgp_distance: 210 + local_distance: 215 + ebgp_max_ecmp: 32 + ibgp_max_ecmp: 32 + state: present + check_mode: true + register: cm_add_bgp_address_family_context_policy + + - name: Add a BGP address family context policy (normal_mode) + cisco.aci.aci_bgp_address_family_context_policy: + <<: *aci_bgp_address_family_context_policy_present + register: nm_add_bgp_address_family_context_policy + + - name: Add the first BGP address family context policy again - testing idempotency + cisco.aci.aci_bgp_address_family_context_policy: + <<: *aci_bgp_address_family_context_policy_present + register: nm_add_bgp_address_family_context_policy_idempotency + + - name: Add Local max ECMP to BGP address family context policy - APIC version >= 5.0 + when: version.current.0.topSystem.attributes.version is version('5.0', '>=') + cisco.aci.aci_bgp_address_family_context_policy: &aci_bgp_address_family_context_policy_present_maxLocalEcmp + <<: *aci_bgp_address_family_context_policy_present + local_max_ecmp: 1 + register: nm_add_maxLocalEcmp_bgp_address_family_context_policy + + - name: Add Path Capability to BGP address family context policy - APIC version >= 6.0(2h) + when: version.current.0.topSystem.attributes.version is version('6.0(2h)', '>=') + cisco.aci.aci_bgp_address_family_context_policy: &aci_bgp_address_family_context_policy_present_bgpCtxAddlPathPol + <<: *aci_bgp_address_family_context_policy_present_maxLocalEcmp + bgp_add_path_capability: receive + register: nm_add_path_capability_bgp_address_family_context_policy + + - name: Add a second BGP address family context policy (normal_mode) + cisco.aci.aci_bgp_address_family_context_policy: + <<: *aci_info + tenant: ansible_tenant + address_family_context_policy: ansible_bgp_address_family_context_policy_2 + description: BGP address family context policy 2 for ansible_tenant tenant + state: present + register: nm_add_bgp_address_family_context_policy_2 + + - name: Asserts for BGP address family context policys creation tasks + ansible.builtin.assert: + that: + - cm_add_bgp_address_family_context_policy is changed + - cm_add_bgp_address_family_context_policy.previous == [] + - cm_add_bgp_address_family_context_policy.current == [] + - nm_add_bgp_address_family_context_policy is changed + - nm_add_bgp_address_family_context_policy.current.0.bgpCtxAfPol.attributes.name == "ansible_bgp_address_family_context_policy_1" + - nm_add_bgp_address_family_context_policy.current.0.bgpCtxAfPol.attributes.eDist == "40" + - nm_add_bgp_address_family_context_policy.current.0.bgpCtxAfPol.attributes.iDist == "210" + - nm_add_bgp_address_family_context_policy.current.0.bgpCtxAfPol.attributes.localDist == "215" + - nm_add_bgp_address_family_context_policy.current.0.bgpCtxAfPol.attributes.maxEcmp == "32" + - nm_add_bgp_address_family_context_policy.current.0.bgpCtxAfPol.attributes.maxEcmpIbgp == "32" + - nm_add_bgp_address_family_context_policy.current.0.bgpCtxAfPol.attributes.ctrl == "host-rt-leak" + - nm_add_bgp_address_family_context_policy_idempotency is not changed + - nm_add_bgp_address_family_context_policy_2 is changed + - nm_add_bgp_address_family_context_policy_2.previous == [] + - nm_add_bgp_address_family_context_policy_2.current.0.bgpCtxAfPol.attributes.name == "ansible_bgp_address_family_context_policy_2" + - nm_add_bgp_address_family_context_policy_2.current.0.bgpCtxAfPol.attributes.eDist == "20" + - nm_add_bgp_address_family_context_policy_2.current.0.bgpCtxAfPol.attributes.iDist == "200" + - nm_add_bgp_address_family_context_policy_2.current.0.bgpCtxAfPol.attributes.localDist == "220" + - nm_add_bgp_address_family_context_policy_2.current.0.bgpCtxAfPol.attributes.maxEcmp == "16" + - nm_add_bgp_address_family_context_policy_2.current.0.bgpCtxAfPol.attributes.maxEcmpIbgp == "16" + - nm_add_bgp_address_family_context_policy_2.current.0.bgpCtxAfPol.attributes.ctrl == "" + + - name: Asserts adding Local max ECMP for BGP address family context policys creation tasks - APIC version >= 5.0 + when: version.current.0.topSystem.attributes.version is version('5.0', '>=') + ansible.builtin.assert: + that: + - nm_add_maxLocalEcmp_bgp_address_family_context_policy is changed + - nm_add_maxLocalEcmp_bgp_address_family_context_policy.current.0.bgpCtxAfPol.attributes.maxLocalEcmp == "1" + - nm_add_bgp_address_family_context_policy_2.current.0.bgpCtxAfPol.attributes.maxLocalEcmp == "0" + + - name: Asserts adding path capability for BGP address family context policys creation tasks - APIC version >= 6.0(2h) + when: version.current.0.topSystem.attributes.version is version('6.0(2h)', '>=') + ansible.builtin.assert: + that: + - nm_add_path_capability_bgp_address_family_context_policy is changed + - nm_add_path_capability_bgp_address_family_context_policy.current.0.bgpCtxAfPol.children.0.bgpCtxAddlPathPol.attributes.capability == "receive" + + - name: Query all BGP address family context policies + cisco.aci.aci_bgp_address_family_context_policy: + <<: *aci_info + state: query + register: query_all_bgp_address_family_context_policy + + - name: Query ansible_bgp_address_family_context_policy_1 + cisco.aci.aci_bgp_address_family_context_policy: + <<: *aci_bgp_address_family_context_policy_present + state: query + register: query_ansible_bgp_address_family_context_policy_1 + + - name: Asserts query tasks + ansible.builtin.assert: + that: + - query_all_bgp_address_family_context_policy is not changed + - query_all_bgp_address_family_context_policy.current|length >= 2 + - query_ansible_bgp_address_family_context_policy_1 is not changed + - query_ansible_bgp_address_family_context_policy_1.current.0.bgpCtxAfPol.attributes.name == "ansible_bgp_address_family_context_policy_1" + - query_ansible_bgp_address_family_context_policy_1.current.0.bgpCtxAfPol.attributes.eDist == "40" + - query_ansible_bgp_address_family_context_policy_1.current.0.bgpCtxAfPol.attributes.iDist == "210" + - query_ansible_bgp_address_family_context_policy_1.current.0.bgpCtxAfPol.attributes.localDist == "215" + - query_ansible_bgp_address_family_context_policy_1.current.0.bgpCtxAfPol.attributes.maxEcmp == "32" + - query_ansible_bgp_address_family_context_policy_1.current.0.bgpCtxAfPol.attributes.maxEcmpIbgp == "32" + - query_ansible_bgp_address_family_context_policy_1.current.0.bgpCtxAfPol.attributes.ctrl == "host-rt-leak" + + - name: Query ansible_bgp_address_family_context_policy_1 with updated Local Max ECMP - APIC version >= 5.0 + when: version.current.0.topSystem.attributes.version is version('5.0', '>=') + cisco.aci.aci_bgp_address_family_context_policy: + <<: *aci_bgp_address_family_context_policy_present_maxLocalEcmp + state: query + register: query_ansible_bgp_address_family_context_policy_maxLocalEcmp + + - name: Asserts path capability - APIC version >= 5.0 + when: version.current.0.topSystem.attributes.version is version('5.0', '>=') + ansible.builtin.assert: + that: + - query_ansible_bgp_address_family_context_policy_maxLocalEcmp.current.0.bgpCtxAfPol.attributes.maxLocalEcmp == "1" + + - name: Query ansible_bgp_address_family_context_policy_1 with added path capability - APIC version >= 6.0(2h) + when: version.current.0.topSystem.attributes.version is version('6.0(2h)', '>=') + cisco.aci.aci_bgp_address_family_context_policy: + <<: *aci_bgp_address_family_context_policy_present_bgpCtxAddlPathPol + state: query + register: query_ansible_bgp_address_family_context_policy_bgpCtxAddlPathPol + + - name: Asserts path capability - APIC version >= 6.0(2h) + when: version.current.0.topSystem.attributes.version is version('6.0(2h)', '>=') + ansible.builtin.assert: + that: + - query_ansible_bgp_address_family_context_policy_bgpCtxAddlPathPol.current.0.bgpCtxAfPol.children.0.bgpCtxAddlPathPol.attributes.capability == "receive" + + - name: Remove children from BGP address family context policy (check_mode) - APIC version >= 6.0(2h) + when: version.current.0.topSystem.attributes.version is version('6.0(2h)', '>=') + cisco.aci.aci_bgp_address_family_context_policy: &bgp_address_family_context_policy_delet_children + <<: *aci_bgp_address_family_context_policy_present_bgpCtxAddlPathPol + bgp_add_path_capability: "" + check_mode: true + register: cm_remove_children_bgp_address_family_context_policy + + - name: Remove children from BGP address family context policy (normal_mode) - APIC version >= 6.0(2h) + when: version.current.0.topSystem.attributes.version is version('6.0(2h)', '>=') + cisco.aci.aci_bgp_address_family_context_policy: + <<: *bgp_address_family_context_policy_delet_children + register: nm_remove_children_bgp_address_family_context_policy + + - name: Remove children from BGP address family context policy (testing idempotency) - APIC version >= 6.0(2h) + when: version.current.0.topSystem.attributes.version is version('6.0(2h)', '>=') + cisco.aci.aci_bgp_address_family_context_policy: + <<: *bgp_address_family_context_policy_delet_children + register: nm_remove_children_bgp_address_family_context_policy_idempotency + + - name: Asserts for children removal tasks for the first address family context policy - APIC version >= 6.0(2h) + when: version.current.0.topSystem.attributes.version is version('6.0(2h)', '>=') + ansible.builtin.assert: + that: + - cm_remove_children_bgp_address_family_context_policy is changed + - cm_remove_children_bgp_address_family_context_policy.current == cm_remove_children_bgp_address_family_context_policy.previous + - nm_remove_children_bgp_address_family_context_policy is changed + - nm_remove_children_bgp_address_family_context_policy.current.0.bgpCtxAfPol | length == 1 + - nm_remove_children_bgp_address_family_context_policy_idempotency is not changed + + - name: Remove BGP address family context policy (check_mode) + cisco.aci.aci_bgp_address_family_context_policy: &bgp_address_family_context_policy_absent + <<: *aci_bgp_address_family_context_policy_present + state: absent + check_mode: true + register: cm_remove_bgp_address_family_context_policy + + - name: Remove BGP address family context policy (normal_mode) + cisco.aci.aci_bgp_address_family_context_policy: + <<: *bgp_address_family_context_policy_absent + register: nm_remove_bgp_address_family_context_policy + + - name: Remove BGP address family context policy - testing idempotency + cisco.aci.aci_bgp_address_family_context_policy: + <<: *bgp_address_family_context_policy_absent + register: nm_remove_bgp_address_family_context_policy_idempotency + + - name: Asserts deletion tasks + ansible.builtin.assert: + that: + - cm_remove_bgp_address_family_context_policy is changed + - cm_remove_bgp_address_family_context_policy.proposed == {} + - nm_remove_bgp_address_family_context_policy is changed + - nm_remove_bgp_address_family_context_policy.previous != [] + - nm_remove_bgp_address_family_context_policy.method == "DELETE" + - nm_remove_bgp_address_family_context_policy_idempotency is not changed + - nm_remove_bgp_address_family_context_policy_idempotency.previous == [] + + - name: Remove the ansible_tenant - cleanup before ending tests + cisco.aci.aci_tenant: + <<: *aci_tenant_present + state: absent diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_bgp_best_path_policy/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_bgp_best_path_policy/tasks/main.yml index d0eae2666..3c9176cd5 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_bgp_best_path_policy/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_bgp_best_path_policy/tasks/main.yml @@ -4,12 +4,12 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: "{{ aci_hostname }}" username: "{{ aci_username }}" @@ -21,26 +21,26 @@ # CLEAN ENVIRONMENT - name: Remove the ansible_tenant - aci_tenant: &aci_tenant_absent + cisco.aci.aci_tenant: &aci_tenant_absent <<: *aci_info tenant: ansible_tenant state: absent - name: Verify Cloud and Non-Cloud Sites in use. - include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml - name: Execute tasks only for non-cloud sites when: query_cloud.current == [] # This condition will execute only non-cloud sites block: # block specifies execution of tasks within, based on conditions - name: Add a new tenant - aci_tenant: &aci_tenant_present + cisco.aci.aci_tenant: &aci_tenant_present <<: *aci_info tenant: ansible_tenant description: Ansible tenant state: present - name: Add a BGP best path policy (check_mode) - aci_bgp_best_path_policy: &aci_bgp_best_path_policy_present + cisco.aci.aci_bgp_best_path_policy: &aci_bgp_best_path_policy_present <<: *aci_info tenant: ansible_tenant bgp_best_path_policy: ansible_bgp_best_path_policy_1 @@ -51,17 +51,17 @@ register: cm_add_bgp_best_path_policy - name: Add a BGP best path policy (normal_mode) - aci_bgp_best_path_policy: + cisco.aci.aci_bgp_best_path_policy: <<: *aci_bgp_best_path_policy_present register: nm_add_bgp_best_path_policy - name: Add the first BGP best path policy again - testing idempotency - aci_bgp_best_path_policy: + cisco.aci.aci_bgp_best_path_policy: <<: *aci_bgp_best_path_policy_present register: nm_add_bgp_best_path_policy_idempotency - name: Add a second BGP best path policy (normal_mode) - aci_bgp_best_path_policy: + cisco.aci.aci_bgp_best_path_policy: <<: *aci_info tenant: ansible_tenant bgp_best_path_policy: ansible_bgp_best_path_policy_2 @@ -71,7 +71,7 @@ register: nm_add_bgp_best_path_policy_2 - name: Asserts for BGP best path policys creation tasks - assert: + ansible.builtin.assert: that: - cm_add_bgp_best_path_policy is changed - cm_add_bgp_best_path_policy.previous == [] @@ -86,19 +86,19 @@ - nm_add_bgp_best_path_policy_2.current.0.bgpBestPathCtrlPol.attributes.ctrl == "" - name: Query all BGP best path policies - aci_bgp_best_path_policy: + cisco.aci.aci_bgp_best_path_policy: <<: *aci_info state: query register: query_all_bgp_best_path_policy - name: Query ansible_bgp_best_path_policy_1 - aci_bgp_best_path_policy: + cisco.aci.aci_bgp_best_path_policy: <<: *aci_bgp_best_path_policy_present state: query register: query_ansible_bgp_best_path_policy_1 - name: Asserts query tasks - assert: + ansible.builtin.assert: that: - query_all_bgp_best_path_policy is not changed - query_all_bgp_best_path_policy.current|length >= 2 @@ -107,24 +107,24 @@ - query_ansible_bgp_best_path_policy_1.current.0.bgpBestPathCtrlPol.attributes.ctrl == "asPathMultipathRelax" - name: Remove BGP best path policy (check_mode) - aci_bgp_best_path_policy: &bgp_best_path_policy_absent + cisco.aci.aci_bgp_best_path_policy: &bgp_best_path_policy_absent <<: *aci_bgp_best_path_policy_present state: absent check_mode: true register: cm_remove_bgp_best_path_policy - name: Remove BGP best path policy (normal_mode) - aci_bgp_best_path_policy: + cisco.aci.aci_bgp_best_path_policy: <<: *bgp_best_path_policy_absent register: nm_remove_bgp_best_path_policy - name: Remove BGP best path policy - testing idempotency - aci_bgp_best_path_policy: + cisco.aci.aci_bgp_best_path_policy: <<: *bgp_best_path_policy_absent register: nm_remove_bgp_best_path_policy_idempotency - name: Asserts deletion tasks - assert: + ansible.builtin.assert: that: - cm_remove_bgp_best_path_policy is changed - cm_remove_bgp_best_path_policy.proposed == {} @@ -135,6 +135,6 @@ - nm_remove_bgp_best_path_policy_idempotency.previous == [] - name: Remove the ansible_tenant - cleanup before ending tests - aci_tenant: + cisco.aci.aci_tenant: <<: *aci_tenant_present state: absent
\ No newline at end of file diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_bgp_peer_prefix_policy/aliases b/ansible_collections/cisco/aci/tests/integration/targets/aci_bgp_peer_prefix_policy/aliases new file mode 100644 index 000000000..209b793f9 --- /dev/null +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_bgp_peer_prefix_policy/aliases @@ -0,0 +1,2 @@ +# No ACI simulator yet, so not enabled +# unsupported diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_bgp_peer_prefix_policy/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_bgp_peer_prefix_policy/tasks/main.yml new file mode 100644 index 000000000..a0a3c2b15 --- /dev/null +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_bgp_peer_prefix_policy/tasks/main.yml @@ -0,0 +1,151 @@ +# Test code for the ACI modules +# Copyright: (c) 2023, Gaspard Micol (@gmicol) <gmicol@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 APIC host, ACI username and ACI password + ansible.builtin.fail: + msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' + when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined + +- name: Set vars + ansible.builtin.set_fact: + aci_info: &aci_info + host: "{{ aci_hostname }}" + username: "{{ aci_username }}" + password: "{{ aci_password }}" + validate_certs: '{{ aci_validate_certs | default(false) }}' + use_ssl: '{{ aci_use_ssl | default(true) }}' + use_proxy: '{{ aci_use_proxy | default(true) }}' + output_level: debug + +# CLEAN ENVIRONMENT +- name: Remove the ansible_tenant + cisco.aci.aci_tenant: &aci_tenant_absent + <<: *aci_info + tenant: ansible_tenant + state: absent + +- name: Verify Cloud and Non-Cloud Sites in use. + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + +- name: Execute tasks only for non-cloud sites + when: query_cloud.current == [] # This condition will execute only non-cloud sites + block: # block specifies execution of tasks within, based on conditions + - name: Add a new tenant + cisco.aci.aci_tenant: &aci_tenant_present + <<: *aci_info + tenant: ansible_tenant + description: Ansible tenant + state: present + + - name: Add a BGP peer prefix policy (check_mode) + cisco.aci.aci_bgp_peer_prefix_policy: &aci_bgp_peer_prefix_policy_present + <<: *aci_info + tenant: ansible_tenant + peer_prefix_policy: ansible_bgp_peer_prefix_policy_1 + description: BGP peer prefix policy 1 for ansible_tenant tenant + action: restart + restart_time: 10 + max_prefix: 10000 + threshold: 80 + state: present + check_mode: true + register: cm_add_bgp_peer_prefix_policy + + - name: Add a BGP peer prefix policy (normal_mode) + cisco.aci.aci_bgp_peer_prefix_policy: + <<: *aci_bgp_peer_prefix_policy_present + register: nm_add_bgp_peer_prefix_policy + + - name: Add the first BGP peer prefix policy again - testing idempotency + cisco.aci.aci_bgp_peer_prefix_policy: + <<: *aci_bgp_peer_prefix_policy_present + register: nm_add_bgp_peer_prefix_policy_idempotency + + - name: Add a second BGP peer prefix policy (normal_mode) + cisco.aci.aci_bgp_peer_prefix_policy: + <<: *aci_info + tenant: ansible_tenant + peer_prefix_policy: ansible_bgp_peer_prefix_policy_2 + description: BGP peer prefix policy 2 for ansible_tenant tenant + state: present + register: nm_add_bgp_peer_prefix_policy_2 + + - name: Asserts for BGP peer prefix policys creation tasks + ansible.builtin.assert: + that: + - cm_add_bgp_peer_prefix_policy is changed + - cm_add_bgp_peer_prefix_policy.previous == [] + - cm_add_bgp_peer_prefix_policy.current == [] + - nm_add_bgp_peer_prefix_policy is changed + - nm_add_bgp_peer_prefix_policy.current.0.bgpPeerPfxPol.attributes.name == "ansible_bgp_peer_prefix_policy_1" + - nm_add_bgp_peer_prefix_policy.current.0.bgpPeerPfxPol.attributes.action == "restart" + - nm_add_bgp_peer_prefix_policy.current.0.bgpPeerPfxPol.attributes.maxPfx == "10000" + - nm_add_bgp_peer_prefix_policy.current.0.bgpPeerPfxPol.attributes.restartTime == "10" + - nm_add_bgp_peer_prefix_policy.current.0.bgpPeerPfxPol.attributes.thresh == "80" + - nm_add_bgp_peer_prefix_policy_idempotency is not changed + - nm_add_bgp_peer_prefix_policy_2 is changed + - nm_add_bgp_peer_prefix_policy_2.previous == [] + - nm_add_bgp_peer_prefix_policy_2.current.0.bgpPeerPfxPol.attributes.name == "ansible_bgp_peer_prefix_policy_2" + - nm_add_bgp_peer_prefix_policy_2.current.0.bgpPeerPfxPol.attributes.action == "reject" + - nm_add_bgp_peer_prefix_policy_2.current.0.bgpPeerPfxPol.attributes.maxPfx == "20000" + - nm_add_bgp_peer_prefix_policy_2.current.0.bgpPeerPfxPol.attributes.restartTime == "infinite" + - nm_add_bgp_peer_prefix_policy_2.current.0.bgpPeerPfxPol.attributes.thresh == "75" + + - name: Query all BGP peer prefix policies + cisco.aci.aci_bgp_peer_prefix_policy: + <<: *aci_info + state: query + register: query_all_bgp_peer_prefix_policy + + - name: Query ansible_bgp_peer_prefix_policy_1 + cisco.aci.aci_bgp_peer_prefix_policy: + <<: *aci_bgp_peer_prefix_policy_present + state: query + register: query_ansible_bgp_peer_prefix_policy_1 + + - name: Asserts query tasks + ansible.builtin.assert: + that: + - query_all_bgp_peer_prefix_policy is not changed + - query_all_bgp_peer_prefix_policy.current|length >= 2 + - query_ansible_bgp_peer_prefix_policy_1 is not changed + - query_ansible_bgp_peer_prefix_policy_1.current.0.bgpPeerPfxPol.attributes.name == "ansible_bgp_peer_prefix_policy_1" + - query_ansible_bgp_peer_prefix_policy_1.current.0.bgpPeerPfxPol.attributes.action == "restart" + - query_ansible_bgp_peer_prefix_policy_1.current.0.bgpPeerPfxPol.attributes.maxPfx == "10000" + - query_ansible_bgp_peer_prefix_policy_1.current.0.bgpPeerPfxPol.attributes.restartTime == "10" + - query_ansible_bgp_peer_prefix_policy_1.current.0.bgpPeerPfxPol.attributes.thresh == "80" + + - name: Remove BGP peer prefix policy (check_mode) + cisco.aci.aci_bgp_peer_prefix_policy: &bgp_peer_prefix_policy_absent + <<: *aci_bgp_peer_prefix_policy_present + state: absent + check_mode: true + register: cm_remove_bgp_peer_prefix_policy + + - name: Remove BGP peer prefix policy (normal_mode) + cisco.aci.aci_bgp_peer_prefix_policy: + <<: *bgp_peer_prefix_policy_absent + register: nm_remove_bgp_peer_prefix_policy + + - name: Remove BGP peer prefix policy - testing idempotency + cisco.aci.aci_bgp_peer_prefix_policy: + <<: *bgp_peer_prefix_policy_absent + register: nm_remove_bgp_peer_prefix_policy_idempotency + + - name: Asserts deletion tasks + ansible.builtin.assert: + that: + - cm_remove_bgp_peer_prefix_policy is changed + - cm_remove_bgp_peer_prefix_policy.proposed == {} + - nm_remove_bgp_peer_prefix_policy is changed + - nm_remove_bgp_peer_prefix_policy.previous != [] + - nm_remove_bgp_peer_prefix_policy.method == "DELETE" + - nm_remove_bgp_peer_prefix_policy_idempotency is not changed + - nm_remove_bgp_peer_prefix_policy_idempotency.previous == [] + + - name: Remove the ansible_tenant - cleanup before ending tests + cisco.aci.aci_tenant: + <<: *aci_tenant_present + state: absent diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_bgp_route_summarization_policy/aliases b/ansible_collections/cisco/aci/tests/integration/targets/aci_bgp_route_summarization_policy/aliases new file mode 100644 index 000000000..209b793f9 --- /dev/null +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_bgp_route_summarization_policy/aliases @@ -0,0 +1,2 @@ +# No ACI simulator yet, so not enabled +# unsupported diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_bgp_route_summarization_policy/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_bgp_route_summarization_policy/tasks/main.yml new file mode 100644 index 000000000..b43cc8330 --- /dev/null +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_bgp_route_summarization_policy/tasks/main.yml @@ -0,0 +1,255 @@ +# Test code for the ACI modules +# Copyright: (c) 2023, Gaspard Micol (@gmicol) <gmicol@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 APIC host, ACI username and ACI password + ansible.builtin.fail: + msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' + when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined + +- name: Set vars + ansible.builtin.set_fact: + aci_info: &aci_info + host: "{{ aci_hostname }}" + username: "{{ aci_username }}" + password: "{{ aci_password }}" + validate_certs: '{{ aci_validate_certs | default(false) }}' + use_ssl: '{{ aci_use_ssl | default(true) }}' + use_proxy: '{{ aci_use_proxy | default(true) }}' + output_level: debug + +# CLEAN ENVIRONMENT +- name: Remove the ansible_tenant + cisco.aci.aci_tenant: &aci_tenant_absent + <<: *aci_info + tenant: ansible_tenant + state: absent + +- name: Verify Cloud and Non-Cloud Sites in use. + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + +- name: Execute tasks only for non-cloud sites + when: query_cloud.current == [] # This condition will execute only non-cloud sites + block: # block specifies execution of tasks within, based on conditions + - name: Add a new tenant + cisco.aci.aci_tenant: &aci_tenant_present + <<: *aci_info + tenant: ansible_tenant + description: Ansible tenant + state: present + + - name: Add a BGP route summarization policy (check_mode) - APIC version >= 5.0 + when: version.current.0.topSystem.attributes.version is version('5', '>=') + cisco.aci.aci_bgp_route_summarization_policy: &aci_bgp_route_summarization_policy_present + <<: *aci_info + tenant: ansible_tenant + route_summarization_policy: ansible_bgp_route_summarization_policy_1 + description: BGP route summarization policy 1 for ansible_tenant tenant + address_type_af_control: [af-mcast, af-ucast] + control_state: [as-set, summary-only] + state: present + check_mode: true + register: cm_add_bgp_route_summarization_policy + + - name: Add a BGP route summarization policy (normal_mode)- APIC version >= 5.0 + when: version.current.0.topSystem.attributes.version is version('5', '>=') + cisco.aci.aci_bgp_route_summarization_policy: + <<: *aci_bgp_route_summarization_policy_present + register: nm_add_bgp_route_summarization_policy + + - name: Add the first BGP route summarization policy again (testing idempotency) - APIC version >= 5.0 + when: version.current.0.topSystem.attributes.version is version('5', '>=') + cisco.aci.aci_bgp_route_summarization_policy: + <<: *aci_bgp_route_summarization_policy_present + register: nm_add_bgp_route_summarization_policy_idempotency + + - name: Add a second BGP route summarization policy (normal_mode) - APIC version >= 5.0 + when: version.current.0.topSystem.attributes.version is version('5', '>=') + cisco.aci.aci_bgp_route_summarization_policy: + <<: *aci_info + tenant: ansible_tenant + route_summarization_policy: ansible_bgp_route_summarization_policy_2 + description: BGP route summarization policy 2 for ansible_tenant tenant + state: present + register: nm_add_bgp_route_summarization_policy_2 + + - name: Asserts for BGP route summarization policys creation tasks - APIC version >= 5.0 + when: version.current.0.topSystem.attributes.version is version('5', '>=') + ansible.builtin.assert: + that: + - cm_add_bgp_route_summarization_policy is changed + - cm_add_bgp_route_summarization_policy.previous == [] + - cm_add_bgp_route_summarization_policy.current == [] + - nm_add_bgp_route_summarization_policy is changed + - nm_add_bgp_route_summarization_policy.current.0.bgpRtSummPol.attributes.name == "ansible_bgp_route_summarization_policy_1" + - nm_add_bgp_route_summarization_policy.current.0.bgpRtSummPol.attributes.addrTCtrl == "af-mcast,af-ucast" + - nm_add_bgp_route_summarization_policy.current.0.bgpRtSummPol.attributes.ctrl == "as-set,summary-only" + - nm_add_bgp_route_summarization_policy_idempotency is not changed + - nm_add_bgp_route_summarization_policy_2 is changed + - nm_add_bgp_route_summarization_policy_2.previous == [] + - nm_add_bgp_route_summarization_policy_2.current.0.bgpRtSummPol.attributes.name == "ansible_bgp_route_summarization_policy_2" + - nm_add_bgp_route_summarization_policy_2.current.0.bgpRtSummPol.attributes.addrTCtrl == "af-ucast" + - nm_add_bgp_route_summarization_policy_2.current.0.bgpRtSummPol.attributes.ctrl == "" + + - name: Add a BGP route summarization policy (check_mode) - APIC version < 5.0 + when: version.current.0.topSystem.attributes.version is version('5', '<') + cisco.aci.aci_bgp_route_summarization_policy: &aci_bgp_route_summarization_policy_present_prior + <<: *aci_info + tenant: ansible_tenant + route_summarization_policy: ansible_bgp_route_summarization_policy_1 + description: BGP route summarization policy 1 for ansible_tenant tenant + control_state: as-set + state: present + check_mode: true + register: cm_add_bgp_route_summarization_policy_prior + + - name: Add a BGP route summarization policy (normal_mode) - APIC version < 5.0 + when: version.current.0.topSystem.attributes.version is version('5', '<') + cisco.aci.aci_bgp_route_summarization_policy: + <<: *aci_bgp_route_summarization_policy_present_prior + register: nm_add_bgp_route_summarization_policy_prior + + - name: Add the first BGP route summarization policy again (testing idempotency) - APIC version < 5.0 + when: version.current.0.topSystem.attributes.version is version('5', '<') + cisco.aci.aci_bgp_route_summarization_policy: + <<: *aci_bgp_route_summarization_policy_present_prior + register: nm_add_bgp_route_summarization_policy_idempotency_prior + + - name: Add a second BGP route summarization policy (normal_mode) - APIC version < 5.0 + when: version.current.0.topSystem.attributes.version is version('5', '<') + cisco.aci.aci_bgp_route_summarization_policy: + <<: *aci_info + tenant: ansible_tenant + route_summarization_policy: ansible_bgp_route_summarization_policy_2 + description: BGP route summarization policy 2 for ansible_tenant tenant + state: present + register: nm_add_bgp_route_summarization_policy_2_prior + + - name: Asserts for BGP route summarization policys creation tasks - APIC version < 5.0 + when: version.current.0.topSystem.attributes.version is version('5', '<') + ansible.builtin.assert: + that: + - cm_add_bgp_route_summarization_policy_prior is changed + - cm_add_bgp_route_summarization_policy_prior.previous == [] + - cm_add_bgp_route_summarization_policy_prior.current == [] + - nm_add_bgp_route_summarization_policy_prior is changed + - nm_add_bgp_route_summarization_policy_prior.current.0.bgpRtSummPol.attributes.name == "ansible_bgp_route_summarization_policy_1" + - nm_add_bgp_route_summarization_policy_prior.current.0.bgpRtSummPol.attributes.ctrl == "as-set" + - nm_add_bgp_route_summarization_policy_idempotency_prior is not changed + - nm_add_bgp_route_summarization_policy_2_prior is changed + - nm_add_bgp_route_summarization_policy_2_prior.previous == [] + - nm_add_bgp_route_summarization_policy_2_prior.current.0.bgpRtSummPol.attributes.name == "ansible_bgp_route_summarization_policy_2" + - nm_add_bgp_route_summarization_policy_2_prior.current.0.bgpRtSummPol.attributes.ctrl == "" + + - name: Query all BGP route summarization policies + cisco.aci.aci_bgp_route_summarization_policy: + <<: *aci_info + state: query + register: query_all_bgp_route_summarization_policy + + - name: Asserts query all tasks + ansible.builtin.assert: + that: + - query_all_bgp_route_summarization_policy is not changed + - query_all_bgp_route_summarization_policy.current|length >= 2 + + - name: Query ansible_bgp_route_summarization_policy_1 - APIC version >= 5.0 + when: version.current.0.topSystem.attributes.version is version('5', '>=') + cisco.aci.aci_bgp_route_summarization_policy: + <<: *aci_bgp_route_summarization_policy_present + state: query + register: query_ansible_bgp_route_summarization_policy_1 + + - name: Asserts individual query tasks - APIC version >= 5.0 + when: version.current.0.topSystem.attributes.version is version('5', '>=') + ansible.builtin.assert: + that: + - query_ansible_bgp_route_summarization_policy_1 is not changed + - query_ansible_bgp_route_summarization_policy_1.current.0.bgpRtSummPol.attributes.name == "ansible_bgp_route_summarization_policy_1" + - query_ansible_bgp_route_summarization_policy_1.current.0.bgpRtSummPol.attributes.addrTCtrl == "af-mcast,af-ucast" + - query_ansible_bgp_route_summarization_policy_1.current.0.bgpRtSummPol.attributes.ctrl == "as-set,summary-only" + + - name: Query ansible_bgp_route_summarization_policy_1 - APIC version < 5.0 + when: version.current.0.topSystem.attributes.version is version('5', '<') + cisco.aci.aci_bgp_route_summarization_policy: + <<: *aci_bgp_route_summarization_policy_present_prior + state: query + register: query_ansible_bgp_route_summarization_policy_1_prior + + - name: Asserts individual query tasks - APIC version < 5.0 + when: version.current.0.topSystem.attributes.version is version('5', '<') + ansible.builtin.assert: + that: + - query_ansible_bgp_route_summarization_policy_1_prior is not changed + - query_ansible_bgp_route_summarization_policy_1_prior.current.0.bgpRtSummPol.attributes.name == "ansible_bgp_route_summarization_policy_1" + - query_ansible_bgp_route_summarization_policy_1_prior.current.0.bgpRtSummPol.attributes.ctrl == "as-set" + + - name: Remove BGP route summarization policy (check_mode) - APIC version >= 5.0 + when: version.current.0.topSystem.attributes.version is version('5', '>=') + cisco.aci.aci_bgp_route_summarization_policy: &bgp_route_summarization_policy_absent + <<: *aci_bgp_route_summarization_policy_present + state: absent + check_mode: true + register: cm_remove_bgp_route_summarization_policy + + - name: Remove BGP route summarization policy (normal_mode) - APIC version >= 5.0 + when: version.current.0.topSystem.attributes.version is version('5', '>=') + cisco.aci.aci_bgp_route_summarization_policy: + <<: *bgp_route_summarization_policy_absent + register: nm_remove_bgp_route_summarization_policy + + - name: Remove BGP route summarization policy (testing idempotency) - APIC version >= 5.0 + when: version.current.0.topSystem.attributes.version is version('5', '>=') + cisco.aci.aci_bgp_route_summarization_policy: + <<: *bgp_route_summarization_policy_absent + register: nm_remove_bgp_route_summarization_policy_idempotency + + - name: Asserts deletion tasks- APIC version >= 5.0 + when: version.current.0.topSystem.attributes.version is version('5', '>=') + ansible.builtin.assert: + that: + - cm_remove_bgp_route_summarization_policy is changed + - cm_remove_bgp_route_summarization_policy.proposed == {} + - nm_remove_bgp_route_summarization_policy is changed + - nm_remove_bgp_route_summarization_policy.previous != [] + - nm_remove_bgp_route_summarization_policy.method == "DELETE" + - nm_remove_bgp_route_summarization_policy_idempotency is not changed + - nm_remove_bgp_route_summarization_policy_idempotency.previous == [] + + - name: Remove BGP route summarization policy (check_mode) - APIC version < 5.0 + when: version.current.0.topSystem.attributes.version is version('5', '<') + cisco.aci.aci_bgp_route_summarization_policy: &bgp_route_summarization_policy_absent_prior + <<: *aci_bgp_route_summarization_policy_present_prior + state: absent + check_mode: true + register: cm_remove_bgp_route_summarization_policy_prior + + - name: Remove BGP route summarization policy (normal_mode) - APIC version < 5.0 + when: version.current.0.topSystem.attributes.version is version('5', '<') + cisco.aci.aci_bgp_route_summarization_policy: + <<: *bgp_route_summarization_policy_absent_prior + register: nm_remove_bgp_route_summarization_policy_prior + + - name: Remove BGP route summarization policy (testing idempotency) - APIC version < 5.0 + when: version.current.0.topSystem.attributes.version is version('5', '<') + cisco.aci.aci_bgp_route_summarization_policy: + <<: *bgp_route_summarization_policy_absent_prior + register: nm_remove_bgp_route_summarization_policy_idempotency_prior + + - name: Asserts deletion tasks - APIC version < 5.0 + when: version.current.0.topSystem.attributes.version is version('5', '<') + ansible.builtin.assert: + that: + - cm_remove_bgp_route_summarization_policy_prior is changed + - cm_remove_bgp_route_summarization_policy_prior.proposed == {} + - nm_remove_bgp_route_summarization_policy_prior is changed + - nm_remove_bgp_route_summarization_policy_prior.previous != [] + - nm_remove_bgp_route_summarization_policy_prior.method == "DELETE" + - nm_remove_bgp_route_summarization_policy_idempotency_prior is not changed + - nm_remove_bgp_route_summarization_policy_idempotency_prior.previous == [] + + - name: Remove the ansible_tenant - cleanup before ending tests + cisco.aci.aci_tenant: + <<: *aci_tenant_present + state: absent diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_bgp_rr_asn/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_bgp_rr_asn/tasks/main.yml index 3b65520bc..cead2ac6c 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_bgp_rr_asn/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_bgp_rr_asn/tasks/main.yml @@ -4,13 +4,13 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined # GET Credentials from the inventory - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: "{{ aci_hostname }}" username: "{{ aci_username }}" @@ -35,7 +35,7 @@ register: add_bgp_rr_asn - name: Verify that BGP route reflector ASN has been created with correct attributes - assert: + ansible.builtin.assert: that: - add_bgp_rr_asn is changed - add_bgp_rr_asn.current.0.bgpAsP.attributes.annotation == 'orchestrator:ansible' @@ -51,7 +51,7 @@ register: add_bgp_rr_asn_again - name: Verify that BGP route reflector ASN idempotence - assert: + ansible.builtin.assert: that: - add_bgp_rr_asn_again is not changed - add_bgp_rr_asn_again.current.0.bgpAsP.attributes.dn == "uni/fabric/bgpInstP-default/as" @@ -66,7 +66,7 @@ register: update_bgp_rr_asn - name: Verify that BGP route reflector ASN has been updated with correct attributes - assert: + ansible.builtin.assert: that: - update_bgp_rr_asn is changed - update_bgp_rr_asn.current.0.bgpAsP.attributes.dn == "uni/fabric/bgpInstP-default/as" @@ -80,7 +80,7 @@ register: query_bgp_rr_asn - name: Verify BGP route reflector ASN - assert: + ansible.builtin.assert: that: - query_bgp_rr_asn is not changed - query_bgp_rr_asn.current.0.bgpAsP.attributes.dn == "uni/fabric/bgpInstP-default/as" diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_bgp_rr_node/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_bgp_rr_node/tasks/main.yml index d1ec77a27..609574cf6 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_bgp_rr_node/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_bgp_rr_node/tasks/main.yml @@ -4,13 +4,13 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined # GET Credentials from the inventory - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: "{{ aci_hostname }}" username: "{{ aci_username }}" @@ -38,7 +38,7 @@ register: add_bgp_rr_node - name: Verify that BGP route reflector node has been created with correct attributes - assert: + ansible.builtin.assert: that: - add_bgp_rr_node is changed - add_bgp_rr_node.current.0.bgpRRNodePEp.attributes.annotation == 'orchestrator:ansible' @@ -58,7 +58,7 @@ register: add_bgp_rr_node_again - name: Verify that BGP route reflector node has been created with correct attributes - assert: + ansible.builtin.assert: that: - add_bgp_rr_node_again is not changed - add_bgp_rr_node_again.current.0.bgpRRNodePEp.attributes.dn == "uni/fabric/bgpInstP-default/rr/node-101" @@ -77,7 +77,7 @@ register: update_bgp_rr_node - name: Verify that BGP route reflector node has been updated with correct attributes - assert: + ansible.builtin.assert: that: - update_bgp_rr_node is changed - update_bgp_rr_node.current.0.bgpRRNodePEp.attributes.dn == "uni/fabric/bgpInstP-default/rr/node-101" @@ -94,7 +94,7 @@ register: query_bgp_rr_node - name: Verify that BGP route reflector node attributes - assert: + ansible.builtin.assert: that: - query_bgp_rr_node is not changed - query_bgp_rr_node.current.0.bgpRRNodePEp.attributes.dn == "uni/fabric/bgpInstP-default/rr/node-101" @@ -109,7 +109,7 @@ register: query_bgp_rr_node_all - name: Verify query_bgp_rr_node_all - assert: + ansible.builtin.assert: that: - query_bgp_rr_node_all is not changed @@ -122,7 +122,7 @@ register: remove_bgp_rr_node - name: Verify BGP route reflector node removal - assert: + ansible.builtin.assert: that: - remove_bgp_rr_node is changed - remove_bgp_rr_node.current == [] diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_bgp_timers_policy/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_bgp_timers_policy/tasks/main.yml index 0c7cdd77d..41a099dab 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_bgp_timers_policy/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_bgp_timers_policy/tasks/main.yml @@ -4,12 +4,12 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: "{{ aci_hostname }}" username: "{{ aci_username }}" @@ -21,26 +21,26 @@ # CLEAN ENVIRONMENT - name: Remove the ansible_tenant - aci_tenant: &aci_tenant_absent + cisco.aci.aci_tenant: &aci_tenant_absent <<: *aci_info tenant: ansible_tenant state: absent - name: Verify Cloud and Non-Cloud Sites in use. - include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml - name: Execute tasks only for non-cloud sites when: query_cloud.current == [] # This condition will execute only non-cloud sites block: # block specifies execution of tasks within, based on conditions - name: Add a new tenant - aci_tenant: &aci_tenant_present + cisco.aci.aci_tenant: &aci_tenant_present <<: *aci_info tenant: ansible_tenant description: Ansible tenant state: present - name: Add a BGP timers policy (check_mode) - aci_bgp_timers_policy: &aci_bgp_timers_policy_present + cisco.aci.aci_bgp_timers_policy: &aci_bgp_timers_policy_present <<: *aci_info tenant: ansible_tenant bgp_timers_policy: ansible_bgp_timers_policy_1 @@ -55,17 +55,17 @@ register: cm_add_bgp_timers_policy - name: Add a BGP timers policy (normal_mode) - aci_bgp_timers_policy: + cisco.aci.aci_bgp_timers_policy: <<: *aci_bgp_timers_policy_present register: nm_add_bgp_timers_policy - name: Add the first BGP timers policy again - testing idempotency - aci_bgp_timers_policy: + cisco.aci.aci_bgp_timers_policy: <<: *aci_bgp_timers_policy_present register: nm_add_bgp_timers_policy_idempotency - name: Add a second BGP timers policy (normal_mode) - aci_bgp_timers_policy: + cisco.aci.aci_bgp_timers_policy: <<: *aci_info tenant: ansible_tenant bgp_timers_policy: ansible_bgp_timers_policy_2 @@ -74,7 +74,7 @@ register: nm_add_bgp_timers_policy_2 - name: Asserts for BGP timers policys creation tasks - assert: + ansible.builtin.assert: that: - cm_add_bgp_timers_policy is changed - cm_add_bgp_timers_policy.previous == [] @@ -97,19 +97,19 @@ - nm_add_bgp_timers_policy_2.current.0.bgpCtxPol.attributes.staleIntvl == "default" - name: Query all BGP timers policies - aci_bgp_timers_policy: + cisco.aci.aci_bgp_timers_policy: <<: *aci_info state: query register: query_all_bgp_timers_policy - name: Query ansible_bgp_timers_policy_1 - aci_bgp_timers_policy: + cisco.aci.aci_bgp_timers_policy: <<: *aci_bgp_timers_policy_present state: query register: query_ansible_bgp_timers_policy_1 - name: Asserts query tasks - assert: + ansible.builtin.assert: that: - query_all_bgp_timers_policy is not changed - query_all_bgp_timers_policy.current|length >= 2 @@ -122,24 +122,24 @@ - query_ansible_bgp_timers_policy_1.current.0.bgpCtxPol.attributes.staleIntvl == "600" - name: Remove BGP timers policy (check_mode) - aci_bgp_timers_policy: &bgp_timers_policy_absent + cisco.aci.aci_bgp_timers_policy: &bgp_timers_policy_absent <<: *aci_bgp_timers_policy_present state: absent check_mode: true register: cm_remove_bgp_timers_policy - name: Remove BGP timers policy (normal_mode) - aci_bgp_timers_policy: + cisco.aci.aci_bgp_timers_policy: <<: *bgp_timers_policy_absent register: nm_remove_bgp_timers_policy - name: Remove BGP timers policy - testing idempotency - aci_bgp_timers_policy: + cisco.aci.aci_bgp_timers_policy: <<: *bgp_timers_policy_absent register: nm_remove_bgp_timers_policy_idempotency - name: Asserts deletion tasks - assert: + ansible.builtin.assert: that: - cm_remove_bgp_timers_policy is changed - cm_remove_bgp_timers_policy.proposed == {} @@ -150,6 +150,6 @@ - nm_remove_bgp_timers_policy_idempotency.previous == [] - name: Remove the ansible_tenant - cleanup before ending tests - aci_tenant: + cisco.aci.aci_tenant: <<: *aci_tenant_present state: absent diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_bulk_static_binding_to_epg/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_bulk_static_binding_to_epg/tasks/main.yml index 909cf933c..700c2975c 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_bulk_static_binding_to_epg/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_bulk_static_binding_to_epg/tasks/main.yml @@ -4,12 +4,12 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: "{{ aci_hostname }}" username: "{{ aci_username }}" @@ -20,7 +20,7 @@ output_level: debug - name: Verify Cloud and Non-Cloud Sites in use. - include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml - name: Execute tasks only for non-cloud sites when: query_cloud.current == [] # This condition will execute only non-cloud sites @@ -70,7 +70,7 @@ register: cm_interfaces_present - name: Assertions check for add list of interfaces with check mode - assert: + ansible.builtin.assert: that: - cm_interfaces_present is changed - cm_interfaces_present.current.0.fvAEPg.attributes.name == "anstest" @@ -83,7 +83,7 @@ register: nm_interfaces_present - name: Assertions check for add list of interfaces with normal mode - assert: + ansible.builtin.assert: that: - nm_interfaces_present is changed - nm_interfaces_present.current.0.fvAEPg.attributes.name == "anstest" @@ -97,7 +97,7 @@ register: idempotency_interfaces_present - name: Idempotency assertions check for add list of interfaces with normal mode - assert: + ansible.builtin.assert: that: - idempotency_interfaces_present is not changed - idempotency_interfaces_present.current.0.fvAEPg.attributes.name == "anstest" @@ -112,7 +112,7 @@ register: cm_update_interfaces_present - name: Assertions check for update list of interfaces - description with normal mode - assert: + ansible.builtin.assert: that: - cm_update_interfaces_present is changed - cm_update_interfaces_present.current.0.fvAEPg.attributes.name == "anstest" @@ -127,7 +127,7 @@ register: nm_update_interfaces_present - name: Assertions check for update list of interfaces - description with normal mode - assert: + ansible.builtin.assert: that: - nm_update_interfaces_present is changed - nm_update_interfaces_present.current.0.fvAEPg.attributes.name == "anstest" @@ -142,7 +142,7 @@ register: idempotency_nm_update_interfaces_present - name: Idempotency assertions check for update list of interfaces - description with normal mode - assert: + ansible.builtin.assert: that: - idempotency_nm_update_interfaces_present is not changed - idempotency_nm_update_interfaces_present.current.0.fvAEPg.attributes.name == "anstest" @@ -177,7 +177,7 @@ register: cm_path_update_interfaces_present - name: Assertions check for update list of interfaces description using path level attributes with check mode - assert: + ansible.builtin.assert: that: - cm_path_update_interfaces_present is changed - cm_path_update_interfaces_present.current.0.fvAEPg.attributes.name == "anstest" @@ -193,7 +193,7 @@ register: nm_path_update_interfaces_present - name: Assertions check for update list of interfaces description using path level attributes with normal mode - assert: + ansible.builtin.assert: that: - nm_path_update_interfaces_present is changed - nm_path_update_interfaces_present.current.0.fvAEPg.attributes.name == "anstest" @@ -208,7 +208,7 @@ register: idempotency_path_update_interfaces_present - name: Idempotency assertions check for update list of interfaces description using path level attributes with normal mode - assert: + ansible.builtin.assert: that: - idempotency_path_update_interfaces_present is not changed - idempotency_path_update_interfaces_present.current.0.fvAEPg.attributes.name == "anstest" @@ -226,7 +226,7 @@ register: query_result_of_anstest_epg - name: Assertions check for query all interfaces of an EPG - assert: + ansible.builtin.assert: that: - query_result_of_anstest_epg is not changed - query_result_of_anstest_epg.current.0.fvAEPg.children | length == 3 @@ -241,7 +241,7 @@ register: query_all_interfaces - name: Assertions check for query all interfaces # Check covers only EPG level - assert: + ansible.builtin.assert: that: - query_all_interfaces is not changed - query_all_interfaces.current | length >= 1 @@ -254,7 +254,7 @@ register: cm_interfaces_absent - name: Assertions check for remove list of interfaces with check mode - assert: + ansible.builtin.assert: that: - cm_interfaces_absent is changed - cm_interfaces_absent.current.0.fvAEPg.children | length == 3 @@ -269,7 +269,7 @@ register: nm_interfaces_absent - name: Assertions check for remove list of interfaces with normal mode - assert: + ansible.builtin.assert: that: - nm_interfaces_absent is changed - "'children' not in nm_interfaces_absent.current.0.fvAEPg" @@ -285,7 +285,7 @@ register: idempotency_interfaces_absent - name: Idempotency assertions check for remove list of interfaces with normal mode - assert: + ansible.builtin.assert: that: - idempotency_interfaces_absent is changed - "'children' not in idempotency_interfaces_absent.current.0.fvAEPg" @@ -309,7 +309,7 @@ register: fex_port_channel_present - name: Assertions check for add fex_port_channel interfaces to anstest epg - assert: + ansible.builtin.assert: that: - fex_port_channel_present is changed - fex_port_channel_present.current.0.fvAEPg.children | length == 1 @@ -325,7 +325,7 @@ register: fex_port_channel_absent - name: Assertions check for remove fex_port_channel interfaces from anstest epg - assert: + ansible.builtin.assert: that: - fex_port_channel_absent is changed - fex_port_channel_absent.previous.0.fvAEPg.children | length == 1 @@ -354,7 +354,7 @@ register: fex_vpc_present - name: Assertions check for add fex_vpc interfaces to anstest epg - assert: + ansible.builtin.assert: that: - fex_vpc_present is changed - fex_vpc_present.current.0.fvAEPg.children | length == 1 @@ -370,7 +370,7 @@ register: fex_vpc_absent - name: Assertions check for remove fex_vpc interfaces from anstest epg - assert: + ansible.builtin.assert: that: - fex_vpc_absent is changed - fex_vpc_absent.previous.0.fvAEPg.children | length == 1 @@ -398,7 +398,7 @@ register: vpc_present - name: Assertions check for add vpc interfaces to anstest epg - assert: + ansible.builtin.assert: that: - vpc_present is changed - vpc_present.current.0.fvAEPg.children | length == 1 @@ -414,7 +414,7 @@ register: vpc_absent - name: Assertions check for remove vpc interfaces from anstest epg - assert: + ansible.builtin.assert: that: - vpc_absent is changed - vpc_absent.previous.0.fvAEPg.children | length == 1 @@ -433,7 +433,7 @@ register: query_result - name: Assertions check for query all interfaces before start module and path level check - assert: + ansible.builtin.assert: that: - query_result is not changed - "'children' not in query_result.current.0.fvAEPg" @@ -456,7 +456,7 @@ register: module_level_check - name: Assertions check for add an interface with module level attributes - assert: + ansible.builtin.assert: that: - module_level_check is changed - module_level_check.current.0.fvAEPg.children | length == 1 @@ -474,7 +474,7 @@ register: module_level_check_absent - name: Assertions check for remove an interface with module level attributes - assert: + ansible.builtin.assert: that: - module_level_check_absent is changed - "'children' not in module_level_check_absent.current.0.fvAEPg" @@ -501,7 +501,7 @@ register: path_level_check - name: Assertions check for add an interface with path level attributes - assert: + ansible.builtin.assert: that: - path_level_check is changed - path_level_check.current.0.fvAEPg.children | length == 1 @@ -515,7 +515,7 @@ register: path_level_check_absent - name: Assertions check for remove an interface with path level attributes - assert: + ansible.builtin.assert: that: - path_level_check_absent is changed - "'children' not in path_level_check_absent.current.0.fvAEPg" @@ -542,7 +542,7 @@ register: path_and_module_encap_id_present - name: Assertions check for add an interface encap_id with path and module level attributes - assert: + ansible.builtin.assert: that: - path_and_module_encap_id_present is changed - path_and_module_encap_id_present.current.0.fvAEPg.children | length == 1 @@ -556,7 +556,7 @@ register: path_and_module_encap_id_absent - name: Assertions check for remove an interface encap_id with path and module level attributes - assert: + ansible.builtin.assert: that: - path_and_module_encap_id_absent is changed - "'children' not in path_and_module_encap_id_absent.current.0.fvAEPg" @@ -751,7 +751,7 @@ register: switch_port_primary_encap_id_not_unknown - name: Negative assertions to check error messages - assert: + ansible.builtin.assert: that: - switch_port_no_leafs.msg == "missing required arguments{{':'}} leafs found in interface_configs" - fex_vpc_no_extpaths.msg == "extpaths is required when interface_type is{{':'}} fex_vpc" diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_cloud_ap/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_cloud_ap/tasks/main.yml index 08a62f8cc..eb1e51704 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_cloud_ap/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_cloud_ap/tasks/main.yml @@ -4,7 +4,7 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined @@ -22,7 +22,7 @@ register: tenant_present - name: Verify Cloud and Non-Cloud Sites in use. - include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml - name: Execute tasks only for cloud sites when: query_cloud.current | length > 0 # This condition will execute only cloud sites @@ -68,7 +68,7 @@ register: update_cloud_ap - name: verify cloud ap creation - assert: + ansible.builtin.assert: that: - cm_create_cloud_ap is changed - nm_create_cloud_ap is changed @@ -119,7 +119,7 @@ register: query_cloud_ap - name: verify query - assert: + ansible.builtin.assert: that: - query_all_tenant is not changed - query_all_tenant.current.0.fvTenant.children | length >= 2 @@ -148,7 +148,7 @@ register: rm_cloud_ap_again - name: verify deletion - assert: + ansible.builtin.assert: that: - rm_cloud_ap is changed - rm_cloud_ap.previous.0.cloudApp.attributes.name == 'anstest' diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_cloud_aws_provider/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_cloud_aws_provider/tasks/main.yml index 4679bf78d..f5a849d69 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_cloud_aws_provider/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_cloud_aws_provider/tasks/main.yml @@ -4,12 +4,12 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: "{{ aci_hostname }}" username: "{{ aci_username }}" @@ -20,7 +20,7 @@ output_level: '{{ aci_output_level | default("info") }}' - name: Verify Cloud and Non-Cloud Sites in use. - include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml - name: Execute tasks only for aws cloud site when: @@ -112,7 +112,7 @@ register: aws_query_all - name: Verify all - assert: + ansible.builtin.assert: that: - aws_present is changed - aws_present_again is not changed diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_cloud_bgp_asn/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_cloud_bgp_asn/tasks/main.yml index 8d442bf14..9fc045ed1 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_cloud_bgp_asn/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_cloud_bgp_asn/tasks/main.yml @@ -4,7 +4,7 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined @@ -17,7 +17,7 @@ # CLEAN ENVIRONMENT - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: "{{ aci_hostname }}" username: "{{ aci_username }}" @@ -28,31 +28,31 @@ output_level: '{{ aci_output_level | default("info") }}' # - name: Verify Cloud and Non-Cloud Sites in use. -# include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml +# ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml # - name: Execute tasks only for cloud sites # when: query_cloud.current | length > 0 # This condition will execute only cloud sites # block: # block specifies execution of tasks within, based on conditions # - name: Ensure cloud BGP ASN doesn't exist -# aci_cloud_bgp_asn: +# cisco.aci.aci_cloud_bgp_asn: # <<: *aci_info # state: absent # - name: Create cloud BGP ASN -# aci_cloud_bgp_asn: +# cisco.aci.aci_cloud_bgp_asn: # <<: *aci_info # state: present # register: asn_present # - name: Verify asn_present -# assert: +# ansible.builtin.assert: # that: # - asn_present is changed # - asn_present.current.0.cloudBgpAsP.attributes.asn == '0' # - name: Create cloud BGP ASN -# aci_cloud_bgp_asn: +# cisco.aci.aci_cloud_bgp_asn: # <<: *aci_info # annotation: 'tag_system' # asn: 64605 @@ -63,13 +63,13 @@ # register: asn_present_2 # - name: Verify asn_present_2 -# assert: +# ansible.builtin.assert: # that: # - asn_present_2 is changed # - asn_present_2.current.0.cloudBgpAsP.attributes.asn == '64605' # - name: Create same cloud BGP ASN again -# aci_cloud_bgp_asn: +# cisco.aci.aci_cloud_bgp_asn: # <<: *aci_info # annotation: 'tag_system' # asn: 64605 @@ -80,13 +80,13 @@ # register: asn_present_again # - name: Verify asn_present_again -# assert: +# ansible.builtin.assert: # that: # - asn_present_again is not changed # - asn_present_again.current.0.cloudBgpAsP.attributes.asn == '64605' # - name: Query particular cloud BGP ASN -# aci_cloud_bgp_asn: +# cisco.aci.aci_cloud_bgp_asn: # <<: *aci_info # annotation: 'tag_system' # asn: 64605 @@ -99,25 +99,25 @@ # # Query all will give same result as query # # There can be only one cloud BGP ASN # - name: Query all cloud BGP ASN -# aci_cloud_bgp_asn: +# cisco.aci.aci_cloud_bgp_asn: # <<: *aci_info # state: query # register: asn_query_all # - name: Verify query -# assert: +# ansible.builtin.assert: # that: # - asn_query is not changed # - asn_query_all is not changed # - name: Delete cloud BGP ASN -# aci_cloud_bgp_asn: +# cisco.aci.aci_cloud_bgp_asn: # <<: *aci_info # state: absent # register: asn_absent # - name: Verify absent -# assert: +# ansible.builtin.assert: # that: # - asn_absent is changed # - asn_absent.current == []
\ No newline at end of file diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_cloud_cidr/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_cloud_cidr/tasks/main.yml index ab61eba83..9c00b67f4 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_cloud_cidr/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_cloud_cidr/tasks/main.yml @@ -4,13 +4,13 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined # CLEAN ENVIRONMENT - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: "{{ aci_hostname }}" username: "{{ aci_username }}" @@ -21,27 +21,27 @@ output_level: '{{ aci_output_level | default("info") }}' - name: Verify Cloud and Non-Cloud Sites in use. - include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml - name: Execute tasks only for cloud sites when: query_cloud.current | length > 0 # This condition will execute only cloud sites block: # block specifies execution of tasks within, based on conditions - name: Ensure tenant doesn't exist - aci_tenant: + cisco.aci.aci_tenant: <<: *aci_info state: absent tenant: ansible_test register: tenant_absent - name: Ensure tenant exists for tests to kick off - aci_tenant: + cisco.aci.aci_tenant: <<: *aci_info state: present tenant: ansible_test register: tenant_present - name: Ensure aci cloud context profile does not exists - aci_cloud_ctx_profile: + cisco.aci.aci_cloud_ctx_profile: <<: *aci_info tenant: ansible_test name: ctx_profile_1 @@ -49,7 +49,7 @@ register: rm_ctx_profile_1 - name: Create aci cloud context profile - aci_cloud_ctx_profile: + cisco.aci.aci_cloud_ctx_profile: <<: *aci_info tenant: ansible_test name: ctx_profile_1 @@ -61,7 +61,7 @@ register: nm_add_aci_ctx_profile - name: Create non_primary CIDR (check_mode) - aci_cloud_cidr: + cisco.aci.aci_cloud_cidr: <<: *aci_info tenant: ansible_test address: 10.0.0.0/16 @@ -71,7 +71,7 @@ register: cm_non_primary_cidr - name: Create non_primary CIDR (normal_mode) - aci_cloud_cidr: + cisco.aci.aci_cloud_cidr: <<: *aci_info tenant: ansible_test address: 10.0.0.0/16 @@ -80,7 +80,7 @@ register: nm_non_primary_cidr - name: Verify cm_non_primary_cidr and nm_non_primary_cidr - assert: + ansible.builtin.assert: that: - cm_non_primary_cidr is changed - nm_non_primary_cidr is changed @@ -95,7 +95,7 @@ - nm_non_primary_cidr.current.0.cloudCidr.attributes.primary == "no" - name: Create non_primary CIDR again - aci_cloud_cidr: + cisco.aci.aci_cloud_cidr: <<: *aci_info tenant: ansible_test address: 10.0.0.0/16 @@ -104,7 +104,7 @@ register: nm_non_primary_cidr_again - name: Verify nm_non_primary_cidr_again - assert: + ansible.builtin.assert: that: - nm_non_primary_cidr_again is not changed - nm_non_primary_cidr_again.previous.0.cloudCidr.attributes.addr == "10.0.0.0/16" @@ -115,7 +115,7 @@ - nm_non_primary_cidr_again.current.0.cloudCidr.attributes.primary == "no" - name: Change primary CIDR to non_primary (check_mode) - aci_cloud_cidr: + cisco.aci.aci_cloud_cidr: <<: *aci_info tenant: ansible_test address: 10.11.0.0/16 @@ -125,7 +125,7 @@ register: cm_change_to_non_primary_cidr - name: Change primary CIDR to non_primary (normal_mode) - aci_cloud_cidr: + cisco.aci.aci_cloud_cidr: <<: *aci_info tenant: ansible_test address: 10.11.0.0/16 @@ -135,14 +135,14 @@ register: nm_change_to_non_primary_cidr - name: Verify cm_primary_cidr and nm_change_to_non_primary_cidr - assert: + ansible.builtin.assert: that: - nm_change_to_non_primary_cidr.msg == "APIC Error 1{{':'}} Invalid Configuration {{':'}} Exactly one Primary CIDR expected for{{':'}} uni/tn-ansible_test/ctxprofile-ctx_profile_1, but found{{':'}} 0" - cm_change_to_non_primary_cidr.proposed.cloudCidr.attributes.primary == "no" - cm_change_to_non_primary_cidr.previous.0.cloudCidr.attributes.primary == cm_change_to_non_primary_cidr.current.0.cloudCidr.attributes.primary == "yes" - name: Remove primary CIDR (check_mode) - aci_cloud_cidr: + cisco.aci.aci_cloud_cidr: <<: *aci_info tenant: ansible_test address: 10.11.0.0/16 @@ -152,7 +152,7 @@ register: cm_remove_primary_cidr - name: Remove primary CIDR (normal_mode) - aci_cloud_cidr: + cisco.aci.aci_cloud_cidr: <<: *aci_info tenant: ansible_test address: 10.11.0.0/16 @@ -162,14 +162,14 @@ register: nm_remove_primary_cidr - name: Verify cm_remove_primary_cidr and nm_remove_primary_cidr - assert: + ansible.builtin.assert: that: - nm_remove_primary_cidr.msg == "APIC Error 1{{':'}} Invalid Configuration {{':'}} Exactly one Primary CIDR expected for{{':'}} uni/tn-ansible_test/ctxprofile-ctx_profile_1, but found{{':'}} 0" - cm_remove_primary_cidr.proposed == {} - cm_remove_primary_cidr.previous.0.cloudCidr.attributes.primary == cm_remove_primary_cidr.current.0.cloudCidr.attributes.primary == "yes" - name: Create second non_primary CIDR - aci_cloud_cidr: + cisco.aci.aci_cloud_cidr: <<: *aci_info tenant: ansible_test address: 10.18.0.0/16 @@ -178,7 +178,7 @@ register: nm_add_second_non_primary_cidr - name: Verify nm_add_second_non_primary_cidr - assert: + ansible.builtin.assert: that: - nm_add_second_non_primary_cidr is changed - nm_add_second_non_primary_cidr.previous == [] @@ -187,7 +187,7 @@ - nm_add_second_non_primary_cidr.current.0.cloudCidr.attributes.dn == "uni/tn-ansible_test/ctxprofile-ctx_profile_1/cidr-[10.18.0.0/16]" - name: Change setting of second non_primary CIDR - aci_cloud_cidr: + cisco.aci.aci_cloud_cidr: <<: *aci_info tenant: ansible_test cidr: 10.18.0.0/16 @@ -198,7 +198,7 @@ register: change_non_primary_cidr - name: Verify change_non_primary_cidr - assert: + ansible.builtin.assert: that: - change_non_primary_cidr is changed - change_non_primary_cidr.current.0.cloudCidr.attributes.addr == "10.18.0.0/16" @@ -207,7 +207,7 @@ - change_non_primary_cidr.current.0.cloudCidr.attributes.dn == "uni/tn-ansible_test/ctxprofile-ctx_profile_1/cidr-[10.18.0.0/16]" - name: Query all CIDRs - aci_cloud_cidr: + cisco.aci.aci_cloud_cidr: <<: *aci_info tenant: ansible_test cloud_context_profile: ctx_profile_1 @@ -215,7 +215,7 @@ register: query_all - name: Verify query_all - assert: + ansible.builtin.assert: that: - query_all is not changed - query_all.current.0.cloudCtxProfile.attributes.name == "ctx_profile_1" @@ -228,7 +228,7 @@ - query_all.current.0.cloudCtxProfile.children.2.cloudCidr.attributes.primary == "yes" - name: Query primary CIDR - aci_cloud_cidr: + cisco.aci.aci_cloud_cidr: <<: *aci_info tenant: ansible_test cloud_context_profile: ctx_profile_1 @@ -237,7 +237,7 @@ register: query_primary - name: Verify query_primary - assert: + ansible.builtin.assert: that: - query_primary is not changed - query_primary.current.0.cloudCidr.attributes.addr == "10.11.0.0/16" @@ -245,7 +245,7 @@ - query_primary.current.0.cloudCidr.attributes.primary == "yes" - name: Query non_primary CIDR - aci_cloud_cidr: + cisco.aci.aci_cloud_cidr: <<: *aci_info tenant: ansible_test cloud_context_profile: ctx_profile_1 @@ -254,7 +254,7 @@ register: query_non_primary - name: Verify query_non_primary - assert: + ansible.builtin.assert: that: - query_non_primary is not changed - query_non_primary.current.0.cloudCidr.attributes.addr == "10.0.0.0/16" @@ -262,7 +262,7 @@ - query_non_primary.current.0.cloudCidr.attributes.primary == "no" - name: Query non_exsisting CIDR - aci_cloud_cidr: + cisco.aci.aci_cloud_cidr: <<: *aci_info tenant: ansible_test cloud_context_profile: ctx_profile_1 @@ -272,12 +272,12 @@ register: query_non_existing - name: Verify query_non_existing - assert: + ansible.builtin.assert: that: - query_non_existing.msg == "APIC Error 104{{':'}} Invalid RN cidr-[non_exsisting]" - name: Remove non_primary CIDR(check_mode) - aci_cloud_cidr: + cisco.aci.aci_cloud_cidr: <<: *aci_info tenant: ansible_test address: 10.0.0.0/16 @@ -287,7 +287,7 @@ register: cm_remove_non_primary_cidr - name: Remove non_primary CIDR(normal_mode) - aci_cloud_cidr: + cisco.aci.aci_cloud_cidr: <<: *aci_info tenant: ansible_test address: 10.0.0.0/16 @@ -296,7 +296,7 @@ register: nm_remove_non_primary_cidr - name: Verify cm_remove_non_primary_cidr and nm_remove_non_primary_cidr - assert: + ansible.builtin.assert: that: - cm_remove_non_primary_cidr is changed - nm_remove_non_primary_cidr is changed diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_cloud_ctx_profile/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_cloud_ctx_profile/tasks/main.yml index 981eadea8..fad2a6452 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_cloud_ctx_profile/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_cloud_ctx_profile/tasks/main.yml @@ -4,13 +4,13 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined # CLEAN ENVIRONMENT - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: "{{ aci_hostname }}" username: "{{ aci_username }}" @@ -21,27 +21,27 @@ output_level: '{{ aci_output_level | default("info") }}' - name: Verify Cloud and Non-Cloud Sites in use. - include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml - name: Execute tasks only for cloud sites when: query_cloud.current | length > 0 # This condition will execute only cloud sites block: # block specifies execution of tasks within, based on conditions - name: Ensure tenant doesn't exist - aci_tenant: + cisco.aci.aci_tenant: <<: *aci_info state: absent tenant: ansible_test register: tenant_absent - name: Ensure tenant exists for tests to kick off - aci_tenant: + cisco.aci.aci_tenant: <<: *aci_info state: present tenant: ansible_test register: tenant_present - name: Ensure aci cloud context profile does not exists - aci_cloud_ctx_profile: + cisco.aci.aci_cloud_ctx_profile: <<: *aci_info tenant: ansible_test name: ctx_profile_1 @@ -49,12 +49,12 @@ register: rm_ctx_profile_1 - name: Verify rm_ctx_profile_1 - assert: + ansible.builtin.assert: that: - rm_ctx_profile_1.current == [] - name: Ensure aci cloud context profile 2 does not exists - aci_cloud_ctx_profile: + cisco.aci.aci_cloud_ctx_profile: <<: *aci_info tenant: ansible_test name: ctx_profile_2 @@ -62,12 +62,12 @@ register: rm_ctx_profile_2 - name: Verify rm_ctx_profile_2 - assert: + ansible.builtin.assert: that: - rm_ctx_profile_2.current == [] - name: Create aci cloud context profile (check mode) - aci_cloud_ctx_profile: + cisco.aci.aci_cloud_ctx_profile: <<: *aci_info tenant: ansible_test cloud: "{{ cloud_type }}" @@ -80,7 +80,7 @@ register: cm_add_aci_ctx_profile - name: Create aci cloud context profile (normal mode) - aci_cloud_ctx_profile: + cisco.aci.aci_cloud_ctx_profile: <<: *aci_info tenant: ansible_test cloud: "{{ cloud_type }}" @@ -92,7 +92,7 @@ register: nm_add_aci_ctx_profile - name: Verify cm_add_aci_ctx_profile - assert: + ansible.builtin.assert: that: - cm_add_aci_ctx_profile is changed - cm_add_aci_ctx_profile.previous == [] @@ -103,7 +103,7 @@ - cm_add_aci_ctx_profile.proposed.cloudCtxProfile.children[2].cloudCidr.attributes.primary == "yes" - name: Verify nm_add_aci_ctx_profile - assert: + ansible.builtin.assert: that: - nm_add_aci_ctx_profile is changed - nm_add_aci_ctx_profile.previous == [] @@ -115,7 +115,7 @@ - nm_add_aci_ctx_profile.current[0].cloudCtxProfile.children[0].cloudCidr.attributes.primary == "yes" - name: Add aci cloud context profile again (check_mode) - aci_cloud_ctx_profile: + cisco.aci.aci_cloud_ctx_profile: <<: *aci_info tenant: ansible_test cloud: "{{ cloud_type }}" @@ -128,7 +128,7 @@ register: cm_add_aci_ctx_profile_again - name: Verify cm_add_aci_ctx_profile_again - assert: + ansible.builtin.assert: that: - cm_add_aci_ctx_profile_again is not changed - cm_add_aci_ctx_profile_again.previous[0].cloudCtxProfile.attributes.name == "ctx_profile_1" @@ -139,7 +139,7 @@ - name: Add aci cloud context profile again (normal_mode) - aci_cloud_ctx_profile: + cisco.aci.aci_cloud_ctx_profile: <<: *aci_info tenant: ansible_test cloud: "{{ cloud_type }}" @@ -151,7 +151,7 @@ register: nm_add_aci_ctx_profile_again - name: Verify nm_add_aci_ctx_profile_again - assert: + ansible.builtin.assert: that: - nm_add_aci_ctx_profile_again is not changed - nm_add_aci_ctx_profile_again.current[0].cloudCtxProfile.attributes.name == "ctx_profile_1" @@ -161,7 +161,7 @@ - nm_add_aci_ctx_profile_again.current[0].cloudCtxProfile.children[0].cloudCidr.attributes.primary == "yes" - name: Add another aci cloud context profile (check_mode) - aci_cloud_ctx_profile: + cisco.aci.aci_cloud_ctx_profile: <<: *aci_info tenant: ansible_test cloud: "{{ cloud_type }}" @@ -175,7 +175,7 @@ register: cm_add_another_aci_ctx_profile - name: Verify cm_add_another_aci_ctx_profile - assert: + ansible.builtin.assert: that: - cm_add_another_aci_ctx_profile is changed - cm_add_another_aci_ctx_profile.previous == [] @@ -187,7 +187,7 @@ - cm_add_another_aci_ctx_profile.proposed.cloudCtxProfile.attributes.descr == "add ctx_profile_2" - name: Add another aci cloud context profile (normal_mode) - aci_cloud_ctx_profile: + cisco.aci.aci_cloud_ctx_profile: <<: *aci_info tenant: ansible_test cloud: "{{ cloud_type }}" @@ -200,7 +200,7 @@ register: nm_add_another_aci_ctx_profile - name: Verify nm_add_another_aci_ctx_profile - assert: + ansible.builtin.assert: that: - nm_add_another_aci_ctx_profile is changed - nm_add_another_aci_ctx_profile.previous == [] @@ -212,7 +212,7 @@ - nm_add_another_aci_ctx_profile.current[0].cloudCtxProfile.attributes.descr == "add ctx_profile_2" - name: Query aci cloud context profile ctx_profile_1 - aci_cloud_ctx_profile: + cisco.aci.aci_cloud_ctx_profile: <<: *aci_info tenant: ansible_test name: ctx_profile_1 @@ -220,28 +220,28 @@ register: query_aci_cloud_profile_1 - name: Verify query_aci_cloud_profile_1 - assert: + ansible.builtin.assert: that: - query_aci_cloud_profile_1 is not changed - query_aci_cloud_profile_1.current[0].cloudCtxProfile.attributes.name == "ctx_profile_1" - query_aci_cloud_profile_1.current[0].cloudCtxProfile.children | length == 3 - name: Query all aci cloud context profiles - aci_cloud_ctx_profile: + cisco.aci.aci_cloud_ctx_profile: <<: *aci_info tenant: ansible_test state: query register: query_all - name: Verify query_all - assert: + ansible.builtin.assert: that: - query_all is not changed - query_all.current | length == 1 - query_all.current.0.fvTenant.children | length == 2 - name: Remove aci cloud context profile - aci_cloud_ctx_profile: + cisco.aci.aci_cloud_ctx_profile: <<: *aci_info tenant: ansible_test name: ctx_profile_1 @@ -249,7 +249,7 @@ register: rm_ctx_profile - name: Verify rm_ctx_profile - assert: + ansible.builtin.assert: that: - rm_ctx_profile.current == [] - rm_ctx_profile.previous.0.cloudCtxProfile.attributes.name == "ctx_profile_1" diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_cloud_epg/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_cloud_epg/tasks/main.yml index 966b6afc2..b8804bad7 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_cloud_epg/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_cloud_epg/tasks/main.yml @@ -4,12 +4,12 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: "{{ aci_hostname }}" username: "{{ aci_username }}" @@ -20,7 +20,7 @@ output_level: '{{ aci_output_level | default("info") }}' - name: Verify Cloud and Non-Cloud Sites in use. - include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml - name: Execute tasks only for cloud sites when: query_cloud.current | length > 0 # This condition will execute only cloud sites @@ -89,7 +89,7 @@ register: nm_another_epg_present - name: Verify cloud epg creation - assert: + ansible.builtin.assert: that: - cm_epg_present is changed - nm_epg_present is changed @@ -129,7 +129,7 @@ # register: create_no_vrf - name: Veirfy update_cloud_epg - assert: + ansible.builtin.assert: that: - update_cloud_epg is changed - update_cloud_epg.current.0.cloudEPg.children.0.cloudRsCloudEPgCtx.attributes.tnFvCtxName == 'anstest_2' @@ -152,7 +152,7 @@ register: query_all - name: Verify query - assert: + ansible.builtin.assert: that: - cloud_epg_query is not changed - cloud_epg_query.current.0.cloudEPg.attributes.name == 'anstest' @@ -178,7 +178,7 @@ register: cloud_epg_absent_again - name: Verify deletion - assert: + ansible.builtin.assert: that: - cloud_epg_absent is changed - cloud_epg_absent.current == [] diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_cloud_epg_selector/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_cloud_epg_selector/tasks/main.yml index c1261eae7..194a35fea 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_cloud_epg_selector/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_cloud_epg_selector/tasks/main.yml @@ -4,12 +4,12 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: "{{ aci_hostname }}" username: "{{ aci_username }}" @@ -20,7 +20,7 @@ output_level: '{{ aci_output_level | default("info") }}' - name: Verify Cloud and Non-Cloud Sites in use. - include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml - name: Execute tasks only for cloud sites when: query_cloud.current | length > 0 # This condition will execute only cloud sites @@ -92,7 +92,7 @@ register: selector_present_again - name: Verify creation of cloud epg selector - assert: + ansible.builtin.assert: that: - cm_selector_present is changed - nm_selector_present is changed @@ -174,7 +174,7 @@ register: equals_without_value - name: Verify creation of other selectors - assert: + ansible.builtin.assert: that: - sec_selector is changed - udpate_selector is changed @@ -204,7 +204,7 @@ register: query_all - name: Verify query - assert: + ansible.builtin.assert: that: - query_selector.current.0.cloudEPSelector.attributes.name == 'ansible_selector' - query_all.current.0.cloudEPg.children | length >= 2 @@ -225,7 +225,7 @@ register: rm_selector_2_again - name: Verify rm_selector_2 - assert: + ansible.builtin.assert: that: - rm_selector_2 is changed - rm_selector_2.current == [] diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_cloud_external_epg/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_cloud_external_epg/tasks/main.yml index b9511e98f..e3676759f 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_cloud_external_epg/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_cloud_external_epg/tasks/main.yml @@ -4,12 +4,12 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: "{{ aci_hostname }}" username: "{{ aci_username }}" @@ -20,7 +20,7 @@ output_level: '{{ aci_output_level | default("info") }}' - name: Verify Cloud and Non-Cloud Sites in use. - include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml - name: Execute tasks only for cloud sites when: query_cloud.current | length > 0 # This condition will execute only cloud sites @@ -92,7 +92,7 @@ register: nm_epg_present_again - name: Verify cloud external epg creation - assert: + ansible.builtin.assert: that: - cm_epg_present is changed - nm_epg_present is changed @@ -116,7 +116,7 @@ register: nm_another_epg_present - name: Verify another cloud external epg creation - assert: + ansible.builtin.assert: that: - nm_another_epg_present is changed - nm_another_epg_present.previous == [] @@ -135,7 +135,7 @@ register: no_vrf - name: Veirfy update_cloud_ext_epg - assert: + ansible.builtin.assert: that: - update_cloud_ext_epg is changed - update_cloud_ext_epg.current.0.cloudExtEPg.children.0.cloudRsCloudEPgCtx.attributes.tnFvCtxName == 'anstest_2' @@ -158,7 +158,7 @@ register: query_all - name: Verify query - assert: + ansible.builtin.assert: that: - cloud_ext_epg_query is not changed - cloud_ext_epg_query.current.0.cloudExtEPg.attributes.name == 'anstest' @@ -184,7 +184,7 @@ register: cloud_ext_epg_absent_again - name: Verify deletion - assert: + ansible.builtin.assert: that: - cloud_ext_epg_absent is changed - cloud_ext_epg_absent.current == [] diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_cloud_external_epg_selector/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_cloud_external_epg_selector/tasks/main.yml index 21260c054..671638a66 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_cloud_external_epg_selector/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_cloud_external_epg_selector/tasks/main.yml @@ -4,12 +4,12 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: "{{ aci_hostname }}" username: "{{ aci_username }}" @@ -20,7 +20,7 @@ output_level: '{{ aci_output_level | default("info") }}' - name: Verify Cloud and Non-Cloud Sites in use. - include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml - name: Execute tasks only for cloud sites when: query_cloud.current | length > 0 # This condition will execute only cloud sites @@ -103,7 +103,7 @@ register: nm_epg_present_again - name: Verify cloud external epg creation - assert: + ansible.builtin.assert: that: - cm_epg_present is changed - nm_epg_present is changed @@ -126,7 +126,7 @@ register: nm_another_epg_present - name: Verify another cloud external epg creation - assert: + ansible.builtin.assert: that: - nm_another_epg_present is changed - nm_another_epg_present.previous == [] @@ -153,7 +153,7 @@ register: query_all - name: Verify query - assert: + ansible.builtin.assert: that: - query_all is not changed - query_all.current.0.cloudExtEPg.children | length >= 2 @@ -175,7 +175,7 @@ register: cloud_ext_epg_absent_again - name: Verify deletion - assert: + ansible.builtin.assert: that: - cloud_ext_epg_absent is changed - cloud_ext_epg_absent.current == [] diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_cloud_provider/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_cloud_provider/tasks/main.yml index 9cc4c87b7..6b1547a8a 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_cloud_provider/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_cloud_provider/tasks/main.yml @@ -4,13 +4,13 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined # CLEAN ENVIRONMENT - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: "{{ aci_hostname }}" username: "{{ aci_username }}" @@ -21,7 +21,7 @@ output_level: '{{ aci_output_level | default("info") }}' - name: Query system information - aci_system: + cisco.aci.aci_system: <<: *aci_info id: 1 state: query @@ -29,25 +29,25 @@ # QUERY OBJECTS - name: Query cloud provider object - aci_cloud_provider: + cisco.aci.aci_cloud_provider: <<: *aci_info state: query register: query_cloud when: version.current.0.topSystem.attributes.version is version('4.1', '>=') - name: Set vars - set_fact: + ansible.builtin.set_fact: query_cloud: current: [] when: version.current.0.topSystem.attributes.version is version('4.1', '<') - name: Verify query_cloud for all sites - assert: + ansible.builtin.assert: that: - query_cloud is not changed - name: Verify query_cloud for Cloud Sites - assert: + ansible.builtin.assert: that: - query_cloud is not changed - query_cloud.current.0.cloudProvP.attributes.environment == "public-cloud" diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_cloud_region/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_cloud_region/tasks/main.yml index f4c19c3f7..ab2384791 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_cloud_region/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_cloud_region/tasks/main.yml @@ -4,13 +4,13 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined # CLEAN ENVIRONMENT - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: "{{ aci_hostname }}" username: "{{ aci_username }}" @@ -21,20 +21,20 @@ output_level: '{{ aci_output_level | default("info") }}' - name: Verify Cloud and Non-Cloud Sites in use. - include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml - name: Execute tasks only for cloud sites when: query_cloud.current | length > 0 # This condition will execute only cloud sites block: # block specifies execution of tasks within, based on conditions - name: Query all regions - aci_cloud_region: + cisco.aci.aci_cloud_region: <<: *aci_info cloud: "{{ cloud_type }}" state: query register: query_all - name: Verify query_all - assert: + ansible.builtin.assert: that: - query_all is not changed - query_all.current.0.cloudProvP.attributes.dn == "uni/clouddomp/provp-{{cloud_type}}" @@ -43,7 +43,7 @@ when: query_all.current != [] - name: Query a specific region - aci_cloud_region: + cisco.aci.aci_cloud_region: <<: *aci_info cloud: "{{ cloud_type }}" region: "{{ region_2 }}" @@ -51,7 +51,7 @@ register: query_region - name: Verify query_region - assert: + ansible.builtin.assert: that: - query_region is not changed - query_region.current.0.cloudRegion.attributes.adminSt == "managed" @@ -60,7 +60,7 @@ when: query_region.current != [] - name: Query non_existing region - aci_cloud_region: + cisco.aci.aci_cloud_region: <<: *aci_info cloud: "{{ cloud_type }}" region: non_existing @@ -68,7 +68,7 @@ register: query_non_existing_region - name: Verify query_non_existing_region - assert: + ansible.builtin.assert: that: - query_non_existing_region is not changed - query_non_existing_region.current == [] diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_cloud_subnet/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_cloud_subnet/tasks/main.yml index e438b4144..8e6a9a15a 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_cloud_subnet/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_cloud_subnet/tasks/main.yml @@ -1,16 +1,17 @@ # Test code for the ACI modules # Copyright: (c) 2020, Cindy Zhao (@cizhao) <cizhao@cisco.com> +# Copyright: (c) 2024, Samita Bhattacharjee (@samitab) <samitab@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 APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined -# CLEAN ENVIRONMENT +# SET VARS - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: "{{ aci_hostname }}" username: "{{ aci_username }}" @@ -21,177 +22,193 @@ output_level: '{{ aci_output_level | default("info") }}' - name: Verify Cloud and Non-Cloud Sites in use. - include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml - name: Execute tasks only for cloud sites when: query_cloud.current | length > 0 # This condition will execute only cloud sites block: # block specifies execution of tasks within, based on conditions - name: Ensure tenant doesn't exist - aci_tenant: + cisco.aci.aci_tenant: <<: *aci_info state: absent tenant: ansible_test register: tenant_absent - - name: Ensure tenant exists for tests to kick off - aci_tenant: - <<: *aci_info - state: present - tenant: ansible_test - register: tenant_present + # CLEAN ENVIRONMENT - - name: Ensure aci cloud context profile does not exists - aci_cloud_ctx_profile: + - name: Remove aci cloud context profile + cisco.aci.aci_cloud_ctx_profile: <<: *aci_info tenant: ansible_test name: ctx_profile_1 state: absent - register: rm_ctx_profile_1 - - - name: Verify rm_ctx_profile_1 - assert: - that: - - rm_ctx_profile_1.current == [] - - name: Create aci cloud context profile (normal mode) - aci_cloud_ctx_profile: + - name: Remove ansible_test + cisco.aci.aci_tenant: &aci_tenant_absent <<: *aci_info tenant: ansible_test + state: absent + + - name: Create ansible_test + cisco.aci.aci_tenant: &aci_tenant + <<: *aci_tenant_absent + state: present + + - name: Create aci cloud context profile + cisco.aci.aci_cloud_ctx_profile: + <<: *aci_tenant cloud: "{{ cloud_type }}" name: ctx_profile_1 vrf: ctx_profile_vrf_1 region: "{{ region_2 }}" primary_cidr: '10.50.0.0/16' state: present - register: nm_add_aci_ctx_profile + + # CREATION TASKS - name: Create aci cloud subnet (check_mode) - aci_cloud_subnet: - <<: *aci_info - tenant: ansible_test + cisco.aci.aci_cloud_subnet: &aci_cloud_subnet + <<: *aci_tenant cloud_context_profile: ctx_profile_1 cidr: '10.50.0.0/16' availability_zone: "{{ availability_zone | default(omit) }}" + azure_region: "{{ az_region | default(omit) }}" + vnet_gateway: "{{ vnet_gateway | default(omit) }}" address: 10.50.0.1 description: test description check_mode: true register: cm_add_subnet - name: Create aci cloud subnet (normal_mode) - aci_cloud_subnet: - <<: *aci_info - tenant: ansible_test - cloud_context_profile: ctx_profile_1 - cidr: '10.50.0.0/16' - availability_zone: "{{ availability_zone | default(omit) }}" - address: 10.50.0.1 - description: test description + cisco.aci.aci_cloud_subnet: + <<: *aci_cloud_subnet register: nm_add_subnet - - name: Verify cm_add_subnet - assert: + - name: Create aci cloud subnet again (normal_mode) + cisco.aci.aci_cloud_subnet: + <<: *aci_cloud_subnet + register: nm_add_subnet_again + + - name: Create aci cloud subnet with invalid zone/region + cisco.aci.aci_cloud_subnet: + <<: *aci_cloud_subnet + availability_zone: us-west-1a + azure_region: westus2 + ignore_errors: true + register: nm_invalid_subnet_zone + + - name: Verify create tasks + ansible.builtin.assert: that: - cm_add_subnet is changed + - cm_add_subnet.current == [] - cm_add_subnet.previous == [] - cm_add_subnet.proposed.cloudSubnet.attributes.ip == "10.50.0.1" - cm_add_subnet.proposed.cloudSubnet.attributes.descr == "test description" - cm_add_subnet.proposed.cloudSubnet.attributes.dn == "uni/tn-ansible_test/ctxprofile-ctx_profile_1/cidr-[10.50.0.0/16]/subnet-[10.50.0.1]" - - - name: Create aci cloud subnet again (normal_mode) - aci_cloud_subnet: - <<: *aci_info - tenant: ansible_test - cloud_context_profile: ctx_profile_1 - cidr: '10.50.0.0/16' - availability_zone: "{{ availability_zone | default(omit) }}" - address: 10.50.0.1 - description: test description - register: nm_add_subnet_again - - - name: Verify nm_add_subnet_again - assert: - that: + - cm_add_subnet.proposed.cloudSubnet.attributes.annotation == "orchestrator:ansible" + - cm_add_subnet.proposed.cloudSubnet.attributes.scope == "private" + - nm_add_subnet is changed + - nm_add_subnet.current.0.cloudSubnet.attributes.ip == "10.50.0.1" + - nm_add_subnet.current.0.cloudSubnet.attributes.descr == "test description" + - nm_add_subnet.current.0.cloudSubnet.attributes.dn == "uni/tn-ansible_test/ctxprofile-ctx_profile_1/cidr-[10.50.0.0/16]/subnet-[10.50.0.1]" + - nm_add_subnet.current.0.cloudSubnet.attributes.annotation == "orchestrator:ansible" + - nm_add_subnet.current.0.cloudSubnet.attributes.scope == "private" + - nm_add_subnet.previous == [] - nm_add_subnet_again is not changed + - nm_add_subnet_again.current.0.cloudSubnet.attributes.ip == "10.50.0.1" + - nm_add_subnet_again.current.0.cloudSubnet.attributes.descr == "test description" + - nm_add_subnet_again.current.0.cloudSubnet.attributes.dn == "uni/tn-ansible_test/ctxprofile-ctx_profile_1/cidr-[10.50.0.0/16]/subnet-[10.50.0.1]" + - nm_add_subnet_again.current.0.cloudSubnet.attributes.annotation == "orchestrator:ansible" + - nm_add_subnet_again.current.0.cloudSubnet.attributes.scope == "private" + - nm_add_subnet_again.previous.0.cloudSubnet.attributes.ip == "10.50.0.1" + - nm_add_subnet_again.previous.0.cloudSubnet.attributes.descr == "test description" + - nm_add_subnet_again.previous.0.cloudSubnet.attributes.dn == "uni/tn-ansible_test/ctxprofile-ctx_profile_1/cidr-[10.50.0.0/16]/subnet-[10.50.0.1]" + - nm_add_subnet_again.previous.0.cloudSubnet.attributes.annotation == "orchestrator:ansible" + - nm_add_subnet_again.previous.0.cloudSubnet.attributes.scope == "private" + - nm_invalid_subnet_zone.msg == "parameters are mutually exclusive{{":"}} aws_availability_zone|azure_region" - - name: Create another cloud subnet (normal_mode) - aci_cloud_subnet: - <<: *aci_info - tenant: ansible_test - cloud_context_profile: ctx_profile_1 - cidr: '10.50.0.0/16' - availability_zone: "{{ availability_zone | default(omit) }}" - address: 10.50.0.2 - description: another subnet - register: nm_add_another_subnet + - name: Verify create tasks for Azure + ansible.builtin.assert: + that: + - cm_add_subnet.proposed.cloudSubnet.attributes.usage == "gateway" + - cm_add_subnet.proposed.cloudSubnet.children.0.cloudRsZoneAttach.attributes.tDn == "uni/clouddomp/provp-azure/region-westus2/zone-default" + - nm_add_subnet.current.0.cloudSubnet.attributes.usage == "gateway" + - nm_add_subnet.current.0.cloudSubnet.children.0.cloudRsZoneAttach.attributes.tDn == "uni/clouddomp/provp-azure/region-westus2/zone-default" + - nm_add_subnet_again.current.0.cloudSubnet.attributes.usage == "gateway" + - nm_add_subnet_again.current.0.cloudSubnet.children.0.cloudRsZoneAttach.attributes.tDn == "uni/clouddomp/provp-azure/region-westus2/zone-default" + - nm_add_subnet_again.previous.0.cloudSubnet.attributes.usage == "gateway" + - nm_add_subnet_again.previous.0.cloudSubnet.children.0.cloudRsZoneAttach.attributes.tDn == "uni/clouddomp/provp-azure/region-westus2/zone-default" + when: az_region is defined and vnet_gateway is defined - - name: Verify nm_add_another_subnet - assert: + - name: Verify create tasks for AWS + ansible.builtin.assert: that: - - nm_add_another_subnet is changed - - nm_add_another_subnet.previous == [] - - nm_add_another_subnet.current.0.cloudSubnet.attributes.annotation == 'orchestrator:ansible' - - nm_add_another_subnet.current.0.cloudSubnet.attributes.descr == "another subnet" - - nm_add_another_subnet.current.0.cloudSubnet.attributes.dn == "uni/tn-ansible_test/ctxprofile-ctx_profile_1/cidr-[10.50.0.0/16]/subnet-[10.50.0.2]" + - cm_add_subnet.proposed.cloudSubnet.attributes.usage == "user" + - cm_add_subnet.proposed.cloudSubnet.children.0.cloudRsZoneAttach.attributes.tDn == "uni/clouddomp/provp-aws/region-us-west-1/zone-a" + - nm_add_subnet.current.0.cloudSubnet.attributes.usage == "user" + - nm_add_subnet.current.0.cloudSubnet.children.0.cloudRsZoneAttach.attributes.tDn == "uni/clouddomp/provp-aws/region-us-west-1/zone-a" + - nm_add_subnet_again.current.0.cloudSubnet.attributes.usage == "user" + - nm_add_subnet_again.current.0.cloudSubnet.children.0.cloudRsZoneAttach.attributes.tDn == "uni/clouddomp/provp-aws/region-us-west-1/zone-a" + - nm_add_subnet_again.previous.0.cloudSubnet.attributes.usage == "user" + - nm_add_subnet_again.previous.0.cloudSubnet.children.0.cloudRsZoneAttach.attributes.tDn == "uni/clouddomp/provp-aws/region-us-west-1/zone-a" + when: availability_zone is defined - - name: Create cloud subnet 3(normal_mode) - aci_cloud_subnet: - <<: *aci_info - tenant: ansible_test - cloud_context_profile: ctx_profile_1 - cidr: '10.50.0.0/16' - availability_zone: "{{ availability_zone | default(omit) }}" - address: 10.50.0.3 - name: subnet_3 - register: nm_add_subnet_3 + # UPDATE TASKS - - name: Specify subnet as VpnGateway enabled - aci_cloud_subnet: - <<: *aci_info - tenant: ansible_test - cloud_context_profile: ctx_profile_1 - cidr: '10.50.0.0/16' - availability_zone: "{{ availability_zone | default(omit) }}" - address: 10.50.0.1 - # name: subnet_1 - description: change subnet 1 - vnet_gateway: "{{ vnet_gateway | default(omit)}}" - #scope: public - register: nm_change_subnet_1 + - name: Update aci cloud subnet + cisco.aci.aci_cloud_subnet: + <<: *aci_cloud_subnet + description: test description 2 + register: nm_update_subnet - # Enable vpn_gateway router in cloud ctx profile - - name: Enable VpnGateway - aci_cloud_vpn_gateway: - <<: *aci_info - tenant: ansible_test - cloud_context_profile: ctx_profile_1 - state: present + - name: Verify aci cloud subnet update + ansible.builtin.assert: + that: + - nm_update_subnet is changed + - nm_update_subnet.current.0.cloudSubnet.attributes.ip == "10.50.0.1" + - nm_update_subnet.current.0.cloudSubnet.attributes.descr == "test description 2" + - nm_update_subnet.current.0.cloudSubnet.attributes.dn == "uni/tn-ansible_test/ctxprofile-ctx_profile_1/cidr-[10.50.0.0/16]/subnet-[10.50.0.1]" + - nm_update_subnet.current.0.cloudSubnet.attributes.annotation == "orchestrator:ansible" + - nm_update_subnet.current.0.cloudSubnet.attributes.scope == "private" + - nm_update_subnet.previous.0.cloudSubnet.attributes.ip == "10.50.0.1" + - nm_update_subnet.previous.0.cloudSubnet.attributes.descr == "test description" + - nm_update_subnet.previous.0.cloudSubnet.attributes.dn == "uni/tn-ansible_test/ctxprofile-ctx_profile_1/cidr-[10.50.0.0/16]/subnet-[10.50.0.1]" + - nm_update_subnet.previous.0.cloudSubnet.attributes.annotation == "orchestrator:ansible" + - nm_update_subnet.previous.0.cloudSubnet.attributes.scope == "private" - # Try to disable vpn_gateway router again in cloud ctx profile - - name: Disable VpnGateway - aci_cloud_vpn_gateway: - <<: *aci_info - tenant: ansible_test - cloud_context_profile: ctx_profile_1 - state: absent + # QUERY TASKS + + - name: Create extra subnets for query + cisco.aci.aci_cloud_subnet: + <<: *aci_cloud_subnet + cidr: 10.50.0.0/16 + vnet_gateway: false + address: "{{ item }}" + loop: + - 10.50.0.2 + - 10.50.0.3 - name: Query all subnets - aci_cloud_subnet: - <<: *aci_info - tenant: ansible_test + cisco.aci.aci_cloud_subnet: + <<: *aci_tenant cloud_context_profile: ctx_profile_1 cidr: '10.50.0.0/16' state: query register: query_all - name: Verify query_all - assert: + ansible.builtin.assert: that: - query_all is not changed - query_all.current.0.cloudCidr.attributes.addr == "10.50.0.0/16" - query_all.current.0.cloudCidr.children | length == 3 + - query_all.current.0.cloudCidr.children.0.cloudSubnet.attributes.ip == "10.50.0.3" + - query_all.current.0.cloudCidr.children.1.cloudSubnet.attributes.ip == "10.50.0.2" + - query_all.current.0.cloudCidr.children.2.cloudSubnet.attributes.ip == "10.50.0.1" - name: Query a specific subnet - aci_cloud_subnet: + cisco.aci.aci_cloud_subnet: <<: *aci_info tenant: ansible_test cloud_context_profile: ctx_profile_1 @@ -201,61 +218,50 @@ register: query_subnet_1 - name: Verify query_subnet_1 - assert: + ansible.builtin.assert: that: - query_subnet_1 is not changed - query_subnet_1.current.0.cloudSubnet.attributes.ip == "10.50.0.1" - query_subnet_1.current.0.cloudSubnet.attributes.scope == "private" - query_subnet_1.current.0.cloudSubnet.attributes.dn == "uni/tn-ansible_test/ctxprofile-ctx_profile_1/cidr-[10.50.0.0/16]/subnet-[10.50.0.1]" - - name: Remove subnet 3 (check_mode) - aci_cloud_subnet: - <<: *aci_info - tenant: ansible_test - cloud_context_profile: ctx_profile_1 - cidr: '10.50.0.0/16' - address: 10.50.0.3 + # DELETE TASKS + + - name: Remove cloud subnet (check_mode) + cisco.aci.aci_cloud_subnet: + <<: *aci_cloud_subnet state: absent check_mode: true - register: cm_remove_subnet_3 + register: cm_remove_subnet - - name: Verify cm_remove_subnet_3 - assert: - that: - - cm_remove_subnet_3 is changed - - cm_remove_subnet_3.proposed == {} - - cm_remove_subnet_3.previous.0.cloudSubnet.attributes.ip == "10.50.0.3" - - - name: Remove subnet 3 (normal_mode) - aci_cloud_subnet: - <<: *aci_info - tenant: ansible_test - cloud_context_profile: ctx_profile_1 - cidr: '10.50.0.0/16' - address: 10.50.0.3 + - name: Remove cloud subnet (normal_mode) + cisco.aci.aci_cloud_subnet: + <<: *aci_cloud_subnet state: absent - register: nm_remove_subnet_3 - - - name: Verify nm_remove_subnet_3 - assert: - that: - - nm_remove_subnet_3 is changed - - nm_remove_subnet_3.current == [] - - nm_remove_subnet_3.previous.0.cloudSubnet.attributes.ip == "10.50.0.3" + register: nm_remove_subnet - - name: Remove subnet 3 again - aci_cloud_subnet: - <<: *aci_info - tenant: ansible_test - cloud_context_profile: ctx_profile_1 - cidr: '10.50.0.0/16' - address: 10.50.0.3 + - name: Remove cloud subnet again (normal_mode) + cisco.aci.aci_cloud_subnet: + <<: *aci_cloud_subnet state: absent - register: nm_remove_subnet_3_again + register: nm_remove_subnet_again - - name: Verify nm_remove_subnet_3_again - assert: + - name: Verify remove cloud subnet + ansible.builtin.assert: that: - - nm_remove_subnet_3_again is not changed - - nm_remove_subnet_3_again.previous == [] - - nm_remove_subnet_3_again.current == [] + - cm_remove_subnet is changed + - cm_remove_subnet.proposed == {} + - cm_remove_subnet.previous.0.cloudSubnet.attributes.ip == "10.50.0.1" + - cm_remove_subnet.previous.0.cloudSubnet.attributes.dn == "uni/tn-ansible_test/ctxprofile-ctx_profile_1/cidr-[10.50.0.0/16]/subnet-[10.50.0.1]" + - nm_remove_subnet is changed + - nm_remove_subnet.current == [] + - nm_remove_subnet.previous.0.cloudSubnet.attributes.ip == "10.50.0.1" + - nm_remove_subnet.previous.0.cloudSubnet.attributes.dn == "uni/tn-ansible_test/ctxprofile-ctx_profile_1/cidr-[10.50.0.0/16]/subnet-[10.50.0.1]" + - nm_remove_subnet_again is not changed + - nm_remove_subnet_again.previous == [] + - nm_remove_subnet_again.current == [] + + # CLEAN ENVIRONMENT + - name: Remove ansible_test + cisco.aci.aci_tenant: + <<: *aci_tenant_absent
\ No newline at end of file diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_cloud_vpn_gateway/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_cloud_vpn_gateway/tasks/main.yml index 834331a03..f1b0683fc 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_cloud_vpn_gateway/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_cloud_vpn_gateway/tasks/main.yml @@ -4,13 +4,13 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined # CLEAN ENVIRONMENT - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: "{{ aci_hostname }}" username: "{{ aci_username }}" @@ -21,27 +21,27 @@ output_level: '{{ aci_output_level | default("info") }}' - name: Verify Cloud and Non-Cloud Sites in use. - include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml - name: Execute tasks only for cloud sites when: query_cloud.current | length > 0 # This condition will execute only cloud sites block: # block specifies execution of tasks within, based on conditions - name: Ensure tenant doesn't exist - aci_tenant: + cisco.aci.aci_tenant: <<: *aci_info state: absent tenant: ansible_test register: tenant_absent - name: Ensure tenant exists for tests to kick off - aci_tenant: + cisco.aci.aci_tenant: <<: *aci_info state: present tenant: ansible_test register: tenant_present - name: Ensure aci cloud context profile does not exists - aci_cloud_ctx_profile: + cisco.aci.aci_cloud_ctx_profile: <<: *aci_info tenant: ansible_test name: ctx_profile_1 @@ -49,12 +49,12 @@ register: rm_ctx_profile_1 - name: Verify rm_ctx_profile_1 - assert: + ansible.builtin.assert: that: - rm_ctx_profile_1.current == [] - name: Create aci cloud context profile (normal mode) - aci_cloud_ctx_profile: + cisco.aci.aci_cloud_ctx_profile: <<: *aci_info tenant: ansible_test cloud: "{{ cloud_type }}" @@ -66,7 +66,7 @@ register: nm_add_aci_ctx_profile - name: Create aci cloud subnet with VpnGateway enabled (normal_mode) - aci_cloud_subnet: + cisco.aci.aci_cloud_subnet: <<: *aci_info tenant: ansible_test cloud_context_profile: ctx_profile_1 @@ -79,35 +79,35 @@ register: nm_add_subnet - name: Enable VpnGateway - aci_cloud_vpn_gateway: + cisco.aci.aci_cloud_vpn_gateway: <<: *aci_info tenant: ansible_test cloud_context_profile: ctx_profile_1 state: present - name: Disable VpnGateway - aci_cloud_vpn_gateway: + cisco.aci.aci_cloud_vpn_gateway: <<: *aci_info tenant: ansible_test cloud_context_profile: ctx_profile_1 state: absent - name: Enable VpnGateway again - aci_cloud_vpn_gateway: + cisco.aci.aci_cloud_vpn_gateway: <<: *aci_info tenant: ansible_test cloud_context_profile: ctx_profile_1 state: present - name: Query VpnGateway - aci_cloud_vpn_gateway: + cisco.aci.aci_cloud_vpn_gateway: <<: *aci_info tenant: ansible_test cloud_context_profile: ctx_profile_1 register: query_vpn_gateway - name: Verify VpnGateway - assert: + ansible.builtin.assert: that: - query_vpn_gateway is not changed - query_vpn_gateway.current.0.cloudRouterP.children | length == 3 diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_cloud_zone/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_cloud_zone/tasks/main.yml index 85a2ec087..09a1d18db 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_cloud_zone/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_cloud_zone/tasks/main.yml @@ -4,13 +4,13 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined # CLEAN ENVIRONMENT - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: "{{ aci_hostname }}" username: "{{ aci_username }}" @@ -21,13 +21,13 @@ output_level: '{{ aci_output_level | default("info") }}' - name: Verify Cloud and Non-Cloud Sites in use. - include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml - name: Execute tasks only for cloud sites when: query_cloud.current | length > 0 # This condition will execute only cloud sites block: # block specifies execution of tasks within, based on conditions - name: Query all zones under us-west-1 - aci_cloud_zone: + cisco.aci.aci_cloud_zone: <<: *aci_info cloud: "{{ cloud_type }}" region: "{{ region_2 }}" @@ -35,14 +35,14 @@ register: query_all - name: Verify query_all - assert: + ansible.builtin.assert: that: - query_all is not changed - query_all.current.0.cloudRegion.attributes.name == "{{region_2}}" - query_all.current.0.cloudRegion.children | length >= 1 - name: Query a specific zone under region us-west-1 - aci_cloud_zone: + cisco.aci.aci_cloud_zone: <<: *aci_info cloud: "{{ cloud_type }}" region: "{{ region_2 }}" @@ -51,7 +51,7 @@ register: query_zone_1 - name: Query another specific zone under region us-west-1 - aci_cloud_zone: + cisco.aci.aci_cloud_zone: <<: *aci_info cloud: "{{ cloud_type }}" region: "{{ region_2 }}" @@ -60,7 +60,7 @@ register: query_zone_2 - name: Verify query_zone_1 and query_zone_2 - assert: + ansible.builtin.assert: that: - query_zone_1 is not changed - query_zone_2 is not changed @@ -71,7 +71,7 @@ when: query_zone_1.current != [] and query_zone_2.current != [] - name: Query non_existing zone under region us-west-1 - aci_cloud_zone: + cisco.aci.aci_cloud_zone: <<: *aci_info cloud: "{{ cloud_type }}" region: "{{ region_2 }}" @@ -80,7 +80,7 @@ register: query_non_existing_zone - name: Query zone under non_existing region - aci_cloud_zone: + cisco.aci.aci_cloud_zone: <<: *aci_info cloud: "{{ cloud_type }}" region: non_existing @@ -89,7 +89,7 @@ register: query_non_existing_region - name: Verify query_non_existing_zone - assert: + ansible.builtin.assert: that: - query_non_existing_zone is not changed - query_non_existing_zone.current == [] diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_config_export_policy/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_config_export_policy/tasks/main.yml index bb290aa5f..ad4389e94 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_config_export_policy/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_config_export_policy/tasks/main.yml @@ -3,7 +3,7 @@ # SET VARS - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: '{{ aci_hostname }}' username: '{{ aci_username }}' diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_config_rollback/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_config_rollback/tasks/main.yml index 9b43c9cfc..c96a2c1e9 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_config_rollback/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_config_rollback/tasks/main.yml @@ -4,7 +4,7 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined @@ -21,7 +21,7 @@ tenant: ansible_test - name: Verify Cloud and Non-Cloud Sites in use. - include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml - name: create a snapshot cisco.aci.aci_config_snapshot: &create_snapshot @@ -43,7 +43,7 @@ register: create_snapshot_annotation_check - name: waiting for snapshot to be finished before querying - pause: + ansible.builtin.pause: seconds: 10 - name: get snapshots @@ -142,7 +142,7 @@ register: rollback_rollback - name: pause execution to let rollback take effect - pause: + ansible.builtin.pause: seconds: 15 - name: ensure tenant doesn't exist after rollback @@ -154,7 +154,7 @@ msg: '{{ rollback_preview_json }}' - name: rollback assertions - assert: + ansible.builtin.assert: that: - rollback_preview_xml is not changed - '"ansible_test" in rollback_preview_xml.preview' diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_config_snapshot/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_config_snapshot/tasks/main.yml index c9415a86d..fc4f7d906 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_config_snapshot/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_config_snapshot/tasks/main.yml @@ -4,7 +4,7 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined @@ -46,7 +46,7 @@ register: missing_param - name: present assertion tests - assert: + ansible.builtin.assert: that: - create is not failed - create is changed @@ -72,7 +72,7 @@ register: query_export - name: generate snapshot name - set_fact: + ansible.builtin.set_fact: test_snapshot: "{{ query_export.current.0.configSnapshotCont.children.0.configSnapshot.attributes.rn.strip('snapshot-') }}" - name: query with export_policy and snapshot @@ -95,7 +95,7 @@ register: query_all - name: query assertion tests - assert: + ansible.builtin.assert: that: - query_export is not failed - query_export is not changed @@ -134,7 +134,7 @@ register: delete_missing_param - name: absent assertion tests - assert: + ansible.builtin.assert: that: - delete_snapshot is not failed - delete_snapshot is changed @@ -149,7 +149,7 @@ # Create, query and delete snapshot with certificate authentication Ref# 427 - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: "{{ aci_hostname }}" username: "{{ aci_username }}" @@ -178,7 +178,7 @@ register: create_private_key - name: creation assertion tests with private key - assert: + ansible.builtin.assert: that: - create_private_key is not failed - create_private_key is changed @@ -193,11 +193,11 @@ register: query_private_key - name: generate snapshot name using query_private_key - set_fact: + ansible.builtin.set_fact: test_snapshot_private_key: "{{ query_private_key.current.0.configSnapshotCont.children.0.configSnapshot.attributes.rn.strip('snapshot-') }}" - name: query assertion tests with private key - assert: + ansible.builtin.assert: that: - query_private_key is not failed - query_private_key is not changed @@ -213,7 +213,7 @@ register: delete_snapshot_private_key - name: delete assertion tests with the private key - assert: + ansible.builtin.assert: that: - delete_snapshot_private_key is not failed - delete_snapshot_private_key is changed diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_contract/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_contract/tasks/main.yml index 635f2d331..1093c6b8e 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_contract/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_contract/tasks/main.yml @@ -4,7 +4,7 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined @@ -57,7 +57,7 @@ register: present_missing_param - name: present assertions - assert: + ansible.builtin.assert: that: - present_check_mode is changed - present_check_mode.previous == [] @@ -99,7 +99,7 @@ register: query_all - name: query assertions - assert: + ansible.builtin.assert: that: - query_contract is not changed - query_contract.current | length == 1 @@ -147,7 +147,7 @@ register: absent_missing_param - name: absent assertions - assert: + ansible.builtin.assert: that: - absent_check_mode is changed - absent_check_mode.previous != [] diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_contract_export/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_contract_export/tasks/main.yml index 5a1139947..8bd55efef 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_contract_export/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_contract_export/tasks/main.yml @@ -3,7 +3,7 @@ # SET VARS - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: '{{ aci_hostname }}' username: '{{ aci_username }}' @@ -62,7 +62,7 @@ register: nm_add_intf - name: Verify add_intf - assert: + ansible.builtin.assert: that: - cm_add_intf is changed - nm_add_intf is changed @@ -76,7 +76,7 @@ register: add_intf_again - name: Verify add_intf_again - assert: + ansible.builtin.assert: that: - add_intf_again is not changed @@ -88,7 +88,7 @@ register: update_intf - name: Verify update_intf - assert: + ansible.builtin.assert: that: - update_intf is changed - update_intf.previous != [] @@ -108,7 +108,7 @@ register: query_all_intfs - name: Verify query_all_intfs - assert: + ansible.builtin.assert: that: - query_all_intfs is not changed - query_all_intfs.current|length > 1 @@ -121,7 +121,7 @@ register: query_spec_intf - name: Verify query_spec_intf - assert: + ansible.builtin.assert: that: - query_spec_intf is not changed - query_spec_intf.current|length == 1 @@ -134,7 +134,7 @@ register: remove_intf - name: Verify remove_intf - assert: + ansible.builtin.assert: that: - remove_intf is changed - remove_intf.current == [] diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_contract_subject/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_contract_subject/tasks/main.yml index b7d53844c..5b3600756 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_contract_subject/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_contract_subject/tasks/main.yml @@ -4,12 +4,12 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: "{{ aci_hostname }}" username: "{{ aci_username }}" @@ -83,7 +83,7 @@ register: present_missing_param - name: present assertions - assert: + ansible.builtin.assert: that: - subject_present_check_mode is changed - subject_present_check_mode.sent.vzSubj.attributes.descr == 'Ansible Test' @@ -157,7 +157,7 @@ register: query_all - name: query assertions - assert: + ansible.builtin.assert: that: - query_tenant_contract_subject is not changed - query_tenant_contract_subject.current | length == 1 @@ -234,7 +234,7 @@ register: absent_missing_param - name: absent assertions - assert: + ansible.builtin.assert: that: - subject_absent_check_mode is changed - subject_absent_check_mode.previous != [] @@ -289,7 +289,7 @@ register: nm_subject_present_one_way_again - name: subject assertions - assert: + ansible.builtin.assert: that: - cm_subject_present_both_default is changed - nm_subject_present_both_default is changed @@ -315,7 +315,7 @@ ignore_errors: true - name: subject assertions - assert: + ansible.builtin.assert: that: - nm_subject_reverse_to_one_way is not changed - nm_subject_reverse_to_one_way.msg == "Direction is not allowed, valid option is both." @@ -365,7 +365,7 @@ register: nm_subject_one_way_dscp_change - name: subject assertions - assert: + ansible.builtin.assert: that: - nm_subject_both_qos_dscp is changed - nm_subject_both_qos_dscp.current.0.vzSubj.attributes.prio == "level1" diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_contract_subject_to_filter/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_contract_subject_to_filter/tasks/main.yml index d21571692..39f209789 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_contract_subject_to_filter/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_contract_subject_to_filter/tasks/main.yml @@ -3,15 +3,15 @@ # 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 APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined - name: Verify Cloud and Non-Cloud Sites in use. - include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: "{{ aci_hostname }}" username: "{{ aci_username }}" @@ -98,7 +98,7 @@ register: present_missing_param - name: present assertions - assert: + ansible.builtin.assert: that: - subject_filter_present_check_mode is changed - subject_filter_present_check_mode.previous == [] @@ -137,7 +137,7 @@ register: query_binding_non_existing_subject - name: query assertions - assert: + ansible.builtin.assert: that: - query_all is not changed - query_all.current | length > 1 @@ -176,7 +176,7 @@ state: absent - name: absent assertions - assert: + ansible.builtin.assert: that: - subject_filter_absent_check_mode is changed - subject_filter_absent_check_mode.proposed == {} @@ -283,7 +283,7 @@ ignore_errors: true - name: filter assertions - assert: + ansible.builtin.assert: that: - cm_filter1_present_default is changed - nm_filter1_present_default is changed @@ -337,7 +337,7 @@ register: filter_present_deny_non_cloud_c2p - name: filter subject with direction assertions - assert: + ansible.builtin.assert: that: - filter_present_deny_non_cloud_both is changed - filter_present_deny_non_cloud_both.current.0.vzRsSubjFiltAtt.attributes.action == "deny" @@ -373,7 +373,7 @@ ignore_errors: true - name: cloud assertions - assert: + ansible.builtin.assert: that: - filter_present_deny_cloud.msg.startswith("APIC Error 1: Invalid Configuration CLOUD_ONLY_PERMIT_ACTION_SUPPORTED") - filter_present_deny_cloud_p2c.msg.startswith("APIC Error 1: Invalid Configuration CLOUD_ONLY_PERMIT_ACTION_SUPPORTED") diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_contract_subject_to_service_graph/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_contract_subject_to_service_graph/tasks/main.yml index c9e41610f..186f93a13 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_contract_subject_to_service_graph/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_contract_subject_to_service_graph/tasks/main.yml @@ -4,7 +4,7 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined @@ -71,7 +71,7 @@ register: present_missing_param - name: present assertions - assert: + ansible.builtin.assert: that: - subject_service_graph_present_check_mode is changed - subject_service_graph_present_check_mode.previous == [] @@ -101,7 +101,7 @@ register: query_binding - name: query assertions - assert: + ansible.builtin.assert: that: - query_all is not changed - query_all.current | length > 0 @@ -134,7 +134,7 @@ register: absent_missing_param - name: absent assertions - assert: + ansible.builtin.assert: that: - subject_service_graph_absent_check_mode is changed - subject_service_graph_absent_check_mode.proposed == {} diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_dhcp_option/aliases b/ansible_collections/cisco/aci/tests/integration/targets/aci_dhcp_option/aliases new file mode 100644 index 000000000..209b793f9 --- /dev/null +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_dhcp_option/aliases @@ -0,0 +1,2 @@ +# No ACI simulator yet, so not enabled +# unsupported diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_dhcp_option/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_dhcp_option/tasks/main.yml new file mode 100644 index 000000000..6e0f2e32e --- /dev/null +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_dhcp_option/tasks/main.yml @@ -0,0 +1,188 @@ +# Test code for the ACI modules +# Copyright: (c) 2023, Gaspard Micol (@gmicol) <gmicol@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 APIC host, ACI username and ACI password + ansible.builtin.fail: + msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' + when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined + +- name: Set vars + ansible.builtin.set_fact: + aci_info: &aci_info + host: "{{ aci_hostname }}" + username: "{{ aci_username }}" + password: "{{ aci_password }}" + validate_certs: '{{ aci_validate_certs | default(false) }}' + use_ssl: '{{ aci_use_ssl | default(true) }}' + use_proxy: '{{ aci_use_proxy | default(true) }}' + output_level: debug + +# CLEAN ENVIRONMENT BEFORE TESTS +- name: Remove the ansible_tenant + cisco.aci.aci_tenant: &aci_tenant_absent + <<: *aci_info + tenant: ansible_tenant + state: absent + +- name: Verify Cloud and Non-Cloud Sites in use. + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + +- name: Execute tasks only for non-cloud sites + when: query_cloud.current == [] # This condition will execute only non-cloud sites + block: # block specifies execution of tasks within, based on conditions + - name: Add a new tenant + cisco.aci.aci_tenant: &aci_tenant_present + <<: *aci_info + tenant: ansible_tenant + description: Ansible tenant + state: present + + - name: Add a new DHCP option policy + cisco.aci.aci_dhcp_option_policy: + <<: *aci_info + tenant: ansible_tenant + dhcp_option_policy: ansible_dhcp_option_policy_1 + description: DHCP option policy 1 for ansible_tenant tenant + state: present + + # CREATE DHCP OPTION + - name: Add a DHCP option (check_mode) + cisco.aci.aci_dhcp_option: &aci_dhcp_option_present + <<: *aci_info + tenant: ansible_tenant + dhcp_option_policy: ansible_dhcp_option_policy_1 + dhcp_option: ansible_dhcp_option_1 + id: 1 + data: 82 + state: present + check_mode: true + register: cm_add_dhcp_option + + - name: Add a DHCP option (normal_mode) + cisco.aci.aci_dhcp_option: + <<: *aci_dhcp_option_present + register: nm_add_dhcp_option + + - name: Add the first DHCP option again - testing idempotency + cisco.aci.aci_dhcp_option: + <<: *aci_dhcp_option_present + register: nm_add_dhcp_option_idempotency + + - name: Add a second DHCP option (normal_mode) + cisco.aci.aci_dhcp_option: + <<: *aci_info + tenant: ansible_tenant + dhcp_option_policy: ansible_dhcp_option_policy_1 + dhcp_option: ansible_dhcp_option_2 + id: 2 + data: 252 + state: present + register: nm_add_dhcp_option_2 + + - name: Asserts for DHCP option creation tasks + ansible.builtin.assert: + that: + - cm_add_dhcp_option is changed + - cm_add_dhcp_option.previous == [] + - cm_add_dhcp_option.current == [] + - nm_add_dhcp_option is changed + - nm_add_dhcp_option.current.0.dhcpOption.attributes.name == "ansible_dhcp_option_1" + - nm_add_dhcp_option.current.0.dhcpOption.attributes.id == "1" + - nm_add_dhcp_option.current.0.dhcpOption.attributes.data == "82" + - nm_add_dhcp_option_idempotency is not changed + - nm_add_dhcp_option_2 is changed + - nm_add_dhcp_option_2.previous == [] + - nm_add_dhcp_option_2.current.0.dhcpOption.attributes.name == "ansible_dhcp_option_2" + - nm_add_dhcp_option_2.current.0.dhcpOption.attributes.id == "2" + - nm_add_dhcp_option_2.current.0.dhcpOption.attributes.data == "252" + + # QUERY DHCP OPTION + - name: Query all DHCP options + cisco.aci.aci_dhcp_option: + <<: *aci_info + state: query + register: query_all_dhcp_option + + - name: Query ansible_dhcp_option_1 + cisco.aci.aci_dhcp_option: + <<: *aci_dhcp_option_present + state: query + register: query_ansible_dhcp_option_1 + + - name: Asserts query tasks + ansible.builtin.assert: + that: + - query_all_dhcp_option is not changed + - query_all_dhcp_option.current|length >= 2 + - query_ansible_dhcp_option_1 is not changed + - query_ansible_dhcp_option_1.current.0.dhcpOption.attributes.name == "ansible_dhcp_option_1" + - query_ansible_dhcp_option_1.current.0.dhcpOption.attributes.id == "1" + - query_ansible_dhcp_option_1.current.0.dhcpOption.attributes.data == "82" + + #UPDATING DHCP OPTION + - name: Update first DHCP option (check_mode) + cisco.aci.aci_dhcp_option: &aci_dhcp_option_update + <<: *aci_dhcp_option_present + id: 3 + data: 255 + state: present + check_mode: true + register: cm_update_dhcp_option + + - name: Update first DHCP option (normal_mode) + cisco.aci.aci_dhcp_option: + <<: *aci_dhcp_option_update + register: nm_update_dhcp_option + + - name: Update first DHCP option again - testing idempotency + cisco.aci.aci_dhcp_option: + <<: *aci_dhcp_option_update + register: nm_update_dhcp_option_idempotency + + - name: Asserts for DHCP option update tasks + ansible.builtin.assert: + that: + - cm_update_dhcp_option is changed + - cm_update_dhcp_option.previous == cm_update_dhcp_option.current + - nm_update_dhcp_option is changed + - nm_update_dhcp_option.current.0.dhcpOption.attributes.name == "ansible_dhcp_option_1" + - nm_update_dhcp_option.current.0.dhcpOption.attributes.id == "3" + - nm_update_dhcp_option.current.0.dhcpOption.attributes.data == "255" + - nm_update_dhcp_option_idempotency is not changed + + # DELETE DHCP OPTION + - name: Remove DHCP option (check_mode) + cisco.aci.aci_dhcp_option: &dhcp_option_absent + <<: *aci_dhcp_option_update + state: absent + check_mode: true + register: cm_remove_dhcp_option + + - name: Remove DHCP option (normal_mode) + cisco.aci.aci_dhcp_option: + <<: *dhcp_option_absent + register: nm_remove_dhcp_option + + - name: Remove DHCP option - testing idempotency + cisco.aci.aci_dhcp_option: + <<: *dhcp_option_absent + register: nm_remove_dhcp_option_idempotency + + - name: Asserts deletion tasks + ansible.builtin.assert: + that: + - cm_remove_dhcp_option is changed + - cm_remove_dhcp_option.proposed == {} + - nm_remove_dhcp_option is changed + - nm_remove_dhcp_option.previous != [] + - nm_remove_dhcp_option.method == "DELETE" + - nm_remove_dhcp_option_idempotency is not changed + - nm_remove_dhcp_option_idempotency.previous == [] + + # CLEAN ENVIRONMENT BEFORE ENDING TESTS + - name: Remove the ansible_tenant - cleanup before ending tests + cisco.aci.aci_tenant: + <<: *aci_tenant_present + state: absent diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_dhcp_option_policy/aliases b/ansible_collections/cisco/aci/tests/integration/targets/aci_dhcp_option_policy/aliases new file mode 100644 index 000000000..209b793f9 --- /dev/null +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_dhcp_option_policy/aliases @@ -0,0 +1,2 @@ +# No ACI simulator yet, so not enabled +# unsupported diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_dhcp_option_policy/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_dhcp_option_policy/tasks/main.yml new file mode 100644 index 000000000..48e721254 --- /dev/null +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_dhcp_option_policy/tasks/main.yml @@ -0,0 +1,139 @@ +# Test code for the ACI modules +# Copyright: (c) 2023, Gaspard Micol (@gmicol) <gmicol@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 APIC host, ACI username and ACI password + ansible.builtin.fail: + msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' + when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined + +- name: Set vars + ansible.builtin.set_fact: + aci_info: &aci_info + host: "{{ aci_hostname }}" + username: "{{ aci_username }}" + password: "{{ aci_password }}" + validate_certs: '{{ aci_validate_certs | default(false) }}' + use_ssl: '{{ aci_use_ssl | default(true) }}' + use_proxy: '{{ aci_use_proxy | default(true) }}' + output_level: debug + +# CLEAN ENVIRONMENT BEFORE TESTS +- name: Remove the ansible_tenant + cisco.aci.aci_tenant: &aci_tenant_absent + <<: *aci_info + tenant: ansible_tenant + state: absent + +- name: Verify Cloud and Non-Cloud Sites in use. + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + +- name: Execute tasks only for non-cloud sites + when: query_cloud.current == [] # This condition will execute only non-cloud sites + block: # block specifies execution of tasks within, based on conditions + - name: Add a new tenant + cisco.aci.aci_tenant: &aci_tenant_present + <<: *aci_info + tenant: ansible_tenant + description: Ansible tenant + state: present + + # CREATE DHCP OPTION POLICY + - name: Add a DHCP option policy (check_mode) + cisco.aci.aci_dhcp_option_policy: &aci_dhcp_option_policy_present + <<: *aci_info + tenant: ansible_tenant + dhcp_option_policy: ansible_dhcp_option_policy_1 + description: DHCP option policy 1 for ansible_tenant tenant + state: present + check_mode: true + register: cm_add_dhcp_option_policy + + - name: Add a DHCP option policy (normal_mode) + cisco.aci.aci_dhcp_option_policy: + <<: *aci_dhcp_option_policy_present + register: nm_add_dhcp_option_policy + + - name: Add the first DHCP option policy again - testing idempotency + cisco.aci.aci_dhcp_option_policy: + <<: *aci_dhcp_option_policy_present + register: nm_add_dhcp_option_policy_idempotency + + - name: Add a second DHCP option policy (normal_mode) + cisco.aci.aci_dhcp_option_policy: + <<: *aci_info + tenant: ansible_tenant + dhcp_option_policy: ansible_dhcp_option_policy_2 + description: DHCP option policy 2 for ansible_tenant tenant + state: present + register: nm_add_dhcp_option_policy_2 + + - name: Asserts for DHCP option policy creation tasks + ansible.builtin.assert: + that: + - cm_add_dhcp_option_policy is changed + - cm_add_dhcp_option_policy.previous == [] + - cm_add_dhcp_option_policy.current == [] + - nm_add_dhcp_option_policy is changed + - nm_add_dhcp_option_policy.current.0.dhcpOptionPol.attributes.name == "ansible_dhcp_option_policy_1" + - nm_add_dhcp_option_policy_idempotency is not changed + - nm_add_dhcp_option_policy_2 is changed + - nm_add_dhcp_option_policy_2.previous == [] + - nm_add_dhcp_option_policy_2.current.0.dhcpOptionPol.attributes.name == "ansible_dhcp_option_policy_2" + + # QUERY DHCP OPTION POLICY + - name: Query all DHCP option policies + cisco.aci.aci_dhcp_option_policy: + <<: *aci_info + state: query + register: query_all_dhcp_option_policy + + - name: Query ansible_dhcp_option_policy_1 + cisco.aci.aci_dhcp_option_policy: + <<: *aci_dhcp_option_policy_present + state: query + register: query_ansible_dhcp_option_policy_1 + + - name: Asserts query tasks + ansible.builtin.assert: + that: + - query_all_dhcp_option_policy is not changed + - query_all_dhcp_option_policy.current|length >= 2 + - query_ansible_dhcp_option_policy_1 is not changed + - query_ansible_dhcp_option_policy_1.current.0.dhcpOptionPol.attributes.name == "ansible_dhcp_option_policy_1" + + # DELETE DHCP OPTION POLICY + - name: Remove DHCP option policy (check_mode) + cisco.aci.aci_dhcp_option_policy: &dhcp_option_policy_absent + <<: *aci_dhcp_option_policy_present + state: absent + check_mode: true + register: cm_remove_dhcp_option_policy + + - name: Remove DHCP option policy (normal_mode) + cisco.aci.aci_dhcp_option_policy: + <<: *dhcp_option_policy_absent + register: nm_remove_dhcp_option_policy + + - name: Remove DHCP option policy - testing idempotency + cisco.aci.aci_dhcp_option_policy: + <<: *dhcp_option_policy_absent + register: nm_remove_dhcp_option_policy_idempotency + + - name: Asserts deletion tasks + ansible.builtin.assert: + that: + - cm_remove_dhcp_option_policy is changed + - cm_remove_dhcp_option_policy.proposed == {} + - nm_remove_dhcp_option_policy is changed + - nm_remove_dhcp_option_policy.previous != [] + - nm_remove_dhcp_option_policy.method == "DELETE" + - nm_remove_dhcp_option_policy_idempotency is not changed + - nm_remove_dhcp_option_policy_idempotency.previous == [] + + # CLEAN ENVIRONMENT BEFORE ENDING TESTS + - name: Remove the ansible_tenant - cleanup before ending tests + cisco.aci.aci_tenant: + <<: *aci_tenant_present + state: absent diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_dhcp_relay/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_dhcp_relay/tasks/main.yml index da10cc2d8..93048e853 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_dhcp_relay/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_dhcp_relay/tasks/main.yml @@ -5,12 +5,12 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: "{{ aci_hostname }}" username: "{{ aci_username }}" @@ -22,7 +22,7 @@ # CLEAN ENVIRONMENT - name: Remove the ansible_tenant - aci_tenant: + cisco.aci.aci_tenant: <<: *aci_info tenant: ansible_tenant state: absent @@ -34,7 +34,7 @@ state: absent - name: Add a new tenant - aci_tenant: + cisco.aci.aci_tenant: <<: *aci_info tenant: ansible_tenant description: Ansible tenant @@ -51,7 +51,7 @@ register: add_dhcp_relay - name: Verify DHCP Relay creation - assert: + ansible.builtin.assert: that: - add_dhcp_relay is changed - add_dhcp_relay.current.0.dhcpRelayP.attributes.annotation == 'orchestrator:ansible' @@ -71,7 +71,7 @@ register: add_dhcp_relay_again - name: Verify DHCP Relay idempotence - assert: + ansible.builtin.assert: that: - add_dhcp_relay_again is not changed - add_dhcp_relay_again.current.0.dhcpRelayP.attributes.dn == "uni/tn-ansible_tenant/relayp-ansible_dhcp_relay" @@ -90,7 +90,7 @@ register: update_dhcp_relay - name: Verify DHCP Relay change - assert: + ansible.builtin.assert: that: - update_dhcp_relay is changed - update_dhcp_relay.current.0.dhcpRelayP.attributes.dn == "uni/tn-ansible_tenant/relayp-ansible_dhcp_relay" @@ -115,7 +115,7 @@ register: add_global_dhcp_relay - name: Verify Global DHCP Relay creation - assert: + ansible.builtin.assert: that: - add_global_dhcp_relay is changed - add_global_dhcp_relay.current.0.dhcpRelayP.attributes.annotation == 'orchestrator:ansible' @@ -134,7 +134,7 @@ register: query_dhcp_relay - name: Verify DHCP Relay query - assert: + ansible.builtin.assert: that: - query_dhcp_relay is not changed - query_dhcp_relay.current.0.dhcpRelayP.attributes.dn == "uni/tn-ansible_tenant/relayp-ansible_dhcp_relay" @@ -150,7 +150,7 @@ register: query_dhcp_relay_all - name: Verify query idempotence - assert: + ansible.builtin.assert: that: - query_dhcp_relay_all is not changed - query_dhcp_relay_all.current.0.fvTenant.children | length >= 2 @@ -164,7 +164,7 @@ register: query_global_dhcp_relay - name: Verify Global DHCP Relay query - assert: + ansible.builtin.assert: that: - query_global_dhcp_relay is not changed - query_global_dhcp_relay.current.0.dhcpRelayP.attributes.dn == "uni/infra/relayp-ansible_global_dhcp_relay" @@ -179,7 +179,7 @@ register: query_global_dhcp_relay_all - name: Verify query idempotence for Global DHCP Relay - assert: + ansible.builtin.assert: that: - query_global_dhcp_relay_all is not changed - query_global_dhcp_relay_all.current | length >= 3 @@ -194,7 +194,7 @@ register: delete_dhcp_relay - name: Verify DHCP Relay deletion - assert: + ansible.builtin.assert: that: - delete_dhcp_relay is changed - delete_dhcp_relay.current == [] @@ -212,7 +212,7 @@ register: delete_dhcp_relay_again - name: Verify DHCP Relay deletion idempotence - assert: + ansible.builtin.assert: that: - delete_dhcp_relay_again is not changed @@ -225,7 +225,7 @@ register: delete_global_dhcp_relay - name: Verify Global DHCP Relay deletion - assert: + ansible.builtin.assert: that: - delete_global_dhcp_relay is changed - delete_global_dhcp_relay.current == [] @@ -236,7 +236,7 @@ # CLEAN ENVIRONMENT AGAIN - name: Remove the ansible_tenant - aci_tenant: + cisco.aci.aci_tenant: <<: *aci_info tenant: ansible_tenant state: absent diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_dhcp_relay_provider/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_dhcp_relay_provider/tasks/main.yml index c133e23ba..078be3f38 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_dhcp_relay_provider/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_dhcp_relay_provider/tasks/main.yml @@ -5,12 +5,12 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: "{{ aci_hostname }}" username: "{{ aci_username }}" @@ -21,11 +21,11 @@ output_level: debug - name: Verify Cloud and Non-Cloud Sites in use. - include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml # CLEAN ENVIRONMENT - name: Remove the ansible_tenant - aci_tenant: + cisco.aci.aci_tenant: <<: *aci_info tenant: ansible_tenant state: absent @@ -54,7 +54,7 @@ when: query_cloud.current == [] # This condition will execute only non-cloud sites block: # block specifies execution of tasks within, based on conditions - name: Add a new tenant - aci_tenant: + cisco.aci.aci_tenant: <<: *aci_info tenant: ansible_tenant description: Ansible tenant @@ -219,7 +219,7 @@ register: add_dn_relay_provider - name: Confirm DHCP relay provider creation - assert: + ansible.builtin.assert: that: - add_epg_relay_provider is changed - add_epg_relay_provider.current.0.dhcpRsProv.attributes.annotation == 'orchestrator:ansible' @@ -289,7 +289,7 @@ register: add_dn_relay_provider_again - name: Confirm DHCP relay provider idempotence - assert: + ansible.builtin.assert: that: - add_epg_relay_provider_again is not changed - add_epg_relay_provider_again.current.0.dhcpRsProv.attributes.dn == "uni/tn-ansible_tenant/relayp-ansible_dhcp_relay/rsprov-[uni/tn-ansible_tenant/ap-ansible_ap/epg-ansible_epg]" @@ -358,7 +358,7 @@ register: update_dn_relay_provider - name: Confirm DHCP relay provider update - assert: + ansible.builtin.assert: that: - update_epg_relay_provider is changed - update_epg_relay_provider.current.0.dhcpRsProv.attributes.dn == "uni/tn-ansible_tenant/relayp-ansible_dhcp_relay/rsprov-[uni/tn-ansible_tenant/ap-ansible_ap/epg-ansible_epg]" @@ -429,7 +429,7 @@ register: query_all_relay_provider - name: Confirm DHCP relay provider query - assert: + ansible.builtin.assert: that: - query_epg_relay_provider is not changed - query_epg_relay_provider.current.0.dhcpRsProv.attributes.dn == "uni/tn-ansible_tenant/relayp-ansible_dhcp_relay/rsprov-[uni/tn-ansible_tenant/ap-ansible_ap/epg-ansible_epg]" @@ -510,7 +510,7 @@ register: add_global_dn_relay_provider - name: Confirm Global DHCP relay provider creation - assert: + ansible.builtin.assert: that: - err_global_epg_relay_provider is failed - err_global_epg_relay_provider.msg == "provider_tenant is required when epg_type is epg" @@ -582,7 +582,7 @@ register: query_global_all_relay_provider - name: Confirm DHCP relay provider query - assert: + ansible.builtin.assert: that: - query_global_epg_relay_provider is not changed - query_global_epg_relay_provider.current.0.dhcpRsProv.attributes.dn == "uni/infra/relayp-ansible_global_dhcp_relay/rsprov-[uni/tn-ansible_tenant/ap-ansible_ap/epg-ansible_epg]" @@ -649,7 +649,7 @@ register: delete_dn_relay_provider - name: Confirm DHCP relay provider removal - assert: + ansible.builtin.assert: that: - delete_epg_relay_provider is changed - delete_epg_relay_provider.current == [] @@ -717,7 +717,7 @@ register: delete_dn_relay_provider_again - name: Confirm DHCP relay provider removal - assert: + ansible.builtin.assert: that: - delete_epg_relay_provider_again is not changed - delete_l2_relay_provider_again is not changed @@ -768,7 +768,7 @@ register: delete_global_dn_relay_provider - name: Confirm DHCP relay provider removal - assert: + ansible.builtin.assert: that: - delete_global_epg_relay_provider is changed - delete_global_epg_relay_provider.current == [] @@ -792,7 +792,7 @@ # CLEAN ENVIRONMENT AGAIN - name: Remove the ansible_tenant - aci_tenant: + cisco.aci.aci_tenant: <<: *aci_info tenant: ansible_tenant state: absent diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_dns_domain/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_dns_domain/tasks/main.yml index af9c1026b..d0fe0b29d 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_dns_domain/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_dns_domain/tasks/main.yml @@ -4,13 +4,13 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined # GET Credentials from the inventory - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: "{{ aci_hostname }}" username: "{{ aci_username }}" @@ -45,7 +45,7 @@ register: add_dns_domain - name: Verify DNS domain creation - assert: + ansible.builtin.assert: that: - add_dns_domain is changed - add_dns_domain.current.0.dnsDomain.attributes.annotation == 'orchestrator:ansible' @@ -64,7 +64,7 @@ register: add_dns_domain_again - name: Verify DNS domain creation idempotence - assert: + ansible.builtin.assert: that: - add_dns_domain_again is not changed - add_dns_domain_again.current.0.dnsDomain.attributes.dn == "uni/fabric/dnsp-ansible_dns_profile/dom-example.com" @@ -82,7 +82,7 @@ register: update_dns_domain - name: Verify DNS domain update - assert: + ansible.builtin.assert: that: - update_dns_domain is changed - update_dns_domain.current.0.dnsDomain.attributes.dn == "uni/fabric/dnsp-ansible_dns_profile/dom-example.com" @@ -99,7 +99,7 @@ register: query_dns_domain - name: Verify DNS domain attributes - assert: + ansible.builtin.assert: that: - query_dns_domain is not changed - query_dns_domain.current.0.dnsDomain.attributes.dn == "uni/fabric/dnsp-ansible_dns_profile/dom-example.com" @@ -115,7 +115,7 @@ register: query_dns_domain_all - name: Verify DNS domain query idempotence - assert: + ansible.builtin.assert: that: - query_dns_domain_all is not changed @@ -129,7 +129,7 @@ register: delete_dns_domain - name: Verify DNS domain deletion - assert: + ansible.builtin.assert: that: - delete_dns_domain is changed - delete_dns_domain.current == [] @@ -147,7 +147,7 @@ register: delete_dns_domain_again - name: Verify DNS domain deletion idempotence - assert: + ansible.builtin.assert: that: - delete_dns_domain_again is not changed diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_dns_profile/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_dns_profile/tasks/main.yml index 126bb27a6..027532f63 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_dns_profile/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_dns_profile/tasks/main.yml @@ -4,13 +4,13 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined # GET Credentials from the inventory - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: "{{ aci_hostname }}" username: "{{ aci_username }}" @@ -29,7 +29,7 @@ register: add_dns_profile - name: Verify that DNS profile has been created with correct attributes - assert: + ansible.builtin.assert: that: - add_dns_profile is changed - add_dns_profile.current.0.dnsProfile.attributes.annotation == 'orchestrator:ansible' @@ -45,7 +45,7 @@ register: add_dns_profile_again - name: Verify that DNS profile creation idempotence - assert: + ansible.builtin.assert: that: - add_dns_profile_again is not changed - add_dns_profile_again.current.0.dnsProfile.attributes.dn == "uni/fabric/dnsp-ansible_dns_profile" @@ -60,7 +60,7 @@ register: query_dns_profile - name: Verify DNS profile - assert: + ansible.builtin.assert: that: - query_dns_profile is not changed - query_dns_profile.current.0.dnsProfile.attributes.dn == "uni/fabric/dnsp-ansible_dns_profile" @@ -73,7 +73,7 @@ register: query_dns_profile_all - name: Verify query idempotence - assert: + ansible.builtin.assert: that: - query_dns_profile_all is not changed @@ -86,7 +86,7 @@ register: remove_dns_profile - name: Verify DNS profile removal - assert: + ansible.builtin.assert: that: - remove_dns_profile is changed - remove_dns_profile.current == [] @@ -102,6 +102,6 @@ register: remove_dns_profile_again - name: Verify DNS profile removal idempotence - assert: + ansible.builtin.assert: that: - remove_dns_profile_again is not changed diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_dns_provider/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_dns_provider/tasks/main.yml index 3e31d2b52..7f55e11c7 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_dns_provider/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_dns_provider/tasks/main.yml @@ -4,13 +4,13 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined # GET Credentials from the inventory - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: "{{ aci_hostname }}" username: "{{ aci_username }}" @@ -45,7 +45,7 @@ register: add_dns_provider - name: Verify DNS provider creation - assert: + ansible.builtin.assert: that: - add_dns_provider is changed - add_dns_provider.current.0.dnsProv.attributes.annotation == 'orchestrator:ansible' @@ -64,7 +64,7 @@ register: add_dns_provider_again - name: Verify DNS provider creation idempotence - assert: + ansible.builtin.assert: that: - add_dns_provider_again is not changed - add_dns_provider_again.current.0.dnsProv.attributes.dn == "uni/fabric/dnsp-ansible_dns_profile/prov-[10.20.30.40]" @@ -82,7 +82,7 @@ register: update_dns_provider - name: Verify DNS provider update - assert: + ansible.builtin.assert: that: - update_dns_provider is changed - update_dns_provider.current.0.dnsProv.attributes.dn == "uni/fabric/dnsp-ansible_dns_profile/prov-[10.20.30.40]" @@ -99,7 +99,7 @@ register: query_dns_provider - name: Verify DNS provider attributes - assert: + ansible.builtin.assert: that: - query_dns_provider is not changed - query_dns_provider.current.0.dnsProv.attributes.dn == "uni/fabric/dnsp-ansible_dns_profile/prov-[10.20.30.40]" @@ -115,7 +115,7 @@ register: query_dns_provider_all - name: Verify DNS provider query idempotence - assert: + ansible.builtin.assert: that: - query_dns_provider_all is not changed @@ -129,7 +129,7 @@ register: delete_dns_provider - name: Verify DNS provider deletion - assert: + ansible.builtin.assert: that: - delete_dns_provider is changed - delete_dns_provider.current == [] @@ -147,7 +147,7 @@ register: delete_dns_provider_again - name: Verify DNS provider deletion idempotence - assert: + ansible.builtin.assert: that: - delete_dns_provider_again is not changed diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_domain/tasks/fc.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_domain/tasks/fc.yml index 2e2a8eb0b..ea27d4ba2 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_domain/tasks/fc.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_domain/tasks/fc.yml @@ -40,7 +40,7 @@ register: nm_add_domain - name: Verify FC add_domain - assert: + ansible.builtin.assert: that: - cm_add_domain is changed - nm_add_domain is changed @@ -61,7 +61,7 @@ register: nm_add_domain_again - name: Verify FC add_domain_again - assert: + ansible.builtin.assert: that: - cm_add_domain_again is not changed - nm_add_domain_again is not changed @@ -172,7 +172,7 @@ register: nm_incorrect_enable_vm_folder - name: Verify incorrect parameter - assert: + ansible.builtin.assert: that: - cm_incorrect_vm_provider.msg == "Domain type 'fc' cannot have parameter 'vm_provider'" - nm_incorrect_vm_provider.msg == "Domain type 'fc' cannot have parameter 'vm_provider'" @@ -209,7 +209,7 @@ register: nm_query_all_domains - name: Verify FC query_all_domains - assert: + ansible.builtin.assert: that: - cm_query_all_domains is not changed - nm_query_all_domains is not changed @@ -232,7 +232,7 @@ register: nm_query_domain - name: Verify FC query_domain - assert: + ansible.builtin.assert: that: - cm_query_domain is not changed - nm_query_domain is not changed @@ -252,7 +252,7 @@ register: nm_remove_domain - name: Verify FC remove_domain - assert: + ansible.builtin.assert: that: - cm_remove_domain is changed - nm_remove_domain is changed @@ -270,7 +270,7 @@ register: nm_remove_domain_again - name: Verify FC remove_domain_again - assert: + ansible.builtin.assert: that: - cm_remove_domain_again is not changed - nm_remove_domain_again is not changed @@ -291,7 +291,7 @@ register: nm_query_non_domain - name: Verify FC query_non_domain - assert: + ansible.builtin.assert: that: - cm_query_non_domain is not changed - nm_query_non_domain is not changed diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_domain/tasks/l2dom.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_domain/tasks/l2dom.yml index 4f0084174..031944789 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_domain/tasks/l2dom.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_domain/tasks/l2dom.yml @@ -40,7 +40,7 @@ register: nm_add_domain - name: Verify L2 add_domain - assert: + ansible.builtin.assert: that: - cm_add_domain is changed - nm_add_domain is changed @@ -61,7 +61,7 @@ register: nm_add_domain_again - name: Verify L2 add_domain_again - assert: + ansible.builtin.assert: that: - cm_add_domain_again is not changed - nm_add_domain_again is not changed @@ -127,7 +127,7 @@ register: nm_incorrect_vswitch - name: Verify incorrect parameter - assert: + ansible.builtin.assert: that: - cm_incorrect_vm_provider.msg == "Domain type 'l2dom' cannot have parameter 'vm_provider'" - nm_incorrect_vm_provider.msg == "Domain type 'l2dom' cannot have parameter 'vm_provider'" @@ -158,7 +158,7 @@ register: nm_query_all_domains - name: Verify L2 query_all_domains - assert: + ansible.builtin.assert: that: - cm_query_all_domains is not changed - nm_query_all_domains is not changed @@ -181,7 +181,7 @@ register: nm_query_domain - name: Verify L2 query_domain - assert: + ansible.builtin.assert: that: - cm_query_domain is not changed - nm_query_domain is not changed @@ -201,7 +201,7 @@ register: nm_remove_domain - name: Verify L2 remove_domain - assert: + ansible.builtin.assert: that: - cm_remove_domain is changed - nm_remove_domain is changed @@ -219,7 +219,7 @@ register: nm_remove_domain_again - name: Verify L2 remove_domain_again - assert: + ansible.builtin.assert: that: - cm_remove_domain_again is not changed - nm_remove_domain_again is not changed @@ -240,7 +240,7 @@ register: nm_query_non_domain - name: Verify L2 query_non_domain - assert: + ansible.builtin.assert: that: - cm_query_non_domain is not changed - nm_query_non_domain is not changed diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_domain/tasks/l3dom.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_domain/tasks/l3dom.yml index 61677d897..aaa55eae8 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_domain/tasks/l3dom.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_domain/tasks/l3dom.yml @@ -40,7 +40,7 @@ register: nm_add_domain - name: Verify L3 add_domain - assert: + ansible.builtin.assert: that: - cm_add_domain is changed - nm_add_domain is changed @@ -61,7 +61,7 @@ register: nm_add_domain_again - name: Verify L3 add_domain_again - assert: + ansible.builtin.assert: that: - cm_add_domain_again is not changed - nm_add_domain_again is not changed @@ -127,7 +127,7 @@ register: nm_incorrect_vswitch - name: Verify incorrect parameter - assert: + ansible.builtin.assert: that: - cm_incorrect_vm_provider.msg == "Domain type 'l3dom' cannot have parameter 'vm_provider'" - nm_incorrect_vm_provider.msg == "Domain type 'l3dom' cannot have parameter 'vm_provider'" @@ -159,7 +159,7 @@ register: nm_query_all_domains - name: Verify query_all_domains - assert: + ansible.builtin.assert: that: - cm_query_all_domains is not changed - nm_query_all_domains is not changed @@ -182,7 +182,7 @@ register: nm_query_domain - name: Verify L3 query_domain - assert: + ansible.builtin.assert: that: - cm_query_domain is not changed - nm_query_domain is not changed @@ -202,7 +202,7 @@ register: nm_remove_domain - name: Verify L3 remove_domain - assert: + ansible.builtin.assert: that: - cm_remove_domain is changed - nm_remove_domain is changed @@ -220,7 +220,7 @@ register: nm_remove_domain_again - name: Verify L3 remove_domain_again - assert: + ansible.builtin.assert: that: - cm_remove_domain_again is not changed - nm_remove_domain_again is not changed @@ -241,7 +241,7 @@ register: nm_query_non_domain - name: Verify L3 query_non_domain - assert: + ansible.builtin.assert: that: - cm_query_non_domain is not changed - nm_query_non_domain is not changed diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_domain/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_domain/tasks/main.yml index be6c9712d..591c01b22 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_domain/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_domain/tasks/main.yml @@ -4,7 +4,7 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_domain/tasks/phys.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_domain/tasks/phys.yml index 39f87a6f0..c12b09ace 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_domain/tasks/phys.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_domain/tasks/phys.yml @@ -40,7 +40,7 @@ register: nm_add_domain - name: Verify physical add_domain - assert: + ansible.builtin.assert: that: - cm_add_domain is changed - nm_add_domain is changed @@ -61,7 +61,7 @@ register: nm_add_domain_again - name: Verify physical add_domain_again - assert: + ansible.builtin.assert: that: - cm_add_domain_again is not changed - nm_add_domain_again is not changed @@ -127,7 +127,7 @@ register: nm_incorrect_vswitch - name: Verify incorrect parameter - assert: + ansible.builtin.assert: that: - cm_incorrect_vm_provider.msg == "Domain type 'phys' cannot have parameter 'vm_provider'" - nm_incorrect_vm_provider.msg == "Domain type 'phys' cannot have parameter 'vm_provider'" @@ -158,7 +158,7 @@ register: nm_query_all_domains - name: Verify physical query_all_domains - assert: + ansible.builtin.assert: that: - cm_query_all_domains is not changed - nm_query_all_domains is not changed @@ -181,7 +181,7 @@ register: nm_query_domain - name: Verify physical query_domain - assert: + ansible.builtin.assert: that: - cm_query_domain is not changed - nm_query_domain is not changed @@ -201,7 +201,7 @@ register: nm_remove_domain - name: Verify physical remove_domain - assert: + ansible.builtin.assert: that: - cm_remove_domain is changed - nm_remove_domain is changed @@ -219,7 +219,7 @@ register: nm_remove_domain_again - name: Verify physical remove_domain_again - assert: + ansible.builtin.assert: that: - cm_remove_domain_again is not changed - nm_remove_domain_again is not changed @@ -240,7 +240,7 @@ register: nm_query_non_domain - name: Verify physical query_non_domain - assert: + ansible.builtin.assert: that: - cm_query_non_domain is not changed - nm_query_non_domain is not changed diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_domain/tasks/vmm-vmware.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_domain/tasks/vmm-vmware.yml index 03d82788c..2f0372186 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_domain/tasks/vmm-vmware.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_domain/tasks/vmm-vmware.yml @@ -19,7 +19,7 @@ state: absent - name: Verify Cloud and Non-Cloud Sites in use. - include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml - name: Execute tasks only for non-cloud sites when: query_cloud.current == [] # This condition will skip execution for cloud sites @@ -48,7 +48,7 @@ register: nm_add_domain - name: Verify VMM add_domain - assert: + ansible.builtin.assert: that: - cm_add_domain is changed - nm_add_domain is changed @@ -69,7 +69,7 @@ register: nm_add_domain_again - name: Verify VMM add_domain_again - assert: + ansible.builtin.assert: that: - cm_add_domain_again is not changed - nm_add_domain_again is not changed @@ -92,7 +92,7 @@ when: version.current.0.topSystem.attributes.version is version('4.1', '>=') - name: Verify update_domain - assert: + ansible.builtin.assert: that: - cm_update_domain is changed - nm_update_domain is changed @@ -123,7 +123,7 @@ register: nm_query_all_domains - name: Verify query_all_domains - assert: + ansible.builtin.assert: that: - cm_query_all_domains is not changed - nm_query_all_domains is not changed @@ -148,7 +148,7 @@ register: nm_query_domain - name: Verify VMM query_domain - assert: + ansible.builtin.assert: that: - cm_query_domain is not changed - nm_query_domain is not changed @@ -167,7 +167,7 @@ register: nm_remove_domain - name: Verify VMM remove_domain - assert: + ansible.builtin.assert: that: - cm_remove_domain is changed - nm_remove_domain is changed @@ -186,7 +186,7 @@ register: nm_remove_domain_again - name: Verify VMM remove_domain_again - assert: + ansible.builtin.assert: that: - cm_remove_domain_again is not changed - nm_remove_domain_again is not changed @@ -209,7 +209,7 @@ register: nm_query_non_domain - name: Verify VMM query_non_domain - assert: + ansible.builtin.assert: that: - cm_query_non_domain is not changed - nm_query_non_domain is not changed diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_domain_to_encap_pool/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_domain_to_encap_pool/tasks/main.yml index f028e2c56..77c824300 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_domain_to_encap_pool/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_domain_to_encap_pool/tasks/main.yml @@ -4,12 +4,12 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: "{{ aci_hostname }}" username: "{{ aci_username }}" @@ -20,11 +20,11 @@ output_level: debug - name: Verify Cloud and Non-Cloud Sites in use. - include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml # Clean Environment - name: Remove domains - aci_domain: + cisco.aci.aci_domain: <<: *aci_info domain: '{{ item.name }}' domain_type: '{{ item.type }}' @@ -36,7 +36,7 @@ - { name: l3_dom, type: l3dom } - name: Remove domains - aci_domain: + cisco.aci.aci_domain: <<: *aci_info domain: vmm_dom domain_type: vmm @@ -56,7 +56,7 @@ block: # block specifies execution of tasks within, based on conditions # Add - name: Add physical domain - aci_domain: + cisco.aci.aci_domain: <<: *aci_info domain: phys_dom domain_type: phys @@ -64,7 +64,7 @@ register: phys_domain - name: Add l2 domain - aci_domain: + cisco.aci.aci_domain: <<: *aci_info domain: l2_dom domain_type: l2dom @@ -72,7 +72,7 @@ register: l2_domain - name: Add l3 domain - aci_domain: + cisco.aci.aci_domain: <<: *aci_info domain: l3_dom domain_type: l3dom @@ -80,7 +80,7 @@ register: l3_domain - name: Add FC domain - aci_domain: + cisco.aci.aci_domain: <<: *aci_info domain: fc_dom domain_type: fc @@ -88,7 +88,7 @@ register: fc_domain - name: Add vmm domain - aci_domain: + cisco.aci.aci_domain: <<: *aci_info domain: vmm_dom domain_type: vmm @@ -97,7 +97,7 @@ register: vmm_domain - name: Add domain to encap pool binding (phys, pool_type=vlan) - aci_domain_to_encap_pool: + cisco.aci.aci_domain_to_encap_pool: <<: *aci_info domain: phys_dom domain_type: phys @@ -108,7 +108,7 @@ register: phys_vlan - name: Add domain to encap pool binding (fc, pool_type=vsan) - aci_domain_to_encap_pool: + cisco.aci.aci_domain_to_encap_pool: <<: *aci_info domain: fc_dom domain_type: fc @@ -119,7 +119,7 @@ register: fc_vsan - name: Add domain to encap pool binding (domain_type=l2dom) - aci_domain_to_encap_pool: + cisco.aci.aci_domain_to_encap_pool: <<: *aci_info domain: l2_dom domain_type: l2dom @@ -130,7 +130,7 @@ register: l2dom - name: Add domain to encap pool binding (domain_type=l3dom) - aci_domain_to_encap_pool: + cisco.aci.aci_domain_to_encap_pool: <<: *aci_info domain: l3_dom domain_type: l3dom @@ -141,7 +141,7 @@ register: l3dom - name: Add domain to encap pool binding (domain_type=vmm, vm_provider=cloudfoundry) - aci_domain_to_encap_pool: + cisco.aci.aci_domain_to_encap_pool: <<: *aci_info domain: vmm_dom domain_type: vmm @@ -153,7 +153,7 @@ register: vmm_cloudfoundry - name: Add domain to encap pool binding (domain_type=vmm, vm_provider=kubernetes) - aci_domain_to_encap_pool: + cisco.aci.aci_domain_to_encap_pool: <<: *aci_info domain: vmm_dom domain_type: vmm @@ -165,7 +165,7 @@ register: vmm_kubernetes - name: Add domain to encap pool binding (domain_type=vmm, vm_provider=microsoft) - aci_domain_to_encap_pool: + cisco.aci.aci_domain_to_encap_pool: <<: *aci_info domain: vmm_dom domain_type: vmm @@ -177,7 +177,7 @@ register: vmm_microsoft - name: Add domain to encap pool binding (domain_type=vmm, vm_provider=openshift) - aci_domain_to_encap_pool: + cisco.aci.aci_domain_to_encap_pool: <<: *aci_info domain: vmm_dom domain_type: vmm @@ -189,7 +189,7 @@ register: vmm_openshift - name: Add domain to encap pool binding (domain_type=vmm, vm_provider=openstack) - aci_domain_to_encap_pool: + cisco.aci.aci_domain_to_encap_pool: <<: *aci_info domain: vmm_dom domain_type: vmm @@ -201,7 +201,7 @@ register: vmm_openstack - name: Add domain to encap pool binding (domain_type=vmm, vm_provider=redhat) - aci_domain_to_encap_pool: + cisco.aci.aci_domain_to_encap_pool: <<: *aci_info domain: vmm_dom domain_type: vmm @@ -213,7 +213,7 @@ register: vmm_redhat - name: Add domain to encap pool binding (domain_type=vmm, vm_provider=vmware) - aci_domain_to_encap_pool: + cisco.aci.aci_domain_to_encap_pool: <<: *aci_info domain: vmm_dom domain_type: vmm @@ -225,7 +225,7 @@ register: vmm_vmware - name: Add domain to encap pool binding (domain_type=vmm, vm_provider=vmware) again - aci_domain_to_encap_pool: + cisco.aci.aci_domain_to_encap_pool: <<: *aci_info domain: vmm_dom domain_type: vmm @@ -237,7 +237,7 @@ register: vmm_vmware_idemp - name: Add domain to encap pool binding (phys with vm_provider) - aci_domain_to_encap_pool: + cisco.aci.aci_domain_to_encap_pool: <<: *aci_info domain: phys_dom domain_type: phys @@ -250,7 +250,7 @@ register: phys_vlan_with_vmm - name: Add domain to encap pool binding (phys, pool_type=vlan, no allocation mode) - aci_domain_to_encap_pool: + cisco.aci.aci_domain_to_encap_pool: <<: *aci_info domain: phys_dom domain_type: phys @@ -261,7 +261,7 @@ register: phys_vlan_no_alloc - name: Add domain to encap pool binding (domain_type=vmm, vm_provider=vmware, pool_type=vxlan) - aci_domain_to_encap_pool: + cisco.aci.aci_domain_to_encap_pool: <<: *aci_info domain: vmm_dom domain_type: vmm @@ -274,7 +274,7 @@ register: vmm_vmware_vxlan - name: Add domain to encap pool binding (phys, pool_type=vlan) missing domain_type - aci_domain_to_encap_pool: + cisco.aci.aci_domain_to_encap_pool: <<: *aci_info domain: phys_dom pool: test_pool @@ -285,7 +285,7 @@ register: phys_missing_domain_type - name: Add domain to encap pool binding (phys, pool_type=vlan) missing pool_type - aci_domain_to_encap_pool: + cisco.aci.aci_domain_to_encap_pool: <<: *aci_info domain: phys_dom domain_type: phys @@ -296,7 +296,7 @@ register: phys_missing_pool_type - name: Verify add operation for All Sites - assert: + ansible.builtin.assert: that: - phys_vlan is changed - fc_vsan is changed @@ -316,7 +316,7 @@ - phys_missing_domain_type.msg is match("missing required arguments{{':'}} domain_type") - name: Verify add operation for Non-Cloud Sites - assert: + ansible.builtin.assert: that: - vmm_cloudfoundry is changed - vmm_openshift is changed @@ -333,7 +333,7 @@ # QUERY - name: Query all - aci_domain_to_encap_pool: + cisco.aci.aci_domain_to_encap_pool: <<: *aci_info domain_type: phys pool_type: vlan @@ -341,7 +341,7 @@ register: query_all - name: Query phys - aci_domain_to_encap_pool: + cisco.aci.aci_domain_to_encap_pool: <<: *aci_info domain: phys_dom domain_type: phys @@ -350,7 +350,7 @@ register: query_phys - name: Query fc - aci_domain_to_encap_pool: + cisco.aci.aci_domain_to_encap_pool: <<: *aci_info domain: fc_dom domain_type: fc @@ -359,7 +359,7 @@ register: query_fc - name: Query l2dom - aci_domain_to_encap_pool: + cisco.aci.aci_domain_to_encap_pool: <<: *aci_info domain: l2_dom domain_type: l2dom @@ -368,7 +368,7 @@ register: query_l2dom - name: Query l3dom - aci_domain_to_encap_pool: + cisco.aci.aci_domain_to_encap_pool: <<: *aci_info domain: l3_dom domain_type: l3dom @@ -377,7 +377,7 @@ register: query_l3dom - name: Query vmm - aci_domain_to_encap_pool: + cisco.aci.aci_domain_to_encap_pool: <<: *aci_info domain: vmm_dom domain_type: vmm @@ -387,7 +387,7 @@ register: query_vmm_microsoft - name: Query vmm - aci_domain_to_encap_pool: + cisco.aci.aci_domain_to_encap_pool: <<: *aci_info domain: vmm_dom domain_type: vmm @@ -397,7 +397,7 @@ register: query_vmm_cloudfoundry - name: Query vmm - aci_domain_to_encap_pool: + cisco.aci.aci_domain_to_encap_pool: <<: *aci_info domain: vmm_dom domain_type: vmm @@ -407,7 +407,7 @@ register: query_vmm_kubernetes - name: Query vmm - aci_domain_to_encap_pool: + cisco.aci.aci_domain_to_encap_pool: <<: *aci_info domain: vmm_dom domain_type: vmm @@ -417,7 +417,7 @@ register: query_vmm_openshift - name: Query vmm - aci_domain_to_encap_pool: + cisco.aci.aci_domain_to_encap_pool: <<: *aci_info domain: vmm_dom domain_type: vmm @@ -427,7 +427,7 @@ register: query_vmm_openstack - name: Query vmm - aci_domain_to_encap_pool: + cisco.aci.aci_domain_to_encap_pool: <<: *aci_info domain: vmm_dom domain_type: vmm @@ -437,7 +437,7 @@ register: query_vmm_redhat - name: Query vmm - aci_domain_to_encap_pool: + cisco.aci.aci_domain_to_encap_pool: <<: *aci_info domain: vmm_dom domain_type: vmm @@ -447,7 +447,7 @@ register: query_vmm_vmware - name: Query vmm - aci_domain_to_encap_pool: + cisco.aci.aci_domain_to_encap_pool: <<: *aci_info domain: vmm_dom domain_type: vmm @@ -457,7 +457,7 @@ register: query_vmm_vmware - name: Verify Query for Non-Cloud sites - assert: + ansible.builtin.assert: that: - query_all | length >=1 - query_phys.current.0.physDomP.children.0.infraRsVlanNs.attributes.tDn =='uni/infra/vlanns-[test_pool]-dynamic' @@ -468,7 +468,7 @@ - name: Verify Query for Cloud sites - assert: + ansible.builtin.assert: that: - query_vmm_cloudfoundry.current.0.vmmDomP.children.0.infraRsVlanNs.attributes.tDn == 'uni/infra/vlanns-[test_pool]-dynamic' - query_vmm_microsoft.current.0.vmmDomP.children.0.infraRsVlanNs.attributes.tDn == 'uni/infra/vlanns-[test_pool]-dynamic' @@ -479,7 +479,7 @@ # REMOVE - name: Remove phys - aci_domain_to_encap_pool: + cisco.aci.aci_domain_to_encap_pool: <<: *aci_info domain_type: phys domain: phys_dom @@ -490,7 +490,7 @@ register: remove_phys - name: Remove fc - aci_domain_to_encap_pool: + cisco.aci.aci_domain_to_encap_pool: <<: *aci_info domain_type: fc domain: fc_dom @@ -501,7 +501,7 @@ register: remove_fc - name: Remove l2dom - aci_domain_to_encap_pool: + cisco.aci.aci_domain_to_encap_pool: <<: *aci_info domain_type: l2dom domain: l2_dom @@ -512,7 +512,7 @@ register: remove_l2dom - name: Remove l3dom - aci_domain_to_encap_pool: + cisco.aci.aci_domain_to_encap_pool: <<: *aci_info domain_type: l3dom domain: l3_dom @@ -523,7 +523,7 @@ register: remove_l3dom - name: Remove vmm cloudfoundry - aci_domain_to_encap_pool: + cisco.aci.aci_domain_to_encap_pool: <<: *aci_info domain_type: vmm domain: vmm_dom @@ -535,7 +535,7 @@ register: remove_vmm_cloudfoundry - name: Remove vmm redhat kubernetes - aci_domain_to_encap_pool: + cisco.aci.aci_domain_to_encap_pool: <<: *aci_info domain_type: vmm domain: vmm_dom @@ -547,7 +547,7 @@ register: remove_vmm_kubernetes - name: Remove vmm microsoft - aci_domain_to_encap_pool: + cisco.aci.aci_domain_to_encap_pool: <<: *aci_info domain_type: vmm domain: vmm_dom @@ -559,7 +559,7 @@ register: remove_vmm_microsoft - name: Remove vmm redhat - aci_domain_to_encap_pool: + cisco.aci.aci_domain_to_encap_pool: <<: *aci_info domain_type: vmm domain: vmm_dom @@ -571,7 +571,7 @@ register: remove_vmm_redhat - name: Remove vmm openstack - aci_domain_to_encap_pool: + cisco.aci.aci_domain_to_encap_pool: <<: *aci_info domain_type: vmm domain: vmm_dom @@ -583,7 +583,7 @@ register: remove_vmm_openstack - name: Remove vmm openshift - aci_domain_to_encap_pool: + cisco.aci.aci_domain_to_encap_pool: <<: *aci_info domain_type: vmm domain: vmm_dom @@ -595,7 +595,7 @@ register: remove_vmm_openshift - name: Remove vmm vmware - aci_domain_to_encap_pool: + cisco.aci.aci_domain_to_encap_pool: <<: *aci_info domain_type: vmm domain: vmm_dom @@ -607,7 +607,7 @@ register: remove_vmm_vmware - name: Verify Remove for All Sites - assert: + ansible.builtin.assert: that: - remove_phys.previous.0.physDomP.children.0.infraRsVlanNs.attributes.tDn =='uni/infra/vlanns-[test_pool]-dynamic' - remove_fc.previous.0.fcDomP.children.0.fcRsVsanNs.attributes.tDn == 'uni/infra/vsanns-[test_pool]-dynamic' @@ -616,7 +616,7 @@ - remove_vmm_kubernetes.previous.0.vmmDomP.children.0.infraRsVlanNs.attributes.tDn == 'uni/infra/vlanns-[test_pool]-dynamic' - name: Verify Remove for Non-Cloud Sites - assert: + ansible.builtin.assert: that: - remove_vmm_cloudfoundry.previous.0.vmmDomP.children.0.infraRsVlanNs.attributes.tDn == 'uni/infra/vlanns-[test_pool]-dynamic' - remove_vmm_microsoft.previous.0.vmmDomP.children.0.infraRsVlanNs.attributes.tDn == 'uni/infra/vlanns-[test_pool]-dynamic' @@ -627,7 +627,7 @@ # Clean Environment Again - name: Remove domains - aci_domain: + cisco.aci.aci_domain: <<: *aci_info domain: '{{ item.name }}' domain_type: '{{ item.type }}' @@ -639,7 +639,7 @@ - { name: l3_dom, type: l3dom } - name: Remove domains - aci_domain: + cisco.aci.aci_domain: <<: *aci_info domain: vmm_dom domain_type: vmm diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_domain_to_vlan_pool/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_domain_to_vlan_pool/tasks/main.yml index ab10856a8..e8c14fc55 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_domain_to_vlan_pool/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_domain_to_vlan_pool/tasks/main.yml @@ -4,7 +4,7 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined @@ -20,7 +20,7 @@ output_level: '{{ aci_output_level | default("info") }}' - name: Verify Cloud and Non-Cloud Sites in use. - include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml - name: Execute tasks only for non-cloud sites when: query_cloud.current == [] # This condition will execute only non-cloud sites @@ -81,7 +81,7 @@ register: nm_add_binding - name: Verify add_binding - assert: + ansible.builtin.assert: that: - cm_add_binding is changed - nm_add_binding is changed @@ -105,7 +105,7 @@ register: nm_add_binding_again - name: Verify add_binding_again - assert: + ansible.builtin.assert: that: - cm_add_binding_again is not changed - nm_add_binding_again is not changed @@ -150,7 +150,7 @@ register: nm_vmm_type - name: Verify bindings with domain types - assert: + ansible.builtin.assert: that: - err_not_vmm_with_vm_provider is not changed - err_not_vmm_with_vm_provider.msg == "Domain type 'phys' cannot have a 'vm_provider'" @@ -182,7 +182,7 @@ register: nm_query_all_bindings - name: Verify query_all_bindings - assert: + ansible.builtin.assert: that: - cm_query_all_bindings is not changed - nm_query_all_bindings is not changed @@ -209,7 +209,7 @@ register: nm_query_binding - name: Verify query_binding - assert: + ansible.builtin.assert: that: - cm_query_binding is not changed - nm_query_binding is not changed @@ -231,7 +231,7 @@ register: nm_remove_binding - name: Verify remove_binding - assert: + ansible.builtin.assert: that: - cm_remove_binding is changed - nm_remove_binding is changed @@ -250,7 +250,7 @@ register: nm_remove_binding_again - name: Verify remove_binding_again - assert: + ansible.builtin.assert: that: - cm_remove_binding_again is not changed - nm_remove_binding_again is not changed @@ -275,7 +275,7 @@ register: nm_query_non_binding - name: Verify query_non_binding - assert: + ansible.builtin.assert: that: - cm_query_non_binding is not changed - nm_query_non_binding is not changed diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_encap_pool/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_encap_pool/tasks/main.yml index f0e61a7ef..4c5bd5578 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_encap_pool/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_encap_pool/tasks/main.yml @@ -4,12 +4,12 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: test that we have an aci apic host, aci username and aci password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined - name: Verify Cloud and Non-Cloud Sites in use. - include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml - name: Execute tasks only for non-cloud sites when: query_cloud.current == [] # This condition will execute only non-cloud sites diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_encap_pool/tasks/vlan.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_encap_pool/tasks/vlan.yml index 1354c149a..abfcda88f 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_encap_pool/tasks/vlan.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_encap_pool/tasks/vlan.yml @@ -27,7 +27,7 @@ register: create_check_mode - name: assertion test - present - assert: + ansible.builtin.assert: that: - create_check_mode is changed - create_check_mode.sent.fvnsVlanInstP.attributes.allocMode == 'static' @@ -40,7 +40,7 @@ register: create_static - name: assertion test - present - assert: + ansible.builtin.assert: that: - create_static is changed - create_static.previous == [] @@ -54,7 +54,7 @@ register: create_dynamic - name: assertion test - present - assert: + ansible.builtin.assert: that: - create_dynamic is changed - create_dynamic.previous == [] @@ -69,7 +69,7 @@ register: idempotent_static - name: assertion test - present - assert: + ansible.builtin.assert: that: - idempotent_static is not changed - idempotent_static.previous.0.fvnsVlanInstP.attributes.allocMode == 'static' @@ -84,7 +84,7 @@ register: idempotent_dynamic - name: assertion test - present - assert: + ansible.builtin.assert: that: - idempotent_dynamic is not changed - idempotent_dynamic.previous.0.fvnsVlanInstP.attributes.allocMode == 'dynamic' @@ -100,7 +100,7 @@ register: update_static - name: assertion test - present - assert: + ansible.builtin.assert: that: - update_static is changed - update_static.sent.fvnsVlanInstP.attributes.descr == 'Ansible Test Change' @@ -112,7 +112,7 @@ register: update_dynamic - name: assertion test - present - assert: + ansible.builtin.assert: that: - update_dynamic is changed - update_dynamic.sent.fvnsVlanInstP.attributes.descr == 'Ansible Test Change' @@ -125,7 +125,7 @@ register: vlan_alloc_fail - name: assertion test - present - assert: + ansible.builtin.assert: that: - vlan_alloc_fail is failed - "vlan_alloc_fail.msg == 'ACI requires parameter \\'pool_allocation_mode\\' for \\'pool_type\\' of \\'vlan\\' and \\'vsan\\' when parameter \\'pool\\' is provided'" @@ -138,7 +138,7 @@ register: vlan_pool_fail - name: assertion test - present - assert: + ansible.builtin.assert: that: - vlan_pool_fail is failed - 'vlan_pool_fail.msg == "state is present but all of the following are missing: pool"' @@ -151,7 +151,7 @@ register: vlan_pool_type_fail - name: assertion test - present - assert: + ansible.builtin.assert: that: - vlan_pool_type_fail is failed - 'vlan_pool_type_fail.msg == "missing required arguments: pool_type"' @@ -165,7 +165,7 @@ register: get_all_pools - name: assertion test - query - assert: + ansible.builtin.assert: that: - get_all_pools is not changed - get_all_pools.method == "GET" @@ -178,7 +178,7 @@ register: get_static_pool - name: assertion test - query - assert: + ansible.builtin.assert: that: - get_static_pool is not changed - get_static_pool.method == "GET" @@ -193,7 +193,7 @@ register: get_dynamic_pool - name: assertion test - query - assert: + ansible.builtin.assert: that: - get_dynamic_pool is not changed - get_dynamic_pool.method == "GET" @@ -210,7 +210,7 @@ register: vlan_query_pool_type_fail - name: assertion test - query - assert: + ansible.builtin.assert: that: - vlan_query_pool_type_fail is failed - 'vlan_query_pool_type_fail.msg == "missing required arguments: pool_type"' @@ -221,7 +221,7 @@ register: delete_static - name: assertion test - absent - assert: + ansible.builtin.assert: that: - delete_static is changed - delete_static.method == "DELETE" @@ -235,7 +235,7 @@ register: delete_check_mode - name: assertion test - absent - assert: + ansible.builtin.assert: that: - delete_check_mode is changed @@ -245,7 +245,7 @@ register: delete_dynamic - name: assertion test - absent - assert: + ansible.builtin.assert: that: - delete_dynamic is changed - delete_dynamic.method == "DELETE" @@ -258,7 +258,7 @@ register: idempotent_delete_static - name: assertion test - absent - assert: + ansible.builtin.assert: that: - idempotent_delete_static is not changed - idempotent_delete_static.previous == [] @@ -269,7 +269,7 @@ register: idempotent_delete_dynamic - name: assertion test - absent - assert: + ansible.builtin.assert: that: - idempotent_delete_dynamic is not changed - idempotent_delete_dynamic.previous == [] diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_encap_pool/tasks/vxlan.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_encap_pool/tasks/vxlan.yml index 6467af376..35b211233 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_encap_pool/tasks/vxlan.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_encap_pool/tasks/vxlan.yml @@ -31,7 +31,7 @@ register: create_vxlan_check_mode - name: assertion test - present - assert: + ansible.builtin.assert: that: - create_vxlan_check_mode is changed - create_vxlan_check_mode.sent.fvnsVxlanInstP.attributes.descr == 'Ansible Test' @@ -43,7 +43,7 @@ register: create_vxlan - name: assertion test - present - assert: + ansible.builtin.assert: that: - create_vxlan is changed - create_vxlan.previous == [] @@ -56,7 +56,7 @@ register: idempotent_vxlan - name: assertion test - present - assert: + ansible.builtin.assert: that: - idempotent_vxlan is not changed - idempotent_vxlan.previous.0.fvnsVxlanInstP.attributes.name == 'anstest' @@ -69,7 +69,7 @@ register: update_vxlan - name: assertion test - present - assert: + ansible.builtin.assert: that: - update_vxlan is changed - update_vxlan.sent.fvnsVxlanInstP.attributes.descr == 'Ansible Test Change' @@ -81,7 +81,7 @@ register: create_vxlan_2 - name: assertion test - present - assert: + ansible.builtin.assert: that: - create_vxlan_2 is changed @@ -94,7 +94,7 @@ register: create_vxlan_alloc_mode - name: assertion test - present - assert: + ansible.builtin.assert: that: - create_vxlan_alloc_mode is failed - "create_vxlan_alloc_mode.msg == 'vxlan pools do not support setting the \\'pool_allocation_mode\\'; please remove this parameter from the task'" @@ -106,7 +106,7 @@ register: query_vxlan - name: assertion test - query - assert: + ansible.builtin.assert: that: - query_vxlan is not changed - query_vxlan.current | length == 1 @@ -119,7 +119,7 @@ register: query_vxlan_all - name: assertion test - query - assert: + ansible.builtin.assert: that: - query_vxlan_all is not changed - query_vxlan_all.current | length > 1 @@ -132,7 +132,7 @@ register: delete_vxlan_check_mode - name: assertion test - absent - assert: + ansible.builtin.assert: that: - delete_vxlan_check_mode is changed - delete_vxlan_check_mode.previous != [] @@ -143,7 +143,7 @@ register: delete_vxlan - name: assertion test - absent - assert: + ansible.builtin.assert: that: - delete_vxlan is changed - delete_vxlan.previous == delete_vxlan_check_mode.previous @@ -162,7 +162,7 @@ register: delete_vxlan_pool_fail - name: assertion test - absent - assert: + ansible.builtin.assert: that: - delete_vxlan_idempotent is not changed - delete_vxlan_idempotent.previous == [] @@ -173,7 +173,7 @@ pool: anstest_2 - name: assertion test - absent - assert: + ansible.builtin.assert: that: - delete_vxlan_pool_fail is failed - 'delete_vxlan_pool_fail.msg == "state is absent but all of the following are missing: pool"' diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_encap_pool_range/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_encap_pool_range/tasks/main.yml index 005628c5d..1b4c1a942 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_encap_pool_range/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_encap_pool_range/tasks/main.yml @@ -4,12 +4,12 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: test that we have an aci apic host, aci username and aci password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined - name: Verify Cloud and Non-Cloud Sites in use. - include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml - name: Execute tasks only for non-cloud sites when: query_cloud.current == [] # This condition will execute only non-cloud sites diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_encap_pool_range/tasks/vlan.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_encap_pool_range/tasks/vlan.yml index 6af58bf5d..e82623a3c 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_encap_pool_range/tasks/vlan.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_encap_pool_range/tasks/vlan.yml @@ -43,7 +43,7 @@ register: range_present_check_mode - name: present assertions - assert: + ansible.builtin.assert: that: - range_present_check_mode is changed - range_present_check_mode.sent.fvnsEncapBlk.attributes.allocMode == 'inherit' @@ -58,7 +58,7 @@ register: range_present - name: present assertions - assert: + ansible.builtin.assert: that: - range_present is changed - range_present.previous == [] @@ -72,7 +72,7 @@ register: range_present_idempotent - name: present assertions - assert: + ansible.builtin.assert: that: - range_present_idempotent is not changed - range_present_idempotent.previous.0.fvnsEncapBlk.attributes.name == "anstest" @@ -85,7 +85,7 @@ register: range_present_update - name: present assertions - assert: + ansible.builtin.assert: that: - range_present_update is changed - range_present_update.previous != [] @@ -100,7 +100,7 @@ register: range_present_2 - name: present assertions - assert: + ansible.builtin.assert: that: - range_present_2 is changed - range_present_2.previous == [] @@ -113,7 +113,7 @@ register: range_start_low - name: present assertions - assert: + ansible.builtin.assert: that: - range_start_low is failed - range_start_low.msg == 'vlan pools must have "range_start" and "range_end" values between 1 and 4094' @@ -126,7 +126,7 @@ register: range_start_high - name: present assertions - assert: + ansible.builtin.assert: that: - range_start_high is failed - range_start_high.msg == 'vlan pools must have "range_start" and "range_end" values between 1 and 4094' @@ -139,7 +139,7 @@ register: range_end_low - name: present assertions - assert: + ansible.builtin.assert: that: - range_end_low is failed - range_end_low.msg == 'vlan pools must have "range_start" and "range_end" values between 1 and 4094' @@ -152,7 +152,7 @@ register: range_end_high - name: present assertions - assert: + ansible.builtin.assert: that: - range_end_high is failed - range_end_high.msg == 'vlan pools must have "range_start" and "range_end" values between 1 and 4094' @@ -165,7 +165,7 @@ register: range_start_end - name: present assertions - assert: + ansible.builtin.assert: that: - range_start_end is failed - range_start_end.msg == 'The "range_start" must be less than or equal to the "range_end"' @@ -178,7 +178,7 @@ register: range_present_pool_type - name: present assertions - assert: + ansible.builtin.assert: that: - range_present_pool_type is failed - "range_present_pool_type.msg == 'missing required arguments: pool_type'" @@ -190,7 +190,7 @@ register: range_present_missing_param - name: present assertions - assert: + ansible.builtin.assert: that: - range_present_missing_param is failed - "range_present_missing_param.msg == 'state is present but all of the following are missing: range_end, range_start'" @@ -203,7 +203,7 @@ register: range_present_allocation - name: present assertions - assert: + ansible.builtin.assert: that: - range_present_allocation is failed - range_present_allocation.msg == 'ACI requires the "pool_allocation_mode" for "pool_type" of "vlan" and "vsan" when the "pool" is provided' @@ -215,7 +215,7 @@ register: range_query - name: query assertions - assert: + ansible.builtin.assert: that: - range_query is not changed - range_query.url.endswith("infra/vlanns-[anstest]-static/from-[vlan-20]-to-[vlan-40].json") @@ -229,7 +229,7 @@ register: range_query_from_to_name - name: query assertions - assert: + ansible.builtin.assert: that: - range_query_from_to_name is not changed - range_query_from_to_name.url.endswith("class/fvnsEncapBlk.json") @@ -247,7 +247,7 @@ register: range_query_from_name - name: query assertions - assert: + ansible.builtin.assert: that: - range_query_from_name is not changed - range_query_from_name.url.endswith("class/fvnsEncapBlk.json") @@ -263,7 +263,7 @@ register: range_query_to_name - name: query assertions - assert: + ansible.builtin.assert: that: - range_query_to_name is not changed - range_query_to_name.url.endswith('class/fvnsEncapBlk.json') @@ -280,7 +280,7 @@ register: range_query_name - name: query assertions - assert: + ansible.builtin.assert: that: - range_query_name is not changed - range_query_name.url.endswith("class/fvnsEncapBlk.json") @@ -294,7 +294,7 @@ register: range_query_from_to - name: query assertions - assert: + ansible.builtin.assert: that: - range_query_from_to is not changed - range_query_from_to.url.endswith("class/fvnsEncapBlk.json") @@ -311,7 +311,7 @@ register: range_query_pool - name: query assertions - assert: + ansible.builtin.assert: that: - range_query_pool.current | length == 1 - range_query_pool.current.0.fvnsVlanInstP.attributes.name == "anstest" @@ -326,7 +326,7 @@ register: range_query_all - name: query assertions - assert: + ansible.builtin.assert: that: - range_query_all is not changed - range_query_all.current | length > 1 @@ -340,7 +340,7 @@ register: delete_range - name: absent assertions - assert: + ansible.builtin.assert: that: - delete_range is changed - delete_range.proposed == {} @@ -354,7 +354,7 @@ register: delete_check_mode - name: absent assertions - assert: + ansible.builtin.assert: that: - delete_check_mode is changed - delete_check_mode.previous != [] @@ -365,7 +365,7 @@ register: delete_range_2 - name: absent assertions - assert: + ansible.builtin.assert: that: - delete_range_2 is changed - delete_range_2.previous == delete_check_mode.previous @@ -376,7 +376,7 @@ register: delete_idempotent - name: absent assertions - assert: + ansible.builtin.assert: that: - delete_idempotent is not changed - delete_idempotent.previous == [] diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_epg/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_epg/tasks/main.yml index ffd3ac599..82587ec93 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_epg/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_epg/tasks/main.yml @@ -1,22 +1,20 @@ # Test code for the ACI modules # Copyright: (c) 2017, Jacob McGill (@jmcgill298) # Copyright: (c) 2020, Shreyas Srish (@shrsr) +# Copyright: (c) 2023, Christian Kolrep (@Christian-Kolrep) +# Copyright: (c) 2024, Akini Ross (@akinross) +# Copyright: (c) 2024, Samita Bhattacharjee (@samiib) <samitab@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 APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined -- name: Verify Cloud and Non-Cloud Sites in use. - include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml - -- name: Execute tasks only for non-cloud sites - when: query_cloud.current == [] # This condition will execute only non-cloud sites - block: # block specifies execution of tasks within, based on conditions - - name: ensure tenant exists for tests to kick off - cisco.aci.aci_tenant: &aci_tenant_present +- name: Set vars + ansible.builtin.set_fact: + aci_info: &aci_info host: "{{ aci_hostname }}" username: "{{ aci_username }}" password: "{{ aci_password }}" @@ -24,35 +22,57 @@ use_ssl: '{{ aci_use_ssl | default(true) }}' use_proxy: '{{ aci_use_proxy | default(true) }}' output_level: debug + +- name: Verify Cloud and Non-Cloud Sites in use. + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + +- name: Execute tasks only for non-cloud sites + when: query_cloud.current == [] # This condition will execute only non-cloud sites + block: # block specifies execution of tasks within, based on conditions + - name: Ensure tenant exists for tests to kick off + cisco.aci.aci_tenant: &aci_tenant_present + <<: *aci_info state: present tenant: ansible_test register: tenant_present - - name: ensure monitoring policy exists + - name: Ensure monitoring policy exists cisco.aci.aci_epg_monitoring_policy: - host: "{{ aci_hostname }}" - username: "{{ aci_username }}" - password: "{{ aci_password }}" - validate_certs: '{{ aci_validate_certs | default(false) }}' - use_ssl: '{{ aci_use_ssl | default(true) }}' - use_proxy: '{{ aci_use_proxy | default(true) }}' - output_level: debug + <<: *aci_info monitoring_policy: check tenant: ansible_test - - name: ensure bd exists for tests to kick off + - name: Ensure bd exists for tests to kick off cisco.aci.aci_bd: &aci_bd_present <<: *aci_tenant_present bd: anstest register: bd_present - - name: ensure ap exists for tests to kick off + - name: Ensure ap exists for tests to kick off cisco.aci.aci_ap: &aci_ap_present <<: *aci_tenant_present ap: anstest register: ap_present - - name: create epg - check mode works + - name: Ensure epg anstest dont exist for tests to kick off + cisco.aci.aci_epg: + <<: *aci_ap_present + epg: anstest + state: absent + + - name: Ensure epg anstest2 dont exist for tests to kick off + cisco.aci.aci_epg: + <<: *aci_ap_present + epg: anstest2 + state: absent + + - name: Ensure epg anstest_useg_epg dont exist for tests to kick off + cisco.aci.aci_epg: + <<: *aci_ap_present + epg: anstest_useg_epg + state: absent + + - name: Create epg - check mode works cisco.aci.aci_epg: &aci_epg_present <<: *aci_ap_present epg: anstest @@ -63,36 +83,36 @@ check_mode: true register: epg_present_check_mode - - name: create epg - creation works + - name: Create epg - creation works cisco.aci.aci_epg: <<: *aci_epg_present register: epg_present - - name: create epg - idempotency works + - name: Create epg - idempotency works cisco.aci.aci_epg: <<: *aci_epg_present register: epg_present_idempotent - - name: update epg - update works + - name: Update epg - update works cisco.aci.aci_epg: <<: *aci_epg_present description: Ansible Test Update register: epg_present_update - - name: create epg - missing param + - name: Create epg - missing param cisco.aci.aci_epg: <<: *aci_epg_present ap: "{{ fakevar | default(omit) }}" ignore_errors: true register: epg_present_missing_param - - name: create epg - used for query + - name: Create epg - used for query cisco.aci.aci_epg: <<: *aci_epg_present epg: anstest2 - - name: present assertions - assert: + - name: Create and Update assertions + ansible.builtin.assert: that: - epg_present_check_mode is changed - epg_present_check_mode.previous == [] @@ -110,21 +130,90 @@ - epg_present_missing_param is failed - 'epg_present_missing_param.msg == "state is present but all of the following are missing: ap"' - - name: get specific epg + # TEST NO VERIFICATION + - name: create epg with no verification (check mode) + cisco.aci.aci_epg: &aci_epg_no_verify + <<: *aci_epg_present + epg: anstest-no-verify + no_verification: true + check_mode: true + register: epg_present_no_verify_cm + + - name: create epg with no verification + cisco.aci.aci_epg: + <<: *aci_epg_no_verify + register: epg_present_no_verify + + - name: create epg with no verification again + cisco.aci.aci_epg: + <<: *aci_epg_no_verify + register: epg_present_no_verify_again + + - name: update epg with no verification + cisco.aci.aci_epg: + <<: *aci_epg_no_verify + description: Ansible Test No Verify + register: update_epg_present_no_verify + + - name: delete epg with no verification + cisco.aci.aci_epg: + <<: *aci_epg_no_verify + state: absent + register: delete_epg_present_no_verify + + - name: delete epg with no verification again + cisco.aci.aci_epg: + <<: *aci_epg_no_verify + state: absent + register: delete_epg_present_no_verify_again + + - name: no verification asserts + ansible.builtin.assert: + that: + - epg_present_no_verify_cm is changed + - epg_present_no_verify_cm.current_verified == false + - epg_present_no_verify_cm.current.0 == epg_present_no_verify_cm.proposed + - epg_present_no_verify is changed + - epg_present_no_verify.current_verified == false + - epg_present_no_verify.current.0 == epg_present_no_verify.proposed + - epg_present_no_verify.previous == [] + - epg_present_no_verify_again is not changed + - epg_present_no_verify_again.current_verified == true + - epg_present_no_verify_again.current.0.fvAEPg.attributes.name == "anstest-no-verify" + - epg_present_no_verify_again.current.0.fvAEPg.attributes.descr == "Ansible Test" + - epg_present_no_verify_again.previous.0.fvAEPg.attributes.name == "anstest-no-verify" + - epg_present_no_verify_again.previous.0.fvAEPg.attributes.descr == "Ansible Test" + - update_epg_present_no_verify is changed + - update_epg_present_no_verify.current_verified == false + - update_epg_present_no_verify.current.0 == update_epg_present_no_verify.proposed + - update_epg_present_no_verify.previous.0.fvAEPg.attributes.name == "anstest-no-verify" + - update_epg_present_no_verify.previous.0.fvAEPg.attributes.descr == "Ansible Test" + - delete_epg_present_no_verify is changed + - delete_epg_present_no_verify.current_verified == false + - delete_epg_present_no_verify.current.0 == delete_epg_present_no_verify.proposed + - delete_epg_present_no_verify.previous.0.fvAEPg.attributes.name == "anstest-no-verify" + - delete_epg_present_no_verify.previous.0.fvAEPg.attributes.descr == "Ansible Test No Verify" + - delete_epg_present_no_verify_again is not changed + - delete_epg_present_no_verify_again.current_verified == true + - delete_epg_present_no_verify_again.current == [] + - delete_epg_present_no_verify_again.previous == [] + - delete_epg_present_no_verify_again.proposed == {} + + - name: Query specific epg cisco.aci.aci_epg: <<: *aci_epg_present state: query register: epg_query - - name: get all epgs + - name: Query all epgs cisco.aci.aci_epg: <<: *aci_tenant_present state: query tenant: "{{ fakevar | default(omit) }}" register: epg_query_all - - name: query assertions - assert: + - name: Query assertions + ansible.builtin.assert: that: - epg_query is not changed - epg_query.current | length == 1 @@ -134,40 +223,40 @@ - '"tn-ansible_test/ap-anstest/epg-anstest.json" in epg_query.url' - epg_query_all is not changed - epg_query_all.current | length > 1 - - '"?rsp-subtree=full&rsp-subtree-class=fvRsAEPgMonPol,fvRsBd" in epg_query_all.filter_string' + - '"?rsp-subtree=full&rsp-subtree-class=fvCrtrn,fvRsAEPgMonPol,fvRsBd" in epg_query_all.filter_string' - '"class/fvAEPg.json" in epg_query_all.url' - - name: delete epg - check mode works + - name: Delete epg - check mode works cisco.aci.aci_epg: &aci_epg_absent <<: *aci_epg_present state: absent check_mode: true register: delete_epg_check_mode - - name: delete epg - delete works + - name: Delete epg - delete works cisco.aci.aci_epg: <<: *aci_epg_absent register: delete_epg - - name: delete epg - idempotency works + - name: Delete epg - idempotency works cisco.aci.aci_epg: <<: *aci_epg_absent register: delete_epg_idempotent - - name: delete epg - cleanup extra epg + - name: Delete epg - cleanup extra epg cisco.aci.aci_epg: <<: *aci_epg_absent epg: anstest2 - - name: delete epg - missing param fails + - name: Delete epg - missing param fails cisco.aci.aci_epg: <<: *aci_epg_absent tenant: "{{ fakevar | default(omit) }}" ignore_errors: true register: delete_epg_missing_param - - name: query assertions - assert: + - name: Delete assertions + ansible.builtin.assert: that: - delete_epg_check_mode is changed - delete_epg_check_mode.previous != [] @@ -178,7 +267,9 @@ - delete_epg_missing_param is failed - 'delete_epg_missing_param.msg == "state is absent but all of the following are missing: tenant"' - - name: create microsegmented epg with check mode + # USEG SPECIFIC TESTS + + - name: Create useg epg (check mode) cisco.aci.aci_epg: &cm_useg_epg_present <<: *aci_ap_present epg: anstest_useg_epg @@ -188,129 +279,137 @@ check_mode: true register: cm_useg_epg_present - - name: Assertions check for create microsegmented epg with check mode - assert: - that: - - cm_useg_epg_present is changed - - cm_useg_epg_present.current == [] - - cm_useg_epg_present.previous == [] - - cm_useg_epg_present.sent.fvAEPg.attributes.name == 'anstest_useg_epg' - - cm_useg_epg_present.sent.fvAEPg.attributes.isAttrBasedEPg == 'yes' - - cm_useg_epg_present.sent.fvAEPg.children.0.fvRsBd.attributes.tnFvBDName == 'anstest' - - - name: create microsegmented epg with normal mode + - name: Create useg epg (normal mode) cisco.aci.aci_epg: &nm_useg_epg_present <<: *cm_useg_epg_present register: nm_useg_epg_present - - name: Assertions check for create microsegmented epg with normal mode - assert: + - name: Create useg epg again + cisco.aci.aci_epg: + <<: *cm_useg_epg_present + register: nm_useg_epg_present_again + + - name: Assertions for creating useg epgs + ansible.builtin.assert: that: + - cm_useg_epg_present is changed + - cm_useg_epg_present.current == [] + - cm_useg_epg_present.previous == [] + - cm_useg_epg_present.proposed.fvAEPg.attributes.name == 'anstest_useg_epg' + - cm_useg_epg_present.proposed.fvAEPg.attributes.isAttrBasedEPg == 'yes' + - cm_useg_epg_present.proposed.fvAEPg.children.1.fvCrtrn.attributes.name == 'default' + - cm_useg_epg_present.proposed.fvAEPg.children.0.fvRsBd.attributes.tnFvBDName == 'anstest' - nm_useg_epg_present is changed - nm_useg_epg_present.current | length == 1 - nm_useg_epg_present.previous == [] - nm_useg_epg_present.current.0.fvAEPg.attributes.name == 'anstest_useg_epg' - nm_useg_epg_present.current.0.fvAEPg.attributes.isAttrBasedEPg == 'yes' - - nm_useg_epg_present.current.0.fvAEPg.children.0.fvRsBd.attributes.tnFvBDName == 'anstest' - - nm_useg_epg_present.sent.fvAEPg.attributes.name == 'anstest_useg_epg' - - nm_useg_epg_present.sent.fvAEPg.attributes.isAttrBasedEPg == 'yes' - - nm_useg_epg_present.sent.fvAEPg.children.0.fvRsBd.attributes.tnFvBDName == 'anstest' - - - name: create microsegmented epg with normal mode - idempotency works - cisco.aci.aci_epg: - <<: *cm_useg_epg_present - register: idempotency_nm_useg_epg_present - - - name: Idempotency assertions check for create microsegmented epg with normal mode - assert: - that: - - idempotency_nm_useg_epg_present is not changed - - idempotency_nm_useg_epg_present.current | length == 1 - - idempotency_nm_useg_epg_present.previous | length == 1 - - idempotency_nm_useg_epg_present.current.0.fvAEPg.attributes.name == 'anstest_useg_epg' - - idempotency_nm_useg_epg_present.previous.0.fvAEPg.attributes.name == 'anstest_useg_epg' - - idempotency_nm_useg_epg_present.current.0.fvAEPg.attributes.isAttrBasedEPg == 'yes' - - idempotency_nm_useg_epg_present.previous.0.fvAEPg.attributes.isAttrBasedEPg == 'yes' - - idempotency_nm_useg_epg_present.current.0.fvAEPg.children.0.fvRsBd.attributes.tnFvBDName == 'anstest' - - idempotency_nm_useg_epg_present.previous.0.fvAEPg.children.0.fvRsBd.attributes.tnFvBDName == 'anstest' - - - name: get anstest_useg_epg epg + - nm_useg_epg_present.current.0.fvAEPg.children.0.fvCrtrn.attributes.name == 'default' + - nm_useg_epg_present.current.0.fvAEPg.children.1.fvRsBd.attributes.tnFvBDName == 'anstest' + - nm_useg_epg_present_again is not changed + - nm_useg_epg_present_again.previous | length == 1 + - nm_useg_epg_present_again.previous.0.fvAEPg.attributes.name == 'anstest_useg_epg' + - nm_useg_epg_present_again.previous.0.fvAEPg.children.0.fvCrtrn.attributes.name == 'default' + - nm_useg_epg_present_again.previous.0.fvAEPg.children.1.fvRsBd.attributes.tnFvBDName == 'anstest' + - nm_useg_epg_present_again.previous.0.fvAEPg.attributes.isAttrBasedEPg == 'yes' + - nm_useg_epg_present_again.current | length == 1 + - nm_useg_epg_present_again.current.0.fvAEPg.attributes.name == 'anstest_useg_epg' + - nm_useg_epg_present_again.current.0.fvAEPg.children.0.fvCrtrn.attributes.name == 'default' + - nm_useg_epg_present_again.current.0.fvAEPg.children.1.fvRsBd.attributes.tnFvBDName == 'anstest' + - nm_useg_epg_present_again.current.0.fvAEPg.attributes.isAttrBasedEPg == 'yes' + + - name: Query useg epg cisco.aci.aci_epg: <<: *nm_useg_epg_present state: query register: useg_epg_present - - name: Assertions check for query microsegmented epg with normal mode - assert: + - name: Assertions check for query useg epg + ansible.builtin.assert: that: - useg_epg_present is not changed - useg_epg_present.current | length == 1 - useg_epg_present.current.0.fvAEPg.attributes.name == 'anstest_useg_epg' - useg_epg_present.current.0.fvAEPg.attributes.isAttrBasedEPg == 'yes' - - useg_epg_present.current.0.fvAEPg.children.0.fvRsBd.attributes.tnFvBDName == 'anstest' + - useg_epg_present.current.0.fvAEPg.children.0.fvCrtrn.attributes.name == 'default' + - useg_epg_present.current.0.fvAEPg.children.1.fvRsBd.attributes.tnFvBDName == 'anstest' + + - name: Update useg epg + cisco.aci.aci_epg: + <<: *cm_useg_epg_present + match: all + precedence: 1 + register: nm_useg_epg_update + + - name: Update useg epg (error) + cisco.aci.aci_epg: + <<: *cm_useg_epg_present + useg: no + ignore_errors: true + register: err_useg_epg_update - - name: delete microsegmented epg with check mode + - name: Assertions check for update useg epg + assert: + that: + - nm_useg_epg_update is changed + - nm_useg_epg_update.previous | length == 1 + - nm_useg_epg_update.previous.0.fvAEPg.children.0.fvCrtrn.attributes.name == 'default' + - nm_useg_epg_update.previous.0.fvAEPg.children.0.fvCrtrn.attributes.prec == '0' + - nm_useg_epg_update.previous.0.fvAEPg.children.0.fvCrtrn.attributes.match == 'any' + - nm_useg_epg_update.previous.0.fvAEPg.children.1.fvRsBd.attributes.tnFvBDName == 'anstest' + - nm_useg_epg_update.current.0.fvAEPg.attributes == nm_useg_epg_update.previous.0.fvAEPg.attributes + - nm_useg_epg_update.current | length == 1 + - nm_useg_epg_update.current.0.fvAEPg.children.0.fvCrtrn.attributes.name == 'default' + - nm_useg_epg_update.current.0.fvAEPg.children.0.fvCrtrn.attributes.prec == '1' + - nm_useg_epg_update.current.0.fvAEPg.children.0.fvCrtrn.attributes.match == 'all' + - nm_useg_epg_update.current.0.fvAEPg.children.1.fvRsBd.attributes.tnFvBDName == 'anstest' + - err_useg_epg_update is failed + - 'err_useg_epg_update.msg == "Changing attribute useg on existing EPG is not supported."' + + - name: Delete useg epg with (check mode) cisco.aci.aci_epg: &cm_useg_epg_absent <<: *nm_useg_epg_present state: absent check_mode: true register: cm_useg_epg_absent - - name: Assertions check for delete microsegmented epg with check mode - assert: + - name: Delete useg epg + cisco.aci.aci_epg: + <<: *cm_useg_epg_absent + register: nm_useg_epg_absent + + - name: Delete useg epg again + cisco.aci.aci_epg: + <<: *cm_useg_epg_absent + register: nm_useg_epg_absent_again + + - name: Assertions check for delete useg epg with check mode + ansible.builtin.assert: that: - cm_useg_epg_absent is changed - - cm_useg_epg_absent.current | length == 1 - cm_useg_epg_absent.previous | length == 1 - - cm_useg_epg_absent.current.0.fvAEPg.attributes.name == 'anstest_useg_epg' - - cm_useg_epg_absent.current.0.fvAEPg.attributes.isAttrBasedEPg == 'yes' - - cm_useg_epg_absent.current.0.fvAEPg.children.0.fvRsBd.attributes.tnFvBDName == 'anstest' - cm_useg_epg_absent.previous.0.fvAEPg.attributes.name == 'anstest_useg_epg' - cm_useg_epg_absent.previous.0.fvAEPg.attributes.isAttrBasedEPg == 'yes' - - cm_useg_epg_absent.previous.0.fvAEPg.children.0.fvRsBd.attributes.tnFvBDName == 'anstest' - - - name: delete microsegmented epg with normal mode - cisco.aci.aci_epg: &nm_useg_epg_absent - <<: *cm_useg_epg_absent - state: absent - register: nm_useg_epg_absent - - - name: Assertions check for delete microsegmented epg with normal mode - assert: - that: + - cm_useg_epg_absent.previous.0.fvAEPg.children.0.fvCrtrn.attributes.name == 'default' + - cm_useg_epg_absent.previous.0.fvAEPg.children.1.fvRsBd.attributes.tnFvBDName == 'anstest' + - cm_useg_epg_absent.current | length == 1 + - cm_useg_epg_absent.current.0.fvAEPg.attributes.name == 'anstest_useg_epg' + - cm_useg_epg_absent.current.0.fvAEPg.attributes.isAttrBasedEPg == 'yes' + - cm_useg_epg_absent.current.0.fvAEPg.children.0.fvCrtrn.attributes.name == 'default' + - cm_useg_epg_absent.current.0.fvAEPg.children.1.fvRsBd.attributes.tnFvBDName == 'anstest' + - cm_useg_epg_absent.proposed == {} - nm_useg_epg_absent is changed - - nm_useg_epg_absent.current | length == 0 + - nm_useg_epg_absent.current == [] - nm_useg_epg_absent.previous | length == 1 - nm_useg_epg_absent.previous.0.fvAEPg.attributes.name == 'anstest_useg_epg' - nm_useg_epg_absent.previous.0.fvAEPg.attributes.isAttrBasedEPg == 'yes' - - nm_useg_epg_absent.previous.0.fvAEPg.children.0.fvRsBd.attributes.tnFvBDName == 'anstest' - - - name: delete microsegmented epg with normal mode - idempotency works - cisco.aci.aci_epg: - <<: *nm_useg_epg_absent - register: idempotency_nm_useg_epg_absent - - - name: Idempotency assertions check for delete microsegmented epg with normal mode - assert: - that: - - idempotency_nm_useg_epg_absent is not changed - - idempotency_nm_useg_epg_absent.current | length == 0 - - idempotency_nm_useg_epg_absent.previous | length == 0 - - - name: cleanup bd - cisco.aci.aci_bd: - <<: *aci_bd_present - state: absent - when: bd_present.previous == [] - - - name: cleanup ap - cisco.aci.aci_ap: - <<: *aci_ap_present - state: absent - when: ap_present.previous == [] + - nm_useg_epg_absent.previous.0.fvAEPg.children.0.fvCrtrn.attributes.name == 'default' + - nm_useg_epg_absent.previous.0.fvAEPg.children.1.fvRsBd.attributes.tnFvBDName == 'anstest' + - nm_useg_epg_absent_again is not changed + - nm_useg_epg_absent_again.current == [] + - nm_useg_epg_absent_again.previous == [] - - name: cleanup tenant + - name: Cleanup tenant cisco.aci.aci_tenant: <<: *aci_tenant_present state: absent - when: tenant_present.previous == [] diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_epg_monitoring_policy/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_epg_monitoring_policy/tasks/main.yml index 1671e252e..dbcf8ed18 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_epg_monitoring_policy/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_epg_monitoring_policy/tasks/main.yml @@ -18,7 +18,7 @@ use_ssl: '{{ aci_use_ssl | default(true) }}' use_proxy: '{{ aci_use_proxy | default(true) }}' output_level: '{{ aci_output_level | default("info") }}' - aci_tenant: ansible_test + cisco.aci.aci_tenant: ansible_test - name: Verify Cloud and Non-Cloud Sites in use. ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_epg_subnet/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_epg_subnet/tasks/main.yml index 07fb1d304..ae194bb89 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_epg_subnet/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_epg_subnet/tasks/main.yml @@ -5,12 +5,12 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: "{{ aci_hostname }}" username: "{{ aci_username }}" @@ -21,14 +21,14 @@ output_level: debug - name: Query system information - aci_system: + cisco.aci.aci_system: <<: *aci_info id: 1 state: query register: version - name: Verify Cloud and Non-Cloud Sites in use. - include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml - name: ensure tenant does not exists cisco.aci.aci_tenant: &aci_tenant_absent @@ -138,7 +138,7 @@ ignore_errors: true - name: asserts for subnet creation tasks - assert: + ansible.builtin.assert: that: - create_check_mode is changed - create_check_mode.sent.fvSubnet.attributes.descr == create_subnet.sent.fvSubnet.attributes.descr == 'Ansible Test' @@ -155,7 +155,7 @@ - create_wrong_mask.msg == "Valid Subnet Masks are 0 to 32 for IPv4 Addresses and 0 to 128 for IPv6 addresses" - name: assert for subnet IpDPlearning tasks version >=5 - assert: + ansible.builtin.assert: that: - create_subnet2_5 is changed - create_subnet2_5.current.0.fvSubnet.attributes.ctrl == 'no-default-gateway' @@ -170,7 +170,7 @@ when: version.current.0.topSystem.attributes.version is version('5', '>=') - name: assert for subnet IpDPlearning tasks version < 5 - assert: + ansible.builtin.assert: that: - create_subnet2 is changed - create_subnet2.current.0.fvSubnet.attributes.ctrl == 'no-default-gateway' @@ -204,7 +204,7 @@ register: get_subnets_gateway - name: asserts for query tasks - assert: + ansible.builtin.assert: that: - get_all_epg is not changed - '"rsp-subtree-class=fvRsBDSubnetToProfile,fvRsNdPfxPol,fvSubnet" in get_all_epg.filter_string' @@ -241,7 +241,7 @@ register: delete_idempotency - name: asserts for deletion task - assert: + ansible.builtin.assert: that: - delete_check_mode is changed - delete_check_mode.proposed == {} diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_epg_to_contract/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_epg_to_contract/tasks/main.yml index ec97334ab..f7213c1e6 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_epg_to_contract/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_epg_to_contract/tasks/main.yml @@ -1,15 +1,16 @@ # Test code for the ACI modules # Copyright: (c) 2017, Jacob McGill (@jmcgill298) +# Copyright: (c) 2023, Akini Ross (@akinross) <akinross@cisco.com> # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined - name: Verify Cloud and Non-Cloud Sites in use. - include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml - name: Ensure contract binding does not exist prior to testing cisco.aci.aci_epg_to_contract: @@ -30,8 +31,8 @@ - name: Execute tasks only for non-cloud sites when: query_cloud.current == [] # This condition will execute only non-cloud sites block: # block specifies execution of tasks within, based on conditions - - name: ensure tenant exists for tests to kick off - cisco.aci.aci_tenant: &aci_tenant_present + - name: remove tenant for tests to kick off + cisco.aci.aci_tenant: &aci_tenant_absent host: "{{ aci_hostname }}" username: "{{ aci_username }}" password: "{{ aci_password }}" @@ -40,6 +41,12 @@ use_proxy: '{{ aci_use_proxy | default(true) }}' output_level: debug tenant: ansible_test + state: absent + register: tenant_present + + - name: ensure tenant exists for tests to kick off + cisco.aci.aci_tenant: &aci_tenant_present + <<: *aci_tenant_absent state: present register: tenant_present @@ -118,7 +125,7 @@ register: incompatible_present - name: present assertions - assert: + ansible.builtin.assert: that: - provide_present_check_mode is changed - provide_present_check_mode.sent.fvRsProv.attributes.tnVzBrCPName == 'anstest_http' @@ -138,6 +145,68 @@ - incompatible_present is failed - incompatible_present.msg == "the 'provider_match' is only configurable for Provided Contracts" + - name: bind taboo contract to epg + cisco.aci.aci_epg_to_contract: + <<: *aci_epg_present + contract: anstest_https + contract_type: taboo + register: taboo_present + + - name: bind interface contract to epg + cisco.aci.aci_epg_to_contract: + <<: *aci_epg_present + contract: anstest_https + contract_type: interface + register: interface_present + + - name: bind intra epg contract to epg + cisco.aci.aci_epg_to_contract: &aci_epg_intra_present + <<: *aci_epg_present + contract: anstest_https + contract_type: intra_epg + register: intra_epg_present + + - name: bind intra epg contract to epg (error contract label) + cisco.aci.aci_epg_to_contract: + <<: *aci_epg_intra_present + contract_label: anstest_contract_label + ignore_errors: true + register: err_contract_label + + - name: bind intra epg contract to epg (error subject label) + cisco.aci.aci_epg_to_contract: + <<: *aci_epg_intra_present + subject_label: anstest_subject_label + ignore_errors: true + register: err_subject_label + + - name: bind intra epg contract to epg (error subject and contract label) + cisco.aci.aci_epg_to_contract: + <<: *aci_epg_intra_present + contract_label: anstest_contract_label + subject_label: anstest_subject_label + ignore_errors: true + register: err_subject_and_contract_label + + - name: present assertions for taboo, interface and intra_epg contract types + assert: + that: + - taboo_present is changed + - taboo_present.previous == [] + - taboo_present.current.0.fvRsProtBy.attributes.tnVzTabooName == 'anstest_https' + - interface_present is changed + - interface_present.previous == [] + - interface_present.current.0.fvRsConsIf.attributes.tnVzCPIfName == 'anstest_https' + - intra_epg_present is changed + - intra_epg_present.previous == [] + - intra_epg_present.current.0.fvRsIntraEpg.attributes.tnVzBrCPName == 'anstest_https' + - err_contract_label is failed + - err_contract_label.msg == "the 'contract_label' and 'subject_label' are not configurable for intra_epg contracts" + - err_subject_label is failed + - err_subject_label.msg == "the 'contract_label' and 'subject_label' are not configurable for intra_epg contracts" + - err_subject_and_contract_label is failed + - err_subject_and_contract_label.msg == "the 'contract_label' and 'subject_label' are not configurable for intra_epg contracts" + - name: get binding cisco.aci.aci_epg_to_contract: <<: *aci_epg_provide_present2 @@ -166,7 +235,7 @@ register: missing_required_query - name: query assertions - assert: + ansible.builtin.assert: that: - query_provide_contract is not changed - query_provide_contract.current != [] @@ -223,7 +292,7 @@ register: missing_required_absent - name: absent assertions - assert: + ansible.builtin.assert: that: - consume_absent_check_mode is changed - consume_absent_check_mode.previous.0.fvRsCons is defined diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_epg_to_contract_interface/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_epg_to_contract_interface/tasks/main.yml index a7ba64768..04edb3030 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_epg_to_contract_interface/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_epg_to_contract_interface/tasks/main.yml @@ -4,13 +4,13 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined # SET VARS - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: '{{ aci_hostname }}' username: '{{ aci_username }}' @@ -20,7 +20,7 @@ use_proxy: '{{ aci_use_proxy | default(true) }}' - name: Verify Cloud and Non-Cloud Sites in use. - include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml - name: Ensure ansible_test does not exist prior to testing cisco.aci.aci_tenant: &ansible_test_absent @@ -95,7 +95,7 @@ register: inter_tenant_contract_interface_present - name: Ensure inter_tenant_contract_interface binding with anstest1_epg - assert: + ansible.builtin.assert: that: - inter_tenant_contract_interface_present is changed - inter_tenant_contract_interface_present.current | length == 1 @@ -109,7 +109,7 @@ register: idempotency_check - name: Verfication of idempotency_check - assert: + ansible.builtin.assert: that: - idempotency_check is not changed @@ -124,7 +124,7 @@ register: single_object_query_result - name: Verification of single consumed contract interface - assert: + ansible.builtin.assert: that: - single_object_query_result is not changed - single_object_query_result.current.0.fvRsConsIf.attributes.tnVzCPIfName == 'inter_tenant_contract_interface' @@ -139,7 +139,7 @@ register: all_object_query_result - name: Verification of all consumed contract interface - assert: + ansible.builtin.assert: that: - all_object_query_result is not changed - inter_tenant_contract_interface_present.current | length >= 1 diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_epg_to_contract_master/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_epg_to_contract_master/tasks/main.yml index 08a956f96..5b21ec87f 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_epg_to_contract_master/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_epg_to_contract_master/tasks/main.yml @@ -4,13 +4,13 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined # CLEAN ENVIRONMENT - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: '{{ aci_hostname }}' username: '{{ aci_username }}' @@ -21,10 +21,10 @@ output_level: '{{ aci_output_level | default("info") }}' - name: Verify Cloud and Non-Cloud Sites in use. - include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml - name: Ensure tenant doesn't exist - aci_tenant: + cisco.aci.aci_tenant: <<: *aci_info state: absent tenant: ansible_test @@ -34,7 +34,7 @@ when: query_cloud.current == [] # This condition will execute only non-cloud sites block: # block specifies execution of tasks within, based on conditions - name: Ensure tenant exists for tests to kick off - aci_tenant: &aci_tenant_present + cisco.aci.aci_tenant: &aci_tenant_present <<: *aci_info state: present tenant: ansible_test @@ -113,7 +113,7 @@ - {ap: 'anstest_2', epg: 'anstest_3'} - name: Verify add_contract_master - assert: + ansible.builtin.assert: that: - item is changed - item.current.0.fvRsSecInherited.attributes.tDn == "uni/tn-ansible_test/ap-anstest/epg-anstest" @@ -132,7 +132,7 @@ - {ap: 'anstest', epg: 'anstest_2'} - {ap: 'anstest_2', epg: 'anstest_3'} - name: Verify add_another_contract_master - assert: + ansible.builtin.assert: that: - item is changed - item.current.0.fvRsSecInherited.attributes.tDn == "uni/tn-ansible_test/ap-anstest_2/epg-anstest_4" @@ -159,7 +159,7 @@ register: query_specific_contract_master - name: Verify query_specific_contract_master - assert: + ansible.builtin.assert: that: - query_specific_contract_master is not changed - query_specific_contract_master.current.0.fvRsSecInherited.attributes.dn == "uni/tn-ansible_test/ap-anstest/epg-anstest_2/rssecInherited-[uni/tn-ansible_test/ap-anstest_2/epg-anstest_4]" @@ -177,7 +177,7 @@ register: query_another_specific_contract_master - name: Verify query_another_specific_contract_master - assert: + ansible.builtin.assert: that: - query_another_specific_contract_master is not changed - query_another_specific_contract_master.current.0.fvRsSecInherited.attributes.dn == "uni/tn-ansible_test/ap-anstest/epg-anstest_2/rssecInherited-[uni/tn-ansible_test/ap-anstest/epg-anstest]" @@ -195,14 +195,14 @@ register: remove_contract_master - name: Verify remove_contract_master - assert: + ansible.builtin.assert: that: - remove_contract_master is changed - remove_contract_master.current == [] # Clean up environment - name: Ensure tenant doesn't exist - aci_tenant: + cisco.aci.aci_tenant: <<: *aci_info state: absent tenant: ansible_test diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_epg_to_domain/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_epg_to_domain/tasks/main.yml index ea482f563..0903178ef 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_epg_to_domain/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_epg_to_domain/tasks/main.yml @@ -4,13 +4,13 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined # CLEAN ENVIRONMENT - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: "{{ aci_hostname }}" username: "{{ aci_username }}" @@ -21,14 +21,14 @@ output_level: '{{ aci_output_level | default("debug") }}' - name: Query system information - aci_system: + cisco.aci.aci_system: <<: *aci_info id: 1 state: query register: version - name: Verify Cloud and Non-Cloud Sites in use. - include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml - name: Execute tasks only for non-cloud sites when: query_cloud.current == [] # This condition will execute only non-cloud sites @@ -237,7 +237,7 @@ register: vmm_uplink_change_active - name: vmm_uplink assertions - assert: + ansible.builtin.assert: that: - vmm_uplink is changed - vmm_uplink.current.0.fvRsDomAtt.children.0.fvUplinkOrderCont.attributes.active == "1,2" @@ -287,7 +287,7 @@ register: vmm_uplink_empty_value_standby - name: vmm_uplink assertions - assert: + ansible.builtin.assert: that: - vmm_uplink_0_value is changed - vmm_uplink_0_value.current.0.fvRsDomAtt.children.0.fvUplinkOrderCont.attributes.active == "0" @@ -324,14 +324,14 @@ register: vmm_uplink_33_value - name: vmm_uplink error assertions - assert: + ansible.builtin.assert: that: - 'vmm_uplink_change_active_same_as_standby.msg == "APIC Error 120: Invalid Configuration. Uplink Id entered more than once or delimiter was misused."' - 'vmm_uplink_empty_value_active.msg == "APIC Error 801: property active of uni/tn-ansible_test/ap-anstest/epg-anstest/rsdomAtt-[uni/vmmp-VMware/dom-anstest]/uplinkorder failed validation for value ''''"' - 'vmm_uplink_string_value.msg == "APIC Error 801: property active of uni/tn-ansible_test/ap-anstest/epg-anstest/rsdomAtt-[uni/vmmp-VMware/dom-anstest]/uplinkorder failed validation for value ''testing''"' - name: vmm_uplink error assertions for non-cloud - assert: + ansible.builtin.assert: that: - 'vmm_uplink_33_value.msg == "APIC Error 120: Invalid Configuration. Uplink Id can not be higher than 32."' @@ -344,7 +344,7 @@ register: custom_epg_name - name: Verify custom epg name - assert: + ansible.builtin.assert: that: - custom_epg_name.current.0.fvRsDomAtt.attributes.customEpgName == "anstest_epg" @@ -386,7 +386,7 @@ loop: "{{ range(0, 7, 1)|list }}" - name: domains with delimiter assertions - assert: + ansible.builtin.assert: that: - delimeter.results.0 is changed - delimeter.results.0.current.0.fvRsDomAtt.attributes.delimiter == "|" @@ -403,7 +403,7 @@ - delimeter.results.6 is changed - delimeter.results.6.current.0.fvRsDomAtt.attributes.delimiter == "=" - delimiter_not_allowed is not changed - - 'delimiter_not_allowed.msg == "value of delimiter must be one of: |, ~, !, @, ^, +, =, got: not_allowed"' + - 'delimiter_not_allowed.msg == "value of delimiter must be one of: |, ~, !, @, ^, +, =, _, got: not_allowed"' - delimeter_absent.results.0 is changed - delimeter_absent.results.0.current == [] - delimeter_absent.results.1 is changed @@ -441,7 +441,7 @@ register: untagged_vlan_absent - name: domains with untagged vlan assertions - assert: + ansible.builtin.assert: that: - untagged_vlan_true is changed - untagged_vlan_true.current.0.fvRsDomAtt.attributes.untagged == "yes" @@ -489,7 +489,7 @@ register: port_binding_absent - name: domains with port binding assertions - assert: + ansible.builtin.assert: that: - port_binding_dynamic is changed - port_binding_dynamic.current.0.fvRsDomAtt.attributes.bindingType == "dynamicBinding" @@ -532,7 +532,7 @@ register: port_allocation_absent - name: domains with port allocation assertions - assert: + ansible.builtin.assert: that: - port_allocation_elastic is changed - port_allocation_elastic.current.0.fvRsDomAtt.attributes.portAllocation == "elastic" @@ -565,7 +565,7 @@ register: number_of_ports_absent - name: domains with number of ports assertions - assert: + ansible.builtin.assert: that: - number_of_ports_2 is changed - number_of_ports_2.current.0.fvRsDomAtt.attributes.numPorts == "2" @@ -598,7 +598,7 @@ register: forged_transmits_and_mac_changes_absent - name: domains with forged transmits and mac changes assertions - assert: + ansible.builtin.assert: that: - forged_transmits_and_mac_changes_accept is changed - forged_transmits_and_mac_changes_accept.current.0.fvRsDomAtt.children.0.vmmSecP.attributes.forgedTransmits == "accept" @@ -610,7 +610,7 @@ - forged_transmits_and_mac_changes_absent.current == [] - name: present assertions - assert: + ansible.builtin.assert: that: - phys_check_mode_present is changed - phys_present is changed @@ -649,7 +649,7 @@ register: binding_query - name: query assertions - assert: + ansible.builtin.assert: that: - binding_query is not changed - binding_query.current | length > 1 @@ -686,7 +686,7 @@ register: absent_missing_param - name: absent assertions - assert: + ansible.builtin.assert: that: - epg_domain_check_mode_absent is changed - epg_domain_check_mode_absent.previous != [] @@ -732,4 +732,46 @@ cisco.aci.aci_tenant: <<: *aci_tenant_present state: absent - when: tenant_present is changed
\ No newline at end of file + when: tenant_present is changed + + # Seperate underscore delimiter tests + # All other tests use underscore delimiters in naming of parents whiches causes tests fail + # Error: 400 - Validation failed: Tenant/Application/EPG name contains _. Please use another delimiter or rename + - name: Ensure tenant exists for testing underscore delimiter + cisco.aci.aci_tenant: &underscore_tenant + <<: *aci_info + tenant: underscore + state: present + register: tenant_present + + - name: Ensure ap exists for testing underscore delimiter + cisco.aci.aci_ap: &underscore_ap + <<: *underscore_tenant + ap: underscore + register: ap_present + + - name: Ensure epg exists for testing underscore delimiter + cisco.aci.aci_epg: &underscore_epg + <<: *underscore_ap + epg: underscore + + - name: Create domain with underscore delimiter delimiter + cisco.aci.aci_epg_to_domain: + <<: *underscore_epg + domain: anstest + domain_type: vmm + vm_provider: vmware + delimiter: "_" + register: underscore + + - name: Assert underscore delimiter + ansible.builtin.assert: + that: + - underscore is changed + - underscore.current.0.fvRsDomAtt.attributes.delimiter == "_" + + - name: Remove tenant used for testing underscore delimiter + cisco.aci.aci_tenant: + <<: *underscore_tenant + state: absent + register: tenant_present
\ No newline at end of file diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_epg_useg_attribute_block_statement/aliases b/ansible_collections/cisco/aci/tests/integration/targets/aci_epg_useg_attribute_block_statement/aliases new file mode 100644 index 000000000..209b793f9 --- /dev/null +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_epg_useg_attribute_block_statement/aliases @@ -0,0 +1,2 @@ +# No ACI simulator yet, so not enabled +# unsupported diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_epg_useg_attribute_block_statement/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_epg_useg_attribute_block_statement/tasks/main.yml new file mode 100644 index 000000000..75bd9b2e6 --- /dev/null +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_epg_useg_attribute_block_statement/tasks/main.yml @@ -0,0 +1,251 @@ +# Test code for the ACI modules +# Copyright: (c) 2024, Akini Ross (@akinross) + +# 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 APIC host, ACI username and ACI password + ansible.builtin.fail: + msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' + when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined + +- name: Set vars + ansible.builtin.set_fact: + aci_info: &aci_info + host: "{{ aci_hostname }}" + username: "{{ aci_username }}" + password: "{{ aci_password }}" + validate_certs: '{{ aci_validate_certs | default(false) }}' + use_ssl: '{{ aci_use_ssl | default(true) }}' + use_proxy: '{{ aci_use_proxy | default(true) }}' + output_level: '{{ aci_output_level | default("info") }}' + +- name: Verify Cloud and Non-Cloud Sites in use. + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + +- name: Execute tasks only for non-cloud sites ( clean after ) + when: + - query_cloud.current == [] + block: + + # CLEAN TEST ENVIRONMENT + - name: Ensure tenant removed + cisco.aci.aci_tenant: &aci_tenant_absent + <<: *aci_info + state: absent + tenant: ansible_test + + # SETUP TEST ENVIRONMENT + - name: Create tenant + cisco.aci.aci_tenant: &aci_tenant_present + <<: *aci_tenant_absent + state: present + + - name: Create AP + cisco.aci.aci_ap: &aci_ap + <<: *aci_tenant_present + ap: ansible_test + + - name: Create uSeg EPG + cisco.aci.aci_epg: + <<: *aci_ap + epg: ansible_test_1 + bd: ansible_test + useg: yes + + # CREATE AND UPDATE TESTS + - name: Create block statement in default block (check mode) + cisco.aci.aci_epg_useg_attribute_block_statement: &block_a_parent_default_present + <<: *aci_ap + epg: ansible_test_1 + name: block_a + check_mode: true + register: cm_create_block_a_parent_default + + - name: Create block statement in default block + cisco.aci.aci_epg_useg_attribute_block_statement: + <<: *block_a_parent_default_present + register: nm_create_block_a_parent_default + + - name: Create block statement in default block again + cisco.aci.aci_epg_useg_attribute_block_statement: + <<: *block_a_parent_default_present + register: nm_create_block_a_parent_default_again + + - name: Assert create block statement in default block + ansible.builtin.assert: + that: + - cm_create_block_a_parent_default is changed + - cm_create_block_a_parent_default.previous == [] + - cm_create_block_a_parent_default.current == [] + - cm_create_block_a_parent_default.proposed.fvSCrtrn.attributes.name == "block_a" + - cm_create_block_a_parent_default.proposed.fvSCrtrn.attributes.dn == "uni/tn-ansible_test/ap-ansible_test/epg-ansible_test_1/crtrn/crtrn-block_a" + - nm_create_block_a_parent_default is changed + - nm_create_block_a_parent_default.previous == [] + - nm_create_block_a_parent_default.current.0.fvSCrtrn.attributes.name == "block_a" + - nm_create_block_a_parent_default.current.0.fvSCrtrn.attributes.match == "any" + - nm_create_block_a_parent_default.current.0.fvSCrtrn.attributes.dn == "uni/tn-ansible_test/ap-ansible_test/epg-ansible_test_1/crtrn/crtrn-block_a" + - nm_create_block_a_parent_default_again is not changed + - nm_create_block_a_parent_default_again.previous.0.fvSCrtrn.attributes.name == "block_a" + - nm_create_block_a_parent_default_again.previous.0.fvSCrtrn.attributes.match == "any" + - nm_create_block_a_parent_default_again.previous.0.fvSCrtrn.attributes.dn == "uni/tn-ansible_test/ap-ansible_test/epg-ansible_test_1/crtrn/crtrn-block_a" + - nm_create_block_a_parent_default_again.current.0.fvSCrtrn.attributes.name == "block_a" + - nm_create_block_a_parent_default_again.current.0.fvSCrtrn.attributes.match == "any" + - nm_create_block_a_parent_default_again.current.0.fvSCrtrn.attributes.dn == "uni/tn-ansible_test/ap-ansible_test/epg-ansible_test_1/crtrn/crtrn-block_a" + + - name: Update block statement in default block + cisco.aci.aci_epg_useg_attribute_block_statement: + <<: *block_a_parent_default_present + match: all + state: present + register: nm_update_block_a_parent_default + + - name: Assert update block statement match + ansible.builtin.assert: + that: + - nm_update_block_a_parent_default is changed + - nm_update_block_a_parent_default.previous.0.fvSCrtrn.attributes.name == "block_a" + - nm_update_block_a_parent_default.previous.0.fvSCrtrn.attributes.match == "any" + - nm_update_block_a_parent_default.previous.0.fvSCrtrn.attributes.dn == "uni/tn-ansible_test/ap-ansible_test/epg-ansible_test_1/crtrn/crtrn-block_a" + - nm_update_block_a_parent_default.current.0.fvSCrtrn.attributes.name == "block_a" + - nm_update_block_a_parent_default.current.0.fvSCrtrn.attributes.match == "all" + - nm_update_block_a_parent_default.current.0.fvSCrtrn.attributes.dn == "uni/tn-ansible_test/ap-ansible_test/epg-ansible_test_1/crtrn/crtrn-block_a" + + - name: Create block statement in block_a + cisco.aci.aci_epg_useg_attribute_block_statement: &block_b_parent_block_a + <<: *block_a_parent_default_present + name: block_b + match: all + parent_block_statements: + - block_a + register: nm_create_block_b_parent_block_a + + - name: Create block statement in block_b + cisco.aci.aci_epg_useg_attribute_block_statement: &block_c_parent_block_b + <<: *block_a_parent_default_present + name: block_c + match: any + parent_block_statements: + - block_a + - block_b + register: nm_create_block_c_parent_block_b + + - name: Assert create block statement in default block + ansible.builtin.assert: + that: + - nm_create_block_b_parent_block_a is changed + - nm_create_block_b_parent_block_a.previous == [] + - nm_create_block_b_parent_block_a.current.0.fvSCrtrn.attributes.name == "block_b" + - nm_create_block_b_parent_block_a.current.0.fvSCrtrn.attributes.match == "all" + - nm_create_block_b_parent_block_a.current.0.fvSCrtrn.attributes.dn == "uni/tn-ansible_test/ap-ansible_test/epg-ansible_test_1/crtrn/crtrn-block_a/crtrn-block_b" + - nm_create_block_c_parent_block_b is changed + - nm_create_block_c_parent_block_b.previous == [] + - nm_create_block_c_parent_block_b.current.0.fvSCrtrn.attributes.name == "block_c" + - nm_create_block_c_parent_block_b.current.0.fvSCrtrn.attributes.match == "any" + - nm_create_block_c_parent_block_b.current.0.fvSCrtrn.attributes.dn == "uni/tn-ansible_test/ap-ansible_test/epg-ansible_test_1/crtrn/crtrn-block_a/crtrn-block_b/crtrn-block_c" + + - name: Create block statement in block_c (error) + cisco.aci.aci_epg_useg_attribute_block_statement: + <<: *block_a_parent_default_present + name: block_d + match: any + parent_block_statements: + - block_a + - block_b + - block_c + register: err_too_many_blocks + ignore_errors: true + + - name: Assert create block statement in default block + ansible.builtin.assert: + that: + - err_too_many_blocks is failed + - err_too_many_blocks.msg == "3 block statements are provided but the maximum amount of parent_block_statements is 2" + + # QUERY TESTS + - name: Query block statement in default block + cisco.aci.aci_epg_useg_attribute_block_statement: + <<: *block_a_parent_default_present + state: query + register: query_block_a_parent_default + + - name: Query all block statements + cisco.aci.aci_epg_useg_attribute_block_statement: + <<: *aci_info + state: query + register: query_all_blocks + + - name: Assert query block statements + ansible.builtin.assert: + that: + - query_block_a_parent_default is not changed + - query_block_a_parent_default.current | length == 1 + - query_block_a_parent_default.current.0.fvSCrtrn.attributes.name == "block_a" + - query_block_a_parent_default.current.0.fvSCrtrn.attributes.match == "all" + - query_block_a_parent_default.current.0.fvSCrtrn.attributes.dn == "uni/tn-ansible_test/ap-ansible_test/epg-ansible_test_1/crtrn/crtrn-block_a" + - query_all_blocks is not changed + - query_all_blocks.current | length >= 3 + + # REMOVE TESTS + - name: Remove block statement from block_b + cisco.aci.aci_epg_useg_attribute_block_statement: + <<: *block_c_parent_block_b + state: absent + register: rm_block_c_parent_block_b + + - name: Remove block statement from block_a + cisco.aci.aci_epg_useg_attribute_block_statement: + <<: *block_b_parent_block_a + state: absent + register: rm_block_b_parent_block_a + + - name: Remove block statement from default (check mode) + cisco.aci.aci_epg_useg_attribute_block_statement: &block_a_parent_default_absent + <<: *block_a_parent_default_present + state: absent + register: cm_remove_block_a_parent_default + check_mode: true + + - name: Remove block statement from default + cisco.aci.aci_epg_useg_attribute_block_statement: + <<: *block_a_parent_default_absent + register: nm_remove_block_a_parent_default + + - name: Remove block statement from default again + cisco.aci.aci_epg_useg_attribute_block_statement: + <<: *block_a_parent_default_absent + register: nm_remove_block_a_parent_default_again + + - name: Assert remove block statements + ansible.builtin.assert: + that: + - rm_block_c_parent_block_b is changed + - rm_block_c_parent_block_b.previous.0.fvSCrtrn.attributes.name == "block_c" + - rm_block_c_parent_block_b.previous.0.fvSCrtrn.attributes.match == "any" + - rm_block_c_parent_block_b.previous.0.fvSCrtrn.attributes.dn == "uni/tn-ansible_test/ap-ansible_test/epg-ansible_test_1/crtrn/crtrn-block_a/crtrn-block_b/crtrn-block_c" + - rm_block_c_parent_block_b.current == [] + - rm_block_b_parent_block_a is changed + - rm_block_b_parent_block_a.previous.0.fvSCrtrn.attributes.name == "block_b" + - rm_block_b_parent_block_a.previous.0.fvSCrtrn.attributes.match == "all" + - rm_block_b_parent_block_a.previous.0.fvSCrtrn.attributes.dn == "uni/tn-ansible_test/ap-ansible_test/epg-ansible_test_1/crtrn/crtrn-block_a/crtrn-block_b" + - rm_block_b_parent_block_a.current == [] + - cm_remove_block_a_parent_default is changed + - cm_remove_block_a_parent_default.previous.0.fvSCrtrn.attributes.name == "block_a" + - cm_remove_block_a_parent_default.previous.0.fvSCrtrn.attributes.match == "all" + - cm_remove_block_a_parent_default.previous.0.fvSCrtrn.attributes.dn == "uni/tn-ansible_test/ap-ansible_test/epg-ansible_test_1/crtrn/crtrn-block_a" + - cm_remove_block_a_parent_default.current.0.fvSCrtrn.attributes.name == "block_a" + - cm_remove_block_a_parent_default.current.0.fvSCrtrn.attributes.match == "all" + - cm_remove_block_a_parent_default.current.0.fvSCrtrn.attributes.dn == "uni/tn-ansible_test/ap-ansible_test/epg-ansible_test_1/crtrn/crtrn-block_a" + - cm_remove_block_a_parent_default.proposed == {} + - nm_remove_block_a_parent_default is changed + - nm_remove_block_a_parent_default.previous.0.fvSCrtrn.attributes.name == "block_a" + - nm_remove_block_a_parent_default.previous.0.fvSCrtrn.attributes.match == "all" + - nm_remove_block_a_parent_default.previous.0.fvSCrtrn.attributes.dn == "uni/tn-ansible_test/ap-ansible_test/epg-ansible_test_1/crtrn/crtrn-block_a" + - nm_remove_block_a_parent_default.current == [] + - nm_remove_block_a_parent_default_again is not changed + - nm_remove_block_a_parent_default_again.previous == [] + - nm_remove_block_a_parent_default_again.current == [] + + # CLEAN TEST ENVIRONMENT + - name: Remove tenant + cisco.aci.aci_tenant: + <<: *aci_tenant_absent diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_epg_useg_attribute_simple_statement/aliases b/ansible_collections/cisco/aci/tests/integration/targets/aci_epg_useg_attribute_simple_statement/aliases new file mode 100644 index 000000000..209b793f9 --- /dev/null +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_epg_useg_attribute_simple_statement/aliases @@ -0,0 +1,2 @@ +# No ACI simulator yet, so not enabled +# unsupported diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_epg_useg_attribute_simple_statement/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_epg_useg_attribute_simple_statement/tasks/main.yml new file mode 100644 index 000000000..32e4c37b8 --- /dev/null +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_epg_useg_attribute_simple_statement/tasks/main.yml @@ -0,0 +1,261 @@ +# Test code for the ACI modules +# Copyright: (c) 2023, Christian Kolrep (@Christian-Kolrep) +# Copyright: (c) 2024, Akini Ross (@akinross) + +# 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 APIC host, ACI username and ACI password + ansible.builtin.fail: + msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' + when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined + +- name: Set vars + ansible.builtin.set_fact: + aci_info: &aci_info + host: "{{ aci_hostname }}" + username: "{{ aci_username }}" + password: "{{ aci_password }}" + validate_certs: '{{ aci_validate_certs | default(false) }}' + use_ssl: '{{ aci_use_ssl | default(true) }}' + use_proxy: '{{ aci_use_proxy | default(true) }}' + output_level: '{{ aci_output_level | default("debug") }}' + +- name: Verify Cloud and Non-Cloud Sites in use. + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + +- name: Execute tasks only for non-cloud sites ( clean after ) + when: + - query_cloud.current == [] + block: + + # CLEAN TEST ENVIRONMENT + - name: Ensure tenant removed + cisco.aci.aci_tenant: &aci_tenant_absent + <<: *aci_info + state: absent + tenant: ansible_test + + # SETUP TEST ENVIRONMENT + - name: Create tenant + cisco.aci.aci_tenant: &aci_tenant_present + <<: *aci_tenant_absent + state: present + + - name: Create AP + cisco.aci.aci_ap: &aci_ap + <<: *aci_tenant_present + ap: ansible_test + + - name: Create uSeg EPG + cisco.aci.aci_epg: + <<: *aci_ap + epg: ansible_test_1 + bd: ansible_test + useg: yes + + - name: Create block statement block_a + cisco.aci.aci_epg_useg_attribute_block_statement: &block + <<: *aci_ap + epg: ansible_test_1 + name: block_a + + - name: Create block statement block_b + cisco.aci.aci_epg_useg_attribute_block_statement: + <<: *block + name: block_b + parent_block_statements: + - block_a + + - name: Create block statement block_c + cisco.aci.aci_epg_useg_attribute_block_statement: + <<: *block + name: block_c + parent_block_statements: + - block_a + - block_b + + # TEST THAT ALL LEVELS OF BLOCK STATEMENTS WORK WITH THE VM_NAME SIMPLE STATEMENT TYPE + - name: Execute tests for each block statement + ansible.builtin.include_tasks: simple_block_levels.yml + loop: + - [] + - [block_a] + - [block_a, block_b] + - [block_a, block_b, block_c] + loop_control: + loop_var: parent_block_statements + + # INPUT TEST FOR OPERATOR INPUT + - name: Create simple statement with all operator input options + cisco.aci.aci_epg_useg_attribute_simple_statement: + <<: *aci_ap + epg: ansible_test_1 + name: ansible_test_vm_name + type: vm_name + operator: "{{ item }}" + value: ansible_test_vm_name_value + register: nm_operators + loop: + - contains + - equals + - starts_with + - ends_with + + - name: Assert simple statement with all operator input options + ansible.builtin.assert: + that: + - nm_operators.results | length == 4 + - nm_operators.results.0.changed == true + - nm_operators.results.0.current.0.fvVmAttr.attributes.operator == "contains" + - nm_operators.results.1.changed == true + - nm_operators.results.1.current.0.fvVmAttr.attributes.operator == "equals" + - nm_operators.results.2.changed == true + - nm_operators.results.2.current.0.fvVmAttr.attributes.operator == "startsWith" + - nm_operators.results.3.changed == true + - nm_operators.results.3.current.0.fvVmAttr.attributes.operator == "endsWith" + + # INPUT TESTS FOR TYPES + - name: Create simple statement with all type input options + cisco.aci.aci_epg_useg_attribute_simple_statement: + <<: *aci_ap + epg: ansible_test_1 + name: "{{ item.name }}" + type: "{{ item.type }}" + operator: "{{ item.operator }}" + category: "{{ item.category }}" + value: "{{ item.value }}" + use_subnet: "{{ item.use_subnet | default(omit) }}" + register: nm_types + loop: + - { name: ansible_test_ip_1, type: ip, operator: "{{ fake_var | default(omit) }}", category: "{{ fake_var | default(omit) }}", use_subnet: "{{ fake_var | default(omit) }}", value: 10.0.0.1 } + - { name: ansible_test_ip_2, type: ip, operator: "{{ fake_var | default(omit) }}", category: "{{ fake_var | default(omit) }}", use_subnet: true, value: "{{ fake_var | default(omit) }}" } + - { name: ansible_test_mac, type: mac, operator: "{{ fake_var | default(omit) }}", category: "{{ fake_var | default(omit) }}", use_subnet: "{{ fake_var | default(omit) }}", value: "aa:bb:cc:dd:ee:ff" } + - { name: ansible_test_dns, type: dns, operator: "{{ fake_var | default(omit) }}", category: "{{ fake_var | default(omit) }}", use_subnet: "{{ fake_var | default(omit) }}", value: "dns_filter" } + - { name: ansible_test_ad_group, type: ad_group, operator: "{{ fake_var | default(omit) }}", category: "{{ fake_var | default(omit) }}", use_subnet: "{{ fake_var | default(omit) }}", value: "ad_group_selector" } + - { name: ansible_test_vm_custom_attr, type: vm_custom_attr, operator: "contains", category: "custom_attribute", use_subnet: "{{ fake_var | default(omit) }}", value: "custom_attribute_value" } + - { name: ansible_test_vm_vmm_domain, type: vm_vmm_domain, operator: "contains", category: "{{ fake_var | default(omit) }}", use_subnet: "{{ fake_var | default(omit) }}", value: "vm_vmm_domain_value" } + - { name: ansible_test_vm_operating_system, type: vm_operating_system, operator: "contains", category: "{{ fake_var | default(omit) }}", use_subnet: "{{ fake_var | default(omit) }}", value: "vm_operating_system_value" } + - { name: ansible_test_vm_hypervisor_id, type: vm_hypervisor_id, operator: "contains", category: "{{ fake_var | default(omit) }}", use_subnet: "{{ fake_var | default(omit) }}", value: "vm_hypervisor_id_value" } + - { name: ansible_test_vm_datacenter, type: vm_datacenter, operator: "contains", category: "{{ fake_var | default(omit) }}", use_subnet: "{{ fake_var | default(omit) }}", value: "vm_datacenter_value" } + - { name: ansible_test_vm_id, type: vm_id, operator: "contains", category: "{{ fake_var | default(omit) }}", use_subnet: "{{ fake_var | default(omit) }}", value: "vm_id_value" } + - { name: ansible_test_vm_name, type: vm_name, operator: "contains", category: "{{ fake_var | default(omit) }}", use_subnet: "{{ fake_var | default(omit) }}", value: "vm_name_value" } + - { name: ansible_test_vm_folder, type: vm_folder, operator: "contains", category: "{{ fake_var | default(omit) }}", use_subnet: "{{ fake_var | default(omit) }}", value: "vm_folder_value" } + - { name: ansible_test_vm_folder_path, type: vm_folder_path, operator: "{{ fake_var | default(omit) }}", category: "{{ fake_var | default(omit) }}", use_subnet: "{{ fake_var | default(omit) }}", value: "vm_folder_path_value" } + - { name: ansible_test_vm_vnic, type: vm_vnic, operator: "contains", category: "{{ fake_var | default(omit) }}", use_subnet: "{{ fake_var | default(omit) }}", value: "vm_vnic_value" } + - { name: ansible_test_vm_tag, type: vm_tag, operator: "equals", category: "vm_attribute", use_subnet: "{{ fake_var | default(omit) }}", value: "vm_attribute_value" } + ignore_errors: true # ignore errors is set to handle the ad group configuration which is not configurable in the lab environment, so error message is expected to ensure payload is sent + + - name: Assert create simple statement with all type input options + ansible.builtin.assert: + that: + - nm_types.results | length == 16 + - nm_types.results.0.changed == true + - nm_types.results.0.current.0.fvIpAttr.attributes.name == "ansible_test_ip_1" + - nm_types.results.0.current.0.fvIpAttr.attributes.ip == "10.0.0.1" + - nm_types.results.0.current.0.fvIpAttr.attributes.usefvSubnet == "no" + - nm_types.results.1.changed == true + - nm_types.results.1.current.0.fvIpAttr.attributes.name == "ansible_test_ip_2" + - nm_types.results.1.current.0.fvIpAttr.attributes.ip == "0.0.0.0" + - nm_types.results.1.current.0.fvIpAttr.attributes.usefvSubnet == "yes" + - nm_types.results.2.changed == true + - nm_types.results.2.current.0.fvMacAttr.attributes.name == "ansible_test_mac" + - nm_types.results.2.current.0.fvMacAttr.attributes.mac == "AA:BB:CC:DD:EE:FF" + - nm_types.results.3.changed == true + - nm_types.results.3.current.0.fvDnsAttr.attributes.name == "ansible_test_dns" + - nm_types.results.3.current.0.fvDnsAttr.attributes.filter == "dns_filter" + - nm_types.results.4.failed == true + - nm_types.results.4.msg == "APIC Error 400{{":"}} Invalid request. Can not contain child 'idgattr-[ad_group_selector]' under parent 'uni/tn-ansible_test/ap-ansible_test/epg-ansible_test_1/crtrn/idgattr-[ansible_test_ad_group]'" + - nm_types.results.5.changed == true + - nm_types.results.5.current.0.fvVmAttr.attributes.name == "ansible_test_vm_custom_attr" + - nm_types.results.5.current.0.fvVmAttr.attributes.labelName == "custom_attribute" + - nm_types.results.5.current.0.fvVmAttr.attributes.operator == "contains" + - nm_types.results.5.current.0.fvVmAttr.attributes.type == "custom-label" + - nm_types.results.5.current.0.fvVmAttr.attributes.value == "custom_attribute_value" + - nm_types.results.6.changed == true + - nm_types.results.6.current.0.fvVmAttr.attributes.name == "ansible_test_vm_vmm_domain" + - nm_types.results.6.current.0.fvVmAttr.attributes.labelName == "" + - nm_types.results.6.current.0.fvVmAttr.attributes.operator == "contains" + - nm_types.results.6.current.0.fvVmAttr.attributes.type == "domain" + - nm_types.results.6.current.0.fvVmAttr.attributes.value == "vm_vmm_domain_value" + - nm_types.results.7.changed == true + - nm_types.results.7.current.0.fvVmAttr.attributes.name == "ansible_test_vm_operating_system" + - nm_types.results.7.current.0.fvVmAttr.attributes.labelName == "" + - nm_types.results.7.current.0.fvVmAttr.attributes.operator == "contains" + - nm_types.results.7.current.0.fvVmAttr.attributes.type == "guest-os" + - nm_types.results.7.current.0.fvVmAttr.attributes.value == "vm_operating_system_value" + - nm_types.results.8.changed == true + - nm_types.results.8.current.0.fvVmAttr.attributes.name == "ansible_test_vm_hypervisor_id" + - nm_types.results.8.current.0.fvVmAttr.attributes.labelName == "" + - nm_types.results.8.current.0.fvVmAttr.attributes.operator == "contains" + - nm_types.results.8.current.0.fvVmAttr.attributes.type == "hv" + - nm_types.results.8.current.0.fvVmAttr.attributes.value == "vm_hypervisor_id_value" + - nm_types.results.9.changed == true + - nm_types.results.9.current.0.fvVmAttr.attributes.name == "ansible_test_vm_datacenter" + - nm_types.results.9.current.0.fvVmAttr.attributes.labelName == "" + - nm_types.results.9.current.0.fvVmAttr.attributes.operator == "contains" + - nm_types.results.9.current.0.fvVmAttr.attributes.type == "rootContName" + - nm_types.results.9.current.0.fvVmAttr.attributes.value == "vm_datacenter_value" + - nm_types.results.10.changed == true + - nm_types.results.10.current.0.fvVmAttr.attributes.name == "ansible_test_vm_id" + - nm_types.results.10.current.0.fvVmAttr.attributes.labelName == "" + - nm_types.results.10.current.0.fvVmAttr.attributes.operator == "contains" + - nm_types.results.10.current.0.fvVmAttr.attributes.type == "vm" + - nm_types.results.10.current.0.fvVmAttr.attributes.value == "vm_id_value" + - nm_types.results.11.changed == true + - nm_types.results.11.current.0.fvVmAttr.attributes.name == "ansible_test_vm_name" + - nm_types.results.11.current.0.fvVmAttr.attributes.labelName == "" + - nm_types.results.11.current.0.fvVmAttr.attributes.operator == "contains" + - nm_types.results.11.current.0.fvVmAttr.attributes.type == "vm-name" + - nm_types.results.11.current.0.fvVmAttr.attributes.value == "vm_name_value" + - nm_types.results.12.changed == true + - nm_types.results.12.current.0.fvVmAttr.attributes.name == "ansible_test_vm_folder" + - nm_types.results.12.current.0.fvVmAttr.attributes.labelName == "" + - nm_types.results.12.current.0.fvVmAttr.attributes.operator == "contains" + - nm_types.results.12.current.0.fvVmAttr.attributes.type == "vm-folder" + - nm_types.results.12.current.0.fvVmAttr.attributes.value == "vm_folder_value" + - nm_types.results.13.changed == true + - nm_types.results.13.current.0.fvVmAttr.attributes.name == "ansible_test_vm_folder_path" + - nm_types.results.13.current.0.fvVmAttr.attributes.labelName == "" + - nm_types.results.13.current.0.fvVmAttr.attributes.operator == "equals" + - nm_types.results.13.current.0.fvVmAttr.attributes.type == "vmfolder-path" + - nm_types.results.13.current.0.fvVmAttr.attributes.value == "vm_folder_path_value" + - nm_types.results.14.changed == true + - nm_types.results.14.current.0.fvVmAttr.attributes.name == "ansible_test_vm_vnic" + - nm_types.results.14.current.0.fvVmAttr.attributes.labelName == "" + - nm_types.results.14.current.0.fvVmAttr.attributes.operator == "contains" + - nm_types.results.14.current.0.fvVmAttr.attributes.type == "vnic" + - nm_types.results.14.current.0.fvVmAttr.attributes.value == "vm_vnic_value" + - nm_types.results.15.changed == true + - nm_types.results.15.current.0.fvVmAttr.attributes.name == "ansible_test_vm_tag" + - nm_types.results.15.current.0.fvVmAttr.attributes.labelName == "" + - nm_types.results.15.current.0.fvVmAttr.attributes.operator == "equals" + - nm_types.results.15.current.0.fvVmAttr.attributes.type == "tag" + - nm_types.results.15.current.0.fvVmAttr.attributes.value == "vm_attribute_value" + + # ERROR TESTS + - name: Create simple statement with too many parents (error) + cisco.aci.aci_epg_useg_attribute_simple_statement: + <<: *aci_ap + epg: ansible_test_1 + parent_block_statements: + - block_a + - block_b + - block_c + - block_d + name: ansible_test_vm_name + type: vm_name + operator: contains + value: ansible_test_vm_name_value + register: err_too_many_blocks + ignore_errors: true + + - name: Assert create block statement in default block + ansible.builtin.assert: + that: + - err_too_many_blocks is failed + - err_too_many_blocks.msg == "4 block statements are provided but the maximum amount of parent_block_statements is 3" + + # CLEAN TEST ENVIRONMENT + - name: Remove tenant + cisco.aci.aci_tenant: + <<: *aci_tenant_absent diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_epg_useg_attribute_simple_statement/tasks/simple_block_levels.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_epg_useg_attribute_simple_statement/tasks/simple_block_levels.yml new file mode 100644 index 000000000..b37a5c7d5 --- /dev/null +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_epg_useg_attribute_simple_statement/tasks/simple_block_levels.yml @@ -0,0 +1,156 @@ +- name: Set vars + ansible.builtin.set_fact: + aci_info: &aci_info + host: "{{ aci_hostname }}" + username: "{{ aci_username }}" + password: "{{ aci_password }}" + validate_certs: '{{ aci_validate_certs | default(false) }}' + use_ssl: '{{ aci_use_ssl | default(true) }}' + use_proxy: '{{ aci_use_proxy | default(true) }}' + output_level: '{{ aci_output_level | default("debug") }}' + aci_epg: &aci_epg + tenant: ansible_test + ap: ansible_test + epg: ansible_test_1 + +# CREATE AND UPDATE TESTS +- name: Create simple statement in block statement (check mode) + cisco.aci.aci_epg_useg_attribute_simple_statement: &simple_present + <<: *aci_info + <<: *aci_epg + parent_block_statements: "{{ parent_block_statements }}" + name: ansible_test_vm_name + type: vm_name + operator: contains + value: ansible_test_vm_name_value + check_mode: true + register: cm_create_simple + +- name: Create simple statement in block statement + cisco.aci.aci_epg_useg_attribute_simple_statement: + <<: *simple_present + register: nm_create_simple + +- name: Create simple statement in block statement again + cisco.aci.aci_epg_useg_attribute_simple_statement: + <<: *simple_present + register: nm_create_simple_again + +- name: Assert create simple statement in block statement + ansible.builtin.assert: + that: + - cm_create_simple is changed + - cm_create_simple.previous == [] + - cm_create_simple.current == [] + - cm_create_simple.proposed.fvVmAttr.attributes.name == "ansible_test_vm_name" + - cm_create_simple.proposed.fvVmAttr.attributes.type == "vm-name" + - cm_create_simple.proposed.fvVmAttr.attributes.operator == "contains" + - cm_create_simple.proposed.fvVmAttr.attributes.value == "ansible_test_vm_name_value" + - nm_create_simple is changed + - nm_create_simple.previous == [] + - nm_create_simple.current.0.fvVmAttr.attributes.name == "ansible_test_vm_name" + - nm_create_simple.current.0.fvVmAttr.attributes.type == "vm-name" + - nm_create_simple.current.0.fvVmAttr.attributes.operator == "contains" + - nm_create_simple.current.0.fvVmAttr.attributes.value == "ansible_test_vm_name_value" + - nm_create_simple_again is not changed + - nm_create_simple_again.previous.0.fvVmAttr.attributes.name == "ansible_test_vm_name" + - nm_create_simple_again.previous.0.fvVmAttr.attributes.type == "vm-name" + - nm_create_simple_again.previous.0.fvVmAttr.attributes.operator == "contains" + - nm_create_simple_again.previous.0.fvVmAttr.attributes.value == "ansible_test_vm_name_value" + - nm_create_simple_again.current.0.fvVmAttr.attributes.name == "ansible_test_vm_name" + - nm_create_simple_again.current.0.fvVmAttr.attributes.type == "vm-name" + - nm_create_simple_again.current.0.fvVmAttr.attributes.operator == "contains" + - nm_create_simple_again.current.0.fvVmAttr.attributes.value == "ansible_test_vm_name_value" + +# QUERY TESTS +- name: Create another simple statement in block statement + cisco.aci.aci_epg_useg_attribute_simple_statement: &simple_present_update + <<: *simple_present + name: ansible_test_vm_name_2 + type: vm_name + operator: contains + value: ansible_test_vm_name_value_2 + register: nm_create_simple_2 + +- name: Create another simple statement in block statement + cisco.aci.aci_epg_useg_attribute_simple_statement: + <<: *simple_present_update + operator: equals + value: ansible_test_vm_name_value_3 + register: nm_create_simple_2_update + +- name: Assert updates + ansible.builtin.assert: + that: + - nm_create_simple_2.current.0.fvVmAttr.attributes.name == "ansible_test_vm_name_2" + - nm_create_simple_2.current.0.fvVmAttr.attributes.type == "vm-name" + - nm_create_simple_2.current.0.fvVmAttr.attributes.operator == "contains" + - nm_create_simple_2.current.0.fvVmAttr.attributes.value == "ansible_test_vm_name_value_2" + - nm_create_simple_2_update.current.0.fvVmAttr.attributes.name == "ansible_test_vm_name_2" + - nm_create_simple_2_update.current.0.fvVmAttr.attributes.type == "vm-name" + - nm_create_simple_2_update.current.0.fvVmAttr.attributes.operator == "equals" + - nm_create_simple_2_update.current.0.fvVmAttr.attributes.value == "ansible_test_vm_name_value_3" + +- name: Query simple statement in block statement + cisco.aci.aci_epg_useg_attribute_simple_statement: + <<: *simple_present + state: query + register: query_one + +- name: Query all simple statements of type vm_name + cisco.aci.aci_epg_useg_attribute_simple_statement: + <<: *aci_info + type: vm_name + state: query + register: query_all + +- name: Assert queries + ansible.builtin.assert: + that: + - query_one.current | length == 1 + - query_one.current.0.fvVmAttr.attributes.name == "ansible_test_vm_name" + - query_one.current.0.fvVmAttr.attributes.type == "vm-name" + - query_one.current.0.fvVmAttr.attributes.operator == "contains" + - query_one.current.0.fvVmAttr.attributes.value == "ansible_test_vm_name_value" + - query_all.current | length >= 2 + +# REMOVE TESTS +- name: Remove simple statement from block statement (check mode) + cisco.aci.aci_epg_useg_attribute_simple_statement: &simple_absent + <<: *simple_present + state: absent + check_mode: true + register: cm_remove_simple + +- name: Remove simple statement from block statement + cisco.aci.aci_epg_useg_attribute_simple_statement: + <<: *simple_absent + register: nm_remove_simple + +- name: Remove simple statement from block statement again + cisco.aci.aci_epg_useg_attribute_simple_statement: + <<: *simple_absent + register: nm_remove_simple_again + +- name: Assert remove simple statement from block statement + ansible.builtin.assert: + that: + - cm_remove_simple is changed + - cm_remove_simple.previous.0.fvVmAttr.attributes.name == "ansible_test_vm_name" + - cm_remove_simple.previous.0.fvVmAttr.attributes.type == "vm-name" + - cm_remove_simple.previous.0.fvVmAttr.attributes.operator == "contains" + - cm_remove_simple.previous.0.fvVmAttr.attributes.value == "ansible_test_vm_name_value" + - cm_remove_simple.current.0.fvVmAttr.attributes.name == "ansible_test_vm_name" + - cm_remove_simple.current.0.fvVmAttr.attributes.type == "vm-name" + - cm_remove_simple.current.0.fvVmAttr.attributes.operator == "contains" + - cm_remove_simple.current.0.fvVmAttr.attributes.value == "ansible_test_vm_name_value" + - cm_remove_simple.proposed == {} + - nm_remove_simple is changed + - nm_remove_simple.previous.0.fvVmAttr.attributes.name == "ansible_test_vm_name" + - nm_remove_simple.previous.0.fvVmAttr.attributes.type == "vm-name" + - nm_remove_simple.previous.0.fvVmAttr.attributes.operator == "contains" + - nm_remove_simple.previous.0.fvVmAttr.attributes.value == "ansible_test_vm_name_value" + - nm_remove_simple.current == [] + - nm_remove_simple_again is not changed + - nm_remove_simple_again.previous == [] + - nm_remove_simple_again.current == [] diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_esg/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_esg/tasks/main.yml index 34a482fa9..3716bd7e8 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_esg/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_esg/tasks/main.yml @@ -4,13 +4,13 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined # SET VARS - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: '{{ aci_hostname }}' username: '{{ aci_username }}' @@ -28,7 +28,7 @@ register: version - name: Verify Cloud and Non-Cloud Sites in use. - include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml - name: Ensure tenant - ansible_test does not exists before testing cisco.aci.aci_tenant: &tenant_absent @@ -71,7 +71,7 @@ register: cm_web_esg_0_present - name: Assertions check for add web_esg_0 with check mode - assert: + ansible.builtin.assert: that: - cm_web_esg_0_present is changed - cm_web_esg_0_present.current | length == 0 @@ -83,7 +83,7 @@ register: nm_web_esg_0_present - name: Assertions check for add web_esg_0 with normal mode - assert: + ansible.builtin.assert: that: - nm_web_esg_0_present is changed - nm_web_esg_0_present.current | length == 1 @@ -96,7 +96,7 @@ - nm_web_esg_0_present.current.0.fvESg.children[0].fvRsScope.attributes.tnFvCtxName == 'default' - name: Assertions check for add web_esg_0 with normal mode (v5.2+) - assert: + ansible.builtin.assert: that: - nm_web_esg_0_present.current.0.fvESg.attributes.shutdown == 'no' when: version.current.0.topSystem.attributes.version is version('5.2', '>=') @@ -107,7 +107,7 @@ register: idempotency_web_esg_0_present - name: Idempotency assertions check for add web_esg_0 with normal mode - assert: + ansible.builtin.assert: that: - idempotency_web_esg_0_present is not changed - idempotency_web_esg_0_present.current | length == 1 @@ -123,7 +123,7 @@ register: ap_1_web_esg_0_present - name: Assertions check for add web_esg_0 under ap(anstest_ap_1_present) - assert: + ansible.builtin.assert: that: - ap_1_web_esg_0_present is changed - ap_1_web_esg_0_present.current | length == 1 @@ -142,7 +142,7 @@ when: version.current.0.topSystem.attributes.version is version('5.2', '>=') - name: Assertions check for add web_esg_1 - assert: + ansible.builtin.assert: that: - web_esg_1_present is changed - web_esg_1_present.current | length == 1 @@ -164,7 +164,7 @@ when: version.current.0.topSystem.attributes.version is version('5.2', '>=') - name: Assertions check for add web_esg_2 - assert: + ansible.builtin.assert: that: - web_esg_2_present is changed - web_esg_2_present.current | length == 1 @@ -183,7 +183,7 @@ register: query_web_esg_0 - name: Assertions check for query an ESG(web_esg_0) under ap(anstest_ap) - assert: + ansible.builtin.assert: that: - query_web_esg_0 is not changed - query_web_esg_0.current | length == 1 @@ -191,7 +191,7 @@ - query_web_esg_0.current.0.fvESg.attributes.dn == "uni/tn-ansible_test/ap-anstest_ap/esg-web_esg_0" - name: Assertions check for query an ESG(web_esg_0) under ap(anstest_ap) (v5.2+) - assert: + ansible.builtin.assert: that: - query_web_esg_0.current.0.fvESg.attributes.shutdown == 'no' when: version.current.0.topSystem.attributes.version is version('5.2', '>=') @@ -203,14 +203,14 @@ register: query_all_esg - name: Assertions check for query all ESGs - assert: + ansible.builtin.assert: that: - query_all_esg is not changed - query_all_esg.current | length >= 2 # Count of ESGs added in the above tasks when: version.current.0.topSystem.attributes.version is version('5.2', '<') - name: Assertions check for query all ESGs - assert: + ansible.builtin.assert: that: - query_all_esg is not changed - query_all_esg.current | length >= 4 # Count of ESGs added in the above tasks @@ -224,7 +224,7 @@ register: query_all_esg_with_name - name: Assertions check for query all ESGs with a Specific Name - assert: + ansible.builtin.assert: that: - query_all_esg_with_name is not changed - query_all_esg_with_name.current | length >= 2 @@ -237,7 +237,7 @@ register: query_all_ap_esg - name: Assertions check for query all ESGs of an App Profile (<v5.2) - assert: + ansible.builtin.assert: that: - query_all_ap_esg is not changed - query_all_ap_esg.current.0.fvAp.attributes.name == 'anstest_ap' @@ -245,7 +245,7 @@ when: version.current.0.topSystem.attributes.version is version('5.2', '<') - name: Assertions check for query all ESGs of an App Profile (>=v5.2) - assert: + ansible.builtin.assert: that: - query_all_ap_esg is not changed - query_all_ap_esg.current.0.fvAp.attributes.name == 'anstest_ap' @@ -261,7 +261,7 @@ check_mode: true - name: Assertions check for remove an ESG with check mode - assert: + ansible.builtin.assert: that: - cm_web_esg_0_absent is changed - cm_web_esg_0_absent.current | length == 1 @@ -275,7 +275,7 @@ register: nm_web_esg_0_absent - name: Assertions check for remove an ESG with normal mode - assert: + ansible.builtin.assert: that: - nm_web_esg_0_absent is changed - nm_web_esg_0_absent.current == [] @@ -288,7 +288,7 @@ register: idempotency_web_esg_0_absent - name: Idempotency assertions check for remove an ESG with normal mode - assert: + ansible.builtin.assert: that: - idempotency_web_esg_0_absent is not changed - idempotency_web_esg_0_absent.current == [] diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_esg_contract_master/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_esg_contract_master/tasks/main.yml index debc3ec47..820e4be56 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_esg_contract_master/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_esg_contract_master/tasks/main.yml @@ -4,13 +4,13 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined # CLEAN ENVIRONMENT - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: '{{ aci_hostname }}' username: '{{ aci_username }}' @@ -28,7 +28,7 @@ register: version - name: Verify Cloud and Non-Cloud Sites in use. - include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml - name: Ensure tenant - ansible_test does not exists before testing cisco.aci.aci_tenant: &tenant_absent @@ -88,7 +88,7 @@ register: cm_contract_esg_present - name: Assertions check for add an ESG contract master to web_esg with check mode - assert: + ansible.builtin.assert: that: - cm_contract_esg_present is changed - cm_contract_esg_present.current == [] @@ -102,7 +102,7 @@ register: nm_contract_esg_present - name: Assertions check for add an ESG contract master to web_esg with normal mode - assert: + ansible.builtin.assert: that: - nm_contract_esg_present is changed - nm_contract_esg_present.current | length == 1 @@ -115,7 +115,7 @@ register: idempotency_contract_esg_present - name: Idempotency assertions check for add an ESG contract master to web_esg with normal mode - assert: + ansible.builtin.assert: that: - idempotency_contract_esg_present is not changed - idempotency_contract_esg_present.current | length == 1 @@ -133,7 +133,7 @@ register: query_result_contract_master_esg - name: Assertions check for query an ESG contract master - assert: + ansible.builtin.assert: that: - query_result_contract_master_esg is not changed - query_result_contract_master_esg.current | length == 1 @@ -149,7 +149,7 @@ register: query_all_contract_master - name: Assertions check for query_all_contract_master - assert: + ansible.builtin.assert: that: - query_all_contract_master is not changed - query_all_contract_master.current | length == 1 @@ -168,7 +168,7 @@ register: cm_contract_esg_absent - name: Assertions check for remove an ESG contract master with check mode - assert: + ansible.builtin.assert: that: - cm_contract_esg_absent is changed - cm_contract_esg_absent.current != [] @@ -182,7 +182,7 @@ register: nm_contract_esg_absent - name: Assertions check for remove an ESG contract master with normal mode - assert: + ansible.builtin.assert: that: - nm_contract_esg_absent is changed - nm_contract_esg_absent.current == [] @@ -195,7 +195,7 @@ register: idempotency_contract_esg_absent - name: Idempotency assertions check for remove an ESG contract master with normal mode - assert: + ansible.builtin.assert: that: - idempotency_contract_esg_absent is not changed - idempotency_contract_esg_absent.current == [] diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_esg_epg_selector/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_esg_epg_selector/tasks/main.yml index 599828ae7..39087a37d 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_esg_epg_selector/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_esg_epg_selector/tasks/main.yml @@ -4,13 +4,13 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined # SET VARS - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: '{{ aci_hostname }}' username: '{{ aci_username }}' @@ -28,7 +28,7 @@ register: version - name: Verify Cloud and Non-Cloud Sites in use. - include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml - name: Ensure tenant - ansible_test does not exists before testing cisco.aci.aci_tenant: &tenant_absent @@ -88,7 +88,7 @@ register: cm_epg_selector_present - name: Assertions check for add an EPG selector with check mode - assert: + ansible.builtin.assert: that: - cm_epg_selector_present is changed - cm_epg_selector_present.current | length == 0 @@ -101,7 +101,7 @@ register: nm_epg_selector_present - name: Assertions check for add an EPG selector with normal mode - assert: + ansible.builtin.assert: that: - nm_epg_selector_present is changed - nm_epg_selector_present.current | length == 1 @@ -114,7 +114,7 @@ register: cm_idempotency_epg_selector_present - name: Idempotency assertions check for add an EPG selector with check mode - assert: + ansible.builtin.assert: that: - cm_idempotency_epg_selector_present is not changed - cm_idempotency_epg_selector_present.current | length == 1 @@ -125,7 +125,7 @@ register: nm_idempotency_epg_selector_present - name: Idempotency assertions check for add an EPG selector with normal mode - assert: + ansible.builtin.assert: that: - nm_idempotency_epg_selector_present is not changed - nm_idempotency_epg_selector_present.current | length == 1 @@ -142,7 +142,7 @@ register: query_single_epg_selector - name: Assertions check for query an EPG selector with esg and epg name - assert: + ansible.builtin.assert: that: - query_single_epg_selector is not changed - query_single_epg_selector.current | length == 1 @@ -158,7 +158,7 @@ register: query_all_epg_selectors_under_ap - name: Assertions check for query all EPG selectors under an application profile - assert: + ansible.builtin.assert: that: - query_all_epg_selectors_under_ap is not changed - query_all_epg_selectors_under_ap.current | length == 1 @@ -173,7 +173,7 @@ register: query_all_epg_selectors - name: Assertions check for query all EPG selectors - assert: + ansible.builtin.assert: that: - query_all_epg_selectors is not changed - query_all_epg_selectors.current | length >= 1 @@ -191,7 +191,7 @@ register: cm_epg_selector_absent - name: Assertions check for remove an EPG selector with check mode - assert: + ansible.builtin.assert: that: - cm_epg_selector_absent is changed - cm_epg_selector_absent.current != [] @@ -204,7 +204,7 @@ register: nm_epg_selector_absent - name: Assertions check for remove an EPG selector with normal mode - assert: + ansible.builtin.assert: that: - nm_epg_selector_absent is changed - nm_epg_selector_absent.current == [] @@ -217,7 +217,7 @@ register: cm_idempotency_epg_selector_absent - name: Idempotency assertions check for EPG selector with check mode - assert: + ansible.builtin.assert: that: - cm_idempotency_epg_selector_absent is not changed - cm_idempotency_epg_selector_absent.current == [] @@ -228,7 +228,7 @@ register: nm_idempotency_epg_selector_absent - name: Idempotency assertions check for EPG selector with normal mode - assert: + ansible.builtin.assert: that: - nm_idempotency_epg_selector_absent is not changed - nm_idempotency_epg_selector_absent.current == [] diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_esg_ip_subnet_selector/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_esg_ip_subnet_selector/tasks/main.yml index f96391704..3564330aa 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_esg_ip_subnet_selector/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_esg_ip_subnet_selector/tasks/main.yml @@ -4,13 +4,13 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined # SET VARS - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: '{{ aci_hostname }}' username: '{{ aci_username }}' @@ -28,7 +28,7 @@ register: version - name: Verify Cloud and Non-Cloud Sites in use. - include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml - name: Ensure tenant - ansible_test does not exists before testing cisco.aci.aci_tenant: &tenant_absent @@ -74,7 +74,7 @@ register: cm_subnet_ip_present - name: Assertions check for add IP Subnet selector with check mode - assert: + ansible.builtin.assert: that: - cm_subnet_ip_present is changed - cm_subnet_ip_present.current == [] @@ -87,7 +87,7 @@ register: nm_subnet_ip_present - name: Assertions check for add IP Subnet selector with normal mode - assert: + ansible.builtin.assert: that: - nm_subnet_ip_present is changed - nm_subnet_ip_present.current | length == 1 @@ -103,7 +103,7 @@ register: idempotency_nm_subnet_ip_present - name: Idempotency assertions check for add IP Subnet selectors with normal mode - assert: + ansible.builtin.assert: that: - idempotency_nm_subnet_ip_present is not changed - idempotency_nm_subnet_ip_present.current.0.fvEPSelector.attributes.matchExpression == "ip=='10.0.0.1'" @@ -118,7 +118,7 @@ register: query_result - name: Assertions check for query all IP Subnet selectors - assert: + ansible.builtin.assert: that: - query_result is not changed - query_result.current | length >= 1 @@ -131,7 +131,7 @@ register: cm_subnet_ip_absent - name: Assertions check for remove IP Subnet selector with check mode - assert: + ansible.builtin.assert: that: - cm_subnet_ip_absent is changed - cm_subnet_ip_absent.current != [] @@ -146,7 +146,7 @@ register: nm_subnet_ip_absent - name: Assertions check for remove IP Subnet selector with normal mode - assert: + ansible.builtin.assert: that: - nm_subnet_ip_absent is changed - nm_subnet_ip_absent.current == [] @@ -159,7 +159,7 @@ register: idempotency_nm_subnet_ip_absent - name: Idempotency assertions check for remove IP Subnet selector with normal mode - assert: + ansible.builtin.assert: that: - idempotency_nm_subnet_ip_absent is not changed - idempotency_nm_subnet_ip_absent.current == [] diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_esg_tag_selector/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_esg_tag_selector/tasks/main.yml index 5df3b0754..f48e5f38c 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_esg_tag_selector/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_esg_tag_selector/tasks/main.yml @@ -4,13 +4,13 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined # SET VARS - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: '{{ aci_hostname }}' username: '{{ aci_username }}' @@ -28,7 +28,7 @@ register: version - name: Verify Cloud and Non-Cloud Sites in use. - include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml - name: Ensure tenant - ansible_test does not exists before testing cisco.aci.aci_tenant: &tenant_absent @@ -79,7 +79,7 @@ register: selector_0_nm_present - name: present assertions for Tag Selector - tag-selector-0 - assert: + ansible.builtin.assert: that: - selector_0_cm_present is changed - selector_0_nm_present is changed @@ -97,7 +97,7 @@ register: query_result - name: Verification of query all Tag Selectors - query_result - assert: + ansible.builtin.assert: that: - query_result is not changed - query_result.current | length >= 1 @@ -111,7 +111,7 @@ register: result_with_name_and_value - name: Verification of query - Tag Selectors with a name and value - assert: + ansible.builtin.assert: that: - result_with_name_and_value is not changed - result_with_name_and_value.current | length == 1 @@ -127,7 +127,7 @@ register: result_with_name - name: Verification of query - Tag Selectors with only name - assert: + ansible.builtin.assert: that: - result_with_name is not changed - result_with_name.current | length == 1 @@ -151,7 +151,7 @@ register: selector_0_nm_absent_with_name_and_value - name: Verification of selector_0_nm_absent_with_name - Tag Selectors under web_esg - assert: + ansible.builtin.assert: that: - selector_0_cm_absent_with_name_and_value is changed - selector_0_cm_absent_with_name_and_value.current | length == 1 @@ -166,7 +166,7 @@ register: idempotency_selector_0_nm_absent_with_name_and_value - name: Verification of idempotency_selector_0_nm_absent_with_name_and_value - Tag Selectors under web_esg - assert: + ansible.builtin.assert: that: - idempotency_selector_0_nm_absent_with_name_and_value is not changed - idempotency_selector_0_nm_absent_with_name_and_value.current | length == 0 diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_fabric_external_connection_profile/aliases b/ansible_collections/cisco/aci/tests/integration/targets/aci_fabric_external_connection_profile/aliases new file mode 100644 index 000000000..209b793f9 --- /dev/null +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_fabric_external_connection_profile/aliases @@ -0,0 +1,2 @@ +# No ACI simulator yet, so not enabled +# unsupported diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_fabric_external_connection_profile/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_fabric_external_connection_profile/tasks/main.yml new file mode 100644 index 000000000..b51aaf08a --- /dev/null +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_fabric_external_connection_profile/tasks/main.yml @@ -0,0 +1,222 @@ +# Test code for the ACI modules +# Copyright: (c) 2024, Samita Bhattacharjee (@samitab) + +# 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 APIC host, ACI username and ACI password + ansible.builtin.fail: + msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' + when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined + +# GET Credentials from the inventory +- name: Set vars + ansible.builtin.set_fact: + aci_info: &aci_info + host: "{{ aci_hostname }}" + username: "{{ aci_username }}" + password: "{{ aci_password }}" + validate_certs: "{{ aci_validate_certs | default(false) }}" + use_ssl: "{{ aci_use_ssl | default(true) }}" + use_proxy: "{{ aci_use_proxy | default(true) }}" + output_level: "{{ aci_output_level | default('info') }}" + +- name: Query system information + cisco.aci.aci_system: + <<: *aci_info + id: 1 + state: query + register: version + +- name: Verify Cloud and Non-Cloud Sites in use. + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + +- name: Execute tasks only for non-cloud sites + when: query_cloud.current == [] + block: + + # CLEAN ENVIRONMENT + - name: Ensure ansible_fabric_ext_conn_profile is absent before testing + cisco.aci.aci_fabric_external_connection_profile: &delete_fabric_external_connection_profile + <<: *aci_info + fabric_id: 1 + state: absent + + # CREATE FABRIC EXTERNAL CONNECTION PROFILE + - name: Create ansible_fabric_ext_conn_profile with check mode + cisco.aci.aci_fabric_external_connection_profile: &create_fabric_external_connection_profile + <<: *aci_info + fabric_id: "1" + name: "ansible_fabric_ext_conn_profile" + description: "Fabric External Connection Profile" + community: "extended:as2-nn4:5:16" + site_id: "1" + peering_type: "automatic_with_rr" + peering_password: "abcd" + state: present + check_mode: true + register: add_fabric_external_connection_profile_cm + + - name: Create ansible_fabric_ext_conn_profile + cisco.aci.aci_fabric_external_connection_profile: + <<: *create_fabric_external_connection_profile + state: present + register: add_fabric_external_connection_profile + + # CREATE FABRIC EXTERNAL CONNECTION PROFILE AGAIN TO TEST IDEMPOTENCE + - name: Create ansible_fabric_ext_conn_profile again + cisco.aci.aci_fabric_external_connection_profile: + <<: *create_fabric_external_connection_profile + state: present + register: add_fabric_external_connection_profile_again + + - name: Verify creation + ansible.builtin.assert: + that: + - add_fabric_external_connection_profile is changed + - add_fabric_external_connection_profile.previous == [] + - add_fabric_external_connection_profile.current.0.fvFabricExtConnP.attributes.dn == "uni/tn-infra/fabricExtConnP-1" + - add_fabric_external_connection_profile.current.0.fvFabricExtConnP.attributes.name == "ansible_fabric_ext_conn_profile" + - add_fabric_external_connection_profile.current.0.fvFabricExtConnP.attributes.descr == "Fabric External Connection Profile" + - add_fabric_external_connection_profile.current.0.fvFabricExtConnP.attributes.annotation == 'orchestrator:ansible' + - add_fabric_external_connection_profile.current.0.fvFabricExtConnP.attributes.rt == "extended:as2-nn4:5:16" + - add_fabric_external_connection_profile.current.0.fvFabricExtConnP.attributes.siteId == "1" + - add_fabric_external_connection_profile.current.0.fvFabricExtConnP.children.0.fvPeeringP.attributes.type == "automatic_with_rr" + - add_fabric_external_connection_profile.current.0.fvFabricExtConnP.children.0.fvPeeringP.attributes.password is undefined + - add_fabric_external_connection_profile_cm is changed + - add_fabric_external_connection_profile_cm.previous == [] + - add_fabric_external_connection_profile_cm.current == [] + - add_fabric_external_connection_profile_cm.proposed.fvFabricExtConnP.attributes.dn == "uni/tn-infra/fabricExtConnP-1" + - add_fabric_external_connection_profile_cm.proposed.fvFabricExtConnP.attributes.name == "ansible_fabric_ext_conn_profile" + - add_fabric_external_connection_profile_cm.proposed.fvFabricExtConnP.attributes.descr == "Fabric External Connection Profile" + - add_fabric_external_connection_profile_cm.proposed.fvFabricExtConnP.attributes.annotation == 'orchestrator:ansible' + - add_fabric_external_connection_profile_cm.proposed.fvFabricExtConnP.attributes.rt == "extended:as2-nn4:5:16" + - add_fabric_external_connection_profile_cm.proposed.fvFabricExtConnP.attributes.siteId == "1" + - add_fabric_external_connection_profile_cm.proposed.fvFabricExtConnP.children.0.fvPeeringP.attributes.type == "automatic_with_rr" + - add_fabric_external_connection_profile_cm.proposed.fvFabricExtConnP.children.0.fvPeeringP.attributes.password == "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER" + - add_fabric_external_connection_profile_again is changed # Idempotence is not supported when peering_password is set + - add_fabric_external_connection_profile_again.current == add_fabric_external_connection_profile_again.previous + - add_fabric_external_connection_profile_again.current.0.fvFabricExtConnP.attributes.dn == "uni/tn-infra/fabricExtConnP-1" + - add_fabric_external_connection_profile_again.current.0.fvFabricExtConnP.attributes.name == "ansible_fabric_ext_conn_profile" + - add_fabric_external_connection_profile_again.current.0.fvFabricExtConnP.attributes.descr == "Fabric External Connection Profile" + - add_fabric_external_connection_profile_again.current.0.fvFabricExtConnP.attributes.annotation == 'orchestrator:ansible' + - add_fabric_external_connection_profile_again.current.0.fvFabricExtConnP.attributes.rt == "extended:as2-nn4:5:16" + - add_fabric_external_connection_profile_again.current.0.fvFabricExtConnP.attributes.siteId == "1" + - add_fabric_external_connection_profile_again.current.0.fvFabricExtConnP.children.0.fvPeeringP.attributes.type == "automatic_with_rr" + - add_fabric_external_connection_profile_again.current.0.fvFabricExtConnP.children.0.fvPeeringP.attributes.password is undefined + - add_fabric_external_connection_profile_again.previous.0.fvFabricExtConnP.attributes.dn == "uni/tn-infra/fabricExtConnP-1" + - add_fabric_external_connection_profile_again.previous.0.fvFabricExtConnP.attributes.name == "ansible_fabric_ext_conn_profile" + - add_fabric_external_connection_profile_again.previous.0.fvFabricExtConnP.attributes.descr == "Fabric External Connection Profile" + - add_fabric_external_connection_profile_again.previous.0.fvFabricExtConnP.attributes.rt == "extended:as2-nn4:5:16" + - add_fabric_external_connection_profile_again.previous.0.fvFabricExtConnP.attributes.siteId == "1" + - add_fabric_external_connection_profile_again.previous.0.fvFabricExtConnP.children.0.fvPeeringP.attributes.type == "automatic_with_rr" + - add_fabric_external_connection_profile_again.previous.0.fvFabricExtConnP.children.0.fvPeeringP.attributes.password is undefined + + # QUERY FABRIC EXTERNAL CONNECTION PROFILE + - name: Query fabric external connection profile + cisco.aci.aci_fabric_external_connection_profile: + <<: *aci_info + fabric_id: 1 + state: query + register: query_fabric_external_connection_profile + + # QUERY ALL FABRIC EXTERNAL CONNECTION PROFILE + - name: Query all fabric external connection profile + cisco.aci.aci_fabric_external_connection_profile: + <<: *aci_info + state: query + register: query_fabric_external_connection_profile_all + + - name: Verify query + ansible.builtin.assert: + that: + - query_fabric_external_connection_profile is not changed + - query_fabric_external_connection_profile.current.0.fvFabricExtConnP.attributes.dn == "uni/tn-infra/fabricExtConnP-1" + - query_fabric_external_connection_profile.current.0.fvFabricExtConnP.attributes.name == "ansible_fabric_ext_conn_profile" + - query_fabric_external_connection_profile.current.0.fvFabricExtConnP.attributes.descr == "Fabric External Connection Profile" + - query_fabric_external_connection_profile.current.0.fvFabricExtConnP.attributes.rt == "extended:as2-nn4:5:16" + - query_fabric_external_connection_profile.current.0.fvFabricExtConnP.attributes.siteId == "1" + - query_fabric_external_connection_profile.current.0.fvFabricExtConnP.children.0.fvPeeringP.attributes.type == "automatic_with_rr" + - query_fabric_external_connection_profile.current.0.fvFabricExtConnP.children.0.fvPeeringP.attributes.password is undefined + - query_fabric_external_connection_profile_all is not changed + - query_fabric_external_connection_profile_all.current | length == 1 + - query_fabric_external_connection_profile_all.current.0.fvFabricExtConnP.attributes.dn == "uni/tn-infra/fabricExtConnP-1" + - query_fabric_external_connection_profile_all.current.0.fvFabricExtConnP.attributes.name == "ansible_fabric_ext_conn_profile" + - query_fabric_external_connection_profile_all.current.0.fvFabricExtConnP.attributes.descr == "Fabric External Connection Profile" + - query_fabric_external_connection_profile_all.current.0.fvFabricExtConnP.attributes.rt == "extended:as2-nn4:5:16" + - query_fabric_external_connection_profile_all.current.0.fvFabricExtConnP.attributes.siteId == "1" + - query_fabric_external_connection_profile_all.current.0.fvFabricExtConnP.children.0.fvPeeringP.attributes.type == "automatic_with_rr" + - query_fabric_external_connection_profile_all.current.0.fvFabricExtConnP.children.0.fvPeeringP.attributes.password is undefined + + # UPDATE PEERING PROFILE + - name: Update ansible_fabric_ext_conn_profile peering password + cisco.aci.aci_fabric_external_connection_profile: + <<: *aci_info + fabric_id: "1" + peering_password: "abcd" + state: present + register: update_fabric_external_connection_profile_1 + + - name: Update ansible_fabric_ext_conn_profile peering type + cisco.aci.aci_fabric_external_connection_profile: + <<: *aci_info + fabric_id: "1" + peering_type: "automatic_with_full_mesh" + state: present + register: update_fabric_external_connection_profile_2 + + - name: Verity updates + ansible.builtin.assert: + that: + - update_fabric_external_connection_profile_1 is changed + - update_fabric_external_connection_profile_1.proposed.fvFabricExtConnP.children.0.fvPeeringP.attributes.password == "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER" + - update_fabric_external_connection_profile_1.proposed.fvFabricExtConnP.children.0.fvPeeringP.attributes.type is undefined + - update_fabric_external_connection_profile_1.current.0.fvFabricExtConnP.children.0.fvPeeringP.attributes.type == "automatic_with_rr" + - update_fabric_external_connection_profile_2 is changed + - update_fabric_external_connection_profile_2.proposed.fvFabricExtConnP.children.0.fvPeeringP.attributes.password is undefined + - update_fabric_external_connection_profile_2.proposed.fvFabricExtConnP.children.0.fvPeeringP.attributes.type == "automatic_with_full_mesh" + - update_fabric_external_connection_profile_2.current.0.fvFabricExtConnP.children.0.fvPeeringP.attributes.type == "automatic_with_full_mesh" + - update_fabric_external_connection_profile_2.previous.0.fvFabricExtConnP.children.0.fvPeeringP.attributes.type == "automatic_with_rr" + + # DELETE FABRIC EXTERNAL CONNECTION PROFILE + - name: Delete ansible_fabric_ext_conn_profile with check mode + cisco.aci.aci_fabric_external_connection_profile: + <<: *delete_fabric_external_connection_profile + check_mode: true + register: delete_fabric_external_connection_profile_cm + + - name: Delete ansible_fabric_ext_conn_profile + cisco.aci.aci_fabric_external_connection_profile: + <<: *delete_fabric_external_connection_profile + register: delete_fabric_external_connection_profile + + # DELETE FABRIC EXTERNAL CONNECTION PROFILE AGAIN TO TEST IDEMPOTENCE + - name: Delete ansible_fabric_ext_conn_profile again + cisco.aci.aci_fabric_external_connection_profile: + <<: *delete_fabric_external_connection_profile + register: delete_fabric_external_connection_profile_again + + - name: Verify deletion + ansible.builtin.assert: + that: + - delete_fabric_external_connection_profile is changed + - delete_fabric_external_connection_profile.current == [] + - delete_fabric_external_connection_profile.previous.0.fvFabricExtConnP.attributes.dn == "uni/tn-infra/fabricExtConnP-1" + - delete_fabric_external_connection_profile.previous.0.fvFabricExtConnP.attributes.name == "ansible_fabric_ext_conn_profile" + - delete_fabric_external_connection_profile.previous.0.fvFabricExtConnP.attributes.descr == "Fabric External Connection Profile" + - delete_fabric_external_connection_profile.previous.0.fvFabricExtConnP.attributes.rt == "extended:as2-nn4:5:16" + - delete_fabric_external_connection_profile.previous.0.fvFabricExtConnP.attributes.siteId == "1" + - delete_fabric_external_connection_profile.previous.0.fvFabricExtConnP.children.0.fvPeeringP.attributes.type == "automatic_with_full_mesh" + - delete_fabric_external_connection_profile.previous.0.fvFabricExtConnP.children.0.fvPeeringP.attributes.password is undefined + - delete_fabric_external_connection_profile_cm is changed + - delete_fabric_external_connection_profile_cm.proposed == {} + - delete_fabric_external_connection_profile_cm.current != [] + - delete_fabric_external_connection_profile_cm.previous.0.fvFabricExtConnP.attributes.dn == "uni/tn-infra/fabricExtConnP-1" + - delete_fabric_external_connection_profile_cm.previous.0.fvFabricExtConnP.attributes.name == "ansible_fabric_ext_conn_profile" + - delete_fabric_external_connection_profile_cm.previous.0.fvFabricExtConnP.attributes.descr == "Fabric External Connection Profile" + - delete_fabric_external_connection_profile_cm.previous.0.fvFabricExtConnP.attributes.rt == "extended:as2-nn4:5:16" + - delete_fabric_external_connection_profile_cm.previous.0.fvFabricExtConnP.attributes.siteId == "1" + - delete_fabric_external_connection_profile_cm.previous.0.fvFabricExtConnP.children.0.fvPeeringP.attributes.type == "automatic_with_full_mesh" + - delete_fabric_external_connection_profile_cm.previous.0.fvFabricExtConnP.children.0.fvPeeringP.attributes.password is undefined + - delete_fabric_external_connection_profile_again is not changed + - delete_fabric_external_connection_profile_again.current == [] + - delete_fabric_external_connection_profile_again.previous == [] diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_fabric_external_routing_profile/aliases b/ansible_collections/cisco/aci/tests/integration/targets/aci_fabric_external_routing_profile/aliases new file mode 100644 index 000000000..209b793f9 --- /dev/null +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_fabric_external_routing_profile/aliases @@ -0,0 +1,2 @@ +# No ACI simulator yet, so not enabled +# unsupported diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_fabric_external_routing_profile/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_fabric_external_routing_profile/tasks/main.yml new file mode 100644 index 000000000..8aa053186 --- /dev/null +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_fabric_external_routing_profile/tasks/main.yml @@ -0,0 +1,278 @@ +# Test code for the ACI modules +# Copyright: (c) 2024, Samita Bhattacharjee (@samitab) + +# 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 APIC host, ACI username and ACI password + ansible.builtin.fail: + msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' + when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined + +# GET Credentials from the inventory +- name: Set vars + ansible.builtin.set_fact: + aci_info: &aci_info + host: "{{ aci_hostname }}" + username: "{{ aci_username }}" + password: "{{ aci_password }}" + validate_certs: "{{ aci_validate_certs | default(false) }}" + use_ssl: "{{ aci_use_ssl | default(true) }}" + use_proxy: "{{ aci_use_proxy | default(true) }}" + output_level: "{{ aci_output_level | default('info') }}" + +- name: Query system information + cisco.aci.aci_system: + <<: *aci_info + id: 1 + state: query + register: version + +- name: Verify Cloud and Non-Cloud Sites in use. + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + +- name: Execute tasks only for non-cloud sites + when: query_cloud.current == [] + block: + + # CLEAN ENVIRONMENT + - name: Ensure fabric external connection profile is absent before testing + cisco.aci.aci_fabric_external_connection_profile: &delete_fabric_external_connection_profile + <<: *aci_info + fabric_id: "1" + name: "ansible_fabric_ext_conn_profile" + community: "extended:as2-nn4:5:16" + state: absent + register: cleaned + + - name: Sleep for 15 seconds and continue + ansible.builtin.wait_for: + timeout: 15 + delegate_to: localhost + when: cleaned is changed + + - name: Ensure ansible_fabric_ext_routing_profile is absent before testing + cisco.aci.aci_fabric_external_routing_profile: &delete_fabric_external_routing_profile + <<: *aci_info + fabric_id: 1 + name: ansible_fabric_ext_routing_profile + state: absent + + - name: Create fabric external connection profile + cisco.aci.aci_fabric_external_connection_profile: + <<: *delete_fabric_external_connection_profile + state: present + + # CREATE FABRIC EXTERNAL ROUTING PROFILE + - name: Create ansible_fabric_ext_routing_profile with check mode + cisco.aci.aci_fabric_external_routing_profile: &create_fabric_external_routing_profile + <<: *aci_info + fabric_id: "1" + description: "Fabric external routing profile" + name: "ansible_fabric_ext_routing_profile" + subnets: + # Intentional duplicate subnet test + - 1.2.3.4/24 + - 1.2.3.4/24 + - 5.6.7.8/24 + state: present + check_mode: true + register: add_fabric_external_routing_profile_cm + + - name: Create ansible_fabric_ext_routing_profile + cisco.aci.aci_fabric_external_routing_profile: + <<: *create_fabric_external_routing_profile + state: present + register: add_fabric_external_routing_profile + + - name: Sleep for 15 seconds and continue + ansible.builtin.wait_for: + timeout: 15 + delegate_to: localhost + when: add_fabric_external_routing_profile is changed + + # CREATE FABRIC EXTERNAL ROUTING PROFILE AGAIN TO TEST IDEMPOTENCE + - name: Create ansible_fabric_ext_routing_profile again + cisco.aci.aci_fabric_external_routing_profile: + <<: *create_fabric_external_routing_profile + state: present + register: add_fabric_external_routing_profile_again + + - name: Verify creation + ansible.builtin.assert: + that: + - add_fabric_external_routing_profile is changed + - add_fabric_external_routing_profile.previous == [] + - add_fabric_external_routing_profile.current.0.l3extFabricExtRoutingP.attributes.dn == "uni/tn-infra/fabricExtConnP-1/fabricExtRoutingP-ansible_fabric_ext_routing_profile" + - add_fabric_external_routing_profile.current.0.l3extFabricExtRoutingP.attributes.descr == "Fabric external routing profile" + - add_fabric_external_routing_profile.current.0.l3extFabricExtRoutingP.attributes.annotation == 'orchestrator:ansible' + - add_fabric_external_routing_profile.current.0.l3extFabricExtRoutingP.attributes.name == "ansible_fabric_ext_routing_profile" + - add_fabric_external_routing_profile.current.0.l3extFabricExtRoutingP.children.1.l3extSubnet.attributes.ip == "1.2.3.4/24" + - add_fabric_external_routing_profile.current.0.l3extFabricExtRoutingP.children.0.l3extSubnet.attributes.ip == "5.6.7.8/24" + - add_fabric_external_routing_profile_cm is changed + - add_fabric_external_routing_profile_cm.previous == [] + - add_fabric_external_routing_profile_cm.current == [] + - add_fabric_external_routing_profile_cm.proposed.l3extFabricExtRoutingP.attributes.dn == "uni/tn-infra/fabricExtConnP-1/fabricExtRoutingP-ansible_fabric_ext_routing_profile" + - add_fabric_external_routing_profile_cm.proposed.l3extFabricExtRoutingP.attributes.descr == "Fabric external routing profile" + - add_fabric_external_routing_profile_cm.proposed.l3extFabricExtRoutingP.attributes.annotation == 'orchestrator:ansible' + - add_fabric_external_routing_profile_cm.proposed.l3extFabricExtRoutingP.attributes.name == "ansible_fabric_ext_routing_profile" + - add_fabric_external_routing_profile_cm.proposed.l3extFabricExtRoutingP.children.0.l3extSubnet.attributes.ip == "1.2.3.4/24" + - add_fabric_external_routing_profile_cm.proposed.l3extFabricExtRoutingP.children.1.l3extSubnet.attributes.ip == "5.6.7.8/24" + - add_fabric_external_routing_profile_again is not changed + - add_fabric_external_routing_profile_again.current == add_fabric_external_routing_profile_again.previous + - add_fabric_external_routing_profile_again.current.0.l3extFabricExtRoutingP.attributes.dn == "uni/tn-infra/fabricExtConnP-1/fabricExtRoutingP-ansible_fabric_ext_routing_profile" + - add_fabric_external_routing_profile_again.current.0.l3extFabricExtRoutingP.attributes.descr == "Fabric external routing profile" + - add_fabric_external_routing_profile_again.current.0.l3extFabricExtRoutingP.attributes.annotation == 'orchestrator:ansible' + - add_fabric_external_routing_profile_again.current.0.l3extFabricExtRoutingP.attributes.name == "ansible_fabric_ext_routing_profile" + - add_fabric_external_routing_profile_again.current.0.l3extFabricExtRoutingP.children.1.l3extSubnet.attributes.ip == "1.2.3.4/24" + - add_fabric_external_routing_profile_again.current.0.l3extFabricExtRoutingP.children.0.l3extSubnet.attributes.ip == "5.6.7.8/24" + - add_fabric_external_routing_profile_again.previous.0.l3extFabricExtRoutingP.attributes.dn == "uni/tn-infra/fabricExtConnP-1/fabricExtRoutingP-ansible_fabric_ext_routing_profile" + - add_fabric_external_routing_profile_again.previous.0.l3extFabricExtRoutingP.attributes.descr == "Fabric external routing profile" + - add_fabric_external_routing_profile_again.previous.0.l3extFabricExtRoutingP.attributes.name == "ansible_fabric_ext_routing_profile" + - add_fabric_external_routing_profile_again.previous.0.l3extFabricExtRoutingP.children.1.l3extSubnet.attributes.ip == "1.2.3.4/24" + - add_fabric_external_routing_profile_again.previous.0.l3extFabricExtRoutingP.children.0.l3extSubnet.attributes.ip == "5.6.7.8/24" + + # QUERY FABRIC EXTERNAL ROUTING PROFILE + - name: Query fabric external routing profile + cisco.aci.aci_fabric_external_routing_profile: + <<: *aci_info + fabric_id: 1 + name: ansible_fabric_ext_routing_profile + state: query + register: query_fabric_external_routing_profile + + # QUERY ALL FABRIC EXTERNAL ROUTING PROFILE + - name: Query all fabric external routing profile + cisco.aci.aci_fabric_external_routing_profile: + <<: *aci_info + state: query + register: query_fabric_external_routing_profile_all + + - name: Verify query + ansible.builtin.assert: + that: + - query_fabric_external_routing_profile is not changed + - query_fabric_external_routing_profile.current.0.l3extFabricExtRoutingP.attributes.dn == "uni/tn-infra/fabricExtConnP-1/fabricExtRoutingP-ansible_fabric_ext_routing_profile" + - query_fabric_external_routing_profile.current.0.l3extFabricExtRoutingP.attributes.descr == "Fabric external routing profile" + - query_fabric_external_routing_profile.current.0.l3extFabricExtRoutingP.attributes.name == "ansible_fabric_ext_routing_profile" + - query_fabric_external_routing_profile.current.0.l3extFabricExtRoutingP.children.1.l3extSubnet.attributes.ip == "1.2.3.4/24" + - query_fabric_external_routing_profile.current.0.l3extFabricExtRoutingP.children.0.l3extSubnet.attributes.ip == "5.6.7.8/24" + - query_fabric_external_routing_profile_all is not changed + - query_fabric_external_routing_profile_all.current | length == 1 + - query_fabric_external_routing_profile_all.current.0.l3extFabricExtRoutingP.attributes.dn == "uni/tn-infra/fabricExtConnP-1/fabricExtRoutingP-ansible_fabric_ext_routing_profile" + - query_fabric_external_routing_profile_all.current.0.l3extFabricExtRoutingP.attributes.descr == "Fabric external routing profile" + - query_fabric_external_routing_profile_all.current.0.l3extFabricExtRoutingP.attributes.name == "ansible_fabric_ext_routing_profile" + - query_fabric_external_routing_profile_all.current.0.l3extFabricExtRoutingP.children.1.l3extSubnet.attributes.ip == "1.2.3.4/24" + - query_fabric_external_routing_profile_all.current.0.l3extFabricExtRoutingP.children.0.l3extSubnet.attributes.ip == "5.6.7.8/24" + + # UPDATE SUBNETS + - name: Update fabric external routing profile - change subnets + cisco.aci.aci_fabric_external_routing_profile: + <<: *create_fabric_external_routing_profile + subnets: + - 5.6.7.8/24 + - 9.10.11.12/24 + state: present + register: update_fabric_external_routing_profile_1 + + - name: Sleep for 15 seconds and continue + ansible.builtin.wait_for: + timeout: 15 + delegate_to: localhost + + - name: Update fabric external routing profile - remove 1 subnet + cisco.aci.aci_fabric_external_routing_profile: + <<: *create_fabric_external_routing_profile + subnets: + - 9.10.11.12/24 + state: present + register: update_fabric_external_routing_profile_2 + + - name: Sleep for 15 seconds and continue + ansible.builtin.wait_for: + timeout: 15 + delegate_to: localhost + + - name: Update fabric external routing profile - remove all subnets + cisco.aci.aci_fabric_external_routing_profile: + <<: *create_fabric_external_routing_profile + subnets: null + state: present + register: update_fabric_external_routing_profile_3 + + - name: Sleep for 15 seconds and continue + ansible.builtin.wait_for: + timeout: 15 + delegate_to: localhost + + - name: Verify subnet update + ansible.builtin.assert: + that: + - update_fabric_external_routing_profile_1 is changed + - update_fabric_external_routing_profile_1.proposed.l3extFabricExtRoutingP.children | length == 3 + - update_fabric_external_routing_profile_1.proposed.l3extFabricExtRoutingP.children.0.l3extSubnet.attributes.ip == "1.2.3.4/24" + - update_fabric_external_routing_profile_1.proposed.l3extFabricExtRoutingP.children.0.l3extSubnet.attributes.status == "deleted" + - update_fabric_external_routing_profile_1.proposed.l3extFabricExtRoutingP.children.1.l3extSubnet.attributes.ip == "5.6.7.8/24" + - update_fabric_external_routing_profile_1.proposed.l3extFabricExtRoutingP.children.2.l3extSubnet.attributes.ip == "9.10.11.12/24" + - update_fabric_external_routing_profile_1.current.0.l3extFabricExtRoutingP.children | length == 2 + - update_fabric_external_routing_profile_1.current.0.l3extFabricExtRoutingP.children.1.l3extSubnet.attributes.ip == "5.6.7.8/24" + - update_fabric_external_routing_profile_1.current.0.l3extFabricExtRoutingP.children.0.l3extSubnet.attributes.ip == "9.10.11.12/24" + - update_fabric_external_routing_profile_2 is changed + - update_fabric_external_routing_profile_2.proposed.l3extFabricExtRoutingP.children | length == 2 + - update_fabric_external_routing_profile_2.proposed.l3extFabricExtRoutingP.children.0.l3extSubnet.attributes.ip == "5.6.7.8/24" + - update_fabric_external_routing_profile_2.proposed.l3extFabricExtRoutingP.children.0.l3extSubnet.attributes.status == "deleted" + - update_fabric_external_routing_profile_2.proposed.l3extFabricExtRoutingP.children.1.l3extSubnet.attributes.ip == "9.10.11.12/24" + - update_fabric_external_routing_profile_2.current.0.l3extFabricExtRoutingP.children | length == 1 + - update_fabric_external_routing_profile_2.current.0.l3extFabricExtRoutingP.children.0.l3extSubnet.attributes.ip == "9.10.11.12/24" + - update_fabric_external_routing_profile_3 is changed + - update_fabric_external_routing_profile_3.proposed.l3extFabricExtRoutingP.children | length == 1 + - update_fabric_external_routing_profile_3.proposed.l3extFabricExtRoutingP.children.0.l3extSubnet.attributes.ip == "9.10.11.12/24" + - update_fabric_external_routing_profile_3.proposed.l3extFabricExtRoutingP.children.0.l3extSubnet.attributes.status == "deleted" + - update_fabric_external_routing_profile_3.current.0.l3extFabricExtRoutingP.children is undefined + + # DELETE FABRIC EXTERNAL ROUTING PROFILE + - name: Delete ansible_fabric_ext_routing_profile with check mode + cisco.aci.aci_fabric_external_routing_profile: + <<: *delete_fabric_external_routing_profile + check_mode: true + register: delete_fabric_external_routing_profile_cm + + - name: Delete ansible_fabric_ext_routing_profile + cisco.aci.aci_fabric_external_routing_profile: + <<: *delete_fabric_external_routing_profile + register: delete_fabric_external_routing_profile + + - name: Sleep for 15 seconds and continue + ansible.builtin.wait_for: + timeout: 15 + delegate_to: localhost + when: delete_fabric_external_routing_profile is changed + + # DELETE FABRIC EXTERNAL ROUTING PROFILE AGAIN TO TEST IDEMPOTENCE + - name: Delete ansible_fabric_ext_routing_profile again + cisco.aci.aci_fabric_external_routing_profile: + <<: *delete_fabric_external_routing_profile + retries: 4 + delay: 5 + register: delete_fabric_external_routing_profile_again + + - name: Verify deletion + ansible.builtin.assert: + that: + - delete_fabric_external_routing_profile is changed + - delete_fabric_external_routing_profile.current == [] + - delete_fabric_external_routing_profile.previous.0.l3extFabricExtRoutingP.attributes.dn == "uni/tn-infra/fabricExtConnP-1/fabricExtRoutingP-ansible_fabric_ext_routing_profile" + - delete_fabric_external_routing_profile.previous.0.l3extFabricExtRoutingP.attributes.descr == "Fabric external routing profile" + - delete_fabric_external_routing_profile.previous.0.l3extFabricExtRoutingP.attributes.name == "ansible_fabric_ext_routing_profile" + - delete_fabric_external_routing_profile_cm is changed + - delete_fabric_external_routing_profile_cm.proposed == {} + - delete_fabric_external_routing_profile_cm.current != [] + - delete_fabric_external_routing_profile_cm.previous.0.l3extFabricExtRoutingP.attributes.dn == "uni/tn-infra/fabricExtConnP-1/fabricExtRoutingP-ansible_fabric_ext_routing_profile" + - delete_fabric_external_routing_profile_cm.previous.0.l3extFabricExtRoutingP.attributes.descr == "Fabric external routing profile" + - delete_fabric_external_routing_profile_cm.previous.0.l3extFabricExtRoutingP.attributes.name == "ansible_fabric_ext_routing_profile" + - delete_fabric_external_routing_profile_again is not changed + - delete_fabric_external_routing_profile_again.current == [] + - delete_fabric_external_routing_profile_again.previous == [] + + - name: Clean up fabric external connection profile + cisco.aci.aci_fabric_external_connection_profile: + <<: *delete_fabric_external_connection_profile
\ No newline at end of file diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_fabric_interface_policy_group/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_fabric_interface_policy_group/tasks/main.yml index 9f871da6b..a591d6435 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_fabric_interface_policy_group/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_fabric_interface_policy_group/tasks/main.yml @@ -4,13 +4,13 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: "Please define the following variables: aci_hostname, aci_username and aci_password." when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined # SET VARS - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: "{{ aci_hostname }}" username: "{{ aci_username }}" @@ -28,21 +28,21 @@ register: version - name: Ensure leaf_policy_group does not exist - aci_fabric_interface_policy_group: + cisco.aci.aci_fabric_interface_policy_group: <<: *aci_info name: leaf_policy_group type: leaf state: absent - name: Ensure spine_policy_group does not exist - aci_fabric_interface_policy_group: + cisco.aci.aci_fabric_interface_policy_group: <<: *aci_info name: spine_policy_group type: spine state: absent - name: Add a leaf fabric interface policy group with check mode - aci_fabric_interface_policy_group: &cm_leaf_policy_group_present + cisco.aci.aci_fabric_interface_policy_group: &cm_leaf_policy_group_present <<: *aci_info name: leaf_policy_group type: leaf @@ -52,7 +52,7 @@ register: cm_leaf_policy_group_present - name: Add a leaf fabric interface policy group with normal mode - aci_fabric_interface_policy_group: &nm_leaf_policy_group_present + cisco.aci.aci_fabric_interface_policy_group: &nm_leaf_policy_group_present <<: *cm_leaf_policy_group_present dwdm_policy: default link_level_policy: default @@ -63,12 +63,12 @@ register: nm_leaf_policy_group_present - name: Add a leaf fabric interface policy group with normal mode again - aci_fabric_interface_policy_group: + cisco.aci.aci_fabric_interface_policy_group: <<: *nm_leaf_policy_group_present register: nm_leaf_policy_group_present_again - name: Add a spine fabric interface policy group with check mode - aci_fabric_interface_policy_group: &cm_spine_policy_group_present + cisco.aci.aci_fabric_interface_policy_group: &cm_spine_policy_group_present <<: *aci_info name: spine_policy_group type: spine @@ -87,7 +87,7 @@ when: version.current.0.topSystem.attributes.version is version('6.0(2h)', '>=') block: - name: Add a spine fabric interface policy group with transceiver_policy_tdn - aci_fabric_interface_policy_group: &tp_spine_policy_group_present + cisco.aci.aci_fabric_interface_policy_group: &tp_spine_policy_group_present <<: *aci_info name: spine_policy_group type: spine @@ -97,7 +97,7 @@ register: tp_spine_policy_group_present - name: Remove the transceiver_policy from the spine fabric interface policy group - aci_fabric_interface_policy_group: + cisco.aci.aci_fabric_interface_policy_group: <<: *aci_info name: spine_policy_group type: spine @@ -107,7 +107,7 @@ register: tp_spine_policy_group_absent - name: Assertions check for add fabric interface policy groups - assert: + ansible.builtin.assert: that: - tp_spine_policy_group_present is changed - tp_spine_policy_group_absent is changed @@ -115,17 +115,17 @@ - tp_spine_policy_group_absent.current.0.fabricSpPortPGrp.children | selectattr('fabricRsOpticsFabIfPol.attributes.tDn', 'defined') | selectattr('fabricRsOpticsFabIfPol.attributes.tDn', 'equalto', "") - name: Add a spine fabric interface policy group with normal mode - aci_fabric_interface_policy_group: + cisco.aci.aci_fabric_interface_policy_group: <<: *cm_spine_policy_group_present register: nm_spine_policy_group_present - name: Add a spine fabric interface policy group with normal mode again - aci_fabric_interface_policy_group: + cisco.aci.aci_fabric_interface_policy_group: <<: *cm_spine_policy_group_present register: nm_spine_policy_group_present_again - name: Update a spine fabric interface policy group with check mode - aci_fabric_interface_policy_group: &cm_spine_policy_group_update + cisco.aci.aci_fabric_interface_policy_group: &cm_spine_policy_group_update <<: *cm_spine_policy_group_present descr: spine_policy_group updated dwdm_policy: "" @@ -138,17 +138,17 @@ register: cm_spine_policy_group_update - name: Update a spine fabric interface policy group with normal mode - aci_fabric_interface_policy_group: + cisco.aci.aci_fabric_interface_policy_group: <<: *cm_spine_policy_group_update register: nm_spine_policy_group_update - name: Update a spine fabric interface policy group with normal mode again - aci_fabric_interface_policy_group: + cisco.aci.aci_fabric_interface_policy_group: <<: *cm_spine_policy_group_update register: nm_spine_policy_group_update_again - name: Assertions check for add fabric interface policy groups - assert: + ansible.builtin.assert: that: - cm_leaf_policy_group_present is changed - cm_leaf_policy_group_present.current == [] @@ -214,7 +214,7 @@ - nm_spine_policy_group_update_again.current.0.fabricSpPortPGrp.attributes.descr == "spine_policy_group updated" - name: Invalid test - add a fabric interface policy group without type - aci_fabric_interface_policy_group: + cisco.aci.aci_fabric_interface_policy_group: <<: *aci_info name: nt_spine_policy_group descr: negative test nt_spine_policy_group @@ -223,7 +223,7 @@ ignore_errors: true - name: Invalid test - add a fabric interface policy group without name - aci_fabric_interface_policy_group: + cisco.aci.aci_fabric_interface_policy_group: <<: *aci_info type: spine descr: negative test spine_policy_group @@ -232,7 +232,7 @@ ignore_errors: true - name: Assertions check for invalid test - add fabric interface policy groups - assert: + ansible.builtin.assert: that: - nt_without_type is not changed - nt_without_type.msg == "missing required arguments{{':'}} type" @@ -240,7 +240,7 @@ - nt_without_name.msg == "state is present but all of the following are missing{{':'}} name" - name: Query a leaf fabric interface policy group with name - aci_fabric_interface_policy_group: + cisco.aci.aci_fabric_interface_policy_group: <<: *aci_info name: leaf_policy_group type: leaf @@ -248,14 +248,14 @@ register: query_leaf_policy_group - name: Query all leaf fabric interface policy groups - aci_fabric_interface_policy_group: + cisco.aci.aci_fabric_interface_policy_group: <<: *aci_info type: leaf state: query register: query_all_leaf_policy_group - name: Query a spine fabric interface policy group with name - aci_fabric_interface_policy_group: + cisco.aci.aci_fabric_interface_policy_group: <<: *aci_info name: spine_policy_group type: spine @@ -263,14 +263,14 @@ register: query_a_spine_policy_group - name: Query all spine fabric interface policy groups - aci_fabric_interface_policy_group: + cisco.aci.aci_fabric_interface_policy_group: <<: *aci_info type: spine state: query register: query_all_spine_policy_group - name: Assertions check for query a fabric interface policy groups - assert: + ansible.builtin.assert: that: - query_leaf_policy_group is not changed - query_leaf_policy_group.current != [] @@ -290,41 +290,41 @@ - query_all_spine_policy_group.current | length >= 1 - name: Remove a leaf fabric interface policy group with check mode - aci_fabric_interface_policy_group: &cm_leaf_policy_group_absent + cisco.aci.aci_fabric_interface_policy_group: &cm_leaf_policy_group_absent <<: *cm_leaf_policy_group_present state: absent check_mode: true register: cm_leaf_policy_group_absent - name: Remove a leaf fabric interface policy group with normal mode - aci_fabric_interface_policy_group: + cisco.aci.aci_fabric_interface_policy_group: <<: *cm_leaf_policy_group_absent register: nm_leaf_policy_group_absent - name: Remove a leaf fabric interface policy group with normal mode again - aci_fabric_interface_policy_group: + cisco.aci.aci_fabric_interface_policy_group: <<: *cm_leaf_policy_group_absent register: nm_leaf_policy_group_absent_again - name: Remove a spine fabric interface policy group with check mode - aci_fabric_interface_policy_group: &cm_spine_policy_group_absent + cisco.aci.aci_fabric_interface_policy_group: &cm_spine_policy_group_absent <<: *cm_spine_policy_group_present state: absent check_mode: true register: cm_spine_policy_group_absent - name: Remove a spine fabric interface policy group with normal mode - aci_fabric_interface_policy_group: + cisco.aci.aci_fabric_interface_policy_group: <<: *cm_spine_policy_group_absent register: nm_spine_policy_group_absent - name: Remove a spine fabric interface policy group with normal mode again - aci_fabric_interface_policy_group: + cisco.aci.aci_fabric_interface_policy_group: <<: *cm_spine_policy_group_absent register: nm_spine_policy_group_absent_again - name: Assertions check for remove a fabric interface policy groups - assert: + ansible.builtin.assert: that: - cm_leaf_policy_group_absent is changed - cm_leaf_policy_group_absent.current != [] diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_fabric_leaf_profile/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_fabric_leaf_profile/tasks/main.yml index d4bf60dd5..6fb60c923 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_fabric_leaf_profile/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_fabric_leaf_profile/tasks/main.yml @@ -4,13 +4,13 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined # GET Credentials from the inventory - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: "{{ aci_hostname }}" username: "{{ aci_username }}" @@ -22,21 +22,21 @@ # CLEAN ENVIRONMENT - name: Remove ansible_leaf_switch_prf if it already exists - aci_fabric_leaf_profile: + cisco.aci.aci_fabric_leaf_profile: <<: *aci_info name: ansible_leaf_switch_prf state: absent # CREATE SPINE SWITCH POLICY - name: Create ansible_leaf_switch_prf - aci_fabric_leaf_profile: + cisco.aci.aci_fabric_leaf_profile: <<: *aci_info name: ansible_leaf_switch_prf state: present register: add_switch_prf - name: Verify profile creation - assert: + ansible.builtin.assert: that: - add_switch_prf.current.0.fabricLeafP.attributes.dn == "uni/fabric/leprof-ansible_leaf_switch_prf" - add_switch_prf.current.0.fabricLeafP.attributes.name == "ansible_leaf_switch_prf" @@ -44,14 +44,14 @@ # CREATE SPINE SWITCH POLICY AGAIN TO TEST IDEMPOTENCE - name: Create ansible_leaf_switch_prf again - aci_fabric_leaf_profile: + cisco.aci.aci_fabric_leaf_profile: <<: *aci_info name: ansible_leaf_switch_prf state: present register: add_switch_prf_again - name: Verify profile creation idempotence - assert: + ansible.builtin.assert: that: - add_switch_prf_again is not changed - add_switch_prf_again.current.0.fabricLeafP.attributes.dn == "uni/fabric/leprof-ansible_leaf_switch_prf" @@ -59,14 +59,14 @@ # QUERY SPINE SWITCH POLICY - name: query leaf switch profile - aci_fabric_leaf_profile: + cisco.aci.aci_fabric_leaf_profile: <<: *aci_info name: ansible_leaf_switch_prf state: query register: query_switch_prf - name: Verify profile query - assert: + ansible.builtin.assert: that: - query_switch_prf is not changed - query_switch_prf.current.0.fabricLeafP.attributes.dn == "uni/fabric/leprof-ansible_leaf_switch_prf" @@ -74,26 +74,26 @@ # QUERY ALL SPINE SWITCH POLICIES - name: query all leaf switch profiles - aci_fabric_leaf_profile: + cisco.aci.aci_fabric_leaf_profile: <<: *aci_info state: query register: query_switch_prf_all - name: Verify profile query idempotence - assert: + ansible.builtin.assert: that: - query_switch_prf_all is not changed # DELETE SPINE SWITCH PROFILE - name: Delete ansible_leaf_switch_prf - aci_fabric_leaf_profile: + cisco.aci.aci_fabric_leaf_profile: <<: *aci_info name: ansible_leaf_switch_prf state: absent register: delete_switch_prf - name: Verify profile deletion - assert: + ansible.builtin.assert: that: - delete_switch_prf is changed - delete_switch_prf.current == [] @@ -102,21 +102,21 @@ # DELETE SPINE SWITCH PROFILE AGAIN TO TEST IDEMPOTENCE - name: Delete ansible_leaf_switch_prf again - aci_fabric_leaf_profile: + cisco.aci.aci_fabric_leaf_profile: <<: *aci_info name: ansible_leaf_switch_prf state: absent register: delete_switch_prf_again - name: Verify profile deletion idempotence - assert: + ansible.builtin.assert: that: - delete_switch_prf_again is not changed - delete_switch_prf_again.current == [] # CLEAN UP ENVIRONMENT - name: Remove ansible_leaf_switch_prf - aci_fabric_leaf_profile: + cisco.aci.aci_fabric_leaf_profile: <<: *aci_info name: ansible_leaf_switch_prf state: absent diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_fabric_leaf_switch_assoc/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_fabric_leaf_switch_assoc/tasks/main.yml index 35caafdb3..68050b8d0 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_fabric_leaf_switch_assoc/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_fabric_leaf_switch_assoc/tasks/main.yml @@ -4,13 +4,13 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined # GET Credentials from the inventory - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: "{{ aci_hostname }}" username: "{{ aci_username }}" @@ -22,21 +22,21 @@ # CLEAN ENVIRONMENT - name: Remove ansible_leaf_switch_prf if it already exists - aci_fabric_leaf_profile: + cisco.aci.aci_fabric_leaf_profile: <<: *aci_info name: ansible_leaf_switch_prf state: absent # CREATE SPINE SWITCH POLICY - name: Create ansible_leaf_switch_prf - aci_fabric_leaf_profile: + cisco.aci.aci_fabric_leaf_profile: <<: *aci_info name: ansible_leaf_switch_prf state: present # CREATE SPINE SWITCH ASSOCIATION - name: Create a leaf switch profile association - aci_fabric_leaf_switch_assoc: + cisco.aci.aci_fabric_leaf_switch_assoc: <<: *aci_info profile: ansible_leaf_switch_prf name: ansible_leaf_switch_assoc @@ -45,7 +45,7 @@ register: add_association - name: Verify association creation - assert: + ansible.builtin.assert: that: - add_association.current.0.fabricLeafS.attributes.dn == "uni/fabric/leprof-ansible_leaf_switch_prf/leaves-ansible_leaf_switch_assoc-typ-range" - add_association.current.0.fabricLeafS.attributes.name == "ansible_leaf_switch_assoc" @@ -53,13 +53,13 @@ - add_association.current.0.fabricLeafS.attributes.annotation == 'orchestrator:ansible' - name: Verify Policy Group association - assert: + ansible.builtin.assert: that: - add_association.current.0.fabricLeafS.children.0.fabricRsLeNodePGrp.attributes.tDn == "uni/fabric/funcprof/lenodepgrp-ansible_leaf_pol_grp1" # CREATE SPINE SWITCH ASSOCIATION AGAIN TO TEST IDEMPOTENCE - name: Create a leaf switch profile association again - aci_fabric_leaf_switch_assoc: + cisco.aci.aci_fabric_leaf_switch_assoc: <<: *aci_info profile: ansible_leaf_switch_prf name: ansible_leaf_switch_assoc @@ -68,7 +68,7 @@ register: add_association_again - name: Verify association creation idempotence - assert: + ansible.builtin.assert: that: - add_association_again is not changed - add_association_again.current.0.fabricLeafS.attributes.dn == "uni/fabric/leprof-ansible_leaf_switch_prf/leaves-ansible_leaf_switch_assoc-typ-range" @@ -76,13 +76,13 @@ - add_association_again.current.0.fabricLeafS.attributes.type == "range" - name: Verify Policy Group association idempotence - assert: + ansible.builtin.assert: that: - add_association_again.current.0.fabricLeafS.children.0.fabricRsLeNodePGrp.attributes.tDn == "uni/fabric/funcprof/lenodepgrp-ansible_leaf_pol_grp1" # CREATE SPINE SWITCH ASSOCIATION WITHOUT POLICY GROUP - name: Create a leaf switch profile association without a policy group - aci_fabric_leaf_switch_assoc: + cisco.aci.aci_fabric_leaf_switch_assoc: <<: *aci_info profile: ansible_leaf_switch_prf name: ansible_leaf_switch_assoc2 @@ -90,7 +90,7 @@ register: add_association_without_policy_group - name: Verify association creation - assert: + ansible.builtin.assert: that: - add_association_without_policy_group.current.0.fabricLeafS.attributes.dn == "uni/fabric/leprof-ansible_leaf_switch_prf/leaves-ansible_leaf_switch_assoc2-typ-range" - add_association_without_policy_group.current.0.fabricLeafS.attributes.name == "ansible_leaf_switch_assoc2" @@ -98,7 +98,7 @@ # UPDATE SPINE SWITCH POLICY GROUP ASSOCIATION - name: Update a leaf switch profile association - aci_fabric_leaf_switch_assoc: + cisco.aci.aci_fabric_leaf_switch_assoc: <<: *aci_info profile: ansible_leaf_switch_prf name: ansible_leaf_switch_assoc @@ -107,7 +107,7 @@ register: update_association - name: Verify association update - assert: + ansible.builtin.assert: that: - update_association is changed - update_association.current.0.fabricLeafS.attributes.dn == "uni/fabric/leprof-ansible_leaf_switch_prf/leaves-ansible_leaf_switch_assoc-typ-range" @@ -115,13 +115,13 @@ - update_association.current.0.fabricLeafS.attributes.type == "range" - name: Verify Policy Group association update - assert: + ansible.builtin.assert: that: - update_association.current.0.fabricLeafS.children.0.fabricRsLeNodePGrp.attributes.tDn == "uni/fabric/funcprof/lenodepgrp-ansible_leaf_pol_grp2" # QUERY SPINE SWITCH ASSOCIATION - name: Query leaf switch profile association - aci_fabric_leaf_switch_assoc: + cisco.aci.aci_fabric_leaf_switch_assoc: <<: *aci_info profile: ansible_leaf_switch_prf name: ansible_leaf_switch_assoc @@ -129,7 +129,7 @@ register: query_association - name: Verify query data - assert: + ansible.builtin.assert: that: - query_association is not changed - query_association.current.0.fabricLeafS.attributes.dn == "uni/fabric/leprof-ansible_leaf_switch_prf/leaves-ansible_leaf_switch_assoc-typ-range" @@ -137,25 +137,25 @@ - query_association.current.0.fabricLeafS.attributes.type == "range" - name: Verify Policy Group association - assert: + ansible.builtin.assert: that: - query_association.current.0.fabricLeafS.children.0.fabricRsLeNodePGrp.attributes.tDn == "uni/fabric/funcprof/lenodepgrp-ansible_leaf_pol_grp2" # QUERY ALL SPINE SWITCH ASSOCIATIONS - name: Query leaf switch profile association - aci_fabric_leaf_switch_assoc: + cisco.aci.aci_fabric_leaf_switch_assoc: <<: *aci_info state: query register: query_association_all - name: Verify query all idempotence - assert: + ansible.builtin.assert: that: - query_association_all is not changed # DELETE SPINE SWITCH ASSOCIATION - name: Delete leaf switch profile association - aci_fabric_leaf_switch_assoc: + cisco.aci.aci_fabric_leaf_switch_assoc: <<: *aci_info profile: ansible_leaf_switch_prf name: ansible_leaf_switch_assoc @@ -163,7 +163,7 @@ register: delete_association - name: Verify association removal - assert: + ansible.builtin.assert: that: - delete_association is changed - delete_association.current == [] @@ -173,7 +173,7 @@ # DELETE SPINE SWITCH ASSOCIATION AGAIN TO TEST IDEMPOTENCE - name: Delete leaf switch profile association again - aci_fabric_leaf_switch_assoc: + cisco.aci.aci_fabric_leaf_switch_assoc: <<: *aci_info profile: ansible_leaf_switch_prf name: ansible_leaf_switch_assoc @@ -181,14 +181,14 @@ register: delete_association_again - name: Verify association removal idempotence - assert: + ansible.builtin.assert: that: - delete_association_again is not changed - delete_association_again.current == [] # CLEAN UP ENVIRONMENT - name: Remove ansible_leaf_switch_prf - aci_fabric_leaf_profile: + cisco.aci.aci_fabric_leaf_profile: <<: *aci_info name: ansible_leaf_switch_prf state: absent diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_fabric_management_access/aliases b/ansible_collections/cisco/aci/tests/integration/targets/aci_fabric_management_access/aliases new file mode 100644 index 000000000..209b793f9 --- /dev/null +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_fabric_management_access/aliases @@ -0,0 +1,2 @@ +# No ACI simulator yet, so not enabled +# unsupported diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_fabric_management_access/pki/admin.crt b/ansible_collections/cisco/aci/tests/integration/targets/aci_fabric_management_access/pki/admin.crt new file mode 100644 index 000000000..cfac5531e --- /dev/null +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_fabric_management_access/pki/admin.crt @@ -0,0 +1,14 @@ +-----BEGIN CERTIFICATE----- +MIICODCCAaGgAwIBAgIJAIt8XMntue0VMA0GCSqGSIb3DQEBCwUAMDQxDjAMBgNV +BAMMBUFkbWluMRUwEwYDVQQKDAxZb3VyIENvbXBhbnkxCzAJBgNVBAYTAlVTMCAX +DTE4MDEwOTAwNTk0NFoYDzIxMTcxMjE2MDA1OTQ0WjA0MQ4wDAYDVQQDDAVBZG1p +bjEVMBMGA1UECgwMWW91ciBDb21wYW55MQswCQYDVQQGEwJVUzCBnzANBgkqhkiG +9w0BAQEFAAOBjQAwgYkCgYEAohG/7axtt7CbSaMP7r+2mhTKbNgh0Ww36C7Ta14i +v+VmLyKkQHnXinKGhp6uy3Nug+15a+eIu7CrgpBVMQeCiWfsnwRocKcQJWIYDrWl +XHxGQn31yYKR6mylE7Dcj3rMFybnyhezr5D8GcP85YRPmwG9H2hO/0Y1FUnWu9Iw +AQkCAwEAAaNQME4wHQYDVR0OBBYEFD0jLXfpkrU/ChzRvfruRs/fy1VXMB8GA1Ud +IwQYMBaAFD0jLXfpkrU/ChzRvfruRs/fy1VXMAwGA1UdEwQFMAMBAf8wDQYJKoZI +hvcNAQELBQADgYEAOmvre+5tgZ0+F3DgsfxNQqLTrGiBgGCIymPkP/cBXXkNuJyl +3ac7tArHQc7WEA4U2R2rZbEq8FC3UJJm4nUVtCPvEh3G9OhN2xwYev79yt6pIn/l +KU0Td2OpVyo0eLqjoX5u2G90IBWzhyjFbo+CcKMrSVKj1YOdG0E3OuiJf00= +-----END CERTIFICATE----- diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_fabric_management_access/pki/admin.key b/ansible_collections/cisco/aci/tests/integration/targets/aci_fabric_management_access/pki/admin.key new file mode 100644 index 000000000..63bb00cc0 --- /dev/null +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_fabric_management_access/pki/admin.key @@ -0,0 +1,16 @@ +-----BEGIN PRIVATE KEY----- +MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBAKIRv+2sbbewm0mj +D+6/tpoUymzYIdFsN+gu02teIr/lZi8ipEB514pyhoaerstzboPteWvniLuwq4KQ +VTEHgoln7J8EaHCnECViGA61pVx8RkJ99cmCkepspROw3I96zBcm58oXs6+Q/BnD +/OWET5sBvR9oTv9GNRVJ1rvSMAEJAgMBAAECgYByu3QO0qF9h7X3JEu0Ld4cKBnB +giQ2uJC/et7KxIJ/LOvw9GopBthyt27KwG1ntBkJpkTuAaQHkyNns7vLkNB0S0IR ++owVFEcKYq9VCHTaiQU8TDp24gN+yPTrpRuH8YhDVq5SfVdVuTMgHVQdj4ya4VlF +Gj+a7+ipxtGiLsVGrQJBAM7p0Fm0xmzi+tBOASUAcVrPLcteFIaTBFwfq16dm/ON +00Khla8Et5kMBttTbqbukl8mxFjBEEBlhQqb6EdQQ0sCQQDIhHx1a9diG7y/4DQA +4KvR3FCYwP8PBORlSamegzCo+P1OzxiEo0amX7yQMA5UyiP/kUsZrme2JBZgna8S +p4R7AkEAr7rMhSOPUnMD6V4WgsJ5g1Jp5kqkzBaYoVUUSms5RASz4+cwJVCwTX91 +Y1jcpVIBZmaaY3a0wrx13ajEAa0dOQJBAIpjnb4wqpsEh7VpmJqOdSdGxb1XXfFQ +sA0T1OQYqQnFppWwqrxIL+d9pZdiA1ITnNqyvUFBNETqDSOrUHwwb2cCQGArE+vu +ffPUWQ0j+fiK+covFG8NL7H+26NSGB5+Xsn9uwOGLj7K/YT6CbBtr9hJiuWjM1Al +0V4ltlTuu2mTMaw= +-----END PRIVATE KEY----- diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_fabric_management_access/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_fabric_management_access/tasks/main.yml new file mode 100644 index 000000000..d5f90d95d --- /dev/null +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_fabric_management_access/tasks/main.yml @@ -0,0 +1,328 @@ +# Test code for the ACI modules +# Copyright: (c) 2024, Akini Ross (@akinross) + +# 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 APIC host, ACI username and ACI password + ansible.builtin.fail: + msg: "Please define the following variables: aci_hostname, aci_username and aci_password." + when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined + +# SET VARS +- name: Set vars + ansible.builtin.set_fact: + aci_info: &aci_info + host: "{{ aci_hostname }}" + username: "{{ aci_username }}" + password: "{{ aci_password }}" + validate_certs: "{{ aci_validate_certs | default(false) }}" + use_ssl: "{{ aci_use_ssl | default(true) }}" + use_proxy: "{{ aci_use_proxy | default(true) }}" + output_level: "{{ aci_output_level | default('info') }}" + +- name: Query system information to fetch version + cisco.aci.aci_system: + <<: *aci_info + id: 1 + state: query + register: version + +# CLEAN ENVIRONMENT +- name: Clean environment + cisco.aci.aci_fabric_management_access: &aci_fabric_management_access_1_absent + <<: *aci_info + name: fabric_management_access_policy_1 + state: absent + +- name: Ensure certificate_authority_1 exists + cisco.aci.aci_aaa_certificate_authority: &certificate_authority_1 + <<: *aci_info + name: certificate_authority_1 + certificate_chain: "{{ lookup('file', 'pki/admin.crt') }}" + state: present + +- name: Ensure key_ring_1 exists + cisco.aci.aci_aaa_key_ring: &key_ring_1 + <<: *aci_info + name: key_ring_1 + certificate: "{{ lookup('file', 'pki/admin.crt') }}" + certificate_authority: certificate_authority_1 + key: "{{ lookup('file', 'pki/admin.key') }}" + state: present + register: create_key_ring_1 + until: create_key_ring_1 is not failed + delay: 2 + retries: 4 + +# CREATE +- name: Create a new fabric management access policy (check_mode) + cisco.aci.aci_fabric_management_access: &aci_fabric_management_access_1_present + <<: *aci_fabric_management_access_1_absent + description: "This is a example Fabric Management Access policy." + state: present + check_mode: true + register: cm_create_fabric_management_access_policy_1 + +- name: Create a new fabric management access policy + cisco.aci.aci_fabric_management_access: + <<: *aci_fabric_management_access_1_present + register: nm_create_fabric_management_access_policy_1 + +- name: Create a new fabric management access policy again + cisco.aci.aci_fabric_management_access: + <<: *aci_fabric_management_access_1_present + register: nm_create_fabric_management_access_policy_1_again + +- name: Assertions for creating a fabric management access policy + ansible.builtin.assert: + that: + - cm_create_fabric_management_access_policy_1 is changed + - cm_create_fabric_management_access_policy_1.previous == [] + - cm_create_fabric_management_access_policy_1.current == [] + - cm_create_fabric_management_access_policy_1.proposed.commPol.attributes.name == "fabric_management_access_policy_1" + - cm_create_fabric_management_access_policy_1.proposed.commPol.attributes.descr == "This is a example Fabric Management Access policy." + - nm_create_fabric_management_access_policy_1 is changed + - nm_create_fabric_management_access_policy_1.previous == [] + - nm_create_fabric_management_access_policy_1.current.0.commPol.attributes.name == "fabric_management_access_policy_1" + - nm_create_fabric_management_access_policy_1.current.0.commPol.attributes.descr == "This is a example Fabric Management Access policy." + - nm_create_fabric_management_access_policy_1.current.0.commPol.children.0.commShellinabox.attributes.adminSt == "disabled" + - nm_create_fabric_management_access_policy_1.current.0.commPol.children.1.commSsh.attributes.adminSt == "enabled" + - nm_create_fabric_management_access_policy_1.current.0.commPol.children.2.commTelnet.attributes.adminSt == "disabled" + - nm_create_fabric_management_access_policy_1.current.0.commPol.children.3.commHttps.attributes.adminSt == "enabled" + - nm_create_fabric_management_access_policy_1.current.0.commPol.children.4.commHttp.attributes.adminSt == "disabled" + - nm_create_fabric_management_access_policy_1_again is not changed + - nm_create_fabric_management_access_policy_1_again.previous.0.commPol.attributes.name == "fabric_management_access_policy_1" + - nm_create_fabric_management_access_policy_1_again.previous.0.commPol.attributes.descr == "This is a example Fabric Management Access policy." + - nm_create_fabric_management_access_policy_1_again.previous.0.commPol.children.0.commShellinabox.attributes.adminSt == "disabled" + - nm_create_fabric_management_access_policy_1_again.previous.0.commPol.children.1.commSsh.attributes.adminSt == "enabled" + - nm_create_fabric_management_access_policy_1_again.previous.0.commPol.children.2.commTelnet.attributes.adminSt == "disabled" + - nm_create_fabric_management_access_policy_1_again.previous.0.commPol.children.3.commHttps.attributes.adminSt == "enabled" + - nm_create_fabric_management_access_policy_1_again.previous.0.commPol.children.4.commHttp.attributes.adminSt == "disabled" + - nm_create_fabric_management_access_policy_1_again.current.0.commPol.attributes.name == "fabric_management_access_policy_1" + - nm_create_fabric_management_access_policy_1_again.current.0.commPol.attributes.descr == "This is a example Fabric Management Access policy." + - nm_create_fabric_management_access_policy_1_again.current.0.commPol.children.0.commShellinabox.attributes.adminSt == "disabled" + - nm_create_fabric_management_access_policy_1_again.current.0.commPol.children.1.commSsh.attributes.adminSt == "enabled" + - nm_create_fabric_management_access_policy_1_again.current.0.commPol.children.2.commTelnet.attributes.adminSt == "disabled" + - nm_create_fabric_management_access_policy_1_again.current.0.commPol.children.3.commHttps.attributes.adminSt == "enabled" + - nm_create_fabric_management_access_policy_1_again.current.0.commPol.children.4.commHttp.attributes.adminSt == "disabled" + +# UPDATE +- name: Update an existing fabric management access policy description + cisco.aci.aci_fabric_management_access: + <<: *aci_fabric_management_access_1_present + description: "This is a changed description." + register: nm_update_fabric_management_access_policy_1_change_description + +- name: Assertions for updating a fabric management access policy description + ansible.builtin.assert: + that: + - nm_update_fabric_management_access_policy_1_change_description is changed + - nm_update_fabric_management_access_policy_1_change_description.previous.0.commPol.attributes.descr == "This is a example Fabric Management Access policy." + - nm_update_fabric_management_access_policy_1_change_description.previous.0.commPol.attributes.name == "fabric_management_access_policy_1" + - nm_update_fabric_management_access_policy_1_change_description.current.0.commPol.attributes.descr == "This is a changed description." + - nm_update_fabric_management_access_policy_1_change_description.current.0.commPol.attributes.name == "fabric_management_access_policy_1" + +- name: Update an existing fabric management access policy telnet, ssh, ssh_web, http, and https configuration + cisco.aci.aci_fabric_management_access: + <<: *aci_fabric_management_access_1_present + telnet: + admin_state: enabled + port: 25 + ssh: + admin_state: enabled + password_auth_state: enabled + port: 20 + ciphers: + - aes128_ctr + - aes192_ctr + - aes256_ctr + kex: + - dh_sha1 + - ecdh_521 + macs: + - sha2_256 + - sha2_512 + ssh_web: + admin_state: enabled + http: + admin_state: enabled + port: 85 + allow_origins: http://127.0.0.1:8000 + allow_credentials: enabled + throttle: enabled + throttle_rate: 7500 + throttle_unit: requests_per_minute + https: + admin_state: enabled + port: 445 + allow_origins: http://127.0.0.1:8000 + allow_credentials: enabled + ssl: + - tls_v1.2 + dh_param: 4096 + throttle: enabled + throttle_rate: 7500 + throttle_unit: requests_per_minute + admin_key_ring: key_ring_1 + client_certificate_trustpoint: certificate_authority_1 + client_certificate_authentication_state: enabled + register: nm_update_fabric_management_access_policy_1_change_child_configuration + +- name: Update an existing fabric management access policy https without admin_key_ring + cisco.aci.aci_fabric_management_access: + <<: *aci_fabric_management_access_1_present + https: + admin_state: enabled + port: 443 + register: nm_update_fabric_management_access_policy_1_change_https_no_keyring + +- name: Assertions for updating a fabric management access policy telnet, ssh_web, http configuration + ansible.builtin.assert: + that: + - nm_update_fabric_management_access_policy_1_change_child_configuration is changed + - nm_update_fabric_management_access_policy_1_change_child_configuration.previous.0.commPol.attributes.name == "fabric_management_access_policy_1" + - nm_update_fabric_management_access_policy_1_change_child_configuration.previous.0.commPol.children.0.commShellinabox.attributes.adminSt == "disabled" + - nm_update_fabric_management_access_policy_1_change_child_configuration.previous.0.commPol.children.1.commSsh.attributes.adminSt == "enabled" + - nm_update_fabric_management_access_policy_1_change_child_configuration.previous.0.commPol.children.2.commTelnet.attributes.adminSt == "disabled" + - nm_update_fabric_management_access_policy_1_change_child_configuration.previous.0.commPol.children.2.commTelnet.attributes.port == "23" + - nm_update_fabric_management_access_policy_1_change_child_configuration.previous.0.commPol.children.3.commHttps.attributes.adminSt == "enabled" + - nm_update_fabric_management_access_policy_1_change_child_configuration.previous.0.commPol.children.3.commHttps.attributes.port == "443" + - nm_update_fabric_management_access_policy_1_change_child_configuration.previous.0.commPol.children.3.commHttps.attributes.accessControlAllowCredential == "disabled" + # - nm_update_fabric_management_access_policy_1_change_child_configuration.previous.0.commPol.children.3.commHttps.attributes.accessControlAllowOrigins == "" Commented because the default value is different between versions. + - nm_update_fabric_management_access_policy_1_change_child_configuration.previous.0.commPol.children.3.commHttps.attributes.clientCertAuthState == "disabled" + - nm_update_fabric_management_access_policy_1_change_child_configuration.previous.0.commPol.children.3.commHttps.attributes.dhParam == "none" + - nm_update_fabric_management_access_policy_1_change_child_configuration.previous.0.commPol.children.3.commHttps.attributes.sslProtocols == "TLSv1.1,TLSv1.2" + - nm_update_fabric_management_access_policy_1_change_child_configuration.previous.0.commPol.children.3.commHttps.attributes.globalThrottleRate == "10000" + - nm_update_fabric_management_access_policy_1_change_child_configuration.previous.0.commPol.children.3.commHttps.attributes.globalThrottleSt == "disabled" + - nm_update_fabric_management_access_policy_1_change_child_configuration.previous.0.commPol.children.3.commHttps.attributes.globalThrottleUnit == "r/s" + - nm_update_fabric_management_access_policy_1_change_child_configuration.previous.0.commPol.children.3.commHttps.children.0.commRsKeyRing.attributes.tnPkiKeyRingName == "default" + - nm_update_fabric_management_access_policy_1_change_child_configuration.previous.0.commPol.children.4.commHttp.attributes.adminSt == "disabled" + - nm_update_fabric_management_access_policy_1_change_child_configuration.previous.0.commPol.children.4.commHttp.attributes.port == "80" + - nm_update_fabric_management_access_policy_1_change_child_configuration.current.0.commPol.attributes.name == "fabric_management_access_policy_1" + - nm_update_fabric_management_access_policy_1_change_child_configuration.current.0.commPol.children.0.commShellinabox.attributes.adminSt == "enabled" + - nm_update_fabric_management_access_policy_1_change_child_configuration.current.0.commPol.children.1.commSsh.attributes.adminSt == "enabled" + - nm_update_fabric_management_access_policy_1_change_child_configuration.current.0.commPol.children.1.commSsh.attributes.passwordAuth == "enabled" + - nm_update_fabric_management_access_policy_1_change_child_configuration.current.0.commPol.children.1.commSsh.attributes.port == "20" + - nm_update_fabric_management_access_policy_1_change_child_configuration.current.0.commPol.children.1.commSsh.attributes.sshCiphers == "aes128-ctr,aes192-ctr,aes256-ctr" + - nm_update_fabric_management_access_policy_1_change_child_configuration.current.0.commPol.children.1.commSsh.attributes.kexAlgos == "diffie-hellman-group14-sha1,ecdh-sha2-nistp521" + - nm_update_fabric_management_access_policy_1_change_child_configuration.current.0.commPol.children.1.commSsh.attributes.sshMacs == "hmac-sha2-256,hmac-sha2-512" + - nm_update_fabric_management_access_policy_1_change_child_configuration.current.0.commPol.children.2.commTelnet.attributes.adminSt == "enabled" + - nm_update_fabric_management_access_policy_1_change_child_configuration.current.0.commPol.children.2.commTelnet.attributes.port == "25" + - nm_update_fabric_management_access_policy_1_change_child_configuration.current.0.commPol.children.3.commHttps.attributes.adminSt == "enabled" + - nm_update_fabric_management_access_policy_1_change_child_configuration.current.0.commPol.children.3.commHttps.attributes.port == "445" + - nm_update_fabric_management_access_policy_1_change_child_configuration.current.0.commPol.children.3.commHttps.attributes.accessControlAllowCredential == "enabled" + - nm_update_fabric_management_access_policy_1_change_child_configuration.current.0.commPol.children.3.commHttps.attributes.accessControlAllowOrigins == "http://127.0.0.1:8000" + - nm_update_fabric_management_access_policy_1_change_child_configuration.current.0.commPol.children.3.commHttps.attributes.clientCertAuthState == "enabled" + - nm_update_fabric_management_access_policy_1_change_child_configuration.current.0.commPol.children.3.commHttps.attributes.dhParam == "4096" + - nm_update_fabric_management_access_policy_1_change_child_configuration.current.0.commPol.children.3.commHttps.attributes.sslProtocols == "TLSv1.2" + - nm_update_fabric_management_access_policy_1_change_child_configuration.current.0.commPol.children.3.commHttps.attributes.globalThrottleRate == "7500" + - nm_update_fabric_management_access_policy_1_change_child_configuration.current.0.commPol.children.3.commHttps.attributes.globalThrottleSt == "enabled" + - nm_update_fabric_management_access_policy_1_change_child_configuration.current.0.commPol.children.3.commHttps.attributes.globalThrottleUnit == "r/m" + - nm_update_fabric_management_access_policy_1_change_child_configuration.current.0.commPol.children.3.commHttps.children.0.commRsKeyRing.attributes.tnPkiKeyRingName == "key_ring_1" + - nm_update_fabric_management_access_policy_1_change_child_configuration.current.0.commPol.children.3.commHttps.children.1.commRsClientCertCA.attributes.tDn == "uni/userext/pkiext/tp-certificate_authority_1" + - nm_update_fabric_management_access_policy_1_change_child_configuration.current.0.commPol.children.4.commHttp.attributes.adminSt == "enabled" + - nm_update_fabric_management_access_policy_1_change_child_configuration.current.0.commPol.children.4.commHttp.attributes.port == "85" + - nm_update_fabric_management_access_policy_1_change_child_configuration.current.0.commPol.children.4.commHttp.attributes.accessControlAllowOrigins == "http://127.0.0.1:8000" + - nm_update_fabric_management_access_policy_1_change_child_configuration.current.0.commPol.children.4.commHttp.attributes.accessControlAllowCredential == "enabled" + - nm_update_fabric_management_access_policy_1_change_child_configuration.current.0.commPol.children.4.commHttp.attributes.globalThrottleSt == "enabled" + - nm_update_fabric_management_access_policy_1_change_child_configuration.current.0.commPol.children.4.commHttp.attributes.globalThrottleRate == "7500" + - nm_update_fabric_management_access_policy_1_change_child_configuration.current.0.commPol.children.4.commHttp.attributes.globalThrottleUnit == "r/m" + - nm_update_fabric_management_access_policy_1_change_https_no_keyring is changed + - nm_update_fabric_management_access_policy_1_change_https_no_keyring.previous.0.commPol.attributes.name == "fabric_management_access_policy_1" + - nm_update_fabric_management_access_policy_1_change_https_no_keyring.previous.0.commPol.children.3.commHttps.attributes.port == "445" + - nm_update_fabric_management_access_policy_1_change_https_no_keyring.previous.0.commPol.children.3.commHttps.children.0.commRsKeyRing.attributes.tnPkiKeyRingName == "key_ring_1" + - nm_update_fabric_management_access_policy_1_change_https_no_keyring.current.0.commPol.attributes.name == "fabric_management_access_policy_1" + - nm_update_fabric_management_access_policy_1_change_https_no_keyring.current.0.commPol.children.3.commHttps.attributes.port == "443" + - nm_update_fabric_management_access_policy_1_change_https_no_keyring.current.0.commPol.children.3.commHttps.children.0.commRsKeyRing.attributes.tnPkiKeyRingName == "key_ring_1" + +# VERSION SPECIFIC TESTS +- name: Test fabric management access policy http redirect + when: version.current.0.topSystem.attributes.version is version('5.2', '>=') + block: + - name: Update an existing fabric management access policy http redirect >= 5.2 + cisco.aci.aci_fabric_management_access: + <<: *aci_fabric_management_access_1_present + http: + redirect: tested + register: nm_update_fabric_management_access_policy_1_http_redirect + + - name: Assertions for fabric management access policy http redirect + ansible.builtin.assert: + that: + - nm_update_fabric_management_access_policy_1_http_redirect is changed + - nm_update_fabric_management_access_policy_1_http_redirect.current.0.commPol.children.4.commHttp.attributes.redirectSt == "tested" + +# QUERY +- name: Query an fabric management access policy + cisco.aci.aci_fabric_management_access: + <<: *aci_fabric_management_access_1_present + state: query + register: query_fabric_management_access_policy_1 + +- name: Query all fabric management access policies + cisco.aci.aci_fabric_management_access: + <<: *aci_info + state: query + register: query_all + +- name: Assertions for querying fabric management access policies + ansible.builtin.assert: + that: + - query_fabric_management_access_policy_1 is not changed + - query_fabric_management_access_policy_1.current.0.commPol.attributes.descr == "This is a example Fabric Management Access policy." + - query_fabric_management_access_policy_1.current.0.commPol.attributes.name == "fabric_management_access_policy_1" + - query_fabric_management_access_policy_1.current.0.commPol.children.0.commShellinabox.attributes.adminSt == "enabled" + - query_fabric_management_access_policy_1.current.0.commPol.children.1.commSsh.attributes.adminSt == "enabled" + - query_fabric_management_access_policy_1.current.0.commPol.children.2.commTelnet.attributes.adminSt == "enabled" + - query_fabric_management_access_policy_1.current.0.commPol.children.3.commHttps.attributes.adminSt == "enabled" + - query_fabric_management_access_policy_1.current.0.commPol.children.4.commHttp.attributes.adminSt == "enabled" + - query_fabric_management_access_policy_1.current.0.commPol.children | length == 5 + - query_fabric_management_access_policy_1.current | length == 1 + - query_all is not changed + - query_all.current | length >= 2 + +# DELETE +- name: Delete an existing fabric management access policy (check_mode) + cisco.aci.aci_fabric_management_access: + <<: *aci_fabric_management_access_1_absent + check_mode: true + register: cm_delete_fabric_management_access_policy_1 + +- name: Delete an existing fabric management access policy + cisco.aci.aci_fabric_management_access: + <<: *aci_fabric_management_access_1_absent + register: nm_delete_fabric_management_access_policy_1 + +- name: Delete an existing fabric management access policy again + cisco.aci.aci_fabric_management_access: + <<: *aci_fabric_management_access_1_absent + register: nm_delete_fabric_management_access_policy_1_again + +- name: Assertions for deleting a fabric management access policy + ansible.builtin.assert: + that: + - cm_delete_fabric_management_access_policy_1 is changed + - cm_delete_fabric_management_access_policy_1.previous.0.commPol.attributes.descr == "This is a example Fabric Management Access policy." + - cm_delete_fabric_management_access_policy_1.previous.0.commPol.attributes.name == "fabric_management_access_policy_1" + - cm_delete_fabric_management_access_policy_1.current.0.commPol.attributes.descr == "This is a example Fabric Management Access policy." + - cm_delete_fabric_management_access_policy_1.current.0.commPol.attributes.name == "fabric_management_access_policy_1" + - cm_delete_fabric_management_access_policy_1.proposed == {} + - nm_delete_fabric_management_access_policy_1 is changed + - nm_delete_fabric_management_access_policy_1.previous.0.commPol.attributes.descr == "This is a example Fabric Management Access policy." + - nm_delete_fabric_management_access_policy_1.previous.0.commPol.attributes.name == "fabric_management_access_policy_1" + - nm_delete_fabric_management_access_policy_1.current == [] + - nm_delete_fabric_management_access_policy_1_again is not changed + - nm_delete_fabric_management_access_policy_1_again.previous == [] + - nm_delete_fabric_management_access_policy_1_again.current == [] + +# CLEAN ENVIRONMENT +- name: Delete key_ring_1 + cisco.aci.aci_aaa_key_ring: + <<: *key_ring_1 + state: absent + register: delete_key_ring_1 + +- name: Delete certificate_authority_1 + cisco.aci.aci_aaa_certificate_authority: + <<: *certificate_authority_1 + state: absent
\ No newline at end of file diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_fabric_management_access_https_cipher/aliases b/ansible_collections/cisco/aci/tests/integration/targets/aci_fabric_management_access_https_cipher/aliases new file mode 100644 index 000000000..209b793f9 --- /dev/null +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_fabric_management_access_https_cipher/aliases @@ -0,0 +1,2 @@ +# No ACI simulator yet, so not enabled +# unsupported diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_fabric_management_access_https_cipher/pki/admin.crt b/ansible_collections/cisco/aci/tests/integration/targets/aci_fabric_management_access_https_cipher/pki/admin.crt new file mode 100644 index 000000000..cfac5531e --- /dev/null +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_fabric_management_access_https_cipher/pki/admin.crt @@ -0,0 +1,14 @@ +-----BEGIN CERTIFICATE----- +MIICODCCAaGgAwIBAgIJAIt8XMntue0VMA0GCSqGSIb3DQEBCwUAMDQxDjAMBgNV +BAMMBUFkbWluMRUwEwYDVQQKDAxZb3VyIENvbXBhbnkxCzAJBgNVBAYTAlVTMCAX +DTE4MDEwOTAwNTk0NFoYDzIxMTcxMjE2MDA1OTQ0WjA0MQ4wDAYDVQQDDAVBZG1p +bjEVMBMGA1UECgwMWW91ciBDb21wYW55MQswCQYDVQQGEwJVUzCBnzANBgkqhkiG +9w0BAQEFAAOBjQAwgYkCgYEAohG/7axtt7CbSaMP7r+2mhTKbNgh0Ww36C7Ta14i +v+VmLyKkQHnXinKGhp6uy3Nug+15a+eIu7CrgpBVMQeCiWfsnwRocKcQJWIYDrWl +XHxGQn31yYKR6mylE7Dcj3rMFybnyhezr5D8GcP85YRPmwG9H2hO/0Y1FUnWu9Iw +AQkCAwEAAaNQME4wHQYDVR0OBBYEFD0jLXfpkrU/ChzRvfruRs/fy1VXMB8GA1Ud +IwQYMBaAFD0jLXfpkrU/ChzRvfruRs/fy1VXMAwGA1UdEwQFMAMBAf8wDQYJKoZI +hvcNAQELBQADgYEAOmvre+5tgZ0+F3DgsfxNQqLTrGiBgGCIymPkP/cBXXkNuJyl +3ac7tArHQc7WEA4U2R2rZbEq8FC3UJJm4nUVtCPvEh3G9OhN2xwYev79yt6pIn/l +KU0Td2OpVyo0eLqjoX5u2G90IBWzhyjFbo+CcKMrSVKj1YOdG0E3OuiJf00= +-----END CERTIFICATE----- diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_fabric_management_access_https_cipher/pki/admin.key b/ansible_collections/cisco/aci/tests/integration/targets/aci_fabric_management_access_https_cipher/pki/admin.key new file mode 100644 index 000000000..63bb00cc0 --- /dev/null +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_fabric_management_access_https_cipher/pki/admin.key @@ -0,0 +1,16 @@ +-----BEGIN PRIVATE KEY----- +MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBAKIRv+2sbbewm0mj +D+6/tpoUymzYIdFsN+gu02teIr/lZi8ipEB514pyhoaerstzboPteWvniLuwq4KQ +VTEHgoln7J8EaHCnECViGA61pVx8RkJ99cmCkepspROw3I96zBcm58oXs6+Q/BnD +/OWET5sBvR9oTv9GNRVJ1rvSMAEJAgMBAAECgYByu3QO0qF9h7X3JEu0Ld4cKBnB +giQ2uJC/et7KxIJ/LOvw9GopBthyt27KwG1ntBkJpkTuAaQHkyNns7vLkNB0S0IR ++owVFEcKYq9VCHTaiQU8TDp24gN+yPTrpRuH8YhDVq5SfVdVuTMgHVQdj4ya4VlF +Gj+a7+ipxtGiLsVGrQJBAM7p0Fm0xmzi+tBOASUAcVrPLcteFIaTBFwfq16dm/ON +00Khla8Et5kMBttTbqbukl8mxFjBEEBlhQqb6EdQQ0sCQQDIhHx1a9diG7y/4DQA +4KvR3FCYwP8PBORlSamegzCo+P1OzxiEo0amX7yQMA5UyiP/kUsZrme2JBZgna8S +p4R7AkEAr7rMhSOPUnMD6V4WgsJ5g1Jp5kqkzBaYoVUUSms5RASz4+cwJVCwTX91 +Y1jcpVIBZmaaY3a0wrx13ajEAa0dOQJBAIpjnb4wqpsEh7VpmJqOdSdGxb1XXfFQ +sA0T1OQYqQnFppWwqrxIL+d9pZdiA1ITnNqyvUFBNETqDSOrUHwwb2cCQGArE+vu +ffPUWQ0j+fiK+covFG8NL7H+26NSGB5+Xsn9uwOGLj7K/YT6CbBtr9hJiuWjM1Al +0V4ltlTuu2mTMaw= +-----END PRIVATE KEY----- diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_fabric_management_access_https_cipher/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_fabric_management_access_https_cipher/tasks/main.yml new file mode 100644 index 000000000..5eced8237 --- /dev/null +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_fabric_management_access_https_cipher/tasks/main.yml @@ -0,0 +1,233 @@ +# Test code for the ACI modules +# Copyright: (c) 2024, Akini Ross (@akinross) + +# 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 APIC host, ACI username and ACI password + ansible.builtin.fail: + msg: "Please define the following variables: aci_hostname, aci_username and aci_password." + when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined + +# SET VARS +- name: Set vars + ansible.builtin.set_fact: + aci_info: &aci_info + host: "{{ aci_hostname }}" + username: "{{ aci_username }}" + password: "{{ aci_password }}" + validate_certs: "{{ aci_validate_certs | default(false) }}" + use_ssl: "{{ aci_use_ssl | default(true) }}" + use_proxy: "{{ aci_use_proxy | default(true) }}" + output_level: "{{ aci_output_level | default('info') }}" + +- name: Query system information to fetch version + cisco.aci.aci_system: + <<: *aci_info + id: 1 + state: query + register: version + +- name: Define cipher in version < 6.0 + set_fact: + supported_cipher: "DHE-RSA-AES128-SHA" + supported_cipher_2: "DHE-RSA-AES256-SHA" + when: version.current.0.topSystem.attributes.version is version('6.0', '<') + +- name: Define speed settings in version >= 6.0 + set_fact: + supported_cipher: "DHE-RSA-AES128-SHA256" + supported_cipher_2: "ECDHE-ECDSA-AES128-CCM" + when: version.current.0.topSystem.attributes.version is version('6.0', '>=') + +# CLEAN ENVIRONMENT +- name: Clean environment + cisco.aci.aci_fabric_management_access: &aci_fabric_management_access_1_absent + <<: *aci_info + name: fabric_management_access_policy_1 + state: absent + +- name: Ensure certificate_authority_1 exists + cisco.aci.aci_aaa_certificate_authority: &certificate_authority_1 + <<: *aci_info + name: certificate_authority_1 + certificate_chain: "{{ lookup('file', 'pki/admin.crt') }}" + state: present + +- name: Ensure key_ring_1 exists + cisco.aci.aci_aaa_key_ring: &key_ring_1 + <<: *aci_info + name: key_ring_1 + certificate: "{{ lookup('file', 'pki/admin.crt') }}" + certificate_authority: certificate_authority_1 + key: "{{ lookup('file', 'pki/admin.key') }}" + state: present + register: create_key_ring_1 + until: create_key_ring_1 is not failed + delay: 2 + retries: 4 + +- name: Ensure fabric_management_access_policy_1 exists + cisco.aci.aci_fabric_management_access: + <<: *aci_fabric_management_access_1_absent + https: + admin_state: enabled + port: 445 + admin_key_ring: key_ring_1 + client_certificate_trustpoint: certificate_authority_1 + client_certificate_authentication_state: enabled + state: present + +# CREATE CIPHER +- name: Create a https ssl cipher (check_mode) + cisco.aci.aci_fabric_management_access_https_cipher: &https_ssl_cipher_disabled + <<: *aci_info + fabric_management_access_policy_name: fabric_management_access_policy_1 + id: "{{ supported_cipher }}" + cipher_state: disabled + state: present + check_mode: true + register: cm_create_https_ssl_cipher + +- name: Create a https ssl cipher + cisco.aci.aci_fabric_management_access_https_cipher: + <<: *https_ssl_cipher_disabled + register: nm_create_https_ssl_cipher + +- name: Create a https ssl cipher again + cisco.aci.aci_fabric_management_access_https_cipher: + <<: *https_ssl_cipher_disabled + register: nm_create_https_ssl_cipher_again + +- name: Assertions for disabling a https ssl cipher + ansible.builtin.assert: + that: + - cm_create_https_ssl_cipher is changed + - cm_create_https_ssl_cipher.previous == [] + - cm_create_https_ssl_cipher.current == [] + - cm_create_https_ssl_cipher.proposed.commCipher.attributes.id == "{{ supported_cipher }}" + - cm_create_https_ssl_cipher.proposed.commCipher.attributes.state == "disabled" + - nm_create_https_ssl_cipher is changed + - nm_create_https_ssl_cipher.previous == [] + - nm_create_https_ssl_cipher.current.0.commCipher.attributes.id == "{{ supported_cipher }}" + - nm_create_https_ssl_cipher.current.0.commCipher.attributes.state == "disabled" + - nm_create_https_ssl_cipher_again is not changed + - nm_create_https_ssl_cipher_again.previous.0.commCipher.attributes.id == "{{ supported_cipher }}" + - nm_create_https_ssl_cipher_again.previous.0.commCipher.attributes.state == "disabled" + - nm_create_https_ssl_cipher_again.current.0.commCipher.attributes.id == "{{ supported_cipher }}" + - nm_create_https_ssl_cipher_again.current.0.commCipher.attributes.state == "disabled" + +# UPDATE CIPHER +- name: Update https ssl cipher (check_mode) + cisco.aci.aci_fabric_management_access_https_cipher: &https_ssl_cipher_enabled + <<: *https_ssl_cipher_disabled + cipher_state: enabled + check_mode: true + register: cm_update_https_ssl_cipher + +- name: Update https ssl cipher + cisco.aci.aci_fabric_management_access_https_cipher: + <<: *https_ssl_cipher_enabled + register: nm_update_https_ssl_cipher + +- name: Update https ssl cipher again + cisco.aci.aci_fabric_management_access_https_cipher: + <<: *https_ssl_cipher_enabled + register: nm_update_https_ssl_cipher_again + +- name: Assertions for enabling a https ssl cipher + ansible.builtin.assert: + that: + - cm_update_https_ssl_cipher is changed + - cm_update_https_ssl_cipher.previous.0.commCipher.attributes.id == "{{ supported_cipher }}" + - cm_update_https_ssl_cipher.previous.0.commCipher.attributes.state == "disabled" + - cm_update_https_ssl_cipher.current.0.commCipher.attributes.id == "{{ supported_cipher }}" + - cm_update_https_ssl_cipher.current.0.commCipher.attributes.state == "disabled" + - cm_update_https_ssl_cipher.proposed.commCipher.attributes.id == "{{ supported_cipher }}" + - cm_update_https_ssl_cipher.proposed.commCipher.attributes.state == "enabled" + - nm_update_https_ssl_cipher is changed + - nm_update_https_ssl_cipher.previous.0.commCipher.attributes.id == "{{ supported_cipher }}" + - nm_update_https_ssl_cipher.previous.0.commCipher.attributes.state == "disabled" + - nm_update_https_ssl_cipher.current.0.commCipher.attributes.id == "{{ supported_cipher }}" + - nm_update_https_ssl_cipher.current.0.commCipher.attributes.state == "enabled" + - nm_update_https_ssl_cipher_again is not changed + - nm_update_https_ssl_cipher_again.previous.0.commCipher.attributes.id == "{{ supported_cipher }}" + - nm_update_https_ssl_cipher_again.previous.0.commCipher.attributes.state == "enabled" + - nm_update_https_ssl_cipher_again.current.0.commCipher.attributes.id == "{{ supported_cipher }}" + - nm_update_https_ssl_cipher_again.current.0.commCipher.attributes.state == "enabled" + +# QUERY +- name: Create another https ssl cipher + cisco.aci.aci_fabric_management_access_https_cipher: + <<: *https_ssl_cipher_disabled + id: "{{ supported_cipher_2 }}" + +- name: Query an fabric management access policy + cisco.aci.aci_fabric_management_access_https_cipher: + <<: *https_ssl_cipher_enabled + state: query + register: query_fabric_management_access_policy_1 + +- name: Query all fabric management access policies + cisco.aci.aci_fabric_management_access_https_cipher: + <<: *aci_info + state: query + register: query_all + +- name: Assertions for querying fabric management access policies + ansible.builtin.assert: + that: + - query_fabric_management_access_policy_1 is not changed + - query_fabric_management_access_policy_1.current | length == 1 + - query_all is not changed + - query_all.current | length >= 2 + +# DELETE +- name: Delete https ssl cipher (check_mode) + cisco.aci.aci_fabric_management_access_https_cipher: &https_ssl_cipher_deleted + <<: *https_ssl_cipher_enabled + state: absent + check_mode: true + register: cm_delete_https_ssl_cipher + +- name: Delete https ssl cipher + cisco.aci.aci_fabric_management_access_https_cipher: + <<: *https_ssl_cipher_deleted + register: nm_delete_https_ssl_cipher + +- name: Delete https ssl cipher again + cisco.aci.aci_fabric_management_access_https_cipher: + <<: *https_ssl_cipher_deleted + register: nm_delete_https_ssl_cipher_again + +- name: Assertions for deleting a https ssl cipher + ansible.builtin.assert: + that: + - cm_delete_https_ssl_cipher is changed + - cm_delete_https_ssl_cipher.previous.0.commCipher.attributes.id == "{{ supported_cipher }}" + - cm_delete_https_ssl_cipher.previous.0.commCipher.attributes.state == "enabled" + - cm_delete_https_ssl_cipher.current.0.commCipher.attributes.id == "{{ supported_cipher }}" + - cm_delete_https_ssl_cipher.current.0.commCipher.attributes.state == "enabled" + - cm_delete_https_ssl_cipher.proposed == {} + - nm_delete_https_ssl_cipher is changed + - nm_delete_https_ssl_cipher.previous.0.commCipher.attributes.id == "{{ supported_cipher }}" + - nm_delete_https_ssl_cipher.previous.0.commCipher.attributes.state == "enabled" + - nm_delete_https_ssl_cipher.current == [] + - nm_delete_https_ssl_cipher_again is not changed + - nm_delete_https_ssl_cipher_again.previous == [] + - nm_delete_https_ssl_cipher_again.current == [] + +# CLEAN ENVIRONMENT +- name: Delete fabric_management_access_policy_1 + cisco.aci.aci_fabric_management_access: + <<: *aci_fabric_management_access_1_absent + +- name: Delete key_ring_1 + cisco.aci.aci_aaa_key_ring: + <<: *key_ring_1 + state: absent + register: delete_key_ring_1 + +- name: Delete certificate_authority_1 + cisco.aci.aci_aaa_certificate_authority: + <<: *certificate_authority_1 + state: absent diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_fabric_node/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_fabric_node/tasks/main.yml index 552661556..c769a9a4e 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_fabric_node/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_fabric_node/tasks/main.yml @@ -5,12 +5,12 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: "{{ aci_hostname }}" username: "{{ aci_username }}" @@ -91,7 +91,7 @@ ignore_errors: true - name: Verify add_fabric_node - assert: + ansible.builtin.assert: that: - cm_add_fabric_node_tier_2 is changed - nm_add_fabric_node is changed @@ -137,7 +137,7 @@ register: nm_add_fabric_node_descr_again - name: Verify add_fabric_node_descr - assert: + ansible.builtin.assert: that: - cm_add_fabric_node_descr is changed - nm_add_fabric_node_descr is changed @@ -157,7 +157,7 @@ register: nm_add_fabric_node_again_no_descr - name: Verify add_fabric_node_again_no_descr - assert: + ansible.builtin.assert: that: # FIXME: Module is not idempotent - cm_add_fabric_node_again_no_descr is not changed @@ -183,7 +183,7 @@ register: nm_query_all_fabric_nodes - name: Verify query_all_fabric_nodes - assert: + ansible.builtin.assert: that: - cm_query_all_fabric_nodes is not changed - nm_query_all_fabric_nodes is not changed @@ -205,7 +205,7 @@ register: nm_query_fabric_node - name: Verify query_fabric_node - assert: + ansible.builtin.assert: that: - cm_query_fabric_node is not changed - nm_query_fabric_node is not changed @@ -232,7 +232,7 @@ register: nm_remove_fabric_node_again - name: Verify remove_fabric_node - assert: + ansible.builtin.assert: that: - cm_remove_fabric_node is changed - nm_remove_fabric_node is changed @@ -255,7 +255,7 @@ register: nm_query_non_fabric_node - name: Verify query_non_fabric_node - assert: + ansible.builtin.assert: that: - cm_query_non_fabric_node is not changed - nm_query_non_fabric_node is not changed diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_fabric_node_control/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_fabric_node_control/tasks/main.yml index f41c69150..5a9d58af1 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_fabric_node_control/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_fabric_node_control/tasks/main.yml @@ -5,12 +5,12 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: "{{ aci_hostname }}" username: "{{ aci_username }}" diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_fabric_pod/aliases b/ansible_collections/cisco/aci/tests/integration/targets/aci_fabric_pod/aliases new file mode 100644 index 000000000..209b793f9 --- /dev/null +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_fabric_pod/aliases @@ -0,0 +1,2 @@ +# No ACI simulator yet, so not enabled +# unsupported diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_fabric_pod/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_fabric_pod/tasks/main.yml new file mode 100644 index 000000000..6da068c24 --- /dev/null +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_fabric_pod/tasks/main.yml @@ -0,0 +1,206 @@ +# Test code for the ACI modules +# Copyright: (c) 2023, Samita Bhattacharjee (@samitab) + +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +# Virtual pod setup has been skipped due to complex setup requirements assosiated with configuring a vPod. + +- name: Test that we have an ACI APIC host, ACI username and ACI password + ansible.builtin.fail: + msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' + when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined + +# GET Credentials from the inventory +- name: Set vars + ansible.builtin.set_fact: + aci_info: &aci_info + host: "{{ aci_hostname }}" + username: "{{ aci_username }}" + password: "{{ aci_password }}" + validate_certs: '{{ aci_validate_certs | default(false) }}' + use_ssl: '{{ aci_use_ssl | default(true) }}' + use_proxy: '{{ aci_use_proxy | default(true) }}' + output_level: debug + +# CLEAN ENVIRONMENT +- name: Ensure Fabric Setup Pod 77 is absent before testing + cisco.aci.aci_fabric_pod: + <<: *aci_info + pod_id: 77 + state: absent + register: cleaned + +- name: Sleep for 15 seconds and continue + ansible.builtin.wait_for: + timeout: 15 + delegate_to: localhost + when: cleaned is changed + +# CREATE FABRIC SETUP POD +- name: Create ansible_fabric_pod_setup with check mode + cisco.aci.aci_fabric_pod: + <<: *aci_info + pod_id: 77 + pool: 10.77.0.0/16 + type: physical + description: Ansible test pod setup + state: present + check_mode: true + register: add_fabric_pod_setup_cm + +- name: Create ansible_fabric_pod_setup + cisco.aci.aci_fabric_pod: + <<: *aci_info + pod_id: 77 + pool: 10.77.0.0/16 + type: physical + description: Ansible test pod setup + state: present + register: add_fabric_pod_setup + +- name: Sleep for 15 seconds and continue + ansible.builtin.wait_for: + timeout: 15 + delegate_to: localhost + +- name: Verify profile creation + ansible.builtin.assert: + that: + - add_fabric_pod_setup is changed + - add_fabric_pod_setup.current.0.fabricSetupP.attributes.dn == "uni/controller/setuppol/setupp-77" + - add_fabric_pod_setup.current.0.fabricSetupP.attributes.podId == "77" + - add_fabric_pod_setup.current.0.fabricSetupP.attributes.podType == "physical" + - add_fabric_pod_setup.current.0.fabricSetupP.attributes.tepPool == "10.77.0.0/16" + - add_fabric_pod_setup.current.0.fabricSetupP.attributes.descr == "Ansible test pod setup" + - add_fabric_pod_setup.current.0.fabricSetupP.attributes.annotation == 'orchestrator:ansible' + - add_fabric_pod_setup_cm is changed + - add_fabric_pod_setup_cm.previous == [] + - add_fabric_pod_setup_cm.current == [] + - add_fabric_pod_setup_cm.proposed.fabricSetupP.attributes.dn == "uni/controller/setuppol/setupp-77" + - add_fabric_pod_setup_cm.proposed.fabricSetupP.attributes.podId == "77" + - add_fabric_pod_setup_cm.proposed.fabricSetupP.attributes.podType == "physical" + - add_fabric_pod_setup_cm.proposed.fabricSetupP.attributes.tepPool == "10.77.0.0/16" + - add_fabric_pod_setup_cm.proposed.fabricSetupP.attributes.descr == "Ansible test pod setup" + - add_fabric_pod_setup_cm.proposed.fabricSetupP.attributes.annotation == 'orchestrator:ansible' + +# CREATE FABRIC SETUP POD AGAIN TO TEST IDEMPOTENCE +- name: Create ansible_fabric_pod_setup again + cisco.aci.aci_fabric_pod: + <<: *aci_info + pod_id: 77 + pool: 10.77.0.0/16 + type: physical + description: Ansible test pod setup + state: present + register: add_fabric_pod_setup_again + +- name: Verify profile creation idempotence + ansible.builtin.assert: + that: + - add_fabric_pod_setup_again is not changed + - add_fabric_pod_setup_again.current.0.fabricSetupP.attributes.dn == "uni/controller/setuppol/setupp-77" + - add_fabric_pod_setup_again.current.0.fabricSetupP.attributes.podId == "77" + - add_fabric_pod_setup_again.current.0.fabricSetupP.attributes.podType == "physical" + - add_fabric_pod_setup_again.current.0.fabricSetupP.attributes.tepPool == "10.77.0.0/16" + - add_fabric_pod_setup_again.current.0.fabricSetupP.attributes.descr == "Ansible test pod setup" + +# QUERY FABRIC SETUP POD +- name: Query fabric setup pod + cisco.aci.aci_fabric_pod: + <<: *aci_info + pod_id: 77 + state: query + register: query_pod_profile + +- name: Verify profile query + ansible.builtin.assert: + that: + - query_pod_profile is not changed + - query_pod_profile.current.0.fabricSetupP.attributes.dn == "uni/controller/setuppol/setupp-77" + - query_pod_profile.current.0.fabricSetupP.attributes.podId == "77" + - query_pod_profile.current.0.fabricSetupP.attributes.podType == "physical" + - query_pod_profile.current.0.fabricSetupP.attributes.tepPool == "10.77.0.0/16" + - query_pod_profile.current.0.fabricSetupP.attributes.descr == "Ansible test pod setup" + +# QUERY ALL POD SETUPS +- name: Query all fabric pod setups + cisco.aci.aci_fabric_pod: + <<: *aci_info + state: query + register: query_pod_profile_all + +- name: Verify profile query idempotence + ansible.builtin.assert: + that: + - query_pod_profile_all is not changed + +# DELETE POD SETUP +- name: Delete pod setup with check mode + cisco.aci.aci_fabric_pod: + <<: *aci_info + pod_id: 77 + state: absent + check_mode: true + register: delete_pod_setup_cm + +- name: Delete pod setup + cisco.aci.aci_fabric_pod: + <<: *aci_info + pod_id: 77 + state: absent + register: delete_pod_setup + +- name: Sleep for 15 seconds and continue + ansible.builtin.wait_for: + timeout: 15 + delegate_to: localhost + +- name: Verify pod setup deletion + ansible.builtin.assert: + that: + - delete_pod_setup is changed + - delete_pod_setup.current == [] + - delete_pod_setup.previous.0.fabricSetupP.attributes.dn == "uni/controller/setuppol/setupp-77" + - delete_pod_setup.previous.0.fabricSetupP.attributes.podId == "77" + - delete_pod_setup.previous.0.fabricSetupP.attributes.podType == "physical" + - delete_pod_setup.previous.0.fabricSetupP.attributes.tepPool == "10.77.0.0/16" + - delete_pod_setup.previous.0.fabricSetupP.attributes.descr == "Ansible test pod setup" + - delete_pod_setup_cm is changed + - delete_pod_setup_cm.current != [] + - delete_pod_setup_cm.previous.0.fabricSetupP.attributes.dn == "uni/controller/setuppol/setupp-77" + - delete_pod_setup_cm.previous.0.fabricSetupP.attributes.podId == "77" + - delete_pod_setup_cm.previous.0.fabricSetupP.attributes.podType == "physical" + - delete_pod_setup_cm.previous.0.fabricSetupP.attributes.tepPool == "10.77.0.0/16" + - delete_pod_setup_cm.previous.0.fabricSetupP.attributes.descr == "Ansible test pod setup" + - delete_pod_setup_cm.proposed == {} + +# DELETE POD SETUP AGAIN TO TEST IDEMPOTENCE +- name: Delete pod setup again + cisco.aci.aci_fabric_pod: + <<: *aci_info + pod_id: 77 + state: absent + register: delete_pod_setup_again + +- name: Verify profile deletion idempotence + ansible.builtin.assert: + that: + - delete_pod_setup_again is not changed + - delete_pod_setup_again.current == [] + +# ERROR HANDLING +- name: Create pod setup with out of range pod_id + cisco.aci.aci_fabric_pod: + <<: *aci_info + pod_id: 300 + pool: 10.123.0.0/24 + state: present + register: pod_setup_id_error + ignore_errors: true + +- name: Verify errors of Fabric Setup Pod + ansible.builtin.assert: + that: + - pod_setup_id_error is not changed + - pod_setup_id_error is failed + - pod_setup_id_error.msg == "Pod ID{{":"}} 300 is invalid; it must be in the range of 1 to 254."
\ No newline at end of file diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_fabric_pod_connectivity_profile/aliases b/ansible_collections/cisco/aci/tests/integration/targets/aci_fabric_pod_connectivity_profile/aliases new file mode 100644 index 000000000..209b793f9 --- /dev/null +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_fabric_pod_connectivity_profile/aliases @@ -0,0 +1,2 @@ +# No ACI simulator yet, so not enabled +# unsupported diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_fabric_pod_connectivity_profile/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_fabric_pod_connectivity_profile/tasks/main.yml new file mode 100644 index 000000000..9a42b4656 --- /dev/null +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_fabric_pod_connectivity_profile/tasks/main.yml @@ -0,0 +1,225 @@ +# Test code for the ACI modules +# Copyright: (c) 2024, Samita Bhattacharjee (@samitab) + +# 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 APIC host, ACI username and ACI password + ansible.builtin.fail: + msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' + when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined + +# GET Credentials from the inventory +- name: Set vars + ansible.builtin.set_fact: + aci_info: &aci_info + host: "{{ aci_hostname }}" + username: "{{ aci_username }}" + password: "{{ aci_password }}" + validate_certs: "{{ aci_validate_certs | default(false) }}" + use_ssl: "{{ aci_use_ssl | default(true) }}" + use_proxy: "{{ aci_use_proxy | default(true) }}" + output_level: "{{ aci_output_level | default('info') }}" + +- name: Query system information + cisco.aci.aci_system: + <<: *aci_info + id: 1 + state: query + register: version + +- name: Verify Cloud and Non-Cloud Sites in use. + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + +- name: Execute tasks only for non-cloud sites + when: query_cloud.current == [] + block: + + # CLEAN ENVIRONMENT + - name: Ensure fabric external connection profile is absent before testing + cisco.aci.aci_fabric_external_connection_profile: &delete_fabric_external_connection_profile + <<: *aci_info + fabric_id: "1" + name: "ansible_fabric_ext_conn_profile" + community: "extended:as2-nn4:5:16" + state: absent + + - name: Ensure fabric pod connectivity profile is absent before testing + cisco.aci.aci_fabric_pod_connectivity_profile: &delete_fabric_pod_connectivity_profile + <<: *aci_info + fabric_id: 1 + pod_id: 1 + state: absent + + - name: Create fabric external connection profile + cisco.aci.aci_fabric_external_connection_profile: + <<: *delete_fabric_external_connection_profile + state: present + + # CREATE FABRIC POD CONNECTIVITY PROFILE + - name: Create fabric pod connectivity profile with check mode + cisco.aci.aci_fabric_pod_connectivity_profile: &create_fabric_pod_connectivity_profile + <<: *aci_info + fabric_id: "1" + description: "Fabric Pod Connectivity Profile" + pod_id: "1" + unicast_tep: "10.1.1.2/32" + data_plane_tep: "10.1.1.1/32" + state: present + check_mode: true + register: add_fabric_pod_connectivity_profile_cm + + - name: Create fabric pod connectivity profile + cisco.aci.aci_fabric_pod_connectivity_profile: + <<: *create_fabric_pod_connectivity_profile + state: present + register: add_fabric_pod_connectivity_profile + + # CREATE FABRIC POD CONNECTIVITY PROFILE AGAIN TO TEST IDEMPOTENCE + - name: Create fabric pod connectivity profile again + cisco.aci.aci_fabric_pod_connectivity_profile: + <<: *create_fabric_pod_connectivity_profile + state: present + register: add_fabric_pod_connectivity_profile_again + + - name: Verify creation + ansible.builtin.assert: + that: + - add_fabric_pod_connectivity_profile is changed + - add_fabric_pod_connectivity_profile.previous == [] + - add_fabric_pod_connectivity_profile.current.0.fvPodConnP.attributes.dn == "uni/tn-infra/fabricExtConnP-1/podConnP-1" + - add_fabric_pod_connectivity_profile.current.0.fvPodConnP.attributes.descr == "Fabric Pod Connectivity Profile" + - add_fabric_pod_connectivity_profile.current.0.fvPodConnP.attributes.annotation == 'orchestrator:ansible' + - add_fabric_pod_connectivity_profile.current.0.fvPodConnP.attributes.id == "1" + - add_fabric_pod_connectivity_profile.current.0.fvPodConnP.children.0.fvExtRoutableUcastConnP.attributes.addr == "10.1.1.2/32" + - add_fabric_pod_connectivity_profile.current.0.fvPodConnP.children.1.fvIp.attributes.addr == "10.1.1.1/32" + - add_fabric_pod_connectivity_profile_cm is changed + - add_fabric_pod_connectivity_profile_cm.previous == [] + - add_fabric_pod_connectivity_profile_cm.current == [] + - add_fabric_pod_connectivity_profile_cm.proposed.fvPodConnP.attributes.dn == "uni/tn-infra/fabricExtConnP-1/podConnP-1" + - add_fabric_pod_connectivity_profile_cm.proposed.fvPodConnP.attributes.descr == "Fabric Pod Connectivity Profile" + - add_fabric_pod_connectivity_profile_cm.proposed.fvPodConnP.attributes.annotation == 'orchestrator:ansible' + - add_fabric_pod_connectivity_profile_cm.proposed.fvPodConnP.attributes.id == "1" + - add_fabric_pod_connectivity_profile_cm.proposed.fvPodConnP.children.0.fvExtRoutableUcastConnP.attributes.addr == "10.1.1.2/32" + - add_fabric_pod_connectivity_profile_cm.proposed.fvPodConnP.children.1.fvIp.attributes.addr == "10.1.1.1/32" + - add_fabric_pod_connectivity_profile_again is not changed + - add_fabric_pod_connectivity_profile_again.current == add_fabric_pod_connectivity_profile_again.previous + - add_fabric_pod_connectivity_profile_again.current.0.fvPodConnP.attributes.dn == "uni/tn-infra/fabricExtConnP-1/podConnP-1" + - add_fabric_pod_connectivity_profile_again.current.0.fvPodConnP.attributes.descr == "Fabric Pod Connectivity Profile" + - add_fabric_pod_connectivity_profile_again.current.0.fvPodConnP.attributes.annotation == 'orchestrator:ansible' + - add_fabric_pod_connectivity_profile_again.current.0.fvPodConnP.attributes.id == "1" + - add_fabric_pod_connectivity_profile_again.current.0.fvPodConnP.children.0.fvExtRoutableUcastConnP.attributes.addr == "10.1.1.2/32" + - add_fabric_pod_connectivity_profile_again.current.0.fvPodConnP.children.1.fvIp.attributes.addr == "10.1.1.1/32" + - add_fabric_pod_connectivity_profile_again.previous.0.fvPodConnP.attributes.dn == "uni/tn-infra/fabricExtConnP-1/podConnP-1" + - add_fabric_pod_connectivity_profile_again.previous.0.fvPodConnP.attributes.descr == "Fabric Pod Connectivity Profile" + - add_fabric_pod_connectivity_profile_again.previous.0.fvPodConnP.attributes.id == "1" + - add_fabric_pod_connectivity_profile_again.previous.0.fvPodConnP.children.0.fvExtRoutableUcastConnP.attributes.addr == "10.1.1.2/32" + - add_fabric_pod_connectivity_profile_again.previous.0.fvPodConnP.children.1.fvIp.attributes.addr == "10.1.1.1/32" + + # QUERY FABRIC POD CONNECTIVITY PROFILE + - name: Query fabric pod connectivity profile + cisco.aci.aci_fabric_pod_connectivity_profile: + <<: *aci_info + fabric_id: 1 + pod_id: 1 + state: query + register: query_fabric_pod_connectivity_profile + + # QUERY ALL FABRIC POD CONNECTIVITY PROFILE + - name: Query all fabric pod connectivity profile + cisco.aci.aci_fabric_pod_connectivity_profile: + <<: *aci_info + state: query + register: query_fabric_pod_connectivity_profile_all + + - name: Verify query + ansible.builtin.assert: + that: + - query_fabric_pod_connectivity_profile is not changed + - query_fabric_pod_connectivity_profile.current.0.fvPodConnP.attributes.dn == "uni/tn-infra/fabricExtConnP-1/podConnP-1" + - query_fabric_pod_connectivity_profile.current.0.fvPodConnP.attributes.descr == "Fabric Pod Connectivity Profile" + - query_fabric_pod_connectivity_profile.current.0.fvPodConnP.attributes.id == "1" + - query_fabric_pod_connectivity_profile.current.0.fvPodConnP.children.0.fvExtRoutableUcastConnP.attributes.addr == "10.1.1.2/32" + - query_fabric_pod_connectivity_profile.current.0.fvPodConnP.children.1.fvIp.attributes.addr == "10.1.1.1/32" + - query_fabric_pod_connectivity_profile_all is not changed + - query_fabric_pod_connectivity_profile_all.current | length == 1 + - query_fabric_pod_connectivity_profile_all.current.0.fvPodConnP.attributes.dn == "uni/tn-infra/fabricExtConnP-1/podConnP-1" + - query_fabric_pod_connectivity_profile_all.current.0.fvPodConnP.attributes.descr == "Fabric Pod Connectivity Profile" + - query_fabric_pod_connectivity_profile_all.current.0.fvPodConnP.attributes.id == "1" + - query_fabric_pod_connectivity_profile_all.current.0.fvPodConnP.children.0.fvExtRoutableUcastConnP.attributes.addr == "10.1.1.2/32" + - query_fabric_pod_connectivity_profile_all.current.0.fvPodConnP.children.1.fvIp.attributes.addr == "10.1.1.1/32" + + - name: Update fabric pod connectivity profile + cisco.aci.aci_fabric_pod_connectivity_profile: + <<: *create_fabric_pod_connectivity_profile + unicast_tep: "10.1.1.3/32" + data_plane_tep: "10.1.1.4/32" + state: present + register: update_fabric_pod_connectivity_profile + + - name: Update fabric pod connectivity profile - remove unicast and data plane tep + cisco.aci.aci_fabric_pod_connectivity_profile: + <<: *create_fabric_pod_connectivity_profile + unicast_tep: null + data_plane_tep: null + state: present + register: update_fabric_pod_connectivity_profile_2 + + - name: Verify updates + ansible.builtin.assert: + that: + - update_fabric_pod_connectivity_profile is changed + - update_fabric_pod_connectivity_profile.proposed.fvPodConnP.children.0.fvExtRoutableUcastConnP.attributes.addr == "10.1.1.2/32" + - update_fabric_pod_connectivity_profile.proposed.fvPodConnP.children.0.fvExtRoutableUcastConnP.attributes.status == "deleted" + - update_fabric_pod_connectivity_profile.proposed.fvPodConnP.children.1.fvIp.attributes.addr == "10.1.1.1/32" + - update_fabric_pod_connectivity_profile.proposed.fvPodConnP.children.1.fvIp.attributes.status == "deleted" + - update_fabric_pod_connectivity_profile.proposed.fvPodConnP.children.2.fvExtRoutableUcastConnP.attributes.addr == "10.1.1.3/32" + - update_fabric_pod_connectivity_profile.proposed.fvPodConnP.children.3.fvIp.attributes.addr == "10.1.1.4/32" + - update_fabric_pod_connectivity_profile.current.0.fvPodConnP.children | length == 2 + - update_fabric_pod_connectivity_profile.current.0.fvPodConnP.children.0.fvExtRoutableUcastConnP.attributes.addr == "10.1.1.3/32" + - update_fabric_pod_connectivity_profile.current.0.fvPodConnP.children.1.fvIp.attributes.addr == "10.1.1.4/32" + - update_fabric_pod_connectivity_profile_2 is changed + - update_fabric_pod_connectivity_profile_2.proposed.fvPodConnP.children.0.fvExtRoutableUcastConnP.attributes.addr == "10.1.1.3/32" + - update_fabric_pod_connectivity_profile_2.proposed.fvPodConnP.children.0.fvExtRoutableUcastConnP.attributes.status == "deleted" + - update_fabric_pod_connectivity_profile_2.proposed.fvPodConnP.children.1.fvIp.attributes.addr == "10.1.1.4/32" + - update_fabric_pod_connectivity_profile_2.proposed.fvPodConnP.children.1.fvIp.attributes.status == "deleted" + - update_fabric_pod_connectivity_profile_2.current.0.fvPodConnP.children is undefined + + # DELETE FABRIC POD CONNECTIVITY PROFILE + - name: Delete fabric pod connectivity profile with check mode + cisco.aci.aci_fabric_pod_connectivity_profile: + <<: *delete_fabric_pod_connectivity_profile + check_mode: true + register: delete_fabric_pod_connectivity_profile_cm + + - name: Delete fabric pod connectivity profile + cisco.aci.aci_fabric_pod_connectivity_profile: + <<: *delete_fabric_pod_connectivity_profile + register: delete_fabric_pod_connectivity_profile + + # DELETE FABRIC POD CONNECTIVITY PROFILE AGAIN TO TEST IDEMPOTENCE + - name: Delete fabric pod connectivity profile again + cisco.aci.aci_fabric_pod_connectivity_profile: + <<: *delete_fabric_pod_connectivity_profile + register: delete_fabric_pod_connectivity_profile_again + + - name: Verify deletion + ansible.builtin.assert: + that: + - delete_fabric_pod_connectivity_profile is changed + - delete_fabric_pod_connectivity_profile.current == [] + - delete_fabric_pod_connectivity_profile.previous.0.fvPodConnP.attributes.dn == "uni/tn-infra/fabricExtConnP-1/podConnP-1" + - delete_fabric_pod_connectivity_profile.previous.0.fvPodConnP.attributes.descr == "Fabric Pod Connectivity Profile" + - delete_fabric_pod_connectivity_profile.previous.0.fvPodConnP.attributes.id == "1" + - delete_fabric_pod_connectivity_profile_cm is changed + - delete_fabric_pod_connectivity_profile_cm.proposed == {} + - delete_fabric_pod_connectivity_profile_cm.current != [] + - delete_fabric_pod_connectivity_profile_cm.previous.0.fvPodConnP.attributes.dn == "uni/tn-infra/fabricExtConnP-1/podConnP-1" + - delete_fabric_pod_connectivity_profile_cm.previous.0.fvPodConnP.attributes.descr == "Fabric Pod Connectivity Profile" + - delete_fabric_pod_connectivity_profile_cm.previous.0.fvPodConnP.attributes.id == "1" + - delete_fabric_pod_connectivity_profile_again is not changed + - delete_fabric_pod_connectivity_profile_again.current == [] + - delete_fabric_pod_connectivity_profile_again.previous == [] + + - name: Clean up fabric external connection profile + cisco.aci.aci_fabric_external_connection_profile: + <<: *delete_fabric_external_connection_profile
\ No newline at end of file diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_fabric_pod_external_tep/aliases b/ansible_collections/cisco/aci/tests/integration/targets/aci_fabric_pod_external_tep/aliases new file mode 100644 index 000000000..209b793f9 --- /dev/null +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_fabric_pod_external_tep/aliases @@ -0,0 +1,2 @@ +# No ACI simulator yet, so not enabled +# unsupported diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_fabric_pod_external_tep/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_fabric_pod_external_tep/tasks/main.yml new file mode 100644 index 000000000..d9cab57a4 --- /dev/null +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_fabric_pod_external_tep/tasks/main.yml @@ -0,0 +1,210 @@ +# Test code for the ACI modules +# Copyright: (c) 2023, Samita Bhattacharjee (@samitab) + +# 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 APIC host, ACI username and ACI password + ansible.builtin.fail: + msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' + when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined + +# GET Credentials from the inventory +- name: Set vars + ansible.builtin.set_fact: + aci_info: &aci_info + host: "{{ aci_hostname }}" + username: "{{ aci_username }}" + password: "{{ aci_password }}" + validate_certs: '{{ aci_validate_certs | default(false) }}' + use_ssl: '{{ aci_use_ssl | default(true) }}' + use_proxy: '{{ aci_use_proxy | default(true) }}' + output_level: debug + +# CLEAN ENVIRONMENT +- name: Change external tep to inactive + cisco.aci.aci_fabric_pod_external_tep: + <<: *aci_info + pod_id: 1 + pool: 10.66.22.0/24 + address_count: 5 + status: inactive + state: present + ignore_errors: true + +- name: Ensure existing external tep is absent + cisco.aci.aci_fabric_pod_external_tep: + <<: *aci_info + pod_id: 1 + pool: 10.66.22.0/24 + state: absent + +# CREATE EXTERNAL TEP +- name: Create an external tep with check mode + cisco.aci.aci_fabric_pod_external_tep: + <<: *aci_info + pod_id: 1 + pool: 10.66.22.0/24 + address_count: 5 + status: active + state: present + check_mode: true + register: add_external_tep_cm + +- name: Create an external tep + cisco.aci.aci_fabric_pod_external_tep: + <<: *aci_info + pod_id: 1 + pool: 10.66.22.0/24 + address_count: 5 + status: active + state: present + register: add_external_tep + +- name: Verify external tep creation + ansible.builtin.assert: + that: + - add_external_tep is changed + - add_external_tep.current.0.fabricExtRoutablePodSubnet.attributes.dn == "uni/controller/setuppol/setupp-1/extrtpodsubnet-[10.66.22.0/24]" + - add_external_tep.current.0.fabricExtRoutablePodSubnet.attributes.pool == "10.66.22.0/24" + - add_external_tep.current.0.fabricExtRoutablePodSubnet.attributes.reserveAddressCount == "5" + - add_external_tep.current.0.fabricExtRoutablePodSubnet.attributes.state == "active" + - add_external_tep.current.0.fabricExtRoutablePodSubnet.attributes.annotation == "orchestrator:ansible" + - add_external_tep_cm is changed + - add_external_tep_cm.previous == [] + - add_external_tep_cm.current == [] + - add_external_tep_cm.proposed.fabricExtRoutablePodSubnet.attributes.dn == "uni/controller/setuppol/setupp-1/extrtpodsubnet-[10.66.22.0/24]" + - add_external_tep_cm.proposed.fabricExtRoutablePodSubnet.attributes.pool == "10.66.22.0/24" + - add_external_tep_cm.proposed.fabricExtRoutablePodSubnet.attributes.reserveAddressCount == "5" + - add_external_tep_cm.proposed.fabricExtRoutablePodSubnet.attributes.state == "active" + - add_external_tep_cm.proposed.fabricExtRoutablePodSubnet.attributes.annotation == "orchestrator:ansible" + +# CREATE FABRIC POD PROFILE AGAIN TO TEST IDEMPOTENCE +- name: Create an external tep again + cisco.aci.aci_fabric_pod_external_tep: + <<: *aci_info + pod_id: 1 + pool: 10.66.22.0/24 + address_count: 5 + status: active + state: present + register: add_external_tep_again + +- name: Verify external tep creation idempotence + ansible.builtin.assert: + that: + - add_external_tep_again is not changed + - add_external_tep_again.current.0.fabricExtRoutablePodSubnet.attributes.dn == "uni/controller/setuppol/setupp-1/extrtpodsubnet-[10.66.22.0/24]" + - add_external_tep_again.current.0.fabricExtRoutablePodSubnet.attributes.pool == "10.66.22.0/24" + - add_external_tep_again.current.0.fabricExtRoutablePodSubnet.attributes.reserveAddressCount == "5" + - add_external_tep_again.current.0.fabricExtRoutablePodSubnet.attributes.state == "active" + - add_external_tep_again.current.0.fabricExtRoutablePodSubnet.attributes.annotation == "orchestrator:ansible" + +# QUERY FABRIC EXTERNAL TEP +- name: Query external tep + cisco.aci.aci_fabric_pod_external_tep: + <<: *aci_info + pod_id: 1 + pool: 10.66.22.0/24 + state: query + register: query_external_tep + +- name: Verify external tep query + ansible.builtin.assert: + that: + - query_external_tep is not changed + - query_external_tep.current.0.fabricExtRoutablePodSubnet.attributes.dn == "uni/controller/setuppol/setupp-1/extrtpodsubnet-[10.66.22.0/24]" + - query_external_tep.current.0.fabricExtRoutablePodSubnet.attributes.pool == "10.66.22.0/24" + - query_external_tep.current.0.fabricExtRoutablePodSubnet.attributes.reserveAddressCount == "5" + - query_external_tep.current.0.fabricExtRoutablePodSubnet.attributes.state == "active" + +# QUERY ALL EXTERNAL TEPs +- name: Query all external teps + cisco.aci.aci_fabric_pod_external_tep: + <<: *aci_info + state: query + register: query_external_tep_all + +- name: Verify query idempotence + ansible.builtin.assert: + that: + - query_external_tep_all is not changed + +# VERIFY UNABLE TO DELETE ACTIVE EXTERNAL TEP +- name: Try to delete active external tep + cisco.aci.aci_fabric_pod_external_tep: + <<: *aci_info + pod_id: 1 + pool: 10.66.22.0/24 + state: absent + register: active_tep_error + ignore_errors: true + +- name: Verify unable to delete active external tep + ansible.builtin.assert: + that: + - active_tep_error is not changed + - active_tep_error is failed + - active_tep_error.msg == "APIC Error 105{{":"}} Unable to delete Routable TEP Pool.Please set the state = inactive." + +# CHANGE EXTERNAL TEP TO INACTIVE +- name: Change external tep to inactive + cisco.aci.aci_fabric_pod_external_tep: + <<: *aci_info + pod_id: 1 + pool: 10.66.22.0/24 + address_count: 5 + status: inactive + state: present + register: external_tep_inactive + +# DELETE EXTERNAL TEP +- name: Delete inactive external tep with check mode + cisco.aci.aci_fabric_pod_external_tep: + <<: *aci_info + pod_id: 1 + pool: 10.66.22.0/24 + state: absent + check_mode: true + register: delete_external_tep_cm + +- name: Delete inactive external tep + cisco.aci.aci_fabric_pod_external_tep: + <<: *aci_info + pod_id: 1 + pool: 10.66.22.0/24 + state: absent + register: delete_external_tep + +- name: Verify external tep deletion + ansible.builtin.assert: + that: + - external_tep_inactive is changed + - external_tep_inactive.current.0.fabricExtRoutablePodSubnet.attributes.state == "inactive" + - delete_external_tep is changed + - delete_external_tep.current == [] + - delete_external_tep.previous.0.fabricExtRoutablePodSubnet.attributes.dn == "uni/controller/setuppol/setupp-1/extrtpodsubnet-[10.66.22.0/24]" + - delete_external_tep.previous.0.fabricExtRoutablePodSubnet.attributes.pool == "10.66.22.0/24" + - delete_external_tep.previous.0.fabricExtRoutablePodSubnet.attributes.reserveAddressCount == "5" + - delete_external_tep.previous.0.fabricExtRoutablePodSubnet.attributes.state == "inactive" + - delete_external_tep_cm is changed + - delete_external_tep_cm.current != [] + - delete_external_tep_cm.previous.0.fabricExtRoutablePodSubnet.attributes.dn == "uni/controller/setuppol/setupp-1/extrtpodsubnet-[10.66.22.0/24]" + - delete_external_tep_cm.previous.0.fabricExtRoutablePodSubnet.attributes.pool == "10.66.22.0/24" + - delete_external_tep_cm.previous.0.fabricExtRoutablePodSubnet.attributes.reserveAddressCount == "5" + - delete_external_tep_cm.previous.0.fabricExtRoutablePodSubnet.attributes.state == "inactive" + - delete_external_tep_cm.proposed == {} + +# DELETE AGAIN TO TEST IDEMPOTENCE +- name: Delete inactive external tep again + cisco.aci.aci_fabric_pod_external_tep: + <<: *aci_info + pod_id: 1 + pool: 10.66.22.0/24 + state: absent + register: delete_external_tep_again + +- name: Verify profile deletion idempotence + ansible.builtin.assert: + that: + - delete_external_tep_again is not changed + - delete_external_tep_again.current == []
\ No newline at end of file diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_fabric_pod_policy_group/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_fabric_pod_policy_group/tasks/main.yml index 282fe15d3..e05c831ad 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_fabric_pod_policy_group/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_fabric_pod_policy_group/tasks/main.yml @@ -4,12 +4,12 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: "{{ aci_hostname }}" username: "{{ aci_username }}" @@ -62,7 +62,7 @@ register: nm_add_group_again - name: Verify add policy group - assert: + ansible.builtin.assert: that: - cm_add_group is changed - nm_add_group is changed @@ -95,7 +95,7 @@ register: nm_add_empty_group - name: Verify add empty policy group - assert: + ansible.builtin.assert: that: - nm_add_empty_group is changed - nm_add_empty_group.current.0.fabricPodPGrp.attributes.dn == 'uni/fabric/funcprof/podpgrp-ansible_empty_pod_policy_group' @@ -141,7 +141,7 @@ register: nm_modify_group_again - name: Verify modify policy - assert: + ansible.builtin.assert: that: - cm_modify_group is changed - nm_modify_group is changed @@ -186,7 +186,7 @@ register: nm_query_all_groups - name: Verify query_all_groups - assert: + ansible.builtin.assert: that: - cm_query_all_groups is not changed - nm_query_all_groups is not changed @@ -206,7 +206,7 @@ register: nm_query_group - name: Verify query_group - assert: + ansible.builtin.assert: that: - cm_query_group is not changed - nm_query_group is not changed @@ -246,7 +246,7 @@ register: nm_remove_group_again - name: Verify remove_group and remove_group_again - assert: + ansible.builtin.assert: that: - cm_remove_group is changed - nm_remove_group is changed diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_fabric_pod_profile/aliases b/ansible_collections/cisco/aci/tests/integration/targets/aci_fabric_pod_profile/aliases new file mode 100644 index 000000000..209b793f9 --- /dev/null +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_fabric_pod_profile/aliases @@ -0,0 +1,2 @@ +# No ACI simulator yet, so not enabled +# unsupported diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_fabric_pod_profile/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_fabric_pod_profile/tasks/main.yml new file mode 100644 index 000000000..987ef55f8 --- /dev/null +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_fabric_pod_profile/tasks/main.yml @@ -0,0 +1,153 @@ +# Test code for the ACI modules +# Copyright: (c) 2023, Samita Bhattacharjee (@samitab) + +# 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 APIC host, ACI username and ACI password + ansible.builtin.fail: + msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' + when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined + +# GET Credentials from the inventory +- name: Set vars + ansible.builtin.set_fact: + aci_info: &aci_info + host: "{{ aci_hostname }}" + username: "{{ aci_username }}" + password: "{{ aci_password }}" + validate_certs: '{{ aci_validate_certs | default(false) }}' + use_ssl: '{{ aci_use_ssl | default(true) }}' + use_proxy: '{{ aci_use_proxy | default(true) }}' + output_level: debug + +# CLEAN ENVIRONMENT +- name: Ensure Fabric Pod Profile is absent before testing + cisco.aci.aci_fabric_pod_profile: + <<: *aci_info + name: ansible_fabric_pod_profile + state: absent + +# CREATE FABRIC POD PROFILE +- name: Create ansible_fabric_pod_profile with check mode + cisco.aci.aci_fabric_pod_profile: + <<: *aci_info + name: ansible_fabric_pod_profile + description: Ansible test pod profile + state: present + check_mode: true + register: add_fabric_pod_profile_cm + +- name: Create ansible_fabric_pod_profile + cisco.aci.aci_fabric_pod_profile: + <<: *aci_info + name: ansible_fabric_pod_profile + description: Ansible test pod profile + state: present + register: add_fabric_pod_profile + +- name: Verify profile creation + ansible.builtin.assert: + that: + - add_fabric_pod_profile is changed + - add_fabric_pod_profile.previous == [] + - add_fabric_pod_profile.current.0.fabricPodP.attributes.dn == "uni/fabric/podprof-ansible_fabric_pod_profile" + - add_fabric_pod_profile.current.0.fabricPodP.attributes.name == "ansible_fabric_pod_profile" + - add_fabric_pod_profile.current.0.fabricPodP.attributes.descr == "Ansible test pod profile" + - add_fabric_pod_profile.current.0.fabricPodP.attributes.annotation == 'orchestrator:ansible' + - add_fabric_pod_profile_cm is changed + - add_fabric_pod_profile_cm.previous == [] + - add_fabric_pod_profile_cm.current == [] + - add_fabric_pod_profile_cm.proposed.fabricPodP.attributes.dn == "uni/fabric/podprof-ansible_fabric_pod_profile" + - add_fabric_pod_profile_cm.proposed.fabricPodP.attributes.name == "ansible_fabric_pod_profile" + - add_fabric_pod_profile_cm.proposed.fabricPodP.attributes.descr == "Ansible test pod profile" + - add_fabric_pod_profile_cm.proposed.fabricPodP.attributes.annotation == 'orchestrator:ansible' + +# CREATE FABRIC POD PROFILE AGAIN TO TEST IDEMPOTENCE +- name: Create ansible_fabric_pod_profile again + cisco.aci.aci_fabric_pod_profile: + <<: *aci_info + name: ansible_fabric_pod_profile + description: Ansible test pod profile + state: present + register: add_fabric_pod_profile_again + +- name: Verify profile creation idempotence + ansible.builtin.assert: + that: + - add_fabric_pod_profile_again is not changed + - add_fabric_pod_profile_again.current.0.fabricPodP.attributes.dn == "uni/fabric/podprof-ansible_fabric_pod_profile" + - add_fabric_pod_profile_again.current.0.fabricPodP.attributes.name == "ansible_fabric_pod_profile" + - add_fabric_pod_profile_again.current.0.fabricPodP.attributes.descr == "Ansible test pod profile" + +# QUERY FABRIC POD PROFILE +- name: Query fabric pod profile + cisco.aci.aci_fabric_pod_profile: + <<: *aci_info + name: ansible_fabric_pod_profile + state: query + register: query_pod_profile + +- name: Verify profile query + ansible.builtin.assert: + that: + - query_pod_profile is not changed + - query_pod_profile.current.0.fabricPodP.attributes.dn == "uni/fabric/podprof-ansible_fabric_pod_profile" + - query_pod_profile.current.0.fabricPodP.attributes.name == "ansible_fabric_pod_profile" + - query_pod_profile.current.0.fabricPodP.attributes.descr == "Ansible test pod profile" + +# QUERY ALL POD PROFILES +- name: Query all fabric pod profiles + cisco.aci.aci_fabric_pod_profile: + <<: *aci_info + state: query + register: query_pod_profile_all + +- name: Verify profile query idempotence + ansible.builtin.assert: + that: + - query_pod_profile_all is not changed + +# DELETE POD PROFILE +- name: Delete ansible_fabric_pod_profile with check mode + cisco.aci.aci_fabric_pod_profile: + <<: *aci_info + name: ansible_fabric_pod_profile + state: absent + check_mode: true + register: delete_pod_profile_cm + +- name: Delete ansible_fabric_pod_profile + cisco.aci.aci_fabric_pod_profile: + <<: *aci_info + name: ansible_fabric_pod_profile + state: absent + register: delete_pod_profile + +- name: Verify profile deletion + ansible.builtin.assert: + that: + - delete_pod_profile is changed + - delete_pod_profile.current == [] + - delete_pod_profile.previous.0.fabricPodP.attributes.dn == "uni/fabric/podprof-ansible_fabric_pod_profile" + - delete_pod_profile.previous.0.fabricPodP.attributes.name == "ansible_fabric_pod_profile" + - delete_pod_profile.previous.0.fabricPodP.attributes.descr == "Ansible test pod profile" + - delete_pod_profile_cm is changed + - delete_pod_profile_cm.current != [] + - delete_pod_profile_cm.previous.0.fabricPodP.attributes.dn == "uni/fabric/podprof-ansible_fabric_pod_profile" + - delete_pod_profile_cm.previous.0.fabricPodP.attributes.name == "ansible_fabric_pod_profile" + - delete_pod_profile_cm.previous.0.fabricPodP.attributes.descr == "Ansible test pod profile" + - delete_pod_profile_cm.proposed == {} + +# DELETE POD PROFILE AGAIN TO TEST IDEMPOTENCE +- name: Delete ansible_fabric_pod_profile again + cisco.aci.aci_fabric_pod_profile: + <<: *aci_info + name: ansible_fabric_pod_profile + state: absent + register: delete_pod_profile_again + +- name: Verify profile deletion idempotence + ansible.builtin.assert: + that: + - delete_pod_profile_again is not changed + - delete_pod_profile_again.current == [] diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_fabric_pod_remote_pool/aliases b/ansible_collections/cisco/aci/tests/integration/targets/aci_fabric_pod_remote_pool/aliases new file mode 100644 index 000000000..209b793f9 --- /dev/null +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_fabric_pod_remote_pool/aliases @@ -0,0 +1,2 @@ +# No ACI simulator yet, so not enabled +# unsupported diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_fabric_pod_remote_pool/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_fabric_pod_remote_pool/tasks/main.yml new file mode 100644 index 000000000..74c33979e --- /dev/null +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_fabric_pod_remote_pool/tasks/main.yml @@ -0,0 +1,246 @@ +# Test code for the ACI modules +# Copyright: (c) 2023, Samita Bhattacharjee (@samitab) + +# 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 APIC host, ACI username and ACI password + ansible.builtin.fail: + msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' + when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined + +# GET Credentials from the inventory +- name: Set vars + ansible.builtin.set_fact: + aci_info: &aci_info + host: "{{ aci_hostname }}" + username: "{{ aci_username }}" + password: "{{ aci_password }}" + validate_certs: '{{ aci_validate_certs | default(false) }}' + use_ssl: '{{ aci_use_ssl | default(true) }}' + use_proxy: '{{ aci_use_proxy | default(true) }}' + output_level: debug + +# CLEAN ENVIRONMENT +- name: Ensure Fabric Pod Remote Pool 66 is absent before testing + cisco.aci.aci_fabric_pod_remote_pool: + <<: *aci_info + pod_id: 1 + remote_id: 66 + state: absent + register: cleaned + +- name: Sleep for 15 seconds and continue + ansible.builtin.wait_for: + timeout: 15 + delegate_to: localhost + when: cleaned is changed + +- name: Change external tep to inactive + cisco.aci.aci_fabric_pod_external_tep: + <<: *aci_info + pod_id: 1 + pool: 10.66.22.0/24 + address_count: 5 + status: inactive + state: present + ignore_errors: true + +- name: Ensure existing external tep is absent + cisco.aci.aci_fabric_pod_external_tep: + <<: *aci_info + pod_id: 1 + pool: 10.66.22.0/24 + state: absent + +- name: Create Fabric External Connection Profile + cisco.aci.aci_fabric_external_connection_profile: + <<: *aci_info + fabric_id: 1 + site_id: 1 + community: extended:as2-nn4:5:16 + state: present + +- name: Create Fabric Pod Connectivity Profile + cisco.aci.aci_fabric_pod_connectivity_profile: + <<: *aci_info + fabric_id: 1 + pod_id: 1 + unicast_tep: 10.1.1.1/32 + state: present + +- name: Create an external tep + cisco.aci.aci_fabric_pod_external_tep: + <<: *aci_info + pod_id: 1 + pool: 10.66.22.0/24 + address_count: 5 + status: active + state: present + +# CREATE FABRIC REMOTE POOL +- name: Create a remote pool with check mode + cisco.aci.aci_fabric_pod_remote_pool: + <<: *aci_info + pod_id: 1 + pool: 10.66.22.0/24 + remote_id: 66 + state: present + check_mode: true + register: add_remote_pool_cm + +- name: Create a remote pool + cisco.aci.aci_fabric_pod_remote_pool: + <<: *aci_info + pod_id: 1 + pool: 10.66.22.0/24 + remote_id: 66 + state: present + register: add_remote_pool + +- name: Verify remote pool creation + ansible.builtin.assert: + that: + - add_remote_pool is changed + - add_remote_pool.current.0.fabricExtSetupP.attributes.dn == "uni/controller/setuppol/setupp-1/extsetupp-66" + - add_remote_pool.current.0.fabricExtSetupP.attributes.extPoolId == "66" + - add_remote_pool.current.0.fabricExtSetupP.attributes.tepPool == "10.66.22.0/24" + - add_remote_pool.current.0.fabricExtSetupP.attributes.annotation == "orchestrator:ansible" + - add_remote_pool_cm is changed + - add_remote_pool_cm.previous == [] + - add_remote_pool_cm.current == [] + - add_remote_pool_cm.proposed.fabricExtSetupP.attributes.dn == "uni/controller/setuppol/setupp-1/extsetupp-66" + - add_remote_pool_cm.proposed.fabricExtSetupP.attributes.extPoolId == "66" + - add_remote_pool_cm.proposed.fabricExtSetupP.attributes.tepPool == "10.66.22.0/24" + - add_remote_pool_cm.proposed.fabricExtSetupP.attributes.annotation == "orchestrator:ansible" + + +- name: Sleep for 15 seconds and continue + ansible.builtin.wait_for: + timeout: 15 + delegate_to: localhost + +# CREATE FABRIC REMOTE POOL AGAIN TO TEST IDEMPOTENCE +- name: Create a remote pool again + cisco.aci.aci_fabric_pod_remote_pool: + <<: *aci_info + pod_id: 1 + pool: 10.66.22.0/24 + remote_id: 66 + state: present + register: add_remote_pool_again + +- name: Verify remote pool creation idempotence + ansible.builtin.assert: + that: + - add_remote_pool_again is not changed + - add_remote_pool_again.current.0.fabricExtSetupP.attributes.dn == "uni/controller/setuppol/setupp-1/extsetupp-66" + - add_remote_pool_again.current.0.fabricExtSetupP.attributes.extPoolId == "66" + - add_remote_pool_again.current.0.fabricExtSetupP.attributes.tepPool == "10.66.22.0/24" + - add_remote_pool_again.current.0.fabricExtSetupP.attributes.annotation == "orchestrator:ansible" + +# QUERY FABRIC REMOTE POOL +- name: Query remote pool + cisco.aci.aci_fabric_pod_remote_pool: + <<: *aci_info + pod_id: 1 + remote_id: 66 + state: query + register: query_remote_pool + +- name: Verify remote pool query + ansible.builtin.assert: + that: + - query_remote_pool is not changed + - query_remote_pool.current.0.fabricExtSetupP.attributes.dn == "uni/controller/setuppol/setupp-1/extsetupp-66" + - query_remote_pool.current.0.fabricExtSetupP.attributes.extPoolId == "66" + - query_remote_pool.current.0.fabricExtSetupP.attributes.tepPool == "10.66.22.0/24" + +# QUERY ALL REMOTE POOLs +- name: Query all remote pools + cisco.aci.aci_fabric_pod_remote_pool: + <<: *aci_info + state: query + register: query_remote_pool_all + +- name: Verify query idempotence + ansible.builtin.assert: + that: + - query_remote_pool_all is not changed + +# DELETE REMOTE POOL +- name: Delete remote pool with check mode + cisco.aci.aci_fabric_pod_remote_pool: + <<: *aci_info + pod_id: 1 + remote_id: 66 + state: absent + check_mode: true + register: delete_remote_pool_cm + +- name: Delete remote pool + cisco.aci.aci_fabric_pod_remote_pool: + <<: *aci_info + pod_id: 1 + remote_id: 66 + state: absent + register: delete_remote_pool + +- name: Verify remote pool deletion + ansible.builtin.assert: + that: + - delete_remote_pool is changed + - delete_remote_pool.current == [] + - delete_remote_pool.previous.0.fabricExtSetupP.attributes.dn == "uni/controller/setuppol/setupp-1/extsetupp-66" + - delete_remote_pool.previous.0.fabricExtSetupP.attributes.extPoolId == "66" + - delete_remote_pool.previous.0.fabricExtSetupP.attributes.tepPool == "10.66.22.0/24" + - delete_remote_pool_cm is changed + - delete_remote_pool_cm.current != [] + - delete_remote_pool_cm.previous.0.fabricExtSetupP.attributes.dn == "uni/controller/setuppol/setupp-1/extsetupp-66" + - delete_remote_pool_cm.previous.0.fabricExtSetupP.attributes.extPoolId == "66" + - delete_remote_pool_cm.previous.0.fabricExtSetupP.attributes.tepPool == "10.66.22.0/24" + - delete_remote_pool_cm.proposed == {} + + +- name: Sleep for 15 seconds and continue + ansible.builtin.wait_for: + timeout: 15 + delegate_to: localhost + +# DELETE AGAIN TO TEST IDEMPOTENCE +- name: Delete remote pool again + cisco.aci.aci_fabric_pod_remote_pool: + <<: *aci_info + pod_id: 1 + remote_id: 66 + state: absent + register: delete_remote_pool_again + +- name: Verify profile deletion idempotence + ansible.builtin.assert: + that: + - delete_remote_pool_again is not changed + - delete_remote_pool_again.current == [] + +# CLEAN ENVIRONMENT +- name: Change external tep to inactive + cisco.aci.aci_fabric_pod_external_tep: + <<: *aci_info + pod_id: 1 + pool: 10.66.22.0/24 + address_count: 5 + status: inactive + state: present + ignore_errors: true + +- name: Ensure existing external tep is absent + cisco.aci.aci_fabric_pod_external_tep: + <<: *aci_info + pod_id: 1 + pool: 10.66.22.0/24 + state: absent + +- name: Ensure Fabric External Connection Profile is absent + cisco.aci.aci_fabric_external_connection_profile: + <<: *aci_info + fabric_id: 1 + state: absent
\ No newline at end of file diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_fabric_pod_selector/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_fabric_pod_selector/tasks/main.yml index ca9fb8209..d1bcf7b95 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_fabric_pod_selector/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_fabric_pod_selector/tasks/main.yml @@ -5,12 +5,12 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: "{{ aci_hostname }}" username: "{{ aci_username }}" diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_fabric_scheduler/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_fabric_scheduler/tasks/main.yml index daf5e8956..532d0739f 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_fabric_scheduler/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_fabric_scheduler/tasks/main.yml @@ -4,12 +4,12 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: "{{ aci_hostname }}" username: "{{ aci_username }}" @@ -20,14 +20,14 @@ output_level: debug - name: Verify Cloud and Non-Cloud Sites in use. - include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml - name: Execute tasks only for non-cloud sites when: query_cloud.current == [] # This condition will execute only non-cloud sites block: # block specifies execution of tasks within, based on conditions # Clean Environment - name: Ensure first scheduler does not exist - aci_fabric_scheduler: &aci_fabric_scheduler_absent + cisco.aci.aci_fabric_scheduler: &aci_fabric_scheduler_absent <<: *aci_info name: anstest_scheduler_reccuring description: ACI scheduler test @@ -40,7 +40,7 @@ state: absent - name: Ensure second scheduler does not exist - aci_fabric_scheduler: &aci_fabric_scheduler_2_absent + cisco.aci.aci_fabric_scheduler: &aci_fabric_scheduler_2_absent <<: *aci_info name: anstest_scheduler_oneTime windowname: OneTime @@ -50,30 +50,30 @@ state: absent - name: Create first scheduler (check_mode) - aci_fabric_scheduler: &aci_fabric_scheduler_present + cisco.aci.aci_fabric_scheduler: &aci_fabric_scheduler_present <<: *aci_fabric_scheduler_absent state: present check_mode: true register: cm_add_fabric_scheduler_1 - name: Create first scheduler (normal_mode) - aci_fabric_scheduler: + cisco.aci.aci_fabric_scheduler: <<: *aci_fabric_scheduler_present register: nm_add_fabric_scheduler_1 - name: Create first scheduler again - testing idempotency - aci_fabric_scheduler: + cisco.aci.aci_fabric_scheduler: <<: *aci_fabric_scheduler_present register: idempotency_add_fabric_scheduler_1 - name: Create second scheduler - aci_fabric_scheduler: &aci_fabric_scheduler_2_present + cisco.aci.aci_fabric_scheduler: &aci_fabric_scheduler_2_present <<: *aci_fabric_scheduler_2_absent state: present register: nm_add_fabric_scheduler_2 - name: Asserts for creation tasks - assert: + ansible.builtin.assert: that: - cm_add_fabric_scheduler_1 is changed - cm_add_fabric_scheduler_1.previous == [] @@ -92,19 +92,19 @@ - nm_add_fabric_scheduler_2.current.0.trigSchedP.children.0.trigAbsWindowP.attributes.date == "2023-11-21T00:00:00.000+00:00" - name: Query all scheduler - aci_fabric_scheduler: + cisco.aci.aci_fabric_scheduler: <<: *aci_info state: query register: query_all_fabric_scheduler - name: Query first scheduler - aci_fabric_scheduler: + cisco.aci.aci_fabric_scheduler: <<: *aci_fabric_scheduler_present state: query register: query_first_fabric_scheduler - name: Asserts for query tasks - assert: + ansible.builtin.assert: that: - query_all_fabric_scheduler is not changed - query_all_fabric_scheduler.current | length >= 2 @@ -119,32 +119,32 @@ - query_first_fabric_scheduler.current.0.trigSchedP.children.0.trigRecurrWindowP.attributes.minute == "30" - name: Delete first scheduler (check_mode) - aci_fabric_scheduler: + cisco.aci.aci_fabric_scheduler: <<: *aci_fabric_scheduler_present state: absent check_mode: true register: cm_delete_fabric_scheduler_1 - name: Delete first scheduler (normal_mode) - aci_fabric_scheduler: + cisco.aci.aci_fabric_scheduler: <<: *aci_fabric_scheduler_present state: absent register: nm_delete_fabric_scheduler_1 - name: Delete first scheduler again - testing idempotency - aci_fabric_scheduler: + cisco.aci.aci_fabric_scheduler: <<: *aci_fabric_scheduler_present state: absent register: idempotency_delete_maintenance_group_1 - name: Delete second scheduler (normal_mode) - aci_fabric_scheduler: + cisco.aci.aci_fabric_scheduler: <<: *aci_fabric_scheduler_2_present state: absent register: nm_delete_fabric_scheduler_2 - name: Asserts for deletion tasks - assert: + ansible.builtin.assert: that: - cm_delete_fabric_scheduler_1 is changed - cm_delete_fabric_scheduler_1.proposed == {} diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_fabric_span_dst_group/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_fabric_span_dst_group/tasks/main.yml index a67026daa..e1ec15be9 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_fabric_span_dst_group/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_fabric_span_dst_group/tasks/main.yml @@ -4,7 +4,7 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_fabric_span_src_group/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_fabric_span_src_group/tasks/main.yml index c3e4eb55c..69673f032 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_fabric_span_src_group/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_fabric_span_src_group/tasks/main.yml @@ -4,12 +4,12 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: "{{ aci_hostname }}" username: "{{ aci_username }}" diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_fabric_span_src_group_src/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_fabric_span_src_group_src/tasks/main.yml index 6767e3e89..dc040b102 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_fabric_span_src_group_src/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_fabric_span_src_group_src/tasks/main.yml @@ -4,12 +4,12 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: "{{ aci_hostname }}" username: "{{ aci_username }}" diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_fabric_span_src_group_src_node/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_fabric_span_src_group_src_node/tasks/main.yml index 0e5ea30b2..ed35acb3a 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_fabric_span_src_group_src_node/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_fabric_span_src_group_src_node/tasks/main.yml @@ -4,12 +4,12 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: "{{ aci_hostname }}" username: "{{ aci_username }}" diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_fabric_span_src_group_src_path/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_fabric_span_src_group_src_path/tasks/main.yml index e0c772843..c63342a1a 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_fabric_span_src_group_src_path/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_fabric_span_src_group_src_path/tasks/main.yml @@ -4,12 +4,12 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: "{{ aci_hostname }}" username: "{{ aci_username }}" diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_fabric_spine_profile/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_fabric_spine_profile/tasks/main.yml index 684a9a874..ea79de9b7 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_fabric_spine_profile/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_fabric_spine_profile/tasks/main.yml @@ -4,13 +4,13 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined # GET Credentials from the inventory - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: "{{ aci_hostname }}" username: "{{ aci_username }}" @@ -22,21 +22,21 @@ # CLEAN ENVIRONMENT - name: Remove ansible_spine_switch_prf if it already exists - aci_fabric_spine_profile: + cisco.aci.aci_fabric_spine_profile: <<: *aci_info name: ansible_spine_switch_prf state: absent # CREATE SPINE SWITCH POLICY - name: Create ansible_spine_switch_prf - aci_fabric_spine_profile: + cisco.aci.aci_fabric_spine_profile: <<: *aci_info name: ansible_spine_switch_prf state: present register: add_switch_prf - name: Verify profile creation - assert: + ansible.builtin.assert: that: - add_switch_prf.current.0.fabricSpineP.attributes.dn == "uni/fabric/spprof-ansible_spine_switch_prf" - add_switch_prf.current.0.fabricSpineP.attributes.name == "ansible_spine_switch_prf" @@ -44,14 +44,14 @@ # CREATE SPINE SWITCH POLICY AGAIN TO TEST IDEMPOTENCE - name: Create ansible_spine_switch_prf again - aci_fabric_spine_profile: + cisco.aci.aci_fabric_spine_profile: <<: *aci_info name: ansible_spine_switch_prf state: present register: add_switch_prf_again - name: Verify profile creation idempotence - assert: + ansible.builtin.assert: that: - add_switch_prf_again is not changed - add_switch_prf_again.current.0.fabricSpineP.attributes.dn == "uni/fabric/spprof-ansible_spine_switch_prf" @@ -59,14 +59,14 @@ # QUERY SPINE SWITCH POLICY - name: query spine switch profile - aci_fabric_spine_profile: + cisco.aci.aci_fabric_spine_profile: <<: *aci_info name: ansible_spine_switch_prf state: query register: query_switch_prf - name: Verify profile query - assert: + ansible.builtin.assert: that: - query_switch_prf is not changed - query_switch_prf.current.0.fabricSpineP.attributes.dn == "uni/fabric/spprof-ansible_spine_switch_prf" @@ -74,26 +74,26 @@ # QUERY ALL SPINE SWITCH POLICIES - name: query all spine switch profiles - aci_fabric_spine_profile: + cisco.aci.aci_fabric_spine_profile: <<: *aci_info state: query register: query_switch_prf_all - name: Verify profile query idempotence - assert: + ansible.builtin.assert: that: - query_switch_prf_all is not changed # DELETE SPINE SWITCH PROFILE - name: Delete ansible_spine_switch_prf - aci_fabric_spine_profile: + cisco.aci.aci_fabric_spine_profile: <<: *aci_info name: ansible_spine_switch_prf state: absent register: delete_switch_prf - name: Verify profile deletion - assert: + ansible.builtin.assert: that: - delete_switch_prf is changed - delete_switch_prf.current == [] @@ -102,21 +102,21 @@ # DELETE SPINE SWITCH PROFILE AGAIN TO TEST IDEMPOTENCE - name: Delete ansible_spine_switch_prf again - aci_fabric_spine_profile: + cisco.aci.aci_fabric_spine_profile: <<: *aci_info name: ansible_spine_switch_prf state: absent register: delete_switch_prf_again - name: Verify profile deletion idempotence - assert: + ansible.builtin.assert: that: - delete_switch_prf_again is not changed - delete_switch_prf_again.current == [] # CLEAN UP ENVIRONMENT - name: Remove ansible_spine_switch_prf - aci_fabric_spine_profile: + cisco.aci.aci_fabric_spine_profile: <<: *aci_info name: ansible_spine_switch_prf state: absent diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_fabric_spine_switch_assoc/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_fabric_spine_switch_assoc/tasks/main.yml index 697590fae..b9e79a9dd 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_fabric_spine_switch_assoc/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_fabric_spine_switch_assoc/tasks/main.yml @@ -4,13 +4,13 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined # GET Credentials from the inventory - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: "{{ aci_hostname }}" username: "{{ aci_username }}" @@ -22,21 +22,21 @@ # CLEAN ENVIRONMENT - name: Remove ansible_spine_switch_prf if it already exists - aci_fabric_spine_profile: + cisco.aci.aci_fabric_spine_profile: <<: *aci_info name: ansible_spine_switch_prf state: absent # CREATE SPINE SWITCH POLICY - name: Create ansible_spine_switch_prf - aci_fabric_spine_profile: + cisco.aci.aci_fabric_spine_profile: <<: *aci_info name: ansible_spine_switch_prf state: present # CREATE SPINE SWITCH ASSOCIATION - name: Create a spine switch profile association - aci_fabric_spine_switch_assoc: + cisco.aci.aci_fabric_spine_switch_assoc: <<: *aci_info profile: ansible_spine_switch_prf name: ansible_spine_switch_assoc @@ -45,7 +45,7 @@ register: add_association - name: Verify association creation - assert: + ansible.builtin.assert: that: - add_association.current.0.fabricSpineS.attributes.dn == "uni/fabric/spprof-ansible_spine_switch_prf/spines-ansible_spine_switch_assoc-typ-range" - add_association.current.0.fabricSpineS.attributes.name == "ansible_spine_switch_assoc" @@ -53,13 +53,13 @@ - add_association.current.0.fabricSpineS.attributes.annotation == 'orchestrator:ansible' - name: Verify Policy Group association - assert: + ansible.builtin.assert: that: - add_association.current.0.fabricSpineS.children.0.fabricRsSpNodePGrp.attributes.tDn == "uni/fabric/funcprof/spnodepgrp-ansible_spine_pol_grp1" # CREATE SPINE SWITCH ASSOCIATION AGAIN TO TEST IDEMPOTENCE - name: Create a spine switch profile association again - aci_fabric_spine_switch_assoc: + cisco.aci.aci_fabric_spine_switch_assoc: <<: *aci_info profile: ansible_spine_switch_prf name: ansible_spine_switch_assoc @@ -68,7 +68,7 @@ register: add_association_again - name: Verify association creation idempotence - assert: + ansible.builtin.assert: that: - add_association_again is not changed - add_association_again.current.0.fabricSpineS.attributes.dn == "uni/fabric/spprof-ansible_spine_switch_prf/spines-ansible_spine_switch_assoc-typ-range" @@ -76,13 +76,13 @@ - add_association_again.current.0.fabricSpineS.attributes.type == "range" - name: Verify Policy Group association idempotence - assert: + ansible.builtin.assert: that: - add_association_again.current.0.fabricSpineS.children.0.fabricRsSpNodePGrp.attributes.tDn == "uni/fabric/funcprof/spnodepgrp-ansible_spine_pol_grp1" # CREATE SPINE SWITCH ASSOCIATION WITHOUT POLICY GROUP - name: Create a spine switch profile association without a policy group - aci_fabric_spine_switch_assoc: + cisco.aci.aci_fabric_spine_switch_assoc: <<: *aci_info profile: ansible_spine_switch_prf name: ansible_spine_switch_assoc2 @@ -90,7 +90,7 @@ register: add_association_without_policy_group - name: Verify association creation - assert: + ansible.builtin.assert: that: - add_association_without_policy_group.current.0.fabricSpineS.attributes.dn == "uni/fabric/spprof-ansible_spine_switch_prf/spines-ansible_spine_switch_assoc2-typ-range" - add_association_without_policy_group.current.0.fabricSpineS.attributes.name == "ansible_spine_switch_assoc2" @@ -98,7 +98,7 @@ # UPDATE SPINE SWITCH POLICY GROUP ASSOCIATION - name: Update a spine switch profile association - aci_fabric_spine_switch_assoc: + cisco.aci.aci_fabric_spine_switch_assoc: <<: *aci_info profile: ansible_spine_switch_prf name: ansible_spine_switch_assoc @@ -107,7 +107,7 @@ register: update_association - name: Verify association update - assert: + ansible.builtin.assert: that: - update_association is changed - update_association.current.0.fabricSpineS.attributes.dn == "uni/fabric/spprof-ansible_spine_switch_prf/spines-ansible_spine_switch_assoc-typ-range" @@ -115,13 +115,13 @@ - update_association.current.0.fabricSpineS.attributes.type == "range" - name: Verify Policy Group association update - assert: + ansible.builtin.assert: that: - update_association.current.0.fabricSpineS.children.0.fabricRsSpNodePGrp.attributes.tDn == "uni/fabric/funcprof/spnodepgrp-ansible_spine_pol_grp2" # QUERY SPINE SWITCH ASSOCIATION - name: Query spine switch profile association - aci_fabric_spine_switch_assoc: + cisco.aci.aci_fabric_spine_switch_assoc: <<: *aci_info profile: ansible_spine_switch_prf name: ansible_spine_switch_assoc @@ -129,7 +129,7 @@ register: query_association - name: Verify query data - assert: + ansible.builtin.assert: that: - query_association is not changed - query_association.current.0.fabricSpineS.attributes.dn == "uni/fabric/spprof-ansible_spine_switch_prf/spines-ansible_spine_switch_assoc-typ-range" @@ -137,25 +137,25 @@ - query_association.current.0.fabricSpineS.attributes.type == "range" - name: Verify Policy Group association - assert: + ansible.builtin.assert: that: - query_association.current.0.fabricSpineS.children.0.fabricRsSpNodePGrp.attributes.tDn == "uni/fabric/funcprof/spnodepgrp-ansible_spine_pol_grp2" # QUERY ALL SPINE SWITCH ASSOCIATIONS - name: Query spine switch profile association - aci_fabric_spine_switch_assoc: + cisco.aci.aci_fabric_spine_switch_assoc: <<: *aci_info state: query register: query_association_all - name: Verify query all idempotence - assert: + ansible.builtin.assert: that: - query_association_all is not changed # DELETE SPINE SWITCH ASSOCIATION - name: Delete spine switch profile association - aci_fabric_spine_switch_assoc: + cisco.aci.aci_fabric_spine_switch_assoc: <<: *aci_info profile: ansible_spine_switch_prf name: ansible_spine_switch_assoc @@ -163,7 +163,7 @@ register: delete_association - name: Verify association removal - assert: + ansible.builtin.assert: that: - delete_association is changed - delete_association.current == [] @@ -173,7 +173,7 @@ # DELETE SPINE SWITCH ASSOCIATION AGAIN TO TEST IDEMPOTENCE - name: Delete spine switch profile association again - aci_fabric_spine_switch_assoc: + cisco.aci.aci_fabric_spine_switch_assoc: <<: *aci_info profile: ansible_spine_switch_prf name: ansible_spine_switch_assoc @@ -181,14 +181,14 @@ register: delete_association_again - name: Verify association removal idempotence - assert: + ansible.builtin.assert: that: - delete_association_again is not changed - delete_association_again.current == [] # CLEAN UP ENVIRONMENT - name: Remove ansible_spine_switch_prf - aci_fabric_spine_profile: + cisco.aci.aci_fabric_spine_profile: <<: *aci_info name: ansible_spine_switch_prf state: absent diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_fabric_switch_block/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_fabric_switch_block/tasks/main.yml index 5bd4ce68b..07fd4fe55 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_fabric_switch_block/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_fabric_switch_block/tasks/main.yml @@ -4,13 +4,13 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined # GET Credentials from the inventory - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: "{{ aci_hostname }}" username: "{{ aci_username }}" @@ -22,13 +22,13 @@ # CLEAN ENVIRONMENT - name: Remove ansible_spine_switch_prf if it already exists - aci_fabric_spine_profile: + cisco.aci.aci_fabric_spine_profile: <<: *aci_info name: ansible_spine_switch_prf state: absent - name: Remove ansible_leaf_switch_prf if it already exists - aci_fabric_leaf_profile: + cisco.aci.aci_fabric_leaf_profile: <<: *aci_info name: ansible_leaf_switch_prf state: absent @@ -37,21 +37,21 @@ # CREATE SPINE SWITCH POLICY - name: Create ansible_spine_switch_prf - aci_fabric_spine_profile: + cisco.aci.aci_fabric_spine_profile: <<: *aci_info name: ansible_spine_switch_prf state: present # CREATE LEAF SWITCH POLICY - name: Create ansible_leaf_switch_prf - aci_fabric_leaf_profile: + cisco.aci.aci_fabric_leaf_profile: <<: *aci_info name: ansible_leaf_switch_prf state: present # CREATE SPINE SWITCH ASSOCIATION - name: Create a spine switch profile association - aci_fabric_spine_switch_assoc: + cisco.aci.aci_fabric_spine_switch_assoc: <<: *aci_info profile: ansible_spine_switch_prf name: ansible_spine_switch_assoc @@ -60,7 +60,7 @@ # CREATE LEAF SWITCH ASSOCIATION - name: Create a leaf switch profile association - aci_fabric_leaf_switch_assoc: + cisco.aci.aci_fabric_leaf_switch_assoc: <<: *aci_info profile: ansible_leaf_switch_prf name: ansible_leaf_switch_assoc @@ -69,7 +69,7 @@ # CREATE SPINE SWITCH BLOCK - name: Create a spine switch association block - aci_fabric_switch_block: + cisco.aci.aci_fabric_switch_block: <<: *aci_info switch_type: spine profile: ansible_spine_switch_prf @@ -81,7 +81,7 @@ register: add_switch_block - name: Verify spine block creation - assert: + ansible.builtin.assert: that: - add_switch_block.current.0.fabricNodeBlk.attributes.dn == "uni/fabric/spprof-ansible_spine_switch_prf/spines-ansible_spine_switch_assoc-typ-range/nodeblk-ansible_spine_block" - add_switch_block.current.0.fabricNodeBlk.attributes.name == "ansible_spine_block" @@ -89,7 +89,7 @@ # ADD SPINE SWITCH BLOCK AGAIN TO TEST IDEMPOTENCE - name: Create a spine switch association block again - aci_fabric_switch_block: + cisco.aci.aci_fabric_switch_block: <<: *aci_info switch_type: spine profile: ansible_spine_switch_prf @@ -101,7 +101,7 @@ register: add_switch_block_again - name: Verify spine block creation idempotence - assert: + ansible.builtin.assert: that: - add_switch_block_again is not changed - add_switch_block_again.current.0.fabricNodeBlk.attributes.dn == "uni/fabric/spprof-ansible_spine_switch_prf/spines-ansible_spine_switch_assoc-typ-range/nodeblk-ansible_spine_block" @@ -109,7 +109,7 @@ # CREATE LEAF SWITCH BLOCK - name: Create a leaf switch association block - aci_fabric_switch_block: + cisco.aci.aci_fabric_switch_block: <<: *aci_info switch_type: leaf profile: ansible_leaf_switch_prf @@ -121,14 +121,14 @@ register: add_leaf_switch_block - name: Verify leaf block creation - assert: + ansible.builtin.assert: that: - add_leaf_switch_block.current.0.fabricNodeBlk.attributes.dn == "uni/fabric/leprof-ansible_leaf_switch_prf/leaves-ansible_leaf_switch_assoc-typ-range/nodeblk-ansible_leaf_block" - add_leaf_switch_block.current.0.fabricNodeBlk.attributes.name == "ansible_leaf_block" # ADD LEAF SWITCH BLOCK AGAIN TO TEST IDEMPOTENCE - name: Create a leaf switch association block again - aci_fabric_switch_block: + cisco.aci.aci_fabric_switch_block: <<: *aci_info switch_type: leaf profile: ansible_leaf_switch_prf @@ -140,7 +140,7 @@ register: add_leaf_switch_block_again - name: Verify leaf block creation idempotence - assert: + ansible.builtin.assert: that: - add_leaf_switch_block_again is not changed - add_leaf_switch_block_again.current.0.fabricNodeBlk.attributes.dn == "uni/fabric/leprof-ansible_leaf_switch_prf/leaves-ansible_leaf_switch_assoc-typ-range/nodeblk-ansible_leaf_block" @@ -148,7 +148,7 @@ # QUERY SPINE SWITCH BLOCK - name: Query spine switch association block - aci_fabric_switch_block: + cisco.aci.aci_fabric_switch_block: <<: *aci_info switch_type: spine profile: ansible_spine_switch_prf @@ -158,7 +158,7 @@ register: query_switch_block - name: Verify block query - assert: + ansible.builtin.assert: that: - query_switch_block is not changed - query_switch_block.current.0.fabricNodeBlk.attributes.dn == "uni/fabric/spprof-ansible_spine_switch_prf/spines-ansible_spine_switch_assoc-typ-range/nodeblk-ansible_spine_block" @@ -166,7 +166,7 @@ # QUERY LEAF SWITCH BLOCK - name: Query leaf switch association block - aci_fabric_switch_block: + cisco.aci.aci_fabric_switch_block: <<: *aci_info switch_type: leaf profile: ansible_leaf_switch_prf @@ -176,7 +176,7 @@ register: query_leaf_switch_block - name: Verify leaf block query - assert: + ansible.builtin.assert: that: - query_leaf_switch_block is not changed - query_leaf_switch_block.current.0.fabricNodeBlk.attributes.dn == "uni/fabric/leprof-ansible_leaf_switch_prf/leaves-ansible_leaf_switch_assoc-typ-range/nodeblk-ansible_leaf_block" @@ -184,7 +184,7 @@ # REMOVE SPINE SWITCH BLOCK - name: Remove spine switch association block - aci_fabric_switch_block: + cisco.aci.aci_fabric_switch_block: <<: *aci_info switch_type: spine profile: ansible_spine_switch_prf @@ -194,7 +194,7 @@ register: delete_switch_block - name: Verify spine switch block removal - assert: + ansible.builtin.assert: that: - delete_switch_block is changed - delete_switch_block.current == [] @@ -203,7 +203,7 @@ # REMOVE SPINE SWITCH BLOCK AGAIN TO TEST IDEMPOTENCE - name: Remove spine switch association block - aci_fabric_switch_block: + cisco.aci.aci_fabric_switch_block: <<: *aci_info switch_type: spine profile: ansible_spine_switch_prf @@ -213,14 +213,14 @@ register: delete_switch_block - name: Verify spine switch block removal idempotence - assert: + ansible.builtin.assert: that: - delete_switch_block is not changed - delete_switch_block.current == [] # REMOVE LEAF SWITCH BLOCK - name: Remove leaf switch association block - aci_fabric_switch_block: + cisco.aci.aci_fabric_switch_block: <<: *aci_info switch_type: leaf profile: ansible_leaf_switch_prf @@ -230,7 +230,7 @@ register: delete_leaf_switch_block - name: Verify leaf switch block removal - assert: + ansible.builtin.assert: that: - delete_leaf_switch_block is changed - delete_leaf_switch_block.current == [] @@ -239,7 +239,7 @@ # REMOVE LEAF SWITCH BLOCK AGAIN TO TEST IDEMPOTENCE - name: Remove leaf switch association block - aci_fabric_switch_block: + cisco.aci.aci_fabric_switch_block: <<: *aci_info switch_type: leaf profile: ansible_leaf_switch_prf @@ -249,20 +249,20 @@ register: delete_leaf_switch_block - name: Verify leaf switch block removal idempotence - assert: + ansible.builtin.assert: that: - delete_leaf_switch_block is not changed - delete_leaf_switch_block.current == [] # CLEAN UP ENVIRONMENT - name: Remove ansible_spine_switch_prf - aci_fabric_spine_profile: + cisco.aci.aci_fabric_spine_profile: <<: *aci_info name: ansible_spine_switch_prf state: absent - name: Remove ansible_leaf_switch_prf - aci_fabric_leaf_profile: + cisco.aci.aci_fabric_leaf_profile: <<: *aci_info name: ansible_leaf_switch_prf state: absent diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_fabric_switch_policy_group/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_fabric_switch_policy_group/tasks/main.yml index 83f5355a6..82acdc7c3 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_fabric_switch_policy_group/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_fabric_switch_policy_group/tasks/main.yml @@ -4,13 +4,13 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined # GET Credentials from the inventory - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: "{{ aci_hostname }}" username: "{{ aci_username }}" @@ -52,14 +52,14 @@ register: add_fabric_leaf_policy_group - name: Verify that ansible_fabric_leaf_policy_group has been created with correct attributes - assert: + ansible.builtin.assert: that: - add_fabric_leaf_policy_group.current.0.fabricLeNodePGrp.attributes.dn == "uni/fabric/funcprof/lenodepgrp-ansible_fabric_leaf_policy_group" - add_fabric_leaf_policy_group.current.0.fabricLeNodePGrp.attributes.name == "ansible_fabric_leaf_policy_group" - add_fabric_leaf_policy_group.current.0.fabricLeNodePGrp.attributes.annotation == 'orchestrator:ansible' - name: Verify that ansible_fabric_leaf_policy_group children have correct attributes - assert: + ansible.builtin.assert: that: - add_fabric_leaf_policy_group.current.0.fabricLeNodePGrp.children.0.fabricRsNodeCfgSrv.attributes.tDn == "uni/fabric/analytics/cluster-ansible_test/cfgsrv-ansible_test" - add_fabric_leaf_policy_group.current.0.fabricLeNodePGrp.children.1.fabricRsCallhomeInvPol.attributes.tnCallhomeInvPName == "default" @@ -78,14 +78,14 @@ register: add_fabric_leaf_policy_group_again - name: Verify that ansible_fabric_leaf_policy_group has not been changed - assert: + ansible.builtin.assert: that: - add_fabric_leaf_policy_group_again is not changed - add_fabric_leaf_policy_group_again.current.0.fabricLeNodePGrp.attributes.dn == "uni/fabric/funcprof/lenodepgrp-ansible_fabric_leaf_policy_group" - add_fabric_leaf_policy_group_again.current.0.fabricLeNodePGrp.attributes.name == "ansible_fabric_leaf_policy_group" - name: Verify that ansible_fabric_leaf_policy_group children are still correct - assert: + ansible.builtin.assert: that: - add_fabric_leaf_policy_group_again.current.0.fabricLeNodePGrp.children.0.fabricRsNodeCfgSrv.attributes.tDn == "uni/fabric/analytics/cluster-ansible_test/cfgsrv-ansible_test" - add_fabric_leaf_policy_group_again.current.0.fabricLeNodePGrp.children.1.fabricRsCallhomeInvPol.attributes.tnCallhomeInvPName == "default" @@ -112,13 +112,13 @@ register: add_fabric_spine_policy_group - name: Verify that ansible_fabric_spine_policy_group has been created with correct attributes - assert: + ansible.builtin.assert: that: - add_fabric_spine_policy_group.current.0.fabricSpNodePGrp.attributes.dn == "uni/fabric/funcprof/spnodepgrp-ansible_fabric_spine_policy_group" - add_fabric_spine_policy_group.current.0.fabricSpNodePGrp.attributes.name == "ansible_fabric_spine_policy_group" - name: Verify that ansible_fabric_spine_policy_group children have correct attributes - assert: + ansible.builtin.assert: that: - add_fabric_spine_policy_group.current.0.fabricSpNodePGrp.children.0.fabricRsCallhomeInvPol.attributes.tnCallhomeInvPName == "default" - add_fabric_spine_policy_group.current.0.fabricSpNodePGrp.children.1.fabricRsTwampResponderPol.attributes.tnTwampResponderPolName == "" @@ -136,14 +136,14 @@ register: add_fabric_spine_policy_group_again - name: Verify that ansible_fabric_spine_policy_group has not been changed - assert: + ansible.builtin.assert: that: - add_fabric_spine_policy_group_again is not changed - add_fabric_spine_policy_group_again.current.0.fabricSpNodePGrp.attributes.dn == "uni/fabric/funcprof/spnodepgrp-ansible_fabric_spine_policy_group" - add_fabric_spine_policy_group_again.current.0.fabricSpNodePGrp.attributes.name == "ansible_fabric_spine_policy_group" - name: Verify that ansible_fabric_spine_policy_group children are still correct - assert: + ansible.builtin.assert: that: - add_fabric_spine_policy_group_again.current.0.fabricSpNodePGrp.children.0.fabricRsCallhomeInvPol.attributes.tnCallhomeInvPName == "default" - add_fabric_spine_policy_group_again.current.0.fabricSpNodePGrp.children.1.fabricRsTwampResponderPol.attributes.tnTwampResponderPolName == "" @@ -166,14 +166,14 @@ register: update_fabric_leaf_policy_group - name: Verify ansible_fabric_leaf_policy_group is changed - assert: + ansible.builtin.assert: that: - update_fabric_leaf_policy_group is changed - update_fabric_leaf_policy_group.current.0.fabricLeNodePGrp.attributes.dn == "uni/fabric/funcprof/lenodepgrp-ansible_fabric_leaf_policy_group" - update_fabric_leaf_policy_group.current.0.fabricLeNodePGrp.attributes.name == "ansible_fabric_leaf_policy_group" - name: Verify ansible_fabric_leaf_policy_group children are updated - assert: + ansible.builtin.assert: that: - update_fabric_leaf_policy_group.current.0.fabricLeNodePGrp.children.0.fabricRsNodeCfgSrv.attributes.tDn == "uni/fabric/analytics/cluster-ansible_test/cfgsrv-ansible_test" - update_fabric_leaf_policy_group.current.0.fabricLeNodePGrp.children.1.fabricRsCallhomeInvPol.attributes.tnCallhomeInvPName == "default" @@ -197,14 +197,14 @@ register: update_fabric_spine_policy_group - name: Verify ansible_fabric_spine_policy_group is changed - assert: + ansible.builtin.assert: that: - update_fabric_spine_policy_group is changed - update_fabric_spine_policy_group.current.0.fabricSpNodePGrp.attributes.dn == "uni/fabric/funcprof/spnodepgrp-ansible_fabric_spine_policy_group" - update_fabric_spine_policy_group.current.0.fabricSpNodePGrp.attributes.name == "ansible_fabric_spine_policy_group" - name: Verify ansible_fabric_spine_policy_group children are updated - assert: + ansible.builtin.assert: that: - update_fabric_spine_policy_group.current.0.fabricSpNodePGrp.children.0.fabricRsCallhomeInvPol.attributes.tnCallhomeInvPName == "default" - update_fabric_spine_policy_group.current.0.fabricSpNodePGrp.children.1.fabricRsTwampResponderPol.attributes.tnTwampResponderPolName == "default" @@ -225,14 +225,14 @@ register: query_fabric_leaf_policy_group - name: Verify attributes - assert: + ansible.builtin.assert: that: - query_fabric_leaf_policy_group is not changed - query_fabric_leaf_policy_group.current.0.fabricLeNodePGrp.attributes.dn == "uni/fabric/funcprof/lenodepgrp-ansible_fabric_leaf_policy_group" - query_fabric_leaf_policy_group.current.0.fabricLeNodePGrp.attributes.name == "ansible_fabric_leaf_policy_group" - name: Verify children - assert: + ansible.builtin.assert: that: - query_fabric_leaf_policy_group.current.0.fabricLeNodePGrp.children.0.fabricRsNodeCfgSrv.attributes.tDn == "uni/fabric/analytics/cluster-ansible_test/cfgsrv-ansible_test" - query_fabric_leaf_policy_group.current.0.fabricLeNodePGrp.children.1.fabricRsCallhomeInvPol.attributes.tnCallhomeInvPName == "default" @@ -252,7 +252,7 @@ register: query_fabric_leaf_policy_group_all - name: Verify query all is idempotent - assert: + ansible.builtin.assert: that: - query_fabric_leaf_policy_group_all is not changed @@ -266,14 +266,14 @@ register: query_fabric_spine_policy_group - name: Verify attributes - assert: + ansible.builtin.assert: that: - query_fabric_spine_policy_group is not changed - query_fabric_spine_policy_group.current.0.fabricSpNodePGrp.attributes.dn == "uni/fabric/funcprof/spnodepgrp-ansible_fabric_spine_policy_group" - query_fabric_spine_policy_group.current.0.fabricSpNodePGrp.attributes.name == "ansible_fabric_spine_policy_group" - name: Verify children - assert: + ansible.builtin.assert: that: - query_fabric_spine_policy_group.current.0.fabricSpNodePGrp.children.0.fabricRsCallhomeInvPol.attributes.tnCallhomeInvPName == "default" - query_fabric_spine_policy_group.current.0.fabricSpNodePGrp.children.1.fabricRsTwampResponderPol.attributes.tnTwampResponderPolName == "default" @@ -292,7 +292,7 @@ register: query_fabric_spine_policy_group_all - name: Verify query all is idempotent - assert: + ansible.builtin.assert: that: - query_fabric_spine_policy_group_all is not changed @@ -306,7 +306,7 @@ register: delete_fabric_leaf_policy_group - name: Verify Fabric Leaf Policy Group deletion - assert: + ansible.builtin.assert: that: - delete_fabric_leaf_policy_group is changed - delete_fabric_leaf_policy_group.current == [] @@ -330,7 +330,7 @@ register: delete_fabric_spine_policy_group - name: Verify Fabric Spine Policy Group deletion - assert: + ansible.builtin.assert: that: - delete_fabric_spine_policy_group is changed - delete_fabric_spine_policy_group.current == [] diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_fabric_wide_settings/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_fabric_wide_settings/tasks/main.yml index 526c8bee0..387d23580 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_fabric_wide_settings/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_fabric_wide_settings/tasks/main.yml @@ -5,12 +5,12 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: "{{ aci_hostname }}" username: "{{ aci_username }}" @@ -21,7 +21,7 @@ output_level: '{{ aci_output_level | default("info") }}' - name: Verify Cloud and Non-Cloud Sites in use. - include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml - name: Execute tasks only for non-cloud sites when: query_cloud.current == [] # This condition will skip execution for cloud sites diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_file_remote_path/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_file_remote_path/tasks/main.yml index ab1560ba6..c0fcbaa9f 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_file_remote_path/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_file_remote_path/tasks/main.yml @@ -4,12 +4,12 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: "{{ aci_hostname }}" username: "{{ aci_username }}" diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_filter/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_filter/tasks/main.yml index a8928de57..db4e07eff 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_filter/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_filter/tasks/main.yml @@ -4,7 +4,7 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined @@ -64,7 +64,7 @@ register: nm_add_filter_again - name: Verify add_filter - assert: + ansible.builtin.assert: that: - cm_add_filter is changed - cm_add_filter_again is changed @@ -100,7 +100,7 @@ register: nm_add_filter_descr_again - name: Verify add_filter_descr - assert: + ansible.builtin.assert: that: - cm_add_filter_descr is changed - cm_add_filter_descr_again is changed @@ -118,7 +118,7 @@ register: nm_add_filter_again_no_descr - name: Verify add_filter_again_no_descr - assert: + ansible.builtin.assert: that: - cm_add_filter_again_no_descr is not changed - nm_add_filter_again_no_descr is not changed @@ -142,7 +142,7 @@ register: nm_query_all_filters - name: Verify query_all_filters - assert: + ansible.builtin.assert: that: - cm_query_all_filters is not changed - nm_query_all_filters is not changed @@ -166,7 +166,7 @@ register: nm_query_filter - name: Verify query_filter - assert: + ansible.builtin.assert: that: - cm_query_filter is not changed - nm_query_filter is not changed @@ -192,7 +192,7 @@ register: nm_remove_filter_again - name: Verify remove_filter - assert: + ansible.builtin.assert: that: - cm_remove_filter is changed - cm_remove_filter_again is changed @@ -217,7 +217,7 @@ register: nm_query_non_filter - name: Verify query_non_filter - assert: + ansible.builtin.assert: that: - cm_query_non_filter is not changed - nm_query_non_filter is not changed diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_filter_entry/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_filter_entry/tasks/main.yml index e969111a2..859df9e97 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_filter_entry/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_filter_entry/tasks/main.yml @@ -4,13 +4,13 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined # CLEAN ENVIRONMENT - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: "{{ aci_hostname }}" username: "{{ aci_username }}" @@ -21,7 +21,7 @@ output_level: '{{ aci_output_level | default("debug") }}' - name: Verify Cloud and Non-Cloud Sites in use. - include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml # TODO current module will fail on cloud sites because range is not supported # APIC Error 1: Invalid Configuration CLOUD_SOURCE_PORT_NOT_SUPPORTED: vz::EntryMo Dn = uni/tn-ansible_test/flt-anstest_fileter_2/e-source_port_start - Source port range is not allowed on CAPIC" @@ -176,7 +176,7 @@ register: icmp6_msg_type_est - name: Assertion check for the filter entry - match_only_fragments, source_port and tcp_flags attributes - assert: + ansible.builtin.assert: that: - nt_match_only_fragments_with_dst_port is not changed - nt_match_only_fragments_with_dst_port.msg == "Parameter 'match_only_fragments' cannot be used with 'Layer 4 Port' value" @@ -266,7 +266,7 @@ register: entry_present_update - name: Verify Cloud and Non-Cloud Sites in use. - include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml - name: create filter entry - test different types cisco.aci.aci_filter_entry: @@ -309,7 +309,7 @@ register: present_incompatible_params - name: present assertions - assert: + ansible.builtin.assert: that: - entry_present_check_mode is changed - entry_present_check_mode.previous == [] @@ -346,7 +346,7 @@ - present_incompatible_params.msg.startswith("Parameter") - name: present assertions for arp - assert: + ansible.builtin.assert: that: - entry_present_2 is changed - entry_present_2.sent.vzEntry.attributes.arpOpc == 'reply' @@ -406,7 +406,7 @@ register: query_all - name: query assertions for all - assert: + ansible.builtin.assert: that: - query_tenant_filter_entry is not changed - query_tenant_filter_entry.current | length == 1 @@ -450,7 +450,7 @@ - name: query assertions for only Non-Cloud - assert: + ansible.builtin.assert: that: - query_tenant_filter.current.0.vzFilter.children | length == 4 when: query_cloud.current == [] # This condition will skip execution for cloud sites @@ -486,7 +486,7 @@ with_items: ["anstest2", "anstest3", "anstest4"] - name: absent assertions - assert: + ansible.builtin.assert: that: - entry_absent_check_mode is changed - entry_absent_check_mode.previous != [] diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_filter_listify/aliases b/ansible_collections/cisco/aci/tests/integration/targets/aci_filter_listify/aliases new file mode 100644 index 000000000..209b793f9 --- /dev/null +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_filter_listify/aliases @@ -0,0 +1,2 @@ +# No ACI simulator yet, so not enabled +# unsupported diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_filter_listify/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_filter_listify/tasks/main.yml new file mode 100644 index 000000000..a186c9ce6 --- /dev/null +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_filter_listify/tasks/main.yml @@ -0,0 +1,197 @@ +# Test code for the ACI modules +# Copyright: (c) 2023, Shreyas Srish (shrsr@cisco.com) +# Copyright: (c) 2024, Akini Ross <akinross@cisco.com> +# +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +- name: Test that we have an ACI APIC host, ACI username and ACI password + ansible.builtin.fail: + msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' + when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined + +- name: Set vars + ansible.builtin.set_fact: + aci_info: &aci_info + host: "{{ aci_hostname }}" + username: "{{ aci_username }}" + password: "{{ aci_password }}" + validate_certs: '{{ aci_validate_certs | default(false) }}' + use_ssl: '{{ aci_use_ssl | default(true) }}' + use_proxy: '{{ aci_use_proxy | default(true) }}' + output_level: '{{ aci_output_level | default("info") }}' + aci_model_data: + tenant: + - name: ansible_test + description: Created using listify + app: + - name: app_test + epg: + - name: web + bd: web_bd + - name: app + bd: app_bd + bd: + - name: bd_test + subnet: + - name: 10.10.10.1 + mask: 24 + scope: + - private + - shared + vrf: vrf_test + - name: bd_test2 + subnet: + - name: 20.20.20.1 + mask: 24 + scope: [public, shared] + vrf: vrf_test + vrf: + - name: vrf_test + - name: ansible_test2 + description: Created using listify + app: + - name: app_test2 + epg: + - name: web2 + bd: web_bd2 + - name: app2 + bd: app_bd2 + policies: + protocol: + bfd: + - name: BFD-ON + description: Enable BFD + admin_state: enabled + detection_multiplier: 3 + min_tx_interval: 50 + min_rx_interval: 50 + echo_rx_interval: 50 + echo_admin_state: enabled + sub_interface_optimization_state: enabled + ospf: + interface: + - name: OSPF-P2P-IntPol + network_type: p2p + priority: 1 + - name: OSPF-Broadcast-IntPol + network_type: bcast + priority: 1 + +- name: Verify Cloud and Non-Cloud Sites in use. + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + +- name: Execute tasks only for non-cloud sites + when: query_cloud.current == [] # This condition will execute only non-cloud sites + block: # block specifies execution of tasks within, based on conditions + + - name: Set facts for nested dictionaries + ansible.builtin.set_fact: + bfd_listify_output: '{{ aci_model_data|cisco.aci.aci_listify("tenant", "policies", "protocol", "bfd") }}' + ospf_listify_output: '{{ aci_model_data|cisco.aci.aci_listify("tenant", "policies", "protocol", "ospf", "interface") }}' + + - name: Validate listify for nested dictionaries + ansible.builtin.assert: + that: + - bfd_listify_output.0.tenant_name == "ansible_test2" + - bfd_listify_output.0.tenant_description == "Created using listify" + - bfd_listify_output.0.tenant_policies_protocol_bfd_admin_state == "enabled" + - bfd_listify_output.0.tenant_policies_protocol_bfd_description == "Enable BFD" + - bfd_listify_output.0.tenant_policies_protocol_bfd_detection_multiplier == 3 + - bfd_listify_output.0.tenant_policies_protocol_bfd_echo_admin_state == "enabled" + - bfd_listify_output.0.tenant_policies_protocol_bfd_echo_rx_interval == 50 + - bfd_listify_output.0.tenant_policies_protocol_bfd_min_rx_interval == 50 + - bfd_listify_output.0.tenant_policies_protocol_bfd_min_tx_interval == 50 + - bfd_listify_output.0.tenant_policies_protocol_bfd_name == "BFD-ON" + - bfd_listify_output.0.tenant_policies_protocol_bfd_sub_interface_optimization_state == "enabled" + - ospf_listify_output.0.tenant_name == "ansible_test2" + - ospf_listify_output.0.tenant_description == "Created using listify" + - ospf_listify_output.0.tenant_policies_protocol_ospf_interface_name == "OSPF-P2P-IntPol" + - ospf_listify_output.0.tenant_policies_protocol_ospf_interface_network_type == "p2p" + - ospf_listify_output.0.tenant_policies_protocol_ospf_interface_priority == 1 + - ospf_listify_output.1.tenant_policies_protocol_ospf_interface_name == "OSPF-Broadcast-IntPol" + - ospf_listify_output.1.tenant_policies_protocol_ospf_interface_network_type == "bcast" + - ospf_listify_output.1.tenant_policies_protocol_ospf_interface_priority == 1 + + - name: Create tenants + cisco.aci.aci_tenant: + <<: *aci_info + tenant: '{{ item.tenant_name }}' + description: '{{ item.tenant_description }}' + with_items: '{{ aci_model_data|cisco.aci.aci_listify("tenant") }}' + register: tenant_listify + + - name: Create VRFs + cisco.aci.aci_vrf: + <<: *aci_info + tenant: '{{ item.tenant_name }}' + vrf_name: '{{ item.tenant_vrf_name }}' + with_items: '{{ aci_model_data|cisco.aci.aci_listify("tenant","vrf") }}' + register: vrf_listify + + - name: Create BDs + cisco.aci.aci_bd: + <<: *aci_info + tenant: '{{ item.tenant_name }}' + vrf: '{{ item.tenant_bd_vrf }}' + bd: '{{ item.tenant_bd_name }}' + enable_routing: yes + with_items: '{{ aci_model_data|cisco.aci.aci_listify("tenant","bd") }}' + register: bd_listify + + - name: Create BD subnets + cisco.aci.aci_bd_subnet: + <<: *aci_info + tenant: '{{ item.tenant_name }}' + bd: '{{ item.tenant_bd_name }}' + gateway: '{{ item.tenant_bd_subnet_name }}' + mask: '{{ item.tenant_bd_subnet_mask }}' + scope: '{{ item.tenant_bd_subnet_scope }}' + with_items: '{{ aci_model_data|cisco.aci.aci_listify("tenant","bd","subnet") }}' + register: bd_subnets_listify + + - name: Create APs + cisco.aci.aci_ap: + <<: *aci_info + tenant: '{{ item.tenant_name }}' + app_profile: '{{ item.tenant_app_name }}' + with_items: '{{ aci_model_data|cisco.aci.aci_listify("tenant","app") }}' + register: ap_listify + + - name: Create EPGs + cisco.aci.aci_epg: + <<: *aci_info + tenant: '{{ item.tenant_name }}' + app_profile: '{{ item.tenant_app_name }}' + epg: '{{ item.tenant_app_epg_name }}' + bd: '{{ item.tenant_app_epg_bd }}' + with_items: '{{ aci_model_data|cisco.aci.aci_listify("tenant","app","epg") }}' + register: epg_listify + + - name: Validate listify + ansible.builtin.assert: + that: + - tenant_listify.results.0.current.0.fvTenant.attributes.name == "ansible_test" + - vrf_listify.results.0.current.0.fvCtx.attributes.name == "vrf_test" + - bd_listify.results.0.current.0.fvBD.attributes.name == "bd_test" + - bd_listify.results.1.current.0.fvBD.attributes.name == "bd_test2" + - bd_subnets_listify.results.0.current.0.fvSubnet.attributes.ip == "10.10.10.1/24" + - bd_subnets_listify.results.0.current.0.fvSubnet.attributes.scope == "private,shared" + - bd_subnets_listify.results.1.current.0.fvSubnet.attributes.ip == "20.20.20.1/24" + - bd_subnets_listify.results.1.current.0.fvSubnet.attributes.scope == "public,shared" + - ap_listify.results.0.current.0.fvAp.attributes.name == "app_test" + - epg_listify.results.0.current.0.fvAEPg.attributes.name == "web" + - epg_listify.results.1.current.0.fvAEPg.attributes.name == "app" + - tenant_listify.results.1.current.0.fvTenant.attributes.name == "ansible_test2" + - ap_listify.results.1.current.0.fvAp.attributes.name == "app_test2" + - epg_listify.results.2.current.0.fvAEPg.attributes.name == "web2" + - epg_listify.results.3.current.0.fvAEPg.attributes.name == "app2" + + # Clean Up Environment + - name: Delete tenants + cisco.aci.aci_tenant: + <<: *aci_info + tenant: "{{ item }}" + state: absent + loop: + - ansible_test + - ansible_test2 diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_firmware_group/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_firmware_group/tasks/main.yml index 5cf88997c..6f2fc7907 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_firmware_group/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_firmware_group/tasks/main.yml @@ -4,12 +4,12 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: "{{ aci_hostname }}" username: "{{ aci_username }}" @@ -20,21 +20,21 @@ output_level: debug - name: Verify Cloud and Non-Cloud Sites in use. - include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml - name: Execute tasks only for non-cloud sites when: query_cloud.current == [] # This condition will execute only non-cloud sites block: # block specifies execution of tasks within, based on conditions # Clean Environment - name: Create firmware policy - aci_firmware_policy: &aci_firmware_policy_present + cisco.aci.aci_firmware_policy: &aci_firmware_policy_present <<: *aci_info name: anstest_policy version: n9000-15.2(7) state: present - name: Ensure first firmware group does not exist - aci_firmware_group: &aci_firmware_group_absent + cisco.aci.aci_firmware_group: &aci_firmware_group_absent <<: *aci_info group: anstest_group policy: anstest_policy @@ -43,37 +43,37 @@ state: absent - name: Ensure second firmware group does not exist - aci_firmware_group: &aci_firmware_group_2_absent + cisco.aci.aci_firmware_group: &aci_firmware_group_2_absent <<: *aci_info group: anstest_group_2 policy: anstest_policy state: absent - name: Create first firmware group (check_mode) - aci_firmware_group: &aci_firmware_group_present + cisco.aci.aci_firmware_group: &aci_firmware_group_present <<: *aci_firmware_group_absent state: present check_mode: true register: cm_add_firmware_group_1 - name: Create first firmware group (normal_mode) - aci_firmware_group: + cisco.aci.aci_firmware_group: <<: *aci_firmware_group_present register: nm_add_firmware_group_1 - name: Create first firmware group again - testing idempotency - aci_firmware_group: + cisco.aci.aci_firmware_group: <<: *aci_firmware_group_present register: idempotency_add_firmware_group_1 - name: Create second firmware group - aci_firmware_group: &aci_firmware_group_2_present + cisco.aci.aci_firmware_group: &aci_firmware_group_2_present <<: *aci_firmware_group_2_absent state: present register: nm_add_firmware_group_2 - name: Asserts for creation tasks - assert: + ansible.builtin.assert: that: - cm_add_firmware_group_1 is changed - cm_add_firmware_group_1.previous == [] @@ -86,19 +86,19 @@ - nm_add_firmware_group_2 is changed - name: Query all firmware groups - aci_firmware_group: + cisco.aci.aci_firmware_group: <<: *aci_info state: query register: query_all_firmware_group - name: Query first firmware group - aci_firmware_group: + cisco.aci.aci_firmware_group: <<: *aci_firmware_group_present state: query register: query_first_firmware_group - name: Asserts for query tasks - assert: + ansible.builtin.assert: that: - query_all_firmware_group is not changed - query_all_firmware_group.current | length >= 2 @@ -110,32 +110,32 @@ - query_first_firmware_group.current.0.firmwareFwGrp.children.0.firmwareRsFwgrpp.attributes.tnFirmwareFwPName == "anstest_policy" - name: Delete first firmware group (check_mode) - aci_firmware_group: + cisco.aci.aci_firmware_group: <<: *aci_firmware_group_present state: absent check_mode: true register: cm_delete_firmware_group_1 - name: Delete first firmware group (normal_mode) - aci_firmware_group: + cisco.aci.aci_firmware_group: <<: *aci_firmware_group_present state: absent register: nm_delete_firmware_group_1 - name: Delete first firmware group again - testing idempotency - aci_firmware_group: + cisco.aci.aci_firmware_group: <<: *aci_firmware_group_present state: absent register: idempotency_delete_firmware_group_1 - name: Delete second firmware group (normal_mode) - aci_firmware_group: + cisco.aci.aci_firmware_group: <<: *aci_firmware_group_2_present state: absent register: nm_delete_firmware_group_2 - name: Asserts for deletion tasks - assert: + ansible.builtin.assert: that: - cm_delete_firmware_group_1 is changed - cm_delete_firmware_group_1.proposed == {} @@ -149,6 +149,6 @@ - nm_delete_firmware_group_2.current == [] - name: Delete firmware policy - clean up the environment - aci_firmware_policy: + cisco.aci.aci_firmware_policy: <<: *aci_firmware_policy_present state: absent diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_firmware_group_node/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_firmware_group_node/tasks/main.yml index 8da20a7ca..49cba8fa2 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_firmware_group_node/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_firmware_group_node/tasks/main.yml @@ -4,12 +4,12 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: "{{ aci_hostname }}" username: "{{ aci_username }}" @@ -20,65 +20,65 @@ output_level: debug - name: Verify Cloud and Non-Cloud Sites in use. - include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml - name: Execute tasks only for non-cloud sites when: query_cloud.current == [] # This condition will execute only non-cloud sites block: # block specifies execution of tasks within, based on conditions # Clean Environment - name: Create firmware policy exists - aci_firmware_policy: &aci_firmware_policy_present + cisco.aci.aci_firmware_policy: &aci_firmware_policy_present <<: *aci_info name: anstest_policy version: n9000-15.2(7) state: present - name: Create first firmware group - aci_firmware_group: &aci_firmware_group_present + cisco.aci.aci_firmware_group: &aci_firmware_group_present <<: *aci_info group: anstest_group firmwarepol: anstest_policy state: present - name: Ensure first firmware group node does not exist - aci_firmware_group_node: &aci_firmware_group_node_absent + cisco.aci.aci_firmware_group_node: &aci_firmware_group_node_absent <<: *aci_info group: anstest_group node: 1001 state: absent - name: Ensure second firmware group node does not exist - aci_firmware_group_node: &aci_firmware_group_node_2_absent + cisco.aci.aci_firmware_group_node: &aci_firmware_group_node_2_absent <<: *aci_info group: anstest_group node: 1002 state: absent - name: Create first firmware group node (check_mode) - aci_firmware_group_node: &aci_firmware_group_node_present + cisco.aci.aci_firmware_group_node: &aci_firmware_group_node_present <<: *aci_firmware_group_node_absent state: present check_mode: true register: cm_add_firmware_group_node_1 - name: Create first firmware group node (normal_mode) - aci_firmware_group_node: + cisco.aci.aci_firmware_group_node: <<: *aci_firmware_group_node_present register: nm_add_firmware_group_node_1 - name: Create first firmware group node again - testing idempotency - aci_firmware_group_node: + cisco.aci.aci_firmware_group_node: <<: *aci_firmware_group_node_present register: idempotency_add_firmware_group_node_1 - name: Create second firmware group node - aci_firmware_group_node: &aci_firmware_group_node_2_present + cisco.aci.aci_firmware_group_node: &aci_firmware_group_node_2_present <<: *aci_firmware_group_node_2_absent state: present register: nm_add_firmware_group_node_2 - name: Asserts for creation tasks - assert: + ansible.builtin.assert: that: - cm_add_firmware_group_node_1 is changed - cm_add_firmware_group_node_1.previous == [] @@ -93,19 +93,19 @@ - name: Query all firmware group nodes - aci_firmware_group_node: + cisco.aci.aci_firmware_group_node: <<: *aci_info state: query register: query_all_firmware_group_node - name: Query first firmware group nnode - aci_firmware_group_node: + cisco.aci.aci_firmware_group_node: <<: *aci_firmware_group_node_present state: query register: query_first_firmware_group_node - name: Asserts for query tasks - assert: + ansible.builtin.assert: that: - query_all_firmware_group_node is not changed - query_all_firmware_group_node.current | length >= 2 @@ -115,32 +115,32 @@ - query_first_firmware_group_node.current.0.fabricNodeBlk.attributes.to_ == "1001" - name: Delete first firmware group (check_mode) - aci_firmware_group_node: + cisco.aci.aci_firmware_group_node: <<: *aci_firmware_group_node_present state: absent check_mode: true register: cm_delete_firmware_group_node_1 - name: Delete first firmware group (normal_mode) - aci_firmware_group_node: + cisco.aci.aci_firmware_group_node: <<: *aci_firmware_group_node_present state: absent register: nm_delete_firmware_group_node_1 - name: Delete first firmware group again - testing idempotency - aci_firmware_group_node: + cisco.aci.aci_firmware_group_node: <<: *aci_firmware_group_node_present state: absent register: idempotency_delete_firmware_group_1 - name: Delete second firmware group (normal_mode) - aci_firmware_group_node: + cisco.aci.aci_firmware_group_node: <<: *aci_firmware_group_node_2_present state: absent register: nm_delete_firmware_group_node_2 - name: Asserts for deletion tasks - assert: + ansible.builtin.assert: that: - cm_delete_firmware_group_node_1 is changed - cm_delete_firmware_group_node_1.proposed == {} @@ -154,11 +154,11 @@ - nm_delete_firmware_group_node_2.current == [] - name: Delete firmware group - clean up the environment - aci_firmware_group: + cisco.aci.aci_firmware_group: <<: *aci_firmware_group_present state: absent - name: Delete firmware policy - clean up the environment - aci_firmware_policy: + cisco.aci.aci_firmware_policy: <<: *aci_firmware_policy_present state: absent diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_firmware_policy/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_firmware_policy/tasks/main.yml index ec0bb88ae..4b4be8ad8 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_firmware_policy/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_firmware_policy/tasks/main.yml @@ -4,12 +4,12 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: "{{ aci_hostname }}" username: "{{ aci_username }}" @@ -20,14 +20,14 @@ output_level: debug - name: Verify Cloud and Non-Cloud Sites in use. - include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml - name: Execute tasks only for non-cloud sites when: query_cloud.current == [] # This condition will execute only non-cloud sites block: # block specifies execution of tasks within, based on conditions # Clean Environment - name: Ensure first firmware policy does not exist - aci_firmware_policy: &aci_firmware_policy_absent + cisco.aci.aci_firmware_policy: &aci_firmware_policy_absent <<: *aci_info name: anstest_policy version: n9000-15.2(7) @@ -35,37 +35,37 @@ state: absent - name: Ensure second firmware policy does not exist - aci_firmware_policy: &aci_firmware_policy_2_absent + cisco.aci.aci_firmware_policy: &aci_firmware_policy_2_absent <<: *aci_info name: anstest_policy_2 version: n9000-16.0(1) state: absent - name: Create first firmware policy (check_mode) - aci_firmware_policy: &aci_firmware_policy_present + cisco.aci.aci_firmware_policy: &aci_firmware_policy_present <<: *aci_firmware_policy_absent state: present check_mode: true register: cm_add_firmware_policy_1 - name: Create first firmware policy (normal_mode) - aci_firmware_policy: + cisco.aci.aci_firmware_policy: <<: *aci_firmware_policy_present register: nm_add_firmware_policy_1 - name: Create first firmware policy again - testing idempotency - aci_firmware_policy: + cisco.aci.aci_firmware_policy: <<: *aci_firmware_policy_present register: idempotency_add_firmware_policy_1 - name: Create second firmware policy - aci_firmware_policy: &aci_firmware_policy_2_present + cisco.aci.aci_firmware_policy: &aci_firmware_policy_2_present <<: *aci_firmware_policy_2_absent state: present register: nm_add_firmware_policy_2 - name: Asserts for creation tasks - assert: + ansible.builtin.assert: that: - cm_add_firmware_policy_1 is changed - cm_add_firmware_policy_1.previous == [] @@ -81,19 +81,19 @@ - nm_add_firmware_policy_2.current.0.firmwareFwP.attributes.version == "n9000-16.0(1)" - name: Query all firmware policies - aci_firmware_policy: + cisco.aci.aci_firmware_policy: <<: *aci_info state: query register: query_all_firmware_policy - name: Query first firmware policy - aci_firmware_policy: + cisco.aci.aci_firmware_policy: <<: *aci_firmware_policy_present state: query register: query_first_firmware_policy - name: Asserts for query tasks - assert: + ansible.builtin.assert: that: - query_all_firmware_policy is not changed - query_all_firmware_policy.current | length >= 2 @@ -104,32 +104,32 @@ - query_first_firmware_policy.current.0.firmwareFwP.attributes.version == "n9000-15.2(7)" - name: Delete first firmware policy (check_mode) - aci_firmware_policy: + cisco.aci.aci_firmware_policy: <<: *aci_firmware_policy_present state: absent check_mode: true register: cm_delete_firmware_policy_1 - name: Delete first firmware policy (normal_mode) - aci_firmware_policy: + cisco.aci.aci_firmware_policy: <<: *aci_firmware_policy_present state: absent register: nm_delete_firmware_policy_1 - name: Delete first firmware policy again - testing idempotency - aci_firmware_policy: + cisco.aci.aci_firmware_policy: <<: *aci_firmware_policy_present state: absent register: idempotency_delete_firmware_policy_1 - name: Delete second firmware policy (normal_mode) - aci_firmware_policy: + cisco.aci.aci_firmware_policy: <<: *aci_firmware_policy_2_present state: absent register: nm_delete_firmware_policy_2 - name: Asserts for deletion tasks - assert: + ansible.builtin.assert: that: - cm_delete_firmware_policy_1 is changed - cm_delete_firmware_policy_1.proposed == {} diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_firmware_source/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_firmware_source/tasks/main.yml index d9287506c..a02049473 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_firmware_source/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_firmware_source/tasks/main.yml @@ -22,7 +22,7 @@ # ADD SOURCE - name: Add source (check_mode) - aci_firmware_source: &source_present + cisco.aci.aci_firmware_source: &source_present host: '{{ aci_hostname }}' username: '{{ aci_username }}' password: '{{ aci_password }}' @@ -38,12 +38,12 @@ register: cm_add_source - name: Add source (normal mode) - aci_firmware_source: + cisco.aci.aci_firmware_source: <<: *source_present register: nm_add_source - name: Verify add_source - assert: + ansible.builtin.assert: that: - cm_add_source is changed - nm_add_source is changed @@ -60,22 +60,22 @@ - nm_add_source.current.0.firmwareOSource.attributes.annotation == 'orchestrator:ansible' - name: Add source again (check_mode) - aci_firmware_source: *source_present + cisco.aci.aci_firmware_source: *source_present check_mode: true register: cm_add_source_again - name: Add source again (normal mode) - aci_firmware_source: + cisco.aci.aci_firmware_source: <<: *source_present register: nm_add_source_again - name: Verify add_source_again - assert: + ansible.builtin.assert: that: - cm_add_source_again is not changed - name: Add another source (normal mode) - aci_firmware_source: + cisco.aci.aci_firmware_source: <<: *source_present source: ansible_test_2 register: nm_add_source @@ -99,7 +99,7 @@ register: nm_query_all_sources - name: Verify query_all_sources - assert: + ansible.builtin.assert: that: - cm_query_all_sources is not changed - nm_query_all_sources is not changed @@ -108,20 +108,20 @@ # QUERY A SOURCE - name: Query our source (check_mode) - aci_firmware_source: + cisco.aci.aci_firmware_source: <<: *source_query source: ansible_test_1 check_mode: true register: cm_query_source - name: Query our source (normal mode) - aci_firmware_source: + cisco.aci.aci_firmware_source: <<: *source_query source: ansible_test_1 register: nm_query_source - name: Verify query_source - assert: + ansible.builtin.assert: that: - cm_query_source is not changed - nm_query_source is not changed @@ -131,7 +131,7 @@ # REMOVE SOURCE - name: Remove source (check_mode) - aci_firmware_source: &source_remove + cisco.aci.aci_firmware_source: &source_remove <<: *source_query source: ansible_test_1 state: absent @@ -139,11 +139,11 @@ register: cm_remove_source - name: Remove source (normal mode) - aci_firmware_source: *source_remove + cisco.aci.aci_firmware_source: *source_remove register: nm_remove_source - name: Verify remove_source - assert: + ansible.builtin.assert: that: - cm_remove_source is changed - nm_remove_source is changed @@ -151,36 +151,36 @@ - nm_remove_source.current == [] - name: Remove source again (check_mode) - aci_firmware_source: *source_remove + cisco.aci.aci_firmware_source: *source_remove check_mode: true register: cm_remove_source_again - name: Remove source again (normal mode) - aci_firmware_source: *source_remove + cisco.aci.aci_firmware_source: *source_remove register: nm_remove_source_again - name: Verify remove_source_again - assert: + ansible.builtin.assert: that: - cm_remove_source_again is not changed - nm_remove_source_again is not changed # QUERY NON-EXISTING SOURCE - name: Query non-existing source (check_mode) - aci_firmware_source: + cisco.aci.aci_firmware_source: <<: *source_query source: non_existing_source check_mode: true register: cm_query_non_source - name: Query non-existing source (normal mode) - aci_firmware_source: + cisco.aci.aci_firmware_source: <<: *source_query source: non_existing_source register: nm_query_non_source - name: Verify query_non_source - assert: + ansible.builtin.assert: that: - cm_query_non_source is not changed - nm_query_non_source is not changed @@ -202,7 +202,7 @@ register: error_on_missing_required_param - name: Verify error_on_missing_required_param - assert: + ansible.builtin.assert: that: - error_on_missing_required_param is failed - 'error_on_missing_required_param.msg == "state is present but all of the following are missing: source, url"' diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_igmp_interface_policy/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_igmp_interface_policy/tasks/main.yml index eac9daf6b..5e5be5de7 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_igmp_interface_policy/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_igmp_interface_policy/tasks/main.yml @@ -4,12 +4,12 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: "{{ aci_hostname }}" port: "{{ aci_port | default(omit) }}" diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_interface_blacklist/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_interface_blacklist/tasks/main.yml index 17e0bb67c..de24043b7 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_interface_blacklist/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_interface_blacklist/tasks/main.yml @@ -4,12 +4,12 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: "{{ aci_hostname }}" username: "{{ aci_username }}" @@ -33,14 +33,14 @@ fex_id: 123 - name: Query system information - aci_system: + cisco.aci.aci_system: <<: *aci_info id: 1 state: query register: version - name: Verify Cloud and Non-Cloud Sites in use. - include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml - name: Execute tasks only for non-cloud sites when: query_cloud.current == [] # This condition will execute only non-cloud sites @@ -53,11 +53,11 @@ register: enable_and_clear - name: set regex - set_fact: + ansible.builtin.set_fact: regexp: '(topology/pod-)(\d)(/paths-)(\d*)(/pathep-\[eth)(.*)(])' - name: Save Target DNs - set_fact: + ansible.builtin.set_fact: tdn: "{{ item.fabricRsOosPath.attributes.tDn }}" loop: "{{ enable_and_clear.current }}" register: enabled_tdn @@ -105,7 +105,7 @@ register: query_leaf_int_enabled - name: Leaf - Verify that outofsvc_interface_blacklist is not present - assert: + ansible.builtin.assert: that: - query_leaf_int_enabled.current.0.fabricOOServicePol.children is not defined @@ -118,7 +118,7 @@ register: disable_leaf_int_check - name: Leaf - Verify that outofsvc_interface_blacklist is not created after check mode - assert: + ansible.builtin.assert: that: - disable_leaf_int_check.current.0.fabricOOServicePol.children is not defined @@ -130,7 +130,7 @@ register: disable_leaf_int - name: Leaf - Verify that outofsvc_interface_blacklist is created - assert: + ansible.builtin.assert: that: - disable_leaf_int.current|length == 1 - disable_leaf_int.current.0.fabricRsOosPath.attributes.tDn == "topology/pod-1/paths-1101/pathep-[eth1/33]" @@ -145,7 +145,7 @@ register: disable_leaf_int_again - name: Leaf - Verify that outofsvc_interface_blacklist remains created after disabling again - assert: + ansible.builtin.assert: that: - disable_leaf_int_again is not changed - disable_leaf_int_again.current|length == 1 @@ -160,7 +160,7 @@ register: query_leaf_int_disabled - name: Leaf - Verify that outofsvc_interface_blacklist remains created after query - assert: + ansible.builtin.assert: that: - query_leaf_int_disabled is not changed - query_leaf_int_disabled.current|length == 1 @@ -176,7 +176,7 @@ register: enable_leaf_int_check - name: Leaf - Verify that outofsvc_interface_blacklist remains created after check mode - assert: + ansible.builtin.assert: that: - enable_leaf_int_check.current|length == 1 - enable_leaf_int_check.current.0.fabricRsOosPath.attributes.tDn == "topology/pod-1/paths-1101/pathep-[eth1/33]" @@ -190,7 +190,7 @@ register: enable_leaf_int - name: Leaf - Verify that outofsvc_interface_blacklist is deleted - assert: + ansible.builtin.assert: that: - enable_leaf_int.current.0.fabricOOServicePol.children is not defined @@ -202,7 +202,7 @@ register: enable_leaf_int_again - name: Leaf - Verify that outofsvc_interface_blacklist remains deleted after enabling again - assert: + ansible.builtin.assert: that: - enable_leaf_int_again is not changed - enable_leaf_int_again.current.0.fabricOOServicePol.children is not defined @@ -221,7 +221,7 @@ register: query_spine_int_enabled - name: Spine - Verify that outofsvc_interface_blacklist is not present - assert: + ansible.builtin.assert: that: - query_spine_int_enabled.current.0.fabricOOServicePol.children is not defined @@ -234,7 +234,7 @@ register: disable_spine_int_check - name: Spine - Verify that outofsvc_interface_blacklist is not created after check mode - assert: + ansible.builtin.assert: that: - disable_spine_int_check.current.0.fabricOOServicePol.children is not defined @@ -246,7 +246,7 @@ register: disable_spine_int - name: Spine - Verify that outofsvc_interface_blacklist is created - assert: + ansible.builtin.assert: that: - disable_spine_int.current|length == 1 - disable_spine_int.current.0.fabricRsOosPath.attributes.tDn == "topology/pod-1/paths-1201/pathep-[eth1/33]" @@ -260,7 +260,7 @@ register: disable_spine_int_again - name: Spine - Verify that outofsvc_interface_blacklist remains created after disabling again - assert: + ansible.builtin.assert: that: - disable_spine_int_again is not changed - disable_spine_int_again.current|length == 1 @@ -275,7 +275,7 @@ register: query_spine_int_disabled - name: Spine - Verify that outofsvc_interface_blacklist remains created after query - assert: + ansible.builtin.assert: that: - query_spine_int_disabled is not changed - query_spine_int_disabled.current|length == 1 @@ -291,7 +291,7 @@ register: enable_spine_int_check - name: Spine - Verify that outofsvc_interface_blacklist remains created after check mode - assert: + ansible.builtin.assert: that: - enable_spine_int_check.current|length == 1 - enable_spine_int_check.current.0.fabricRsOosPath.attributes.tDn == "topology/pod-1/paths-1201/pathep-[eth1/33]" @@ -305,7 +305,7 @@ register: enable_spine_int - name: Spine - Verify that outofsvc_interface_blacklist is deleted - assert: + ansible.builtin.assert: that: - enable_spine_int.current.0.fabricOOServicePol.children is not defined @@ -317,7 +317,7 @@ register: enable_spine_int_again - name: Spine - Verify that outofsvc_interface_blacklist remains deleted after enabling again - assert: + ansible.builtin.assert: that: - enable_spine_int_again is not changed - enable_spine_int_again.current.0.fabricOOServicePol.children is not defined @@ -336,7 +336,7 @@ register: query_fex_int_enabled - name: Fex - Verify that outofsvc_interface_blacklist is not present - assert: + ansible.builtin.assert: that: - query_fex_int_enabled.current.0.fabricOOServicePol.children is not defined @@ -349,7 +349,7 @@ register: disable_fex_int_check - name: Fex - Verify that outofsvc_interface_blacklist is not created after check mode - assert: + ansible.builtin.assert: that: - disable_fex_int_check.current.0.fabricOOServicePol.children is not defined @@ -361,7 +361,7 @@ register: disable_fex_int - name: Fex - Verify that outofsvc_interface_blacklist is created - assert: + ansible.builtin.assert: that: - disable_fex_int.current|length == 1 - disable_fex_int.current.0.fabricRsOosPath.attributes.tDn == "topology/pod-1/paths-1101/extpaths-123/pathep-[eth1/33]" @@ -375,7 +375,7 @@ register: disable_fex_int_again - name: Fex - Verify that outofsvc_interface_blacklist remains created after disabling again - assert: + ansible.builtin.assert: that: - disable_fex_int_again is not changed - disable_fex_int_again.current|length == 1 @@ -390,7 +390,7 @@ register: query_fex_int_disabled - name: Fex - Verify that outofsvc_interface_blacklist remains created after query - assert: + ansible.builtin.assert: that: - query_fex_int_disabled is not changed - query_fex_int_disabled.current|length == 1 @@ -406,7 +406,7 @@ register: enable_fex_int_check - name: Fex - Verify that outofsvc_interface_blacklist remains created after check mode - assert: + ansible.builtin.assert: that: - enable_fex_int_check.current|length == 1 - enable_fex_int_check.current.0.fabricRsOosPath.attributes.tDn == "topology/pod-1/paths-1101/extpaths-123/pathep-[eth1/33]" @@ -420,7 +420,7 @@ register: enable_fex_int - name: Fex - Verify that outofsvc_interface_blacklist is deleted - assert: + ansible.builtin.assert: that: - enable_fex_int.current.0.fabricOOServicePol.children is not defined @@ -432,7 +432,7 @@ register: enable_fex_int_again - name: Fex - Verify that outofsvc_interface_blacklist remains deleted after enabling again - assert: + ansible.builtin.assert: that: - enable_fex_int_again is not changed - enable_fex_int_again.current.0.fabricOOServicePol.children is not defined @@ -462,7 +462,7 @@ register: query_all_disabled - name: All - Verify that multiple outofsvc_interface_blacklist exist - assert: + ansible.builtin.assert: that: - query_all_disabled is not changed - query_all_disabled.current | length == 3 @@ -492,7 +492,7 @@ register: query_all_enabled - name: All - Verify that no outofsvc_interface_blacklist exist - assert: + ansible.builtin.assert: that: - query_all_enabled is not changed - query_all_enabled.current == [] diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_interface_config/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_interface_config/tasks/main.yml index 3e8ebcb82..b9bf19f61 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_interface_config/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_interface_config/tasks/main.yml @@ -4,12 +4,12 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: "{{ aci_hostname }}" username: "{{ aci_username }}" @@ -28,7 +28,7 @@ register: version - name: Verify Cloud and Non-Cloud Sites in use. - include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml - name: Execute tasks only for ACI v6+ and non-cloud sites when: @@ -74,7 +74,7 @@ ignore_errors: true - name: Assertions check for the invalid tasks - assert: + ansible.builtin.assert: that: - invalid_interface_absent.msg is match("state is absent but all of the following are missing{{':'}} node") - invalid_interface_details is not changed @@ -128,7 +128,7 @@ ignore_errors: true - name: Assertions check for invalid interface configuration tasks - assert: + ansible.builtin.assert: that: - invalid_node is not changed - invalid_node.msg is match("^Node ID{{':'}} .+? is invalid; it must be in the range of 101 to 4000.") @@ -169,7 +169,7 @@ register: nm_interface_501_present - name: Assertions check for an interface 501 - assert: + ansible.builtin.assert: that: - interface_501_absent.current == [] - cm_interface_501_present is changed @@ -213,7 +213,7 @@ register: nm_interface_502_present - name: Assertions check for an interface 502 - assert: + ansible.builtin.assert: that: - interface_502_absent.current == [] - cm_interface_502_present is changed @@ -257,7 +257,7 @@ register: nm_interface_505_present - name: Assertions check for an interface 505 - assert: + ansible.builtin.assert: that: - interface_505_absent.current == [] - cm_interface_505_present is changed @@ -301,7 +301,7 @@ register: nm_interface_506_present - name: Assertions check for an interface 506 - assert: + ansible.builtin.assert: that: - interface_506_absent.current == [] - cm_interface_506_present is changed @@ -345,7 +345,7 @@ register: nm_interface_507_present - name: Assertions check for an interface 507 - assert: + ansible.builtin.assert: that: - interface_507_absent.current == [] - cm_interface_507_present is changed @@ -385,7 +385,7 @@ register: nm_interface_508_present - name: Assertions check for an interface 508 - assert: + ansible.builtin.assert: that: - interface_508_absent.current == [] - cm_interface_508_present is changed @@ -431,7 +431,7 @@ register: idm_interface_509_present - name: Assertions check for an interface 509 - assert: + ansible.builtin.assert: that: - interface_509_absent.current == [] - cm_interface_509_present is changed @@ -493,7 +493,7 @@ register: idm_breakout_501_present - name: Assertions check for convert the interface 501 to breakout(100g-4x) - assert: + ansible.builtin.assert: that: - invalid_breakout_501_present is not changed - invalid_breakout_501_present.msg == "parameters are mutually exclusive{{':'}} policy_group|breakout" @@ -524,7 +524,7 @@ register: query_all_access_interfaces - name: Assertions check for query all access interfaces - assert: + ansible.builtin.assert: that: - query_all_access_interfaces is not changed - query_all_access_interfaces.current|length >= 5 @@ -537,7 +537,7 @@ register: query_all_fabric_interfaces - name: Assertions check for query all fabric interfaces - assert: + ansible.builtin.assert: that: - query_all_fabric_interfaces is not changed - query_all_fabric_interfaces.current|length >= 2 @@ -551,7 +551,7 @@ register: query_access_interface_502 - name: Assertions check for query a access interface with node id 502 - assert: + ansible.builtin.assert: that: - query_access_interface_502 is not changed - query_access_interface_502.current|length == 1 @@ -570,7 +570,7 @@ register: query_access_fabric_509 - name: Assertions check for query a fabric interface with node id 509 - assert: + ansible.builtin.assert: that: - query_access_fabric_509 is not changed - query_access_fabric_509.current|length == 1 @@ -617,7 +617,7 @@ register: rm_interface_508_present - name: Assertions check for remove Interfaces 501 to 508 - assert: + ansible.builtin.assert: that: - rm_interface_501_present is changed - rm_interface_501_present.current == [] @@ -646,7 +646,7 @@ register: nm_rm_interface_509_present - name: Assertions check for remove Interface 509 - assert: + ansible.builtin.assert: that: - cm_rm_interface_509_present is changed - cm_rm_interface_509_present.current != [] @@ -660,7 +660,7 @@ register: idm_rm_interface_509_present - name: Assertions check for remove Interface 509 with idempotency check - assert: + ansible.builtin.assert: that: - idm_rm_interface_509_present is not changed - idm_rm_interface_509_present.current == [] @@ -674,7 +674,7 @@ register: query_interface_509 - name: Assertions check for query an interface 509 after removed from the APIC - assert: + ansible.builtin.assert: that: - query_interface_509 is not changed - query_interface_509.current == [] diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_interface_description/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_interface_description/tasks/main.yml index ec4f0250d..474603c12 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_interface_description/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_interface_description/tasks/main.yml @@ -4,12 +4,12 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: "{{ aci_hostname }}" username: "{{ aci_username }}" @@ -20,7 +20,7 @@ output_level: debug - name: Node types - set_fact: + ansible.builtin.set_fact: test_vars_leaf: &test_vars_leaf pod_id: 1 node_id: 1101 @@ -41,7 +41,7 @@ description: testing - name: Verify Cloud and Non-Cloud Sites in use. - include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml - name: Execute tasks only for non-cloud sites when: query_cloud.current == [] # This condition will execute only non-cloud sites @@ -72,7 +72,7 @@ register: query_leaf_description - name: Leaf - Verify that no infraHPathS is present - assert: + ansible.builtin.assert: that: - query_leaf_description.current.0.infraInfra.children.0.infraHPathS.children is not defined @@ -84,7 +84,7 @@ register: set_leaf_description - name: Leaf - Verify that description is set on interface - assert: + ansible.builtin.assert: that: - set_leaf_description.current|length == 1 - set_leaf_description.current.0.infraHPathS.children.0.infraRsHPathAtt.attributes.tDn == "topology/pod-1/paths-1101/pathep-[eth1/33]" @@ -99,7 +99,7 @@ register: query_leaf_interface_1101_eth1_33 - name: Assertion check for query Leaf interface - 1101_eth1_33 - assert: + ansible.builtin.assert: that: - query_leaf_interface_1101_eth1_33.current.0.infraHPathS.children | length == 1 - query_leaf_interface_1101_eth1_33.current.0.infraHPathS.children.0.infraRsHPathAtt.attributes.rn == "rsHPathAtt-[topology/pod-1/paths-1101/pathep-[eth1/33]]" @@ -115,7 +115,7 @@ register: query_all_leaf_interfaces - name: Verify query all leaf interfaces - assert: + ansible.builtin.assert: that: - query_all_leaf_interfaces.current | length > 1 - query_all_leaf_interfaces.current.1.infraHPathS.children.0.infraRsHPathAtt.attributes.rn == "rsHPathAtt-[topology/pod-1/paths-1101/pathep-[eth1/33]]" @@ -137,7 +137,7 @@ register: query_leaf_description_again - name: Leaf - Verify that no infraHPathS is present - assert: + ansible.builtin.assert: that: - query_leaf_description_again.current.0.infraInfra.children.0.infraHPathS.children is not defined @@ -155,7 +155,7 @@ register: query_spine_description - name: Spine - Verify that no infraSHPathS is present - assert: + ansible.builtin.assert: that: - query_spine_description.current.0.infraInfra.children.0.infraSHPathS.children is not defined @@ -167,7 +167,7 @@ register: set_spine_description - name: Spine - Verify that description is set on interface - assert: + ansible.builtin.assert: that: - set_spine_description.current|length == 1 - set_spine_description.current.0.infraSHPathS.children.0.infraRsSHPathAtt.attributes.tDn == "topology/pod-1/paths-1201/pathep-[eth1/33]" @@ -181,7 +181,7 @@ register: query_spine_interface_1201_eth1_33 - name: Assertion check for query Spine interface - 1201_eth1_33 - assert: + ansible.builtin.assert: that: - query_spine_interface_1201_eth1_33.current.0.infraSHPathS.children | length == 1 - query_spine_interface_1201_eth1_33.current.0.infraSHPathS.children.0.infraRsSHPathAtt.attributes.rn == "rsSHPathAtt-[topology/pod-1/paths-1201/pathep-[eth1/33]]" @@ -197,7 +197,7 @@ register: query_all_spine_interfaces - name: Verify query all spine interfaces - assert: + ansible.builtin.assert: that: - query_all_spine_interfaces.current | length >= 1 - query_all_spine_interfaces.current.1.infraSHPathS.children.0.infraRsSHPathAtt.attributes.rn == "rsSHPathAtt-[topology/pod-1/paths-1201/pathep-[eth1/33]]" @@ -219,7 +219,7 @@ register: query_spine_description_again - name: Spine - Verify that no infraSHPathS is present - assert: + ansible.builtin.assert: that: - query_spine_description_again.current.0.infraInfra.children.0.infraSHPathS.children is not defined @@ -237,7 +237,7 @@ register: query_fex_description - name: Fex - Verify that no infraHPathS is present - assert: + ansible.builtin.assert: that: - query_fex_description.current.0.infraInfra.children.0.infraHPathS.children is not defined @@ -249,7 +249,7 @@ register: set_fex_description - name: Fex - Verify that description is set on interface - assert: + ansible.builtin.assert: that: - set_fex_description.current|length == 1 - set_fex_description.current.0.infraHPathS.children.0.infraRsHPathAtt.attributes.tDn == "topology/pod-1/paths-1101/extpaths-123/pathep-[eth1/33]" @@ -263,7 +263,7 @@ register: query_fex_interface_1201_eth1_33 - name: Assertion check for query Fex interface - 1101_eth123_1_33 - assert: + ansible.builtin.assert: that: - query_fex_interface_1201_eth1_33.current.0.infraHPathS.children | length == 1 - query_fex_interface_1201_eth1_33.current.0.infraHPathS.children.0.infraRsHPathAtt.attributes.rn == "rsHPathAtt-[topology/pod-1/paths-1101/extpaths-123/pathep-[eth1/33]]" @@ -284,6 +284,6 @@ register: query_fex_description_again - name: Fex - Verify that no infraHPathS is present - assert: + ansible.builtin.assert: that: - query_fex_description_again.current.0.infraInfra.children.0.infraHPathS.children is not defined diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_interface_policy_bfd/aliases b/ansible_collections/cisco/aci/tests/integration/targets/aci_interface_policy_bfd/aliases new file mode 100644 index 000000000..209b793f9 --- /dev/null +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_interface_policy_bfd/aliases @@ -0,0 +1,2 @@ +# No ACI simulator yet, so not enabled +# unsupported diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_interface_policy_bfd/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_interface_policy_bfd/tasks/main.yml new file mode 100644 index 000000000..2d688f2c6 --- /dev/null +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_interface_policy_bfd/tasks/main.yml @@ -0,0 +1,245 @@ +# Test code for the ACI modules +# Copyright: (c) 2023, Anvitha Jain (@anvjain) + +# 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 APIC host, ACI username and ACI password + fail: + msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' + when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined + +- name: Set vars + ansible.builtin.set_fact: + aci_info: &aci_info + host: "{{ aci_hostname }}" + username: "{{ aci_username }}" + password: "{{ aci_password }}" + validate_certs: '{{ aci_validate_certs | default(false) }}' + use_ssl: '{{ aci_use_ssl | default(true) }}' + use_proxy: '{{ aci_use_proxy | default(true) }}' + output_level: debug + +- name: Query system information + cisco.aci.aci_system: + <<: *aci_info + id: 1 + state: query + register: version + +- name: Execute tasks only for non-cloud sites + when: version.current.0.topSystem.attributes.version is version('5.2', '>=') # This condition will execute only when APIC version >= 5.2 + block: # block specifies execution of tasks within, based on conditions + + # CLEAN ENVIRONMENT + - name: Remove the ansible_tenant + cisco.aci.aci_tenant: + <<: *aci_info + tenant: ansible_tenant + state: absent + + - name: Add a new tenant + cisco.aci.aci_tenant: + <<: *aci_info + tenant: ansible_tenant + description: Ansible tenant + state: present + + # CREATE BFD Interface policy + - name: Add a new BFD Interface policy - check mode + cisco.aci.aci_interface_policy_bfd: &add_bfd_interface_pol + <<: *aci_info + tenant: ansible_tenant + name: ansible_bfd_interface_policy + description: Ansible BFD Interface Policy + state: present + check_mode: true + register: cm_add_bfd_interface_pol + + - name: Add a new BFD Interface policy - normal mode + cisco.aci.aci_interface_policy_bfd: + <<: *add_bfd_interface_pol + state: present + register: nm_add_bfd_interface_pol + + - name: Verify BFD Interface Policy creation + assert: + that: + - cm_add_bfd_interface_pol is changed + - nm_add_bfd_interface_pol is changed + - cm_add_bfd_interface_pol.previous == nm_add_bfd_interface_pol.previous == [] + - cm_add_bfd_interface_pol.proposed.bfdIfPol.attributes.dn == nm_add_bfd_interface_pol.current.0.bfdIfPol.attributes.dn == "uni/tn-ansible_tenant/bfdIfPol-ansible_bfd_interface_policy" + - cm_add_bfd_interface_pol.proposed.bfdIfPol.attributes.name == nm_add_bfd_interface_pol.current.0.bfdIfPol.attributes.name == "ansible_bfd_interface_policy" + - cm_add_bfd_interface_pol.proposed.bfdIfPol.attributes.descr == nm_add_bfd_interface_pol.current.0.bfdIfPol.attributes.descr == "Ansible BFD Interface Policy" + + - name: Add a new BFD Interface policy again - idempotency + cisco.aci.aci_interface_policy_bfd: + <<: *add_bfd_interface_pol + state: present + register: add_bfd_interface_pol_again + + - name: Verify BFD Interface Policy creation again - idempotency + assert: + that: + - add_bfd_interface_pol_again is not changed + - add_bfd_interface_pol_again.previous != [] + - add_bfd_interface_pol_again.current | length == 1 + - add_bfd_interface_pol_again.previous | length == 1 + + - name: Modify a BFD Interface policy + cisco.aci.aci_interface_policy_bfd: + <<: *add_bfd_interface_pol + admin_state: disabled + detection_multiplier: 5 + min_transmit_interval: 270 + min_receive_interval: 500 + state: present + register: update_bfd_interface_pol + + - name: Verify modifying BFD Interface Policy + assert: + that: + - update_bfd_interface_pol is changed + - update_bfd_interface_pol.previous != update_bfd_interface_pol.current + - update_bfd_interface_pol.current.0.bfdIfPol.attributes.dn == "uni/tn-ansible_tenant/bfdIfPol-ansible_bfd_interface_policy" + - update_bfd_interface_pol.current.0.bfdIfPol.attributes.name == "ansible_bfd_interface_policy" + - update_bfd_interface_pol.current.0.bfdIfPol.attributes.descr == "Ansible BFD Interface Policy" + - update_bfd_interface_pol.current.0.bfdIfPol.attributes.adminSt == "disabled" + - update_bfd_interface_pol.current.0.bfdIfPol.attributes.detectMult == "5" + - update_bfd_interface_pol.current.0.bfdIfPol.attributes.minRxIntvl == "500" + - update_bfd_interface_pol.current.0.bfdIfPol.attributes.minTxIntvl == "270" + + # Added another BFD Interface policy + - name: Add a new BFD Interface policy - normal mode + cisco.aci.aci_interface_policy_bfd: + <<: *add_bfd_interface_pol + name: ansible_bfd_interface_policy_2 + state: present + register: add_bfd_interface_pol_2 + + - name: Verify BFD Interface Policy creation + assert: + that: + - add_bfd_interface_pol_2 is changed + - add_bfd_interface_pol_2.previous == [] + - add_bfd_interface_pol_2.current.0.bfdIfPol.attributes.dn == "uni/tn-ansible_tenant/bfdIfPol-ansible_bfd_interface_policy_2" + - add_bfd_interface_pol_2.current.0.bfdIfPol.attributes.name == "ansible_bfd_interface_policy_2" + - add_bfd_interface_pol_2.current.0.bfdIfPol.attributes.descr == "Ansible BFD Interface Policy" + - add_bfd_interface_pol_2.current.0.bfdIfPol.attributes.adminSt == "enabled" + - add_bfd_interface_pol_2.current.0.bfdIfPol.attributes.detectMult == "3" + - add_bfd_interface_pol_2.current.0.bfdIfPol.attributes.minRxIntvl == "50" + - add_bfd_interface_pol_2.current.0.bfdIfPol.attributes.minTxIntvl == "50" + + - name: Query all BFD Interface policies in a specific tenant + cisco.aci.aci_interface_policy_bfd: + <<: *aci_info + tenant: ansible_tenant + state: query + register: query_all_result + + - name: Verify querying all BFD Interface Policies + assert: + that: + - query_all_result is not changed + - query_all_result.current.0.fvTenant.children | length == 2 + - query_all_result.current.0.fvTenant.children[0].bfdIfPol.attributes.name == "ansible_bfd_interface_policy_2" + - query_all_result.current.0.fvTenant.children[1].bfdIfPol.attributes.name == "ansible_bfd_interface_policy" + + - name: Query 'ansible_bfd_interface_policy' BFD Interface policies in a specific tenant + cisco.aci.aci_interface_policy_bfd: + <<: *aci_info + tenant: ansible_tenant + name: ansible_bfd_interface_policy + state: query + register: query_result + + - name: Verify querying'ansible_bfd_interface_policy BFD' Multihop Interface Policy + assert: + that: + - query_result is not changed + - query_result.current.0.bfdIfPol.attributes.dn == "uni/tn-ansible_tenant/bfdIfPol-ansible_bfd_interface_policy" + - query_result.current.0.bfdIfPol.attributes.name == "ansible_bfd_interface_policy" + + - name: Remove a BFD Interface policy - check mode + cisco.aci.aci_interface_policy_bfd: + <<: *aci_info + tenant: ansible_tenant + name: ansible_bfd_interface_policy + state: absent + check_mode: true + register: cm_remove_bfd_interface_pol + + - name: Remove a BFD Interface policy - normal mode + cisco.aci.aci_interface_policy_bfd: + <<: *aci_info + tenant: ansible_tenant + name: ansible_bfd_interface_policy + state: absent + register: nm_remove_bfd_interface_pol + + - name: Remove a BFD Interface policy again + cisco.aci.aci_interface_policy_bfd: + <<: *aci_info + tenant: ansible_tenant + name: ansible_bfd_interface_policy + state: absent + register: remove_bfd_interface_pol_again + + - name: Verify removing BFD Interface Policies + assert: + that: + - nm_remove_bfd_interface_pol is changed + - cm_remove_bfd_interface_pol is changed + - cm_remove_bfd_interface_pol.proposed == {} + - nm_remove_bfd_interface_pol.previous != [] + - remove_bfd_interface_pol_again is not changed + - nm_remove_bfd_interface_pol.current == remove_bfd_interface_pol_again.current == [] + +# Validating out of range parameters. + +# Added BFD Interface policy with out of the range detection_multiplier + - name: Add a new BFD Interface policy - out of the range detection_multiplier + cisco.aci.aci_interface_policy_bfd: + <<: *add_bfd_interface_pol + name: ansible_bfd_interface_policy_3 + detection_multiplier: 256 + state: present + ignore_errors: true + register: add_bfd_interface_pol_3 + + - name: Verify BFD Interface Policy creation + assert: + that: + - add_bfd_interface_pol_3 is not changed + - add_bfd_interface_pol_3.msg == "The \"detection_multiplier\" must be a value between 1 and 50" + +# Added BFD Interface policy with out of the range min_transmit_interval + - name: Add a new BFD Interface policy - out of the range min_transmit_interval + cisco.aci.aci_interface_policy_bfd: + <<: *add_bfd_interface_pol + name: ansible_bfd_interface_policy_3 + min_transmit_interval: 10 + state: present + ignore_errors: true + register: add_bfd_interface_pol_3 + + - name: Verify BFD Interface Policy creation + assert: + that: + - add_bfd_interface_pol_3 is not changed + - add_bfd_interface_pol_3.msg == "The \"min_transmit_interval\" must be a value between 50 and 999" + +# Added BFD Interface policy with out of the range min_receive_interval + - name: Add a new BFD Interface policy - out of the range min_receive_interval + cisco.aci.aci_interface_policy_bfd: + <<: *add_bfd_interface_pol + name: ansible_bfd_interface_policy_3 + min_receive_interval: 1000 + state: present + ignore_errors: true + register: add_bfd_interface_pol_3 + + - name: Verify BFD Interface Policy creation + assert: + that: + - add_bfd_interface_pol_3 is not changed + - add_bfd_interface_pol_3.msg == "The \"min_receive_interval\" must be a value between 50 and 999"
\ No newline at end of file diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_interface_policy_bfd_multihop/aliases b/ansible_collections/cisco/aci/tests/integration/targets/aci_interface_policy_bfd_multihop/aliases new file mode 100644 index 000000000..209b793f9 --- /dev/null +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_interface_policy_bfd_multihop/aliases @@ -0,0 +1,2 @@ +# No ACI simulator yet, so not enabled +# unsupported diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_interface_policy_bfd_multihop/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_interface_policy_bfd_multihop/tasks/main.yml new file mode 100644 index 000000000..8454803ec --- /dev/null +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_interface_policy_bfd_multihop/tasks/main.yml @@ -0,0 +1,245 @@ +# Test code for the ACI modules +# Copyright: (c) 2023, Anvitha Jain (@anvjain) + +# 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 APIC host, ACI username and ACI password + fail: + msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' + when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined + +- name: Set vars + ansible.builtin.set_fact: + aci_info: &aci_info + host: "{{ aci_hostname }}" + username: "{{ aci_username }}" + password: "{{ aci_password }}" + validate_certs: '{{ aci_validate_certs | default(false) }}' + use_ssl: '{{ aci_use_ssl | default(true) }}' + use_proxy: '{{ aci_use_proxy | default(true) }}' + output_level: debug + +- name: Query system information + cisco.aci.aci_system: + <<: *aci_info + id: 1 + state: query + register: version + +- name: Execute tasks only for non-cloud sites + when: version.current.0.topSystem.attributes.version is version('5.2', '>=') # This condition will execute only when APIC version >= 5.2 + block: # block specifies execution of tasks within, based on conditions + + # CLEAN ENVIRONMENT + - name: Remove the ansible_tenant + aci_tenant: + <<: *aci_info + tenant: ansible_tenant + state: absent + + - name: Add a new tenant + aci_tenant: + <<: *aci_info + tenant: ansible_tenant + description: Ansible tenant + state: present + + # CREATE BFD Multihop Interface policy + - name: Add a new BFD Multihop Interface policy - check mode + cisco.aci.aci_interface_policy_bfd_multihop: &add_bfd_multihop_interface_pol + <<: *aci_info + tenant: ansible_tenant + name: ansible_bfd_multihop_interface_policy + description: Ansible BFD Multihop Interface Policy + state: present + check_mode: true + register: cm_add_bfd_multihop_interface_pol + + - name: Add a new BFD Multihop Interface policy - normal mode + cisco.aci.aci_interface_policy_bfd_multihop: + <<: *add_bfd_multihop_interface_pol + state: present + register: nm_add_bfd_multihop_interface_pol + + - name: Verify BFD Multihop Interface Policy creation + assert: + that: + - cm_add_bfd_multihop_interface_pol is changed + - nm_add_bfd_multihop_interface_pol is changed + - cm_add_bfd_multihop_interface_pol.previous == nm_add_bfd_multihop_interface_pol.previous == [] + - cm_add_bfd_multihop_interface_pol.proposed.bfdMhIfPol.attributes.dn == nm_add_bfd_multihop_interface_pol.current.0.bfdMhIfPol.attributes.dn == "uni/tn-ansible_tenant/bfdMhIfPol-ansible_bfd_multihop_interface_policy" + - cm_add_bfd_multihop_interface_pol.proposed.bfdMhIfPol.attributes.name == nm_add_bfd_multihop_interface_pol.current.0.bfdMhIfPol.attributes.name == "ansible_bfd_multihop_interface_policy" + - cm_add_bfd_multihop_interface_pol.proposed.bfdMhIfPol.attributes.descr == nm_add_bfd_multihop_interface_pol.current.0.bfdMhIfPol.attributes.descr == "Ansible BFD Multihop Interface Policy" + + - name: Add a new BFD Multihop Interface policy again - idempotency + cisco.aci.aci_interface_policy_bfd_multihop: + <<: *add_bfd_multihop_interface_pol + state: present + register: add_bfd_multihop_interface_pol_again + + - name: Verify BFD Multihop Interface Policy creation again - idempotency + assert: + that: + - add_bfd_multihop_interface_pol_again is not changed + - add_bfd_multihop_interface_pol_again.previous != [] + - add_bfd_multihop_interface_pol_again.current | length == 1 + - add_bfd_multihop_interface_pol_again.previous | length == 1 + + - name: Modify a BFD Multihop Interface policy + cisco.aci.aci_interface_policy_bfd_multihop: + <<: *add_bfd_multihop_interface_pol + admin_state: disabled + detection_multiplier: 5 + min_transmit_interval: 270 + min_receive_interval: 500 + state: present + register: update_bfd_multihop_interface_pol + + - name: Verify modifying BFD Multihop Interface Policy + assert: + that: + - update_bfd_multihop_interface_pol is changed + - update_bfd_multihop_interface_pol.previous != update_bfd_multihop_interface_pol.current + - update_bfd_multihop_interface_pol.current.0.bfdMhIfPol.attributes.dn == "uni/tn-ansible_tenant/bfdMhIfPol-ansible_bfd_multihop_interface_policy" + - update_bfd_multihop_interface_pol.current.0.bfdMhIfPol.attributes.name == "ansible_bfd_multihop_interface_policy" + - update_bfd_multihop_interface_pol.current.0.bfdMhIfPol.attributes.descr == "Ansible BFD Multihop Interface Policy" + - update_bfd_multihop_interface_pol.current.0.bfdMhIfPol.attributes.adminSt == "disabled" + - update_bfd_multihop_interface_pol.current.0.bfdMhIfPol.attributes.detectMult == "5" + - update_bfd_multihop_interface_pol.current.0.bfdMhIfPol.attributes.minRxIntvl == "500" + - update_bfd_multihop_interface_pol.current.0.bfdMhIfPol.attributes.minTxIntvl == "270" + + # Added another BFD Multihop Interface policy + - name: Add a new BFD Multihop Interface policy - normal mode + cisco.aci.aci_interface_policy_bfd_multihop: + <<: *add_bfd_multihop_interface_pol + name: ansible_bfd_multihop_interface_policy_2 + state: present + register: add_bfd_multihop_interface_pol_2 + + - name: Verify BFD Multihop Interface Policy creation + assert: + that: + - add_bfd_multihop_interface_pol_2 is changed + - add_bfd_multihop_interface_pol_2.previous == [] + - add_bfd_multihop_interface_pol_2.current.0.bfdMhIfPol.attributes.dn == "uni/tn-ansible_tenant/bfdMhIfPol-ansible_bfd_multihop_interface_policy_2" + - add_bfd_multihop_interface_pol_2.current.0.bfdMhIfPol.attributes.name == "ansible_bfd_multihop_interface_policy_2" + - add_bfd_multihop_interface_pol_2.current.0.bfdMhIfPol.attributes.descr == "Ansible BFD Multihop Interface Policy" + - add_bfd_multihop_interface_pol_2.current.0.bfdMhIfPol.attributes.adminSt == "enabled" + - add_bfd_multihop_interface_pol_2.current.0.bfdMhIfPol.attributes.detectMult == "3" + - add_bfd_multihop_interface_pol_2.current.0.bfdMhIfPol.attributes.minRxIntvl == "250" + - add_bfd_multihop_interface_pol_2.current.0.bfdMhIfPol.attributes.minTxIntvl == "250" + + - name: Query all BFD Multihop Interface policies in a specific tenant + cisco.aci.aci_interface_policy_bfd_multihop: + <<: *aci_info + tenant: ansible_tenant + state: query + register: query_all_result + + - name: Verify querying all BFD Multihop Interface Policies + assert: + that: + - query_all_result is not changed + - query_all_result.current.0.fvTenant.children | length == 2 + - query_all_result.current.0.fvTenant.children[0].bfdMhIfPol.attributes.name == "ansible_bfd_multihop_interface_policy_2" + - query_all_result.current.0.fvTenant.children[1].bfdMhIfPol.attributes.name == "ansible_bfd_multihop_interface_policy" + + - name: Query 'ansible_bfd_multihop_interface_policy' BFD Multihop Interface policies in a specific tenant + cisco.aci.aci_interface_policy_bfd_multihop: + <<: *aci_info + tenant: ansible_tenant + name: ansible_bfd_multihop_interface_policy + state: query + register: query_result + + - name: Verify querying'ansible_bfd_multihop_interface_policy BFD' Multihop Interface Policy + assert: + that: + - query_result is not changed + - query_result.current.0.bfdMhIfPol.attributes.dn == "uni/tn-ansible_tenant/bfdMhIfPol-ansible_bfd_multihop_interface_policy" + - query_result.current.0.bfdMhIfPol.attributes.name == "ansible_bfd_multihop_interface_policy" + + - name: Remove a BFD Multihop Interface policy - check mode + cisco.aci.aci_interface_policy_bfd_multihop: + <<: *aci_info + tenant: ansible_tenant + name: ansible_bfd_multihop_interface_policy + state: absent + check_mode: true + register: cm_remove_bfd_multihop_interface_pol + + - name: Remove a BFD Multihop Interface policy - normal mode + cisco.aci.aci_interface_policy_bfd_multihop: + <<: *aci_info + tenant: ansible_tenant + name: ansible_bfd_multihop_interface_policy + state: absent + register: nm_remove_bfd_multihop_interface_pol + + - name: Remove a BFD Multihop Interface policy again - idempotency + cisco.aci.aci_interface_policy_bfd_multihop: + <<: *aci_info + tenant: ansible_tenant + name: ansible_bfd_multihop_interface_policy + state: absent + register: remove_bfd_multihop_interface_pol_again + + - name: Verify removing BFD Multihop Interface Policies + assert: + that: + - nm_remove_bfd_multihop_interface_pol is changed + - cm_remove_bfd_multihop_interface_pol is changed + - cm_remove_bfd_multihop_interface_pol.proposed == nm_remove_bfd_multihop_interface_pol.proposed == {} + - nm_remove_bfd_multihop_interface_pol.previous != [] + - remove_bfd_multihop_interface_pol_again is not changed + - nm_remove_bfd_multihop_interface_pol.current == remove_bfd_multihop_interface_pol_again.current == [] + +# Validating out of rage parameters. + +# Added BFD Multihop Interface policy with out of the range detection_multiplier + - name: Add a new BFD Multihop Interface policy - out of the range detection_multiplier + cisco.aci.aci_interface_policy_bfd_multihop: + <<: *add_bfd_multihop_interface_pol + name: ansible_bfd_multihop_interface_policy_3 + detection_multiplier: 256 + state: present + ignore_errors: true + register: add_bfd_multihop_interface_pol_3 + + - name: Verify BFD Multihop Interface Policy creation + assert: + that: + - add_bfd_multihop_interface_pol_3 is not changed + - add_bfd_multihop_interface_pol_3.msg == "The \"detection_multiplier\" must be a value between 1 and 50" + +# Added BFD Multihop Interface policy with out of the range min_transmit_interval + - name: Add a new BFD Multihop Interface policy - out of the range min_transmit_interval + cisco.aci.aci_interface_policy_bfd_multihop: + <<: *add_bfd_multihop_interface_pol + name: ansible_bfd_multihop_interface_policy_3 + min_transmit_interval: 50 + state: present + ignore_errors: true + register: add_bfd_multihop_interface_pol_3 + + - name: Verify BFD Multihop Interface Policy creation + assert: + that: + - add_bfd_multihop_interface_pol_3 is not changed + - add_bfd_multihop_interface_pol_3.msg == "The \"min_transmit_interval\" must be a value between 250 and 999" + +# Added BFD Multihop Interface policy with out of the range min_receive_interval + - name: Add a new BFD Multihop Interface policy - out of the range min_receive_interval + cisco.aci.aci_interface_policy_bfd_multihop: + <<: *add_bfd_multihop_interface_pol + name: ansible_bfd_multihop_interface_policy_3 + min_receive_interval: 1000 + state: present + ignore_errors: true + register: add_bfd_multihop_interface_pol_3 + + - name: Verify BFD Multihop Interface Policy creation + assert: + that: + - add_bfd_multihop_interface_pol_3 is not changed + - add_bfd_multihop_interface_pol_3.msg == "The \"min_receive_interval\" must be a value between 250 and 999"
\ No newline at end of file diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_interface_policy_cdp/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_interface_policy_cdp/tasks/main.yml index 48ac1d806..db7751943 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_interface_policy_cdp/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_interface_policy_cdp/tasks/main.yml @@ -4,12 +4,12 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined - name: Verify Cloud and Non-Cloud Sites in use. - include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml - name: Execute tasks only for non-cloud sites when: query_cloud.current == [] # This condition will execute only non-cloud sites @@ -63,7 +63,7 @@ register: cdp_idem - name: Assert that idempotency is not changed - assert: + ansible.builtin.assert: that: - cdp_idem is not changed @@ -86,7 +86,7 @@ var: cdp_disable - name: Assert that CDP is Disabled - assert: + ansible.builtin.assert: that: - cdp_disable.current.0.cdpIfPol.attributes.adminSt == 'disabled' @@ -106,6 +106,6 @@ var: cdp_query - name: CDP Query Assertion - assert: + ansible.builtin.assert: that: - cdp_query is not changed
\ No newline at end of file diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_interface_policy_eigrp/aliases b/ansible_collections/cisco/aci/tests/integration/targets/aci_interface_policy_eigrp/aliases new file mode 100644 index 000000000..209b793f9 --- /dev/null +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_interface_policy_eigrp/aliases @@ -0,0 +1,2 @@ +# No ACI simulator yet, so not enabled +# unsupported diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_interface_policy_eigrp/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_interface_policy_eigrp/tasks/main.yml new file mode 100644 index 000000000..841c29ad8 --- /dev/null +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_interface_policy_eigrp/tasks/main.yml @@ -0,0 +1,192 @@ +# Test code for the ACI modules +# Copyright: (c) 2023, Gaspard Micol (@gmicol) <gmicol@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 APIC host, ACI username and ACI password + ansible.builtin.fail: + msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' + when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined + +- name: Set vars + ansible.builtin.set_fact: + aci_info: &aci_info + host: "{{ aci_hostname }}" + username: "{{ aci_username }}" + password: "{{ aci_password }}" + validate_certs: '{{ aci_validate_certs | default(false) }}' + use_ssl: '{{ aci_use_ssl | default(true) }}' + use_proxy: '{{ aci_use_proxy | default(true) }}' + output_level: debug + +# CLEAN ENVIRONMENT +- name: Remove the ansible_tenant + cisco.aci.aci_tenant: &aci_tenant_absent + <<: *aci_info + tenant: ansible_tenant + state: absent + +- name: Verify Cloud and Non-Cloud Sites in use. + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + +- name: Execute tasks only for non-cloud sites + when: query_cloud.current == [] # This condition will execute only non-cloud sites + block: # block specifies execution of tasks within, based on conditions + - name: Add a new tenant + cisco.aci.aci_tenant: &aci_tenant_present + <<: *aci_info + tenant: ansible_tenant + description: Ansible tenant + state: present + + - name: Add a eigrp interface policy (check_mode) + cisco.aci.aci_interface_policy_eigrp: &aci_interface_policy_eigrp_present + <<: *aci_info + tenant: ansible_tenant + eigrp_interface: ansible_eigrp_interface_1 + description: eigrp interface policy 1 for ansible_tenant tenant + bandwidth: 100000 + control_state: [bfd, nexthop_self, passive, split_horizon] + delay: 10 + delay_unit: picoseconds + hello_interval: 10 + hold_interval: 30 + state: present + check_mode: true + register: cm_add_eigrp_interface + + - name: Add a eigrp interface policy (normal_mode) + cisco.aci.aci_interface_policy_eigrp: + <<: *aci_interface_policy_eigrp_present + register: nm_add_eigrp_interface + + - name: Add the first eigrp interface policy again - testing idempotency + cisco.aci.aci_interface_policy_eigrp: + <<: *aci_interface_policy_eigrp_present + register: nm_add_eigrp_interface_idempotency + + - name: Add a second eigrp interface policy (normal_mode) + cisco.aci.aci_interface_policy_eigrp: + <<: *aci_info + tenant: ansible_tenant + eigrp_interface: ansible_eigrp_interface_2 + description: eigrp interface policy 2 for ansible_tenant tenant + state: present + register: nm_add_eigrp_interface_2 + + - name: Add a third eigrp interface policy - bandwidth out of bounds + cisco.aci.aci_interface_policy_eigrp: + <<: *aci_info + tenant: ansible_tenant + eigrp_interface: ansible_eigrp_interface_3 + bandwidth: 2560000001 + state: present + ignore_errors: true + register: error_bw_out_of_bounds + + - name: Add a fourth eigrp interface policy - hello_interval out of bounds + cisco.aci.aci_interface_policy_eigrp: + <<: *aci_info + tenant: ansible_tenant + eigrp_interface: ansible_eigrp_interface_4 + hello_interval: 65536 + state: present + ignore_errors: true + register: error_helloIntvl_out_of_bounds + + - name: Add a fifth eigrp interface policy - hold_interval out of bounds + cisco.aci.aci_interface_policy_eigrp: + <<: *aci_info + tenant: ansible_tenant + eigrp_interface: ansible_eigrp_interface_5 + hold_interval: 65536 + state: present + ignore_errors: true + register: error_holdIntvl_out_of_bounds + + - name: Asserts for eigrp interface policys creation tasks + ansible.builtin.assert: + that: + - cm_add_eigrp_interface is changed + - cm_add_eigrp_interface.previous == [] + - cm_add_eigrp_interface.current == [] + - nm_add_eigrp_interface is changed + - nm_add_eigrp_interface.current.0.eigrpIfPol.attributes.name == "ansible_eigrp_interface_1" + - nm_add_eigrp_interface.current.0.eigrpIfPol.attributes.bw == "100000" + - nm_add_eigrp_interface.current.0.eigrpIfPol.attributes.ctrl == "bfd,nh-self,passive,split-horizon" + - nm_add_eigrp_interface.current.0.eigrpIfPol.attributes.delay == "10" + - nm_add_eigrp_interface.current.0.eigrpIfPol.attributes.delayUnit == "pico" + - nm_add_eigrp_interface.current.0.eigrpIfPol.attributes.helloIntvl == "10" + - nm_add_eigrp_interface.current.0.eigrpIfPol.attributes.holdIntvl == "30" + - nm_add_eigrp_interface_idempotency is not changed + - nm_add_eigrp_interface_2 is changed + - nm_add_eigrp_interface_2.previous == [] + - nm_add_eigrp_interface_2.current.0.eigrpIfPol.attributes.name == "ansible_eigrp_interface_2" + - nm_add_eigrp_interface_2.current.0.eigrpIfPol.attributes.bw == "0" + - nm_add_eigrp_interface_2.current.0.eigrpIfPol.attributes.ctrl == "nh-self,split-horizon" + - nm_add_eigrp_interface_2.current.0.eigrpIfPol.attributes.delay == "0" + - nm_add_eigrp_interface_2.current.0.eigrpIfPol.attributes.delayUnit == "tens-of-micro" + - nm_add_eigrp_interface_2.current.0.eigrpIfPol.attributes.helloIntvl == "5" + - nm_add_eigrp_interface_2.current.0.eigrpIfPol.attributes.holdIntvl == "15" + - error_bw_out_of_bounds.msg == "Parameter 'bandwidth' is only valid in range between 0 and 2560000000." + - error_helloIntvl_out_of_bounds.msg == "Parameter 'hello_interval' is only valid in range between 1 and 65535." + - error_holdIntvl_out_of_bounds.msg == "Parameter 'hold_interval' is only valid in range between 1 and 65535." + + - name: Query all eigrp interface policies + cisco.aci.aci_interface_policy_eigrp: + <<: *aci_info + state: query + register: query_all_eigrp_interface + + - name: Query ansible_eigrp_interface_1 + cisco.aci.aci_interface_policy_eigrp: + <<: *aci_interface_policy_eigrp_present + state: query + register: query_ansible_eigrp_interface_1 + + - name: Asserts query tasks + ansible.builtin.assert: + that: + - query_all_eigrp_interface is not changed + - query_all_eigrp_interface.current|length >= 2 + - query_ansible_eigrp_interface_1 is not changed + - query_ansible_eigrp_interface_1.current.0.eigrpIfPol.attributes.name == "ansible_eigrp_interface_1" + - query_ansible_eigrp_interface_1.current.0.eigrpIfPol.attributes.bw == "100000" + - query_ansible_eigrp_interface_1.current.0.eigrpIfPol.attributes.ctrl == "bfd,nh-self,passive,split-horizon" + - query_ansible_eigrp_interface_1.current.0.eigrpIfPol.attributes.delay == "10" + - query_ansible_eigrp_interface_1.current.0.eigrpIfPol.attributes.delayUnit == "pico" + - query_ansible_eigrp_interface_1.current.0.eigrpIfPol.attributes.helloIntvl == "10" + - query_ansible_eigrp_interface_1.current.0.eigrpIfPol.attributes.holdIntvl == "30" + + - name: Remove eigrp interface policy (check_mode) + cisco.aci.aci_interface_policy_eigrp: &eigrp_interface_absent + <<: *aci_interface_policy_eigrp_present + state: absent + check_mode: true + register: cm_remove_eigrp_interface + + - name: Remove eigrp interface policy (normal_mode) + cisco.aci.aci_interface_policy_eigrp: + <<: *eigrp_interface_absent + register: nm_remove_eigrp_interface + + - name: Remove eigrp interface policy - testing idempotency + cisco.aci.aci_interface_policy_eigrp: + <<: *eigrp_interface_absent + register: nm_remove_eigrp_interface_idempotency + + - name: Asserts deletion tasks + ansible.builtin.assert: + that: + - cm_remove_eigrp_interface is changed + - cm_remove_eigrp_interface.proposed == {} + - nm_remove_eigrp_interface is changed + - nm_remove_eigrp_interface.previous != [] + - nm_remove_eigrp_interface.method == "DELETE" + - nm_remove_eigrp_interface_idempotency is not changed + - nm_remove_eigrp_interface_idempotency.previous == [] + + - name: Remove the ansible_tenant - cleanup before ending tests + cisco.aci.aci_tenant: + <<: *aci_tenant_present + state: absent diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_interface_policy_fc/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_interface_policy_fc/tasks/main.yml index 5e039380e..001ce0323 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_interface_policy_fc/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_interface_policy_fc/tasks/main.yml @@ -4,12 +4,12 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: "{{ aci_hostname }}" username: "{{ aci_username }}" @@ -20,14 +20,14 @@ output_level: debug - name: Verify Cloud and Non-Cloud Sites in use. - include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml - name: Execute tasks only for non-cloud sites when: query_cloud.current == [] # This condition will execute only non-cloud sites block: # block specifies execution of tasks within, based on conditions # Clean Environment - name: Ensure first fc interface policy does not exist - aci_interface_policy_fc: &aci_interface_policy_fc_absent + cisco.aci.aci_interface_policy_fc: &aci_interface_policy_fc_absent <<: *aci_info name: anstest_policy description: test for fc interface policy @@ -40,36 +40,36 @@ state: absent - name: Ensure second fc interface policy does not exist - aci_interface_policy_fc: &aci_interface_policy_fc_2_absent + cisco.aci.aci_interface_policy_fc: &aci_interface_policy_fc_2_absent <<: *aci_info name: anstest_policy_2 state: absent - name: Create first fc interface policy (check_mode) - aci_interface_policy_fc: &aci_interface_policy_fc_present + cisco.aci.aci_interface_policy_fc: &aci_interface_policy_fc_present <<: *aci_interface_policy_fc_absent state: present check_mode: true register: cm_add_interface_policy_fc_1 - name: Create first fc interface policy (normal_mode) - aci_interface_policy_fc: + cisco.aci.aci_interface_policy_fc: <<: *aci_interface_policy_fc_present register: nm_add_interface_policy_fc_1 - name: Create first fc interface policy again - testing idempotency - aci_interface_policy_fc: + cisco.aci.aci_interface_policy_fc: <<: *aci_interface_policy_fc_present register: idempotency_add_interface_policy_fc_1 - name: Create second fc interface policy - aci_interface_policy_fc: &aci_interface_policy_fc_2_present + cisco.aci.aci_interface_policy_fc: &aci_interface_policy_fc_2_present <<: *aci_interface_policy_fc_2_absent state: present register: nm_add_interface_policy_fc_2 - name: Asserts for creation tasks - assert: + ansible.builtin.assert: that: - cm_add_interface_policy_fc_1 is changed - cm_add_interface_policy_fc_1.previous == [] @@ -94,19 +94,19 @@ - idempotency_add_interface_policy_fc_1 is not changed - name: Query all fc interface policies - aci_interface_policy_fc: + cisco.aci.aci_interface_policy_fc: <<: *aci_info state: query register: query_all_interface_policy_fc - name: Query first fc interface policy - aci_interface_policy_fc: + cisco.aci.aci_interface_policy_fc: <<: *aci_interface_policy_fc_present state: query register: query_first_interface_policy_fc - name: Asserts for query tasks - assert: + ansible.builtin.assert: that: - query_all_interface_policy_fc is not changed - query_all_interface_policy_fc.current | length >= 2 @@ -121,32 +121,32 @@ - query_first_interface_policy_fc.current.0.fcIfPol.attributes.trunkMode == "trunk-on" - name: Delete first fc interface policy (check_mode) - aci_interface_policy_fc: + cisco.aci.aci_interface_policy_fc: <<: *aci_interface_policy_fc_present state: absent check_mode: true register: cm_delete_interface_policy_fc_1 - name: Delete first fc interface policy (normal_mode) - aci_interface_policy_fc: + cisco.aci.aci_interface_policy_fc: <<: *aci_interface_policy_fc_present state: absent register: nm_delete_interface_policy_fc_1 - name: Delete first fc interface policy again - testing idempotency - aci_interface_policy_fc: + cisco.aci.aci_interface_policy_fc: <<: *aci_interface_policy_fc_present state: absent register: idempotency_delete_interface_policy_fc_1 - name: Delete second fc interface policy (normal_mode) - aci_interface_policy_fc: + cisco.aci.aci_interface_policy_fc: <<: *aci_interface_policy_fc_2_present state: absent register: nm_delete_interface_policy_fc_2 - name: Asserts for deletion tasks - assert: + ansible.builtin.assert: that: - cm_delete_interface_policy_fc_1 is changed - cm_delete_interface_policy_fc_1.proposed == {} diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_interface_policy_hsrp/aliases b/ansible_collections/cisco/aci/tests/integration/targets/aci_interface_policy_hsrp/aliases new file mode 100644 index 000000000..209b793f9 --- /dev/null +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_interface_policy_hsrp/aliases @@ -0,0 +1,2 @@ +# No ACI simulator yet, so not enabled +# unsupported diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_interface_policy_hsrp/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_interface_policy_hsrp/tasks/main.yml new file mode 100644 index 000000000..4a8fca8f4 --- /dev/null +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_interface_policy_hsrp/tasks/main.yml @@ -0,0 +1,184 @@ +# Test code for the ACI modules +# Copyright: (c) 2023, Shreyas Srish (@shrsr) +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +# SET VARS +- name: Set vars + ansible.builtin.set_fact: + aci_info: &aci_info + host: '{{ aci_hostname }}' + username: '{{ aci_username }}' + password: '{{ aci_password }}' + validate_certs: '{{ aci_validate_certs | default(false) }}' + use_ssl: '{{ aci_use_ssl | default(true) }}' + use_proxy: '{{ aci_use_proxy | default(true) }}' + output_level: '{{ aci_output_level | default("debug") }}' + +# CLEAN ENVIRONMENT +- name: Remove test tenant before we kickoff + cisco.aci.aci_tenant: &tenant_absent + <<: *aci_info + tenant: ansible_test + state: absent + +- name: Verify Cloud and Non-Cloud Sites in use. + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + +- name: Execute tasks only for non-cloud sites + when: query_cloud.current == [] # This condition will execute only non-cloud sites + block: # block specifies execution of tasks within, based on conditions + # SETUP ENVIRONMENT + - name: Create tenant + cisco.aci.aci_tenant: &tenant_present + <<: *tenant_absent + state: present + + - name: Add a HSRP interface policy in check mode + cisco.aci.aci_interface_policy_hsrp: &hsrp_present + <<: *tenant_present + hsrp: hsrp1 + controls: ["bia"] + reload_delay: 2 + delay: 2 + state: present + check_mode: true + register: cm_add_hsrp + + - name: Add a HSRP interface policy in normal mode + cisco.aci.aci_interface_policy_hsrp: *hsrp_present + register: nm_add_hsrp + + - name: Verify add hsrp + ansible.builtin.assert: + that: + - cm_add_hsrp is changed + - nm_add_hsrp is changed + - cm_add_hsrp.previous == nm_add_hsrp.previous == [] + - cm_add_hsrp.proposed.hsrpIfPol.attributes.ctrl == "bia" + - cm_add_hsrp.proposed.hsrpIfPol.attributes.delay == "2" + - cm_add_hsrp.proposed.hsrpIfPol.attributes.reloadDelay == "2" + - cm_add_hsrp.proposed.hsrpIfPol.attributes.name == "hsrp1" + - nm_add_hsrp.current.0.hsrpIfPol.attributes.ctrl == "bia" + - nm_add_hsrp.current.0.hsrpIfPol.attributes.delay == "2" + - nm_add_hsrp.current.0.hsrpIfPol.attributes.reloadDelay == "2" + - nm_add_hsrp.current.0.hsrpIfPol.attributes.name == "hsrp1" + - nm_add_hsrp.current.0.hsrpIfPol.attributes.dn == "uni/tn-ansible_test/hsrpIfPol-hsrp1" + + - name: Add the HSRP interface policy again to check idempotency + cisco.aci.aci_interface_policy_hsrp: *hsrp_present + register: nm_add_hsrp_again + + - name: Verify add_hsrp again + ansible.builtin.assert: + that: + - nm_add_hsrp_again is not changed + + - name: Update hsrp interface policy + cisco.aci.aci_interface_policy_hsrp: &hsrp_update + <<: *hsrp_present + delay: 3 + register: nm_hsrp_update + + - name: Verify update hsrp + ansible.builtin.assert: + that: + - nm_hsrp_update is changed + - nm_hsrp_update.current.0.hsrpIfPol.attributes.delay == "3" + - nm_hsrp_update.current.0.hsrpIfPol.attributes.reloadDelay == "2" + - nm_hsrp_update.current.0.hsrpIfPol.attributes.name == "hsrp1" + - nm_hsrp_update.current.0.hsrpIfPol.attributes.dn == "uni/tn-ansible_test/hsrpIfPol-hsrp1" + + - name: Update hsrp interface policy to check for errors in delay + cisco.aci.aci_interface_policy_hsrp: + <<: *hsrp_update + delay: 10001 + register: nm_hsrp_error1 + ignore_errors: true + + - name: Update hsrp interface policy to check for errors in reload delay + cisco.aci.aci_interface_policy_hsrp: + <<: *hsrp_update + reload_delay: 10001 + register: nm_hsrp_error2 + ignore_errors: true + + - name: Verify errors + ansible.builtin.assert: + that: + - nm_hsrp_error1.msg == "Parameter 'delay' is only valid in range between 1 and 10000." + - nm_hsrp_error2.msg == "Parameter 'reload_delay' is only valid in range between 1 and 10000." + + - name: Add another HSRP interface policy in check mode + cisco.aci.aci_interface_policy_hsrp: &hsrp2 + <<: *tenant_present + hsrp: hsrp2 + controls: ["bfd"] + state: present + register: add_hsrp2 + + - name: Query hsrp interface policy 1 + cisco.aci.aci_interface_policy_hsrp: + <<: *hsrp_update + state: query + register: query_hsrp + + - name: Query all hsrp interface policies under the tenant + cisco.aci.aci_interface_policy_hsrp: + <<: *tenant_present + state: query + register: query_all_tenant + + - name: Query all hsrp interface policies + cisco.aci.aci_interface_policy_hsrp: + <<: *tenant_present + state: query + register: query_all + + - name: Verify query hsrp + ansible.builtin.assert: + that: + - query_hsrp is not changed + - query_all_tenant is not changed + - query_all is not changed + - query_hsrp.current.0.hsrpIfPol.attributes.delay == "3" + - query_hsrp.current.0.hsrpIfPol.attributes.reloadDelay == "2" + - query_hsrp.current.0.hsrpIfPol.attributes.name == "hsrp1" + - query_hsrp.current.0.hsrpIfPol.attributes.dn == "uni/tn-ansible_test/hsrpIfPol-hsrp1" + - query_all_tenant.current.0.fvTenant.children | length == 2 + - query_all.current.0.fvTenant.children | length >= 2 + + - name: Remove hsrp interface policy 1 in check mode + cisco.aci.aci_interface_policy_hsrp: + <<: *hsrp_update + state: absent + check_mode: true + register: cm_remove_hsrp + + - name: Remove hsrp interface policy 1 + cisco.aci.aci_interface_policy_hsrp: + <<: *hsrp_update + state: absent + register: remove_hsrp + + - name: Remove hsrp interface policy 2 + cisco.aci.aci_interface_policy_hsrp: + <<: *hsrp2 + state: absent + register: remove_hsrp2 + + - name: Remove hsrp interface policy again + cisco.aci.aci_interface_policy_hsrp: + <<: *hsrp2 + state: absent + register: remove_hsrp2_again + + - name: Verify remove hsrp + ansible.builtin.assert: + that: + - cm_remove_hsrp is changed + - cm_remove_hsrp.proposed == {} + - remove_hsrp is changed + - remove_hsrp2 is changed + - remove_hsrp.current == [] + - remove_hsrp2.current == [] + - remove_hsrp2_again is not changed diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_interface_policy_l2/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_interface_policy_l2/tasks/main.yml index f52b74fdb..ccfb3a641 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_interface_policy_l2/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_interface_policy_l2/tasks/main.yml @@ -4,12 +4,12 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: "{{ aci_hostname }}" username: "{{ aci_username }}" @@ -20,14 +20,14 @@ output_level: debug - name: Verify Cloud and Non-Cloud Sites in use. - include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml - name: Execute tasks only for non-cloud sites when: query_cloud.current == [] # This condition will execute only non-cloud sites block: # block specifies execution of tasks within, based on conditions # Clean Environment - name: Ensure first l2 interface policy does not exist - aci_interface_policy_l2: &aci_interface_policy_l2_absent + cisco.aci.aci_interface_policy_l2: &aci_interface_policy_l2_absent <<: *aci_info name: anstest_policy description: test for l2 interface policy @@ -37,36 +37,36 @@ state: absent - name: Ensure second l2 interface policy does not exist - aci_interface_policy_l2: &aci_interface_policy_l2_2_absent + cisco.aci.aci_interface_policy_l2: &aci_interface_policy_l2_2_absent <<: *aci_info name: anstest_policy_2 state: absent - name: Create first l2 interface policy (check_mode) - aci_interface_policy_l2: &aci_interface_policy_l2_present + cisco.aci.aci_interface_policy_l2: &aci_interface_policy_l2_present <<: *aci_interface_policy_l2_absent state: present check_mode: true register: cm_add_interface_policy_l2_1 - name: Create first l2 interface policy (normal_mode) - aci_interface_policy_l2: + cisco.aci.aci_interface_policy_l2: <<: *aci_interface_policy_l2_present register: nm_add_interface_policy_l2_1 - name: Create first l2 interface policy again - testing idempotency - aci_interface_policy_l2: + cisco.aci.aci_interface_policy_l2: <<: *aci_interface_policy_l2_present register: idempotency_add_interface_policy_l2_1 - name: Create second l2 interface policy - aci_interface_policy_l2: &aci_interface_policy_l2_2_present + cisco.aci.aci_interface_policy_l2: &aci_interface_policy_l2_2_present <<: *aci_interface_policy_l2_2_absent state: present register: nm_add_interface_policy_l2_2 - name: Asserts for creation tasks - assert: + ansible.builtin.assert: that: - cm_add_interface_policy_l2_1 is changed - cm_add_interface_policy_l2_1.previous == [] @@ -84,19 +84,19 @@ - nm_add_interface_policy_l2_2.current.0.l2IfPol.attributes.vepa == "disabled" - name: Query all l2 interface policies - aci_interface_policy_l2: + cisco.aci.aci_interface_policy_l2: <<: *aci_info state: query register: query_all_interface_policy_l2 - name: Query first l2 interface policy - aci_interface_policy_l2: + cisco.aci.aci_interface_policy_l2: <<: *aci_interface_policy_l2_present state: query register: query_first_interface_policy_l2 - name: Asserts for query tasks - assert: + ansible.builtin.assert: that: - query_all_interface_policy_l2 is not changed - query_all_interface_policy_l2.current | length >= 2 @@ -108,32 +108,32 @@ - query_first_interface_policy_l2.current.0.l2IfPol.attributes.vepa == "enabled" - name: Delete first l2 interface policy (check_mode) - aci_interface_policy_l2: + cisco.aci.aci_interface_policy_l2: <<: *aci_interface_policy_l2_present state: absent check_mode: true register: cm_delete_interface_policy_l2_1 - name: Delete first l2 interface policy (normal_mode) - aci_interface_policy_l2: + cisco.aci.aci_interface_policy_l2: <<: *aci_interface_policy_l2_present state: absent register: nm_delete_interface_policy_l2_1 - name: Delete first l2 interface policy again - testing idempotency - aci_interface_policy_l2: + cisco.aci.aci_interface_policy_l2: <<: *aci_interface_policy_l2_present state: absent register: idempotency_delete_interface_policy_l2_1 - name: Delete second l2 interface policy (normal_mode) - aci_interface_policy_l2: + cisco.aci.aci_interface_policy_l2: <<: *aci_interface_policy_l2_2_present state: absent register: nm_delete_interface_policy_l2_2 - name: Asserts for deletion tasks - assert: + ansible.builtin.assert: that: - cm_delete_interface_policy_l2_1 is changed - cm_delete_interface_policy_l2_1.proposed == {} diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_interface_policy_leaf_breakout_port_group/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_interface_policy_leaf_breakout_port_group/tasks/main.yml index b84f64b9a..25c8a1aec 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_interface_policy_leaf_breakout_port_group/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_interface_policy_leaf_breakout_port_group/tasks/main.yml @@ -4,13 +4,13 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined # CLEAN ENVIRONMENT - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: '{{ aci_hostname }}' username: '{{ aci_username }}' @@ -21,7 +21,7 @@ output_level: '{{ aci_output_level | default("info") }}' - name: Verify Cloud and Non-Cloud Sites in use. - include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml - name: Execute tasks only for non-cloud sites when: query_cloud.current == [] # This condition will execute only non-cloud sites @@ -55,7 +55,7 @@ register: nm_create_brkout_port - name: Verify cm_create_brkout_port and nm_create_brkout_port - assert: + ansible.builtin.assert: that: - cm_create_brkout_port is changed - cm_create_brkout_port.previous == [] @@ -81,7 +81,7 @@ register: nm_create_brkout_port_again - name: Verify nm_create_brkout_port_again - assert: + ansible.builtin.assert: that: - nm_create_brkout_port_again is not changed @@ -93,7 +93,7 @@ register: nm_create_another_brkout_port - name: Verify nm_create_another_brkout_port - assert: + ansible.builtin.assert: that: - nm_create_another_brkout_port is changed - nm_create_another_brkout_port.previous == [] @@ -110,7 +110,7 @@ register: query_all - name: Verify query_all - assert: + ansible.builtin.assert: that: query_all.current | length >= 2 @@ -122,7 +122,7 @@ register: query_one - name: Verify query_one - assert: + ansible.builtin.assert: that: - query_one is not changed - query_one.current.0.infraBrkoutPortGrp.attributes.name == "ansible_breakout_port" @@ -137,7 +137,7 @@ register: change_ansible_breakout_port - name: Verify change_ansible_breakout_port - assert: + ansible.builtin.assert: that: - change_ansible_breakout_port is changed - change_ansible_breakout_port.current.0.infraBrkoutPortGrp.attributes.brkoutMap == "none" @@ -151,7 +151,7 @@ register: rm_breakout_port - name: Verify rm_breakout_port - assert: + ansible.builtin.assert: that: - rm_breakout_port is changed - rm_breakout_port.current == [] @@ -164,6 +164,6 @@ register: query_removed_breakout_port - name: Verify query_removed_breakout_port - assert: + ansible.builtin.assert: that: - query_removed_breakout_port.current == []
\ No newline at end of file diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_interface_policy_leaf_fc_policy_group/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_interface_policy_leaf_fc_policy_group/tasks/main.yml index 5a758bb3d..ed646ec01 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_interface_policy_leaf_fc_policy_group/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_interface_policy_leaf_fc_policy_group/tasks/main.yml @@ -4,12 +4,12 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: "{{ aci_hostname }}" username: "{{ aci_username }}" @@ -20,7 +20,7 @@ output_level: debug - name: Verify Cloud and Non-Cloud Sites in use. - include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml - name: Execute tasks only for non-cloud sites when: query_cloud.current == [] # This condition will execute only non-cloud sites @@ -71,7 +71,7 @@ register: intf_policy_leaf_access_fc_port_polgrp_update - name: Verify present assertions for FC Port Policy Group - assert: + ansible.builtin.assert: that: - intf_policy_leaf_access_fc_port_polgrp_check_mode_present is changed - intf_policy_leaf_access_fc_port_polgrp_present is changed @@ -116,7 +116,7 @@ register: intf_policy_leaf_access_fc_pc_polgrp_update - name: Verify present assertions for FC PC Policy Group - assert: + ansible.builtin.assert: that: - intf_policy_leaf_access_fc_pc_polgrp_check_mode_present is changed - intf_policy_leaf_access_fc_pc_polgrp_present is changed @@ -149,7 +149,7 @@ register: query_leaf_access_fc_port_policy_group - name: Verify query assertions for Leaf Access FC Port Policy Group - assert: + ansible.builtin.assert: that: - query_leaf_access_fc_port_policy_group is not changed - query_leaf_access_fc_port_policy_group.current[0] | length >= 1 @@ -172,7 +172,7 @@ register: query_leaf_access_fc_pc_policy_group - name: Verify query assertions for Leaf Access FC PC Policy Group - assert: + ansible.builtin.assert: that: - query_leaf_access_fc_pc_policy_group is not changed - query_leaf_access_fc_pc_policy_group.current[0] | length >= 1 @@ -196,7 +196,7 @@ register: intf_policy_leaf_access_fc_port_polgrp_absent_idempotent - name: Verify absent assertions for FC Port Policy Group - assert: + ansible.builtin.assert: that: - intf_policy_leaf_access_fc_port_polgrp_check_mode_absent is changed - intf_policy_leaf_access_fc_port_polgrp_check_mode_absent.previous != [] @@ -222,7 +222,7 @@ register: intf_policy_leaf_access_fc_pc_polgrp_absent_idempotent - name: Verify absent assertions for FC PC policy group - assert: + ansible.builtin.assert: that: - intf_policy_leaf_access_fc_pc_polgrp_check_mode_absent is changed - intf_policy_leaf_access_fc_pc_polgrp_check_mode_absent.previous != [] diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_interface_policy_leaf_policy_group/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_interface_policy_leaf_policy_group/tasks/main.yml index 3f6e25505..730710869 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_interface_policy_leaf_policy_group/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_interface_policy_leaf_policy_group/tasks/main.yml @@ -5,13 +5,13 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined # GET Credentials from the inventory - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: "{{ aci_hostname }}" username: "{{ aci_username }}" @@ -29,7 +29,7 @@ register: version - name: Verify Cloud and Non-Cloud Sites in use. - include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml - name: Execute tasks only for non-cloud sites when: query_cloud.current == [] # This condition will execute only non-cloud sites @@ -86,7 +86,7 @@ # TODO: also test for errors - name: present assertions for interface policy leaf policy group (PC) - assert: + ansible.builtin.assert: that: - intf_policy_leaf_polgrp_check_mode_present is changed - intf_policy_leaf_polgrp_present is changed @@ -110,7 +110,7 @@ register: binding_query - name: Query assertions for interface policy leaf policy group (PC) - assert: + ansible.builtin.assert: that: - binding_query is not changed - binding_query.current | length >= 1 @@ -142,7 +142,7 @@ register: intf_policy_leaf_polgrp_absent_missing_param - name: absent assertions for interface policy leaf policy group (PC) - assert: + ansible.builtin.assert: that: - intf_policy_leaf_polgrp_check_mode_absent is changed - intf_policy_leaf_polgrp_check_mode_absent.previous != [] @@ -191,7 +191,7 @@ # TODO: also test for errors - name: present assertions for interface policy leaf policy group (VPC) - assert: + ansible.builtin.assert: that: - intf_policy_leaf_polgrp_check_mode_present is changed - intf_policy_leaf_polgrp_present is changed @@ -215,7 +215,7 @@ register: binding_query - name: Query assertions for interface policy leaf policy group (VPC) - assert: + ansible.builtin.assert: that: - binding_query is not changed - binding_query.current | length >= 1 @@ -235,7 +235,7 @@ register: binding_query_node_all - name: Query assertions for interface policy leaf policy group (VPC) - assert: + ansible.builtin.assert: that: - binding_query_node_all is not changed - binding_query_node_all.current | length >= 1 @@ -267,7 +267,7 @@ register: intf_policy_leaf_polgrp_absent_missing_param - name: absent assertions for interface policy leaf policy group (VPC) - assert: + ansible.builtin.assert: that: - intf_policy_leaf_polgrp_check_mode_absent is changed - intf_policy_leaf_polgrp_check_mode_absent.previous != [] @@ -286,7 +286,7 @@ register: intf_policy_leaf_polgrp_pa_policy_error - name: VPC error assertions (adding invalid parameters) - assert: + ansible.builtin.assert: that: - intf_policy_leaf_polgrp_pa_policy_error.msg == 'port_authentication is not a valid parameter for link/node (Port Channel, Virtual Port Channel), if used assign null to it (port_authentication{{":"}} null).' @@ -343,7 +343,7 @@ # TODO: also test for errors - name: present assertions for interface policy leaf policy group (Leaf Access Port) - assert: + ansible.builtin.assert: that: - intf_policy_leaf_polgrp_check_mode_present is changed - intf_policy_leaf_polgrp_present is changed @@ -368,12 +368,12 @@ register: binding_query - name: Query assertions interface policy leaf policy group (Leaf Access Port) - assert: + ansible.builtin.assert: that: - binding_query is not changed - binding_query.current | length >= 1 - '"/api/mo/uni/infra/funcprof/accportgrp-policygroupname_leaf.json" in binding_query.url' - - binding_query.current.0.infraAccPortGrp.children.14.infraRsAttEntP.attributes.tDn == "uni/infra/attentp-test_aep" + - binding_query.current.0.infraAccPortGrp.children.10.infraRsAttEntP.attributes.tDn == "uni/infra/attentp-test_aep" - name: Remove interface policy leaf policy group (Leaf Access Port) - check mode cisco.aci.aci_interface_policy_leaf_policy_group: @@ -400,7 +400,7 @@ register: intf_policy_leaf_polgrp_absent_missing_param - name: absent assertions for interface policy leaf policy group (Leaf Access Port) - assert: + ansible.builtin.assert: that: - intf_policy_leaf_polgrp_check_mode_absent is changed - intf_policy_leaf_polgrp_check_mode_absent.previous != [] @@ -430,7 +430,7 @@ register: intf_policy_leaf_policy_group_link_present_2 - name: present assertions (PC) for APIC version > 5 - assert: + ansible.builtin.assert: that: - intf_policy_leaf_policy_group_link_present_2 is changed - intf_policy_leaf_policy_group_link_present_2.previous != [] @@ -446,7 +446,7 @@ register: intf_policy_leaf_polgrp_present_2 - name: present assertions (Leaf Access Port) for APIC version > 5 - assert: + ansible.builtin.assert: that: - intf_policy_leaf_polgrp_present_2 is changed - intf_policy_leaf_polgrp_present_2.previous == [] @@ -474,7 +474,7 @@ register: intf_policy_leaf_policy_group_node_present_2 - name: present assertions (VPC) for APIC version > 6 - assert: + ansible.builtin.assert: that: - intf_policy_leaf_policy_group_node_present_2 is changed - intf_policy_leaf_policy_group_node_present_2.previous == [] @@ -497,7 +497,7 @@ register: intf_policy_leaf_polgrp_present_3 - name: present assertions (Leaf Access Port) for APIC version >= 6.0.2 - assert: + ansible.builtin.assert: that: - intf_policy_leaf_polgrp_present_3 is changed - intf_policy_leaf_polgrp_present_3.previous != [] @@ -530,7 +530,7 @@ register: intf_policy_leaf_polgrp_all_policy_present - name: present assertions (Leaf Access Port) for all the policies. - assert: + ansible.builtin.assert: that: - intf_policy_leaf_polgrp_all_policy_present is changed - intf_policy_leaf_polgrp_all_policy_present.previous != [] diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_interface_policy_leaf_profile/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_interface_policy_leaf_profile/tasks/main.yml index 51d553c54..08bbd31b6 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_interface_policy_leaf_profile/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_interface_policy_leaf_profile/tasks/main.yml @@ -5,12 +5,12 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined - name: Verify Cloud and Non-Cloud Sites in use. - include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml - name: Execute tasks only for non-cloud sites when: query_cloud.current == [] # This condition will execute only non-cloud sites @@ -70,7 +70,7 @@ register: nm_add_leaf_interface_profile_fex - name: Verify add_leaf_interface_profile - assert: + ansible.builtin.assert: that: - cm_add_leaf_interface_profile is changed - nm_add_leaf_interface_profile is changed @@ -115,7 +115,7 @@ register: nm_add_leaf_interface_profile_descr_fex - name: Verify add_leaf_interface_profile_descr - assert: + ansible.builtin.assert: that: - cm_add_leaf_interface_profile_descr is changed - nm_add_leaf_interface_profile_descr is changed @@ -141,7 +141,7 @@ register: nm_add_leaf_interface_profile_again_no_descr_fex - name: Verify add_leaf_interface_profile_again_no_descr - assert: + ansible.builtin.assert: that: - cm_add_leaf_interface_profile_again_no_descr is not changed - nm_add_leaf_interface_profile_again_no_descr is not changed @@ -171,7 +171,7 @@ type: fex - name: Verify query_all_leaf_interface_profiles - assert: + ansible.builtin.assert: that: - cm_query_all_leaf_interface_profiles is not changed - nm_query_all_leaf_interface_profiles is not changed @@ -200,7 +200,7 @@ register: nm_query_leaf_interface_profile_fex - name: Verify query_leaf_interface_profile - assert: + ansible.builtin.assert: that: - cm_query_leaf_interface_profile is not changed - nm_query_leaf_interface_profile is not changed @@ -234,7 +234,7 @@ register: nm_remove_leaf_interface_profile_again_fex - name: Verify remove_leaf_interface_profile - assert: + ansible.builtin.assert: that: - cm_remove_leaf_interface_profile is changed - nm_remove_leaf_interface_profile is changed @@ -265,7 +265,7 @@ # TODO: Implement more tests - name: Verify query_non_leaf_interface_profile - assert: + ansible.builtin.assert: that: - cm_query_non_leaf_interface_profile is not changed - nm_query_non_leaf_interface_profile is not changed diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_interface_policy_leaf_profile_fex_policy_group/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_interface_policy_leaf_profile_fex_policy_group/tasks/main.yml index 41853af11..2fc177909 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_interface_policy_leaf_profile_fex_policy_group/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_interface_policy_leaf_profile_fex_policy_group/tasks/main.yml @@ -4,13 +4,13 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: "Please define the following variables: aci_hostname, aci_username and aci_password." when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined # SET VARS - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: "{{ aci_hostname }}" username: "{{ aci_username }}" @@ -21,7 +21,7 @@ output_level: '{{ aci_output_level | default("info") }}' - name: Verify Cloud and Non-Cloud Sites in use. - include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml - name: Execute tasks only for non-cloud sites when: query_cloud.current == [] # This condition will execute only non-cloud sites @@ -50,7 +50,7 @@ register: cm_fex_policy_group_present - name: Assertions check for add Fex Policy Group to anstest_fex_profile - Interface Policy Fex profile with check mode - assert: + ansible.builtin.assert: that: - cm_fex_policy_group_present is changed - cm_fex_policy_group_present.current | length == 0 @@ -65,7 +65,7 @@ register: nm_fex_policy_group_present - name: Assertions check for add Fex Policy Group to anstest_fex_profile - Interface Policy Fex profile with normal mode - assert: + ansible.builtin.assert: that: - nm_fex_policy_group_present is changed - nm_fex_policy_group_present.current | length == 1 @@ -80,7 +80,7 @@ register: idempotency_fex_policy_group_present - name: Idempotency assertions check for add Fex Policy Group to anstest_fex_profile - Interface Policy Fex profile with normal mode - assert: + ansible.builtin.assert: that: - idempotency_fex_policy_group_present is not changed - idempotency_fex_policy_group_present.current | length == 1 @@ -104,7 +104,7 @@ register: multiple_fex_policy_group_present - name: Assertions check for add multiple Fex Policy Group to anstest_fex_profile - Interface Policy Fex profile with normal mode - assert: + ansible.builtin.assert: that: - multiple_fex_policy_group_present is changed - multiple_fex_policy_group_present.results.0 is changed @@ -125,7 +125,7 @@ register: temp_anstest_fex_profile_absent - name: Assertions check for remove temp_anstest_fex_profile - Interface Policy Fex profile - assert: + ansible.builtin.assert: that: - temp_anstest_fex_profile_absent.current | length == 0 @@ -136,7 +136,7 @@ register: temp_anstest_fex_profile_present - name: Assertions check for add temp_anstest_fex_profile - Interface Policy Fex profile - assert: + ansible.builtin.assert: that: - temp_anstest_fex_profile_present is changed - temp_anstest_fex_profile_present.current | length == 1 @@ -151,7 +151,7 @@ register: temp_anstest_fex_policy_group_present - name: Assertions check for add Fex Policy Group to temp_anstest_fex_profile - Interface Policy Fex profile - assert: + ansible.builtin.assert: that: - temp_anstest_fex_policy_group_present is changed - temp_anstest_fex_policy_group_present.current | length == 1 @@ -168,7 +168,7 @@ register: query_res_fex_policy_group_with_profile - name: Assertions check for query anstest_fex_policy_group - fex policy group with fex_profile - assert: + ansible.builtin.assert: that: - query_res_fex_policy_group_with_profile is not changed - query_res_fex_policy_group_with_profile.current | length == 1 @@ -183,7 +183,7 @@ register: query_all_policy_groups_under_fex_profile - name: Assertions check for query all fex policy group under anstest_fex_profile - assert: + ansible.builtin.assert: that: - query_all_policy_groups_under_fex_profile is not changed - query_all_policy_groups_under_fex_profile.current.0.infraFexP.children | length == 3 @@ -196,7 +196,7 @@ register: query_res_anstest_fex_policy_group - name: Assertions check for query all anstest_fex_policy_group - fex policy groups - assert: + ansible.builtin.assert: that: - query_res_anstest_fex_policy_group is not changed - query_res_anstest_fex_policy_group.current | length >= 2 @@ -210,7 +210,7 @@ register: all_fex_policy_groups - name: Assertions check for query all - fex policy groups - assert: + ansible.builtin.assert: that: - all_fex_policy_groups is not changed - all_fex_policy_groups.current | length >= 4 @@ -226,7 +226,7 @@ register: cm_anstest_fex_policy_group_absent - name: Assertions check for remove anstest_fex_policy_group - Fex Policy Group from anstest_fex_profile with check mode - assert: + ansible.builtin.assert: that: - cm_anstest_fex_policy_group_absent is changed - cm_anstest_fex_policy_group_absent.current | length == 1 @@ -243,7 +243,7 @@ register: nm_anstest_fex_policy_group_absent - name: Assertions check for remove anstest_fex_policy_group - Fex Policy Group from anstest_fex_profile with normal mode - assert: + ansible.builtin.assert: that: - nm_anstest_fex_policy_group_absent is changed - nm_anstest_fex_policy_group_absent.current | length == 0 @@ -258,7 +258,7 @@ register: idempotency_anstest_fex_policy_group_absent - name: Idempotency assertions check for remove anstest_fex_policy_group - Fex Policy Group from anstest_fex_profile with normal mode - assert: + ansible.builtin.assert: that: - idempotency_anstest_fex_policy_group_absent is not changed - idempotency_anstest_fex_policy_group_absent.current | length == 0 @@ -271,7 +271,7 @@ register: temp_anstest_fex_profile_absent - name: Assertions check for remove temp_anstest_fex_profile Fex Profile - assert: + ansible.builtin.assert: that: - temp_anstest_fex_profile_absent is changed - temp_anstest_fex_profile_absent.current | length == 0 @@ -286,7 +286,7 @@ register: fex_profile_present_absent - name: Assertions check for remove anstest_fex_profile Fex Profile - assert: + ansible.builtin.assert: that: - fex_profile_present_absent is changed - fex_profile_present_absent.current | length == 0 diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_interface_policy_link_level/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_interface_policy_link_level/tasks/main.yml index a3ee0c4b8..c5a6843e5 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_interface_policy_link_level/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_interface_policy_link_level/tasks/main.yml @@ -5,19 +5,32 @@ # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined - name: Verify Cloud and Non-Cloud Sites in use. - include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml - name: Execute tasks only for non-cloud sites when: query_cloud.current == [] # This condition will execute only non-cloud sites block: # block specifies execution of tasks within, based on conditions + # SET ACI_INFO VARS FOR SYSTEM LOGIN WITHIN TASKS + - name: Set vars for system login + ansible.builtin.set_fact: + aci_info: &aci_info + host: "{{ aci_hostname }}" + port: "{{ aci_port | default(omit) }}" + username: "{{ aci_username }}" + password: "{{ aci_password }}" + validate_certs: '{{ aci_validate_certs | default(false) }}' + use_ssl: '{{ aci_use_ssl | default(true) }}' + use_proxy: '{{ aci_use_proxy | default(true) }}' + output_level: '{{ aci_output_level | default("info") }}' + # CLEAN ENVIRONMENT - name: Remove Link Level Policy - aci_interface_policy_link_level: &interface_policy_link_level_absent + cisco.aci.aci_interface_policy_link_level: &interface_policy_link_level_absent host: '{{ aci_hostname }}' username: '{{ aci_username }}' password: '{{ aci_password }}' @@ -30,7 +43,7 @@ # ADD LINK LEVEL POLICY - name: Add Link Level Policy (check mode) - aci_interface_policy_link_level: &interface_policy_link_level_present + cisco.aci.aci_interface_policy_link_level: &interface_policy_link_level_present host: '{{ aci_hostname }}' username: '{{ aci_username }}' password: '{{ aci_password }}' @@ -44,11 +57,11 @@ register: cm_add_policy - name: Add Link Level Policy (normal mode) - aci_interface_policy_link_level: *interface_policy_link_level_present + cisco.aci.aci_interface_policy_link_level: *interface_policy_link_level_present register: nm_add_policy - name: Verify Add Link Level Policy - assert: + ansible.builtin.assert: that: - cm_add_policy is changed - nm_add_policy is changed @@ -59,16 +72,16 @@ - nm_add_policy.proposed.fabricHIfPol.attributes.name == cm_add_policy.proposed.fabricHIfPol.attributes.name == nm_add_policy.sent.fabricHIfPol.attributes.name == 'ansible_test' - name: Add Link Level Policy again (check mode) - aci_interface_policy_link_level: *interface_policy_link_level_present + cisco.aci.aci_interface_policy_link_level: *interface_policy_link_level_present check_mode: true register: cm_add_policy_again - name: Add Link Level Policy again (normal mode) - aci_interface_policy_link_level: *interface_policy_link_level_present + cisco.aci.aci_interface_policy_link_level: *interface_policy_link_level_present register: nm_add_policy_again - name: Verify Add Link Level Policy again - assert: + ansible.builtin.assert: that: - cm_add_policy_again is not changed - nm_add_policy_again is not changed @@ -78,20 +91,20 @@ # CHANGE LINK LEVEL POLICY - name: Change description of Link Level Policy (check mode) - aci_interface_policy_link_level: + cisco.aci.aci_interface_policy_link_level: <<: *interface_policy_link_level_present description: Ansible test Link Level Policy check_mode: true register: cm_add_policy_descr - name: Change description of Link Level Policy (normal mode) - aci_interface_policy_link_level: + cisco.aci.aci_interface_policy_link_level: <<: *interface_policy_link_level_present description: Ansible test Link Level Policy register: nm_add_policy_descr - name: Verify add_policy_descr - assert: + ansible.builtin.assert: that: - cm_add_policy_descr is changed - nm_add_policy_descr is changed @@ -99,20 +112,20 @@ - nm_add_policy_descr.current.0.fabricHIfPol.attributes.dn == 'uni/infra/hintfpol-ansible_test' - name: Change description of Link Level Policy again (check mode) - aci_interface_policy_link_level: + cisco.aci.aci_interface_policy_link_level: <<: *interface_policy_link_level_present description: Ansible test Link Level Policy check_mode: true register: cm_add_policy_descr_again - name: Change description of Link Level Policy again (normal mode) - aci_interface_policy_link_level: + cisco.aci.aci_interface_policy_link_level: <<: *interface_policy_link_level_present description: Ansible test Link Level Policy register: nm_add_policy_descr_again - name: Verify add_policy_descr_again - assert: + ansible.builtin.assert: that: - cm_add_policy_descr_again is not changed - nm_add_policy_descr_again is not changed @@ -122,26 +135,88 @@ # ADD LINK LEVEL POLICY AGAIN WITH NO DESCRIPTION - name: Add Link Level Policy again with no description (check mode) - aci_interface_policy_link_level: *interface_policy_link_level_present + cisco.aci.aci_interface_policy_link_level: *interface_policy_link_level_present check_mode: true register: cm_add_policy_again_no_descr - name: Add Link Level Policy again with no description (normal mode) - aci_interface_policy_link_level: *interface_policy_link_level_present + cisco.aci.aci_interface_policy_link_level: *interface_policy_link_level_present register: nm_add_policy_again_no_descr - name: Verify add_policy_again_no_descr - assert: + ansible.builtin.assert: that: - cm_add_policy_again_no_descr is not changed - nm_add_policy_again_no_descr is not changed - cm_add_policy_again_no_descr.proposed.fabricHIfPol.attributes.name == nm_add_policy_again_no_descr.proposed.fabricHIfPol.attributes.name == 'ansible_test' - cm_add_policy_again_no_descr.sent == nm_add_policy_again_no_descr.sent == {} - cm_add_policy_again_no_descr.previous.0.fabricHIfPol.attributes.dn== nm_add_policy_again_no_descr.previous.0.fabricHIfPol.attributes.dn == cm_add_policy_again_no_descr.current.0.fabricHIfPol.attributes.dn == nm_add_policy_again_no_descr.current.0.fabricHIfPol.attributes.dn == 'uni/infra/hintfpol-ansible_test' + + # CHANGE SPEED ON LINK LEVEL POLICY + - name: Test each speed setting for Link Level Policy + block: + - name: Query system information to fetch version + cisco.aci.aci_system: + <<: *aci_info + id: 1 + state: query + register: version + + - name: Define speed settings in version < 5.2 + set_fact: + supported_speed: ["100M", "1G", "10G", "25G", "40G", "50G", "100G", "200G", "400G", "inherit"] + when: version.current.0.topSystem.attributes.version is version('5.2', '<') + + - name: Define speed settings in version >= 5.2 + set_fact: + supported_speed: ["100M", "1G", "10G", "25G", "40G", "50G", "100G", "200G", "400G", "auto", "inherit"] + when: version.current.0.topSystem.attributes.version is version('5.2', '>=') + + - name: Add Link Level Policy with various speeds (check mode) + cisco.aci.aci_interface_policy_link_level: + <<: *interface_policy_link_level_present + speed: "{{ item }}" + check_mode: true + loop: "{{ supported_speed }}" + register: cm_add_policy_speed + loop_control: + label: "speed-{{ item }}" + + - name: Add Link Level Policy with various speeds (normal mode) + cisco.aci.aci_interface_policy_link_level: + <<: *interface_policy_link_level_present + speed: "{{ item }}" + loop: "{{ supported_speed }}" + register: nm_add_policy_speed + loop_control: + label: "speed-{{ item }}" + + - name: Verify each speed setting (normal mode) + ansible.builtin.assert: + that: + - "item.1.current.0.fabricHIfPol.attributes.name == 'ansible_test'" + - "item.1.current.0.fabricHIfPol.attributes.dn == 'uni/infra/hintfpol-ansible_test'" + - "item.1.current.0.fabricHIfPol.attributes.speed == item.0" + quiet: true + loop: "{{ supported_speed | zip(nm_add_policy_speed.results) }}" + loop_control: + label: "speed-{{ item.0 }}" + + - name: Verify each speed setting (check mode) + ansible.builtin.assert: + that: + - "item.1.current.0.fabricHIfPol.attributes.name == 'ansible_test'" + - "item.1.current.0.fabricHIfPol.attributes.dn == 'uni/infra/hintfpol-ansible_test'" + - "item.1.current.0.fabricHIfPol.attributes.speed == 'inherit'" + - "item.1.proposed.fabricHIfPol.attributes.speed == item.0" + quiet: true + loop: "{{ supported_speed | zip(cm_add_policy_speed.results) }}" + loop_control: + label: "speed-{{ item.0 }}" # QUERY ALL LINK LEVEL POLICIES - name: Query all Link Level Policies (check mode) - aci_interface_policy_link_level: &interface_policy_link_level_query + cisco.aci.aci_interface_policy_link_level: &interface_policy_link_level_query host: '{{ aci_hostname }}' username: '{{ aci_username }}' password: '{{ aci_password }}' @@ -154,11 +229,11 @@ register: cm_query_all_policies - name: Query all Link Level Policies (normal mode) - aci_interface_policy_link_level: *interface_policy_link_level_query + cisco.aci.aci_interface_policy_link_level: *interface_policy_link_level_query register: nm_query_all_policies - name: Verify query_all_policies - assert: + ansible.builtin.assert: that: - cm_query_all_policies is not changed - nm_query_all_policies is not changed @@ -167,20 +242,20 @@ # QUERY A LINK LEVEL POLICY - name: Query our Link Level Policy (check mode) - aci_interface_policy_link_level: + cisco.aci.aci_interface_policy_link_level: <<: *interface_policy_link_level_query link_level_policy: ansible_test check_mode: true register: cm_query_policy - name: Query our Link Level Policy (normal mode) - aci_interface_policy_link_level: + cisco.aci.aci_interface_policy_link_level: <<: *interface_policy_link_level_query link_level_policy: ansible_test register: nm_query_policy - name: Verify query_policy - assert: + ansible.builtin.assert: that: - cm_query_policy is not changed - nm_query_policy is not changed @@ -191,16 +266,16 @@ # REMOVE LINK LEVEL POLICY - name: Remove Link Level Policy (check mode) - aci_interface_policy_link_level: *interface_policy_link_level_absent + cisco.aci.aci_interface_policy_link_level: *interface_policy_link_level_absent check_mode: true register: cm_remove_policy - name: Remove Link Level Policy (normal mode) - aci_interface_policy_link_level: *interface_policy_link_level_absent + cisco.aci.aci_interface_policy_link_level: *interface_policy_link_level_absent register: nm_remove_policy - name: Verify remove_policy - assert: + ansible.builtin.assert: that: - cm_remove_policy is changed - nm_remove_policy is changed @@ -210,16 +285,16 @@ - nm_remove_policy.current == [] - name: Remove Link Level Policy again (check mode) - aci_interface_policy_link_level: *interface_policy_link_level_absent + cisco.aci.aci_interface_policy_link_level: *interface_policy_link_level_absent check_mode: true register: cm_remove_policy_again - name: Remove Link Level Policy again (normal mode) - aci_interface_policy_link_level: *interface_policy_link_level_absent + cisco.aci.aci_interface_policy_link_level: *interface_policy_link_level_absent register: nm_remove_policy_again - name: Verify remove_policy_again - assert: + ansible.builtin.assert: that: - cm_remove_policy_again is not changed - nm_remove_policy_again is not changed @@ -229,20 +304,20 @@ # QUERY NON-EXISTING LINK LEVEL POLICY - name: Query non-existing Link Level Policy (check mode) - aci_interface_policy_link_level: + cisco.aci.aci_interface_policy_link_level: <<: *interface_policy_link_level_query link_level_policy: ansible_test check_mode: true register: cm_query_non_policy - name: Query non-existing Link Level Policy (normal mode) - aci_interface_policy_link_level: + cisco.aci.aci_interface_policy_link_level: <<: *interface_policy_link_level_query link_level_policy: ansible_test register: nm_query_non_policy - name: Verify query_non_policy - assert: + ansible.builtin.assert: that: - cm_query_non_policy is not changed - nm_query_non_policy is not changed @@ -251,7 +326,7 @@ # PROVOKE ERRORS - REQUIRED PARAMETER MISSING - name: Error when required parameter is missing - aci_interface_policy_link_level: + cisco.aci.aci_interface_policy_link_level: host: '{{ aci_hostname }}' username: '{{ aci_username }}' password: '{{ aci_password }}' @@ -264,14 +339,14 @@ register: error_on_missing_required_param - name: Verify error_on_missing_required_param - assert: + ansible.builtin.assert: that: - error_on_missing_required_param is failed - 'error_on_missing_required_param.msg == "state is present but all of the following are missing: link_level_policy"' # PROVOKE ERRORS - DEBOUNCE OUT OF RANGE - name: Error when link debounce interval is out of range - aci_interface_policy_link_level: + cisco.aci.aci_interface_policy_link_level: host: '{{ aci_hostname }}' username: '{{ aci_username }}' password: '{{ aci_password }}' @@ -286,7 +361,7 @@ register: error_on_debounce_out_of_range - name: Verify error_on_debounce_out_of_range - assert: + ansible.builtin.assert: that: - error_on_debounce_out_of_range is failed - 'error_on_debounce_out_of_range.msg == "The \"link_debounce_interval\" must be a value between 0 and 5000"'
\ No newline at end of file diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_interface_policy_lldp/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_interface_policy_lldp/tasks/main.yml index 225e142ba..f06adae80 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_interface_policy_lldp/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_interface_policy_lldp/tasks/main.yml @@ -4,12 +4,12 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: "{{ aci_hostname }}" username: "{{ aci_username }}" @@ -20,14 +20,14 @@ output_level: debug - name: Verify Cloud and Non-Cloud Sites in use. - include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml - name: Execute tasks only for non-cloud sites when: query_cloud.current == [] # This condition will execute only non-cloud sites block: # block specifies execution of tasks within, based on conditions # Clean Environment - name: Ensure first lldp interface policy does not exist - aci_interface_policy_lldp: &aci_interface_policy_lldp_absent + cisco.aci.aci_interface_policy_lldp: &aci_interface_policy_lldp_absent <<: *aci_info name: anstest_policy description: test for lldp interface policy @@ -36,36 +36,36 @@ state: absent - name: Ensure second lldp interface policy does not exist - aci_interface_policy_lldp: &aci_interface_policy_lldp_2_absent + cisco.aci.aci_interface_policy_lldp: &aci_interface_policy_lldp_2_absent <<: *aci_info name: anstest_policy_2 state: absent - name: Create first lldp interface policy (check_mode) - aci_interface_policy_lldp: &aci_interface_policy_lldp_present + cisco.aci.aci_interface_policy_lldp: &aci_interface_policy_lldp_present <<: *aci_interface_policy_lldp_absent state: present check_mode: true register: cm_add_interface_policy_lldp_1 - name: Create first lldp interface policy (normal_mode) - aci_interface_policy_lldp: + cisco.aci.aci_interface_policy_lldp: <<: *aci_interface_policy_lldp_present register: nm_add_interface_policy_lldp_1 - name: Create first lldp interface policy again - testing idempotency - aci_interface_policy_lldp: + cisco.aci.aci_interface_policy_lldp: <<: *aci_interface_policy_lldp_present register: idempotency_add_interface_policy_lldp_1 - name: Create second lldp interface policy - aci_interface_policy_lldp: &aci_interface_policy_lldp_2_present + cisco.aci.aci_interface_policy_lldp: &aci_interface_policy_lldp_2_present <<: *aci_interface_policy_lldp_2_absent state: present register: nm_add_interface_policy_lldp_2 - name: Asserts for creation tasks - assert: + ansible.builtin.assert: that: - cm_add_interface_policy_lldp_1 is changed - cm_add_interface_policy_lldp_1.previous == [] @@ -81,19 +81,19 @@ - nm_add_interface_policy_lldp_2.current.0.lldpIfPol.attributes.adminTxSt == "enabled" - name: Query all lldp interface policies - aci_interface_policy_lldp: + cisco.aci.aci_interface_policy_lldp: <<: *aci_info state: query register: query_all_interface_policy_lldp - name: Query first lldp interface policy - aci_interface_policy_lldp: + cisco.aci.aci_interface_policy_lldp: <<: *aci_interface_policy_lldp_present state: query register: query_first_interface_policy_lldp - name: Asserts for query tasks - assert: + ansible.builtin.assert: that: - query_all_interface_policy_lldp is not changed - query_all_interface_policy_lldp.current | length >= 2 @@ -104,32 +104,32 @@ - query_first_interface_policy_lldp.current.0.lldpIfPol.attributes.adminTxSt == "disabled" - name: Delete first lldp interface policy (check_mode) - aci_interface_policy_lldp: + cisco.aci.aci_interface_policy_lldp: <<: *aci_interface_policy_lldp_present state: absent check_mode: true register: cm_delete_interface_policy_lldp_1 - name: Delete first lldp interface policy (normal_mode) - aci_interface_policy_lldp: + cisco.aci.aci_interface_policy_lldp: <<: *aci_interface_policy_lldp_present state: absent register: nm_delete_interface_policy_lldp_1 - name: Delete first lldp interface policy again - testing idempotency - aci_interface_policy_lldp: + cisco.aci.aci_interface_policy_lldp: <<: *aci_interface_policy_lldp_present state: absent register: idempotency_delete_interface_policy_lldp_1 - name: Delete second lldp interface policy (normal_mode) - aci_interface_policy_lldp: + cisco.aci.aci_interface_policy_lldp: <<: *aci_interface_policy_lldp_2_present state: absent register: nm_delete_interface_policy_lldp_2 - name: Asserts for deletion tasks - assert: + ansible.builtin.assert: that: - cm_delete_interface_policy_lldp_1 is changed - cm_delete_interface_policy_lldp_1.proposed == {} diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_interface_policy_mcp/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_interface_policy_mcp/tasks/main.yml index 7255c14ad..63ceb0f45 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_interface_policy_mcp/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_interface_policy_mcp/tasks/main.yml @@ -4,12 +4,12 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: "{{ aci_hostname }}" username: "{{ aci_username }}" @@ -20,14 +20,14 @@ output_level: debug - name: Verify Cloud and Non-Cloud Sites in use. - include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml - name: Execute tasks only for non-cloud sites when: query_cloud.current == [] # This condition will execute only non-cloud sites block: # block specifies execution of tasks within, based on conditions # Clean Environment - name: Ensure first mcp interface policy does not exist - APIC version >= 5.0 - aci_interface_policy_mcp: &aci_interface_policy_mcp_absent_5 + cisco.aci.aci_interface_policy_mcp: &aci_interface_policy_mcp_absent_5 <<: *aci_info name: anstest_policy description: test for mcp interface policy @@ -42,7 +42,7 @@ when: version.current.0.topSystem.attributes.version is version('5', '>=') - name: Ensure first mcp interface policy does not exist - aci_interface_policy_mcp: &aci_interface_policy_mcp_absent + cisco.aci.aci_interface_policy_mcp: &aci_interface_policy_mcp_absent <<: *aci_info name: anstest_policy description: test for mcp interface policy @@ -51,13 +51,13 @@ when: version.current.0.topSystem.attributes.version is version('5', '<') - name: Ensure second mcp interface policy does not exist - aci_interface_policy_mcp: &aci_interface_policy_mcp_2_absent + cisco.aci.aci_interface_policy_mcp: &aci_interface_policy_mcp_2_absent <<: *aci_info name: anstest_policy_2 state: absent - name: Create first mcp interface policy (check_mode) - APIC version >= 5.0 - aci_interface_policy_mcp: &aci_interface_policy_mcp_present_5 + cisco.aci.aci_interface_policy_mcp: &aci_interface_policy_mcp_present_5 <<: *aci_interface_policy_mcp_absent_5 state: present check_mode: true @@ -65,19 +65,19 @@ when: version.current.0.topSystem.attributes.version is version('5', '>=') - name: Create first mcp interface policy (normal_mode) - APIC version >= 5.0 - aci_interface_policy_mcp: + cisco.aci.aci_interface_policy_mcp: <<: *aci_interface_policy_mcp_present_5 register: nm_add_interface_policy_mcp_1_5 when: version.current.0.topSystem.attributes.version is version('5', '>=') - name: Create first mcp interface policy again - testing idempotency - APIC version >= 5.0 - aci_interface_policy_mcp: + cisco.aci.aci_interface_policy_mcp: <<: *aci_interface_policy_mcp_present_5 register: idempotency_add_interface_policy_mcp_1_5 when: version.current.0.topSystem.attributes.version is version('5', '>=') - name: Create first mcp interface policy (check_mode) - APIC version < 5.0 - aci_interface_policy_mcp: &aci_interface_policy_mcp_present + cisco.aci.aci_interface_policy_mcp: &aci_interface_policy_mcp_present <<: *aci_interface_policy_mcp_absent state: present check_mode: true @@ -85,25 +85,25 @@ when: version.current.0.topSystem.attributes.version is version('5', '<') - name: Create first mcp interface policy (normal_mode) - APIC version < 5.0 - aci_interface_policy_mcp: + cisco.aci.aci_interface_policy_mcp: <<: *aci_interface_policy_mcp_present register: nm_add_interface_policy_mcp_1 when: version.current.0.topSystem.attributes.version is version('5', '<') - name: Create first mcp interface policy again - testing idempotency - APIC version < 5.0 - aci_interface_policy_mcp: + cisco.aci.aci_interface_policy_mcp: <<: *aci_interface_policy_mcp_present register: idempotency_add_interface_policy_mcp_1 when: version.current.0.topSystem.attributes.version is version('5', '<') - name: Create second mcp interface policy - aci_interface_policy_mcp: &aci_interface_policy_mcp_2_present + cisco.aci.aci_interface_policy_mcp: &aci_interface_policy_mcp_2_present <<: *aci_interface_policy_mcp_2_absent state: present register: nm_add_interface_policy_mcp_2 - name: Asserts for creation tasks for first mcp interface policy - APIC version >= 5.0 - assert: + ansible.builtin.assert: that: - cm_add_interface_policy_mcp_1_5 is changed - cm_add_interface_policy_mcp_1_5.previous == [] @@ -115,7 +115,7 @@ when: version.current.0.topSystem.attributes.version is version('5', '>=') - name: Asserts for creation tasks for first mcp interface policy - APIC version < 5.0 - assert: + ansible.builtin.assert: that: - cm_add_interface_policy_mcp_1 is changed - cm_add_interface_policy_mcp_1.previous == [] @@ -127,55 +127,55 @@ when: version.current.0.topSystem.attributes.version is version('5', '<') - name: Asserts for creation tasks for second mcp interface policy - assert: + ansible.builtin.assert: that: - nm_add_interface_policy_mcp_2 is changed - nm_add_interface_policy_mcp_2.current.0.mcpIfPol.attributes.name == "anstest_policy_2" - nm_add_interface_policy_mcp_2.current.0.mcpIfPol.attributes.adminSt == "enabled" - name: Query all mcp interface policies - aci_interface_policy_mcp: + cisco.aci.aci_interface_policy_mcp: <<: *aci_info state: query register: query_all_interface_policy_mcp - name: Query first mcp interface policy - aci_interface_policy_mcp: + cisco.aci.aci_interface_policy_mcp: <<: *aci_interface_policy_mcp_present_5 state: query register: query_first_interface_policy_mcp_5 when: version.current.0.topSystem.attributes.version is version('5', '>=') - name: Query first mcp interface policy - aci_interface_policy_mcp: + cisco.aci.aci_interface_policy_mcp: <<: *aci_interface_policy_mcp_present state: query register: query_first_interface_policy_mcp when: version.current.0.topSystem.attributes.version is version('5', '<') - name: Asserts for query tasks - assert: + ansible.builtin.assert: that: - query_all_interface_policy_mcp is not changed - query_all_interface_policy_mcp.current | length >= 2 - '"class/mcpIfPol.json" in query_all_interface_policy_mcp.url' - name: Asserts for individual query tasks - APIC version >= 5.0 - assert: + ansible.builtin.assert: that: - query_first_interface_policy_mcp_5.current.0.mcpIfPol.attributes.name == "anstest_policy" - query_first_interface_policy_mcp_5.current.0.mcpIfPol.attributes.adminSt == "disabled" when: version.current.0.topSystem.attributes.version is version('5', '>=') - name: Asserts for individual query tasks - APIC version < 5.0 - assert: + ansible.builtin.assert: that: - query_first_interface_policy_mcp.current.0.mcpIfPol.attributes.name == "anstest_policy" - query_first_interface_policy_mcp.current.0.mcpIfPol.attributes.adminSt == "disabled" when: version.current.0.topSystem.attributes.version is version('5', '<') - name: Delete first mcp interface policy (check_mode) - APIC version >= 5.0 - aci_interface_policy_mcp: + cisco.aci.aci_interface_policy_mcp: <<: *aci_interface_policy_mcp_present_5 state: absent check_mode: true @@ -183,21 +183,21 @@ when: version.current.0.topSystem.attributes.version is version('5', '>=') - name: Delete first mcp interface policy (normal_mode) - APIC version >= 5.0 - aci_interface_policy_mcp: + cisco.aci.aci_interface_policy_mcp: <<: *aci_interface_policy_mcp_present_5 state: absent register: nm_delete_interface_policy_mcp_1_5 when: version.current.0.topSystem.attributes.version is version('5', '>=') - name: Delete first mcp interface policy again - testing idempotency - APIC version >= 5.0 - aci_interface_policy_mcp: + cisco.aci.aci_interface_policy_mcp: <<: *aci_interface_policy_mcp_present_5 state: absent register: idempotency_delete_interface_policy_mcp_1_5 when: version.current.0.topSystem.attributes.version is version('5', '>=') - name: Delete first mcp interface policy (check_mode) - APIC version < 5.0 - aci_interface_policy_mcp: + cisco.aci.aci_interface_policy_mcp: <<: *aci_interface_policy_mcp_present state: absent check_mode: true @@ -205,27 +205,27 @@ when: version.current.0.topSystem.attributes.version is version('5', '<') - name: Delete first mcp interface policy (normal_mode) - APIC version < 5.0 - aci_interface_policy_mcp: + cisco.aci.aci_interface_policy_mcp: <<: *aci_interface_policy_mcp_present state: absent register: nm_delete_interface_policy_mcp_1 when: version.current.0.topSystem.attributes.version is version('5', '<') - name: Delete first mcp interface policy again - testing idempotency - APIC version < 5.0 - aci_interface_policy_mcp: + cisco.aci.aci_interface_policy_mcp: <<: *aci_interface_policy_mcp_present state: absent register: idempotency_delete_interface_policy_mcp_1 when: version.current.0.topSystem.attributes.version is version('5', '<') - name: Delete second mcp interface policy (normal_mode) - aci_interface_policy_mcp: + cisco.aci.aci_interface_policy_mcp: <<: *aci_interface_policy_mcp_2_present state: absent register: nm_delete_interface_policy_mcp_2 - name: Asserts for first mcp interface policy deletion tasks - APIC version >= 5.0 - assert: + ansible.builtin.assert: that: - cm_delete_interface_policy_mcp_1_5 is changed - cm_delete_interface_policy_mcp_1_5.proposed == {} @@ -237,7 +237,7 @@ when: version.current.0.topSystem.attributes.version is version('5', '>=') - name: Asserts for first mcp interface policy deletion tasks - APIC version < 5.0 - assert: + ansible.builtin.assert: that: - cm_delete_interface_policy_mcp_1 is changed - cm_delete_interface_policy_mcp_1.proposed == {} @@ -249,7 +249,7 @@ when: version.current.0.topSystem.attributes.version is version('5', '<') - name: Asserts for second mcp interface policy deletion tasks - assert: + ansible.builtin.assert: that: - nm_delete_interface_policy_mcp_2.previous != [] - nm_delete_interface_policy_mcp_2.current == [] diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_interface_policy_ospf/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_interface_policy_ospf/tasks/main.yml index 71e096435..5dce71fcb 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_interface_policy_ospf/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_interface_policy_ospf/tasks/main.yml @@ -4,12 +4,12 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: '{{ aci_hostname }}' username: '{{ aci_username }}' @@ -53,7 +53,7 @@ register: nm_add_ospf_interface_policy_again - name: Verify add_ospf_interface_policy - assert: + ansible.builtin.assert: that: - cm_add_ospf_interface_policy is changed - cm_add_ospf_interface_policy.current == [] @@ -134,7 +134,7 @@ register: nm_add_ospf_descr_again - name: Verify add_ospf_descr - assert: + ansible.builtin.assert: that: - cm_add_ospf_descr is changed - cm_add_ospf_descr.previous.0.ospfIfPol.attributes.annotation == "orchestrator:ansible" @@ -256,7 +256,7 @@ register: err_change_ospf_transmit_delay - name: Verify cost change and error input values - assert: + ansible.builtin.assert: that: - err_change_ospf_cost is not changed - err_change_ospf_cost.msg == "Parameter 'cost' is only valid in range between 1 and 450." @@ -282,7 +282,7 @@ register: nm_add_ospf_again_no_descr - name: Verify add_ospf_again_no_descr - assert: + ansible.builtin.assert: that: - cm_add_ospf_again_no_descr is not changed - nm_add_ospf_again_no_descr is not changed @@ -308,7 +308,7 @@ register: nm_query_all_ospfs - name: Verify query_all_ospfs - assert: + ansible.builtin.assert: that: - cm_query_all_ospfs is not changed - nm_query_all_ospfs is not changed @@ -333,7 +333,7 @@ register: nm_query_ospf - name: Verify query_ospf - assert: + ansible.builtin.assert: that: - cm_query_ospf is not changed - nm_query_ospf is not changed @@ -360,7 +360,7 @@ register: nm_remove_ospf_again - name: Verify remove_ospf - assert: + ansible.builtin.assert: that: - cm_remove_ospf is changed - nm_remove_ospf is changed @@ -384,7 +384,7 @@ # TODO: Implement more tests - name: Verify query_non_ospf - assert: + ansible.builtin.assert: that: - cm_query_non_ospf is not changed - nm_query_non_ospf is not changed diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_interface_policy_pim/aliases b/ansible_collections/cisco/aci/tests/integration/targets/aci_interface_policy_pim/aliases new file mode 100644 index 000000000..209b793f9 --- /dev/null +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_interface_policy_pim/aliases @@ -0,0 +1,2 @@ +# No ACI simulator yet, so not enabled +# unsupported diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_interface_policy_pim/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_interface_policy_pim/tasks/main.yml new file mode 100644 index 000000000..df4914b7a --- /dev/null +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_interface_policy_pim/tasks/main.yml @@ -0,0 +1,275 @@ +# Test code for the ACI modules +# Copyright: (c) 2023, Gaspard Micol (@gmicol) <gmicol@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 APIC host, ACI username and ACI password + ansible.builtin.fail: + msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' + when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined + +- name: Set vars + ansible.builtin.set_fact: + aci_info: &aci_info + host: "{{ aci_hostname }}" + username: "{{ aci_username }}" + password: "{{ aci_password }}" + validate_certs: '{{ aci_validate_certs | default(false) }}' + use_ssl: '{{ aci_use_ssl | default(true) }}' + use_proxy: '{{ aci_use_proxy | default(true) }}' + output_level: '{{ aci_output_level | default("info") }}' + +# CLEAN ENVIRONMENT +- name: Remove the ansible_tenant + cisco.aci.aci_tenant: &aci_tenant_absent + <<: *aci_info + tenant: ansible_tenant + state: absent + +- name: Verify Cloud and Non-Cloud Sites in use. + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + +- name: Execute tasks only for non-cloud sites + when: query_cloud.current == [] # This condition will execute only non-cloud sites + block: # block specifies execution of tasks within, based on conditions + - name: Add a new tenant + cisco.aci.aci_tenant: &aci_tenant_present + <<: *aci_info + tenant: ansible_tenant + description: Ansible tenant + state: present + + - name: Add a new PIM route map policy + cisco.aci.aci_pim_route_map_policy: + <<: *aci_info + tenant: ansible_tenant + pim_route_map_policy: ansible_pim_route_map_policy + description: PIM route map policy 1 for ansible_tenant tenant + state: present + + # CREATION TASKS + - name: Add a pim interface policy (check_mode) + cisco.aci.aci_interface_policy_pim: &aci_interface_policy_pim_present + <<: *aci_info + tenant: ansible_tenant + pim: ansible_pim_interface_1 + description: pim interface policy 1 for ansible_tenant tenant + authentication_key: my_password + authentication_type: md5_hmac + control_state: [multicast_domain_boundary, strict_rfc_compliant, passive] + designated_router_delay: 6 + designated_router_priority: 2 + hello_interval: 60000 + join_prune_interval: 120 + inbound_join_prune_filter_policy: ansible_pim_route_map_policy + outbound_join_prune_filter_policy: ansible_pim_route_map_policy + neighbor_filter_policy: ansible_pim_route_map_policy + state: present + check_mode: true + register: cm_add_pim_interface + + - name: Add a pim interface policy (normal_mode) + cisco.aci.aci_interface_policy_pim: + <<: *aci_interface_policy_pim_present + register: nm_add_pim_interface + + - name: Add a second pim interface policy (normal_mode) + cisco.aci.aci_interface_policy_pim: + <<: *aci_info + tenant: ansible_tenant + pim: ansible_pim_interface_2 + description: pim interface policy 2 for ansible_tenant tenant + state: present + register: nm_add_pim_interface_2 + + - name: Add a third pim interface policy - designed router delay out of bounds + cisco.aci.aci_interface_policy_pim: + <<: *aci_info + tenant: ansible_tenant + pim: ansible_pim_interface_3 + designated_router_delay: 65536 + state: present + ignore_errors: true + register: error_dr_relay_out_of_bounds + + - name: Add a fourth pim interface policy - designed router priority out of bounds + cisco.aci.aci_interface_policy_pim: + <<: *aci_info + tenant: ansible_tenant + pim: ansible_pim_interface_4 + designated_router_priority: 4294967296 + state: present + ignore_errors: true + register: error_dr_priority_out_of_bounds + + - name: Add a fifth pim interface policy - hello interval out of bounds + cisco.aci.aci_interface_policy_pim: + <<: *aci_info + tenant: ansible_tenant + pim: ansible_pim_interface_5 + hello_interval: 18724287 + state: present + ignore_errors: true + register: error_helloIntvl_out_of_bounds + + - name: Add a sixth pim interface policy - join prune interval out of bounds + cisco.aci.aci_interface_policy_pim: + <<: *aci_info + tenant: ansible_tenant + pim: ansible_pim_interface_6 + join_prune_interval: 65521 + state: present + ignore_errors: true + register: error_jpIntvl_out_of_bounds + + - name: Asserts for pim interface policy creation tasks + ansible.builtin.assert: + that: + - cm_add_pim_interface is changed + - cm_add_pim_interface.previous == [] + - cm_add_pim_interface.current == [] + - nm_add_pim_interface is changed + - nm_add_pim_interface.current.0.pimIfPol.attributes.name == "ansible_pim_interface_1" + - nm_add_pim_interface.current.0.pimIfPol.attributes.authT == "ah-md5" + - nm_add_pim_interface.current.0.pimIfPol.attributes.ctrl == "border,passive,strict-rfc-compliant" + - nm_add_pim_interface.current.0.pimIfPol.attributes.drDelay == "6" + - nm_add_pim_interface.current.0.pimIfPol.attributes.drPrio == "2" + - nm_add_pim_interface.current.0.pimIfPol.attributes.helloItvl == "60000" + - nm_add_pim_interface.current.0.pimIfPol.attributes.jpInterval == "120" + - nm_add_pim_interface.sent.pimIfPol.attributes.authKey == "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER" + - nm_add_pim_interface_2 is changed + - nm_add_pim_interface_2.previous == [] + - nm_add_pim_interface_2.current.0.pimIfPol.attributes.name == "ansible_pim_interface_2" + - nm_add_pim_interface_2.current.0.pimIfPol.attributes.authT == "none" + - nm_add_pim_interface_2.current.0.pimIfPol.attributes.ctrl == "" + - nm_add_pim_interface_2.current.0.pimIfPol.attributes.drDelay == "3" + - nm_add_pim_interface_2.current.0.pimIfPol.attributes.drPrio == "1" + - nm_add_pim_interface_2.current.0.pimIfPol.attributes.helloItvl == "30000" + - nm_add_pim_interface_2.current.0.pimIfPol.attributes.jpInterval == "60" + - error_dr_relay_out_of_bounds.msg == "Parameter 'designated_router_delay' is only valid in range between 1 and 65535." + - error_dr_priority_out_of_bounds.msg == "Parameter 'designated_router_priority' is only valid in range between 1 and 4294967295." + - error_helloIntvl_out_of_bounds.msg == "Parameter 'hello_interval' is only valid in range between 1 and 18724286." + - error_jpIntvl_out_of_bounds.msg == "Parameter 'join_prune_interval' is only valid in range between 60 and 65520." + + # CREATION TASKS + - name: Query all pim interface policies + cisco.aci.aci_interface_policy_pim: + <<: *aci_info + state: query + register: query_all_pim_interface + + - name: Query ansible_pim_interface_1 + cisco.aci.aci_interface_policy_pim: + <<: *aci_interface_policy_pim_present + state: query + register: query_ansible_pim_interface_1 + + - name: Asserts query tasks + ansible.builtin.assert: + that: + - query_all_pim_interface is not changed + - query_all_pim_interface.current|length >= 2 + - query_ansible_pim_interface_1 is not changed + - query_ansible_pim_interface_1.current.0.pimIfPol.attributes.name == "ansible_pim_interface_1" + - query_ansible_pim_interface_1.current.0.pimIfPol.attributes.authT == "ah-md5" + - query_ansible_pim_interface_1.current.0.pimIfPol.attributes.ctrl == "border,passive,strict-rfc-compliant" + - query_ansible_pim_interface_1.current.0.pimIfPol.attributes.drDelay == "6" + - query_ansible_pim_interface_1.current.0.pimIfPol.attributes.drPrio == "2" + - query_ansible_pim_interface_1.current.0.pimIfPol.attributes.helloItvl == "60000" + - query_ansible_pim_interface_1.current.0.pimIfPol.attributes.jpInterval == "120" + + # UPDATE TASKS + - name: Update first pim interface policy (check_mode) + cisco.aci.aci_interface_policy_pim: &aci_interface_policy_pim_update + <<: *aci_interface_policy_pim_present + control_state: passive + designated_router_delay: 4 + designated_router_priority: 1 + hello_interval: 30000 + join_prune_interval: 60 + check_mode: true + register: cm_update_pim_interface + + - name: Update first pim interface policy (normal_mode) + cisco.aci.aci_interface_policy_pim: + <<: *aci_interface_policy_pim_update + register: nm_update_pim_interface + + - name: Asserts for pim interface policy update tasks + ansible.builtin.assert: + that: + - cm_update_pim_interface is changed + - cm_update_pim_interface.previous == cm_update_pim_interface.current + - nm_update_pim_interface is changed + - nm_update_pim_interface.current.0.pimIfPol.attributes.name == "ansible_pim_interface_1" + - nm_update_pim_interface.current.0.pimIfPol.attributes.authT == "ah-md5" + - nm_update_pim_interface.current.0.pimIfPol.attributes.ctrl == "passive" + - nm_update_pim_interface.current.0.pimIfPol.attributes.drDelay == "4" + - nm_update_pim_interface.current.0.pimIfPol.attributes.drPrio == "1" + - nm_update_pim_interface.current.0.pimIfPol.attributes.helloItvl == "30000" + - nm_update_pim_interface.current.0.pimIfPol.attributes.jpInterval == "60" + - nm_update_pim_interface.sent.pimIfPol.attributes.authKey == "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER" + + # CHILDREN DELETION TASKS + - name: Remove inbound join prune filter from pim interface policy (check_mode) + cisco.aci.aci_interface_policy_pim: &pim_interface_inbound_jp_absent + <<: *aci_interface_policy_pim_update + inbound_join_prune_filter_policy: "" + check_mode: true + register: cm_remove_pim_interface_inbound_jp + + - name: Remove inbound join prune filter from pim interface policy (normal_mode) + cisco.aci.aci_interface_policy_pim: + <<: *pim_interface_inbound_jp_absent + register: nm_remove_pim_interface_inbound_jp + + - name: Remove outbound join prune filter and neighbor filter from pim interface policy (normal_mode) + cisco.aci.aci_interface_policy_pim: + <<: *pim_interface_inbound_jp_absent + outbound_join_prune_filter_policy: "" + neighbor_filter_policy: "" + register: cm_remove_pim_interface_all_child_classes + + - name: Asserts child classes deletion tasks + ansible.builtin.assert: + that: + - cm_remove_pim_interface_inbound_jp is changed + - cm_remove_pim_interface_inbound_jp.current == cm_remove_pim_interface_inbound_jp.previous + - nm_remove_pim_interface_inbound_jp is changed + - nm_remove_pim_interface_inbound_jp.current.0.pimIfPol.children | length == 2 + - cm_remove_pim_interface_all_child_classes is changed + - cm_remove_pim_interface_all_child_classes.current.0.pimIfPol.children is not defined + + # DELETION TASKS + - name: Remove pim interface policy (check_mode) + cisco.aci.aci_interface_policy_pim: &pim_interface_absent + <<: *aci_interface_policy_pim_update + state: absent + check_mode: true + register: cm_remove_pim_interface + + - name: Remove pim interface policy (normal_mode) + cisco.aci.aci_interface_policy_pim: + <<: *pim_interface_absent + register: nm_remove_pim_interface + + - name: Remove pim interface policy - testing idempotency + cisco.aci.aci_interface_policy_pim: + <<: *pim_interface_absent + register: nm_remove_pim_interface_idempotency + + - name: Asserts deletion tasks + ansible.builtin.assert: + that: + - cm_remove_pim_interface is changed + - cm_remove_pim_interface.proposed == {} + - nm_remove_pim_interface is changed + - nm_remove_pim_interface.previous != [] + - nm_remove_pim_interface.current == [] + - nm_remove_pim_interface_idempotency is not changed + - nm_remove_pim_interface_idempotency.previous == [] + + - name: Remove the ansible_tenant - cleanup before ending tests + cisco.aci.aci_tenant: + <<: *aci_tenant_present + state: absent diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_interface_policy_port_channel/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_interface_policy_port_channel/tasks/main.yml index 36c84b30f..cac1bb65a 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_interface_policy_port_channel/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_interface_policy_port_channel/tasks/main.yml @@ -4,12 +4,12 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: "{{ aci_hostname }}" username: "{{ aci_username }}" @@ -20,14 +20,14 @@ output_level: debug - name: Verify Cloud and Non-Cloud Sites in use. - include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml - name: Execute tasks only for non-cloud sites when: query_cloud.current == [] # This condition will execute only non-cloud sites block: # block specifies execution of tasks within, based on conditions # Clean Environment - name: Ensure first port channel interface policy does not exist - aci_interface_policy_port_channel: &aci_interface_policy_port_channel_absent + cisco.aci.aci_interface_policy_port_channel: &aci_interface_policy_port_channel_absent <<: *aci_info name: anstest_policy description: test for port channel interface policy @@ -42,7 +42,7 @@ state: absent - name: Ensure second port channel interface policy does not exist - aci_interface_policy_port_channel: &aci_interface_policy_port_channel_2_absent + cisco.aci.aci_interface_policy_port_channel: &aci_interface_policy_port_channel_2_absent <<: *aci_info name: anstest_policy_2 fast_select: true @@ -51,44 +51,44 @@ state: absent - name: Create first port channel interface policy (check_mode) - aci_interface_policy_port_channel: &aci_interface_policy_port_channel_present + cisco.aci.aci_interface_policy_port_channel: &aci_interface_policy_port_channel_present <<: *aci_interface_policy_port_channel_absent state: present check_mode: true register: cm_add_interface_policy_port_channel_1 - name: Create first port channel interface policy (normal_mode) - aci_interface_policy_port_channel: + cisco.aci.aci_interface_policy_port_channel: <<: *aci_interface_policy_port_channel_present register: nm_add_interface_policy_port_channel_1 - name: Create first port channel interface policy again - testing idempotency - aci_interface_policy_port_channel: + cisco.aci.aci_interface_policy_port_channel: <<: *aci_interface_policy_port_channel_present register: idempotency_add_interface_policy_port_channel_1 - name: Create second port channel interface policy - aci_interface_policy_port_channel: &aci_interface_policy_port_channel_2_present + cisco.aci.aci_interface_policy_port_channel: &aci_interface_policy_port_channel_2_present <<: *aci_interface_policy_port_channel_2_absent state: present register: nm_add_interface_policy_port_channel_2 - name: Modify first port channel interface policy with max links above 16 - testing failure message - aci_interface_policy_port_channel: + cisco.aci.aci_interface_policy_port_channel: <<: *aci_interface_policy_port_channel_present max_links: 17 ignore_errors: true register: nm_policy_port_channel_max_links_failure - name: Modify first port channel interface policy with min links bellow 1 - testing failure message - aci_interface_policy_port_channel: + cisco.aci.aci_interface_policy_port_channel: <<: *aci_interface_policy_port_channel_present min_links: 0 ignore_errors: true register: nm_policy_port_channel_min_links_failure - name: Asserts for creation tasks - assert: + ansible.builtin.assert: that: - cm_add_interface_policy_port_channel_1 is changed - cm_add_interface_policy_port_channel_1.previous == [] @@ -110,19 +110,19 @@ - nm_policy_port_channel_min_links_failure.msg == "The \"min_links\" must be a value between 1 and 16" - name: Query all port channel interface policies - aci_interface_policy_port_channel: + cisco.aci.aci_interface_policy_port_channel: <<: *aci_info state: query register: query_all_interface_policy_port_channel - name: Query first port channel interface policy - aci_interface_policy_port_channel: + cisco.aci.aci_interface_policy_port_channel: <<: *aci_interface_policy_port_channel_present state: query register: query_first_interface_policy_port_channel - name: Asserts for query tasks - assert: + ansible.builtin.assert: that: - query_all_interface_policy_port_channel is not changed - query_all_interface_policy_port_channel.current | length >= 2 @@ -135,32 +135,32 @@ - query_first_interface_policy_port_channel.current.0.lacpLagPol.attributes.mode == "active" - name: Delete first port channel interface policy (check_mode) - aci_interface_policy_port_channel: + cisco.aci.aci_interface_policy_port_channel: <<: *aci_interface_policy_port_channel_present state: absent check_mode: true register: cm_delete_interface_policy_port_channel_1 - name: Delete first port channel interface policy (normal_mode) - aci_interface_policy_port_channel: + cisco.aci.aci_interface_policy_port_channel: <<: *aci_interface_policy_port_channel_present state: absent register: nm_delete_interface_policy_port_channel_1 - name: Delete first port channel interface policy again - testing idempotency - aci_interface_policy_port_channel: + cisco.aci.aci_interface_policy_port_channel: <<: *aci_interface_policy_port_channel_present state: absent register: idempotency_delete_interface_policy_port_channel_1 - name: Delete second port channel interface policy (normal_mode) - aci_interface_policy_port_channel: + cisco.aci.aci_interface_policy_port_channel: <<: *aci_interface_policy_port_channel_2_present state: absent register: nm_delete_interface_policy_port_channel_2 - name: Asserts for deletion tasks - assert: + ansible.builtin.assert: that: - cm_delete_interface_policy_port_channel_1 is changed - cm_delete_interface_policy_port_channel_1.proposed == {} diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_interface_policy_port_security/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_interface_policy_port_security/tasks/main.yml index c040bfb1e..9f4e958c4 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_interface_policy_port_security/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_interface_policy_port_security/tasks/main.yml @@ -4,12 +4,12 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: "{{ aci_hostname }}" username: "{{ aci_username }}" @@ -20,14 +20,14 @@ output_level: debug - name: Verify Cloud and Non-Cloud Sites in use. - include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml - name: Execute tasks only for non-cloud sites when: query_cloud.current == [] # This condition will execute only non-cloud sites block: # block specifies execution of tasks within, based on conditions # CLEAN ENVIRONMENT - name: Remove policy port security - aci_interface_policy_port_security: + cisco.aci.aci_interface_policy_port_security: <<: *aci_info port_security: '{{ item }}' state: absent @@ -38,7 +38,7 @@ # ADD - name: Add a port security interface policy - check mode - aci_interface_policy_port_security: + cisco.aci.aci_interface_policy_port_security: <<: *aci_info port_security: security1 description: security 1 @@ -49,7 +49,7 @@ register: port_security1_cm - name: Add a port security interface policy - normal mode - aci_interface_policy_port_security: + cisco.aci.aci_interface_policy_port_security: <<: *aci_info port_security: security1 description: security 1 @@ -59,7 +59,7 @@ register: port_security1_nm - name: Add a port security interface policy again - normal mode - aci_interface_policy_port_security: + cisco.aci.aci_interface_policy_port_security: <<: *aci_info port_security: security1 description: security 1 @@ -69,7 +69,7 @@ register: port_security1_nm_again - name: Add a port security interface policy - normal mode - aci_interface_policy_port_security: + cisco.aci.aci_interface_policy_port_security: <<: *aci_info port_security: security2 description: security 2 @@ -80,7 +80,7 @@ register: port_security1_nm_error_timeout - name: Add a port security interface policy - normal mode - aci_interface_policy_port_security: + cisco.aci.aci_interface_policy_port_security: <<: *aci_info port_security: security3 description: security 3 @@ -91,7 +91,7 @@ register: port_security1_nm_error_max - name: Add a port security interface policy again for security 3- normal mode - aci_interface_policy_port_security: + cisco.aci.aci_interface_policy_port_security: <<: *aci_info port_security: security3 description: security 3 @@ -102,7 +102,7 @@ register: port_security1_nm_with_no_error - name: Verify present cases - assert: + ansible.builtin.assert: that: - port_security1_cm is changed - port_security1_nm is changed @@ -123,20 +123,20 @@ # QUERY - name: Query a port security interface policy - normal mode - aci_interface_policy_port_security: + cisco.aci.aci_interface_policy_port_security: <<: *aci_info port_security: security1 state: query register: port_security1_query - name: Query all port security interface policies - normal mode - aci_interface_policy_port_security: + cisco.aci.aci_interface_policy_port_security: <<: *aci_info state: query register: port_all_query - name: Verify query cases - assert: + ansible.builtin.assert: that: - port_security1_query is not changed - port_all_query is not changed @@ -149,14 +149,14 @@ # REMOVE - name: Remove a port security interface policy - normal mode - aci_interface_policy_port_security: + cisco.aci.aci_interface_policy_port_security: <<: *aci_info port_security: security1 state: absent register: port_security1_remove - name: Verify remove cases - assert: + ansible.builtin.assert: that: - port_security1_remove is changed - port_security1_remove.previous.0.l2PortSecurityPol.attributes.dn == "uni/infra/portsecurityP-security1" @@ -167,7 +167,7 @@ # CLEAN END - name: Remove all policy port securities - aci_interface_policy_port_security: + cisco.aci.aci_interface_policy_port_security: <<: *aci_info port_security: '{{ item }}' state: absent diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_interface_policy_spanning_tree/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_interface_policy_spanning_tree/tasks/main.yml index 3bb33d896..aad106ae6 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_interface_policy_spanning_tree/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_interface_policy_spanning_tree/tasks/main.yml @@ -4,12 +4,12 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: "{{ aci_hostname }}" username: "{{ aci_username }}" @@ -20,14 +20,14 @@ output_level: "{{ aci_output_level | default('info') }}" - name: Verify Cloud and Non-Cloud Sites in use. - include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml - name: Execute tasks only for non-cloud sites when: query_cloud.current == [] # This condition will execute only non-cloud sites block: # block specifies execution of tasks within, based on conditions # CLEAN ENVIRONMENT - name: Remove policy spanning tree - aci_interface_policy_spanning_tree: + cisco.aci.aci_interface_policy_spanning_tree: <<: *aci_info stp_policy: "{{ item }}" state: absent @@ -38,7 +38,7 @@ # ADD - name: Add a spanning tree interface policy BPDU Guard - check mode - aci_interface_policy_spanning_tree: + cisco.aci.aci_interface_policy_spanning_tree: <<: *aci_info stp_policy: stp_bpduguard description: BPDU Guard @@ -48,7 +48,7 @@ register: stp_bpduguard_cm - name: Add a spanning tree interface policy BPDU Guard - normal mode - aci_interface_policy_spanning_tree: + cisco.aci.aci_interface_policy_spanning_tree: <<: *aci_info stp_policy: stp_bpduguard description: BPDU Guard @@ -57,7 +57,7 @@ register: stp_bpduguard_nm - name: Add a spanning tree interface policy BPDU Guard - normal mode again - aci_interface_policy_spanning_tree: + cisco.aci.aci_interface_policy_spanning_tree: <<: *aci_info stp_policy: stp_bpduguard description: BPDU Guard @@ -66,7 +66,7 @@ register: stp_bpduguard_nm_again - name: Add a spanning tree interface policy BPDU Filter - check mode - aci_interface_policy_spanning_tree: + cisco.aci.aci_interface_policy_spanning_tree: <<: *aci_info stp_policy: stp_bpdufilter description: BPDU Filter @@ -76,7 +76,7 @@ register: stp_bpdufilter_cm - name: Add a spanning tree interface policy BPDU Filter - normal mode - aci_interface_policy_spanning_tree: + cisco.aci.aci_interface_policy_spanning_tree: <<: *aci_info stp_policy: stp_bpdufilter description: BPDU Filter @@ -85,7 +85,7 @@ register: stp_bpdufilter_nm - name: Add a spanning tree interface policy BPDU Filter - normal mode again - aci_interface_policy_spanning_tree: + cisco.aci.aci_interface_policy_spanning_tree: <<: *aci_info stp_policy: stp_bpdufilter description: BPDU Filter @@ -94,7 +94,7 @@ register: stp_bpdufilter_nm_again - name: Add a spanning tree interface policy Both - normal mode - aci_interface_policy_spanning_tree: + cisco.aci.aci_interface_policy_spanning_tree: <<: *aci_info stp_policy: stp_both description: Both controls @@ -104,7 +104,7 @@ register: stp_both_nm - name: Add a spanning tree interface policy Both - normal mode again - aci_interface_policy_spanning_tree: + cisco.aci.aci_interface_policy_spanning_tree: <<: *aci_info stp_policy: stp_both description: Both controls @@ -114,7 +114,7 @@ register: stp_both_nm_again - name: verify add tasks - assert: + ansible.builtin.assert: that: - stp_bpduguard_cm is changed - stp_bpduguard_nm is changed @@ -130,20 +130,20 @@ # QUERY - name: Query a spanning tree interface policy - aci_interface_policy_spanning_tree: + cisco.aci.aci_interface_policy_spanning_tree: <<: *aci_info stp_policy: stp_both state: query register: stp_query_both - name: Query all spanning tree interface policies - aci_interface_policy_spanning_tree: + cisco.aci.aci_interface_policy_spanning_tree: <<: *aci_info state: query register: stp_query_all - name: verify query tasks - assert: + ansible.builtin.assert: that: - stp_query_both is not changed - stp_query_all is not changed @@ -152,7 +152,7 @@ # CLEAN ENVIRONMENT - name: Remove policy port security - aci_interface_policy_spanning_tree: + cisco.aci.aci_interface_policy_spanning_tree: <<: *aci_info stp_policy: "{{ item }}" state: absent diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_interface_policy_spine_policy_group/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_interface_policy_spine_policy_group/tasks/main.yml index fec8415a3..534614450 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_interface_policy_spine_policy_group/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_interface_policy_spine_policy_group/tasks/main.yml @@ -4,12 +4,12 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: "{{ aci_hostname }}" username: "{{ aci_username }}" @@ -20,7 +20,7 @@ output_level: debug - name: Verify Cloud and Non-Cloud Sites in use. - include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml - name: Execute tasks only for non-cloud sites when: query_cloud.current == [] # This condition will execute only non-cloud sites @@ -65,7 +65,7 @@ register: intf_policy_spine_polgrp_update - name: Verify present assertions for Spine Policy Group - assert: + ansible.builtin.assert: that: - intf_policy_spine_polgrp_check_mode_present is changed - intf_policy_spine_polgrp_present is changed @@ -97,7 +97,7 @@ register: query_spine_policy_group - name: Verify query assertions for Spine Policy Group - assert: + ansible.builtin.assert: that: - query_spine_policy_group is not changed - query_spine_policy_group.current[0] | length >= 1 @@ -120,7 +120,7 @@ register: intf_policy_spine_polgrp_absent_idempotent - name: Verify absent assertions for Spine Policy Group - assert: + ansible.builtin.assert: that: - intf_policy_spine_polgrp_check_mode_absent is changed - intf_policy_spine_polgrp_check_mode_absent.previous != [] diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_interface_policy_storm_control/aliases b/ansible_collections/cisco/aci/tests/integration/targets/aci_interface_policy_storm_control/aliases new file mode 100644 index 000000000..209b793f9 --- /dev/null +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_interface_policy_storm_control/aliases @@ -0,0 +1,2 @@ +# No ACI simulator yet, so not enabled +# unsupported diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_interface_policy_storm_control/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_interface_policy_storm_control/tasks/main.yml new file mode 100644 index 000000000..656a50213 --- /dev/null +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_interface_policy_storm_control/tasks/main.yml @@ -0,0 +1,285 @@ +# Test code for the ACI modules +# Copyright: (c) 2023, Eric Girard <@netgirard> +# Copyright: (c) 2024, Gaspard Micol (@gmicol) <gmicol@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 APIC host, ACI username and ACI password + ansible.builtin.fail: + msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' + when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined + +- name: Set vars + ansible.builtin.set_fact: + aci_info: &aci_info + host: "{{ aci_hostname }}" + username: "{{ aci_username }}" + password: "{{ aci_password }}" + validate_certs: '{{ aci_validate_certs | default(false) }}' + use_ssl: '{{ aci_use_ssl | default(true) }}' + use_proxy: '{{ aci_use_proxy | default(true) }}' + output_level: '{{ aci_output_level | default("info") }}' + +- name: Verify Cloud and Non-Cloud Sites in use. + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + +- name: Execute tasks only for non-cloud sites + when: query_cloud.current == [] # This condition will execute only non-cloud sites + block: # block specifies execution of tasks within, based on conditions + - name: Remove all ansible Storm Control policies before test begins + cisco.aci.aci_interface_policy_storm_control: &caci_storm_control_policies_cleanup + <<: *aci_info + storm_control_policy: '{{ item }}' + state: absent + loop: + - ansible_storm_control_policy_1 + - ansible_storm_control_policy_2 + - ansible_storm_control_policy_3 + - ansible_storm_control_policy_4 + + # CREATE STORM CONTROL POLICY + - name: Add a Storm Control policy (check_mode) + cisco.aci.aci_interface_policy_storm_control: &aci_interface_policy_storm_control_present + <<: *aci_info + storm_control_policy: ansible_storm_control_policy_1 + description: Storm Control policy 1 + all_types_configuration: + rate: 100 + burst_rate: 125 + rate_type: pps + storm_control_action: shutdown + storm_control_soak_action: 5 + check_mode: true + register: cm_add_storm_control_policy + + - name: Add a Storm Control policy (normal_mode) + cisco.aci.aci_interface_policy_storm_control: + <<: *aci_interface_policy_storm_control_present + register: nm_add_storm_control_policy + + - name: Add the first Storm Control policy again - testing idempotency + cisco.aci.aci_interface_policy_storm_control: + <<: *aci_interface_policy_storm_control_present + register: nm_add_storm_control_policy_idempotency + + - name: Add a second Storm Control policy (normal_mode) + cisco.aci.aci_interface_policy_storm_control: &aci_interface_policy_storm_control_2_present + <<: *aci_info + storm_control_policy: ansible_storm_control_policy_2 + description: Storm Control policy 2 + broadcast_configuration: + rate: 100 + burst_rate: 125 + rate_type: pps + multicast_configuration: + rate: 75 + burst_rate: 100 + rate_type: pps + unicast_configuration: + rate: 50 + burst_rate: 75 + rate_type: pps + register: nm_add_storm_control_policy_2 + + - name: Add a third Storm Control Policy (normal_mode) - testing empty configuration for multicast and unicast + cisco.aci.aci_interface_policy_storm_control: + <<: *aci_info + storm_control_policy: ansible_storm_control_policy_3 + broadcast_configuration: + rate: 25 + burst_rate: 50 + rate_type: pps + register: nm_add_storm_control_policy_3 + + - name: Add a fourth Storm Control Policy with rate in percentage out of bonds - testing error message + cisco.aci.aci_interface_policy_storm_control: + <<: *aci_info + storm_control_policy: ansible_storm_control_policy_4 + all_types_configuration: + rate: 125 + burst_rate: 100 + rate_type: percentage + ignore_errors: true + register: nm_test_error_msg_storm_control_policy + + - name: Asserts for Storm Control policy creation tasks + ansible.builtin.assert: + that: + - cm_add_storm_control_policy is changed + - cm_add_storm_control_policy.previous == [] + - cm_add_storm_control_policy.current == [] + - cm_add_storm_control_policy.proposed.stormctrlIfPol.attributes.name == "ansible_storm_control_policy_1" + - cm_add_storm_control_policy.proposed.stormctrlIfPol.attributes.descr == "Storm Control policy 1" + - cm_add_storm_control_policy.proposed.stormctrlIfPol.attributes.ratePps == "100" + - cm_add_storm_control_policy.proposed.stormctrlIfPol.attributes.burstPps == "125" + - cm_add_storm_control_policy.proposed.stormctrlIfPol.attributes.isUcMcBcStormPktCfgValid == "Invalid" + - cm_add_storm_control_policy.proposed.stormctrlIfPol.attributes.stormCtrlAction == "shutdown" + - cm_add_storm_control_policy.proposed.stormctrlIfPol.attributes.stormCtrlSoakInstCount == "5" + - nm_add_storm_control_policy is changed + - nm_add_storm_control_policy.previous == [] + - nm_add_storm_control_policy.current.0.stormctrlIfPol.attributes.name == "ansible_storm_control_policy_1" + - nm_add_storm_control_policy.current.0.stormctrlIfPol.attributes.descr == "Storm Control policy 1" + - nm_add_storm_control_policy.current.0.stormctrlIfPol.attributes.ratePps == "100" + - nm_add_storm_control_policy.current.0.stormctrlIfPol.attributes.burstPps == "125" + - nm_add_storm_control_policy.current.0.stormctrlIfPol.attributes.isUcMcBcStormPktCfgValid == "Invalid" + - nm_add_storm_control_policy.current.0.stormctrlIfPol.attributes.stormCtrlAction == "shutdown" + - nm_add_storm_control_policy.current.0.stormctrlIfPol.attributes.stormCtrlSoakInstCount == "5" + - nm_add_storm_control_policy_idempotency is not changed + - nm_add_storm_control_policy_idempotency.current.0.stormctrlIfPol.attributes.name == "ansible_storm_control_policy_1" + - nm_add_storm_control_policy_idempotency.current.0.stormctrlIfPol.attributes.descr == "Storm Control policy 1" + - nm_add_storm_control_policy_idempotency.current.0.stormctrlIfPol.attributes.ratePps == "100" + - nm_add_storm_control_policy_idempotency.current.0.stormctrlIfPol.attributes.burstPps == "125" + - nm_add_storm_control_policy_idempotency.current.0.stormctrlIfPol.attributes.isUcMcBcStormPktCfgValid == "Invalid" + - nm_add_storm_control_policy_idempotency.current.0.stormctrlIfPol.attributes.stormCtrlAction == "shutdown" + - nm_add_storm_control_policy_idempotency.current.0.stormctrlIfPol.attributes.stormCtrlSoakInstCount == "5" + - nm_add_storm_control_policy_2 is changed + - nm_add_storm_control_policy_2.previous == [] + - nm_add_storm_control_policy_2.current.0.stormctrlIfPol.attributes.name == "ansible_storm_control_policy_2" + - nm_add_storm_control_policy_2.current.0.stormctrlIfPol.attributes.descr == "Storm Control policy 2" + - nm_add_storm_control_policy_2.current.0.stormctrlIfPol.attributes.bcRatePps == "100" + - nm_add_storm_control_policy_2.current.0.stormctrlIfPol.attributes.bcBurstPps == "125" + - nm_add_storm_control_policy_2.current.0.stormctrlIfPol.attributes.mcRatePps == "75" + - nm_add_storm_control_policy_2.current.0.stormctrlIfPol.attributes.mcBurstPps == "100" + - nm_add_storm_control_policy_2.current.0.stormctrlIfPol.attributes.uucRatePps == "50" + - nm_add_storm_control_policy_2.current.0.stormctrlIfPol.attributes.uucBurstPps == "75" + - nm_add_storm_control_policy_2.current.0.stormctrlIfPol.attributes.isUcMcBcStormPktCfgValid == "Valid" + - nm_add_storm_control_policy_2.current.0.stormctrlIfPol.attributes.stormCtrlAction == "drop" + - nm_add_storm_control_policy_2.current.0.stormctrlIfPol.attributes.stormCtrlSoakInstCount == "3" + - nm_add_storm_control_policy_3 is changed + - nm_add_storm_control_policy_3.previous == [] + - nm_add_storm_control_policy_3.current.0.stormctrlIfPol.attributes.name == "ansible_storm_control_policy_3" + - nm_add_storm_control_policy_3.current.0.stormctrlIfPol.attributes.bcRatePps == "25" + - nm_add_storm_control_policy_3.current.0.stormctrlIfPol.attributes.bcBurstPps == "50" + - nm_add_storm_control_policy_3.current.0.stormctrlIfPol.attributes.mcRatePps == "unspecified" + - nm_add_storm_control_policy_3.current.0.stormctrlIfPol.attributes.mcRate == "100.000000" + - nm_add_storm_control_policy_3.current.0.stormctrlIfPol.attributes.mcBurstPps == "unspecified" + - nm_add_storm_control_policy_3.current.0.stormctrlIfPol.attributes.mcBurstRate == "100.000000" + - nm_add_storm_control_policy_3.current.0.stormctrlIfPol.attributes.uucRatePps == "unspecified" + - nm_add_storm_control_policy_3.current.0.stormctrlIfPol.attributes.uucRate == "100.000000" + - nm_add_storm_control_policy_3.current.0.stormctrlIfPol.attributes.uucBurstPps == "unspecified" + - nm_add_storm_control_policy_3.current.0.stormctrlIfPol.attributes.uucBurstRate == "100.000000" + - nm_add_storm_control_policy_3.current.0.stormctrlIfPol.attributes.isUcMcBcStormPktCfgValid == "Valid" + - nm_add_storm_control_policy_3.current.0.stormctrlIfPol.attributes.stormCtrlAction == "drop" + - nm_add_storm_control_policy_3.current.0.stormctrlIfPol.attributes.stormCtrlSoakInstCount == "3" + - nm_test_error_msg_storm_control_policy.msg == "If argument rate_type is percentage, the rate needs to be a value between 0 and 100 inclusive, got 125" + + # QUERY STORM CONTROL POLICY + - name: Query all Storm Control policies + cisco.aci.aci_interface_policy_storm_control: + <<: *aci_info + state: query + register: query_all_storm_control_policy + + - name: Query ansible_storm_control_policy_1 + cisco.aci.aci_interface_policy_storm_control: + <<: *aci_interface_policy_storm_control_present + state: query + register: query_ansible_storm_control_policy_1 + + - name: Asserts query tasks + ansible.builtin.assert: + that: + - query_all_storm_control_policy is not changed + - query_all_storm_control_policy.current|length >= 2 + - query_ansible_storm_control_policy_1 is not changed + - query_ansible_storm_control_policy_1.current|length == 1 + - query_ansible_storm_control_policy_1.current.0.stormctrlIfPol.attributes.name == "ansible_storm_control_policy_1" + - query_ansible_storm_control_policy_1.current.0.stormctrlIfPol.attributes.descr == "Storm Control policy 1" + - query_ansible_storm_control_policy_1.current.0.stormctrlIfPol.attributes.ratePps == "100" + - query_ansible_storm_control_policy_1.current.0.stormctrlIfPol.attributes.burstPps == "125" + - query_ansible_storm_control_policy_1.current.0.stormctrlIfPol.attributes.isUcMcBcStormPktCfgValid == "Invalid" + - query_ansible_storm_control_policy_1.current.0.stormctrlIfPol.attributes.stormCtrlAction == "shutdown" + - query_ansible_storm_control_policy_1.current.0.stormctrlIfPol.attributes.stormCtrlSoakInstCount == "5" + + # UPDATE STORM CONTROL POLICY + - name: Update first Storm Control policy (check_mode) + cisco.aci.aci_interface_policy_storm_control: &aci_interface_policy_storm_control_update + <<: *aci_interface_policy_storm_control_present + description: Updated description for first ansible Storm Control policy + all_types_configuration: + rate: 50 + burst_rate: 75 + rate_type: percentage + storm_control_action: drop + check_mode: true + register: cm_update_storm_control_policy + + - name: Update first Storm Control policy (normal_mode) + cisco.aci.aci_interface_policy_storm_control: + <<: *aci_interface_policy_storm_control_update + register: nm_update_storm_control_policy + + - name: Update first Storm Control policy again - testing idempotency + cisco.aci.aci_interface_policy_storm_control: + <<: *aci_interface_policy_storm_control_update + register: nm_udpate_storm_control_policy_idempotency + + - name: Asserts for Storm Control policy update tasks + ansible.builtin.assert: + that: + - cm_update_storm_control_policy is changed + - cm_update_storm_control_policy.previous == cm_update_storm_control_policy.current + - cm_update_storm_control_policy.proposed.stormctrlIfPol.attributes.descr == "Updated description for first ansible Storm Control policy" + - cm_update_storm_control_policy.proposed.stormctrlIfPol.attributes.rate == "50.000000" + - cm_update_storm_control_policy.proposed.stormctrlIfPol.attributes.burstRate == "75.000000" + - cm_update_storm_control_policy.proposed.stormctrlIfPol.attributes.ratePps == "unspecified" + - cm_update_storm_control_policy.proposed.stormctrlIfPol.attributes.burstPps == "unspecified" + - cm_update_storm_control_policy.proposed.stormctrlIfPol.attributes.stormCtrlAction == "drop" + - nm_update_storm_control_policy is changed + - nm_update_storm_control_policy.current.0.stormctrlIfPol.attributes.name == "ansible_storm_control_policy_1" + - nm_update_storm_control_policy.current.0.stormctrlIfPol.attributes.descr == "Updated description for first ansible Storm Control policy" + - nm_update_storm_control_policy.current.0.stormctrlIfPol.attributes.rate == "50.000000" + - nm_update_storm_control_policy.current.0.stormctrlIfPol.attributes.burstRate == "75.000000" + - nm_update_storm_control_policy.current.0.stormctrlIfPol.attributes.ratePps == "unspecified" + - nm_update_storm_control_policy.current.0.stormctrlIfPol.attributes.burstPps == "unspecified" + - nm_update_storm_control_policy.current.0.stormctrlIfPol.attributes.stormCtrlAction == "drop" + - nm_udpate_storm_control_policy_idempotency is not changed + - nm_udpate_storm_control_policy_idempotency.current.0.stormctrlIfPol.attributes.name == "ansible_storm_control_policy_1" + - nm_udpate_storm_control_policy_idempotency.current.0.stormctrlIfPol.attributes.descr == "Updated description for first ansible Storm Control policy" + - nm_udpate_storm_control_policy_idempotency.current.0.stormctrlIfPol.attributes.rate == "50.000000" + - nm_udpate_storm_control_policy_idempotency.current.0.stormctrlIfPol.attributes.burstRate == "75.000000" + - nm_udpate_storm_control_policy_idempotency.current.0.stormctrlIfPol.attributes.ratePps == "unspecified" + - nm_udpate_storm_control_policy_idempotency.current.0.stormctrlIfPol.attributes.burstPps == "unspecified" + - nm_udpate_storm_control_policy_idempotency.current.0.stormctrlIfPol.attributes.stormCtrlAction == "drop" + + # DELETE STORM CONTROL POLICY + - name: Remove Storm Control policy (check_mode) + cisco.aci.aci_interface_policy_storm_control: &storm_control_policy_absent + <<: *aci_interface_policy_storm_control_update + state: absent + check_mode: true + register: cm_remove_storm_control_policy + + - name: Remove Storm Control policy (normal_mode) + cisco.aci.aci_interface_policy_storm_control: + <<: *storm_control_policy_absent + register: nm_remove_storm_control_policy + + - name: Remove Storm Control policy - testing idempotency + cisco.aci.aci_interface_policy_storm_control: + <<: *storm_control_policy_absent + register: nm_remove_storm_control_policy_idempotency + + - name: Asserts deletion tasks + ansible.builtin.assert: + that: + - cm_remove_storm_control_policy is changed + - cm_remove_storm_control_policy.current == cm_remove_storm_control_policy.previous + - cm_remove_storm_control_policy.proposed == {} + - nm_remove_storm_control_policy is changed + - nm_remove_storm_control_policy.previous != [] + - nm_remove_storm_control_policy.proposed == {} + - nm_remove_storm_control_policy.current == [] + - nm_remove_storm_control_policy_idempotency is not changed + - nm_remove_storm_control_policy_idempotency.previous == [] + - nm_remove_storm_control_policy_idempotency.current == [] + + # CLEAN ENVIRONMENT BEFORE ENDING TESTS + - name: Remove all ansible Storm Control Policies - cleanup before ending tests + cisco.aci.aci_interface_policy_storm_control: + <<: *caci_storm_control_policies_cleanup + loop: + - ansible_storm_control_policy_1 + - ansible_storm_control_policy_2 + - ansible_storm_control_policy_3 + - ansible_storm_control_policy_4 diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_interface_selector_to_switch_policy_leaf_profile/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_interface_selector_to_switch_policy_leaf_profile/tasks/main.yml index 099b2eed9..4b5c32455 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_interface_selector_to_switch_policy_leaf_profile/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_interface_selector_to_switch_policy_leaf_profile/tasks/main.yml @@ -4,12 +4,12 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined - name: Verify Cloud and Non-Cloud Sites in use. - include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml - name: Execute tasks only for non-cloud sites when: query_cloud.current == [] # This condition will execute only non-cloud sites @@ -83,7 +83,7 @@ # TODO: also test for errors - name: present assertions - assert: + ansible.builtin.assert: that: - intftoleaf_check_mode_present is changed - intftoleaf_present is changed @@ -101,7 +101,7 @@ register: binding_query1 - name: query 1 assertions - assert: + ansible.builtin.assert: that: - binding_query1 is not changed - binding_query1.current | length >= 1 @@ -121,7 +121,7 @@ register: binding_query2 - name: query 2 assertions - assert: + ansible.builtin.assert: that: - binding_query2 is not changed - binding_query2.current | length >= 1 @@ -153,7 +153,7 @@ register: intftoleaf_absent_missing_param - name: absent assertions - assert: + ansible.builtin.assert: that: - intftoleaf_check_mode_absent is changed - intftoleaf_check_mode_absent.previous != [] diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_key_policy/aliases b/ansible_collections/cisco/aci/tests/integration/targets/aci_key_policy/aliases new file mode 100644 index 000000000..209b793f9 --- /dev/null +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_key_policy/aliases @@ -0,0 +1,2 @@ +# No ACI simulator yet, so not enabled +# unsupported diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_key_policy/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_key_policy/tasks/main.yml new file mode 100644 index 000000000..db44b6719 --- /dev/null +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_key_policy/tasks/main.yml @@ -0,0 +1,153 @@ +# Test code for the ACI modules +# Copyright: (c) 2023, Gaspard Micol (@gmicol) <gmicol@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 APIC host, ACI username and ACI password + ansible.builtin.fail: + msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' + when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined + +- name: Set vars + ansible.builtin.set_fact: + aci_info: &aci_info + host: "{{ aci_hostname }}" + username: "{{ aci_username }}" + password: "{{ aci_password }}" + validate_certs: '{{ aci_validate_certs | default(false) }}' + use_ssl: '{{ aci_use_ssl | default(true) }}' + use_proxy: '{{ aci_use_proxy | default(true) }}' + output_level: debug + +# CLEAN ENVIRONMENT +- name: Remove the ansible_tenant + cisco.aci.aci_tenant: &aci_tenant_absent + <<: *aci_info + tenant: ansible_tenant + state: absent + +- name: Verify Cloud and Non-Cloud Sites in use. + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + +- name: Execute tasks only for non-cloud sites + when: query_cloud.current == [] # This condition will execute only non-cloud sites + block: # block specifies execution of tasks within, based on conditions + - name: Add a new tenant + cisco.aci.aci_tenant: &aci_tenant_present + <<: *aci_info + tenant: ansible_tenant + description: Ansible tenant + state: present + + - name: Add a new Keychain policy + cisco.aci.aci_keychain_policy: + <<: *aci_info + tenant: ansible_tenant + keychain_policy: ansible_keychain_policy_1 + description: Keychain policy 1 for ansible_tenant tenant + state: present + + - name: Add a Key policy (check_mode) + cisco.aci.aci_key_policy: &aci_key_policy_present + <<: *aci_info + tenant: ansible_tenant + keychain_policy: ansible_keychain_policy_1 + id: 1 + description: Key policy 1 for ansible_tenant tenant + start_time: "2024-01-01 00:00:00" + end_time: "2026-01-01 00:00:00" + pre_shared_key: my_password + state: present + check_mode: true + register: cm_add_key_policy + + - name: Add a Key policy (normal_mode) + cisco.aci.aci_key_policy: + <<: *aci_key_policy_present + register: nm_add_key_policy + + - name: Add the first Key policy again - testing hidden key authentification + cisco.aci.aci_key_policy: + <<: *aci_key_policy_present + register: nm_add_key_policy_idempotency + + - name: Add a second Key policy (normal_mode) + cisco.aci.aci_key_policy: + <<: *aci_info + tenant: ansible_tenant + keychain_policy: ansible_keychain_policy_1 + id: 2 + description: Key policy 2 for ansible_tenant tenant + state: present + register: nm_add_key_policy_2 + + - name: Asserts for Key policys creation tasks + ansible.builtin.assert: + that: + - cm_add_key_policy is changed + - cm_add_key_policy.previous == [] + - cm_add_key_policy.current == [] + - nm_add_key_policy is changed + - nm_add_key_policy.current.0.fvKeyPol.attributes.id == "1" + - nm_add_key_policy.current.0.fvKeyPol.attributes.startTime == "2024-01-01T00:00:00.000+00:00" + - nm_add_key_policy.current.0.fvKeyPol.attributes.endTime == "2026-01-01T00:00:00.000+00:00" + - nm_add_key_policy_idempotency is changed + - nm_add_key_policy_2 is changed + - nm_add_key_policy_2.previous == [] + - nm_add_key_policy_2.current.0.fvKeyPol.attributes.id == "2" + - nm_add_key_policy_2.current.0.fvKeyPol.attributes.endTime == "infinite" + + - name: Query all Key policies + cisco.aci.aci_key_policy: + <<: *aci_info + state: query + register: query_all_key_policy + + - name: Query ansible_key_policy_1 + cisco.aci.aci_key_policy: + <<: *aci_key_policy_present + state: query + register: query_ansible_key_policy_1 + + - name: Asserts query tasks + ansible.builtin.assert: + that: + - query_all_key_policy is not changed + - query_all_key_policy.current|length >= 2 + - query_ansible_key_policy_1 is not changed + - query_ansible_key_policy_1.current.0.fvKeyPol.attributes.id == "1" + - query_ansible_key_policy_1.current.0.fvKeyPol.attributes.startTime == "2024-01-01T00:00:00.000+00:00" + - query_ansible_key_policy_1.current.0.fvKeyPol.attributes.endTime == "2026-01-01T00:00:00.000+00:00" + + - name: Remove Key policy (check_mode) + cisco.aci.aci_key_policy: &key_policy_absent + <<: *aci_key_policy_present + state: absent + check_mode: true + register: cm_remove_key_policy + + - name: Remove Key policy (normal_mode) + cisco.aci.aci_key_policy: + <<: *key_policy_absent + register: nm_remove_key_policy + + - name: Remove Key policy - testing idempotency + cisco.aci.aci_key_policy: + <<: *key_policy_absent + register: nm_remove_key_policy_idempotency + + - name: Asserts deletion tasks + ansible.builtin.assert: + that: + - cm_remove_key_policy is changed + - cm_remove_key_policy.proposed == {} + - nm_remove_key_policy is changed + - nm_remove_key_policy.previous != [] + - nm_remove_key_policy.method == "DELETE" + - nm_remove_key_policy_idempotency is not changed + - nm_remove_key_policy_idempotency.previous == [] + + - name: Remove the ansible_tenant - cleanup before ending tests + cisco.aci.aci_tenant: + <<: *aci_tenant_present + state: absent diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_keychain_policy/aliases b/ansible_collections/cisco/aci/tests/integration/targets/aci_keychain_policy/aliases new file mode 100644 index 000000000..209b793f9 --- /dev/null +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_keychain_policy/aliases @@ -0,0 +1,2 @@ +# No ACI simulator yet, so not enabled +# unsupported diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_keychain_policy/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_keychain_policy/tasks/main.yml new file mode 100644 index 000000000..0a0356cf7 --- /dev/null +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_keychain_policy/tasks/main.yml @@ -0,0 +1,135 @@ +# Test code for the ACI modules +# Copyright: (c) 2023, Gaspard Micol (@gmicol) <gmicol@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 APIC host, ACI username and ACI password + ansible.builtin.fail: + msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' + when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined + +- name: Set vars + ansible.builtin.set_fact: + aci_info: &aci_info + host: "{{ aci_hostname }}" + username: "{{ aci_username }}" + password: "{{ aci_password }}" + validate_certs: '{{ aci_validate_certs | default(false) }}' + use_ssl: '{{ aci_use_ssl | default(true) }}' + use_proxy: '{{ aci_use_proxy | default(true) }}' + output_level: debug + +# CLEAN ENVIRONMENT +- name: Remove the ansible_tenant + cisco.aci.aci_tenant: &aci_tenant_absent + <<: *aci_info + tenant: ansible_tenant + state: absent + +- name: Verify Cloud and Non-Cloud Sites in use. + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + +- name: Execute tasks only for non-cloud sites + when: query_cloud.current == [] # This condition will execute only non-cloud sites + block: # block specifies execution of tasks within, based on conditions + - name: Add a new tenant + cisco.aci.aci_tenant: &aci_tenant_present + <<: *aci_info + tenant: ansible_tenant + description: Ansible tenant + state: present + + - name: Add a Keychain policy (check_mode) + cisco.aci.aci_keychain_policy: &aci_keychain_policy_present + <<: *aci_info + tenant: ansible_tenant + keychain_policy: ansible_keychain_policy_1 + description: Keychain policy 1 for ansible_tenant tenant + state: present + check_mode: true + register: cm_add_keychain_policy + + - name: Add a Keychain policy (normal_mode) + cisco.aci.aci_keychain_policy: + <<: *aci_keychain_policy_present + register: nm_add_keychain_policy + + - name: Add the first Keychain policy again - testing idempotency + cisco.aci.aci_keychain_policy: + <<: *aci_keychain_policy_present + register: nm_add_keychain_policy_idempotency + + - name: Add a second Keychain policy (normal_mode) + cisco.aci.aci_keychain_policy: + <<: *aci_info + tenant: ansible_tenant + keychain_policy: ansible_keychain_policy_2 + description: Keychain policy 2 for ansible_tenant tenant + state: present + register: nm_add_keychain_policy_2 + + - name: Asserts for Keychain policys creation tasks + ansible.builtin.assert: + that: + - cm_add_keychain_policy is changed + - cm_add_keychain_policy.previous == [] + - cm_add_keychain_policy.current == [] + - nm_add_keychain_policy is changed + - nm_add_keychain_policy.current.0.fvKeyChainPol.attributes.name == "ansible_keychain_policy_1" + - nm_add_keychain_policy_idempotency is not changed + - nm_add_keychain_policy_2 is changed + - nm_add_keychain_policy_2.previous == [] + - nm_add_keychain_policy_2.current.0.fvKeyChainPol.attributes.name == "ansible_keychain_policy_2" + + - name: Query all Keychain policies + cisco.aci.aci_keychain_policy: + <<: *aci_info + state: query + register: query_all_keychain_policy + + - name: Query ansible_keychain_policy_1 + cisco.aci.aci_keychain_policy: + <<: *aci_keychain_policy_present + state: query + register: query_ansible_keychain_policy_1 + + - name: Asserts query tasks + ansible.builtin.assert: + that: + - query_all_keychain_policy is not changed + - query_all_keychain_policy.current|length >= 2 + - query_ansible_keychain_policy_1 is not changed + - query_ansible_keychain_policy_1.current.0.fvKeyChainPol.attributes.name == "ansible_keychain_policy_1" + + - name: Remove Keychain policy (check_mode) + cisco.aci.aci_keychain_policy: &keychain_policy_absent + <<: *aci_keychain_policy_present + state: absent + check_mode: true + register: cm_remove_keychain_policy + + - name: Remove Keychain policy (normal_mode) + cisco.aci.aci_keychain_policy: + <<: *keychain_policy_absent + register: nm_remove_keychain_policy + + - name: Remove Keychain policy - testing idempotency + cisco.aci.aci_keychain_policy: + <<: *keychain_policy_absent + register: nm_remove_keychain_policy_idempotency + + - name: Asserts deletion tasks + ansible.builtin.assert: + that: + - cm_remove_keychain_policy is changed + - cm_remove_keychain_policy.proposed == {} + - nm_remove_keychain_policy is changed + - nm_remove_keychain_policy.previous != [] + - nm_remove_keychain_policy.method == "DELETE" + - nm_remove_keychain_policy_idempotency is not changed + - nm_remove_keychain_policy_idempotency.previous == [] + + - name: Remove the ansible_tenant - cleanup before ending tests + cisco.aci.aci_tenant: + <<: *aci_tenant_present + state: absent diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_l2out/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_l2out/tasks/main.yml index f72831322..2fcafc985 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_l2out/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_l2out/tasks/main.yml @@ -4,12 +4,12 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: "{{ aci_hostname }}" username: "{{ aci_username }}" @@ -21,26 +21,26 @@ # CLEAN ENVIRONMENT - name: Remove the ansible_tenant - aci_tenant: + cisco.aci.aci_tenant: <<: *aci_info tenant: ansible_tenant state: absent - name: Verify Cloud and Non-Cloud Sites in use. - include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml - name: Execute tasks only for non-cloud sites when: query_cloud.current == [] # This condition will execute only non-cloud sites block: # block specifies execution of tasks within, based on conditions - name: Add a new tenant - aci_tenant: + cisco.aci.aci_tenant: <<: *aci_info tenant: ansible_tenant description: Ansible tenant state: present - name: Add a new L2Out - aci_l2out: + cisco.aci.aci_l2out: <<: *aci_info tenant: ansible_tenant l2out: ansible_l2out @@ -52,14 +52,14 @@ register: add_l2out - name: Verify add_l2out - assert: + ansible.builtin.assert: that: - add_l2out.current.0.l2extOut.attributes.dn == "uni/tn-ansible_tenant/l2out-ansible_l2out" - add_l2out.current.0.l2extOut.attributes.name == "ansible_l2out" - add_l2out.current.0.l2extOut.attributes.annotation == 'orchestrator:ansible' - name: Add the L2Out again - aci_l2out: + cisco.aci.aci_l2out: <<: *aci_info tenant: ansible_tenant l2out: ansible_l2out @@ -71,12 +71,12 @@ register: add_l2out_again - name: Verify add_l2out_again - assert: + ansible.builtin.assert: that: - add_l2out_again is not changed - name: Add a new L2Out - aci_l2out: + cisco.aci.aci_l2out: <<: *aci_info tenant: ansible_tenant l2out: ansible_l2out_2 @@ -88,13 +88,13 @@ register: add_l2out_2 - name: Verify add_l2out_2 - assert: + ansible.builtin.assert: that: - add_l2out_2.current.0.l2extOut.attributes.dn == "uni/tn-ansible_tenant/l2out-ansible_l2out_2" - add_l2out_2.current.0.l2extOut.attributes.name == "ansible_l2out_2" - name: Query the L2Out - aci_l2out: + cisco.aci.aci_l2out: <<: *aci_info tenant: ansible_tenant l2out: ansible_l2out @@ -102,26 +102,26 @@ register: query_l2out - name: Verify query_l2out - assert: + ansible.builtin.assert: that: - query_l2out is not changed - query_l2out.current.0.l2extOut.attributes.dn == "uni/tn-ansible_tenant/l2out-ansible_l2out" - query_l2out.current.0.l2extOut.attributes.name == "ansible_l2out" - name: Query all l2outs under a specific tenant - aci_l2out: + cisco.aci.aci_l2out: <<: *aci_info tenant: ansible_tenant state: query register: query_l2out_all - name: Verify query_l2out_all - assert: + ansible.builtin.assert: that: - query_l2out_all is not changed - name: Remove the L2Out - aci_l2out: + cisco.aci.aci_l2out: <<: *aci_info tenant: ansible_tenant l2out: ansible_l2out @@ -129,7 +129,7 @@ register: remove_l2out - name: Verify remove_l2out - assert: + ansible.builtin.assert: that: - remove_l2out is changed - remove_l2out.previous.0.l2extOut.attributes.dn == "uni/tn-ansible_tenant/l2out-ansible_l2out" diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_l2out_extepg/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_l2out_extepg/tasks/main.yml index 39feb5216..9b2698498 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_l2out_extepg/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_l2out_extepg/tasks/main.yml @@ -4,12 +4,12 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: "{{ aci_hostname }}" username: "{{ aci_username }}" @@ -21,26 +21,26 @@ # CLEAN ENVIRONMENT - name: Remove the ansible_tenant - aci_tenant: + cisco.aci.aci_tenant: <<: *aci_info tenant: ansible_tenant state: absent - name: Verify Cloud and Non-Cloud Sites in use. - include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml - name: Execute tasks only for non-cloud sites when: query_cloud.current == [] # This condition will execute only non-cloud sites block: # block specifies execution of tasks within, based on conditions - name: Add a new tenant - aci_tenant: + cisco.aci.aci_tenant: <<: *aci_info tenant: ansible_tenant description: Ansible tenant state: present - name: Add New L2Out - aci_l2out: + cisco.aci.aci_l2out: <<: *aci_info tenant: ansible_tenant l2out: ansible_l2out @@ -52,7 +52,7 @@ register: add_l2out - name: Add another L2Out - aci_l2out: + cisco.aci.aci_l2out: <<: *aci_info tenant: ansible_tenant l2out: ansible_l2out_2 @@ -64,7 +64,7 @@ register: add_l2out_2 - name: Add L2 external end point group - aci_l2out_extepg: + cisco.aci.aci_l2out_extepg: <<: *aci_info tenant: ansible_tenant l2out: ansible_l2out @@ -75,13 +75,13 @@ register: l2extepg - name: Verify l2extepg - assert: + ansible.builtin.assert: that: - l2extepg.current.0.l2extInstP.attributes.dn == "uni/tn-ansible_tenant/l2out-ansible_l2out/instP-ansible_extepg" - l2extepg.current.0.l2extInstP.attributes.annotation == 'orchestrator:ansible' - name: Add L2 external end point group again - aci_l2out_extepg: + cisco.aci.aci_l2out_extepg: <<: *aci_info tenant: ansible_tenant l2out: ansible_l2out @@ -92,13 +92,13 @@ register: l2extepg_again - name: Verify l2extepg_again - assert: + ansible.builtin.assert: that: - l2extepg_again is not changed - l2extepg.current.0.l2extInstP.attributes.dn == "uni/tn-ansible_tenant/l2out-ansible_l2out/instP-ansible_extepg" - name: Add another L2 external end point group - aci_l2out_extepg: + cisco.aci.aci_l2out_extepg: <<: *aci_info tenant: ansible_tenant l2out: ansible_l2out_2 @@ -110,12 +110,12 @@ register: l2extepg_2 - name: Verify l2extepg_2 - assert: + ansible.builtin.assert: that: - l2extepg_2.current.0.l2extInstP.attributes.dn == "uni/tn-ansible_tenant/l2out-ansible_l2out_2/instP-ansible_extepg_2" - name: Query the L2 external end point group - aci_l2out_extepg: + cisco.aci.aci_l2out_extepg: <<: *aci_info tenant: ansible_tenant l2out: ansible_l2out @@ -124,30 +124,30 @@ register: query_l2extepg - name: Query all L2 external epg in a tenant - aci_l2out_extepg: + cisco.aci.aci_l2out_extepg: <<: *aci_info tenant: ansible_tenant state: query register: query_all_in_tenant - name: Verify query_all_in_tenant - assert: + ansible.builtin.assert: that: - query_all_in_tenant is not changed - name: Query all L2 external epgs - aci_l2out_extepg: + cisco.aci.aci_l2out_extepg: <<: *aci_info state: query register: query_all - name: Verify query_all - assert: + ansible.builtin.assert: that: - query_all is not changed - name: Remove L2 external end point group - aci_l2out_extepg: + cisco.aci.aci_l2out_extepg: <<: *aci_info tenant: ansible_tenant l2out: ansible_l2out @@ -157,7 +157,7 @@ register: remove_l2extepg - name: Verify remove_l2extepg - assert: + ansible.builtin.assert: that: - remove_l2extepg is changed - remove_l2extepg.previous.0.l2extInstP.attributes.dn == "uni/tn-ansible_tenant/l2out-ansible_l2out/instP-ansible_extepg"
\ No newline at end of file diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_l2out_extepg_to_contract/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_l2out_extepg_to_contract/tasks/main.yml index 25c211f6b..0781aa682 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_l2out_extepg_to_contract/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_l2out_extepg_to_contract/tasks/main.yml @@ -4,12 +4,12 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: "{{ aci_hostname }}" username: "{{ aci_username }}" @@ -21,26 +21,26 @@ # CLEAN ENVIRONMENT - name: Remove the ansible_tenant - aci_tenant: + cisco.aci.aci_tenant: <<: *aci_info tenant: ansible_tenant state: absent - name: Verify Cloud and Non-Cloud Sites in use. - include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml - name: Execute tasks only for non-cloud sites when: query_cloud.current == [] # This condition will execute only non-cloud sites block: # block specifies execution of tasks within, based on conditions - name: Add a new tenant - aci_tenant: + cisco.aci.aci_tenant: <<: *aci_info tenant: ansible_tenant description: Ansible tenant state: present - name: Add New L2Out - aci_l2out: + cisco.aci.aci_l2out: <<: *aci_info tenant: ansible_tenant l2out: ansible_l2out @@ -52,7 +52,7 @@ register: add_l2out - name: Add another L2Out - aci_l2out: + cisco.aci.aci_l2out: <<: *aci_info tenant: ansible_tenant l2out: ansible_l2out_2 @@ -64,7 +64,7 @@ register: add_l2out_2 - name: Add L2 external end point group - aci_l2out_extepg: + cisco.aci.aci_l2out_extepg: <<: *aci_info tenant: ansible_tenant l2out: ansible_l2out @@ -75,13 +75,13 @@ register: l2extepg - name: Verify l2extepg - assert: + ansible.builtin.assert: that: - l2extepg is changed - l2extepg.current.0.l2extInstP.attributes.dn == "uni/tn-ansible_tenant/l2out-ansible_l2out/instP-ansible_extepg" - name: Add L2 external end point group again - aci_l2out_extepg: + cisco.aci.aci_l2out_extepg: <<: *aci_info tenant: ansible_tenant l2out: ansible_l2out @@ -92,13 +92,13 @@ register: l2extepg_again - name: Verify l2extepg_again - assert: + ansible.builtin.assert: that: - l2extepg_again is not changed - l2extepg.current.0.l2extInstP.attributes.dn == "uni/tn-ansible_tenant/l2out-ansible_l2out/instP-ansible_extepg" - name: Add another L2 external end point group - aci_l2out_extepg: + cisco.aci.aci_l2out_extepg: <<: *aci_info tenant: ansible_tenant l2out: ansible_l2out_2 @@ -110,13 +110,13 @@ register: l2extepg_2 - name: Verify l2extepg_2 - assert: + ansible.builtin.assert: that: - l2extepg_2 is changed - l2extepg_2.current.0.l2extInstP.attributes.dn == "uni/tn-ansible_tenant/l2out-ansible_l2out_2/instP-ansible_extepg_2" - name: Bind External End Point Groups to Contracts - aci_l2out_extepg_to_contract: + cisco.aci.aci_l2out_extepg_to_contract: <<: *aci_info tenant: ansible_tenant l2out: ansible_l2out @@ -127,14 +127,14 @@ register: bind_extepg_provider_contract - name: Verify bind_extepg_provider_contract - assert: + ansible.builtin.assert: that: - bind_extepg_provider_contract is changed - bind_extepg_provider_contract.current.0.fvRsProv.attributes.dn == "uni/tn-ansible_tenant/l2out-ansible_l2out/instP-ansible_extepg/rsprov-ansible_contract" - bind_extepg_provider_contract.current.0.fvRsProv.attributes.annotation == 'orchestrator:ansible' - name: Bind second External End Point Groups to Contracts - aci_l2out_extepg_to_contract: + cisco.aci.aci_l2out_extepg_to_contract: <<: *aci_info tenant: ansible_tenant l2out: ansible_l2out_2 @@ -145,13 +145,13 @@ register: bind_extepg_provider_contract - name: Verify bind_extepg_provider_contract - assert: + ansible.builtin.assert: that: - bind_extepg_provider_contract is changed - bind_extepg_provider_contract.current.0.fvRsProv.attributes.dn == "uni/tn-ansible_tenant/l2out-ansible_l2out_2/instP-ansible_extepg_2/rsprov-ansible_contract2" - name: Query the External End Point Groups - aci_l2out_extepg_to_contract: + cisco.aci.aci_l2out_extepg_to_contract: <<: *aci_info tenant: ansible_tenant l2out: ansible_l2out @@ -162,26 +162,26 @@ register: query_extepg - name: Verify query_extepg - assert: + ansible.builtin.assert: that: - query_extepg is not changed - query_extepg.current.0.fvRsProv.attributes.dn == "uni/tn-ansible_tenant/l2out-ansible_l2out/instP-ansible_extepg/rsprov-ansible_contract" - name: Query all the External End Point Groups - aci_l2out_extepg_to_contract: + cisco.aci.aci_l2out_extepg_to_contract: <<: *aci_info contract_type: provider state: query register: query_all - name: Verify query_extepg - assert: + ansible.builtin.assert: that: - query_extepg is not changed - query_extepg.current | length > 0 - name: Remove existing contract to External End Point Groups - aci_l2out_extepg_to_contract: + cisco.aci.aci_l2out_extepg_to_contract: <<: *aci_info tenant: ansible_tenant l2out: ansible_l2out @@ -192,14 +192,14 @@ register: remove_contract_extepg - name: Verify remove_contract_extepg - assert: + ansible.builtin.assert: that: - remove_contract_extepg is changed - remove_contract_extepg.current == [] - remove_contract_extepg.previous.0.fvRsProv.attributes.dn == "uni/tn-ansible_tenant/l2out-ansible_l2out/instP-ansible_extepg/rsprov-ansible_contract" - name: Bind External End Point Groups to Contracts - aci_l2out_extepg_to_contract: + cisco.aci.aci_l2out_extepg_to_contract: <<: *aci_info tenant: ansible_tenant l2out: ansible_l2out @@ -212,7 +212,7 @@ register: bind_extepg_consumer_contract - name: Verify bind_extepg_consumer_contract - assert: + ansible.builtin.assert: that: - bind_extepg_consumer_contract is not changed - bind_extepg_consumer_contract.msg == "the 'provider_match' is only configurable for Provided Contracts"
\ No newline at end of file diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_l2out_logical_interface_path/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_l2out_logical_interface_path/tasks/main.yml index a573668de..62440ce64 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_l2out_logical_interface_path/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_l2out_logical_interface_path/tasks/main.yml @@ -4,12 +4,12 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: "{{ aci_hostname }}" username: "{{ aci_username }}" @@ -26,7 +26,7 @@ state: absent - name: Verify Cloud and Non-Cloud Sites in use. - include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml - name: Execute tasks only for non-cloud sites when: query_cloud.current == [] # This condition will execute only non-cloud sites @@ -83,7 +83,7 @@ register: nm_path_to_intfp - name: Verify path to interface profile - assert: + ansible.builtin.assert: that: - cm_path_to_intfp is changed - nm_path_to_intfp is changed @@ -111,7 +111,7 @@ register: third_path - name: Verify path to interface profile - assert: + ansible.builtin.assert: that: - second_path is changed - third_path is changed @@ -166,7 +166,7 @@ register: query_path - name: Verify query - assert: + ansible.builtin.assert: that: - query_all is not changed - query_all.current.0.l2extLIfP.children | length >= 3 @@ -192,7 +192,7 @@ register: rm_non_existing - name: Verify remove path - assert: + ansible.builtin.assert: that: - cm_rm_path is changed - nm_rm_path is changed diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_l2out_logical_interface_profile/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_l2out_logical_interface_profile/tasks/main.yml index 7e28c1cd4..86e6548f8 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_l2out_logical_interface_profile/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_l2out_logical_interface_profile/tasks/main.yml @@ -5,7 +5,7 @@ # SET VARS - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: '{{ aci_hostname }}' username: '{{ aci_username }}' @@ -23,7 +23,7 @@ state: absent - name: Verify Cloud and Non-Cloud Sites in use. - include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml - name: Execute tasks only for non-cloud sites when: query_cloud.current == [] # This condition will execute only non-cloud sites @@ -65,7 +65,7 @@ register: nm_add_intf - name: Verify nm_add_intf - assert: + ansible.builtin.assert: that: - cm_add_intf is changed - nm_add_intf is changed @@ -79,7 +79,7 @@ register: add_intf_again - name: Verify add_intf_again - assert: + ansible.builtin.assert: that: - add_intf_again is not changed @@ -100,7 +100,7 @@ register: query_all_profiles - name: Verify query_all_profiles - assert: + ansible.builtin.assert: that: - query_all_profiles is not changed - query_all_profiles.current.0.l2extLNodeP.children | length > 1 @@ -113,7 +113,7 @@ register: query_spec_profile - name: Verify query_spec_profile - assert: + ansible.builtin.assert: that: - query_spec_profile is not changed - query_spec_profile.current|length == 1 @@ -129,7 +129,7 @@ register: query_nonexist_profile - name: Verify query_nonexist_profile - assert: + ansible.builtin.assert: that: - query_nonexist_profile is not changed - query_nonexist_profile.current == [] @@ -142,7 +142,7 @@ register: remove_profile - name: Verify remove_profile - assert: + ansible.builtin.assert: that: - remove_profile is changed - remove_profile.current == [] @@ -154,7 +154,7 @@ register: remove_nonexist_profile - name: Verify remove_nonexist_profile - assert: + ansible.builtin.assert: that: - remove_nonexist_profile is not changed - remove_nonexist_profile.current == [] diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_l2out_logical_node_profile/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_l2out_logical_node_profile/tasks/main.yml index 82b4aaac5..d8b8f8b21 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_l2out_logical_node_profile/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_l2out_logical_node_profile/tasks/main.yml @@ -4,12 +4,12 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: "{{ aci_hostname }}" username: "{{ aci_username }}" @@ -27,7 +27,7 @@ state: absent - name: Verify Cloud and Non-Cloud Sites in use. - include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml - name: Execute tasks only for non-cloud sites when: query_cloud.current == [] # This condition will execute only non-cloud sites @@ -74,7 +74,7 @@ register: nm_add_second_node_profile - name: Verify add_node_profile - assert: + ansible.builtin.assert: that: - cm_add_node_profile is changed - nm_add_node_profile is changed @@ -121,7 +121,7 @@ register: nm_query_all_node_profiles - name: Verify query_node_profile - assert: + ansible.builtin.assert: that: - cm_query_node_profile is not changed - nm_query_node_profile is not changed @@ -166,7 +166,7 @@ register: nm_remove_second_node_profile - name: Verify remove_node_profile - assert: + ansible.builtin.assert: that: - cm_remove_node_profile is changed - cm_remove_second_node_profile is changed diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_l3out/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_l3out/tasks/main.yml index 65474048c..352f9d5b4 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_l3out/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_l3out/tasks/main.yml @@ -1,15 +1,16 @@ # Test code for the ACI modules # Copyright: (c) 2023, Gaspard Micol (@gmicol) <gmicol@cisco.com> +# Copyright: (c) 2023, Akini Ross (@akinross) <akinross@cisco.com> # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: "{{ aci_hostname }}" username: "{{ aci_username }}" @@ -18,29 +19,36 @@ use_ssl: '{{ aci_use_ssl | default(true) }}' use_proxy: '{{ aci_use_proxy | default(true) }}' output_level: debug - + +- name: Query system information + cisco.aci.aci_system: + <<: *aci_info + id: 1 + state: query + register: version + # CLEAN ENVIRONMENT - name: Remove the ansible_tenant - aci_tenant: + cisco.aci.aci_tenant: <<: *aci_info tenant: ansible_tenant state: absent - name: Verify Cloud and Non-Cloud Sites in use. - include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml - name: Execute tasks only for non-cloud sites when: query_cloud.current == [] # This condition will execute only non-cloud sites block: # block specifies execution of tasks within, based on conditions - name: Add a new tenant - aci_tenant: + cisco.aci.aci_tenant: <<: *aci_info tenant: ansible_tenant description: Ansible tenant state: present - name: Remove the ansible_l3out - aci_l3out: &aci_l3out_absent + cisco.aci.aci_l3out: &aci_l3out_absent <<: *aci_info tenant: ansible_tenant name: ansible_l3out @@ -50,7 +58,7 @@ state: absent - name: Remove the second ansible_l3out - aci_l3out: &aci_l3out_2_absent + cisco.aci.aci_l3out: &aci_l3out_2_absent <<: *aci_info tenant: ansible_tenant name: ansible_l3out_2 @@ -61,30 +69,30 @@ state: absent - name: Add a new L3Out (check_mode) - aci_l3out: &aci_l3out_present + cisco.aci.aci_l3out: &aci_l3out_present <<: *aci_l3out_absent state: present check_mode: true register: cm_add_l3out - name: Add a new L3Out (normal_mode) - aci_l3out: + cisco.aci.aci_l3out: <<: *aci_l3out_present register: nm_add_l3out - name: create L3Out again - testing idempotency - aci_l3out: + cisco.aci.aci_l3out: <<: *aci_l3out_present register: create_idempotency - name: Add the second ansible_l3out - aci_l3out: + cisco.aci.aci_l3out: <<: *aci_l3out_2_absent state: present register: cm_add_l3out_2 - name: asserts for l3out creation tasks - assert: + ansible.builtin.assert: that: - cm_add_l3out is changed - cm_add_l3out.previous == [] @@ -95,26 +103,26 @@ - create_idempotency is not changed - name: Add export and import to route_control - aci_l3out: + cisco.aci.aci_l3out: <<: *aci_l3out_present route_control: [ import, export ] register: nm_add_l3out_import_export - name: Add export to route_control - aci_l3out: + cisco.aci.aci_l3out: <<: *aci_l3out_present route_control: export register: nm_add_l3out_export - name: Add just import to route_control - testing failure message - aci_l3out: + cisco.aci.aci_l3out: <<: *aci_l3out_present route_control: import register: nm_add_l3out_import_error ignore_errors: true - name: asserts for l3out route control tasks - assert: + ansible.builtin.assert: that: - nm_add_l3out_import_export is changed - nm_add_l3out_import_export.current.0.l3extOut.attributes.enforceRtctrl == "export,import" @@ -123,26 +131,44 @@ - nm_add_l3out_import_error.msg == "The route_control parameter is invalid{{':'}} allowed options are export or import,export only" - name: Add BGP protocol - aci_l3out: + cisco.aci.aci_l3out: <<: *aci_l3out_present l3protocol: bgp register: nm_add_l3out_bgp - name: Add BGP protocol again - testing L3protocol changes - aci_l3out: + cisco.aci.aci_l3out: <<: *aci_l3out_present l3protocol: bgp register: nm_add_l3out_bgp_again + - name: Remove OSPF protocol - testing L3protocol changes + cisco.aci.aci_l3out: &aci_l3out_remove_ospf + <<: *aci_l3out_2_absent + l3protocol: [ eigrp, pim ] + asn: 1 + state: present + register: nm_add_l3out_bgp_without_ospf + + - name: Remove OSPF protocol again - testing L3protocol changes + cisco.aci.aci_l3out: + <<: *aci_l3out_remove_ospf + register: nm_add_l3out_bgp_without_ospf_again + - name: Add PIM protocol, ospf_spec and asn - testing warning message for asn - aci_l3out: + aci_l3out: &aci_l3out_add_pim <<: *aci_l3out_present l3protocol: pim asn: 1 register: nm_add_l3out_pim + - name: Add PIM protocol, ospf_spec and asn again - testing warning message for asn + aci_l3out: + <<: *aci_l3out_add_pim + register: nm_add_l3out_pim_again + - name: Add EIGRP protocol - testing warning message for OSPF spec - aci_l3out: + cisco.aci.aci_l3out: &aci_l3out_add_eigrp <<: *aci_l3out_present l3protocol: eigrp asn: 1 @@ -150,8 +176,13 @@ description: OSPF warnings message works register: nm_add_l3out_eigrp - - name: remove asn - testing failure message + - name: Add EIGRP protocol again - testing warning message for OSPF spec aci_l3out: + <<: *aci_l3out_add_eigrp + register: nm_add_l3out_eigrp_again + + - name: remove asn - testing failure message + cisco.aci.aci_l3out: <<: *aci_l3out_present l3protocol: eigrp asn: null @@ -159,26 +190,30 @@ ignore_errors: true - name: remove protocol - testing static protocol - aci_l3out: + cisco.aci.aci_l3out: <<: *aci_l3out_present l3protocol: static register: nm_remove_l3protocol - name: asserts for l3out protocols tasks - assert: + ansible.builtin.assert: that: - nm_add_l3out_bgp is changed - - nm_add_l3out_bgp_again is changed + - nm_add_l3out_bgp_again is not changed + - nm_add_l3out_bgp_without_ospf is changed + - nm_add_l3out_bgp_without_ospf_again is not changed - nm_add_l3out_pim is changed - nm_add_l3out_pim.warnings.0 == "Parameter 'asn' is only applicable when l3protocol is 'eigrp'. The ASN will be ignored" + - nm_add_l3out_pim_again is not changed - nm_add_l3out_eigrp is changed - nm_add_l3out_eigrp.current.0.l3extOut.children.0.eigrpExtP.attributes.asn == "1" - nm_add_l3out_eigrp.warnings.0 == "Parameter 'ospf' is only applicable when l3protocol is 'ospf'. The OPSF specifications will be ignored" + - nm_add_l3out_eigrp_again is not changed - add_l3out_without_asn.msg == "Parameter 'asn' is required when l3protocol is 'eigrp'" - nm_remove_l3protocol is changed - name: Add OSPF protocol - aci_l3out: + cisco.aci.aci_l3out: <<: *aci_l3out_present l3protocol: ospf ospf: @@ -191,7 +226,7 @@ register: nm_add_l3out_ospf - name: asserts for l3out OSPF protocol tasks - assert: + ansible.builtin.assert: that: - nm_add_l3out_ospf is changed - nm_add_l3out_ospf.current.0.l3extOut.children.2.ospfExtP.attributes.areaCost == "1" @@ -202,58 +237,58 @@ - nm_add_l3out_ospf.current.0.l3extOut.children.2.ospfExtP.attributes.multipodInternal == "no" - name: get ansible_l3out - aci_l3out: + cisco.aci.aci_l3out: <<: *aci_l3out_present state: query register: get_l3out - name: get all l3outs in ansible_tenant - aci_l3out: + cisco.aci.aci_l3out: <<: *aci_info tenant: ansible_tenant state: query register: get_all_l3out_ansible_tenant - name: get all l3outs - aci_l3out: + cisco.aci.aci_l3out: <<: *aci_info state: query register: get_all_l3out - name: asserts query tasks - assert: + ansible.builtin.assert: that: - get_l3out is not changed - '"rsp-subtree=full&rsp-subtree-class=bgpExtP,eigrpExtP,l3extRsEctx,l3extRsL3DomAtt,ospfExtP,pimExtP" in get_l3out.filter_string' - '"tn-ansible_tenant/out-ansible_l3out.json" in get_l3out.url' - get_all_l3out_ansible_tenant is not changed - - '"ospfExtP" in get_all_l3out_ansible_tenant.current.0.fvTenant.children.0.l3extOut.children.2' + - '"pimExtP" in get_all_l3out_ansible_tenant.current.0.fvTenant.children.0.l3extOut.children.0' + - '"eigrpExtP" in get_all_l3out_ansible_tenant.current.0.fvTenant.children.0.l3extOut.children.1' - '"ospfExtP" in get_all_l3out_ansible_tenant.current.0.fvTenant.children.1.l3extOut.children.2' - - '"bgpExtP" in get_all_l3out_ansible_tenant.current.0.fvTenant.children.1.l3extOut.children.3' - get_all_l3out is not changed - get_all_l3out.current | length >= 2 - name: delete l3out (check_mode) - aci_l3out: + cisco.aci.aci_l3out: <<: *aci_l3out_present state: absent check_mode: true register: delete_cm - name: delete l3out (normal_mode) - aci_l3out: + cisco.aci.aci_l3out: <<: *aci_l3out_present state: absent register: delete_l3out - name: delete l3out again - testing idempotency - aci_l3out: + cisco.aci.aci_l3out: <<: *aci_l3out_present state: absent register: delete_idempotency - name: asserts for deletion tasks - assert: + ansible.builtin.assert: that: - delete_cm is changed - delete_cm.proposed == {} @@ -263,8 +298,120 @@ - delete_idempotency is not changed - delete_idempotency.previous == [] + - name: Execute tasks only for ACI v5+ because SR-MPLS L3Out is not supported lower versions + when: version.current.0.topSystem.attributes.version is version('5', '>=') + block: + + - name: Add a SR-MPLS l3out + cisco.aci.aci_l3out: &aci_sr_mpls_l3out + <<: *aci_info + tenant: ansible_tenant + name: ansible_sr_mpls_l3out + domain: ansible_dom + vrf: ansible_vrf + mpls: "yes" + state: present + register: add_sr_mpls_l3out + + - name: Add a SR-MPLS l3out again + cisco.aci.aci_l3out: + <<: *aci_sr_mpls_l3out + register: add_sr_mpls_l3out_again + + - name: Delete a SR-MPLS l3out + cisco.aci.aci_l3out: + <<: *aci_sr_mpls_l3out + state: absent + register: delete_sr_mpls_l3out + + - name: Ensure infra SR-MPLS l3out does not exist + cisco.aci.aci_l3out: &aci_infra_sr_mpls_l3out_absent + <<: *aci_info + tenant: infra + name: ansible_infra_sr_mpls_l3out + mpls: "yes" + state: absent + + - name: Add a infra SR-MPLS l3out (error) + cisco.aci.aci_l3out: &aci_infra_sr_mpls_l3out + <<: *aci_info + tenant: infra + name: ansible_infra_sr_mpls_l3out + domain: ansible_dom + vrf: ansible_vrf + l3protocol: ospf + mpls: "yes" + ignore_errors: true + register: err_infra_sr_mpls_l3out_no_bgp + + - name: Add a infra SR-MPLS l3out (error) + cisco.aci.aci_l3out: + <<: *aci_infra_sr_mpls_l3out + l3protocol: bgp + ignore_errors: true + register: err_infra_sr_mpls_l3out_no_overlay_1_vrf + + - name: Add a infra SR-MPLS l3out + cisco.aci.aci_l3out: + <<: *aci_infra_sr_mpls_l3out + vrf: overlay-1 + l3protocol: bgp + register: add_infra_sr_mpls_l3out + + - name: Add a infra SR-MPLS l3out again + cisco.aci.aci_l3out: + <<: *aci_infra_sr_mpls_l3out + vrf: overlay-1 + l3protocol: bgp + register: add_infra_sr_mpls_l3out_again + + - name: Delete a infra SR-MPLS l3out + cisco.aci.aci_l3out: + <<: *aci_infra_sr_mpls_l3out_absent + register: delete_infra_sr_mpls_l3out + + - name: Asserts SR-MPLS l3out + ansible.builtin.assert: + that: + - add_sr_mpls_l3out is changed + - add_sr_mpls_l3out.previous == [] + - add_sr_mpls_l3out.current.0.l3extOut.attributes.mplsEnabled == "yes" + - add_sr_mpls_l3out.current.0.l3extOut.attributes.name == "ansible_sr_mpls_l3out" + - add_sr_mpls_l3out.current.0.l3extOut.children.0.l3extRsL3DomAtt.attributes.tDn == "uni/l3dom-ansible_dom" + - add_sr_mpls_l3out.current.0.l3extOut.children.1.l3extRsEctx.attributes.tnFvCtxName == "ansible_vrf" + - add_sr_mpls_l3out_again is not changed + - delete_sr_mpls_l3out is changed + - delete_sr_mpls_l3out.previous.0.l3extOut.attributes.mplsEnabled == "yes" + - delete_sr_mpls_l3out.previous.0.l3extOut.attributes.name == "ansible_sr_mpls_l3out" + - delete_sr_mpls_l3out.previous.0.l3extOut.children.0.l3extRsL3DomAtt.attributes.tDn == "uni/l3dom-ansible_dom" + - delete_sr_mpls_l3out.previous.0.l3extOut.children.1.l3extRsEctx.attributes.tnFvCtxName == "ansible_vrf" + - delete_sr_mpls_l3out.current == [] + - add_infra_sr_mpls_l3out is changed + - add_infra_sr_mpls_l3out.previous == [] + - add_infra_sr_mpls_l3out.current.0.l3extOut.attributes.mplsEnabled == "yes" + - add_infra_sr_mpls_l3out.current.0.l3extOut.attributes.name == "ansible_infra_sr_mpls_l3out" + - add_infra_sr_mpls_l3out.current.0.l3extOut.children.0.mplsExtP.children.0.mplsRsLabelPol.attributes.tDn == "uni/tn-infra/mplslabelpol-default" + - add_infra_sr_mpls_l3out.current.0.l3extOut.children.1.l3extRsL3DomAtt.attributes.tDn == "uni/l3dom-ansible_dom" + - add_infra_sr_mpls_l3out.current.0.l3extOut.children.2.l3extProvLbl.attributes.name == "ansible_infra_sr_mpls_l3out" + - add_infra_sr_mpls_l3out.current.0.l3extOut.children.3.l3extRsEctx.attributes.tnFvCtxName == "overlay-1" + - add_infra_sr_mpls_l3out.current.0.l3extOut.children.4.bgpExtP.attributes.descr == "" + - add_infra_sr_mpls_l3out_again is not changed + - delete_infra_sr_mpls_l3out is changed + - delete_infra_sr_mpls_l3out.previous.0.l3extOut.attributes.mplsEnabled == "yes" + - delete_infra_sr_mpls_l3out.previous.0.l3extOut.attributes.name == "ansible_infra_sr_mpls_l3out" + - delete_infra_sr_mpls_l3out.previous.0.l3extOut.children.0.mplsExtP.children.0.mplsRsLabelPol.attributes.tDn == "uni/tn-infra/mplslabelpol-default" + - delete_infra_sr_mpls_l3out.previous.0.l3extOut.children.1.l3extRsL3DomAtt.attributes.tDn == "uni/l3dom-ansible_dom" + - delete_infra_sr_mpls_l3out.previous.0.l3extOut.children.2.l3extProvLbl.attributes.name == "ansible_infra_sr_mpls_l3out" + - delete_infra_sr_mpls_l3out.previous.0.l3extOut.children.3.l3extRsEctx.attributes.tnFvCtxName == "overlay-1" + - delete_infra_sr_mpls_l3out.previous.0.l3extOut.children.4.bgpExtP.attributes.descr == "" + - delete_infra_sr_mpls_l3out.current == [] + - err_infra_sr_mpls_l3out_no_overlay_1_vrf.failed == true + - err_infra_sr_mpls_l3out_no_overlay_1_vrf.msg == "The vrf parameter must be 'overlay-1' when tenant is 'infra' and mpls is 'yes'" + - err_infra_sr_mpls_l3out_no_bgp.failed == true + - err_infra_sr_mpls_l3out_no_bgp.msg == "The l3protocol parameter must be 'bgp' when tenant is 'infra' and mpls is 'yes'" + - name: Delete the ansible_tenant - cleanup before ending tests - aci_tenant: + cisco.aci.aci_tenant: <<: *aci_info tenant: ansible_tenant state: absent diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_l3out_bfd_interface_profile/aliases b/ansible_collections/cisco/aci/tests/integration/targets/aci_l3out_bfd_interface_profile/aliases new file mode 100644 index 000000000..209b793f9 --- /dev/null +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_l3out_bfd_interface_profile/aliases @@ -0,0 +1,2 @@ +# No ACI simulator yet, so not enabled +# unsupported diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_l3out_bfd_interface_profile/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_l3out_bfd_interface_profile/tasks/main.yml new file mode 100644 index 000000000..19c034eb8 --- /dev/null +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_l3out_bfd_interface_profile/tasks/main.yml @@ -0,0 +1,226 @@ +# Test code for the ACI modules +# Copyright: (c) 2023, Anvitha Jain (@anvjain) + +# 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 APIC host, ACI username and ACI password + fail: + msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' + when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined + +- name: Set vars + ansible.builtin.set_fact: + aci_info: &aci_info + host: "{{ aci_hostname }}" + username: "{{ aci_username }}" + password: "{{ aci_password }}" + validate_certs: '{{ aci_validate_certs | default(false) }}' + use_ssl: '{{ aci_use_ssl | default(true) }}' + use_proxy: '{{ aci_use_proxy | default(true) }}' + output_level: debug + +- name: Query system information + cisco.aci.aci_system: + <<: *aci_info + id: 1 + state: query + register: version + +- name: Verify Cloud and Non-Cloud Sites in use. + include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + +- name: Execute tasks only for non-cloud sites + # This condition will execute only when APIC version >= 5.2 and for non-cloud APICs + when: version.current.0.topSystem.attributes.version is version('5.2', '>=') and query_cloud.current == [] + block: # block specifies execution of tasks within, based on conditions + + # CLEAN ENVIRONMENT + - name: Remove the ansible_tenant + cisco.aci.aci_tenant: + <<: *aci_info + tenant: ansible_tenant + state: absent + + # Add a tenant + - name: Add a new tenant + cisco.aci.aci_tenant: + <<: *aci_info + tenant: ansible_tenant + description: Ansible tenant + state: present + + # Add VRF + - name: Add a new VRF + cisco.aci.aci_vrf: + <<: *aci_info + tenant: ansible_tenant + name: ansible_vrf + description: Ansible VRF + state: present + + # Add L3Out + - name: Add a new L3 Outside + cisco.aci.aci_l3out: + <<: *aci_info + tenant: ansible_tenant + name: ansible_l3out + description: Ansible L3 Outside + domain: ansible_dom + vrf: ansible_vrf + l3protocol: bgp + state: present + + # ADD l3out logical node profile + - name: l3out logical node profile + cisco.aci.aci_l3out_logical_node_profile: + <<: *aci_info + tenant: ansible_tenant + l3out: ansible_l3out + node_profile: ansible_node_profile + state: present + + # ADD l3out logical interface profile + - name: l3out logical interface profile + cisco.aci.aci_l3out_logical_interface_profile: + <<: *aci_info + tenant: ansible_tenant + l3out: ansible_l3out + node_profile: ansible_node_profile + interface_profile: ansible_interface_profile + state: present + + # CREATE L3Out BFD Interface policy + - name: Add a new L3Out BFD Interface policy + cisco.aci.aci_interface_policy_bfd: + <<: *aci_info + tenant: ansible_tenant + name: ansible_bfd__interface_policy + description: Ansible BFD Interface Policy + state: present + register: add_bfd_interface_pol + + # Add L3Out BFD Interface Profile + - name: Add a new L3Out BFD Interface Profile - check mode + cisco.aci.aci_l3out_bfd_interface_profile: &present_l3out_bfd_int_profile + <<: *aci_info + tenant: ansible_tenant + l3out: ansible_l3out + l3out_logical_node_profile: ansible_node_profile + l3out_logical_interface_profile: ansible_interface_profile + bfd_interface_policy: ansible_bfd_interface_policy + state: present + check_mode: true + register: cm_add_l3out_bfd_int_prof + + - name: Add a new L3Out BFD Interface Profile - normal mode + cisco.aci.aci_l3out_bfd_interface_profile: + <<: *present_l3out_bfd_int_profile + state: present + register: nm_add_l3out_bfd_int_prof + + - name: Verify adding L3Out BFD Interface Profile + assert: + that: + - cm_add_l3out_bfd_int_prof is changed + - nm_add_l3out_bfd_int_prof is changed + - cm_add_l3out_bfd_int_prof.previous == nm_add_l3out_bfd_int_prof.previous == [] + - cm_add_l3out_bfd_int_prof.proposed.bfdIfP.attributes.dn == nm_add_l3out_bfd_int_prof.proposed.bfdIfP.attributes.dn == "uni/tn-ansible_tenant/out-ansible_l3out/lnodep-ansible_node_profile/lifp-ansible_interface_profile/bfdIfP" + - cm_add_l3out_bfd_int_prof.proposed.bfdIfP.children.0.bfdRsIfPol.attributes.tnBfdIfPolName == cm_add_l3out_bfd_int_prof.proposed.bfdIfP.children.0.bfdRsIfPol.attributes.tnBfdIfPolName == "ansible_bfd_interface_policy" + + - name: Add L3Out BFD Interface Profile again- idempotency + cisco.aci.aci_l3out_bfd_interface_profile: + <<: *present_l3out_bfd_int_profile + state: present + register: add_l3out_bfd_int_prof_again + + - name: Verify adding L3Out BFD Interface Profile again - idempotency + assert: + that: + - add_l3out_bfd_int_prof_again is not changed + + # Update L3Out BFD Interface Profile + - name: Update L3Out BFD Interface Profile + cisco.aci.aci_l3out_bfd_interface_profile: + <<: *present_l3out_bfd_int_profile + authentication_type: sha1 + key: "abc*123" + key_id: 15 + state: present + register: update_l3out_bfd_int_prof + + - name: Verify updating L3Out BFD Interface Profile + assert: + that: + - update_l3out_bfd_int_prof is changed + - update_l3out_bfd_int_prof.sent.bfdIfP.attributes.keyId == "15" + - update_l3out_bfd_int_prof.sent.bfdIfP.attributes.key == "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER" + - update_l3out_bfd_int_prof.sent.bfdIfP.attributes.type == "sha1" + + # Remove children from L3Out BFD Interface Profile + - name: Remove children from L3Out BFD Interface Profile + cisco.aci.aci_l3out_bfd_interface_profile: + <<: *present_l3out_bfd_int_profile + bfd_interface_policy: "" + register: remove_children_l3out_bfd_int_prof + + - name: Asserts for children removal tasks for the from L3Out BFD Interface Profile + ansible.builtin.assert: + that: + - remove_children_l3out_bfd_int_prof is changed + - remove_children_l3out_bfd_int_prof.sent.bfdIfP.children.0.bfdRsIfPol.attributes.tnBfdIfPolName == "" + + # Query L3Out BFD Interface Profile + - name: Query L3Out BFD Interface Profile + cisco.aci.aci_l3out_bfd_interface_profile: + <<: *present_l3out_bfd_int_profile + state: query + register: query_l3out_bfd_int_prof + + - name: Query all L3Out BFD Interface Profile + cisco.aci.aci_l3out_bfd_interface_profile: + <<: *aci_info + state: query + register: query_all_l3out_bfd_int_prof + + # Validating out of range parameters. + - name: Add out of range key_id + cisco.aci.aci_l3out_bfd_interface_profile: + <<: *present_l3out_bfd_int_profile + key_id: 256 + state: present + ignore_errors: true + register: out_of_range_key_id + + - name: Verify out of range key_id + assert: + that: + - out_of_range_key_id is not changed + - out_of_range_key_id.msg == "The \"key_id\" must be a value between 1 and 255" + + - name: Delete L3Out BFD Interface Profile - check mode + cisco.aci.aci_l3out_bfd_interface_profile: + <<: *present_l3out_bfd_int_profile + state: absent + check_mode: true + register: cm_remove_l3out_bfd_int_prof + + - name: Delete L3Out BFD Interface Profile - normal mode + cisco.aci.aci_l3out_bfd_interface_profile: + <<: *present_l3out_bfd_int_profile + state: absent + register: nm_remove_l3out_bfd_int_prof + + - name: Delete L3Out BFD Interface Profile again - idempotency + cisco.aci.aci_l3out_bfd_interface_profile: + <<: *present_l3out_bfd_int_profile + state: absent + register: remove_l3out_bfd_int_prof_again + + - name: Verify removing L3Out BFD Interface Profile + assert: + that: + - cm_remove_l3out_bfd_int_prof is changed + - nm_remove_l3out_bfd_int_prof is changed + - cm_remove_l3out_bfd_int_prof.proposed == nm_remove_l3out_bfd_int_prof.proposed == {} + - remove_l3out_bfd_int_prof_again is not changed + - nm_remove_l3out_bfd_int_prof.current == remove_l3out_bfd_int_prof_again.current == []
\ No newline at end of file diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_l3out_bfd_multihop_interface_profile/aliases b/ansible_collections/cisco/aci/tests/integration/targets/aci_l3out_bfd_multihop_interface_profile/aliases new file mode 100644 index 000000000..209b793f9 --- /dev/null +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_l3out_bfd_multihop_interface_profile/aliases @@ -0,0 +1,2 @@ +# No ACI simulator yet, so not enabled +# unsupported diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_l3out_bfd_multihop_interface_profile/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_l3out_bfd_multihop_interface_profile/tasks/main.yml new file mode 100644 index 000000000..920453708 --- /dev/null +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_l3out_bfd_multihop_interface_profile/tasks/main.yml @@ -0,0 +1,233 @@ +# Test code for the ACI modules +# Copyright: (c) 2023, Anvitha Jain (@anvjain) + +# 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 APIC host, ACI username and ACI password + fail: + msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' + when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined + +- name: Set vars + ansible.builtin.set_fact: + aci_info: &aci_info + host: "{{ aci_hostname }}" + username: "{{ aci_username }}" + password: "{{ aci_password }}" + validate_certs: '{{ aci_validate_certs | default(false) }}' + use_ssl: '{{ aci_use_ssl | default(true) }}' + use_proxy: '{{ aci_use_proxy | default(true) }}' + output_level: debug + +- name: Query system information + cisco.aci.aci_system: + <<: *aci_info + id: 1 + state: query + register: version + +- name: Verify Cloud and Non-Cloud Sites in use. + include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + +- name: Execute tasks only for non-cloud sites + # This condition will execute only when APIC version >= 5.2 and for non-cloud APICs + when: version.current.0.topSystem.attributes.version is version('5.2', '>=') and query_cloud.current == [] + block: # block specifies execution of tasks within, based on conditions + + # CLEAN ENVIRONMENT + - name: Remove the ansible_tenant + cisco.aci.aci_tenant: + <<: *aci_info + tenant: ansible_tenant + state: absent + + # Add a tenant + - name: Add a new tenant + cisco.aci.aci_tenant: + <<: *aci_info + tenant: ansible_tenant + description: Ansible tenant + state: present + + # Add VRF + - name: Add a new VRF + cisco.aci.aci_vrf: + <<: *aci_info + tenant: ansible_tenant + name: ansible_vrf + description: Ansible VRF + state: present + + # Add L3Out + - name: Add a new L3 Outside + cisco.aci.aci_l3out: + <<: *aci_info + tenant: ansible_tenant + name: ansible_l3out + description: Ansible L3 Outside + domain: ansible_dom + vrf: ansible_vrf + l3protocol: bgp + state: present + + # ADD l3out logical node profile + - name: l3out logical node profile + cisco.aci.aci_l3out_logical_node_profile: + <<: *aci_info + tenant: ansible_tenant + l3out: ansible_l3out + node_profile: ansible_node_profile + state: present + + # ADD l3out logical interface profile + - name: l3out logical interface profile + cisco.aci.aci_l3out_logical_interface_profile: + <<: *aci_info + tenant: ansible_tenant + l3out: ansible_l3out + node_profile: ansible_node_profile + interface_profile: ansible_interface_profile + state: present + + # CREATE BFD Multihop Interface policy + - name: Add a new BFD Multihop Interface policy + cisco.aci.aci_interface_policy_bfd_multihop: + <<: *aci_info + tenant: ansible_tenant + name: ansible_bfd_multihop_interface_policy + description: Ansible BFD Multihop Interface Policy + state: present + register: add_bfd_multihop_interface_pol + + # Add BFD Multihop Interface Profile + - name: Add a new BFD Multihop Interface Profile - check mode + cisco.aci.aci_l3out_bfd_multihop_interface_profile: &present_bfd_mh_int_profile + <<: *aci_info + tenant: ansible_tenant + l3out: ansible_l3out + l3out_logical_node_profile: ansible_node_profile + l3out_logical_interface_profile: ansible_interface_profile + bfd_multihop_interface_policy: ansible_bfd_multihop_interface_policy + state: present + check_mode: true + register: cm_add_bfd_mh_int_prof + + - name: Add a new BFD Multihop Interface Profile - normal mode + cisco.aci.aci_l3out_bfd_multihop_interface_profile: + <<: *present_bfd_mh_int_profile + state: present + register: nm_add_bfd_mh_int_prof + + - name: Verify adding BFD Multihop Interface Profile + assert: + that: + - cm_add_bfd_mh_int_prof is changed + - nm_add_bfd_mh_int_prof is changed + - cm_add_bfd_mh_int_prof.previous == nm_add_bfd_mh_int_prof.previous == [] + - cm_add_bfd_mh_int_prof.proposed.bfdMhIfP.attributes.dn == nm_add_bfd_mh_int_prof.proposed.bfdMhIfP.attributes.dn == "uni/tn-ansible_tenant/out-ansible_l3out/lnodep-ansible_node_profile/lifp-ansible_interface_profile/bfdMhIfP" + - cm_add_bfd_mh_int_prof.proposed.bfdMhIfP.children.0.bfdRsMhIfPol.attributes.tnBfdMhIfPolName == nm_add_bfd_mh_int_prof.proposed.bfdMhIfP.children.0.bfdRsMhIfPol.attributes.tnBfdMhIfPolName == "ansible_bfd_multihop_interface_policy" + + # Query BFD Multihop Interface Profile + - name: Query BFD Multihop Interface Profile + cisco.aci.aci_l3out_bfd_multihop_interface_profile: + <<: *present_bfd_mh_int_profile + state: query + register: query_bfd_mh_int_prof + + - name: Add BFD Multihop Interface Profile again- idempotency + cisco.aci.aci_l3out_bfd_multihop_interface_profile: + <<: *present_bfd_mh_int_profile + state: present + register: add_bfd_mh_int_prof_again + + - name: Verify adding BFD Multihop Interface Profile again - idempotency + assert: + that: + - add_bfd_mh_int_prof_again is not changed + + # Update BFD Multihop Interface Profile + - name: Update BFD Multihop Interface Profile + cisco.aci.aci_l3out_bfd_multihop_interface_profile: + <<: *present_bfd_mh_int_profile + authentication_type: sha1 + key: "abc*123" + key_id: 15 + state: present + register: update_bfd_mh_int_prof + + - name: Verify updating BFD Multihop Interface Profile + assert: + that: + - update_bfd_mh_int_prof is changed + - update_bfd_mh_int_prof.sent.bfdMhIfP.attributes.keyId == "15" + - update_bfd_mh_int_prof.sent.bfdMhIfP.attributes.key == "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER" + - update_bfd_mh_int_prof.sent.bfdMhIfP.attributes.type == "sha1" + + # Remove children from L3Out BFD Interface Profile + - name: Remove children from BFD Multihop Interface Profile + cisco.aci.aci_l3out_bfd_multihop_interface_profile: + <<: *present_bfd_mh_int_profile + bfd_multihop_interface_policy: "" + register: remove_children_bfd_mh_int_prof + + - name: Asserts for children removal tasks for the from BFD Multihop Interface Profile + ansible.builtin.assert: + that: + - remove_children_bfd_mh_int_prof is changed + - remove_children_bfd_mh_int_prof.sent.bfdMhIfP.children.0.bfdRsMhIfPol.attributes.tnBfdMhIfPolName == "" + + # Query BFD Multihop Interface Profile + - name: Query BFD Multihop Interface Profile + cisco.aci.aci_l3out_bfd_multihop_interface_profile: + <<: *present_bfd_mh_int_profile + state: query + register: query_bfd_mh_int_prof + + - name: Query all BFD Multihop Interface Profile + cisco.aci.aci_l3out_bfd_multihop_interface_profile: + <<: *aci_info + state: query + register: query_all_bfd_mh_int_prof + + # Validating out of range parameters. + - name: Add out of range key_id + cisco.aci.aci_l3out_bfd_multihop_interface_profile: + <<: *present_bfd_mh_int_profile + key_id: 256 + state: present + ignore_errors: true + register: out_of_range_key_id + + - name: Verify out of range key_id + assert: + that: + - out_of_range_key_id is not changed + - out_of_range_key_id.msg == "The \"key_id\" must be a value between 1 and 255" + + - name: Delete BFD Multihop Interface Profile - check mode + cisco.aci.aci_l3out_bfd_multihop_interface_profile: + <<: *present_bfd_mh_int_profile + state: absent + check_mode: true + register: cm_remove_bfd_mh_int_prof + + - name: Delete BFD Multihop Interface Profile - normal mode + cisco.aci.aci_l3out_bfd_multihop_interface_profile: + <<: *present_bfd_mh_int_profile + state: absent + register: nm_remove_bfd_mh_int_prof + + - name: Delete BFD Multihop Interface Profile again - idempotency + cisco.aci.aci_l3out_bfd_multihop_interface_profile: + <<: *present_bfd_mh_int_profile + state: absent + register: remove_bfd_mh_int_prof_again + + - name: Verify removing BFD Multihop Interface Profile + assert: + that: + - cm_remove_bfd_mh_int_prof is changed + - nm_remove_bfd_mh_int_prof is changed + - cm_remove_bfd_mh_int_prof.proposed == nm_remove_bfd_mh_int_prof.proposed == {} + - remove_bfd_mh_int_prof_again is not changed + - nm_remove_bfd_mh_int_prof.current == remove_bfd_mh_int_prof_again.current == []
\ No newline at end of file diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_l3out_bgp_peer/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_l3out_bgp_peer/tasks/main.yml index 8ed2daee3..e7588be41 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_l3out_bgp_peer/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_l3out_bgp_peer/tasks/main.yml @@ -1,16 +1,18 @@ # Test code for the ACI modules # Copyright: (c) 2021, Tim Cragg (@timcragg) +# Copyright: (c) 2023, Akini ROss (@akinross) + # 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 APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: "Please define the following variables: aci_hostname, aci_username and aci_password." when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined # GET Credentials from the inventory - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: "{{ aci_hostname }}" username: "{{ aci_username }}" @@ -28,17 +30,17 @@ register: version - name: Verify Cloud and Non-Cloud Sites in use. - include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml # CLEAN ENVIRONMENT - name: Remove ansible_tenant if it already exists - aci_tenant: + cisco.aci.aci_tenant: <<: *aci_info tenant: ansible_tenant state: absent - name: Remove ansible_l3ext_domain if it already exists - aci_domain: + cisco.aci.aci_domain: <<: *aci_info domain: ansible_l3ext_domain domain_type: l3dom @@ -48,21 +50,21 @@ when: query_cloud.current == [] # This condition will skip execution for cloud sites block: - name: Remove ansible_port_channel_ipg if it already exists - aci_interface_policy_leaf_policy_group: + cisco.aci.aci_interface_policy_leaf_policy_group: <<: *aci_info lag_type: link policy_group: ansible_port_channel_ipg state: absent - name: Remove ansible_vpc_ipg if it already exists - aci_interface_policy_leaf_policy_group: + cisco.aci.aci_interface_policy_leaf_policy_group: <<: *aci_info lag_type: node policy_group: ansible_vpc_ipg state: absent - name: Add a new tenant required for l3out - aci_tenant: + cisco.aci.aci_tenant: <<: *aci_info tenant: ansible_tenant description: Ansible tenant @@ -70,7 +72,7 @@ # ADD domain - name: Add domain for l3out - aci_domain: + cisco.aci.aci_domain: <<: *aci_info domain: ansible_l3ext_domain domain_type: l3dom @@ -78,7 +80,7 @@ # ADD VRF - name: Add VRF for l3out - aci_vrf: + cisco.aci.aci_vrf: <<: *aci_info tenant: ansible_tenant vrf: ansible_vrf @@ -86,7 +88,7 @@ # ADD PC IPG - name: Add port-channel IPG - aci_interface_policy_leaf_policy_group: + cisco.aci.aci_interface_policy_leaf_policy_group: <<: *aci_info lag_type: link policy_group: ansible_port_channel_ipg @@ -94,7 +96,7 @@ # ADD vPC IPG - name: Add vPC IPG - aci_interface_policy_leaf_policy_group: + cisco.aci.aci_interface_policy_leaf_policy_group: <<: *aci_info lag_type: node policy_group: ansible_vpc_ipg @@ -102,7 +104,7 @@ # ADD l3out - name: Add l3out - aci_l3out: + cisco.aci.aci_l3out: <<: *aci_info tenant: ansible_tenant name: ansible_l3out @@ -113,7 +115,7 @@ # ADD l3out logical node profile - name: l3out logical node profile - aci_l3out_logical_node_profile: + cisco.aci.aci_l3out_logical_node_profile: <<: *aci_info tenant: ansible_tenant l3out: ansible_l3out @@ -122,7 +124,7 @@ # ADD l3out logical interface profile - name: l3out logical interface profile - aci_l3out_logical_interface_profile: + cisco.aci.aci_l3out_logical_interface_profile: <<: *aci_info tenant: ansible_tenant l3out: ansible_l3out @@ -132,7 +134,7 @@ # ADD l3out interface - name: Add routed interface - aci_l3out_interface: + cisco.aci.aci_l3out_interface: <<: *aci_info tenant: ansible_tenant l3out: ansible_l3out @@ -148,7 +150,7 @@ # ADD l3out port-channel - name: Add routed interface port-channel - aci_l3out_interface: + cisco.aci.aci_l3out_interface: <<: *aci_info tenant: ansible_tenant l3out: ansible_l3out @@ -164,7 +166,7 @@ # ADD l3out vPC - name: Add interface vPC - aci_l3out_interface: + cisco.aci.aci_l3out_interface: <<: *aci_info tenant: ansible_tenant l3out: ansible_l3out @@ -181,7 +183,7 @@ # ADD BGP peer to ethernet port - name: add BGP peer to ethernet port (version >= 4) - aci_l3out_bgp_peer: + cisco.aci.aci_l3out_bgp_peer: <<: *aci_info tenant: ansible_tenant l3out: ansible_l3out @@ -207,7 +209,7 @@ when: version.current.0.topSystem.attributes.version is version('4', '>=') - name: add BGP peer to ethernet port (version < 4) - aci_l3out_bgp_peer: + cisco.aci.aci_l3out_bgp_peer: <<: *aci_info tenant: ansible_tenant l3out: ansible_l3out @@ -230,7 +232,7 @@ when: version.current.0.topSystem.attributes.version is version('4', '<') - name: verify BGP peer has been created with correct attributes (version >= 4) - assert: + ansible.builtin.assert: that: - add_eth_bgp_peer.current.0.bgpPeerP.attributes.dn == "uni/tn-ansible_tenant/out-ansible_l3out/lnodep-ansible_node_profile/lifp-ansible_interface_profile/rspathL3OutAtt-[topology/pod-1/paths-201/pathep-[eth1/15]]/peerP-[192.168.50.2]" - add_eth_bgp_peer.current.0.bgpPeerP.attributes.addr == "192.168.50.2" @@ -245,7 +247,7 @@ when: version.current.0.topSystem.attributes.version is version('4', '>=') - name: verify BGP peer has been created with correct attributes (version < 4) - assert: + ansible.builtin.assert: that: - add_eth_bgp_peer_32.current.0.bgpPeerP.attributes.dn == "uni/tn-ansible_tenant/out-ansible_l3out/lnodep-ansible_node_profile/lifp-ansible_interface_profile/rspathL3OutAtt-[topology/pod-1/paths-201/pathep-[eth1/15]]/peerP-[192.168.50.2]" - add_eth_bgp_peer_32.current.0.bgpPeerP.attributes.addr == "192.168.50.2" @@ -256,20 +258,20 @@ when: version.current.0.topSystem.attributes.version is version('4', '<') - name: verify remote AS object has been created correctly - assert: + ansible.builtin.assert: that: - add_eth_bgp_peer.current.0.bgpPeerP.children.2.bgpAsP.attributes.asn == "65456" when: version.current.0.topSystem.attributes.version is version('4', '>=') - name: verify remote AS object has been created correctly - assert: + ansible.builtin.assert: that: - add_eth_bgp_peer_32.current.0.bgpPeerP.children.1.bgpAsP.attributes.asn == "65456" when: version.current.0.topSystem.attributes.version is version('4', '<') # ADD BGP peer again to check idempotence - name: add BGP peer to ethernet port again (version >= 4) - aci_l3out_bgp_peer: + cisco.aci.aci_l3out_bgp_peer: <<: *aci_info tenant: ansible_tenant l3out: ansible_l3out @@ -294,7 +296,7 @@ when: version.current.0.topSystem.attributes.version is version('4', '>=') - name: add BGP peer to ethernet port again (version < 4) - aci_l3out_bgp_peer: + cisco.aci.aci_l3out_bgp_peer: <<: *aci_info tenant: ansible_tenant l3out: ansible_l3out @@ -317,7 +319,7 @@ when: version.current.0.topSystem.attributes.version is version('4', '<') - name: verify BGP peer has been created with correct attributes (version >= 4) - assert: + ansible.builtin.assert: that: - add_eth_bgp_peer_again is not changed - add_eth_bgp_peer_again.current.0.bgpPeerP.attributes.dn == "uni/tn-ansible_tenant/out-ansible_l3out/lnodep-ansible_node_profile/lifp-ansible_interface_profile/rspathL3OutAtt-[topology/pod-1/paths-201/pathep-[eth1/15]]/peerP-[192.168.50.2]" @@ -330,7 +332,7 @@ when: version.current.0.topSystem.attributes.version is version('4', '>=') - name: verify BGP peer has been created with correct attributes (version < 4) - assert: + ansible.builtin.assert: that: - add_eth_bgp_peer_again_32 is not changed - add_eth_bgp_peer_again_32.current.0.bgpPeerP.attributes.dn == "uni/tn-ansible_tenant/out-ansible_l3out/lnodep-ansible_node_profile/lifp-ansible_interface_profile/rspathL3OutAtt-[topology/pod-1/paths-201/pathep-[eth1/15]]/peerP-[192.168.50.2]" @@ -341,20 +343,20 @@ when: version.current.0.topSystem.attributes.version is version('4', '<') - name: verify remote AS object is still correct (version >= 4) - assert: + ansible.builtin.assert: that: - add_eth_bgp_peer_again.current.0.bgpPeerP.children.2.bgpAsP.attributes.asn == "65456" when: version.current.0.topSystem.attributes.version is version('4', '>=') - name: verify remote AS object his still correct (version < 4) - assert: + ansible.builtin.assert: that: - add_eth_bgp_peer_again_32.current.0.bgpPeerP.children.1.bgpAsP.attributes.asn == "65456" when: version.current.0.topSystem.attributes.version is version('4', '<') # MODIFY BGP peer - name: update BGP peer (version >= 4) - aci_l3out_bgp_peer: &interface_profile_bgp_peer_present + cisco.aci.aci_l3out_bgp_peer: &interface_profile_bgp_peer_present <<: *aci_info tenant: ansible_tenant l3out: ansible_l3out @@ -386,7 +388,7 @@ when: version.current.0.topSystem.attributes.version is version('4', '>=') - name: update BGP peer (version < 4) - aci_l3out_bgp_peer: + cisco.aci.aci_l3out_bgp_peer: <<: *aci_info tenant: ansible_tenant l3out: ansible_l3out @@ -412,7 +414,7 @@ when: version.current.0.topSystem.attributes.version is version('4', '<') - name: verify BGP peer has been updated with correct attributes (version >= 4) - assert: + ansible.builtin.assert: that: - update_eth_bgp_peer is changed - update_eth_bgp_peer.current.0.bgpPeerP.attributes.dn == "uni/tn-ansible_tenant/out-ansible_l3out/lnodep-ansible_node_profile/lifp-ansible_interface_profile/rspathL3OutAtt-[topology/pod-1/paths-201/pathep-[eth1/15]]/peerP-[192.168.50.2]" @@ -429,7 +431,7 @@ when: version.current.0.topSystem.attributes.version is version('4', '>=') - name: verify BGP peer has been updated with correct attributes (version < 4) - assert: + ansible.builtin.assert: that: - update_eth_bgp_peer_32 is changed - update_eth_bgp_peer_32.current.0.bgpPeerP.attributes.dn == "uni/tn-ansible_tenant/out-ansible_l3out/lnodep-ansible_node_profile/lifp-ansible_interface_profile/rspathL3OutAtt-[topology/pod-1/paths-201/pathep-[eth1/15]]/peerP-[192.168.50.2]" @@ -442,20 +444,20 @@ when: version.current.0.topSystem.attributes.version is version('4', '<') - name: verify remote AS object has been updated correctly (version >= 4) - assert: + ansible.builtin.assert: that: - update_eth_bgp_peer.current.0.bgpPeerP.children.2.bgpAsP.attributes.asn == "65457" when: version.current.0.topSystem.attributes.version is version('4', '>=') - name: verify remote AS object has been updated correctly (version < 4) - assert: + ansible.builtin.assert: that: - update_eth_bgp_peer_32.current.0.bgpPeerP.children.1.bgpAsP.attributes.asn == "65457" when: version.current.0.topSystem.attributes.version is version('4', '<') # QUERY BGP peer - name: query BGP peer (version >= 4) - aci_l3out_bgp_peer: + cisco.aci.aci_l3out_bgp_peer: <<: *aci_info tenant: ansible_tenant l3out: ansible_l3out @@ -470,7 +472,7 @@ when: version.current.0.topSystem.attributes.version is version('4', '>=') - name: query BGP peer (version < 4) - aci_l3out_bgp_peer: + cisco.aci.aci_l3out_bgp_peer: <<: *aci_info tenant: ansible_tenant l3out: ansible_l3out @@ -485,7 +487,7 @@ when: version.current.0.topSystem.attributes.version is version('4', '<') - name: verify BGP peer attributes (version >= 4) - assert: + ansible.builtin.assert: that: - query_eth_bgp_peer is not changed - query_eth_bgp_peer.current.0.bgpPeerP.attributes.dn == "uni/tn-ansible_tenant/out-ansible_l3out/lnodep-ansible_node_profile/lifp-ansible_interface_profile/rspathL3OutAtt-[topology/pod-1/paths-201/pathep-[eth1/15]]/peerP-[192.168.50.2]" @@ -500,7 +502,7 @@ when: version.current.0.topSystem.attributes.version is version('4', '>=') - name: verify BGP peer attributes (version < 4) - assert: + ansible.builtin.assert: that: - query_eth_bgp_peer_32 is not changed - query_eth_bgp_peer_32.current.0.bgpPeerP.attributes.dn == "uni/tn-ansible_tenant/out-ansible_l3out/lnodep-ansible_node_profile/lifp-ansible_interface_profile/rspathL3OutAtt-[topology/pod-1/paths-201/pathep-[eth1/15]]/peerP-[192.168.50.2]" @@ -513,13 +515,13 @@ when: version.current.0.topSystem.attributes.version is version('4', '<') - name: verify BGP remote AS (version >= 4) - assert: + ansible.builtin.assert: that: - query_eth_bgp_peer.current.0.bgpPeerP.children.2.bgpAsP.attributes.asn == "65457" when: version.current.0.topSystem.attributes.version is version('4', '>=') - name: verify BGP remote AS (version < 4) - assert: + ansible.builtin.assert: that: - query_eth_bgp_peer_32.current.0.bgpPeerP.children.1.bgpAsP.attributes.asn == "65457" when: version.current.0.topSystem.attributes.version is version('4', '<') @@ -529,7 +531,7 @@ block: # Route Control Profile validation check for Interface Profile level - name: Add Route Control Profile to the ansible_interface_profile (version >= 4) - check mode - aci_l3out_bgp_peer: + cisco.aci.aci_l3out_bgp_peer: <<: *interface_profile_bgp_peer_present route_control_profiles: - tenant: "ansible_tenant" @@ -544,13 +546,13 @@ register: cm_if_rtctrl_present - name: Assertions check for add Route Control Profile to the ansible_interface_profile (version >= 4) - check mode - assert: + ansible.builtin.assert: that: - cm_if_rtctrl_present is changed - cm_if_rtctrl_present.sent.bgpPeerP.children | length == 2 - name: Add Route Control Profile to the ansible_interface_profile (version >= 4) - normal mode - missing param - aci_l3out_bgp_peer: + cisco.aci.aci_l3out_bgp_peer: <<: *interface_profile_bgp_peer_present route_control_profiles: - tenant: "ansible_tenant" @@ -564,13 +566,13 @@ ignore_errors: true - name: Assertions check for add Route Control Profile to the ansible_interface_profile (version >= 4) - normal mode - missing param - assert: + ansible.builtin.assert: that: - nm_if_rtctrl_present_missing_param is failed - "nm_if_rtctrl_present_missing_param.msg == 'missing required arguments: direction found in route_control_profiles'" - name: Add Route Control Profile to the ansible_interface_profile (version >= 4) - normal mode - aci_l3out_bgp_peer: &nm_if_rtctrl_present + cisco.aci.aci_l3out_bgp_peer: &nm_if_rtctrl_present <<: *interface_profile_bgp_peer_present route_control_profiles: - tenant: "ansible_tenant" @@ -584,7 +586,7 @@ register: nm_if_rtctrl_present - name: Assertions check for add Route Control Profile to the ansible_interface_profile (version >= 4) - normal mode - assert: + ansible.builtin.assert: that: - nm_if_rtctrl_present is changed - nm_if_rtctrl_present.current | length == 1 @@ -594,13 +596,13 @@ - nm_if_rtctrl_present.current.0.bgpPeerP.children | length >= nm_if_rtctrl_present.previous.0.bgpPeerP.children | length - name: Add Route Control Profile to the ansible_interface_profile (version >= 4) - normal mode - idempotency works - aci_l3out_bgp_peer: + cisco.aci.aci_l3out_bgp_peer: <<: *nm_if_rtctrl_present state: present register: idempotency_nm_if_rtctrl_present - name: Idempotency assertions check for add Route Control Profile to the ansible_interface_profile (version >= 4) - normal mode - assert: + ansible.builtin.assert: that: - idempotency_nm_if_rtctrl_present is not changed - idempotency_nm_if_rtctrl_present.current | length == 1 @@ -611,7 +613,7 @@ - idempotency_nm_if_rtctrl_present.previous.0.bgpPeerP.children | length >= 2 - name: Query a BGP Peer with Interface Profile - aci_l3out_bgp_peer: + cisco.aci.aci_l3out_bgp_peer: <<: *aci_info tenant: ansible_tenant l3out: ansible_l3out @@ -625,7 +627,7 @@ register: query_if_bgp_peer - name: Assertions check for query a BGP Peer with Interface Profile - assert: + ansible.builtin.assert: that: - query_if_bgp_peer is not changed - query_if_bgp_peer.current | length == 1 @@ -634,7 +636,7 @@ # Route Control Profile validation check for Node Profile level - name: Add BGP Peer to the Node Profile level (version >= 4) - check mode - aci_l3out_bgp_peer: &cm_ln_rtctrl_present + cisco.aci.aci_l3out_bgp_peer: &cm_ln_rtctrl_present <<: *aci_info tenant: ansible_tenant l3out: ansible_l3out @@ -655,7 +657,7 @@ register: cm_ln_rtctrl_present - name: Assertions check for add BGP Peer to the Node Profile level (version >= 4) - check mode - assert: + ansible.builtin.assert: that: - cm_ln_rtctrl_present is changed - cm_ln_rtctrl_present.current | length == 0 @@ -664,13 +666,13 @@ - cm_ln_rtctrl_present.sent.bgpPeerP.children | length >= 2 - name: Add BGP Peer to the Node Profile level (version >= 4) - normal mode - aci_l3out_bgp_peer: + cisco.aci.aci_l3out_bgp_peer: <<: *cm_ln_rtctrl_present state: present register: nm_ln_rtctrl_present - name: Assertions check for add BGP Peer to the Node Profile level (version >= 4) - normal mode - assert: + ansible.builtin.assert: that: - nm_ln_rtctrl_present is changed - nm_ln_rtctrl_present.current | length == 1 @@ -681,13 +683,13 @@ - nm_ln_rtctrl_present.current.0.bgpPeerP.children.2.bgpLocalAsnP.attributes.localAsn == "100" - name: Add BGP Peer to the Node Profile level (version >= 4) - normal mode - idempotency works - aci_l3out_bgp_peer: + cisco.aci.aci_l3out_bgp_peer: <<: *cm_ln_rtctrl_present state: present register: idempotency_nm_ln_rtctrl_present - name: Idempotency assertions check for add BGP Peer to the Node Profile level (version >= 4) - normal mode - assert: + ansible.builtin.assert: that: - idempotency_nm_ln_rtctrl_present is not changed - idempotency_nm_ln_rtctrl_present.current | length == 1 @@ -697,7 +699,7 @@ - idempotency_nm_ln_rtctrl_present.previous.0.bgpPeerP.attributes.addr == "192.168.50.3" - name: Add BGP Peer to the Node Profile level (version >= 4) - normal mode - missing param - aci_l3out_bgp_peer: + cisco.aci.aci_l3out_bgp_peer: <<: *cm_ln_rtctrl_present route_control_profiles: - tenant: "ansible_tenant" @@ -711,13 +713,13 @@ ignore_errors: true - name: Assertions check for add BGP Peer to the Node Profile level (version >= 4) - normal mode - missing param - assert: + ansible.builtin.assert: that: - nm_ln_rtctrl_present_missing_param is failed - "nm_ln_rtctrl_present_missing_param.msg == 'missing required arguments: direction found in route_control_profiles'" - name: Query a BGP Peer from the Node Profile level - aci_l3out_bgp_peer: + cisco.aci.aci_l3out_bgp_peer: <<: *aci_info tenant: ansible_tenant l3out: ansible_l3out @@ -727,27 +729,27 @@ register: query_ln_bgp_peer - name: Assertions check for query a BGP Peer from the Node Profile level - assert: + ansible.builtin.assert: that: - query_ln_bgp_peer is not changed - query_ln_bgp_peer.current | length == 1 - query_ln_bgp_peer.current.0.bgpPeerP.attributes.addr == "192.168.50.3" - name: Query all BGP peers - aci_l3out_bgp_peer: + cisco.aci.aci_l3out_bgp_peer: <<: *aci_info state: query register: query_all_bgp_peer - name: Assertions check for query all BGP peers - assert: + ansible.builtin.assert: that: - query_all_bgp_peer is not changed - query_all_bgp_peer.current | length != 0 # DELETE BGP peer - name: delete BGP peer - aci_l3out_bgp_peer: + cisco.aci.aci_l3out_bgp_peer: <<: *aci_info tenant: ansible_tenant l3out: ansible_l3out @@ -761,7 +763,7 @@ register: remove_eth_bgp_peer - name: verify remove_eth_bgp_peer - assert: + ansible.builtin.assert: that: - remove_eth_bgp_peer is changed - remove_eth_bgp_peer.current == [] @@ -770,7 +772,7 @@ # ADD BGP peer to port-channel - name: add BGP peer to port-channel (version >= 4) - aci_l3out_bgp_peer: + cisco.aci.aci_l3out_bgp_peer: <<: *aci_info tenant: ansible_tenant l3out: ansible_l3out @@ -795,7 +797,7 @@ when: version.current.0.topSystem.attributes.version is version('4', '>=') - name: add BGP peer to port-channel (version < 4) - aci_l3out_bgp_peer: + cisco.aci.aci_l3out_bgp_peer: <<: *aci_info tenant: ansible_tenant l3out: ansible_l3out @@ -818,7 +820,7 @@ when: version.current.0.topSystem.attributes.version is version('4', '<') - name: verify BGP peer has been created with correct attributes (version >= 4) - assert: + ansible.builtin.assert: that: - add_pc_bgp_peer.current.0.bgpPeerP.attributes.dn == "uni/tn-ansible_tenant/out-ansible_l3out/lnodep-ansible_node_profile/lifp-ansible_interface_profile/rspathL3OutAtt-[topology/pod-1/paths-201/pathep-[ansible_port_channel_ipg]]/peerP-[192.168.50.2]" - add_pc_bgp_peer.current.0.bgpPeerP.attributes.addr == "192.168.50.2" @@ -830,7 +832,7 @@ when: version.current.0.topSystem.attributes.version is version('4', '>=') - name: verify BGP peer has been created with correct attributes (version < 4) - assert: + ansible.builtin.assert: that: - add_pc_bgp_peer_32.current.0.bgpPeerP.attributes.dn == "uni/tn-ansible_tenant/out-ansible_l3out/lnodep-ansible_node_profile/lifp-ansible_interface_profile/rspathL3OutAtt-[topology/pod-1/paths-201/pathep-[ansible_port_channel_ipg]]/peerP-[192.168.50.2]" - add_pc_bgp_peer_32.current.0.bgpPeerP.attributes.addr == "192.168.50.2" @@ -840,20 +842,20 @@ when: version.current.0.topSystem.attributes.version is version('4', '<') - name: verify remote AS object has been created correctly (version >= 4) - assert: + ansible.builtin.assert: that: - add_pc_bgp_peer.current.0.bgpPeerP.children.1.bgpAsP.attributes.asn == "65456" when: version.current.0.topSystem.attributes.version is version('4', '>=') - name: verify remote AS object has been created correctly (version < 4) - assert: + ansible.builtin.assert: that: - add_pc_bgp_peer_32.current.0.bgpPeerP.children.1.bgpAsP.attributes.asn == "65456" when: version.current.0.topSystem.attributes.version is version('4', '<') # ADD BGP peer again to check idempotence - name: add BGP peer to port-channel again (version >= 4) - aci_l3out_bgp_peer: + cisco.aci.aci_l3out_bgp_peer: <<: *aci_info tenant: ansible_tenant l3out: ansible_l3out @@ -878,7 +880,7 @@ when: version.current.0.topSystem.attributes.version is version('4', '>=') - name: add BGP peer to port-channel again (version < 4) - aci_l3out_bgp_peer: + cisco.aci.aci_l3out_bgp_peer: <<: *aci_info tenant: ansible_tenant l3out: ansible_l3out @@ -901,7 +903,7 @@ when: version.current.0.topSystem.attributes.version is version('4', '<') - name: verify BGP peer has been created with correct attributes (version >= 4) - assert: + ansible.builtin.assert: that: - add_pc_bgp_peer_again is not changed - add_pc_bgp_peer_again.current.0.bgpPeerP.attributes.dn == "uni/tn-ansible_tenant/out-ansible_l3out/lnodep-ansible_node_profile/lifp-ansible_interface_profile/rspathL3OutAtt-[topology/pod-1/paths-201/pathep-[ansible_port_channel_ipg]]/peerP-[192.168.50.2]" @@ -914,7 +916,7 @@ when: version.current.0.topSystem.attributes.version is version('4', '>=') - name: verify BGP peer has been created with correct attributes (version < 4) - assert: + ansible.builtin.assert: that: - add_pc_bgp_peer_again_32 is not changed - add_pc_bgp_peer_again_32.current.0.bgpPeerP.attributes.dn == "uni/tn-ansible_tenant/out-ansible_l3out/lnodep-ansible_node_profile/lifp-ansible_interface_profile/rspathL3OutAtt-[topology/pod-1/paths-201/pathep-[ansible_port_channel_ipg]]/peerP-[192.168.50.2]" @@ -925,20 +927,20 @@ when: version.current.0.topSystem.attributes.version is version('4', '<') - name: verify remote AS object has been created correctly (version >= 4) - assert: + ansible.builtin.assert: that: - add_pc_bgp_peer_again.current.0.bgpPeerP.children.1.bgpAsP.attributes.asn == "65456" when: version.current.0.topSystem.attributes.version is version('4', '>=') - name: verify remote AS object has been created correctly (version < 4) - assert: + ansible.builtin.assert: that: - add_pc_bgp_peer_again_32.current.0.bgpPeerP.children.1.bgpAsP.attributes.asn == "65456" when: version.current.0.topSystem.attributes.version is version('4', '<') # MODIFY BGP peer - name: update BGP peer (version >= 4) - aci_l3out_bgp_peer: + cisco.aci.aci_l3out_bgp_peer: <<: *aci_info tenant: ansible_tenant l3out: ansible_l3out @@ -971,7 +973,7 @@ when: version.current.0.topSystem.attributes.version is version('4', '>=') - name: update BGP peer (version < 4) - aci_l3out_bgp_peer: + cisco.aci.aci_l3out_bgp_peer: <<: *aci_info tenant: ansible_tenant l3out: ansible_l3out @@ -1000,7 +1002,7 @@ when: version.current.0.topSystem.attributes.version is version('4', '<') - name: verify BGP peer has been updated with correct attributes (version >= 4) - assert: + ansible.builtin.assert: that: - update_pc_bgp_peer is changed - update_pc_bgp_peer.current.0.bgpPeerP.attributes.dn == "uni/tn-ansible_tenant/out-ansible_l3out/lnodep-ansible_node_profile/lifp-ansible_interface_profile/rspathL3OutAtt-[topology/pod-1/paths-201/pathep-[ansible_port_channel_ipg]]/peerP-[192.168.50.2]" @@ -1015,7 +1017,7 @@ when: version.current.0.topSystem.attributes.version is version('4', '>=') - name: verify BGP peer has been updated with correct attributes (version < 4) - assert: + ansible.builtin.assert: that: - update_pc_bgp_peer_32 is changed - update_pc_bgp_peer_32.current.0.bgpPeerP.attributes.dn == "uni/tn-ansible_tenant/out-ansible_l3out/lnodep-ansible_node_profile/lifp-ansible_interface_profile/rspathL3OutAtt-[topology/pod-1/paths-201/pathep-[ansible_port_channel_ipg]]/peerP-[192.168.50.2]" @@ -1028,20 +1030,20 @@ when: version.current.0.topSystem.attributes.version is version('4', '<') - name: verify remote AS object has been created correctly (version >= 4) - assert: + ansible.builtin.assert: that: - update_pc_bgp_peer.current.0.bgpPeerP.children.1.bgpAsP.attributes.asn == "65457" when: version.current.0.topSystem.attributes.version is version('4', '>=') - name: verify remote AS object has been created correctly (version < 4) - assert: + ansible.builtin.assert: that: - update_pc_bgp_peer_32.current.0.bgpPeerP.children.1.bgpAsP.attributes.asn == "65457" when: version.current.0.topSystem.attributes.version is version('4', '<') # QUERY BGP peer - name: query BGP peer (version >= 4) - aci_l3out_bgp_peer: + cisco.aci.aci_l3out_bgp_peer: <<: *aci_info tenant: ansible_tenant l3out: ansible_l3out @@ -1056,7 +1058,7 @@ when: version.current.0.topSystem.attributes.version is version('4', '>=') - name: query BGP peer (version < 4) - aci_l3out_bgp_peer: + cisco.aci.aci_l3out_bgp_peer: <<: *aci_info tenant: ansible_tenant l3out: ansible_l3out @@ -1071,7 +1073,7 @@ when: version.current.0.topSystem.attributes.version is version('4', '<') - name: verify BGP peer attributes (version >= 4) - assert: + ansible.builtin.assert: that: - query_pc_bgp_peer is not changed - query_pc_bgp_peer.current.0.bgpPeerP.attributes.dn == "uni/tn-ansible_tenant/out-ansible_l3out/lnodep-ansible_node_profile/lifp-ansible_interface_profile/rspathL3OutAtt-[topology/pod-1/paths-201/pathep-[ansible_port_channel_ipg]]/peerP-[192.168.50.2]" @@ -1086,7 +1088,7 @@ when: version.current.0.topSystem.attributes.version is version('4', '>=') - name: verify BGP peer attributes (version < 4) - assert: + ansible.builtin.assert: that: - query_pc_bgp_peer_32 is not changed - query_pc_bgp_peer_32.current.0.bgpPeerP.attributes.dn == "uni/tn-ansible_tenant/out-ansible_l3out/lnodep-ansible_node_profile/lifp-ansible_interface_profile/rspathL3OutAtt-[topology/pod-1/paths-201/pathep-[ansible_port_channel_ipg]]/peerP-[192.168.50.2]" @@ -1099,20 +1101,20 @@ when: version.current.0.topSystem.attributes.version is version('4', '<') - name: verify BGP remote AS (version >= 4) - assert: + ansible.builtin.assert: that: - query_pc_bgp_peer.current.0.bgpPeerP.children.1.bgpAsP.attributes.asn == "65457" when: version.current.0.topSystem.attributes.version is version('4', '>=') - name: verify BGP remote AS (version < 4) - assert: + ansible.builtin.assert: that: - query_pc_bgp_peer_32.current.0.bgpPeerP.children.1.bgpAsP.attributes.asn == "65457" when: version.current.0.topSystem.attributes.version is version('4', '<') # DELETE BGP peer - name: delete BGP peer - aci_l3out_bgp_peer: + cisco.aci.aci_l3out_bgp_peer: <<: *aci_info tenant: ansible_tenant l3out: ansible_l3out @@ -1126,7 +1128,7 @@ register: remove_pc_bgp_peer - name: verify remove_pc_bgp_peer - assert: + ansible.builtin.assert: that: - remove_pc_bgp_peer is changed - remove_pc_bgp_peer.current == [] @@ -1135,7 +1137,7 @@ # ADD BGP peer to vPC - name: add BGP peer to vPC (version >= 4) - aci_l3out_bgp_peer: + cisco.aci.aci_l3out_bgp_peer: <<: *aci_info tenant: ansible_tenant l3out: ansible_l3out @@ -1160,7 +1162,7 @@ when: version.current.0.topSystem.attributes.version is version('4', '>=') - name: add BGP peer to vPC (version < 4) - aci_l3out_bgp_peer: + cisco.aci.aci_l3out_bgp_peer: <<: *aci_info tenant: ansible_tenant l3out: ansible_l3out @@ -1183,7 +1185,7 @@ when: version.current.0.topSystem.attributes.version is version('4', '<') - name: verify BGP peer has been created with correct attributes (version >= 4) - assert: + ansible.builtin.assert: that: - add_vpc_bgp_peer.current.0.bgpPeerP.attributes.dn == "uni/tn-ansible_tenant/out-ansible_l3out/lnodep-ansible_node_profile/lifp-ansible_interface_profile/rspathL3OutAtt-[topology/pod-1/protpaths-201-202/pathep-[ansible_vpc_ipg]]/peerP-[192.168.50.2]" - add_vpc_bgp_peer.current.0.bgpPeerP.attributes.addr == "192.168.50.2" @@ -1195,7 +1197,7 @@ when: version.current.0.topSystem.attributes.version is version('4', '>=') - name: verify BGP peer has been created with correct attributes (version < 4) - assert: + ansible.builtin.assert: that: - add_vpc_bgp_peer_32.current.0.bgpPeerP.attributes.dn == "uni/tn-ansible_tenant/out-ansible_l3out/lnodep-ansible_node_profile/lifp-ansible_interface_profile/rspathL3OutAtt-[topology/pod-1/protpaths-201-202/pathep-[ansible_vpc_ipg]]/peerP-[192.168.50.2]" - add_vpc_bgp_peer_32.current.0.bgpPeerP.attributes.addr == "192.168.50.2" @@ -1205,20 +1207,20 @@ when: version.current.0.topSystem.attributes.version is version('4', '<') - name: verify remote AS object has been created correctly (version >= 4) - assert: + ansible.builtin.assert: that: - add_vpc_bgp_peer.current.0.bgpPeerP.children.1.bgpAsP.attributes.asn == "65456" when: version.current.0.topSystem.attributes.version is version('4', '>=') - name: verify remote AS object has been created correctly (version < 4) - assert: + ansible.builtin.assert: that: - add_vpc_bgp_peer_32.current.0.bgpPeerP.children.1.bgpAsP.attributes.asn == "65456" when: version.current.0.topSystem.attributes.version is version('4', '<') # ADD BGP peer again to check idempotence - name: add BGP peer to vPC again (version >= 4) - aci_l3out_bgp_peer: + cisco.aci.aci_l3out_bgp_peer: <<: *aci_info tenant: ansible_tenant l3out: ansible_l3out @@ -1243,7 +1245,7 @@ when: version.current.0.topSystem.attributes.version is version('4', '>=') - name: add BGP peer to vPC again (version < 4) - aci_l3out_bgp_peer: + cisco.aci.aci_l3out_bgp_peer: <<: *aci_info tenant: ansible_tenant l3out: ansible_l3out @@ -1266,7 +1268,7 @@ when: version.current.0.topSystem.attributes.version is version('4', '<') - name: verify BGP peer has been created with correct attributes (version >= 4) - assert: + ansible.builtin.assert: that: - add_vpc_bgp_peer_again is not changed - add_vpc_bgp_peer_again.current.0.bgpPeerP.attributes.dn == "uni/tn-ansible_tenant/out-ansible_l3out/lnodep-ansible_node_profile/lifp-ansible_interface_profile/rspathL3OutAtt-[topology/pod-1/protpaths-201-202/pathep-[ansible_vpc_ipg]]/peerP-[192.168.50.2]" @@ -1279,7 +1281,7 @@ when: version.current.0.topSystem.attributes.version is version('4', '>=') - name: verify BGP peer has been created with correct attributes (version < 4) - assert: + ansible.builtin.assert: that: - add_vpc_bgp_peer_again_32 is not changed - add_vpc_bgp_peer_again_32.current.0.bgpPeerP.attributes.dn == "uni/tn-ansible_tenant/out-ansible_l3out/lnodep-ansible_node_profile/lifp-ansible_interface_profile/rspathL3OutAtt-[topology/pod-1/protpaths-201-202/pathep-[ansible_vpc_ipg]]/peerP-[192.168.50.2]" @@ -1290,20 +1292,20 @@ when: version.current.0.topSystem.attributes.version is version('4', '<') - name: verify remote AS object has been created correctly (version >= 4) - assert: + ansible.builtin.assert: that: - add_vpc_bgp_peer_again.current.0.bgpPeerP.children.1.bgpAsP.attributes.asn == "65456" when: version.current.0.topSystem.attributes.version is version('4', '>=') - name: verify remote AS object has been created correctly (version < 4) - assert: + ansible.builtin.assert: that: - add_vpc_bgp_peer_again_32.current.0.bgpPeerP.children.1.bgpAsP.attributes.asn == "65456" when: version.current.0.topSystem.attributes.version is version('4', '<') # MODIFY BGP peer - name: update BGP peer (version >= 4) - aci_l3out_bgp_peer: + cisco.aci.aci_l3out_bgp_peer: <<: *aci_info tenant: ansible_tenant l3out: ansible_l3out @@ -1336,7 +1338,7 @@ when: version.current.0.topSystem.attributes.version is version('4', '>=') - name: update BGP peer (version < 4) - aci_l3out_bgp_peer: + cisco.aci.aci_l3out_bgp_peer: <<: *aci_info tenant: ansible_tenant l3out: ansible_l3out @@ -1365,7 +1367,7 @@ when: version.current.0.topSystem.attributes.version is version('4', '<') - name: verify BGP peer has been updated with correct attributes (version >= 4) - assert: + ansible.builtin.assert: that: - update_vpc_bgp_peer is changed - update_vpc_bgp_peer.current.0.bgpPeerP.attributes.dn == "uni/tn-ansible_tenant/out-ansible_l3out/lnodep-ansible_node_profile/lifp-ansible_interface_profile/rspathL3OutAtt-[topology/pod-1/protpaths-201-202/pathep-[ansible_vpc_ipg]]/peerP-[192.168.50.2]" @@ -1380,7 +1382,7 @@ when: version.current.0.topSystem.attributes.version is version('4', '>=') - name: verify BGP peer has been updated with correct attributes (version < 4) - assert: + ansible.builtin.assert: that: - update_vpc_bgp_peer_32 is changed - update_vpc_bgp_peer_32.current.0.bgpPeerP.attributes.dn == "uni/tn-ansible_tenant/out-ansible_l3out/lnodep-ansible_node_profile/lifp-ansible_interface_profile/rspathL3OutAtt-[topology/pod-1/protpaths-201-202/pathep-[ansible_vpc_ipg]]/peerP-[192.168.50.2]" @@ -1393,20 +1395,20 @@ when: version.current.0.topSystem.attributes.version is version('4', '<') - name: verify remote AS object has been created correctly (version >= 4) - assert: + ansible.builtin.assert: that: - update_vpc_bgp_peer.current.0.bgpPeerP.children.1.bgpAsP.attributes.asn == "65457" when: version.current.0.topSystem.attributes.version is version('4', '>=') - name: verify remote AS object has been created correctly (version < 4) - assert: + ansible.builtin.assert: that: - update_vpc_bgp_peer_32.current.0.bgpPeerP.children.1.bgpAsP.attributes.asn == "65457" when: version.current.0.topSystem.attributes.version is version('4', '<') # QUERY BGP peer - name: query BGP peer (version >= 4) - aci_l3out_bgp_peer: + cisco.aci.aci_l3out_bgp_peer: <<: *aci_info tenant: ansible_tenant l3out: ansible_l3out @@ -1421,7 +1423,7 @@ when: version.current.0.topSystem.attributes.version is version('4', '>=') - name: query BGP peer (version < 4) - aci_l3out_bgp_peer: + cisco.aci.aci_l3out_bgp_peer: <<: *aci_info tenant: ansible_tenant l3out: ansible_l3out @@ -1436,7 +1438,7 @@ when: version.current.0.topSystem.attributes.version is version('4', '<') - name: verify BGP peer attributes (version >= 4) - assert: + ansible.builtin.assert: that: - query_vpc_bgp_peer is not changed - query_vpc_bgp_peer.current.0.bgpPeerP.attributes.dn == "uni/tn-ansible_tenant/out-ansible_l3out/lnodep-ansible_node_profile/lifp-ansible_interface_profile/rspathL3OutAtt-[topology/pod-1/protpaths-201-202/pathep-[ansible_vpc_ipg]]/peerP-[192.168.50.2]" @@ -1451,7 +1453,7 @@ when: version.current.0.topSystem.attributes.version is version('4', '>=') - name: verify BGP peer attributes (version < 4) - assert: + ansible.builtin.assert: that: - query_vpc_bgp_peer_32 is not changed - query_vpc_bgp_peer_32.current.0.bgpPeerP.attributes.dn == "uni/tn-ansible_tenant/out-ansible_l3out/lnodep-ansible_node_profile/lifp-ansible_interface_profile/rspathL3OutAtt-[topology/pod-1/protpaths-201-202/pathep-[ansible_vpc_ipg]]/peerP-[192.168.50.2]" @@ -1464,20 +1466,20 @@ when: version.current.0.topSystem.attributes.version is version('4', '<') - name: verify BGP remote AS (version >= 4) - assert: + ansible.builtin.assert: that: - query_pc_bgp_peer.current.0.bgpPeerP.children.1.bgpAsP.attributes.asn == "65457" when: version.current.0.topSystem.attributes.version is version('4', '>=') - name: verify BGP remote AS (version < 4) - assert: + ansible.builtin.assert: that: - query_pc_bgp_peer_32.current.0.bgpPeerP.children.1.bgpAsP.attributes.asn == "65457" when: version.current.0.topSystem.attributes.version is version('4', '<') # DELETE BGP peer - name: delete BGP peer - aci_l3out_bgp_peer: + cisco.aci.aci_l3out_bgp_peer: <<: *aci_info tenant: ansible_tenant l3out: ansible_l3out @@ -1491,36 +1493,170 @@ register: remove_vpc_bgp_peer - name: verify remove_vpc_bgp_peer - assert: + ansible.builtin.assert: that: - remove_vpc_bgp_peer is changed - remove_vpc_bgp_peer.current == [] - remove_vpc_bgp_peer.previous.0.bgpPeerP.attributes.dn == "uni/tn-ansible_tenant/out-ansible_l3out/lnodep-ansible_node_profile/lifp-ansible_interface_profile/rspathL3OutAtt-[topology/pod-1/protpaths-201-202/pathep-[ansible_vpc_ipg]]/peerP-[192.168.50.2]" - remove_vpc_bgp_peer.previous.0.bgpPeerP.attributes.addr == "192.168.50.2" + # Create BGP Peer with password + - name: Create BGP Peer with password + aci_l3out_bgp_peer: &bgp_peer_with_password + <<: *aci_info + tenant: ansible_tenant + l3out: ansible_l3out + node_profile: ansible_node_profile + interface_profile: ansible_interface_profile + pod_id: 1 + node_id: 201-202 + path_ep: ansible_vpc_ipg + peer_ip: 192.168.50.2 + description: ansible_test_description + bgp_password: ansible_test_password + remote_asn: 65450 + local_as_number: 65460 + bgp_controls: + - send-com + transport_data_plane: mpls + state: present + register: create_with_password + + - name: Update BGP Peer to remove remote as and local as number + aci_l3out_bgp_peer: + <<: *bgp_peer_with_password + remote_asn: 0 + local_as_number: 0 + state: present + register: update_remove_remote_local_as + + - name: Asser that BGP Peer with password, remote as and local as + assert: + that: + - create_with_password is changed + - create_with_password.previous == [] + - create_with_password.current.0.bgpPeerP.attributes.password is not defined + - create_with_password.current.0.bgpPeerP.children.0.bgpLocalAsnP.attributes.localAsn == "65460" + - create_with_password.current.0.bgpPeerP.children.2.bgpAsP.attributes.asn == "65450" + - update_remove_remote_local_as is changed + - update_remove_remote_local_as.previous != [] + - update_remove_remote_local_as.current.0.bgpPeerP.children | length == 1 + - update_remove_remote_local_as.current.0.bgpPeerP.children.0.bgpLocalAsnP is not defined + - update_remove_remote_local_as.current.0.bgpPeerP.children.0.bgpAsP is not defined + + - name: Execute tasks only for ACI v5+ because SR MPLS L3Out is not supported lower versions + when: version.current.0.topSystem.attributes.version is version('5', '>=') + block: + + - name: Create l3out in infra tenant + aci_l3out: &aci_infra_l3out + <<: *aci_info + tenant: infra + name: ansible_infra_l3out + vrf: overlay-1 + mpls: yes + domain: ansible_domain + route_control: export + l3protocol: bgp + state: present + + - name: Create l3out logical node profile in infra tenant + aci_l3out_logical_node_profile: + <<: *aci_info + tenant: infra + l3out: ansible_infra_l3out + node_profile: ansible_infra_l3out_node_profile + state: present + + - name: Create Infra BGP Peer with password + aci_l3out_bgp_peer: &infra_bgp_peer + <<: *aci_info + tenant: infra + l3out: ansible_infra_l3out + node_profile: ansible_infra_l3out_node_profile + ttl: 2 + bgp_infra_peer: true + bgp_password: ansible_test_password + peer_ip: 192.168.50.2 + remote_asn: 65450 + local_as_number: 65460 + peer_type: sr_mpls + bgp_controls: + - send-domain-path + transport_data_plane: sr_mpls + bgp_peer_prefix_policy: ansible_peer_prefix_profile + state: present + register: create_infra_bgp_peer + + - name: Query Infra BGP Peer + aci_l3out_bgp_peer: + <<: *infra_bgp_peer + state: query + register: query_infra_bgp_peer + + - name: Query all Infra BGP Peer + aci_l3out_bgp_peer: + <<: *infra_bgp_peer + bgp_infra_peer: true + state: query + register: query_all_infra_bgp_peer + + - name: Remove Infra BGP Peer + aci_l3out_bgp_peer: + <<: *infra_bgp_peer + state: absent + register: remove_infra_bgp_peer + + # CLEAN UP INFRA L3OUT + - name: Remove ansible_infra_l3out + aci_l3out: + <<: *aci_infra_l3out + state: absent + + - name: Asser that BGP Peer with password, remote as and local as + assert: + that: + - create_infra_bgp_peer is changed + - create_infra_bgp_peer.previous == [] + - create_infra_bgp_peer.current.0.bgpInfraPeerP.attributes.dn == "uni/tn-infra/out-ansible_infra_l3out/lnodep-ansible_infra_l3out_node_profile/infraPeerP-[192.168.50.2]" + - create_infra_bgp_peer.current.0.bgpInfraPeerP.attributes.peerT == "sr-mpls" + - create_infra_bgp_peer.current.0.bgpInfraPeerP.attributes.ctrlExt == "send-domain-path" + - create_infra_bgp_peer.current.0.bgpInfraPeerP.children.1.bgpRsPeerPfxPol.attributes.tnBgpPeerPfxPolName == "ansible_peer_prefix_profile" + - query_infra_bgp_peer is not changed + - query_infra_bgp_peer.current | length == 1 + - query_infra_bgp_peer.current.0.bgpInfraPeerP.attributes.dn == "uni/tn-infra/out-ansible_infra_l3out/lnodep-ansible_infra_l3out_node_profile/infraPeerP-[192.168.50.2]" + - query_all_infra_bgp_peer is not changed + - query_all_infra_bgp_peer.current | length >= 1 + - remove_infra_bgp_peer is changed + - remove_infra_bgp_peer.previous.0.bgpInfraPeerP.attributes.dn == "uni/tn-infra/out-ansible_infra_l3out/lnodep-ansible_infra_l3out_node_profile/infraPeerP-[192.168.50.2]" + - remove_infra_bgp_peer.previous.0.bgpInfraPeerP.attributes.peerT == "sr-mpls" + - remove_infra_bgp_peer.previous.0.bgpInfraPeerP.attributes.ctrlExt == "send-domain-path" + - remove_infra_bgp_peer.previous.0.bgpInfraPeerP.children.1.bgpRsPeerPfxPol.attributes.tnBgpPeerPfxPolName == "ansible_peer_prefix_profile" + - remove_infra_bgp_peer.current == [] + # CLEAN UP - name: Remove ansible_tenant - aci_tenant: + cisco.aci.aci_tenant: <<: *aci_info tenant: ansible_tenant state: absent - name: Remove ansible_l3ext_domain - aci_domain: + cisco.aci.aci_domain: <<: *aci_info domain: ansible_l3ext_domain domain_type: l3dom state: absent - name: Remove ansible_port_channel_ipg - aci_interface_policy_leaf_policy_group: + cisco.aci.aci_interface_policy_leaf_policy_group: <<: *aci_info lag_type: link policy_group: ansible_port_channel_ipg state: absent - name: Remove ansible_vpc_ipg - aci_interface_policy_leaf_policy_group: + cisco.aci.aci_interface_policy_leaf_policy_group: <<: *aci_info lag_type: node policy_group: ansible_vpc_ipg diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_l3out_bgp_protocol_profile/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_l3out_bgp_protocol_profile/tasks/main.yml index 85b43726c..26d0f436f 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_l3out_bgp_protocol_profile/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_l3out_bgp_protocol_profile/tasks/main.yml @@ -4,12 +4,12 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: "{{ aci_hostname }}" username: "{{ aci_username }}" @@ -21,26 +21,26 @@ # CLEAN ENVIRONMENT - name: Remove the ansible_tenant - aci_tenant: &aci_tenant_absent + cisco.aci.aci_tenant: &aci_tenant_absent <<: *aci_info tenant: ansible_tenant state: absent - name: Verify Cloud and Non-Cloud Sites in use. - include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml - name: Execute tasks only for non-cloud sites when: query_cloud.current == [] # This condition will execute only non-cloud sites block: # block specifies execution of tasks within, based on conditions - name: Add a new tenant - aci_tenant: &aci_tenant_present + cisco.aci.aci_tenant: &aci_tenant_present <<: *aci_info tenant: ansible_tenant description: Ansible tenant state: present - name: Add a new l3out - aci_l3out: + cisco.aci.aci_l3out: <<: *aci_info tenant: ansible_tenant l3out: ansible_l3out @@ -50,7 +50,7 @@ state: present - name: Add a new logical node profile - aci_l3out_logical_node_profile: + cisco.aci.aci_l3out_logical_node_profile: <<: *aci_info tenant: ansible_tenant l3out: ansible_l3out @@ -59,7 +59,7 @@ state: present - name: Add a second logical node profile - aci_l3out_logical_node_profile: + cisco.aci.aci_l3out_logical_node_profile: <<: *aci_info tenant: ansible_tenant l3out: ansible_l3out @@ -68,7 +68,7 @@ state: present - name: Add a new BGP timers policy - aci_bgp_timers_policy: + cisco.aci.aci_bgp_timers_policy: <<: *aci_info tenant: ansible_tenant bgp_timers_policy: ansible_bgp_timers_policy @@ -76,7 +76,7 @@ state: present - name: Add a new BGP protocol profile - aci_bgp_best_path_policy: + cisco.aci.aci_bgp_best_path_policy: <<: *aci_info tenant: ansible_tenant bgp_best_path_policy: ansible_bgp_best_path_policy @@ -84,7 +84,7 @@ state: present - name: Add a BGP protocol profile (check_mode) - aci_l3out_bgp_protocol_profile: &aci_l3out_bgp_protocol_profile_present + cisco.aci.aci_l3out_bgp_protocol_profile: &aci_l3out_bgp_protocol_profile_present <<: *aci_info tenant: ansible_tenant l3out: ansible_l3out @@ -96,17 +96,17 @@ register: cm_add_bgp_protocol_profile - name: Add a BGP protocol profile (normal_mode) - aci_l3out_bgp_protocol_profile: + cisco.aci.aci_l3out_bgp_protocol_profile: <<: *aci_l3out_bgp_protocol_profile_present register: nm_add_bgp_protocol_profile - name: Add the first BGP protocol profile again - testing idempotency - aci_l3out_bgp_protocol_profile: + cisco.aci.aci_l3out_bgp_protocol_profile: <<: *aci_l3out_bgp_protocol_profile_present register: nm_add_bgp_protocol_profile_idempotency - name: Add a second BGP protocol profile (normal_mode) - aci_l3out_bgp_protocol_profile: + cisco.aci.aci_l3out_bgp_protocol_profile: <<: *aci_info tenant: ansible_tenant l3out: ansible_l3out @@ -115,7 +115,7 @@ register: nm_add_bgp_protocol_profile_2 - name: Asserts for BGP protocol profiles creation tasks - assert: + ansible.builtin.assert: that: - cm_add_bgp_protocol_profile is changed - cm_add_bgp_protocol_profile.previous == [] @@ -128,19 +128,19 @@ - nm_add_bgp_protocol_profile_2.previous == [] - name: Query all BGP best path policies - aci_l3out_bgp_protocol_profile: + cisco.aci.aci_l3out_bgp_protocol_profile: <<: *aci_info state: query register: query_all_bgp_protocol_profile - name: Query ansible_bgp_protocol_profile_1 - aci_l3out_bgp_protocol_profile: + cisco.aci.aci_l3out_bgp_protocol_profile: <<: *aci_l3out_bgp_protocol_profile_present state: query register: query_ansible_bgp_protocol_profile_1 - name: Asserts query tasks - assert: + ansible.builtin.assert: that: - query_all_bgp_protocol_profile is not changed - query_all_bgp_protocol_profile.current|length >= 2 @@ -151,24 +151,24 @@ - query_ansible_bgp_protocol_profile_1.current.0.bgpProtP.children.1.bgpRsBgpNodeCtxPol.attributes.state == "formed" - name: Remove BGP protocol profile (check_mode) - aci_l3out_bgp_protocol_profile: &bgp_protocol_profile_absent + cisco.aci.aci_l3out_bgp_protocol_profile: &bgp_protocol_profile_absent <<: *aci_l3out_bgp_protocol_profile_present state: absent check_mode: true register: cm_remove_bgp_protocol_profile - name: Remove BGP protocol profile (normal_mode) - aci_l3out_bgp_protocol_profile: + cisco.aci.aci_l3out_bgp_protocol_profile: <<: *bgp_protocol_profile_absent register: nm_remove_bgp_protocol_profile - name: Remove BGP protocol profile - testing idempotency - aci_l3out_bgp_protocol_profile: + cisco.aci.aci_l3out_bgp_protocol_profile: <<: *bgp_protocol_profile_absent register: nm_remove_bgp_protocol_profile_idempotency - name: Asserts deletion tasks - assert: + ansible.builtin.assert: that: - cm_remove_bgp_protocol_profile is changed - cm_remove_bgp_protocol_profile.proposed == {} @@ -179,6 +179,6 @@ - nm_remove_bgp_protocol_profile_idempotency.previous == [] - name: Remove the ansible_tenant - cleanup before ending tests - aci_tenant: + cisco.aci.aci_tenant: <<: *aci_tenant_present state: absent
\ No newline at end of file diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_l3out_dhcp_relay_label/aliases b/ansible_collections/cisco/aci/tests/integration/targets/aci_l3out_dhcp_relay_label/aliases new file mode 100644 index 000000000..209b793f9 --- /dev/null +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_l3out_dhcp_relay_label/aliases @@ -0,0 +1,2 @@ +# No ACI simulator yet, so not enabled +# unsupported diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_l3out_dhcp_relay_label/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_l3out_dhcp_relay_label/tasks/main.yml new file mode 100644 index 000000000..5b34dadf1 --- /dev/null +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_l3out_dhcp_relay_label/tasks/main.yml @@ -0,0 +1,242 @@ +# Test code for the ACI modules +# Copyright: (c) 2023, Gaspard Micol (@gmicol) <gmicol@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 APIC host, ACI username and ACI password + ansible.builtin.fail: + msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' + when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined + +- name: Set vars + ansible.builtin.set_fact: + aci_info: &aci_info + host: "{{ aci_hostname }}" + username: "{{ aci_username }}" + password: "{{ aci_password }}" + validate_certs: '{{ aci_validate_certs | default(false) }}' + use_ssl: '{{ aci_use_ssl | default(true) }}' + use_proxy: '{{ aci_use_proxy | default(true) }}' + output_level: debug + +# CLEAN ENVIRONMENT +- name: Remove the ansible_tenant + cisco.aci.aci_tenant: &aci_tenant_absent + <<: *aci_info + tenant: ansible_tenant + state: absent + +- name: Verify Cloud and Non-Cloud Sites in use. + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + +- name: Execute tasks only for non-cloud sites + when: query_cloud.current == [] # This condition will execute only non-cloud sites + block: # block specifies execution of tasks within, based on conditions + - name: Add a new tenant + cisco.aci.aci_tenant: &aci_tenant_present + <<: *aci_info + tenant: ansible_tenant + description: Ansible tenant + state: present + + - name: Add new Domain + cisco.aci.aci_domain: &aci_domain_present + <<: *aci_info + domain: ansible_dom + domain_type: l3dom + state: present + + - name: Addd a new VRF + cisco.aci.aci_vrf: &aci_vrf_present + <<: *aci_tenant_present + vrf: ansible_vrf + description: Ansible VRF + + - name: Add a new L3Out + cisco.aci.aci_l3out: &aci_l3out_present + <<: *aci_vrf_present + l3out: ansible_l3out + domain: ansible_dom + route_control: export + l3protocol: eigrp + asn: 1 + description: Ansible L3Out + + - name: Add a new L3Out logical node profile + cisco.aci.aci_l3out_logical_node_profile: &aci_l3out_node_profile_present + <<: *aci_tenant_present + l3out: ansible_l3out + node_profile: ansible_l3out_node_profile + description: Ansible L3Out Logical Node Profile + + - name: Add a new L3Out logical interface profile + cisco.aci.aci_l3out_logical_interface_profile: &aci_l3out_interface_profile_present + <<: *aci_l3out_node_profile_present + interface_profile: ansible_l3out_interface_profile + description: First Ansible L3Out Logical Interface Profile + + - name: Add a new DHCP relay policy in infra + cisco.aci.aci_dhcp_relay: + <<: *aci_info + relay_policy: ansible_dhcp_relay_policy_infra + description: Ansible DHCP Relay Policy in infra + state: present + + - name: Add a new DHCP relay policy in ansible tenant + cisco.aci.aci_dhcp_relay: + <<: *aci_tenant_present + relay_policy: ansible_dhcp_relay_policy_tenant + description: Ansible DHCP Relay Policy in tenant + state: present + + - name: Add a new DHCP option policy + cisco.aci.aci_dhcp_option_policy: + <<: *aci_tenant_present + dhcp_option_policy: ansible_dhcp_option_policy + description: Ansible DHCP Option Policy + state: present + + - name: Add L3Out DHCP Relay Label to first interface profile (check mode) + cisco.aci.aci_l3out_dhcp_relay_label: &aci_l3out_dhcp_relay_label_present + <<: *aci_l3out_interface_profile_present + dhcp_relay_label: ansible_dhcp_relay_policy_tenant + scope: tenant + dhcp_option_policy: ansible_dhcp_option_policy + description: First Ansible DHCP Relay Label + check_mode: true + register: cm_add_l3out_dhcp_relay_label + + - name: Add L3Out DHCP Relay Label to first interface profile (normal mode) + cisco.aci.aci_l3out_dhcp_relay_label: + <<: *aci_l3out_dhcp_relay_label_present + register: nm_add_l3out_dhcp_relay_label + + - name: Add L3Out DHCP relay label to first interface profile again - testing idempotency + cisco.aci.aci_l3out_dhcp_relay_label: + <<: *aci_l3out_dhcp_relay_label_present + register: nm_add_l3out_dhcp_relay_label_idempotency + + - name: Create a second L3Out logical interface profile + cisco.aci.aci_l3out_logical_interface_profile: &aci_l3out_interface_profile_present_2 + <<: *aci_l3out_node_profile_present + interface_profile: ansible_l3out_interface_profile_2 + description: Second Ansible L3Out Logical Interface Profile + + - name: Add L3Out DHCP Relay Label to second interface profile (normal_mode) + cisco.aci.aci_l3out_dhcp_relay_label: + <<: *aci_l3out_interface_profile_present_2 + dhcp_relay_label: ansible_dhcp_relay_policy_infra + description: Second Ansible DHCP Relay Label + state: present + register: nm_add_l3out_dhcp_relay_label_2 + + - name: Asserts for DHCP relay labels creation tasks + ansible.builtin.assert: + that: + - cm_add_l3out_dhcp_relay_label is changed + - cm_add_l3out_dhcp_relay_label.previous == [] + - cm_add_l3out_dhcp_relay_label.current == [] + - nm_add_l3out_dhcp_relay_label is changed + - nm_add_l3out_dhcp_relay_label.current.0.dhcpLbl.attributes.name == "ansible_dhcp_relay_policy_tenant" + - nm_add_l3out_dhcp_relay_label.current.0.dhcpLbl.attributes.owner == "tenant" + - nm_add_l3out_dhcp_relay_label.current.0.dhcpLbl.children.0.dhcpRsDhcpOptionPol.attributes.tnDhcpOptionPolName == "ansible_dhcp_option_policy" + - nm_add_l3out_dhcp_relay_label_idempotency is not changed + - nm_add_l3out_dhcp_relay_label_2 is changed + - nm_add_l3out_dhcp_relay_label_2.previous == [] + - nm_add_l3out_dhcp_relay_label_2.current.0.dhcpLbl.attributes.name == "ansible_dhcp_relay_policy_infra" + - nm_add_l3out_dhcp_relay_label_2.current.0.dhcpLbl.attributes.owner == "infra" + + - name: Query all l3Out DHCP relay labels + cisco.aci.aci_l3out_dhcp_relay_label: + <<: *aci_info + state: query + register: query_all_l3out_dhcp_relay_label + + - name: Query first L3Out DHCP relay label + cisco.aci.aci_l3out_dhcp_relay_label: + <<: *aci_l3out_dhcp_relay_label_present + state: query + register: query_ansible_l3out_dhcp_relay_label_1 + + - name: Asserts query tasks + ansible.builtin.assert: + that: + - query_all_l3out_dhcp_relay_label is not changed + - query_all_l3out_dhcp_relay_label.current|length >= 2 + - query_ansible_l3out_dhcp_relay_label_1 is not changed + - query_ansible_l3out_dhcp_relay_label_1.current.0.dhcpLbl.attributes.name == "ansible_dhcp_relay_policy_tenant" + - query_ansible_l3out_dhcp_relay_label_1.current.0.dhcpLbl.attributes.owner == "tenant" + - query_ansible_l3out_dhcp_relay_label_1.current.0.dhcpLbl.children.0.dhcpRsDhcpOptionPol.attributes.tnDhcpOptionPolName == "ansible_dhcp_option_policy" + + - name: Update first L3out DHCP relay label by deleting current DHCP options (check_mode) + cisco.aci.aci_l3out_dhcp_relay_label: &aci_l3out_dhcp_relay_label_update + <<: *aci_l3out_dhcp_relay_label_present + dhcp_option_policy: "" + check_mode: true + register: cm_update_l3out_dhcp_relay_label + + - name: Update first L3out DHCP relay label by deleting current DHCP options (normal_mode) + cisco.aci.aci_l3out_dhcp_relay_label: + <<: *aci_l3out_dhcp_relay_label_update + register: nm_update_l3out_dhcp_relay_label + + - name: Update first L3out DHCP relay label by deleting current DHCP options again - testing idempotency + cisco.aci.aci_l3out_dhcp_relay_label: + <<: *aci_l3out_dhcp_relay_label_update + register: nm_update_l3out_dhcp_relay_label_idempotency + + - name: Query updated first L3Out DHCP relay label + cisco.aci.aci_l3out_dhcp_relay_label: + <<: *aci_l3out_dhcp_relay_label_update + state: query + register: query_ansible_l3out_dhcp_relay_label_1_updated + + - name: Asserts for DHCP relay labels update tasks + ansible.builtin.assert: + that: + - cm_update_l3out_dhcp_relay_label is changed + - cm_update_l3out_dhcp_relay_label.previous == cm_update_l3out_dhcp_relay_label.current + - nm_update_l3out_dhcp_relay_label is changed + - nm_update_l3out_dhcp_relay_label.current.0.dhcpLbl.children.0.dhcpRsDhcpOptionPol.attributes.tnDhcpOptionPolName == "" + - nm_update_l3out_dhcp_relay_label_idempotency is not changed + - query_ansible_l3out_dhcp_relay_label_1_updated is not changed + - query_ansible_l3out_dhcp_relay_label_1_updated.current.0.dhcpLbl.children.0.dhcpRsDhcpOptionPol.attributes.tDn == "uni/tn-common/dhcpoptpol-default" + - query_ansible_l3out_dhcp_relay_label_1_updated.current.0.dhcpLbl.children.0.dhcpRsDhcpOptionPol.attributes.tnDhcpOptionPolName == "" + + - name: Remove L3Out DHCP relay label from interface profile (check_mode) + cisco.aci.aci_l3out_dhcp_relay_label: &l3out_dhcp_relay_label_absent + <<: *aci_l3out_dhcp_relay_label_update + state: absent + check_mode: true + register: cm_remove_l3out_dhcp_relay_label + + - name: Remove L3Out DHCP relay label from interface profile (normal_mode) + cisco.aci.aci_l3out_dhcp_relay_label: + <<: *l3out_dhcp_relay_label_absent + register: nm_remove_l3out_dhcp_relay_label + + - name: Remove L3Out DHCP relay label from interface profile - testing idempotency + cisco.aci.aci_l3out_dhcp_relay_label: + <<: *l3out_dhcp_relay_label_absent + register: nm_remove_l3out_dhcp_relay_label_idempotency + + - name: Asserts deletion tasks + ansible.builtin.assert: + that: + - cm_remove_l3out_dhcp_relay_label is changed + - cm_remove_l3out_dhcp_relay_label.proposed == {} + - nm_remove_l3out_dhcp_relay_label is changed + - nm_remove_l3out_dhcp_relay_label.previous != [] + - nm_remove_l3out_dhcp_relay_label.method == "DELETE" + - nm_remove_l3out_dhcp_relay_label_idempotency is not changed + - nm_remove_l3out_dhcp_relay_label_idempotency.previous == [] + + - name: Remove the ansible_tenant - cleanup before ending tests + cisco.aci.aci_tenant: + <<: *aci_tenant_present + state: absent + + - name: Remove the ansible_dom - cleanup before ending tests + cisco.aci.aci_domain: + <<: *aci_domain_present + state: absent diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_l3out_eigrp_interface_profile/aliases b/ansible_collections/cisco/aci/tests/integration/targets/aci_l3out_eigrp_interface_profile/aliases new file mode 100644 index 000000000..209b793f9 --- /dev/null +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_l3out_eigrp_interface_profile/aliases @@ -0,0 +1,2 @@ +# No ACI simulator yet, so not enabled +# unsupported diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_l3out_eigrp_interface_profile/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_l3out_eigrp_interface_profile/tasks/main.yml new file mode 100644 index 000000000..8607897b1 --- /dev/null +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_l3out_eigrp_interface_profile/tasks/main.yml @@ -0,0 +1,224 @@ +# Test code for the ACI modules +# Copyright: (c) 2023, Gaspard Micol (@gmicol) <gmicol@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 APIC host, ACI username and ACI password + ansible.builtin.fail: + msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' + when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined + +- name: Set vars + ansible.builtin.set_fact: + aci_info: &aci_info + host: "{{ aci_hostname }}" + username: "{{ aci_username }}" + password: "{{ aci_password }}" + validate_certs: '{{ aci_validate_certs | default(false) }}' + use_ssl: '{{ aci_use_ssl | default(true) }}' + use_proxy: '{{ aci_use_proxy | default(true) }}' + output_level: debug + +# CLEAN ENVIRONMENT +- name: Remove the ansible_tenant + cisco.aci.aci_tenant: &aci_tenant_absent + <<: *aci_info + tenant: ansible_tenant + state: absent + +- name: Verify Cloud and Non-Cloud Sites in use. + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + +- name: Execute tasks only for non-cloud sites + when: query_cloud.current == [] # This condition will execute only non-cloud sites + block: # block specifies execution of tasks within, based on conditions + - name: Add a new tenant + cisco.aci.aci_tenant: &aci_tenant_present + <<: *aci_info + tenant: ansible_tenant + description: Ansible tenant + state: present + + - name: Add new Domain + cisco.aci.aci_domain: &aci_domain_present + <<: *aci_info + domain: ansible_dom + domain_type: l3dom + state: present + + - name: Addd a new VRF + cisco.aci.aci_vrf: &aci_vrf_present + <<: *aci_tenant_present + vrf: ansible_vrf + description: Ansible VRF + + - name: Add a new L3Out + cisco.aci.aci_l3out: &aci_l3out_present + <<: *aci_vrf_present + l3out: ansible_l3out + domain: ansible_dom + route_control: export + l3protocol: eigrp + asn: 1 + description: Ansible L3Out + + - name: Add a new L3Out logical node profile + cisco.aci.aci_l3out_logical_node_profile: &aci_l3out_node_profile_present + <<: *aci_tenant_present + l3out: ansible_l3out + node_profile: ansible_l3out_node_profile + description: Ansible L3Out Logical Node Profile + + - name: Add a new L3Out logical interface profile + cisco.aci.aci_l3out_logical_interface_profile: &aci_l3out_interface_profile_present + <<: *aci_l3out_node_profile_present + interface_profile: ansible_l3out_interface_profile + description: First Ansible L3Out Logical Interface Profile + + - name: Add a new eigrp interface policy + cisco.aci.aci_interface_policy_eigrp: + <<: *aci_tenant_present + eigrp: ansible_eigrp_interface_policy + description: Ansible EIGRP Interface Policy + state: present + + - name: Add a new keychain policy + cisco.aci.aci_keychain_policy: + <<: *aci_tenant_present + keychain_policy: ansible_keychain_policy + description: Ansible Keychain Policy + state: present + + - name: Add eigrp policy to first interface profile (check mode) + cisco.aci.aci_l3out_eigrp_interface_profile: &aci_l3out_eigrp_interface_profile_present + <<: *aci_l3out_interface_profile_present + eigrp_policy: ansible_eigrp_interface_policy + eigrp_keychain_policy: ansible_keychain_policy + description: First Ansible EIGRP Interface Profile + check_mode: true + register: cm_add_l3out_eigrp_interface_profile + + - name: Add eigrp policy to first interface profile (normal mode) + cisco.aci.aci_l3out_eigrp_interface_profile: + <<: *aci_l3out_eigrp_interface_profile_present + register: nm_add_l3out_eigrp_interface_profile + + - name: Add eigrp interface profile again - testing idempotency + cisco.aci.aci_l3out_eigrp_interface_profile: + <<: *aci_l3out_eigrp_interface_profile_present + register: nm_add_l3out_eigrp_interface_profile_idempotency + + - name: Create a second L3Out logical interface profile + cisco.aci.aci_l3out_logical_interface_profile: &aci_l3out_interface_profile_present_2 + <<: *aci_l3out_node_profile_present + interface_profile: ansible_l3out_interface_profile_2 + description: Second Ansible L3Out Logical Interface Profile + + - name: Add eigrp policy to second interface profile (normal_mode) + cisco.aci.aci_l3out_eigrp_interface_profile: + <<: *aci_l3out_interface_profile_present_2 + eigrp_policy: ansible_eigrp_interface_policy + description: Second Ansible EIGRP Interface Profile + state: present + register: nm_add_l3out_eigrp_interface_profile_2 + + - name: Asserts for eigrp interface policies creation tasks + ansible.builtin.assert: + that: + - cm_add_l3out_eigrp_interface_profile is changed + - cm_add_l3out_eigrp_interface_profile.previous == [] + - cm_add_l3out_eigrp_interface_profile.current == [] + - nm_add_l3out_eigrp_interface_profile is changed + - nm_add_l3out_eigrp_interface_profile.current.0.eigrpIfP.children.0.eigrpAuthIfP.children.0.eigrpRsKeyChainPol.attributes.tnFvKeyChainPolName == "ansible_keychain_policy" + - nm_add_l3out_eigrp_interface_profile.current.0.eigrpIfP.children.1.eigrpRsIfPol.attributes.tnEigrpIfPolName == "ansible_eigrp_interface_policy" + - nm_add_l3out_eigrp_interface_profile_idempotency is not changed + - nm_add_l3out_eigrp_interface_profile_2 is changed + - nm_add_l3out_eigrp_interface_profile_2.previous == [] + - nm_add_l3out_eigrp_interface_profile_2.current.0.eigrpIfP.children.0.eigrpRsIfPol.attributes.tnEigrpIfPolName == "ansible_eigrp_interface_policy" + + - name: Query all eigrp interface profiles + cisco.aci.aci_l3out_eigrp_interface_profile: + <<: *aci_info + state: query + register: query_all_l3out_eigrp_interface_profile + + - name: Query first eigrp interface profile + cisco.aci.aci_l3out_eigrp_interface_profile: + <<: *aci_l3out_eigrp_interface_profile_present + state: query + register: query_ansible_l3out_eigrp_interface_profile_1 + + - name: Asserts query tasks + ansible.builtin.assert: + that: + - query_all_l3out_eigrp_interface_profile is not changed + - query_all_l3out_eigrp_interface_profile.current|length >= 2 + - query_ansible_l3out_eigrp_interface_profile_1 is not changed + - query_ansible_l3out_eigrp_interface_profile_1.current.0.eigrpIfP.children.0.eigrpAuthIfP.children.0.eigrpRsKeyChainPol.attributes.tDn == "uni/tn-ansible_tenant/keychainp-ansible_keychain_policy" + - query_ansible_l3out_eigrp_interface_profile_1.current.0.eigrpIfP.children.0.eigrpAuthIfP.children.0.eigrpRsKeyChainPol.attributes.state == "formed" + - query_ansible_l3out_eigrp_interface_profile_1.current.0.eigrpIfP.children.1.eigrpRsIfPol.attributes.tDn == "uni/tn-ansible_tenant/eigrpIfPol-ansible_eigrp_interface_policy" + - query_ansible_l3out_eigrp_interface_profile_1.current.0.eigrpIfP.children.1.eigrpRsIfPol.attributes.state == "formed" + + - name: Remove authentification from first eigrp interface profile (check mode) + cisco.aci.aci_l3out_eigrp_interface_profile: &aci_l3out_eigrp_interface_profile_remove_auth + <<: *aci_l3out_eigrp_interface_profile_present + eigrp_keychain_policy: "" + check_mode: true + register: cm_remove_auth_l3out_eigrp_interface_profile + + - name: Remove authentification from first eigrp interface profile (normal mode) + cisco.aci.aci_l3out_eigrp_interface_profile: + <<: *aci_l3out_eigrp_interface_profile_remove_auth + register: nm_remove_auth_l3out_eigrp_interface_profile + + - name: Remove authentification from first eigrp interface profile again - testing idempotency + cisco.aci.aci_l3out_eigrp_interface_profile: + <<: *aci_l3out_eigrp_interface_profile_remove_auth + register: nm_remove_auth_eigrp_interface_profile_idempotency + + - name: Asserts authentification removal tasks + ansible.builtin.assert: + that: + - cm_remove_auth_l3out_eigrp_interface_profile is changed + - cm_remove_auth_l3out_eigrp_interface_profile.current == cm_remove_auth_l3out_eigrp_interface_profile.previous + - nm_remove_auth_l3out_eigrp_interface_profile is changed + - nm_remove_auth_l3out_eigrp_interface_profile.current.0.eigrpIfP.children|length == 1 + - nm_remove_auth_eigrp_interface_profile_idempotency is not changed + + - name: Remove eigrp interface profile (check_mode) + cisco.aci.aci_l3out_eigrp_interface_profile: &l3out_eigrp_interface_profile_absent + <<: *aci_l3out_eigrp_interface_profile_present + state: absent + check_mode: true + register: cm_remove_l3out_eigrp_interface_profile + + - name: Remove eigrp interface profile (normal_mode) + cisco.aci.aci_l3out_eigrp_interface_profile: + <<: *l3out_eigrp_interface_profile_absent + register: nm_remove_l3out_eigrp_interface_profile + + - name: Remove eigrp interface profile - testing idempotency + cisco.aci.aci_l3out_eigrp_interface_profile: + <<: *l3out_eigrp_interface_profile_absent + register: nm_remove_l3out_eigrp_interface_profile_idempotency + + - name: Asserts deletion tasks + ansible.builtin.assert: + that: + - cm_remove_l3out_eigrp_interface_profile is changed + - cm_remove_l3out_eigrp_interface_profile.proposed == {} + - nm_remove_l3out_eigrp_interface_profile is changed + - nm_remove_l3out_eigrp_interface_profile.previous != [] + - nm_remove_l3out_eigrp_interface_profile.method == "DELETE" + - nm_remove_l3out_eigrp_interface_profile_idempotency is not changed + - nm_remove_l3out_eigrp_interface_profile_idempotency.previous == [] + + - name: Remove the ansible_tenant - cleanup before ending tests + cisco.aci.aci_tenant: + <<: *aci_tenant_present + state: absent + + - name: Remove the ansible_dom - cleanup before ending tests + cisco.aci.aci_domain: + <<: *aci_domain_present + state: absent diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_l3out_extepg/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_l3out_extepg/tasks/main.yml index d52fb5ef4..61291cb6a 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_l3out_extepg/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_l3out_extepg/tasks/main.yml @@ -29,7 +29,7 @@ block: - name: Query system information - aci_system: + cisco.aci.aci_system: <<: *aci_info id: 1 state: query diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_l3out_extepg_to_contract/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_l3out_extepg_to_contract/tasks/main.yml index c49475d0a..d8437c522 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_l3out_extepg_to_contract/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_l3out_extepg_to_contract/tasks/main.yml @@ -1,15 +1,16 @@ # Test code for the ACI modules # Copyright: (c) 2020, Shreyas Srish (@shrsr) +# Copyright: (c) 2023, Akini Ross (@akinross) # 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 APIC host, ACI username and ACI password - fail: +- name: Test that we have an ACI APIC host, ACI username and ACI password + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: "{{ aci_hostname }}" username: "{{ aci_username }}" @@ -21,28 +22,35 @@ # CLEAN ENVIRONMENT - name: Remove the ansible_tenant - aci_tenant: - <<: *aci_info - tenant: ansible_tenant + cisco.aci.aci_tenant: + <<: *aci_info + tenant: ansible_test state: absent +- name: Query system information + cisco.aci.aci_system: + <<: *aci_info + id: 1 + state: query + register: version + - name: Verify Cloud and Non-Cloud Sites in use. - include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml - name: Execute tasks only for non-cloud sites when: query_cloud.current == [] # This condition will execute only non-cloud sites block: # block specifies execution of tasks within, based on conditions - name: Add a new tenant - aci_tenant: + cisco.aci.aci_tenant: <<: *aci_info - tenant: ansible_tenant + tenant: ansible_test description: Ansible tenant state: present - name: Add a new l3out - aci_l3out: + cisco.aci.aci_l3out: <<: *aci_info - tenant: ansible_tenant + tenant: ansible_test name: ansible_l3out description: l3out for Ansible tenant domain: ansible_dom @@ -52,91 +60,202 @@ state: present - name: Add a new ExtEpg - aci_l3out_extepg: + cisco.aci.aci_l3out_extepg: <<: *aci_info - tenant: ansible_tenant + tenant: ansible_test l3out: ansible_l3out name: ansible_extEpg description: ExtEpg for Ansible l3out state: present - - - name: Bind External End Point Groups to Contracts - aci_l3out_extepg_to_contract: + + - name: Bind External End Point Groups to Contracts (check-mode) + cisco.aci.aci_l3out_extepg_to_contract: &aci_ext_epg_present <<: *aci_info - tenant: ansible_tenant + tenant: ansible_test l3out: ansible_l3out extepg: ansible_extEpg contract: ansible_contract contract_type: provider state: present - register: bind_extepg_provider_contract + register: cm_bind_extepg_provider_contract + check_mode: true + + - name: Bind External End Point Groups to Contracts + aci_l3out_extepg_to_contract: + <<: *aci_ext_epg_present + register: nm_bind_extepg_provider_contract + + - name: Bind External End Point Groups to Contracts again + aci_l3out_extepg_to_contract: + <<: *aci_ext_epg_present + register: nm_bind_extepg_provider_contract_again - name: Verify bind_extepg_provider_contract - assert: + ansible.builtin.assert: that: - - bind_extepg_provider_contract.current.0.fvRsProv.attributes.dn == "uni/tn-ansible_tenant/out-ansible_l3out/instP-ansible_extEpg/rsprov-ansible_contract" - - bind_extepg_provider_contract.current.0.fvRsProv.attributes.annotation == 'orchestrator:ansible' + - cm_bind_extepg_provider_contract is changed + - cm_bind_extepg_provider_contract.previous == [] + - cm_bind_extepg_provider_contract.proposed.fvRsProv.attributes.dn == "uni/tn-ansible_test/out-ansible_l3out/instP-ansible_extEpg/rsprov-ansible_contract" + - cm_bind_extepg_provider_contract.proposed.fvRsProv.attributes.annotation == "orchestrator:ansible" + - cm_bind_extepg_provider_contract.proposed.fvRsProv.attributes.tnVzBrCPName == "ansible_contract" + - nm_bind_extepg_provider_contract is changed + - nm_bind_extepg_provider_contract.previous == [] + - nm_bind_extepg_provider_contract.current.0.fvRsProv.attributes.dn == "uni/tn-ansible_test/out-ansible_l3out/instP-ansible_extEpg/rsprov-ansible_contract" + - nm_bind_extepg_provider_contract.current.0.fvRsProv.attributes.annotation == "orchestrator:ansible" + - nm_bind_extepg_provider_contract.current.0.fvRsProv.attributes.tnVzBrCPName == "ansible_contract" + - nm_bind_extepg_provider_contract_again is not changed + - nm_bind_extepg_provider_contract_again.previous.0.fvRsProv.attributes.dn == "uni/tn-ansible_test/out-ansible_l3out/instP-ansible_extEpg/rsprov-ansible_contract" + - nm_bind_extepg_provider_contract_again.previous.0.fvRsProv.attributes.annotation == "orchestrator:ansible" + - nm_bind_extepg_provider_contract_again.previous.0.fvRsProv.attributes.tnVzBrCPName == "ansible_contract" + - nm_bind_extepg_provider_contract_again.current.0.fvRsProv.attributes.dn == "uni/tn-ansible_test/out-ansible_l3out/instP-ansible_extEpg/rsprov-ansible_contract" + - nm_bind_extepg_provider_contract_again.current.0.fvRsProv.attributes.annotation == "orchestrator:ansible" + - nm_bind_extepg_provider_contract_again.current.0.fvRsProv.attributes.tnVzBrCPName == "ansible_contract" - - name: Bind second External End Point Groups to Contracts - aci_l3out_extepg_to_contract: + - name: Bind second External End Point Groups to Contracts with contract label and subject label + cisco.aci.aci_l3out_extepg_to_contract: <<: *aci_info - tenant: ansible_tenant + tenant: ansible_test l3out: ansible_l3out extepg: ansible_extEpg contract: ansible_contract2 contract_type: provider + contract_label: anstest_contract_label + subject_label: anstest_subject_label state: present register: bind_extepg_provider_contract_2 - name: Verify bind_extepg_provider_contract_2 - assert: + ansible.builtin.assert: that: - - bind_extepg_provider_contract_2.current.0.fvRsProv.attributes.dn == "uni/tn-ansible_tenant/out-ansible_l3out/instP-ansible_extEpg/rsprov-ansible_contract2" + - bind_extepg_provider_contract_2.current.0.fvRsProv.attributes.dn == "uni/tn-ansible_test/out-ansible_l3out/instP-ansible_extEpg/rsprov-ansible_contract2" + - bind_extepg_provider_contract_2.current.0.fvRsProv.attributes.tnVzBrCPName == "ansible_contract2" + - bind_extepg_provider_contract_2.current.0.fvRsProv.children.0.vzProvSubjLbl.attributes.name == "anstest_subject_label" + - bind_extepg_provider_contract_2.current.0.fvRsProv.children.1.vzProvLbl.attributes.name == "anstest_contract_label" + - bind_extepg_provider_contract_2.current.0.fvRsProv.children | length == 2 - - name: Query the External End Point Groups - aci_l3out_extepg_to_contract: - <<: *aci_info - tenant: ansible_tenant - l3out: ansible_l3out - extepg: ansible_extEpg + - name: Bind taboo contract to external epg + cisco.aci.aci_l3out_extepg_to_contract: + <<: *aci_ext_epg_present contract: ansible_contract - contract_type: provider - state: query - register: query_extepg + contract_type: taboo + register: taboo_present - - name: Verify query_extepg - assert: + - name: Bind interface contract to external epg + cisco.aci.aci_l3out_extepg_to_contract: + <<: *aci_ext_epg_present + contract: ansible_contract + contract_type: interface + register: interface_present + + - name: Bind intra epg contract to external epg + cisco.aci.aci_l3out_extepg_to_contract: &aci_ext_epg_intra_present + <<: *aci_ext_epg_present + contract: ansible_contract + contract_type: intra_epg + register: intra_epg_present + when: version.current.0.topSystem.attributes.version is version('5', '>=') # This condition will execute only for APIC version 5.x and above + + - name: Bind intra epg contract to external epg (error contract label) + cisco.aci.aci_l3out_extepg_to_contract: + <<: *aci_ext_epg_intra_present + contract_label: anstest_contract_label + ignore_errors: true + register: err_contract_label + + - name: Bind intra epg contract to external epg (error subject label) + cisco.aci.aci_l3out_extepg_to_contract: + <<: *aci_ext_epg_intra_present + subject_label: anstest_subject_label + ignore_errors: true + register: err_subject_label + + - name: Bind intra epg contract to external epg (error subject and contract label) + cisco.aci.aci_l3out_extepg_to_contract: + <<: *aci_ext_epg_intra_present + contract_label: anstest_contract_label + subject_label: anstest_subject_label + ignore_errors: true + register: err_subject_and_contract_label + + - name: Verify present assertions for taboo, interface and intra_epg contract types + ansible.builtin.assert: that: - - query_extepg is not changed - - query_extepg.current.0.fvRsProv.attributes.dn == "uni/tn-ansible_tenant/out-ansible_l3out/instP-ansible_extEpg/rsprov-ansible_contract" + - taboo_present is changed + - taboo_present.previous == [] + - taboo_present.current.0.fvRsProtBy.attributes.tnVzTabooName == 'ansible_contract' + - interface_present is changed + - interface_present.previous == [] + - interface_present.current.0.fvRsConsIf.attributes.tnVzCPIfName == 'ansible_contract' + - err_contract_label is failed + - err_contract_label.msg == "the 'contract_label' and 'subject_label' are not configurable for intra_epg contracts" + - err_subject_label is failed + - err_subject_label.msg == "the 'contract_label' and 'subject_label' are not configurable for intra_epg contracts" + - err_subject_and_contract_label is failed + - err_subject_and_contract_label.msg == "the 'contract_label' and 'subject_label' are not configurable for intra_epg contracts" + + - name: Verify present assertions for taboo, interface and intra_epg contract types + ansible.builtin.assert: + that: + - intra_epg_present is changed + - intra_epg_present.previous == [] + - intra_epg_present.current.0.fvRsIntraEpg.attributes.tnVzBrCPName == 'ansible_contract' + when: version.current.0.topSystem.attributes.version is version('5', '>=') # This condition will execute only for APIC version 5.x and above + + - name: Query the External End Point Groups + cisco.aci.aci_l3out_extepg_to_contract: + <<: *aci_ext_epg_present + state: query + register: query_extepg - name: Query all the External End Point Groups - aci_l3out_extepg_to_contract: + cisco.aci.aci_l3out_extepg_to_contract: <<: *aci_info contract_type: provider state: query register: query_all - - name: Remove existing contract to External End Point Groups - aci_l3out_extepg_to_contract: - <<: *aci_info - tenant: ansible_tenant - l3out: ansible_l3out - extepg: ansible_extEpg - contract: ansible_contract - contract_type: provider + - name: Verify query_extepg + ansible.builtin.assert: + that: + - query_extepg is not changed + - query_extepg.current | length == 1 + - query_extepg.current.0.fvRsProv.attributes.dn == "uni/tn-ansible_test/out-ansible_l3out/instP-ansible_extEpg/rsprov-ansible_contract" + - query_all is not changed + - query_all.current | length >= 1 + + - name: Remove existing contract to External End Point Groups (check-mode) + aci_l3out_extepg_to_contract: &aci_ext_epg_absent + <<: *aci_ext_epg_present state: absent - register: remove_contract_extepg + register: cm_remove_contract_extepg + check_mode: true + + - name: Remove existing contract to External End Point Groups + cisco.aci.aci_l3out_extepg_to_contract: + <<: *aci_ext_epg_absent + register: nm_remove_contract_extepg + + - name: Remove existing contract to External End Point Groups again + cisco.aci.aci_l3out_extepg_to_contract: + <<: *aci_ext_epg_absent + register: nm_remove_contract_extepg_again - name: Verify remove_contract_extepg - assert: + ansible.builtin.assert: that: - - remove_contract_extepg.previous.0.fvRsProv.attributes.dn == "uni/tn-ansible_tenant/out-ansible_l3out/instP-ansible_extEpg/rsprov-ansible_contract" + - cm_remove_contract_extepg is changed + - cm_remove_contract_extepg.previous.0.fvRsProv.attributes.dn == "uni/tn-ansible_test/out-ansible_l3out/instP-ansible_extEpg/rsprov-ansible_contract" + - nm_remove_contract_extepg is changed + - nm_remove_contract_extepg.previous.0.fvRsProv.attributes.dn == "uni/tn-ansible_test/out-ansible_l3out/instP-ansible_extEpg/rsprov-ansible_contract" + - nm_remove_contract_extepg.current == [] + - nm_remove_contract_extepg_again is not changed + - nm_remove_contract_extepg_again.previous == [] + - nm_remove_contract_extepg_again.current == [] - name: Bind External End Point Groups to Contracts - aci_l3out_extepg_to_contract: + cisco.aci.aci_l3out_extepg_to_contract: <<: *aci_info - tenant: ansible_tenant + tenant: ansible_test l3out: ansible_l3out extepg: ansible_extEpg contract: ansible_contract @@ -147,6 +266,13 @@ register: bind_extepg_consumer_contract - name: Verify bind_extepg_consumer_contract - assert: + ansible.builtin.assert: that: - - bind_extepg_consumer_contract.msg == "the 'provider_match' is only configurable for Provided Contracts"
\ No newline at end of file + - bind_extepg_consumer_contract.msg == "the 'provider_match' is only configurable for Provided Contracts" + + # CLEAN ENVIRONMENT + - name: Remove the ansible_tenant + cisco.aci.aci_tenant: + <<: *aci_info + tenant: ansible_test + state: absent diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_l3out_extsubnet/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_l3out_extsubnet/tasks/main.yml index 4be8a65f7..be15031db 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_l3out_extsubnet/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_l3out_extsubnet/tasks/main.yml @@ -4,12 +4,12 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: "{{ aci_hostname }}" username: "{{ aci_username }}" @@ -21,26 +21,26 @@ # CLEAN ENVIRONMENT - name: Remove the ansible_tenant - aci_tenant: + cisco.aci.aci_tenant: <<: *aci_info tenant: ansible_tenant state: absent - name: Verify Cloud and Non-Cloud Sites in use. - include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml - name: Execute tasks only for non-cloud sites when: query_cloud.current == [] # This condition will execute only non-cloud sites block: # block specifies execution of tasks within, based on conditions - name: Add a new tenant - aci_tenant: + cisco.aci.aci_tenant: <<: *aci_info tenant: ansible_tenant description: Ansible tenant state: present - name: Add a new l3out - aci_l3out: + cisco.aci.aci_l3out: <<: *aci_info tenant: ansible_tenant name: ansible_l3out @@ -52,7 +52,7 @@ state: present - name: Add a new ExtEpg - aci_l3out_extepg: + cisco.aci.aci_l3out_extepg: <<: *aci_info tenant: ansible_tenant l3out: ansible_l3out @@ -84,7 +84,7 @@ register: nm_add_subnet - name: Verify cm_add_subnet and nm_add_subnet - assert: + ansible.builtin.assert: that: - cm_add_subnet is changed - nm_add_subnet is changed @@ -107,7 +107,7 @@ register: nm_add_subnet_again - name: Verify nm_add_subnet_again - assert: + ansible.builtin.assert: that: - nm_add_subnet_again is not changed @@ -139,7 +139,7 @@ register: nm_change_subnet - name: Verify cm_change_subnet and nm_change_subnet - assert: + ansible.builtin.assert: that: - cm_change_subnet is changed - nm_change_subnet is changed @@ -164,7 +164,7 @@ register: nm_add_another_subnet - name: Verify nm_add_another_subnet - assert: + ansible.builtin.assert: that: - nm_add_another_subnet is changed - nm_add_another_subnet.current.0.l3extSubnet.attributes.ip == "192.1.2.0/24" @@ -189,7 +189,7 @@ register: query_subnet - name: Verify query_all and query_subnet - assert: + ansible.builtin.assert: that: - query_all is not changed - query_subnet is not changed @@ -208,7 +208,7 @@ register: rm_subnet - name: Verify rm_subnet - assert: + ansible.builtin.assert: that: - rm_subnet is changed - rm_subnet.current == [] @@ -230,7 +230,7 @@ ignore_errors: true - name: asserts failed aggregate creation tasks - assert: + ansible.builtin.assert: that: - nm_aggregate_scope_none is failed - nm_aggregate_scope_none.msg.startswith("missing parameter(s) required by 'aggregate'") @@ -251,7 +251,7 @@ ignore_errors: true - name: asserts failed aggregate creation tasks - assert: + ansible.builtin.assert: that: - nm_aggregate_scope_mismatch is failed - nm_aggregate_scope_mismatch.msg == "All aggregate values ['export-rtctrl', 'import-rtctrl'] need to be defined in scope ['import-security']." @@ -286,7 +286,7 @@ register: nm_aggregate_scope_match - name: asserts success aggregate creation task - assert: + ansible.builtin.assert: that: - cm_aggregate_scope_match is changed - cm_aggregate_scope_match.proposed.l3extSubnet.attributes.ip == "0.0.0.0/0" @@ -313,6 +313,6 @@ register: nm_aggregate_scope_match - name: asserts success aggregate creation task reversed input order - assert: + ansible.builtin.assert: that: - nm_aggregate_scope_match is not changed
\ No newline at end of file diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_l3out_floating_svi/aliases b/ansible_collections/cisco/aci/tests/integration/targets/aci_l3out_floating_svi/aliases new file mode 100644 index 000000000..209b793f9 --- /dev/null +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_l3out_floating_svi/aliases @@ -0,0 +1,2 @@ +# No ACI simulator yet, so not enabled +# unsupported diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_l3out_floating_svi/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_l3out_floating_svi/tasks/main.yml new file mode 100644 index 000000000..5bc0cf78b --- /dev/null +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_l3out_floating_svi/tasks/main.yml @@ -0,0 +1,220 @@ +# Author: Shreyas Srish (@shrsr) +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +# SET VARS +- name: Set vars + ansible.builtin.set_fact: + aci_info: &aci_info + host: '{{ aci_hostname }}' + username: '{{ aci_username }}' + password: '{{ aci_password }}' + validate_certs: '{{ aci_validate_certs | default(false) }}' + use_ssl: '{{ aci_use_ssl | default(true) }}' + use_proxy: '{{ aci_use_proxy | default(true) }}' + output_level: '{{ aci_output_level | default("info") }}' + +# CLEAN ENVIRONMENT +- name: Remove test tenant before we kickoff + cisco.aci.aci_tenant: &tenant_absent + <<: *aci_info + tenant: ansible_test + state: absent + +- name: Verify Cloud and Non-Cloud Sites in use. + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + +- name: Execute tasks only for non-cloud sites + when: query_cloud.current == [] # This condition will execute only non-cloud sites + block: # block specifies execution of tasks within, based on conditions + # SETUP ENVIRONMENT + - name: Create domain + cisco.aci.aci_domain: &domain_present + <<: *aci_info + domain: l3outintftest + domain_type: l3dom + state: present + + - name: Create tenant + cisco.aci.aci_tenant: &tenant_present + <<: *tenant_absent + state: present + + - name: Configure VRF + cisco.aci.aci_vrf: &vrf_present + <<: *tenant_present + vrf: l3outintftest + + - name: Create L3Out + cisco.aci.aci_l3out: + <<: *vrf_present + l3out: l3outintftest + domain: l3outintftest + route_control: export + + - name: Create node profile + cisco.aci.aci_l3out_logical_node_profile: &np_present + <<: *tenant_present + l3out: l3outintftest + node_profile: nodes + + - name: Add interface profile + cisco.aci.aci_l3out_logical_interface_profile: &intf_present + <<: *np_present + interface_profile: Floating + + - name: Create a floating svi in check mode + cisco.aci.aci_l3out_floating_svi: &floating_svi + <<: *intf_present + pod_id: 1 + node_id: 201 + encap: vlan-1 + address: 23.45.67.90/24 + external_bridge_group_profile: bridge1 + state: present + check_mode: true + register: add_floating_cm + when: version.current.0.topSystem.attributes.version is version('5', '>=') + + - name: Create a floating svi in normal mode + cisco.aci.aci_l3out_floating_svi: + <<: *floating_svi + state: present + register: add_floating_nm + when: version.current.0.topSystem.attributes.version is version('5', '>=') + + - name: Create a floating svi again + cisco.aci.aci_l3out_floating_svi: + <<: *floating_svi + state: present + register: add_floating_again + when: version.current.0.topSystem.attributes.version is version('5', '>=') + + - name: Update floating svi + cisco.aci.aci_l3out_floating_svi: + <<: *floating_svi + external_bridge_group_profile: bridge2 + state: present + register: update_floating + when: version.current.0.topSystem.attributes.version is version('5', '>=') + + - name: Delete an external_bridge_group_profile + cisco.aci.aci_l3out_floating_svi: + <<: *floating_svi + external_bridge_group_profile: "" + state: present + register: remove_bridge + when: version.current.0.topSystem.attributes.version is version('5', '>=') + + - name: Create another floating svi + cisco.aci.aci_l3out_floating_svi: + <<: *intf_present + pod_id: 1 + node_id: 202 + encap: vlan-1 + address: 24.45.67.90/24 + external_bridge_group_profile: "" + state: present + register: add_floating2 + when: version.current.0.topSystem.attributes.version is version('5', '>=') + + - name: Create another floating svi with no external_bridge_group_profile + cisco.aci.aci_l3out_floating_svi: + <<: *intf_present + pod_id: 1 + node_id: 203 + encap: vlan-1 + address: 25.45.67.90/24 + state: present + register: add_floating3 + + - name: Change floating svi with an attempt to delete external_bridge_group_profile + cisco.aci.aci_l3out_floating_svi: + <<: *intf_present + pod_id: 1 + node_id: 203 + encap: vlan-1 + address: 25.45.67.90/24 + external_bridge_group_profile: "" + state: present + register: change_floating3 + when: version.current.0.topSystem.attributes.version is version('5', '>=') + + - name: Verify present ops + ansible.builtin.assert: + that: + - add_floating_cm is changed + - add_floating_nm is changed + - add_floating_again is not changed + - update_floating is changed + - remove_bridge is changed + - add_floating2 is changed + - add_floating3 is changed + - change_floating3 is not changed + - add_floating_cm.proposed.l3extVirtualLIfP.attributes.addr == "23.45.67.90/24" + - add_floating_cm.proposed.l3extVirtualLIfP.attributes.dn == "uni/tn-ansible_test/out-l3outintftest/lnodep-nodes/lifp-Floating/vlifp-[topology/pod-1/node-201]-[vlan-1]" + - add_floating_cm.proposed.l3extVirtualLIfP.attributes.encap == "vlan-1" + - add_floating_cm.proposed.l3extVirtualLIfP.children.0.l3extBdProfileCont.children.0.l3extRsBdProfile.attributes.tDn == "uni/tn-ansible_test/bdprofile-bridge1" + - add_floating_nm.current.0.l3extVirtualLIfP.attributes.addr == "23.45.67.90/24" + - add_floating_nm.current.0.l3extVirtualLIfP.attributes.dn == "uni/tn-ansible_test/out-l3outintftest/lnodep-nodes/lifp-Floating/vlifp-[topology/pod-1/node-201]-[vlan-1]" + - add_floating_nm.current.0.l3extVirtualLIfP.attributes.encap == "vlan-1" + - add_floating_nm.current.0.l3extVirtualLIfP.children.0.l3extBdProfileCont.children.0.l3extRsBdProfile.attributes.tDn == "uni/tn-ansible_test/bdprofile-bridge1" + - update_floating.current.0.l3extVirtualLIfP.children.0.l3extBdProfileCont.children.0.l3extRsBdProfile.attributes.tDn == "uni/tn-ansible_test/bdprofile-bridge2" + - remove_bridge.current.0.l3extVirtualLIfP.children is not defined + - add_floating2.current.0.l3extVirtualLIfP.attributes.addr == "24.45.67.90/24" + - add_floating2.current.0.l3extVirtualLIfP.attributes.dn == "uni/tn-ansible_test/out-l3outintftest/lnodep-nodes/lifp-Floating/vlifp-[topology/pod-1/node-202]-[vlan-1]" + - add_floating2.current.0.l3extVirtualLIfP.attributes.encap == "vlan-1" + when: version.current.0.topSystem.attributes.version is version('5', '>=') + + - name: Verify present ops for all versions + ansible.builtin.assert: + that: + - add_floating3 is changed + - add_floating3.current.0.l3extVirtualLIfP.attributes.addr == "25.45.67.90/24" + - add_floating3.current.0.l3extVirtualLIfP.attributes.dn == "uni/tn-ansible_test/out-l3outintftest/lnodep-nodes/lifp-Floating/vlifp-[topology/pod-1/node-203]-[vlan-1]" + - add_floating3.current.0.l3extVirtualLIfP.attributes.encap == "vlan-1" + - add_floating3.current.0.l3extVirtualLIfP.children is not defined + + - name: Query a floating svi + cisco.aci.aci_l3out_floating_svi: + <<: *floating_svi + state: query + register: query_floating + when: version.current.0.topSystem.attributes.version is version('5', '>=') + + - name: Query all floating svis + cisco.aci.aci_l3out_floating_svi: + <<: *intf_present + state: query + register: query_all_floating + when: version.current.0.topSystem.attributes.version is version('5', '>=') + + - name: Verify Query ops + ansible.builtin.assert: + that: + - query_floating is not changed + - query_all_floating is not changed + - query_floating.current.0.l3extVirtualLIfP.attributes.addr == "23.45.67.90/24" + - query_floating.current.0.l3extVirtualLIfP.attributes.dn == "uni/tn-ansible_test/out-l3outintftest/lnodep-nodes/lifp-Floating/vlifp-[topology/pod-1/node-201]-[vlan-1]" + - query_floating.current.0.l3extVirtualLIfP.attributes.encap == "vlan-1" + - query_all_floating.current.0.l3extLIfP.children | length == 3 + when: version.current.0.topSystem.attributes.version is version('5', '>=') + + - name: Remove a floating svi + cisco.aci.aci_l3out_floating_svi: + <<: *floating_svi + state: absent + register: remove_floating + when: version.current.0.topSystem.attributes.version is version('5', '>=') + + - name: Verify remove ops + ansible.builtin.assert: + that: + - remove_floating is changed + - remove_floating.current == [] + when: version.current.0.topSystem.attributes.version is version('5', '>=') + + - name: Clean up environment + cisco.aci.aci_tenant: + <<: *aci_info + tenant: ansible_test + state: absent diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_l3out_floating_svi_path/aliases b/ansible_collections/cisco/aci/tests/integration/targets/aci_l3out_floating_svi_path/aliases new file mode 100644 index 000000000..209b793f9 --- /dev/null +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_l3out_floating_svi_path/aliases @@ -0,0 +1,2 @@ +# No ACI simulator yet, so not enabled +# unsupported diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_l3out_floating_svi_path/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_l3out_floating_svi_path/tasks/main.yml new file mode 100644 index 000000000..3ecc01a2e --- /dev/null +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_l3out_floating_svi_path/tasks/main.yml @@ -0,0 +1,365 @@ +# Author: Shreyas Srish (@shrsr) +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +# SET VARS +- name: Set vars + ansible.builtin.set_fact: + aci_info: &aci_info + host: '{{ aci_hostname }}' + username: '{{ aci_username }}' + password: '{{ aci_password }}' + validate_certs: '{{ aci_validate_certs | default(false) }}' + use_ssl: '{{ aci_use_ssl | default(true) }}' + use_proxy: '{{ aci_use_proxy | default(true) }}' + output_level: '{{ aci_output_level | default("info") }}' + +# CLEAN ENVIRONMENT +- name: Remove test tenant before we kickoff + cisco.aci.aci_tenant: &tenant_absent + <<: *aci_info + tenant: ansible_test + state: absent + +- name: Verify Cloud and Non-Cloud Sites in use. + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + +- name: Execute tasks only for non-cloud sites + when: query_cloud.current == [] # This condition will execute only non-cloud sites + block: # block specifies execution of tasks within, based on conditions + # SETUP ENVIRONMENT + - name: Create domain + cisco.aci.aci_domain: &domain_present + <<: *aci_info + domain: l3outintftest + domain_type: l3dom + state: present + + - name: Create tenant + cisco.aci.aci_tenant: &tenant_present + <<: *tenant_absent + state: present + + - name: Configure VRF + cisco.aci.aci_vrf: &vrf_present + <<: *tenant_present + vrf: l3outintftest + + - name: Create L3Out + cisco.aci.aci_l3out: + <<: *vrf_present + l3out: l3outintftest + domain: l3outintftest + route_control: export + + - name: Create node profile + cisco.aci.aci_l3out_logical_node_profile: &np_present + <<: *tenant_present + l3out: l3outintftest + node_profile: nodes + + - name: Add interface profile + cisco.aci.aci_l3out_logical_interface_profile: &intf_present + <<: *np_present + interface_profile: Floating + + - name: Create a floating svi + cisco.aci.aci_l3out_floating_svi: + <<: *intf_present + pod_id: 1 + node_id: 201 + encap: vlan-1 + address: 23.45.67.90/24 + state: present + + - name: Create a floating svi + cisco.aci.aci_l3out_floating_svi: + <<: *intf_present + pod_id: 1 + node_id: 202 + encap: vlan-1 + address: 26.45.67.90/24 + state: present + + - name: Add VMM domain + cisco.aci.aci_domain: + <<: *aci_info + domain: vmm_dom + domain_type: vmm + vm_provider: vmware + state: present + + - name: Add a vSwitch policy to vmware domain + cisco.aci.aci_vmm_vswitch_policy: + <<: *aci_info + domain: vmm_dom + vm_provider: vmware + enhanced_lag: + - name: enhanced + - name: enhanced2 + state: present + + - name: Create a floating svi path of type physical in check_mode + cisco.aci.aci_l3out_floating_svi_path: + <<: *intf_present + pod_id: 1 + node_id: 201 + encap: vlan-1 + domain_type: physical + domain: physical_dom + floating_ip: 25.45.67.90/24 + access_encap: vlan-1 + state: present + check_mode: true + register: add_floating_path_cm + when: version.current.0.topSystem.attributes.version is version('5', '>=') + + - name: Create a floating svi path of type physical in normal mode + cisco.aci.aci_l3out_floating_svi_path: + <<: *intf_present + pod_id: 1 + node_id: 201 + encap: vlan-1 + domain_type: physical + domain: physical_dom + floating_ip: 25.45.67.90/24 + access_encap: vlan-1 + state: present + register: add_floating_path_nm + when: version.current.0.topSystem.attributes.version is version('5', '>=') + + - name: Create a floating svi path of type physical in normal mode again + cisco.aci.aci_l3out_floating_svi_path: + <<: *intf_present + pod_id: 1 + node_id: 201 + encap: vlan-1 + domain_type: physical + domain: physical_dom + floating_ip: 25.45.67.90/24 + access_encap: vlan-1 + state: present + register: add_floating_path_again + when: version.current.0.topSystem.attributes.version is version('5', '>=') + + - name: Update a floating svi path of type physical + cisco.aci.aci_l3out_floating_svi_path: + <<: *intf_present + pod_id: 1 + node_id: 201 + encap: vlan-1 + domain_type: physical + domain: physical_dom + floating_ip: 25.45.67.90/24 + access_encap: vlan-2 + state: present + register: update_floating_path + when: version.current.0.topSystem.attributes.version is version('5', '>=') + + - name: Create another floating svi path of type physical + cisco.aci.aci_l3out_floating_svi_path: + <<: *intf_present + pod_id: 1 + node_id: 201 + encap: vlan-1 + domain_type: physical + domain: physical_dom2 + floating_ip: 25.45.67.90/24 + access_encap: vlan-1 + state: present + register: add_another_floating_path + when: version.current.0.topSystem.attributes.version is version('5', '>=') + + - name: Create a floating svi path of type virtual + cisco.aci.aci_l3out_floating_svi_path: + <<: *intf_present + pod_id: 1 + node_id: 202 + encap: vlan-1 + domain_type: vmware + domain: vmm_dom + floating_ip: 27.45.67.90/24 + forged_transmit: enabled + mac_change: enabled + promiscuous_mode: enabled + enhanced_lag_policy: enhanced + state: present + register: add_enhanced + when: version.current.0.topSystem.attributes.version is version('5', '>=') + + - name: Create a floating svi path of type virtual (change enhanced_lag_policy) + cisco.aci.aci_l3out_floating_svi_path: + <<: *intf_present + pod_id: 1 + node_id: 202 + encap: vlan-1 + domain_type: vmware + domain: vmm_dom + floating_ip: 27.45.67.90/24 + forged_transmit: enabled + mac_change: enabled + promiscuous_mode: enabled + enhanced_lag_policy: enhanced2 + state: present + register: change_enhanced + when: version.current.0.topSystem.attributes.version is version('5', '>=') + + - name: Create a floating svi path of type virtual (delete enhanced_lag_policy) + cisco.aci.aci_l3out_floating_svi_path: + <<: *intf_present + pod_id: 1 + node_id: 202 + encap: vlan-1 + domain_type: vmware + domain: vmm_dom + floating_ip: 27.45.67.90/24 + forged_transmit: enabled + mac_change: enabled + promiscuous_mode: enabled + enhanced_lag_policy: "" + state: present + register: del_enhanced + when: version.current.0.topSystem.attributes.version is version('5', '>=') + + - name: Verify present ops + ansible.builtin.assert: + that: + - add_floating_path_cm is changed + - add_floating_path_nm is changed + - add_floating_path_again is not changed + - update_floating_path is changed + - add_another_floating_path is changed + - add_enhanced is changed + - change_enhanced is changed + - del_enhanced is changed + - add_floating_path_nm.current.0.l3extRsDynPathAtt.attributes.dn == "uni/tn-ansible_test/out-l3outintftest/lnodep-nodes/lifp-Floating/vlifp-[topology/pod-1/node-201]-[vlan-1]/rsdynPathAtt-[uni/phys-physical_dom]" + - add_floating_path_nm.current.0.l3extRsDynPathAtt.attributes.encap == "vlan-1" + - add_floating_path_nm.current.0.l3extRsDynPathAtt.attributes.floatingAddr == "25.45.67.90/24" + - update_floating_path.current.0.l3extRsDynPathAtt.attributes.encap == "vlan-2" + - add_enhanced.current.0.l3extRsDynPathAtt.attributes.dn == "uni/tn-ansible_test/out-l3outintftest/lnodep-nodes/lifp-Floating/vlifp-[topology/pod-1/node-202]-[vlan-1]/rsdynPathAtt-[uni/vmmp-VMware/dom-vmm_dom]" + - add_enhanced.current.0.l3extRsDynPathAtt.attributes.floatingAddr == "27.45.67.90/24" + - add_enhanced.current.0.l3extRsDynPathAtt.attributes.forgedTransmit == "Enabled" + - add_enhanced.current.0.l3extRsDynPathAtt.attributes.macChange == "Enabled" + - add_enhanced.current.0.l3extRsDynPathAtt.attributes.promMode == "Enabled" + - add_enhanced.current.0.l3extRsDynPathAtt.children.0.l3extVirtualLIfPLagPolAtt.children.0.l3extRsVSwitchEnhancedLagPol.attributes.tDn == "uni/vmmp-VMware/dom-vmm_dom/vswitchpolcont/enlacplagp-enhanced" + - change_enhanced.current.0.l3extRsDynPathAtt.children.0.l3extVirtualLIfPLagPolAtt.children.0.l3extRsVSwitchEnhancedLagPol.attributes.tDn == "uni/vmmp-VMware/dom-vmm_dom/vswitchpolcont/enlacplagp-enhanced2" + - add_enhanced.sent.l3extRsDynPathAtt.children.0.l3extVirtualLIfPLagPolAtt.children.0.l3extRsVSwitchEnhancedLagPol.attributes.tDn == "uni/vmmp-VMware/dom-vmm_dom/vswitchpolcont/enlacplagp-enhanced" + - change_enhanced.sent.l3extRsDynPathAtt.children.0.l3extVirtualLIfPLagPolAtt.children.0.l3extRsVSwitchEnhancedLagPol.attributes.tDn == "uni/vmmp-VMware/dom-vmm_dom/vswitchpolcont/enlacplagp-enhanced2" + - del_enhanced.current.0.l3extRsDynPathAtt.children is not defined + when: version.current.0.topSystem.attributes.version is version('5', '>=') + +# Special Case + - name: Create a floating svi path of type virtual with enhanced2 of type l3extRsVSwitchEnhancedLagPol + cisco.aci.aci_l3out_floating_svi_path: + <<: *intf_present + pod_id: 1 + node_id: 202 + encap: vlan-1 + domain_type: vmware + domain: vmm_dom + floating_ip: 27.45.67.90/24 + enhanced_lag_policy: enhanced2 + state: present + register: check_v_four + + - name: Delete enhanced2 of type l3extRsVSwitchEnhancedLagPol + cisco.aci.aci_rest: + <<: *aci_info + path: api/node/mo/uni/tn-ansible_test/out-l3outintftest/lnodep-nodes/lifp-Floating/vlifp-[topology/pod-1/node-202]-[vlan-1]/rsdynPathAtt-[uni/vmmp-VMware/dom-vmm_dom]/vlifplagpolatt/rsvSwitchEnhancedLagPol-[uni/vmmp-VMware/dom-vmm_dom/vswitchpolcont/enlacplagp-enhanced2].json + method: post + content: | + {"l3extRsVSwitchEnhancedLagPol":{"attributes":{"dn":"uni/tn-ansible_test/out-l3outintftest/lnodep-nodes/lifp-Floating/vlifp-[topology/pod-1/node-202]-[vlan-1]/rsdynPathAtt-[uni/vmmp-VMware/dom-vmm_dom]/vlifplagpolatt/rsvSwitchEnhancedLagPol-[uni/vmmp-VMware/dom-vmm_dom/vswitchpolcont/enlacplagp-enhanced2]","status":"deleted"}}} + + - name: Create a floating svi path of type virtual with enhanced2 of type l3extRsVSwitchEnhancedLagPol + cisco.aci.aci_l3out_floating_svi_path: + <<: *intf_present + pod_id: 1 + node_id: 202 + encap: vlan-1 + domain_type: vmware + domain: vmm_dom + floating_ip: 27.45.67.90/24 + enhanced_lag_policy: enhanced2 + state: present + register: check_enhanced + + - name: Verify special case + ansible.builtin.assert: + that: + - check_v_four is changed + - check_enhanced is changed + - check_v_four.current.0.l3extRsDynPathAtt.attributes.floatingAddr == "27.45.67.90/24" + - check_enhanced.current.0.l3extRsDynPathAtt.children.0.l3extVirtualLIfPLagPolAtt.children.0.l3extRsVSwitchEnhancedLagPol.attributes.tDn == "uni/vmmp-VMware/dom-vmm_dom/vswitchpolcont/enlacplagp-enhanced2" + + - name: Query a floating svi path + cisco.aci.aci_l3out_floating_svi_path: + <<: *intf_present + pod_id: 1 + node_id: 201 + encap: vlan-1 + domain_type: physical + domain: physical_dom + state: query + register: query_floating + when: version.current.0.topSystem.attributes.version is version('5', '>=') + + - name: Query all floating svi paths + cisco.aci.aci_l3out_floating_svi_path: + <<: *intf_present + pod_id: 1 + node_id: 201 + encap: vlan-1 + state: query + register: query_all_floating + when: version.current.0.topSystem.attributes.version is version('5', '>=') + + - name: Verify query ops + ansible.builtin.assert: + that: + - query_floating is not changed + - query_all_floating is not changed + - query_floating.current.0.l3extRsDynPathAtt.attributes.dn == "uni/tn-ansible_test/out-l3outintftest/lnodep-nodes/lifp-Floating/vlifp-[topology/pod-1/node-201]-[vlan-1]/rsdynPathAtt-[uni/phys-physical_dom]" + - query_floating.current.0.l3extRsDynPathAtt.attributes.floatingAddr == "25.45.67.90/24" + - query_floating.current.0.l3extRsDynPathAtt.attributes.encap == "vlan-2" + - query_all_floating.current.0.l3extVirtualLIfP.children | length == 2 + when: version.current.0.topSystem.attributes.version is version('5', '>=') + + - name: Remove a floating svi path + cisco.aci.aci_l3out_floating_svi_path: + <<: *intf_present + pod_id: 1 + node_id: 201 + encap: vlan-1 + domain_type: physical + domain: physical_dom + state: absent + register: remove_floating_path + when: version.current.0.topSystem.attributes.version is version('5', '>=') + + - name: Verify absent ops + ansible.builtin.assert: + that: + - remove_floating_path is changed + - remove_floating_path.current == [] + when: version.current.0.topSystem.attributes.version is version('5', '>=') + + # Clean up Environment + - name: Remove vSwitch Policy + cisco.aci.aci_vmm_vswitch_policy: + <<: *aci_info + domain: vmm_dom + vm_provider: vmware + state: absent + + - name: Remove VMM domain + cisco.aci.aci_domain: + <<: *aci_info + domain: vmm_dom + domain_type: vmm + vm_provider: vmware + state: absent + + - name: Remove test tenant + cisco.aci.aci_tenant: + <<: *aci_info + tenant: ansible_test + state: absent diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_l3out_floating_svi_path_secondary_ip/aliases b/ansible_collections/cisco/aci/tests/integration/targets/aci_l3out_floating_svi_path_secondary_ip/aliases new file mode 100644 index 000000000..209b793f9 --- /dev/null +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_l3out_floating_svi_path_secondary_ip/aliases @@ -0,0 +1,2 @@ +# No ACI simulator yet, so not enabled +# unsupported diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_l3out_floating_svi_path_secondary_ip/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_l3out_floating_svi_path_secondary_ip/tasks/main.yml new file mode 100644 index 000000000..a1aedf96c --- /dev/null +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_l3out_floating_svi_path_secondary_ip/tasks/main.yml @@ -0,0 +1,226 @@ +# Author: Shreyas Srish (@shrsr) +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +# SET VARS +- name: Set vars + ansible.builtin.set_fact: + aci_info: &aci_info + host: '{{ aci_hostname }}' + username: '{{ aci_username }}' + password: '{{ aci_password }}' + validate_certs: '{{ aci_validate_certs | default(false) }}' + use_ssl: '{{ aci_use_ssl | default(true) }}' + use_proxy: '{{ aci_use_proxy | default(true) }}' + output_level: '{{ aci_output_level | default("debug") }}' + +# CLEAN ENVIRONMENT +- name: Remove test tenant before we kickoff + cisco.aci.aci_tenant: &tenant_absent + <<: *aci_info + tenant: ansible_test + state: absent + +- name: Verify Cloud and Non-Cloud Sites in use. + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + +- name: Execute tasks only for non-cloud sites + when: + - version.current.0.topSystem.attributes.version is version('5', '>=') + - query_cloud.current == [] # This condition will execute only non-cloud sites + block: # block specifies execution of tasks within, based on conditions + # SETUP ENVIRONMENT + - name: Create domain + cisco.aci.aci_domain: &domain_present + <<: *aci_info + domain: l3outintftest + domain_type: l3dom + state: present + + - name: Create tenant + cisco.aci.aci_tenant: &tenant_present + <<: *tenant_absent + state: present + + - name: Configure VRF + cisco.aci.aci_vrf: &vrf_present + <<: *tenant_present + vrf: l3outintftest + + - name: Create L3Out + cisco.aci.aci_l3out: + <<: *vrf_present + l3out: l3outintftest + domain: l3outintftest + route_control: export + + - name: Create node profile + cisco.aci.aci_l3out_logical_node_profile: &np_present + <<: *tenant_present + l3out: l3outintftest + node_profile: NODES + + - name: Add interface profile + cisco.aci.aci_l3out_logical_interface_profile: &intf_present + <<: *np_present + interface_profile: Floating + + - name: Create a floating svi + cisco.aci.aci_l3out_floating_svi: + <<: *intf_present + pod_id: 1 + node_id: 201 + encap: vlan-1 + address: 23.45.67.90/24 + state: present + + - name: Create a floating svi path of type physical + cisco.aci.aci_l3out_floating_svi_path: + <<: *intf_present + pod_id: 1 + node_id: 201 + encap: vlan-1 + domain_type: physical + domain: physical_dom + floating_ip: 25.45.67.90/24 + state: present + + - name: Create a floating svi path of type virtual + cisco.aci.aci_l3out_floating_svi_path: + <<: *intf_present + pod_id: 1 + node_id: 201 + encap: vlan-1 + domain_type: vmware + domain: virtual + floating_ip: 25.45.67.90/24 + state: present + + - name: Create a floating svi path secondary_ip (virtual) + cisco.aci.aci_l3out_floating_svi_path_secondary_ip: + <<: *intf_present + pod_id: 1 + node_id: 201 + encap: vlan-1 + domain_type: vmware + domain: virtual + secondary_ip: 30.45.67.90/24 + state: present + register: add_ip_virtual + + - name: Create a floating svi path secondary_ip in check mode + cisco.aci.aci_l3out_floating_svi_path_secondary_ip: + <<: *intf_present + pod_id: 1 + node_id: 201 + encap: vlan-1 + domain_type: physical + domain: physical_dom + secondary_ip: 27.45.67.90/24 + state: present + check_mode: true + register: add_ip_cm + + - name: Create a floating svi path secondary_ip in normal mode + cisco.aci.aci_l3out_floating_svi_path_secondary_ip: + <<: *intf_present + pod_id: 1 + node_id: 201 + encap: vlan-1 + domain_type: physical + domain: physical_dom + secondary_ip: 27.45.67.90/24 + state: present + register: add_ip_nm + + - name: Create a floating svi path secondary_ip again + cisco.aci.aci_l3out_floating_svi_path_secondary_ip: + <<: *intf_present + pod_id: 1 + node_id: 201 + encap: vlan-1 + domain_type: physical + domain: physical_dom + secondary_ip: 27.45.67.90/24 + state: present + register: add_ip_again + + - name: Create another floating svi path secondary_ip + cisco.aci.aci_l3out_floating_svi_path_secondary_ip: + <<: *intf_present + pod_id: 1 + node_id: 201 + encap: vlan-1 + domain_type: physical + domain: physical_dom + secondary_ip: 28.45.67.90/24 + state: present + register: add_another_ip + + - name: Verify present ops + ansible.builtin.assert: + that: + - add_ip_cm is changed + - add_ip_nm is changed + - add_ip_again is not changed + - add_another_ip is changed + - add_ip_virtual.current.0.l3extIp.attributes.addr == "30.45.67.90/24" + - add_ip_cm.proposed.l3extIp.attributes.addr == "27.45.67.90/24" + - add_ip_nm.current.0.l3extIp.attributes.addr == "27.45.67.90/24" + - add_another_ip.current.0.l3extIp.attributes.addr == "28.45.67.90/24" + + - name: Query a floating svi path secondary_ip + cisco.aci.aci_l3out_floating_svi_path_secondary_ip: + <<: *intf_present + pod_id: 1 + node_id: 201 + encap: vlan-1 + domain_type: physical + domain: physical_dom + secondary_ip: 27.45.67.90/24 + state: query + register: query_ip + + - name: Query all ips + cisco.aci.aci_l3out_floating_svi_path_secondary_ip: + <<: *intf_present + pod_id: 1 + node_id: 201 + encap: vlan-1 + domain_type: physical + domain: physical_dom + state: query + register: query_all + + - name: Verify query ops + ansible.builtin.assert: + that: + - query_ip is not changed + - query_all is not changed + - query_ip.current.0.l3extIp.attributes.addr == "27.45.67.90/24" + - query_all.current.0.l3extRsDynPathAtt.children | length == 2 + + - name: Delete a floating svi path secondary_ip + cisco.aci.aci_l3out_floating_svi_path_secondary_ip: + <<: *intf_present + pod_id: 1 + node_id: 201 + encap: vlan-1 + domain_type: physical + domain: physical_dom + secondary_ip: 27.45.67.90/24 + state: absent + register: delete_ip + + - name: Verify delete ops + ansible.builtin.assert: + that: + - delete_ip is changed + - delete_ip.current == [] + +# Clean up environment + - name: Remove test tenant + cisco.aci.aci_tenant: + <<: *aci_info + tenant: ansible_test + state: absent +
\ No newline at end of file diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_l3out_floating_svi_secondary_ip/aliases b/ansible_collections/cisco/aci/tests/integration/targets/aci_l3out_floating_svi_secondary_ip/aliases new file mode 100644 index 000000000..209b793f9 --- /dev/null +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_l3out_floating_svi_secondary_ip/aliases @@ -0,0 +1,2 @@ +# No ACI simulator yet, so not enabled +# unsupported diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_l3out_floating_svi_secondary_ip/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_l3out_floating_svi_secondary_ip/tasks/main.yml new file mode 100644 index 000000000..f0d2040c6 --- /dev/null +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_l3out_floating_svi_secondary_ip/tasks/main.yml @@ -0,0 +1,159 @@ +# Author: Shreyas Srish (@shrsr) +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +# SET VARS +- name: Set vars + ansible.builtin.set_fact: + aci_info: &aci_info + host: '{{ aci_hostname }}' + username: '{{ aci_username }}' + password: '{{ aci_password }}' + validate_certs: '{{ aci_validate_certs | default(false) }}' + use_ssl: '{{ aci_use_ssl | default(true) }}' + use_proxy: '{{ aci_use_proxy | default(true) }}' + output_level: '{{ aci_output_level | default("info") }}' + +# CLEAN ENVIRONMENT +- name: Remove test tenant before we kickoff + cisco.aci.aci_tenant: &tenant_absent + <<: *aci_info + tenant: ansible_test + state: absent + +- name: Verify Cloud and Non-Cloud Sites in use. + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + +- name: Execute tasks only for non-cloud sites + when: query_cloud.current == [] # This condition will execute only non-cloud sites + block: # block specifies execution of tasks within, based on conditions + # SETUP ENVIRONMENT + - name: Create domain + cisco.aci.aci_domain: &domain_present + <<: *aci_info + domain: l3outintftest + domain_type: l3dom + state: present + + - name: Create tenant + cisco.aci.aci_tenant: &tenant_present + <<: *tenant_absent + state: present + + - name: Configure VRF + cisco.aci.aci_vrf: &vrf_present + <<: *tenant_present + vrf: l3outintftest + + - name: Create L3Out + cisco.aci.aci_l3out: + <<: *vrf_present + l3out: l3outintftest + domain: l3outintftest + route_control: export + + - name: Create node profile + cisco.aci.aci_l3out_logical_node_profile: &np_present + <<: *tenant_present + l3out: l3outintftest + node_profile: NODES + + - name: Add interface profile + cisco.aci.aci_l3out_logical_interface_profile: &intf_present + <<: *np_present + interface_profile: Floating + + - name: Create a floating svi + cisco.aci.aci_l3out_floating_svi: + <<: *intf_present + pod_id: 1 + node_id: 201 + encap: vlan-1 + address: 23.45.67.90/24 + external_bridge_group_profile: bridge1 + state: present + register: add_floating_cm + + - name: Create a floating svi secondary_ip in check mode + cisco.aci.aci_l3out_floating_svi_secondary_ip: &floating_svi + <<: *intf_present + pod_id: 1 + node_id: 201 + encap: vlan-1 + secondary_ip: 25.45.67.90/24 + state: present + check_mode: true + register: add_ip_cm + + - name: Create a floating svi secondary_ip in normal mode + cisco.aci.aci_l3out_floating_svi_secondary_ip: + <<: *floating_svi + state: present + register: add_ip_nm + + - name: Create a floating svi secondary_ip again + cisco.aci.aci_l3out_floating_svi_secondary_ip: + <<: *floating_svi + state: present + register: add_ip_again + + - name: Create another floating svi secondary_ip + cisco.aci.aci_l3out_floating_svi_secondary_ip: + <<: *intf_present + pod_id: 1 + node_id: 201 + encap: vlan-1 + secondary_ip: 26.45.67.90/24 + state: present + register: add_another_ip + + - name: Verify present ops + ansible.builtin.assert: + that: + - add_ip_cm is changed + - add_ip_nm is changed + - add_ip_again is not changed + - add_another_ip is changed + - add_ip_nm.current.0.l3extIp.attributes.addr == "25.45.67.90/24" + - add_another_ip.current.0.l3extIp.attributes.addr == "26.45.67.90/24" + + - name: Query a floating svi secondary_ip + cisco.aci.aci_l3out_floating_svi_secondary_ip: + <<: *floating_svi + state: query + register: query_ip + + - name: Query all ips + cisco.aci.aci_l3out_floating_svi_secondary_ip: + <<: *intf_present + pod_id: 1 + node_id: 201 + encap: vlan-1 + state: query + register: query_all + + - name: Verify query ops + ansible.builtin.assert: + that: + - query_ip is not changed + - query_all is not changed + - query_ip.current.0.l3extIp.attributes.addr == "25.45.67.90/24" + - query_all.current.0.l3extVirtualLIfP.children | length == 2 + + - name: Delete a floating svi secondary_ip + cisco.aci.aci_l3out_floating_svi_secondary_ip: + <<: *floating_svi + state: absent + register: delete_ip + + - name: Verify delete ops + ansible.builtin.assert: + that: + - delete_ip is changed + - delete_ip.current == [] + +# Clean up environment + - name: Remove test tenant + cisco.aci.aci_tenant: + <<: *aci_info + tenant: ansible_test + state: absent
\ No newline at end of file diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_l3out_hsrp_group/aliases b/ansible_collections/cisco/aci/tests/integration/targets/aci_l3out_hsrp_group/aliases new file mode 100644 index 000000000..209b793f9 --- /dev/null +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_l3out_hsrp_group/aliases @@ -0,0 +1,2 @@ +# No ACI simulator yet, so not enabled +# unsupported diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_l3out_hsrp_group/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_l3out_hsrp_group/tasks/main.yml new file mode 100644 index 000000000..d1a4ef501 --- /dev/null +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_l3out_hsrp_group/tasks/main.yml @@ -0,0 +1,195 @@ +# Test code for the ACI modules +# Copyright: (c) 2023, Shreyas Srish (@shrsr) +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +# SET VARS +- name: Set vars + ansible.builtin.set_fact: + aci_info: &aci_info + host: '{{ aci_hostname }}' + username: '{{ aci_username }}' + password: '{{ aci_password }}' + validate_certs: '{{ aci_validate_certs | default(false) }}' + use_ssl: '{{ aci_use_ssl | default(true) }}' + use_proxy: '{{ aci_use_proxy | default(true) }}' + output_level: '{{ aci_output_level | default("debug") }}' + +# CLEAN ENVIRONMENT +- name: Remove test tenant before we kickoff + cisco.aci.aci_tenant: &tenant_absent + <<: *aci_info + tenant: ansible_test + state: absent + +- name: Verify Cloud and Non-Cloud Sites in use. + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + +- name: Execute tasks only for non-cloud sites + when: query_cloud.current == [] # This condition will execute only non-cloud sites + block: # block specifies execution of tasks within, based on conditions + # SETUP ENVIRONMENT + - name: Create domain + cisco.aci.aci_domain: + <<: *aci_info + domain: l3outintftest + domain_type: l3dom + state: present + + - name: Create tenant + cisco.aci.aci_tenant: &tenant_present + <<: *tenant_absent + state: present + + - name: Configure VRF + cisco.aci.aci_vrf: &vrf_present + <<: *tenant_present + vrf: l3outintftest + + - name: Create L3Out + cisco.aci.aci_l3out: + <<: *vrf_present + l3out: l3outintftest + domain: l3outintftest + route_control: export + + - name: Create node profile + cisco.aci.aci_l3out_logical_node_profile: &np_present + <<: *tenant_present + l3out: l3outintftest + node_profile: node1 + + - name: Create interface profile + cisco.aci.aci_l3out_logical_interface_profile: &intf_present + <<: *np_present + interface_profile: intf1 + + - name: Add a hsrp interface profile + cisco.aci.aci_l3out_hsrp_interface_profile: + <<: *intf_present + hsrp_policy: default + version: v1 + state: present + + - name: Add a hsrp group (check mode) + cisco.aci.aci_l3out_hsrp_group: &group_present + <<: *intf_present + hsrp_interface_group: group1 + group_id: 1 + ip: 12.34.56.32 + mac: 00:00:00:00:00:FF + group_name: one + group_type: ipv4 + ip_obtain_mode: admin + group_policy: default + state: present + check_mode: true + register: cm_add_group + + - name: Add a hsrp group (normal mode) + cisco.aci.aci_l3out_hsrp_group: + <<: *group_present + register: nm_add_group + + - name: Add hsrp group again + cisco.aci.aci_l3out_hsrp_group: + <<: *group_present + register: add_group_again + + - name: Change hsrp group + cisco.aci.aci_l3out_hsrp_group: &group_update + <<: *group_present + group_id: 3 + register: update_group + + - name: Add another hsrp group + cisco.aci.aci_l3out_hsrp_group: + <<: *intf_present + hsrp_interface_group: group2 + group_name: two + ip_obtain_mode: learn + state: present + register: nm_add_group2 + + - name: Verify add hsrp groups + ansible.builtin.assert: + that: + - cm_add_group is changed + - nm_add_group is changed + - add_group_again is not changed + - cm_add_group.proposed.hsrpGroupP.attributes.groupAf == "ipv4" + - cm_add_group.proposed.hsrpGroupP.attributes.groupId == "1" + - cm_add_group.proposed.hsrpGroupP.attributes.groupName == "one" + - cm_add_group.proposed.hsrpGroupP.attributes.ip == "12.34.56.32" + - cm_add_group.proposed.hsrpGroupP.attributes.ipObtainMode == "admin" + - cm_add_group.proposed.hsrpGroupP.attributes.mac == "00:00:00:00:00:FF" + - cm_add_group.proposed.hsrpGroupP.children.0.hsrpRsGroupPol.attributes.tnHsrpGroupPolName == "default" + - nm_add_group.current.0.hsrpGroupP.attributes.dn == "uni/tn-ansible_test/out-l3outintftest/lnodep-node1/lifp-intf1/hsrpIfP/hsrpGroupP-group1" + - nm_add_group.current.0.hsrpGroupP.attributes.groupAf == "ipv4" + - nm_add_group.current.0.hsrpGroupP.attributes.groupId == "1" + - cm_add_group.previous == nm_add_group.previous == [] + - update_group.current.0.hsrpGroupP.attributes.groupId == "3" + - nm_add_group.current.0.hsrpGroupP.attributes.name == "group1" + - nm_add_group.current.0.hsrpGroupP.attributes.groupName == "one" + - nm_add_group.current.0.hsrpGroupP.attributes.ip == "12.34.56.32" + - nm_add_group.current.0.hsrpGroupP.attributes.ipObtainMode == "admin" + - nm_add_group.current.0.hsrpGroupP.attributes.mac == "00:00:00:00:00:FF" + - nm_add_group.current.0.hsrpGroupP.children.0.hsrpRsGroupPol.attributes.tnHsrpGroupPolName == "default" + - nm_add_group2.current.0.hsrpGroupP.attributes.name == "group2" + - nm_add_group2.current.0.hsrpGroupP.attributes.groupName == "two" + - nm_add_group2.current.0.hsrpGroupP.attributes.ipObtainMode == "learn" + + - name: Query a hsrp group + cisco.aci.aci_l3out_hsrp_group: + <<: *group_update + state: query + register: query_group + + - name: Query all hsrp groups + cisco.aci.aci_l3out_hsrp_group: + <<: *intf_present + state: query + register: query_all + + - name: Verify query + ansible.builtin.assert: + that: + - query_group is not changed + - query_all is not changed + - query_group.current.0.hsrpGroupP.attributes.dn == "uni/tn-ansible_test/out-l3outintftest/lnodep-node1/lifp-intf1/hsrpIfP/hsrpGroupP-group1" + - query_group.current.0.hsrpGroupP.attributes.groupAf == "ipv4" + - query_group.current.0.hsrpGroupP.attributes.groupId == "3" + - query_group.current.0.hsrpGroupP.attributes.name == "group1" + - query_group.current.0.hsrpGroupP.attributes.groupName == "one" + - query_group.current.0.hsrpGroupP.attributes.ip == "12.34.56.32" + - query_group.current.0.hsrpGroupP.attributes.ipObtainMode == "admin" + - query_group.current.0.hsrpGroupP.attributes.mac == "00:00:00:00:00:FF" + - query_group.current.0.hsrpGroupP.children.0.hsrpRsGroupPol.attributes.tnHsrpGroupPolName == "default" + - query_all.current.0.hsrpIfP.children | length == 2 + + - name: Remove a hsrp group in check mode + cisco.aci.aci_l3out_hsrp_group: + <<: *group_update + state: absent + check_mode: true + register: cm_absent_group + + - name: Remove a hsrp group + cisco.aci.aci_l3out_hsrp_group: + <<: *group_update + state: absent + register: absent_group + + - name: Remove hsrp group again + cisco.aci.aci_l3out_hsrp_group: + <<: *group_update + state: absent + register: absent_group_again + + - name: Verify remove + ansible.builtin.assert: + that: + - cm_absent_group is changed + - cm_absent_group.proposed == {} + - absent_group is changed + - absent_group.current == [] + - absent_group_again is not changed diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_l3out_hsrp_interface_profile/aliases b/ansible_collections/cisco/aci/tests/integration/targets/aci_l3out_hsrp_interface_profile/aliases new file mode 100644 index 000000000..209b793f9 --- /dev/null +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_l3out_hsrp_interface_profile/aliases @@ -0,0 +1,2 @@ +# No ACI simulator yet, so not enabled +# unsupported diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_l3out_hsrp_interface_profile/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_l3out_hsrp_interface_profile/tasks/main.yml new file mode 100644 index 000000000..162e1ce04 --- /dev/null +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_l3out_hsrp_interface_profile/tasks/main.yml @@ -0,0 +1,152 @@ +# Test code for the ACI modules +# Copyright: (c) 2023, Shreyas Srish (@shrsr) +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +# SET VARS +- name: Set vars + ansible.builtin.set_fact: + aci_info: &aci_info + host: '{{ aci_hostname }}' + username: '{{ aci_username }}' + password: '{{ aci_password }}' + validate_certs: '{{ aci_validate_certs | default(false) }}' + use_ssl: '{{ aci_use_ssl | default(true) }}' + use_proxy: '{{ aci_use_proxy | default(true) }}' + output_level: '{{ aci_output_level | default("debug") }}' + +# CLEAN ENVIRONMENT +- name: Remove test tenant before we kickoff + cisco.aci.aci_tenant: &tenant_absent + <<: *aci_info + tenant: ansible_test + state: absent + +- name: Verify Cloud and Non-Cloud Sites in use. + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + +- name: Execute tasks only for non-cloud sites + when: query_cloud.current == [] # This condition will execute only non-cloud sites + block: # block specifies execution of tasks within, based on conditions + # SETUP ENVIRONMENT + - name: Create domain + cisco.aci.aci_domain: + <<: *aci_info + domain: l3outintftest + domain_type: l3dom + state: present + + - name: Create tenant + cisco.aci.aci_tenant: &tenant_present + <<: *tenant_absent + state: present + + - name: Configure VRF + cisco.aci.aci_vrf: &vrf_present + <<: *tenant_present + vrf: l3outintftest + + - name: Create L3Out + cisco.aci.aci_l3out: + <<: *vrf_present + l3out: l3outintftest + domain: l3outintftest + route_control: export + + - name: Create node profile + cisco.aci.aci_l3out_logical_node_profile: &np_present + <<: *tenant_present + l3out: l3outintftest + node_profile: node1 + + - name: Create interface profile + cisco.aci.aci_l3out_logical_interface_profile: &intf_present + <<: *np_present + interface_profile: intf1 + + - name: Add a new hsrp interface profile (check mode) + cisco.aci.aci_l3out_hsrp_interface_profile: &hsrp_present + <<: *intf_present + version: v1 + state: present + check_mode: true + register: cm_add_hsrp + + - name: Add a new hsrp interface profile (normal mode) + cisco.aci.aci_l3out_hsrp_interface_profile: *hsrp_present + register: nm_add_hsrp + + - name: Verify add hsrp + ansible.builtin.assert: + that: + - cm_add_hsrp is changed + - nm_add_hsrp is changed + - cm_add_hsrp.proposed.hsrpIfP.attributes.version == "v1" + - cm_add_hsrp.previous == nm_add_hsrp.previous == [] + - nm_add_hsrp.current.0.hsrpIfP.attributes.dn == "uni/tn-ansible_test/out-l3outintftest/lnodep-node1/lifp-intf1/hsrpIfP" + - nm_add_hsrp.current.0.hsrpIfP.attributes.version == "v1" + + - name: Add the hsrp interface profile again to check idempotency + cisco.aci.aci_l3out_hsrp_interface_profile: *hsrp_present + register: nm_add_hsrp_again + + - name: Verify idempotency + ansible.builtin.assert: + that: + - nm_add_hsrp_again is not changed + + - name: Update the hsrp interface_profile + cisco.aci.aci_l3out_hsrp_interface_profile: &hsrp_update + <<: *hsrp_present + hsrp_policy: default + version: v2 + register: nm_hsrp_update + + - name: Verify update hsrp + ansible.builtin.assert: + that: + - nm_hsrp_update is changed + - nm_hsrp_update.current.0.hsrpIfP.attributes.dn == "uni/tn-ansible_test/out-l3outintftest/lnodep-node1/lifp-intf1/hsrpIfP" + - nm_hsrp_update.current.0.hsrpIfP.attributes.version == "v2" + - nm_hsrp_update.current.0.hsrpIfP.children.0.hsrpRsIfPol.attributes.tnHsrpIfPolName == "default" + + - name: Query the hsrp interface profile + cisco.aci.aci_l3out_hsrp_interface_profile: + <<: *hsrp_update + state: query + register: query_hsrp + + - name: Verify query hsrp + ansible.builtin.assert: + that: + - query_hsrp is not changed + - query_hsrp.current.0.hsrpIfP.attributes.dn == "uni/tn-ansible_test/out-l3outintftest/lnodep-node1/lifp-intf1/hsrpIfP" + - query_hsrp.current.0.hsrpIfP.attributes.version == "v2" + - query_hsrp.current.0.hsrpIfP.children.0.hsrpRsIfPol.attributes.tnHsrpIfPolName == "default" + + - name: Remove the hsrp interface profile + cisco.aci.aci_l3out_hsrp_interface_profile: + <<: *hsrp_update + state: absent + register: cm_remove_hsrp + check_mode: true + + - name: Remove the hsrp interface profile + cisco.aci.aci_l3out_hsrp_interface_profile: + <<: *hsrp_update + state: absent + register: remove_hsrp + + - name: Remove the hsrp interface profile again + cisco.aci.aci_l3out_hsrp_interface_profile: + <<: *hsrp_update + state: absent + register: remove_hsrp_again + + - name: Verify remove_hsrp + ansible.builtin.assert: + that: + - cm_remove_hsrp is changed + - cm_remove_hsrp.proposed == {} + - remove_hsrp is changed + - remove_hsrp.current == [] + - remove_hsrp_again is not changed diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_l3out_hsrp_secondary_vip/aliases b/ansible_collections/cisco/aci/tests/integration/targets/aci_l3out_hsrp_secondary_vip/aliases new file mode 100644 index 000000000..209b793f9 --- /dev/null +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_l3out_hsrp_secondary_vip/aliases @@ -0,0 +1,2 @@ +# No ACI simulator yet, so not enabled +# unsupported diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_l3out_hsrp_secondary_vip/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_l3out_hsrp_secondary_vip/tasks/main.yml new file mode 100644 index 000000000..d267f2d3d --- /dev/null +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_l3out_hsrp_secondary_vip/tasks/main.yml @@ -0,0 +1,173 @@ +# Test code for the ACI modules +# Copyright: (c) 2023, Shreyas Srish (@shrsr) +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +# SET VARS +- name: Set vars + ansible.builtin.set_fact: + aci_info: &aci_info + host: '{{ aci_hostname }}' + username: '{{ aci_username }}' + password: '{{ aci_password }}' + validate_certs: '{{ aci_validate_certs | default(false) }}' + use_ssl: '{{ aci_use_ssl | default(true) }}' + use_proxy: '{{ aci_use_proxy | default(true) }}' + output_level: '{{ aci_output_level | default("debug") }}' + +# CLEAN ENVIRONMENT +- name: Remove test tenant before we kickoff + cisco.aci.aci_tenant: &tenant_absent + <<: *aci_info + tenant: ansible_test + state: absent + +- name: Verify Cloud and Non-Cloud Sites in use. + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + +- name: Execute tasks only for non-cloud sites + when: query_cloud.current == [] # This condition will execute only non-cloud sites + block: # block specifies execution of tasks within, based on conditions + # SETUP ENVIRONMENT + - name: Create domain + cisco.aci.aci_domain: + <<: *aci_info + domain: l3outintftest + domain_type: l3dom + state: present + + - name: Create tenant + cisco.aci.aci_tenant: &tenant_present + <<: *tenant_absent + state: present + + - name: Configure VRF + cisco.aci.aci_vrf: &vrf_present + <<: *tenant_present + vrf: l3outintftest + + - name: Create L3Out + cisco.aci.aci_l3out: + <<: *vrf_present + l3out: l3outintftest + domain: l3outintftest + route_control: export + + - name: Create node profile + cisco.aci.aci_l3out_logical_node_profile: &np_present + <<: *tenant_present + l3out: l3outintftest + node_profile: node1 + + - name: Create interface profile + cisco.aci.aci_l3out_logical_interface_profile: &intf_present + <<: *np_present + interface_profile: intf1 + + - name: Add a hsrp interface profile + cisco.aci.aci_l3out_hsrp_interface_profile: + <<: *intf_present + hsrp_policy: default + version: v1 + state: present + + - name: Add a hsrp group + cisco.aci.aci_l3out_hsrp_group: + <<: *intf_present + hsrp_interface_group: group1 + group_id: 1 + ip: 12.34.56.32 + mac: 00:00:00:00:00:FF + group_name: one + group_type: ipv4 + ip_obtain_mode: admin + group_policy: default + state: present + + - name: Add a hsrp group secondary vip (check mode) + cisco.aci.aci_l3out_hsrp_secondary_vip: &vip + <<: *intf_present + hsrp_interface_group: group1 + secondary_virtual_ip: 191.1.1.1 + check_mode: true + register: cm_vip + + - name: Add a hsrp group secondary vip (normal mode) + cisco.aci.aci_l3out_hsrp_secondary_vip: + <<: *vip + register: nm_vip + + - name: Add a hsrp group secondary vip again + cisco.aci.aci_l3out_hsrp_secondary_vip: + <<: *vip + register: add_vip_again + + - name: Add another vip + cisco.aci.aci_l3out_hsrp_secondary_vip: + <<: *vip + secondary_virtual_ip: 191.1.1.2 + register: add_vip2 + + - name: Verify add hsrp vips + ansible.builtin.assert: + that: + - cm_vip is changed + - nm_vip is changed + - add_vip_again is not changed + - add_vip2 is changed + - cm_vip.previous == nm_vip.previous == [] + - cm_vip.proposed.hsrpSecVip.attributes.ip == "191.1.1.1" + - nm_vip.current.0.hsrpSecVip.attributes.dn == "uni/tn-ansible_test/out-l3outintftest/lnodep-node1/lifp-intf1/hsrpIfP/hsrpGroupP-group1/hsrpSecVip-[191.1.1.1]" + - nm_vip.current.0.hsrpSecVip.attributes.ip == "191.1.1.1" + - add_vip2.current.0.hsrpSecVip.attributes.dn == "uni/tn-ansible_test/out-l3outintftest/lnodep-node1/lifp-intf1/hsrpIfP/hsrpGroupP-group1/hsrpSecVip-[191.1.1.2]" + - add_vip2.current.0.hsrpSecVip.attributes.ip == "191.1.1.2" + + + - name: Query a vip + cisco.aci.aci_l3out_hsrp_secondary_vip: + <<: *vip + state: query + register: query_vip + + - name: Query all vips + cisco.aci.aci_l3out_hsrp_secondary_vip: + <<: *intf_present + hsrp_interface_group: group1 + state: query + register: query_all + + - name: Verify query + ansible.builtin.assert: + that: + - query_vip is not changed + - query_all is not changed + - query_vip.current.0.hsrpSecVip.attributes.dn == "uni/tn-ansible_test/out-l3outintftest/lnodep-node1/lifp-intf1/hsrpIfP/hsrpGroupP-group1/hsrpSecVip-[191.1.1.1]" + - query_vip.current.0.hsrpSecVip.attributes.ip == "191.1.1.1" + - query_all.current.0.hsrpGroupP.children | length == 2 + + - name: Remove a hsrp group vip in check mode + cisco.aci.aci_l3out_hsrp_secondary_vip: + <<: *vip + state: absent + check_mode: true + register: cm_absent_vip + + - name: Remove a hsrp group vip + cisco.aci.aci_l3out_hsrp_secondary_vip: + <<: *vip + state: absent + register: absent_vip + + - name: Remove hsrp group again + cisco.aci.aci_l3out_hsrp_secondary_vip: + <<: *vip + state: absent + register: absent_vip_again + + - name: Verify remove + ansible.builtin.assert: + that: + - cm_absent_vip is changed + - cm_absent_vip.proposed == {} + - absent_vip is changed + - absent_vip.current == [] + - absent_vip_again is not changed diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_l3out_interface/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_l3out_interface/tasks/main.yml index 5b2a247d8..38e4321e3 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_l3out_interface/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_l3out_interface/tasks/main.yml @@ -1,16 +1,17 @@ # Test code for the ACI modules # Copyright: (c) 2021, Tim Cragg (@timcragg) +# Copyright: (c) 2023, Akini Ross (@akinross) <akinross@cisco.com> # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined # GET Credentials from the inventory - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: "{{ aci_hostname }}" username: "{{ aci_username }}" @@ -22,40 +23,40 @@ # CLEAN ENVIRONMENT - name: Remove ansible_tenant if it already exists - aci_tenant: + cisco.aci.aci_tenant: <<: *aci_info tenant: ansible_tenant state: absent - name: Verify Cloud and Non-Cloud Sites in use. - include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml - name: Execute tasks only for non-cloud sites when: query_cloud.current == [] # This condition will execute only non-cloud sites block: # block specifies execution of tasks within, based on conditions - name: Remove ansible_l3ext_domain if it already exists - aci_domain: + cisco.aci.aci_domain: <<: *aci_info domain: ansible_l3ext_domain domain_type: l3dom state: absent - name: Remove ansible_port_channel_ipg if it already exists - aci_interface_policy_leaf_policy_group: + cisco.aci.aci_interface_policy_leaf_policy_group: <<: *aci_info lag_type: link policy_group: ansible_port_channel_ipg state: absent - name: Remove ansible_vpc_ipg if it already exists - aci_interface_policy_leaf_policy_group: + cisco.aci.aci_interface_policy_leaf_policy_group: <<: *aci_info lag_type: node policy_group: ansible_vpc_ipg state: absent - name: Add a new tenant required for l3out - aci_tenant: + cisco.aci.aci_tenant: <<: *aci_info tenant: ansible_tenant description: Ansible tenant @@ -63,7 +64,7 @@ # ADD domain - name: Add domain for l3out - aci_domain: + cisco.aci.aci_domain: <<: *aci_info domain: ansible_l3ext_domain domain_type: l3dom @@ -71,7 +72,7 @@ # ADD VRF - name: Add VRF for l3out - aci_vrf: + cisco.aci.aci_vrf: <<: *aci_info tenant: ansible_tenant vrf: ansible_vrf @@ -79,7 +80,7 @@ # ADD PC IPG - name: Add port-channel IPG - aci_interface_policy_leaf_policy_group: + cisco.aci.aci_interface_policy_leaf_policy_group: <<: *aci_info lag_type: link policy_group: ansible_port_channel_ipg @@ -87,7 +88,7 @@ # ADD vPC IPG - name: Add vPC IPG - aci_interface_policy_leaf_policy_group: + cisco.aci.aci_interface_policy_leaf_policy_group: <<: *aci_info lag_type: node policy_group: ansible_vpc_ipg @@ -95,7 +96,7 @@ # ADD l3out - name: Add l3out - aci_l3out: + cisco.aci.aci_l3out: <<: *aci_info tenant: ansible_tenant name: ansible_l3out @@ -106,7 +107,7 @@ # ADD l3out logical node profile - name: l3out logical node profile - aci_l3out_logical_node_profile: + cisco.aci.aci_l3out_logical_node_profile: <<: *aci_info tenant: ansible_tenant l3out: ansible_l3out @@ -115,7 +116,7 @@ # ADD l3out logical interface profile - name: l3out logical interface profile - aci_l3out_logical_interface_profile: + cisco.aci.aci_l3out_logical_interface_profile: <<: *aci_info tenant: ansible_tenant l3out: ansible_l3out @@ -125,7 +126,7 @@ # ADD l3out interface - name: Add routed interface - aci_l3out_interface: + cisco.aci.aci_l3out_interface: <<: *aci_info tenant: ansible_tenant l3out: ansible_l3out @@ -144,7 +145,7 @@ register: add_l3out_interface - name: Verify l3out has been created with the correct attributes - assert: + ansible.builtin.assert: that: - add_l3out_interface.current.0.l3extRsPathL3OutAtt.attributes.dn == "uni/tn-ansible_tenant/out-ansible_l3out/lnodep-ansible_node_profile/lifp-ansible_interface_profile/rspathL3OutAtt-[topology/pod-1/paths-201/pathep-[eth1/15]]" - add_l3out_interface.current.0.l3extRsPathL3OutAtt.attributes.addr == "192.168.50.1/27" @@ -157,7 +158,7 @@ # ADD l3out interface again to check idempotency - name: Add routed interface again - aci_l3out_interface: + cisco.aci.aci_l3out_interface: <<: *aci_info tenant: ansible_tenant l3out: ansible_l3out @@ -176,13 +177,13 @@ register: add_l3out_interface_again - name: Verify l3out has not changed - assert: + ansible.builtin.assert: that: - add_l3out_interface_again is not changed # MODIFY l3out attributes - name: Update routed interface - aci_l3out_interface: + cisco.aci.aci_l3out_interface: <<: *aci_info tenant: ansible_tenant l3out: ansible_l3out @@ -199,7 +200,7 @@ register: update_l3out_interface - name: Verify routed interface has correct attributes - assert: + ansible.builtin.assert: that: - update_l3out_interface.current.0.l3extRsPathL3OutAtt.attributes.dn == "uni/tn-ansible_tenant/out-ansible_l3out/lnodep-ansible_node_profile/lifp-ansible_interface_profile/rspathL3OutAtt-[topology/pod-1/paths-201/pathep-[eth1/15]]" - update_l3out_interface.current.0.l3extRsPathL3OutAtt.attributes.addr == "192.168.60.1/27" @@ -209,7 +210,7 @@ # QUERY l3out interface - name: Query routed interface - aci_l3out_interface: + cisco.aci.aci_l3out_interface: <<: *aci_info tenant: ansible_tenant l3out: ansible_l3out @@ -222,7 +223,7 @@ register: query_l3out_interface - name: Verify query_l3out_interface - assert: + ansible.builtin.assert: that: - query_l3out_interface is not changed - query_l3out_interface.current.0.l3extRsPathL3OutAtt.attributes.dn == "uni/tn-ansible_tenant/out-ansible_l3out/lnodep-ansible_node_profile/lifp-ansible_interface_profile/rspathL3OutAtt-[topology/pod-1/paths-201/pathep-[eth1/15]]" @@ -232,7 +233,7 @@ - query_l3out_interface.current.0.l3extRsPathL3OutAtt.attributes.mode == "regular" - name: Query all interfaces - aci_l3out_interface: + cisco.aci.aci_l3out_interface: <<: *aci_info tenant: ansible_tenant l3out: ansible_l3out @@ -242,7 +243,7 @@ register: query_l3out_interfaces - name: Verify query_l3out_interfaces - assert: + ansible.builtin.assert: that: - query_l3out_interfaces is not changed - query_l3out_interfaces.current.0.l3extLIfP.children.0.l3extRsPathL3OutAtt.attributes.rn == "rspathL3OutAtt-[topology/pod-1/paths-201/pathep-[eth1/15]]" @@ -253,7 +254,7 @@ # DELETE l3out interface - name: Remove routed sub-interface - aci_l3out_interface: + cisco.aci.aci_l3out_interface: <<: *aci_info tenant: ansible_tenant l3out: ansible_l3out @@ -266,14 +267,14 @@ register: delete_l3out_interface - name: Verify interface has been deleted - assert: + ansible.builtin.assert: that: - delete_l3out_interface.current == [] - delete_l3out_interface.previous.0.l3extRsPathL3OutAtt.attributes.dn == "uni/tn-ansible_tenant/out-ansible_l3out/lnodep-ansible_node_profile/lifp-ansible_interface_profile/rspathL3OutAtt-[topology/pod-1/paths-201/pathep-[eth1/15]]" # ADD l3out port-channel - name: Add routed interface port-channel - aci_l3out_interface: + cisco.aci.aci_l3out_interface: <<: *aci_info tenant: ansible_tenant l3out: ansible_l3out @@ -289,7 +290,7 @@ register: add_l3out_pc_interface - name: Verify l3out port-channel has been created with the correct attributes - assert: + ansible.builtin.assert: that: - add_l3out_pc_interface.current.0.l3extRsPathL3OutAtt.attributes.dn == "uni/tn-ansible_tenant/out-ansible_l3out/lnodep-ansible_node_profile/lifp-ansible_interface_profile/rspathL3OutAtt-[topology/pod-1/paths-201/pathep-[ansible_port_channel_ipg]]" - add_l3out_pc_interface.current.0.l3extRsPathL3OutAtt.attributes.addr == "192.168.70.1/27" @@ -298,7 +299,7 @@ # ADD l3out port-channel again to check idempotency - name: Add routed interface port-channel again - aci_l3out_interface: + cisco.aci.aci_l3out_interface: <<: *aci_info tenant: ansible_tenant l3out: ansible_l3out @@ -314,13 +315,13 @@ register: add_l3out_pc_interface_again - name: Verify interface has not changed - assert: + ansible.builtin.assert: that: - add_l3out_pc_interface_again is not changed # MODIFY l3out port-channel attributes - name: Update routed port-channel interface - aci_l3out_interface: + cisco.aci.aci_l3out_interface: <<: *aci_info tenant: ansible_tenant l3out: ansible_l3out @@ -336,7 +337,7 @@ register: update_l3out_pc_interface - name: Verify l3out port-channel has been updated with the correct attributes - assert: + ansible.builtin.assert: that: - update_l3out_pc_interface is changed - update_l3out_pc_interface.current.0.l3extRsPathL3OutAtt.attributes.dn == "uni/tn-ansible_tenant/out-ansible_l3out/lnodep-ansible_node_profile/lifp-ansible_interface_profile/rspathL3OutAtt-[topology/pod-1/paths-201/pathep-[ansible_port_channel_ipg]]" @@ -346,7 +347,7 @@ # QUERY l3out port-channel interface - name: Query l3out port-channel - aci_l3out_interface: + cisco.aci.aci_l3out_interface: <<: *aci_info tenant: ansible_tenant l3out: ansible_l3out @@ -359,7 +360,7 @@ register: query_l3out_pc_interface - name: Verify query_l3out_pc_interface - assert: + ansible.builtin.assert: that: - query_l3out_pc_interface is not changed - query_l3out_pc_interface.current.0.l3extRsPathL3OutAtt.attributes.dn == "uni/tn-ansible_tenant/out-ansible_l3out/lnodep-ansible_node_profile/lifp-ansible_interface_profile/rspathL3OutAtt-[topology/pod-1/paths-201/pathep-[ansible_port_channel_ipg]]" @@ -369,7 +370,7 @@ # DELETE l3out port-channel interface - name: Remove port-channel - aci_l3out_interface: + cisco.aci.aci_l3out_interface: <<: *aci_info tenant: ansible_tenant l3out: ansible_l3out @@ -382,14 +383,14 @@ register: delete_l3out_pc_interface - name: Verify interface has been deleted - assert: + ansible.builtin.assert: that: - delete_l3out_pc_interface.current == [] - delete_l3out_pc_interface.previous.0.l3extRsPathL3OutAtt.attributes.dn == "uni/tn-ansible_tenant/out-ansible_l3out/lnodep-ansible_node_profile/lifp-ansible_interface_profile/rspathL3OutAtt-[topology/pod-1/paths-201/pathep-[ansible_port_channel_ipg]]" # ADD l3out vPC - name: Add interface vPC - aci_l3out_interface: + cisco.aci.aci_l3out_interface: &ext_svi_interface <<: *aci_info tenant: ansible_tenant l3out: ansible_l3out @@ -402,43 +403,45 @@ mode: native addr: 192.168.90.1/27 encap: vlan-913 + mac: "00:22:BD:F8:19:FE" + description: "anisble test description" state: present register: add_l3out_vpc_interface - name: Verify l3out vPC has been created with the correct attributes - assert: + ansible.builtin.assert: that: - add_l3out_vpc_interface.current.0.l3extRsPathL3OutAtt.attributes.dn == "uni/tn-ansible_tenant/out-ansible_l3out/lnodep-ansible_node_profile/lifp-ansible_interface_profile/rspathL3OutAtt-[topology/pod-1/protpaths-201-202/pathep-[ansible_vpc_ipg]]" - add_l3out_vpc_interface.current.0.l3extRsPathL3OutAtt.attributes.addr == "192.168.90.1/27" - add_l3out_vpc_interface.current.0.l3extRsPathL3OutAtt.attributes.ifInstT == "ext-svi" - add_l3out_vpc_interface.current.0.l3extRsPathL3OutAtt.attributes.encap == "vlan-913" + - add_l3out_vpc_interface.current.0.l3extRsPathL3OutAtt.attributes.encapScope == "local" - add_l3out_vpc_interface.current.0.l3extRsPathL3OutAtt.attributes.mode == "native" + - add_l3out_vpc_interface.current.0.l3extRsPathL3OutAtt.attributes.mac == "00:22:BD:F8:19:FE" + - add_l3out_vpc_interface.current.0.l3extRsPathL3OutAtt.attributes.descr == "anisble test description" - name: Add interface vPC again - aci_l3out_interface: - <<: *aci_info - tenant: ansible_tenant - l3out: ansible_l3out - node_profile: ansible_node_profile - interface_profile: ansible_interface_profile - pod_id: 1 - node_id: 201-202 - path_ep: ansible_vpc_ipg - interface_type: ext-svi - mode: native - addr: 192.168.90.1/27 - encap: vlan-913 - state: present + cisco.aci.aci_l3out_interface: + <<: *ext_svi_interface register: add_l3out_vpc_interface_again + - name: Change encap_scope on interface vPC + cisco.aci.aci_l3out_interface: + <<: *ext_svi_interface + encap_scope: vrf + state: present + register: change_l3out_vpc_interface_encap_scope + - name: Verify vPC interface is not changed - assert: + ansible.builtin.assert: that: - add_l3out_vpc_interface_again is not changed + - change_l3out_vpc_interface_encap_scope.previous.0.l3extRsPathL3OutAtt.attributes.encapScope == "local" + - change_l3out_vpc_interface_encap_scope.current.0.l3extRsPathL3OutAtt.attributes.encapScope == "ctx" # MODIFY vPC interface - name: Update interface vPC - aci_l3out_interface: + cisco.aci.aci_l3out_interface: <<: *aci_info tenant: ansible_tenant l3out: ansible_l3out @@ -455,7 +458,7 @@ register: modify_l3out_vpc_interface - name: Verify l3out vPC has been updated with the correct attributes - assert: + ansible.builtin.assert: that: - modify_l3out_vpc_interface is changed - modify_l3out_vpc_interface.current.0.l3extRsPathL3OutAtt.attributes.dn == "uni/tn-ansible_tenant/out-ansible_l3out/lnodep-ansible_node_profile/lifp-ansible_interface_profile/rspathL3OutAtt-[topology/pod-1/protpaths-201-202/pathep-[ansible_vpc_ipg]]" @@ -466,7 +469,7 @@ # QUERY vPC interface - name: Query vPC interface - aci_l3out_interface: + cisco.aci.aci_l3out_interface: <<: *aci_info tenant: ansible_tenant l3out: ansible_l3out @@ -479,7 +482,7 @@ register: query_l3out_vpc_interface - name: Verify l3out vPC query - assert: + ansible.builtin.assert: that: - query_l3out_vpc_interface is not changed - query_l3out_vpc_interface.current.0.l3extRsPathL3OutAtt.attributes.dn == "uni/tn-ansible_tenant/out-ansible_l3out/lnodep-ansible_node_profile/lifp-ansible_interface_profile/rspathL3OutAtt-[topology/pod-1/protpaths-201-202/pathep-[ansible_vpc_ipg]]" @@ -489,7 +492,7 @@ - query_l3out_vpc_interface.current.0.l3extRsPathL3OutAtt.attributes.mode == "regular" - name: Delete vPC interface - aci_l3out_interface: + cisco.aci.aci_l3out_interface: <<: *aci_info tenant: ansible_tenant l3out: ansible_l3out @@ -502,33 +505,264 @@ register: delete_l3out_vpc_interface - name: Verify vPC interface is deleted - assert: + ansible.builtin.assert: that: - delete_l3out_vpc_interface.current == [] + - name: Execute tasks only for APIC version 5.x and above + when: + - version.current.0.topSystem.attributes.version is version('5', '>=') # This condition will execute only for APIC version 5.x and above + block: + + - name: Ensure infra SR-MPLS l3out does not exist + cisco.aci.aci_l3out: &aci_infra_sr_mpls_l3out_absent + <<: *aci_info + tenant: infra + name: ansible_infra_sr_mpls_l3out + domain: ansible_dom + vrf: overlay-1 + mpls: "yes" + l3protocol: bgp + state: absent + + - name: Add a infra SR-MPLS l3out + cisco.aci.aci_l3out: + <<: *aci_infra_sr_mpls_l3out_absent + state: present + + - name: Add a node profile in the infra SR-MPLS l3out + cisco.aci.aci_l3out_logical_node_profile: &aci_infra_node_profile + <<: *aci_info + tenant: infra + l3out: ansible_infra_sr_mpls_l3out + node_profile: ansible_infra_sr_mpls_l3out_node_profile + + - name: Add interface profile in the infra SR-MPLS l3out node profile + cisco.aci.aci_l3out_logical_interface_profile: &aci_infra_interface_profile + <<: *aci_infra_node_profile + interface_profile: ansible_infra_sr_mpls_l3out_interface_profile + + - name: Add direct port channel interface in the infra SR-MPLS l3out interface profile (check_mode) + aci_l3out_interface: &aci_infra_pc_interface + <<: *aci_infra_interface_profile + pod_id: 1 + node_id: 101 + path_ep: pc_ansible_test + interface_type: l3-port + addr: 192.168.90.1/24 + state: present + register: cm_add_infra_sr_mpls_l3out_port_channel_interface + check_mode: true + + - name: Add direct port channel interface in the infra SR-MPLS l3out interface profile + aci_l3out_interface: + <<: *aci_infra_pc_interface + register: nm_add_infra_sr_mpls_l3out_port_channel_interface + + - name: Add direct port channel interface in the infra SR-MPLS l3out interface profile again + aci_l3out_interface: + <<: *aci_infra_pc_interface + register: nm_add_infra_sr_mpls_l3out_port_channel_interface_again + + - name: Add interface in the infra SR-MPLS l3out interface profile + aci_l3out_interface: &aci_infra_interface + <<: *aci_infra_interface_profile + pod_id: 1 + node_id: 101 + path_ep: eth1/17 + interface_type: l3-port + addr: 192.168.91.1/24 + state: present + register: nm_add_infra_sr_mpls_l3out_interface + + - name: Add sub interface in the infra SR-MPLS l3out interface profile + aci_l3out_interface: &aci_infra_sub_interface + <<: *aci_infra_interface_profile + pod_id: 1 + node_id: 101 + path_ep: eth1/18 + interface_type: sub-interface + addr: 192.168.92.1/24 + state: present + register: nm_add_infra_sr_mpls_l3out_sub_interface + + - name: Verify interfaces in the infra SR-MPLS l3out interface profile + assert: + that: + - cm_add_infra_sr_mpls_l3out_port_channel_interface is changed + - cm_add_infra_sr_mpls_l3out_port_channel_interface.previous == [] + - cm_add_infra_sr_mpls_l3out_port_channel_interface.proposed.l3extRsPathL3OutAtt.attributes.annotation == "orchestrator:ansible" + - cm_add_infra_sr_mpls_l3out_port_channel_interface.proposed.l3extRsPathL3OutAtt.attributes.addr == "192.168.90.1/24" + - cm_add_infra_sr_mpls_l3out_port_channel_interface.proposed.l3extRsPathL3OutAtt.attributes.ifInstT == "l3-port" + - cm_add_infra_sr_mpls_l3out_port_channel_interface.proposed.l3extRsPathL3OutAtt.attributes.tDn == "topology/pod-1/paths-101/pathep-[pc_ansible_test]" + - nm_add_infra_sr_mpls_l3out_port_channel_interface is changed + - nm_add_infra_sr_mpls_l3out_port_channel_interface.previous == [] + - nm_add_infra_sr_mpls_l3out_port_channel_interface.current.0.l3extRsPathL3OutAtt.attributes.annotation == "orchestrator:ansible" + - nm_add_infra_sr_mpls_l3out_port_channel_interface.current.0.l3extRsPathL3OutAtt.attributes.addr == "192.168.90.1/24" + - nm_add_infra_sr_mpls_l3out_port_channel_interface.current.0.l3extRsPathL3OutAtt.attributes.ifInstT == "l3-port" + - nm_add_infra_sr_mpls_l3out_port_channel_interface.current.0.l3extRsPathL3OutAtt.attributes.tDn == "topology/pod-1/paths-101/pathep-[pc_ansible_test]" + - nm_add_infra_sr_mpls_l3out_port_channel_interface_again is not changed + - nm_add_infra_sr_mpls_l3out_port_channel_interface_again.previous.0.l3extRsPathL3OutAtt.attributes.annotation == "orchestrator:ansible" + - nm_add_infra_sr_mpls_l3out_port_channel_interface_again.previous.0.l3extRsPathL3OutAtt.attributes.addr == "192.168.90.1/24" + - nm_add_infra_sr_mpls_l3out_port_channel_interface_again.previous.0.l3extRsPathL3OutAtt.attributes.ifInstT == "l3-port" + - nm_add_infra_sr_mpls_l3out_port_channel_interface_again.previous.0.l3extRsPathL3OutAtt.attributes.tDn == "topology/pod-1/paths-101/pathep-[pc_ansible_test]" + - nm_add_infra_sr_mpls_l3out_port_channel_interface_again.current.0.l3extRsPathL3OutAtt.attributes.annotation == "orchestrator:ansible" + - nm_add_infra_sr_mpls_l3out_port_channel_interface_again.current.0.l3extRsPathL3OutAtt.attributes.addr == "192.168.90.1/24" + - nm_add_infra_sr_mpls_l3out_port_channel_interface_again.current.0.l3extRsPathL3OutAtt.attributes.ifInstT == "l3-port" + - nm_add_infra_sr_mpls_l3out_port_channel_interface_again.current.0.l3extRsPathL3OutAtt.attributes.tDn == "topology/pod-1/paths-101/pathep-[pc_ansible_test]" + - nm_add_infra_sr_mpls_l3out_interface is changed + - nm_add_infra_sr_mpls_l3out_interface.previous == [] + - nm_add_infra_sr_mpls_l3out_interface.current.0.l3extRsPathL3OutAtt.attributes.annotation == "orchestrator:ansible" + - nm_add_infra_sr_mpls_l3out_interface.current.0.l3extRsPathL3OutAtt.attributes.addr == "192.168.91.1/24" + - nm_add_infra_sr_mpls_l3out_interface.current.0.l3extRsPathL3OutAtt.attributes.ifInstT == "l3-port" + - nm_add_infra_sr_mpls_l3out_interface.current.0.l3extRsPathL3OutAtt.attributes.tDn == "topology/pod-1/paths-101/pathep-[eth1/17]" + - nm_add_infra_sr_mpls_l3out_sub_interface is changed + - nm_add_infra_sr_mpls_l3out_sub_interface.previous == [] + - nm_add_infra_sr_mpls_l3out_sub_interface.current.0.l3extRsPathL3OutAtt.attributes.annotation == "orchestrator:ansible" + - nm_add_infra_sr_mpls_l3out_sub_interface.current.0.l3extRsPathL3OutAtt.attributes.addr == "192.168.92.1/24" + - nm_add_infra_sr_mpls_l3out_sub_interface.current.0.l3extRsPathL3OutAtt.attributes.ifInstT == "sub-interface" + - nm_add_infra_sr_mpls_l3out_sub_interface.current.0.l3extRsPathL3OutAtt.attributes.tDn == "topology/pod-1/paths-101/pathep-[eth1/18]" + + - name: Enable micro BFD on direct port channel interface in the infra SR-MPLS l3out interface profile without destination (error) + aci_l3out_interface: + <<: *aci_infra_pc_interface + micro_bfd: true + register: err_micro_bfd_not_provided_destination + ignore_errors: true + + - name: Enable micro BFD on direct port channel interface in the infra SR-MPLS l3out interface profile timer without micro BFD (error) + aci_l3out_interface: + <<: *aci_infra_pc_interface + micro_bfd_timer: 75 + register: err_micro_bfd_timer_not_provided_micro_bfd + ignore_errors: true + + - name: Enable micro BFD on direct port channel interface in the infra SR-MPLS l3out interface profile destination without micro BFD (error) + aci_l3out_interface: + <<: *aci_infra_pc_interface + micro_bfd_destination: true + register: err_micro_bfd_destination_not_provided_micro_bfd + ignore_errors: true + + - name: Verify micro BFD errors + assert: + that: + - err_micro_bfd_not_provided_destination is failed + - err_micro_bfd_not_provided_destination.msg == "micro_bfd is True but all of the following are missing{{":"}} micro_bfd_destination" + - err_micro_bfd_timer_not_provided_micro_bfd is failed + - err_micro_bfd_timer_not_provided_micro_bfd.msg == "missing parameter(s) required by 'micro_bfd_timer'{{":"}} micro_bfd" + - err_micro_bfd_destination_not_provided_micro_bfd is failed + - err_micro_bfd_destination_not_provided_micro_bfd.msg == "missing parameter(s) required by 'micro_bfd_destination'{{":"}} micro_bfd" + + - name: Enable micro BFD on direct port channel interface in the infra SR-MPLS l3out interface (check_mode) + aci_l3out_interface: &enable_bfd + <<: *aci_infra_pc_interface + micro_bfd: true + micro_bfd_destination: 192.168.90.2 + register: cm_enable_micro_bfd + check_mode: true + + - name: Enable micro BFD on direct port channel interface in the infra SR-MPLS l3out interface + aci_l3out_interface: + <<: *enable_bfd + register: nm_enable_micro_bfd + + - name: Change timer for micro on direct port channel interface in the infra SR-MPLS l3out interface + aci_l3out_interface: + <<: *enable_bfd + micro_bfd_timer: 75 + register: nm_change_micro_bfd_timer + + - name: Diable micro BFD on direct port channel interface in the infra SR-MPLS l3out interface + aci_l3out_interface: + <<: *enable_bfd + micro_bfd: false + register: nm_disable_micro_bfd + + - name: Verify micro BFD configuration on direct port channel interface in the infra SR-MPLS l3out interface + assert: + that: + - cm_enable_micro_bfd is changed + - cm_enable_micro_bfd.previous.0.l3extRsPathL3OutAtt.children is undefined + - cm_enable_micro_bfd.proposed.l3extRsPathL3OutAtt.children.0.bfdMicroBfdP.attributes.adminState == "yes" + - cm_enable_micro_bfd.proposed.l3extRsPathL3OutAtt.children.0.bfdMicroBfdP.attributes.dst == "192.168.90.2" + - nm_enable_micro_bfd is changed + - nm_enable_micro_bfd.previous.0.l3extRsPathL3OutAtt.children is undefined + - nm_enable_micro_bfd.current.0.l3extRsPathL3OutAtt.children.0.bfdMicroBfdP.attributes.adminState == "yes" + - nm_enable_micro_bfd.current.0.l3extRsPathL3OutAtt.children.0.bfdMicroBfdP.attributes.dst == "192.168.90.2" + - nm_enable_micro_bfd.current.0.l3extRsPathL3OutAtt.children.0.bfdMicroBfdP.attributes.stTm == "0" + - nm_change_micro_bfd_timer is changed + - nm_change_micro_bfd_timer.previous.0.l3extRsPathL3OutAtt.children.0.bfdMicroBfdP.attributes.adminState == "yes" + - nm_change_micro_bfd_timer.previous.0.l3extRsPathL3OutAtt.children.0.bfdMicroBfdP.attributes.dst == "192.168.90.2" + - nm_change_micro_bfd_timer.previous.0.l3extRsPathL3OutAtt.children.0.bfdMicroBfdP.attributes.stTm == "0" + - nm_change_micro_bfd_timer.current.0.l3extRsPathL3OutAtt.children.0.bfdMicroBfdP.attributes.adminState == "yes" + - nm_change_micro_bfd_timer.current.0.l3extRsPathL3OutAtt.children.0.bfdMicroBfdP.attributes.dst == "192.168.90.2" + - nm_change_micro_bfd_timer.current.0.l3extRsPathL3OutAtt.children.0.bfdMicroBfdP.attributes.stTm == "75" + - nm_disable_micro_bfd is changed + - nm_disable_micro_bfd.previous.0.l3extRsPathL3OutAtt.children.0.bfdMicroBfdP.attributes.adminState == "yes" + - nm_disable_micro_bfd.previous.0.l3extRsPathL3OutAtt.children.0.bfdMicroBfdP.attributes.dst == "192.168.90.2" + - nm_disable_micro_bfd.previous.0.l3extRsPathL3OutAtt.children.0.bfdMicroBfdP.attributes.stTm == "75" + - nm_disable_micro_bfd.current.0.l3extRsPathL3OutAtt.children.0.bfdMicroBfdP.attributes.adminState == "no" + - nm_disable_micro_bfd.current.0.l3extRsPathL3OutAtt.children.0.bfdMicroBfdP.attributes.dst == "192.168.90.2" + - nm_disable_micro_bfd.current.0.l3extRsPathL3OutAtt.children.0.bfdMicroBfdP.attributes.stTm == "75" + + - name: Delete direct port channel interface in the infra SR-MPLS l3out interface profile again (check_mode) + aci_l3out_interface: &aci_infra_pc_interface_absent + <<: *aci_infra_pc_interface + state: absent + register: cm_delete_infra_sr_mpls_l3out_port_channel_interface + check_mode: true + + - name: Delete direct port channel interface in the infra SR-MPLS l3out interface profile + aci_l3out_interface: + <<: *aci_infra_pc_interface_absent + register: nm_delete_infra_sr_mpls_l3out_port_channel_interface + + - name: Delete direct port channel interface in the infra SR-MPLS l3out interface profile again + aci_l3out_interface: + <<: *aci_infra_pc_interface_absent + register: nm_delete_infra_sr_mpls_l3out_port_channel_interface_again + + - name: Verify deletion of port channel interfaces in the infra SR-MPLS l3out interface profile + assert: + that: + - cm_delete_infra_sr_mpls_l3out_port_channel_interface is changed + - cm_delete_infra_sr_mpls_l3out_port_channel_interface.previous != [] + - cm_delete_infra_sr_mpls_l3out_port_channel_interface.proposed == {} + - nm_delete_infra_sr_mpls_l3out_port_channel_interface is changed + - nm_delete_infra_sr_mpls_l3out_port_channel_interface.previous != [] + - nm_delete_infra_sr_mpls_l3out_port_channel_interface.current == [] + - nm_delete_infra_sr_mpls_l3out_port_channel_interface_again is not changed + - nm_delete_infra_sr_mpls_l3out_port_channel_interface_again.previous == [] + - nm_delete_infra_sr_mpls_l3out_port_channel_interface_again.current == [] + + - name: Remove a infra SR-MPLS l3out + cisco.aci.aci_l3out: + <<: *aci_infra_sr_mpls_l3out_absent + # CLEAN UP - name: Remove ansible_tenant - aci_tenant: + cisco.aci.aci_tenant: <<: *aci_info tenant: ansible_tenant state: absent - name: Remove ansible_l3ext_domain - aci_domain: + cisco.aci.aci_domain: <<: *aci_info domain: ansible_l3ext_domain domain_type: l3dom state: absent - name: Remove ansible_port_channel_ipg - aci_interface_policy_leaf_policy_group: + cisco.aci.aci_interface_policy_leaf_policy_group: <<: *aci_info lag_type: link policy_group: ansible_port_channel_ipg state: absent - name: Remove ansible_vpc_ipg - aci_interface_policy_leaf_policy_group: + cisco.aci.aci_interface_policy_leaf_policy_group: <<: *aci_info lag_type: node policy_group: ansible_vpc_ipg diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_l3out_interface_secondary_ip/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_l3out_interface_secondary_ip/tasks/main.yml index 775d40ee8..df49658be 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_l3out_interface_secondary_ip/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_l3out_interface_secondary_ip/tasks/main.yml @@ -4,13 +4,13 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined # GET Credentials from the inventory - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: "{{ aci_hostname }}" username: "{{ aci_username }}" @@ -22,26 +22,26 @@ # CLEAN ENVIRONMENT - name: Remove test tenant if it already exists - aci_tenant: + cisco.aci.aci_tenant: <<: *aci_info tenant: ansible_test state: absent - name: Verify Cloud and Non-Cloud Sites in use. - include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml - name: Execute tasks only for non-cloud sites when: query_cloud.current == [] # This condition will execute only non-cloud sites block: # block specifies execution of tasks within, based on conditions - name: Remove port-channel IPG - aci_interface_policy_leaf_policy_group: + cisco.aci.aci_interface_policy_leaf_policy_group: <<: *aci_info lag_type: link policy_group: ansible_port_channel_ipg state: absent - name: Remove vPC IPG - aci_interface_policy_leaf_policy_group: + cisco.aci.aci_interface_policy_leaf_policy_group: <<: *aci_info lag_type: node policy_group: ansible_vpc_ipg @@ -49,7 +49,7 @@ # ADD PC IPG - name: Add port-channel IPG - aci_interface_policy_leaf_policy_group: + cisco.aci.aci_interface_policy_leaf_policy_group: <<: *aci_info lag_type: link policy_group: ansible_port_channel_ipg @@ -57,7 +57,7 @@ # ADD vPC IPG - name: Add vPC IPG - aci_interface_policy_leaf_policy_group: + cisco.aci.aci_interface_policy_leaf_policy_group: <<: *aci_info lag_type: node policy_group: ansible_vpc_ipg @@ -65,7 +65,7 @@ # ADD domain - name: Add domain for l3out - aci_domain: + cisco.aci.aci_domain: <<: *aci_info domain: ansible_l3ext_domain domain_type: l3dom @@ -73,7 +73,7 @@ # ADD tenant - name: Add a new tenant required for l3out - aci_tenant: + cisco.aci.aci_tenant: <<: *aci_info tenant: ansible_test description: Ansible tenant @@ -81,7 +81,7 @@ # ADD VRF - name: Add VRF for l3out - aci_vrf: + cisco.aci.aci_vrf: <<: *aci_info tenant: ansible_test vrf: ansible_vrf @@ -89,7 +89,7 @@ # ADD l3out - name: Add l3out - aci_l3out: + cisco.aci.aci_l3out: <<: *aci_info tenant: ansible_test name: ansible_l3out @@ -100,7 +100,7 @@ # ADD l3out logical node profile - name: l3out logical node profile - aci_l3out_logical_node_profile: + cisco.aci.aci_l3out_logical_node_profile: <<: *aci_info tenant: ansible_test l3out: ansible_l3out @@ -109,7 +109,7 @@ # ADD l3out logical interface profile - name: l3out logical interface profile - aci_l3out_logical_interface_profile: + cisco.aci.aci_l3out_logical_interface_profile: <<: *aci_info tenant: ansible_test l3out: ansible_l3out @@ -119,7 +119,7 @@ # ADD l3out routed interface - name: Add routed interface - aci_l3out_interface: + cisco.aci.aci_l3out_interface: <<: *aci_info tenant: ansible_test l3out: ansible_l3out @@ -135,7 +135,7 @@ # ADD l3out routed interface po - name: Add routed interface port-channel - aci_l3out_interface: + cisco.aci.aci_l3out_interface: <<: *aci_info tenant: ansible_test l3out: ansible_l3out @@ -151,7 +151,7 @@ # ADD l3out routed interface vPC - name: Add routed interface vPC - aci_l3out_interface: + cisco.aci.aci_l3out_interface: <<: *aci_info tenant: ansible_test l3out: ansible_l3out @@ -167,7 +167,7 @@ # ADD l3out routed interface vPC member - name: Add routed interface vPC member - aci_l3out_logical_interface_vpc_member: + cisco.aci.aci_l3out_logical_interface_vpc_member: <<: *aci_info tenant: ansible_test l3out: ansible_l3out @@ -182,7 +182,7 @@ # ADD secondary IPs to the interfaces - name: Add secondary IP to routed interface - aci_l3out_interface_secondary_ip: + cisco.aci.aci_l3out_interface_secondary_ip: <<: *aci_info tenant: ansible_test l3out: ansible_l3out @@ -197,7 +197,7 @@ register: secondary_intf - name: Add secondary to IP routed interface port-channel - aci_l3out_interface_secondary_ip: + cisco.aci.aci_l3out_interface_secondary_ip: <<: *aci_info tenant: ansible_test l3out: ansible_l3out @@ -212,7 +212,7 @@ register: secondary_po - name: Add secondary IP to routed interface vPC - aci_l3out_interface_secondary_ip: + cisco.aci.aci_l3out_interface_secondary_ip: <<: *aci_info tenant: ansible_test l3out: ansible_l3out @@ -228,7 +228,7 @@ register: secondary_vpc - name: Verify secondaries have been created with the correct attributes - assert: + ansible.builtin.assert: that: - secondary_intf.current.0.l3extIp.attributes.dn == "uni/tn-ansible_test/out-ansible_l3out/lnodep-ansible_node_profile/lifp-ansible_interface_profile/rspathL3OutAtt-[topology/pod-1/paths-201/pathep-[eth1/15]]/addr-[192.168.50.2/27]" - secondary_intf.current.0.l3extIp.attributes.ipv6Dad == "disabled" @@ -240,7 +240,7 @@ # CHECK idempotency - name: Add secondary IP to routed interface with no changes - aci_l3out_interface_secondary_ip: + cisco.aci.aci_l3out_interface_secondary_ip: <<: *aci_info tenant: ansible_test l3out: ansible_l3out @@ -255,7 +255,7 @@ register: secondary_intf_again - name: Add secondary to IP routed interface port-channel with no changes - aci_l3out_interface_secondary_ip: + cisco.aci.aci_l3out_interface_secondary_ip: <<: *aci_info tenant: ansible_test l3out: ansible_l3out @@ -270,7 +270,7 @@ register: secondary_po_again - name: Add secondary IP to routed interface vPC with no changes - aci_l3out_interface_secondary_ip: + cisco.aci.aci_l3out_interface_secondary_ip: <<: *aci_info tenant: ansible_test l3out: ansible_l3out @@ -286,7 +286,7 @@ register: secondary_vpc_again - name: Verify MOs have not changed - assert: + ansible.builtin.assert: that: - secondary_intf_again is not changed - secondary_po_again is not changed @@ -294,7 +294,7 @@ # CHECK updates/modifications - name: Modify routed interface - aci_l3out_interface_secondary_ip: + cisco.aci.aci_l3out_interface_secondary_ip: <<: *aci_info tenant: ansible_test l3out: ansible_l3out @@ -309,7 +309,7 @@ register: secondary_intf_update - name: Modify routed port-channel - aci_l3out_interface_secondary_ip: + cisco.aci.aci_l3out_interface_secondary_ip: <<: *aci_info tenant: ansible_test l3out: ansible_l3out @@ -324,7 +324,7 @@ register: secondary_po_update - name: Modify routed vPC - aci_l3out_interface_secondary_ip: + cisco.aci.aci_l3out_interface_secondary_ip: <<: *aci_info tenant: ansible_test l3out: ansible_l3out @@ -340,7 +340,7 @@ register: secondary_vpc_update - name: Verify updates have been applied - assert: + ansible.builtin.assert: that: - secondary_intf_update is changed - secondary_po_update is changed @@ -351,7 +351,7 @@ # QUERIES - name: Query secondary for interface - aci_l3out_interface_secondary_ip: + cisco.aci.aci_l3out_interface_secondary_ip: <<: *aci_info tenant: ansible_test l3out: ansible_l3out @@ -366,7 +366,7 @@ register: secondary_intf_query - name: Query secondary for po - aci_l3out_interface_secondary_ip: + cisco.aci.aci_l3out_interface_secondary_ip: <<: *aci_info tenant: ansible_test l3out: ansible_l3out @@ -381,7 +381,7 @@ register: secondary_po_query - name: Query secondary for vpc - aci_l3out_interface_secondary_ip: + cisco.aci.aci_l3out_interface_secondary_ip: <<: *aci_info tenant: ansible_test l3out: ansible_l3out @@ -397,13 +397,13 @@ register: secondary_vpc_query - name: Query all secondary IPs - aci_l3out_interface_secondary_ip: + cisco.aci.aci_l3out_interface_secondary_ip: <<: *aci_info state: query register: secondary_all_query - name: Verify queries - assert: + ansible.builtin.assert: that: - secondary_intf_query is not changed - secondary_po_query is not changed @@ -418,7 +418,7 @@ # DELETE secondary IPs - name: Delete secondary for interface - aci_l3out_interface_secondary_ip: + cisco.aci.aci_l3out_interface_secondary_ip: <<: *aci_info tenant: ansible_test l3out: ansible_l3out @@ -433,7 +433,7 @@ register: secondary_intf_remove - name: Delete secondary for po - aci_l3out_interface_secondary_ip: + cisco.aci.aci_l3out_interface_secondary_ip: <<: *aci_info tenant: ansible_test l3out: ansible_l3out @@ -448,7 +448,7 @@ register: secondary_po_remove - name: Delete secondary for vpc - aci_l3out_interface_secondary_ip: + cisco.aci.aci_l3out_interface_secondary_ip: <<: *aci_info tenant: ansible_test l3out: ansible_l3out @@ -464,7 +464,7 @@ register: secondary_vpc_remove - name: Verify objects have been deleted - assert: + ansible.builtin.assert: that: - secondary_intf_remove.current == [] - secondary_po_remove.current == [] @@ -475,27 +475,27 @@ # CLEAN UP - name: Remove tenant - aci_tenant: + cisco.aci.aci_tenant: <<: *aci_info tenant: ansible_test state: absent - name: Remove ext domain - aci_domain: + cisco.aci.aci_domain: <<: *aci_info domain: ansible_l3ext_domain domain_type: l3dom state: absent - name: Remove port-channel - aci_interface_policy_leaf_policy_group: + cisco.aci.aci_interface_policy_leaf_policy_group: <<: *aci_info lag_type: link policy_group: ansible_port_channel_ipg state: absent - name: Remove vpc - aci_interface_policy_leaf_policy_group: + cisco.aci.aci_interface_policy_leaf_policy_group: <<: *aci_info lag_type: node policy_group: ansible_vpc_ipg diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_l3out_logical_interface_profile/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_l3out_logical_interface_profile/tasks/main.yml index b3ad827f1..506690c70 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_l3out_logical_interface_profile/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_l3out_logical_interface_profile/tasks/main.yml @@ -1,9 +1,12 @@ +# Test code for the ACI modules # Author: Marcel Zehnder (@maercu) +# Copyright: (c) 2024, Gaspard Micol (@gmicol) <gmicol@cisco.com> + # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) # SET VARS - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: '{{ aci_hostname }}' username: '{{ aci_username }}' @@ -15,164 +18,287 @@ # CLEAN ENVIRONMENT - name: Remove test tenant before we kickoff - cisco.aci.aci_tenant: &tenant_absent + cisco.aci.aci_tenant: &aci_tenant_absent <<: *aci_info - tenant: ansible_test + tenant: ansible_tenant state: absent - name: Verify Cloud and Non-Cloud Sites in use. - include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml - name: Execute tasks only for non-cloud sites when: query_cloud.current == [] # This condition will execute only non-cloud sites block: # block specifies execution of tasks within, based on conditions # SETUP ENVIRONMENT - name: Create domain - cisco.aci.aci_domain: &domain_present + cisco.aci.aci_domain: &aci_domain_present <<: *aci_info - domain: l3outintftest + domain: ansible_dom domain_type: l3dom state: present - name: Create tenant - cisco.aci.aci_tenant: &tenant_present - <<: *tenant_absent + cisco.aci.aci_tenant: &aci_tenant_present + <<: *aci_tenant_absent state: present - name: Configure VRF - cisco.aci.aci_vrf: &vrf_present - <<: *tenant_present - vrf: l3outintftest + cisco.aci.aci_vrf: &aci_vrf_present + <<: *aci_tenant_present + vrf: ansible_vrf + state: present - name: Create L3Out cisco.aci.aci_l3out: - <<: *vrf_present - l3out: l3outintftest - domain: l3outintftest - route_control: export + <<: *aci_vrf_present + l3out: ansible_l3out + domain: ansible_dom + state: present - name: Crete node profile - cisco.aci.aci_l3out_logical_node_profile: &np_present - <<: *tenant_present - l3out: l3outintftest - node_profile: NODES - - # BEGIN WITH TESTS (ADD PROFILE) - - name: Add interface profile (check_mode) - cisco.aci.aci_l3out_logical_interface_profile: &intf_present - <<: *np_present - interface_profile: INTFS - description: test + cisco.aci.aci_l3out_logical_node_profile: &aci_np_present + <<: *aci_tenant_present + l3out: ansible_l3out + node_profile: ansible_node_profile + state: present + +# CREATE Logical Interface Profile + - name: Add a Logical Interface Profile (check_mode) + cisco.aci.aci_l3out_logical_interface_profile: &aci_l3out_logical_interface_profile_present + <<: *aci_np_present + interface_profile: ansible_interface_profile_1 + description: Logical Interface Profile 1 for ansible_node_profile + nd_policy: default + egress_dpp_policy: default + ingress_dpp_policy: default + qos_priority: level1 + qos_custom_policy: default + pim_v4_interface_profile: + tenant: common + pim: default + pim_v6_interface_profile: + tenant: common + pim: default + igmp_interface_profile: + tenant: common + igmp: default + state: present check_mode: true - register: cm_add_intf + register: cm_add_interface_profile - - name: Add interface profile (normal_mode) + - name: Add a Logical Interface Profile (normal_mode) cisco.aci.aci_l3out_logical_interface_profile: - <<: *intf_present - register: nm_add_intf + <<: *aci_l3out_logical_interface_profile_present + register: nm_add_interface_profile - - name: Verify nm_add_intf - assert: - that: - - cm_add_intf is changed - - nm_add_intf is changed - - cm_add_intf.previous == nm_add_intf.previous == [] - - cm_add_intf.sent.l3extLIfP.attributes.name == nm_add_intf.sent.l3extLIfP.attributes.name == 'INTFS' - - cm_add_intf.sent.l3extLIfP.attributes.descr == nm_add_intf.sent.l3extLIfP.attributes.descr == 'test' - - nm_add_intf.current.0.l3extLIfP.attributes.annotation == 'orchestrator:ansible' - - - name: Add profile again, check if idempotency works + - name: Add the first Logical Interface Profile again - testing idempotency cisco.aci.aci_l3out_logical_interface_profile: - <<: *intf_present - register: add_intf_again + <<: *aci_l3out_logical_interface_profile_present + register: nm_add_interface_profile_idempotency - - name: Verify add_intf_again - assert: - that: - - add_intf_again is not changed - - # UPDATE INTERFACE PROFILE - - name: Update profile - cisco.aci.aci_l3out_logical_interface_profile: &intf_update - <<: *intf_present - nd_policy: NDTEST - description: new test - register: update_intf - - - name: Verify update_intf - assert: + - name: Add a second Logical Interface Profile (normal_mode) + cisco.aci.aci_l3out_logical_interface_profile: &aci_l3out_logical_interface_profile_2_present + <<: *aci_np_present + interface_profile: ansible_interface_profile_2 + description: Logical Interface Profile 2 for ansible_node_profile + state: present + register: nm_add_interface_profile_2 + + - name: Asserts for Logical Interface Profile creation tasks + ansible.builtin.assert: that: - - update_intf.sent.l3extLIfP.attributes.descr == 'new test' - - update_intf is changed - - update_intf.previous != [] + - cm_add_interface_profile is changed + - cm_add_interface_profile.previous == [] + - cm_add_interface_profile.current == [] + - cm_add_interface_profile.proposed.l3extLIfP.attributes.name == "ansible_interface_profile_1" + - cm_add_interface_profile.proposed.l3extLIfP.attributes.prio == "level1" + - nm_add_interface_profile.proposed.l3extLIfP.children.0.l3extRsNdIfPol.attributes.tnNdIfPolName == "default" + - nm_add_interface_profile.proposed.l3extLIfP.children.1.l3extRsIngressQosDppPol.attributes.tnQosDppPolName == "default" + - nm_add_interface_profile.proposed.l3extLIfP.children.2.l3extRsEgressQosDppPol.attributes.tnQosDppPolName == "default" + - nm_add_interface_profile.proposed.l3extLIfP.children.3.l3extRsLIfPCustQosPol.attributes.tnQosCustomPolName == "default" + - nm_add_interface_profile.proposed.l3extLIfP.children.4.pimIPV6IfP.children.0.pimRsV6IfPol.attributes.tDn == "uni/tn-common/pimifpol-default" + - nm_add_interface_profile.proposed.l3extLIfP.children.5.pimIfP.children.0.pimRsIfPol.attributes.tDn == "uni/tn-common/pimifpol-default" + - nm_add_interface_profile.proposed.l3extLIfP.children.6.igmpIfP.children.0.igmpRsIfPol.attributes.tDn == "uni/tn-common/igmpIfPol-default" + - nm_add_interface_profile is changed + - nm_add_interface_profile.previous == [] + - nm_add_interface_profile.current.0.l3extLIfP.attributes.name == "ansible_interface_profile_1" + - nm_add_interface_profile.current.0.l3extLIfP.attributes.prio == "level1" + - nm_add_interface_profile.current.0.l3extLIfP.children.0.l3extRsLIfPCustQosPol.attributes.tnQosCustomPolName == "default" + - nm_add_interface_profile.current.0.l3extLIfP.children.1.igmpIfP.children.0.igmpRsIfPol.attributes.tDn == "uni/tn-common/igmpIfPol-default" + - nm_add_interface_profile.current.0.l3extLIfP.children.2.pimIfP.children.0.pimRsIfPol.attributes.tDn == "uni/tn-common/pimifpol-default" + - nm_add_interface_profile.current.0.l3extLIfP.children.3.pimIPV6IfP.children.0.pimRsV6IfPol.attributes.tDn == "uni/tn-common/pimifpol-default" + - nm_add_interface_profile.current.0.l3extLIfP.children.4.l3extRsEgressQosDppPol.attributes.tnQosDppPolName == "default" + - nm_add_interface_profile.current.0.l3extLIfP.children.5.l3extRsIngressQosDppPol.attributes.tnQosDppPolName == "default" + - nm_add_interface_profile.current.0.l3extLIfP.children.6.l3extRsNdIfPol.attributes.tnNdIfPolName == "default" + - nm_add_interface_profile_idempotency is not changed + - nm_add_interface_profile_idempotency.current.0.l3extLIfP.attributes.name == "ansible_interface_profile_1" + - nm_add_interface_profile_idempotency.current.0.l3extLIfP.attributes.prio == "level1" + - nm_add_interface_profile_idempotency.current.0.l3extLIfP.children.0.l3extRsLIfPCustQosPol.attributes.tnQosCustomPolName == "default" + - nm_add_interface_profile_idempotency.current.0.l3extLIfP.children.1.igmpIfP.children.0.igmpRsIfPol.attributes.tDn == "uni/tn-common/igmpIfPol-default" + - nm_add_interface_profile_idempotency.current.0.l3extLIfP.children.2.pimIfP.children.0.pimRsIfPol.attributes.tDn == "uni/tn-common/pimifpol-default" + - nm_add_interface_profile_idempotency.current.0.l3extLIfP.children.3.pimIPV6IfP.children.0.pimRsV6IfPol.attributes.tDn == "uni/tn-common/pimifpol-default" + - nm_add_interface_profile_idempotency.current.0.l3extLIfP.children.4.l3extRsEgressQosDppPol.attributes.tnQosDppPolName == "default" + - nm_add_interface_profile_idempotency.current.0.l3extLIfP.children.5.l3extRsIngressQosDppPol.attributes.tnQosDppPolName == "default" + - nm_add_interface_profile_idempotency.current.0.l3extLIfP.children.6.l3extRsNdIfPol.attributes.tnNdIfPolName == "default" + - nm_add_interface_profile_2 is changed + - nm_add_interface_profile_2.previous == [] + - nm_add_interface_profile_2.current.0.l3extLIfP.attributes.name == "ansible_interface_profile_2" + - nm_add_interface_profile_2.current.0.l3extLIfP.attributes.prio == "unspecified" - # ADD ANOTHER PROFILE - - name: Add another profile + # QUERY Logical Interface Profile + - name: Query all Logical Interface Profiles cisco.aci.aci_l3out_logical_interface_profile: - <<: *intf_present - interface_profile: INTF2 + <<: *aci_info + state: query + register: query_all_interface_profile - # QUERY ALL PROFILES - - name: Query all profiles + - name: Query ansible_interface_profile_1 cisco.aci.aci_l3out_logical_interface_profile: - <<: *aci_info + <<: *aci_l3out_logical_interface_profile_present state: query - register: query_all_profiles + register: query_ansible_interface_profile_1 - - name: Verify query_all_profiles - assert: + - name: Asserts query tasks + ansible.builtin.assert: that: - - query_all_profiles is not changed - - query_all_profiles.current|length >= 1 + - query_all_interface_profile is not changed + - query_all_interface_profile.current|length >= 2 + - query_ansible_interface_profile_1 is not changed + - query_ansible_interface_profile_1.current|length == 1 + - query_ansible_interface_profile_1.current.0.l3extLIfP.attributes.name == "ansible_interface_profile_1" + - query_ansible_interface_profile_1.current.0.l3extLIfP.attributes.prio == "level1" + - query_ansible_interface_profile_1.current.0.l3extLIfP.children.0.l3extRsLIfPCustQosPol.attributes.tDn == "uni/tn-common/qoscustom-default" + - query_ansible_interface_profile_1.current.0.l3extLIfP.children.1.igmpIfP.children.0.igmpRsIfPol.attributes.tDn == "uni/tn-common/igmpIfPol-default" + - query_ansible_interface_profile_1.current.0.l3extLIfP.children.2.pimIfP.children.0.pimRsIfPol.attributes.tDn == "uni/tn-common/pimifpol-default" + - query_ansible_interface_profile_1.current.0.l3extLIfP.children.3.pimIPV6IfP.children.0.pimRsV6IfPol.attributes.tDn == "uni/tn-common/pimifpol-default" + - query_ansible_interface_profile_1.current.0.l3extLIfP.children.4.l3extRsEgressQosDppPol.attributes.tDn == "uni/tn-common/qosdpppol-default" + - query_ansible_interface_profile_1.current.0.l3extLIfP.children.5.l3extRsIngressQosDppPol.attributes.tDn == "uni/tn-common/qosdpppol-default" + - query_ansible_interface_profile_1.current.0.l3extLIfP.children.6.l3extRsNdIfPol.attributes.tDn == "uni/tn-common/ndifpol-default" + + #REMOVE ASSOCIATED EPG/EXTERNAL EPG FROM NETFLOW EXPORTER POLICIES + - name: Remove all child classes from first Logical Interface Profile (check_mode) + cisco.aci.aci_l3out_logical_interface_profile: &aci_l3out_logical_interface_profile_remove_child_classes + <<: *aci_l3out_logical_interface_profile_present + nd_policy: "" + egress_dpp_policy: "" + ingress_dpp_policy: "" + qos_custom_policy: "" + pim_v4_interface_profile: {} + pim_v6_interface_profile: {} + igmp_interface_profile: {} + check_mode: true + register: cm_remove_child_classes_interface_profile - # QUERY A SPECIFIC PROFILE - - name: Query a specific profile + - name: Remove all child classes from first Logical Interface Profile (normal_mode) cisco.aci.aci_l3out_logical_interface_profile: - <<: *intf_update - state: query - register: query_spec_profile + <<: *aci_l3out_logical_interface_profile_remove_child_classes + register: nm_remove_child_classes_interface_profile + + - name: Remove all child classes from first Logical Interface Profile again - testing idempotency + cisco.aci.aci_l3out_logical_interface_profile: + <<: *aci_l3out_logical_interface_profile_remove_child_classes + register: nm_remove_child_classes_interface_profile_idempotency - - name: Verify query_spec_profile - assert: + - name: Asserts for child classes removal tasks + ansible.builtin.assert: that: - - query_spec_profile is not changed - - query_spec_profile.current|length == 1 + - cm_remove_child_classes_interface_profile is changed + - cm_remove_child_classes_interface_profile.current == cm_remove_child_classes_interface_profile.previous + - cm_remove_child_classes_interface_profile.proposed.l3extLIfP.children.0.l3extRsNdIfPol.attributes.tnNdIfPolName == "" + - cm_remove_child_classes_interface_profile.proposed.l3extLIfP.children.1.l3extRsIngressQosDppPol.attributes.tnQosDppPolName == "" + - cm_remove_child_classes_interface_profile.proposed.l3extLIfP.children.2.l3extRsEgressQosDppPol.attributes.tnQosDppPolName == "" + - cm_remove_child_classes_interface_profile.proposed.l3extLIfP.children.3.l3extRsLIfPCustQosPol.attributes.tnQosCustomPolName == "" + - cm_remove_child_classes_interface_profile.proposed.l3extLIfP.children.4.pimIPV6IfP.attributes.status == "deleted" + - cm_remove_child_classes_interface_profile.proposed.l3extLIfP.children.5.pimIfP.attributes.status == "deleted" + - cm_remove_child_classes_interface_profile.proposed.l3extLIfP.children.6.igmpIfP.attributes.status == "deleted" + - nm_remove_child_classes_interface_profile is changed + - nm_remove_child_classes_interface_profile.current.0.l3extLIfP.children.0.l3extRsLIfPCustQosPol.attributes.tnQosCustomPolName == "" + - nm_remove_child_classes_interface_profile.current.0.l3extLIfP.children.1.l3extRsEgressQosDppPol.attributes.tnQosDppPolName == "" + - nm_remove_child_classes_interface_profile.current.0.l3extLIfP.children.2.l3extRsIngressQosDppPol.attributes.tnQosDppPolName == "" + - nm_remove_child_classes_interface_profile.current.0.l3extLIfP.children.3.l3extRsNdIfPol.attributes.tnNdIfPolName == "" + - nm_remove_child_classes_interface_profile.proposed.l3extLIfP.children.4.pimIPV6IfP.attributes.status == "deleted" + - nm_remove_child_classes_interface_profile.proposed.l3extLIfP.children.5.pimIfP.attributes.status == "deleted" + - nm_remove_child_classes_interface_profile.proposed.l3extLIfP.children.6.igmpIfP.attributes.status == "deleted" + - nm_remove_child_classes_interface_profile.current.0.l3extLIfP.children|length == 4 + - nm_remove_child_classes_interface_profile_idempotency is not changed + - nm_remove_child_classes_interface_profile_idempotency.current.0.l3extLIfP.children.0.l3extRsLIfPCustQosPol.attributes.tnQosCustomPolName == "" + - nm_remove_child_classes_interface_profile_idempotency.current.0.l3extLIfP.children.1.l3extRsEgressQosDppPol.attributes.tnQosDppPolName == "" + - nm_remove_child_classes_interface_profile_idempotency.current.0.l3extLIfP.children.2.l3extRsIngressQosDppPol.attributes.tnQosDppPolName == "" + - nm_remove_child_classes_interface_profile_idempotency.current.0.l3extLIfP.children.3.l3extRsNdIfPol.attributes.tnNdIfPolName == "" + - nm_remove_child_classes_interface_profile_idempotency.current.0.l3extLIfP.children|length == 4 + + #UPDATE Logical Interface Profile + - name: Update first Logical Interface Profile (check_mode) + cisco.aci.aci_l3out_logical_interface_profile: &aci_l3out_logical_interface_profile_update + <<: *aci_l3out_logical_interface_profile_remove_child_classes + prio: level2 + description: Updated description for first ansible Logical Interface Profile + check_mode: true + register: cm_update_interface_profile - # QUERY A NON EXISTING PROFILE - - name: Query a nonexisting profile + - name: Update first Logical Interface Profile (normal_mode) cisco.aci.aci_l3out_logical_interface_profile: - <<: *np_present - interface_profile: nonexist - state: query - register: query_nonexist_profile + <<: *aci_l3out_logical_interface_profile_update + register: nm_update_interface_profile + + - name: Update first Logical Interface Profile again - testing idempotency + cisco.aci.aci_l3out_logical_interface_profile: + <<: *aci_l3out_logical_interface_profile_update + register: nm_udpate_interface_profile_idempotency - - name: Verify query_nonexist_profile - assert: + - name: Asserts for Logical Interface Profile update tasks + ansible.builtin.assert: that: - - query_nonexist_profile is not changed - - query_nonexist_profile.current == [] + - cm_update_interface_profile is changed + - cm_update_interface_profile.previous == cm_update_interface_profile.current + - cm_update_interface_profile.proposed.l3extLIfP.attributes.prio == "level2" + - cm_update_interface_profile.proposed.l3extLIfP.attributes.descr == "Updated description for first ansible Logical Interface Profile" + - nm_update_interface_profile is changed + - nm_update_interface_profile.current.0.l3extLIfP.attributes.prio == "level2" + - nm_update_interface_profile.current.0.l3extLIfP.attributes.descr == "Updated description for first ansible Logical Interface Profile" + - nm_udpate_interface_profile_idempotency is not changed + - nm_udpate_interface_profile_idempotency.current.0.l3extLIfP.attributes.prio == "level2" + - nm_udpate_interface_profile_idempotency.current.0.l3extLIfP.attributes.descr == "Updated description for first ansible Logical Interface Profile" - # REMOVE PROFILE - - name: Remove interface profile - cisco.aci.aci_l3out_logical_interface_profile: &intf_absent - <<: *intf_update + # DELETE Logical Interface Profile + - name: Remove Logical Interface Profile (check_mode) + cisco.aci.aci_l3out_logical_interface_profile: &interface_profile_absent + <<: *aci_l3out_logical_interface_profile_update state: absent - register: remove_profile + check_mode: true + register: cm_remove_interface_profile - - name: Verify remove_profile - assert: - that: - - remove_profile is changed - - remove_profile.current == [] + - name: Remove Logical Interface Profile (normal_mode) + cisco.aci.aci_l3out_logical_interface_profile: + <<: *interface_profile_absent + register: nm_remove_interface_profile - # REMOVE NONEXISTING PROFILE - - name: Remove interface profile again (nonexisting) + - name: Remove Logical Interface Profile - testing idempotency cisco.aci.aci_l3out_logical_interface_profile: - <<: *intf_absent - register: remove_nonexist_profile + <<: *interface_profile_absent + register: nm_remove_interface_profile_idempotency - - name: Verify remove_nonexist_profile - assert: + - name: Asserts deletion tasks + ansible.builtin.assert: that: - - remove_nonexist_profile is not changed - - remove_nonexist_profile.current == [] + - cm_remove_interface_profile is changed + - cm_remove_interface_profile.current == cm_remove_interface_profile.previous + - cm_remove_interface_profile.proposed == {} + - nm_remove_interface_profile is changed + - nm_remove_interface_profile.previous != [] + - nm_remove_interface_profile.proposed == {} + - nm_remove_interface_profile.current == [] + - nm_remove_interface_profile_idempotency is not changed + - nm_remove_interface_profile_idempotency.previous == [] + - nm_remove_interface_profile_idempotency.current == [] + + # CLEAN ENVIRONMENT BEFORE ENDING TESTS + - name: Remove the ansible_tenant - cleanup before ending tests + cisco.aci.aci_tenant: + <<: *aci_tenant_present + state: absent + + - name: Remove the ansible_dom - cleanup before ending tests + cisco.aci.aci_domain: + <<: *aci_domain_present + state: absent diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_l3out_logical_interface_profile_ospf_policy/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_l3out_logical_interface_profile_ospf_policy/tasks/main.yml index d10a88a7f..e98864604 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_l3out_logical_interface_profile_ospf_policy/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_l3out_logical_interface_profile_ospf_policy/tasks/main.yml @@ -3,7 +3,7 @@ # SET VARS - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: '{{ aci_hostname }}' username: '{{ aci_username }}' @@ -21,7 +21,7 @@ state: absent - name: Verify Cloud and Non-Cloud Sites in use. - include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml - name: Execute tasks only for non-cloud sites when: query_cloud.current == [] # This condition will execute only non-cloud sites @@ -75,7 +75,7 @@ register: nm_add_ospfIfP - name: Verify add_ospfIfP - assert: + ansible.builtin.assert: that: - cm_add_ospfIfP is changed - nm_add_ospfIfP is changed @@ -88,7 +88,7 @@ register: nm_add_ospfIfP_again - name: Verify add_ospfIfP_again - assert: + ansible.builtin.assert: that: - nm_add_ospfIfP_again is not changed @@ -101,7 +101,7 @@ register: update_ospfIfP - name: Verify update_ospfIfP - assert: + ansible.builtin.assert: that: - update_ospfIfP is changed - update_ospfIfP.previous != [] @@ -116,7 +116,7 @@ register: query_ospfIfP_profile - name: Verify query_ospfIfP_profile - assert: + ansible.builtin.assert: that: - query_ospfIfP_profile is not changed - query_ospfIfP_profile.current|length == 1 @@ -137,7 +137,7 @@ register: remove_profile_again - name: Verify remove_profile and remove_profile_again - assert: + ansible.builtin.assert: that: - remove_profile.previous|length == 1 - remove_profile.previous[0].ospfIfP.children[0].ospfRsIfPol.attributes.tnOspfIfPolName == 'default' @@ -154,7 +154,7 @@ register: query_nonexist_policy - name: Verify query_nonexist_policy - assert: + ansible.builtin.assert: that: - query_nonexist_policy is not changed - query_nonexist_policy.current == [] @@ -166,7 +166,7 @@ register: remove_nonexist_policy - name: Verify remove_nonexist_policy - assert: + ansible.builtin.assert: that: - remove_nonexist_policy is not changed - remove_nonexist_policy.current == [] diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_l3out_logical_interface_vpc_member/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_l3out_logical_interface_vpc_member/tasks/main.yml index 749d2137f..755e93bea 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_l3out_logical_interface_vpc_member/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_l3out_logical_interface_vpc_member/tasks/main.yml @@ -4,12 +4,12 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: "{{ aci_hostname }}" username: "{{ aci_username }}" @@ -21,26 +21,26 @@ # CLEAN ENVIRONMENT - name: Remove the ansible_tenant - aci_tenant: + cisco.aci.aci_tenant: <<: *aci_info tenant: ansible_tenant state: absent - name: Verify Cloud and Non-Cloud Sites in use. - include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml - name: Execute tasks only for non-cloud sites when: query_cloud.current == [] # This condition will execute only non-cloud sites block: # block specifies execution of tasks within, based on conditions - name: Add a new tenant - aci_tenant: + cisco.aci.aci_tenant: <<: *aci_info tenant: ansible_tenant description: Ansible tenant state: present - name: Add a new L3Out - aci_l3out: + cisco.aci.aci_l3out: <<: *aci_info tenant: ansible_tenant name: ansible_l3out @@ -69,7 +69,7 @@ state: present - name: Add two vPC-interfaces - aci_l3out_interface: + cisco.aci.aci_l3out_interface: <<: *aci_info tenant: ansible_tenant l3out: ansible_l3out @@ -85,7 +85,7 @@ - policy_group_two - name: Add a VPC member based on path_dn - aci_l3out_logical_interface_vpc_member: + cisco.aci.aci_l3out_logical_interface_vpc_member: <<: *aci_info tenant: ansible_tenant l3out: ansible_l3out @@ -97,13 +97,13 @@ register: l3out_logical_interface_vpc_member_present - name: Assertions check for add a VPC member based on path_dn - assert: + ansible.builtin.assert: that: - l3out_logical_interface_vpc_member_present is changed - l3out_logical_interface_vpc_member_present.current.0.l3extMember.attributes.annotation == 'orchestrator:ansible' - name: Add a VPC member based on pod_id, node_id, path_ep - aci_l3out_logical_interface_vpc_member: + cisco.aci.aci_l3out_logical_interface_vpc_member: <<: *aci_info tenant: ansible_tenant l3out: ansible_l3out @@ -118,7 +118,7 @@ state: present - name: Query a specific VPC member under ansible_l3out - aci_l3out_logical_interface_vpc_member: + cisco.aci.aci_l3out_logical_interface_vpc_member: <<: *aci_info tenant: ansible_tenant l3out: ansible_l3out @@ -130,7 +130,7 @@ register: query_result - name: Query all relationships - aci_l3out_logical_interface_vpc_member: + cisco.aci.aci_l3out_logical_interface_vpc_member: <<: *aci_info tenant: ansible_tenant state: query @@ -138,7 +138,7 @@ register: query_result - name: Remove a VPC member - aci_l3out_logical_interface_vpc_member: + cisco.aci.aci_l3out_logical_interface_vpc_member: <<: *aci_info tenant: ansible_tenant l3out: ansible_l3out diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_l3out_logical_node/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_l3out_logical_node/tasks/main.yml index 1d61ee3e3..52ae8d7d9 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_l3out_logical_node/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_l3out_logical_node/tasks/main.yml @@ -1,14 +1,16 @@ -# Author: Marcel Zehnder (@maercu) +# Test code for the ACI modules +# Copyright: (c) 2021, Marcel Zehnder (@maercu) +# Copyright: (c) 2023, Akini Ross (@akinross) <akinross@cisco.com> # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined # SET VARS - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: '{{ aci_hostname }}' username: '{{ aci_username }}' @@ -18,6 +20,13 @@ use_proxy: '{{ aci_use_proxy | default(true) }}' output_level: '{{ aci_output_level | default("info") }}' +- name: Query system information + cisco.aci.aci_system: + <<: *aci_info + id: 1 + state: query + register: version + # CLEAN ENVIRONMENT - name: Remove test tenant before we kickoff cisco.aci.aci_tenant: &tenant_absent @@ -26,7 +35,7 @@ state: absent - name: Verify Cloud and Non-Cloud Sites in use. - include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml - name: Execute tasks only for non-cloud sites when: query_cloud.current == [] # This condition will execute only non-cloud sites @@ -79,7 +88,7 @@ register: nm_add_node - name: Verify nm_add_node - assert: + ansible.builtin.assert: that: - cm_add_node is changed - nm_add_node is changed @@ -95,7 +104,7 @@ register: add_node_again - name: Verify add_node_again - assert: + ansible.builtin.assert: that: - add_node_again is not changed @@ -119,7 +128,7 @@ register: remove_loopback_ip - name: Verify update_node - assert: + ansible.builtin.assert: that: - update_node is changed - update_node.previous != [] @@ -138,6 +147,138 @@ router_id: 12.12.12.12 loopback_address: 12.12.12.13 + - name: Execute tasks only for APIC version 5.x and above + when: + - version.current.0.topSystem.attributes.version is version('5', '>=') # This condition will execute only for APIC version 5.x and above + block: + + - name: Ensure infra SR-MPLS l3out does not exist + cisco.aci.aci_l3out: &aci_infra_sr_mpls_l3out_absent + <<: *aci_info + tenant: infra + name: ansible_infra_sr_mpls_l3out + domain: ansible_dom + vrf: overlay-1 + mpls: "yes" + l3protocol: bgp + state: absent + + - name: Add a infra SR-MPLS l3out + cisco.aci.aci_l3out: + <<: *aci_infra_sr_mpls_l3out_absent + state: present + + - name: Add a node profile in the infra SR-MPLS l3out + cisco.aci.aci_l3out_logical_node_profile: &aci_infra_node_profile + <<: *aci_info + tenant: infra + l3out: ansible_infra_sr_mpls_l3out + node_profile: ansible_infra_sr_mpls_l3out_node_profile + + - name: Add a node in the infra SR-MPLS l3out node profile (check_mode) + cisco.aci.aci_l3out_logical_node: &aci_infra_node_profile_node + <<: *aci_infra_node_profile + tenant: infra + l3out: ansible_infra_sr_mpls_l3out + node_profile: ansible_infra_sr_mpls_l3out_node_profile + pod_id: 1 + node_id: 113 + router_id_as_loopback: no + loopback_address: 50.0.0.1 + mpls_transport_loopback_address: 51.0.0.1 + sid: 500 + check_mode: true + register: cm_add_infra_node_profile_node + + - name: Add a node in the infra SR-MPLS l3out node profile without loopback (error) + cisco.aci.aci_l3out_logical_node: + <<: *aci_infra_node_profile_node + loopback_address: "{{ fake_var | default(omit) }}" + ignore_errors: true + register: err_add_infra_node_profile_node_without_loopback + + - name: Add a node in the infra SR-MPLS l3out node profile without sid (error) + cisco.aci.aci_l3out_logical_node: + <<: *aci_infra_node_profile_node + sid: "{{ fake_var | default(omit) }}" + ignore_errors: true + register: err_add_infra_node_profile_node_without_sid + + - name: Add a node in the infra SR-MPLS l3out node profile without mpls transport loopback addressid (error) + cisco.aci.aci_l3out_logical_node: + <<: *aci_infra_node_profile_node + mpls_transport_loopback_address: "{{ fake_var | default(omit) }}" + ignore_errors: true + register: err_add_infra_node_profile_node_without_mpls_transport_loopback_address + + - name: Add a node in the infra SR-MPLS l3out node profile (normal mode) + cisco.aci.aci_l3out_logical_node: + <<: *aci_infra_node_profile_node + register: nm_add_infra_node_profile_node + + - name: Add a node in the infra SR-MPLS l3out node profile again + cisco.aci.aci_l3out_logical_node: + <<: *aci_infra_node_profile_node + register: nm_add_infra_node_profile_node_again + + - name: Change the node in the infra SR-MPLS l3out node profile + cisco.aci.aci_l3out_logical_node: + <<: *aci_infra_node_profile_node + loopback_address: 50.0.0.2 + mpls_transport_loopback_address: 51.0.0.2 + sid: 501 + register: nm_change_infra_node_profile_node + + - name: Verify mpls custom qos policy configuration on node profile + assert: + that: + - cm_add_infra_node_profile_node is changed + - cm_add_infra_node_profile_node.previous == [] + - cm_add_infra_node_profile_node.proposed.l3extRsNodeL3OutAtt.attributes.rtrIdLoopBack == "no" + - cm_add_infra_node_profile_node.proposed.l3extRsNodeL3OutAtt.attributes.tDn == "topology/pod-1/node-113" + - cm_add_infra_node_profile_node.proposed.l3extRsNodeL3OutAtt.children.0.l3extLoopBackIfP.attributes.addr == "50.0.0.1" + - cm_add_infra_node_profile_node.proposed.l3extRsNodeL3OutAtt.children.0.l3extLoopBackIfP.children.0.mplsNodeSidP.attributes.loopbackAddr == "51.0.0.1" + - cm_add_infra_node_profile_node.proposed.l3extRsNodeL3OutAtt.children.0.l3extLoopBackIfP.children.0.mplsNodeSidP.attributes.sidoffset == "500" + - err_add_infra_node_profile_node_without_loopback is failed + - err_add_infra_node_profile_node_without_loopback.msg == "missing parameter(s) required by 'mpls_transport_loopback_address'{{":"}} loopback_address" + - err_add_infra_node_profile_node_without_sid is failed + - err_add_infra_node_profile_node_without_sid.msg == "parameters are required together{{":"}} mpls_transport_loopback_address, sid" + - err_add_infra_node_profile_node_without_mpls_transport_loopback_address is failed + - err_add_infra_node_profile_node_without_mpls_transport_loopback_address.msg == "parameters are required together{{":"}} mpls_transport_loopback_address, sid" + - nm_add_infra_node_profile_node is changed + - nm_add_infra_node_profile_node.previous == [] + - nm_add_infra_node_profile_node.current.0.l3extRsNodeL3OutAtt.attributes.rtrIdLoopBack == "no" + - nm_add_infra_node_profile_node.current.0.l3extRsNodeL3OutAtt.attributes.tDn == "topology/pod-1/node-113" + - nm_add_infra_node_profile_node.current.0.l3extRsNodeL3OutAtt.children.0.l3extLoopBackIfP.attributes.addr == "50.0.0.1" + - nm_add_infra_node_profile_node.current.0.l3extRsNodeL3OutAtt.children.0.l3extLoopBackIfP.children.0.mplsNodeSidP.attributes.loopbackAddr == "51.0.0.1" + - nm_add_infra_node_profile_node.current.0.l3extRsNodeL3OutAtt.children.0.l3extLoopBackIfP.children.0.mplsNodeSidP.attributes.sidoffset == "500" + - nm_add_infra_node_profile_node_again is not changed + - nm_add_infra_node_profile_node_again.previous.0.l3extRsNodeL3OutAtt.attributes.rtrIdLoopBack == "no" + - nm_add_infra_node_profile_node_again.previous.0.l3extRsNodeL3OutAtt.attributes.tDn == "topology/pod-1/node-113" + - nm_add_infra_node_profile_node_again.previous.0.l3extRsNodeL3OutAtt.children.0.l3extLoopBackIfP.attributes.addr == "50.0.0.1" + - nm_add_infra_node_profile_node_again.previous.0.l3extRsNodeL3OutAtt.children.0.l3extLoopBackIfP.children.0.mplsNodeSidP.attributes.loopbackAddr == "51.0.0.1" + - nm_add_infra_node_profile_node_again.previous.0.l3extRsNodeL3OutAtt.children.0.l3extLoopBackIfP.children.0.mplsNodeSidP.attributes.sidoffset == "500" + - nm_add_infra_node_profile_node_again.current.0.l3extRsNodeL3OutAtt.attributes.rtrIdLoopBack == "no" + - nm_add_infra_node_profile_node_again.current.0.l3extRsNodeL3OutAtt.attributes.tDn == "topology/pod-1/node-113" + - nm_add_infra_node_profile_node_again.current.0.l3extRsNodeL3OutAtt.children.0.l3extLoopBackIfP.attributes.addr == "50.0.0.1" + - nm_add_infra_node_profile_node_again.current.0.l3extRsNodeL3OutAtt.children.0.l3extLoopBackIfP.children.0.mplsNodeSidP.attributes.loopbackAddr == "51.0.0.1" + - nm_add_infra_node_profile_node_again.current.0.l3extRsNodeL3OutAtt.children.0.l3extLoopBackIfP.children.0.mplsNodeSidP.attributes.sidoffset == "500" + - nm_change_infra_node_profile_node is changed + - nm_change_infra_node_profile_node.previous.0.l3extRsNodeL3OutAtt.attributes.rtrIdLoopBack == "no" + - nm_change_infra_node_profile_node.previous.0.l3extRsNodeL3OutAtt.attributes.tDn == "topology/pod-1/node-113" + - nm_change_infra_node_profile_node.previous.0.l3extRsNodeL3OutAtt.children.0.l3extLoopBackIfP.attributes.addr == "50.0.0.1" + - nm_change_infra_node_profile_node.previous.0.l3extRsNodeL3OutAtt.children.0.l3extLoopBackIfP.children.0.mplsNodeSidP.attributes.loopbackAddr == "51.0.0.1" + - nm_change_infra_node_profile_node.previous.0.l3extRsNodeL3OutAtt.children.0.l3extLoopBackIfP.children.0.mplsNodeSidP.attributes.sidoffset == "500" + - nm_change_infra_node_profile_node.current.0.l3extRsNodeL3OutAtt.attributes.rtrIdLoopBack == "no" + - nm_change_infra_node_profile_node.current.0.l3extRsNodeL3OutAtt.attributes.tDn == "topology/pod-1/node-113" + - nm_change_infra_node_profile_node.current.0.l3extRsNodeL3OutAtt.children.0.l3extLoopBackIfP.attributes.addr == "50.0.0.2" + - nm_change_infra_node_profile_node.current.0.l3extRsNodeL3OutAtt.children.0.l3extLoopBackIfP.children.0.mplsNodeSidP.attributes.loopbackAddr == "51.0.0.2" + - nm_change_infra_node_profile_node.current.0.l3extRsNodeL3OutAtt.children.0.l3extLoopBackIfP.children.0.mplsNodeSidP.attributes.sidoffset == "501" + + - name: Remove a infra SR-MPLS l3out + cisco.aci.aci_l3out: + <<: *aci_infra_sr_mpls_l3out_absent + # QUERY ALL NODES - name: Query all nodes cisco.aci.aci_l3out_logical_node: @@ -146,7 +287,7 @@ register: query_all_nodes - name: Verify query_all_nodes - assert: + ansible.builtin.assert: that: - query_all_nodes is not changed - query_all_nodes.current|length >= 1 @@ -159,7 +300,7 @@ register: query_spec_node - name: Verify query_spec_node - assert: + ansible.builtin.assert: that: - query_spec_node is not changed - query_spec_node.current|length == 1 @@ -174,7 +315,7 @@ register: remove_node - name: Verify remove_node - assert: + ansible.builtin.assert: that: - remove_node is changed - remove_node.current == [] diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_l3out_logical_node_profile/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_l3out_logical_node_profile/tasks/main.yml index cbd3fa1a9..a744027d9 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_l3out_logical_node_profile/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_l3out_logical_node_profile/tasks/main.yml @@ -1,15 +1,16 @@ # Test code for the ACI modules # Copyright: (c) 2021, Jason Juenger (@jasonjuenger) +# Copyright: (c) 2023, Akini Ross (@akinross) <akinross@cisco.com> # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: "{{ aci_hostname }}" username: "{{ aci_username }}" @@ -19,6 +20,13 @@ use_proxy: '{{ aci_use_proxy | default(true) }}' output_level: info +- name: Query system information + cisco.aci.aci_system: + <<: *aci_info + id: 1 + state: query + register: version + # CLEAN ENVIRONMENT - name: Remove the ansible_tenant cisco.aci.aci_tenant: @@ -27,7 +35,7 @@ state: absent - name: Verify Cloud and Non-Cloud Sites in use. - include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml - name: Execute tasks only for non-cloud sites when: query_cloud.current == [] # This condition will execute only non-cloud sites @@ -79,7 +87,7 @@ register: nm_add_second_node_profile - name: Verify add_node_profile - assert: + ansible.builtin.assert: that: - cm_add_node_profile is changed - nm_add_node_profile is changed @@ -111,7 +119,7 @@ register: nm_mod_node_profile - name: Verify mod_node_profile - assert: + ansible.builtin.assert: that: - cm_mod_node_profile is changed - nm_mod_node_profile is changed @@ -120,6 +128,73 @@ - nm_mod_node_profile.current.0.l3extLNodeP.attributes.dn == 'uni/tn-ansible_tenant/out-ansible_l3out/lnodep-ansible_node_profile' - nm_mod_node_profile.current.0.l3extLNodeP.attributes.name == 'ansible_node_profile' + - name: Execute tasks only for APIC version 5.x and above + when: + - version.current.0.topSystem.attributes.version is version('5', '>=') # This condition will execute only for APIC version 5.x and above + block: + + - name: Ensure infra SR-MPLS l3out does not exist + cisco.aci.aci_l3out: &aci_infra_sr_mpls_l3out_absent + <<: *aci_info + tenant: infra + name: ansible_infra_sr_mpls_l3out + domain: ansible_dom + vrf: overlay-1 + mpls: "yes" + l3protocol: bgp + state: absent + + - name: Add a infra SR-MPLS l3out + cisco.aci.aci_l3out: + <<: *aci_infra_sr_mpls_l3out_absent + state: present + + - name: Add a node profile with MPLS custom QoS policy + cisco.aci.aci_l3out_logical_node_profile: &aci_infra_node_profile_qos + <<: *aci_info + tenant: infra + l3out: ansible_infra_sr_mpls_l3out + node_profile: ansible_infra_sr_mpls_l3out_node_profile + mpls_custom_qos_policy: ansible_test_mpls_custom_qos_policy + register: nm_add_node_profile_qos + + - name: Modify MPLS custom QoS policy to node profile + cisco.aci.aci_l3out_logical_node_profile: &aci_infra_node_profile_qos_changed + <<: *aci_infra_node_profile_qos + mpls_custom_qos_policy: ansible_test_mpls_custom_qos_policy_changed + register: nm_mod_node_profile_qos_changed + + - name: Modify MPLS custom QoS policy to node profile again + cisco.aci.aci_l3out_logical_node_profile: + <<: *aci_infra_node_profile_qos_changed + register: nm_mod_node_profile_qos_again + + - name: Remove MPLS custom QoS policy from node profile again + cisco.aci.aci_l3out_logical_node_profile: + <<: *aci_infra_node_profile_qos_changed + mpls_custom_qos_policy: "" + register: nm_del_node_profile_qos + + - name: Verify MPLS custom QoS policy configuration on node profile + assert: + that: + - nm_add_node_profile_qos is changed + - nm_add_node_profile_qos.previous == [] + - nm_add_node_profile_qos.current.0.l3extLNodeP.children.0.l3extRsLNodePMplsCustQosPol.attributes.tDn == "uni/tn-infra/qosmplscustom-ansible_test_mpls_custom_qos_policy" + - nm_mod_node_profile_qos_changed is changed + - nm_mod_node_profile_qos_changed.previous.0.l3extLNodeP.children.0.l3extRsLNodePMplsCustQosPol.attributes.tDn == "uni/tn-infra/qosmplscustom-ansible_test_mpls_custom_qos_policy" + - nm_mod_node_profile_qos_changed.current.0.l3extLNodeP.children.0.l3extRsLNodePMplsCustQosPol.attributes.tDn == "uni/tn-infra/qosmplscustom-ansible_test_mpls_custom_qos_policy_changed" + - nm_mod_node_profile_qos_again is not changed + - nm_mod_node_profile_qos_again.previous.0.l3extLNodeP.children.0.l3extRsLNodePMplsCustQosPol.attributes.tDn == "uni/tn-infra/qosmplscustom-ansible_test_mpls_custom_qos_policy_changed" + - nm_mod_node_profile_qos_again.current.0.l3extLNodeP.children.0.l3extRsLNodePMplsCustQosPol.attributes.tDn == "uni/tn-infra/qosmplscustom-ansible_test_mpls_custom_qos_policy_changed" + - nm_del_node_profile_qos is changed + - nm_del_node_profile_qos.previous.0.l3extLNodeP.children.0.l3extRsLNodePMplsCustQosPol.attributes.tDn == "uni/tn-infra/qosmplscustom-ansible_test_mpls_custom_qos_policy_changed" + - nm_del_node_profile_qos.current.0.l3extLNodeP.children is undefined + + - name: Remove a infra SR-MPLS l3out + cisco.aci.aci_l3out: + <<: *aci_infra_sr_mpls_l3out_absent + - name: Query existing node profile (check mode) cisco.aci.aci_l3out_logical_node_profile: &query_existing_node_profile <<: *aci_info @@ -153,7 +228,7 @@ register: nm_query_all_node_profiles - name: Verify query_node_profile - assert: + ansible.builtin.assert: that: - cm_query_node_profile is not changed - nm_query_node_profile is not changed @@ -198,7 +273,7 @@ register: nm_remove_second_node_profile - name: Verify remove_node_profile - assert: + ansible.builtin.assert: that: - cm_remove_node_profile is changed - cm_remove_second_node_profile is changed diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_l3out_route_tag_policy/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_l3out_route_tag_policy/tasks/main.yml index d7ad61c6d..69b19c53f 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_l3out_route_tag_policy/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_l3out_route_tag_policy/tasks/main.yml @@ -4,12 +4,12 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: "{{ aci_hostname }}" username: "{{ aci_username }}" @@ -27,7 +27,7 @@ state: absent - name: Verify Cloud and Non-Cloud Sites in use. - include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml - name: Execute tasks only for non-cloud sites when: query_cloud.current == [] # This condition will execute only non-cloud sites @@ -66,7 +66,7 @@ register: nm_add_rtp_2 - name: asserts for creation tasks - assert: + ansible.builtin.assert: that: - cm_add_rtp is changed - cm_add_rtp.previous == [] @@ -93,7 +93,7 @@ register: query_first_rtp - name: asserts query tasks - assert: + ansible.builtin.assert: that: - query_all_rtp is not changed - query_all_rtp.current.0.fvTenant.children | length >= 2 @@ -130,7 +130,7 @@ register: nm_delete_rtp_2 - name: asserts for deletion tasks - assert: + ansible.builtin.assert: that: - cm_delete_rtp is changed - cm_delete_rtp.proposed == {} diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_l3out_static_routes/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_l3out_static_routes/tasks/main.yml index 147d180fc..90f8c4cbb 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_l3out_static_routes/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_l3out_static_routes/tasks/main.yml @@ -4,12 +4,12 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: "{{ aci_hostname }}" username: "{{ aci_username }}" @@ -21,26 +21,26 @@ # CLEAN ENVIRONMENT - name: Remove the ansible_tenant - aci_tenant: + cisco.aci.aci_tenant: <<: *aci_info tenant: ansible_tenant state: absent - name: Verify Cloud and Non-Cloud Sites in use. - include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml - name: Execute tasks only for non-cloud sites when: query_cloud.current == [] # This condition will execute only non-cloud sites block: # block specifies execution of tasks within, based on conditions - name: Add a new tenant - aci_tenant: + cisco.aci.aci_tenant: <<: *aci_info tenant: ansible_tenant description: Ansible tenant state: present - name: Add a new L3Out - aci_l3out: + cisco.aci.aci_l3out: <<: *aci_info tenant: ansible_tenant name: ansible_l3out @@ -71,7 +71,7 @@ register: l3out_logical_node - name: Verify l3out_logical_node - assert: + ansible.builtin.assert: that: - l3out_logical_node is changed - l3out_logical_node.previous == [] @@ -80,7 +80,7 @@ - l3out_logical_node.sent.l3extRsNodeL3OutAtt.attributes.tDn == 'topology/pod-1/node-101' - name: Add static routes (check_mode) - aci_l3out_static_routes: &route_present + cisco.aci.aci_l3out_static_routes: &route_present <<: *aci_info tenant: ansible_tenant l3out: ansible_l3out @@ -93,12 +93,12 @@ register: cm_add_route - name: Add static routes (normal_mode) - aci_l3out_static_routes: + cisco.aci.aci_l3out_static_routes: <<: *route_present register: nm_add_route - name: Verify cm_add_route and nm_add_route - assert: + ansible.builtin.assert: that: - cm_add_route is changed - nm_add_route is changed @@ -109,18 +109,18 @@ - nm_add_route.current[0].ipRouteP.attributes.annotation == 'orchestrator:ansible' - name: Add static routes again (check_mode) - aci_l3out_static_routes: + cisco.aci.aci_l3out_static_routes: <<: *route_present check_mode: true register: cm_add_route_again - name: Add static routes again (normal_mode) - aci_l3out_static_routes: + cisco.aci.aci_l3out_static_routes: <<: *route_present register: nm_add_route_again - name: Verify cm_add_route_again and nm_add_route_again - assert: + ansible.builtin.assert: that: - cm_add_route_again is not changed - nm_add_route_again is not changed @@ -130,14 +130,14 @@ - nm_add_route_again.current[0].ipRouteP.attributes.ip == "10.1.0.1/24" - name: Query system information - aci_system: + cisco.aci.aci_system: <<: *aci_info id: 1 state: query register: version - name: Add static routes with bfd - aci_l3out_static_routes: + cisco.aci.aci_l3out_static_routes: <<: *aci_info tenant: ansible_tenant l3out: ansible_l3out @@ -152,7 +152,7 @@ register: nm_add_route_with_bfd - name: Verify nm_add_route_with_bfd - assert: + ansible.builtin.assert: that: - nm_add_route_with_bfd is changed - nm_add_route_with_bfd.current[0].ipRouteP.attributes.dn == "uni/tn-ansible_tenant/out-ansible_l3out/lnodep-lNode/rsnodeL3OutAtt-[topology/pod-1/node-101]/rt-[10.1.0.1/24]" @@ -162,7 +162,7 @@ when: version.current.0.topSystem.attributes.version is version('4.2', '>=') - name: Query for a specific MO under l3out - aci_l3out_static_routes: + cisco.aci.aci_l3out_static_routes: <<: *aci_info tenant: ansible_tenant l3out: ansible_l3out @@ -174,14 +174,14 @@ register: query_specific_mo - name: Verify query_specific_mo - assert: + ansible.builtin.assert: that: - query_specific_mo is not changed - query_specific_mo.current|length == 1 - query_specific_mo.current[0].ipRouteP.attributes.ip == "10.1.0.1/24" - name: Query all relationships - aci_l3out_static_routes: + cisco.aci.aci_l3out_static_routes: <<: *aci_info tenant: ansible_tenant state: query @@ -189,7 +189,7 @@ register: query_all_relationships - name: Verify query_all_relationships - assert: + ansible.builtin.assert: that: - query_all_relationships is not changed - query_all_relationships.current|length == 1 @@ -201,13 +201,13 @@ - query_all_relationships.current[0].fvTenant.children[0].l3extOut.children[0].l3extLNodeP.children[0].l3extRsNodeL3OutAtt.attributes.tDn == "topology/pod-1/node-101" - name: Verify query_all_relationships for bfd - assert: + ansible.builtin.assert: that: - query_all_relationships.current[0].fvTenant.children[0].l3extOut.children[0].l3extLNodeP.children[0].l3extRsNodeL3OutAtt.children[0].ipRouteP.attributes.rtCtrl == "bfd" when: version.current.0.topSystem.attributes.version is version('4.2', '>=') - name: Remove static routes (check_mode) - aci_l3out_static_routes: &route_absent + cisco.aci.aci_l3out_static_routes: &route_absent <<: *aci_info tenant: ansible_tenant l3out: ansible_l3out @@ -220,12 +220,12 @@ register: cm_remove_static_routes - name: Remove static routes (normal_mode) - aci_l3out_static_routes: + cisco.aci.aci_l3out_static_routes: <<: *route_absent register: nm_remove_static_routes - name: Verify cm_remove_static_routes and nm_remove_static_routes - assert: + ansible.builtin.assert: that: - cm_remove_static_routes is changed - nm_remove_static_routes is changed @@ -233,18 +233,18 @@ - nm_remove_static_routes.current|length == 0 - name: Remove static routes again (check_mode) - aci_l3out_static_routes: + cisco.aci.aci_l3out_static_routes: <<: *route_absent check_mode: true register: cm_remove_static_routes_again - name: Remove static routes again (normal_mode) - aci_l3out_static_routes: + cisco.aci.aci_l3out_static_routes: <<: *route_absent register: nm_remove_static_routes_again - name: Verify cm_remove_static_routes_again and nm_remove_static_routes_again - assert: + ansible.builtin.assert: that: - cm_remove_static_routes_again is not changed - nm_remove_static_routes_again is not changed @@ -252,7 +252,7 @@ - nm_remove_static_routes_again.current|length == 0 - name: Remove the ansible_tenant - aci_tenant: + cisco.aci.aci_tenant: <<: *aci_info tenant: ansible_tenant state: absent diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_l3out_static_routes_nexthop/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_l3out_static_routes_nexthop/tasks/main.yml index 7d4de1a09..1e7d495fe 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_l3out_static_routes_nexthop/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_l3out_static_routes_nexthop/tasks/main.yml @@ -3,7 +3,7 @@ # SET VARS - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: '{{ aci_hostname }}' username: '{{ aci_username }}' @@ -21,7 +21,7 @@ state: absent - name: Verify Cloud and Non-Cloud Sites in use. - include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml - name: Execute tasks only for non-cloud sites when: query_cloud.current == [] # This condition will execute only non-cloud sites @@ -85,7 +85,7 @@ register: nm_add_nh - name: Verify nm_add_nh - assert: + ansible.builtin.assert: that: - cm_add_nh is changed - nm_add_nh is changed @@ -99,7 +99,7 @@ register: add_nh_again - name: Verify add_nh_again - assert: + ansible.builtin.assert: that: - add_nh_again is not changed @@ -117,7 +117,7 @@ register: query_all_nhs - name: Verify query_all_nhs - assert: + ansible.builtin.assert: that: - query_all_nhs is not changed - query_all_nhs.current|length >= 1 @@ -130,7 +130,7 @@ register: query_spec_nh - name: Verify query_spec_node - assert: + ansible.builtin.assert: that: - query_spec_nh is not changed - query_spec_nh.current|length == 1 @@ -143,7 +143,7 @@ register: remove_nh - name: Verify remove_nh - assert: + ansible.builtin.assert: that: - remove_nh is changed - remove_nh.current == [] diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_l3out_to_sr_mpls_infra_l3out/aliases b/ansible_collections/cisco/aci/tests/integration/targets/aci_l3out_to_sr_mpls_infra_l3out/aliases new file mode 100644 index 000000000..209b793f9 --- /dev/null +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_l3out_to_sr_mpls_infra_l3out/aliases @@ -0,0 +1,2 @@ +# No ACI simulator yet, so not enabled +# unsupported diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_l3out_to_sr_mpls_infra_l3out/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_l3out_to_sr_mpls_infra_l3out/tasks/main.yml new file mode 100644 index 000000000..f4e987492 --- /dev/null +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_l3out_to_sr_mpls_infra_l3out/tasks/main.yml @@ -0,0 +1,238 @@ +# Test code for the ACI modules +# Copyright: (c) 2023, Akini Ross (@akinross) <akinross@cisco.com> + +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +- name: Test that we have an ACI APIC host, ACI username and ACI password + ansible.builtin.fail: + msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' + when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined + +- name: Set vars + ansible.builtin.set_fact: + aci_info: &aci_info + host: "{{ aci_hostname }}" + username: "{{ aci_username }}" + password: "{{ aci_password }}" + validate_certs: '{{ aci_validate_certs | default(false) }}' + use_ssl: '{{ aci_use_ssl | default(true) }}' + use_proxy: '{{ aci_use_proxy | default(true) }}' + output_level: debug + +- name: Query system information + cisco.aci.aci_system: + <<: *aci_info + id: 1 + state: query + register: version + +- name: Verify Cloud and Non-Cloud Sites in use. + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + +- name: Execute tasks only for non-cloud sites + when: + - query_cloud.current == [] # This condition will execute only non-cloud sites + - version.current.0.topSystem.attributes.version is version('5', '>=') # This condition will execute only for APIC version 5.x and above + block: # block specifies execution of tasks within, based on conditions + + # CLEAN ENVIRONMENT + - name: Remove the ansible_tenant + cisco.aci.aci_tenant: &aci_tenant_absent + <<: *aci_info + tenant: ansible_test + state: absent + + - name: Ensure infra sr mpls l3out does not exist + cisco.aci.aci_l3out: &aci_infra_sr_mpls_l3out_absent + <<: *aci_info + tenant: infra + name: ansible_infra_sr_mpls_l3out + domain: ansible_dom + vrf: overlay-1 + mpls: "yes" + l3protocol: bgp + state: absent + + - name: Add a new ansible_tenant + cisco.aci.aci_tenant: + <<: *aci_tenant_absent + state: present + + - name: Add a infra sr mpls l3out + cisco.aci.aci_l3out: + <<: *aci_infra_sr_mpls_l3out_absent + state: present + + - name: Add a sr mpls l3out + cisco.aci.aci_l3out: + <<: *aci_tenant_absent + name: ansible_sr_mpls_l3out + domain: ansible_dom + vrf: ansible_vrf + mpls: "yes" + state: present + + - name: Add a new l3out to sr-mpls infra l3out (check_mode) + cisco.aci.aci_l3out_to_sr_mpls_infra_l3out: &l3out_to_infra_present + <<: *aci_tenant_absent + l3out: ansible_sr_mpls_l3out + description: ansible_sr_mpls_l3out_description + infra_l3out: ansible_infra_sr_mpls_l3out + external_epg: uni/tn-ansible_test/out-ansible_sr_mpls_l3out/instP-ansible_external_epg + outbound_route_map: uni/tn-ansible_test/prof-outbound_route_map + state: present + check_mode: true + register: cm_add_l3out_to_infra + + - name: Add a new l3out to sr-mpls infra l3out + cisco.aci.aci_l3out_to_sr_mpls_infra_l3out: + <<: *l3out_to_infra_present + register: nm_add_l3out_to_infra + + - name: Add a new l3out to sr-mpls infra l3out again + cisco.aci.aci_l3out_to_sr_mpls_infra_l3out: + <<: *l3out_to_infra_present + register: nm_add_l3out_to_infra_again + + - name: Assert creation of l3out to sr-mpls infra l3outs + ansible.builtin.assert: + that: + - cm_add_l3out_to_infra is changed + - cm_add_l3out_to_infra.previous == [] + - cm_add_l3out_to_infra.proposed.l3extConsLbl.attributes.name == "ansible_infra_sr_mpls_l3out" + - cm_add_l3out_to_infra.proposed.l3extConsLbl.attributes.descr == "ansible_sr_mpls_l3out_description" + - cm_add_l3out_to_infra.proposed.l3extConsLbl.children.0.l3extRsLblToProfile.attributes.direction == "export" + - cm_add_l3out_to_infra.proposed.l3extConsLbl.children.0.l3extRsLblToProfile.attributes.tDn == "uni/tn-ansible_test/prof-outbound_route_map" + - cm_add_l3out_to_infra.proposed.l3extConsLbl.children.1.l3extRsLblToInstP.attributes.tDn == "uni/tn-ansible_test/out-ansible_sr_mpls_l3out/instP-ansible_external_epg" + - nm_add_l3out_to_infra is changed + - nm_add_l3out_to_infra.previous == [] + - nm_add_l3out_to_infra.current.0.l3extConsLbl.attributes.name == "ansible_infra_sr_mpls_l3out" + - nm_add_l3out_to_infra.current.0.l3extConsLbl.attributes.descr == "ansible_sr_mpls_l3out_description" + - nm_add_l3out_to_infra.current.0.l3extConsLbl.children.1.l3extRsLblToProfile.attributes.direction == "export" + - nm_add_l3out_to_infra.current.0.l3extConsLbl.children.1.l3extRsLblToProfile.attributes.tDn == "uni/tn-ansible_test/prof-outbound_route_map" + - nm_add_l3out_to_infra.current.0.l3extConsLbl.children.0.l3extRsLblToInstP.attributes.tDn == "uni/tn-ansible_test/out-ansible_sr_mpls_l3out/instP-ansible_external_epg" + - nm_add_l3out_to_infra_again is not changed + - nm_add_l3out_to_infra_again.previous.0.l3extConsLbl.attributes.name == "ansible_infra_sr_mpls_l3out" + - nm_add_l3out_to_infra_again.previous.0.l3extConsLbl.attributes.descr == "ansible_sr_mpls_l3out_description" + - nm_add_l3out_to_infra_again.previous.0.l3extConsLbl.children.1.l3extRsLblToProfile.attributes.direction == "export" + - nm_add_l3out_to_infra_again.previous.0.l3extConsLbl.children.1.l3extRsLblToProfile.attributes.tDn == "uni/tn-ansible_test/prof-outbound_route_map" + - nm_add_l3out_to_infra_again.previous.0.l3extConsLbl.children.0.l3extRsLblToInstP.attributes.tDn == "uni/tn-ansible_test/out-ansible_sr_mpls_l3out/instP-ansible_external_epg" + - nm_add_l3out_to_infra_again.current.0.l3extConsLbl.attributes.name == "ansible_infra_sr_mpls_l3out" + - nm_add_l3out_to_infra_again.current.0.l3extConsLbl.attributes.descr == "ansible_sr_mpls_l3out_description" + - nm_add_l3out_to_infra_again.current.0.l3extConsLbl.children.1.l3extRsLblToProfile.attributes.direction == "export" + - nm_add_l3out_to_infra_again.current.0.l3extConsLbl.children.1.l3extRsLblToProfile.attributes.tDn == "uni/tn-ansible_test/prof-outbound_route_map" + - nm_add_l3out_to_infra_again.current.0.l3extConsLbl.children.0.l3extRsLblToInstP.attributes.tDn == "uni/tn-ansible_test/out-ansible_sr_mpls_l3out/instP-ansible_external_epg" + + - name: Update a l3out to sr-mpls infra l3out + cisco.aci.aci_l3out_to_sr_mpls_infra_l3out: &l3out_to_infra_present_updated + <<: *l3out_to_infra_present + description: ansible_sr_mpls_l3out_description_updated + external_epg: uni/tn-ansible_test/out-ansible_sr_mpls_l3out/instP-ansible_external_epg_updated + outbound_route_map: uni/tn-ansible_test/prof-outbound_route_map_updated + inbound_route_map: uni/tn-ansible_test/prof-inbound_route_map + register: nm_update_l3out_to_infra + + - name: Update a l3out to sr-mpls infra l3out to remove inbound route map + cisco.aci.aci_l3out_to_sr_mpls_infra_l3out: + <<: *l3out_to_infra_present_updated + inbound_route_map: "" + register: nm_update_l3out_to_infra_remove_inbound_route_map + + - name: Assert updates of l3out to sr-mpls infra l3outs + ansible.builtin.assert: + that: + - nm_update_l3out_to_infra is changed + - nm_update_l3out_to_infra.previous.0.l3extConsLbl.attributes.name == "ansible_infra_sr_mpls_l3out" + - nm_update_l3out_to_infra.previous.0.l3extConsLbl.attributes.descr == "ansible_sr_mpls_l3out_description" + - nm_update_l3out_to_infra.previous.0.l3extConsLbl.children.1.l3extRsLblToProfile.attributes.direction == "export" + - nm_update_l3out_to_infra.previous.0.l3extConsLbl.children.1.l3extRsLblToProfile.attributes.tDn == "uni/tn-ansible_test/prof-outbound_route_map" + - nm_update_l3out_to_infra.previous.0.l3extConsLbl.children.0.l3extRsLblToInstP.attributes.tDn == "uni/tn-ansible_test/out-ansible_sr_mpls_l3out/instP-ansible_external_epg" + - nm_update_l3out_to_infra.previous.0.l3extConsLbl.children | length == 2 + - nm_update_l3out_to_infra.current.0.l3extConsLbl.attributes.name == "ansible_infra_sr_mpls_l3out" + - nm_update_l3out_to_infra.current.0.l3extConsLbl.attributes.descr == "ansible_sr_mpls_l3out_description_updated" + - nm_update_l3out_to_infra.current.0.l3extConsLbl.children.1.l3extRsLblToProfile.attributes.direction == "import" + - nm_update_l3out_to_infra.current.0.l3extConsLbl.children.1.l3extRsLblToProfile.attributes.tDn == "uni/tn-ansible_test/prof-inbound_route_map" + - nm_update_l3out_to_infra.current.0.l3extConsLbl.children.2.l3extRsLblToProfile.attributes.direction == "export" + - nm_update_l3out_to_infra.current.0.l3extConsLbl.children.2.l3extRsLblToProfile.attributes.tDn == "uni/tn-ansible_test/prof-outbound_route_map_updated" + - nm_update_l3out_to_infra.current.0.l3extConsLbl.children.0.l3extRsLblToInstP.attributes.tDn == "uni/tn-ansible_test/out-ansible_sr_mpls_l3out/instP-ansible_external_epg_updated" + - nm_update_l3out_to_infra.current.0.l3extConsLbl.children | length == 3 + - nm_update_l3out_to_infra_remove_inbound_route_map is changed + - nm_update_l3out_to_infra_remove_inbound_route_map.previous.0.l3extConsLbl.attributes.name == "ansible_infra_sr_mpls_l3out" + - nm_update_l3out_to_infra_remove_inbound_route_map.previous.0.l3extConsLbl.attributes.descr == "ansible_sr_mpls_l3out_description_updated" + - nm_update_l3out_to_infra_remove_inbound_route_map.previous.0.l3extConsLbl.children.1.l3extRsLblToProfile.attributes.direction == "import" + - nm_update_l3out_to_infra_remove_inbound_route_map.previous.0.l3extConsLbl.children.1.l3extRsLblToProfile.attributes.tDn == "uni/tn-ansible_test/prof-inbound_route_map" + - nm_update_l3out_to_infra_remove_inbound_route_map.previous.0.l3extConsLbl.children.2.l3extRsLblToProfile.attributes.direction == "export" + - nm_update_l3out_to_infra_remove_inbound_route_map.previous.0.l3extConsLbl.children.2.l3extRsLblToProfile.attributes.tDn == "uni/tn-ansible_test/prof-outbound_route_map_updated" + - nm_update_l3out_to_infra_remove_inbound_route_map.previous.0.l3extConsLbl.children.0.l3extRsLblToInstP.attributes.tDn == "uni/tn-ansible_test/out-ansible_sr_mpls_l3out/instP-ansible_external_epg_updated" + - nm_update_l3out_to_infra_remove_inbound_route_map.previous.0.l3extConsLbl.children | length == 3 + - nm_update_l3out_to_infra_remove_inbound_route_map.current.0.l3extConsLbl.attributes.name == "ansible_infra_sr_mpls_l3out" + - nm_update_l3out_to_infra_remove_inbound_route_map.current.0.l3extConsLbl.attributes.descr == "ansible_sr_mpls_l3out_description_updated" + - nm_update_l3out_to_infra_remove_inbound_route_map.current.0.l3extConsLbl.children.1.l3extRsLblToProfile.attributes.direction == "export" + - nm_update_l3out_to_infra_remove_inbound_route_map.current.0.l3extConsLbl.children.1.l3extRsLblToProfile.attributes.tDn == "uni/tn-ansible_test/prof-outbound_route_map_updated" + - nm_update_l3out_to_infra_remove_inbound_route_map.current.0.l3extConsLbl.children.0.l3extRsLblToInstP.attributes.tDn == "uni/tn-ansible_test/out-ansible_sr_mpls_l3out/instP-ansible_external_epg_updated" + - nm_update_l3out_to_infra_remove_inbound_route_map.current.0.l3extConsLbl.children | length == 2 + + - name: Query a l3out to sr-mpls infra l3out + cisco.aci.aci_l3out_to_sr_mpls_infra_l3out: + <<: *l3out_to_infra_present + state: query + register: query_one + + - name: Query all l3out to sr-mpls infra l3outs + cisco.aci.aci_l3out_to_sr_mpls_infra_l3out: + <<: *aci_info + state: query + register: query_all + + - name: Assert l3out to sr-mpls infra l3outs queries + ansible.builtin.assert: + that: + - query_one is not changed + - query_one.current | length == 1 + - query_one.current.0.l3extConsLbl.attributes.name == "ansible_infra_sr_mpls_l3out" + - query_one.current.0.l3extConsLbl.children | length == 4 + - query_one.current.0.l3extConsLbl.children.0.bgpDomainIdAllocator.attributes.rn == "bgpdomainid" + - query_one.current.0.l3extConsLbl.children.1.l3extRsProvLblDef.attributes.tDn == "resPolCont/tn-[uni/tn-infra]/provlbl-ansible_infra_sr_mpls_l3out" + - query_one.current.0.l3extConsLbl.children.2.l3extRsLblToInstP.attributes.tDn == "uni/tn-ansible_test/out-ansible_sr_mpls_l3out/instP-ansible_external_epg_updated" + - query_one.current.0.l3extConsLbl.children.3.l3extRsLblToProfile.attributes.tDn == "uni/tn-ansible_test/prof-outbound_route_map_updated" + - query_all is not changed + - query_all.current | length >= 1 + + - name: Delete a l3out to sr-mpls infra l3out (check_mode) + cisco.aci.aci_l3out_to_sr_mpls_infra_l3out: &l3out_to_infra_absent + <<: *l3out_to_infra_present + state: absent + check_mode: true + register: cm_delete_l3out_to_infra + + - name: Delete a l3out to sr-mpls infra l3out + cisco.aci.aci_l3out_to_sr_mpls_infra_l3out: + <<: *l3out_to_infra_absent + register: nm_delete_l3out_to_infra + + - name: Delete a l3out to sr-mpls infra l3out again + cisco.aci.aci_l3out_to_sr_mpls_infra_l3out: + <<: *l3out_to_infra_absent + register: nm_delete_l3out_to_infra_again + + - name: Assert deletion of l3out to sr-mpls infra l3outs + ansible.builtin.assert: + that: + - cm_delete_l3out_to_infra is changed + - cm_delete_l3out_to_infra.previous.0.l3extConsLbl.attributes.name == "ansible_infra_sr_mpls_l3out" + - cm_delete_l3out_to_infra.proposed == {} + - nm_delete_l3out_to_infra is changed + - nm_delete_l3out_to_infra.previous.0.l3extConsLbl.attributes.name == "ansible_infra_sr_mpls_l3out" + - nm_delete_l3out_to_infra.current == [] + - nm_delete_l3out_to_infra_again is not changed + - nm_delete_l3out_to_infra_again.previous == [] + - nm_delete_l3out_to_infra_again.current == [] + + # CLEAN ENVIRONMENT END OF TESTS + - name: Delete the ansible_tenant at the end of tests + cisco.aci.aci_tenant: + <<: *aci_tenant_absent + + - name: Delete a infra sr mpls l3out at the end of tests + cisco.aci.aci_l3out: + <<: *aci_infra_sr_mpls_l3out_absent diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_lookup_interface_range/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_lookup_interface_range/tasks/main.yml index 5660d0b87..cac0c5b52 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_lookup_interface_range/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_lookup_interface_range/tasks/main.yml @@ -4,12 +4,12 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: "{{ aci_hostname }}" username: "{{ aci_username }}" @@ -26,7 +26,7 @@ register: single_string_single_range - name: Valid input assertions - assert: + ansible.builtin.assert: that: - single_string_single_range.results.0.item == "5/0" - single_string_single_range.results.1.item == "5/1" @@ -39,7 +39,7 @@ register: single_string_multiple_interface - name: Valid input assertions - assert: + ansible.builtin.assert: that: - single_string_multiple_interface.results.0.item == "1/1" - single_string_multiple_interface.results.1.item == "1/2" @@ -59,7 +59,7 @@ register: single_string_single_interface_as_range - name: Valid input assertions - assert: + ansible.builtin.assert: that: - single_string_single_interface_as_range.results.0.item == "1/1" @@ -70,7 +70,7 @@ register: single_string_mix_ranges - name: Valid input assertions - assert: + ansible.builtin.assert: that: - single_string_mix_ranges.results.0.item == "1/1" - single_string_mix_ranges.results.1.item == "1/2" @@ -101,7 +101,7 @@ register: invalid_range_order - name: Invalid input assertions - assert: + ansible.builtin.assert: that: - "'Invalid range inputs,' in invalid_pattern.msg" - "'Invalid range inputs,' in invalid_range_order.msg" @@ -121,7 +121,7 @@ msg: "{{ disable_leaf_int }}" - name: Valid disable interface assertions - assert: + ansible.builtin.assert: that: - disable_leaf_int.results.0.current.0.fabricRsOosPath.attributes.lc == "blacklist" - disable_leaf_int.results.0.current.0.fabricRsOosPath.attributes.tDn == "topology/pod-1/paths-1101/pathep-[eth1/30]" @@ -141,7 +141,7 @@ register: enable_leaf_int - name: Valid enable interface assertions - assert: + ansible.builtin.assert: that: - enable_leaf_int.results.0.current == [] - enable_leaf_int.results.1.current == [] diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_maintenance_group/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_maintenance_group/tasks/main.yml index 12284c8a6..b3a6701f4 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_maintenance_group/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_maintenance_group/tasks/main.yml @@ -4,12 +4,12 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: "{{ aci_hostname }}" username: "{{ aci_username }}" @@ -20,27 +20,27 @@ output_level: debug - name: Verify Cloud and Non-Cloud Sites in use. - include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml - name: Execute tasks only for non-cloud sites when: query_cloud.current == [] # This condition will execute only non-cloud sites block: # block specifies execution of tasks within, based on conditions # Clean Environment - name: Create Scheduler - aci_fabric_scheduler: &aci_fabric_scheduler_present + cisco.aci.aci_fabric_scheduler: &aci_fabric_scheduler_present <<: *aci_info name: anstest_scheduler state: present - name: Create maintenance policy - aci_maintenance_policy: &aci_maintenance_policy_present + cisco.aci.aci_maintenance_policy: &aci_maintenance_policy_present <<: *aci_info name: anstest_policy scheduler: anstest_scheduler state: present - name: Ensure first maintenance group does not exist - aci_maintenance_group: &aci_maintenance_group_absent + cisco.aci.aci_maintenance_group: &aci_maintenance_group_absent <<: *aci_info group: anstest_group policy: anstest_policy @@ -50,37 +50,37 @@ state: absent - name: Ensure second maintenance group does not exist - aci_maintenance_group: &aci_maintenance_group_2_absent + cisco.aci.aci_maintenance_group: &aci_maintenance_group_2_absent <<: *aci_info group: anstest_group_2 policy: anstest_policy_2 state: absent - name: Create first maintenance group (check_mode) - aci_maintenance_group: &aci_maintenance_group_present + cisco.aci.aci_maintenance_group: &aci_maintenance_group_present <<: *aci_maintenance_group_absent state: present check_mode: true register: cm_add_maintenance_group_1 - name: Create first maintenance group (normal_mode) - aci_maintenance_group: + cisco.aci.aci_maintenance_group: <<: *aci_maintenance_group_present register: nm_add_maintenance_group_1 - name: Create first maintenance group again - testing idempotency - aci_maintenance_group: + cisco.aci.aci_maintenance_group: <<: *aci_maintenance_group_present register: idempotency_add_maintenance_group_1 - name: Create second maintenance group - aci_maintenance_group: &aci_maintenance_group_2_present + cisco.aci.aci_maintenance_group: &aci_maintenance_group_2_present <<: *aci_maintenance_group_2_absent state: present register: nm_add_maintenance_group_2 - name: Asserts for creation tasks - assert: + ansible.builtin.assert: that: - cm_add_maintenance_group_1 is changed - cm_add_maintenance_group_1.previous == [] @@ -99,19 +99,19 @@ - name: Query all maintenance groups - aci_maintenance_group: + cisco.aci.aci_maintenance_group: <<: *aci_info state: query register: query_all_maintenance_group - name: Query first maintenance group - aci_maintenance_group: + cisco.aci.aci_maintenance_group: <<: *aci_maintenance_group_present state: query register: query_first_maintenance_group - name: Asserts for query tasks - assert: + ansible.builtin.assert: that: - query_all_maintenance_group is not changed - query_all_maintenance_group.current | length >= 2 @@ -126,32 +126,32 @@ - query_first_maintenance_group.current.0.maintMaintGrp.attributes.type == "ALL" - name: Delete first maintenance group (check_mode) - aci_maintenance_group: + cisco.aci.aci_maintenance_group: <<: *aci_maintenance_group_present state: absent check_mode: true register: cm_delete_maintenance_group_1 - name: Delete first maintenance group (normal_mode) - aci_maintenance_group: + cisco.aci.aci_maintenance_group: <<: *aci_maintenance_group_present state: absent register: nm_delete_maintenance_group_1 - name: Delete first maintenance group again - testing idempotency - aci_maintenance_group: + cisco.aci.aci_maintenance_group: <<: *aci_maintenance_group_present state: absent register: idempotency_delete_maintenance_group_1 - name: Delete second maintenance group (normal_mode) - aci_maintenance_group: + cisco.aci.aci_maintenance_group: <<: *aci_maintenance_group_2_present state: absent register: nm_delete_maintenance_group_2 - name: Asserts for deletion tasks - assert: + ansible.builtin.assert: that: - cm_delete_maintenance_group_1 is changed - cm_delete_maintenance_group_1.proposed == {} @@ -165,11 +165,11 @@ - nm_delete_maintenance_group_2.current == [] - name: Delete maintenance policy - clean up the environment - aci_maintenance_policy: + cisco.aci.aci_maintenance_policy: <<: *aci_maintenance_policy_present state: absent - name: Delete scheduler - clean up the environment - aci_fabric_scheduler: + cisco.aci.aci_fabric_scheduler: <<: *aci_fabric_scheduler_present state: absent diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_maintenance_group_node/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_maintenance_group_node/tasks/main.yml index 9be9ecbe8..d2223e892 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_maintenance_group_node/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_maintenance_group_node/tasks/main.yml @@ -4,12 +4,12 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: "{{ aci_hostname }}" username: "{{ aci_username }}" @@ -20,71 +20,71 @@ output_level: debug - name: Verify Cloud and Non-Cloud Sites in use. - include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml - name: Execute tasks only for non-cloud sites when: query_cloud.current == [] # This condition will execute only non-cloud sites block: # block specifies execution of tasks within, based on conditions # Clean Environment - name: Create Scheduler - aci_fabric_scheduler: &aci_fabric_scheduler_present + cisco.aci.aci_fabric_scheduler: &aci_fabric_scheduler_present <<: *aci_info name: anstest_scheduler state: present - name: Create maintenance policy - aci_maintenance_policy: &aci_maintenance_policy_present + cisco.aci.aci_maintenance_policy: &aci_maintenance_policy_present <<: *aci_info name: anstest_policy scheduler: anstest_scheduler state: present - name: Create maintenance groupe - aci_maintenance_group: &aci_maintenance_group_present + cisco.aci.aci_maintenance_group: &aci_maintenance_group_present <<: *aci_info group: anstest_group policy: anstest_policy state: present - name: Ensure first maintenance group node does not exist - aci_maintenance_group_node: &aci_maintenance_group_node_absent + cisco.aci.aci_maintenance_group_node: &aci_maintenance_group_node_absent <<: *aci_info group: anstest_group node: 1001 state: absent - name: Ensure second maintenance group node does not exist - aci_maintenance_group_node: &aci_maintenance_group_node_2_absent + cisco.aci.aci_maintenance_group_node: &aci_maintenance_group_node_2_absent <<: *aci_info group: anstest_group node: 1002 state: absent - name: Create first maintenance group node (check_mode) - aci_maintenance_group_node: &aci_maintenance_group_node_present + cisco.aci.aci_maintenance_group_node: &aci_maintenance_group_node_present <<: *aci_maintenance_group_node_absent state: present check_mode: true register: cm_add_maintenance_group_node_1 - name: Create first maintenance group node (normal_mode) - aci_maintenance_group_node: + cisco.aci.aci_maintenance_group_node: <<: *aci_maintenance_group_node_present register: nm_add_maintenance_group_node_1 - name: Create first maintenance group node again - testing idempotency - aci_maintenance_group_node: + cisco.aci.aci_maintenance_group_node: <<: *aci_maintenance_group_node_present register: idempotency_add_maintenance_group_node_1 - name: Create second maintenance group node - aci_maintenance_group_node: &aci_maintenance_group_node_2_present + cisco.aci.aci_maintenance_group_node: &aci_maintenance_group_node_2_present <<: *aci_maintenance_group_node_2_absent state: present register: nm_add_maintenance_group_node_2 - name: Asserts for creation tasks - assert: + ansible.builtin.assert: that: - cm_add_maintenance_group_node_1 is changed - cm_add_maintenance_group_node_1.previous == [] @@ -99,19 +99,19 @@ - name: Query all maintenance group nodes - aci_maintenance_group_node: + cisco.aci.aci_maintenance_group_node: <<: *aci_info state: query register: query_all_maintenance_group_node - name: Query first maintenance group nnode - aci_maintenance_group_node: + cisco.aci.aci_maintenance_group_node: <<: *aci_maintenance_group_node_present state: query register: query_first_maintenance_group_node - name: Asserts for query tasks - assert: + ansible.builtin.assert: that: - query_all_maintenance_group_node is not changed - query_all_maintenance_group_node.current | length >= 2 @@ -120,32 +120,32 @@ - query_first_maintenance_group_node.current.0.fabricNodeBlk.attributes.to_ == "1001" - name: Delete first maintenance group (check_mode) - aci_maintenance_group_node: + cisco.aci.aci_maintenance_group_node: <<: *aci_maintenance_group_node_present state: absent check_mode: true register: cm_delete_maintenance_group_node_1 - name: Delete first maintenance group (normal_mode) - aci_maintenance_group_node: + cisco.aci.aci_maintenance_group_node: <<: *aci_maintenance_group_node_present state: absent register: nm_delete_maintenance_group_node_1 - name: Delete first maintenance group again - testing idempotency - aci_maintenance_group_node: + cisco.aci.aci_maintenance_group_node: <<: *aci_maintenance_group_node_present state: absent register: idempotency_delete_maintenance_group_1 - name: Delete second maintenance group (normal_mode) - aci_maintenance_group_node: + cisco.aci.aci_maintenance_group_node: <<: *aci_maintenance_group_node_2_present state: absent register: nm_delete_maintenance_group_node_2 - name: Asserts for deletion tasks - assert: + ansible.builtin.assert: that: - cm_delete_maintenance_group_node_1 is changed - cm_delete_maintenance_group_node_1.proposed == {} @@ -159,16 +159,16 @@ - nm_delete_maintenance_group_node_2.current == [] - name: Delete maintenance group - clean up the environment - aci_maintenance_group: + cisco.aci.aci_maintenance_group: <<: *aci_maintenance_group_present state: absent - name: Delete maintenance policy - clean up the environment - aci_maintenance_policy: + cisco.aci.aci_maintenance_policy: <<: *aci_maintenance_policy_present state: absent - name: Delete scheduler - clean up the environment - aci_fabric_scheduler: + cisco.aci.aci_fabric_scheduler: <<: *aci_fabric_scheduler_present state: absent diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_maintenance_policy/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_maintenance_policy/tasks/main.yml index 8628c2a84..28abdbc72 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_maintenance_policy/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_maintenance_policy/tasks/main.yml @@ -4,12 +4,12 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: "{{ aci_hostname }}" username: "{{ aci_username }}" @@ -20,20 +20,20 @@ output_level: debug - name: Verify Cloud and Non-Cloud Sites in use. - include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml - name: Execute tasks only for non-cloud sites when: query_cloud.current == [] # This condition will execute only non-cloud sites block: # block specifies execution of tasks within, based on conditions # Clean Environment - name: Create Scheduler - aci_fabric_scheduler: &aci_fabric_scheduler_present + cisco.aci.aci_fabric_scheduler: &aci_fabric_scheduler_present <<: *aci_info name: anstest_scheduler state: present - name: Ensure first maintenance policy does not exist - aci_maintenance_policy: &aci_maintenance_policy_absent + cisco.aci.aci_maintenance_policy: &aci_maintenance_policy_absent <<: *aci_info name: anstest_policy description: test for maintenance policy @@ -49,37 +49,37 @@ state: absent - name: Ensure second maintenance policy does not exist - aci_maintenance_policy: &aci_maintenance_policy_2_absent + cisco.aci.aci_maintenance_policy: &aci_maintenance_policy_2_absent <<: *aci_info name: anstest_policy_2 scheduler: anstest_scheduler state: absent - name: Create first maintenance policy (check_mode) - aci_maintenance_policy: &aci_maintenance_policy_present + cisco.aci.aci_maintenance_policy: &aci_maintenance_policy_present <<: *aci_maintenance_policy_absent state: present check_mode: true register: cm_add_maintenance_policy_1 - name: Create first maintenance policy (normal_mode) - aci_maintenance_policy: + cisco.aci.aci_maintenance_policy: <<: *aci_maintenance_policy_present register: nm_add_maintenance_policy_1 - name: Create first maintenance policy again - testing idempotency - aci_maintenance_policy: + cisco.aci.aci_maintenance_policy: <<: *aci_maintenance_policy_present register: idempotency_add_maintenance_policy_1 - name: Create second maintenance policy - aci_maintenance_policy: &aci_maintenance_policy_2_present + cisco.aci.aci_maintenance_policy: &aci_maintenance_policy_2_present <<: *aci_maintenance_policy_2_absent state: present register: nm_add_maintenance_policy_2 - name: Asserts for creation tasks - assert: + ansible.builtin.assert: that: - cm_add_maintenance_policy_1 is changed - cm_add_maintenance_policy_1.previous == [] @@ -109,19 +109,19 @@ - nm_add_maintenance_policy_2.current.0.maintMaintP.children.0.maintRsPolScheduler.attributes.tnTrigSchedPName == "anstest_scheduler" - name: Query all maintenance policies - aci_maintenance_policy: + cisco.aci.aci_maintenance_policy: <<: *aci_info state: query register: query_all_maintenance_policy - name: Query first maintenance policy - aci_maintenance_policy: + cisco.aci.aci_maintenance_policy: <<: *aci_maintenance_policy_present state: query register: query_first_maintenance_policy - name: Asserts for query tasks - assert: + ansible.builtin.assert: that: - query_all_maintenance_policy is not changed - query_all_maintenance_policy.current | length >= 2 @@ -140,32 +140,32 @@ - query_first_maintenance_policy.current.0.maintMaintP.children.0.maintRsPolScheduler.attributes.tnTrigSchedPName == "anstest_scheduler" - name: Delete first maintenance policy (check_mode) - aci_maintenance_policy: + cisco.aci.aci_maintenance_policy: <<: *aci_maintenance_policy_present state: absent check_mode: true register: cm_delete_maintenance_policy_1 - name: Delete first maintenance policy (normal_mode) - aci_maintenance_policy: + cisco.aci.aci_maintenance_policy: <<: *aci_maintenance_policy_present state: absent register: nm_delete_maintenance_policy_1 - name: Delete first maintenance policy again - testing idempotency - aci_maintenance_policy: + cisco.aci.aci_maintenance_policy: <<: *aci_maintenance_policy_present state: absent register: idempotency_delete_maintenance_policy_1 - name: Delete second maintenance policy (normal_mode) - aci_maintenance_policy: + cisco.aci.aci_maintenance_policy: <<: *aci_maintenance_policy_2_present state: absent register: nm_delete_maintenance_policy_2 - name: Asserts for deletion tasks - assert: + ansible.builtin.assert: that: - cm_delete_maintenance_policy_1 is changed - cm_delete_maintenance_policy_1.proposed == {} @@ -179,6 +179,6 @@ - nm_delete_maintenance_policy_2.current == [] - name: Delete scheduler - clean up the environment - aci_fabric_scheduler: + cisco.aci.aci_fabric_scheduler: <<: *aci_fabric_scheduler_present state: absent diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_match_as_path_regex_term/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_match_as_path_regex_term/tasks/main.yml index cdabd8b4e..120acf12d 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_match_as_path_regex_term/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_match_as_path_regex_term/tasks/main.yml @@ -4,12 +4,12 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: "{{ aci_hostname }}" username: "{{ aci_username }}" @@ -21,26 +21,26 @@ # CLEAN ENVIRONMENT - name: Remove the ansible_tenant - aci_tenant: &aci_tenant_absent + cisco.aci.aci_tenant: &aci_tenant_absent <<: *aci_info tenant: ansible_tenant state: absent - name: Verify Cloud and Non-Cloud Sites in use. - include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml - name: Execute tasks only for non-cloud sites when: query_cloud.current == [] # This condition will execute only non-cloud sites block: # block specifies execution of tasks within, based on conditions - name: Add a new tenant - aci_tenant: &aci_tenant_present + cisco.aci.aci_tenant: &aci_tenant_present <<: *aci_info tenant: ansible_tenant description: Ansible tenant state: present - name: Add a match rule profile - aci_match_rule: + cisco.aci.aci_match_rule: <<: *aci_info tenant: ansible_tenant match_rule: ansible_match_rule @@ -49,7 +49,7 @@ register: cm_add_match_rule - name: Add a match regex AS-Path term (check_mode) - aci_match_as_path_regex_term: &aci_match_as_path_regex_term_present + cisco.aci.aci_match_as_path_regex_term: &aci_match_as_path_regex_term_present <<: *aci_info tenant: ansible_tenant match_rule: ansible_match_rule @@ -61,17 +61,17 @@ register: cm_add_match_as_path_regex_term - name: Add a match regex AS-Path term (normal_mode) - aci_match_as_path_regex_term: + cisco.aci.aci_match_as_path_regex_term: <<: *aci_match_as_path_regex_term_present register: nm_add_match_as_path_regex_term - name: Add the first match regex AS-Path term again - testing idempotency - aci_match_as_path_regex_term: + cisco.aci.aci_match_as_path_regex_term: <<: *aci_match_as_path_regex_term_present register: nm_add_match_as_path_regex_term_idempotency - name: Add a second match regex AS-Path term (normal_mode) - aci_match_as_path_regex_term: + cisco.aci.aci_match_as_path_regex_term: <<: *aci_info tenant: ansible_tenant match_rule: ansible_match_rule @@ -81,7 +81,7 @@ register: nm_add_match_as_path_regex_term_2 - name: Asserts for match regex AS-Path terms creation tasks - assert: + ansible.builtin.assert: that: - cm_add_match_as_path_regex_term is changed - cm_add_match_as_path_regex_term.previous == [] @@ -96,19 +96,19 @@ - nm_add_match_as_path_regex_term_2.current.0.rtctrlMatchAsPathRegexTerm.attributes.regex == "" - name: Query all match regex AS-Path terms - aci_match_as_path_regex_term: + cisco.aci.aci_match_as_path_regex_term: <<: *aci_info state: query register: query_all_match_as_path_regex_term - name: Query ansible_match_as_path_regex_term_1 - aci_match_as_path_regex_term: + cisco.aci.aci_match_as_path_regex_term: <<: *aci_match_as_path_regex_term_present state: query register: query_ansible_match_as_path_regex_term_1 - name: Asserts query tasks - assert: + ansible.builtin.assert: that: - query_all_match_as_path_regex_term is not changed - query_all_match_as_path_regex_term.current|length >= 2 @@ -117,24 +117,24 @@ - query_ansible_match_as_path_regex_term_1.current.0.rtctrlMatchAsPathRegexTerm.attributes.regex == ".*" - name: Remove match regex AS-Path term for l3out (check_mode) - aci_match_as_path_regex_term: &match_as_path_regex_term_absent + cisco.aci.aci_match_as_path_regex_term: &match_as_path_regex_term_absent <<: *aci_match_as_path_regex_term_present state: absent check_mode: true register: cm_remove_match_as_path_regex_term - name: Remove match regex AS-Path term for l3out (normal_mode) - aci_match_as_path_regex_term: + cisco.aci.aci_match_as_path_regex_term: <<: *match_as_path_regex_term_absent register: nm_remove_match_as_path_regex_term - name: Remove match regex AS-Path term for l3out again - testing previous Removal - aci_match_as_path_regex_term: + cisco.aci.aci_match_as_path_regex_term: <<: *match_as_path_regex_term_absent register: nm_remove_match_as_path_regex_term_idempotency - name: Asserts deletion tasks - assert: + ansible.builtin.assert: that: - cm_remove_match_as_path_regex_term is changed - cm_remove_match_as_path_regex_term.proposed == {} @@ -145,6 +145,6 @@ - nm_remove_match_as_path_regex_term_idempotency.previous == [] - name: Remove the ansible_tenant - cleanup before ending tests - aci_tenant: + cisco.aci.aci_tenant: <<: *aci_tenant_present state: absent diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_match_community_factor/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_match_community_factor/tasks/main.yml index 2cc1f3ac1..22a69dcfe 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_match_community_factor/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_match_community_factor/tasks/main.yml @@ -4,12 +4,12 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: "{{ aci_hostname }}" username: "{{ aci_username }}" @@ -21,26 +21,26 @@ # CLEAN ENVIRONMENT - name: Remove the ansible_tenant - aci_tenant: &aci_tenant_absent + cisco.aci.aci_tenant: &aci_tenant_absent <<: *aci_info tenant: ansible_tenant state: absent - name: Verify Cloud and Non-Cloud Sites in use. - include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml - name: Execute tasks only for non-cloud sites when: query_cloud.current == [] # This condition will execute only non-cloud sites block: # block specifies execution of tasks within, based on conditions - name: Add a new tenant - aci_tenant: &aci_tenant_present + cisco.aci.aci_tenant: &aci_tenant_present <<: *aci_info tenant: ansible_tenant description: Ansible tenant state: present - name: Add a match rule profile - aci_match_rule: + cisco.aci.aci_match_rule: <<: *aci_info tenant: ansible_tenant match_rule: ansible_match_rule @@ -48,7 +48,7 @@ state: present - name: Add a match community term - aci_match_community_term: + cisco.aci.aci_match_community_term: <<: *aci_info tenant: ansible_tenant match_rule: ansible_match_rule @@ -57,7 +57,7 @@ state: present - name: Add a match community factor (check_mode) - aci_match_community_factor: &aci_match_community_factor_present + cisco.aci.aci_match_community_factor: &aci_match_community_factor_present <<: *aci_info tenant: ansible_tenant match_rule: ansible_match_rule @@ -70,17 +70,17 @@ register: cm_add_match_community_factor - name: Add a match community factor (normal_mode) - aci_match_community_factor: + cisco.aci.aci_match_community_factor: <<: *aci_match_community_factor_present register: nm_add_match_community_factor - name: Add the first match community factor again - testing idempotency - aci_match_community_factor: + cisco.aci.aci_match_community_factor: <<: *aci_match_community_factor_present register: nm_add_match_community_factor_idempotency - name: Add a second match community factor (normal_mode) - aci_match_community_factor: + cisco.aci.aci_match_community_factor: <<: *aci_info tenant: ansible_tenant match_rule: ansible_match_rule @@ -91,7 +91,7 @@ register: nm_add_match_community_factor_2 - name: Asserts for match community factors creation tasks - assert: + ansible.builtin.assert: that: - cm_add_match_community_factor is changed - cm_add_match_community_factor.previous == [] @@ -104,19 +104,19 @@ - nm_add_match_community_factor_2.current.0.rtctrlMatchCommFactor.attributes.community == "regular:as2-nn2:4:16" - name: Query all match community factors - aci_match_community_factor: + cisco.aci.aci_match_community_factor: <<: *aci_info state: query register: query_all_match_community_factor - name: Query a specific match community factor - aci_match_community_factor: + cisco.aci.aci_match_community_factor: <<: *aci_match_community_factor_present state: query register: query_ansible_match_community_factor_1 - name: Asserts query tasks - assert: + ansible.builtin.assert: that: - query_all_match_community_factor is not changed - query_all_match_community_factor.current|length >= 2 @@ -124,24 +124,24 @@ - query_ansible_match_community_factor_1.current.0.rtctrlMatchCommFactor.attributes.community == "regular:as2-nn2:4:15" - name: Remove match community factor (check_mode) - aci_match_community_factor: &match_community_term_absent + cisco.aci.aci_match_community_factor: &match_community_term_absent <<: *aci_match_community_factor_present state: absent check_mode: true register: cm_remove_match_community_factor - name: Remove match community factor (normal_mode) - aci_match_community_factor: + cisco.aci.aci_match_community_factor: <<: *match_community_term_absent register: nm_remove_match_community_factor - name: Remove match community factor again - testing previous Removal - aci_match_community_factor: + cisco.aci.aci_match_community_factor: <<: *match_community_term_absent register: nm_remove_match_community_factor_idempotency - name: Asserts deletion tasks - assert: + ansible.builtin.assert: that: - cm_remove_match_community_factor is changed - cm_remove_match_community_factor.proposed == {} @@ -152,6 +152,6 @@ - nm_remove_match_community_factor_idempotency.previous == [] - name: Remove the ansible_tenant - cleanup before ending tests - aci_tenant: + cisco.aci.aci_tenant: <<: *aci_tenant_present state: absent diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_match_community_regex_term/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_match_community_regex_term/tasks/main.yml index c0b12c78c..264a04afa 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_match_community_regex_term/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_match_community_regex_term/tasks/main.yml @@ -4,12 +4,12 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: "{{ aci_hostname }}" username: "{{ aci_username }}" @@ -21,26 +21,26 @@ # CLEAN ENVIRONMENT - name: Remove the ansible_tenant - aci_tenant: &aci_tenant_absent + cisco.aci.aci_tenant: &aci_tenant_absent <<: *aci_info tenant: ansible_tenant state: absent - name: Verify Cloud and Non-Cloud Sites in use. - include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml - name: Execute tasks only for non-cloud sites when: query_cloud.current == [] # This condition will execute only non-cloud sites block: # block specifies execution of tasks within, based on conditions - name: Add a new tenant - aci_tenant: &aci_tenant_present + cisco.aci.aci_tenant: &aci_tenant_present <<: *aci_info tenant: ansible_tenant description: Ansible tenant state: present - name: Add a match rule profile - aci_match_rule: + cisco.aci.aci_match_rule: <<: *aci_info tenant: ansible_tenant match_rule: ansible_match_rule @@ -49,7 +49,7 @@ register: cm_add_match_rule - name: Add a match community regex term (check_mode) - aci_match_community_regex_term: &aci_match_community_regex_term_present + cisco.aci.aci_match_community_regex_term: &aci_match_community_regex_term_present <<: *aci_info tenant: ansible_tenant match_rule: ansible_match_rule @@ -62,17 +62,17 @@ register: cm_add_match_community_regex_term - name: Add a match community regex term (normal_mode) - aci_match_community_regex_term: + cisco.aci.aci_match_community_regex_term: <<: *aci_match_community_regex_term_present register: nm_add_match_community_regex_term - name: Add the first match community regex term again - testing idempotency - aci_match_community_regex_term: + cisco.aci.aci_match_community_regex_term: <<: *aci_match_community_regex_term_present register: nm_add_match_community_regex_term_idempotency - name: Add a second match community regex term (normal_mode) - aci_match_community_regex_term: &aci_match_community_regex_term_2_present + cisco.aci.aci_match_community_regex_term: &aci_match_community_regex_term_2_present <<: *aci_info tenant: ansible_tenant match_rule: ansible_match_rule @@ -81,7 +81,7 @@ register: nm_add_match_community_regex_term_2 - name: Asserts for match community regex terms creation tasks - assert: + ansible.builtin.assert: that: - cm_add_match_community_regex_term is changed - cm_add_match_community_regex_term.previous == [] @@ -97,20 +97,20 @@ - nm_add_match_community_regex_term_2.current.0.rtctrlMatchCommRegexTerm.attributes.commType == "regular" - name: Query all match community regex terms - aci_match_community_regex_term: + cisco.aci.aci_match_community_regex_term: <<: *aci_info state: query community_type: extended register: query_all_match_community_regex_term - name: Query ansible_match_community_regex_term_regular - aci_match_community_regex_term: + cisco.aci.aci_match_community_regex_term: <<: *aci_match_community_regex_term_2_present state: query register: query_ansible_match_community_regex_term_regular - name: Asserts query tasks - assert: + ansible.builtin.assert: that: - query_all_match_community_regex_term is not changed - query_all_match_community_regex_term.current.0.rtctrlMatchCommRegexTerm.attributes.commType == "extended" @@ -119,24 +119,24 @@ - query_ansible_match_community_regex_term_regular.current.0.rtctrlMatchCommRegexTerm.attributes.commType == "regular" - name: Remove match community regex term (check_mode) - aci_match_community_regex_term: &match_community_regex_term_absent + cisco.aci.aci_match_community_regex_term: &match_community_regex_term_absent <<: *aci_match_community_regex_term_present state: absent check_mode: true register: cm_remove_match_community_regex_term - name: Remove match community regex term (normal_mode) - aci_match_community_regex_term: + cisco.aci.aci_match_community_regex_term: <<: *match_community_regex_term_absent register: nm_remove_match_community_regex_term - name: Remove match community regex term again - testing previous Removal - aci_match_community_regex_term: + cisco.aci.aci_match_community_regex_term: <<: *match_community_regex_term_absent register: nm_remove_match_community_regex_term_idempotency - name: Asserts deletion tasks - assert: + ansible.builtin.assert: that: - cm_remove_match_community_regex_term is changed - cm_remove_match_community_regex_term.proposed == {} @@ -147,6 +147,6 @@ - nm_remove_match_community_regex_term_idempotency.previous == [] - name: Remove the ansible_tenant - cleanup before ending tests - aci_tenant: + cisco.aci.aci_tenant: <<: *aci_tenant_present state: absent
\ No newline at end of file diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_match_community_term/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_match_community_term/tasks/main.yml index aecf89096..038abb761 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_match_community_term/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_match_community_term/tasks/main.yml @@ -4,12 +4,12 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: "{{ aci_hostname }}" username: "{{ aci_username }}" @@ -21,26 +21,26 @@ # CLEAN ENVIRONMENT - name: Remove the ansible_tenant - aci_tenant: &aci_tenant_absent + cisco.aci.aci_tenant: &aci_tenant_absent <<: *aci_info tenant: ansible_tenant state: absent - name: Verify Cloud and Non-Cloud Sites in use. - include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml - name: Execute tasks only for non-cloud sites when: query_cloud.current == [] # This condition will execute only non-cloud sites block: # block specifies execution of tasks within, based on conditions - name: Add a new tenant - aci_tenant: &aci_tenant_present + cisco.aci.aci_tenant: &aci_tenant_present <<: *aci_info tenant: ansible_tenant description: Ansible tenant state: present - name: Add a match rule profile - aci_match_rule: + cisco.aci.aci_match_rule: <<: *aci_info tenant: ansible_tenant match_rule: ansible_match_rule @@ -49,7 +49,7 @@ register: cm_add_match_rule - name: Add a match community term (check_mode) - aci_match_community_term: &aci_match_community_term_present + cisco.aci.aci_match_community_term: &aci_match_community_term_present <<: *aci_info tenant: ansible_tenant match_rule: ansible_match_rule @@ -60,17 +60,17 @@ register: cm_add_match_community_term - name: Add a match community term (normal_mode) - aci_match_community_term: + cisco.aci.aci_match_community_term: <<: *aci_match_community_term_present register: nm_add_match_community_term - name: Add the first match community term again - testing idempotency - aci_match_community_term: + cisco.aci.aci_match_community_term: <<: *aci_match_community_term_present register: nm_add_match_community_term_idempotency - name: Add a second match community term (normal_mode) - aci_match_community_term: + cisco.aci.aci_match_community_term: <<: *aci_info tenant: ansible_tenant match_rule: ansible_match_rule @@ -80,7 +80,7 @@ register: nm_add_match_community_term_2 - name: Asserts for match community terms creation tasks - assert: + ansible.builtin.assert: that: - cm_add_match_community_term is changed - cm_add_match_community_term.previous == [] @@ -93,19 +93,19 @@ - nm_add_match_community_term_2.current.0.rtctrlMatchCommTerm.attributes.name == "ansible_match_community_term_2" - name: Query all match community terms - aci_match_community_term: + cisco.aci.aci_match_community_term: <<: *aci_info state: query register: query_all_match_community_term - name: Query ansible_match_community_term_1 - aci_match_community_term: + cisco.aci.aci_match_community_term: <<: *aci_match_community_term_present state: query register: query_ansible_match_community_term_1 - name: Asserts query tasks - assert: + ansible.builtin.assert: that: - query_all_match_community_term is not changed - query_all_match_community_term.current|length >= 2 @@ -113,24 +113,24 @@ - query_ansible_match_community_term_1.current.0.rtctrlMatchCommTerm.attributes.name == "ansible_match_community_term_1" - name: Remove match community term (check_mode) - aci_match_community_term: &match_community_term_absent + cisco.aci.aci_match_community_term: &match_community_term_absent <<: *aci_match_community_term_present state: absent check_mode: true register: cm_remove_match_community_term - name: Remove match community term (normal_mode) - aci_match_community_term: + cisco.aci.aci_match_community_term: <<: *match_community_term_absent register: nm_remove_match_community_term - name: Remove match community term again - testing previous Removal - aci_match_community_term: + cisco.aci.aci_match_community_term: <<: *match_community_term_absent register: nm_remove_match_community_term_idempotency - name: Asserts deletion tasks - assert: + ansible.builtin.assert: that: - cm_remove_match_community_term is changed - cm_remove_match_community_term.proposed == {} @@ -141,6 +141,6 @@ - nm_remove_match_community_term_idempotency.previous == [] - name: Remove the ansible_tenant - cleanup before ending tests - aci_tenant: + cisco.aci.aci_tenant: <<: *aci_tenant_present state: absent diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_match_route_destination/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_match_route_destination/tasks/main.yml index b4d49c2ff..54d906952 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_match_route_destination/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_match_route_destination/tasks/main.yml @@ -5,12 +5,12 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: "{{ aci_hostname }}" username: "{{ aci_username }}" @@ -22,26 +22,26 @@ # CLEAN ENVIRONMENT - name: Remove the ansible_tenant - aci_tenant: &aci_tenant_absent + cisco.aci.aci_tenant: &aci_tenant_absent <<: *aci_info tenant: ansible_tenant state: absent - name: Verify Cloud and Non-Cloud Sites in use. - include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml - name: Execute tasks only for non-cloud sites when: query_cloud.current == [] # This condition will execute only non-cloud sites block: # block specifies execution of tasks within, based on conditions - name: Add a new tenant - aci_tenant: &aci_tenant_present + cisco.aci.aci_tenant: &aci_tenant_present <<: *aci_info tenant: ansible_tenant description: Ansible tenant state: present - name: Add a match rule profile - aci_match_rule: + cisco.aci.aci_match_rule: <<: *aci_info tenant: ansible_tenant match_rule: ansible_match_rule @@ -50,7 +50,7 @@ register: cm_add_match_rule - name: Add a match route destination rule (check_mode) - aci_match_route_destination: &aci_match_route_destination_present + cisco.aci.aci_match_route_destination: &aci_match_route_destination_present <<: *aci_info tenant: ansible_tenant match_rule: ansible_match_rule @@ -64,17 +64,17 @@ register: cm_add_match_route_destination - name: Add a match route destination rule (normal_mode) - aci_match_route_destination: + cisco.aci.aci_match_route_destination: <<: *aci_match_route_destination_present register: nm_add_match_route_destination - name: Add the first match route destination rule again - testing idempotency - aci_match_route_destination: + cisco.aci.aci_match_route_destination: <<: *aci_match_route_destination_present register: nm_add_match_route_destination_idempotency - name: Add a second match route destination rule (normal_mode) - aci_match_route_destination: + cisco.aci.aci_match_route_destination: <<: *aci_info tenant: ansible_tenant match_rule: ansible_match_rule @@ -84,7 +84,7 @@ register: nm_add_match_route_destination_2 - name: Asserts for match route destination rule creation tasks - assert: + ansible.builtin.assert: that: - cm_add_match_route_destination is changed - cm_add_match_route_destination.previous == [] @@ -103,19 +103,19 @@ - nm_add_match_route_destination_2.current.0.rtctrlMatchRtDest.attributes.toPfxLen == "0" - name: Query all match regex AS-Path terms - aci_match_route_destination: + cisco.aci.aci_match_route_destination: <<: *aci_info state: query register: query_all_match_route_destination - name: Query ansible_match_route_destination_1 - aci_match_route_destination: + cisco.aci.aci_match_route_destination: <<: *aci_match_route_destination_present state: query register: query_ansible_match_route_destination_1 - name: Asserts query tasks - assert: + ansible.builtin.assert: that: - query_all_match_route_destination is not changed - query_all_match_route_destination.current|length >= 2 @@ -126,24 +126,24 @@ - query_ansible_match_route_destination_1.current.0.rtctrlMatchRtDest.attributes.toPfxLen == "32" - name: Remove match route destination rule (check_mode) - aci_match_route_destination: &match_route_destination_absent + cisco.aci.aci_match_route_destination: &match_route_destination_absent <<: *aci_match_route_destination_present state: absent check_mode: true register: cm_remove_match_route_destination - name: Remove match route destination rule (normal_mode) - aci_match_route_destination: + cisco.aci.aci_match_route_destination: <<: *match_route_destination_absent register: nm_remove_match_route_destination - name: Remove match route destination rule again - testing previous Removal - aci_match_route_destination: + cisco.aci.aci_match_route_destination: <<: *match_route_destination_absent register: nm_remove_match_route_destination_idempotency - name: Asserts deletion tasks - assert: + ansible.builtin.assert: that: - cm_remove_match_route_destination is changed - cm_remove_match_route_destination.proposed == {} @@ -154,6 +154,6 @@ - nm_remove_match_route_destination_idempotency.previous == [] - name: Remove the ansible_tenant - cleanup before ending tests - aci_tenant: + cisco.aci.aci_tenant: <<: *aci_tenant_present state: absent
\ No newline at end of file diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_match_rule/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_match_rule/tasks/main.yml index 23509494c..4d453d017 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_match_rule/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_match_rule/tasks/main.yml @@ -5,12 +5,12 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: "{{ aci_hostname }}" username: "{{ aci_username }}" @@ -22,26 +22,26 @@ # CLEAN ENVIRONMENT - name: Remove the ansible_tenant - aci_tenant: &aci_tenant_absent + cisco.aci.aci_tenant: &aci_tenant_absent <<: *aci_info tenant: ansible_tenant state: absent - name: Verify Cloud and Non-Cloud Sites in use. - include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml - name: Execute tasks only for non-cloud sites when: query_cloud.current == [] # This condition will execute only non-cloud sites block: # block specifies execution of tasks within, based on conditions - name: Add a new tenant - aci_tenant: &aci_tenant_present + cisco.aci.aci_tenant: &aci_tenant_present <<: *aci_info tenant: ansible_tenant description: Ansible tenant state: present - name: Add a match rule profile (check_mode) - aci_match_rule: &aci_match_rule_present + cisco.aci.aci_match_rule: &aci_match_rule_present <<: *aci_info tenant: ansible_tenant match_rule: ansible_match_rule_1 @@ -51,17 +51,17 @@ register: cm_add_match_rule - name: Add a match rule profile (normal_mode) - aci_match_rule: + cisco.aci.aci_match_rule: <<: *aci_match_rule_present register: nm_add_match_rule - name: Add the first match rule profile again - testing idempotency - aci_match_rule: + cisco.aci.aci_match_rule: <<: *aci_match_rule_present register: nm_add_match_rule_idempotency - name: Add a second match rule profile (normal_mode) - aci_match_rule: + cisco.aci.aci_match_rule: <<: *aci_info tenant: ansible_tenant match_rule: ansible_match_rule_2 @@ -70,7 +70,7 @@ register: nm_add_match_rule_2 - name: Asserts for match rule profiles creation tasks - assert: + ansible.builtin.assert: that: - cm_add_match_rule is changed - cm_add_match_rule.previous == [] @@ -83,19 +83,19 @@ - nm_add_match_rule_2.current.0.rtctrlSubjP.attributes.name == "ansible_match_rule_2" - name: Query all match rule profiles - aci_match_rule: + cisco.aci.aci_match_rule: <<: *aci_info state: query register: query_all_match_rule - name: Query ansible_match_rule_1 - aci_match_rule: + cisco.aci.aci_match_rule: <<: *aci_match_rule_present state: query register: query_ansible_match_rule_1 - name: Asserts query tasks - assert: + ansible.builtin.assert: that: - query_all_match_rule is not changed - query_all_match_rule.current|length >= 2 @@ -103,24 +103,24 @@ - query_ansible_match_rule_1.current.0.rtctrlSubjP.attributes.name == "ansible_match_rule_1" - name: Remove match rule profile for l3out (check_mode) - aci_match_rule: &match_rule_absent + cisco.aci.aci_match_rule: &match_rule_absent <<: *aci_match_rule_present state: absent check_mode: true register: cm_remove_match_rule - name: Remove match rule profile for l3out (normal_mode) - aci_match_rule: + cisco.aci.aci_match_rule: <<: *match_rule_absent register: nm_remove_match_rule - name: Remove match rule profile for l3out again - testing previous Removal - aci_match_rule: + cisco.aci.aci_match_rule: <<: *match_rule_absent register: nm_remove_match_rule_idempotency - name: Asserts deletion tasks - assert: + ansible.builtin.assert: that: - cm_remove_match_rule is changed - cm_remove_match_rule.proposed == {} @@ -131,6 +131,6 @@ - nm_remove_match_rule_idempotency.previous == [] - name: Remove the ansible_tenant - cleanup before ending tests - aci_tenant: + cisco.aci.aci_tenant: <<: *aci_tenant_present state: absent diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_netflow_exporter_policy/aliases b/ansible_collections/cisco/aci/tests/integration/targets/aci_netflow_exporter_policy/aliases new file mode 100644 index 000000000..209b793f9 --- /dev/null +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_netflow_exporter_policy/aliases @@ -0,0 +1,2 @@ +# No ACI simulator yet, so not enabled +# unsupported diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_netflow_exporter_policy/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_netflow_exporter_policy/tasks/main.yml new file mode 100644 index 000000000..a5b58cb39 --- /dev/null +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_netflow_exporter_policy/tasks/main.yml @@ -0,0 +1,337 @@ +# Test code for the ACI modules +# Copyright: (c) 2023, Gaspard Micol (@gmicol) <gmicol@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 APIC host, ACI username and ACI password + ansible.builtin.fail: + msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' + when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined + +- name: Set vars + ansible.builtin.set_fact: + aci_info: &aci_info + host: "{{ aci_hostname }}" + username: "{{ aci_username }}" + password: "{{ aci_password }}" + validate_certs: '{{ aci_validate_certs | default(false) }}' + use_ssl: '{{ aci_use_ssl | default(true) }}' + use_proxy: '{{ aci_use_proxy | default(true) }}' + output_level: '{{ aci_output_level | default("info") }}' + +# CLEAN ENVIRONMENT BEFORE TESTS +- name: Remove the ansible_tenant + cisco.aci.aci_tenant: &aci_tenant_absent + <<: *aci_info + tenant: ansible_tenant + state: absent + +- name: Verify Cloud and Non-Cloud Sites in use. + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + +- name: Execute tasks only for non-cloud sites + when: query_cloud.current == [] # This condition will execute only non-cloud sites + block: # block specifies execution of tasks within, based on conditions + - name: Add a new tenant + cisco.aci.aci_tenant: &aci_tenant_present + <<: *aci_info + tenant: ansible_tenant + description: Ansible tenant + state: present + + - name: Add a new VRF + cisco.aci.aci_vrf: + <<: *aci_info + tenant: ansible_tenant + vrf: ansible_vrf + description: ansible VRF for ansible_tenant tenant + state: present + + - name: Add a new Application Profile + cisco.aci.aci_ap: + <<: *aci_info + tenant: ansible_tenant + ap: ansible_ap + description: ansible Application Profile for ansible_tenant tenant + state: present + + - name: Add a new EPG + cisco.aci.aci_epg: + <<: *aci_info + tenant: ansible_tenant + ap: ansible_ap + epg: ansible_epg + description: ansible EPG for ansible_ap Application Profile + state: present + + - name: Add a new L3Out + cisco.aci.aci_l3out: + <<: *aci_info + tenant: ansible_tenant + vrf: ansible_vrf + domain: ansible_dom + l3out: ansible_l3out + description: ansible L3Out for ansible_tenant tenant + state: present + + - name: Add a new External EPG + cisco.aci.aci_l3out_extepg: + <<: *aci_info + tenant: ansible_tenant + extepg: ansible_extepg + l3out: ansible_l3out + description: ansible External EPG for ansible_l3out L3Out + state: present + + # CREATE NETFLOW EXPORTER POLICY + - name: Add a Netflow Exporter policy (check_mode) + cisco.aci.aci_netflow_exporter_policy: &aci_netflow_exporter_policy_present + <<: *aci_info + tenant: ansible_tenant + netflow_exporter_policy: ansible_netflow_exporter_policy_1 + description: Netflow Exporter policy 1 for ansible_tenant tenant + dscp: AF12 + destination_address: 11.11.11.1 + destination_port: smtp + source_ip_type: inband_management_ip + associated_epg: + tenant: ansible_tenant + ap: ansible_ap + epg: ansible_epg + state: present + associated_vrf: + tenant: ansible_tenant + vrf: ansible_vrf + check_mode: true + register: cm_add_netflow_exporter_policy + + - name: Add a Netflow Exporter policy (normal_mode) + cisco.aci.aci_netflow_exporter_policy: + <<: *aci_netflow_exporter_policy_present + register: nm_add_netflow_exporter_policy + + - name: Add the first Netflow Exporter policy again - testing idempotency + cisco.aci.aci_netflow_exporter_policy: + <<: *aci_netflow_exporter_policy_present + register: nm_add_netflow_exporter_policy_idempotency + + - name: Add a second Netflow Exporter policy (normal_mode) + cisco.aci.aci_netflow_exporter_policy: &aci_netflow_exporter_policy_2_present + <<: *aci_info + tenant: ansible_tenant + netflow_exporter_policy: ansible_netflow_exporter_policy_2 + description: Netflow Exporter policy 2 for ansible_tenant tenant + dscp: CS2 + destination_address: 11.11.11.2 + destination_port: https + custom_source_address: 12.12.12.2/12 + associated_extepg: + tenant: ansible_tenant + l3out: ansible_l3out + extepg: ansible_extepg + state: present + register: nm_add_netflow_exporter_policy_2 + + - name: Asserts for Netflow Exporter policy creation tasks + ansible.builtin.assert: + that: + - cm_add_netflow_exporter_policy is changed + - cm_add_netflow_exporter_policy.previous == [] + - cm_add_netflow_exporter_policy.current == [] + - cm_add_netflow_exporter_policy.proposed.netflowExporterPol.attributes.name == "ansible_netflow_exporter_policy_1" + - cm_add_netflow_exporter_policy.proposed.netflowExporterPol.attributes.dscp == "AF12" + - cm_add_netflow_exporter_policy.proposed.netflowExporterPol.attributes.dstAddr == "11.11.11.1" + - cm_add_netflow_exporter_policy.proposed.netflowExporterPol.attributes.dstPort == "smtp" + - cm_add_netflow_exporter_policy.proposed.netflowExporterPol.attributes.sourceIpType == "inband-mgmt-ip" + - cm_add_netflow_exporter_policy.proposed.netflowExporterPol.children.0.netflowRsExporterToCtx.attributes.tDn == "uni/tn-ansible_tenant/ctx-ansible_vrf" + - cm_add_netflow_exporter_policy.proposed.netflowExporterPol.children.1.netflowRsExporterToEPg.attributes.tDn == "uni/tn-ansible_tenant/ap-ansible_ap/epg-ansible_epg" + - nm_add_netflow_exporter_policy is changed + - nm_add_netflow_exporter_policy.previous == [] + - nm_add_netflow_exporter_policy.current.0.netflowExporterPol.attributes.name == "ansible_netflow_exporter_policy_1" + - nm_add_netflow_exporter_policy.current.0.netflowExporterPol.attributes.dscp == "AF12" + - nm_add_netflow_exporter_policy.current.0.netflowExporterPol.attributes.dstAddr == "11.11.11.1" + - nm_add_netflow_exporter_policy.current.0.netflowExporterPol.attributes.dstPort == "smtp" + - nm_add_netflow_exporter_policy.current.0.netflowExporterPol.attributes.sourceIpType == "inband-mgmt-ip" + - nm_add_netflow_exporter_policy.current.0.netflowExporterPol.attributes.srcAddr == "0.0.0.0" + - nm_add_netflow_exporter_policy.current.0.netflowExporterPol.children.0.netflowRsExporterToCtx.attributes.tDn == "uni/tn-ansible_tenant/ctx-ansible_vrf" + - nm_add_netflow_exporter_policy.current.0.netflowExporterPol.children.1.netflowRsExporterToEPg.attributes.tDn == "uni/tn-ansible_tenant/ap-ansible_ap/epg-ansible_epg" + - nm_add_netflow_exporter_policy_idempotency is not changed + - nm_add_netflow_exporter_policy_idempotency.current.0.netflowExporterPol.attributes.name == "ansible_netflow_exporter_policy_1" + - nm_add_netflow_exporter_policy_idempotency.current.0.netflowExporterPol.attributes.dscp == "AF12" + - nm_add_netflow_exporter_policy_idempotency.current.0.netflowExporterPol.attributes.dstAddr == "11.11.11.1" + - nm_add_netflow_exporter_policy_idempotency.current.0.netflowExporterPol.attributes.dstPort == "smtp" + - nm_add_netflow_exporter_policy_idempotency.current.0.netflowExporterPol.attributes.sourceIpType == "inband-mgmt-ip" + - nm_add_netflow_exporter_policy_idempotency.current.0.netflowExporterPol.attributes.srcAddr == "0.0.0.0" + - nm_add_netflow_exporter_policy_idempotency.current.0.netflowExporterPol.children.0.netflowRsExporterToCtx.attributes.tDn == "uni/tn-ansible_tenant/ctx-ansible_vrf" + - nm_add_netflow_exporter_policy_idempotency.current.0.netflowExporterPol.children.1.netflowRsExporterToEPg.attributes.tDn == "uni/tn-ansible_tenant/ap-ansible_ap/epg-ansible_epg" + - nm_add_netflow_exporter_policy_2 is changed + - nm_add_netflow_exporter_policy_2.previous == [] + - nm_add_netflow_exporter_policy_2.current.0.netflowExporterPol.attributes.name == "ansible_netflow_exporter_policy_2" + - nm_add_netflow_exporter_policy_2.current.0.netflowExporterPol.attributes.dscp == "CS2" + - nm_add_netflow_exporter_policy_2.current.0.netflowExporterPol.attributes.dstAddr == "11.11.11.2" + - nm_add_netflow_exporter_policy_2.current.0.netflowExporterPol.attributes.dstPort == "https" + - nm_add_netflow_exporter_policy_2.current.0.netflowExporterPol.attributes.sourceIpType == "custom-src-ip" + - nm_add_netflow_exporter_policy_2.current.0.netflowExporterPol.attributes.srcAddr == "12.12.12.2/12" + - nm_add_netflow_exporter_policy_2.current.0.netflowExporterPol.children.0.netflowRsExporterToEPg.attributes.tDn == "uni/tn-ansible_tenant/out-ansible_l3out/instP-ansible_extepg" + + # QUERY NETFLOW EXPORTER POLICY + - name: Query all Netflow Exporter policies + cisco.aci.aci_netflow_exporter_policy: + <<: *aci_info + state: query + register: query_all_netflow_exporter_policy + + - name: Query ansible_netflow_exporter_policy_1 + cisco.aci.aci_netflow_exporter_policy: + <<: *aci_netflow_exporter_policy_present + state: query + register: query_ansible_netflow_exporter_policy_1 + + - name: Asserts query tasks + ansible.builtin.assert: + that: + - query_all_netflow_exporter_policy is not changed + - query_all_netflow_exporter_policy.current|length >= 2 + - query_ansible_netflow_exporter_policy_1 is not changed + - query_ansible_netflow_exporter_policy_1.current|length == 1 + - query_ansible_netflow_exporter_policy_1.current.0.netflowExporterPol.attributes.name == "ansible_netflow_exporter_policy_1" + - query_ansible_netflow_exporter_policy_1.current.0.netflowExporterPol.attributes.dscp == "AF12" + - query_ansible_netflow_exporter_policy_1.current.0.netflowExporterPol.attributes.dstAddr == "11.11.11.1" + - query_ansible_netflow_exporter_policy_1.current.0.netflowExporterPol.attributes.dstPort == "smtp" + - query_ansible_netflow_exporter_policy_1.current.0.netflowExporterPol.attributes.sourceIpType == "inband-mgmt-ip" + - query_ansible_netflow_exporter_policy_1.current.0.netflowExporterPol.attributes.srcAddr == "0.0.0.0" + - query_ansible_netflow_exporter_policy_1.current.0.netflowExporterPol.children.0.netflowRsExporterToCtx.attributes.tDn == "uni/tn-ansible_tenant/ctx-ansible_vrf" + - query_ansible_netflow_exporter_policy_1.current.0.netflowExporterPol.children.1.netflowRsExporterToEPg.attributes.tDn == "uni/tn-ansible_tenant/ap-ansible_ap/epg-ansible_epg" + + #REMOVE ASSOCIATED EPG/EXTERNAL EPG FROM NETFLOW EXPORTER POLICIES + - name: Remove associated EPG from first Netflow Exporter policy (check_mode) + cisco.aci.aci_netflow_exporter_policy: &aci_netflow_exporter_policy_remove_epg + <<: *aci_netflow_exporter_policy_present + associated_epg: {} + associated_vrf: {} + check_mode: true + register: cm_remove_epg_netflow_exporter_policy + + - name: Remove associated EPG from first Netflow Exporter policy (normal_mode) + cisco.aci.aci_netflow_exporter_policy: + <<: *aci_netflow_exporter_policy_remove_epg + register: nm_remove_epg_netflow_exporter_policy + + - name: Remove associated EPG from first Netflow Exporter policy again - testing idempotency + cisco.aci.aci_netflow_exporter_policy: + <<: *aci_netflow_exporter_policy_remove_epg + register: nm_remove_epg_netflow_exporter_policy_idempotency + + - name: Remove associated external EPG from second Netflow Exporter policy (normal_mode) + cisco.aci.aci_netflow_exporter_policy: &aci_netflow_exporter_policy_2_remove_extepg + <<: *aci_netflow_exporter_policy_2_present + associated_extepg: {} + register: nm_remove_extepg_netflow_exporter_policy_2 + + - name: Remove associated external EPG from second Netflow Exporter policy again - testing idempotency + cisco.aci.aci_netflow_exporter_policy: + <<: *aci_netflow_exporter_policy_2_remove_extepg + register: nm_remove_extepg_netflow_exporter_policy_2_idempotency + + - name: Asserts for associated EPGs removal tasks + ansible.builtin.assert: + that: + - cm_remove_epg_netflow_exporter_policy is changed + - cm_remove_epg_netflow_exporter_policy.current == cm_remove_epg_netflow_exporter_policy.previous + - cm_remove_epg_netflow_exporter_policy.proposed.netflowExporterPol.children.0.netflowRsExporterToCtx.attributes.status == "deleted" + - cm_remove_epg_netflow_exporter_policy.proposed.netflowExporterPol.children.1.netflowRsExporterToEPg.attributes.status == "deleted" + - nm_remove_epg_netflow_exporter_policy is changed + - nm_remove_epg_netflow_exporter_policy.proposed.netflowExporterPol.children.0.netflowRsExporterToCtx.attributes.status == "deleted" + - nm_remove_epg_netflow_exporter_policy.proposed.netflowExporterPol.children.1.netflowRsExporterToEPg.attributes.status == "deleted" + - '"children" not in nm_remove_epg_netflow_exporter_policy.current.0.netflowExporterPol' + - nm_remove_epg_netflow_exporter_policy_idempotency is not changed + - '"children" not in nm_remove_epg_netflow_exporter_policy_idempotency.current.0.netflowExporterPol' + - nm_remove_extepg_netflow_exporter_policy_2 is changed + - nm_remove_extepg_netflow_exporter_policy_2.proposed.netflowExporterPol.children.0.netflowRsExporterToEPg.attributes.status == "deleted" + - '"children" not in nm_remove_extepg_netflow_exporter_policy_2.current.0.netflowExporterPol' + - nm_remove_extepg_netflow_exporter_policy_2_idempotency is not changed + - '"children" not in nm_remove_extepg_netflow_exporter_policy_2_idempotency.current.0.netflowExporterPol' + + #UPDATE NETFLOW EXPORTER POLICY + - name: Update first Netflow Exporter policy (check_mode) + cisco.aci.aci_netflow_exporter_policy: &aci_netflow_exporter_policy_update + <<: *aci_netflow_exporter_policy_remove_epg + dscp: AF13 + destination_address: 11.11.11.3 + destination_port: http + source_ip_type: out_of_band_management_ip + description: Updated description for first ansible Netflow Exporter policy + check_mode: true + register: cm_update_netflow_exporter_policy + + - name: Update first Netflow Exporter policy (normal_mode) + cisco.aci.aci_netflow_exporter_policy: + <<: *aci_netflow_exporter_policy_update + register: nm_update_netflow_exporter_policy + + - name: Update first Netflow Exporter policy again - testing idempotency + cisco.aci.aci_netflow_exporter_policy: + <<: *aci_netflow_exporter_policy_update + register: nm_udpate_netflow_exporter_policy_idempotency + + - name: Asserts for Netflow Exporter policy update tasks + ansible.builtin.assert: + that: + - cm_update_netflow_exporter_policy is changed + - cm_update_netflow_exporter_policy.previous == cm_update_netflow_exporter_policy.current + - cm_update_netflow_exporter_policy.proposed.netflowExporterPol.attributes.dscp == "AF13" + - cm_update_netflow_exporter_policy.proposed.netflowExporterPol.attributes.dstAddr == "11.11.11.3" + - cm_update_netflow_exporter_policy.proposed.netflowExporterPol.attributes.dstPort == "http" + - cm_update_netflow_exporter_policy.proposed.netflowExporterPol.attributes.sourceIpType == "oob-mgmt-ip" + - cm_update_netflow_exporter_policy.proposed.netflowExporterPol.attributes.descr == "Updated description for first ansible Netflow Exporter policy" + - nm_update_netflow_exporter_policy is changed + - nm_update_netflow_exporter_policy.current.0.netflowExporterPol.attributes.dscp == "AF13" + - nm_update_netflow_exporter_policy.current.0.netflowExporterPol.attributes.dstAddr == "11.11.11.3" + - nm_update_netflow_exporter_policy.current.0.netflowExporterPol.attributes.dstPort == "http" + - nm_update_netflow_exporter_policy.current.0.netflowExporterPol.attributes.sourceIpType == "oob-mgmt-ip" + - nm_update_netflow_exporter_policy.current.0.netflowExporterPol.attributes.srcAddr == "0.0.0.0" + - nm_update_netflow_exporter_policy.current.0.netflowExporterPol.attributes.descr == "Updated description for first ansible Netflow Exporter policy" + - nm_udpate_netflow_exporter_policy_idempotency is not changed + - nm_udpate_netflow_exporter_policy_idempotency.current.0.netflowExporterPol.attributes.dstAddr == "11.11.11.3" + - nm_udpate_netflow_exporter_policy_idempotency.current.0.netflowExporterPol.attributes.dstPort == "http" + - nm_udpate_netflow_exporter_policy_idempotency.current.0.netflowExporterPol.attributes.sourceIpType == "oob-mgmt-ip" + - nm_udpate_netflow_exporter_policy_idempotency.current.0.netflowExporterPol.attributes.srcAddr == "0.0.0.0" + - nm_udpate_netflow_exporter_policy_idempotency.current.0.netflowExporterPol.attributes.descr == "Updated description for first ansible Netflow Exporter policy" + + # DELETE NETFLOW EXPORTER POLICY + - name: Remove Netflow Exporter policy (check_mode) + cisco.aci.aci_netflow_exporter_policy: &netflow_exporter_policy_absent + <<: *aci_netflow_exporter_policy_update + state: absent + check_mode: true + register: cm_remove_netflow_exporter_policy + + - name: Remove Netflow Exporter policy (normal_mode) + cisco.aci.aci_netflow_exporter_policy: + <<: *netflow_exporter_policy_absent + register: nm_remove_netflow_exporter_policy + + - name: Remove Netflow Exporter policy - testing idempotency + cisco.aci.aci_netflow_exporter_policy: + <<: *netflow_exporter_policy_absent + register: nm_remove_netflow_exporter_policy_idempotency + + - name: Asserts deletion tasks + ansible.builtin.assert: + that: + - cm_remove_netflow_exporter_policy is changed + - cm_remove_netflow_exporter_policy.current == cm_remove_netflow_exporter_policy.previous + - cm_remove_netflow_exporter_policy.proposed == {} + - nm_remove_netflow_exporter_policy is changed + - nm_remove_netflow_exporter_policy.previous != [] + - nm_remove_netflow_exporter_policy.proposed == {} + - nm_remove_netflow_exporter_policy.current == [] + - nm_remove_netflow_exporter_policy_idempotency is not changed + - nm_remove_netflow_exporter_policy_idempotency.previous == [] + - nm_remove_netflow_exporter_policy_idempotency.current == [] + + # CLEAN ENVIRONMENT BEFORE ENDING TESTS + - name: Remove the ansible_tenant - cleanup before ending tests + cisco.aci.aci_tenant: + <<: *aci_tenant_present + state: absent diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_netflow_monitor_policy/aliases b/ansible_collections/cisco/aci/tests/integration/targets/aci_netflow_monitor_policy/aliases new file mode 100644 index 000000000..209b793f9 --- /dev/null +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_netflow_monitor_policy/aliases @@ -0,0 +1,2 @@ +# No ACI simulator yet, so not enabled +# unsupported diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_netflow_monitor_policy/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_netflow_monitor_policy/tasks/main.yml new file mode 100644 index 000000000..ada9d5ad8 --- /dev/null +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_netflow_monitor_policy/tasks/main.yml @@ -0,0 +1,193 @@ +# Test code for the ACI modules +# Copyright: (c) 2023, Gaspard Micol (@gmicol) <gmicol@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 APIC host, ACI username and ACI password + ansible.builtin.fail: + msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' + when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined + +- name: Set vars + ansible.builtin.set_fact: + aci_info: &aci_info + host: "{{ aci_hostname }}" + username: "{{ aci_username }}" + password: "{{ aci_password }}" + validate_certs: '{{ aci_validate_certs | default(false) }}' + use_ssl: '{{ aci_use_ssl | default(true) }}' + use_proxy: '{{ aci_use_proxy | default(true) }}' + output_level: '{{ aci_output_level | default("info") }}' + +# CLEAN ENVIRONMENT BEFORE TESTS +- name: Remove the ansible_tenant + cisco.aci.aci_tenant: &aci_tenant_absent + <<: *aci_info + tenant: ansible_tenant + state: absent + +- name: Verify Cloud and Non-Cloud Sites in use. + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + +- name: Execute tasks only for non-cloud sites + when: query_cloud.current == [] # This condition will execute only non-cloud sites + block: # block specifies execution of tasks within, based on conditions + - name: Add a new tenant + cisco.aci.aci_tenant: &aci_tenant_present + <<: *aci_info + tenant: ansible_tenant + description: Ansible tenant + state: present + + - name: Add a Netflow Record policy + cisco.aci.aci_netflow_record_policy: + <<: *aci_info + tenant: ansible_tenant + netflow_record_policy: ansible_netflow_record_policy + description: Netflow Record policy for ansible_tenant tenant + state: present + + # CREATE NETFLOW MONITOR POLICY + - name: Add a Netflow Monitor policy (check_mode) + cisco.aci.aci_netflow_monitor_policy: &aci_netflow_monitor_policy_present + <<: *aci_info + tenant: ansible_tenant + netflow_monitor_policy: ansible_netflow_monitor_policy_1 + netflow_record_policy: ansible_netflow_record_policy + description: Netflow Monitor policy 1 for ansible_tenant tenant + state: present + check_mode: true + register: cm_add_netflow_monitor_policy + + - name: Add a Netflow Monitor policy (normal_mode) + cisco.aci.aci_netflow_monitor_policy: + <<: *aci_netflow_monitor_policy_present + register: nm_add_netflow_monitor_policy + + - name: Add the first Netflow Monitor policy again - testing idempotency + cisco.aci.aci_netflow_monitor_policy: + <<: *aci_netflow_monitor_policy_present + register: nm_add_netflow_monitor_policy_idempotency + + - name: Add a second Netflow Monitor policy (normal_mode) + cisco.aci.aci_netflow_monitor_policy: + <<: *aci_info + tenant: ansible_tenant + netflow_monitor_policy: ansible_netflow_monitor_policy_2 + description: Netflow Monitor policy 2 for ansible_tenant tenant + state: present + register: nm_add_netflow_monitor_policy_2 + + - name: Asserts for Netflow Monitor policy creation tasks + ansible.builtin.assert: + that: + - cm_add_netflow_monitor_policy is changed + - cm_add_netflow_monitor_policy.previous == [] + - cm_add_netflow_monitor_policy.current == [] + - cm_add_netflow_monitor_policy.proposed.netflowMonitorPol.attributes.name == "ansible_netflow_monitor_policy_1" + - cm_add_netflow_monitor_policy.proposed.netflowMonitorPol.children.0.netflowRsMonitorToRecord.attributes.tnNetflowRecordPolName == "ansible_netflow_record_policy" + - nm_add_netflow_monitor_policy is changed + - nm_add_netflow_monitor_policy.previous == [] + - nm_add_netflow_monitor_policy.current.0.netflowMonitorPol.attributes.name == "ansible_netflow_monitor_policy_1" + - nm_add_netflow_monitor_policy.current.0.netflowMonitorPol.children.0.netflowRsMonitorToRecord.attributes.tnNetflowRecordPolName == "ansible_netflow_record_policy" + - nm_add_netflow_monitor_policy_idempotency is not changed + - nm_add_netflow_monitor_policy_idempotency.current.0.netflowMonitorPol.attributes.name == "ansible_netflow_monitor_policy_1" + - nm_add_netflow_monitor_policy_idempotency.current.0.netflowMonitorPol.children.0.netflowRsMonitorToRecord.attributes.tnNetflowRecordPolName == "ansible_netflow_record_policy" + - nm_add_netflow_monitor_policy_2 is changed + - nm_add_netflow_monitor_policy_2.previous == [] + - nm_add_netflow_monitor_policy_2.current.0.netflowMonitorPol.attributes.name == "ansible_netflow_monitor_policy_2" + + # QUERY NETFLOW MONITOR POLICY + - name: Query all Netflow Monitor policies + cisco.aci.aci_netflow_monitor_policy: + <<: *aci_info + state: query + register: query_all_netflow_monitor_policy + + - name: Query ansible_netflow_monitor_policy_1 + cisco.aci.aci_netflow_monitor_policy: + <<: *aci_netflow_monitor_policy_present + state: query + register: query_ansible_netflow_monitor_policy_1 + + - name: Asserts query tasks + ansible.builtin.assert: + that: + - query_all_netflow_monitor_policy is not changed + - query_all_netflow_monitor_policy.current|length >= 2 + - query_ansible_netflow_monitor_policy_1 is not changed + - query_ansible_netflow_monitor_policy_1.current|length == 1 + - query_ansible_netflow_monitor_policy_1.current.0.netflowMonitorPol.attributes.name == "ansible_netflow_monitor_policy_1" + - query_ansible_netflow_monitor_policy_1.current.0.netflowMonitorPol.children.0.netflowRsMonitorToRecord.attributes.tDn == "uni/tn-ansible_tenant/recordpol-ansible_netflow_record_policy" + + # UPDATE NETFLOW MONITOR POLICY + - name: Add a Netflow Monitor policy (check_mode) + cisco.aci.aci_netflow_monitor_policy: &aci_netflow_monitor_policy_update + <<: *aci_netflow_monitor_policy_present + netflow_record_policy: "" + description: Updated Netflow Monitor policy 1 for ansible_tenant tenant + state: present + check_mode: true + register: cm_update_netflow_monitor_policy + + - name: Add a Netflow Monitor policy (normal_mode) + cisco.aci.aci_netflow_monitor_policy: + <<: *aci_netflow_monitor_policy_update + register: nm_update_netflow_monitor_policy + + - name: Add the first Netflow Monitor policy again - testing idempotency + cisco.aci.aci_netflow_monitor_policy: + <<: *aci_netflow_monitor_policy_update + register: nm_update_netflow_monitor_policy_idempotency + + - name: Asserts for Netflow Monitor policy update tasks + ansible.builtin.assert: + that: + - cm_update_netflow_monitor_policy is changed + - cm_update_netflow_monitor_policy.previous == cm_update_netflow_monitor_policy.current + - cm_update_netflow_monitor_policy.proposed.netflowMonitorPol.attributes.descr == "Updated Netflow Monitor policy 1 for ansible_tenant tenant" + - cm_update_netflow_monitor_policy.proposed.netflowMonitorPol.children.0.netflowRsMonitorToRecord.attributes.tnNetflowRecordPolName == "" + - nm_update_netflow_monitor_policy is changed + - nm_update_netflow_monitor_policy.current.0.netflowMonitorPol.attributes.descr == "Updated Netflow Monitor policy 1 for ansible_tenant tenant" + - nm_update_netflow_monitor_policy.current.0.netflowMonitorPol.children.0.netflowRsMonitorToRecord.attributes.tnNetflowRecordPolName == "" + - nm_update_netflow_monitor_policy_idempotency is not changed + - nm_update_netflow_monitor_policy_idempotency.current.0.netflowMonitorPol.attributes.descr == "Updated Netflow Monitor policy 1 for ansible_tenant tenant" + - nm_update_netflow_monitor_policy_idempotency.current.0.netflowMonitorPol.children.0.netflowRsMonitorToRecord.attributes.tnNetflowRecordPolName == "" + + # DELETE NETFLOW MONITOR POLICY + - name: Remove Netflow Monitor policy (check_mode) + cisco.aci.aci_netflow_monitor_policy: &netflow_monitor_policy_absent + <<: *aci_netflow_monitor_policy_update + state: absent + check_mode: true + register: cm_remove_netflow_monitor_policy + + - name: Remove Netflow Monitor policy (normal_mode) + cisco.aci.aci_netflow_monitor_policy: + <<: *netflow_monitor_policy_absent + register: nm_remove_netflow_monitor_policy + + - name: Remove Netflow Monitor policy - testing idempotency + cisco.aci.aci_netflow_monitor_policy: + <<: *netflow_monitor_policy_absent + register: nm_remove_netflow_monitor_policy_idempotency + + - name: Asserts deletion tasks + ansible.builtin.assert: + that: + - cm_remove_netflow_monitor_policy is changed + - cm_remove_netflow_monitor_policy.current == cm_remove_netflow_monitor_policy.previous + - cm_remove_netflow_monitor_policy.proposed == {} + - nm_remove_netflow_monitor_policy is changed + - nm_remove_netflow_monitor_policy.previous != [] + - nm_remove_netflow_monitor_policy.proposed == {} + - nm_remove_netflow_monitor_policy.current == [] + - nm_remove_netflow_monitor_policy_idempotency is not changed + - nm_remove_netflow_monitor_policy_idempotency.previous == [] + - nm_remove_netflow_monitor_policy_idempotency.current == [] + + # CLEAN ENVIRONMENT BEFORE ENDING TESTS + - name: Remove the ansible_tenant - cleanup before ending tests + cisco.aci.aci_tenant: + <<: *aci_tenant_present + state: absent diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_netflow_monitor_to_exporter/aliases b/ansible_collections/cisco/aci/tests/integration/targets/aci_netflow_monitor_to_exporter/aliases new file mode 100644 index 000000000..209b793f9 --- /dev/null +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_netflow_monitor_to_exporter/aliases @@ -0,0 +1,2 @@ +# No ACI simulator yet, so not enabled +# unsupported diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_netflow_monitor_to_exporter/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_netflow_monitor_to_exporter/tasks/main.yml new file mode 100644 index 000000000..7ee25f61c --- /dev/null +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_netflow_monitor_to_exporter/tasks/main.yml @@ -0,0 +1,172 @@ +# Test code for the ACI modules +# Copyright: (c) 2023, Gaspard Micol (@gmicol) <gmicol@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 APIC host, ACI username and ACI password + ansible.builtin.fail: + msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' + when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined + +- name: Set vars + ansible.builtin.set_fact: + aci_info: &aci_info + host: "{{ aci_hostname }}" + username: "{{ aci_username }}" + password: "{{ aci_password }}" + validate_certs: '{{ aci_validate_certs | default(false) }}' + use_ssl: '{{ aci_use_ssl | default(true) }}' + use_proxy: '{{ aci_use_proxy | default(true) }}' + output_level: '{{ aci_output_level | default("info") }}' + +# CLEAN ENVIRONMENT BEFORE TESTS +- name: Remove the ansible_tenant + cisco.aci.aci_tenant: &aci_tenant_absent + <<: *aci_info + tenant: ansible_tenant + state: absent + +- name: Verify Cloud and Non-Cloud Sites in use. + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + +- name: Execute tasks only for non-cloud sites + when: query_cloud.current == [] # This condition will execute only non-cloud sites + block: # block specifies execution of tasks within, based on conditions + - name: Add a new tenant + cisco.aci.aci_tenant: &aci_tenant_present + <<: *aci_info + tenant: ansible_tenant + description: Ansible tenant + state: present + + - name: Add a Netflow Monitor policy + cisco.aci.aci_netflow_monitor_policy: + <<: *aci_info + tenant: ansible_tenant + netflow_monitor_policy: ansible_netflow_monitor_policy + description: Netflow Monitor policy for ansible_tenant tenant + state: present + + - name: Add a first Netflow Exporter policy + cisco.aci.aci_netflow_exporter_policy: + <<: *aci_info + tenant: ansible_tenant + netflow_exporter_policy: ansible_netflow_exporter_policy_1 + description: Netflow Exporter policy 1 for ansible_tenant tenant + destination_address: 11.11.11.1 + destination_port: https + state: present + + - name: Add a second Netflow Exporter policy + cisco.aci.aci_netflow_exporter_policy: + <<: *aci_info + tenant: ansible_tenant + netflow_exporter_policy: ansible_netflow_exporter_policy_2 + description: Netflow Exporter policy 2 for ansible_tenant tenant + destination_address: 12.12.12.2 + destination_port: http + state: present + + # CREATE NETFLOW MONITOR TO EXPORTER + - name: Add a first Netflow Exporter policy to the Netflow Monitor policy (check_mode) + cisco.aci.aci_netflow_monitor_to_exporter: &aci_netflow_monitor_to_exporter_present + <<: *aci_info + tenant: ansible_tenant + netflow_monitor_policy: ansible_netflow_monitor_policy + netflow_exporter_policy: ansible_netflow_exporter_policy_1 + state: present + check_mode: true + register: cm_add_netflow_monitor_to_exporter + + - name: Add a first Netflow Exporter policy to the Netflow Monitor policy (normal_mode) + cisco.aci.aci_netflow_monitor_to_exporter: + <<: *aci_netflow_monitor_to_exporter_present + register: nm_add_netflow_monitor_to_exporter + + - name: Add the first Netflow Monitor policy again - testing idempotency + cisco.aci.aci_netflow_monitor_to_exporter: + <<: *aci_netflow_monitor_to_exporter_present + register: nm_add_netflow_monitor_to_exporter_idempotency + + - name: Add a second Netflow Monitor policy (normal_mode) + cisco.aci.aci_netflow_monitor_to_exporter: + <<: *aci_info + tenant: ansible_tenant + netflow_monitor_policy: ansible_netflow_monitor_policy + netflow_exporter_policy: ansible_netflow_exporter_policy_2 + state: present + register: nm_add_netflow_monitor_to_exporter_2 + + - name: Asserts for Netflow Monitor policy creation tasks + ansible.builtin.assert: + that: + - cm_add_netflow_monitor_to_exporter is changed + - cm_add_netflow_monitor_to_exporter.previous == [] + - cm_add_netflow_monitor_to_exporter.current == [] + - cm_add_netflow_monitor_to_exporter.proposed.netflowRsMonitorToExporter.attributes.tnNetflowExporterPolName == "ansible_netflow_exporter_policy_1" + - nm_add_netflow_monitor_to_exporter is changed + - nm_add_netflow_monitor_to_exporter.previous == [] + - nm_add_netflow_monitor_to_exporter.current.0.netflowRsMonitorToExporter.attributes.tnNetflowExporterPolName == "ansible_netflow_exporter_policy_1" + - nm_add_netflow_monitor_to_exporter_idempotency is not changed + - nm_add_netflow_monitor_to_exporter_idempotency.current.0.netflowRsMonitorToExporter.attributes.tnNetflowExporterPolName == "ansible_netflow_exporter_policy_1" + - nm_add_netflow_monitor_to_exporter_2 is changed + - nm_add_netflow_monitor_to_exporter_2.previous == [] + - nm_add_netflow_monitor_to_exporter_2.current.0.netflowRsMonitorToExporter.attributes.tnNetflowExporterPolName == "ansible_netflow_exporter_policy_2" + + # QUERY NETFLOW MONITOR TO EXPORTER + - name: Query all Netflow Monitor to Exporter Associations + cisco.aci.aci_netflow_monitor_to_exporter: + <<: *aci_info + state: query + register: query_all_netflow_monitor_to_exporter + + - name: Query first Netflow Monitor to Exporter Association + cisco.aci.aci_netflow_monitor_to_exporter: + <<: *aci_netflow_monitor_to_exporter_present + state: query + register: query_ansible_netflow_monitor_policy_to_exporter + + - name: Asserts query tasks + ansible.builtin.assert: + that: + - query_all_netflow_monitor_to_exporter is not changed + - query_all_netflow_monitor_to_exporter.current|length >= 2 + - query_ansible_netflow_monitor_policy_to_exporter is not changed + - query_ansible_netflow_monitor_policy_to_exporter.current|length == 1 + - query_ansible_netflow_monitor_policy_to_exporter.current.0.netflowRsMonitorToExporter.attributes.tnNetflowExporterPolName == "ansible_netflow_exporter_policy_1" + + # DELETE NETFLOW MONITOR TO EXPORTER + - name: Remove first Netflow Exporter policy from the Netflow Monitor policy (check_mode) + cisco.aci.aci_netflow_monitor_to_exporter: &netflow_monitor_to_exporter_absent + <<: *aci_netflow_monitor_to_exporter_present + state: absent + check_mode: true + register: cm_remove_netflow_monitor_to_exporter + + - name: Remove first Netflow Exporter policy from the Netflow Monitor policy (normal_mode) + cisco.aci.aci_netflow_monitor_to_exporter: + <<: *netflow_monitor_to_exporter_absent + register: nm_remove_netflow_monitor_to_exporter + + - name: Remove first Netflow Exporter policy from the Netflow Monitor policy - testing idempotency + cisco.aci.aci_netflow_monitor_to_exporter: + <<: *netflow_monitor_to_exporter_absent + register: nm_remove_netflow_monitor_to_exporter_idempotency + + - name: Asserts deletion tasks + ansible.builtin.assert: + that: + - cm_remove_netflow_monitor_to_exporter is changed + - cm_remove_netflow_monitor_to_exporter.current == cm_remove_netflow_monitor_to_exporter.previous + - cm_remove_netflow_monitor_to_exporter.proposed == {} + - nm_remove_netflow_monitor_to_exporter is changed + - nm_remove_netflow_monitor_to_exporter.previous != [] + - nm_remove_netflow_monitor_to_exporter.current == [] + - nm_remove_netflow_monitor_to_exporter_idempotency is not changed + - nm_remove_netflow_monitor_to_exporter_idempotency.previous == [] + + # CLEAN ENVIRONMENT BEFORE ENDING TESTS + - name: Remove the ansible_tenant - cleanup before ending tests + cisco.aci.aci_tenant: + <<: *aci_tenant_present + state: absent diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_netflow_record_policy/aliases b/ansible_collections/cisco/aci/tests/integration/targets/aci_netflow_record_policy/aliases new file mode 100644 index 000000000..209b793f9 --- /dev/null +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_netflow_record_policy/aliases @@ -0,0 +1,2 @@ +# No ACI simulator yet, so not enabled +# unsupported diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_netflow_record_policy/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_netflow_record_policy/tasks/main.yml new file mode 100644 index 000000000..0645e9159 --- /dev/null +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_netflow_record_policy/tasks/main.yml @@ -0,0 +1,194 @@ +# Test code for the ACI modules +# Copyright: (c) 2023, Gaspard Micol (@gmicol) <gmicol@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 APIC host, ACI username and ACI password + ansible.builtin.fail: + msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' + when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined + +- name: Set vars + ansible.builtin.set_fact: + aci_info: &aci_info + host: "{{ aci_hostname }}" + username: "{{ aci_username }}" + password: "{{ aci_password }}" + validate_certs: '{{ aci_validate_certs | default(false) }}' + use_ssl: '{{ aci_use_ssl | default(true) }}' + use_proxy: '{{ aci_use_proxy | default(true) }}' + output_level: '{{ aci_output_level | default("info") }}' + +# CLEAN ENVIRONMENT BEFORE TESTS +- name: Remove the ansible_tenant + cisco.aci.aci_tenant: &aci_tenant_absent + <<: *aci_info + tenant: ansible_tenant + state: absent + +- name: Verify Cloud and Non-Cloud Sites in use. + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + +- name: Execute tasks only for non-cloud sites + when: query_cloud.current == [] # This condition will execute only non-cloud sites + block: # block specifies execution of tasks within, based on conditions + - name: Add a new tenant + cisco.aci.aci_tenant: &aci_tenant_present + <<: *aci_info + tenant: ansible_tenant + description: Ansible tenant + state: present + + # CREATE NETFLOW RECORD POLICY + - name: Add a Netflow Record policy (check_mode) + cisco.aci.aci_netflow_record_policy: &aci_netflow_record_policy_present + <<: *aci_info + tenant: ansible_tenant + netflow_record_policy: ansible_netflow_record_policy_1 + description: Netflow Record policy 1 for ansible_tenant tenant + collect: [sampler_id, bytes_counter] + match: [destination_ipv4_v6, source_ipv4_v6] + state: present + check_mode: true + register: cm_add_netflow_record_policy + + - name: Add a Netflow Record policy (normal_mode) + cisco.aci.aci_netflow_record_policy: + <<: *aci_netflow_record_policy_present + register: nm_add_netflow_record_policy + + - name: Add the first Netflow Record policy again - testing idempotency + cisco.aci.aci_netflow_record_policy: + <<: *aci_netflow_record_policy_present + register: nm_add_netflow_record_policy_idempotency + + - name: Add a second Netflow Record policy (normal_mode) + cisco.aci.aci_netflow_record_policy: + <<: *aci_info + tenant: ansible_tenant + netflow_record_policy: ansible_netflow_record_policy_2 + description: Netflow Record policy 2 for ansible_tenant tenant + state: present + register: nm_add_netflow_record_policy_2 + + - name: Asserts for Netflow Record policy creation tasks + ansible.builtin.assert: + that: + - cm_add_netflow_record_policy is changed + - cm_add_netflow_record_policy.previous == [] + - cm_add_netflow_record_policy.current == [] + - cm_add_netflow_record_policy.proposed.netflowRecordPol.attributes.name == "ansible_netflow_record_policy_1" + - cm_add_netflow_record_policy.proposed.netflowRecordPol.attributes.collect == "count-bytes,sampler-id" + - cm_add_netflow_record_policy.proposed.netflowRecordPol.attributes.match == "dst-ip,src-ip" + - nm_add_netflow_record_policy is changed + - nm_add_netflow_record_policy.previous == [] + - nm_add_netflow_record_policy.current.0.netflowRecordPol.attributes.name == "ansible_netflow_record_policy_1" + - nm_add_netflow_record_policy.current.0.netflowRecordPol.attributes.collect == "count-bytes,sampler-id" + - nm_add_netflow_record_policy.current.0.netflowRecordPol.attributes.match == "dst-ip,src-ip" + - nm_add_netflow_record_policy_idempotency is not changed + - nm_add_netflow_record_policy_idempotency.current.0.netflowRecordPol.attributes.name == "ansible_netflow_record_policy_1" + - nm_add_netflow_record_policy_idempotency.current.0.netflowRecordPol.attributes.collect == "count-bytes,sampler-id" + - nm_add_netflow_record_policy_idempotency.current.0.netflowRecordPol.attributes.match == "dst-ip,src-ip" + - nm_add_netflow_record_policy_2 is changed + - nm_add_netflow_record_policy_2.previous == [] + - nm_add_netflow_record_policy_2.current.0.netflowRecordPol.attributes.name == "ansible_netflow_record_policy_2" + - nm_add_netflow_record_policy_2.current.0.netflowRecordPol.attributes.collect == "src-intf" + - nm_add_netflow_record_policy_2.current.0.netflowRecordPol.attributes.match == "" + + # QUERY NETFLOW RECORD POLICY + - name: Query all Netflow Record policies + cisco.aci.aci_netflow_record_policy: + <<: *aci_info + state: query + register: query_all_netflow_record_policy + + - name: Query ansible_netflow_record_policy_1 + cisco.aci.aci_netflow_record_policy: + <<: *aci_netflow_record_policy_present + state: query + register: query_ansible_netflow_record_policy_1 + + - name: Asserts query tasks + ansible.builtin.assert: + that: + - query_all_netflow_record_policy is not changed + - query_all_netflow_record_policy.current|length >= 2 + - query_ansible_netflow_record_policy_1 is not changed + - query_ansible_netflow_record_policy_1.current|length == 1 + - query_ansible_netflow_record_policy_1.current.0.netflowRecordPol.attributes.name == "ansible_netflow_record_policy_1" + - query_ansible_netflow_record_policy_1.current.0.netflowRecordPol.attributes.collect == "count-bytes,sampler-id" + - query_ansible_netflow_record_policy_1.current.0.netflowRecordPol.attributes.match == "dst-ip,src-ip" + + #UPDATE NETFLOW RECORD POLICY + - name: Update first Netflow Record policy (check_mode) + cisco.aci.aci_netflow_record_policy: &aci_netflow_record_policy_update + <<: *aci_netflow_record_policy_present + collect: [pkts_counter, pkt_disposition] + match: [destination_ipv4, source_ipv4] + state: present + check_mode: true + register: cm_update_netflow_record_policy + + - name: Update first Netflow Record policy (normal_mode) + cisco.aci.aci_netflow_record_policy: + <<: *aci_netflow_record_policy_update + register: nm_update_netflow_record_policy + + - name: Update first Netflow Record policy again - testing idempotency + cisco.aci.aci_netflow_record_policy: + <<: *aci_netflow_record_policy_update + register: nm_udpate_netflow_record_policy_idempotency + + - name: Asserts for Netflow Record policy update tasks + ansible.builtin.assert: + that: + - cm_update_netflow_record_policy is changed + - cm_update_netflow_record_policy.previous == cm_update_netflow_record_policy.current + - cm_update_netflow_record_policy.proposed.netflowRecordPol.attributes.name == "ansible_netflow_record_policy_1" + - cm_update_netflow_record_policy.proposed.netflowRecordPol.attributes.collect == "count-pkts,pkt-disp" + - cm_update_netflow_record_policy.proposed.netflowRecordPol.attributes.match == "dst-ipv4,src-ipv4" + - nm_update_netflow_record_policy is changed + - nm_update_netflow_record_policy.current.0.netflowRecordPol.attributes.name == "ansible_netflow_record_policy_1" + - nm_update_netflow_record_policy.current.0.netflowRecordPol.attributes.collect == "count-pkts,pkt-disp" + - nm_update_netflow_record_policy.current.0.netflowRecordPol.attributes.match == "dst-ipv4,src-ipv4" + - nm_udpate_netflow_record_policy_idempotency is not changed + - nm_udpate_netflow_record_policy_idempotency.current.0.netflowRecordPol.attributes.name == "ansible_netflow_record_policy_1" + - nm_udpate_netflow_record_policy_idempotency.current.0.netflowRecordPol.attributes.collect == "count-pkts,pkt-disp" + - nm_udpate_netflow_record_policy_idempotency.current.0.netflowRecordPol.attributes.match == "dst-ipv4,src-ipv4" + + # DELETE NETFLOW RECORD POLICY + - name: Remove Netflow Record policy (check_mode) + cisco.aci.aci_netflow_record_policy: &netflow_record_policy_absent + <<: *aci_netflow_record_policy_update + state: absent + check_mode: true + register: cm_remove_netflow_record_policy + + - name: Remove Netflow Record policy (normal_mode) + cisco.aci.aci_netflow_record_policy: + <<: *netflow_record_policy_absent + register: nm_remove_netflow_record_policy + + - name: Remove Netflow Record policy - testing idempotency + cisco.aci.aci_netflow_record_policy: + <<: *netflow_record_policy_absent + register: nm_remove_netflow_record_policy_idempotency + + - name: Asserts deletion tasks + ansible.builtin.assert: + that: + - cm_remove_netflow_record_policy is changed + - cm_remove_netflow_record_policy.current == cm_remove_netflow_record_policy.previous + - cm_remove_netflow_record_policy.proposed == {} + - nm_remove_netflow_record_policy is changed + - nm_remove_netflow_record_policy.previous != [] + - nm_remove_netflow_record_policy.current == [] + - nm_remove_netflow_record_policy_idempotency is not changed + - nm_remove_netflow_record_policy_idempotency.previous == [] + - nm_remove_netflow_record_policy_idempotency.current == [] + + # CLEAN ENVIRONMENT BEFORE ENDING TESTS + - name: Remove the ansible_tenant - cleanup before ending tests + cisco.aci.aci_tenant: + <<: *aci_tenant_present + state: absent diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_node_block/aliases b/ansible_collections/cisco/aci/tests/integration/targets/aci_node_block/aliases new file mode 100644 index 000000000..209b793f9 --- /dev/null +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_node_block/aliases @@ -0,0 +1,2 @@ +# No ACI simulator yet, so not enabled +# unsupported diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_node_block/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_node_block/tasks/main.yml new file mode 100644 index 000000000..a7f77758b --- /dev/null +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_node_block/tasks/main.yml @@ -0,0 +1,275 @@ +# Test code for the ACI modules +# Copyright: (c) 2024, Gaspard Micol (@gmicol) <gmicol@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 APIC host, ACI username and ACI password + ansible.builtin.fail: + msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' + when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined + +- name: Set vars + ansible.builtin.set_fact: + aci_info: &aci_info + host: "{{ aci_hostname }}" + username: "{{ aci_username }}" + password: "{{ aci_password }}" + validate_certs: '{{ aci_validate_certs | default(false) }}' + use_ssl: '{{ aci_use_ssl | default(true) }}' + use_proxy: '{{ aci_use_proxy | default(true) }}' + output_level: '{{ aci_output_level | default("info") }}' + +- name: Verify Cloud and Non-Cloud Sites in use. + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + +- name: Execute tasks only for non-cloud sites + when: query_cloud.current == [] # This condition will execute only non-cloud sites + block: # block specifies execution of tasks within, based on conditions + # CLEAN ENVIRONMENT + - name: Remove the ansible_access_spine_switch_profile + cisco.aci.aci_access_spine_switch_profile: &aci_access_spine_switch_profile_absent + <<: *aci_info + switch_profile: ansible_access_spine_switch_profile + state: absent + + - name: Remove the ansible_access_leaf_switch_profile + cisco.aci.aci_switch_policy_leaf_profile: &aci_access_leaf_switch_profile_absent + <<: *aci_info + leaf_profile: ansible_access_leaf_switch_profile + state: absent + + # CREATE ACCESS SWITCH POLICY PROFILES + - name: Add a new Access Spine Switch profile + cisco.aci.aci_access_spine_switch_profile: &aci_access_spine_switch_profile_present + <<: *aci_access_spine_switch_profile_absent + state: present + + - name: Add a new Access Leaf Switch profile + cisco.aci.aci_switch_policy_leaf_profile: &aci_access_leaf_switch_profile_present + <<: *aci_access_leaf_switch_profile_absent + state: present + + # CREATE ACCESS SWITCH POLICY SELECTORS + - name: Add a new Access Spine Switch selector + cisco.aci.aci_access_spine_switch_selector: + <<: *aci_access_spine_switch_profile_present + switch_selector: ansible_access_spine_switch_selector + selector_type: range + state: present + + - name: Add a new Access Leaf Switch selector + cisco.aci.aci_switch_leaf_selector: + <<: *aci_access_leaf_switch_profile_present + leaf: ansible_access_leaf_switch_selector + state: present + + # CREATE NODE BLOCK FOR SWITCH POLICY LEAF SELECTOR + - name: Add a new Node Block for Switch policy leaf selector (check_mode) + cisco.aci.aci_node_block: &aci_node_block_leaf_present + <<: *aci_info + switch_profile: ansible_access_leaf_switch_profile + port_selector: ansible_access_leaf_switch_selector + node_block: ansible_node_block_leaf_1 + from: 1011 + to: 1011 + description: Node Block for Switch policy leaf selector 1 + type_node: leaf + state: present + check_mode: true + register: cm_add_node_block_leaf + + - name: Add a new Node Block for Switch policy leaf selector (normal_mode) + cisco.aci.aci_node_block: + <<: *aci_node_block_leaf_present + register: nm_add_node_block_leaf + + - name: Add the first Node Block for Switch policy leaf selector again - testing idempotency + cisco.aci.aci_node_block: + <<: *aci_node_block_leaf_present + register: nm_add_node_block_leaf_idempotency + + - name: Add a second Node Block for Switch policy leaf selector (normal_mode) + cisco.aci.aci_node_block: &aci_node_block_leaf_2_present + <<: *aci_info + switch_profile: ansible_access_leaf_switch_profile + port_selector: ansible_access_leaf_switch_selector + node_block: ansible_node_block_leaf_2 + from: 1012 + to: 1012 + description: Node Block for Switch policy leaf selector 2 + type_node: leaf + state: present + register: nm_add_node_block_leaf_2 + + - name: Add a Node Block for Switch policy spine selector (normal_mode) + cisco.aci.aci_node_block: &aci_node_block_spine_present + <<: *aci_info + switch_profile: ansible_access_spine_switch_profile + port_selector: ansible_access_spine_switch_selector + node_block: ansible_node_block_spine + from: 1014 + to: 1014 + description: Node Block for Switch policy spine selector + type_node: spine + state: present + register: nm_add_node_block_spine + + - name: Asserts for Node Blocks creation tasks + ansible.builtin.assert: + that: + - cm_add_node_block_leaf is changed + - cm_add_node_block_leaf.previous == [] + - cm_add_node_block_leaf.current == [] + - cm_add_node_block_leaf.proposed.infraNodeBlk.attributes.name == "ansible_node_block_leaf_1" + - cm_add_node_block_leaf.proposed.infraNodeBlk.attributes.descr == "Node Block for Switch policy leaf selector 1" + - cm_add_node_block_leaf.proposed.infraNodeBlk.attributes.from_ == "1011" + - cm_add_node_block_leaf.proposed.infraNodeBlk.attributes.to_ == "1011" + - cm_add_node_block_leaf.proposed.infraNodeBlk.attributes.dn == "uni/infra/nprof-ansible_access_leaf_switch_profile/leaves-ansible_access_leaf_switch_selector-typ-range/nodeblk-ansible_node_block_leaf_1" + - nm_add_node_block_leaf is changed + - nm_add_node_block_leaf.previous == [] + - nm_add_node_block_leaf.current.0.infraNodeBlk.attributes.name == "ansible_node_block_leaf_1" + - nm_add_node_block_leaf.current.0.infraNodeBlk.attributes.descr == "Node Block for Switch policy leaf selector 1" + - nm_add_node_block_leaf.current.0.infraNodeBlk.attributes.from_ == "1011" + - nm_add_node_block_leaf.current.0.infraNodeBlk.attributes.to_ == "1011" + - nm_add_node_block_leaf.current.0.infraNodeBlk.attributes.dn == "uni/infra/nprof-ansible_access_leaf_switch_profile/leaves-ansible_access_leaf_switch_selector-typ-range/nodeblk-ansible_node_block_leaf_1" + - nm_add_node_block_leaf_idempotency is not changed + - nm_add_node_block_leaf_idempotency.current.0.infraNodeBlk.attributes.name == "ansible_node_block_leaf_1" + - nm_add_node_block_leaf_idempotency.current.0.infraNodeBlk.attributes.descr == "Node Block for Switch policy leaf selector 1" + - nm_add_node_block_leaf_idempotency.current.0.infraNodeBlk.attributes.from_ == "1011" + - nm_add_node_block_leaf_idempotency.current.0.infraNodeBlk.attributes.to_ == "1011" + - nm_add_node_block_leaf_idempotency.current.0.infraNodeBlk.attributes.dn == "uni/infra/nprof-ansible_access_leaf_switch_profile/leaves-ansible_access_leaf_switch_selector-typ-range/nodeblk-ansible_node_block_leaf_1" + - nm_add_node_block_leaf_2 is changed + - nm_add_node_block_leaf_2.previous == [] + - nm_add_node_block_leaf_2.current.0.infraNodeBlk.attributes.name == "ansible_node_block_leaf_2" + - nm_add_node_block_leaf_2.current.0.infraNodeBlk.attributes.descr == "Node Block for Switch policy leaf selector 2" + - nm_add_node_block_leaf_2.current.0.infraNodeBlk.attributes.from_ == "1012" + - nm_add_node_block_leaf_2.current.0.infraNodeBlk.attributes.to_ == "1012" + - nm_add_node_block_leaf_2.current.0.infraNodeBlk.attributes.dn == "uni/infra/nprof-ansible_access_leaf_switch_profile/leaves-ansible_access_leaf_switch_selector-typ-range/nodeblk-ansible_node_block_leaf_2" + - nm_add_node_block_leaf_2 is changed + - nm_add_node_block_leaf_2.previous == [] + - nm_add_node_block_spine.current.0.infraNodeBlk.attributes.name == "ansible_node_block_spine" + - nm_add_node_block_spine.current.0.infraNodeBlk.attributes.descr == "Node Block for Switch policy spine selector" + - nm_add_node_block_spine.current.0.infraNodeBlk.attributes.from_ == "1014" + - nm_add_node_block_spine.current.0.infraNodeBlk.attributes.to_ == "1014" + - nm_add_node_block_spine.current.0.infraNodeBlk.attributes.dn == "uni/infra/spprof-ansible_access_spine_switch_profile/spines-ansible_access_spine_switch_selector-typ-range/nodeblk-ansible_node_block_spine" + + # QUERY NODE BLOCKS + - name: Query all Node Block for Switch policy leaf selectors + cisco.aci.aci_node_block: + <<: *aci_info + state: query + register: query_all_node_block + + - name: Query ansible_node_block_leaf_1 + cisco.aci.aci_node_block: + <<: *aci_node_block_leaf_present + state: query + register: query_ansible_node_block_leaf_1 + + - name: Query ansible_node_block_spine + cisco.aci.aci_node_block: + <<: *aci_node_block_spine_present + state: query + register: query_ansible_node_block_spine + + - name: Asserts query tasks + ansible.builtin.assert: + that: + - query_all_node_block is not changed + - query_all_node_block.current|length >= 3 + - query_ansible_node_block_leaf_1 is not changed + - query_ansible_node_block_leaf_1.current|length == 1 + - query_ansible_node_block_leaf_1.current.0.infraNodeBlk.attributes.name == "ansible_node_block_leaf_1" + - query_ansible_node_block_leaf_1.current.0.infraNodeBlk.attributes.descr == "Node Block for Switch policy leaf selector 1" + - query_ansible_node_block_leaf_1.current.0.infraNodeBlk.attributes.from_ == "1011" + - query_ansible_node_block_leaf_1.current.0.infraNodeBlk.attributes.to_ == "1011" + - query_ansible_node_block_leaf_1.current.0.infraNodeBlk.attributes.dn == "uni/infra/nprof-ansible_access_leaf_switch_profile/leaves-ansible_access_leaf_switch_selector-typ-range/nodeblk-ansible_node_block_leaf_1" + - query_ansible_node_block_spine is not changed + - query_ansible_node_block_spine.current|length == 1 + - query_ansible_node_block_spine.current.0.infraNodeBlk.attributes.name == "ansible_node_block_spine" + - query_ansible_node_block_spine.current.0.infraNodeBlk.attributes.descr == "Node Block for Switch policy spine selector" + - query_ansible_node_block_spine.current.0.infraNodeBlk.attributes.from_ == "1014" + - query_ansible_node_block_spine.current.0.infraNodeBlk.attributes.to_ == "1014" + - query_ansible_node_block_spine.current.0.infraNodeBlk.attributes.dn == "uni/infra/spprof-ansible_access_spine_switch_profile/spines-ansible_access_spine_switch_selector-typ-range/nodeblk-ansible_node_block_spine" + + # UPDATE NODE BLOCKS + - name: Update first Node Block for Switch policy leaf selector (check_mode) + cisco.aci.aci_node_block: &aci_node_block_leaf_update + <<: *aci_node_block_leaf_present + description: Updated description for first ansible Node Block for Switch policy leaf selector + from: 1013 + to: 1013 + check_mode: true + register: cm_update_node_block + + - name: Update first Node Block for Switch policy leaf selector (normal_mode) + cisco.aci.aci_node_block: + <<: *aci_node_block_leaf_update + register: nm_update_node_block + + - name: Update first Node Block for Switch policy leaf selector again - testing idempotency + cisco.aci.aci_node_block: + <<: *aci_node_block_leaf_update + register: nm_udpate_node_block_leaf_idempotency + + - name: Asserts for Node Blocks update tasks + ansible.builtin.assert: + that: + - cm_update_node_block is changed + - cm_update_node_block.previous == cm_update_node_block.current + - cm_update_node_block.proposed.infraNodeBlk.attributes.descr == "Updated description for first ansible Node Block for Switch policy leaf selector" + - cm_update_node_block.proposed.infraNodeBlk.attributes.from_ == "1013" + - cm_update_node_block.proposed.infraNodeBlk.attributes.to_ == "1013" + - nm_update_node_block is changed + - nm_update_node_block.current.0.infraNodeBlk.attributes.name == "ansible_node_block_leaf_1" + - nm_update_node_block.current.0.infraNodeBlk.attributes.descr == "Updated description for first ansible Node Block for Switch policy leaf selector" + - nm_update_node_block.current.0.infraNodeBlk.attributes.from_ == "1013" + - nm_update_node_block.current.0.infraNodeBlk.attributes.to_ == "1013" + - nm_update_node_block.current.0.infraNodeBlk.attributes.dn == "uni/infra/nprof-ansible_access_leaf_switch_profile/leaves-ansible_access_leaf_switch_selector-typ-range/nodeblk-ansible_node_block_leaf_1" + - nm_udpate_node_block_leaf_idempotency is not changed + - nm_udpate_node_block_leaf_idempotency.current.0.infraNodeBlk.attributes.name == "ansible_node_block_leaf_1" + - nm_udpate_node_block_leaf_idempotency.current.0.infraNodeBlk.attributes.descr == "Updated description for first ansible Node Block for Switch policy leaf selector" + - nm_udpate_node_block_leaf_idempotency.current.0.infraNodeBlk.attributes.from_ == "1013" + - nm_udpate_node_block_leaf_idempotency.current.0.infraNodeBlk.attributes.to_ == "1013" + - nm_udpate_node_block_leaf_idempotency.current.0.infraNodeBlk.attributes.dn == "uni/infra/nprof-ansible_access_leaf_switch_profile/leaves-ansible_access_leaf_switch_selector-typ-range/nodeblk-ansible_node_block_leaf_1" + + # DELETE NODE BLOCKS + - name: Remove Node Block for Switch policy leaf selector (check_mode) + cisco.aci.aci_node_block: &node_block_leaf_absent + <<: *aci_node_block_leaf_update + state: absent + check_mode: true + register: cm_remove_node_block_leaf + + - name: Remove Node Block for Switch policy leaf selector (normal_mode) + cisco.aci.aci_node_block: + <<: *node_block_leaf_absent + register: nm_remove_node_block_leaf + + - name: Remove Node Block for Switch policy leaf selector - testing idempotency + cisco.aci.aci_node_block: + <<: *node_block_leaf_absent + register: nm_remove_node_block_leaf_idempotency + + - name: Asserts deletion tasks + ansible.builtin.assert: + that: + - cm_remove_node_block_leaf is changed + - cm_remove_node_block_leaf.current == cm_remove_node_block_leaf.previous + - cm_remove_node_block_leaf.proposed == {} + - nm_remove_node_block_leaf is changed + - nm_remove_node_block_leaf.previous != [] + - nm_remove_node_block_leaf.proposed == {} + - nm_remove_node_block_leaf.current == [] + - nm_remove_node_block_leaf_idempotency is not changed + - nm_remove_node_block_leaf_idempotency.previous == [] + - nm_remove_node_block_leaf_idempotency.current == [] + + # CLEAN ENVIRONMENT BEFORE ENDING TESTS + - name: Remove the Access Spine Switch profile - cleanup before ending tests + cisco.aci.aci_access_spine_switch_profile: + <<: *aci_access_spine_switch_profile_absent + + - name: Remove the Access Leaf Switch profile - cleanup before ending tests + cisco.aci.aci_switch_policy_leaf_profile: + <<: *aci_access_leaf_switch_profile_absent diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_node_mgmt_epg/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_node_mgmt_epg/tasks/main.yml index 310fc822b..8cdf876f6 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_node_mgmt_epg/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_node_mgmt_epg/tasks/main.yml @@ -4,12 +4,12 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: "{{ aci_hostname }}" username: "{{ aci_username }}" @@ -20,14 +20,14 @@ output_level: debug - name: Verify Cloud and Non-Cloud Sites in use. - include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml - name: Execute tasks only for non-cloud sites when: query_cloud.current == [] # This condition will execute only non-cloud sites block: # block specifies execution of tasks within, based on conditions # Clean Environment - name: Remove node mgmt in_band epg - aci_node_mgmt_epg: + cisco.aci.aci_node_mgmt_epg: <<: *aci_info type: in_band epg: "{{ item }}" @@ -39,7 +39,7 @@ - ansible-inband-2 - name: Remove node mgmt out_of_band epg - aci_node_mgmt_epg: + cisco.aci.aci_node_mgmt_epg: <<: *aci_info type: out_of_band epg: "{{ item }}" @@ -50,7 +50,7 @@ # Add operations - name: Add node mgmt in_band epg in check mode - aci_node_mgmt_epg: + cisco.aci.aci_node_mgmt_epg: <<: *aci_info type: in_band epg: ansible-inband @@ -61,7 +61,7 @@ register: add_cm_inband - name: Add node mgmt out_of_band epg in check mode - aci_node_mgmt_epg: + cisco.aci.aci_node_mgmt_epg: <<: *aci_info type: out_of_band epg: ansible-outofband @@ -70,7 +70,7 @@ register: add_cm_outofband - name: Add node mgmt in_band epg in normal mode - aci_node_mgmt_epg: + cisco.aci.aci_node_mgmt_epg: <<: *aci_info type: in_band epg: ansible-inband @@ -80,7 +80,7 @@ register: add_nm_inband - name: Add node mgmt out_of_band epg in normal mode - aci_node_mgmt_epg: + cisco.aci.aci_node_mgmt_epg: <<: *aci_info type: out_of_band epg: ansible-outofband @@ -88,7 +88,7 @@ register: add_nm_outofband - name: Add node mgmt in_band epg in normal mode again - aci_node_mgmt_epg: + cisco.aci.aci_node_mgmt_epg: <<: *aci_info type: in_band epg: ansible-inband @@ -98,7 +98,7 @@ register: add_nm_inband_again - name: Add node mgmt out_of_band epg in normal mode again - aci_node_mgmt_epg: + cisco.aci.aci_node_mgmt_epg: <<: *aci_info type: out_of_band epg: ansible-outofband @@ -106,7 +106,7 @@ register: add_nm_outofband_again - name: Add another node mgmt in_band epg in normal mode - aci_node_mgmt_epg: + cisco.aci.aci_node_mgmt_epg: <<: *aci_info type: in_band epg: ansible-inband-2 @@ -116,7 +116,7 @@ register: add_nm_inband_2 - name: Add another node mgmt out_of_band epg in normal mode - aci_node_mgmt_epg: + cisco.aci.aci_node_mgmt_epg: <<: *aci_info type: out_of_band epg: ansible-outofband-2 @@ -124,7 +124,7 @@ register: add_nm_outofband_2 - name: Add another node mgmt in_band epg in normal mode with change made to bd - aci_node_mgmt_epg: + cisco.aci.aci_node_mgmt_epg: <<: *aci_info type: in_band epg: ansible-inband-2 @@ -134,7 +134,7 @@ register: add_nm_inband_bd4 - name: Add another node mgmt in_band epg in normal mode with change made to encap - aci_node_mgmt_epg: + cisco.aci.aci_node_mgmt_epg: <<: *aci_info type: in_band epg: ansible-inband-2 @@ -144,7 +144,7 @@ register: add_nm_inband_encap4 - name: Verify add operations - assert: + ansible.builtin.assert: that: - add_cm_inband is changed - add_cm_inband.sent.mgmtInB.attributes.name == 'ansible-inband' @@ -173,7 +173,7 @@ # Query operations - name: Query node mgmt in_band epg - aci_node_mgmt_epg: + cisco.aci.aci_node_mgmt_epg: <<: *aci_info type: in_band epg: ansible-inband @@ -183,7 +183,7 @@ register: query_inband - name: Query node mgmt out_of_band epg - aci_node_mgmt_epg: + cisco.aci.aci_node_mgmt_epg: <<: *aci_info type: out_of_band epg: ansible-outofband @@ -191,21 +191,21 @@ register: query_outofband - name: Query all in band - aci_node_mgmt_epg: + cisco.aci.aci_node_mgmt_epg: <<: *aci_info type: in_band state: query register: query_all_inband - name: Query all out of band - aci_node_mgmt_epg: + cisco.aci.aci_node_mgmt_epg: <<: *aci_info type: out_of_band state: query register: query_all_outofband - name: Verify query operations - assert: + ansible.builtin.assert: that: - query_inband is not changed - query_inband.current.0.mgmtInB.attributes.name == 'ansible-inband' @@ -217,7 +217,7 @@ # Remove operations - name: Remove node mgmt in_band epg - aci_node_mgmt_epg: + cisco.aci.aci_node_mgmt_epg: <<: *aci_info type: in_band epg: ansible-inband-2 @@ -225,7 +225,7 @@ register: remove_inband_2 - name: Remove node mgmt out_of_band epg - aci_node_mgmt_epg: + cisco.aci.aci_node_mgmt_epg: <<: *aci_info type: out_of_band epg: ansible-outofband-2 @@ -233,7 +233,7 @@ register: remove_outofband_2 - name: Remove node mgmt in_band epg again - aci_node_mgmt_epg: + cisco.aci.aci_node_mgmt_epg: <<: *aci_info type: in_band epg: ansible-inband-2 @@ -241,7 +241,7 @@ register: remove_inband_2_again - name: Verify remove operations - assert: + ansible.builtin.assert: that: - remove_inband_2 is changed - remove_inband_2.previous.0.mgmtInB.attributes.name == 'ansible-inband-2' diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_ntp_policy/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_ntp_policy/tasks/main.yml index ddc5b69e6..6d07f2b00 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_ntp_policy/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_ntp_policy/tasks/main.yml @@ -4,12 +4,12 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: "{{ aci_hostname }}" username: "{{ aci_username }}" @@ -56,7 +56,7 @@ register: nm_add_policy_again - name: Verify add policy - assert: + ansible.builtin.assert: that: - cm_add_policy is changed - nm_add_policy is changed @@ -105,7 +105,7 @@ register: nm_modify_policy_again - name: Verify modify policy - assert: + ansible.builtin.assert: that: - cm_modify_policy is changed - nm_modify_policy is changed @@ -138,7 +138,7 @@ register: nm_query_all_policies - name: Verify query_all_policies - assert: + ansible.builtin.assert: that: - cm_query_all_policies is not changed - nm_query_all_policies is not changed @@ -158,7 +158,7 @@ register: nm_query_policy - name: Verify query_policy - assert: + ansible.builtin.assert: that: - cm_query_policy is not changed - nm_query_policy is not changed @@ -194,7 +194,7 @@ register: nm_remove_policy_again - name: Verify remove_policy - assert: + ansible.builtin.assert: that: - cm_remove_policy is changed - nm_remove_policy is changed diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_ntp_server/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_ntp_server/tasks/main.yml index 15c6799cb..1a1ea2879 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_ntp_server/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_ntp_server/tasks/main.yml @@ -4,12 +4,12 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: "{{ aci_hostname }}" username: "{{ aci_username }}" @@ -68,7 +68,7 @@ register: nm_add_server_again - name: Verify add server - assert: + ansible.builtin.assert: that: - cm_add_server is changed - nm_add_server is changed @@ -120,7 +120,7 @@ register: nm_modify_server_again - name: Verify modify policy - assert: + ansible.builtin.assert: that: - cm_modify_server is changed - nm_modify_server is changed @@ -156,7 +156,7 @@ register: nm_query_all_servers - name: Verify query_all_servers - assert: + ansible.builtin.assert: that: - cm_query_all_servers is not changed - nm_query_all_servers is not changed @@ -176,7 +176,7 @@ register: nm_query_server - name: Verify query_server - assert: + ansible.builtin.assert: that: - cm_query_server is not changed - nm_query_server is not changed @@ -215,7 +215,7 @@ register: nm_remove_server_again - name: Verify remove_server - assert: + ansible.builtin.assert: that: - cm_remove_server is changed - nm_remove_server is changed diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_pim_route_map_entry/aliases b/ansible_collections/cisco/aci/tests/integration/targets/aci_pim_route_map_entry/aliases new file mode 100644 index 000000000..209b793f9 --- /dev/null +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_pim_route_map_entry/aliases @@ -0,0 +1,2 @@ +# No ACI simulator yet, so not enabled +# unsupported diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_pim_route_map_entry/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_pim_route_map_entry/tasks/main.yml new file mode 100644 index 000000000..c9cdf09c2 --- /dev/null +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_pim_route_map_entry/tasks/main.yml @@ -0,0 +1,196 @@ +# Test code for the ACI modules +# Copyright: (c) 2023, Gaspard Micol (@gmicol) <gmicol@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 APIC host, ACI username and ACI password + ansible.builtin.fail: + msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' + when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined + +- name: Set vars + ansible.builtin.set_fact: + aci_info: &aci_info + host: "{{ aci_hostname }}" + username: "{{ aci_username }}" + password: "{{ aci_password }}" + validate_certs: '{{ aci_validate_certs | default(false) }}' + use_ssl: '{{ aci_use_ssl | default(true) }}' + use_proxy: '{{ aci_use_proxy | default(true) }}' + output_level: '{{ aci_output_level | default("info") }}' + +# CLEAN ENVIRONMENT +- name: Remove the ansible_tenant + cisco.aci.aci_tenant: &aci_tenant_absent + <<: *aci_info + tenant: ansible_tenant + state: absent + +- name: Verify Cloud and Non-Cloud Sites in use. + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + +- name: Execute tasks only for non-cloud sites + when: query_cloud.current == [] # This condition will execute only non-cloud sites + block: # block specifies execution of tasks within, based on conditions + - name: Add a new tenant + cisco.aci.aci_tenant: &aci_tenant_present + <<: *aci_info + tenant: ansible_tenant + description: Ansible tenant + state: present + + - name: Add a new PIM route map policy + cisco.aci.aci_pim_route_map_policy: + <<: *aci_info + tenant: ansible_tenant + pim_route_map_policy: ansible_pim_route_map_policy + description: PIM route map policy 1 for ansible_tenant tenant + state: present + + # CREATION TASKS + - name: Add a PIM route map entry (check_mode) + cisco.aci.aci_pim_route_map_entry: &aci_pim_route_map_entry_present + <<: *aci_info + tenant: ansible_tenant + pim_route_map_policy: ansible_pim_route_map_policy + order: 1 + description: PIM route map entry 1 for pim_route_map_policy + source_ip: 1.1.1.1/24 + group_ip: 224.0.0.1/24 + rp_ip: 1.1.1.2 + action: deny + state: present + check_mode: true + register: cm_add_pim_route_map_entry + + - name: Add a PIM route map entry (normal_mode) + cisco.aci.aci_pim_route_map_entry: + <<: *aci_pim_route_map_entry_present + register: nm_add_pim_route_map_entry + + - name: Add the first PIM route map entry again - testing idempotency + cisco.aci.aci_pim_route_map_entry: + <<: *aci_pim_route_map_entry_present + register: nm_add_pim_route_map_entry_idempotency + + - name: Add a second PIM route map entry (normal_mode) + cisco.aci.aci_pim_route_map_entry: + <<: *aci_info + tenant: ansible_tenant + pim_route_map_policy: ansible_pim_route_map_policy + order: 2 + description: PIM route map entry 2 for pim_route_map_policy + state: present + register: nm_add_pim_route_map_entry_2 + + - name: Asserts for PIM route map entry creation tasks + ansible.builtin.assert: + that: + - cm_add_pim_route_map_entry is changed + - cm_add_pim_route_map_entry.previous == [] + - cm_add_pim_route_map_entry.current == [] + - nm_add_pim_route_map_entry is changed + - nm_add_pim_route_map_entry.current.0.pimRouteMapEntry.attributes.order == "1" + - nm_add_pim_route_map_entry.current.0.pimRouteMapEntry.attributes.action == "deny" + - nm_add_pim_route_map_entry.current.0.pimRouteMapEntry.attributes.grp == "224.0.0.1/24" + - nm_add_pim_route_map_entry.current.0.pimRouteMapEntry.attributes.rp == "1.1.1.2" + - nm_add_pim_route_map_entry.current.0.pimRouteMapEntry.attributes.src == "1.1.1.1/24" + - nm_add_pim_route_map_entry_idempotency is not changed + - nm_add_pim_route_map_entry_2 is changed + - nm_add_pim_route_map_entry_2.previous == [] + - nm_add_pim_route_map_entry_2.current.0.pimRouteMapEntry.attributes.order == "2" + - nm_add_pim_route_map_entry_2.current.0.pimRouteMapEntry.attributes.action == "permit" + + # QUERY TASKS + - name: Query all PIM route map entries + cisco.aci.aci_pim_route_map_entry: + <<: *aci_info + state: query + register: query_all_pim_route_map_entry + + - name: Query ansible_pim_route_map_entry_1 + cisco.aci.aci_pim_route_map_entry: + <<: *aci_pim_route_map_entry_present + state: query + register: query_ansible_pim_route_map_entry_1 + + - name: Asserts query tasks + ansible.builtin.assert: + that: + - query_all_pim_route_map_entry is not changed + - query_all_pim_route_map_entry.current|length >= 2 + - query_ansible_pim_route_map_entry_1 is not changed + - query_ansible_pim_route_map_entry_1.current.0.pimRouteMapEntry.attributes.order == "1" + - query_ansible_pim_route_map_entry_1.current.0.pimRouteMapEntry.attributes.action == "deny" + - query_ansible_pim_route_map_entry_1.current.0.pimRouteMapEntry.attributes.grp == "224.0.0.1/24" + - query_ansible_pim_route_map_entry_1.current.0.pimRouteMapEntry.attributes.rp == "1.1.1.2" + - query_ansible_pim_route_map_entry_1.current.0.pimRouteMapEntry.attributes.src == "1.1.1.1/24" + + # UPDATE TASKS + - name: Update first PIM route map entry (check_mode) + cisco.aci.aci_pim_route_map_entry: &aci_pim_route_map_entry_update + <<: *aci_pim_route_map_entry_present + order: 3 + source_ip: 1.1.1.3/24 + group_ip: 224.0.0.3/24 + rp_ip: 1.1.1.3 + action: permit + check_mode: true + register: cm_update_pim_route_map_entry + + - name: Update first PIM route map entry (normal_mode) + cisco.aci.aci_pim_route_map_entry: + <<: *aci_pim_route_map_entry_update + register: nm_update_pim_route_map_entry + + - name: Update first PIM route map entry again - testing idempotency + cisco.aci.aci_pim_route_map_entry: + <<: *aci_pim_route_map_entry_update + register: nm_update_pim_route_map_entry_idempotency + + - name: Asserts for PIM route map entry update tasks + ansible.builtin.assert: + that: + - cm_update_pim_route_map_entry is changed + - cm_update_pim_route_map_entry.previous == cm_update_pim_route_map_entry.current + - nm_update_pim_route_map_entry is changed + - nm_update_pim_route_map_entry.current.0.pimRouteMapEntry.attributes.order == "3" + - nm_update_pim_route_map_entry.current.0.pimRouteMapEntry.attributes.action == "permit" + - nm_update_pim_route_map_entry.current.0.pimRouteMapEntry.attributes.grp == "224.0.0.3/24" + - nm_update_pim_route_map_entry.current.0.pimRouteMapEntry.attributes.rp == "1.1.1.3" + - nm_update_pim_route_map_entry.current.0.pimRouteMapEntry.attributes.src == "1.1.1.3/24" + - nm_update_pim_route_map_entry_idempotency is not changed + + # DELETION TASKS + - name: Remove PIM route map entry (check_mode) + cisco.aci.aci_pim_route_map_entry: &pim_route_map_entry_absent + <<: *aci_pim_route_map_entry_update + state: absent + check_mode: true + register: cm_remove_pim_route_map_entry + + - name: Remove PIM route map entry (normal_mode) + cisco.aci.aci_pim_route_map_entry: + <<: *pim_route_map_entry_absent + register: nm_remove_pim_route_map_entry + + - name: Remove PIM route map entry - testing idempotency + cisco.aci.aci_pim_route_map_entry: + <<: *pim_route_map_entry_absent + register: nm_remove_pim_route_map_entry_idempotency + + - name: Asserts deletion tasks + ansible.builtin.assert: + that: + - cm_remove_pim_route_map_entry is changed + - cm_remove_pim_route_map_entry.proposed == {} + - nm_remove_pim_route_map_entry is changed + - nm_remove_pim_route_map_entry.previous != [] + - nm_remove_pim_route_map_entry.current == [] + - nm_remove_pim_route_map_entry_idempotency is not changed + - nm_remove_pim_route_map_entry_idempotency.previous == [] + + - name: Remove the ansible_tenant - cleanup before ending tests + cisco.aci.aci_tenant: + <<: *aci_tenant_present + state: absent diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_pim_route_map_policy/aliases b/ansible_collections/cisco/aci/tests/integration/targets/aci_pim_route_map_policy/aliases new file mode 100644 index 000000000..209b793f9 --- /dev/null +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_pim_route_map_policy/aliases @@ -0,0 +1,2 @@ +# No ACI simulator yet, so not enabled +# unsupported diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_pim_route_map_policy/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_pim_route_map_policy/tasks/main.yml new file mode 100644 index 000000000..4737bb2bb --- /dev/null +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_pim_route_map_policy/tasks/main.yml @@ -0,0 +1,135 @@ +# Test code for the ACI modules +# Copyright: (c) 2023, Gaspard Micol (@gmicol) <gmicol@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 APIC host, ACI username and ACI password + ansible.builtin.fail: + msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' + when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined + +- name: Set vars + ansible.builtin.set_fact: + aci_info: &aci_info + host: "{{ aci_hostname }}" + username: "{{ aci_username }}" + password: "{{ aci_password }}" + validate_certs: '{{ aci_validate_certs | default(false) }}' + use_ssl: '{{ aci_use_ssl | default(true) }}' + use_proxy: '{{ aci_use_proxy | default(true) }}' + output_level: '{{ aci_output_level | default("info") }}' + +# CLEAN ENVIRONMENT +- name: Remove the ansible_tenant + cisco.aci.aci_tenant: &aci_tenant_absent + <<: *aci_info + tenant: ansible_tenant + state: absent + +- name: Verify Cloud and Non-Cloud Sites in use. + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + +- name: Execute tasks only for non-cloud sites + when: query_cloud.current == [] # This condition will execute only non-cloud sites + block: # block specifies execution of tasks within, based on conditions + - name: Add a new tenant + cisco.aci.aci_tenant: &aci_tenant_present + <<: *aci_info + tenant: ansible_tenant + description: Ansible tenant + state: present + + - name: Add a PIM route map policy (check_mode) + cisco.aci.aci_pim_route_map_policy: &aci_pim_route_map_policy_present + <<: *aci_info + tenant: ansible_tenant + pim_route_map_policy: ansible_pim_route_map_policy_1 + description: PIM route map policy 1 for ansible_tenant tenant + state: present + check_mode: true + register: cm_add_pim_route_map_policy + + - name: Add a PIM route map policy (normal_mode) + cisco.aci.aci_pim_route_map_policy: + <<: *aci_pim_route_map_policy_present + register: nm_add_pim_route_map_policy + + - name: Add the first PIM route map policy again - testing idempotency + cisco.aci.aci_pim_route_map_policy: + <<: *aci_pim_route_map_policy_present + register: nm_add_pim_route_map_policy_idempotency + + - name: Add a second PIM route map policy (normal_mode) + cisco.aci.aci_pim_route_map_policy: + <<: *aci_info + tenant: ansible_tenant + pim_route_map_policy: ansible_pim_route_map_policy_2 + description: PIM route map policy 2 for ansible_tenant tenant + state: present + register: nm_add_pim_route_map_policy_2 + + - name: Asserts for PIM route map policy creation tasks + ansible.builtin.assert: + that: + - cm_add_pim_route_map_policy is changed + - cm_add_pim_route_map_policy.previous == [] + - cm_add_pim_route_map_policy.current == [] + - nm_add_pim_route_map_policy is changed + - nm_add_pim_route_map_policy.current.0.pimRouteMapPol.attributes.name == "ansible_pim_route_map_policy_1" + - nm_add_pim_route_map_policy_idempotency is not changed + - nm_add_pim_route_map_policy_2 is changed + - nm_add_pim_route_map_policy_2.previous == [] + - nm_add_pim_route_map_policy_2.current.0.pimRouteMapPol.attributes.name == "ansible_pim_route_map_policy_2" + + - name: Query all PIM route map policies + cisco.aci.aci_pim_route_map_policy: + <<: *aci_info + state: query + register: query_all_pim_route_map_policy + + - name: Query ansible_pim_route_map_policy_1 + cisco.aci.aci_pim_route_map_policy: + <<: *aci_pim_route_map_policy_present + state: query + register: query_ansible_pim_route_map_policy_1 + + - name: Asserts query tasks + ansible.builtin.assert: + that: + - query_all_pim_route_map_policy is not changed + - query_all_pim_route_map_policy.current|length >= 2 + - query_ansible_pim_route_map_policy_1 is not changed + - query_ansible_pim_route_map_policy_1.current.0.pimRouteMapPol.attributes.name == "ansible_pim_route_map_policy_1" + + - name: Remove PIM route map policy (check_mode) + cisco.aci.aci_pim_route_map_policy: &pim_route_map_policy_absent + <<: *aci_pim_route_map_policy_present + state: absent + check_mode: true + register: cm_remove_pim_route_map_policy + + - name: Remove PIM route map policy (normal_mode) + cisco.aci.aci_pim_route_map_policy: + <<: *pim_route_map_policy_absent + register: nm_remove_pim_route_map_policy + + - name: Remove PIM route map policy - testing idempotency + cisco.aci.aci_pim_route_map_policy: + <<: *pim_route_map_policy_absent + register: nm_remove_pim_route_map_policy_idempotency + + - name: Asserts deletion tasks + ansible.builtin.assert: + that: + - cm_remove_pim_route_map_policy is changed + - cm_remove_pim_route_map_policy.proposed == {} + - nm_remove_pim_route_map_policy is changed + - nm_remove_pim_route_map_policy.previous != [] + - nm_remove_pim_route_map_policy.current == [] + - nm_remove_pim_route_map_policy_idempotency is not changed + - nm_remove_pim_route_map_policy_idempotency.previous == [] + + - name: Remove the ansible_tenant - cleanup before ending tests + cisco.aci.aci_tenant: + <<: *aci_tenant_present + state: absent diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_qos_custom_policy/aliases b/ansible_collections/cisco/aci/tests/integration/targets/aci_qos_custom_policy/aliases new file mode 100644 index 000000000..209b793f9 --- /dev/null +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_qos_custom_policy/aliases @@ -0,0 +1,2 @@ +# No ACI simulator yet, so not enabled +# unsupported diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_qos_custom_policy/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_qos_custom_policy/tasks/main.yml new file mode 100644 index 000000000..0a984577a --- /dev/null +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_qos_custom_policy/tasks/main.yml @@ -0,0 +1,139 @@ +# Test code for the ACI modules +# Copyright: (c) 2023, Gaspard Micol (@gmicol) <gmicol@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 APIC host, ACI username and ACI password + ansible.builtin.fail: + msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' + when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined + +- name: Set vars + ansible.builtin.set_fact: + aci_info: &aci_info + host: "{{ aci_hostname }}" + username: "{{ aci_username }}" + password: "{{ aci_password }}" + validate_certs: '{{ aci_validate_certs | default(false) }}' + use_ssl: '{{ aci_use_ssl | default(true) }}' + use_proxy: '{{ aci_use_proxy | default(true) }}' + output_level: '{{ aci_output_level | default("info") }}' + +# CLEAN ENVIRONMENT BEFORE TESTS +- name: Remove the ansible_tenant + cisco.aci.aci_tenant: &aci_tenant_absent + <<: *aci_info + tenant: ansible_tenant + state: absent + +- name: Verify Cloud and Non-Cloud Sites in use. + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + +- name: Execute tasks only for non-cloud sites + when: query_cloud.current == [] # This condition will execute only non-cloud sites + block: # block specifies execution of tasks within, based on conditions + - name: Add a new tenant + cisco.aci.aci_tenant: &aci_tenant_present + <<: *aci_info + tenant: ansible_tenant + description: Ansible tenant + state: present + + # CREATE QOS CUSTOM POLICY + - name: Add a QoS Custom policy (check_mode) + cisco.aci.aci_qos_custom_policy: &aci_qos_custom_policy_present + <<: *aci_info + tenant: ansible_tenant + qos_custom_policy: ansible_qos_custom_policy_1 + description: QoS Custom policy 1 for ansible_tenant tenant + state: present + check_mode: true + register: cm_add_qos_custom_policy + + - name: Add a QoS Custom policy (normal_mode) + cisco.aci.aci_qos_custom_policy: + <<: *aci_qos_custom_policy_present + register: nm_add_qos_custom_policy + + - name: Add the first QoS Custom policy again - testing idempotency + cisco.aci.aci_qos_custom_policy: + <<: *aci_qos_custom_policy_present + register: nm_add_qos_custom_policy_idempotency + + - name: Add a second QoS Custom policy (normal_mode) + cisco.aci.aci_qos_custom_policy: + <<: *aci_info + tenant: ansible_tenant + qos_custom_policy: ansible_qos_custom_policy_2 + description: QoS Custom policy 2 for ansible_tenant tenant + state: present + register: nm_add_qos_custom_policy_2 + + - name: Asserts for QoS Custom policy creation tasks + ansible.builtin.assert: + that: + - cm_add_qos_custom_policy is changed + - cm_add_qos_custom_policy.previous == [] + - cm_add_qos_custom_policy.current == [] + - nm_add_qos_custom_policy is changed + - nm_add_qos_custom_policy.current.0.qosCustomPol.attributes.name == "ansible_qos_custom_policy_1" + - nm_add_qos_custom_policy_idempotency is not changed + - nm_add_qos_custom_policy_2 is changed + - nm_add_qos_custom_policy_2.previous == [] + - nm_add_qos_custom_policy_2.current.0.qosCustomPol.attributes.name == "ansible_qos_custom_policy_2" + + # QUERY QOS CUSTOM POLICY + - name: Query all QoS Custom policies + cisco.aci.aci_qos_custom_policy: + <<: *aci_info + state: query + register: query_all_qos_custom_policy + + - name: Query ansible_qos_custom_policy_1 + cisco.aci.aci_qos_custom_policy: + <<: *aci_qos_custom_policy_present + state: query + register: query_ansible_qos_custom_policy_1 + + - name: Asserts query tasks + ansible.builtin.assert: + that: + - query_all_qos_custom_policy is not changed + - query_all_qos_custom_policy.current|length >= 2 + - query_ansible_qos_custom_policy_1 is not changed + - query_ansible_qos_custom_policy_1.current.0.qosCustomPol.attributes.name == "ansible_qos_custom_policy_1" + + # DELETE QOS CUSTOM POLICY + - name: Remove QoS Custom policy (check_mode) + cisco.aci.aci_qos_custom_policy: &qos_custom_policy_absent + <<: *aci_qos_custom_policy_present + state: absent + check_mode: true + register: cm_remove_qos_custom_policy + + - name: Remove QoS Custom policy (normal_mode) + cisco.aci.aci_qos_custom_policy: + <<: *qos_custom_policy_absent + register: nm_remove_qos_custom_policy + + - name: Remove QoS Custom policy - testing idempotency + cisco.aci.aci_qos_custom_policy: + <<: *qos_custom_policy_absent + register: nm_remove_qos_custom_policy_idempotency + + - name: Asserts deletion tasks + ansible.builtin.assert: + that: + - cm_remove_qos_custom_policy is changed + - cm_remove_qos_custom_policy.proposed == {} + - nm_remove_qos_custom_policy is changed + - nm_remove_qos_custom_policy.previous != [] + - nm_remove_qos_custom_policy.current == [] + - nm_remove_qos_custom_policy_idempotency is not changed + - nm_remove_qos_custom_policy_idempotency.previous == [] + + # CLEAN ENVIRONMENT BEFORE ENDING TESTS + - name: Remove the ansible_tenant - cleanup before ending tests + cisco.aci.aci_tenant: + <<: *aci_tenant_present + state: absent diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_qos_dot1p_class/aliases b/ansible_collections/cisco/aci/tests/integration/targets/aci_qos_dot1p_class/aliases new file mode 100644 index 000000000..209b793f9 --- /dev/null +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_qos_dot1p_class/aliases @@ -0,0 +1,2 @@ +# No ACI simulator yet, so not enabled +# unsupported diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_qos_dot1p_class/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_qos_dot1p_class/tasks/main.yml new file mode 100644 index 000000000..efcfa993f --- /dev/null +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_qos_dot1p_class/tasks/main.yml @@ -0,0 +1,167 @@ +# Test code for the ACI modules +# Copyright: (c) 2023, Gaspard Micol (@gmicol) <gmicol@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 APIC host, ACI username and ACI password + ansible.builtin.fail: + msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' + when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined + +- name: Set vars + ansible.builtin.set_fact: + aci_info: &aci_info + host: "{{ aci_hostname }}" + username: "{{ aci_username }}" + password: "{{ aci_password }}" + validate_certs: '{{ aci_validate_certs | default(false) }}' + use_ssl: '{{ aci_use_ssl | default(true) }}' + use_proxy: '{{ aci_use_proxy | default(true) }}' + output_level: '{{ aci_output_level | default("info") }}' + +# CLEAN ENVIRONMENT BEFORE TESTS +- name: Remove the ansible_tenant + cisco.aci.aci_tenant: &aci_tenant_absent + <<: *aci_info + tenant: ansible_tenant + state: absent + +- name: Verify Cloud and Non-Cloud Sites in use. + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + +- name: Execute tasks only for non-cloud sites + when: query_cloud.current == [] # This condition will execute only non-cloud sites + block: # block specifies execution of tasks within, based on conditions + - name: Add a new tenant + cisco.aci.aci_tenant: &aci_tenant_present + <<: *aci_info + tenant: ansible_tenant + description: Ansible tenant + state: present + + - name: Add a QoS Custom policy + cisco.aci.aci_qos_custom_policy: + <<: *aci_info + tenant: ansible_tenant + qos_custom_policy: ansible_qos_custom_policy_1 + description: QoS Custom policy 1 for ansible_tenant tenant + state: present + + # CREATE QOS Dot1P Class + - name: Add a QoS Dot1P Class (check_mode) + cisco.aci.aci_qos_dot1p_class: &aci_qos_dot1p_class_present + <<: *aci_info + tenant: ansible_tenant + qos_custom_policy: ansible_qos_custom_policy_1 + priority: level1 + dot1p_from: best_effort + dot1p_to: excellent_effort + dot1p_target: AF31 + target_cos: best_effort + state: present + check_mode: true + register: cm_add_qos_dot1p_class + + - name: Add a QoS Dot1P Class (normal_mode) + cisco.aci.aci_qos_dot1p_class: + <<: *aci_qos_dot1p_class_present + register: nm_add_qos_dot1p_class + + - name: Add the first QoS Dot1P Class again - testing idempotency + cisco.aci.aci_qos_dot1p_class: + <<: *aci_qos_dot1p_class_present + register: nm_add_qos_dot1p_class_idempotency + + - name: Add a second QoS Dot1P Class (normal_mode) + cisco.aci.aci_qos_dot1p_class: + <<: *aci_info + tenant: ansible_tenant + qos_custom_policy: ansible_qos_custom_policy_1 + dot1p_from: video + dot1p_to: voice + state: present + register: nm_add_qos_dot1p_class_2 + + - name: Asserts for QoS Dot1P Class creation tasks + ansible.builtin.assert: + that: + - cm_add_qos_dot1p_class is changed + - cm_add_qos_dot1p_class.previous == [] + - cm_add_qos_dot1p_class.current == [] + - nm_add_qos_dot1p_class is changed + - nm_add_qos_dot1p_class.current.0.qosDot1PClass.attributes.prio == "level1" + - nm_add_qos_dot1p_class.current.0.qosDot1PClass.attributes.from == "1" + - nm_add_qos_dot1p_class.current.0.qosDot1PClass.attributes.to == "2" + - nm_add_qos_dot1p_class.current.0.qosDot1PClass.attributes.target == "AF31" + - nm_add_qos_dot1p_class.current.0.qosDot1PClass.attributes.targetCos == "1" + - nm_add_qos_dot1p_class.current.0.qosDot1PClass.attributes.dn == "uni/tn-ansible_tenant/qoscustom-ansible_qos_custom_policy_1/dot1P-1-2" + - nm_add_qos_dot1p_class_idempotency is not changed + - nm_add_qos_dot1p_class_2 is changed + - nm_add_qos_dot1p_class_2.previous == [] + - nm_add_qos_dot1p_class_2.current.0.qosDot1PClass.attributes.prio == "unspecified" + - nm_add_qos_dot1p_class_2.current.0.qosDot1PClass.attributes.from == "4" + - nm_add_qos_dot1p_class_2.current.0.qosDot1PClass.attributes.to == "5" + - nm_add_qos_dot1p_class_2.current.0.qosDot1PClass.attributes.target == "unspecified" + - nm_add_qos_dot1p_class_2.current.0.qosDot1PClass.attributes.targetCos == "unspecified" + - nm_add_qos_dot1p_class_2.current.0.qosDot1PClass.attributes.dn == "uni/tn-ansible_tenant/qoscustom-ansible_qos_custom_policy_1/dot1P-4-5" + + # QUERY QOS Dot1P Class + - name: Query all QoS Custom policies + cisco.aci.aci_qos_dot1p_class: + <<: *aci_info + state: query + register: query_all_qos_dot1p_class + + - name: Query ansible_qos_dot1p_class_1 + cisco.aci.aci_qos_dot1p_class: + <<: *aci_qos_dot1p_class_present + state: query + register: query_ansible_qos_dot1p_class_1 + + - name: Asserts query tasks + ansible.builtin.assert: + that: + - query_all_qos_dot1p_class is not changed + - query_all_qos_dot1p_class.current|length >= 2 + - query_ansible_qos_dot1p_class_1 is not changed + - query_ansible_qos_dot1p_class_1.current.0.qosDot1PClass.attributes.prio == "level1" + - query_ansible_qos_dot1p_class_1.current.0.qosDot1PClass.attributes.from == "1" + - query_ansible_qos_dot1p_class_1.current.0.qosDot1PClass.attributes.to == "2" + - query_ansible_qos_dot1p_class_1.current.0.qosDot1PClass.attributes.target == "AF31" + - query_ansible_qos_dot1p_class_1.current.0.qosDot1PClass.attributes.targetCos == "1" + - query_ansible_qos_dot1p_class_1.current.0.qosDot1PClass.attributes.dn == "uni/tn-ansible_tenant/qoscustom-ansible_qos_custom_policy_1/dot1P-1-2" + + # DELETE QOS Dot1P Class + - name: Remove QoS Dot1P Class (check_mode) + cisco.aci.aci_qos_dot1p_class: &qos_dot1p_class_absent + <<: *aci_qos_dot1p_class_present + state: absent + check_mode: true + register: cm_remove_qos_dot1p_class + + - name: Remove QoS Dot1P Class (normal_mode) + cisco.aci.aci_qos_dot1p_class: + <<: *qos_dot1p_class_absent + register: nm_remove_qos_dot1p_class + + - name: Remove QoS Dot1P Class - testing idempotency + cisco.aci.aci_qos_dot1p_class: + <<: *qos_dot1p_class_absent + register: nm_remove_qos_dot1p_class_idempotency + + - name: Asserts deletion tasks + ansible.builtin.assert: + that: + - cm_remove_qos_dot1p_class is changed + - cm_remove_qos_dot1p_class.proposed == {} + - nm_remove_qos_dot1p_class is changed + - nm_remove_qos_dot1p_class.previous != [] + - nm_remove_qos_dot1p_class.current == [] + - nm_remove_qos_dot1p_class_idempotency is not changed + - nm_remove_qos_dot1p_class_idempotency.previous == [] + + # CLEAN ENVIRONMENT BEFORE ENDING TESTS + - name: Remove the ansible_tenant - cleanup before ending tests + cisco.aci.aci_tenant: + <<: *aci_tenant_present + state: absent diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_qos_dscp_class/aliases b/ansible_collections/cisco/aci/tests/integration/targets/aci_qos_dscp_class/aliases new file mode 100644 index 000000000..209b793f9 --- /dev/null +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_qos_dscp_class/aliases @@ -0,0 +1,2 @@ +# No ACI simulator yet, so not enabled +# unsupported diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_qos_dscp_class/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_qos_dscp_class/tasks/main.yml new file mode 100644 index 000000000..b64848d05 --- /dev/null +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_qos_dscp_class/tasks/main.yml @@ -0,0 +1,167 @@ +# Test code for the ACI modules +# Copyright: (c) 2023, Gaspard Micol (@gmicol) <gmicol@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 APIC host, ACI username and ACI password + ansible.builtin.fail: + msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' + when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined + +- name: Set vars + ansible.builtin.set_fact: + aci_info: &aci_info + host: "{{ aci_hostname }}" + username: "{{ aci_username }}" + password: "{{ aci_password }}" + validate_certs: '{{ aci_validate_certs | default(false) }}' + use_ssl: '{{ aci_use_ssl | default(true) }}' + use_proxy: '{{ aci_use_proxy | default(true) }}' + output_level: '{{ aci_output_level | default("info") }}' + +# CLEAN ENVIRONMENT BEFORE TESTS +- name: Remove the ansible_tenant + cisco.aci.aci_tenant: &aci_tenant_absent + <<: *aci_info + tenant: ansible_tenant + state: absent + +- name: Verify Cloud and Non-Cloud Sites in use. + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + +- name: Execute tasks only for non-cloud sites + when: query_cloud.current == [] # This condition will execute only non-cloud sites + block: # block specifies execution of tasks within, based on conditions + - name: Add a new tenant + cisco.aci.aci_tenant: &aci_tenant_present + <<: *aci_info + tenant: ansible_tenant + description: Ansible tenant + state: present + + - name: Add a QoS Custom policy + cisco.aci.aci_qos_custom_policy: + <<: *aci_info + tenant: ansible_tenant + qos_custom_policy: ansible_qos_custom_policy_1 + description: QoS Custom policy 1 for ansible_tenant tenant + state: present + + # CREATE QOS DSCP Class + - name: Add a QoS DSCP Class (check_mode) + cisco.aci.aci_qos_dscp_class: &aci_qos_dscp_class_present + <<: *aci_info + tenant: ansible_tenant + qos_custom_policy: ansible_qos_custom_policy_1 + priority: level1 + dscp_from: AF11 + dscp_to: AF21 + dscp_target: AF31 + target_cos: best_effort + state: present + check_mode: true + register: cm_add_qos_dscp_class + + - name: Add a QoS DSCP Class (normal_mode) + cisco.aci.aci_qos_dscp_class: + <<: *aci_qos_dscp_class_present + register: nm_add_qos_dscp_class + + - name: Add the first QoS DSCP Class again - testing idempotency + cisco.aci.aci_qos_dscp_class: + <<: *aci_qos_dscp_class_present + register: nm_add_qos_dscp_class_idempotency + + - name: Add a second QoS DSCP Class (normal_mode) + cisco.aci.aci_qos_dscp_class: + <<: *aci_info + tenant: ansible_tenant + qos_custom_policy: ansible_qos_custom_policy_1 + dscp_from: AF32 + dscp_to: AF42 + state: present + register: nm_add_qos_dscp_class_2 + + - name: Asserts for QoS DSCP Class creation tasks + ansible.builtin.assert: + that: + - cm_add_qos_dscp_class is changed + - cm_add_qos_dscp_class.previous == [] + - cm_add_qos_dscp_class.current == [] + - nm_add_qos_dscp_class is changed + - nm_add_qos_dscp_class.current.0.qosDscpClass.attributes.prio == "level1" + - nm_add_qos_dscp_class.current.0.qosDscpClass.attributes.from == "AF11" + - nm_add_qos_dscp_class.current.0.qosDscpClass.attributes.to == "AF21" + - nm_add_qos_dscp_class.current.0.qosDscpClass.attributes.target == "AF31" + - nm_add_qos_dscp_class.current.0.qosDscpClass.attributes.targetCos == "1" + - nm_add_qos_dscp_class.current.0.qosDscpClass.attributes.dn == "uni/tn-ansible_tenant/qoscustom-ansible_qos_custom_policy_1/dcsp-AF11-AF21" + - nm_add_qos_dscp_class_idempotency is not changed + - nm_add_qos_dscp_class_2 is changed + - nm_add_qos_dscp_class_2.previous == [] + - nm_add_qos_dscp_class_2.current.0.qosDscpClass.attributes.prio == "unspecified" + - nm_add_qos_dscp_class_2.current.0.qosDscpClass.attributes.from == "AF32" + - nm_add_qos_dscp_class_2.current.0.qosDscpClass.attributes.to == "AF42" + - nm_add_qos_dscp_class_2.current.0.qosDscpClass.attributes.target == "unspecified" + - nm_add_qos_dscp_class_2.current.0.qosDscpClass.attributes.targetCos == "unspecified" + - nm_add_qos_dscp_class_2.current.0.qosDscpClass.attributes.dn == "uni/tn-ansible_tenant/qoscustom-ansible_qos_custom_policy_1/dcsp-AF32-AF42" + + # QUERY QOS DSCP Class + - name: Query all QoS Custom policies + cisco.aci.aci_qos_dscp_class: + <<: *aci_info + state: query + register: query_all_qos_dscp_class + + - name: Query ansible_qos_dscp_class_1 + cisco.aci.aci_qos_dscp_class: + <<: *aci_qos_dscp_class_present + state: query + register: query_ansible_qos_dscp_class_1 + + - name: Asserts query tasks + ansible.builtin.assert: + that: + - query_all_qos_dscp_class is not changed + - query_all_qos_dscp_class.current|length >= 2 + - query_ansible_qos_dscp_class_1 is not changed + - query_ansible_qos_dscp_class_1.current.0.qosDscpClass.attributes.prio == "level1" + - query_ansible_qos_dscp_class_1.current.0.qosDscpClass.attributes.from == "AF11" + - query_ansible_qos_dscp_class_1.current.0.qosDscpClass.attributes.to == "AF21" + - query_ansible_qos_dscp_class_1.current.0.qosDscpClass.attributes.target == "AF31" + - query_ansible_qos_dscp_class_1.current.0.qosDscpClass.attributes.targetCos == "1" + - query_ansible_qos_dscp_class_1.current.0.qosDscpClass.attributes.dn == "uni/tn-ansible_tenant/qoscustom-ansible_qos_custom_policy_1/dcsp-AF11-AF21" + + # DELETE QOS DSCP Class + - name: Remove QoS DSCP Class (check_mode) + cisco.aci.aci_qos_dscp_class: &qos_dscp_class_absent + <<: *aci_qos_dscp_class_present + state: absent + check_mode: true + register: cm_remove_qos_dscp_class + + - name: Remove QoS DSCP Class (normal_mode) + cisco.aci.aci_qos_dscp_class: + <<: *qos_dscp_class_absent + register: nm_remove_qos_dscp_class + + - name: Remove QoS DSCP Class - testing idempotency + cisco.aci.aci_qos_dscp_class: + <<: *qos_dscp_class_absent + register: nm_remove_qos_dscp_class_idempotency + + - name: Asserts deletion tasks + ansible.builtin.assert: + that: + - cm_remove_qos_dscp_class is changed + - cm_remove_qos_dscp_class.proposed == {} + - nm_remove_qos_dscp_class is changed + - nm_remove_qos_dscp_class.previous != [] + - nm_remove_qos_dscp_class.current == [] + - nm_remove_qos_dscp_class_idempotency is not changed + - nm_remove_qos_dscp_class_idempotency.previous == [] + + # CLEAN ENVIRONMENT BEFORE ENDING TESTS + - name: Remove the ansible_tenant - cleanup before ending tests + cisco.aci.aci_tenant: + <<: *aci_tenant_present + state: absent diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_rest/tasks/error_handling.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_rest/tasks/error_handling.yml index 49c6fca53..2ea77b46f 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_rest/tasks/error_handling.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_rest/tasks/error_handling.yml @@ -24,7 +24,7 @@ register: error_on_name_resolution - name: Verify error_on_name_resolution - assert: + ansible.builtin.assert: that: - error_on_name_resolution is failed - error_on_name_resolution.msg.startswith("Connection failed for https://foo.bar.cisco.com/api/aaaLogin.json.") @@ -51,7 +51,7 @@ register: error_on_missing_required_param - name: Verify error_on_missing_required_param - assert: + ansible.builtin.assert: that: - error_on_missing_required_param is failed - 'error_on_missing_required_param.msg == "missing required arguments: path"' @@ -78,7 +78,7 @@ register: error_on_missing_attributes - name: Verify error_on_missing_attributes - assert: + ansible.builtin.assert: that: - error_on_missing_attributes is failed - error_on_missing_attributes.method == 'POST' @@ -110,11 +110,11 @@ register: error_on_input_validation - name: Verify error_on_input_validation - assert: + ansible.builtin.assert: that: - error_on_input_validation is failed - error_on_input_validation.method == 'POST' - - "error_on_input_validation.msg == 'APIC Error 801: property descr of tn-ansible_test failed validation for value \\'This is an [invalid] description\\''" + - "error_on_input_validation.msg is ansible.builtin.regex('APIC Error 801: property descr of.*tn-ansible_test failed validation for value \\'This is an \\[invalid\\] description\\'')" - 'error_on_input_validation.response == "HTTP Error 400: Bad Request"' - error_on_input_validation.status == 400 - "'current' not in error_on_input_validation" @@ -142,7 +142,7 @@ register: error_on_invalid_attributes - name: Verify error_on_invalid_attributes - assert: + ansible.builtin.assert: that: - error_on_invalid_attributes is failed - error_on_invalid_attributes.method == 'POST' @@ -173,7 +173,7 @@ register: error_on_invalid_object - name: Verify error_on_invalid_object - assert: + ansible.builtin.assert: that: - error_on_invalid_object is failed - error_on_invalid_object.method == 'POST' @@ -314,7 +314,7 @@ register: err_fail_parse_json - name: Assertions checks for import error handling, invalid src, invalid path extension and parse failures - assert: + ansible.builtin.assert: that: - err_missing_lxml.msg == "The lxml python library is missing, or lacks etree support." - err_missing_xmljson.msg == "The xmljson python library is missing, or lacks cobra support." diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_rest/tasks/json_inline.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_rest/tasks/json_inline.yml index 3d5c9be48..74711ffed 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_rest/tasks/json_inline.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_rest/tasks/json_inline.yml @@ -54,10 +54,11 @@ register: cm_verify_checkmode_tenant - name: Verify checkmode POST operation - assert: + ansible.builtin.assert: that: - cm_add_tenant is changed - cm_add_tenant.proposed.fvTenant.attributes.name == "ansible_test" + - cm_add_tenant.proposed.fvTenant.attributes.annotation == "orchestrator:ansible" - cm_verify_checkmode_tenant.current == [] - name: Add tenant (normal mode) @@ -69,9 +70,10 @@ register: nm_add_tenant_again - name: Verify add_tenant - assert: + ansible.builtin.assert: that: - nm_add_tenant is changed + - nm_add_tenant.imdata.0.fvTenant.attributes.annotation == "orchestrator:ansible" - nm_add_tenant_again is not changed # CHANGE TENANT @@ -102,7 +104,7 @@ register: nm_add_tenant_descr_again - name: Verify add_tenant_descr - assert: + ansible.builtin.assert: that: - nm_add_tenant_descr is changed - nm_add_tenant_descr_again is not changed @@ -113,7 +115,7 @@ register: nm_add_tenant_again_no_descr - name: Verify add_tenant_again_no_descr - assert: + ansible.builtin.assert: that: - nm_add_tenant_again_no_descr is not changed @@ -132,7 +134,7 @@ register: nm_query_all_tenants - name: Verify query_all_tenants - assert: + ansible.builtin.assert: that: - nm_query_all_tenants is not changed @@ -151,7 +153,7 @@ register: nm_query_tenant - name: Verify query_tenant - assert: + ansible.builtin.assert: that: - nm_query_tenant is not changed @@ -165,7 +167,7 @@ register: nm_remove_tenant_again - name: Verify remove_tenant - assert: + ansible.builtin.assert: that: - nm_remove_tenant is changed - nm_remove_tenant_again is not changed @@ -176,6 +178,163 @@ register: nm_query_non_tenant - name: Verify query_non_tenant - assert: + ansible.builtin.assert: that: - nm_query_non_tenant is not changed + +# VERIFY ANNOTATION SUPPORT +- name: Add tenant with annotation option + cisco.aci.aci_rest: + host: '{{ aci_hostname }}' + username: '{{ aci_username }}' + password: '{{ aci_password }}' + validate_certs: '{{ aci_validate_certs | default(false) }}' + use_ssl: '{{ aci_use_ssl | default(true) }}' + use_proxy: '{{ aci_use_proxy | default(true) }}' + output_level: '{{ aci_output_level | default("info") }}' + path: /api/mo/uni.json + method: post + annotation: test:inoption + content: + { + "fvTenant": { + "attributes": { + "descr": "Ansible test tenant", + "name": "ansible_test" + } + } + } + register: nm_add_tenant_annotation_option + +- name: Add tenant with annotation in content + cisco.aci.aci_rest: + host: '{{ aci_hostname }}' + username: '{{ aci_username }}' + password: '{{ aci_password }}' + validate_certs: '{{ aci_validate_certs | default(false) }}' + use_ssl: '{{ aci_use_ssl | default(true) }}' + use_proxy: '{{ aci_use_proxy | default(true) }}' + output_level: '{{ aci_output_level | default("info") }}' + path: /api/mo/uni.json + method: post + content: + { + "fvTenant": { + "attributes": { + "descr": "Ansible test tenant", + "name": "ansible_test", + "annotation": "test:incontent" + } + } + } + register: nm_add_tenant_annotation_content + +- name: Add tenant with annotation in content and option + cisco.aci.aci_rest: + host: '{{ aci_hostname }}' + username: '{{ aci_username }}' + password: '{{ aci_password }}' + validate_certs: '{{ aci_validate_certs | default(false) }}' + use_ssl: '{{ aci_use_ssl | default(true) }}' + use_proxy: '{{ aci_use_proxy | default(true) }}' + output_level: '{{ aci_output_level | default("info") }}' + path: /api/mo/uni.json + method: post + annotation: test:inoption + content: + { + "fvTenant": { + "attributes": { + "descr": "Ansible test tenant", + "name": "ansible_test", + "annotation": "test:optionincontent" + } + } + } + register: nm_add_tenant_annotation_option_content + +- name: Add tag to tenant with annotation unsupported + cisco.aci.aci_rest: + host: '{{ aci_hostname }}' + username: '{{ aci_username }}' + password: '{{ aci_password }}' + validate_certs: '{{ aci_validate_certs | default(false) }}' + use_ssl: '{{ aci_use_ssl | default(true) }}' + use_proxy: '{{ aci_use_proxy | default(true) }}' + output_level: '{{ aci_output_level | default("info") }}' + path: /api/mo/uni/tn-ansible_test/tagKey-foo.json + method: post + annotation: test:inoption + content: + { + "tagTag": { + "attributes": { + "value": "bar" + } + } + } + register: nm_add_tag_no_annotation + +- name: Remove tenant + cisco.aci.aci_rest: *tenant_absent + +- name: Add tenant with children objects including annotation + cisco.aci.aci_rest: + host: '{{ aci_hostname }}' + username: '{{ aci_username }}' + password: '{{ aci_password }}' + validate_certs: '{{ aci_validate_certs | default(false) }}' + use_ssl: '{{ aci_use_ssl | default(true) }}' + use_proxy: '{{ aci_use_proxy | default(true) }}' + output_level: '{{ aci_output_level | default("info") }}' + path: /api/mo/uni.json + method: post + annotation: test:inoption + content: + { + "fvTenant": { + "attributes": { + "descr": "Ansible test tenant", + "name": "ansible_test" + }, + "children": [ + { + "fvCtx": { + "attributes": { + "name": "VRF1" + } + } + }, + { + "fvAp": { + "attributes": { + "name": "Application1" + }, + "children": [ + { + "fvAEPg": { + "attributes": { + "name": "WebTier", + "annotation": "test:inchild" + } + } + } + ] + } + } + ] + } + } + register: nm_add_tenant_annotation_children + +- name: Verify annotation support + assert: + that: + - nm_add_tenant_annotation_option.imdata.0.fvTenant.attributes.annotation == "test:inoption" + - nm_add_tenant_annotation_content.imdata.0.fvTenant.attributes.annotation == "test:incontent" + - nm_add_tenant_annotation_option_content.imdata.0.fvTenant.attributes.annotation == "test:optionincontent" + - nm_add_tag_no_annotation.imdata.0.tagTag.attributes.annotation is undefined + - nm_add_tenant_annotation_children.imdata.0.fvTenant.attributes.annotation == "test:inoption" + - nm_add_tenant_annotation_children.imdata.0.fvTenant.children.0.fvAp.attributes.annotation == "test:inoption" + - nm_add_tenant_annotation_children.imdata.0.fvTenant.children.0.fvAp.children.0.fvAEPg.attributes.annotation == "test:inchild" + - nm_add_tenant_annotation_children.imdata.0.fvTenant.children.2.fvCtx.attributes.annotation == "test:inoption"
\ No newline at end of file diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_rest/tasks/json_string.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_rest/tasks/json_string.yml index 7a1dfd8ce..9efa19c71 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_rest/tasks/json_string.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_rest/tasks/json_string.yml @@ -55,10 +55,11 @@ register: cm_verify_checkmode_tenant - name: Verify checkmode POST operation - assert: + ansible.builtin.assert: that: - cm_add_tenant is changed - cm_add_tenant.proposed.fvTenant.attributes.name == "ansible_test" + - cm_add_tenant.proposed.fvTenant.attributes.annotation == "orchestrator:ansible" - cm_verify_checkmode_tenant.current == [] - name: Add tenant (normal mode) @@ -70,9 +71,10 @@ register: nm_add_tenant_again - name: Verify add_tenant - assert: + ansible.builtin.assert: that: - nm_add_tenant is changed + - nm_add_tenant.imdata.0.fvTenant.attributes.annotation == "orchestrator:ansible" - nm_add_tenant_again is not changed # CHANGE TENANT @@ -103,7 +105,7 @@ register: nm_add_tenant_descr_again - name: Verify add_tenant_descr - assert: + ansible.builtin.assert: that: - nm_add_tenant_descr is changed - nm_add_tenant_descr_again is not changed @@ -114,7 +116,7 @@ register: nm_add_tenant_again_no_descr - name: Verify add_tenant_again_no_descr - assert: + ansible.builtin.assert: that: - nm_add_tenant_again_no_descr is not changed @@ -133,7 +135,7 @@ register: nm_query_all_tenants - name: Verify query_all_tenants - assert: + ansible.builtin.assert: that: - nm_query_all_tenants is not changed @@ -152,7 +154,7 @@ register: nm_query_tenant - name: Verify query_tenant - assert: + ansible.builtin.assert: that: - nm_query_tenant is not changed @@ -166,7 +168,7 @@ register: nm_remove_tenant_again - name: Verify remove_tenant - assert: + ansible.builtin.assert: that: - nm_remove_tenant is changed - nm_remove_tenant_again is not changed @@ -177,6 +179,163 @@ register: nm_query_non_tenant - name: Verify query_non_tenant - assert: + ansible.builtin.assert: that: - nm_query_non_tenant is not changed + +# VERIFY ANNOTATION SUPPORT +- name: Add tenant with annotation option + cisco.aci.aci_rest: + host: '{{ aci_hostname }}' + username: '{{ aci_username }}' + password: '{{ aci_password }}' + validate_certs: '{{ aci_validate_certs | default(false) }}' + use_ssl: '{{ aci_use_ssl | default(true) }}' + use_proxy: '{{ aci_use_proxy | default(true) }}' + output_level: '{{ aci_output_level | default("info") }}' + path: /api/mo/uni.json + method: post + annotation: test:inoption + content: | + { + "fvTenant": { + "attributes": { + "descr": "Ansible test tenant", + "name": "ansible_test" + } + } + } + register: nm_add_tenant_annotation_option + +- name: Add tenant with annotation in content + cisco.aci.aci_rest: + host: '{{ aci_hostname }}' + username: '{{ aci_username }}' + password: '{{ aci_password }}' + validate_certs: '{{ aci_validate_certs | default(false) }}' + use_ssl: '{{ aci_use_ssl | default(true) }}' + use_proxy: '{{ aci_use_proxy | default(true) }}' + output_level: '{{ aci_output_level | default("info") }}' + path: /api/mo/uni.json + method: post + content: | + { + "fvTenant": { + "attributes": { + "descr": "Ansible test tenant", + "name": "ansible_test", + "annotation": "test:incontent" + } + } + } + register: nm_add_tenant_annotation_content + +- name: Add tenant with annotation in content and option + cisco.aci.aci_rest: + host: '{{ aci_hostname }}' + username: '{{ aci_username }}' + password: '{{ aci_password }}' + validate_certs: '{{ aci_validate_certs | default(false) }}' + use_ssl: '{{ aci_use_ssl | default(true) }}' + use_proxy: '{{ aci_use_proxy | default(true) }}' + output_level: '{{ aci_output_level | default("info") }}' + path: /api/mo/uni.json + method: post + annotation: test:inoption + content: | + { + "fvTenant": { + "attributes": { + "descr": "Ansible test tenant", + "name": "ansible_test", + "annotation": "test:optionincontent" + } + } + } + register: nm_add_tenant_annotation_option_content + +- name: Add tag to tenant with annotation unsupported + cisco.aci.aci_rest: + host: '{{ aci_hostname }}' + username: '{{ aci_username }}' + password: '{{ aci_password }}' + validate_certs: '{{ aci_validate_certs | default(false) }}' + use_ssl: '{{ aci_use_ssl | default(true) }}' + use_proxy: '{{ aci_use_proxy | default(true) }}' + output_level: '{{ aci_output_level | default("info") }}' + path: /api/mo/uni/tn-ansible_test/tagKey-foo.json + method: post + annotation: test:inoption + content: | + { + "tagTag": { + "attributes": { + "value": "bar" + } + } + } + register: nm_add_tag_no_annotation + +- name: Remove tenant + cisco.aci.aci_rest: *tenant_absent + +- name: Add tenant with children objects including annotation + cisco.aci.aci_rest: + host: '{{ aci_hostname }}' + username: '{{ aci_username }}' + password: '{{ aci_password }}' + validate_certs: '{{ aci_validate_certs | default(false) }}' + use_ssl: '{{ aci_use_ssl | default(true) }}' + use_proxy: '{{ aci_use_proxy | default(true) }}' + output_level: '{{ aci_output_level | default("info") }}' + path: /api/mo/uni.json + method: post + annotation: test:inoption + content: | + { + "fvTenant": { + "attributes": { + "descr": "Ansible test tenant", + "name": "ansible_test" + }, + "children": [ + { + "fvCtx": { + "attributes": { + "name": "VRF1" + } + } + }, + { + "fvAp": { + "attributes": { + "name": "Application1" + }, + "children": [ + { + "fvAEPg": { + "attributes": { + "name": "WebTier", + "annotation": "test:inchild" + } + } + } + ] + } + } + ] + } + } + register: nm_add_tenant_annotation_children + +- name: Verify annotation support + assert: + that: + - nm_add_tenant_annotation_option.imdata.0.fvTenant.attributes.annotation == "test:inoption" + - nm_add_tenant_annotation_content.imdata.0.fvTenant.attributes.annotation == "test:incontent" + - nm_add_tenant_annotation_option_content.imdata.0.fvTenant.attributes.annotation == "test:optionincontent" + - nm_add_tag_no_annotation.imdata.0.tagTag.attributes.annotation is undefined + - nm_add_tenant_annotation_children.imdata.0.fvTenant.attributes.annotation == "test:inoption" + - nm_add_tenant_annotation_children.imdata.0.fvTenant.children.0.fvAp.attributes.annotation == "test:inoption" + - nm_add_tenant_annotation_children.imdata.0.fvTenant.children.0.fvAp.children.0.fvAEPg.attributes.annotation == "test:inchild" + - nm_add_tenant_annotation_children.imdata.0.fvTenant.children.2.fvCtx.attributes.annotation == "test:inoption"
\ No newline at end of file diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_rest/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_rest/tasks/main.yml index c06f0cee2..c0055bbd3 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_rest/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_rest/tasks/main.yml @@ -5,7 +5,7 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_rest/tasks/xml_file.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_rest/tasks/xml_file.yml index fea63112b..6b3ffc841 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_rest/tasks/xml_file.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_rest/tasks/xml_file.yml @@ -5,7 +5,7 @@ # SET VARS - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: '{{ aci_hostname }}' username: '{{ aci_username }}' @@ -17,7 +17,7 @@ output_path: "/tmp/ansible_output_file.log" - name: Ensure tenant does not exists using ans_test_delete xml template - cisco.aci.aci_rest: + cisco.aci.aci_rest: &tenant_delete <<: *aci_info path: /api/mo/uni.xml src: "./targets/aci_rest/tasks/xml_files/tn-ans_test_delete.xml" @@ -46,10 +46,11 @@ register: cm_verify_checkmode_tenant - name: Assertions check for add tenant using ans_test_create xml template file with check mode - assert: + ansible.builtin.assert: that: - cm_add_tenant is changed - '"ans_test_create" in cm_add_tenant.proposed' + - '"orchestrator:ansible" in cm_add_tenant.proposed' - cm_verify_checkmode_tenant.current == [] - name: Add tenant using ans_test_create xml template file with normal mode @@ -61,12 +62,13 @@ register: nm_add_tenant - name: Assertions check for add tenant using ans_test_create xml template file with normal mode - assert: + ansible.builtin.assert: that: - nm_add_tenant is changed - nm_add_tenant.imdata.0.fvTenant.attributes.name == "ans_test_create" - nm_add_tenant.imdata.0.fvTenant.attributes.descr == "ans_test_create tenant created successfully" - nm_add_tenant.imdata.0.fvTenant.attributes.dn == "uni/tn-ans_test_create" + - nm_add_tenant.imdata.0.fvTenant.attributes.annotation == "orchestrator:ansible" - nm_add_tenant.imdata.0.fvTenant.children != [] - name: Add tenant using ans_test_create xml template file with normal mode - idempotency works @@ -78,7 +80,7 @@ register: idempotency_nm_add_tenant - name: Idempotency assertions check for add tenant using ans_test_create xml template file with normal mode - assert: + ansible.builtin.assert: that: - idempotency_nm_add_tenant is not changed @@ -90,7 +92,7 @@ register: query_ans_test_create - name: Assertions check for querying ans_test_create tenant using query string after the create - assert: + ansible.builtin.assert: that: - query_ans_test_create is not changed - query_ans_test_create.imdata != [] @@ -108,7 +110,7 @@ register: cm_update_tenant - name: Assertions check for update tenant description using ans_test_update xml template file with check mode - assert: + ansible.builtin.assert: that: - cm_update_tenant is changed @@ -121,7 +123,7 @@ register: nm_update_tenant - name: Assertions check for update tenant description using ans_test_update xml template file with normal mode - assert: + ansible.builtin.assert: that: - nm_update_tenant is changed - nm_update_tenant.imdata.0.fvTenant.attributes.name == "ans_test_create" @@ -137,7 +139,7 @@ register: idempotency_nm_update_tenant - name: Idempotency assertions check for update tenant description using ans_test_update xml template file with normal mode - assert: + ansible.builtin.assert: that: - idempotency_nm_update_tenant is not changed @@ -149,7 +151,7 @@ register: query_ans_test_update - name: Assertions check for querying ans_test_create tenant using query string after the update - assert: + ansible.builtin.assert: that: - query_ans_test_update is not changed - query_ans_test_update.imdata != [] @@ -167,7 +169,7 @@ ignore_errors: true - name: Assertions check for update tenant name using ans_test_negative_update_check xml template file with normal mode - assert: + ansible.builtin.assert: that: - negative_update_tenant_check is failed @@ -181,7 +183,7 @@ register: cm_delete_tenant - name: Assertions check for delete tenant using ans_test_delete xml template file with check mode - assert: + ansible.builtin.assert: that: - cm_delete_tenant is changed @@ -194,7 +196,7 @@ register: nm_delete_tenant - name: Assertions check for delete tenant using ans_test_delete xml template file with normal mode - assert: + ansible.builtin.assert: that: - nm_delete_tenant is changed - nm_delete_tenant.imdata.0.fvTenant.attributes.name == "ans_test_create" @@ -210,7 +212,7 @@ register: idempotency_nm_delete_tenant - name: Idempotency assertions check for delete tenant using ans_test_delete xml template file with normal mode - assert: + ansible.builtin.assert: that: - idempotency_nm_delete_tenant is not changed - idempotency_nm_delete_tenant.imdata == {} @@ -223,7 +225,100 @@ register: query_ans_test_delete - name: Assertions check for querying ans_test_create tenant using query string after the delete - assert: + ansible.builtin.assert: that: - query_ans_test_delete is not changed - query_ans_test_delete.imdata == [] + +# VERIFY ANNOTATION SUPPORT +- name: Add tenant with annotation option + cisco.aci.aci_rest: + host: '{{ aci_hostname }}' + username: '{{ aci_username }}' + password: '{{ aci_password }}' + validate_certs: '{{ aci_validate_certs | default(false) }}' + use_ssl: '{{ aci_use_ssl | default(true) }}' + use_proxy: '{{ aci_use_proxy | default(true) }}' + output_level: '{{ aci_output_level | default("info") }}' + path: /api/mo/uni.xml + method: post + annotation: test:inoption + src: "./targets/aci_rest/tasks/xml_files/tn-ans_test_create.xml" + register: nm_add_tenant_annotation_option + +- name: Add tenant with annotation in content + cisco.aci.aci_rest: + host: '{{ aci_hostname }}' + username: '{{ aci_username }}' + password: '{{ aci_password }}' + validate_certs: '{{ aci_validate_certs | default(false) }}' + use_ssl: '{{ aci_use_ssl | default(true) }}' + use_proxy: '{{ aci_use_proxy | default(true) }}' + output_level: '{{ aci_output_level | default("info") }}' + path: /api/mo/uni.xml + method: post + src: "./targets/aci_rest/tasks/xml_files/tn-ans_test_annotation.xml" + register: nm_add_tenant_annotation_content + +- name: Remove tenant + cisco.aci.aci_rest: *tenant_delete + +- name: Add tenant with annotation in content and option + cisco.aci.aci_rest: + host: '{{ aci_hostname }}' + username: '{{ aci_username }}' + password: '{{ aci_password }}' + validate_certs: '{{ aci_validate_certs | default(false) }}' + use_ssl: '{{ aci_use_ssl | default(true) }}' + use_proxy: '{{ aci_use_proxy | default(true) }}' + output_level: '{{ aci_output_level | default("info") }}' + path: /api/mo/uni.xml + method: post + annotation: test:inoption + src: "./targets/aci_rest/tasks/xml_files/tn-ans_test_annotation.xml" + register: nm_add_tenant_annotation_option_content + +- name: Add tag to tenant with annotation unsupported + cisco.aci.aci_rest: + host: '{{ aci_hostname }}' + username: '{{ aci_username }}' + password: '{{ aci_password }}' + validate_certs: '{{ aci_validate_certs | default(false) }}' + use_ssl: '{{ aci_use_ssl | default(true) }}' + use_proxy: '{{ aci_use_proxy | default(true) }}' + output_level: '{{ aci_output_level | default("info") }}' + path: /api/mo/uni/tn-ans_test_create/tagKey-foo.xml + method: post + annotation: test:inoption + src: "./targets/aci_rest/tasks/xml_files/tag.xml" + register: nm_add_tag_no_annotation + +- name: Remove tenant + cisco.aci.aci_rest: *tenant_delete + +- name: Add tenant with children objects including annotation + cisco.aci.aci_rest: + host: '{{ aci_hostname }}' + username: '{{ aci_username }}' + password: '{{ aci_password }}' + validate_certs: '{{ aci_validate_certs | default(false) }}' + use_ssl: '{{ aci_use_ssl | default(true) }}' + use_proxy: '{{ aci_use_proxy | default(true) }}' + output_level: '{{ aci_output_level | default("info") }}' + path: /api/mo/uni.xml + method: post + annotation: test:inoption + src: "./targets/aci_rest/tasks/xml_files/tn-ans_test_annotation_children.xml" + register: nm_add_tenant_annotation_children + +- name: Verify annotation support + assert: + that: + - nm_add_tenant_annotation_option.imdata.0.fvTenant.attributes.annotation == "test:inoption" + - nm_add_tenant_annotation_content.imdata.0.fvTenant.attributes.annotation == "test:optionincontent" + - nm_add_tenant_annotation_option_content.imdata.0.fvTenant.attributes.annotation == "test:optionincontent" + - nm_add_tag_no_annotation.imdata.0.tagTag.attributes.annotation is undefined + - nm_add_tenant_annotation_children.imdata.0.fvTenant.attributes.annotation == "test:inoption" + - nm_add_tenant_annotation_children.imdata.0.fvTenant.children.0.fvAp.attributes.annotation == "test:inoption" + - nm_add_tenant_annotation_children.imdata.0.fvTenant.children.0.fvAp.children.0.fvAEPg.attributes.annotation == "test:inchild" + - nm_add_tenant_annotation_children.imdata.0.fvTenant.children.1.fvCtx.attributes.annotation == "test:inoption"
\ No newline at end of file diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_rest/tasks/xml_files/tag.xml b/ansible_collections/cisco/aci/tests/integration/targets/aci_rest/tasks/xml_files/tag.xml new file mode 100644 index 000000000..f5918f0e3 --- /dev/null +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_rest/tasks/xml_files/tag.xml @@ -0,0 +1 @@ +<tagTag value="bar"/>
\ No newline at end of file diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_rest/tasks/xml_files/tn-ans_test_annotation.xml b/ansible_collections/cisco/aci/tests/integration/targets/aci_rest/tasks/xml_files/tn-ans_test_annotation.xml new file mode 100644 index 000000000..281e6e282 --- /dev/null +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_rest/tasks/xml_files/tn-ans_test_annotation.xml @@ -0,0 +1 @@ +<fvTenant descr="ans_test_create tenant created successfully" dn="uni/tn-ans_test_create" name="ans_test_create" status="" annotation="test:optionincontent"/>
\ No newline at end of file diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_rest/tasks/xml_files/tn-ans_test_annotation_children.xml b/ansible_collections/cisco/aci/tests/integration/targets/aci_rest/tasks/xml_files/tn-ans_test_annotation_children.xml new file mode 100644 index 000000000..448998bf6 --- /dev/null +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_rest/tasks/xml_files/tn-ans_test_annotation_children.xml @@ -0,0 +1,6 @@ +<fvTenant name="ans_test_create" descr="Ansible test tenant xml"> + <fvCtx name="VRF1"/> + <fvAp name="Application1"> + <fvAEPg name="WebTier" annotation="test:inchild"/> + </fvAp> +</fvTenant>
\ No newline at end of file diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_rest/tasks/xml_string.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_rest/tasks/xml_string.yml index d1424bafa..e3e627e3e 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_rest/tasks/xml_string.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_rest/tasks/xml_string.yml @@ -70,12 +70,14 @@ register: cm_verify_checkmode_tenant - name: Verify checkmode POST operation - assert: + ansible.builtin.assert: that: - cm_add_tenant is changed - '"ansible_test" in cm_add_tenant.proposed' + - '"orchestrator:ansible" in cm_add_tenant.proposed' - cm_add_tenant_2 is changed - - '"ansible_test" in cm_add_tenant.proposed' + - '"ansible_test" in cm_add_tenant_2.proposed' + - '"orchestrator:ansible" in cm_add_tenant_2.proposed' - cm_verify_checkmode_tenant.current == [] - name: Add tenant (normal mode) @@ -108,7 +110,7 @@ register: nm_add_tenant_again - name: Verify add_tenant - assert: + ansible.builtin.assert: that: - nm_add_tenant is changed - nm_add_tenant_again is not changed @@ -144,7 +146,7 @@ register: nm_add_tenant_descr_again - name: Verify add_tenant_descr - assert: + ansible.builtin.assert: that: - nm_add_tenant_descr is changed - nm_add_tenant_descr_again is not changed @@ -159,7 +161,7 @@ register: nm_add_tenant_again_no_descr - name: Verify add_tenant_again_no_descr - assert: + ansible.builtin.assert: that: - nm_add_tenant_again_no_descr is not changed @@ -178,7 +180,7 @@ register: nm_query_all_tenants - name: Verify query_all_tenants - assert: + ansible.builtin.assert: that: - nm_query_all_tenants is not changed @@ -197,7 +199,7 @@ register: nm_query_tenant - name: Verify query_tenant - assert: + ansible.builtin.assert: that: - nm_query_tenant is not changed @@ -211,7 +213,7 @@ register: nm_remove_tenant_again - name: Verify remove_tenant - assert: + ansible.builtin.assert: that: - nm_remove_tenant is changed - nm_remove_tenant_again is not changed @@ -222,6 +224,123 @@ register: nm_query_non_tenant - name: Verify query_non_tenant - assert: + ansible.builtin.assert: that: - nm_query_non_tenant is not changed + +# VERIFY ANNOTATION +- name: Add tenant with annotation (normal mode) + cisco.aci.aci_rest: &tenant_annotation + host: '{{ aci_hostname }}' + username: '{{ aci_username }}' + password: '{{ aci_password }}' + validate_certs: '{{ aci_validate_certs | default(false) }}' + use_ssl: '{{ aci_use_ssl | default(true) }}' + use_proxy: '{{ aci_use_proxy | default(true) }}' + output_level: '{{ aci_output_level | default("info") }}' + path: /api/mo/uni.xml + method: post + annotation: test:label + content: + <fvTenant name="ansible_test_annotation"/> + register: nm_add_tenant_annotation + +# VERIFY ANNOTATION SUPPORT +- name: Add tenant with annotation option + cisco.aci.aci_rest: + host: '{{ aci_hostname }}' + username: '{{ aci_username }}' + password: '{{ aci_password }}' + validate_certs: '{{ aci_validate_certs | default(false) }}' + use_ssl: '{{ aci_use_ssl | default(true) }}' + use_proxy: '{{ aci_use_proxy | default(true) }}' + output_level: '{{ aci_output_level | default("info") }}' + path: /api/mo/uni.xml + method: post + annotation: test:inoption + content: + <fvTenant name="ansible_test" descr="Ansible test tenant"/> + register: nm_add_tenant_annotation_option + +- name: Add tenant with annotation in content + cisco.aci.aci_rest: + host: '{{ aci_hostname }}' + username: '{{ aci_username }}' + password: '{{ aci_password }}' + validate_certs: '{{ aci_validate_certs | default(false) }}' + use_ssl: '{{ aci_use_ssl | default(true) }}' + use_proxy: '{{ aci_use_proxy | default(true) }}' + output_level: '{{ aci_output_level | default("info") }}' + path: /api/mo/uni.xml + method: post + content: + <fvTenant name="ansible_test" descr="Ansible test tenant" annotation="test:incontent"/> + register: nm_add_tenant_annotation_content + +- name: Add tenant with annotation in content and option + cisco.aci.aci_rest: + host: '{{ aci_hostname }}' + username: '{{ aci_username }}' + password: '{{ aci_password }}' + validate_certs: '{{ aci_validate_certs | default(false) }}' + use_ssl: '{{ aci_use_ssl | default(true) }}' + use_proxy: '{{ aci_use_proxy | default(true) }}' + output_level: '{{ aci_output_level | default("info") }}' + path: /api/mo/uni.xml + method: post + annotation: test:inoption + content: + <fvTenant name="ansible_test" descr="Ansible test tenant" annotation="test:optionincontent"/> + register: nm_add_tenant_annotation_option_content + +- name: Add tag to tenant with annotation unsupported + cisco.aci.aci_rest: + host: '{{ aci_hostname }}' + username: '{{ aci_username }}' + password: '{{ aci_password }}' + validate_certs: '{{ aci_validate_certs | default(false) }}' + use_ssl: '{{ aci_use_ssl | default(true) }}' + use_proxy: '{{ aci_use_proxy | default(true) }}' + output_level: '{{ aci_output_level | default("info") }}' + path: /api/mo/uni/tn-ansible_test/tagKey-foo.xml + method: post + annotation: test:inoption + content: + <tagTag value="bar"/> + register: nm_add_tag_no_annotation + +- name: Remove tenant + cisco.aci.aci_rest: *tenant_absent + +- name: Add tenant with children objects including annotation + cisco.aci.aci_rest: + host: '{{ aci_hostname }}' + username: '{{ aci_username }}' + password: '{{ aci_password }}' + validate_certs: '{{ aci_validate_certs | default(false) }}' + use_ssl: '{{ aci_use_ssl | default(true) }}' + use_proxy: '{{ aci_use_proxy | default(true) }}' + output_level: '{{ aci_output_level | default("info") }}' + path: /api/mo/uni.xml + method: post + annotation: test:inoption + content: + <fvTenant name="ansible_test" descr="Ansible test tenant"> + <fvCtx name="VRF1"/> + <fvAp name="Application1"> + <fvAEPg name="WebTier" annotation="test:inchild"/> + </fvAp> + </fvTenant> + register: nm_add_tenant_annotation_children + +- name: Verify annotation support + assert: + that: + - nm_add_tenant_annotation_option.imdata.0.fvTenant.attributes.annotation == "test:inoption" + - nm_add_tenant_annotation_content.imdata.0.fvTenant.attributes.annotation == "test:incontent" + - nm_add_tenant_annotation_option_content.imdata.0.fvTenant.attributes.annotation == "test:optionincontent" + - nm_add_tag_no_annotation.imdata.0.tagTag.attributes.annotation is undefined + - nm_add_tenant_annotation_children.imdata.0.fvTenant.attributes.annotation == "test:inoption" + - nm_add_tenant_annotation_children.imdata.0.fvTenant.children.0.fvAp.attributes.annotation == "test:inoption" + - nm_add_tenant_annotation_children.imdata.0.fvTenant.children.0.fvAp.children.0.fvAEPg.attributes.annotation == "test:inchild" + - nm_add_tenant_annotation_children.imdata.0.fvTenant.children.1.fvCtx.attributes.annotation == "test:inoption"
\ No newline at end of file diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_rest/tasks/yaml_inline.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_rest/tasks/yaml_inline.yml index 6cd06afcd..3d0ca07d8 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_rest/tasks/yaml_inline.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_rest/tasks/yaml_inline.yml @@ -50,10 +50,11 @@ register: cm_verify_checkmode_tenant - name: Verify checkmode POST operation - assert: + ansible.builtin.assert: that: - cm_add_tenant is changed - cm_add_tenant.proposed.fvTenant.attributes.name == "ansible_test" + - cm_add_tenant.proposed.fvTenant.attributes.annotation == "orchestrator:ansible" - cm_verify_checkmode_tenant.current == [] - name: Add tenant (normal mode) @@ -65,7 +66,7 @@ register: nm_add_tenant_again - name: Verify add_tenant - assert: + ansible.builtin.assert: that: - nm_add_tenant is changed - nm_add_tenant_again is not changed @@ -94,9 +95,10 @@ register: nm_add_tenant_descr_again - name: Verify add_tenant_descr - assert: + ansible.builtin.assert: that: - nm_add_tenant_descr is changed + - nm_add_tenant.imdata.0.fvTenant.attributes.annotation == "orchestrator:ansible" - nm_add_tenant_descr_again is not changed # ADD TENANT AGAIN @@ -105,7 +107,7 @@ register: nm_add_tenant_again_no_descr - name: Verify add_tenant_again_no_descr - assert: + ansible.builtin.assert: that: - nm_add_tenant_again_no_descr is not changed @@ -124,7 +126,7 @@ register: nm_query_all_tenants - name: Verify query_all_tenants - assert: + ansible.builtin.assert: that: - nm_query_all_tenants is not changed @@ -143,7 +145,7 @@ register: nm_query_tenant - name: Verify query_tenant - assert: + ansible.builtin.assert: that: - nm_query_tenant is not changed @@ -157,7 +159,7 @@ register: nm_remove_tenant_again - name: Verify remove_tenant - assert: + ansible.builtin.assert: that: - nm_remove_tenant is changed - nm_remove_tenant_again is not changed @@ -168,6 +170,129 @@ register: nm_query_non_tenant - name: Verify query_non_tenant - assert: + ansible.builtin.assert: that: - nm_query_non_tenant is not changed + +# VERIFY ANNOTATION SUPPORT +- name: Add tenant with annotation option + cisco.aci.aci_rest: + host: '{{ aci_hostname }}' + username: '{{ aci_username }}' + password: '{{ aci_password }}' + validate_certs: '{{ aci_validate_certs | default(false) }}' + use_ssl: '{{ aci_use_ssl | default(true) }}' + use_proxy: '{{ aci_use_proxy | default(true) }}' + output_level: '{{ aci_output_level | default("info") }}' + path: /api/mo/uni.json + method: post + annotation: test:inoption + content: + fvTenant: + attributes: + descr: Ansible test tenant + name: ansible_test + register: nm_add_tenant_annotation_option + +- name: Add tenant with annotation in content + cisco.aci.aci_rest: + host: '{{ aci_hostname }}' + username: '{{ aci_username }}' + password: '{{ aci_password }}' + validate_certs: '{{ aci_validate_certs | default(false) }}' + use_ssl: '{{ aci_use_ssl | default(true) }}' + use_proxy: '{{ aci_use_proxy | default(true) }}' + output_level: '{{ aci_output_level | default("info") }}' + path: /api/mo/uni.json + method: post + content: + fvTenant: + attributes: + descr: Ansible test tenant + name: ansible_test + annotation: test:incontent + register: nm_add_tenant_annotation_content + +- name: Add tenant with annotation in content and option + cisco.aci.aci_rest: + host: '{{ aci_hostname }}' + username: '{{ aci_username }}' + password: '{{ aci_password }}' + validate_certs: '{{ aci_validate_certs | default(false) }}' + use_ssl: '{{ aci_use_ssl | default(true) }}' + use_proxy: '{{ aci_use_proxy | default(true) }}' + output_level: '{{ aci_output_level | default("info") }}' + path: /api/mo/uni.json + method: post + annotation: test:inoption + content: + fvTenant: + attributes: + descr: Ansible test tenant + name: ansible_test + annotation: test:optionincontent + register: nm_add_tenant_annotation_option_content + +- name: Add tag to tenant with annotation unsupported + cisco.aci.aci_rest: + host: '{{ aci_hostname }}' + username: '{{ aci_username }}' + password: '{{ aci_password }}' + validate_certs: '{{ aci_validate_certs | default(false) }}' + use_ssl: '{{ aci_use_ssl | default(true) }}' + use_proxy: '{{ aci_use_proxy | default(true) }}' + output_level: '{{ aci_output_level | default("info") }}' + path: /api/mo/uni/tn-ansible_test/tagKey-foo.json + method: post + annotation: test:inoption + content: + tagTag: + attributes: + value: bar + register: nm_add_tag_no_annotation + +- name: Remove tenant + cisco.aci.aci_rest: *tenant_absent + +- name: Add tenant with children objects including annotation + cisco.aci.aci_rest: + host: '{{ aci_hostname }}' + username: '{{ aci_username }}' + password: '{{ aci_password }}' + validate_certs: '{{ aci_validate_certs | default(false) }}' + use_ssl: '{{ aci_use_ssl | default(true) }}' + use_proxy: '{{ aci_use_proxy | default(true) }}' + output_level: '{{ aci_output_level | default("info") }}' + path: /api/mo/uni.json + method: post + annotation: test:inoption + content: + fvTenant: + attributes: + descr: Ansible test tenant + name: ansible_test + children: + - fvCtx: + attributes: + name: VRF1 + - fvAp: + attributes: + name: Application1 + children: + - fvAEPg: + attributes: + name: WebTier + annotation: test:inchild + register: nm_add_tenant_annotation_children + +- name: Verify annotation support + assert: + that: + - nm_add_tenant_annotation_option.imdata.0.fvTenant.attributes.annotation == "test:inoption" + - nm_add_tenant_annotation_content.imdata.0.fvTenant.attributes.annotation == "test:incontent" + - nm_add_tenant_annotation_option_content.imdata.0.fvTenant.attributes.annotation == "test:optionincontent" + - nm_add_tag_no_annotation.imdata.0.tagTag.attributes.annotation is undefined + - nm_add_tenant_annotation_children.imdata.0.fvTenant.attributes.annotation == "test:inoption" + - nm_add_tenant_annotation_children.imdata.0.fvTenant.children.0.fvAp.attributes.annotation == "test:inoption" + - nm_add_tenant_annotation_children.imdata.0.fvTenant.children.0.fvAp.children.0.fvAEPg.attributes.annotation == "test:inchild" + - nm_add_tenant_annotation_children.imdata.0.fvTenant.children.2.fvCtx.attributes.annotation == "test:inoption" diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_rest/tasks/yaml_string.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_rest/tasks/yaml_string.yml index 895045474..982235c9a 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_rest/tasks/yaml_string.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_rest/tasks/yaml_string.yml @@ -50,10 +50,11 @@ register: cm_verify_checkmode_tenant - name: Verify checkmode POST operation - assert: + ansible.builtin.assert: that: - cm_add_tenant is changed - cm_add_tenant.proposed.fvTenant.attributes.name == "ansible_test" + - cm_add_tenant.proposed.fvTenant.attributes.annotation == "orchestrator:ansible" - cm_verify_checkmode_tenant.current == [] - name: Add tenant (normal mode) @@ -65,9 +66,10 @@ register: nm_add_tenant_again - name: Verify add_tenant - assert: + ansible.builtin.assert: that: - nm_add_tenant is changed + - nm_add_tenant.imdata.0.fvTenant.attributes.annotation == "orchestrator:ansible" - nm_add_tenant_again is not changed # CHANGE TENANT @@ -94,7 +96,7 @@ register: nm_add_tenant_descr_again - name: Verify add_tenant_descr - assert: + ansible.builtin.assert: that: - nm_add_tenant_descr is changed - nm_add_tenant_descr_again is not changed @@ -105,7 +107,7 @@ register: nm_add_tenant_again_no_descr - name: Verify add_tenant_again_no_descr - assert: + ansible.builtin.assert: that: - nm_add_tenant_again_no_descr is not changed @@ -124,7 +126,7 @@ register: nm_query_all_tenants - name: Verify query_all_tenants - assert: + ansible.builtin.assert: that: - nm_query_all_tenants is not changed @@ -143,7 +145,7 @@ register: nm_query_tenant - name: Verify query_tenant - assert: + ansible.builtin.assert: that: - nm_query_tenant is not changed @@ -157,7 +159,7 @@ register: nm_remove_tenant_again - name: Verify remove_tenant - assert: + ansible.builtin.assert: that: - nm_remove_tenant is changed - nm_remove_tenant_again is not changed @@ -168,6 +170,129 @@ register: nm_query_non_tenant - name: Verify query_non_tenant - assert: + ansible.builtin.assert: that: - nm_query_non_tenant is not changed + +# VERIFY ANNOTATION SUPPORT +- name: Add tenant with annotation option + cisco.aci.aci_rest: + host: '{{ aci_hostname }}' + username: '{{ aci_username }}' + password: '{{ aci_password }}' + validate_certs: '{{ aci_validate_certs | default(false) }}' + use_ssl: '{{ aci_use_ssl | default(true) }}' + use_proxy: '{{ aci_use_proxy | default(true) }}' + output_level: '{{ aci_output_level | default("info") }}' + path: /api/mo/uni.json + method: post + annotation: test:inoption + content: | + fvTenant: + attributes: + descr: Ansible test tenant + name: ansible_test + register: nm_add_tenant_annotation_option + +- name: Add tenant with annotation in content + cisco.aci.aci_rest: + host: '{{ aci_hostname }}' + username: '{{ aci_username }}' + password: '{{ aci_password }}' + validate_certs: '{{ aci_validate_certs | default(false) }}' + use_ssl: '{{ aci_use_ssl | default(true) }}' + use_proxy: '{{ aci_use_proxy | default(true) }}' + output_level: '{{ aci_output_level | default("info") }}' + path: /api/mo/uni.json + method: post + content: | + fvTenant: + attributes: + descr: Ansible test tenant + name: ansible_test + annotation: test:incontent + register: nm_add_tenant_annotation_content + +- name: Add tenant with annotation in content and option + cisco.aci.aci_rest: + host: '{{ aci_hostname }}' + username: '{{ aci_username }}' + password: '{{ aci_password }}' + validate_certs: '{{ aci_validate_certs | default(false) }}' + use_ssl: '{{ aci_use_ssl | default(true) }}' + use_proxy: '{{ aci_use_proxy | default(true) }}' + output_level: '{{ aci_output_level | default("info") }}' + path: /api/mo/uni.json + method: post + annotation: test:inoption + content: | + fvTenant: + attributes: + descr: Ansible test tenant + name: ansible_test + annotation: test:optionincontent + register: nm_add_tenant_annotation_option_content + +- name: Add tag to tenant with annotation unsupported + cisco.aci.aci_rest: + host: '{{ aci_hostname }}' + username: '{{ aci_username }}' + password: '{{ aci_password }}' + validate_certs: '{{ aci_validate_certs | default(false) }}' + use_ssl: '{{ aci_use_ssl | default(true) }}' + use_proxy: '{{ aci_use_proxy | default(true) }}' + output_level: '{{ aci_output_level | default("info") }}' + path: /api/mo/uni/tn-ansible_test/tagKey-foo.json + method: post + annotation: test:inoption + content: | + tagTag: + attributes: + value: bar + register: nm_add_tag_no_annotation + +- name: Remove tenant + cisco.aci.aci_rest: *tenant_absent + +- name: Add tenant with children objects including annotation + cisco.aci.aci_rest: + host: '{{ aci_hostname }}' + username: '{{ aci_username }}' + password: '{{ aci_password }}' + validate_certs: '{{ aci_validate_certs | default(false) }}' + use_ssl: '{{ aci_use_ssl | default(true) }}' + use_proxy: '{{ aci_use_proxy | default(true) }}' + output_level: '{{ aci_output_level | default("info") }}' + path: /api/mo/uni.json + method: post + annotation: test:inoption + content: | + fvTenant: + attributes: + descr: Ansible test tenant + name: ansible_test + children: + - fvCtx: + attributes: + name: VRF1 + - fvAp: + attributes: + name: Application1 + children: + - fvAEPg: + attributes: + name: WebTier + annotation: test:inchild + register: nm_add_tenant_annotation_children + +- name: Verify annotation support + assert: + that: + - nm_add_tenant_annotation_option.imdata.0.fvTenant.attributes.annotation == "test:inoption" + - nm_add_tenant_annotation_content.imdata.0.fvTenant.attributes.annotation == "test:incontent" + - nm_add_tenant_annotation_option_content.imdata.0.fvTenant.attributes.annotation == "test:optionincontent" + - nm_add_tag_no_annotation.imdata.0.tagTag.attributes.annotation is undefined + - nm_add_tenant_annotation_children.imdata.0.fvTenant.attributes.annotation == "test:inoption" + - nm_add_tenant_annotation_children.imdata.0.fvTenant.children.0.fvAp.attributes.annotation == "test:inoption" + - nm_add_tenant_annotation_children.imdata.0.fvTenant.children.0.fvAp.children.0.fvAEPg.attributes.annotation == "test:inchild" + - nm_add_tenant_annotation_children.imdata.0.fvTenant.children.2.fvCtx.attributes.annotation == "test:inoption"
\ No newline at end of file diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_route_control_context/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_route_control_context/tasks/main.yml index 83f46e4b8..31eef79a6 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_route_control_context/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_route_control_context/tasks/main.yml @@ -5,12 +5,12 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: "{{ aci_hostname }}" username: "{{ aci_username }}" @@ -22,26 +22,26 @@ # CLEAN ENVIRONMENT - name: Remove the ansible_tenant - aci_tenant: &aci_tenant_absent + cisco.aci.aci_tenant: &aci_tenant_absent <<: *aci_info tenant: ansible_tenant state: absent - name: Verify Cloud and Non-Cloud Sites in use. - include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml - name: Execute tasks only for non-cloud sites when: query_cloud.current == [] # This condition will execute only non-cloud sites block: # block specifies execution of tasks within, based on conditions - name: Add a new tenant - aci_tenant: &aci_tenant_present + cisco.aci.aci_tenant: &aci_tenant_present <<: *aci_info tenant: ansible_tenant description: Ansible tenant state: present - name: Add a new action rule profile - aci_tenant_action_rule_profile: &aci_action_rule_present + cisco.aci.aci_tenant_action_rule_profile: &aci_action_rule_present <<: *aci_info tenant: ansible_tenant action_rule: ansible_action_rule @@ -49,7 +49,7 @@ state: present - name: Add a new L3Out - aci_l3out: + cisco.aci.aci_l3out: <<: *aci_info tenant: ansible_tenant l3out: ansible_l3out @@ -59,7 +59,7 @@ state: present - name: Add a route control profile for l3out - aci_route_control_profile: + cisco.aci.aci_route_control_profile: <<: *aci_info tenant: ansible_tenant l3out: ansible_l3out @@ -68,7 +68,7 @@ state: present - name: Add a subject profile - aci_match_rule: &aci_match_rule_present + cisco.aci.aci_match_rule: &aci_match_rule_present <<: *aci_info tenant: ansible_tenant match_rule: ansible_match_rule @@ -76,7 +76,7 @@ state: present - name: Add a route control context policy for l3out (check_mode) - aci_route_control_context: &aci_route_control_context_present + cisco.aci.aci_route_control_context: &aci_route_control_context_present <<: *aci_info tenant: ansible_tenant l3out: ansible_l3out @@ -92,17 +92,17 @@ register: cm_add_route_control_context_l3out - name: Add a route control context policy again (normal_mode) - aci_route_control_context: + cisco.aci.aci_route_control_context: <<: *aci_route_control_context_present register: nm_add_route_control_context_l3out - name: Add a route control context policy again - testing idempotency - aci_route_control_context: + cisco.aci.aci_route_control_context: <<: *aci_route_control_context_present register: nm_add_route_control_context_l3out_idempotency - name: Add a route control profile for tenant - aci_route_control_profile: + cisco.aci.aci_route_control_profile: <<: *aci_info tenant: ansible_tenant route_control_profile: ansible_rtctrl_profile_tenant @@ -110,7 +110,7 @@ state: present - name: Add a route control context policy for tenant - aci_route_control_context: + cisco.aci.aci_route_control_context: <<: *aci_info tenant: ansible_tenant route_control_profile: ansible_rtctrl_profile_tenant @@ -120,7 +120,7 @@ register: nm_add_route_control_context_tenant - name: Asserts for route control profiles creation tasks - assert: + ansible.builtin.assert: that: - cm_add_route_control_context_l3out is changed - cm_add_route_control_context_l3out.previous == [] @@ -139,20 +139,20 @@ - nm_add_route_control_context_tenant.current.0.rtctrlCtxP.attributes.order == "0" - name: Query all route control context policies - aci_route_control_context: + cisco.aci.aci_route_control_context: <<: *aci_info state: query register: query_all_route_control_context - name: Query ansible_route_control_context_l3out route control context policy - aci_route_control_context: + cisco.aci.aci_route_control_context: <<: *aci_info route_control_context: ansible_route_control_context_l3out state: query register: query_route_control_context_l3out - name: Asserts query tasks - assert: + ansible.builtin.assert: that: - query_all_route_control_context is not changed - query_all_route_control_context.current|length >= 2 @@ -164,24 +164,24 @@ - query_route_control_context_l3out.current.0.rtctrlCtxP.children.1.rtctrlRsCtxPToSubjP.attributes.tDn == "uni/tn-ansible_tenant/subj-ansible_match_rule" - name: Remove route control context policy for l3out (check_mode) - aci_route_control_context: &aci_route_control_context_absent + cisco.aci.aci_route_control_context: &aci_route_control_context_absent <<: *aci_route_control_context_present state: absent check_mode: true register: cm_remove_route_control_context - name: Remove route control context policy for l3out (normal_mode) - aci_route_control_context: + cisco.aci.aci_route_control_context: <<: *aci_route_control_context_absent register: nm_remove_remove_route_control_context - name: Remove route control profile for l3out again - testing previous Removal - aci_route_control_context: + cisco.aci.aci_route_control_context: <<: *aci_route_control_context_absent register: nm_remove_route_control_context_idempotency - name: Asserts deletion tasks - assert: + ansible.builtin.assert: that: - cm_remove_route_control_context is changed - cm_remove_route_control_context.proposed == {} @@ -192,6 +192,6 @@ - nm_remove_route_control_context_idempotency.previous == [] - name: Remove the ansible_tenant - cleanup before ending tests - aci_tenant: + cisco.aci.aci_tenant: <<: *aci_tenant_present state: absent diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_route_control_profile/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_route_control_profile/tasks/main.yml index db0022100..d0c044472 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_route_control_profile/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_route_control_profile/tasks/main.yml @@ -5,12 +5,12 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: "{{ aci_hostname }}" username: "{{ aci_username }}" @@ -22,26 +22,26 @@ # CLEAN ENVIRONMENT - name: Remove the ansible_tenant - aci_tenant: &aci_tenant_absent + cisco.aci.aci_tenant: &aci_tenant_absent <<: *aci_info tenant: ansible_tenant state: absent - name: Verify Cloud and Non-Cloud Sites in use. - include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml - name: Execute tasks only for non-cloud sites when: query_cloud.current == [] # This condition will execute only non-cloud sites block: # block specifies execution of tasks within, based on conditions - name: Add a new tenant - aci_tenant: &aci_tenant_present + cisco.aci.aci_tenant: &aci_tenant_present <<: *aci_info tenant: ansible_tenant description: Ansible tenant state: present - name: Add a new L3Out - aci_l3out: + cisco.aci.aci_l3out: <<: *aci_info tenant: ansible_tenant l3out: ansible_l3out @@ -51,7 +51,7 @@ state: present - name: Add route control profile for l3out (check_mode) - aci_route_control_profile: &aci_route_control_profile_present + cisco.aci.aci_route_control_profile: &aci_route_control_profile_present <<: *aci_info tenant: ansible_tenant l3out: ansible_l3out @@ -64,17 +64,17 @@ register: cm_add_route_control_profile - name: Add route control profile for l3out (normal_mode) - aci_route_control_profile: + cisco.aci.aci_route_control_profile: <<: *aci_route_control_profile_present register: nm_add_route_control_profile - name: Add route control profile for l3out again - testing idempotency - aci_route_control_profile: + cisco.aci.aci_route_control_profile: <<: *aci_route_control_profile_present register: nm_add_route_control_profile_idempotency - name: Add route control profile for tenant (normal_mode) - aci_route_control_profile: + cisco.aci.aci_route_control_profile: <<: *aci_info tenant: ansible_tenant route_control_profile: ansible_rtctrl_profile_tenant @@ -83,7 +83,7 @@ register: nm_add_route_control_profile_2 - name: Asserts for route control profiles creation tasks - assert: + ansible.builtin.assert: that: - cm_add_route_control_profile is changed - cm_add_route_control_profile.previous == [] @@ -94,42 +94,42 @@ - nm_add_route_control_profile_2.previous == [] - name: Query all route control profiles - aci_route_control_profile: + cisco.aci.aci_route_control_profile: <<: *aci_info state: query register: query_all_route_control_profile - name: Query ansible_rtctrl_profile_l3out - aci_route_control_profile: + cisco.aci.aci_route_control_profile: <<: *aci_route_control_profile_present state: query register: query_ansible_rtctrl_profile_l3out - name: Asserts query tasks - assert: + ansible.builtin.assert: that: - query_all_route_control_profile is not changed - query_all_route_control_profile.current|length >= 2 - name: Remove route control profile for l3out (check_mode) - aci_route_control_profile: &route_control_profile_absent + cisco.aci.aci_route_control_profile: &route_control_profile_absent <<: *aci_route_control_profile_present state: absent check_mode: true register: cm_remove_route_control_profile - name: Remove route control profile for l3out (normal_mode) - aci_route_control_profile: + cisco.aci.aci_route_control_profile: <<: *route_control_profile_absent register: nm_remove_route_control_profile - name: Remove route control profile for l3out again - testing previous Removal - aci_route_control_profile: + cisco.aci.aci_route_control_profile: <<: *route_control_profile_absent register: nm_remove_route_control_profile_idempotency - name: Asserts deletion tasks - assert: + ansible.builtin.assert: that: - cm_remove_route_control_profile is changed - cm_remove_route_control_profile.proposed == {} @@ -140,6 +140,6 @@ - nm_remove_route_control_profile_idempotency.previous == [] - name: Remove the ansible_tenant - cleanup before ending tests - aci_tenant: + cisco.aci.aci_tenant: <<: *aci_tenant_present state: absent diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_snmp_client/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_snmp_client/tasks/main.yml index e5c0ce185..5e6f44ceb 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_snmp_client/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_snmp_client/tasks/main.yml @@ -4,13 +4,13 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined # GET Credentials from the inventory - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: "{{ aci_hostname }}" username: "{{ aci_username }}" @@ -22,14 +22,14 @@ # CLEAN ENVIRONMENT - name: Remove ansible_snmp_client_group if it already exists - aci_snmp_policy: + cisco.aci.aci_snmp_policy: <<: *aci_info name: ansible_snmp_policy state: absent # ADD snmp policy - name: Add snmp policy - aci_snmp_policy: + cisco.aci.aci_snmp_policy: <<: *aci_info name: ansible_snmp_policy admin_state: enabled @@ -37,7 +37,7 @@ # ADD snmp client group - name: Add snmp client group - aci_snmp_client_group: + cisco.aci.aci_snmp_client_group: <<: *aci_info policy: ansible_snmp_policy client_group: ansible_snmp_client_group @@ -46,7 +46,7 @@ # ADD snmp client - name: Add snmp client - aci_snmp_client: + cisco.aci.aci_snmp_client: <<: *aci_info policy: ansible_snmp_policy client_group: ansible_snmp_client_group @@ -56,7 +56,7 @@ register: add_snmp_client - name: Verify that ansible_snmp_client has been created with correct attributes - assert: + ansible.builtin.assert: that: - add_snmp_client.current.0.snmpClientP.attributes.dn == "uni/fabric/snmppol-ansible_snmp_policy/clgrp-ansible_snmp_client_group/client-[10.20.30.0/24]" - add_snmp_client.current.0.snmpClientP.attributes.addr == "10.20.30.0/24" @@ -65,7 +65,7 @@ # ADD snmp client again to check idempotency - name: Add snmp client again - aci_snmp_client: + cisco.aci.aci_snmp_client: <<: *aci_info policy: ansible_snmp_policy client_group: ansible_snmp_client_group @@ -75,13 +75,13 @@ register: add_snmp_client_again - name: Verify that add_snmp_client_group_again stays the same - assert: + ansible.builtin.assert: that: - add_snmp_client_again is not changed # MODIFY snmp client - name: Update snmp client - aci_snmp_client: + cisco.aci.aci_snmp_client: <<: *aci_info policy: ansible_snmp_policy client_group: ansible_snmp_client_group @@ -91,7 +91,7 @@ register: update_snmp_client - name: Verify that ansible_snmp_client_group has been updated with correct attributes - assert: + ansible.builtin.assert: that: - update_snmp_client is changed - update_snmp_client.current.0.snmpClientP.attributes.dn == "uni/fabric/snmppol-ansible_snmp_policy/clgrp-ansible_snmp_client_group/client-[10.20.30.0/24]" @@ -100,7 +100,7 @@ # QUERY snmp client - name: Query snmp client - aci_snmp_client: + cisco.aci.aci_snmp_client: <<: *aci_info policy: ansible_snmp_policy client_group: ansible_snmp_client_group @@ -109,7 +109,7 @@ register: query_snmp_client - name: Verify the attributes under query_snmp_client - assert: + ansible.builtin.assert: that: - query_snmp_client is not changed - query_snmp_client.current.0.snmpClientP.attributes.dn == "uni/fabric/snmppol-ansible_snmp_policy/clgrp-ansible_snmp_client_group/client-[10.20.30.0/24]" @@ -117,19 +117,19 @@ - query_snmp_client.current.0.snmpClientP.attributes.name == "new_snmp_client_name" - name: Query all snmp client - aci_snmp_client: + cisco.aci.aci_snmp_client: <<: *aci_info state: query register: query_snmp_client_all - name: Verify query_snmp_client_all - assert: + ansible.builtin.assert: that: - query_snmp_client_all is not changed # DELETE snmp client group - name: Remove the snmp client - aci_snmp_client: + cisco.aci.aci_snmp_client: <<: *aci_info policy: ansible_snmp_policy client_group: ansible_snmp_client_group @@ -138,7 +138,7 @@ register: remove_snmp_client - name: Verify remove_snmp_client - assert: + ansible.builtin.assert: that: - remove_snmp_client is changed - remove_snmp_client.previous.0.snmpClientP.attributes.dn == "uni/fabric/snmppol-ansible_snmp_policy/clgrp-ansible_snmp_client_group/client-[10.20.30.0/24]" @@ -146,14 +146,14 @@ # DELETE snmp policy - name: Remove the snmp policy - aci_snmp_policy: + cisco.aci.aci_snmp_policy: <<: *aci_info name: ansible_snmp_policy state: absent # DELETE snmp client group - name: Remove the snmp client group - aci_snmp_client_group: + cisco.aci.aci_snmp_client_group: <<: *aci_info policy: ansible_snmp_policy client_group: ansible_snmp_client_group diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_snmp_client_group/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_snmp_client_group/tasks/main.yml index f54a7841a..b93d3f2fb 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_snmp_client_group/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_snmp_client_group/tasks/main.yml @@ -4,13 +4,13 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined # GET Credentials from the inventory - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: "{{ aci_hostname }}" username: "{{ aci_username }}" @@ -22,14 +22,14 @@ # CLEAN ENVIRONMENT - name: Remove ansible_snmp_client_group if it already exists - aci_snmp_policy: + cisco.aci.aci_snmp_policy: <<: *aci_info name: ansible_snmp_policy state: absent # ADD snmp policy - name: Add snmp policy - aci_snmp_policy: + cisco.aci.aci_snmp_policy: <<: *aci_info name: ansible_snmp_policy admin_state: enabled @@ -37,7 +37,7 @@ # ADD snmp client group - name: Add snmp client group - aci_snmp_client_group: + cisco.aci.aci_snmp_client_group: <<: *aci_info policy: ansible_snmp_policy client_group: ansible_snmp_client_group @@ -47,7 +47,7 @@ register: add_snmp_client_group - name: Add snmp client group on default mgmt_epg - aci_snmp_client_group: + cisco.aci.aci_snmp_client_group: <<: *aci_info policy: ansible_snmp_policy client_group: ansible_snmp_client_group_no_epg @@ -56,7 +56,7 @@ register: add_snmp_client_group_no_epg - name: Verify that ansible_snmp_client_group has been created with correct attributes - assert: + ansible.builtin.assert: that: - add_snmp_client_group.current.0.snmpClientGrpP.attributes.dn == "uni/fabric/snmppol-ansible_snmp_policy/clgrp-ansible_snmp_client_group" - add_snmp_client_group.current.0.snmpClientGrpP.attributes.name == "ansible_snmp_client_group" @@ -64,20 +64,20 @@ - add_snmp_client_group.current.0.snmpClientGrpP.attributes.annotation == 'orchestrator:ansible' - name: Verify that ansible_snmp_client_group_no_epg has been created with correct attributes - assert: + ansible.builtin.assert: that: - add_snmp_client_group_no_epg.current.0.snmpClientGrpP.attributes.dn == "uni/fabric/snmppol-ansible_snmp_policy/clgrp-ansible_snmp_client_group_no_epg" - add_snmp_client_group_no_epg.current.0.snmpClientGrpP.attributes.name == "ansible_snmp_client_group_no_epg" - add_snmp_client_group_no_epg.current.0.snmpClientGrpP.attributes.descr == "client group descr" - name: Verify that children of ansible_snmp_client_group have been created with correct values - assert: + ansible.builtin.assert: that: - add_snmp_client_group.current.0.snmpClientGrpP.children.0.snmpRsEpg.attributes.tDn == "uni/tn-mgmt/mgmtp-default/oob-default" # ADD snmp client group again to check idempotency - name: Add snmp client group again - aci_snmp_client_group: + cisco.aci.aci_snmp_client_group: <<: *aci_info policy: ansible_snmp_policy client_group: ansible_snmp_client_group @@ -87,13 +87,13 @@ register: add_snmp_client_group_again - name: Verify that add_snmp_client_group_again stays the same - assert: + ansible.builtin.assert: that: - add_snmp_client_group_again is not changed # MODIFY snmp client group - name: Update snmp client group - aci_snmp_client_group: + cisco.aci.aci_snmp_client_group: <<: *aci_info policy: ansible_snmp_policy client_group: ansible_snmp_client_group @@ -103,7 +103,7 @@ register: update_snmp_client_group - name: Verify that ansible_snmp_client_group has been updated with correct attributes - assert: + ansible.builtin.assert: that: - update_snmp_client_group is changed - update_snmp_client_group.current.0.snmpClientGrpP.attributes.dn == "uni/fabric/snmppol-ansible_snmp_policy/clgrp-ansible_snmp_client_group" @@ -112,7 +112,7 @@ # QUERY snmp client group - name: Query snmp client group - aci_snmp_client_group: + cisco.aci.aci_snmp_client_group: <<: *aci_info policy: ansible_snmp_policy client_group: ansible_snmp_client_group @@ -120,7 +120,7 @@ register: query_snmp_client_group - name: Verify the attributes under query_snmp_client_group - assert: + ansible.builtin.assert: that: - query_snmp_client_group is not changed - query_snmp_client_group.current.0.snmpClientGrpP.attributes.dn == "uni/fabric/snmppol-ansible_snmp_policy/clgrp-ansible_snmp_client_group" @@ -128,19 +128,19 @@ - query_snmp_client_group.current.0.snmpClientGrpP.attributes.descr == "new client group descr" - name: Query all snmp client groups - aci_snmp_client_group: + cisco.aci.aci_snmp_client_group: <<: *aci_info state: query register: query_snmp_client_group_all - name: Verify query_snmp_client_group_all - assert: + ansible.builtin.assert: that: - query_snmp_client_group_all is not changed # DELETE snmp client group - name: Remove the snmp client group - aci_snmp_client_group: + cisco.aci.aci_snmp_client_group: <<: *aci_info policy: ansible_snmp_policy client_group: ansible_snmp_client_group @@ -148,7 +148,7 @@ register: remove_snmp_client_group - name: Verify remove_snmp_client_group - assert: + ansible.builtin.assert: that: - remove_snmp_client_group is changed - remove_snmp_client_group.previous.0.snmpClientGrpP.attributes.dn == "uni/fabric/snmppol-ansible_snmp_policy/clgrp-ansible_snmp_client_group" @@ -156,7 +156,7 @@ # DELETE snmp policy - name: Remove the snmp policy - aci_snmp_policy: + cisco.aci.aci_snmp_policy: <<: *aci_info name: ansible_snmp_policy state: absent diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_snmp_community_policy/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_snmp_community_policy/tasks/main.yml index 570476d37..53538a09f 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_snmp_community_policy/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_snmp_community_policy/tasks/main.yml @@ -4,13 +4,13 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined # GET Credentials from the inventory - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: "{{ aci_hostname }}" username: "{{ aci_username }}" @@ -22,14 +22,14 @@ # CLEAN ENVIRONMENT - name: Remove ansible_snmp_policy if it already exists - aci_snmp_policy: + cisco.aci.aci_snmp_policy: <<: *aci_info name: ansible_snmp_policy state: absent # ADD snmp policy - name: Add snmp policy - aci_snmp_policy: + cisco.aci.aci_snmp_policy: <<: *aci_info name: ansible_snmp_policy admin_state: enabled @@ -37,7 +37,7 @@ # ADD snmp community - name: Add snmp community - aci_snmp_community_policy: + cisco.aci.aci_snmp_community_policy: <<: *aci_info policy: ansible_snmp_policy community: ansible_snmp_community @@ -45,7 +45,7 @@ register: add_snmp_community - name: Verify that ansible_snmp_community has been created with correct attributes - assert: + ansible.builtin.assert: that: - add_snmp_community.current.0.snmpCommunityP.attributes.dn == "uni/fabric/snmppol-ansible_snmp_policy/community-ansible_snmp_community" - add_snmp_community.current.0.snmpCommunityP.attributes.name == "ansible_snmp_community" @@ -54,7 +54,7 @@ # ADD snmp community again to check idempotency - name: Add snmp client group again - aci_snmp_community_policy: + cisco.aci.aci_snmp_community_policy: <<: *aci_info policy: ansible_snmp_policy community: ansible_snmp_community @@ -62,13 +62,13 @@ register: add_snmp_community_again - name: Verify that add_snmp_community_again stays the same - assert: + ansible.builtin.assert: that: - add_snmp_community_again is not changed # MODIFY snmp client community - name: Update snmp community - aci_snmp_community_policy: + cisco.aci.aci_snmp_community_policy: <<: *aci_info policy: ansible_snmp_policy community: ansible_snmp_community @@ -76,7 +76,7 @@ register: update_snmp_community - name: Verify that ansible_snmp_community has been updated with correct attributes - assert: + ansible.builtin.assert: that: - update_snmp_community is changed - update_snmp_community.current.0.snmpCommunityP.attributes.dn == "uni/fabric/snmppol-ansible_snmp_policy/community-ansible_snmp_community" @@ -85,7 +85,7 @@ # QUERY snmp community - name: Query snmp community - aci_snmp_community_policy: + cisco.aci.aci_snmp_community_policy: <<: *aci_info policy: ansible_snmp_policy community: ansible_snmp_community @@ -93,7 +93,7 @@ register: query_snmp_community - name: Verify the attributes under query_snmp_client_group - assert: + ansible.builtin.assert: that: - query_snmp_community is not changed - query_snmp_community.current.0.snmpCommunityP.attributes.dn == "uni/fabric/snmppol-ansible_snmp_policy/community-ansible_snmp_community" @@ -101,19 +101,19 @@ - query_snmp_community.current.0.snmpCommunityP.attributes.descr == "new community description" - name: Query all snmp communities - aci_snmp_community_policy: + cisco.aci.aci_snmp_community_policy: <<: *aci_info state: query register: query_snmp_community_all - name: Verify query_snmp_community_all - assert: + ansible.builtin.assert: that: - query_snmp_community_all is not changed # DELETE snmp community - name: Remove the snmp community - aci_snmp_community_policy: + cisco.aci.aci_snmp_community_policy: <<: *aci_info policy: ansible_snmp_policy community: ansible_snmp_community @@ -121,7 +121,7 @@ register: remove_snmp_community - name: Verify remove_snmp_community - assert: + ansible.builtin.assert: that: - remove_snmp_community is changed - remove_snmp_community.current == [] @@ -130,7 +130,7 @@ # DELETE snmp policy - name: Remove the snmp policy - aci_snmp_policy: + cisco.aci.aci_snmp_policy: <<: *aci_info name: ansible_snmp_policy state: absent diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_snmp_policy/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_snmp_policy/tasks/main.yml index 823ea8f30..70f60f5be 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_snmp_policy/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_snmp_policy/tasks/main.yml @@ -4,13 +4,13 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined # GET Credentials from the inventory - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: "{{ aci_hostname }}" username: "{{ aci_username }}" @@ -22,14 +22,14 @@ # CLEAN ENVIRONMENT - name: Remove ansible_snmp_policy if it already exists - aci_snmp_policy: + cisco.aci.aci_snmp_policy: <<: *aci_info name: ansible_snmp_policy state: absent # ADD snmp policy - name: Add snmp policy - aci_snmp_policy: + cisco.aci.aci_snmp_policy: <<: *aci_info name: ansible_snmp_policy admin_state: enabled @@ -40,7 +40,7 @@ register: add_snmp_policy - name: Verify that ansible_snmp_policy has been created with correct attributes - assert: + ansible.builtin.assert: that: - add_snmp_policy.current.0.snmpPol.attributes.dn == "uni/fabric/snmppol-ansible_snmp_policy" - add_snmp_policy.current.0.snmpPol.attributes.name == "ansible_snmp_policy" @@ -52,7 +52,7 @@ # ADD snmp policy again to check idempotency - name: Add snmp policy - aci_snmp_policy: + cisco.aci.aci_snmp_policy: <<: *aci_info name: ansible_snmp_policy admin_state: enabled @@ -63,13 +63,13 @@ register: add_snmp_policy_again - name: Verify that ansible_snmp_policy stays the same - assert: + ansible.builtin.assert: that: - add_snmp_policy_again is not changed # MODIFY snmp policy - name: Update snmp policy - aci_snmp_policy: + cisco.aci.aci_snmp_policy: <<: *aci_info name: ansible_snmp_policy admin_state: disabled @@ -80,7 +80,7 @@ register: update_snmp_policy - name: Verify that ansible_snmp_policy has been updated with correct attributes - assert: + ansible.builtin.assert: that: - update_snmp_policy.current.0.snmpPol.attributes.dn == "uni/fabric/snmppol-ansible_snmp_policy" - update_snmp_policy.current.0.snmpPol.attributes.name == "ansible_snmp_policy" @@ -91,14 +91,14 @@ # QUERY snmp policy - name: Query snmp policy - aci_snmp_policy: + cisco.aci.aci_snmp_policy: <<: *aci_info name: ansible_snmp_policy state: query register: query_snmp_policy - name: Verify the attributes under query_snmp_policy - assert: + ansible.builtin.assert: that: - query_snmp_policy is not changed - query_snmp_policy.current.0.snmpPol.attributes.dn == "uni/fabric/snmppol-ansible_snmp_policy" @@ -109,26 +109,26 @@ - query_snmp_policy.current.0.snmpPol.attributes.descr == "new policy description" - name: Query all snmp policies - aci_snmp_policy: + cisco.aci.aci_snmp_policy: <<: *aci_info state: query register: query_snmp_policy_all - name: Verify query_snmp_policy_all - assert: + ansible.builtin.assert: that: - query_snmp_policy_all is not changed # DELETE snmp policy - name: Remove the snmp policy - aci_snmp_policy: + cisco.aci.aci_snmp_policy: <<: *aci_info name: ansible_snmp_policy state: absent register: remove_snmp_policy - name: Verify remove_snmp_policy - assert: + ansible.builtin.assert: that: - remove_snmp_policy is changed - remove_snmp_policy.previous.0.snmpPol.attributes.dn == "uni/fabric/snmppol-ansible_snmp_policy" diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_static_binding_to_epg/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_static_binding_to_epg/tasks/main.yml index 0e9096b85..7917551ad 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_static_binding_to_epg/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_static_binding_to_epg/tasks/main.yml @@ -5,12 +5,12 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: "{{ aci_hostname }}" username: "{{ aci_username }}" @@ -21,7 +21,7 @@ output_level: debug - name: Verify Cloud and Non-Cloud Sites in use. - include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml - name: Execute tasks only for non-cloud sites when: query_cloud.current == [] # This condition will execute only non-cloud sites @@ -163,7 +163,7 @@ register: missing_required_present - name: Present assertions - assert: + ansible.builtin.assert: that: - provide_present_check_mode is changed - provide_present_check_mode.sent.fvRsPathAtt.attributes.encap == 'vlan-222' @@ -198,7 +198,7 @@ register: query_all - name: Query assertions - assert: + ansible.builtin.assert: that: - query_static_binding is not changed - query_static_binding.current != [] @@ -234,7 +234,7 @@ register: encap_id_range - name: primary_ecap_id assertions - assert: + ansible.builtin.assert: that: - primary_ecap_id_unknown is changed - primary_ecap_id_unknown.sent.fvRsPathAtt.attributes.primaryEncap == 'unknown' @@ -330,7 +330,7 @@ register: nm_multiple_extpaths - name: Verify interface type and extpaths - assert: + ansible.builtin.assert: that: - cm_fex_port_channel is changed - nm_fex_port_channel is changed @@ -361,7 +361,7 @@ register: missing_param_absent - name: Absent assertions - assert: + ansible.builtin.assert: that: - provide_absent is changed - provide_absent.previous.0.fvRsPathAtt is defined diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_static_node_mgmt_address/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_static_node_mgmt_address/tasks/main.yml index ce1553a45..ed86fd5fe 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_static_node_mgmt_address/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_static_node_mgmt_address/tasks/main.yml @@ -4,12 +4,12 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: "{{ aci_hostname }}" username: "{{ aci_username }}" @@ -20,14 +20,14 @@ output_level: debug - name: Verify Cloud and Non-Cloud Sites in use. - include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml - name: Execute tasks only for non-cloud sites when: query_cloud.current == [] # This condition will execute only non-cloud sites block: # block specifies execution of tasks within, based on conditions # Clean Environment - name: Remove node mgmt in_band epg - aci_node_mgmt_epg: + cisco.aci.aci_node_mgmt_epg: <<: *aci_info type: in_band epg: ansible-inband @@ -36,7 +36,7 @@ state: absent - name: Remove node mgmt out_of_band epg - aci_node_mgmt_epg: + cisco.aci.aci_node_mgmt_epg: <<: *aci_info type: out_of_band epg: ansible-outofband @@ -44,7 +44,7 @@ # Add operations - name: Add node mgmt in_band epg - aci_node_mgmt_epg: + cisco.aci.aci_node_mgmt_epg: <<: *aci_info type: in_band epg: ansible-inband @@ -53,14 +53,14 @@ state: present - name: Add node mgmt out_of_band epg - aci_node_mgmt_epg: + cisco.aci.aci_node_mgmt_epg: <<: *aci_info type: out_of_band epg: ansible-outofband state: present - name: Add ipv4 address to mgmt interface in band in check mode - aci_static_node_mgmt_address: + cisco.aci.aci_static_node_mgmt_address: <<: *aci_info epg: ansible-inband pod_id: 1 @@ -73,7 +73,7 @@ register: cm_add_inb - name: Add ipv4 address to mgmt interface out of band in check mode - aci_static_node_mgmt_address: + cisco.aci.aci_static_node_mgmt_address: <<: *aci_info epg: ansible-outofband pod_id: 1 @@ -86,7 +86,7 @@ register: cm_add_oob - name: Add ipv4 address to mgmt interface in band in normal mode - aci_static_node_mgmt_address: + cisco.aci.aci_static_node_mgmt_address: <<: *aci_info epg: ansible-inband pod_id: 1 @@ -98,7 +98,7 @@ register: nm_add_inb - name: Add ipv4 address to mgmt interface out of band in normal mode - aci_static_node_mgmt_address: + cisco.aci.aci_static_node_mgmt_address: <<: *aci_info epg: ansible-outofband pod_id: 1 @@ -110,7 +110,7 @@ register: nm_add_oob - name: Add ipv4 address to mgmt interface in band in normal mode again - aci_static_node_mgmt_address: + cisco.aci.aci_static_node_mgmt_address: <<: *aci_info epg: ansible-inband pod_id: 1 @@ -122,7 +122,7 @@ register: nm_add_inb_again - name: Add ipv4 address to mgmt interface out of band in normal mode again - aci_static_node_mgmt_address: + cisco.aci.aci_static_node_mgmt_address: <<: *aci_info epg: ansible-outofband pod_id: 1 @@ -134,7 +134,7 @@ register: nm_add_oob_again - name: Add another ipv4 address to mgmt interface in band in normal mode - aci_static_node_mgmt_address: + cisco.aci.aci_static_node_mgmt_address: <<: *aci_info epg: ansible-inband pod_id: 1 @@ -146,7 +146,7 @@ register: nm_add_inb_2 - name: Add another ipv4 address to mgmt interface out of band in normal mode - aci_static_node_mgmt_address: + cisco.aci.aci_static_node_mgmt_address: <<: *aci_info epg: ansible-outofband pod_id: 1 @@ -158,7 +158,7 @@ register: nm_add_oob_2 - name: Verify add operations - assert: + ansible.builtin.assert: that: - cm_add_inb is changed - cm_add_inb.sent.mgmtRsInBStNode.attributes.addr == '3.1.1.2/24' @@ -177,7 +177,7 @@ - nm_add_oob_again is not changed - name: Query ipv4 address to mgmt interface in band in normal mode - aci_static_node_mgmt_address: + cisco.aci.aci_static_node_mgmt_address: <<: *aci_info epg: ansible-inband pod_id: 1 @@ -189,7 +189,7 @@ register: nm_query_inb - name: Query ipv4 address to mgmt interface out_of_band in normal mode - aci_static_node_mgmt_address: + cisco.aci.aci_static_node_mgmt_address: <<: *aci_info epg: ansible-outofband pod_id: 1 @@ -201,7 +201,7 @@ register: nm_query_oob - name: Query all addresses in epg in band - aci_static_node_mgmt_address: + cisco.aci.aci_static_node_mgmt_address: <<: *aci_info epg: ansible-inband type: in_band @@ -209,7 +209,7 @@ register: query_all_epg_inb - name: Query all addresses in epg out of band - aci_static_node_mgmt_address: + cisco.aci.aci_static_node_mgmt_address: <<: *aci_info epg: ansible-outofband type: out_of_band @@ -217,21 +217,21 @@ register: query_all_epg_oob - name: Query all in band addresses - aci_static_node_mgmt_address: + cisco.aci.aci_static_node_mgmt_address: <<: *aci_info type: in_band state: query register: query_all_inb - name: Query all out_of_band addresses - aci_static_node_mgmt_address: + cisco.aci.aci_static_node_mgmt_address: <<: *aci_info type: out_of_band state: query register: query_all_oob - name: Verify query operations - assert: + ansible.builtin.assert: that: - nm_query_inb is not changed - nm_query_oob is not changed @@ -245,7 +245,7 @@ - query_all_oob.current.0.mgmtMgmtP.children.0.mgmtOoB.children | length == 2 - name: Remove ipv4 address to mgmt interface in-band - aci_static_node_mgmt_address: + cisco.aci.aci_static_node_mgmt_address: <<: *aci_info epg: ansible-inband pod_id: 1 @@ -257,7 +257,7 @@ register: remove_in_band - name: Remove ipv4 address to mgmt interface out of band - aci_static_node_mgmt_address: + cisco.aci.aci_static_node_mgmt_address: <<: *aci_info epg: ansible-outofband pod_id: 1 @@ -269,7 +269,7 @@ register: remove_out_of_band - name: Remove ipv4 address to mgmt interface in-band again - aci_static_node_mgmt_address: + cisco.aci.aci_static_node_mgmt_address: <<: *aci_info epg: ansible-inband pod_id: 1 @@ -281,7 +281,7 @@ register: remove_in_band_again - name: Remove ipv4 address to mgmt interface out of band again - aci_static_node_mgmt_address: + cisco.aci.aci_static_node_mgmt_address: <<: *aci_info epg: ansible-outofband pod_id: 1 @@ -293,7 +293,7 @@ register: remove_out_of_band_again - name: Verify remove operations - assert: + ansible.builtin.assert: that: - remove_in_band is changed - remove_in_band.previous.0.mgmtRsInBStNode.attributes.addr == '2.1.1.4/24' @@ -306,7 +306,7 @@ # Clean environment for other ci test cases - name: Remove node mgmt in_band epg - aci_node_mgmt_epg: + cisco.aci.aci_node_mgmt_epg: <<: *aci_info type: in_band epg: ansible-inband @@ -315,7 +315,7 @@ state: absent - name: Remove node mgmt out_of_band epg - aci_node_mgmt_epg: + cisco.aci.aci_node_mgmt_epg: <<: *aci_info type: out_of_band epg: ansible-outofband diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_subject_label/aliases b/ansible_collections/cisco/aci/tests/integration/targets/aci_subject_label/aliases new file mode 100644 index 000000000..209b793f9 --- /dev/null +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_subject_label/aliases @@ -0,0 +1,2 @@ +# No ACI simulator yet, so not enabled +# unsupported diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_subject_label/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_subject_label/tasks/main.yml new file mode 100644 index 000000000..eb39aabf5 --- /dev/null +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_subject_label/tasks/main.yml @@ -0,0 +1,253 @@ +# Test code for the ACI modules + +# Copyright: (c) 2022, Mark Ciecior (@markciecior) +# Copyright: (c) 2024, Akini Ross (akinross@cisco.com) + +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +- name: Test that we have an ACI APIC host, ACI username and ACI password + ansible.builtin.fail: + msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' + when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined + +- name: Set vars + ansible.builtin.set_fact: + aci_info: &aci_info + host: "{{ aci_hostname }}" + username: "{{ aci_username }}" + password: "{{ aci_password }}" + validate_certs: '{{ aci_validate_certs | default(false) }}' + use_ssl: '{{ aci_use_ssl | default(true) }}' + use_proxy: '{{ aci_use_proxy | default(true) }}' + output_level: '{{ aci_output_level | default("info") }}' + +- name: Query system information + cisco.aci.aci_system: + <<: *aci_info + id: 1 + state: query + register: version + +- name: Verify Cloud and Non-Cloud Sites in use. + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + +- name: Execute tasks only for non-cloud sites + when: + - query_cloud.current == [] + block: + + # CLEAN TEST ENVIRONMENT + - name: Ensure tenant removed + cisco.aci.aci_tenant: &aci_tenant_absent + <<: *aci_info + state: absent + tenant: ansible_test + + # SETUP TEST ENVIRONMENT + - name: Create tenant + cisco.aci.aci_tenant: &aci_tenant_present + <<: *aci_tenant_absent + state: present + + - name: Create BD + cisco.aci.aci_bd: + <<: *aci_tenant_present + bd: ansible_test_bd + + - name: Create VRF + cisco.aci.aci_vrf: + <<: *aci_tenant_present + vrf: ansible_test_vrf + + - name: Create AP + cisco.aci.aci_ap: &aci_ap + <<: *aci_tenant_present + ap: ansible_test_ap + + - name: Create EPG + cisco.aci.aci_epg: + <<: *aci_ap + epg: ansible_test_epg + bd: ansible_test_bd + + - name: Bind End Point Group to Provider Contract + cisco.aci.aci_epg_to_contract: + <<: *aci_tenant_present + ap: ansible_test_ap + epg: ansible_test_epg + contract_type: provider + contract: ansible_test_contract + + - name: Bind End Point Group to Consumer Contract + cisco.aci.aci_epg_to_contract: + <<: *aci_tenant_present + ap: ansible_test_ap + epg: ansible_test_epg + contract_type: consumer + contract: ansible_test_contract + + - name: Create ESG + cisco.aci.aci_esg: + <<: *aci_ap + esg: ansible_test_esg + vrf: ansible_test_vrf + when: version.current.0.topSystem.attributes.version is version('5', '>=') + + - name: Create L2Out + cisco.aci.aci_l2out: + <<: *aci_tenant_present + l2out: ansible_test_l2out + bd: ansible_test_bd + domain: l2Dom + vlan: 3200 + + - name: Create L2Out External End Point Group + cisco.aci.aci_l2out_extepg: + <<: *aci_tenant_present + l2out: ansible_test_l2out + extepg: ansible_test_external_epg + + - name: Create L2Out + cisco.aci.aci_l3out: + <<: *aci_tenant_present + l3out: ansible_test_l3out + vrf: ansible_test_vrf + domain: l3dom + + - name: Create L3Out External End Point Group + cisco.aci.aci_l3out_extepg: + <<: *aci_tenant_present + l3out: ansible_test_l3out + extepg: ansible_test_external_epg + + - name: Bind L3out External End Point Group to Provider Contract + cisco.aci.aci_l3out_extepg_to_contract: + <<: *aci_tenant_present + tenant: ansible_test + l3out: ansible_test_l3out + extepg: ansible_test_external_epg + contract: ansible_test_contract + contract_type: provider + + - name: Bind L3out External End Point Group to Consumer Contract + cisco.aci.aci_l3out_extepg_to_contract: + <<: *aci_tenant_present + tenant: ansible_test + l3out: ansible_test_l3out + extepg: ansible_test_external_epg + contract: ansible_test_contract + contract_type: consumer + + - name: Create Contract + cisco.aci.aci_contract: &aci_contract_present + <<: *aci_tenant_present + contract: ansible_test_contract + + - name: Create Subject + cisco.aci.aci_contract_subject: + <<: *aci_contract_present + subject: ansible_test_subject + + # TESTS THAT ALL PARENT CLASS COMBINATIONS ARE CONFIGURABLE + - name: Execute tests for each parent class + ansible.builtin.include_tasks: subject_label.yml + loop: + - { l2out: "{{ fake_var | default(omit) }}", l3out: "{{ fake_var | default(omit) }}", external_epg: "{{ fake_var | default(omit) }}", contract: "ansible_test_contract", subject: "ansible_test_subject", ap: "{{ fake_var | default(omit) }}", epg: "{{ fake_var | default(omit) }}", esg: "{{ fake_var | default(omit) }}"} + - { l2out: "ansible_test_l2out", l3out: "{{ fake_var | default(omit) }}", external_epg: "ansible_test_external_epg", contract: "{{ fake_var | default(omit) }}", subject: "{{ fake_var | default(omit) }}", ap: "{{ fake_var | default(omit) }}", epg: "{{ fake_var | default(omit) }}", esg: "{{ fake_var | default(omit) }}"} + - { l2out: "{{ fake_var | default(omit) }}", l3out: "ansible_test_l3out", external_epg: "ansible_test_external_epg", contract: "{{ fake_var | default(omit) }}", subject: "{{ fake_var | default(omit) }}", ap: "{{ fake_var | default(omit) }}", epg: "{{ fake_var | default(omit) }}", esg: "{{ fake_var | default(omit) }}"} + - { l2out: "{{ fake_var | default(omit) }}", l3out: "ansible_test_l3out", external_epg: "ansible_test_external_epg", contract: "ansible_test_contract", subject: "{{ fake_var | default(omit) }}", ap: "{{ fake_var | default(omit) }}", epg: "{{ fake_var | default(omit) }}", esg: "{{ fake_var | default(omit) }}"} + - { l2out: "{{ fake_var | default(omit) }}", l3out: "{{ fake_var | default(omit) }}", external_epg: "{{ fake_var | default(omit) }}", contract: "{{ fake_var | default(omit) }}", subject: "{{ fake_var | default(omit) }}", ap: "ansible_test_ap", epg: "ansible_test_epg", esg: "{{ fake_var | default(omit) }}"} + - { l2out: "{{ fake_var | default(omit) }}", l3out: "{{ fake_var | default(omit) }}", external_epg: "{{ fake_var | default(omit) }}", contract: "ansible_test_contract", subject: "{{ fake_var | default(omit) }}", ap: "ansible_test_ap", epg: "ansible_test_epg", esg: "{{ fake_var | default(omit) }}"} + loop_control: + loop_var: parent_class + + - name: Execute tests for esg class which is only supported in 5+ + ansible.builtin.include_tasks: subject_label.yml + loop: + - { l2out: "{{ fake_var | default(omit) }}", l3out: "{{ fake_var | default(omit) }}", external_epg: "{{ fake_var | default(omit) }}", contract: "{{ fake_var | default(omit) }}", subject: "{{ fake_var | default(omit) }}", ap: "ansible_test_ap", epg: "{{ fake_var | default(omit) }}", esg: "ansible_test_esg"} + loop_control: + loop_var: parent_class + when: version.current.0.topSystem.attributes.version is version('5', '>=') + + # ERROR TESTS + - name: Mutually exclusive all provided (error) + cisco.aci.aci_subject_label: + <<: *aci_tenant_present + l2out: ansible_test_l2out + l3out: ansible_test_l3out + subject: ansible_test_subject + epg: ansible_test_epg + esg: ansible_test_esg + register: err_mutually_exclusive_all + ignore_errors: true + + - name: Mutually exclusive two provided (error) + cisco.aci.aci_subject_label: + <<: *aci_tenant_present + l2out: ansible_test_l2out + l3out: ansible_test_l3out + register: err_mutually_exclusive_two + ignore_errors: true + + - name: Mutually exclusive esg with contract provided (error) + cisco.aci.aci_subject_label: + <<: *aci_tenant_present + esg: ansible_test_esg + contract: ansible_test_contract + register: err_mutually_exclusive_esg + ignore_errors: true + + - name: Missing required input one of L2Out, L3Out, EPG, ESG, subject (error) + cisco.aci.aci_subject_label: + <<: *aci_tenant_present + subject_label: ansible_test_l2out + subject_label_type: consumer + register: err_missing_required_input_missing_one_of + ignore_errors: true + + - name: Missing required input subject_type (error) + cisco.aci.aci_subject_label: + <<: *aci_tenant_present + l2out: ansible_test_l2out + register: err_missing_required_input_subject_type + ignore_errors: true + + - name: Missing required input subject_label (error) + cisco.aci.aci_subject_label: + <<: *aci_tenant_present + l2out: ansible_test_l2out + subject_label_type: consumer + register: err_missing_required_input_subject_label + ignore_errors: true + + - name: Missing required input external_epg (error) + cisco.aci.aci_subject_label: + <<: *aci_tenant_present + l2out: ansible_test_l2out + subject_label_type: consumer + subject_label: ansible_test_subject_label + register: err_missing_required_input_external_epg + ignore_errors: true + + - name: Assert input errors + ansible.builtin.assert: + that: + - err_mutually_exclusive_all is failed + - err_mutually_exclusive_all.msg == "parameters are mutually exclusive{{":"}} l2out|l3out|epg|esg|subject" + - err_mutually_exclusive_two is failed + - err_mutually_exclusive_two.msg == "parameters are mutually exclusive{{":"}} l2out|l3out|epg|esg|subject" + - err_mutually_exclusive_esg is failed + - err_mutually_exclusive_esg.msg == "parameters are mutually exclusive{{":"}} esg|contract" + - err_missing_required_input_missing_one_of is failed + - err_missing_required_input_missing_one_of.msg == "state is present but any of the following are missing{{":"}} l2out, l3out, epg, esg, subject" + - err_missing_required_input_subject_type is failed + - err_missing_required_input_subject_type.msg == "missing required arguments{{":"}} subject_label_type" + - err_missing_required_input_subject_label is failed + - err_missing_required_input_subject_label.msg == "state is present but all of the following are missing{{":"}} subject_label" + - err_missing_required_input_external_epg is failed + - err_missing_required_input_external_epg.msg == "missing parameter(s) required by 'l2out'{{":"}} external_epg" + + # CLEAN TEST ENVIRONMENT + - name: Remove tenant + cisco.aci.aci_tenant: + <<: *aci_tenant_absent diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_subject_label/tasks/subject_label.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_subject_label/tasks/subject_label.yml new file mode 100644 index 000000000..bb15cc846 --- /dev/null +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_subject_label/tasks/subject_label.yml @@ -0,0 +1,188 @@ +- name: Set vars + ansible.builtin.set_fact: + aci_info: &aci_info + host: "{{ aci_hostname }}" + username: "{{ aci_username }}" + password: "{{ aci_password }}" + validate_certs: '{{ aci_validate_certs | default(false) }}' + use_ssl: '{{ aci_use_ssl | default(true) }}' + use_proxy: '{{ aci_use_proxy | default(true) }}' + output_level: '{{ aci_output_level | default("debug") }}' + +# CREATE TESTS +- name: Create subject label (check mode) + cisco.aci.aci_subject_label: &subject_label_present + <<: *aci_info + tenant: ansible_test + l2out: "{{ parent_class.l2out }}" + l3out: "{{ parent_class.l3out }}" + external_epg: "{{ parent_class.external_epg }}" + contract: "{{ parent_class.contract }}" + subject: "{{ parent_class.subject }}" + ap: "{{ parent_class.ap }}" + epg: "{{ parent_class.epg }}" + esg: "{{ parent_class.esg }}" + subject_label_type: consumer + subject_label: ansible_test_subject_label_1 + check_mode: true + register: cm_create_subject_label + +- name: Create subject label + cisco.aci.aci_subject_label: + <<: *subject_label_present + register: nm_create_subject_label + +- name: Create subject label again + cisco.aci.aci_subject_label: + <<: *subject_label_present + register: nm_create_subject_label_again + +- name: Assert create subject label + ansible.builtin.assert: + that: + - cm_create_subject_label is changed + - cm_create_subject_label.previous == [] + - cm_create_subject_label.current == [] + - cm_create_subject_label.proposed.vzConsSubjLbl.attributes.name == "ansible_test_subject_label_1" + - nm_create_subject_label is changed + - nm_create_subject_label.previous == [] + - nm_create_subject_label.current.0.vzConsSubjLbl.attributes.name == "ansible_test_subject_label_1" + - nm_create_subject_label.current.0.vzConsSubjLbl.attributes.descr == "" + - nm_create_subject_label.current.0.vzConsSubjLbl.attributes.isComplement == "no" + - nm_create_subject_label.current.0.vzConsSubjLbl.attributes.tag == "yellow-green" + - nm_create_subject_label_again is not changed + - nm_create_subject_label_again.previous.0.vzConsSubjLbl.attributes.name == "ansible_test_subject_label_1" + - nm_create_subject_label_again.previous.0.vzConsSubjLbl.attributes.descr == "" + - nm_create_subject_label_again.previous.0.vzConsSubjLbl.attributes.isComplement == "no" + - nm_create_subject_label_again.previous.0.vzConsSubjLbl.attributes.tag == "yellow-green" + - nm_create_subject_label_again.current.0.vzConsSubjLbl.attributes.name == "ansible_test_subject_label_1" + - nm_create_subject_label_again.current.0.vzConsSubjLbl.attributes.descr == "" + - nm_create_subject_label_again.current.0.vzConsSubjLbl.attributes.isComplement == "no" + - nm_create_subject_label_again.current.0.vzConsSubjLbl.attributes.tag == "yellow-green" + +# UPDATE TESTS +- name: Update subject label + cisco.aci.aci_subject_label: + <<: *subject_label_present + description: changed_description + complement: true + tag: chartreuse + register: nm_update_subject_label + +- name: Assert update subject label + ansible.builtin.assert: + that: + - nm_update_subject_label is changed + - nm_update_subject_label.previous.0.vzConsSubjLbl.attributes.name == "ansible_test_subject_label_1" + - nm_update_subject_label.previous.0.vzConsSubjLbl.attributes.descr == "" + - nm_update_subject_label.previous.0.vzConsSubjLbl.attributes.isComplement == "no" + - nm_update_subject_label.previous.0.vzConsSubjLbl.attributes.tag == "yellow-green" + - nm_update_subject_label.current.0.vzConsSubjLbl.attributes.name == "ansible_test_subject_label_1" + - nm_update_subject_label.current.0.vzConsSubjLbl.attributes.descr == "changed_description" + - nm_update_subject_label.current.0.vzConsSubjLbl.attributes.isComplement == "yes" + - nm_update_subject_label.current.0.vzConsSubjLbl.attributes.tag == "chartreuse" + +# QUERY TESTS +- name: Create subject label 2 + cisco.aci.aci_subject_label: + <<: *subject_label_present + subject_label: ansible_test_subject_label_2 + tag: cadet_blue + +- name: Create provider subject label 3, 4 and 5 + cisco.aci.aci_subject_label: + <<: *subject_label_present + subject_label: "{{ item }}" + subject_label_type: provider + loop: + - ansible_test_subject_label_3 + - ansible_test_subject_label_4 + - ansible_test_subject_label_5 + register: create_provider_subject_labels + +- name: Assert create of provider subject label + ansible.builtin.assert: + that: + - create_provider_subject_labels.results.0.current.0.vzProvSubjLbl.attributes.name == "ansible_test_subject_label_3" + - create_provider_subject_labels.results.1.current.0.vzProvSubjLbl.attributes.name == "ansible_test_subject_label_4" + - create_provider_subject_labels.results.2.current.0.vzProvSubjLbl.attributes.name == "ansible_test_subject_label_5" + +- name: Query subject label + cisco.aci.aci_subject_label: + <<: *subject_label_present + register: query_one + +- name: Query all consumer subject labels + cisco.aci.aci_subject_label: + <<: *aci_info + subject_label_type: consumer + state: query + register: query_all_consumer + +- name: Query all provider subject labels + cisco.aci.aci_subject_label: + <<: *aci_info + subject_label_type: provider + state: query + register: query_all_provider + +- name: Assert query subject label + ansible.builtin.assert: + that: + - query_one is not changed + - query_one.current.0.vzConsSubjLbl.attributes.name == "ansible_test_subject_label_1" + - query_one.current.0.vzConsSubjLbl.attributes.descr == "changed_description" + - query_one.current.0.vzConsSubjLbl.attributes.isComplement == "yes" + - query_one.current.0.vzConsSubjLbl.attributes.tag == "chartreuse" + - query_all_consumer is not changed + - query_all_consumer.current | length >= 2 + - query_all_provider is not changed + - query_all_provider.current | length >= 3 + +# DELETE TESTS +- name: Delete subject label (check mode) + cisco.aci.aci_subject_label: &subject_label_absent + <<: *subject_label_present + state: absent + check_mode: true + register: cm_delete_subject_label + +- name: Delete subject label + cisco.aci.aci_subject_label: + <<: *subject_label_absent + register: nm_delete_subject_label + +- name: Delete subject label again + cisco.aci.aci_subject_label: + <<: *subject_label_absent + register: nm_delete_subject_label_again + +- name: Assert delete subject label + ansible.builtin.assert: + that: + - cm_delete_subject_label is changed + - cm_delete_subject_label.previous.0.vzConsSubjLbl.attributes.name == "ansible_test_subject_label_1" + - cm_delete_subject_label.current.0.vzConsSubjLbl.attributes.name == "ansible_test_subject_label_1" + - cm_delete_subject_label.proposed == {} + - nm_delete_subject_label is changed + - nm_delete_subject_label.previous.0.vzConsSubjLbl.attributes.name == "ansible_test_subject_label_1" + - nm_delete_subject_label.current == [] + - nm_delete_subject_label_again is not changed + - nm_delete_subject_label_again.previous == [] + - nm_delete_subject_label_again.current == [] + +# CLEAN TEST ENVIRONMENT +- name: Delete consumer subject label 2 + cisco.aci.aci_subject_label: + <<: *subject_label_absent + subject_label: ansible_test_subject_label_2 + +- name: Delete provider subject labels 3, 4 and 5 + cisco.aci.aci_subject_label: + <<: *subject_label_absent + subject_label: "{{ item }}" + subject_label_type: provider + loop: + - ansible_test_subject_label_3 + - ansible_test_subject_label_4 + - ansible_test_subject_label_5 diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_switch_leaf_selector/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_switch_leaf_selector/tasks/main.yml index d57239e49..da683c852 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_switch_leaf_selector/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_switch_leaf_selector/tasks/main.yml @@ -4,12 +4,12 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined - name: Verify Cloud and Non-Cloud Sites in use. - include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml - name: Execute tasks only for non-cloud sites when: query_cloud.current == [] # This condition will execute only non-cloud sites @@ -69,7 +69,7 @@ # TODO: also test for errors - name: present assertions - assert: + ansible.builtin.assert: that: - sw_leaf_selec_check_mode_present is changed - sw_leaf_selec_present is changed @@ -93,7 +93,7 @@ register: binding_query - name: present assertions - assert: + ansible.builtin.assert: that: - binding_query is not changed - binding_query.current | length >= 1 @@ -126,7 +126,7 @@ register: sw_leaf_selec_absent_missing_param - name: absent assertions - assert: + ansible.builtin.assert: that: - sw_leaf_selec_check_mode_absent is changed - sw_leaf_selec_check_mode_absent.previous != [] diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_switch_policy_leaf_profile/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_switch_policy_leaf_profile/tasks/main.yml index 2bed3b67c..022013c67 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_switch_policy_leaf_profile/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_switch_policy_leaf_profile/tasks/main.yml @@ -4,12 +4,12 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined - name: Verify Cloud and Non-Cloud Sites in use. - include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml - name: Execute tasks only for non-cloud sites when: query_cloud.current == [] # This condition will execute only non-cloud sites @@ -57,7 +57,7 @@ register: nm_add_switch_leaf_profile_again - name: Verify add_switch_leaf_profile - assert: + ansible.builtin.assert: that: - cm_add_switch_leaf_profile is changed - nm_add_switch_leaf_profile is changed @@ -94,7 +94,7 @@ register: nm_add_switch_leaf_profile_descr_again - name: Verify add_switch_leaf_profile_descr - assert: + ansible.builtin.assert: that: - cm_add_switch_leaf_profile_descr is changed - nm_add_switch_leaf_profile_descr is changed @@ -113,7 +113,7 @@ register: nm_add_switch_leaf_profile_again_no_descr - name: Verify add_switch_leaf_profile_again_no_descr - assert: + ansible.builtin.assert: that: - cm_add_switch_leaf_profile_again_no_descr is not changed - nm_add_switch_leaf_profile_again_no_descr is not changed @@ -138,7 +138,7 @@ register: nm_query_all_switch_leaf_profiles - name: Verify query_all_switch_leaf_profiles - assert: + ansible.builtin.assert: that: - cm_query_all_switch_leaf_profiles is not changed - nm_query_all_switch_leaf_profiles is not changed @@ -161,7 +161,7 @@ register: nm_query_switch_leaf_profile - name: Verify query_switch_leaf_profile - assert: + ansible.builtin.assert: that: - cm_query_switch_leaf_profile is not changed - nm_query_switch_leaf_profile is not changed @@ -188,7 +188,7 @@ register: nm_remove_switch_leaf_profile_again - name: Verify remove_switch_leaf_profile - assert: + ansible.builtin.assert: that: - cm_remove_switch_leaf_profile is changed - nm_remove_switch_leaf_profile is changed @@ -212,7 +212,7 @@ # TODO: Implement more tests - name: Verify query_non_switch_leaf_profile - assert: + ansible.builtin.assert: that: - cm_query_non_switch_leaf_profile is not changed - nm_query_non_switch_leaf_profile is not changed diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_switch_policy_vpc_protection_group/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_switch_policy_vpc_protection_group/tasks/main.yml index c0ef39cfe..a161025a1 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_switch_policy_vpc_protection_group/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_switch_policy_vpc_protection_group/tasks/main.yml @@ -4,7 +4,7 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined @@ -54,7 +54,7 @@ register: nm_add_vpc_prot_grp_again - name: Verify add_vpc_prot_grp_again - assert: + ansible.builtin.assert: that: - cm_add_vpc_prot_grp is changed - nm_add_vpc_prot_grp is changed @@ -91,7 +91,7 @@ register: nm_add_vpc_prot_grp_pol_again - name: Verify add_vpc_prot_grp_pol - assert: + ansible.builtin.assert: that: - cm_add_vpc_prot_grp_pol is changed - nm_add_vpc_prot_grp_pol is changed @@ -110,7 +110,7 @@ register: nm_add_vpc_prot_grp_again_no_pol - name: Verify add_vpc_prot_grp_again_no_pol - assert: + ansible.builtin.assert: that: - cm_add_vpc_prot_grp_again_no_pol is not changed - nm_add_vpc_prot_grp_again_no_pol is not changed @@ -135,7 +135,7 @@ register: nm_query_all_vpc_prot_grps - name: Verify query_all_vpc_prot_grps - assert: + ansible.builtin.assert: that: - cm_query_all_vpc_prot_grps is not changed - nm_query_all_vpc_prot_grps is not changed @@ -157,7 +157,7 @@ register: nm_query_vpc_prot_grp - name: Verify query_vpc_prot_grp - assert: + ansible.builtin.assert: that: - cm_query_vpc_prot_grp is not changed - nm_query_vpc_prot_grp is not changed @@ -184,7 +184,7 @@ register: nm_remove_vpc_prot_grp_again - name: Verify remove_vpc_prot_grp - assert: + ansible.builtin.assert: that: - cm_remove_vpc_prot_grp is changed - nm_remove_vpc_prot_grp is changed @@ -207,7 +207,7 @@ register: nm_query_non_vpc_prot_grp - name: Verify query_non_vpc_prot_grp - assert: + ansible.builtin.assert: that: - cm_query_non_vpc_prot_grp is not changed - nm_query_non_vpc_prot_grp is not changed diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_syslog_group/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_syslog_group/tasks/main.yml index f80ca35d2..34a2ddf63 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_syslog_group/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_syslog_group/tasks/main.yml @@ -4,13 +4,13 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined # GET Credentials from the inventory - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: "{{ aci_hostname }}" username: "{{ aci_username }}" @@ -67,7 +67,7 @@ when: version.current.0.topSystem.attributes.version is version('4', '<') - name: Verify that ansible_syslog_group has been created with correct attributes (version > 4) - assert: + ansible.builtin.assert: that: - add_syslog_group.current.0.syslogGroup.attributes.dn == "uni/fabric/slgroup-ansible_syslog_group" - add_syslog_group.current.0.syslogGroup.attributes.name == "ansible_syslog_group" @@ -78,7 +78,7 @@ when: version.current.0.topSystem.attributes.version is version('4', '>=') - name: Verify that ansible_syslog_group has been created with correct attributes (version < 4) - assert: + ansible.builtin.assert: that: - add_syslog_group_32.current.0.syslogGroup.attributes.dn == "uni/fabric/slgroup-ansible_syslog_group" - add_syslog_group_32.current.0.syslogGroup.attributes.name == "ansible_syslog_group" @@ -88,7 +88,7 @@ when: version.current.0.topSystem.attributes.version is version('4', '<') - name: Verify that ansible_syslog_group children have correct attributes (version >= 4) - assert: + ansible.builtin.assert: that: - add_syslog_group.current.0.syslogGroup.children.0.syslogConsole.attributes.adminState == "enabled" - add_syslog_group.current.0.syslogGroup.children.0.syslogConsole.attributes.severity == "critical" @@ -98,7 +98,7 @@ when: version.current.0.topSystem.attributes.version is version('4', '>=') - name: Verify that ansible_syslog_group children have correct attributes (version < 4) - assert: + ansible.builtin.assert: that: - add_syslog_group_32.current.0.syslogGroup.children.0.syslogConsole.attributes.adminState == "enabled" - add_syslog_group_32.current.0.syslogGroup.children.0.syslogConsole.attributes.severity == "critical" @@ -121,13 +121,13 @@ when: version.current.0.topSystem.attributes.version is version('4', '<') - name: Verify that ansible_syslog_group stays the same (version >= 4) - assert: + ansible.builtin.assert: that: - add_syslog_group_again is not changed when: version.current.0.topSystem.attributes.version is version('4', '>=') - name: Verify that ansible_syslog_group stays the same (version < 4) - assert: + ansible.builtin.assert: that: - add_syslog_group_again_32 is not changed when: version.current.0.topSystem.attributes.version is version('4', '<') @@ -165,7 +165,7 @@ when: version.current.0.topSystem.attributes.version is version('4', '<') - name: Verify that ansible_syslog_group has been updated with correct attributes (version >= 4) - assert: + ansible.builtin.assert: that: - update_syslog_group.current.0.syslogGroup.attributes.dn == "uni/fabric/slgroup-ansible_syslog_group" - update_syslog_group.current.0.syslogGroup.attributes.name == "ansible_syslog_group" @@ -175,7 +175,7 @@ when: version.current.0.topSystem.attributes.version is version('4', '>=') - name: Verify that ansible_syslog_group has been updated with correct attributes (version < 4) - assert: + ansible.builtin.assert: that: - update_syslog_group_32.current.0.syslogGroup.attributes.dn == "uni/fabric/slgroup-ansible_syslog_group" - update_syslog_group_32.current.0.syslogGroup.attributes.name == "ansible_syslog_group" @@ -184,7 +184,7 @@ when: version.current.0.topSystem.attributes.version is version('4', '<') - name: Verify that ansible_syslog_group children have correct attributes (version >= 4) - assert: + ansible.builtin.assert: that: - update_syslog_group.current.0.syslogGroup.children.0.syslogConsole.attributes.adminState == "disabled" - update_syslog_group.current.0.syslogGroup.children.0.syslogConsole.attributes.severity == "emergencies" @@ -194,7 +194,7 @@ when: version.current.0.topSystem.attributes.version is version('4', '>=') - name: Verify that ansible_syslog_group children have correct attributes (version < 4) - assert: + ansible.builtin.assert: that: - update_syslog_group_32.current.0.syslogGroup.children.0.syslogConsole.attributes.adminState == "disabled" - update_syslog_group_32.current.0.syslogGroup.children.0.syslogConsole.attributes.severity == "emergencies" @@ -212,7 +212,7 @@ register: query_syslog_group - name: Verify the attributes under query_syslog_group - assert: + ansible.builtin.assert: that: - query_syslog_group is not changed - query_syslog_group.current.0.syslogGroup.attributes.dn == "uni/fabric/slgroup-ansible_syslog_group" @@ -225,7 +225,7 @@ register: query_syslog_group_all - name: Verify query_syslog_group_all - assert: + ansible.builtin.assert: that: - query_syslog_group_all is not changed @@ -238,7 +238,7 @@ register: remove_syslog_group - name: Verify remove_syslog_group - assert: + ansible.builtin.assert: that: - remove_syslog_group is changed - remove_syslog_group.previous.0.syslogGroup.attributes.dn == "uni/fabric/slgroup-ansible_syslog_group" diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_syslog_remote_dest/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_syslog_remote_dest/tasks/main.yml index 82839ddf7..73fddc6f7 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_syslog_remote_dest/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_syslog_remote_dest/tasks/main.yml @@ -4,13 +4,13 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined # GET Credentials from the inventory - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: "{{ aci_hostname }}" username: "{{ aci_username }}" @@ -22,7 +22,7 @@ # CLEAN ENVIRONMENT - name: Remove ansible_syslog_src if it already exists - aci_syslog_remote_dest: + cisco.aci.aci_syslog_remote_dest: <<: *aci_info group: ansible_syslog_group destination: "10.20.30.40" @@ -30,7 +30,7 @@ # ADD syslog group - name: Add syslog group - aci_syslog_group: + cisco.aci.aci_syslog_group: <<: *aci_info name: ansible_syslog_group admin_state: enabled @@ -38,7 +38,7 @@ # ADD syslog remote destination - name: Add syslog remote destination - aci_syslog_remote_dest: + cisco.aci.aci_syslog_remote_dest: <<: *aci_info group: ansible_syslog_group destination: "10.20.30.40" @@ -53,7 +53,7 @@ register: add_syslog_remote_dest - name: Verify that ansible_syslog_src has been created with correct attributes - assert: + ansible.builtin.assert: that: - add_syslog_remote_dest.current.0.syslogRemoteDest.attributes.dn == "uni/fabric/slgroup-ansible_syslog_group/rdst-10.20.30.40" - add_syslog_remote_dest.current.0.syslogRemoteDest.attributes.name == "remote_destination_name" @@ -69,7 +69,7 @@ # ADD syslog remote dest again to check idempotency - name: Add syslog remote dest - aci_syslog_remote_dest: + cisco.aci.aci_syslog_remote_dest: <<: *aci_info group: ansible_syslog_group destination: "10.20.30.40" @@ -84,13 +84,13 @@ register: add_syslog_remote_dest_again - name: Verify that ansible_syslog_remote_dest stays the same - assert: + ansible.builtin.assert: that: - add_syslog_remote_dest_again is not changed # MODIFY syslog remote destination - name: Update the syslog remote destination - aci_syslog_remote_dest: + cisco.aci.aci_syslog_remote_dest: <<: *aci_info group: ansible_syslog_group destination: "10.20.30.40" @@ -106,7 +106,7 @@ register: update_syslog_remote_dest - name: Verify that ansible_syslog_src has been updated with correct attributes - assert: + ansible.builtin.assert: that: - update_syslog_remote_dest.current.0.syslogRemoteDest.attributes.dn == "uni/fabric/slgroup-ansible_syslog_group/rdst-10.20.30.40" - update_syslog_remote_dest.current.0.syslogRemoteDest.attributes.name == "new_remote_destination_name" @@ -119,13 +119,13 @@ - update_syslog_remote_dest.current.0.syslogRemoteDest.attributes.severity == "information" - name: Verify that ansible_syslog_remote_dest children have correct attributes - assert: + ansible.builtin.assert: that: - update_syslog_remote_dest.current.0.syslogRemoteDest.children.0.fileRsARemoteHostToEpg.attributes.tDn == "uni/tn-mgmt/mgmtp-default/oob-default" # QUERY syslog source - name: Query the syslog source - aci_syslog_remote_dest: + cisco.aci.aci_syslog_remote_dest: <<: *aci_info group: ansible_syslog_group destination: "10.20.30.40" @@ -133,7 +133,7 @@ register: query_syslog_remote_dest - name: Verify the attributes under query_syslog_src - assert: + ansible.builtin.assert: that: - query_syslog_remote_dest is not changed - query_syslog_remote_dest.current.0.syslogRemoteDest.attributes.dn == "uni/fabric/slgroup-ansible_syslog_group/rdst-10.20.30.40" @@ -147,19 +147,19 @@ - query_syslog_remote_dest.current.0.syslogRemoteDest.attributes.severity == "information" - name: Query all syslog remote destinations - aci_syslog_remote_dest: + cisco.aci.aci_syslog_remote_dest: <<: *aci_info state: query register: query_syslog_remote_dest_all - name: Verify query_syslog_remote_dest_all - assert: + ansible.builtin.assert: that: - query_syslog_remote_dest_all is not changed # DELETE syslog remote destination - name: Remove the syslog remote dest - aci_syslog_remote_dest: + cisco.aci.aci_syslog_remote_dest: <<: *aci_info group: ansible_syslog_group destination: "10.20.30.40" @@ -167,7 +167,7 @@ register: remove_syslog_remote_dest - name: Verify remove_syslog_remote_dest - assert: + ansible.builtin.assert: that: - remove_syslog_remote_dest is changed - remove_syslog_remote_dest.current == [] @@ -175,7 +175,7 @@ # DELETE syslog remote destination again to test idempotence - name: Remove the syslog remote dest again - aci_syslog_remote_dest: + cisco.aci.aci_syslog_remote_dest: <<: *aci_info group: ansible_syslog_group destination: "10.20.30.40" @@ -183,13 +183,13 @@ register: remove_syslog_remote_dest_again - name: Verify remove_syslog_remote_dest idempotence - assert: + ansible.builtin.assert: that: - remove_syslog_remote_dest_again is not changed # DELETE syslog group - name: Remove syslog group - aci_syslog_group: + cisco.aci.aci_syslog_group: <<: *aci_info name: ansible_syslog_group admin_state: enabled diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_syslog_source/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_syslog_source/tasks/main.yml index a7180649f..b2c7bd866 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_syslog_source/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_syslog_source/tasks/main.yml @@ -4,13 +4,13 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined # GET Credentials from the inventory - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: "{{ aci_hostname }}" username: "{{ aci_username }}" @@ -22,14 +22,14 @@ # CLEAN ENVIRONMENT - name: Remove ansible_syslog_src if it already exists - aci_syslog_source: + cisco.aci.aci_syslog_source: <<: *aci_info name: ansible_syslog_src state: absent # ADD syslog group - name: Add syslog group - aci_syslog_group: + cisco.aci.aci_syslog_group: <<: *aci_info name: ansible_syslog_group admin_state: enabled @@ -37,7 +37,7 @@ # ADD syslog source - name: Add syslog source - aci_syslog_source: + cisco.aci.aci_syslog_source: <<: *aci_info name: ansible_syslog_src min_severity: errors @@ -46,7 +46,7 @@ register: add_syslog_src - name: Verify that ansible_syslog_src has been created with correct attributes - assert: + ansible.builtin.assert: that: - add_syslog_src.current.0.syslogSrc.attributes.dn == "uni/fabric/moncommon/slsrc-ansible_syslog_src" - add_syslog_src.current.0.syslogSrc.attributes.name == "ansible_syslog_src" @@ -55,13 +55,13 @@ - add_syslog_src.current.0.syslogSrc.attributes.annotation == 'orchestrator:ansible' - name: Verify that ansible_syslog_src children have correct attributes - assert: + ansible.builtin.assert: that: - add_syslog_src.current.0.syslogSrc.children.0.syslogRsDestGroup.attributes.tDn == "uni/fabric/slgroup-ansible_syslog_group" # ADD syslog source again to check idempotency - name: Add syslog source - aci_syslog_source: + cisco.aci.aci_syslog_source: <<: *aci_info name: ansible_syslog_src min_severity: errors @@ -70,13 +70,13 @@ register: add_syslog_src_again - name: Verify that ansible_syslog_src stays the same - assert: + ansible.builtin.assert: that: - add_syslog_src_again is not changed # MODIFY syslog source - name: Update the syslog source - aci_syslog_source: + cisco.aci.aci_syslog_source: <<: *aci_info name: ansible_syslog_src include: @@ -89,7 +89,7 @@ register: update_syslog_src - name: Verify that ansible_syslog_src has been updated with correct attributes - assert: + ansible.builtin.assert: that: - update_syslog_src.current.0.syslogSrc.attributes.dn == "uni/fabric/moncommon/slsrc-ansible_syslog_src" - update_syslog_src.current.0.syslogSrc.attributes.name == "ansible_syslog_src" @@ -98,14 +98,14 @@ # QUERY syslog source - name: Query the syslog source - aci_syslog_source: + cisco.aci.aci_syslog_source: <<: *aci_info name: ansible_syslog_src state: query register: query_syslog_src - name: Verify the attributes under query_syslog_src - assert: + ansible.builtin.assert: that: - query_syslog_src is not changed - query_syslog_src.current.0.syslogSrc.attributes.dn == "uni/fabric/moncommon/slsrc-ansible_syslog_src" @@ -114,26 +114,26 @@ - query_syslog_src.current.0.syslogSrc.attributes.minSev == "information" - name: Query all syslog sources - aci_syslog_source: + cisco.aci.aci_syslog_source: <<: *aci_info state: query register: query_syslog_src_all - name: Verify query_syslog_src_all - assert: + ansible.builtin.assert: that: - query_syslog_src_all is not changed # DELETE syslog source - name: Remove the syslog source - aci_syslog_source: + cisco.aci.aci_syslog_source: <<: *aci_info name: ansible_syslog_src state: absent register: remove_syslog_src - name: Verify remove_syslog_src - assert: + ansible.builtin.assert: that: - remove_syslog_src is changed - remove_syslog_src.current == [] @@ -142,20 +142,20 @@ # DELETE syslog source again to test idempotence - name: Remove the syslog source - aci_syslog_source: + cisco.aci.aci_syslog_source: <<: *aci_info name: ansible_syslog_src state: absent register: remove_syslog_src_again - name: Verify remove_syslog_src idempotence - assert: + ansible.builtin.assert: that: - remove_syslog_src_again is not changed # DELETE syslog group - name: Remove syslog group - aci_syslog_group: + cisco.aci.aci_syslog_group: <<: *aci_info name: ansible_syslog_group admin_state: enabled diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_system/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_system/tasks/main.yml index 6be69c245..21555c224 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_system/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_system/tasks/main.yml @@ -4,13 +4,13 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined # CLEAN ENVIRONMENT - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: "{{ aci_hostname }}" username: "{{ aci_username }}" @@ -22,13 +22,13 @@ # QUERY OBJECTS - name: Query all controllers system information - aci_system: + cisco.aci.aci_system: <<: *aci_info state: query register: query_all - name: Verify query_all - assert: + ansible.builtin.assert: that: - query_all is not changed - query_all.current.0.topSystem.attributes.id == "1" @@ -36,28 +36,28 @@ - name: Query a specific controller system information - aci_system: + cisco.aci.aci_system: <<: *aci_info id: 1 state: query register: query_controller - name: Verify query_controller - assert: + ansible.builtin.assert: that: - query_controller is not changed - query_controller.current.0.topSystem.attributes.id == "1" - '"version" in query_controller.current.0.topSystem.attributes' - name: Query non_existing controller - aci_system: + cisco.aci.aci_system: <<: *aci_info id: 99 state: query register: query_non_existing - name: Verify query_non_existing - assert: + ansible.builtin.assert: that: - query_non_existing is not changed - query_non_existing.current == []
\ No newline at end of file diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_system_banner/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_system_banner/tasks/main.yml index 5b9cb96f0..7e750af42 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_system_banner/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_system_banner/tasks/main.yml @@ -5,12 +5,12 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: "{{ aci_hostname }}" username: "{{ aci_username }}" diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_system_endpoint_controls/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_system_endpoint_controls/tasks/main.yml index fa98657f6..8b480175d 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_system_endpoint_controls/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_system_endpoint_controls/tasks/main.yml @@ -4,12 +4,12 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: "{{ aci_hostname }}" username: "{{ aci_username }}" @@ -20,7 +20,7 @@ output_level: '{{ aci_output_level | default("info") }}' - name: Verify Cloud and Non-Cloud Sites in use. - include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml - name: Execute tasks only for non-cloud sites when: query_cloud.current == [] # This condition will skip execution for cloud sites diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_system_global_aes_passphrase_encryption/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_system_global_aes_passphrase_encryption/tasks/main.yml index 732a4d4f3..2fdebe23b 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_system_global_aes_passphrase_encryption/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_system_global_aes_passphrase_encryption/tasks/main.yml @@ -5,13 +5,13 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined # SET VARS - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: '{{ aci_hostname }}' username: '{{ aci_username }}' @@ -22,7 +22,7 @@ output_level: '{{ aci_output_level | default("info") }}' - name: Verify Cloud and Non-Cloud Sites in use. - include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml - name: Execute tasks only for non-cloud sites when: query_cloud.current == [] # This condition will skip execution for cloud sites diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_taboo_contract/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_taboo_contract/tasks/main.yml index 8a5bb5911..19304b8fe 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_taboo_contract/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_taboo_contract/tasks/main.yml @@ -52,7 +52,7 @@ register: nm_add_taboo_contract - name: Verify add_taboo_contract - assert: + ansible.builtin.assert: that: - cm_add_taboo_contract is changed - nm_add_taboo_contract is changed @@ -76,7 +76,7 @@ register: nm_add_taboo_contract_again - name: Verify add_taboo_contract_again - assert: + ansible.builtin.assert: that: - cm_add_taboo_contract_again is not changed - nm_add_taboo_contract_again is not changed @@ -98,7 +98,7 @@ register: nm_add_taboo_contract_descr - name: Verify add_taboo_contract_descr - assert: + ansible.builtin.assert: that: - cm_add_taboo_contract_descr is changed - nm_add_taboo_contract_descr is changed @@ -124,7 +124,7 @@ register: nm_add_taboo_contract_descr_again - name: Verify add_taboo_contract_descr_again - assert: + ansible.builtin.assert: that: - cm_add_taboo_contract_descr_again is not changed - nm_add_taboo_contract_descr_again is not changed @@ -142,7 +142,7 @@ register: nm_add_taboo_contract_again_no_descr - name: Verify add_taboo_contract_again_no_descr - assert: + ansible.builtin.assert: that: - cm_add_taboo_contract_again_no_descr is not changed - nm_add_taboo_contract_again_no_descr is not changed @@ -168,7 +168,7 @@ register: nm_query_all_taboo_contracts - name: Verify query_all_taboo_contracts - assert: + ansible.builtin.assert: that: - cm_query_all_taboo_contracts is not changed - nm_query_all_taboo_contracts is not changed @@ -193,7 +193,7 @@ register: nm_query_taboo_contract - name: Verify query_taboo_contract - assert: + ansible.builtin.assert: that: - cm_query_taboo_contract is not changed - nm_query_taboo_contract is not changed @@ -214,7 +214,7 @@ register: nm_remove_taboo_contract - name: Verify remove_taboo_contract - assert: + ansible.builtin.assert: that: - cm_remove_taboo_contract is changed - nm_remove_taboo_contract is changed @@ -233,7 +233,7 @@ register: nm_remove_taboo_contract_again - name: Verify remove_taboo_contract_again - assert: + ansible.builtin.assert: that: - cm_remove_taboo_contract_again is not changed - nm_remove_taboo_contract_again is not changed @@ -261,7 +261,7 @@ # TODO: Implement more tests - name: Verify query_non_taboo_contract - assert: + ansible.builtin.assert: that: - cm_query_non_taboo_contract is not changed - nm_query_non_taboo_contract is not changed @@ -284,7 +284,7 @@ register: error_on_missing_required_param - name: Verify error_on_missing_required_param - assert: + ansible.builtin.assert: that: - error_on_missing_required_param is failed - 'error_on_missing_required_param.msg == "state is present but all of the following are missing: tenant, taboo_contract"' diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_tag/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_tag/tasks/main.yml index e5a13ba7b..14d145dcf 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_tag/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_tag/tasks/main.yml @@ -4,12 +4,12 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: "{{ aci_hostname }}" username: "{{ aci_username }}" @@ -20,7 +20,7 @@ output_level: debug - name: Verify Cloud and Non-Cloud Sites in use. - include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml - name: Remove tenant to cleanup cisco.aci.aci_tenant: @@ -36,7 +36,7 @@ register: query_result - name: Get DN - set_fact: + ansible.builtin.set_fact: dn: "{{ query_result.current[0].fvTenant.attributes.dn }}" - name: Annotation Create tag (check_mode) @@ -57,7 +57,7 @@ register: nm_annotation_create - name: Annotation tag created - assert: + ansible.builtin.assert: that: - cm_annotation_create is changed - cm_annotation_create.proposed.tagAnnotation.attributes.value == "bar" @@ -79,7 +79,7 @@ register: nm_annotation_create_again - name: Annotation tag create again - assert: + ansible.builtin.assert: that: - cm_annotation_create_again is not changed - cm_annotation_create_again.current.0.tagAnnotation.attributes.key == "foo" @@ -95,7 +95,7 @@ register: annotation_query_result - name: Annotation tag query verification - assert: + ansible.builtin.assert: that: - annotation_query_result is not changed - annotation_query_result.current.0.tagAnnotation.attributes.key == "foo" @@ -110,12 +110,12 @@ register: annotation_query_all - name: Annotation tag query verification - assert: + ansible.builtin.assert: that: - annotation_query_all is not changed - name: Annotation tag query verification (continued) - assert: + ansible.builtin.assert: that: - annotation_query_all.current.0.tagAnnotation.attributes.key == "foo" - annotation_query_all.current.0.tagAnnotation.attributes.value == "bar" @@ -136,7 +136,7 @@ register: nm_annotation_delete - name: Annotation tag deleted - assert: + ansible.builtin.assert: that: - cm_annotation_delete is changed - nm_annotation_delete is changed @@ -161,7 +161,7 @@ register: nm_annotation_delete_again - name: Annotation tag deleted again - assert: + ansible.builtin.assert: that: - cm_annotation_delete_again is not changed - nm_annotation_delete_again is not changed @@ -187,7 +187,7 @@ register: nm_instance_create - name: Instance tag created - assert: + ansible.builtin.assert: that: - cm_instance_create is changed - nm_instance_create is changed @@ -207,7 +207,7 @@ register: nm_instance_create_again - name: Instance tag create again - assert: + ansible.builtin.assert: that: - cm_instance_create_again is not changed - cm_instance_create_again.current.0.tagInst.attributes.name == "foo" @@ -221,7 +221,7 @@ register: instance_query_result - name: Instance tag query verification - assert: + ansible.builtin.assert: that: - instance_query_result is not changed - instance_query_result.current.0.tagInst.attributes.name == "foo" @@ -235,12 +235,12 @@ register: instance_query_all - name: Instance tag query verification - assert: + ansible.builtin.assert: that: - instance_query_all is not changed - name: Instance tag query verification (continued) - assert: + ansible.builtin.assert: that: - instance_query_all.current.0.tagInst.attributes.name == "foo" when: query_cloud.current == [] # This condition will skip execution for cloud sites @@ -260,7 +260,7 @@ register: nm_instance_delete - name: Instance tag deleted - assert: + ansible.builtin.assert: that: - cm_instance_delete is changed - nm_instance_delete is changed @@ -283,7 +283,7 @@ register: nm_instance_delete_again - name: Instance tag deleted again - assert: + ansible.builtin.assert: that: - cm_instance_delete_again is not changed - nm_instance_delete_again is not changed @@ -310,7 +310,7 @@ register: nm_tag_create - name: Tag tag created - assert: + ansible.builtin.assert: that: - cm_tag_create is changed - cm_tag_create.proposed.tagTag.attributes.value == "bar" @@ -332,7 +332,7 @@ register: nm_tag_create_again - name: Tag tag create again - assert: + ansible.builtin.assert: that: - cm_tag_create_again is not changed - cm_tag_create_again.current.0.tagTag.attributes.key == "foo" @@ -348,7 +348,7 @@ register: tag_query_result - name: Tag tag query verification - assert: + ansible.builtin.assert: that: - tag_query_result is not changed - tag_query_result.current.0.tagTag.attributes.key == "foo" @@ -363,12 +363,12 @@ register: tag_query_all - name: Tag tag query verification - assert: + ansible.builtin.assert: that: - tag_query_all is not changed - name: Tag tag query verification (continued) - assert: + ansible.builtin.assert: that: - tag_query_all.current.0.tagTag.attributes.key == "foo" - tag_query_all.current.0.tagTag.attributes.value == "bar" @@ -389,7 +389,7 @@ register: nm_tag_delete - name: Tag tag deleted - assert: + ansible.builtin.assert: that: - cm_tag_delete is changed - nm_tag_delete is changed @@ -414,7 +414,7 @@ register: nm_tag_delete_again - name: Tag tag deleted again - assert: + ansible.builtin.assert: that: - cm_tag_delete_again is not changed - nm_tag_delete_again is not changed diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_tenant/tasks/httpapi_connection.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_tenant/tasks/httpapi_connection.yml index 214f55fe2..885ff3f9a 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_tenant/tasks/httpapi_connection.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_tenant/tasks/httpapi_connection.yml @@ -1,7 +1,7 @@ ## Tests HTTTP Connection when a list of host are provided - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: "{{ aci_hostname }}" username: "{{ aci_username }}" @@ -35,7 +35,7 @@ ansible_command_timeout: 5 - name: Run aci_aaa_user_certificate through the plugin - include_tasks: ../../../../../../integration/targets/aci_aaa_user_certificate/tasks/main.yml + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_aaa_user_certificate/tasks/main.yml - name: Add user certificate to be used later in the test cisco.aci.aci_aaa_user_certificate: @@ -103,7 +103,7 @@ no_username_flattened: "{{ no_username.httpapi_logs | flatten }}" - name: Verify XML operation and HTTP error returned by APIC - assert: + ansible.builtin.assert: that: - tenant_xml_plugin.status == 200 - '"Received response from {{ aci_hostname }} for POST operation with HTTP: 400" in ap_non_existent_tenant_flattened' @@ -160,7 +160,7 @@ op18_flattened_task_pwd_add_ap: "{{ op18_task_pwd_add_ap.httpapi_logs | flatten }}" - name: Verify forbidden error 403 - assert: + ansible.builtin.assert: that: - op17_task_pwd_add_tenant is changed - op18_task_pwd_add_ap is changed @@ -169,7 +169,7 @@ - '"Connection to {{ aci_hostname }} was successful" in op18_flattened_task_pwd_add_ap' - name: reset connection to test other scenarios - meta: reset_connection + ansible.builtin.meta: reset_connection # Precedence test - name: Delete Tenant with password and private key in the task (private_key takes precedence) @@ -246,7 +246,7 @@ op4_flattened_inventory_pwd_add_tenant: "{{ op4_inventory_pwd_add_tenant.httpapi_logs | flatten }}" - name: Verify Precedence - assert: + ansible.builtin.assert: that: - '"Provided Hosts: [''{{ aci_hostname }}'']" in op1_flattened_task_private_key_delete_tenant' - '"Initializing operation on {{ aci_hostname }}" in op1_flattened_task_private_key_delete_tenant' @@ -270,7 +270,7 @@ - '"Connection to {{ aci_hostname }} was successful" not in op4_flattened_inventory_pwd_add_tenant' - name: reset connection to test other scenarios - meta: reset_connection + ansible.builtin.meta: reset_connection # Switching of hosts test with the password in the task - name: Delete Tenant with only password in the task (Check for successful operation on the last host) @@ -295,7 +295,7 @@ op5_flattened_task_pwd_add_tenant: "{{ op5_task_pwd_add_tenant.httpapi_logs | flatten }}" - name: Verify switching of hosts with the password in the task - assert: + ansible.builtin.assert: that: - op5_task_pwd_delete_tenant is changed - op5_flattened_task_pwd_delete_tenant | regex_search('Switching host from [0-9]+(?:\.[0-9]+){3} to {{ aci_hostname }}') is not none @@ -327,7 +327,7 @@ op6_flattened_task_pwd_add_tenant: "{{ op6_task_pwd_add_tenant.httpapi_logs | flatten }}" - name: Verify continuation of the operations on the connected host with the password in the task - assert: + ansible.builtin.assert: that: - op6_task_pwd_delete_tenant is changed - '"Connected host {{ aci_hostname }} found in the provided hosts. Continuing with it." in op6_flattened_task_pwd_delete_tenant' @@ -353,7 +353,7 @@ register: op7_task_pwd_add_tenant - name: Verify failure when no hosts are active - assert: + ansible.builtin.assert: that: - op7_task_pwd_delete_tenant.error.text | regex_search('No hosts left in the cluster to continue operation! Error on final host [0-9]+(?:\.[0-9]+){3}') is not none - op7_task_pwd_add_tenant is not changed @@ -383,7 +383,7 @@ op8_flattened_inventory_pwd_add_tenant: "{{ op8_inventory_pwd_add_tenant.httpapi_logs | flatten }}" - name: Verify switching of hosts with the password in the inventory - assert: + ansible.builtin.assert: that: - op8_inventory_pwd_delete_tenant is changed - op8_flattened_inventory_pwd_delete_tenant | regex_search('Switching host from [0-9]+(?:\.[0-9]+){3} to {{ aci_hostname }}') is not none @@ -417,7 +417,7 @@ op9_flattened_inventory_pwd_add_tenant: "{{ op9_inventory_pwd_add_tenant.httpapi_logs | flatten }}" - name: Verify switching of hosts with the password in the inventory - assert: + ansible.builtin.assert: that: - op9_inventory_pwd_delete_tenant is changed - op9_flattened_inventory_pwd_delete_tenant | regex_search('Switching host from [0-9]+(?:\.[0-9]+){3} to {{ aci_hostname }}') is not none @@ -440,7 +440,7 @@ ignore_errors: True - name: Verify failure when no hosts are active in the inventory - assert: + ansible.builtin.assert: that: - op10_inventory_pwd_delete_tenant.error.text | regex_search('No hosts left in the cluster to continue operation! Error on final host [0-9]+(?:\.[0-9]+){3}') is not none @@ -469,7 +469,7 @@ op11_flattened_task_private_key_add_tenant: "{{ op11_task_private_key_add_tenant.httpapi_logs | flatten }}" - name: Verify switching of hosts with the private key in the task - assert: + ansible.builtin.assert: that: - op11_task_private_key_delete_tenant is changed - op11_flattened_task_private_key_delete_tenant | regex_search('Switching host from [0-9]+(?:\.[0-9]+){3} to {{ aci_hostname }}') is not none @@ -503,7 +503,7 @@ op12_flattened_task_private_key_add_tenant: "{{ op12_task_private_key_add_tenant.httpapi_logs | flatten }}" - name: Verify continuation of the operations on the connected host with the password in the task - assert: + ansible.builtin.assert: that: - op12_task_private_key_delete_tenant is changed - '"Connected host {{ aci_hostname }} found in the provided hosts. Continuing with it." in op12_flattened_task_private_key_delete_tenant' @@ -531,7 +531,7 @@ register: op13_task_private_key_add_tenant - name: Verify failure when no hosts are active in the task - assert: + ansible.builtin.assert: that: - op13_task_private_key_delete_tenant.error.text | regex_search('No hosts left in the cluster to continue operation! Error on final host [0-9]+(?:\.[0-9]+){3}') is not none - op13_task_private_key_add_tenant is not changed @@ -562,7 +562,7 @@ op14_flattened_inventory_session_key_add_tenant: "{{ op14_inventory_session_key_add_tenant.httpapi_logs | flatten }}" - name: Verify switching of hosts with the session key in the inventory - assert: + ansible.builtin.assert: that: - op14_inventory_session_key_delete_tenant is changed - op14_flattened_inventory_session_key_delete_tenant | regex_search('Switching host from [0-9]+(?:\.[0-9]+){3} to {{ aci_hostname }}') is not none @@ -596,7 +596,7 @@ op15_flattened_inventory_session_key_add_tenant: "{{ op15_inventory_session_key_add_tenant.httpapi_logs | flatten }}" - name: Verify switching of hosts with the session key in the inventory - assert: + ansible.builtin.assert: that: - op15_inventory_session_key_delete_tenant is changed - op15_flattened_inventory_session_key_delete_tenant | regex_search('Switching host from [0-9]+(?:\.[0-9]+){3} to {{ aci_hostname }}') is not none @@ -619,7 +619,7 @@ ignore_errors: True - name: Verify failure when no hosts are active in the inventory - assert: + ansible.builtin.assert: that: - op16_inventory_session_key_delete_tenant.error.text | regex_search('No hosts left in the cluster to continue operation! Error on final host [0-9]+(?:\.[0-9]+){3}') is not none diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_tenant/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_tenant/tasks/main.yml index b8a7a310f..4208676ca 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_tenant/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_tenant/tasks/main.yml @@ -1,11 +1,12 @@ # Test code for the ACI modules # Copyright: (c) 2017, Dag Wieers (@dagwieers) <dag@wieers.com> # Copyright: (c) 2020, Lionel Hercot (@lhercot) <lhercot@cisco.com> +# Copyright: (c) 2024, Samita Bhattacharjee (@samiib) <samitab@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 APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined @@ -13,7 +14,7 @@ tags: httpapi_connection - name: Delete old log files to clean test directory - file: + ansible.builtin.file: path: "{{ item }}" state: absent with_items: @@ -63,7 +64,7 @@ register: cm_add_tenant - name: Dump content of files - debug: + ansible.builtin.debug: msg: "{{ lookup('file', aci_hostname +'_cm_add_tenant.json')}}" - name: Add tenant (normal mode) @@ -86,19 +87,19 @@ register: nm_add_tenant_again - name: Dump content of files - debug: + ansible.builtin.debug: msg: "{{ lookup('file', aci_hostname + '_cm_add_tenant.json')}}" - name: Store file content on variables for create object - set_fact: + ansible.builtin.set_fact: fc_cm_add_tenant: "{{ lookup('file', aci_hostname + '_cm_add_tenant.json') | from_json }}" fc_nm_add_tenant: "{{ lookup('file', aci_hostname + '_nm_add_tenant.json') | from_json }}" fc_cm_add_tenant_again: "{{ lookup('file', aci_hostname + '_cm_add_tenant_again.json') }}" fc_nm_add_tenant_again: "{{ lookup('file', aci_hostname + '_nm_add_tenant_again.json') }}" - name: Log file content verification for create object - assert: + ansible.builtin.assert: that: - fc_cm_add_tenant.0.fvTenant.attributes.name == 'ansible_test' - fc_cm_add_tenant.0.fvTenant.attributes.dn == 'uni/tn-ansible_test' @@ -108,7 +109,7 @@ - fc_nm_add_tenant_again == '' - name: Verify add_tenant - assert: + ansible.builtin.assert: that: - cm_add_tenant is changed - nm_add_tenant is changed @@ -165,14 +166,14 @@ register: nm_add_tenant_descr_again - name: Store file content on variables for update object - set_fact: + ansible.builtin.set_fact: fc_cm_add_tenant_descr: "{{ lookup('file', aci_hostname + '_cm_add_tenant_descr.json') | from_json }}" fc_nm_add_tenant_descr: "{{ lookup('file', aci_hostname + '_nm_add_tenant_descr.json') | from_json }}" fc_cm_add_tenant_descr_again: "{{ lookup('file', aci_hostname + '_cm_add_tenant_descr_again.json') }}" fc_nm_add_tenant_descr_again: "{{ lookup('file', aci_hostname + '_nm_add_tenant_descr_again.json') }}" - name: Log file content verification for update object - assert: + ansible.builtin.assert: that: - fc_cm_add_tenant_descr.0.fvTenant.attributes.descr == 'Ansible test tenant' - fc_nm_add_tenant_descr.0.fvTenant.attributes.descr == 'Ansible test tenant' @@ -180,7 +181,7 @@ - fc_nm_add_tenant_descr_again == '' - name: Verify add_tenant_descr - assert: + ansible.builtin.assert: that: - cm_add_tenant_descr is changed - nm_add_tenant_descr is changed @@ -219,11 +220,80 @@ register: nm_add_tenant_again_no_descr - name: Verify add_tenant_again_no_descr - assert: + ansible.builtin.assert: that: - cm_add_tenant_again_no_descr is not changed - nm_add_tenant_again_no_descr is not changed +# TEST NO VERIFICATION +- name: Create tenant with no verification (check mode) + cisco.aci.aci_tenant: &aci_tenant_no_verify + <<: *tenant_present + tenant: anstest-no-verify + description: Ansible Test + no_verification: true + check_mode: true + register: tenant_present_no_verify_cm + +- name: Create tenant with no verification + cisco.aci.aci_tenant: + <<: *aci_tenant_no_verify + register: tenant_present_no_verify + +- name: Create tenant with no verification again + cisco.aci.aci_tenant: + <<: *aci_tenant_no_verify + register: tenant_present_no_verify_again + +- name: Update tenant with no verification + cisco.aci.aci_tenant: + <<: *aci_tenant_no_verify + description: Ansible Test No Verify + register: update_tenant_present_no_verify + +- name: Delete tenant with no verification + cisco.aci.aci_tenant: + <<: *aci_tenant_no_verify + state: absent + register: delete_tenant_present_no_verify + +- name: Delete tenant with no verification again + cisco.aci.aci_tenant: + <<: *aci_tenant_no_verify + state: absent + register: delete_tenant_present_no_verify_again + +- name: No verification asserts + ansible.builtin.assert: + that: + - tenant_present_no_verify_cm is changed + - tenant_present_no_verify_cm.current_verified == false + - tenant_present_no_verify_cm.current.0 == tenant_present_no_verify_cm.proposed + - tenant_present_no_verify is changed + - tenant_present_no_verify.current_verified == false + - tenant_present_no_verify.current.0 == tenant_present_no_verify.proposed + - tenant_present_no_verify.previous == [] + - tenant_present_no_verify_again is not changed + - tenant_present_no_verify_again.current_verified == true + - tenant_present_no_verify_again.current.0.fvTenant.attributes.name == "anstest-no-verify" + - tenant_present_no_verify_again.current.0.fvTenant.attributes.descr == "Ansible Test" + - tenant_present_no_verify_again.previous.0.fvTenant.attributes.name == "anstest-no-verify" + - tenant_present_no_verify_again.previous.0.fvTenant.attributes.descr == "Ansible Test" + - update_tenant_present_no_verify is changed + - update_tenant_present_no_verify.current_verified == false + - update_tenant_present_no_verify.current.0 == update_tenant_present_no_verify.proposed + - update_tenant_present_no_verify.previous.0.fvTenant.attributes.name == "anstest-no-verify" + - update_tenant_present_no_verify.previous.0.fvTenant.attributes.descr == "Ansible Test" + - delete_tenant_present_no_verify is changed + - delete_tenant_present_no_verify.current_verified == false + - delete_tenant_present_no_verify.current.0 == delete_tenant_present_no_verify.proposed + - delete_tenant_present_no_verify.previous.0.fvTenant.attributes.name == "anstest-no-verify" + - delete_tenant_present_no_verify.previous.0.fvTenant.attributes.descr == "Ansible Test No Verify" + - delete_tenant_present_no_verify_again is not changed + - delete_tenant_present_no_verify_again.current_verified == true + - delete_tenant_present_no_verify_again.current == [] + - delete_tenant_present_no_verify_again.previous == [] + - delete_tenant_present_no_verify_again.proposed == {} # QUERY ALL TENANTS - name: Query all tenants (check_mode) @@ -244,7 +314,7 @@ register: nm_query_all_tenants - name: Verify query_all_tenants - assert: + ansible.builtin.assert: that: - cm_query_all_tenants is not changed - nm_query_all_tenants is not changed @@ -267,7 +337,7 @@ register: nm_query_tenant - name: Verify query_tenant - assert: + ansible.builtin.assert: that: - cm_query_tenant is not changed - nm_query_tenant is not changed @@ -287,7 +357,7 @@ register: default_annotation - name: Assertion check for update tenant with default annotation - assert: + ansible.builtin.assert: that: - default_annotation is changed - default_annotation.current.0.fvTenant.attributes.annotation == 'orchestrator:ansible' @@ -320,14 +390,14 @@ register: nm_remove_tenant_again - name: Store file content on variables for delete object - set_fact: + ansible.builtin.set_fact: fc_cm_remove_tenant: "{{ lookup('file', aci_hostname + '_cm_remove_tenant.json') | from_json }}" fc_nm_remove_tenant: "{{ lookup('file', aci_hostname + '_nm_remove_tenant.json') | from_json }}" fc_cm_remove_tenant_again: "{{ lookup('file', aci_hostname + '_cm_remove_tenant_again.json') }}" fc_nm_remove_tenant_again: "{{ lookup('file', aci_hostname + '_nm_remove_tenant_again.json') }}" - name: Log file content verification for delete object - assert: + ansible.builtin.assert: that: - fc_cm_remove_tenant.0.fvTenant.attributes.status == 'deleted' - fc_cm_remove_tenant.0.fvTenant.attributes.dn == 'uni/tn-ansible_test' @@ -336,7 +406,7 @@ - fc_nm_remove_tenant_again == '' - name: Verify remove_tenant - assert: + ansible.builtin.assert: that: - cm_remove_tenant is changed - nm_remove_tenant is changed @@ -360,7 +430,7 @@ # TODO: Implement more tests - name: Verify query_non_tenant - assert: + ansible.builtin.assert: that: - cm_query_non_tenant is not changed - nm_query_non_tenant is not changed diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_tenant_action_rule_profile/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_tenant_action_rule_profile/tasks/main.yml index b993b0e33..7531863e0 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_tenant_action_rule_profile/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_tenant_action_rule_profile/tasks/main.yml @@ -1,15 +1,17 @@ # Test code for the ACI modules +# Copyright: (c) 2023, Dag Wieers (@dagwieers) +# Copyright: (c) 2023, Tim Cragg (@timcragg) <tcragg@cisco.com> # Copyright: (c) 2023, Gaspard Micol (@gmicol) <gmicol@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 APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: "{{ aci_hostname }}" username: "{{ aci_username }}" @@ -19,115 +21,266 @@ use_proxy: '{{ aci_use_proxy | default(true) }}' output_level: debug +# CLEAN ENVIRONMENT +- name: Remove the ansible_tenant + cisco.aci.aci_tenant: &aci_tenant_absent + <<: *aci_info + tenant: ansible_tenant + state: absent + - name: Verify Cloud and Non-Cloud Sites in use. - include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml - name: Execute tasks only for non-cloud sites when: query_cloud.current == [] # This condition will execute only non-cloud sites block: # block specifies execution of tasks within, based on conditions - # Clean Environment - name: create tenant - aci_tenant: &aci_tenant_present + cisco.aci.aci_tenant: &aci_tenant_present <<: *aci_info tenant: ansible_test state: present - name: Ensure first action rule profile does not exist - aci_tenant_action_rule_profile: &aci_tenant_action_rule_profile_absent + cisco.aci.aci_tenant_action_rule_profile: &aci_tenant_action_rule_profile_absent <<: *aci_tenant_present name: anstest description: test for action rule profile + set_preference: 100 + set_route_tag: 100 + set_weight: 100 + set_metric: 100 + set_metric_type: ospf_type_1 + set_next_hop: 1.1.1.1 + set_community: + community: no-advertise + criteria: replace + set_dampening: + half_life: 10 + reuse: 1 + suppress: 10 + max_suppress_time: 100 state: absent - - name: Ensure second action rule profile does not exist - aci_tenant_action_rule_profile: &aci_tenant_action_rule_profile_2_absent + - name: Ensure second action rule profile does not exist - APIC version >= 5.0 + when: version.current.0.topSystem.attributes.version is version('5', '>=') + cisco.aci.aci_tenant_action_rule_profile: &aci_tenant_action_rule_profile_2_5_absent + <<: *aci_tenant_present + name: anstest_2 + set_next_hop: 1.1.1.2 + next_hop_propagation: true + multipath: true + state: absent + + - name: Ensure second action rule profile does not exist - APIC version < 5.0 + when: version.current.0.topSystem.attributes.version is version('5', '<') + cisco.aci.aci_tenant_action_rule_profile: &aci_tenant_action_rule_profile_2_absent <<: *aci_tenant_present name: anstest_2 + set_next_hop: 1.1.1.2 state: absent - name: Create first action rule profile (check_mode) - aci_tenant_action_rule_profile: &aci_tenant_action_rule_profile_present + cisco.aci.aci_tenant_action_rule_profile: &aci_tenant_action_rule_profile_present <<: *aci_tenant_action_rule_profile_absent state: present check_mode: true register: cm_add_tenant_action_rule_profile_1 - name: Create first action rule profile (normal_mode) - aci_tenant_action_rule_profile: + cisco.aci.aci_tenant_action_rule_profile: <<: *aci_tenant_action_rule_profile_present register: nm_add_tenant_action_rule_profile_1 - name: Create first action rule profile again - testing idempotency - aci_tenant_action_rule_profile: + cisco.aci.aci_tenant_action_rule_profile: <<: *aci_tenant_action_rule_profile_present register: idempotency_add_tenant_action_rule_profile_1 - - name: Create second action rule profile - aci_tenant_action_rule_profile: &aci_tenant_action_rule_profile_2_present + - name: Create second action rule profile - APIC version >= 5.0 + when: version.current.0.topSystem.attributes.version is version('5', '>=') + cisco.aci.aci_tenant_action_rule_profile: &aci_tenant_action_rule_profile_2_5_present + <<: *aci_tenant_action_rule_profile_2_5_absent + state: present + register: nm_add_tenant_action_rule_profile_2_5 + + - name: Create second action rule profile - APIC version < 5.0 + when: version.current.0.topSystem.attributes.version is version('5', '<') + cisco.aci.aci_tenant_action_rule_profile: &aci_tenant_action_rule_profile_2_present <<: *aci_tenant_action_rule_profile_2_absent state: present register: nm_add_tenant_action_rule_profile_2 - - name: Asserts for creation tasks - assert: + - name: Asserts for creation tasks for action rule profile 1 + ansible.builtin.assert: that: - cm_add_tenant_action_rule_profile_1 is changed - cm_add_tenant_action_rule_profile_1.previous == [] - cm_add_tenant_action_rule_profile_1.current == [] - nm_add_tenant_action_rule_profile_1 is changed - nm_add_tenant_action_rule_profile_1.current.0.rtctrlAttrP.attributes.name == "anstest" + - nm_add_tenant_action_rule_profile_1.current.0.rtctrlAttrP.children.0.rtctrlSetWeight.attributes.weight == "100" + - nm_add_tenant_action_rule_profile_1.current.0.rtctrlAttrP.children.1.rtctrlSetDamp.attributes.halfLife == "10" + - nm_add_tenant_action_rule_profile_1.current.0.rtctrlAttrP.children.1.rtctrlSetDamp.attributes.maxSuppressTime == "100" + - nm_add_tenant_action_rule_profile_1.current.0.rtctrlAttrP.children.1.rtctrlSetDamp.attributes.reuse == "1" + - nm_add_tenant_action_rule_profile_1.current.0.rtctrlAttrP.children.1.rtctrlSetDamp.attributes.suppress == "10" + - nm_add_tenant_action_rule_profile_1.current.0.rtctrlAttrP.children.2.rtctrlSetRtMetricType.attributes.metricType == "ospf-type1" + - nm_add_tenant_action_rule_profile_1.current.0.rtctrlAttrP.children.3.rtctrlSetNh.attributes.addr == "1.1.1.1" + - nm_add_tenant_action_rule_profile_1.current.0.rtctrlAttrP.children.4.rtctrlSetPref.attributes.localPref == "100" + - nm_add_tenant_action_rule_profile_1.current.0.rtctrlAttrP.children.5.rtctrlSetRtMetric.attributes.metric == "100" + - nm_add_tenant_action_rule_profile_1.current.0.rtctrlAttrP.children.6.rtctrlSetComm.attributes.community == "no-advertise" + - nm_add_tenant_action_rule_profile_1.current.0.rtctrlAttrP.children.6.rtctrlSetComm.attributes.setCriteria == "replace" + - nm_add_tenant_action_rule_profile_1.current.0.rtctrlAttrP.children.7.rtctrlSetTag.attributes.tag == "100" - idempotency_add_tenant_action_rule_profile_1 is not changed + + - name: Asserts for creation tasks for action rule profile 2 - APIC version >= 5.0 + when: version.current.0.topSystem.attributes.version is version('5', '>=') + ansible.builtin.assert: + that: + - nm_add_tenant_action_rule_profile_2_5 is changed + - nm_add_tenant_action_rule_profile_2_5.current.0.rtctrlAttrP.attributes.name == "anstest_2" + - nm_add_tenant_action_rule_profile_2_5.current.0.rtctrlAttrP.children.0.rtctrlSetRedistMultipath.attributes.descr == "" + - nm_add_tenant_action_rule_profile_2_5.current.0.rtctrlAttrP.children.1.rtctrlSetNhUnchanged.attributes.descr == "" + - nm_add_tenant_action_rule_profile_2_5.current.0.rtctrlAttrP.children.2.rtctrlSetNh.attributes.addr == "1.1.1.2" + + - name: Asserts for creation tasks for action rule profile 2 - APIC version < 5.0 + when: version.current.0.topSystem.attributes.version is version('5', '<') + ansible.builtin.assert: + that: - nm_add_tenant_action_rule_profile_2 is changed - nm_add_tenant_action_rule_profile_2.current.0.rtctrlAttrP.attributes.name == "anstest_2" + - nm_add_tenant_action_rule_profile_2.current.0.rtctrlAttrP.children.0.rtctrlSetNh.attributes.addr == "1.1.1.2" - name: Query all action rule profiles - aci_tenant_action_rule_profile: + cisco.aci.aci_tenant_action_rule_profile: <<: *aci_info state: query register: query_all_tenant_action_rule_profile - name: Query first action rule profile - aci_tenant_action_rule_profile: + cisco.aci.aci_tenant_action_rule_profile: <<: *aci_tenant_action_rule_profile_present state: query register: query_first_tenant_action_rule_profile - name: Asserts for query tasks - assert: + ansible.builtin.assert: that: - query_all_tenant_action_rule_profile is not changed - query_all_tenant_action_rule_profile.current | length >= 2 - '"class/rtctrlAttrP.json" in query_all_tenant_action_rule_profile.url' - query_first_tenant_action_rule_profile is not changed - query_first_tenant_action_rule_profile.current.0.rtctrlAttrP.attributes.name == "anstest" + - query_first_tenant_action_rule_profile.current.0.rtctrlAttrP.children.0.rtctrlSetWeight.attributes.weight == "100" + - query_first_tenant_action_rule_profile.current.0.rtctrlAttrP.children.1.rtctrlSetDamp.attributes.halfLife == "10" + - query_first_tenant_action_rule_profile.current.0.rtctrlAttrP.children.1.rtctrlSetDamp.attributes.maxSuppressTime == "100" + - query_first_tenant_action_rule_profile.current.0.rtctrlAttrP.children.1.rtctrlSetDamp.attributes.reuse == "1" + - query_first_tenant_action_rule_profile.current.0.rtctrlAttrP.children.1.rtctrlSetDamp.attributes.suppress == "10" + - query_first_tenant_action_rule_profile.current.0.rtctrlAttrP.children.2.rtctrlSetRtMetricType.attributes.metricType == "ospf-type1" + - query_first_tenant_action_rule_profile.current.0.rtctrlAttrP.children.3.rtctrlSetNh.attributes.addr == "1.1.1.1" + - query_first_tenant_action_rule_profile.current.0.rtctrlAttrP.children.4.rtctrlSetPref.attributes.localPref == "100" + - query_first_tenant_action_rule_profile.current.0.rtctrlAttrP.children.5.rtctrlSetRtMetric.attributes.metric == "100" + - query_first_tenant_action_rule_profile.current.0.rtctrlAttrP.children.6.rtctrlSetComm.attributes.community == "no-advertise" + - query_first_tenant_action_rule_profile.current.0.rtctrlAttrP.children.6.rtctrlSetComm.attributes.setCriteria == "replace" + - query_first_tenant_action_rule_profile.current.0.rtctrlAttrP.children.7.rtctrlSetTag.attributes.tag == "100" + + - name: Delete children for first action rule profile (check_mode) + cisco.aci.aci_tenant_action_rule_profile: &aci_tenant_action_rule_profile_children_deleted + <<: *aci_tenant_action_rule_profile_present + set_preference: "" + set_route_tag: "" + set_weight: "" + set_metric: "" + set_metric_type: "" + set_next_hop: "" + set_community: {} + set_dampening: {} + check_mode: true + register: cm_delete_children_tenant_action_rule_profile_1 + + - name: Delete children for first action rule profile (normal_mode) + cisco.aci.aci_tenant_action_rule_profile: + <<: *aci_tenant_action_rule_profile_children_deleted + register: nm_delete_children_tenant_action_rule_profile_1 + + - name: Delete children for first action rule profile again - testing idempotency + cisco.aci.aci_tenant_action_rule_profile: + <<: *aci_tenant_action_rule_profile_children_deleted + register: idempotency_delete_children_tenant_action_rule_profile_1 + + - name: Delete children for second action rule profile - APIC version >= 5.0 + when: version.current.0.topSystem.attributes.version is version('5', '>=') + cisco.aci.aci_tenant_action_rule_profile: + <<: *aci_tenant_action_rule_profile_2_5_present + set_next_hop: "" + next_hop_propagation: false + multipath: false + register: nm_delete_children_tenant_action_rule_profile_2_5 + + - name: Delete children for second action rule profile - APIC version < 5.0 + when: version.current.0.topSystem.attributes.version is version('5', '<') + cisco.aci.aci_tenant_action_rule_profile: + <<: *aci_tenant_action_rule_profile_2_present + set_next_hop: "" + register: nm_delete_children_tenant_action_rule_profile_2 + + - name: Asserts for deletion tasks for action rule profile 1 + ansible.builtin.assert: + that: + - cm_delete_children_tenant_action_rule_profile_1 is changed + - cm_delete_children_tenant_action_rule_profile_1.current == cm_delete_children_tenant_action_rule_profile_1.previous + - nm_delete_children_tenant_action_rule_profile_1 is changed + - nm_delete_children_tenant_action_rule_profile_1.current.0.rtctrlAttrP | length == 1 + - idempotency_delete_children_tenant_action_rule_profile_1 is not changed + + - name: Asserts for deletion tasks for action rule profile 2 - APIC version >= 5.0 + when: version.current.0.topSystem.attributes.version is version('5', '>=') + ansible.builtin.assert: + that: + - nm_delete_children_tenant_action_rule_profile_2_5 is changed + - nm_delete_children_tenant_action_rule_profile_2_5.current.0.rtctrlAttrP | length == 1 + + - name: Asserts for deletion tasks for action rule profile 2 - APIC version < 5.0 + when: version.current.0.topSystem.attributes.version is version('5', '<') + ansible.builtin.assert: + that: + - nm_delete_children_tenant_action_rule_profile_2 is changed + - nm_delete_children_tenant_action_rule_profile_2.current.0.rtctrlAttrP | length == 1 - name: Delete first action rule profile (check_mode) - aci_tenant_action_rule_profile: + cisco.aci.aci_tenant_action_rule_profile: <<: *aci_tenant_action_rule_profile_present state: absent check_mode: true register: cm_delete_tenant_action_rule_profile_1 - name: Delete first action rule profile (normal_mode) - aci_tenant_action_rule_profile: + cisco.aci.aci_tenant_action_rule_profile: <<: *aci_tenant_action_rule_profile_present state: absent register: nm_delete_tenant_action_rule_profile_1 - name: Delete first action rule profile again - testing idempotency - aci_tenant_action_rule_profile: + cisco.aci.aci_tenant_action_rule_profile: <<: *aci_tenant_action_rule_profile_present state: absent register: idempotency_delete_tenant_action_rule_profile_1 - - name: Delete second action rule profile (normal_mode) - aci_tenant_action_rule_profile: + - name: Delete second action rule profile - APIC version >= 5.0 + when: version.current.0.topSystem.attributes.version is version('5', '>=') + cisco.aci.aci_tenant_action_rule_profile: + <<: *aci_tenant_action_rule_profile_2_5_present + state: absent + register: nm_delete_tenant_action_rule_profile_2_5 + + - name: Delete second action rule profile - APIC version < 5.0 + when: version.current.0.topSystem.attributes.version is version('5', '<') + cisco.aci.aci_tenant_action_rule_profile: <<: *aci_tenant_action_rule_profile_2_present state: absent register: nm_delete_tenant_action_rule_profile_2 - - name: Asserts for deletion tasks - assert: + - name: Asserts for deletion tasks for action rule profile 1 + ansible.builtin.assert: that: - cm_delete_tenant_action_rule_profile_1 is changed - cm_delete_tenant_action_rule_profile_1.proposed == {} @@ -136,11 +289,24 @@ - nm_delete_tenant_action_rule_profile_1.current == [] - idempotency_delete_tenant_action_rule_profile_1 is not changed - idempotency_delete_tenant_action_rule_profile_1.previous == [] + + - name: Asserts for deletion tasks for action rule profile 2 - APIC version >= 5.0 + when: version.current.0.topSystem.attributes.version is version('5', '>=') + ansible.builtin.assert: + that: + - nm_delete_tenant_action_rule_profile_2_5 is changed + - nm_delete_tenant_action_rule_profile_2_5.previous != [] + - nm_delete_tenant_action_rule_profile_2_5.current == [] + + - name: Asserts for deletion tasks for action rule profile 2 - APIC version < 5.0 + when: version.current.0.topSystem.attributes.version is version('5', '<') + ansible.builtin.assert: + that: - nm_delete_tenant_action_rule_profile_2 is changed - nm_delete_tenant_action_rule_profile_2.previous != [] - nm_delete_tenant_action_rule_profile_2.current == [] - - name: Delete tenant - clean up the environment - aci_tenant: + - name: Delete tenant - cleanup before ending tests + cisco.aci.aci_tenant: <<: *aci_tenant_present state: absent
\ No newline at end of file diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_tenant_ep_retention_policy/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_tenant_ep_retention_policy/tasks/main.yml index 96ba34077..29b45938f 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_tenant_ep_retention_policy/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_tenant_ep_retention_policy/tasks/main.yml @@ -4,12 +4,12 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: "{{ aci_hostname }}" username: "{{ aci_username }}" @@ -20,20 +20,20 @@ output_level: debug - name: Verify Cloud and Non-Cloud Sites in use. - include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml - name: Execute tasks only for non-cloud sites when: query_cloud.current == [] # This condition will execute only non-cloud sites block: # block specifies execution of tasks within, based on conditions # Clean Environment - name: create tenant - aci_tenant: &aci_tenant_present + cisco.aci.aci_tenant: &aci_tenant_present <<: *aci_info tenant: ansible_test state: present - name: Ensure first EP retention protocol policy does not exist - aci_tenant_ep_retention_policy: &aci_tenant_ep_retention_policy_absent + cisco.aci.aci_tenant_ep_retention_policy: &aci_tenant_ep_retention_policy_absent <<: *aci_tenant_present name: ep_policy_anstest description: test for EP retention protocol policy @@ -46,7 +46,7 @@ state: absent - name: Ensure second EP retention protocol policy does not exist - aci_tenant_ep_retention_policy: &aci_tenant_ep_retention_policy_2_absent + cisco.aci.aci_tenant_ep_retention_policy: &aci_tenant_ep_retention_policy_2_absent <<: *aci_tenant_present name: ep_policy_anstest_2 bounce_age: 0 @@ -56,65 +56,65 @@ state: absent - name: Create first EP retention protocol policy (check_mode) - aci_tenant_ep_retention_policy: &aci_tenant_ep_retention_policy_present + cisco.aci.aci_tenant_ep_retention_policy: &aci_tenant_ep_retention_policy_present <<: *aci_tenant_ep_retention_policy_absent state: present check_mode: true register: cm_add_tenant_ep_retention_policy_1 - name: Create first EP retention protocol policy (normal_mode) - aci_tenant_ep_retention_policy: + cisco.aci.aci_tenant_ep_retention_policy: <<: *aci_tenant_ep_retention_policy_present register: nm_add_tenant_ep_retention_policy_1 - name: Create first EP retention protocol policy again - testing idempotency - aci_tenant_ep_retention_policy: + cisco.aci.aci_tenant_ep_retention_policy: <<: *aci_tenant_ep_retention_policy_present register: idempotency_add_tenant_ep_retention_policy_1 - name: Create second EP retention protocol policy - aci_tenant_ep_retention_policy: &aci_tenant_ep_retention_policy_2_present + cisco.aci.aci_tenant_ep_retention_policy: &aci_tenant_ep_retention_policy_2_present <<: *aci_tenant_ep_retention_policy_2_absent state: present register: nm_add_tenant_ep_retention_policy_2 - name: Modify EP retention protocol policy bounce age - testing failure message - aci_tenant_ep_retention_policy: + cisco.aci.aci_tenant_ep_retention_policy: <<: *aci_tenant_ep_retention_policy_present bounce_age: 100 ignore_errors: true register: Modify_tenant_ep_retention_policy_bounce_age - name: Modify EP retention protocol policy hold interval - testing failure message - aci_tenant_ep_retention_policy: + cisco.aci.aci_tenant_ep_retention_policy: <<: *aci_tenant_ep_retention_policy_present hold_interval: 4 ignore_errors: true register: Modify_tenant_ep_retention_policy_hold_interval - name: Modify EP retention protocol policy move frequency - testing failure message - aci_tenant_ep_retention_policy: + cisco.aci.aci_tenant_ep_retention_policy: <<: *aci_tenant_ep_retention_policy_present move_frequency: 65540 ignore_errors: true register: Modify_tenant_ep_retention_policy_move_frequency - name: Modify EP retention protocol policy local ep interval - testing failure message - aci_tenant_ep_retention_policy: + cisco.aci.aci_tenant_ep_retention_policy: <<: *aci_tenant_ep_retention_policy_present local_ep_interval: 119 ignore_errors: true register: Modify_tenant_ep_retention_policy_local_ep_interval - name: Modify EP retention protocol policy remote ep interval - testing failure message - aci_tenant_ep_retention_policy: + cisco.aci.aci_tenant_ep_retention_policy: <<: *aci_tenant_ep_retention_policy_present remote_ep_interval: 119 ignore_errors: true register: Modify_tenant_ep_retention_policy_remote_ep_interval - name: Asserts for creation tasks - assert: + ansible.builtin.assert: that: - cm_add_tenant_ep_retention_policy_1 is changed - cm_add_tenant_ep_retention_policy_1.previous == [] @@ -143,19 +143,19 @@ - Modify_tenant_ep_retention_policy_remote_ep_interval.msg == "The remote_ep_interval must be a value of 0 or between 120 and 65535" - name: Query all EP retention protocol policies - aci_tenant_ep_retention_policy: + cisco.aci.aci_tenant_ep_retention_policy: <<: *aci_info state: query register: query_all_tenant_ep_retention_policy - name: Query first EP retention protocol policy - aci_tenant_ep_retention_policy: + cisco.aci.aci_tenant_ep_retention_policy: <<: *aci_tenant_ep_retention_policy_present state: query register: query_first_tenant_ep_retention_policy - name: Asserts for query tasks - assert: + ansible.builtin.assert: that: - query_all_tenant_ep_retention_policy is not changed - query_all_tenant_ep_retention_policy.current | length >= 2 @@ -170,32 +170,32 @@ - query_first_tenant_ep_retention_policy.current.0.fvEpRetPol.attributes.remoteEpAgeIntvl == "600" - name: Delete first EP retention protocol policy (check_mode) - aci_tenant_ep_retention_policy: + cisco.aci.aci_tenant_ep_retention_policy: <<: *aci_tenant_ep_retention_policy_present state: absent check_mode: true register: cm_delete_tenant_ep_retention_policy_1 - name: Delete first EP retention protocol policy (normal_mode) - aci_tenant_ep_retention_policy: + cisco.aci.aci_tenant_ep_retention_policy: <<: *aci_tenant_ep_retention_policy_present state: absent register: nm_delete_tenant_ep_retention_policy_1 - name: Delete first EP retention protocol policy again - testing idempotency - aci_tenant_ep_retention_policy: + cisco.aci.aci_tenant_ep_retention_policy: <<: *aci_tenant_ep_retention_policy_present state: absent register: idempotency_delete_tenant_ep_retention_policy_1 - name: Delete second EP retention protocol policy (normal_mode) - aci_tenant_ep_retention_policy: + cisco.aci.aci_tenant_ep_retention_policy: <<: *aci_tenant_ep_retention_policy_2_present state: absent register: nm_delete_tenant_ep_retention_policy_2 - name: Asserts for deletion tasks - assert: + ansible.builtin.assert: that: - cm_delete_tenant_ep_retention_policy_1 is changed - cm_delete_tenant_ep_retention_policy_1.proposed == {} @@ -209,6 +209,6 @@ - nm_delete_tenant_ep_retention_policy_2.current == [] - name: Delete tenant - clean up the environment - aci_tenant: + cisco.aci.aci_tenant: <<: *aci_tenant_present state: absent
\ No newline at end of file diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_tenant_span_dst_group/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_tenant_span_dst_group/tasks/main.yml index 543a25cd5..6b27dcb27 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_tenant_span_dst_group/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_tenant_span_dst_group/tasks/main.yml @@ -4,12 +4,12 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: "{{ aci_hostname }}" username: "{{ aci_username }}" @@ -21,27 +21,27 @@ # CLEAN ENVIRONMENT - name: Remove the ansible_tenant - aci_tenant: + cisco.aci.aci_tenant: <<: *aci_info tenant: ansible_tenant state: absent - name: Verify Cloud and Non-Cloud Sites in use. - include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml - name: Execute tasks only for non-cloud sites when: query_cloud.current == [] # This condition will execute only non-cloud sites block: # block specifies execution of tasks within, based on conditions - name: Add a new tenant - aci_tenant: + cisco.aci.aci_tenant: <<: *aci_info tenant: ansible_tenant description: Ansible tenant state: present - name: Add span ansible_group - aci_tenant_span_dst_group: + cisco.aci.aci_tenant_span_dst_group: <<: *aci_info destination_group: ansible_group description: Test span @@ -62,7 +62,7 @@ register: add_span1 - name: Verify add span - assert: + ansible.builtin.assert: that: - add_span1 is changed - add_span1.current.0.spanDestGrp.attributes.name == "ansible_group" @@ -80,7 +80,7 @@ - add_span1.current.0.spanDestGrp.attributes.annotation == 'orchestrator:ansible' - name: Add span ansible_group again - aci_tenant_span_dst_group: + cisco.aci.aci_tenant_span_dst_group: <<: *aci_info destination_group: ansible_group description: Test span @@ -101,12 +101,12 @@ register: add_span1_again - name: Verify add span again - assert: + ansible.builtin.assert: that: - add_span1_again is not changed - name: Change span ansible_group's src ip - aci_tenant_span_dst_group: + cisco.aci.aci_tenant_span_dst_group: <<: *aci_info destination_group: ansible_group2 description: Test span @@ -127,7 +127,7 @@ register: change_span1_ip - name: Change span ansible_group's dscp - aci_tenant_span_dst_group: + cisco.aci.aci_tenant_span_dst_group: <<: *aci_info destination_group: ansible_group2 description: Test span @@ -148,13 +148,13 @@ register: change_span1_dscp - name: Verify changes in span - assert: + ansible.builtin.assert: that: - change_span1_ip.current.0.spanDestGrp.children.0.spanDest.children.0.spanRsDestEpg.attributes.ip == "10.0.0.2" - change_span1_dscp.current.0.spanDestGrp.children.0.spanDest.children.0.spanRsDestEpg.attributes.dscp == "VA" - name: Add span ansible_group2 - aci_tenant_span_dst_group: + cisco.aci.aci_tenant_span_dst_group: <<: *aci_info destination_group: ansible_group2 description: Test span @@ -175,7 +175,7 @@ register: add_span2 - name: Verify addition of second span - assert: + ansible.builtin.assert: that: - add_span2 is changed - add_span2.current.0.spanDestGrp.attributes.name == "ansible_group2" @@ -192,7 +192,7 @@ - add_span2.current.0.spanDestGrp.children.0.spanDest.children.0.spanRsDestEpg.attributes.ttl == "2" - name: Query span ansible_group - aci_tenant_span_dst_group: + cisco.aci.aci_tenant_span_dst_group: <<: *aci_info tenant: ansible_tenant destination_group: ansible_group @@ -200,13 +200,13 @@ register: query_span_ansible_group - name: Query all span dest groups - aci_tenant_span_dst_group: + cisco.aci.aci_tenant_span_dst_group: <<: *aci_info state: query register: query_all_span - name: Verify Query of span - assert: + ansible.builtin.assert: that: - query_span_ansible_group is not changed - query_span_ansible_group.current.0.spanDestGrp.attributes.name == "ansible_group" @@ -224,7 +224,7 @@ - query_all_span | length >= 2 - name: Remove span ansible_group - aci_tenant_span_dst_group: + cisco.aci.aci_tenant_span_dst_group: <<: *aci_info tenant: ansible_tenant destination_group: ansible_group @@ -232,7 +232,7 @@ register: remove_span1 - name: Remove span ansible_group2 - aci_tenant_span_dst_group: + cisco.aci.aci_tenant_span_dst_group: <<: *aci_info tenant: ansible_tenant destination_group: ansible_group2 @@ -240,7 +240,7 @@ register: remove_span2 - name: Verify Remove of span - assert: + ansible.builtin.assert: that: - remove_span1 is changed - remove_span1.current == [] @@ -249,7 +249,7 @@ # CLEAN ENVIRONMENT - name: Remove the ansible_tenant - aci_tenant: + cisco.aci.aci_tenant: <<: *aci_info tenant: ansible_tenant state: absent diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_tenant_span_src_group/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_tenant_span_src_group/tasks/main.yml index 9f83d0344..06b78e596 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_tenant_span_src_group/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_tenant_span_src_group/tasks/main.yml @@ -4,12 +4,12 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: "{{ aci_hostname }}" username: "{{ aci_username }}" @@ -27,7 +27,7 @@ state: absent - name: Verify Cloud and Non-Cloud Sites in use. - include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml - name: Execute tasks only for non-cloud sites when: query_cloud.current == [] # This condition will execute only non-cloud sites diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_tenant_span_src_group_src/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_tenant_span_src_group_src/tasks/main.yml index 65b8722f9..7c4f5d708 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_tenant_span_src_group_src/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_tenant_span_src_group_src/tasks/main.yml @@ -4,12 +4,12 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: "{{ aci_hostname }}" username: "{{ aci_username }}" @@ -27,7 +27,7 @@ state: absent - name: Verify Cloud and Non-Cloud Sites in use. - include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml - name: Execute tasks only for non-cloud sites when: query_cloud.current == [] # This condition will execute only non-cloud sites diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_tenant_span_src_group_to_dst_group/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_tenant_span_src_group_to_dst_group/tasks/main.yml index e9dac612d..6a3b87016 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_tenant_span_src_group_to_dst_group/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_tenant_span_src_group_to_dst_group/tasks/main.yml @@ -4,12 +4,12 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: "{{ aci_hostname }}" username: "{{ aci_username }}" @@ -27,7 +27,7 @@ state: absent - name: Verify Cloud and Non-Cloud Sites in use. - include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml - name: Execute tasks only for non-cloud sites when: query_cloud.current == [] # This condition will execute only non-cloud sites diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_vlan_pool/tasks/dynamic.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_vlan_pool/tasks/dynamic.yml index 0469210f8..6453552c1 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_vlan_pool/tasks/dynamic.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_vlan_pool/tasks/dynamic.yml @@ -39,7 +39,7 @@ register: nm_add_dynamic_vlan_pool - name: Verify add_dynamic_vlan_pool - assert: + ansible.builtin.assert: that: - cm_add_dynamic_vlan_pool is changed - nm_add_dynamic_vlan_pool is changed @@ -66,7 +66,7 @@ register: nm_add_dynamic_vlan_pool_again - name: Verify add_dynamic_vlan_pool_again - assert: + ansible.builtin.assert: that: - cm_add_dynamic_vlan_pool_again is not changed - nm_add_dynamic_vlan_pool_again is not changed @@ -88,7 +88,7 @@ register: nm_add_dynamic_vlan_pool_descr - name: Verify add_dynamic_vlan_pool_descr - assert: + ansible.builtin.assert: that: - cm_add_dynamic_vlan_pool_descr is changed - nm_add_dynamic_vlan_pool_descr is changed @@ -116,7 +116,7 @@ register: nm_add_dynamic_vlan_pool_descr_again - name: Verify add_dynamic_vlan_pool_descr_again - assert: + ansible.builtin.assert: that: - cm_add_dynamic_vlan_pool_descr_again is not changed - nm_add_dynamic_vlan_pool_descr_again is not changed @@ -134,7 +134,7 @@ register: nm_add_dynamic_vlan_pool_again_no_descr - name: Verify add_dynamic_vlan_pool_again_no_descr - assert: + ansible.builtin.assert: that: - cm_add_dynamic_vlan_pool_again_no_descr is not changed - nm_add_dynamic_vlan_pool_again_no_descr is not changed @@ -160,7 +160,7 @@ register: nm_query_all_dynamic_vlan_pools - name: Verify query_all_dynamic_vlan_pools - assert: + ansible.builtin.assert: that: - cm_query_all_dynamic_vlan_pools is not changed - nm_query_all_dynamic_vlan_pools is not changed @@ -185,7 +185,7 @@ register: nm_query_dynamic_vlan_pool - name: Verify query_dynamic_vlan_pool - assert: + ansible.builtin.assert: that: - cm_query_dynamic_vlan_pool is not changed - nm_query_dynamic_vlan_pool is not changed @@ -207,7 +207,7 @@ register: nm_remove_dynamic_vlan_pool - name: Verify remove_dynamic_vlan_pool - assert: + ansible.builtin.assert: that: - cm_remove_dynamic_vlan_pool is changed - nm_remove_dynamic_vlan_pool is changed @@ -227,7 +227,7 @@ register: nm_remove_dynamic_vlan_pool_again - name: Verify remove_dynamic_vlan_pool_again - assert: + ansible.builtin.assert: that: - cm_remove_dynamic_vlan_pool_again is not changed - nm_remove_dynamic_vlan_pool_again is not changed @@ -255,7 +255,7 @@ # TODO: Implement more tests - name: Verify query_non_dynamic_vlan_pool - assert: + ansible.builtin.assert: that: - cm_query_non_dynamic_vlan_pool is not changed - nm_query_non_dynamic_vlan_pool is not changed @@ -278,7 +278,7 @@ register: error_on_missing_required_param - name: Verify error_on_missing_required_param - assert: + ansible.builtin.assert: that: - error_on_missing_required_param is failed - 'error_on_missing_required_param.msg == "state is present but all of the following are missing: pool"' @@ -298,7 +298,7 @@ register: error_on_missing_together_param - name: Verify error_on_missing_together_param - assert: + ansible.builtin.assert: that: - error_on_missing_together_param is failed - error_on_missing_together_param.msg == "ACI requires the 'pool_allocation_mode' when 'pool' is provided" diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_vlan_pool/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_vlan_pool/tasks/main.yml index 0bac9032c..21d769f61 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_vlan_pool/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_vlan_pool/tasks/main.yml @@ -4,12 +4,12 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined - name: Verify Cloud and Non-Cloud Sites in use. - include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml - name: Execute tasks only for non-cloud sites when: query_cloud.current == [] # This condition will execute only non-cloud sites diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_vlan_pool/tasks/static.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_vlan_pool/tasks/static.yml index 3ddae4c47..de35cba16 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_vlan_pool/tasks/static.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_vlan_pool/tasks/static.yml @@ -38,7 +38,7 @@ register: nm_add_static_vlan_pool - name: Verify add_static_vlan_pool - assert: + ansible.builtin.assert: that: - cm_add_static_vlan_pool is changed - nm_add_static_vlan_pool is changed @@ -65,7 +65,7 @@ register: nm_add_static_vlan_pool_again - name: Verify add_static_vlan_pool_again - assert: + ansible.builtin.assert: that: - cm_add_static_vlan_pool_again is not changed - nm_add_static_vlan_pool_again is not changed @@ -87,7 +87,7 @@ register: nm_add_static_vlan_pool_descr - name: Verify add_static_vlan_pool_descr - assert: + ansible.builtin.assert: that: - cm_add_static_vlan_pool_descr is changed - nm_add_static_vlan_pool_descr is changed @@ -115,7 +115,7 @@ register: nm_add_static_vlan_pool_descr_again - name: Verify add_static_vlan_pool_descr_again - assert: + ansible.builtin.assert: that: - cm_add_static_vlan_pool_descr_again is not changed - nm_add_static_vlan_pool_descr_again is not changed @@ -133,7 +133,7 @@ register: nm_add_static_vlan_pool_again_no_descr - name: Verify add_static_vlan_pool_again_no_descr - assert: + ansible.builtin.assert: that: - cm_add_static_vlan_pool_again_no_descr is not changed - nm_add_static_vlan_pool_again_no_descr is not changed @@ -159,7 +159,7 @@ register: nm_query_all_static_vlan_pools - name: Verify query_all_static_vlan_pools - assert: + ansible.builtin.assert: that: - cm_query_all_static_vlan_pools is not changed - nm_query_all_static_vlan_pools is not changed @@ -184,7 +184,7 @@ register: nm_query_static_vlan_pool - name: Verify query_static_vlan_pool - assert: + ansible.builtin.assert: that: - cm_query_static_vlan_pool is not changed - nm_query_static_vlan_pool is not changed @@ -206,7 +206,7 @@ register: nm_remove_static_vlan_pool - name: Verify remove_static_vlan_pool - assert: + ansible.builtin.assert: that: - cm_remove_static_vlan_pool is changed - nm_remove_static_vlan_pool is changed @@ -226,7 +226,7 @@ register: nm_remove_static_vlan_pool_again - name: Verify remove_static_vlan_pool_again - assert: + ansible.builtin.assert: that: - cm_remove_static_vlan_pool_again is not changed - nm_remove_static_vlan_pool_again is not changed @@ -254,7 +254,7 @@ # TODO: Implement more tests - name: Verify query_non_static_vlan_pool - assert: + ansible.builtin.assert: that: - cm_query_non_static_vlan_pool is not changed - nm_query_non_static_vlan_pool is not changed @@ -277,7 +277,7 @@ register: error_on_missing_required_param - name: Verify error_on_missing_required_param - assert: + ansible.builtin.assert: that: - error_on_missing_required_param is failed - 'error_on_missing_required_param.msg == "state is present but all of the following are missing: pool"' @@ -297,7 +297,7 @@ register: error_on_missing_together_param - name: Verify error_on_missing_together_param - assert: + ansible.builtin.assert: that: - error_on_missing_together_param is failed - error_on_missing_together_param.msg == "ACI requires the 'pool_allocation_mode' when 'pool' is provided" diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_vlan_pool_encap_block/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_vlan_pool_encap_block/tasks/main.yml index 5ccf8bfbf..125d210a9 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_vlan_pool_encap_block/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_vlan_pool_encap_block/tasks/main.yml @@ -5,12 +5,12 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an aci apic host, aci username and aci password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined - name: Verify Cloud and Non-Cloud Sites in use. - include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml - name: Execute tasks only for non-cloud sites when: query_cloud.current == [] # This condition will execute only non-cloud sites @@ -58,7 +58,7 @@ register: encap_block_present_check_mode - name: Present assertions - assert: + ansible.builtin.assert: that: - encap_block_present_check_mode is changed - encap_block_present_check_mode.sent.fvnsEncapBlk.attributes.allocMode == 'inherit' @@ -73,7 +73,7 @@ register: encap_block_present - name: Present assertions - assert: + ansible.builtin.assert: that: - encap_block_present is changed - encap_block_present.previous == [] @@ -87,7 +87,7 @@ register: encap_block_present_idempotent - name: Present assertions - assert: + ansible.builtin.assert: that: - encap_block_present_idempotent is not changed - encap_block_present_idempotent.previous.0.fvnsEncapBlk.attributes.name == "anstest" @@ -100,7 +100,7 @@ register: encap_block_present_update - name: Present assertions - assert: + ansible.builtin.assert: that: - encap_block_present_update is changed - encap_block_present_update.previous != [] @@ -115,7 +115,7 @@ register: encap_block_present_2 - name: Present assertions - assert: + ansible.builtin.assert: that: - encap_block_present_2 is changed - encap_block_present_2.previous == [] @@ -128,7 +128,7 @@ register: encap_block_start_low - name: Present assertions - assert: + ansible.builtin.assert: that: - encap_block_start_low is failed - encap_block_start_low.msg == "vlan pools must have 'block_start' and 'block_end' values between 1 and 4094" @@ -141,7 +141,7 @@ register: encap_block_start_high - name: Present assertions - assert: + ansible.builtin.assert: that: - encap_block_start_high is failed - encap_block_start_high.msg == "vlan pools must have 'block_start' and 'block_end' values between 1 and 4094" @@ -154,7 +154,7 @@ register: encap_block_end_low - name: Present assertions - assert: + ansible.builtin.assert: that: - encap_block_end_low is failed - encap_block_end_low.msg == "vlan pools must have 'block_start' and 'block_end' values between 1 and 4094" @@ -167,7 +167,7 @@ register: encap_block_end_high - name: Present assertions - assert: + ansible.builtin.assert: that: - encap_block_end_high is failed - encap_block_end_high.msg == "vlan pools must have 'block_start' and 'block_end' values between 1 and 4094" @@ -180,7 +180,7 @@ register: encap_block_start_end - name: Present assertions - assert: + ansible.builtin.assert: that: - encap_block_start_end is failed - encap_block_start_end.msg == "The 'block_start' must be less than or equal to the 'block_end'" @@ -192,7 +192,7 @@ register: encap_block_present_missing_param - name: Present assertions - assert: + ansible.builtin.assert: that: - encap_block_present_missing_param is failed - 'encap_block_present_missing_param.msg == "state is present but all of the following are missing: block_end, block_start"' @@ -204,7 +204,7 @@ register: encap_block_query - name: Query assertions - assert: + ansible.builtin.assert: that: - encap_block_query is not changed - encap_block_query.url.endswith("infra/vlanns-[anstest]-static/from-[vlan-20]-to-[vlan-40].json") @@ -219,7 +219,7 @@ register: encap_block_query_from_to_name - name: Query assertions - assert: + ansible.builtin.assert: that: - encap_block_query_from_to_name is not changed - encap_block_query_from_to_name.url.endswith("class/fvnsEncapBlk.json") @@ -237,7 +237,7 @@ register: encap_block_query_from_name - name: Query assertions - assert: + ansible.builtin.assert: that: - encap_block_query_from_name is not changed - encap_block_query_from_name.url.endswith("class/fvnsEncapBlk.json") @@ -253,7 +253,7 @@ register: encap_block_query_to_name - name: Query assertions - assert: + ansible.builtin.assert: that: - encap_block_query_to_name is not changed - encap_block_query_to_name.url.endswith("class/fvnsEncapBlk.json") @@ -270,7 +270,7 @@ register: encap_block_query_name - name: Query assertions - assert: + ansible.builtin.assert: that: - encap_block_query_name is not changed - encap_block_query_name.url.endswith("class/fvnsEncapBlk.json") @@ -284,7 +284,7 @@ register: encap_block_query_from_to - name: Query assertions - assert: + ansible.builtin.assert: that: - encap_block_query_from_to is not changed - encap_block_query_from_to.url.endswith("class/fvnsEncapBlk.json") @@ -301,7 +301,7 @@ register: encap_block_query_pool - name: Query assertions - assert: + ansible.builtin.assert: that: - encap_block_query_pool is not changed - encap_block_query_pool.current | length == 1 @@ -318,7 +318,7 @@ register: encap_block_query_all - name: Query assertions - assert: + ansible.builtin.assert: that: - encap_block_query_all is not changed - encap_block_query_all.current | length > 1 @@ -332,7 +332,7 @@ register: delete_range - name: Absent assertions - assert: + ansible.builtin.assert: that: - delete_range is changed - delete_range.proposed == {} @@ -346,7 +346,7 @@ register: delete_check_mode - name: Absent assertions - assert: + ansible.builtin.assert: that: - delete_check_mode is changed - delete_check_mode.previous != [] @@ -357,7 +357,7 @@ register: delete_encap_block_2 - name: Absent assertions - assert: + ansible.builtin.assert: that: - delete_encap_block_2 is changed - delete_encap_block_2.previous == delete_check_mode.previous @@ -368,7 +368,7 @@ register: delete_idempotent - name: Absent assertions - assert: + ansible.builtin.assert: that: - delete_idempotent is not changed - delete_idempotent.previous == [] diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_vmm_controller/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_vmm_controller/tasks/main.yml index 7a02169b0..820d03e75 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_vmm_controller/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_vmm_controller/tasks/main.yml @@ -1,11 +1,12 @@ # Test code for the ACI modules # Copyright: (c) 2021, Anvitha Jain (@anvitha-jain) <anvjain@cisco.com> +# Copyright: (c) 2023, Akini Ross (@akinross) <akinross@cisco.com> # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) # CLEAN ENVIRONMENT - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: "{{ aci_hostname }}" username: "{{ aci_username }}" @@ -31,7 +32,7 @@ - openstack - name: Verify Cloud and Non-Cloud Sites in use. - include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml - name: Execute tasks only for non-cloud sites when: query_cloud.current == [] # This condition will skip execution for cloud sites @@ -52,12 +53,12 @@ - openstack - name: Verify VMM add_domain - assert: + ansible.builtin.assert: that: - nm_add_domain is changed - name: Add controller to VMware VMM domain - aci_vmm_controller: &add_controller + cisco.aci.aci_vmm_controller: &add_controller <<: *aci_info domain: vmm_dom name: vCenter1 @@ -69,7 +70,7 @@ register: nm_add_controller - name: Verify VMM add_controller - assert: + ansible.builtin.assert: that: - nm_add_controller is changed - nm_add_controller.sent.vmmCtrlrP.attributes.name == 'vCenter1' @@ -80,7 +81,7 @@ - nm_add_controller.current.0.vmmCtrlrP.attributes.annotation == 'orchestrator:ansible' - name: Add another controller to all VMM domain - aci_vmm_controller: + cisco.aci.aci_vmm_controller: <<: *add_controller name: vCenter2 credentials: vCenterCredentials1 @@ -96,12 +97,12 @@ - openstack - name: Verify another VMM add_controller - assert: + ansible.builtin.assert: that: - add_controller is changed - name: Add controller to VMware VMM domain again - aci_vmm_controller: + cisco.aci.aci_vmm_controller: <<: *add_controller name: vCenter2 controller_hostname: 10.10.1.1 @@ -109,12 +110,12 @@ register: add_controller_again - name: Verify another VMM add_controller again - assert: + ansible.builtin.assert: that: - add_controller_again is not changed - name: Query controller - aci_vmm_controller: + cisco.aci.aci_vmm_controller: <<: *aci_info domain: vmm_dom name: vCenter1 @@ -123,41 +124,96 @@ register: query_controller - name: Verify VMM query_controller - assert: + ansible.builtin.assert: that: - query_controller is not changed - query_controller.current.0.vmmCtrlrP.attributes.dn == 'uni/vmmp-VMware/dom-vmm_dom/ctrlr-vCenter1' - query_controller.current.0.vmmCtrlrP.attributes.name == 'vCenter1' - - name: Query all controllers - aci_vmm_controller: + - name: Query controller ( only vm_provider set ) + cisco.aci.aci_vmm_controller: + <<: *aci_info + vm_provider: vmware + state: query + register: query_controller_vm_provider + + - name: Query controller ( only domain set ) + cisco.aci.aci_vmm_controller: <<: *aci_info domain: vmm_dom + state: query + register: query_controller_domain + + - name: Query controller ( only name set ) + cisco.aci.aci_vmm_controller: + <<: *aci_info + name: vCenter2 + state: query + register: query_controller_name + + - name: Query controller ( only vm_provider and domain set ) + cisco.aci.aci_vmm_controller: + <<: *aci_info vm_provider: vmware + domain: vmm_dom state: query - register: query_controller + register: query_controller_vm_provider_domain + + - name: Query controller ( only vm_provider and name set ) + cisco.aci.aci_vmm_controller: + <<: *aci_info + vm_provider: vmware + name: vCenter2 + state: query + register: query_controller_vm_provider_name + + - name: Query controller ( only domain and name set ) + cisco.aci.aci_vmm_controller: + <<: *aci_info + domain: vmm_dom + name: vCenter2 + state: query + register: query_controller_domain_name + + - name: Query all controllers + cisco.aci.aci_vmm_controller: + <<: *aci_info + state: query + register: query_controller_all - name: Verify VMM query_controller - assert: + ansible.builtin.assert: that: - - query_controller is not changed + - query_controller_vm_provider is not changed + - query_controller_vm_provider.current.0.vmmProvP.attributes.dn == "uni/vmmp-VMware" + - query_controller_domain is not changed + - query_controller_domain.current.0.vmmDomP.attributes.dn == "uni/vmmp-VMware/dom-vmm_dom" + - query_controller_name is not changed + - query_controller_name.current.0.vmmCtrlrP.attributes.dn == "uni/vmmp-VMware/dom-vmm_dom/ctrlr-vCenter2" + - query_controller_vm_provider_domain is not changed + - query_controller_vm_provider_domain.current.0.vmmDomP.attributes.dn == "uni/vmmp-VMware/dom-vmm_dom" + - query_controller_vm_provider_name is not changed + - query_controller_vm_provider_name.current.0.vmmCtrlrP.attributes.dn == "uni/vmmp-VMware/dom-vmm_dom/ctrlr-vCenter2" + - query_controller_domain_name is not changed + - query_controller_domain_name.current.0.vmmDomP.attributes.dn == "uni/vmmp-VMware/dom-vmm_dom" + - query_controller_all is not changed - name: Delete controllers - aci_vmm_controller: + cisco.aci.aci_vmm_controller: <<: *add_controller name: vCenter1 state: absent register: remove_controller - name: Delete controllers - aci_vmm_controller: + cisco.aci.aci_vmm_controller: <<: *add_controller name: vCenter2 state: absent register: remove_controller_2 - name: Verify VMM remove_controller - assert: + ansible.builtin.assert: that: - remove_controller is changed - remove_controller_2 is changed diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_vmm_credential/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_vmm_credential/tasks/main.yml index b76c4563a..f88676dd8 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_vmm_credential/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_vmm_credential/tasks/main.yml @@ -4,7 +4,7 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_vmm_credential/tasks/vmware.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_vmm_credential/tasks/vmware.yml index 262ecf33c..c56d62c6c 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_vmm_credential/tasks/vmware.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_vmm_credential/tasks/vmware.yml @@ -5,7 +5,7 @@ # CLEAN ENVIRONMENT - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: "{{ aci_hostname }}" username: "{{ aci_username }}" @@ -26,7 +26,7 @@ register: nm_remove_domain - name: Verify Cloud and Non-Cloud Sites in use. - include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml - name: Execute tasks only for non-cloud sites when: query_cloud.current == [] # This condition will skip execution for cloud sites @@ -42,7 +42,7 @@ register: nm_add_domain - name: Verify add_domain - assert: + ansible.builtin.assert: that: - nm_add_domain is changed @@ -65,7 +65,7 @@ register: nm_remove_credential - name: Verify remove_credential - assert: + ansible.builtin.assert: that: - cm_remove_credential is not changed - nm_remove_credential is not changed @@ -96,7 +96,7 @@ register: cm_add_credential_again - name: Verify add_credential - assert: + ansible.builtin.assert: that: - cm_add_credential is changed - nm_add_credential is changed @@ -132,7 +132,7 @@ register: nm_mod_credential - name: Verify mod_credential - assert: + ansible.builtin.assert: that: - cm_mod_credential is changed - nm_mod_credential is changed @@ -182,7 +182,7 @@ register: nm_query_all_credential - name: Verify query_credential - assert: + ansible.builtin.assert: that: - cm_query_credential is not changed - nm_query_credential is not changed @@ -209,7 +209,7 @@ register: nm_remove_credential_final - name: Verify remove_credential - assert: + ansible.builtin.assert: that: - cm_remove_credential_again is changed - nm_remove_credential_again is changed diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_vmm_uplink/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_vmm_uplink/tasks/main.yml index 1e7b6a6cf..8d627c730 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_vmm_uplink/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_vmm_uplink/tasks/main.yml @@ -4,13 +4,13 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined # GET Credentials from the inventory - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: "{{ aci_hostname }}" username: "{{ aci_username }}" @@ -22,14 +22,14 @@ # PERFORM TESTS ONLY ON SUPPORTED APICS - name: Query system information - aci_system: + cisco.aci.aci_system: <<: *aci_info id: 1 state: query register: version - name: Verify Cloud and Non-Cloud Sites in use. - include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml - name: Execute tasks only for non-cloud sites when: @@ -38,7 +38,7 @@ block: # CLEAN ENVIRONMENT - name: Remove ansible_domain if it already exists - aci_domain: + cisco.aci.aci_domain: <<: *aci_info domain: ansible_domain domain_type: vmm @@ -47,7 +47,7 @@ # CREATE VMWARE DOMAIN - name: Create ansible_domain - aci_domain: + cisco.aci.aci_domain: <<: *aci_info domain: ansible_domain domain_type: vmm @@ -56,7 +56,7 @@ # CREATE VMWARE UPLINK CONTAINER - name: Create VMWare Uplink Container - aci_vmm_uplink_container: + cisco.aci.aci_vmm_uplink_container: <<: *aci_info domain: ansible_domain num_of_uplinks: 1 @@ -73,7 +73,7 @@ register: create_uplink - name: Verify Uplink Creation - assert: + ansible.builtin.assert: that: - create_uplink.current.0.vmmUplinkP.attributes.dn == "uni/vmmp-VMware/dom-ansible_domain/uplinkpcont/uplinkp-1" - create_uplink.current.0.vmmUplinkP.attributes.uplinkId == "1" @@ -91,7 +91,7 @@ register: create_uplink_again - name: Verify Uplink Creation idempotence - assert: + ansible.builtin.assert: that: - create_uplink_again is not changed - create_uplink_again.current.0.vmmUplinkP.attributes.dn == "uni/vmmp-VMware/dom-ansible_domain/uplinkpcont/uplinkp-1" @@ -109,7 +109,7 @@ register: update_uplink - name: Verify Uplink update - assert: + ansible.builtin.assert: that: - update_uplink is changed - update_uplink.current.0.vmmUplinkP.attributes.dn == "uni/vmmp-VMware/dom-ansible_domain/uplinkpcont/uplinkp-1" @@ -126,7 +126,7 @@ register: query_uplink - name: Verify Uplink query - assert: + ansible.builtin.assert: that: - query_uplink is not changed - query_uplink.current.0.vmmUplinkP.attributes.dn == "uni/vmmp-VMware/dom-ansible_domain/uplinkpcont/uplinkp-1" @@ -143,7 +143,7 @@ register: remove_uplink - name: Verify VMWare Uplink deletion - assert: + ansible.builtin.assert: that: - remove_uplink is changed - remove_uplink.current == [] @@ -161,13 +161,13 @@ register: remove_uplink_again - name: Verify VMWare Uplink deletion idempotence - assert: + ansible.builtin.assert: that: - remove_uplink_again is not changed # CLEAN UP - name: Remove ansible_domain - aci_domain: + cisco.aci.aci_domain: <<: *aci_info domain: ansible_domain domain_type: vmm diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_vmm_uplink_container/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_vmm_uplink_container/tasks/main.yml index 0ddbe2174..7839728a9 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_vmm_uplink_container/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_vmm_uplink_container/tasks/main.yml @@ -4,13 +4,13 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined # GET Credentials from the inventory - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: "{{ aci_hostname }}" username: "{{ aci_username }}" @@ -22,14 +22,14 @@ # PERFORM TESTS ONLY ON SUPPORTED APICS - name: Query system information - aci_system: + cisco.aci.aci_system: <<: *aci_info id: 1 state: query register: version - name: Verify Cloud and Non-Cloud Sites in use. - include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml - name: Execute tasks only for non-cloud sites when: @@ -38,7 +38,7 @@ block: # CLEAN ENVIRONMENT - name: Remove ansible_domain if it already exists - aci_domain: + cisco.aci.aci_domain: <<: *aci_info domain: ansible_domain domain_type: vmm @@ -47,7 +47,7 @@ # CREATE VMWARE DOMAIN - name: Create ansible_domain - aci_domain: + cisco.aci.aci_domain: <<: *aci_info domain: ansible_domain domain_type: vmm @@ -56,7 +56,7 @@ # CREATE VMWARE UPLINK CONTAINER - name: Create VMWare Uplink Container - aci_vmm_uplink_container: + cisco.aci.aci_vmm_uplink_container: <<: *aci_info domain: ansible_domain num_of_uplinks: 2 @@ -64,7 +64,7 @@ register: create_container - name: Verify Uplink Container Creation - assert: + ansible.builtin.assert: that: - create_container.current.0.vmmUplinkPCont.attributes.dn == "uni/vmmp-VMware/dom-ansible_domain/uplinkpcont" - create_container.current.0.vmmUplinkPCont.attributes.numOfUplinks == "2" @@ -72,7 +72,7 @@ # CREATE VMWARE UPLINK CONTAINER AGAIN TO CHECK IDEMPOTENCE - name: Create VMWare Uplink Container again - aci_vmm_uplink_container: + cisco.aci.aci_vmm_uplink_container: <<: *aci_info domain: ansible_domain num_of_uplinks: 2 @@ -80,7 +80,7 @@ register: create_container_again - name: Verify Uplink Container Creation Idempotence - assert: + ansible.builtin.assert: that: - create_container_again is not changed - create_container_again.current.0.vmmUplinkPCont.attributes.dn == "uni/vmmp-VMware/dom-ansible_domain/uplinkpcont" @@ -88,7 +88,7 @@ # MODIFY VMWARE UPLINK CONTAINER - name: Update VMWare Uplink Container - aci_vmm_uplink_container: + cisco.aci.aci_vmm_uplink_container: <<: *aci_info domain: ansible_domain num_of_uplinks: 3 @@ -96,7 +96,7 @@ register: update_container - name: Verify Uplink Container is updated - assert: + ansible.builtin.assert: that: - update_container is changed - update_container.current.0.vmmUplinkPCont.attributes.dn == "uni/vmmp-VMware/dom-ansible_domain/uplinkpcont" @@ -104,14 +104,14 @@ # QUERY VMWARE UPLINK CONTAINER - name: Update VMWare Uplink Container - aci_vmm_uplink_container: + cisco.aci.aci_vmm_uplink_container: <<: *aci_info domain: ansible_domain state: query register: query_container - name: Verify Uplink Container Query - assert: + ansible.builtin.assert: that: - query_container is not changed - query_container.current.0.vmmUplinkPCont.attributes.dn == "uni/vmmp-VMware/dom-ansible_domain/uplinkpcont" @@ -119,14 +119,14 @@ # DELETE VMWARE UPLINK CONTAINER - name: Remove Uplink Container - aci_vmm_uplink_container: + cisco.aci.aci_vmm_uplink_container: <<: *aci_info domain: ansible_domain state: absent register: delete_container - name: Verify Uplink Container removal - assert: + ansible.builtin.assert: that: - delete_container is changed - delete_container.current == [] @@ -135,20 +135,20 @@ # DELETE VMWARE UPLINK CONTAINER AGAIN TO TEST IDEMPOTENCE - name: Remove Uplink Container again - aci_vmm_uplink_container: + cisco.aci.aci_vmm_uplink_container: <<: *aci_info domain: ansible_domain state: absent register: delete_container_again - name: Verify Uplink Container removal idempotence - assert: + ansible.builtin.assert: that: - delete_container_again is not changed # CLEAN UP - name: Remove ansible_domain - aci_domain: + cisco.aci.aci_domain: <<: *aci_info domain: ansible_domain domain_type: vmm diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_vmm_vswitch_policy/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_vmm_vswitch_policy/tasks/main.yml index 371137af4..3038ff30a 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_vmm_vswitch_policy/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_vmm_vswitch_policy/tasks/main.yml @@ -5,7 +5,7 @@ # CLEAN ENVIRONMENT - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: "{{ aci_hostname }}" username: "{{ aci_username }}" @@ -16,7 +16,7 @@ output_level: '{{ aci_output_level | default("debug") }}' - name: Query system information - aci_system: + cisco.aci.aci_system: <<: *aci_info id: 1 state: query @@ -37,7 +37,7 @@ - { domain: 'microsoft_dom', provider: 'microsoft' } - name: Verify Cloud and Non-Cloud Sites in use. - include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml - name: Execute tasks only for non-cloud sites when: query_cloud.current == [] # This condition will skip execution for cloud sites @@ -57,12 +57,12 @@ - { domain: 'microsoft_dom', provider: 'microsoft' } - name: Verify VMM add_domain - assert: + ansible.builtin.assert: that: - nm_add_domain is changed - name: Add a vSwitch policy to vmware domain - aci_vmm_vswitch_policy: &add_vmware_policies + cisco.aci.aci_vmm_vswitch_policy: &add_vmware_policies <<: *aci_info domain: vmm_dom vm_provider: vmware @@ -73,7 +73,7 @@ register: add_vmware_policy - name: Verify VMM add_vmware_policy - assert: + ansible.builtin.assert: that: - add_vmware_policy is changed - add_vmware_policy.previous == [] @@ -84,7 +84,7 @@ - add_vmware_policy.current.0.vmmVSwitchPolicyCont.attributes.annotation == 'orchestrator:ansible' - name: Add a vSwitch policy to vmware domain - aci_vmm_vswitch_policy: + cisco.aci.aci_vmm_vswitch_policy: <<: *add_vmware_policies netflow_exporter: name: Netflow_Exporter_policy @@ -94,7 +94,7 @@ register: add_vmware_policy_2 - name: Verify VMM add_vmware_policy_2 - assert: + ansible.builtin.assert: that: - add_vmware_policy_2 is changed - add_vmware_policy_2.current.0.vmmVSwitchPolicyCont.attributes.dn == 'uni/vmmp-VMware/dom-vmm_dom/vswitchpolcont' @@ -105,7 +105,7 @@ - add_vmware_policy_2.current.0.vmmVSwitchPolicyCont.children.4.vmmRsVswitchOverrideLldpIfPol.attributes.tDn == 'uni/infra/lldpIfP-LLDP_policy' - name: Add MTU policy to vmware domain when version is >= 4.2 - aci_vmm_vswitch_policy: + cisco.aci.aci_vmm_vswitch_policy: <<: *add_vmware_policies mtu_policy: MTU_policy state: present @@ -113,7 +113,7 @@ when: version.current.0.topSystem.attributes.version is version('4.2', '>=') - name: Verify VMM add_vmware_mtu_policy - assert: + ansible.builtin.assert: that: - add_vmware_mtu_policy is changed - add_vmware_mtu_policy.current.0.vmmVSwitchPolicyCont.attributes.dn == 'uni/vmmp-VMware/dom-vmm_dom/vswitchpolcont' @@ -121,7 +121,7 @@ when: version.current.0.topSystem.attributes.version is version('4.2', '>=') - name: Add a vSwitch policy to microsoft domain - aci_vmm_vswitch_policy: + cisco.aci.aci_vmm_vswitch_policy: <<: *aci_info domain: vmm_dom vm_provider: microsoft @@ -132,7 +132,7 @@ register: add_microsoft_policy - name: Verify VMM add_microsoft_policy - assert: + ansible.builtin.assert: that: - add_microsoft_policy is changed - add_microsoft_policy.previous == [] @@ -142,7 +142,7 @@ - add_microsoft_policy.current.0.vmmVSwitchPolicyCont.children.2.vmmRsVswitchOverrideLldpIfPol.attributes.tDn == 'uni/infra/lldpIfP-ms_LLDP_policy' - name: Add STP vSwitch policy to another microsoft domain - aci_vmm_vswitch_policy: + cisco.aci.aci_vmm_vswitch_policy: <<: *aci_info domain: microsoft_dom vm_provider: microsoft @@ -151,7 +151,7 @@ register: add_microsoft_stp_policy - name: Verify VMM add_microsoft_stp_policy - assert: + ansible.builtin.assert: that: - add_microsoft_stp_policy is changed - add_microsoft_stp_policy.previous == [] @@ -159,25 +159,25 @@ - add_microsoft_stp_policy.current.0.vmmVSwitchPolicyCont.children.0.vmmRsVswitchOverrideStpPol.attributes.tDn == 'uni/infra/ifPol-ms_STP_policy' - name: Query all the vSwitch policy - aci_vmm_vswitch_policy: + cisco.aci.aci_vmm_vswitch_policy: <<: *aci_info state: query register: query_all_vmware - name: Query all the vSwitch policy of the VMWare domain - aci_vmm_vswitch_policy: + cisco.aci.aci_vmm_vswitch_policy: <<: *aci_info state: query register: query_all_microsoft - name: Verify Query all tasks for vmware and microsoft domain - assert: + ansible.builtin.assert: that: - query_all_vmware is not changed - query_all_microsoft is not changed - name: Query vSwitch policies of VMWare domain - aci_vmm_vswitch_policy: + cisco.aci.aci_vmm_vswitch_policy: <<: *aci_info domain: vmm_dom vm_provider: vmware @@ -185,13 +185,13 @@ register: query_vmware - name: Verify Query vSwitch policy of the VMWare domain - assert: + ansible.builtin.assert: that: - query_vmware is not changed - query_vmware.current.0.vmmVSwitchPolicyCont.attributes.dn == 'uni/vmmp-VMware/dom-vmm_dom/vswitchpolcont' - name: Remove vSwitch Policy from VMware VMM domain - aci_vmm_vswitch_policy: + cisco.aci.aci_vmm_vswitch_policy: <<: *aci_info domain: vmm_dom vm_provider: vmware @@ -199,7 +199,7 @@ register: remove_vmware_vSwitch_policy - name: Verify remove_vmware_vSwitch_policy - assert: + ansible.builtin.assert: that: - remove_vmware_vSwitch_policy is changed - remove_vmware_vSwitch_policy.current == []
\ No newline at end of file diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_vrf/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_vrf/tasks/main.yml index 695f40fe7..6903b3c71 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_vrf/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_vrf/tasks/main.yml @@ -4,7 +4,7 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined @@ -73,7 +73,7 @@ register: vrf_present_missing_param - name: present asserts - assert: + ansible.builtin.assert: that: - vrf_present_check_mode is changed - vrf_present_check_mode.sent.fvCtx.attributes.descr == 'Ansible Test' @@ -126,7 +126,7 @@ register: query_vrf - name: query asserts - assert: + ansible.builtin.assert: that: - query_all is not changed - query_all.current | length > 1 @@ -177,7 +177,7 @@ register: vrf_absent_missing_param - name: asserts for deletion task - assert: + ansible.builtin.assert: that: - vrf_absent_check_mode is changed - vrf_absent_check_mode.previous != [] diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_vrf_leak_internal_subnet/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_vrf_leak_internal_subnet/tasks/main.yml index 2455f24e4..33df4b78f 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_vrf_leak_internal_subnet/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_vrf_leak_internal_subnet/tasks/main.yml @@ -4,12 +4,12 @@ # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) - name: Test that we have an ACI APIC host, ACI username and ACI password - fail: + ansible.builtin.fail: msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined - name: Verify Cloud and Non-Cloud Sites in use. - include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml + ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml - name: Execute tasks only for non-cloud sites when: @@ -17,7 +17,7 @@ - version.current.0.topSystem.attributes.version is version('5', '>=') block: # block specifies execution of tasks within, based on conditions - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: '{{ aci_hostname }}' username: '{{ aci_username }}' @@ -113,7 +113,7 @@ attributes_list_present: "{{ leak_sub_present.current.0.leakInternalSubnet.children | map(attribute='leakTo.attributes') | list | sort(attribute='ctxName') }}" - name: present asserts - assert: + ansible.builtin.assert: that: - vrf_present is changed - leak_sub_check_mode is changed @@ -166,7 +166,7 @@ attributes_list_query: "{{ query.current.0.leakInternalSubnet.children | map(attribute='leakTo.attributes') | list | sort(attribute='ctxName') }}" - name: query asserts - assert: + ansible.builtin.assert: that: - query_all is not changed - query is not changed @@ -215,7 +215,7 @@ register: leak_sub_delete_idempotency - name: delete asserts - assert: + ansible.builtin.assert: that: - leak_sub_delete_check_mode is changed - leak_sub_delete_check_mode.current.0.leakInternalSubnet.children.0.leakTo.attributes.ctxName == 'test3' diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_vrf_multicast/aliases b/ansible_collections/cisco/aci/tests/integration/targets/aci_vrf_multicast/aliases new file mode 100644 index 000000000..209b793f9 --- /dev/null +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_vrf_multicast/aliases @@ -0,0 +1,2 @@ +# No ACI simulator yet, so not enabled +# unsupported diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_vrf_multicast/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_vrf_multicast/tasks/main.yml new file mode 100644 index 000000000..7b2991bd5 --- /dev/null +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_vrf_multicast/tasks/main.yml @@ -0,0 +1,1133 @@ +# Test code for the ACI modules +# Copyright: (c) 2023, Tim Cragg (@timcragg) +# Copyright: (c) 2023, Akini Ross (@akinross) + +# 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 APIC host, ACI username and ACI password + ansible.builtin.fail: + msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.' + when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined + +# SET VARS + +- name: Set vars + ansible.builtin.set_fact: + aci_info: &aci_info + host: '{{ aci_hostname }}' + username: '{{ aci_username }}' + password: '{{ aci_password }}' + validate_certs: '{{ aci_validate_certs | default(false) }}' + use_ssl: '{{ aci_use_ssl | default(true) }}' + use_proxy: '{{ aci_use_proxy | default(true) }}' + output_level: '{{ aci_output_level | default("info") }}' + +# CLEAN ENVIRONMENT + +- name: Remove ansible_tenant + cisco.aci.aci_tenant: &aci_tenant_absent + <<: *aci_info + tenant: ansible_tenant + state: absent + +- name: Create ansible_tenant + cisco.aci.aci_tenant: &aci_tenant + <<: *aci_tenant_absent + state: present + +- name: Create ansible_vrf + cisco.aci.aci_vrf: &aci_ansible_vrf_1 + <<: *aci_tenant + vrf: ansible_vrf_1 + state: present + +- name: Create ansible_second_vrf + cisco.aci.aci_vrf: &aci_ansible_vrf_2 + <<: *aci_tenant + vrf: ansible_vrf_2 + state: present + +# ENABLE MULTICAST + +- name: Enable multicast on VRF 1 (check mode) + cisco.aci.aci_vrf_multicast: + <<: *aci_ansible_vrf_1 + check_mode: yes + register: cm_enable_multicast + +- name: Enable multicast on VRF 1 (normal mode) + cisco.aci.aci_vrf_multicast: + <<: *aci_ansible_vrf_1 + register: nm_enable_multicast + +- name: Enable multicast on VRF 1 again + cisco.aci.aci_vrf_multicast: + <<: *aci_ansible_vrf_1 + register: nm_enable_multicast_again + +- name: Verify create multicast VRF 1 + ansible.builtin.assert: + that: + - cm_enable_multicast is changed + - cm_enable_multicast.current == [] + - cm_enable_multicast.previous == [] + - cm_enable_multicast.proposed.pimCtxP.attributes.annotation == "orchestrator:ansible" + - cm_enable_multicast.proposed.pimCtxP.attributes.dn == "uni/tn-ansible_tenant/ctx-ansible_vrf_1/pimctxp" + - cm_enable_multicast.proposed.pimCtxP.children.0.pimResPol.children == [] + - cm_enable_multicast.proposed.pimCtxP.children.1.pimASMPatPol.children.0.pimSharedRangePol.children == [] + - cm_enable_multicast.proposed.pimCtxP.children.1.pimASMPatPol.children.1.pimSGRangeExpPol.children == [] + - cm_enable_multicast.proposed.pimCtxP.children.1.pimASMPatPol.children.2.pimRegTrPol.children == [] + - cm_enable_multicast.proposed.pimCtxP.children.2.pimSSMPatPol.children.0.pimSSMRangePol.children == [] + - nm_enable_multicast is changed + - nm_enable_multicast.current.0.pimCtxP.attributes.annotation == "orchestrator:ansible" + - nm_enable_multicast.current.0.pimCtxP.attributes.dn == "uni/tn-ansible_tenant/ctx-ansible_vrf_1/pimctxp" + - nm_enable_multicast.current.0.pimCtxP.attributes.mtu == "1500" + - nm_enable_multicast.current.0.pimCtxP.attributes.ctrl == "" + - nm_enable_multicast.current.0.pimCtxP.children.0.pimSSMPatPol.children.0.pimSSMRangePol.attributes.name == "" + - nm_enable_multicast.current.0.pimCtxP.children.1.pimASMPatPol.children.0.pimSharedRangePol.attributes.name == "" + - nm_enable_multicast.current.0.pimCtxP.children.1.pimASMPatPol.children.1.pimSGRangeExpPol.attributes.sgExpItvl == "default-timeout" + - nm_enable_multicast.current.0.pimCtxP.children.1.pimASMPatPol.children.2.pimRegTrPol.attributes.maxRate == "65535" + - nm_enable_multicast.current.0.pimCtxP.children.1.pimASMPatPol.children.2.pimRegTrPol.attributes.srcIp == "0.0.0.0" + - nm_enable_multicast.current.0.pimCtxP.children.2.pimResPol.attributes.max == "unlimited" + - nm_enable_multicast.current.0.pimCtxP.children.2.pimResPol.attributes.rsvd == "undefined" + - nm_enable_multicast.previous == [] + - nm_enable_multicast_again is not changed + - nm_enable_multicast_again.current.0.pimCtxP.attributes.annotation == "orchestrator:ansible" + - nm_enable_multicast_again.current.0.pimCtxP.attributes.dn == "uni/tn-ansible_tenant/ctx-ansible_vrf_1/pimctxp" + - nm_enable_multicast_again.current.0.pimCtxP.attributes.mtu == "1500" + - nm_enable_multicast_again.current.0.pimCtxP.attributes.ctrl == "" + - nm_enable_multicast_again.current.0.pimCtxP.children.0.pimSSMPatPol.children.0.pimSSMRangePol.attributes.name == "" + - nm_enable_multicast_again.current.0.pimCtxP.children.1.pimASMPatPol.children.0.pimSharedRangePol.attributes.name == "" + - nm_enable_multicast_again.current.0.pimCtxP.children.1.pimASMPatPol.children.1.pimSGRangeExpPol.attributes.sgExpItvl == "default-timeout" + - nm_enable_multicast_again.current.0.pimCtxP.children.1.pimASMPatPol.children.2.pimRegTrPol.attributes.maxRate == "65535" + - nm_enable_multicast_again.current.0.pimCtxP.children.1.pimASMPatPol.children.2.pimRegTrPol.attributes.srcIp == "0.0.0.0" + - nm_enable_multicast_again.current.0.pimCtxP.children.2.pimResPol.attributes.max == "unlimited" + - nm_enable_multicast_again.current.0.pimCtxP.children.2.pimResPol.attributes.rsvd == "undefined" + - nm_enable_multicast_again.previous.0.pimCtxP.attributes.annotation == "orchestrator:ansible" + - nm_enable_multicast_again.previous.0.pimCtxP.attributes.dn == "uni/tn-ansible_tenant/ctx-ansible_vrf_1/pimctxp" + - nm_enable_multicast_again.previous.0.pimCtxP.attributes.mtu == "1500" + - nm_enable_multicast_again.previous.0.pimCtxP.attributes.ctrl == "" + - nm_enable_multicast_again.previous.0.pimCtxP.children.0.pimSSMPatPol.children.0.pimSSMRangePol.attributes.name == "" + - nm_enable_multicast_again.previous.0.pimCtxP.children.1.pimASMPatPol.children.0.pimSharedRangePol.attributes.name == "" + - nm_enable_multicast_again.previous.0.pimCtxP.children.1.pimASMPatPol.children.1.pimSGRangeExpPol.attributes.sgExpItvl == "default-timeout" + - nm_enable_multicast_again.previous.0.pimCtxP.children.1.pimASMPatPol.children.2.pimRegTrPol.attributes.maxRate == "65535" + - nm_enable_multicast_again.previous.0.pimCtxP.children.1.pimASMPatPol.children.2.pimRegTrPol.attributes.srcIp == "0.0.0.0" + - nm_enable_multicast_again.previous.0.pimCtxP.children.2.pimResPol.attributes.max == "unlimited" + - nm_enable_multicast_again.previous.0.pimCtxP.children.2.pimResPol.attributes.rsvd == "undefined" + +# UPDATE MULTICAST SETTINGS + +- name: Update pim setting on VRF 1 + cisco.aci.aci_vrf_multicast: + <<: *aci_ansible_vrf_1 + pim_setting: + mtu: 2000 + control_state: [ fast, strict ] + register: nm_update_pim_setting + +- name: Remove control_state from pim setting on VRF 1 + cisco.aci.aci_vrf_multicast: + <<: *aci_ansible_vrf_1 + pim_setting: + control_state: [] + register: nm_update_pim_setting_remove_control_state + +- name: Verify update pim setting on VRF 1 + ansible.builtin.assert: + that: + - nm_update_pim_setting is changed + - nm_update_pim_setting.current.0.pimCtxP.attributes.annotation == "orchestrator:ansible" + - nm_update_pim_setting.current.0.pimCtxP.attributes.dn == "uni/tn-ansible_tenant/ctx-ansible_vrf_1/pimctxp" + - nm_update_pim_setting.current.0.pimCtxP.attributes.mtu == "2000" + - nm_update_pim_setting.current.0.pimCtxP.attributes.ctrl == "fast-conv,strict-rfc-compliant" + - nm_update_pim_setting.current.0.pimCtxP.children.0.pimSSMPatPol.children.0.pimSSMRangePol.attributes.name == "" + - nm_update_pim_setting.current.0.pimCtxP.children.1.pimASMPatPol.children.0.pimSharedRangePol.attributes.name == "" + - nm_update_pim_setting.current.0.pimCtxP.children.1.pimASMPatPol.children.1.pimSGRangeExpPol.attributes.sgExpItvl == "default-timeout" + - nm_update_pim_setting.current.0.pimCtxP.children.1.pimASMPatPol.children.2.pimRegTrPol.attributes.maxRate == "65535" + - nm_update_pim_setting.current.0.pimCtxP.children.1.pimASMPatPol.children.2.pimRegTrPol.attributes.srcIp == "0.0.0.0" + - nm_update_pim_setting.current.0.pimCtxP.children.2.pimResPol.attributes.max == "unlimited" + - nm_update_pim_setting.current.0.pimCtxP.children.2.pimResPol.attributes.rsvd == "undefined" + - nm_update_pim_setting.previous.0.pimCtxP.attributes.annotation == "orchestrator:ansible" + - nm_update_pim_setting.previous.0.pimCtxP.attributes.dn == "uni/tn-ansible_tenant/ctx-ansible_vrf_1/pimctxp" + - nm_update_pim_setting.previous.0.pimCtxP.attributes.mtu == "1500" + - nm_update_pim_setting.previous.0.pimCtxP.attributes.ctrl == "" + - nm_update_pim_setting.previous.0.pimCtxP.children.0.pimSSMPatPol.children.0.pimSSMRangePol.attributes.name == "" + - nm_update_pim_setting.previous.0.pimCtxP.children.1.pimASMPatPol.children.0.pimSharedRangePol.attributes.name == "" + - nm_update_pim_setting.previous.0.pimCtxP.children.1.pimASMPatPol.children.1.pimSGRangeExpPol.attributes.sgExpItvl == "default-timeout" + - nm_update_pim_setting.previous.0.pimCtxP.children.1.pimASMPatPol.children.2.pimRegTrPol.attributes.maxRate == "65535" + - nm_update_pim_setting.previous.0.pimCtxP.children.1.pimASMPatPol.children.2.pimRegTrPol.attributes.srcIp == "0.0.0.0" + - nm_update_pim_setting.previous.0.pimCtxP.children.2.pimResPol.attributes.max == "unlimited" + - nm_update_pim_setting.previous.0.pimCtxP.children.2.pimResPol.attributes.rsvd == "undefined" + - nm_update_pim_setting_remove_control_state is changed + - nm_update_pim_setting_remove_control_state.current.0.pimCtxP.attributes.annotation == "orchestrator:ansible" + - nm_update_pim_setting_remove_control_state.current.0.pimCtxP.attributes.dn == "uni/tn-ansible_tenant/ctx-ansible_vrf_1/pimctxp" + - nm_update_pim_setting_remove_control_state.current.0.pimCtxP.attributes.mtu == "2000" + - nm_update_pim_setting_remove_control_state.current.0.pimCtxP.attributes.ctrl == "" + - nm_update_pim_setting_remove_control_state.current.0.pimCtxP.children.0.pimSSMPatPol.children.0.pimSSMRangePol.attributes.name == "" + - nm_update_pim_setting_remove_control_state.current.0.pimCtxP.children.1.pimASMPatPol.children.0.pimSharedRangePol.attributes.name == "" + - nm_update_pim_setting_remove_control_state.current.0.pimCtxP.children.1.pimASMPatPol.children.1.pimSGRangeExpPol.attributes.sgExpItvl == "default-timeout" + - nm_update_pim_setting_remove_control_state.current.0.pimCtxP.children.1.pimASMPatPol.children.2.pimRegTrPol.attributes.maxRate == "65535" + - nm_update_pim_setting_remove_control_state.current.0.pimCtxP.children.1.pimASMPatPol.children.2.pimRegTrPol.attributes.srcIp == "0.0.0.0" + - nm_update_pim_setting_remove_control_state.current.0.pimCtxP.children.2.pimResPol.attributes.max == "unlimited" + - nm_update_pim_setting_remove_control_state.current.0.pimCtxP.children.2.pimResPol.attributes.rsvd == "undefined" + - nm_update_pim_setting_remove_control_state.previous.0.pimCtxP.attributes.annotation == "orchestrator:ansible" + - nm_update_pim_setting_remove_control_state.previous.0.pimCtxP.attributes.dn == "uni/tn-ansible_tenant/ctx-ansible_vrf_1/pimctxp" + - nm_update_pim_setting_remove_control_state.previous.0.pimCtxP.attributes.mtu == "2000" + - nm_update_pim_setting_remove_control_state.previous.0.pimCtxP.attributes.ctrl == "fast-conv,strict-rfc-compliant" + - nm_update_pim_setting_remove_control_state.previous.0.pimCtxP.children.0.pimSSMPatPol.children.0.pimSSMRangePol.attributes.name == "" + - nm_update_pim_setting_remove_control_state.previous.0.pimCtxP.children.1.pimASMPatPol.children.0.pimSharedRangePol.attributes.name == "" + - nm_update_pim_setting_remove_control_state.previous.0.pimCtxP.children.1.pimASMPatPol.children.1.pimSGRangeExpPol.attributes.sgExpItvl == "default-timeout" + - nm_update_pim_setting_remove_control_state.previous.0.pimCtxP.children.1.pimASMPatPol.children.2.pimRegTrPol.attributes.maxRate == "65535" + - nm_update_pim_setting_remove_control_state.previous.0.pimCtxP.children.1.pimASMPatPol.children.2.pimRegTrPol.attributes.srcIp == "0.0.0.0" + - nm_update_pim_setting_remove_control_state.previous.0.pimCtxP.children.2.pimResPol.attributes.max == "unlimited" + - nm_update_pim_setting_remove_control_state.previous.0.pimCtxP.children.2.pimResPol.attributes.rsvd == "undefined" + +# UPDATE MULTICAST RESOURCE POLICY + +- name: Update resource policy on VRF 1 + cisco.aci.aci_vrf_multicast: + <<: *aci_ansible_vrf_1 + resource_policy: + maximum_limit: 100 + register: nm_update_resource_policy + +- name: Add a routemap to resource policy on VRF 1 + cisco.aci.aci_vrf_multicast: + <<: *aci_ansible_vrf_1 + resource_policy: + reserved_multicast_entries: 10 + reserved_route_map: uni/tn-ansible_test/rtmap-ansible_test + register: nm_update_resource_policy_add_route_map + +- name: Update maximum limit from resource policy with routemap on VRF 1 + cisco.aci.aci_vrf_multicast: + <<: *aci_ansible_vrf_1 + resource_policy: + maximum_limit: 50 + register: nm_update_resource_policy_with_route_map + +- name: Remove maximum limit from resource policy on VRF 1 + cisco.aci.aci_vrf_multicast: + <<: *aci_ansible_vrf_1 + resource_policy: + maximum_limit: 0 + register: nm_update_resource_policy_with_route_map_remove_maximum_limit + +- name: Update reserved multicast entries from resource policy on VRF 1 + cisco.aci.aci_vrf_multicast: + <<: *aci_ansible_vrf_1 + resource_policy: + reserved_multicast_entries: 20 + reserved_route_map: uni/tn-ansible_test/rtmap-ansible_test_changed + register: nm_update_resource_policy_change_reserved_multicast_entries + +- name: Remove a routemap from resource policy on VRF 1 + cisco.aci.aci_vrf_multicast: + <<: *aci_ansible_vrf_1 + resource_policy: + reserved_route_map: "" + register: nm_update_resource_policy_remove_route_map + +- name: Remove a routemap from resource policy on VRF 1 again + cisco.aci.aci_vrf_multicast: + <<: *aci_ansible_vrf_1 + resource_policy: + reserved_route_map: "" + register: nm_update_resource_policy_remove_route_map_again + +- name: Verify update resource policy on VRF 1 + ansible.builtin.assert: + that: + - nm_update_resource_policy is changed + - nm_update_resource_policy.current.0.pimCtxP.attributes.annotation == "orchestrator:ansible" + - nm_update_resource_policy.current.0.pimCtxP.attributes.dn == "uni/tn-ansible_tenant/ctx-ansible_vrf_1/pimctxp" + - nm_update_resource_policy.current.0.pimCtxP.attributes.mtu == "2000" + - nm_update_resource_policy.current.0.pimCtxP.attributes.ctrl == "" + - nm_update_resource_policy.current.0.pimCtxP.children.0.pimSSMPatPol.children.0.pimSSMRangePol.attributes.name == "" + - nm_update_resource_policy.current.0.pimCtxP.children.1.pimASMPatPol.children.0.pimSharedRangePol.attributes.name == "" + - nm_update_resource_policy.current.0.pimCtxP.children.1.pimASMPatPol.children.1.pimSGRangeExpPol.attributes.sgExpItvl == "default-timeout" + - nm_update_resource_policy.current.0.pimCtxP.children.1.pimASMPatPol.children.2.pimRegTrPol.attributes.maxRate == "65535" + - nm_update_resource_policy.current.0.pimCtxP.children.1.pimASMPatPol.children.2.pimRegTrPol.attributes.srcIp == "0.0.0.0" + - nm_update_resource_policy.current.0.pimCtxP.children.2.pimResPol.attributes.max == "100" + - nm_update_resource_policy.current.0.pimCtxP.children.2.pimResPol.attributes.rsvd == "undefined" + - nm_update_resource_policy.previous.0.pimCtxP.attributes.annotation == "orchestrator:ansible" + - nm_update_resource_policy.previous.0.pimCtxP.attributes.dn == "uni/tn-ansible_tenant/ctx-ansible_vrf_1/pimctxp" + - nm_update_resource_policy.previous.0.pimCtxP.attributes.mtu == "2000" + - nm_update_resource_policy.previous.0.pimCtxP.attributes.ctrl == "" + - nm_update_resource_policy.previous.0.pimCtxP.children.0.pimSSMPatPol.children.0.pimSSMRangePol.attributes.name == "" + - nm_update_resource_policy.previous.0.pimCtxP.children.1.pimASMPatPol.children.0.pimSharedRangePol.attributes.name == "" + - nm_update_resource_policy.previous.0.pimCtxP.children.1.pimASMPatPol.children.1.pimSGRangeExpPol.attributes.sgExpItvl == "default-timeout" + - nm_update_resource_policy.previous.0.pimCtxP.children.1.pimASMPatPol.children.2.pimRegTrPol.attributes.maxRate == "65535" + - nm_update_resource_policy.previous.0.pimCtxP.children.1.pimASMPatPol.children.2.pimRegTrPol.attributes.srcIp == "0.0.0.0" + - nm_update_resource_policy.previous.0.pimCtxP.children.2.pimResPol.attributes.max == "unlimited" + - nm_update_resource_policy.previous.0.pimCtxP.children.2.pimResPol.attributes.rsvd == "undefined" + - nm_update_resource_policy_add_route_map is changed + - nm_update_resource_policy_add_route_map.current.0.pimCtxP.attributes.annotation == "orchestrator:ansible" + - nm_update_resource_policy_add_route_map.current.0.pimCtxP.attributes.dn == "uni/tn-ansible_tenant/ctx-ansible_vrf_1/pimctxp" + - nm_update_resource_policy_add_route_map.current.0.pimCtxP.attributes.mtu == "2000" + - nm_update_resource_policy_add_route_map.current.0.pimCtxP.attributes.ctrl == "" + - nm_update_resource_policy_add_route_map.current.0.pimCtxP.children.0.pimSSMPatPol.children.0.pimSSMRangePol.attributes.name == "" + - nm_update_resource_policy_add_route_map.current.0.pimCtxP.children.1.pimASMPatPol.children.0.pimSharedRangePol.attributes.name == "" + - nm_update_resource_policy_add_route_map.current.0.pimCtxP.children.1.pimASMPatPol.children.1.pimSGRangeExpPol.attributes.sgExpItvl == "default-timeout" + - nm_update_resource_policy_add_route_map.current.0.pimCtxP.children.1.pimASMPatPol.children.2.pimRegTrPol.attributes.maxRate == "65535" + - nm_update_resource_policy_add_route_map.current.0.pimCtxP.children.1.pimASMPatPol.children.2.pimRegTrPol.attributes.srcIp == "0.0.0.0" + - nm_update_resource_policy_add_route_map.current.0.pimCtxP.children.2.pimResPol.attributes.max == "100" + - nm_update_resource_policy_add_route_map.current.0.pimCtxP.children.2.pimResPol.attributes.rsvd == "10" + - nm_update_resource_policy_add_route_map.current.0.pimCtxP.children.2.pimResPol.children.0.rtdmcRsFilterToRtMapPol.attributes.tDn == "uni/tn-ansible_test/rtmap-ansible_test" + - nm_update_resource_policy_add_route_map.previous.0.pimCtxP.attributes.annotation == "orchestrator:ansible" + - nm_update_resource_policy_add_route_map.previous.0.pimCtxP.attributes.dn == "uni/tn-ansible_tenant/ctx-ansible_vrf_1/pimctxp" + - nm_update_resource_policy_add_route_map.previous.0.pimCtxP.attributes.mtu == "2000" + - nm_update_resource_policy_add_route_map.previous.0.pimCtxP.attributes.ctrl == "" + - nm_update_resource_policy_add_route_map.previous.0.pimCtxP.children.0.pimSSMPatPol.children.0.pimSSMRangePol.attributes.name == "" + - nm_update_resource_policy_add_route_map.previous.0.pimCtxP.children.1.pimASMPatPol.children.0.pimSharedRangePol.attributes.name == "" + - nm_update_resource_policy_add_route_map.previous.0.pimCtxP.children.1.pimASMPatPol.children.1.pimSGRangeExpPol.attributes.sgExpItvl == "default-timeout" + - nm_update_resource_policy_add_route_map.previous.0.pimCtxP.children.1.pimASMPatPol.children.2.pimRegTrPol.attributes.maxRate == "65535" + - nm_update_resource_policy_add_route_map.previous.0.pimCtxP.children.1.pimASMPatPol.children.2.pimRegTrPol.attributes.srcIp == "0.0.0.0" + - nm_update_resource_policy_add_route_map.previous.0.pimCtxP.children.2.pimResPol.attributes.max == "100" + - nm_update_resource_policy_add_route_map.previous.0.pimCtxP.children.2.pimResPol.attributes.rsvd == "undefined" + - "'children' not in nm_update_resource_policy_add_route_map.previous.0.pimCtxP.children.2.pimResPol" + - nm_update_resource_policy_with_route_map is changed + - nm_update_resource_policy_with_route_map.current.0.pimCtxP.attributes.annotation == "orchestrator:ansible" + - nm_update_resource_policy_with_route_map.current.0.pimCtxP.attributes.dn == "uni/tn-ansible_tenant/ctx-ansible_vrf_1/pimctxp" + - nm_update_resource_policy_with_route_map.current.0.pimCtxP.attributes.mtu == "2000" + - nm_update_resource_policy_with_route_map.current.0.pimCtxP.attributes.ctrl == "" + - nm_update_resource_policy_with_route_map.current.0.pimCtxP.children.0.pimSSMPatPol.children.0.pimSSMRangePol.attributes.name == "" + - nm_update_resource_policy_with_route_map.current.0.pimCtxP.children.1.pimASMPatPol.children.0.pimSharedRangePol.attributes.name == "" + - nm_update_resource_policy_with_route_map.current.0.pimCtxP.children.1.pimASMPatPol.children.1.pimSGRangeExpPol.attributes.sgExpItvl == "default-timeout" + - nm_update_resource_policy_with_route_map.current.0.pimCtxP.children.1.pimASMPatPol.children.2.pimRegTrPol.attributes.maxRate == "65535" + - nm_update_resource_policy_with_route_map.current.0.pimCtxP.children.1.pimASMPatPol.children.2.pimRegTrPol.attributes.srcIp == "0.0.0.0" + - nm_update_resource_policy_with_route_map.current.0.pimCtxP.children.2.pimResPol.attributes.max == "50" + - nm_update_resource_policy_with_route_map.current.0.pimCtxP.children.2.pimResPol.attributes.rsvd == "10" + - nm_update_resource_policy_with_route_map.current.0.pimCtxP.children.2.pimResPol.children.0.rtdmcRsFilterToRtMapPol.attributes.tDn == "uni/tn-ansible_test/rtmap-ansible_test" + - nm_update_resource_policy_with_route_map.previous.0.pimCtxP.attributes.annotation == "orchestrator:ansible" + - nm_update_resource_policy_with_route_map.previous.0.pimCtxP.attributes.dn == "uni/tn-ansible_tenant/ctx-ansible_vrf_1/pimctxp" + - nm_update_resource_policy_with_route_map.previous.0.pimCtxP.attributes.mtu == "2000" + - nm_update_resource_policy_with_route_map.previous.0.pimCtxP.attributes.ctrl == "" + - nm_update_resource_policy_with_route_map.previous.0.pimCtxP.children.0.pimSSMPatPol.children.0.pimSSMRangePol.attributes.name == "" + - nm_update_resource_policy_with_route_map.previous.0.pimCtxP.children.1.pimASMPatPol.children.0.pimSharedRangePol.attributes.name == "" + - nm_update_resource_policy_with_route_map.previous.0.pimCtxP.children.1.pimASMPatPol.children.1.pimSGRangeExpPol.attributes.sgExpItvl == "default-timeout" + - nm_update_resource_policy_with_route_map.previous.0.pimCtxP.children.1.pimASMPatPol.children.2.pimRegTrPol.attributes.maxRate == "65535" + - nm_update_resource_policy_with_route_map.previous.0.pimCtxP.children.1.pimASMPatPol.children.2.pimRegTrPol.attributes.srcIp == "0.0.0.0" + - nm_update_resource_policy_with_route_map.previous.0.pimCtxP.children.2.pimResPol.attributes.max == "100" + - nm_update_resource_policy_with_route_map.previous.0.pimCtxP.children.2.pimResPol.attributes.rsvd == "10" + - nm_update_resource_policy_with_route_map.previous.0.pimCtxP.children.2.pimResPol.children.0.rtdmcRsFilterToRtMapPol.attributes.tDn == "uni/tn-ansible_test/rtmap-ansible_test" + - nm_update_resource_policy_with_route_map_remove_maximum_limit is changed + - nm_update_resource_policy_with_route_map_remove_maximum_limit.current.0.pimCtxP.attributes.annotation == "orchestrator:ansible" + - nm_update_resource_policy_with_route_map_remove_maximum_limit.current.0.pimCtxP.attributes.dn == "uni/tn-ansible_tenant/ctx-ansible_vrf_1/pimctxp" + - nm_update_resource_policy_with_route_map_remove_maximum_limit.current.0.pimCtxP.attributes.mtu == "2000" + - nm_update_resource_policy_with_route_map_remove_maximum_limit.current.0.pimCtxP.attributes.ctrl == "" + - nm_update_resource_policy_with_route_map_remove_maximum_limit.current.0.pimCtxP.children.0.pimSSMPatPol.children.0.pimSSMRangePol.attributes.name == "" + - nm_update_resource_policy_with_route_map_remove_maximum_limit.current.0.pimCtxP.children.1.pimASMPatPol.children.0.pimSharedRangePol.attributes.name == "" + - nm_update_resource_policy_with_route_map_remove_maximum_limit.current.0.pimCtxP.children.1.pimASMPatPol.children.1.pimSGRangeExpPol.attributes.sgExpItvl == "default-timeout" + - nm_update_resource_policy_with_route_map_remove_maximum_limit.current.0.pimCtxP.children.1.pimASMPatPol.children.2.pimRegTrPol.attributes.maxRate == "65535" + - nm_update_resource_policy_with_route_map_remove_maximum_limit.current.0.pimCtxP.children.1.pimASMPatPol.children.2.pimRegTrPol.attributes.srcIp == "0.0.0.0" + - nm_update_resource_policy_with_route_map_remove_maximum_limit.current.0.pimCtxP.children.2.pimResPol.attributes.max == "unlimited" + - nm_update_resource_policy_with_route_map_remove_maximum_limit.current.0.pimCtxP.children.2.pimResPol.attributes.rsvd == "10" + - nm_update_resource_policy_with_route_map_remove_maximum_limit.current.0.pimCtxP.children.2.pimResPol.children.0.rtdmcRsFilterToRtMapPol.attributes.tDn == "uni/tn-ansible_test/rtmap-ansible_test" + - nm_update_resource_policy_with_route_map_remove_maximum_limit.previous.0.pimCtxP.attributes.annotation == "orchestrator:ansible" + - nm_update_resource_policy_with_route_map_remove_maximum_limit.previous.0.pimCtxP.attributes.dn == "uni/tn-ansible_tenant/ctx-ansible_vrf_1/pimctxp" + - nm_update_resource_policy_with_route_map_remove_maximum_limit.previous.0.pimCtxP.attributes.mtu == "2000" + - nm_update_resource_policy_with_route_map_remove_maximum_limit.previous.0.pimCtxP.attributes.ctrl == "" + - nm_update_resource_policy_with_route_map_remove_maximum_limit.previous.0.pimCtxP.children.0.pimSSMPatPol.children.0.pimSSMRangePol.attributes.name == "" + - nm_update_resource_policy_with_route_map_remove_maximum_limit.previous.0.pimCtxP.children.1.pimASMPatPol.children.0.pimSharedRangePol.attributes.name == "" + - nm_update_resource_policy_with_route_map_remove_maximum_limit.previous.0.pimCtxP.children.1.pimASMPatPol.children.1.pimSGRangeExpPol.attributes.sgExpItvl == "default-timeout" + - nm_update_resource_policy_with_route_map_remove_maximum_limit.previous.0.pimCtxP.children.1.pimASMPatPol.children.2.pimRegTrPol.attributes.maxRate == "65535" + - nm_update_resource_policy_with_route_map_remove_maximum_limit.previous.0.pimCtxP.children.1.pimASMPatPol.children.2.pimRegTrPol.attributes.srcIp == "0.0.0.0" + - nm_update_resource_policy_with_route_map_remove_maximum_limit.previous.0.pimCtxP.children.2.pimResPol.attributes.max == "50" + - nm_update_resource_policy_with_route_map_remove_maximum_limit.previous.0.pimCtxP.children.2.pimResPol.attributes.rsvd == "10" + - nm_update_resource_policy_with_route_map_remove_maximum_limit.previous.0.pimCtxP.children.2.pimResPol.children.0.rtdmcRsFilterToRtMapPol.attributes.tDn == "uni/tn-ansible_test/rtmap-ansible_test" + - nm_update_resource_policy_change_reserved_multicast_entries is changed + - nm_update_resource_policy_change_reserved_multicast_entries.current.0.pimCtxP.attributes.annotation == "orchestrator:ansible" + - nm_update_resource_policy_change_reserved_multicast_entries.current.0.pimCtxP.attributes.dn == "uni/tn-ansible_tenant/ctx-ansible_vrf_1/pimctxp" + - nm_update_resource_policy_change_reserved_multicast_entries.current.0.pimCtxP.attributes.mtu == "2000" + - nm_update_resource_policy_change_reserved_multicast_entries.current.0.pimCtxP.attributes.ctrl == "" + - nm_update_resource_policy_change_reserved_multicast_entries.current.0.pimCtxP.children.0.pimSSMPatPol.children.0.pimSSMRangePol.attributes.name == "" + - nm_update_resource_policy_change_reserved_multicast_entries.current.0.pimCtxP.children.1.pimASMPatPol.children.0.pimSharedRangePol.attributes.name == "" + - nm_update_resource_policy_change_reserved_multicast_entries.current.0.pimCtxP.children.1.pimASMPatPol.children.1.pimSGRangeExpPol.attributes.sgExpItvl == "default-timeout" + - nm_update_resource_policy_change_reserved_multicast_entries.current.0.pimCtxP.children.1.pimASMPatPol.children.2.pimRegTrPol.attributes.maxRate == "65535" + - nm_update_resource_policy_change_reserved_multicast_entries.current.0.pimCtxP.children.1.pimASMPatPol.children.2.pimRegTrPol.attributes.srcIp == "0.0.0.0" + - nm_update_resource_policy_change_reserved_multicast_entries.current.0.pimCtxP.children.2.pimResPol.attributes.max == "unlimited" + - nm_update_resource_policy_change_reserved_multicast_entries.current.0.pimCtxP.children.2.pimResPol.attributes.rsvd == "20" + - nm_update_resource_policy_change_reserved_multicast_entries.current.0.pimCtxP.children.2.pimResPol.children.0.rtdmcRsFilterToRtMapPol.attributes.tDn == "uni/tn-ansible_test/rtmap-ansible_test_changed" + - nm_update_resource_policy_change_reserved_multicast_entries.previous.0.pimCtxP.attributes.annotation == "orchestrator:ansible" + - nm_update_resource_policy_change_reserved_multicast_entries.previous.0.pimCtxP.attributes.dn == "uni/tn-ansible_tenant/ctx-ansible_vrf_1/pimctxp" + - nm_update_resource_policy_change_reserved_multicast_entries.previous.0.pimCtxP.attributes.mtu == "2000" + - nm_update_resource_policy_change_reserved_multicast_entries.previous.0.pimCtxP.attributes.ctrl == "" + - nm_update_resource_policy_change_reserved_multicast_entries.previous.0.pimCtxP.children.0.pimSSMPatPol.children.0.pimSSMRangePol.attributes.name == "" + - nm_update_resource_policy_change_reserved_multicast_entries.previous.0.pimCtxP.children.1.pimASMPatPol.children.0.pimSharedRangePol.attributes.name == "" + - nm_update_resource_policy_change_reserved_multicast_entries.previous.0.pimCtxP.children.1.pimASMPatPol.children.1.pimSGRangeExpPol.attributes.sgExpItvl == "default-timeout" + - nm_update_resource_policy_change_reserved_multicast_entries.previous.0.pimCtxP.children.1.pimASMPatPol.children.2.pimRegTrPol.attributes.maxRate == "65535" + - nm_update_resource_policy_change_reserved_multicast_entries.previous.0.pimCtxP.children.1.pimASMPatPol.children.2.pimRegTrPol.attributes.srcIp == "0.0.0.0" + - nm_update_resource_policy_change_reserved_multicast_entries.previous.0.pimCtxP.children.2.pimResPol.attributes.max == "unlimited" + - nm_update_resource_policy_change_reserved_multicast_entries.previous.0.pimCtxP.children.2.pimResPol.attributes.rsvd == "10" + - nm_update_resource_policy_change_reserved_multicast_entries.previous.0.pimCtxP.children.2.pimResPol.children.0.rtdmcRsFilterToRtMapPol.attributes.tDn == "uni/tn-ansible_test/rtmap-ansible_test" + - nm_update_resource_policy_remove_route_map is changed + - nm_update_resource_policy_remove_route_map.current.0.pimCtxP.attributes.annotation == "orchestrator:ansible" + - nm_update_resource_policy_remove_route_map.current.0.pimCtxP.attributes.dn == "uni/tn-ansible_tenant/ctx-ansible_vrf_1/pimctxp" + - nm_update_resource_policy_remove_route_map.current.0.pimCtxP.attributes.mtu == "2000" + - nm_update_resource_policy_remove_route_map.current.0.pimCtxP.attributes.ctrl == "" + - nm_update_resource_policy_remove_route_map.current.0.pimCtxP.children.0.pimSSMPatPol.children.0.pimSSMRangePol.attributes.name == "" + - nm_update_resource_policy_remove_route_map.current.0.pimCtxP.children.1.pimASMPatPol.children.0.pimSharedRangePol.attributes.name == "" + - nm_update_resource_policy_remove_route_map.current.0.pimCtxP.children.1.pimASMPatPol.children.1.pimSGRangeExpPol.attributes.sgExpItvl == "default-timeout" + - nm_update_resource_policy_remove_route_map.current.0.pimCtxP.children.1.pimASMPatPol.children.2.pimRegTrPol.attributes.maxRate == "65535" + - nm_update_resource_policy_remove_route_map.current.0.pimCtxP.children.1.pimASMPatPol.children.2.pimRegTrPol.attributes.srcIp == "0.0.0.0" + - nm_update_resource_policy_remove_route_map.current.0.pimCtxP.children.2.pimResPol.attributes.max == "unlimited" + - nm_update_resource_policy_remove_route_map.current.0.pimCtxP.children.2.pimResPol.attributes.rsvd == "undefined" + - "'children' not in nm_update_resource_policy_remove_route_map.current.0.pimCtxP.children.2.pimResPol" + - nm_update_resource_policy_remove_route_map.previous.0.pimCtxP.attributes.annotation == "orchestrator:ansible" + - nm_update_resource_policy_remove_route_map.previous.0.pimCtxP.attributes.dn == "uni/tn-ansible_tenant/ctx-ansible_vrf_1/pimctxp" + - nm_update_resource_policy_remove_route_map.previous.0.pimCtxP.attributes.mtu == "2000" + - nm_update_resource_policy_remove_route_map.previous.0.pimCtxP.attributes.ctrl == "" + - nm_update_resource_policy_remove_route_map.previous.0.pimCtxP.children.0.pimSSMPatPol.children.0.pimSSMRangePol.attributes.name == "" + - nm_update_resource_policy_remove_route_map.previous.0.pimCtxP.children.1.pimASMPatPol.children.0.pimSharedRangePol.attributes.name == "" + - nm_update_resource_policy_remove_route_map.previous.0.pimCtxP.children.1.pimASMPatPol.children.1.pimSGRangeExpPol.attributes.sgExpItvl == "default-timeout" + - nm_update_resource_policy_remove_route_map.previous.0.pimCtxP.children.1.pimASMPatPol.children.2.pimRegTrPol.attributes.maxRate == "65535" + - nm_update_resource_policy_remove_route_map.previous.0.pimCtxP.children.1.pimASMPatPol.children.2.pimRegTrPol.attributes.srcIp == "0.0.0.0" + - nm_update_resource_policy_remove_route_map.previous.0.pimCtxP.children.2.pimResPol.attributes.max == "unlimited" + - nm_update_resource_policy_remove_route_map.previous.0.pimCtxP.children.2.pimResPol.attributes.rsvd == "20" + - nm_update_resource_policy_remove_route_map.previous.0.pimCtxP.children.2.pimResPol.children.0.rtdmcRsFilterToRtMapPol.attributes.tDn == "uni/tn-ansible_test/rtmap-ansible_test_changed" + - nm_update_resource_policy_remove_route_map_again is not changed + +# UPDATE MULTICAST ASM + +- name: Add a shared range routemap to any source multicast on VRF 1 + cisco.aci.aci_vrf_multicast: + <<: *aci_ansible_vrf_1 + any_source_multicast: + shared_range_route_map: uni/tn-ansible_test/rtmap-ansible_test + register: nm_update_any_source_multicast_add_shared_range_route_map + +- name: Remove a shared range routemap from any source multicast on VRF 1 + cisco.aci.aci_vrf_multicast: + <<: *aci_ansible_vrf_1 + any_source_multicast: + shared_range_route_map: "" + register: nm_update_any_source_multicast_remove_shared_range_route_map + +- name: Remove a shared range routemap from any source multicast on VRF 1 again + cisco.aci.aci_vrf_multicast: + <<: *aci_ansible_vrf_1 + any_source_multicast: + shared_range_route_map: "" + register: nm_update_any_source_multicast_remove_shared_range_route_map_again + +- name: Update expiry seconds for any source multicast on VRF 1 + cisco.aci.aci_vrf_multicast: + <<: *aci_ansible_vrf_1 + any_source_multicast: + expiry: 500 + register: nm_update_any_source_multicast_expiry_seconds + +- name: Remove expiry seconds for any source multicast on VRF 1 + cisco.aci.aci_vrf_multicast: + <<: *aci_ansible_vrf_1 + any_source_multicast: + expiry: 0 + register: nm_update_any_source_multicast_remove_expiry_seconds + +- name: Add a source group expiry routemap to any source multicast on VRF 1 + cisco.aci.aci_vrf_multicast: + <<: *aci_ansible_vrf_1 + any_source_multicast: + source_group_expiry_route_map: uni/tn-ansible_test/rtmap-ansible_test + register: nm_update_any_source_multicast_add_source_group_expiry_route_map + +- name: Remove a source group expiry routemap from any source multicast on VRF 1 + cisco.aci.aci_vrf_multicast: + <<: *aci_ansible_vrf_1 + any_source_multicast: + source_group_expiry_route_map: "" + register: nm_update_any_source_multicast_remove_source_group_expiry_route_map + +- name: Remove a source group expiry routemap from any source multicast on VRF 1 again + cisco.aci.aci_vrf_multicast: + <<: *aci_ansible_vrf_1 + any_source_multicast: + source_group_expiry_route_map: "" + register: nm_update_any_source_multicast_remove_source_group_expiry_route_map_again + +- name: Update max rate for any source multicast on VRF 1 + cisco.aci.aci_vrf_multicast: + <<: *aci_ansible_vrf_1 + any_source_multicast: + max_rate: 64000 + register: nm_update_any_source_multicast_max_rate + +- name: Remove max rate for any source multicast on VRF 1 + cisco.aci.aci_vrf_multicast: + <<: *aci_ansible_vrf_1 + any_source_multicast: + source_ip: 1.1.1.1 + register: nm_update_any_source_multicast_ip + +- name: Verify update any source multicast on VRF 1 + ansible.builtin.assert: + that: + - nm_update_any_source_multicast_add_shared_range_route_map is changed + - nm_update_any_source_multicast_add_shared_range_route_map.current.0.pimCtxP.attributes.annotation == "orchestrator:ansible" + - nm_update_any_source_multicast_add_shared_range_route_map.current.0.pimCtxP.attributes.dn == "uni/tn-ansible_tenant/ctx-ansible_vrf_1/pimctxp" + - nm_update_any_source_multicast_add_shared_range_route_map.current.0.pimCtxP.attributes.mtu == "2000" + - nm_update_any_source_multicast_add_shared_range_route_map.current.0.pimCtxP.attributes.ctrl == "" + - nm_update_any_source_multicast_add_shared_range_route_map.current.0.pimCtxP.children.0.pimSSMPatPol.children.0.pimSSMRangePol.attributes.name == "" + - nm_update_any_source_multicast_add_shared_range_route_map.current.0.pimCtxP.children.1.pimASMPatPol.children.0.pimSharedRangePol.attributes.name == "" + - nm_update_any_source_multicast_add_shared_range_route_map.current.0.pimCtxP.children.1.pimASMPatPol.children.0.pimSharedRangePol.children.0.rtdmcRsFilterToRtMapPol.attributes.tDn == "uni/tn-ansible_test/rtmap-ansible_test" + - nm_update_any_source_multicast_add_shared_range_route_map.current.0.pimCtxP.children.1.pimASMPatPol.children.1.pimSGRangeExpPol.attributes.sgExpItvl == "default-timeout" + - nm_update_any_source_multicast_add_shared_range_route_map.current.0.pimCtxP.children.1.pimASMPatPol.children.2.pimRegTrPol.attributes.maxRate == "65535" + - nm_update_any_source_multicast_add_shared_range_route_map.current.0.pimCtxP.children.1.pimASMPatPol.children.2.pimRegTrPol.attributes.srcIp == "0.0.0.0" + - nm_update_any_source_multicast_add_shared_range_route_map.current.0.pimCtxP.children.2.pimResPol.attributes.max == "unlimited" + - nm_update_any_source_multicast_add_shared_range_route_map.current.0.pimCtxP.children.2.pimResPol.attributes.rsvd == "undefined" + - nm_update_any_source_multicast_add_shared_range_route_map.previous.0.pimCtxP.attributes.annotation == "orchestrator:ansible" + - nm_update_any_source_multicast_add_shared_range_route_map.previous.0.pimCtxP.attributes.dn == "uni/tn-ansible_tenant/ctx-ansible_vrf_1/pimctxp" + - nm_update_any_source_multicast_add_shared_range_route_map.previous.0.pimCtxP.attributes.mtu == "2000" + - nm_update_any_source_multicast_add_shared_range_route_map.previous.0.pimCtxP.attributes.ctrl == "" + - nm_update_any_source_multicast_add_shared_range_route_map.previous.0.pimCtxP.children.0.pimSSMPatPol.children.0.pimSSMRangePol.attributes.name == "" + - nm_update_any_source_multicast_add_shared_range_route_map.previous.0.pimCtxP.children.1.pimASMPatPol.children.0.pimSharedRangePol.attributes.name == "" + - "'children' not in nm_update_any_source_multicast_remove_shared_range_route_map.current.0.pimCtxP.children.1.pimASMPatPol.children.0.pimSharedRangePol" + - nm_update_any_source_multicast_add_shared_range_route_map.previous.0.pimCtxP.children.1.pimASMPatPol.children.1.pimSGRangeExpPol.attributes.sgExpItvl == "default-timeout" + - nm_update_any_source_multicast_add_shared_range_route_map.previous.0.pimCtxP.children.1.pimASMPatPol.children.2.pimRegTrPol.attributes.maxRate == "65535" + - nm_update_any_source_multicast_add_shared_range_route_map.previous.0.pimCtxP.children.1.pimASMPatPol.children.2.pimRegTrPol.attributes.srcIp == "0.0.0.0" + - nm_update_any_source_multicast_add_shared_range_route_map.previous.0.pimCtxP.children.2.pimResPol.attributes.max == "unlimited" + - nm_update_any_source_multicast_add_shared_range_route_map.previous.0.pimCtxP.children.2.pimResPol.attributes.rsvd == "undefined" + - nm_update_any_source_multicast_remove_shared_range_route_map is changed + - nm_update_any_source_multicast_remove_shared_range_route_map.current.0.pimCtxP.attributes.annotation == "orchestrator:ansible" + - nm_update_any_source_multicast_remove_shared_range_route_map.current.0.pimCtxP.attributes.dn == "uni/tn-ansible_tenant/ctx-ansible_vrf_1/pimctxp" + - nm_update_any_source_multicast_remove_shared_range_route_map.current.0.pimCtxP.attributes.mtu == "2000" + - nm_update_any_source_multicast_remove_shared_range_route_map.current.0.pimCtxP.attributes.ctrl == "" + - nm_update_any_source_multicast_remove_shared_range_route_map.current.0.pimCtxP.children.0.pimSSMPatPol.children.0.pimSSMRangePol.attributes.name == "" + - nm_update_any_source_multicast_remove_shared_range_route_map.current.0.pimCtxP.children.1.pimASMPatPol.children.0.pimSharedRangePol.attributes.name == "" + - "'children' not in nm_update_any_source_multicast_remove_shared_range_route_map.current.0.pimCtxP.children.1.pimASMPatPol.children.0.pimSharedRangePol" + - nm_update_any_source_multicast_remove_shared_range_route_map.current.0.pimCtxP.children.1.pimASMPatPol.children.1.pimSGRangeExpPol.attributes.sgExpItvl == "default-timeout" + - nm_update_any_source_multicast_remove_shared_range_route_map.current.0.pimCtxP.children.1.pimASMPatPol.children.2.pimRegTrPol.attributes.maxRate == "65535" + - nm_update_any_source_multicast_remove_shared_range_route_map.current.0.pimCtxP.children.1.pimASMPatPol.children.2.pimRegTrPol.attributes.srcIp == "0.0.0.0" + - nm_update_any_source_multicast_remove_shared_range_route_map.current.0.pimCtxP.children.2.pimResPol.attributes.max == "unlimited" + - nm_update_any_source_multicast_remove_shared_range_route_map.current.0.pimCtxP.children.2.pimResPol.attributes.rsvd == "undefined" + - nm_update_any_source_multicast_remove_shared_range_route_map.previous.0.pimCtxP.attributes.annotation == "orchestrator:ansible" + - nm_update_any_source_multicast_remove_shared_range_route_map.previous.0.pimCtxP.attributes.dn == "uni/tn-ansible_tenant/ctx-ansible_vrf_1/pimctxp" + - nm_update_any_source_multicast_remove_shared_range_route_map.previous.0.pimCtxP.attributes.mtu == "2000" + - nm_update_any_source_multicast_remove_shared_range_route_map.previous.0.pimCtxP.attributes.ctrl == "" + - nm_update_any_source_multicast_remove_shared_range_route_map.previous.0.pimCtxP.children.0.pimSSMPatPol.children.0.pimSSMRangePol.attributes.name == "" + - nm_update_any_source_multicast_remove_shared_range_route_map.previous.0.pimCtxP.children.1.pimASMPatPol.children.0.pimSharedRangePol.attributes.name == "" + - nm_update_any_source_multicast_remove_shared_range_route_map.previous.0.pimCtxP.children.1.pimASMPatPol.children.0.pimSharedRangePol.children.0.rtdmcRsFilterToRtMapPol.attributes.tDn == "uni/tn-ansible_test/rtmap-ansible_test" + - nm_update_any_source_multicast_remove_shared_range_route_map.previous.0.pimCtxP.children.1.pimASMPatPol.children.1.pimSGRangeExpPol.attributes.sgExpItvl == "default-timeout" + - nm_update_any_source_multicast_remove_shared_range_route_map.previous.0.pimCtxP.children.1.pimASMPatPol.children.2.pimRegTrPol.attributes.maxRate == "65535" + - nm_update_any_source_multicast_remove_shared_range_route_map.previous.0.pimCtxP.children.1.pimASMPatPol.children.2.pimRegTrPol.attributes.srcIp == "0.0.0.0" + - nm_update_any_source_multicast_remove_shared_range_route_map.previous.0.pimCtxP.children.2.pimResPol.attributes.max == "unlimited" + - nm_update_any_source_multicast_remove_shared_range_route_map.previous.0.pimCtxP.children.2.pimResPol.attributes.rsvd == "undefined" + - nm_update_any_source_multicast_remove_shared_range_route_map_again is not changed + - nm_update_any_source_multicast_expiry_seconds is changed + - nm_update_any_source_multicast_expiry_seconds.current.0.pimCtxP.attributes.annotation == "orchestrator:ansible" + - nm_update_any_source_multicast_expiry_seconds.current.0.pimCtxP.attributes.dn == "uni/tn-ansible_tenant/ctx-ansible_vrf_1/pimctxp" + - nm_update_any_source_multicast_expiry_seconds.current.0.pimCtxP.attributes.mtu == "2000" + - nm_update_any_source_multicast_expiry_seconds.current.0.pimCtxP.attributes.ctrl == "" + - nm_update_any_source_multicast_expiry_seconds.current.0.pimCtxP.children.0.pimSSMPatPol.children.0.pimSSMRangePol.attributes.name == "" + - nm_update_any_source_multicast_expiry_seconds.current.0.pimCtxP.children.1.pimASMPatPol.children.0.pimSharedRangePol.attributes.name == "" + - nm_update_any_source_multicast_expiry_seconds.current.0.pimCtxP.children.1.pimASMPatPol.children.1.pimSGRangeExpPol.attributes.sgExpItvl == "500" + - nm_update_any_source_multicast_expiry_seconds.current.0.pimCtxP.children.1.pimASMPatPol.children.2.pimRegTrPol.attributes.maxRate == "65535" + - nm_update_any_source_multicast_expiry_seconds.current.0.pimCtxP.children.1.pimASMPatPol.children.2.pimRegTrPol.attributes.srcIp == "0.0.0.0" + - nm_update_any_source_multicast_expiry_seconds.current.0.pimCtxP.children.2.pimResPol.attributes.max == "unlimited" + - nm_update_any_source_multicast_expiry_seconds.current.0.pimCtxP.children.2.pimResPol.attributes.rsvd == "undefined" + - nm_update_any_source_multicast_expiry_seconds.previous.0.pimCtxP.attributes.annotation == "orchestrator:ansible" + - nm_update_any_source_multicast_expiry_seconds.previous.0.pimCtxP.attributes.dn == "uni/tn-ansible_tenant/ctx-ansible_vrf_1/pimctxp" + - nm_update_any_source_multicast_expiry_seconds.previous.0.pimCtxP.attributes.mtu == "2000" + - nm_update_any_source_multicast_expiry_seconds.previous.0.pimCtxP.attributes.ctrl == "" + - nm_update_any_source_multicast_expiry_seconds.previous.0.pimCtxP.children.0.pimSSMPatPol.children.0.pimSSMRangePol.attributes.name == "" + - nm_update_any_source_multicast_expiry_seconds.previous.0.pimCtxP.children.1.pimASMPatPol.children.0.pimSharedRangePol.attributes.name == "" + - nm_update_any_source_multicast_expiry_seconds.previous.0.pimCtxP.children.1.pimASMPatPol.children.1.pimSGRangeExpPol.attributes.sgExpItvl == "default-timeout" + - nm_update_any_source_multicast_expiry_seconds.previous.0.pimCtxP.children.1.pimASMPatPol.children.2.pimRegTrPol.attributes.maxRate == "65535" + - nm_update_any_source_multicast_expiry_seconds.previous.0.pimCtxP.children.1.pimASMPatPol.children.2.pimRegTrPol.attributes.srcIp == "0.0.0.0" + - nm_update_any_source_multicast_expiry_seconds.previous.0.pimCtxP.children.2.pimResPol.attributes.max == "unlimited" + - nm_update_any_source_multicast_expiry_seconds.previous.0.pimCtxP.children.2.pimResPol.attributes.rsvd == "undefined" + - nm_update_any_source_multicast_remove_expiry_seconds is changed + - nm_update_any_source_multicast_remove_expiry_seconds.current.0.pimCtxP.attributes.annotation == "orchestrator:ansible" + - nm_update_any_source_multicast_remove_expiry_seconds.current.0.pimCtxP.attributes.dn == "uni/tn-ansible_tenant/ctx-ansible_vrf_1/pimctxp" + - nm_update_any_source_multicast_remove_expiry_seconds.current.0.pimCtxP.attributes.mtu == "2000" + - nm_update_any_source_multicast_remove_expiry_seconds.current.0.pimCtxP.attributes.ctrl == "" + - nm_update_any_source_multicast_remove_expiry_seconds.current.0.pimCtxP.children.0.pimSSMPatPol.children.0.pimSSMRangePol.attributes.name == "" + - nm_update_any_source_multicast_remove_expiry_seconds.current.0.pimCtxP.children.1.pimASMPatPol.children.0.pimSharedRangePol.attributes.name == "" + - nm_update_any_source_multicast_remove_expiry_seconds.current.0.pimCtxP.children.1.pimASMPatPol.children.1.pimSGRangeExpPol.attributes.sgExpItvl == "default-timeout" + - nm_update_any_source_multicast_remove_expiry_seconds.current.0.pimCtxP.children.1.pimASMPatPol.children.2.pimRegTrPol.attributes.maxRate == "65535" + - nm_update_any_source_multicast_remove_expiry_seconds.current.0.pimCtxP.children.1.pimASMPatPol.children.2.pimRegTrPol.attributes.srcIp == "0.0.0.0" + - nm_update_any_source_multicast_remove_expiry_seconds.current.0.pimCtxP.children.2.pimResPol.attributes.max == "unlimited" + - nm_update_any_source_multicast_remove_expiry_seconds.current.0.pimCtxP.children.2.pimResPol.attributes.rsvd == "undefined" + - nm_update_any_source_multicast_remove_expiry_seconds.previous.0.pimCtxP.attributes.annotation == "orchestrator:ansible" + - nm_update_any_source_multicast_remove_expiry_seconds.previous.0.pimCtxP.attributes.dn == "uni/tn-ansible_tenant/ctx-ansible_vrf_1/pimctxp" + - nm_update_any_source_multicast_remove_expiry_seconds.previous.0.pimCtxP.attributes.mtu == "2000" + - nm_update_any_source_multicast_remove_expiry_seconds.previous.0.pimCtxP.attributes.ctrl == "" + - nm_update_any_source_multicast_remove_expiry_seconds.previous.0.pimCtxP.children.0.pimSSMPatPol.children.0.pimSSMRangePol.attributes.name == "" + - nm_update_any_source_multicast_remove_expiry_seconds.previous.0.pimCtxP.children.1.pimASMPatPol.children.0.pimSharedRangePol.attributes.name == "" + - nm_update_any_source_multicast_remove_expiry_seconds.previous.0.pimCtxP.children.1.pimASMPatPol.children.1.pimSGRangeExpPol.attributes.sgExpItvl == "500" + - nm_update_any_source_multicast_remove_expiry_seconds.previous.0.pimCtxP.children.1.pimASMPatPol.children.2.pimRegTrPol.attributes.maxRate == "65535" + - nm_update_any_source_multicast_remove_expiry_seconds.previous.0.pimCtxP.children.1.pimASMPatPol.children.2.pimRegTrPol.attributes.srcIp == "0.0.0.0" + - nm_update_any_source_multicast_remove_expiry_seconds.previous.0.pimCtxP.children.2.pimResPol.attributes.max == "unlimited" + - nm_update_any_source_multicast_remove_expiry_seconds.previous.0.pimCtxP.children.2.pimResPol.attributes.rsvd == "undefined" + - nm_update_any_source_multicast_add_source_group_expiry_route_map is changed + - nm_update_any_source_multicast_add_source_group_expiry_route_map.current.0.pimCtxP.attributes.annotation == "orchestrator:ansible" + - nm_update_any_source_multicast_add_source_group_expiry_route_map.current.0.pimCtxP.attributes.dn == "uni/tn-ansible_tenant/ctx-ansible_vrf_1/pimctxp" + - nm_update_any_source_multicast_add_source_group_expiry_route_map.current.0.pimCtxP.attributes.mtu == "2000" + - nm_update_any_source_multicast_add_source_group_expiry_route_map.current.0.pimCtxP.attributes.ctrl == "" + - nm_update_any_source_multicast_add_source_group_expiry_route_map.current.0.pimCtxP.children.0.pimSSMPatPol.children.0.pimSSMRangePol.attributes.name == "" + - nm_update_any_source_multicast_add_source_group_expiry_route_map.current.0.pimCtxP.children.1.pimASMPatPol.children.0.pimSharedRangePol.attributes.name == "" + - nm_update_any_source_multicast_add_source_group_expiry_route_map.current.0.pimCtxP.children.1.pimASMPatPol.children.1.pimSGRangeExpPol.attributes.sgExpItvl == "default-timeout" + - nm_update_any_source_multicast_add_source_group_expiry_route_map.current.0.pimCtxP.children.1.pimASMPatPol.children.1.pimSGRangeExpPol.children.0.rtdmcRsFilterToRtMapPol.attributes.tDn == "uni/tn-ansible_test/rtmap-ansible_test" + - nm_update_any_source_multicast_add_source_group_expiry_route_map.current.0.pimCtxP.children.1.pimASMPatPol.children.2.pimRegTrPol.attributes.maxRate == "65535" + - nm_update_any_source_multicast_add_source_group_expiry_route_map.current.0.pimCtxP.children.1.pimASMPatPol.children.2.pimRegTrPol.attributes.srcIp == "0.0.0.0" + - nm_update_any_source_multicast_add_source_group_expiry_route_map.current.0.pimCtxP.children.2.pimResPol.attributes.max == "unlimited" + - nm_update_any_source_multicast_add_source_group_expiry_route_map.current.0.pimCtxP.children.2.pimResPol.attributes.rsvd == "undefined" + - nm_update_any_source_multicast_add_source_group_expiry_route_map.previous.0.pimCtxP.attributes.annotation == "orchestrator:ansible" + - nm_update_any_source_multicast_add_source_group_expiry_route_map.previous.0.pimCtxP.attributes.dn == "uni/tn-ansible_tenant/ctx-ansible_vrf_1/pimctxp" + - nm_update_any_source_multicast_add_source_group_expiry_route_map.previous.0.pimCtxP.attributes.mtu == "2000" + - nm_update_any_source_multicast_add_source_group_expiry_route_map.previous.0.pimCtxP.attributes.ctrl == "" + - nm_update_any_source_multicast_add_source_group_expiry_route_map.previous.0.pimCtxP.children.0.pimSSMPatPol.children.0.pimSSMRangePol.attributes.name == "" + - nm_update_any_source_multicast_add_source_group_expiry_route_map.previous.0.pimCtxP.children.1.pimASMPatPol.children.0.pimSharedRangePol.attributes.name == "" + - nm_update_any_source_multicast_add_source_group_expiry_route_map.previous.0.pimCtxP.children.1.pimASMPatPol.children.1.pimSGRangeExpPol.attributes.sgExpItvl == "default-timeout" + - "'children' not in nm_update_any_source_multicast_add_source_group_expiry_route_map.previous.0.pimCtxP.children.1.pimASMPatPol.children.1.pimSGRangeExpPol" + - nm_update_any_source_multicast_add_source_group_expiry_route_map.previous.0.pimCtxP.children.1.pimASMPatPol.children.2.pimRegTrPol.attributes.maxRate == "65535" + - nm_update_any_source_multicast_add_source_group_expiry_route_map.previous.0.pimCtxP.children.1.pimASMPatPol.children.2.pimRegTrPol.attributes.srcIp == "0.0.0.0" + - nm_update_any_source_multicast_add_source_group_expiry_route_map.previous.0.pimCtxP.children.2.pimResPol.attributes.max == "unlimited" + - nm_update_any_source_multicast_add_source_group_expiry_route_map.previous.0.pimCtxP.children.2.pimResPol.attributes.rsvd == "undefined" + - nm_update_any_source_multicast_remove_source_group_expiry_route_map is changed + - nm_update_any_source_multicast_remove_source_group_expiry_route_map.current.0.pimCtxP.attributes.annotation == "orchestrator:ansible" + - nm_update_any_source_multicast_remove_source_group_expiry_route_map.current.0.pimCtxP.attributes.dn == "uni/tn-ansible_tenant/ctx-ansible_vrf_1/pimctxp" + - nm_update_any_source_multicast_remove_source_group_expiry_route_map.current.0.pimCtxP.attributes.mtu == "2000" + - nm_update_any_source_multicast_remove_source_group_expiry_route_map.current.0.pimCtxP.attributes.ctrl == "" + - nm_update_any_source_multicast_remove_source_group_expiry_route_map.current.0.pimCtxP.children.0.pimSSMPatPol.children.0.pimSSMRangePol.attributes.name == "" + - nm_update_any_source_multicast_remove_source_group_expiry_route_map.current.0.pimCtxP.children.1.pimASMPatPol.children.0.pimSharedRangePol.attributes.name == "" + - nm_update_any_source_multicast_remove_source_group_expiry_route_map.current.0.pimCtxP.children.1.pimASMPatPol.children.1.pimSGRangeExpPol.attributes.sgExpItvl == "default-timeout" + - "'children' not in nm_update_any_source_multicast_remove_source_group_expiry_route_map.current.0.pimCtxP.children.1.pimASMPatPol.children.1.pimSGRangeExpPol" + - nm_update_any_source_multicast_remove_source_group_expiry_route_map.current.0.pimCtxP.children.1.pimASMPatPol.children.2.pimRegTrPol.attributes.maxRate == "65535" + - nm_update_any_source_multicast_remove_source_group_expiry_route_map.current.0.pimCtxP.children.1.pimASMPatPol.children.2.pimRegTrPol.attributes.srcIp == "0.0.0.0" + - nm_update_any_source_multicast_remove_source_group_expiry_route_map.current.0.pimCtxP.children.2.pimResPol.attributes.max == "unlimited" + - nm_update_any_source_multicast_remove_source_group_expiry_route_map.current.0.pimCtxP.children.2.pimResPol.attributes.rsvd == "undefined" + - nm_update_any_source_multicast_remove_source_group_expiry_route_map.previous.0.pimCtxP.attributes.annotation == "orchestrator:ansible" + - nm_update_any_source_multicast_remove_source_group_expiry_route_map.previous.0.pimCtxP.attributes.dn == "uni/tn-ansible_tenant/ctx-ansible_vrf_1/pimctxp" + - nm_update_any_source_multicast_remove_source_group_expiry_route_map.previous.0.pimCtxP.attributes.mtu == "2000" + - nm_update_any_source_multicast_remove_source_group_expiry_route_map.previous.0.pimCtxP.attributes.ctrl == "" + - nm_update_any_source_multicast_remove_source_group_expiry_route_map.previous.0.pimCtxP.children.0.pimSSMPatPol.children.0.pimSSMRangePol.attributes.name == "" + - nm_update_any_source_multicast_remove_source_group_expiry_route_map.previous.0.pimCtxP.children.1.pimASMPatPol.children.0.pimSharedRangePol.attributes.name == "" + - nm_update_any_source_multicast_remove_source_group_expiry_route_map.previous.0.pimCtxP.children.1.pimASMPatPol.children.1.pimSGRangeExpPol.attributes.sgExpItvl == "default-timeout" + - nm_update_any_source_multicast_remove_source_group_expiry_route_map.previous.0.pimCtxP.children.1.pimASMPatPol.children.1.pimSGRangeExpPol.children.0.rtdmcRsFilterToRtMapPol.attributes.tDn == "uni/tn-ansible_test/rtmap-ansible_test" + - nm_update_any_source_multicast_remove_source_group_expiry_route_map.previous.0.pimCtxP.children.1.pimASMPatPol.children.2.pimRegTrPol.attributes.maxRate == "65535" + - nm_update_any_source_multicast_remove_source_group_expiry_route_map.previous.0.pimCtxP.children.1.pimASMPatPol.children.2.pimRegTrPol.attributes.srcIp == "0.0.0.0" + - nm_update_any_source_multicast_remove_source_group_expiry_route_map.previous.0.pimCtxP.children.2.pimResPol.attributes.max == "unlimited" + - nm_update_any_source_multicast_remove_source_group_expiry_route_map.previous.0.pimCtxP.children.2.pimResPol.attributes.rsvd == "undefined" + - nm_update_any_source_multicast_remove_source_group_expiry_route_map_again is not changed + - nm_update_any_source_multicast_max_rate is changed + - nm_update_any_source_multicast_max_rate.current.0.pimCtxP.attributes.annotation == "orchestrator:ansible" + - nm_update_any_source_multicast_max_rate.current.0.pimCtxP.attributes.dn == "uni/tn-ansible_tenant/ctx-ansible_vrf_1/pimctxp" + - nm_update_any_source_multicast_max_rate.current.0.pimCtxP.attributes.mtu == "2000" + - nm_update_any_source_multicast_max_rate.current.0.pimCtxP.attributes.ctrl == "" + - nm_update_any_source_multicast_max_rate.current.0.pimCtxP.children.0.pimSSMPatPol.children.0.pimSSMRangePol.attributes.name == "" + - nm_update_any_source_multicast_max_rate.current.0.pimCtxP.children.1.pimASMPatPol.children.0.pimSharedRangePol.attributes.name == "" + - nm_update_any_source_multicast_max_rate.current.0.pimCtxP.children.1.pimASMPatPol.children.1.pimSGRangeExpPol.attributes.sgExpItvl == "default-timeout" + - nm_update_any_source_multicast_max_rate.current.0.pimCtxP.children.1.pimASMPatPol.children.2.pimRegTrPol.attributes.maxRate == "64000" + - nm_update_any_source_multicast_max_rate.current.0.pimCtxP.children.1.pimASMPatPol.children.2.pimRegTrPol.attributes.srcIp == "0.0.0.0" + - nm_update_any_source_multicast_max_rate.current.0.pimCtxP.children.2.pimResPol.attributes.max == "unlimited" + - nm_update_any_source_multicast_max_rate.current.0.pimCtxP.children.2.pimResPol.attributes.rsvd == "undefined" + - nm_update_any_source_multicast_max_rate.previous.0.pimCtxP.attributes.annotation == "orchestrator:ansible" + - nm_update_any_source_multicast_max_rate.previous.0.pimCtxP.attributes.dn == "uni/tn-ansible_tenant/ctx-ansible_vrf_1/pimctxp" + - nm_update_any_source_multicast_max_rate.previous.0.pimCtxP.attributes.mtu == "2000" + - nm_update_any_source_multicast_max_rate.previous.0.pimCtxP.attributes.ctrl == "" + - nm_update_any_source_multicast_max_rate.previous.0.pimCtxP.children.0.pimSSMPatPol.children.0.pimSSMRangePol.attributes.name == "" + - nm_update_any_source_multicast_max_rate.previous.0.pimCtxP.children.1.pimASMPatPol.children.0.pimSharedRangePol.attributes.name == "" + - nm_update_any_source_multicast_max_rate.previous.0.pimCtxP.children.1.pimASMPatPol.children.1.pimSGRangeExpPol.attributes.sgExpItvl == "default-timeout" + - nm_update_any_source_multicast_max_rate.previous.0.pimCtxP.children.1.pimASMPatPol.children.2.pimRegTrPol.attributes.maxRate == "65535" + - nm_update_any_source_multicast_max_rate.previous.0.pimCtxP.children.1.pimASMPatPol.children.2.pimRegTrPol.attributes.srcIp == "0.0.0.0" + - nm_update_any_source_multicast_max_rate.previous.0.pimCtxP.children.2.pimResPol.attributes.max == "unlimited" + - nm_update_any_source_multicast_max_rate.previous.0.pimCtxP.children.2.pimResPol.attributes.rsvd == "undefined" + - nm_update_any_source_multicast_ip is changed + - nm_update_any_source_multicast_ip.current.0.pimCtxP.attributes.annotation == "orchestrator:ansible" + - nm_update_any_source_multicast_ip.current.0.pimCtxP.attributes.dn == "uni/tn-ansible_tenant/ctx-ansible_vrf_1/pimctxp" + - nm_update_any_source_multicast_ip.current.0.pimCtxP.attributes.mtu == "2000" + - nm_update_any_source_multicast_ip.current.0.pimCtxP.attributes.ctrl == "" + - nm_update_any_source_multicast_ip.current.0.pimCtxP.children.0.pimSSMPatPol.children.0.pimSSMRangePol.attributes.name == "" + - nm_update_any_source_multicast_ip.current.0.pimCtxP.children.1.pimASMPatPol.children.0.pimSharedRangePol.attributes.name == "" + - nm_update_any_source_multicast_ip.current.0.pimCtxP.children.1.pimASMPatPol.children.1.pimSGRangeExpPol.attributes.sgExpItvl == "default-timeout" + - nm_update_any_source_multicast_ip.current.0.pimCtxP.children.1.pimASMPatPol.children.2.pimRegTrPol.attributes.maxRate == "64000" + - nm_update_any_source_multicast_ip.current.0.pimCtxP.children.1.pimASMPatPol.children.2.pimRegTrPol.attributes.srcIp == "1.1.1.1" + - nm_update_any_source_multicast_ip.current.0.pimCtxP.children.2.pimResPol.attributes.max == "unlimited" + - nm_update_any_source_multicast_ip.current.0.pimCtxP.children.2.pimResPol.attributes.rsvd == "undefined" + - nm_update_any_source_multicast_ip.previous.0.pimCtxP.attributes.annotation == "orchestrator:ansible" + - nm_update_any_source_multicast_ip.previous.0.pimCtxP.attributes.dn == "uni/tn-ansible_tenant/ctx-ansible_vrf_1/pimctxp" + - nm_update_any_source_multicast_ip.previous.0.pimCtxP.attributes.mtu == "2000" + - nm_update_any_source_multicast_ip.previous.0.pimCtxP.attributes.ctrl == "" + - nm_update_any_source_multicast_ip.previous.0.pimCtxP.children.0.pimSSMPatPol.children.0.pimSSMRangePol.attributes.name == "" + - nm_update_any_source_multicast_ip.previous.0.pimCtxP.children.1.pimASMPatPol.children.0.pimSharedRangePol.attributes.name == "" + - nm_update_any_source_multicast_ip.previous.0.pimCtxP.children.1.pimASMPatPol.children.1.pimSGRangeExpPol.attributes.sgExpItvl == "default-timeout" + - nm_update_any_source_multicast_ip.previous.0.pimCtxP.children.1.pimASMPatPol.children.2.pimRegTrPol.attributes.maxRate == "64000" + - nm_update_any_source_multicast_ip.previous.0.pimCtxP.children.1.pimASMPatPol.children.2.pimRegTrPol.attributes.srcIp == "0.0.0.0" + - nm_update_any_source_multicast_ip.previous.0.pimCtxP.children.2.pimResPol.attributes.max == "unlimited" + - nm_update_any_source_multicast_ip.previous.0.pimCtxP.children.2.pimResPol.attributes.rsvd == "undefined" + +# UPDATE MULTICAST SSM + +- name: Add a routemap to source specific multicast on VRF 1 + cisco.aci.aci_vrf_multicast: + <<: *aci_ansible_vrf_1 + source_specific_multicast: + group_range_route_map: uni/tn-ansible_test/rtmap-ansible_test + register: nm_update_source_specific_multicast_add_route_map + +- name: Remove a routemap from source specific multicast on VRF 1 + cisco.aci.aci_vrf_multicast: + <<: *aci_ansible_vrf_1 + source_specific_multicast: + group_range_route_map: "" + register: nm_update_source_specific_multicast_remove_route_map + +- name: Remove a routemap from source specific multicast on VRF 1 again + cisco.aci.aci_vrf_multicast: + <<: *aci_ansible_vrf_1 + source_specific_multicast: + group_range_route_map: "" + register: nm_update_source_specific_multicast_remove_route_map_again + +- name: Verify update source specific multicast on VRF 1 + ansible.builtin.assert: + that: + - nm_update_source_specific_multicast_add_route_map is changed + - nm_update_source_specific_multicast_add_route_map.current.0.pimCtxP.attributes.annotation == "orchestrator:ansible" + - nm_update_source_specific_multicast_add_route_map.current.0.pimCtxP.attributes.dn == "uni/tn-ansible_tenant/ctx-ansible_vrf_1/pimctxp" + - nm_update_source_specific_multicast_add_route_map.current.0.pimCtxP.attributes.mtu == "2000" + - nm_update_source_specific_multicast_add_route_map.current.0.pimCtxP.attributes.ctrl == "" + - nm_update_source_specific_multicast_add_route_map.current.0.pimCtxP.children.0.pimSSMPatPol.children.0.pimSSMRangePol.attributes.name == "" + - nm_update_source_specific_multicast_add_route_map.current.0.pimCtxP.children.0.pimSSMPatPol.children.0.pimSSMRangePol.children.0.rtdmcRsFilterToRtMapPol.attributes.tDn == "uni/tn-ansible_test/rtmap-ansible_test" + - nm_update_source_specific_multicast_add_route_map.current.0.pimCtxP.children.1.pimASMPatPol.children.0.pimSharedRangePol.attributes.name == "" + - nm_update_source_specific_multicast_add_route_map.current.0.pimCtxP.children.1.pimASMPatPol.children.1.pimSGRangeExpPol.attributes.sgExpItvl == "default-timeout" + - nm_update_source_specific_multicast_add_route_map.current.0.pimCtxP.children.1.pimASMPatPol.children.2.pimRegTrPol.attributes.maxRate == "64000" + - nm_update_source_specific_multicast_add_route_map.current.0.pimCtxP.children.1.pimASMPatPol.children.2.pimRegTrPol.attributes.srcIp == "1.1.1.1" + - nm_update_source_specific_multicast_add_route_map.current.0.pimCtxP.children.2.pimResPol.attributes.max == "unlimited" + - nm_update_source_specific_multicast_add_route_map.current.0.pimCtxP.children.2.pimResPol.attributes.rsvd == "undefined" + - nm_update_source_specific_multicast_add_route_map.previous.0.pimCtxP.attributes.annotation == "orchestrator:ansible" + - nm_update_source_specific_multicast_add_route_map.previous.0.pimCtxP.attributes.dn == "uni/tn-ansible_tenant/ctx-ansible_vrf_1/pimctxp" + - nm_update_source_specific_multicast_add_route_map.previous.0.pimCtxP.attributes.mtu == "2000" + - nm_update_source_specific_multicast_add_route_map.previous.0.pimCtxP.attributes.ctrl == "" + - nm_update_source_specific_multicast_add_route_map.previous.0.pimCtxP.children.0.pimSSMPatPol.children.0.pimSSMRangePol.attributes.name == "" + - "'children' not in nm_update_source_specific_multicast_add_route_map.previous.0.pimCtxP.children.0.pimSSMPatPol.children.0.pimSSMRangePol" + - nm_update_source_specific_multicast_add_route_map.previous.0.pimCtxP.children.1.pimASMPatPol.children.0.pimSharedRangePol.attributes.name == "" + - nm_update_source_specific_multicast_add_route_map.previous.0.pimCtxP.children.1.pimASMPatPol.children.1.pimSGRangeExpPol.attributes.sgExpItvl == "default-timeout" + - nm_update_source_specific_multicast_add_route_map.previous.0.pimCtxP.children.1.pimASMPatPol.children.2.pimRegTrPol.attributes.maxRate == "64000" + - nm_update_source_specific_multicast_add_route_map.previous.0.pimCtxP.children.1.pimASMPatPol.children.2.pimRegTrPol.attributes.srcIp == "1.1.1.1" + - nm_update_source_specific_multicast_add_route_map.previous.0.pimCtxP.children.2.pimResPol.attributes.max == "unlimited" + - nm_update_source_specific_multicast_add_route_map.previous.0.pimCtxP.children.2.pimResPol.attributes.rsvd == "undefined" + - nm_update_source_specific_multicast_remove_route_map is changed + - nm_update_source_specific_multicast_remove_route_map.current.0.pimCtxP.attributes.annotation == "orchestrator:ansible" + - nm_update_source_specific_multicast_remove_route_map.current.0.pimCtxP.attributes.dn == "uni/tn-ansible_tenant/ctx-ansible_vrf_1/pimctxp" + - nm_update_source_specific_multicast_remove_route_map.current.0.pimCtxP.attributes.mtu == "2000" + - nm_update_source_specific_multicast_remove_route_map.current.0.pimCtxP.attributes.ctrl == "" + - nm_update_source_specific_multicast_remove_route_map.current.0.pimCtxP.children.0.pimSSMPatPol.children.0.pimSSMRangePol.attributes.name == "" + - "'children' not in nm_update_source_specific_multicast_remove_route_map.current.0.pimCtxP.children.0.pimSSMPatPol.children.0.pimSSMRangePol" + - nm_update_source_specific_multicast_remove_route_map.current.0.pimCtxP.children.1.pimASMPatPol.children.0.pimSharedRangePol.attributes.name == "" + - nm_update_source_specific_multicast_remove_route_map.current.0.pimCtxP.children.1.pimASMPatPol.children.1.pimSGRangeExpPol.attributes.sgExpItvl == "default-timeout" + - nm_update_source_specific_multicast_remove_route_map.current.0.pimCtxP.children.1.pimASMPatPol.children.2.pimRegTrPol.attributes.maxRate == "64000" + - nm_update_source_specific_multicast_remove_route_map.current.0.pimCtxP.children.1.pimASMPatPol.children.2.pimRegTrPol.attributes.srcIp == "1.1.1.1" + - nm_update_source_specific_multicast_remove_route_map.current.0.pimCtxP.children.2.pimResPol.attributes.max == "unlimited" + - nm_update_source_specific_multicast_remove_route_map.current.0.pimCtxP.children.2.pimResPol.attributes.rsvd == "undefined" + - nm_update_source_specific_multicast_remove_route_map.previous.0.pimCtxP.attributes.annotation == "orchestrator:ansible" + - nm_update_source_specific_multicast_remove_route_map.previous.0.pimCtxP.attributes.dn == "uni/tn-ansible_tenant/ctx-ansible_vrf_1/pimctxp" + - nm_update_source_specific_multicast_remove_route_map.previous.0.pimCtxP.attributes.mtu == "2000" + - nm_update_source_specific_multicast_remove_route_map.previous.0.pimCtxP.attributes.ctrl == "" + - nm_update_source_specific_multicast_remove_route_map.previous.0.pimCtxP.children.0.pimSSMPatPol.children.0.pimSSMRangePol.attributes.name == "" + - nm_update_source_specific_multicast_remove_route_map.previous.0.pimCtxP.children.0.pimSSMPatPol.children.0.pimSSMRangePol.children.0.rtdmcRsFilterToRtMapPol.attributes.tDn == "uni/tn-ansible_test/rtmap-ansible_test" + - nm_update_source_specific_multicast_remove_route_map.previous.0.pimCtxP.children.1.pimASMPatPol.children.0.pimSharedRangePol.attributes.name == "" + - nm_update_source_specific_multicast_remove_route_map.previous.0.pimCtxP.children.1.pimASMPatPol.children.1.pimSGRangeExpPol.attributes.sgExpItvl == "default-timeout" + - nm_update_source_specific_multicast_remove_route_map.previous.0.pimCtxP.children.1.pimASMPatPol.children.2.pimRegTrPol.attributes.maxRate == "64000" + - nm_update_source_specific_multicast_remove_route_map.previous.0.pimCtxP.children.1.pimASMPatPol.children.2.pimRegTrPol.attributes.srcIp == "1.1.1.1" + - nm_update_source_specific_multicast_remove_route_map.previous.0.pimCtxP.children.2.pimResPol.attributes.max == "unlimited" + - nm_update_source_specific_multicast_remove_route_map.previous.0.pimCtxP.children.2.pimResPol.attributes.rsvd == "undefined" + - nm_update_source_specific_multicast_remove_route_map_again is not changed + +# UPDATE MULTICAST BOOTSTRAP ROUTER (BSR) + +- name: Add a routemap to bootstrap router on VRF 1 + cisco.aci.aci_vrf_multicast: + <<: *aci_ansible_vrf_1 + bootstrap_router: + bsr_filter: uni/tn-ansible_test/rtmap-ansible_test + register: nm_update_bootstrap_router_add_route_map + +- name: Remove a routemap to bootstrap router on VRF 1 + cisco.aci.aci_vrf_multicast: + <<: *aci_ansible_vrf_1 + bootstrap_router: + bsr_filter: "" + register: nm_update_bootstrap_router_remove_route_map + +- name: Update bootstrap router on VRF 1 + cisco.aci.aci_vrf_multicast: + <<: *aci_ansible_vrf_1 + bootstrap_router: + rp_updates: [ forward, listen ] + register: nm_update_bootstrap_router + +- name: Remove rp_updates for bootstrap router on VRF 1 + cisco.aci.aci_vrf_multicast: + <<: *aci_ansible_vrf_1 + bootstrap_router: + rp_updates: [] + register: nm_update_bootstrap_router_remove_rp_updates + +- name: Verify update bootstrap router on VRF 1 + ansible.builtin.assert: + that: + - nm_update_bootstrap_router_add_route_map is changed + - nm_update_bootstrap_router_add_route_map.current.0.pimCtxP.attributes.dn == "uni/tn-ansible_tenant/ctx-ansible_vrf_1/pimctxp" + - nm_update_bootstrap_router_add_route_map.current.0.pimCtxP.attributes.mtu == "2000" + - nm_update_bootstrap_router_add_route_map.current.0.pimCtxP.attributes.ctrl == "" + - nm_update_bootstrap_router_add_route_map.current.0.pimCtxP.children.0.pimSSMPatPol.children.0.pimSSMRangePol.attributes.name == "" + - nm_update_bootstrap_router_add_route_map.current.0.pimCtxP.children.1.pimResPol.attributes.max == "unlimited" + - nm_update_bootstrap_router_add_route_map.current.0.pimCtxP.children.1.pimResPol.attributes.rsvd == "undefined" + - nm_update_bootstrap_router_add_route_map.current.0.pimCtxP.children.2.pimASMPatPol.children.0.pimSharedRangePol.attributes.name == "" + - nm_update_bootstrap_router_add_route_map.current.0.pimCtxP.children.2.pimASMPatPol.children.1.pimSGRangeExpPol.attributes.sgExpItvl == "default-timeout" + - nm_update_bootstrap_router_add_route_map.current.0.pimCtxP.children.2.pimASMPatPol.children.2.pimRegTrPol.attributes.maxRate == "64000" + - nm_update_bootstrap_router_add_route_map.current.0.pimCtxP.children.2.pimASMPatPol.children.2.pimRegTrPol.attributes.srcIp == "1.1.1.1" + - nm_update_bootstrap_router_add_route_map.current.0.pimCtxP.children.3.pimBSRPPol.children.0.pimBSRFilterPol.children.0.rtdmcRsFilterToRtMapPol.attributes.tDn == "uni/tn-ansible_test/rtmap-ansible_test" + - nm_update_bootstrap_router_add_route_map.current.0.pimCtxP.children.3.pimBSRPPol.attributes.ctrl == "" + - nm_update_bootstrap_router_add_route_map.previous.0.pimCtxP.attributes.annotation == "orchestrator:ansible" + - nm_update_bootstrap_router_add_route_map.previous.0.pimCtxP.attributes.dn == "uni/tn-ansible_tenant/ctx-ansible_vrf_1/pimctxp" + - nm_update_bootstrap_router_add_route_map.previous.0.pimCtxP.attributes.mtu == "2000" + - nm_update_bootstrap_router_add_route_map.previous.0.pimCtxP.attributes.ctrl == "" + - nm_update_bootstrap_router_add_route_map.previous.0.pimCtxP.children.0.pimSSMPatPol.children.0.pimSSMRangePol.attributes.name == "" + - nm_update_bootstrap_router_add_route_map.previous.0.pimCtxP.children.1.pimASMPatPol.children.0.pimSharedRangePol.attributes.name == "" + - nm_update_bootstrap_router_add_route_map.previous.0.pimCtxP.children.1.pimASMPatPol.children.1.pimSGRangeExpPol.attributes.sgExpItvl == "default-timeout" + - nm_update_bootstrap_router_add_route_map.previous.0.pimCtxP.children.1.pimASMPatPol.children.2.pimRegTrPol.attributes.maxRate == "64000" + - nm_update_bootstrap_router_add_route_map.previous.0.pimCtxP.children.1.pimASMPatPol.children.2.pimRegTrPol.attributes.srcIp == "1.1.1.1" + - nm_update_bootstrap_router_add_route_map.previous.0.pimCtxP.children.2.pimResPol.attributes.max == "unlimited" + - nm_update_bootstrap_router_add_route_map.previous.0.pimCtxP.children.2.pimResPol.attributes.rsvd == "undefined" + - nm_update_bootstrap_router_add_route_map.previous.0.pimCtxP.children | length == 3 + - nm_update_bootstrap_router_remove_route_map is changed + - nm_update_bootstrap_router_remove_route_map.current.0.pimCtxP.attributes.dn == "uni/tn-ansible_tenant/ctx-ansible_vrf_1/pimctxp" + - nm_update_bootstrap_router_remove_route_map.current.0.pimCtxP.attributes.mtu == "2000" + - nm_update_bootstrap_router_remove_route_map.current.0.pimCtxP.attributes.ctrl == "" + - nm_update_bootstrap_router_remove_route_map.current.0.pimCtxP.children.0.pimSSMPatPol.children.0.pimSSMRangePol.attributes.name == "" + - nm_update_bootstrap_router_remove_route_map.current.0.pimCtxP.children.1.pimResPol.attributes.max == "unlimited" + - nm_update_bootstrap_router_remove_route_map.current.0.pimCtxP.children.1.pimResPol.attributes.rsvd == "undefined" + - nm_update_bootstrap_router_remove_route_map.current.0.pimCtxP.children.2.pimASMPatPol.children.0.pimSharedRangePol.attributes.name == "" + - nm_update_bootstrap_router_remove_route_map.current.0.pimCtxP.children.2.pimASMPatPol.children.1.pimSGRangeExpPol.attributes.sgExpItvl == "default-timeout" + - nm_update_bootstrap_router_remove_route_map.current.0.pimCtxP.children.2.pimASMPatPol.children.2.pimRegTrPol.attributes.maxRate == "64000" + - nm_update_bootstrap_router_remove_route_map.current.0.pimCtxP.children.2.pimASMPatPol.children.2.pimRegTrPol.attributes.srcIp == "1.1.1.1" + - "'children' not in nm_update_bootstrap_router_remove_route_map.current.0.pimCtxP.children.3.pimBSRPPol.children.0.pimBSRFilterPol" + - nm_update_bootstrap_router_remove_route_map.current.0.pimCtxP.children.3.pimBSRPPol.attributes.ctrl == "" + - nm_update_bootstrap_router_remove_route_map.previous.0.pimCtxP.attributes.dn == "uni/tn-ansible_tenant/ctx-ansible_vrf_1/pimctxp" + - nm_update_bootstrap_router_remove_route_map.previous.0.pimCtxP.attributes.mtu == "2000" + - nm_update_bootstrap_router_remove_route_map.previous.0.pimCtxP.attributes.ctrl == "" + - nm_update_bootstrap_router_remove_route_map.previous.0.pimCtxP.children.0.pimSSMPatPol.children.0.pimSSMRangePol.attributes.name == "" + - nm_update_bootstrap_router_remove_route_map.previous.0.pimCtxP.children.1.pimResPol.attributes.max == "unlimited" + - nm_update_bootstrap_router_remove_route_map.previous.0.pimCtxP.children.1.pimResPol.attributes.rsvd == "undefined" + - nm_update_bootstrap_router_remove_route_map.previous.0.pimCtxP.children.2.pimASMPatPol.children.0.pimSharedRangePol.attributes.name == "" + - nm_update_bootstrap_router_remove_route_map.previous.0.pimCtxP.children.2.pimASMPatPol.children.1.pimSGRangeExpPol.attributes.sgExpItvl == "default-timeout" + - nm_update_bootstrap_router_remove_route_map.previous.0.pimCtxP.children.2.pimASMPatPol.children.2.pimRegTrPol.attributes.maxRate == "64000" + - nm_update_bootstrap_router_remove_route_map.previous.0.pimCtxP.children.2.pimASMPatPol.children.2.pimRegTrPol.attributes.srcIp == "1.1.1.1" + - nm_update_bootstrap_router_remove_route_map.previous.0.pimCtxP.children.3.pimBSRPPol.children.0.pimBSRFilterPol.children.0.rtdmcRsFilterToRtMapPol.attributes.tDn == "uni/tn-ansible_test/rtmap-ansible_test" + - nm_update_bootstrap_router_remove_route_map.previous.0.pimCtxP.children.3.pimBSRPPol.attributes.ctrl == "" + - nm_update_bootstrap_router is changed + - nm_update_bootstrap_router.current.0.pimCtxP.attributes.dn == "uni/tn-ansible_tenant/ctx-ansible_vrf_1/pimctxp" + - nm_update_bootstrap_router.current.0.pimCtxP.attributes.mtu == "2000" + - nm_update_bootstrap_router.current.0.pimCtxP.attributes.ctrl == "" + - nm_update_bootstrap_router.current.0.pimCtxP.children.0.pimSSMPatPol.children.0.pimSSMRangePol.attributes.name == "" + - nm_update_bootstrap_router.current.0.pimCtxP.children.1.pimResPol.attributes.max == "unlimited" + - nm_update_bootstrap_router.current.0.pimCtxP.children.1.pimResPol.attributes.rsvd == "undefined" + - nm_update_bootstrap_router.current.0.pimCtxP.children.2.pimASMPatPol.children.0.pimSharedRangePol.attributes.name == "" + - nm_update_bootstrap_router.current.0.pimCtxP.children.2.pimASMPatPol.children.1.pimSGRangeExpPol.attributes.sgExpItvl == "default-timeout" + - nm_update_bootstrap_router.current.0.pimCtxP.children.2.pimASMPatPol.children.2.pimRegTrPol.attributes.maxRate == "64000" + - nm_update_bootstrap_router.current.0.pimCtxP.children.2.pimASMPatPol.children.2.pimRegTrPol.attributes.srcIp == "1.1.1.1" + - nm_update_bootstrap_router.current.0.pimCtxP.children.3.pimBSRPPol.attributes.ctrl == "forward,listen" + - nm_update_bootstrap_router.previous.0.pimCtxP.attributes.dn == "uni/tn-ansible_tenant/ctx-ansible_vrf_1/pimctxp" + - nm_update_bootstrap_router.previous.0.pimCtxP.attributes.mtu == "2000" + - nm_update_bootstrap_router.previous.0.pimCtxP.attributes.ctrl == "" + - nm_update_bootstrap_router.previous.0.pimCtxP.children.0.pimSSMPatPol.children.0.pimSSMRangePol.attributes.name == "" + - nm_update_bootstrap_router.previous.0.pimCtxP.children.1.pimResPol.attributes.max == "unlimited" + - nm_update_bootstrap_router.previous.0.pimCtxP.children.1.pimResPol.attributes.rsvd == "undefined" + - nm_update_bootstrap_router.previous.0.pimCtxP.children.2.pimASMPatPol.children.0.pimSharedRangePol.attributes.name == "" + - nm_update_bootstrap_router.previous.0.pimCtxP.children.2.pimASMPatPol.children.1.pimSGRangeExpPol.attributes.sgExpItvl == "default-timeout" + - nm_update_bootstrap_router.previous.0.pimCtxP.children.2.pimASMPatPol.children.2.pimRegTrPol.attributes.maxRate == "64000" + - nm_update_bootstrap_router.previous.0.pimCtxP.children.2.pimASMPatPol.children.2.pimRegTrPol.attributes.srcIp == "1.1.1.1" + - nm_update_bootstrap_router.previous.0.pimCtxP.children.3.pimBSRPPol.attributes.ctrl == "" + - nm_update_bootstrap_router_remove_rp_updates is changed + - nm_update_bootstrap_router_remove_rp_updates.current.0.pimCtxP.attributes.dn == "uni/tn-ansible_tenant/ctx-ansible_vrf_1/pimctxp" + - nm_update_bootstrap_router_remove_rp_updates.current.0.pimCtxP.attributes.mtu == "2000" + - nm_update_bootstrap_router_remove_rp_updates.current.0.pimCtxP.attributes.ctrl == "" + - nm_update_bootstrap_router_remove_rp_updates.current.0.pimCtxP.children.0.pimSSMPatPol.children.0.pimSSMRangePol.attributes.name == "" + - nm_update_bootstrap_router_remove_rp_updates.current.0.pimCtxP.children.1.pimResPol.attributes.max == "unlimited" + - nm_update_bootstrap_router_remove_rp_updates.current.0.pimCtxP.children.1.pimResPol.attributes.rsvd == "undefined" + - nm_update_bootstrap_router_remove_rp_updates.current.0.pimCtxP.children.2.pimASMPatPol.children.0.pimSharedRangePol.attributes.name == "" + - nm_update_bootstrap_router_remove_rp_updates.current.0.pimCtxP.children.2.pimASMPatPol.children.1.pimSGRangeExpPol.attributes.sgExpItvl == "default-timeout" + - nm_update_bootstrap_router_remove_rp_updates.current.0.pimCtxP.children.2.pimASMPatPol.children.2.pimRegTrPol.attributes.maxRate == "64000" + - nm_update_bootstrap_router_remove_rp_updates.current.0.pimCtxP.children.2.pimASMPatPol.children.2.pimRegTrPol.attributes.srcIp == "1.1.1.1" + - nm_update_bootstrap_router_remove_rp_updates.current.0.pimCtxP.children.3.pimBSRPPol.attributes.ctrl == "" + - nm_update_bootstrap_router_remove_rp_updates.previous.0.pimCtxP.attributes.dn == "uni/tn-ansible_tenant/ctx-ansible_vrf_1/pimctxp" + - nm_update_bootstrap_router_remove_rp_updates.previous.0.pimCtxP.attributes.mtu == "2000" + - nm_update_bootstrap_router_remove_rp_updates.previous.0.pimCtxP.attributes.ctrl == "" + - nm_update_bootstrap_router_remove_rp_updates.previous.0.pimCtxP.children.0.pimSSMPatPol.children.0.pimSSMRangePol.attributes.name == "" + - nm_update_bootstrap_router_remove_rp_updates.previous.0.pimCtxP.children.1.pimResPol.attributes.max == "unlimited" + - nm_update_bootstrap_router_remove_rp_updates.previous.0.pimCtxP.children.1.pimResPol.attributes.rsvd == "undefined" + - nm_update_bootstrap_router_remove_rp_updates.previous.0.pimCtxP.children.2.pimASMPatPol.children.0.pimSharedRangePol.attributes.name == "" + - nm_update_bootstrap_router_remove_rp_updates.previous.0.pimCtxP.children.2.pimASMPatPol.children.1.pimSGRangeExpPol.attributes.sgExpItvl == "default-timeout" + - nm_update_bootstrap_router_remove_rp_updates.previous.0.pimCtxP.children.2.pimASMPatPol.children.2.pimRegTrPol.attributes.maxRate == "64000" + - nm_update_bootstrap_router_remove_rp_updates.previous.0.pimCtxP.children.2.pimASMPatPol.children.2.pimRegTrPol.attributes.srcIp == "1.1.1.1" + - nm_update_bootstrap_router_remove_rp_updates.previous.0.pimCtxP.children.3.pimBSRPPol.attributes.ctrl == "forward,listen" + +# UPDATE MULTICAST AUTO-RP + +- name: Add a routemap to auro-rp on VRF 1 + cisco.aci.aci_vrf_multicast: + <<: *aci_ansible_vrf_1 + auto_rp: + ma_filter: uni/tn-ansible_test/rtmap-ansible_test + register: nm_update_auto_rp_add_route_map + +- name: Remove a routemap to auro-rp on VRF 1 + cisco.aci.aci_vrf_multicast: + <<: *aci_ansible_vrf_1 + auto_rp: + ma_filter: "" + register: nm_update_auto_rp_remove_route_map + +- name: Update auro-rp on VRF 1 + cisco.aci.aci_vrf_multicast: + <<: *aci_ansible_vrf_1 + auto_rp: + rp_updates: [ forward, listen ] + register: nm_update_auto_rp + +- name: Remove rp_updates for auro-rp on VRF 1 + cisco.aci.aci_vrf_multicast: + <<: *aci_ansible_vrf_1 + auto_rp: + rp_updates: [] + register: nm_update_auto_rp_remove_rp_updates + +- name: Verify update auro-rp on VRF 1 + ansible.builtin.assert: + that: + - nm_update_auto_rp_add_route_map is changed + - nm_update_auto_rp_add_route_map.current.0.pimCtxP.attributes.dn == "uni/tn-ansible_tenant/ctx-ansible_vrf_1/pimctxp" + - nm_update_auto_rp_add_route_map.current.0.pimCtxP.attributes.mtu == "2000" + - nm_update_auto_rp_add_route_map.current.0.pimCtxP.attributes.ctrl == "" + - nm_update_auto_rp_add_route_map.current.0.pimCtxP.children.0.pimSSMPatPol.children.0.pimSSMRangePol.attributes.name == "" + - nm_update_auto_rp_add_route_map.current.0.pimCtxP.children.1.pimASMPatPol.children.0.pimSharedRangePol.attributes.name == "" + - nm_update_auto_rp_add_route_map.current.0.pimCtxP.children.1.pimASMPatPol.children.1.pimSGRangeExpPol.attributes.sgExpItvl == "default-timeout" + - nm_update_auto_rp_add_route_map.current.0.pimCtxP.children.1.pimASMPatPol.children.2.pimRegTrPol.attributes.maxRate == "64000" + - nm_update_auto_rp_add_route_map.current.0.pimCtxP.children.1.pimASMPatPol.children.2.pimRegTrPol.attributes.srcIp == "1.1.1.1" + - nm_update_auto_rp_add_route_map.current.0.pimCtxP.children.2.pimBSRPPol.attributes.ctrl == "" + - nm_update_auto_rp_add_route_map.current.0.pimCtxP.children.3.pimResPol.attributes.max == "unlimited" + - nm_update_auto_rp_add_route_map.current.0.pimCtxP.children.3.pimResPol.attributes.rsvd == "undefined" + - nm_update_auto_rp_add_route_map.current.0.pimCtxP.children.4.pimAutoRPPol.attributes.ctrl == "" + - nm_update_auto_rp_add_route_map.current.0.pimCtxP.children.4.pimAutoRPPol.children.0.pimMAFilterPol.children.0.rtdmcRsFilterToRtMapPol.attributes.tDn == "uni/tn-ansible_test/rtmap-ansible_test" + - nm_update_auto_rp_add_route_map.previous.0.pimCtxP.attributes.annotation == "orchestrator:ansible" + - nm_update_auto_rp_add_route_map.previous.0.pimCtxP.attributes.dn == "uni/tn-ansible_tenant/ctx-ansible_vrf_1/pimctxp" + - nm_update_auto_rp_add_route_map.previous.0.pimCtxP.attributes.mtu == "2000" + - nm_update_auto_rp_add_route_map.previous.0.pimCtxP.attributes.ctrl == "" + - nm_update_auto_rp_add_route_map.previous.0.pimCtxP.children.0.pimSSMPatPol.children.0.pimSSMRangePol.attributes.name == "" + - nm_update_auto_rp_add_route_map.previous.0.pimCtxP.children.1.pimResPol.attributes.max == "unlimited" + - nm_update_auto_rp_add_route_map.previous.0.pimCtxP.children.1.pimResPol.attributes.rsvd == "undefined" + - nm_update_auto_rp_add_route_map.previous.0.pimCtxP.children.2.pimASMPatPol.children.0.pimSharedRangePol.attributes.name == "" + - nm_update_auto_rp_add_route_map.previous.0.pimCtxP.children.2.pimASMPatPol.children.1.pimSGRangeExpPol.attributes.sgExpItvl == "default-timeout" + - nm_update_auto_rp_add_route_map.previous.0.pimCtxP.children.2.pimASMPatPol.children.2.pimRegTrPol.attributes.maxRate == "64000" + - nm_update_auto_rp_add_route_map.previous.0.pimCtxP.children.2.pimASMPatPol.children.2.pimRegTrPol.attributes.srcIp == "1.1.1.1" + - nm_update_auto_rp_add_route_map.previous.0.pimCtxP.children.3.pimBSRPPol.attributes.ctrl == "" + - nm_update_auto_rp_add_route_map.previous.0.pimCtxP.children | length == 4 + - nm_update_auto_rp_remove_route_map is changed + - nm_update_auto_rp_remove_route_map.current.0.pimCtxP.attributes.dn == "uni/tn-ansible_tenant/ctx-ansible_vrf_1/pimctxp" + - nm_update_auto_rp_remove_route_map.current.0.pimCtxP.attributes.mtu == "2000" + - nm_update_auto_rp_remove_route_map.current.0.pimCtxP.attributes.ctrl == "" + - nm_update_auto_rp_remove_route_map.current.0.pimCtxP.children.0.pimSSMPatPol.children.0.pimSSMRangePol.attributes.name == "" + - nm_update_auto_rp_remove_route_map.current.0.pimCtxP.children.1.pimASMPatPol.children.0.pimSharedRangePol.attributes.name == "" + - nm_update_auto_rp_remove_route_map.current.0.pimCtxP.children.1.pimASMPatPol.children.1.pimSGRangeExpPol.attributes.sgExpItvl == "default-timeout" + - nm_update_auto_rp_remove_route_map.current.0.pimCtxP.children.1.pimASMPatPol.children.2.pimRegTrPol.attributes.maxRate == "64000" + - nm_update_auto_rp_remove_route_map.current.0.pimCtxP.children.1.pimASMPatPol.children.2.pimRegTrPol.attributes.srcIp == "1.1.1.1" + - nm_update_auto_rp_remove_route_map.current.0.pimCtxP.children.2.pimBSRPPol.attributes.ctrl == "" + - nm_update_auto_rp_remove_route_map.current.0.pimCtxP.children.3.pimResPol.attributes.max == "unlimited" + - nm_update_auto_rp_remove_route_map.current.0.pimCtxP.children.3.pimResPol.attributes.rsvd == "undefined" + - nm_update_auto_rp_remove_route_map.current.0.pimCtxP.children.4.pimAutoRPPol.attributes.ctrl == "" + - "'children' not in nm_update_auto_rp_remove_route_map.current.0.pimCtxP.children.4.pimAutoRPPol.children.0.pimMAFilterPol" + - nm_update_auto_rp_remove_route_map.previous.0.pimCtxP.attributes.dn == "uni/tn-ansible_tenant/ctx-ansible_vrf_1/pimctxp" + - nm_update_auto_rp_remove_route_map.previous.0.pimCtxP.attributes.mtu == "2000" + - nm_update_auto_rp_remove_route_map.previous.0.pimCtxP.attributes.ctrl == "" + - nm_update_auto_rp_remove_route_map.previous.0.pimCtxP.children.0.pimSSMPatPol.children.0.pimSSMRangePol.attributes.name == "" + - nm_update_auto_rp_remove_route_map.previous.0.pimCtxP.children.1.pimASMPatPol.children.0.pimSharedRangePol.attributes.name == "" + - nm_update_auto_rp_remove_route_map.previous.0.pimCtxP.children.1.pimASMPatPol.children.1.pimSGRangeExpPol.attributes.sgExpItvl == "default-timeout" + - nm_update_auto_rp_remove_route_map.previous.0.pimCtxP.children.1.pimASMPatPol.children.2.pimRegTrPol.attributes.maxRate == "64000" + - nm_update_auto_rp_remove_route_map.previous.0.pimCtxP.children.1.pimASMPatPol.children.2.pimRegTrPol.attributes.srcIp == "1.1.1.1" + - nm_update_auto_rp_remove_route_map.previous.0.pimCtxP.children.2.pimBSRPPol.attributes.ctrl == "" + - nm_update_auto_rp_remove_route_map.previous.0.pimCtxP.children.3.pimResPol.attributes.max == "unlimited" + - nm_update_auto_rp_remove_route_map.previous.0.pimCtxP.children.3.pimResPol.attributes.rsvd == "undefined" + - nm_update_auto_rp_remove_route_map.previous.0.pimCtxP.children.4.pimAutoRPPol.attributes.ctrl == "" + - nm_update_auto_rp_remove_route_map.previous.0.pimCtxP.children.4.pimAutoRPPol.children.0.pimMAFilterPol.children.0.rtdmcRsFilterToRtMapPol.attributes.tDn == "uni/tn-ansible_test/rtmap-ansible_test" + - nm_update_auto_rp is changed + - nm_update_auto_rp.current.0.pimCtxP.attributes.dn == "uni/tn-ansible_tenant/ctx-ansible_vrf_1/pimctxp" + - nm_update_auto_rp.current.0.pimCtxP.attributes.mtu == "2000" + - nm_update_auto_rp.current.0.pimCtxP.attributes.ctrl == "" + - nm_update_auto_rp.current.0.pimCtxP.children.0.pimSSMPatPol.children.0.pimSSMRangePol.attributes.name == "" + - nm_update_auto_rp.current.0.pimCtxP.children.1.pimASMPatPol.children.0.pimSharedRangePol.attributes.name == "" + - nm_update_auto_rp.current.0.pimCtxP.children.1.pimASMPatPol.children.1.pimSGRangeExpPol.attributes.sgExpItvl == "default-timeout" + - nm_update_auto_rp.current.0.pimCtxP.children.1.pimASMPatPol.children.2.pimRegTrPol.attributes.maxRate == "64000" + - nm_update_auto_rp.current.0.pimCtxP.children.1.pimASMPatPol.children.2.pimRegTrPol.attributes.srcIp == "1.1.1.1" + - nm_update_auto_rp.current.0.pimCtxP.children.2.pimBSRPPol.attributes.ctrl == "" + - nm_update_auto_rp.current.0.pimCtxP.children.3.pimResPol.attributes.max == "unlimited" + - nm_update_auto_rp.current.0.pimCtxP.children.3.pimResPol.attributes.rsvd == "undefined" + - nm_update_auto_rp.current.0.pimCtxP.children.4.pimAutoRPPol.attributes.ctrl == "forward,listen" + - nm_update_auto_rp.previous.0.pimCtxP.attributes.dn == "uni/tn-ansible_tenant/ctx-ansible_vrf_1/pimctxp" + - nm_update_auto_rp.previous.0.pimCtxP.attributes.mtu == "2000" + - nm_update_auto_rp.previous.0.pimCtxP.attributes.ctrl == "" + - nm_update_auto_rp.previous.0.pimCtxP.children.0.pimSSMPatPol.children.0.pimSSMRangePol.attributes.name == "" + - nm_update_auto_rp.previous.0.pimCtxP.children.1.pimASMPatPol.children.0.pimSharedRangePol.attributes.name == "" + - nm_update_auto_rp.previous.0.pimCtxP.children.1.pimASMPatPol.children.1.pimSGRangeExpPol.attributes.sgExpItvl == "default-timeout" + - nm_update_auto_rp.previous.0.pimCtxP.children.1.pimASMPatPol.children.2.pimRegTrPol.attributes.maxRate == "64000" + - nm_update_auto_rp.previous.0.pimCtxP.children.1.pimASMPatPol.children.2.pimRegTrPol.attributes.srcIp == "1.1.1.1" + - nm_update_auto_rp.previous.0.pimCtxP.children.2.pimBSRPPol.attributes.ctrl == "" + - nm_update_auto_rp.previous.0.pimCtxP.children.3.pimResPol.attributes.max == "unlimited" + - nm_update_auto_rp.previous.0.pimCtxP.children.3.pimResPol.attributes.rsvd == "undefined" + - nm_update_auto_rp.previous.0.pimCtxP.children.4.pimAutoRPPol.attributes.ctrl == "" + - nm_update_auto_rp_remove_rp_updates is changed + - nm_update_auto_rp_remove_rp_updates.current.0.pimCtxP.attributes.dn == "uni/tn-ansible_tenant/ctx-ansible_vrf_1/pimctxp" + - nm_update_auto_rp_remove_rp_updates.current.0.pimCtxP.attributes.mtu == "2000" + - nm_update_auto_rp_remove_rp_updates.current.0.pimCtxP.attributes.ctrl == "" + - nm_update_auto_rp_remove_rp_updates.current.0.pimCtxP.children.0.pimSSMPatPol.children.0.pimSSMRangePol.attributes.name == "" + - nm_update_auto_rp_remove_rp_updates.current.0.pimCtxP.children.1.pimASMPatPol.children.0.pimSharedRangePol.attributes.name == "" + - nm_update_auto_rp_remove_rp_updates.current.0.pimCtxP.children.1.pimASMPatPol.children.1.pimSGRangeExpPol.attributes.sgExpItvl == "default-timeout" + - nm_update_auto_rp_remove_rp_updates.current.0.pimCtxP.children.1.pimASMPatPol.children.2.pimRegTrPol.attributes.maxRate == "64000" + - nm_update_auto_rp_remove_rp_updates.current.0.pimCtxP.children.1.pimASMPatPol.children.2.pimRegTrPol.attributes.srcIp == "1.1.1.1" + - nm_update_auto_rp_remove_rp_updates.current.0.pimCtxP.children.2.pimBSRPPol.attributes.ctrl == "" + - nm_update_auto_rp_remove_rp_updates.current.0.pimCtxP.children.3.pimResPol.attributes.max == "unlimited" + - nm_update_auto_rp_remove_rp_updates.current.0.pimCtxP.children.3.pimResPol.attributes.rsvd == "undefined" + - nm_update_auto_rp_remove_rp_updates.current.0.pimCtxP.children.4.pimAutoRPPol.attributes.ctrl == "" + - nm_update_auto_rp_remove_rp_updates.previous.0.pimCtxP.attributes.dn == "uni/tn-ansible_tenant/ctx-ansible_vrf_1/pimctxp" + - nm_update_auto_rp_remove_rp_updates.previous.0.pimCtxP.attributes.mtu == "2000" + - nm_update_auto_rp_remove_rp_updates.previous.0.pimCtxP.attributes.ctrl == "" + - nm_update_auto_rp_remove_rp_updates.previous.0.pimCtxP.children.0.pimSSMPatPol.children.0.pimSSMRangePol.attributes.name == "" + - nm_update_auto_rp_remove_rp_updates.previous.0.pimCtxP.children.1.pimASMPatPol.children.0.pimSharedRangePol.attributes.name == "" + - nm_update_auto_rp_remove_rp_updates.previous.0.pimCtxP.children.1.pimASMPatPol.children.1.pimSGRangeExpPol.attributes.sgExpItvl == "default-timeout" + - nm_update_auto_rp_remove_rp_updates.previous.0.pimCtxP.children.1.pimASMPatPol.children.2.pimRegTrPol.attributes.maxRate == "64000" + - nm_update_auto_rp_remove_rp_updates.previous.0.pimCtxP.children.1.pimASMPatPol.children.2.pimRegTrPol.attributes.srcIp == "1.1.1.1" + - nm_update_auto_rp_remove_rp_updates.previous.0.pimCtxP.children.2.pimBSRPPol.attributes.ctrl == "" + - nm_update_auto_rp_remove_rp_updates.previous.0.pimCtxP.children.3.pimResPol.attributes.max == "unlimited" + - nm_update_auto_rp_remove_rp_updates.previous.0.pimCtxP.children.3.pimResPol.attributes.rsvd == "undefined" + - nm_update_auto_rp_remove_rp_updates.previous.0.pimCtxP.children.4.pimAutoRPPol.attributes.ctrl == "forward,listen" + +# QUERY MULTICAST SETTINGS + +- name: Enable multicast on VRF 2 + cisco.aci.aci_vrf_multicast: + <<: *aci_ansible_vrf_2 + register: nm_update_resource_policy + +- name: Query multicast on VRF 1 + cisco.aci.aci_vrf_multicast: + <<: *aci_ansible_vrf_1 + state: query + register: query_one + +- name: Query multicast on all VRFs + cisco.aci.aci_vrf_multicast: + <<: *aci_info + state: query + register: query_all + +- name: Verify multicast VRF queries + ansible.builtin.assert: + that: + - query_one is not changed + - query_one.current | length == 1 + - query_one.current.0.fvCtx.children.0.pimCtxP.attributes.rn == "pimctxp" + - query_one.current.0.fvCtx.children.0.pimCtxP.attributes.mtu == "2000" + - query_one.current.0.fvCtx.children.0.pimCtxP.attributes.ctrl == "" + - query_one.current.0.fvCtx.children.0.pimCtxP.children.0.pimSSMPatPol.children.0.pimSSMRangePol.attributes.name == "" + - query_one.current.0.fvCtx.children.0.pimCtxP.children.1.pimASMPatPol.children.0.pimSharedRangePol.attributes.name == "" + - query_one.current.0.fvCtx.children.0.pimCtxP.children.1.pimASMPatPol.children.1.pimSGRangeExpPol.attributes.sgExpItvl == "default-timeout" + - query_one.current.0.fvCtx.children.0.pimCtxP.children.1.pimASMPatPol.children.2.pimRegTrPol.attributes.maxRate == "64000" + - query_one.current.0.fvCtx.children.0.pimCtxP.children.1.pimASMPatPol.children.2.pimRegTrPol.attributes.srcIp == "1.1.1.1" + - query_one.current.0.fvCtx.children.0.pimCtxP.children.2.pimBSRPPol.attributes.ctrl == "" + - query_one.current.0.fvCtx.children.0.pimCtxP.children.3.pimResPol.attributes.max == "unlimited" + - query_one.current.0.fvCtx.children.0.pimCtxP.children.3.pimResPol.attributes.rsvd == "undefined" + - query_one.current.0.fvCtx.children.0.pimCtxP.children.4.pimAutoRPPol.attributes.ctrl == "" + - query_all is not changed + - query_all.current | length > 1 + +# DISABLE MULTICAST + +- name: Disable multicast on VRF + cisco.aci.aci_vrf_multicast: + <<: *aci_ansible_vrf_1 + state: absent + check_mode: true + register: cm_disable_multicast + +- name: Disable multicast on VRF + cisco.aci.aci_vrf_multicast: + <<: *aci_ansible_vrf_1 + state: absent + register: nm_disable_multicast + +- name: Disable multicast on VRF again + cisco.aci.aci_vrf_multicast: + <<: *aci_ansible_vrf_1 + state: absent + register: nm_disable_multicast_again + +- name: Verify disable multicast on VRF + ansible.builtin.assert: + that: + - cm_disable_multicast is changed + - cm_disable_multicast.proposed == {} + - cm_disable_multicast.previous.0.pimCtxP.attributes.dn == "uni/tn-ansible_tenant/ctx-ansible_vrf_1/pimctxp" + - cm_disable_multicast.previous.0.pimCtxP.attributes.mtu == "2000" + - cm_disable_multicast.previous.0.pimCtxP.attributes.ctrl == "" + - cm_disable_multicast.previous.0.pimCtxP.children.0.pimSSMPatPol.children.0.pimSSMRangePol.attributes.name == "" + - cm_disable_multicast.previous.0.pimCtxP.children.1.pimASMPatPol.children.0.pimSharedRangePol.attributes.name == "" + - cm_disable_multicast.previous.0.pimCtxP.children.1.pimASMPatPol.children.1.pimSGRangeExpPol.attributes.sgExpItvl == "default-timeout" + - cm_disable_multicast.previous.0.pimCtxP.children.1.pimASMPatPol.children.2.pimRegTrPol.attributes.maxRate == "64000" + - cm_disable_multicast.previous.0.pimCtxP.children.1.pimASMPatPol.children.2.pimRegTrPol.attributes.srcIp == "1.1.1.1" + - cm_disable_multicast.previous.0.pimCtxP.children.2.pimBSRPPol.attributes.ctrl == "" + - cm_disable_multicast.previous.0.pimCtxP.children.3.pimResPol.attributes.max == "unlimited" + - cm_disable_multicast.previous.0.pimCtxP.children.3.pimResPol.attributes.rsvd == "undefined" + - cm_disable_multicast.previous.0.pimCtxP.children.4.pimAutoRPPol.attributes.ctrl == "" + - nm_disable_multicast is changed + - nm_disable_multicast.current == [] + - nm_disable_multicast.previous.0.pimCtxP.attributes.dn == "uni/tn-ansible_tenant/ctx-ansible_vrf_1/pimctxp" + - nm_disable_multicast.previous.0.pimCtxP.attributes.mtu == "2000" + - nm_disable_multicast.previous.0.pimCtxP.attributes.ctrl == "" + - nm_disable_multicast.previous.0.pimCtxP.children.0.pimSSMPatPol.children.0.pimSSMRangePol.attributes.name == "" + - nm_disable_multicast.previous.0.pimCtxP.children.1.pimASMPatPol.children.0.pimSharedRangePol.attributes.name == "" + - nm_disable_multicast.previous.0.pimCtxP.children.1.pimASMPatPol.children.1.pimSGRangeExpPol.attributes.sgExpItvl == "default-timeout" + - nm_disable_multicast.previous.0.pimCtxP.children.1.pimASMPatPol.children.2.pimRegTrPol.attributes.maxRate == "64000" + - nm_disable_multicast.previous.0.pimCtxP.children.1.pimASMPatPol.children.2.pimRegTrPol.attributes.srcIp == "1.1.1.1" + - nm_disable_multicast.previous.0.pimCtxP.children.2.pimBSRPPol.attributes.ctrl == "" + - nm_disable_multicast.previous.0.pimCtxP.children.3.pimResPol.attributes.max == "unlimited" + - nm_disable_multicast.previous.0.pimCtxP.children.3.pimResPol.attributes.rsvd == "undefined" + - nm_disable_multicast.previous.0.pimCtxP.children.4.pimAutoRPPol.attributes.ctrl == "" + - nm_disable_multicast_again is not changed + - nm_disable_multicast_again.current == [] + - nm_disable_multicast_again.previous == [] + +# ERRORS + +- name: Mutually exclusive parameters resource_policy (error) + cisco.aci.aci_vrf_multicast: + <<: *aci_ansible_vrf_1 + resource_policy: + reserved_multicast_entries: 10 + ignore_errors: true + register: err_mutually_exclusive_resource_policy + +- name: Entries is 0 when routemap provided (error) + cisco.aci.aci_vrf_multicast: + <<: *aci_ansible_vrf_1 + resource_policy: + reserved_route_map: uni/tn-ansible_test/rtmap-ansible_test + reserved_multicast_entries: 0 + ignore_errors: true + register: err_reserved_multicast_entries_is_0 + +- name: Verify errors + ansible.builtin.assert: + that: + - err_mutually_exclusive_resource_policy is failed + - err_mutually_exclusive_resource_policy.msg == "parameters are mutually exclusive{{':'}} reserved_route_map|reserved_multicast_entries" + - err_reserved_multicast_entries_is_0 is failed + - err_reserved_multicast_entries_is_0.msg == "C(reserved_multicast_entries) must be provided and greater than 0 when C(reserved_route_map) is provided" + +# CLEAN ENVIRONMENT + +- name: Remove ansible_tenant + cisco.aci.aci_tenant: + <<: *aci_tenant_absent diff --git a/ansible_collections/cisco/aci/tests/integration/targets/aci_vzany_to_contract/tasks/main.yml b/ansible_collections/cisco/aci/tests/integration/targets/aci_vzany_to_contract/tasks/main.yml index 65e6f1278..11c4d4e86 100644 --- a/ansible_collections/cisco/aci/tests/integration/targets/aci_vzany_to_contract/tasks/main.yml +++ b/ansible_collections/cisco/aci/tests/integration/targets/aci_vzany_to_contract/tasks/main.yml @@ -3,7 +3,7 @@ # SET VARS - name: Set vars - set_fact: + ansible.builtin.set_fact: aci_info: &aci_info host: '{{ aci_hostname }}' username: '{{ aci_username }}' @@ -77,7 +77,7 @@ register: nm_vzany_prov - name: Verify vzany_prov - assert: + ansible.builtin.assert: that: - cm_vzany_prov is changed - nm_vzany_prov is changed @@ -91,7 +91,7 @@ register: add_prov_again - name: Verify add_prov_again - assert: + ansible.builtin.assert: that: - add_prov_again is not changed @@ -123,7 +123,7 @@ register: query_all_provs - name: Verify query_all_provs - assert: + ansible.builtin.assert: that: - query_all_provs is not changed - query_all_provs.current|length >= 2 @@ -136,7 +136,7 @@ register: query_spec_bind - name: Verify query_spec_bind - assert: + ansible.builtin.assert: that: - query_spec_bind is not changed - query_spec_bind.current|length == 1 @@ -161,7 +161,7 @@ register: del_cif - name: Verify remove_intf - assert: + ansible.builtin.assert: that: - del_prov is changed - del_cons is changed diff --git a/ansible_collections/cisco/aci/tests/unit/compat/builtins.py b/ansible_collections/cisco/aci/tests/unit/compat/builtins.py index bfc8adfbe..43f88203a 100644 --- a/ansible_collections/cisco/aci/tests/unit/compat/builtins.py +++ b/ansible_collections/cisco/aci/tests/unit/compat/builtins.py @@ -19,16 +19,3 @@ from __future__ import absolute_import, division, print_function __metaclass__ = type - -# -# Compat for python2.7 -# - -# One unittest needs to import builtins via __import__() so we need to have -# the string that represents it -try: - import __builtin__ -except ImportError: - BUILTINS = "builtins" -else: - BUILTINS = "__builtin__" diff --git a/ansible_collections/cisco/aci/tests/unit/mock/loader.py b/ansible_collections/cisco/aci/tests/unit/mock/loader.py index 524870cfa..2caea2883 100644 --- a/ansible_collections/cisco/aci/tests/unit/mock/loader.py +++ b/ansible_collections/cisco/aci/tests/unit/mock/loader.py @@ -30,7 +30,7 @@ from ansible.module_utils._text import to_bytes, to_text class DictDataLoader(DataLoader): def __init__(self, file_mapping=None): file_mapping = {} if file_mapping is None else file_mapping - assert type(file_mapping) == dict + assert isinstance(file_mapping, dict) super(DictDataLoader, self).__init__() diff --git a/ansible_collections/cisco/aci/tests/unit/module_utils/test_aci.py b/ansible_collections/cisco/aci/tests/unit/module_utils/test_aci.py index a1e07ed24..0305ee4c3 100644 --- a/ansible_collections/cisco/aci/tests/unit/module_utils/test_aci.py +++ b/ansible_collections/cisco/aci/tests/unit/module_utils/test_aci.py @@ -40,8 +40,6 @@ aci = AltACIModule() try: from lxml import etree - if sys.version_info >= (2, 7): - from xmljson import cobra except ImportError: pytestmark = pytest.mark.skip("ACI Ansible modules require the lxml and xmljson Python libraries") |