6from __future__
import absolute_import, division, print_function
9ANSIBLE_METADATA = {
'metadata_version':
'1.1',
10 'status': [
'preview'],
11 'supported_by':
'certified'}
16short_description: Manages top level filter objects (vz:Filter)
18- Manages top level filter objects on Cisco ACI fabrics.
19- This modules does not manage filter entries, see M(aci_filter_entry) for this functionality.
24 - The name of the filter.
27 aliases: [ filter_name, name ]
30 - Description for the filter.
35 - The name of the tenant.
38 aliases: [ tenant_name ]
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- The C(tenant) used must exist before using this module
in your playbook.
49 The M(aci_tenant) module can be used
for this.
52- name: APIC Management Information Model reference
53 description: More information about the internal APIC
class B(vz:Filter).
54 link: https://developer.cisco.com/docs/apic-mim-ref/
56- Dag Wieers (
@dagwieers)
60- name: Add a new filter to a tenant
64 password: SomeSecretPassword
66 description: Filter for web protocols
69 delegate_to: localhost
71- name: Remove a filter
for a tenant
75 password: SomeSecretPassword
79 delegate_to: localhost
81- name: Query a filter of a tenant
85 password: SomeSecretPassword
89 delegate_to: localhost
90 register: query_result
92- name: Query all filters
for a tenant
96 password: SomeSecretPassword
99 delegate_to: localhost
100 register: query_result
105 description: The existing configuration from the APIC after the module has finished
113 "descr":
"Production environment",
114 "dn":
"uni/tn-production",
115 "name":
"production",
124 description: The error information
as returned
from the APIC
130 "text":
"unknown managed object class foo"
133 description: The raw output returned by the APIC REST API (xml
or json)
134 returned: parse error
136 sample:
'<?xml version="1.0" encoding="UTF-8"?><imdata totalCount="1"><error code="122" text="unknown managed object class foo"/></imdata>'
138 description: The actual/minimal configuration pushed to the APIC
145 "descr":
"Production environment"
150 description: The original configuration
from the APIC before the module has started
158 "descr":
"Production",
159 "dn":
"uni/tn-production",
160 "name":
"production",
169 description: The assembled configuration
from the user-provided parameters
176 "descr":
"Production environment",
182 description: The filter string used
for the request
183 returned: failure
or debug
185 sample: ?rsp-prop-include=config-only
187 description: The HTTP method used
for the request to the APIC
188 returned: failure
or debug
192 description: The HTTP response
from the APIC
193 returned: failure
or debug
195 sample: OK (30 bytes)
197 description: The HTTP status
from the APIC
198 returned: failure
or debug
202 description: The HTTP url used
for the request to the APIC
203 returned: failure
or debug
205 sample: https://10.11.12.13/api/mo/uni/tn-production.json
208from ansible.module_utils.basic import AnsibleModule
209from ansible.module_utils.network.aci.aci import ACIModule, aci_argument_spec
214 argument_spec.update(
215 filter=dict(type='str', aliases=[
'name',
'filter_name']),
216 tenant=dict(type=
'str', aliases=[
'tenant_name']),
217 description=dict(type=
'str', aliases=[
'descr']),
218 state=dict(type=
'str', default=
'present', choices=[
'absent',
'present',
'query']),
222 argument_spec=argument_spec,
223 supports_check_mode=
True,
225 [
'state',
'absent', [
'filter',
'tenant']],
226 [
'state',
'present', [
'filter',
'tenant']],
230 filter_name = module.params[
'filter']
231 description = module.params[
'description']
232 state = module.params[
'state']
233 tenant = module.params[
'tenant']
238 aci_class=
'fvTenant',
239 aci_rn=
'tn-{0}'.
format(tenant),
240 module_object=tenant,
241 target_filter={
'name': tenant},
244 aci_class=
'vzFilter',
245 aci_rn=
'flt-{0}'.
format(filter_name),
246 module_object=filter_name,
247 target_filter={
'name': filter_name},
253 if state ==
'present':
255 aci_class=
'vzFilter',
262 aci.get_diff(aci_class=
'vzFilter')
266 elif state ==
'absent':
272if __name__ ==
"__main__":