diff --git a/plugins/modules/aci_access_port_to_interface_policy_leaf_profile.py b/plugins/modules/aci_access_port_to_interface_policy_leaf_profile.py index be2133d3a..b9407f34d 100644 --- a/plugins/modules/aci_access_port_to_interface_policy_leaf_profile.py +++ b/plugins/modules/aci_access_port_to_interface_policy_leaf_profile.py @@ -93,13 +93,24 @@ interface_type: description: - The type of interface for the static EPG deployment. + - The interface_type fex_profile can not be configured with a profile of type fex. type: str - choices: [ breakout, fex, port_channel, switch_port, vpc, fex_port_channel, fex_vpc] + choices: [ breakout, fex, port_channel, switch_port, vpc, fex_port_channel, fex_vpc , fex_profile] default: switch_port + fex_id: + description: + - Id of the fex profile, a valid FEX ID is between 101 to 199. + type: int + fex_profile: + description: + - The name of the Fex Profile. Value of the fex_profile is overridden by the policy_group. + type: str + aliases: [ fex_profile_name ] type: description: - The type of access port to be created under respective profile. type: str + aliases: [ profile_type ] choices: [ fex, leaf ] default: leaf state: @@ -196,6 +207,23 @@ state: query delegate_to: localhost register: query_result + +- name: Create and Bind Access Port Selector with Fex Profile Policy Group + cisco.aci.aci_access_port_to_interface_policy_leaf_profile: + host: apic + username: admin + password: SomeSecretPassword + leaf_interface_profile: leafintprftest + fex_profile: fexintprftest + policy_group: fexintprftest + access_port_selector_name: anstest_fex_accessportselector + interface_type: fex_profile + from_port: 13 + to_port: 13 + port_blk: block2 + fex_id: 105 + state: present + delegate_to: localhost """ RETURN = r""" @@ -311,6 +339,7 @@ INTERFACE_TYPE_MAPPING = dict( breakout="uni/infra/funcprof/brkoutportgrp-{0}", fex="uni/infra/funcprof/accportgrp-{0}", + fex_profile="uni/infra/fexprof-{0}/fexbundle-{1}", port_channel=port_channels_dn, switch_port="uni/infra/funcprof/accportgrp-{0}", vpc=port_channels_dn, @@ -335,9 +364,11 @@ def main(): to_card=dict(type="str", aliases=["to_card_range"]), policy_group=dict(type="str", aliases=["policy_group_name"]), interface_type=dict( - type="str", default="switch_port", choices=["breakout", "fex", "port_channel", "switch_port", "vpc", "fex_port_channel", "fex_vpc"] + type="str", default="switch_port", choices=["breakout", "fex", "port_channel", "switch_port", "vpc", "fex_port_channel", "fex_vpc", "fex_profile"] ), - type=dict(type="str", default="leaf", choices=["fex", "leaf"]), + fex_id=dict(type="int"), + fex_profile=dict(type="str", aliases=["fex_profile_name"]), + type=dict(type="str", default="leaf", choices=["fex", "leaf"], aliases=["profile_type"]), state=dict(type="str", default="present", choices=["absent", "present", "query"]), ) @@ -361,6 +392,8 @@ def main(): to_card = module.params.get("to_card") policy_group = module.params.get("policy_group") interface_type = module.params.get("interface_type") + fex_id = module.params.get("fex_id") + fex_profile = module.params.get("fex_profile") state = module.params.get("state") type_profile = module.params.get("type") @@ -382,16 +415,34 @@ def main(): # Add infraRsAccBaseGrp only when policy_group was defined if policy_group is not None: - child_configs.append( - dict( - infraRsAccBaseGrp=dict( - attributes=dict( - tDn=INTERFACE_TYPE_MAPPING[interface_type].format(policy_group), - ), - ), - ) + + infra_rs_acc_base_grp = dict( + infraRsAccBaseGrp=dict( + attributes=dict(), + ), ) + if interface_type == "fex_profile": + if type_profile == "fex": + module.fail_json(msg="Invalid Configuration - interface_type fex_profile can not be configured with a profile of type fex") + elif fex_profile is not None: + infra_rs_acc_base_grp["infraRsAccBaseGrp"]["attributes"]["tDn"] = INTERFACE_TYPE_MAPPING[interface_type].format(fex_profile, policy_group) + elif fex_profile is None: + infra_rs_acc_base_grp["infraRsAccBaseGrp"]["attributes"]["tDn"] = INTERFACE_TYPE_MAPPING[interface_type].format(policy_group, policy_group) + + if fex_id is not None: + if fex_id in range(101, 200): + infra_rs_acc_base_grp["infraRsAccBaseGrp"]["attributes"]["fexId"] = fex_id + else: + module.fail_json(msg="A valid FEX ID is between 101 to 199") + else: + module.fail_json(msg="The fex_id must not be None, when interface_type is fex_profile") + + else: + infra_rs_acc_base_grp["infraRsAccBaseGrp"]["attributes"]["tDn"] = INTERFACE_TYPE_MAPPING[interface_type].format(policy_group) + + child_configs.append(infra_rs_acc_base_grp) + aci = ACIModule(module) aci_class = "infraAccPortP" aci_rn = "accportprof" diff --git a/plugins/modules/aci_interface_policy_leaf_profile_fex_policy_group.py b/plugins/modules/aci_interface_policy_leaf_profile_fex_policy_group.py new file mode 100644 index 000000000..8b0208546 --- /dev/null +++ b/plugins/modules/aci_interface_policy_leaf_profile_fex_policy_group.py @@ -0,0 +1,292 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright: (c) 2022, Sabari Jaganathan +# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +ANSIBLE_METADATA = {"metadata_version": "1.1", "status": ["preview"], "supported_by": "certified"} + +DOCUMENTATION = r""" +--- +module: aci_interface_policy_leaf_profile_fex_policy_group +short_description: Manage leaf interface profiles fex policy group (infra:FexBndlGrp) +description: +- Manage leaf interface profiles fex policy group on Cisco ACI fabrics. +options: + name: + description: + - The name of the Fex Profile Policy Group. + type: str + aliases: [ policy_group ] + fex_profile: + description: + - The name of the Fex Profile. + type: str + state: + description: + - Use C(present) or C(absent) for adding or removing. + - Use C(query) for listing an object or multiple objects. + type: str + choices: [ absent, present, query ] + default: present +extends_documentation_fragment: +- cisco.aci.aci +- cisco.aci.annotation +- cisco.aci.owner + +seealso: +- name: APIC Management Information Model reference + description: More information about the internal APIC class B(infra:FexBndlGrp). + link: https://developer.cisco.com/docs/apic-mim-ref/ +author: +- Sabari Jaganathan (@sajagana) +""" + +EXAMPLES = r""" +- name: Add a new fex policy group + cisco.aci.aci_interface_policy_leaf_profile_fex_policy_group: + host: apic + username: admin + password: SomeSecretPassword + name: fex_policy_group + fex_profile: anstest_fex_profile + state: present + delegate_to: localhost + +- name: Add list of fex policy groups + cisco.aci.aci_interface_policy_leaf_profile_fex_policy_group: + host: apic + username: admin + password: SomeSecretPassword + name: "{{ item.name }}" + fex_profile: "{{ item.fex_profile }}" + state: present + delegate_to: localhost + with_items: + - name: fex_policy_group_1 + fex_profile: anstest_fex_profile + - name: fex_policy_group_2 + fex_profile: anstest_fex_profile + +- name: Query a fex policy group under fex profile + cisco.aci.aci_interface_policy_leaf_profile_fex_policy_group: + host: apic + username: admin + password: SomeSecretPassword + name: fex_policy_group + fex_profile: anstest_fex_profile + state: query + delegate_to: localhost + +- name: Query all fex policy groups under fex profile + cisco.aci.aci_interface_policy_leaf_profile_fex_policy_group: + host: apic + username: admin + password: SomeSecretPassword + fex_profile: anstest_fex_profile + state: query + delegate_to: localhost + +- name: Query all fex policy groups with name + cisco.aci.aci_interface_policy_leaf_profile_fex_policy_group: + host: apic + username: admin + password: SomeSecretPassword + name: fex_policy_group + state: query + delegate_to: localhost + +- name: Query all fex policy groups + cisco.aci.aci_interface_policy_leaf_profile_fex_policy_group: + host: apic + username: admin + password: SomeSecretPassword + state: query + delegate_to: localhost + +- name: Remove fex policy group + cisco.aci.aci_interface_policy_leaf_profile_fex_policy_group: + host: apic + username: admin + password: SomeSecretPassword + name: fex_policy_group + fex_profile: anstest_fex_profile + state: absent + delegate_to: localhost +""" + +RETURN = r""" +current: + description: The existing configuration from the APIC after the module has finished + returned: success + type: list + sample: + [ + { + "fvTenant": { + "attributes": { + "descr": "Production environment", + "dn": "uni/tn-production", + "name": "production", + "nameAlias": "", + "ownerKey": "", + "ownerTag": "" + } + } + } + ] +error: + description: The error information as returned from the APIC + returned: failure + type: dict + sample: + { + "code": "122", + "text": "unknown managed object class foo" + } +raw: + description: The raw output returned by the APIC REST API (xml or json) + returned: parse error + type: str + sample: '' +sent: + description: The actual/minimal configuration pushed to the APIC + returned: info + type: list + sample: + { + "fvTenant": { + "attributes": { + "descr": "Production environment" + } + } + } +previous: + description: The original configuration from the APIC before the module has started + returned: info + type: list + sample: + [ + { + "fvTenant": { + "attributes": { + "descr": "Production", + "dn": "uni/tn-production", + "name": "production", + "nameAlias": "", + "ownerKey": "", + "ownerTag": "" + } + } + } + ] +proposed: + description: The assembled configuration from the user-provided parameters + returned: info + type: dict + sample: + { + "fvTenant": { + "attributes": { + "descr": "Production environment", + "name": "production" + } + } + } +filter_string: + description: The filter string used for the request + returned: failure or debug + type: str + sample: ?rsp-prop-include=config-only +method: + description: The HTTP method used for the request to the APIC + returned: failure or debug + type: str + sample: POST +response: + description: The HTTP response from the APIC + returned: failure or debug + type: str + sample: OK (30 bytes) +status: + description: The HTTP status from the APIC + returned: failure or debug + type: int + sample: 200 +url: + description: The HTTP url used for the request to the APIC + returned: failure or debug + type: str + sample: https://10.11.12.13/api/mo/uni/tn-production.json +""" + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.cisco.aci.plugins.module_utils.aci import ACIModule, aci_argument_spec, aci_annotation_spec, aci_owner_spec + + +def main(): + argument_spec = aci_argument_spec() + argument_spec.update(aci_annotation_spec()) + argument_spec.update(aci_owner_spec()) + argument_spec.update( + name=dict(type="str", aliases=["policy_group"]), + fex_profile=dict(type="str"), + state=dict(type="str", default="present", choices=["absent", "present", "query"]), + ) + + module = AnsibleModule( + argument_spec=argument_spec, + supports_check_mode=True, + required_if=[ + ["state", "absent", ["name", "fex_profile"]], + ["state", "present", ["name", "fex_profile"]], + ], + ) + + name = module.params.get("name") + fex_profile = module.params.get("fex_profile") + state = module.params.get("state") + + aci = ACIModule(module) + + aci.construct_url( + root_class=dict( + aci_class="infraFexP", + aci_rn="infra/fexprof-{0}".format(fex_profile), + module_object=fex_profile, + target_filter={"name": fex_profile}, + ), + subclass_1=dict( + aci_class="infraFexBndlGrp", + aci_rn="fexbundle-{0}".format(name), + module_object=name, + target_filter={"name": name}, + ), + ) + + aci.get_existing() + + if state == "present": + aci.payload( + aci_class="infraFexBndlGrp", + class_config=dict( + name=name, + ), + ) + + aci.get_diff(aci_class="infraFexBndlGrp") + + aci.post_config() + + elif state == "absent": + aci.delete_config() + + aci.exit_json() + + +if __name__ == "__main__": + main() diff --git a/tests/integration/targets/aci_access_port_to_interface_policy_leaf_profile/tasks/main.yml b/tests/integration/targets/aci_access_port_to_interface_policy_leaf_profile/tasks/main.yml index 893514196..6aa648043 100644 --- a/tests/integration/targets/aci_access_port_to_interface_policy_leaf_profile/tasks/main.yml +++ b/tests/integration/targets/aci_access_port_to_interface_policy_leaf_profile/tasks/main.yml @@ -6,29 +6,25 @@ - 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.' + 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: 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) }}' + 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: Remove Interface policy leaf profile - Cleanup - 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) }}' + cisco.aci.aci_interface_policy_leaf_profile: + &aci_interface_policy_leaf_profile_absent + <<: *aci_info leaf_interface_profile: leafintprftest state: absent @@ -40,13 +36,9 @@ state: absent - name: Ensuring bindings do not already exist - cisco.aci.aci_access_port_to_interface_policy_leaf_profile: &aci_access_port_to_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) }}' + cisco.aci.aci_access_port_to_interface_policy_leaf_profile: + &aci_access_port_to_interface_policy_leaf_profile_absent + <<: *aci_info leaf_interface_profile: leafintprftest access_port_selector: anstest_accessportselector state: absent @@ -59,28 +51,42 @@ state: absent - name: Ensuring Interface Policy Leaf profile exists for kick off - cisco.aci.aci_interface_policy_leaf_profile: &aci_interface_policy_leaf_profile_present - 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 + cisco.aci.aci_interface_policy_leaf_profile: + &aci_interface_policy_leaf_profile_present + <<: *aci_info state: present leaf_interface_profile: leafintprftest register: leaf_profile_present - name: Ensuring Interface Policy Fex profile exists for kick off - cisco.aci.aci_interface_policy_leaf_profile: + cisco.aci.aci_interface_policy_leaf_profile: <<: *aci_interface_policy_leaf_profile_present type: fex leaf_interface_profile: fexintprftest +- name: Add a new fex policy group to the fexintprftest fex profile + cisco.aci.aci_interface_policy_leaf_profile_fex_policy_group: + &fexintprftest_policy_group_present + <<: *aci_info + policy_group: fexintprftest + fex_profile: fexintprftest + state: present + register: fexintprftest_policy_group_present + +- name: Assertions check for remove fex policy group from the fexintprftest fex profile + assert: + that: + - fexintprftest_policy_group_present is changed + - fexintprftest_policy_group_present.current | length == 1 + - fexintprftest_policy_group_present.previous | length == 0 + - fexintprftest_policy_group_present.current.0.infraFexBndlGrp.attributes.name == "fexintprftest" + - fexintprftest_policy_group_present.current.0.infraFexBndlGrp.attributes.dn == "uni/infra/fexprof-fexintprftest/fexbundle-fexintprftest" + # TODO: Ensure that leaf Policy Group Exists (module missing) (infra:AccPortGrp) - name: Bind an Interface Access Port Selector to an Interface Policy Leaf Profile with a Policy Group - check mode works - cisco.aci.aci_access_port_to_interface_policy_leaf_profile: &aci_access_port_to_interface_policy_leaf_profile_present + cisco.aci.aci_access_port_to_interface_policy_leaf_profile: + &aci_access_port_to_interface_policy_leaf_profile_present <<: *aci_interface_policy_leaf_profile_present access_port_selector: anstest_accessportselector check_mode: yes @@ -131,29 +137,30 @@ - name: present assertions assert: that: - - accessport_to_intf_check_mode_present is changed - - accessport_to_intf_present is changed - - accessport_to_intf_present.current.0.infraHPortS.attributes.annotation == 'orchestrator:ansible' - - accessport_to_intf_present.previous == [] - - accessport_to_intf_present.sent.infraHPortS.attributes.name == 'anstest_accessportselector' - - accessport_to_intf_idempotent is not changed - - accessport_to_intf_idempotent.sent == {} - - accessport_to_intf_update is changed - - accessport_to_intf_update.sent.infraHPortS.attributes == {} - - accessport_to_intf_update.sent.infraHPortS.children[0].infraRsAccBaseGrp.attributes.tDn == 'uni/infra/funcprof/accportgrp-anstest_policygroupname' - - accessport_to_intf_present_fex is changed - - accessport_to_intf_present_fex.previous == [] - - accessport_to_intf_present_fex.sent.infraHPortS.attributes.name == 'anstest_fex_accessportselector' - - accessport_to_intf_idempotent_fex is not changed - - accessport_to_intf_idempotent_fex.sent == {} - - accessport_to_intf_update_fex is changed - - accessport_to_intf_update_fex.sent.infraHPortS.children[0].infraRsAccBaseGrp.attributes.tDn == 'uni/infra/funcprof/accportgrp-anstest_fex_policygroupname' + - accessport_to_intf_check_mode_present is changed + - accessport_to_intf_present is changed + - accessport_to_intf_present.current.0.infraHPortS.attributes.annotation == 'orchestrator:ansible' + - accessport_to_intf_present.previous == [] + - accessport_to_intf_present.sent.infraHPortS.attributes.name == 'anstest_accessportselector' + - accessport_to_intf_idempotent is not changed + - accessport_to_intf_idempotent.sent == {} + - accessport_to_intf_update is changed + - accessport_to_intf_update.sent.infraHPortS.attributes == {} + - accessport_to_intf_update.sent.infraHPortS.children[0].infraRsAccBaseGrp.attributes.tDn == 'uni/infra/funcprof/accportgrp-anstest_policygroupname' + - accessport_to_intf_present_fex is changed + - accessport_to_intf_present_fex.previous == [] + - accessport_to_intf_present_fex.sent.infraHPortS.attributes.name == 'anstest_fex_accessportselector' + - accessport_to_intf_idempotent_fex is not changed + - accessport_to_intf_idempotent_fex.sent == {} + - accessport_to_intf_update_fex is changed + - accessport_to_intf_update_fex.sent.infraHPortS.children[0].infraRsAccBaseGrp.attributes.tDn == 'uni/infra/funcprof/accportgrp-anstest_fex_policygroupname' - name: Query Specific access_port_selector and leaf_interface_profile binding cisco.aci.aci_access_port_to_interface_policy_leaf_profile: <<: *aci_interface_policy_leaf_profile_present access_port_selector: anstest_accessportselector # "{{ fake_var | default(omit) }}" ? state: query + output_level: debug register: binding_query - name: Query Specific access_port_selector and fex_interface_profile binding @@ -163,6 +170,7 @@ access_port_selector: anstest_fex_accessportselector leaf_interface_profile: fexintprftest state: query + output_level: debug register: binding_query_fex - name: present assertions @@ -173,6 +181,68 @@ - binding_query.current | length >= 1 - '"api/mo/uni/infra/accportprof-leafintprftest/hports-anstest_accessportselector-typ-range.json" in binding_query.url' +- name: Bind anstest_fex_accessportselector with fexintprftest - Fex Profile Policy Group + cisco.aci.aci_access_port_to_interface_policy_leaf_profile: + <<: *aci_info + state: present + leaf_interface_profile: leafintprftest + fex_profile: fexintprftest + policy_group: fexintprftest + access_port_selector_name: anstest_fex_accessportselector + interface_type: fex_profile + from_port: 13 + to_port: 13 + port_blk: block2 + fex_id: 105 + register: bind_fexintprftest_policy_group + +- name: Assertions check for bind anstest_fex_accessportselector with fexintprftest - Fex Profile Policy Group + assert: + that: + - bind_fexintprftest_policy_group is changed + - bind_fexintprftest_policy_group.previous | length == 0 + - bind_fexintprftest_policy_group.current.0.infraHPortS.attributes.name == "anstest_fex_accessportselector" + - bind_fexintprftest_policy_group.current.0.infraHPortS.children.1.infraRsAccBaseGrp.attributes.fexId == "105" + - bind_fexintprftest_policy_group.current.0.infraHPortS.children.1.infraRsAccBaseGrp.attributes.tDn == "uni/infra/fexprof-fexintprftest/fexbundle-fexintprftest" + +- name: Bind anstest_fex_accessportselector_2 without fex_profile + cisco.aci.aci_access_port_to_interface_policy_leaf_profile: + <<: *aci_info + state: present + leaf_interface_profile: leafintprftest + policy_group: fexintprftest + access_port_selector_name: anstest_fex_accessportselector_2 + interface_type: fex_profile + from_port: 14 + to_port: 14 + port_blk: block2 + fex_id: 106 + register: bind_fexintprftest_policy_group_2 + +- name: Assertions check for bind anstest_fex_accessportselector with fexintprftest - Fex Profile Policy Group + assert: + that: + - bind_fexintprftest_policy_group_2 is changed + - bind_fexintprftest_policy_group_2.previous | length == 0 + - bind_fexintprftest_policy_group_2.current.0.infraHPortS.attributes.name == "anstest_fex_accessportselector_2" + - bind_fexintprftest_policy_group_2.current.0.infraHPortS.children.1.infraRsAccBaseGrp.attributes.fexId == "106" + - bind_fexintprftest_policy_group_2.current.0.infraHPortS.children.1.infraRsAccBaseGrp.attributes.tDn == "uni/infra/fexprof-fexintprftest/fexbundle-fexintprftest" + +- name: Remove fex policy group from the fexintprftest fex profile + cisco.aci.aci_interface_policy_leaf_profile_fex_policy_group: + <<: *fexintprftest_policy_group_present + state: absent + register: fexintprftest_policy_group_absent + +- name: Assertions check for remove fex policy group from the fexintprftest fex profile + assert: + that: + - fexintprftest_policy_group_absent is changed + - fexintprftest_policy_group_absent.current | length == 0 + - fexintprftest_policy_group_absent.previous | length == 1 + - fexintprftest_policy_group_absent.previous.0.infraFexBndlGrp.attributes.name == "fexintprftest" + - fexintprftest_policy_group_absent.previous.0.infraFexBndlGrp.attributes.dn == "uni/infra/fexprof-fexintprftest/fexbundle-fexintprftest" + - name: Remove binding of interface access port selector and Interface Policy Leaf Profile - check mode cisco.aci.aci_access_port_to_interface_policy_leaf_profile: <<: *aci_access_port_to_interface_policy_leaf_profile_absent @@ -244,10 +314,10 @@ - name: Assertion check for bind anstest_fex_port_channel Access Port Selector with policygroupname_link_fpc Policy Group - check mode assert: that: - - cm_fpc_present.current | length == 0 - - cm_fpc_present.previous | length == 0 - - cm_fpc_present.sent.infraHPortS.attributes.name == "anstest_fex_port_channel" - - cm_fpc_present.sent.infraHPortS.children.0.infraRsAccBaseGrp.attributes.tDn == "uni/infra/funcprof/accbundle-policygroupname_link_fpc" + - cm_fpc_present.current | length == 0 + - cm_fpc_present.previous | length == 0 + - cm_fpc_present.sent.infraHPortS.attributes.name == "anstest_fex_port_channel" + - cm_fpc_present.sent.infraHPortS.children.0.infraRsAccBaseGrp.attributes.tDn == "uni/infra/funcprof/accbundle-policygroupname_link_fpc" - name: Bind anstest_fex_port_channel Access Port Selector with policygroupname_link_fpc Policy Group - normal mode cisco.aci.aci_access_port_to_interface_policy_leaf_profile: &nm_fpc_present @@ -257,11 +327,11 @@ - name: Assertion check for bind anstest_fex_port_channel Access Port Selector with policygroupname_link_fpc Policy Group - normal mode assert: that: - - nm_fpc_present.current | length == 1 - - nm_fpc_present.previous | length == 0 - - nm_fpc_present.current.0.infraHPortS.attributes.name == "anstest_fex_port_channel" - - nm_fpc_present.current.0.infraHPortS.children.0.infraRsAccBaseGrp.attributes.tDn == "uni/infra/funcprof/accbundle-policygroupname_link_fpc" - - nm_fpc_present.current.0.infraHPortS.children.0.infraRsAccBaseGrp.attributes.fexId == "101" + - nm_fpc_present.current | length == 1 + - nm_fpc_present.previous | length == 0 + - nm_fpc_present.current.0.infraHPortS.attributes.name == "anstest_fex_port_channel" + - nm_fpc_present.current.0.infraHPortS.children.0.infraRsAccBaseGrp.attributes.tDn == "uni/infra/funcprof/accbundle-policygroupname_link_fpc" + - nm_fpc_present.current.0.infraHPortS.children.0.infraRsAccBaseGrp.attributes.fexId == "101" - name: Remove anstest_fex_port_channel Access Port Selector with policygroupname_link_fpc Policy Group - check mode cisco.aci.aci_access_port_to_interface_policy_leaf_profile: &cm_fpc_absent @@ -273,14 +343,14 @@ - name: Assertion check for remove anstest_fex_port_channel Access Port Selector with policygroupname_link_fpc Policy Group - check mode assert: that: - - cm_fpc_absent.current | length == 1 - - cm_fpc_absent.previous | length == 1 - - cm_fpc_absent.current.0.infraHPortS.attributes.name == "anstest_fex_port_channel" - - cm_fpc_absent.previous.0.infraHPortS.attributes.name == "anstest_fex_port_channel" - - cm_fpc_absent.current.0.infraHPortS.children.0.infraRsAccBaseGrp.attributes.tDn == "uni/infra/funcprof/accbundle-policygroupname_link_fpc" - - cm_fpc_absent.previous.0.infraHPortS.children.0.infraRsAccBaseGrp.attributes.tDn == "uni/infra/funcprof/accbundle-policygroupname_link_fpc" - - cm_fpc_absent.current.0.infraHPortS.children.0.infraRsAccBaseGrp.attributes.fexId == "101" - - cm_fpc_absent.previous.0.infraHPortS.children.0.infraRsAccBaseGrp.attributes.fexId == "101" + - cm_fpc_absent.current | length == 1 + - cm_fpc_absent.previous | length == 1 + - cm_fpc_absent.current.0.infraHPortS.attributes.name == "anstest_fex_port_channel" + - cm_fpc_absent.previous.0.infraHPortS.attributes.name == "anstest_fex_port_channel" + - cm_fpc_absent.current.0.infraHPortS.children.0.infraRsAccBaseGrp.attributes.tDn == "uni/infra/funcprof/accbundle-policygroupname_link_fpc" + - cm_fpc_absent.previous.0.infraHPortS.children.0.infraRsAccBaseGrp.attributes.tDn == "uni/infra/funcprof/accbundle-policygroupname_link_fpc" + - cm_fpc_absent.current.0.infraHPortS.children.0.infraRsAccBaseGrp.attributes.fexId == "101" + - cm_fpc_absent.previous.0.infraHPortS.children.0.infraRsAccBaseGrp.attributes.fexId == "101" - name: Remove anstest_fex_port_channel Access Port Selector with policygroupname_link_fpc Policy Group - normal mode cisco.aci.aci_access_port_to_interface_policy_leaf_profile: @@ -290,11 +360,11 @@ - name: Assertion check for remove anstest_fex_port_channel Access Port Selector with policygroupname_link_fpc Policy Group - normal mode assert: that: - - nm_fpc_absent.current | length == 0 - - nm_fpc_absent.previous | length == 1 - - nm_fpc_absent.previous.0.infraHPortS.attributes.name == "anstest_fex_port_channel" - - nm_fpc_absent.previous.0.infraHPortS.children.0.infraRsAccBaseGrp.attributes.tDn == "uni/infra/funcprof/accbundle-policygroupname_link_fpc" - - nm_fpc_absent.previous.0.infraHPortS.children.0.infraRsAccBaseGrp.attributes.fexId == "101" + - nm_fpc_absent.current | length == 0 + - nm_fpc_absent.previous | length == 1 + - nm_fpc_absent.previous.0.infraHPortS.attributes.name == "anstest_fex_port_channel" + - nm_fpc_absent.previous.0.infraHPortS.children.0.infraRsAccBaseGrp.attributes.tDn == "uni/infra/funcprof/accbundle-policygroupname_link_fpc" + - nm_fpc_absent.previous.0.infraHPortS.children.0.infraRsAccBaseGrp.attributes.fexId == "101" - name: Add anstest_fex_vpc - Interface Policy Leaf Profile with type Fex cisco.aci.aci_interface_policy_leaf_profile: &anstest_fex_vpc @@ -306,9 +376,9 @@ - name: Assertion check for add anstest_fex_vpc - Interface Policy Leaf Profile with type Fex assert: that: - - anstest_fex_vpc_present.current | length == 1 - - anstest_fex_vpc_present.current.0.infraFexP.attributes.name == "anstest_fex_vpc" - - anstest_fex_vpc_present.current.0.infraFexP.attributes.dn == "uni/infra/fexprof-anstest_fex_vpc" + - anstest_fex_vpc_present.current | length == 1 + - anstest_fex_vpc_present.current.0.infraFexP.attributes.name == "anstest_fex_vpc" + - anstest_fex_vpc_present.current.0.infraFexP.attributes.dn == "uni/infra/fexprof-anstest_fex_vpc" - name: Add policygroupname_node_fvpc - Policy Group with lag type node cisco.aci.aci_interface_policy_leaf_policy_group: @@ -323,12 +393,13 @@ - name: Assertion check for add policygroupname_node_fvpc - Policy Group with lag type node assert: that: - - policygroupname_node_fvpc_present.current | length == 1 - - policygroupname_node_fvpc_present.current.0.infraAccBndlGrp.attributes.name == "policygroupname_node_fvpc" - - policygroupname_node_fvpc_present.current.0.infraAccBndlGrp.attributes.lagT == "node" + - policygroupname_node_fvpc_present.current | length == 1 + - policygroupname_node_fvpc_present.current.0.infraAccBndlGrp.attributes.name == "policygroupname_node_fvpc" + - policygroupname_node_fvpc_present.current.0.infraAccBndlGrp.attributes.lagT == "node" - name: Bind anstest_fex_vpc Access Port Selector with policygroupname_node_fvpc Policy Group - check mode - cisco.aci.aci_access_port_to_interface_policy_leaf_profile: &cm_fex_vpc_present + cisco.aci.aci_access_port_to_interface_policy_leaf_profile: + &cm_fex_vpc_present <<: *anstest_fex_vpc interface_type: fex_vpc access_port_selector: anstest_fex_vpc @@ -339,10 +410,10 @@ - name: Assertion check for bind anstest_fex_vpc Access Port Selector with policygroupname_node_fvpc Policy Group - check mode assert: that: - - cm_fex_vpc_present.current | length == 0 - - cm_fex_vpc_present.previous | length == 0 - - cm_fex_vpc_present.sent.infraHPortS.attributes.name == "anstest_fex_vpc" - - cm_fex_vpc_present.sent.infraHPortS.children.0.infraRsAccBaseGrp.attributes.tDn == "uni/infra/funcprof/accbundle-policygroupname_node_fvpc" + - cm_fex_vpc_present.current | length == 0 + - cm_fex_vpc_present.previous | length == 0 + - cm_fex_vpc_present.sent.infraHPortS.attributes.name == "anstest_fex_vpc" + - cm_fex_vpc_present.sent.infraHPortS.children.0.infraRsAccBaseGrp.attributes.tDn == "uni/infra/funcprof/accbundle-policygroupname_node_fvpc" - name: Bind anstest_fex_vpc Access Port Selector with policygroupname_node_fvpc Policy Group - normal mode cisco.aci.aci_access_port_to_interface_policy_leaf_profile: @@ -352,11 +423,11 @@ - name: Assertion check for bind anstest_fex_vpc Access Port Selector with policygroupname_node_fvpc Policy Group - normal mode assert: that: - - nm_fex_vpc_present.current | length == 1 - - nm_fex_vpc_present.previous | length == 0 - - nm_fex_vpc_present.current.0.infraHPortS.attributes.name == "anstest_fex_vpc" - - nm_fex_vpc_present.current.0.infraHPortS.children.0.infraRsAccBaseGrp.attributes.fexId == "101" - - nm_fex_vpc_present.current.0.infraHPortS.children.0.infraRsAccBaseGrp.attributes.tDn == "uni/infra/funcprof/accbundle-policygroupname_node_fvpc" + - nm_fex_vpc_present.current | length == 1 + - nm_fex_vpc_present.previous | length == 0 + - nm_fex_vpc_present.current.0.infraHPortS.attributes.name == "anstest_fex_vpc" + - nm_fex_vpc_present.current.0.infraHPortS.children.0.infraRsAccBaseGrp.attributes.fexId == "101" + - nm_fex_vpc_present.current.0.infraHPortS.children.0.infraRsAccBaseGrp.attributes.tDn == "uni/infra/funcprof/accbundle-policygroupname_node_fvpc" - name: Remove anstest_fex_vpc Access Port Selector with policygroupname_node_fvpc Policy Group - check mode cisco.aci.aci_access_port_to_interface_policy_leaf_profile: &cm_fex_vpc_absent @@ -368,14 +439,14 @@ - name: Assertion check for remove anstest_fex_vpc Access Port Selector with policygroupname_node_fvpc Policy Group - check mode assert: that: - - cm_fex_vpc_absent.current | length == 1 - - cm_fex_vpc_absent.previous | length == 1 - - cm_fex_vpc_absent.current.0.infraHPortS.attributes.name == "anstest_fex_vpc" - - cm_fex_vpc_absent.previous.0.infraHPortS.attributes.name == "anstest_fex_vpc" - - cm_fex_vpc_absent.current.0.infraHPortS.children.0.infraRsAccBaseGrp.attributes.fexId == "101" - - cm_fex_vpc_absent.previous.0.infraHPortS.children.0.infraRsAccBaseGrp.attributes.fexId == "101" - - cm_fex_vpc_absent.current.0.infraHPortS.children.0.infraRsAccBaseGrp.attributes.tDn == "uni/infra/funcprof/accbundle-policygroupname_node_fvpc" - - cm_fex_vpc_absent.previous.0.infraHPortS.children.0.infraRsAccBaseGrp.attributes.tDn == "uni/infra/funcprof/accbundle-policygroupname_node_fvpc" + - cm_fex_vpc_absent.current | length == 1 + - cm_fex_vpc_absent.previous | length == 1 + - cm_fex_vpc_absent.current.0.infraHPortS.attributes.name == "anstest_fex_vpc" + - cm_fex_vpc_absent.previous.0.infraHPortS.attributes.name == "anstest_fex_vpc" + - cm_fex_vpc_absent.current.0.infraHPortS.children.0.infraRsAccBaseGrp.attributes.fexId == "101" + - cm_fex_vpc_absent.previous.0.infraHPortS.children.0.infraRsAccBaseGrp.attributes.fexId == "101" + - cm_fex_vpc_absent.current.0.infraHPortS.children.0.infraRsAccBaseGrp.attributes.tDn == "uni/infra/funcprof/accbundle-policygroupname_node_fvpc" + - cm_fex_vpc_absent.previous.0.infraHPortS.children.0.infraRsAccBaseGrp.attributes.tDn == "uni/infra/funcprof/accbundle-policygroupname_node_fvpc" - name: Remove anstest_fex_vpc Access Port Selector with policygroupname_node_fvpc Policy Group - normal mode cisco.aci.aci_access_port_to_interface_policy_leaf_profile: @@ -385,11 +456,11 @@ - name: Assertion check for remove anstest_fex_vpc Access Port Selector with policygroupname_node_fvpc Policy Group - normal mode assert: that: - - nm_fex_vpc_absent.current | length == 0 - - nm_fex_vpc_absent.previous | length == 1 - - nm_fex_vpc_absent.previous.0.infraHPortS.attributes.name == "anstest_fex_vpc" - - nm_fex_vpc_absent.previous.0.infraHPortS.children.0.infraRsAccBaseGrp.attributes.fexId == "101" - - nm_fex_vpc_absent.previous.0.infraHPortS.children.0.infraRsAccBaseGrp.attributes.tDn == "uni/infra/funcprof/accbundle-policygroupname_node_fvpc" + - nm_fex_vpc_absent.current | length == 0 + - nm_fex_vpc_absent.previous | length == 1 + - nm_fex_vpc_absent.previous.0.infraHPortS.attributes.name == "anstest_fex_vpc" + - nm_fex_vpc_absent.previous.0.infraHPortS.children.0.infraRsAccBaseGrp.attributes.fexId == "101" + - nm_fex_vpc_absent.previous.0.infraHPortS.children.0.infraRsAccBaseGrp.attributes.tDn == "uni/infra/funcprof/accbundle-policygroupname_node_fvpc" # Removing profiles - name: Remove anstest_fex_vpc - Interface Policy Leaf Profile with type Fex @@ -401,9 +472,9 @@ - name: Assertion check for remove anstest_fex_vpc - Interface Policy Leaf Profile with type Fex assert: that: - - anstest_fex_vpc_absent.current | length == 0 - - anstest_fex_vpc_absent.previous | length == 1 - - anstest_fex_vpc_absent.previous.0.infraFexP.attributes.name == "anstest_fex_vpc" + - anstest_fex_vpc_absent.current | length == 0 + - anstest_fex_vpc_absent.previous | length == 1 + - anstest_fex_vpc_absent.previous.0.infraFexP.attributes.name == "anstest_fex_vpc" - name: Remove anstest_fex_port_channel - Interface Policy Leaf Profile with type Fex cisco.aci.aci_interface_policy_leaf_profile: @@ -414,6 +485,238 @@ - name: Assertion check for remove anstest_fex_port_channel - Interface Policy Leaf Profile with type Fex assert: that: - - anstest_fex_port_channel_absent.current | length == 0 - - anstest_fex_port_channel_absent.previous | length == 1 - - anstest_fex_port_channel_absent.previous.0.infraFexP.attributes.name == "anstest_fex_port_channel" + - anstest_fex_port_channel_absent.current | length == 0 + - anstest_fex_port_channel_absent.previous | length == 1 + - anstest_fex_port_channel_absent.previous.0.infraFexP.attributes.name == "anstest_fex_port_channel" + +- name: Ensure anstest_leaf_profile interface does not exists + cisco.aci.aci_interface_policy_leaf_profile: &anstest_leaf_profile_absent + <<: *aci_info + type: leaf + leaf_interface_profile: anstest_leaf_profile + state: absent + register: anstest_leaf_profile_absent + +- name: Assertion check for ensure anstest_leaf_profile interface does not exists + assert: + that: + - anstest_leaf_profile_absent.current | length == 0 + +- name: Ensure anstest_fex_profile interface does not exists + cisco.aci.aci_interface_policy_leaf_profile: &anstest_fex_profile_absent + <<: *aci_info + type: fex + leaf_interface_profile: anstest_fex_profile + state: absent + register: anstest_fex_profile_absent + +- name: Assertion check for ensure anstest_fex_profile interface does not exists + assert: + that: + - anstest_fex_profile_absent.current | length == 0 + +- name: Ensure temp_anstest_fex_profile interface does not exists + cisco.aci.aci_interface_policy_leaf_profile: &temp_anstest_fex_profile_absent + <<: *aci_info + type: fex + leaf_interface_profile: temp_anstest_fex_profile + state: absent + register: temp_anstest_fex_profile_absent + +- name: Assertion check for ensure temp_anstest_fex_profile interface does not exists + assert: + that: + - temp_anstest_fex_profile_absent.current | length == 0 + +- name: Add a new anstest_leaf_profile with profile type leaf + cisco.aci.aci_interface_policy_leaf_profile: &anstest_leaf_profile_present + <<: *anstest_leaf_profile_absent + state: present + register: anstest_leaf_profile_present + +- name: Assertion check for add a new anstest_leaf_profile with profile type leaf + assert: + that: + - anstest_leaf_profile_present is changed + - anstest_leaf_profile_present.current | length == 1 + - anstest_leaf_profile_present.previous | length == 0 + - anstest_leaf_profile_present.current.0.infraAccPortP.attributes.name == "anstest_leaf_profile" + - anstest_leaf_profile_present.current.0.infraAccPortP.attributes.dn == "uni/infra/accportprof-anstest_leaf_profile" + +- name: Add a new anstest_fex_profile with profile type fex + cisco.aci.aci_interface_policy_leaf_profile: &anstest_fex_profile_present + <<: *anstest_fex_profile_absent + state: present + register: anstest_fex_profile_present + +- name: Assertion check for add a new anstest_fex_profile with profile type fex + assert: + that: + - anstest_fex_profile_present is changed + - anstest_fex_profile_present.current | length == 1 + - anstest_fex_profile_present.previous | length == 0 + - anstest_fex_profile_present.current.0.infraFexP.attributes.name == "anstest_fex_profile" + - anstest_fex_profile_present.current.0.infraFexP.attributes.dn == "uni/infra/fexprof-anstest_fex_profile" + +- name: Add a new temp_anstest_fex_profile with profile type fex + cisco.aci.aci_interface_policy_leaf_profile: &temp_anstest_fex_profile_present + <<: *temp_anstest_fex_profile_absent + state: present + register: temp_anstest_fex_profile_present + +- name: Assertion check for add a new temp_anstest_fex_profile with profile type fex + assert: + that: + - temp_anstest_fex_profile_present is changed + - temp_anstest_fex_profile_present.current | length == 1 + - temp_anstest_fex_profile_present.previous | length == 0 + - temp_anstest_fex_profile_present.current.0.infraFexP.attributes.name == "temp_anstest_fex_profile" + - temp_anstest_fex_profile_present.current.0.infraFexP.attributes.dn == "uni/infra/fexprof-temp_anstest_fex_profile" + +- name: Add a new policy_group with the same name of interface profile - temp_anstest_fex_profile + cisco.aci.aci_interface_policy_leaf_profile_fex_policy_group: + &temp_anstest_fex_profile_policy_group_present + <<: *aci_info + policy_group: temp_anstest_fex_profile + fex_profile: temp_anstest_fex_profile + state: present + 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: + that: + - temp_anstest_fex_profile_policy_group_present is changed + - temp_anstest_fex_profile_policy_group_present.current | length == 1 + - temp_anstest_fex_profile_policy_group_present.previous | length == 0 + - temp_anstest_fex_profile_policy_group_present.current.0.infraFexBndlGrp.attributes.name == "temp_anstest_fex_profile" + - temp_anstest_fex_profile_policy_group_present.current.0.infraFexBndlGrp.attributes.dn == "uni/infra/fexprof-temp_anstest_fex_profile/fexbundle-temp_anstest_fex_profile" + +- name: Bind temp_anstest_fex_profile with anstest_fex_profile - Fex Profile Policy Group + cisco.aci.aci_access_port_to_interface_policy_leaf_profile: + <<: *aci_info + leaf_interface_profile: anstest_fex_profile + policy_group: temp_anstest_fex_profile + access_port_selector_name: temp_anstest_fex_profile_access_port + interface_type: fex_profile + fex_id: 105 + type: fex + state: present + register: temp_anstest_fex_profile_access_port_present + ignore_errors: yes + +- name: Assertion check for bind temp_anstest_fex_profile with anstest_fex_profile - Fex Profile Policy Group + 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" + +- name: Remove temp_anstest_fex_profile + cisco.aci.aci_interface_policy_leaf_profile: + <<: *temp_anstest_fex_profile_absent + register: remove_anstest_fex_profile_absent + +- name: Assertion check for remove temp_anstest_fex_profile + assert: + that: + - remove_anstest_fex_profile_absent is changed + - remove_anstest_fex_profile_absent.current | length == 0 + - remove_anstest_fex_profile_absent.previous | length == 1 + +- name: Add a new policy_group with the same name of interface profile - anstest_fex_profile + cisco.aci.aci_interface_policy_leaf_profile_fex_policy_group: + &anstest_fex_profile_policy_group_present + <<: *aci_info + policy_group: anstest_fex_profile + fex_profile: anstest_fex_profile + state: present + 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: + that: + - anstest_fex_profile_policy_group_present is changed + - anstest_fex_profile_policy_group_present.current | length == 1 + - anstest_fex_profile_policy_group_present.previous | length == 0 + - anstest_fex_profile_policy_group_present.current.0.infraFexBndlGrp.attributes.name == "anstest_fex_profile" + - anstest_fex_profile_policy_group_present.current.0.infraFexBndlGrp.attributes.dn == "uni/infra/fexprof-anstest_fex_profile/fexbundle-anstest_fex_profile" + +- name: Bind anstest_leaf_profile with anstest_fex_profile - Fex Profile Policy Group + cisco.aci.aci_access_port_to_interface_policy_leaf_profile: + &anstest_leaf_profile_access_port_present + <<: *aci_info + leaf_interface_profile: anstest_leaf_profile + policy_group: anstest_fex_profile + access_port_selector_name: anstest_leaf_profile_access_port + interface_type: fex_profile + fex_id: 105 + type: leaf + state: present + register: anstest_leaf_profile_access_port_present + +- name: Assertion check for bind anstest_leaf_profile with anstest_fex_profile - Fex Profile Policy Group + assert: + that: + - anstest_leaf_profile_access_port_present is changed + - anstest_leaf_profile_access_port_present.current | length == 1 + - anstest_leaf_profile_access_port_present.previous | length == 0 + - anstest_leaf_profile_access_port_present.current.0.infraHPortS.attributes.name == "anstest_leaf_profile_access_port" + - anstest_leaf_profile_access_port_present.current.0.infraHPortS.children.0.infraRsAccBaseGrp.attributes.tDn == "uni/infra/fexprof-anstest_fex_profile/fexbundle-anstest_fex_profile" + - anstest_leaf_profile_access_port_present.current.0.infraHPortS.children.0.infraRsAccBaseGrp.attributes.fexId == "105" + +- name: Bind anstest_leaf_profile with anstest_fex_profile with wrong fex_id + cisco.aci.aci_access_port_to_interface_policy_leaf_profile: + <<: *aci_info + leaf_interface_profile: anstest_leaf_profile + policy_group: anstest_fex_profile + access_port_selector_name: anstest_leaf_profile_access_port + interface_type: fex_profile + fex_id: 999 + type: leaf + state: present + ignore_errors: yes + register: anstest_leaf_profile_access_port_wrong_fex_id + +- name: Assertion check for bind anstest_leaf_profile with wrong fex_id + assert: + that: + - anstest_leaf_profile_access_port_wrong_fex_id.msg == "A valid FEX ID is between 101 to 199" + +- name: Bind anstest_leaf_profile with anstest_fex_profile with no fex_id + cisco.aci.aci_access_port_to_interface_policy_leaf_profile: + <<: *aci_info + leaf_interface_profile: anstest_leaf_profile + policy_group: anstest_fex_profile + access_port_selector_name: anstest_leaf_profile_access_port + interface_type: fex_profile + type: leaf + state: present + ignore_errors: yes + register: anstest_leaf_profile_access_port_no_fex_id + +- name: Assertion check for bind anstest_leaf_profile with no fex_id + assert: + that: + - anstest_leaf_profile_access_port_no_fex_id.msg == "The fex_id must not be None, when interface_type is fex_profile" + +- name: Remove anstest_leaf_profile + cisco.aci.aci_interface_policy_leaf_profile: + <<: *anstest_leaf_profile_absent + register: anstest_leaf_profile_cleanup + +- name: Assertion check for remove anstest_leaf_profile + assert: + that: + - anstest_leaf_profile_cleanup is changed + - anstest_leaf_profile_cleanup.previous | length == 1 + - anstest_leaf_profile_cleanup.current | length == 0 + +- name: Remove anstest_fex_profile + cisco.aci.aci_interface_policy_leaf_profile: + <<: *anstest_fex_profile_absent + register: anstest_fex_profile_cleanup + +- name: Assertion check for remove anstest_fex_profile + assert: + that: + - anstest_fex_profile_cleanup is changed + - anstest_fex_profile_cleanup.previous | length == 1 + - anstest_fex_profile_cleanup.current | length == 0 diff --git a/tests/integration/targets/aci_interface_policy_leaf_profile_fex_policy_group/aliases b/tests/integration/targets/aci_interface_policy_leaf_profile_fex_policy_group/aliases new file mode 100644 index 000000000..209b793f9 --- /dev/null +++ b/tests/integration/targets/aci_interface_policy_leaf_profile_fex_policy_group/aliases @@ -0,0 +1,2 @@ +# No ACI simulator yet, so not enabled +# unsupported diff --git a/tests/integration/targets/aci_interface_policy_leaf_profile_fex_policy_group/tasks/main.yml b/tests/integration/targets/aci_interface_policy_leaf_profile_fex_policy_group/tasks/main.yml new file mode 100644 index 000000000..bbea74d61 --- /dev/null +++ b/tests/integration/targets/aci_interface_policy_leaf_profile_fex_policy_group/tasks/main.yml @@ -0,0 +1,289 @@ +# Test code for the ACI modules +# Copyright: (c) 2022, Sabari Jaganathan (@sajagana) + +# GNU 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 + +# SET VARS +- name: Set vars + 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: Ensure anstest_fex_profile - Interface Policy Fex profile does not exists + cisco.aci.aci_interface_policy_leaf_profile: &fex_profile_absent + <<: *aci_info + type: fex + leaf_interface_profile: anstest_fex_profile + state: absent + +- name: Add anstest_fex_profile - Interface Policy Fex profile + cisco.aci.aci_interface_policy_leaf_profile: &fex_profile_present + <<: *fex_profile_absent + state: present + register: fex_profile_present + +- name: Add Fex Policy Group to anstest_fex_profile - Interface Policy Fex profile with check mode + cisco.aci.aci_interface_policy_leaf_profile_fex_policy_group: + &cm_fex_policy_group_present + <<: *aci_info + name: anstest_fex_policy_group + fex_profile: anstest_fex_profile + state: present + check_mode: yes + 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: + that: + - cm_fex_policy_group_present is changed + - cm_fex_policy_group_present.current | length == 0 + - cm_fex_policy_group_present.previous | length == 0 + - cm_fex_policy_group_present.sent.infraFexBndlGrp.attributes.name == "anstest_fex_policy_group" + - cm_fex_policy_group_present.sent.infraFexBndlGrp.attributes.dn == "uni/infra/fexprof-anstest_fex_profile/fexbundle-anstest_fex_policy_group" + +- name: Add Fex Policy Group to anstest_fex_profile - Interface Policy Fex profile with normal mode + cisco.aci.aci_interface_policy_leaf_profile_fex_policy_group: + &nm_fex_policy_group_present + <<: *cm_fex_policy_group_present + 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: + that: + - nm_fex_policy_group_present is changed + - nm_fex_policy_group_present.current | length == 1 + - nm_fex_policy_group_present.previous | length == 0 + - nm_fex_policy_group_present.current.0.infraFexBndlGrp.attributes.name == "anstest_fex_policy_group" + - nm_fex_policy_group_present.current.0.infraFexBndlGrp.attributes.dn == "uni/infra/fexprof-anstest_fex_profile/fexbundle-anstest_fex_policy_group" + +- name: Add Fex Policy Group to anstest_fex_profile - Interface Policy Fex profile with normal mode - idempotency works + cisco.aci.aci_interface_policy_leaf_profile_fex_policy_group: + &idempotency_fex_policy_group_present + <<: *nm_fex_policy_group_present + 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: + that: + - idempotency_fex_policy_group_present is not changed + - idempotency_fex_policy_group_present.current | length == 1 + - idempotency_fex_policy_group_present.previous | length == 1 + - idempotency_fex_policy_group_present.current.0.infraFexBndlGrp.attributes.name == "anstest_fex_policy_group" + - idempotency_fex_policy_group_present.current.0.infraFexBndlGrp.attributes.dn == "uni/infra/fexprof-anstest_fex_profile/fexbundle-anstest_fex_policy_group" + - idempotency_fex_policy_group_present.previous.0.infraFexBndlGrp.attributes.name == "anstest_fex_policy_group" + - idempotency_fex_policy_group_present.previous.0.infraFexBndlGrp.attributes.dn == "uni/infra/fexprof-anstest_fex_profile/fexbundle-anstest_fex_policy_group" + +- name: Add multiple Fex Policy Group to anstest_fex_profile - Interface Policy Fex profile with normal mode + cisco.aci.aci_interface_policy_leaf_profile_fex_policy_group: + <<: *aci_info + name: "{{ item.name }}" + fex_profile: "{{ item.fex_profile }}" + state: present + with_items: + - name: anstest_fex_policy_group_1 + fex_profile: anstest_fex_profile + - name: anstest_fex_policy_group_2 + fex_profile: anstest_fex_profile + 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: + that: + - multiple_fex_policy_group_present is changed + - multiple_fex_policy_group_present.results.0 is changed + - multiple_fex_policy_group_present.results.1 is changed + - multiple_fex_policy_group_present.results.0.current | length == 1 + - multiple_fex_policy_group_present.results.1.current | length == 1 + - multiple_fex_policy_group_present.results.0.current.0.infraFexBndlGrp.attributes.name == "anstest_fex_policy_group_1" + - multiple_fex_policy_group_present.results.1.current.0.infraFexBndlGrp.attributes.name == "anstest_fex_policy_group_2" + - multiple_fex_policy_group_present.results.0.current.0.infraFexBndlGrp.attributes.dn == "uni/infra/fexprof-anstest_fex_profile/fexbundle-anstest_fex_policy_group_1" + - multiple_fex_policy_group_present.results.1.current.0.infraFexBndlGrp.attributes.dn == "uni/infra/fexprof-anstest_fex_profile/fexbundle-anstest_fex_policy_group_2" + +- name: Ensure temp_anstest_fex_profile - Interface Policy Fex profile does not exists + cisco.aci.aci_interface_policy_leaf_profile: &temp_anstest_fex_profile_absent + <<: *aci_info + type: fex + leaf_interface_profile: temp_anstest_fex_profile + state: absent + register: temp_anstest_fex_profile_absent + +- name: Assertions check for remove temp_anstest_fex_profile - Interface Policy Fex profile + assert: + that: + - temp_anstest_fex_profile_absent.current | length == 0 + +- name: Add temp_anstest_fex_profile - Interface Policy Fex profile + cisco.aci.aci_interface_policy_leaf_profile: &temp_anstest_fex_profile_present + <<: *temp_anstest_fex_profile_absent + state: present + register: temp_anstest_fex_profile_present + +- name: Assertions check for add temp_anstest_fex_profile - Interface Policy Fex profile + assert: + that: + - temp_anstest_fex_profile_present is changed + - temp_anstest_fex_profile_present.current | length == 1 + - temp_anstest_fex_profile_present.previous | length == 0 + +- name: Add Fex Policy Group to temp_anstest_fex_profile - Interface Policy Fex profile + cisco.aci.aci_interface_policy_leaf_profile_fex_policy_group: + <<: *aci_info + name: anstest_fex_policy_group + fex_profile: temp_anstest_fex_profile + state: present + 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: + that: + - temp_anstest_fex_policy_group_present is changed + - temp_anstest_fex_policy_group_present.current | length == 1 + - temp_anstest_fex_policy_group_present.previous | length == 0 + - temp_anstest_fex_policy_group_present.current.0.infraFexBndlGrp.attributes.name == "anstest_fex_policy_group" + - temp_anstest_fex_policy_group_present.current.0.infraFexBndlGrp.attributes.dn == "uni/infra/fexprof-temp_anstest_fex_profile/fexbundle-anstest_fex_policy_group" + +- name: Query anstest_fex_policy_group - fex policy group with fex_profile + cisco.aci.aci_interface_policy_leaf_profile_fex_policy_group: + <<: *aci_info + name: anstest_fex_policy_group + fex_profile: anstest_fex_profile + state: query + register: query_res_fex_policy_group_with_profile + +- name: Assertions check for query anstest_fex_policy_group - fex policy group with fex_profile + assert: + that: + - query_res_fex_policy_group_with_profile is not changed + - query_res_fex_policy_group_with_profile.current | length == 1 + - query_res_fex_policy_group_with_profile.current.0.infraFexBndlGrp.attributes.name == "anstest_fex_policy_group" + - query_res_fex_policy_group_with_profile.current.0.infraFexBndlGrp.attributes.dn == "uni/infra/fexprof-anstest_fex_profile/fexbundle-anstest_fex_policy_group" + +- name: Query all fex policy group under anstest_fex_profile + cisco.aci.aci_interface_policy_leaf_profile_fex_policy_group: + <<: *aci_info + fex_profile: anstest_fex_profile + state: query + register: query_all_policy_groups_under_fex_profile + +- name: Assertions check for query all fex policy group under anstest_fex_profile + 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 + +- name: Query all anstest_fex_policy_group - fex policy groups + cisco.aci.aci_interface_policy_leaf_profile_fex_policy_group: + <<: *aci_info + name: anstest_fex_policy_group + state: query + register: query_res_anstest_fex_policy_group + +- name: Assertions check for query all anstest_fex_policy_group - fex policy groups + assert: + that: + - query_res_anstest_fex_policy_group is not changed + - query_res_anstest_fex_policy_group.current | length >= 2 + - query_res_anstest_fex_policy_group.current.0.infraFexBndlGrp.attributes.name == "anstest_fex_policy_group" + - query_res_anstest_fex_policy_group.current.1.infraFexBndlGrp.attributes.name == "anstest_fex_policy_group" + +- name: Query all - fex policy groups + cisco.aci.aci_interface_policy_leaf_profile_fex_policy_group: + <<: *aci_info + state: query + register: all_fex_policy_groups + +- name: Assertions check for query all - fex policy groups + assert: + that: + - all_fex_policy_groups is not changed + - all_fex_policy_groups.current | length >= 4 + +- name: Remove anstest_fex_policy_group - Fex Policy Group from anstest_fex_profile with check mode + cisco.aci.aci_interface_policy_leaf_profile_fex_policy_group: + &cm_anstest_fex_policy_group_absent + <<: *aci_info + name: anstest_fex_policy_group + fex_profile: anstest_fex_profile + state: absent + check_mode: yes + 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: + that: + - cm_anstest_fex_policy_group_absent is changed + - cm_anstest_fex_policy_group_absent.current | length == 1 + - cm_anstest_fex_policy_group_absent.previous | length == 1 + - cm_anstest_fex_policy_group_absent.current.0.infraFexBndlGrp.attributes.name == "anstest_fex_policy_group" + - cm_anstest_fex_policy_group_absent.current.0.infraFexBndlGrp.attributes.dn == "uni/infra/fexprof-anstest_fex_profile/fexbundle-anstest_fex_policy_group" + - cm_anstest_fex_policy_group_absent.previous.0.infraFexBndlGrp.attributes.name == "anstest_fex_policy_group" + - cm_anstest_fex_policy_group_absent.previous.0.infraFexBndlGrp.attributes.dn == "uni/infra/fexprof-anstest_fex_profile/fexbundle-anstest_fex_policy_group" + +- name: Remove anstest_fex_policy_group - Fex Policy Group from anstest_fex_profile with normal mode + cisco.aci.aci_interface_policy_leaf_profile_fex_policy_group: + &nm_anstest_fex_policy_group_absent + <<: *cm_anstest_fex_policy_group_absent + 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: + that: + - nm_anstest_fex_policy_group_absent is changed + - nm_anstest_fex_policy_group_absent.current | length == 0 + - nm_anstest_fex_policy_group_absent.previous | length == 1 + - nm_anstest_fex_policy_group_absent.previous.0.infraFexBndlGrp.attributes.name == "anstest_fex_policy_group" + - nm_anstest_fex_policy_group_absent.previous.0.infraFexBndlGrp.attributes.dn == "uni/infra/fexprof-anstest_fex_profile/fexbundle-anstest_fex_policy_group" + +- name: Remove anstest_fex_policy_group - Fex Policy Group from anstest_fex_profile with normal mode - idempotency works + cisco.aci.aci_interface_policy_leaf_profile_fex_policy_group: + &idempotency_anstest_fex_policy_group_absent + <<: *nm_anstest_fex_policy_group_absent + 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: + that: + - idempotency_anstest_fex_policy_group_absent is not changed + - idempotency_anstest_fex_policy_group_absent.current | length == 0 + - idempotency_anstest_fex_policy_group_absent.previous | length == 0 + +- name: Remove temp_anstest_fex_profile Fex Profile + cisco.aci.aci_interface_policy_leaf_profile: + <<: *temp_anstest_fex_profile_present + state: absent + register: temp_anstest_fex_profile_absent + +- name: Assertions check for remove temp_anstest_fex_profile Fex Profile + assert: + that: + - temp_anstest_fex_profile_absent is changed + - temp_anstest_fex_profile_absent.current | length == 0 + - temp_anstest_fex_profile_absent.previous | length == 1 + - temp_anstest_fex_profile_absent.previous.0.infraFexP.attributes.name == "temp_anstest_fex_profile" + - temp_anstest_fex_profile_absent.previous.0.infraFexP.attributes.dn == "uni/infra/fexprof-temp_anstest_fex_profile" + +- name: Remove anstest_fex_profile Fex Profile + cisco.aci.aci_interface_policy_leaf_profile: + <<: *fex_profile_present + state: absent + register: fex_profile_present_absent + +- name: Assertions check for remove anstest_fex_profile Fex Profile + assert: + that: + - fex_profile_present_absent is changed + - fex_profile_present_absent.current | length == 0 + - fex_profile_present_absent.previous | length == 1 + - fex_profile_present_absent.previous.0.infraFexP.attributes.name == "anstest_fex_profile" + - fex_profile_present_absent.previous.0.infraFexP.attributes.dn == "uni/infra/fexprof-anstest_fex_profile"