6from __future__
import absolute_import, division, print_function
9ANSIBLE_METADATA = {
'metadata_version':
'1.1',
10 'status': [
'preview'],
11 'supported_by':
'certified'}
16short_description: Manage contract resources (vz:BrCP)
18- Manage Contract resources on Cisco ACI fabrics.
23 - The name of the contract.
26 aliases: [ contract_name, name ]
29 - Description for the contract.
34 - The name of the tenant.
37 aliases: [ tenant_name ]
40 - The scope of a service contract.
41 - The APIC defaults to C(context) when unset during creation.
43 choices: [ application-profile, context,
global, tenant ]
46 - The desired QoS
class to be used.
47 - The APIC defaults to C(unspecified) when unset during creation.
49 choices: [ level1, level2, level3, unspecified ]
52 - The target Differentiated Service (DSCP) value.
53 - The APIC defaults to C(unspecified) when unset during creation.
55 choices: [ AF11, AF12, AF13, AF21, AF22, AF23, AF31, AF32, AF33, AF41, AF42, AF43, CS0, CS1, CS2, CS3, CS4, CS5, CS6, CS7, EF, VA, unspecified ]
59 - Use C(present)
or C(absent)
for adding
or removing.
60 - Use C(query)
for listing an object
or multiple objects.
62 choices: [ absent, present, query ]
64extends_documentation_fragment: aci
66- This module does
not manage Contract Subjects, see M(aci_contract_subject) to do this.
67 Contract Subjects can still be removed using this module.
68- The C(tenant) used must exist before using this module
in your playbook.
69 The M(aci_tenant) module can be used
for this.
71- module: aci_contract_subject
73- name: APIC Management Information Model reference
74 description: More information about the internal APIC
class B(vz:BrCP).
75 link: https://developer.cisco.com/docs/apic-mim-ref/
77- Dag Wieers (
@dagwieers)
81- name: Add a new contract
85 password: SomeSecretPassword
88 description: Communication between web-servers and database
89 scope: application-profile
91 delegate_to: localhost
93- name: Remove an existing contract
97 password: SomeSecretPassword
101 delegate_to: localhost
103- name: Query a specific contract
107 password: SomeSecretPassword
111 delegate_to: localhost
112 register: query_result
114- name: Query all contracts
118 password: SomeSecretPassword
120 delegate_to: localhost
121 register: query_result
126 description: The existing configuration from the APIC after the module has finished
134 "descr":
"Production environment",
135 "dn":
"uni/tn-production",
136 "name":
"production",
145 description: The error information
as returned
from the APIC
151 "text":
"unknown managed object class foo"
154 description: The raw output returned by the APIC REST API (xml
or json)
155 returned: parse error
157 sample:
'<?xml version="1.0" encoding="UTF-8"?><imdata totalCount="1"><error code="122" text="unknown managed object class foo"/></imdata>'
159 description: The actual/minimal configuration pushed to the APIC
166 "descr":
"Production environment"
171 description: The original configuration
from the APIC before the module has started
179 "descr":
"Production",
180 "dn":
"uni/tn-production",
181 "name":
"production",
190 description: The assembled configuration
from the user-provided parameters
197 "descr":
"Production environment",
203 description: The filter string used
for the request
204 returned: failure
or debug
206 sample: ?rsp-prop-include=config-only
208 description: The HTTP method used
for the request to the APIC
209 returned: failure
or debug
213 description: The HTTP response
from the APIC
214 returned: failure
or debug
216 sample: OK (30 bytes)
218 description: The HTTP status
from the APIC
219 returned: failure
or debug
223 description: The HTTP url used
for the request to the APIC
224 returned: failure
or debug
226 sample: https://10.11.12.13/api/mo/uni/tn-production.json
229from ansible.module_utils.basic import AnsibleModule
230from ansible.module_utils.network.aci.aci import ACIModule, aci_argument_spec
235 argument_spec.update(
236 contract=dict(type='str', aliases=[
'contract_name',
'name']),
237 tenant=dict(type=
'str', aliases=[
'tenant_name']),
238 description=dict(type=
'str', aliases=[
'descr']),
239 scope=dict(type=
'str', choices=[
'application-profile',
'context',
'global',
'tenant']),
240 priority=dict(type=
'str', choices=[
'level1',
'level2',
'level3',
'unspecified']),
241 dscp=dict(type=
'str',
242 choices=[
'AF11',
'AF12',
'AF13',
'AF21',
'AF22',
'AF23',
'AF31',
'AF32',
'AF33',
'AF41',
'AF42',
'AF43',
243 'CS0',
'CS1',
'CS2',
'CS3',
'CS4',
'CS5',
'CS6',
'CS7',
'EF',
'VA',
'unspecified'],
245 state=dict(type=
'str', default=
'present', choices=[
'absent',
'present',
'query']),
249 argument_spec=argument_spec,
250 supports_check_mode=
True,
252 [
'state',
'absent', [
'contract',
'tenant']],
253 [
'state',
'present', [
'contract',
'tenant']],
257 contract = module.params[
'contract']
258 description = module.params[
'description']
259 scope = module.params[
'scope']
260 priority = module.params[
'priority']
261 dscp = module.params[
'dscp']
262 state = module.params[
'state']
263 tenant = module.params[
'tenant']
268 aci_class=
'fvTenant',
269 aci_rn=
'tn-{0}'.
format(tenant),
270 module_object=tenant,
271 target_filter={
'name': tenant},
275 aci_rn=
'brc-{0}'.
format(contract),
276 module_object=contract,
277 target_filter={
'name': contract},
283 if state ==
'present':
295 aci.get_diff(aci_class=
'vzBrCP')
299 elif state ==
'absent':
305if __name__ ==
"__main__":