diff --git a/lib/ansible/module_utils/network/aci/aci.py b/lib/ansible/module_utils/network/aci/aci.py index bdb4d8feb4d..25fea209536 100644 --- a/lib/ansible/module_utils/network/aci/aci.py +++ b/lib/ansible/module_utils/network/aci/aci.py @@ -808,11 +808,15 @@ class ACIModule(object): proposed_config = proposed_child[key]['attributes'] existing_config = None + # FIXME: Design causes issues for repeated child_classes # get existing dictionary from the list of existing to use for comparison for child in existing_children: if child.get(child_class): existing_config = child[key]['attributes'] - break + # NOTE: This is an ugly fix + # Return the one that is a subset match + if set(proposed_config.items()).issubset(set(existing_config.items())): + break return child_class, proposed_config, existing_config diff --git a/lib/ansible/modules/network/aci/aci_switch_policy_vpc_protection_group.py b/lib/ansible/modules/network/aci/aci_switch_policy_vpc_protection_group.py index 508777de60e..8cb3d4bed51 100644 --- a/lib/ansible/modules/network/aci/aci_switch_policy_vpc_protection_group.py +++ b/lib/ansible/modules/network/aci/aci_switch_policy_vpc_protection_group.py @@ -255,14 +255,12 @@ def main(): class_config=dict( name=protection_group, id=protection_group_id, - rn='expgep-{0}'.format(protection_group), ), child_configs=[ dict( fabricNodePEp=dict( attributes=dict( id='{0}'.format(switch_1_id), - rn='nodepep-{0}'.format(switch_1_id), ), ), ), @@ -270,7 +268,6 @@ def main(): fabricNodePEp=dict( attributes=dict( id='{0}'.format(switch_2_id), - rn='nodepep-{0}'.format(switch_2_id), ), ), ), diff --git a/test/integration/targets/aci_switch_policy_vpc_protection_group/tasks/main.yml b/test/integration/targets/aci_switch_policy_vpc_protection_group/tasks/main.yml index bf52ed7236a..3924800d5df 100644 --- a/test/integration/targets/aci_switch_policy_vpc_protection_group/tasks/main.yml +++ b/test/integration/targets/aci_switch_policy_vpc_protection_group/tasks/main.yml @@ -58,9 +58,8 @@ that: - cm_add_vpc_prot_grp is changed - nm_add_vpc_prot_grp is changed - # FIXME: Not idempotent ! - #- cm_add_vpc_prot_grp_again is not changed - #- nm_add_vpc_prot_grp_again is not changed + - cm_add_vpc_prot_grp_again is not changed + - nm_add_vpc_prot_grp_again is not changed # CHANGE VPC PROTECTION GROUP @@ -95,9 +94,8 @@ that: - cm_add_vpc_prot_grp_pol is changed - nm_add_vpc_prot_grp_pol is changed - # FIXME: Not idempotent !! - #- cm_add_vpc_prot_grp_pol_again is not changed - #- nm_add_vpc_prot_grp_pol_again is not changed + - cm_add_vpc_prot_grp_pol_again is not changed + - nm_add_vpc_prot_grp_pol_again is not changed # ADD FABRIC NODE AGAIN @@ -113,9 +111,8 @@ - name: Verify add_vpc_prot_grp_again_no_pol assert: that: - # FIXME: Not idempoten !! - #- cm_add_vpc_prot_grp_again_no_pol is not changed - #- nm_add_vpc_prot_grp_again_no_pol is not changed + - cm_add_vpc_prot_grp_again_no_pol is not changed + - nm_add_vpc_prot_grp_again_no_pol is not changed # QUERY ALL VPC PROTECTION GROUPS