6from __future__
import absolute_import, division, print_function
9ANSIBLE_METADATA = {
'metadata_version':
'1.1',
10 'status': [
'preview'],
11 'supported_by':
'certified'}
15module: aci_epg_monitoring_policy
16short_description: Manage monitoring policies (mon:EPGPol)
18- Manage monitoring policies on Cisco ACI fabrics.
23 - The name of the monitoring policy.
29 - Description for the monitoring policy.
34 - The name of the tenant.
37 aliases: [ tenant_name ]
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 ]
45extends_documentation_fragment: aci
47- The C(tenant) used must exist before using this module
in your playbook.
48 The M(aci_tenant) module can be used
for this.
51- name: APIC Management Information Model reference
52 description: More information about the internal APIC
class B(mon:EPGPol).
53 link: https://developer.cisco.com/docs/apic-mim-ref/
55- Dag Wieers (
@dagwieers)
58# FIXME: Add more, better examples
60- aci_epg_monitoring_policy:
61 host: '{{ hostname }}'
62 username:
'{{ username }}'
63 password:
'{{ password }}'
64 monitoring_policy:
'{{ monitoring_policy }}'
65 description:
'{{ description }}'
66 tenant:
'{{ tenant }}'
67 delegate_to: localhost
72 description: The existing configuration from the APIC after the module has finished
80 "descr":
"Production environment",
81 "dn":
"uni/tn-production",
91 description: The error information
as returned
from the APIC
97 "text":
"unknown managed object class foo"
100 description: The raw output returned by the APIC REST API (xml
or json)
101 returned: parse error
103 sample:
'<?xml version="1.0" encoding="UTF-8"?><imdata totalCount="1"><error code="122" text="unknown managed object class foo"/></imdata>'
105 description: The actual/minimal configuration pushed to the APIC
112 "descr":
"Production environment"
117 description: The original configuration
from the APIC before the module has started
125 "descr":
"Production",
126 "dn":
"uni/tn-production",
127 "name":
"production",
136 description: The assembled configuration
from the user-provided parameters
143 "descr":
"Production environment",
149 description: The filter string used
for the request
150 returned: failure
or debug
152 sample: ?rsp-prop-include=config-only
154 description: The HTTP method used
for the request to the APIC
155 returned: failure
or debug
159 description: The HTTP response
from the APIC
160 returned: failure
or debug
162 sample: OK (30 bytes)
164 description: The HTTP status
from the APIC
165 returned: failure
or debug
169 description: The HTTP url used
for the request to the APIC
170 returned: failure
or debug
172 sample: https://10.11.12.13/api/mo/uni/tn-production.json
175from ansible.module_utils.basic import AnsibleModule
176from ansible.module_utils.network.aci.aci import ACIModule, aci_argument_spec
181 argument_spec.update(
182 monitoring_policy=dict(type='str', aliases=[
'name']),
183 tenant=dict(type=
'str', aliases=[
'tenant_name']),
184 description=dict(type=
'str', aliases=[
'descr']),
185 state=dict(type=
'str', default=
'present', choices=[
'absent',
'present',
'query']),
189 argument_spec=argument_spec,
190 supports_check_mode=
True,
192 [
'state',
'absent', [
'monitoring_policy',
'tenant']],
193 [
'state',
'present', [
'monitoring_policy',
'tenant']],
197 monitoring_policy = module.params[
'monitoring_policy']
198 description = module.params[
'description']
199 state = module.params[
'state']
200 tenant = module.params[
'tenant']
205 aci_class=
'fvTenant',
206 aci_rn=
'tn-{0}'.
format(tenant),
207 module_object=tenant,
208 target_filter={
'name': tenant},
211 aci_class=
'monEPGPol',
212 aci_rn=
'monepg-{0}'.
format(monitoring_policy),
213 module_object=monitoring_policy,
214 target_filter={
'name': monitoring_policy},
220 if state ==
'present':
222 aci_class=
'monEPGPol',
224 name=monitoring_policy,
229 aci.get_diff(aci_class=
'monEPGPol')
233 elif state ==
'absent':
239if __name__ ==
"__main__":