6from __future__
import absolute_import, division, print_function
9ANSIBLE_METADATA = {
'metadata_version':
'1.1',
10 'status': [
'preview'],
11 'supported_by':
'certified'}
16short_description: Manage tenants (fv:Tenant)
18- Manage tenants on Cisco ACI fabrics.
23 - The name of the tenant.
26 aliases: [ name, tenant_name ]
29 - Description for the tenant.
34 - Use C(present)
or C(absent)
for adding
or removing.
35 - Use C(query)
for listing an object
or multiple objects.
37 choices: [ absent, present, query ]
39extends_documentation_fragment: aci
46- name: APIC Management Information Model reference
47 description: More information about the internal APIC
class B(fv:Tenant).
48 link: https://developer.cisco.com/docs/apic-mim-ref/
50- Jacob McGill (
@jmcgill298)
54- name: Add a new tenant
58 password: SomeSecretPassword
60 description: Production tenant
62 delegate_to: localhost
64- name: Remove a tenant
68 password: SomeSecretPassword
71 delegate_to: localhost
77 password: SomeSecretPassword
80 delegate_to: localhost
81 register: query_result
83- name: Query all tenants
87 password: SomeSecretPassword
89 delegate_to: localhost
90 register: query_result
95 description: The existing configuration from the APIC after the module has finished
103 "descr":
"Production environment",
104 "dn":
"uni/tn-production",
105 "name":
"production",
114 description: The error information
as returned
from the APIC
120 "text":
"unknown managed object class foo"
123 description: The raw output returned by the APIC REST API (xml
or json)
124 returned: parse error
126 sample:
'<?xml version="1.0" encoding="UTF-8"?><imdata totalCount="1"><error code="122" text="unknown managed object class foo"/></imdata>'
128 description: The actual/minimal configuration pushed to the APIC
135 "descr":
"Production environment"
140 description: The original configuration
from the APIC before the module has started
148 "descr":
"Production",
149 "dn":
"uni/tn-production",
150 "name":
"production",
159 description: The assembled configuration
from the user-provided parameters
166 "descr":
"Production environment",
172 description: The filter string used
for the request
173 returned: failure
or debug
175 sample: ?rsp-prop-include=config-only
177 description: The HTTP method used
for the request to the APIC
178 returned: failure
or debug
182 description: The HTTP response
from the APIC
183 returned: failure
or debug
185 sample: OK (30 bytes)
187 description: The HTTP status
from the APIC
188 returned: failure
or debug
192 description: The HTTP url used
for the request to the APIC
193 returned: failure
or debug
195 sample: https://10.11.12.13/api/mo/uni/tn-production.json
198from ansible.module_utils.basic import AnsibleModule
199from ansible.module_utils.network.aci.aci import ACIModule, aci_argument_spec
204 argument_spec.update(
205 tenant=dict(type='str', aliases=[
'name',
'tenant_name']),
206 description=dict(type=
'str', aliases=[
'descr']),
207 state=dict(type=
'str', default=
'present', choices=[
'absent',
'present',
'query']),
211 argument_spec=argument_spec,
212 supports_check_mode=
True,
214 [
'state',
'absent', [
'tenant']],
215 [
'state',
'present', [
'tenant']],
219 description = module.params[
'description']
220 state = module.params[
'state']
221 tenant = module.params[
'tenant']
226 aci_class=
'fvTenant',
227 aci_rn=
'tn-{0}'.
format(tenant),
228 module_object=tenant,
229 target_filter={
'name': tenant},
234 if state ==
'present':
236 aci_class=
'fvTenant',
243 aci.get_diff(aci_class=
'fvTenant')
247 elif state ==
'absent':
253if __name__ ==
"__main__":