6from __future__
import absolute_import, division, print_function
10 'metadata_version':
'1.1',
11 'status': [
'preview'],
12 'supported_by':
'community'
17module: aci_interface_policy_cdp
18short_description: Manage CDP interface policies (cdp:IfPol)
20- Manage CDP interface policies on Cisco ACI fabrics.
25 - The CDP interface policy name.
28 aliases: [ cdp_interface, name ]
31 - The description for the CDP interface policy name.
36 - Enable
or Disable CDP state.
37 - The APIC defaults to C(yes) when unset during creation.
41 - Use C(present)
or C(absent)
for adding
or removing.
42 - Use C(query)
for listing an object
or multiple objects.
44 choices: [ absent, present, query ]
46extends_documentation_fragment: aci
48- name: APIC Management Information Model reference
49 description: More information about the internal APIC
class B(cdp:IfPol).
50 link: https://developer.cisco.com/docs/apic-mim-ref/
52- Tim Knipper (
@tknipper11)
56- name: Create CDP Test Policy
57 aci_interface_policy_cdp:
58 name: Ansible_CDP_Test_Policy
59 host: apic.example.com
64- name: Remove CDP Test Policy
65 aci_interface_policy_cdp:
66 name: Ansible_CDP_Test_Policy
67 host: apic.example.com
73- name: Query CDP Policy
74 aci_interface_policy_cdp:
75 host: apic.example.com
83 description: The existing configuration from the APIC after the module has finished
91 "adminSt":
"disabled",
93 "descr":
"Ansible Created CDP Test Policy",
94 "dn":
"uni/infra/cdpIfP-Ansible_CDP_Test_Policy",
95 "name":
"Ansible_CDP_Test_Policy",
104 description: The error information
as returned
from the APIC
110 "text":
"unknown managed object class foo"
113 description: The raw output returned by the APIC REST API (xml
or json)
114 returned: parse error
116 sample:
'<?xml version="1.0" encoding="UTF-8"?><imdata totalCount="1"><error code="122" text="unknown managed object class foo"/></imdata>'
118 description: The actual/minimal configuration pushed to the APIC
125 "descr":
"Production environment"
130 description: The original configuration
from the APIC before the module has started
138 "descr":
"Production",
139 "dn":
"uni/tn-production",
140 "name":
"production",
149 description: The assembled configuration
from the user-provided parameters
156 "descr":
"Production environment",
162 description: The filter string used
for the request
163 returned: failure
or debug
165 sample: ?rsp-prop-include=config-only
167 description: The HTTP method used
for the request to the APIC
168 returned: failure
or debug
172 description: The HTTP response
from the APIC
173 returned: failure
or debug
175 sample: OK (30 bytes)
177 description: The HTTP status
from the APIC
178 returned: failure
or debug
182 description: The HTTP url used
for the request to the APIC
183 returned: failure
or debug
185 sample: https://10.11.12.13/api/mo/uni/tn-production.json
187from ansible.module_utils.network.aci.aci import ACIModule, aci_argument_spec
189from ansible.module_utils.basic import AnsibleModule
194 argument_spec.update(
195 cdp_policy=dict(type='str', required=
False, aliases=[
'cdp_interface',
'name']),
196 description=dict(type=
'str', aliases=[
'descr']),
197 admin_state=dict(type=
'bool'),
198 state=dict(type=
'str', default=
'present', choices=[
'absent',
'present',
'query']),
202 argument_spec=argument_spec,
203 supports_check_mode=
True,
205 [
'state',
'absent', [
'cdp_policy']],
206 [
'state',
'present', [
'cdp_policy']],
212 cdp_policy = module.params[
'cdp_policy']
213 description = module.params[
'description']
214 admin_state = aci.boolean(module.params[
'admin_state'],
'enabled',
'disabled')
215 state = module.params[
'state']
219 aci_class=
'cdpIfPol',
220 aci_rn=
'infra/cdpIfP-{0}'.
format(cdp_policy),
221 module_object=cdp_policy,
222 target_filter={
'name': cdp_policy},
228 if state ==
'present':
230 aci_class=
'cdpIfPol',
238 aci.get_diff(aci_class=
'cdpIfPol')
242 elif state ==
'absent':
248if __name__ ==
'__main__':