diff --git a/plugins/modules/aci_endpoint_ip_tag.py b/plugins/modules/aci_endpoint_ip_tag.py index 42c2b04e0..26ebc1735 100644 --- a/plugins/modules/aci_endpoint_ip_tag.py +++ b/plugins/modules/aci_endpoint_ip_tag.py @@ -94,11 +94,30 @@ host: apic username: admin password: SomeSecretPassword + tenant: endpoint_tenant endpoint_ip_address: "1.1.1.1" vrf: endpoint_vrf state: query register: query_one +- name: Query all IP Tag Objects with only VRF + cisco.aci.aci_endpoint_ip_tag: + host: apic + username: admin + password: SomeSecretPassword + vrf: default + state: query + register: query_with_vrf + +- name: Query all IP Tag Objects with only IP + cisco.aci.aci_endpoint_ip_tag: + host: apic + username: admin + password: SomeSecretPassword + endpoint_ip_address: "1.1.1.1" + state: query + register: query_with_ip + - name: Query all IP Tags cisco.aci.aci_endpoint_ip_tag: host: apic @@ -261,22 +280,26 @@ def main(): aci = ACIModule(module) + endpoint_ip_tag_rn = None + endpoint_ip_tag_module_object = None + if endpoint_ip_address and vrf: + endpoint_ip_tag_rn = "eptags/epiptag-[{0}]-{1}".format(endpoint_ip_address, vrf) + endpoint_ip_tag_module_object = "[{0}]-{1}".format(endpoint_ip_address, vrf) + aci.construct_url( root_class=dict( aci_class="fvTenant", aci_rn="tn-{0}".format(tenant), + module_object=tenant, + target_filter={"name": tenant}, ), subclass_1=dict( - aci_class="fvEpTags", - aci_rn="eptags", - ), - subclass_2=dict( aci_class="fvEpIpTag", - aci_rn="epiptag-[{0}]-{1}".format(endpoint_ip_address, vrf), + aci_rn=endpoint_ip_tag_rn, + module_object=endpoint_ip_tag_module_object, target_filter=dict(ip=endpoint_ip_address, ctxName=vrf), ), ) - aci.get_existing() if state == "present": diff --git a/plugins/modules/aci_endpoint_mac_tag.py b/plugins/modules/aci_endpoint_mac_tag.py index e8d078673..5da0d181e 100644 --- a/plugins/modules/aci_endpoint_mac_tag.py +++ b/plugins/modules/aci_endpoint_mac_tag.py @@ -110,6 +110,24 @@ state: query register: query_one +- name: Query all MAC Tag Objects with only BD + cisco.aci.aci_endpoint_mac_tag: + host: apic + username: admin + password: SomeSecretPassword + bd: default + state: query + register: query_with_bd + +- name: Query all MAC Tag Objects with only MAC + cisco.aci.aci_endpoint_mac_tag: + host: apic + username: admin + password: SomeSecretPassword + endpoint_mac_address: "AE:ED:EE:EE:AA:AA" + state: query + register: query_with_mac + - name: Query all MAC Tags cisco.aci.aci_endpoint_mac_tag: host: apic @@ -272,18 +290,23 @@ def main(): aci = ACIModule(module) + endpoint_mac_tag_rn = None + endpoint_mac_tag_module_object = None + if endpoint_mac_address and bd: + endpoint_mac_tag_rn = "eptags/epmactag-{0}-[{1}]".format(endpoint_mac_address, bd) + endpoint_mac_tag_module_object = "{0}-[{1}]".format(endpoint_mac_address, bd) + aci.construct_url( root_class=dict( aci_class="fvTenant", aci_rn="tn-{0}".format(tenant), + module_object=tenant, + target_filter={"name": tenant}, ), subclass_1=dict( - aci_class="fvEpTags", - aci_rn="eptags", - ), - subclass_2=dict( aci_class="fvEpMacTag", - aci_rn="epmactag-{0}-[{1}]".format(endpoint_mac_address, bd), + aci_rn=endpoint_mac_tag_rn, + module_object=endpoint_mac_tag_module_object, target_filter=dict(mac=endpoint_mac_address, bdName=bd), ), ) diff --git a/tests/integration/targets/aci_endpoint_ip_tag/tasks/main.yml b/tests/integration/targets/aci_endpoint_ip_tag/tasks/main.yml index dcd6154b0..0f7086c1c 100644 --- a/tests/integration/targets/aci_endpoint_ip_tag/tasks/main.yml +++ b/tests/integration/targets/aci_endpoint_ip_tag/tasks/main.yml @@ -32,6 +32,7 @@ - name: Execute tasks only for ACI v5.2+ and non-cloud sites when: + # - 1 == 1 - version.current.0.topSystem.attributes.version is version('5.2', '>=') - query_cloud.current == [] # This condition will execute only non-cloud sites block: # block specifies execution of tasks within, based on conditions @@ -236,6 +237,7 @@ - name: Query IP Tag Object with ip and vrf cisco.aci.aci_endpoint_ip_tag: <<: *aci_info + tenant: ansible_test endpoint_ip_address: "2.2.2.2" vrf: ansible_test_vrf state: query @@ -264,6 +266,7 @@ - name: Negative test - query IP Tag Object with ip and vrf cisco.aci.aci_endpoint_ip_tag: <<: *aci_info + tenant: ansible_test endpoint_ip_address: "2.2.2.2" vrf: default state: query diff --git a/tests/integration/targets/aci_endpoint_mac_tag/tasks/main.yml b/tests/integration/targets/aci_endpoint_mac_tag/tasks/main.yml index 1996badb5..40cb9821e 100644 --- a/tests/integration/targets/aci_endpoint_mac_tag/tasks/main.yml +++ b/tests/integration/targets/aci_endpoint_mac_tag/tasks/main.yml @@ -243,6 +243,7 @@ - name: Query MAC Tag Object with mac and bd cisco.aci.aci_endpoint_mac_tag: <<: *aci_info + tenant: ansible_test endpoint_mac_address: "AE:ED:EE:EE:AA:AB" bd: ansible_test_bd state: query