From 3d4e551f885b132d4eea007558ebb3f71c244b2f Mon Sep 17 00:00:00 2001 From: anvitha-jain Date: Wed, 8 Nov 2023 10:09:53 -0800 Subject: [PATCH] [ignore_changes] Fixing sanity issues --- plugins/modules/aci_bfd_interface_policy.py | 23 ++++---- .../aci_bfd_multihop_interface_policy.py | 17 +++--- .../aci_bfd_multihop_interface_profile.py | 8 ++- .../modules/aci_bfd_multihop_node_policy.py | 15 +++--- .../aci_l3out_bfd_interface_profile.py | 9 +++- .../aci_bfd_interface_policy/tasks/main.yml | 54 +++++++++++++------ .../tasks/main.yml | 46 +++++++++++----- .../tasks/main.yml | 46 ++++++++++++++-- .../tasks/main.yml | 46 +++++++++++----- .../tasks/main.yml | 52 +++++++++++++++--- 10 files changed, 229 insertions(+), 87 deletions(-) diff --git a/plugins/modules/aci_bfd_interface_policy.py b/plugins/modules/aci_bfd_interface_policy.py index 4afb3df77..f2b303241 100644 --- a/plugins/modules/aci_bfd_interface_policy.py +++ b/plugins/modules/aci_bfd_interface_policy.py @@ -26,7 +26,7 @@ description: - Name of the BFD Interface policy type: str - aliases: [ bfd_multihop_interface_policy ] + aliases: [ bfd_interface_policy ] description: description: - Description of the BFD Interface policy @@ -48,13 +48,13 @@ - Minimum transmit (Tx) interval of the BFD Interface policy - Allowed range is 250-999. type: int - default: 250 + default: 50 min_receive_interval: description: - Minimum receive (Rx) interval of the BFD Interface policy - Allowed range is 250-999. type: int - default: 250 + default: 50 state: description: - Use C(present) or C(absent) for adding or removing. @@ -79,14 +79,13 @@ EXAMPLES = r""" - name: Add a new BFD Interface policy - cisco.aci.aci_bfd_interface_policy: - host: apic - username: admin - password: SomeSecretPassword - tenant: ansible_tenant - name: ansible_bfd_interface_policy - description: Ansible BFD Interface Policy - state: present + cisco.aci.aci_bfd_interface_policy: + host: apic + username: admin + password: SomeSecretPassword + tenant: ansible_tenant + name: ansible_bfd_interface_policy + description: Ansible BFD Interface Policy state: present delegate_to: localhost @@ -109,7 +108,6 @@ name: ansible_bfd_interface_policy state: query delegate_to: localhost - register: query_result - name: Query all BFD Interface policies in a specific tenant cisco.aci.aci_bfd_interface_policy: @@ -119,7 +117,6 @@ tenant: ansible_tenant state: query delegate_to: localhost - register: query_result """ RETURN = r""" diff --git a/plugins/modules/aci_bfd_multihop_interface_policy.py b/plugins/modules/aci_bfd_multihop_interface_policy.py index 8dab45fcc..43005d67e 100644 --- a/plugins/modules/aci_bfd_multihop_interface_policy.py +++ b/plugins/modules/aci_bfd_multihop_interface_policy.py @@ -79,14 +79,13 @@ EXAMPLES = r""" - name: Add a new BFD Multihop Interface policy - cisco.aci.aci_bfd_multihop_interface_policy: - host: apic - username: admin - password: SomeSecretPassword - tenant: ansible_tenant - name: ansible_bfd_multihop_interface_policy - description: Ansible BFD Multihop Interface Policy - state: present + cisco.aci.aci_bfd_multihop_interface_policy: + host: apic + username: admin + password: SomeSecretPassword + tenant: ansible_tenant + name: ansible_bfd_multihop_interface_policy + description: Ansible BFD Multihop Interface Policy state: present delegate_to: localhost @@ -109,7 +108,6 @@ name: ansible_bfd_multihop_interface_policy state: query delegate_to: localhost - register: query_result - name: Query all BFD Multihop Interface policies in a specific tenant cisco.aci.aci_bfd_multihop_interface_policy: @@ -119,7 +117,6 @@ tenant: ansible_tenant state: query delegate_to: localhost - register: query_result """ RETURN = r""" diff --git a/plugins/modules/aci_bfd_multihop_interface_profile.py b/plugins/modules/aci_bfd_multihop_interface_profile.py index aec0faa1e..345cb940e 100644 --- a/plugins/modules/aci_bfd_multihop_interface_profile.py +++ b/plugins/modules/aci_bfd_multihop_interface_profile.py @@ -16,16 +16,18 @@ short_description: Manage BFD Multihop Interface profile. description: - Manage BFD Multihop Interface profile (bfdMhIfP) configuration on Cisco ACI fabrics. -- Only available in APIC version 5.2 or later. +- Only available in APIC version 5.2 or later and for non-cloud APICs. options: tenant: description: - Name of an existing tenant. type: str + aliases: [ tenant_name ] l3out: description: - Name of an existing L3Out. type: str + aliases: [ l3out_name ] l3out_logical_node_profile: description: - Name of an existing L3Out Logical Node profile. @@ -49,6 +51,7 @@ description: - Description of the BFD Multihop Interface Profile object. type: str + aliases: [ descr ] interface_profile_type: description: - Authentication Type of the BFD Multihop Interface Profile object. @@ -280,11 +283,12 @@ def main(): interface_profile_type = module.params.get("interface_profile_type") key = module.params.get("key") key_id = module.params.get("key_id") + if key_id is not None and key_id not in range(1, 255): + module.fail_json(msg='The "key_id" must be a value between 1 and 255') bfd_multihop_interface_policy = module.params.get("bfd_multihop_interface_policy") state = module.params.get("state") aci = ACIModule(module) - aci.stdout = str("CHECK MODE: ") + str(bfd_multihop_interface_policy) aci.construct_url( root_class=dict( aci_class="fvTenant", diff --git a/plugins/modules/aci_bfd_multihop_node_policy.py b/plugins/modules/aci_bfd_multihop_node_policy.py index f15eac081..6a1453c92 100644 --- a/plugins/modules/aci_bfd_multihop_node_policy.py +++ b/plugins/modules/aci_bfd_multihop_node_policy.py @@ -79,14 +79,13 @@ EXAMPLES = r""" - name: Add a new BFD Multihop Node policy - cisco.aci.aci_bfd_multihop_node_policy: - host: apic - username: admin - password: SomeSecretPassword - tenant: ansible_tenant - name: ansible_bfd_multihop_node_policy - description: Ansible BFD Multihop Node Policy - state: present + cisco.aci.aci_bfd_multihop_node_policy: + host: apic + username: admin + password: SomeSecretPassword + tenant: ansible_tenant + name: ansible_bfd_multihop_node_policy + description: Ansible BFD Multihop Node Policy state: present delegate_to: localhost diff --git a/plugins/modules/aci_l3out_bfd_interface_profile.py b/plugins/modules/aci_l3out_bfd_interface_profile.py index 6eadbbfd8..0b04e3031 100644 --- a/plugins/modules/aci_l3out_bfd_interface_profile.py +++ b/plugins/modules/aci_l3out_bfd_interface_profile.py @@ -16,16 +16,18 @@ short_description: Manage L3Out BFD Interface profile. description: - Manage L3Out BFD Interface profile (bfdIfP) configuration on Cisco ACI fabrics. -- Only available in APIC version 5.2 or later. +- Only available in APIC version 5.2 or later and for non-cloud APICs. options: tenant: description: - Name of an existing tenant. type: str + aliases: [ tenant_name ] l3out: description: - Name of an existing L3Out. type: str + aliases: [ l3out_name ] l3out_logical_node_profile: description: - Name of an existing L3Out Logical Node profile. @@ -49,6 +51,7 @@ description: - Description of the L3Out BFD Interface profile object. type: str + aliases: [ descr ] interface_profile_type: description: - Authentication Type of the L3Out BFD Interface profile object. @@ -255,7 +258,7 @@ def main(): name_alias=dict(type="str"), description=dict(type="str", aliases=["descr"]), interface_profile_type=dict(type="str", default="none", choices=["none", "sha1"]), - key=dict(type="str"), + key=dict(type="str", no_log=True), key_id=dict(type="int", default=3), bfd_interface_policy=dict(type="str", aliases=["interface_policy", "interface_policy_name"]), state=dict(type="str", default="present", choices=["absent", "present", "query"]), @@ -280,6 +283,8 @@ def main(): interface_profile_type = module.params.get("interface_profile_type") key = module.params.get("key") key_id = module.params.get("key_id") + if key_id is not None and key_id not in range(1, 255): + module.fail_json(msg='The "key_id" must be a value between 1 and 255') bfd_interface_policy = module.params.get("bfd_interface_policy") state = module.params.get("state") diff --git a/tests/integration/targets/aci_bfd_interface_policy/tasks/main.yml b/tests/integration/targets/aci_bfd_interface_policy/tasks/main.yml index 21f659f91..0ffffe0ea 100644 --- a/tests/integration/targets/aci_bfd_interface_policy/tasks/main.yml +++ b/tests/integration/targets/aci_bfd_interface_policy/tasks/main.yml @@ -9,7 +9,7 @@ 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 }}" @@ -32,13 +32,13 @@ # CLEAN ENVIRONMENT - name: Remove the ansible_tenant - aci_tenant: + cisco.aci.aci_tenant: <<: *aci_info tenant: ansible_tenant state: absent - name: Add a new tenant - aci_tenant: + cisco.aci.aci_tenant: <<: *aci_info tenant: ansible_tenant description: Ansible tenant @@ -67,13 +67,13 @@ - 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 == [] - - nm_add_bfd_interface_pol.current.0.bfdIfPol.attributes.dn == "uni/tn-ansible_tenant/bfdIfPol-ansible_bfd_interface_policy" - - nm_add_bfd_interface_pol.current.0.bfdIfPol.attributes.name == "ansible_bfd_interface_policy" - - nm_add_bfd_interface_pol.current.0.bfdIfPol.attributes.descr == "Ansible BFD Interface Policy" - - nm_add_bfd_interface_pol.current.0.bfdIfPol.attributes.adminSt == "enabled" - - nm_add_bfd_interface_pol.current.0.bfdIfPol.attributes.detectMult == "3" - - nm_add_bfd_interface_pol.current.0.bfdIfPol.attributes.minRxIntvl == "50" - - nm_add_bfd_interface_pol.current.0.bfdIfPol.attributes.minTxIntvl == "50" + - 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" + - cm_add_bfd_interface_pol.proposed.bfdIfPol.attributes.adminSt == nm_add_bfd_interface_pol.current.0.bfdIfPol.attributes.adminSt == "enabled" + - cm_add_bfd_interface_pol.proposed.bfdIfPol.attributes.detectMult == nm_add_bfd_interface_pol.current.0.bfdIfPol.attributes.detectMult == "3" + - cm_add_bfd_interface_pol.proposed.bfdIfPol.attributes.minRxIntvl == nm_add_bfd_interface_pol.current.0.bfdIfPol.attributes.minRxIntvl == "50" + - cm_add_bfd_interface_pol.proposed.bfdIfPol.attributes.minTxIntvl == nm_add_bfd_interface_pol.current.0.bfdIfPol.attributes.minTxIntvl == "50" - name: Add a new BFD Interface policy again - idempotency cisco.aci.aci_bfd_interface_policy: @@ -163,22 +163,42 @@ - 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 + - name: Remove a BFD Interface policy - check mode cisco.aci.aci_bfd_interface_policy: <<: *aci_info tenant: ansible_tenant name: ansible_bfd_interface_policy state: absent - register: remove_bfd_interface_pol + check_mode: true + register: cm_remove_bfd_interface_pol + + - name: Remove a BFD Interface policy - normal mode + cisco.aci.aci_bfd_interface_policy: + <<: *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_bfd_interface_policy: + <<: *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: - - remove_bfd_interface_pol is changed - - remove_bfd_interface_pol.previous != [] - - remove_bfd_interface_pol.current == [] - -# Validating out of rage parameters. + - 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 diff --git a/tests/integration/targets/aci_bfd_multihop_interface_policy/tasks/main.yml b/tests/integration/targets/aci_bfd_multihop_interface_policy/tasks/main.yml index 8e7be35a7..11f66b13c 100644 --- a/tests/integration/targets/aci_bfd_multihop_interface_policy/tasks/main.yml +++ b/tests/integration/targets/aci_bfd_multihop_interface_policy/tasks/main.yml @@ -9,7 +9,7 @@ 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 }}" @@ -67,13 +67,13 @@ - 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 == [] - - nm_add_bfd_multihop_interface_pol.current.0.bfdMhIfPol.attributes.dn == "uni/tn-ansible_tenant/bfdMhIfPol-ansible_bfd_multihop_interface_policy" - - nm_add_bfd_multihop_interface_pol.current.0.bfdMhIfPol.attributes.name == "ansible_bfd_multihop_interface_policy" - - nm_add_bfd_multihop_interface_pol.current.0.bfdMhIfPol.attributes.descr == "Ansible BFD Multihop Interface Policy" - - nm_add_bfd_multihop_interface_pol.current.0.bfdMhIfPol.attributes.adminSt == "enabled" - - nm_add_bfd_multihop_interface_pol.current.0.bfdMhIfPol.attributes.detectMult == "3" - - nm_add_bfd_multihop_interface_pol.current.0.bfdMhIfPol.attributes.minRxIntvl == "250" - - nm_add_bfd_multihop_interface_pol.current.0.bfdMhIfPol.attributes.minTxIntvl == "250" + - 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" + - cm_add_bfd_multihop_interface_pol.proposed.bfdMhIfPol.attributes.adminSt == nm_add_bfd_multihop_interface_pol.current.0.bfdMhIfPol.attributes.adminSt == "enabled" + - cm_add_bfd_multihop_interface_pol.proposed.bfdMhIfPol.attributes.detectMult == nm_add_bfd_multihop_interface_pol.current.0.bfdMhIfPol.attributes.detectMult == "3" + - cm_add_bfd_multihop_interface_pol.proposed.bfdMhIfPol.attributes.minRxIntvl == nm_add_bfd_multihop_interface_pol.current.0.bfdMhIfPol.attributes.minRxIntvl == "250" + - cm_add_bfd_multihop_interface_pol.proposed.bfdMhIfPol.attributes.minTxIntvl == nm_add_bfd_multihop_interface_pol.current.0.bfdMhIfPol.attributes.minTxIntvl == "250" - name: Add a new BFD Multihop Interface policy again - idempotency cisco.aci.aci_bfd_multihop_interface_policy: @@ -163,20 +163,40 @@ - 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 + - name: Remove a BFD Multihop Interface policy - check mode cisco.aci.aci_bfd_multihop_interface_policy: <<: *aci_info tenant: ansible_tenant name: ansible_bfd_multihop_interface_policy state: absent - register: remove_bfd_multihop_interface_pol + check_mode: true + register: cm_remove_bfd_multihop_interface_pol + + - name: Remove a BFD Multihop Interface policy - normal mode + cisco.aci.aci_bfd_multihop_interface_policy: + <<: *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_bfd_multihop_interface_policy: + <<: *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: - - remove_bfd_multihop_interface_pol is changed - - remove_bfd_multihop_interface_pol.previous != [] - - remove_bfd_multihop_interface_pol.current == [] + - 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. diff --git a/tests/integration/targets/aci_bfd_multihop_interface_profile/tasks/main.yml b/tests/integration/targets/aci_bfd_multihop_interface_profile/tasks/main.yml index 1785e87da..4c91d9ecb 100644 --- a/tests/integration/targets/aci_bfd_multihop_interface_profile/tasks/main.yml +++ b/tests/integration/targets/aci_bfd_multihop_interface_profile/tasks/main.yml @@ -9,7 +9,7 @@ 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,8 +26,12 @@ 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 - when: version.current.0.topSystem.attributes.version is version('5.2', '>=') # This condition will execute only when APIC version >= 5.2 + # 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 @@ -166,9 +170,45 @@ state: query register: query_all_bfd_mh_int_prof + # Validating out of range parameters. + - name: Add out of range key_id + cisco.aci.aci_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_bfd_multihop_interface_profile: <<: *present_bfd_mh_int_profile state: absent check_mode: true - register: cm_remove_bfd_mh_int_prof \ No newline at end of file + register: cm_remove_bfd_mh_int_prof + + - name: Delete BFD Multihop Interface Profile - normal mode + cisco.aci.aci_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_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/tests/integration/targets/aci_bfd_multihop_node_policy/tasks/main.yml b/tests/integration/targets/aci_bfd_multihop_node_policy/tasks/main.yml index a7b7edf40..98a96aac7 100644 --- a/tests/integration/targets/aci_bfd_multihop_node_policy/tasks/main.yml +++ b/tests/integration/targets/aci_bfd_multihop_node_policy/tasks/main.yml @@ -9,7 +9,7 @@ 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 }}" @@ -67,13 +67,13 @@ - 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 == [] - - nm_add_bfd_multihop_node_pol.current.0.bfdMhNodePol.attributes.dn == "uni/tn-ansible_tenant/bfdMhNodePol-ansible_bfd_multihop_node_policy" - - nm_add_bfd_multihop_node_pol.current.0.bfdMhNodePol.attributes.name == "ansible_bfd_multihop_node_policy" - - nm_add_bfd_multihop_node_pol.current.0.bfdMhNodePol.attributes.descr == "Ansible BFD Multihop Node Policy" - - nm_add_bfd_multihop_node_pol.current.0.bfdMhNodePol.attributes.adminSt == "enabled" - - nm_add_bfd_multihop_node_pol.current.0.bfdMhNodePol.attributes.detectMult == "3" - - nm_add_bfd_multihop_node_pol.current.0.bfdMhNodePol.attributes.minRxIntvl == "250" - - nm_add_bfd_multihop_node_pol.current.0.bfdMhNodePol.attributes.minTxIntvl == "250" + - 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" + - cm_add_bfd_multihop_node_pol.proposed.bfdMhNodePol.attributes.adminSt == nm_add_bfd_multihop_node_pol.current.0.bfdMhNodePol.attributes.adminSt == "enabled" + - cm_add_bfd_multihop_node_pol.proposed.bfdMhNodePol.attributes.detectMult == nm_add_bfd_multihop_node_pol.current.0.bfdMhNodePol.attributes.detectMult == "3" + - cm_add_bfd_multihop_node_pol.proposed.bfdMhNodePol.attributes.minRxIntvl == nm_add_bfd_multihop_node_pol.current.0.bfdMhNodePol.attributes.minRxIntvl == "250" + - cm_add_bfd_multihop_node_pol.proposed.bfdMhNodePol.attributes.minTxIntvl == nm_add_bfd_multihop_node_pol.current.0.bfdMhNodePol.attributes.minTxIntvl == "250" - name: Add a new BFD Multihop Node policy again - idempotency cisco.aci.aci_bfd_multihop_node_policy: @@ -163,20 +163,40 @@ - 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 + - 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 - register: remove_bfd_multihop_node_pol + 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: - - remove_bfd_multihop_node_pol is changed - - remove_bfd_multihop_node_pol.previous != [] - - remove_bfd_multihop_node_pol.current == [] + - 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. diff --git a/tests/integration/targets/aci_l3out_bfd_interface_profile/tasks/main.yml b/tests/integration/targets/aci_l3out_bfd_interface_profile/tasks/main.yml index 89f7a3eaa..11e1ef26c 100644 --- a/tests/integration/targets/aci_l3out_bfd_interface_profile/tasks/main.yml +++ b/tests/integration/targets/aci_l3out_bfd_interface_profile/tasks/main.yml @@ -9,7 +9,7 @@ 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,8 +26,12 @@ 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 - when: version.current.0.topSystem.attributes.version is version('5.2', '>=') # This condition will execute only when APIC version >= 5.2 + # 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 @@ -56,7 +60,7 @@ # Add L3Out - name: Add a new L3 Outside - cisco.aci.cisco.aci.aci_l3out: + cisco.aci.aci_l3out: <<: *aci_info tenant: ansible_tenant name: ansible_l3out @@ -68,7 +72,7 @@ # ADD l3out logical node profile - name: l3out logical node profile - cisco.aci.cisco.aci.aci_l3out_logical_node_profile: + cisco.aci.aci_l3out_logical_node_profile: <<: *aci_info tenant: ansible_tenant l3out: ansible_l3out @@ -152,7 +156,7 @@ - update_l3out_bfd_int_prof.sent.bfdIfP.attributes.keyId == "15" - update_l3out_bfd_int_prof.sent.bfdIfP.attributes.key == "abc*123" - update_l3out_bfd_int_prof.sent.bfdIfP.attributes.type == "sha1" - - update_l3out_bfd_int_prof.sent.bfdIfP.children.0.bfdIfPol.attributes.tnBfdIfPolName == "ansible_bfd_interface_policy" + - update_l3out_bfd_int_prof.sent.bfdIfP.children.0.bfdRsIfPol.attributes.tnBfdIfPolName == "ansible_bfd_interface_policy" - name: Query L3Out BFD Interface Profile cisco.aci.aci_l3out_bfd_interface_profile: @@ -166,9 +170,45 @@ 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 \ No newline at end of file + 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_add_l3out_bfd_int_prof.current == remove_l3out_bfd_int_prof_again.current == [] \ No newline at end of file