6from __future__
import absolute_import, division, print_function
10 'metadata_version':
'1.1',
11 'status': [
'preview'],
12 'supported_by':
'community'
17module: aci_maintenance_policy
18short_description: Manage firmware maintenance policies
21- Manage maintenance policies that defines behavior during an ACI upgrade.
25 - The name for the maintenance policy.
27 aliases: [ maintenance_policy ]
30 - Whether the system pauses on error
or just continues through it.
31 choices: [
'pauseOnlyOnFailures',
'pauseNever']
32 default: pauseOnlyOnFailures
35 - Whether the system will bring down the nodes gracefully during an upgrade, which reduces traffic lost.
36 - The APIC defaults to C(no) when unset during creation.
40 - The name of scheduler that
is applied to the policy.
45 - Will trigger an immediate upgrade
for nodes
if adminst
is set to triggered.
46 choices: [ triggered, untriggered ]
50 - To check whether compatibility checks should be ignored
51 - The APIC defaults to C(no) when unset during creation.
55 - Use C(present)
or C(absent)
for adding
or removing.
56 - Use C(query)
for listing an object
or multiple objects.
57 choices: [ absent, present, query ]
59extends_documentation_fragment:
62- A scheduler
is required
for this module, which could have been created using the M(aci_fabric_scheduler) module
or via the UI.
64- Steven Gerhart (
@sgerhart)
68- name: Ensure maintenance policy is present
69 aci_maintenance_policy:
70 host: '{{ inventory_hostname }}'
71 username:
'{{ user }}'
72 password:
'{{ pass }}'
75 scheduler: simpleScheduler
82 description: The existing configuration from the APIC after the module has finished
90 "descr":
"Production environment",
91 "dn":
"uni/tn-production",
101 description: The error information
as returned
from the APIC
107 "text":
"unknown managed object class foo"
110 description: The raw output returned by the APIC REST API (xml
or json)
111 returned: parse error
113 sample:
'<?xml version="1.0" encoding="UTF-8"?><imdata totalCount="1"><error code="122" text="unknown managed object class foo"/></imdata>'
115 description: The actual/minimal configuration pushed to the APIC
122 "descr":
"Production environment"
127 description: The original configuration
from the APIC before the module has started
135 "descr":
"Production",
136 "dn":
"uni/tn-production",
137 "name":
"production",
146 description: The assembled configuration
from the user-provided parameters
153 "descr":
"Production environment",
159 description: The filter string used
for the request
160 returned: failure
or debug
162 sample: ?rsp-prop-include=config-only
164 description: The HTTP method used
for the request to the APIC
165 returned: failure
or debug
169 description: The HTTP response
from the APIC
170 returned: failure
or debug
172 sample: OK (30 bytes)
174 description: The HTTP status
from the APIC
175 returned: failure
or debug
179 description: The HTTP url used
for the request to the APIC
180 returned: failure
or debug
182 sample: https://10.11.12.13/api/mo/uni/tn-production.json
186from ansible.module_utils.network.aci.aci import ACIModule, aci_argument_spec
187from ansible.module_utils.basic import AnsibleModule
192 argument_spec.update(
193 name=dict(type='str', aliases=[
'maintenance_policy']),
194 runmode=dict(type=
'str', default=
'pauseOnlyOnFailures', choices=[
'pauseOnlyOnFailures',
'pauseNever']),
195 graceful=dict(type=
'bool'),
196 scheduler=dict(type=
'str'),
197 ignoreCompat=dict(type=
'bool'),
198 adminst=dict(type=
'str', default=
'untriggered', choices=[
'triggered',
'untriggered']),
199 state=dict(type=
'str', default=
'present', choices=[
'absent',
'present',
'query']),
203 argument_spec=argument_spec,
204 supports_check_mode=
True,
206 [
'state',
'absent', [
'name']],
207 [
'state',
'present', [
'name',
'scheduler']],
213 state = module.params[
'state']
214 name = module.params[
'name']
215 runmode = module.params[
'runmode']
216 scheduler = module.params[
'scheduler']
217 adminst = module.params[
'adminst']
218 graceful = aci.boolean(module.params[
'graceful'])
219 ignoreCompat = aci.boolean(module.params[
'ignoreCompat'])
223 aci_class=
'maintMaintP',
224 aci_rn=
'fabric/maintpol-{0}'.
format(name),
225 target_filter={
'name': name},
228 child_classes=[
'maintRsPolScheduler']
234 if state ==
'present':
236 aci_class=
'maintMaintP',
242 ignoreCompat=ignoreCompat,
246 maintRsPolScheduler=dict(
248 tnTrigSchedPName=scheduler,
256 aci.get_diff(aci_class=
'maintMaintP')
260 elif state ==
'absent':
266if __name__ ==
"__main__":