7from __future__
import absolute_import, division, print_function
10ANSIBLE_METADATA = {
'metadata_version':
'1.1',
11 'status': [
'preview'],
12 'supported_by':
'certified'}
16module: aci_aep_to_domain
17short_description: Bind AEPs to Physical or Virtual Domains (infra:RsDomP)
19- Bind AEPs to Physical or Virtual Domains on Cisco ACI fabrics.
24 - The name of the Attachable Access Entity Profile.
29 - Name of the physical or virtual domain being associated
with the AEP.
31 aliases: [ domain_name, domain_profile ]
34 - Determines
if the Domain
is physical (phys)
or virtual (vmm).
36 choices: [ fc, l2dom, l3dom, phys, vmm ]
40 - Use C(present)
or C(absent)
for adding
or removing.
41 - Use C(query)
for listing an object
or multiple objects.
43 choices: [ absent, present, query ]
47 - The VM platform
for VMM Domains.
48 - Support
for Kubernetes was added
in ACI v3.0.
49 - Support
for CloudFoundry, OpenShift
and Red Hat was added
in ACI v3.1.
51 choices: [ cloudfoundry, kubernetes, microsoft, openshift, openstack, redhat, vmware ]
52extends_documentation_fragment: aci
54- The C(aep)
and C(domain) parameters should exist before using this module.
55 The M(aci_aep)
and M(aci_domain) can be used
for these.
59- name: APIC Management Information Model reference
60 description: More information about the internal APIC
class B(infra:RsDomP).
61 link: https://developer.cisco.com/docs/apic-mim-ref/
63- Dag Wieers (
@dagwieers)
67- name: Add AEP to domain binding
68 aci_aep_to_domain: &binding_present
71 password: SomeSecretPassword
76 delegate_to: localhost
78- name: Remove AEP to domain binding
79 aci_aep_to_domain: &binding_absent
82 password: SomeSecretPassword
87 delegate_to: localhost
89- name: Query our AEP to domain binding
93 password: SomeSecretPassword
98 delegate_to: localhost
99 register: query_result
101- name: Query all AEP to domain bindings
102 aci_aep_to_domain: &binding_query
105 password: SomeSecretPassword
107 delegate_to: localhost
108 register: query_result
113 description: The existing configuration from the APIC after the module has finished
121 "descr":
"Production environment",
122 "dn":
"uni/tn-production",
123 "name":
"production",
132 description: The error information
as returned
from the APIC
138 "text":
"unknown managed object class foo"
141 description: The raw output returned by the APIC REST API (xml
or json)
142 returned: parse error
144 sample:
'<?xml version="1.0" encoding="UTF-8"?><imdata totalCount="1"><error code="122" text="unknown managed object class foo"/></imdata>'
146 description: The actual/minimal configuration pushed to the APIC
153 "descr":
"Production environment"
158 description: The original configuration
from the APIC before the module has started
166 "descr":
"Production",
167 "dn":
"uni/tn-production",
168 "name":
"production",
177 description: The assembled configuration
from the user-provided parameters
184 "descr":
"Production environment",
190 description: The filter string used
for the request
191 returned: failure
or debug
193 sample: ?rsp-prop-include=config-only
195 description: The HTTP method used
for the request to the APIC
196 returned: failure
or debug
200 description: The HTTP response
from the APIC
201 returned: failure
or debug
203 sample: OK (30 bytes)
205 description: The HTTP status
from the APIC
206 returned: failure
or debug
210 description: The HTTP url used
for the request to the APIC
211 returned: failure
or debug
213 sample: https://10.11.12.13/api/mo/uni/tn-production.json
216from ansible.module_utils.basic import AnsibleModule
217from ansible.module_utils.network.aci.aci import ACIModule, aci_argument_spec
219VM_PROVIDER_MAPPING = dict(
220 cloudfoundry='CloudFoundry',
221 kubernetes=
'Kubernetes',
222 microsoft=
'Microsoft',
223 openshift=
'OpenShift',
224 openstack=
'OpenStack',
232 argument_spec.update(
233 aep=dict(type=
'str', aliases=[
'aep_name']),
234 domain=dict(type=
'str', aliases=[
'domain_name',
'domain_profile']),
235 domain_type=dict(type=
'str', choices=[
'fc',
'l2dom',
'l3dom',
'phys',
'vmm'], aliases=[
'type']),
236 state=dict(type=
'str', default=
'present', choices=[
'absent',
'present',
'query']),
237 vm_provider=dict(type=
'str', choices=[
'cloudfoundry',
'kubernetes',
'microsoft',
'openshift',
'openstack',
'redhat',
'vmware']),
241 argument_spec=argument_spec,
242 supports_check_mode=
True,
244 [
'domain_type',
'vmm', [
'vm_provider']],
245 [
'state',
'absent', [
'aep',
'domain',
'domain_type']],
246 [
'state',
'present', [
'aep',
'domain',
'domain_type']],
249 [
'domain',
'domain_type'],
253 aep = module.params[
'aep']
254 domain = module.params[
'domain']
255 domain_type = module.params[
'domain_type']
256 vm_provider = module.params[
'vm_provider']
257 state = module.params[
'state']
260 if domain_type !=
'vmm' and vm_provider
is not None:
261 module.fail_json(msg=
"Domain type '{0}' cannot have a 'vm_provider'".
format(domain_type))
264 if domain_type ==
'fc':
265 domain_mo =
'uni/fc-{0}'.
format(domain)
266 elif domain_type ==
'l2dom':
267 domain_mo =
'uni/l2dom-{0}'.
format(domain)
268 elif domain_type ==
'l3dom':
269 domain_mo =
'uni/l3dom-{0}'.
format(domain)
270 elif domain_type ==
'phys':
271 domain_mo =
'uni/phys-{0}'.
format(domain)
272 elif domain_type ==
'vmm':
273 domain_mo =
'uni/vmmp-{0}/dom-{1}'.
format(VM_PROVIDER_MAPPING[vm_provider], domain)
280 aci_class=
'infraAttEntityP',
281 aci_rn=
'infra/attentp-{0}'.
format(aep),
283 target_filter={
'name': aep},
286 aci_class=
'infraRsDomP',
287 aci_rn=
'rsdomP-[{0}]'.
format(domain_mo),
288 module_object=domain_mo,
289 target_filter={
'tDn': domain_mo},
295 if state ==
'present':
297 aci_class=
'infraRsDomP',
298 class_config=dict(tDn=domain_mo),
301 aci.get_diff(aci_class=
'infraRsDomP')
305 elif state ==
'absent':
311if __name__ ==
"__main__":