7from __future__
import absolute_import, division, print_function
10ANSIBLE_METADATA = {
'metadata_version':
'1.1',
11 'status': [
'preview'],
12 'supported_by':
'certified'}
16module: aci_fabric_node
17short_description: Manage Fabric Node Members (fabric:NodeIdentP)
19- Manage Fabric Node Members on Cisco ACI fabrics.
24 - The pod id of the new Fabric Node Member.
28 - Serial Number for the new Fabric Node Member.
30 aliases: [ serial_number ]
33 - Node ID Number
for the new Fabric Node Member.
37 - Switch Name
for the new Fabric Node Member.
39 aliases: [ name, switch_name ]
42 - Description
for the new Fabric Node Member.
47 - Role
for the new Fabric Node Member.
49 aliases: [ role_name ]
50 choices: [ leaf, spine, unspecified ]
53 - Use C(present)
or C(absent)
for adding
or removing.
54 - Use C(query)
for listing an object
or multiple objects.
56 choices: [ absent, present, query ]
58extends_documentation_fragment: aci
60- name: APIC Management Information Model reference
61 description: More information about the internal APIC
class B(fabric:NodeIdentP).
62 link: https://developer.cisco.com/docs/apic-mim-ref/
64- Bruno Calogero (
@brunocalogero)
68- name: Add fabric node
72 password: SomeSecretPassword
77 delegate_to: localhost
79- name: Remove fabric node
83 password: SomeSecretPassword
87 delegate_to: localhost
89- name: Query fabric nodes
93 password: SomeSecretPassword
95 delegate_to: localhost
96 register: query_result
101 description: The existing configuration from the APIC after the module has finished
109 "descr":
"Production environment",
110 "dn":
"uni/tn-production",
111 "name":
"production",
120 description: The error information
as returned
from the APIC
126 "text":
"unknown managed object class foo"
129 description: The raw output returned by the APIC REST API (xml
or json)
130 returned: parse error
132 sample:
'<?xml version="1.0" encoding="UTF-8"?><imdata totalCount="1"><error code="122" text="unknown managed object class foo"/></imdata>'
134 description: The actual/minimal configuration pushed to the APIC
141 "descr":
"Production environment"
146 description: The original configuration
from the APIC before the module has started
154 "descr":
"Production",
155 "dn":
"uni/tn-production",
156 "name":
"production",
165 description: The assembled configuration
from the user-provided parameters
172 "descr":
"Production environment",
178 description: The filter string used
for the request
179 returned: failure
or debug
181 sample:
'?rsp-prop-include=config-only'
183 description: The HTTP method used
for the request to the APIC
184 returned: failure
or debug
188 description: The HTTP response
from the APIC
189 returned: failure
or debug
191 sample: OK (30 bytes)
193 description: The HTTP status
from the APIC
194 returned: failure
or debug
198 description: The HTTP url used
for the request to the APIC
199 returned: failure
or debug
201 sample: https://10.11.12.13/api/mo/uni/tn-production.json
204from ansible.module_utils.basic import AnsibleModule
205from ansible.module_utils.network.aci.aci import ACIModule, aci_argument_spec
208# NOTE: (This problem is also present on the APIC GUI)
209# NOTE: When specifying a C(role) the new Fabric Node Member will be created but Role on GUI will be "unknown", hence not what seems to be a module problem
213 argument_spec.update(
214 description=dict(type='str', aliases=[
'descr']),
215 node_id=dict(type=
'int'),
216 pod_id=dict(type=
'int'),
217 role=dict(type=
'str', choices=[
'leaf',
'spine',
'unspecified'], aliases=[
'role_name']),
218 serial=dict(type=
'str', aliases=[
'serial_number']),
219 switch=dict(type=
'str', aliases=[
'name',
'switch_name']),
220 state=dict(type=
'str', default=
'present', choices=[
'absent',
'present',
'query']),
224 argument_spec=argument_spec,
225 supports_check_mode=
True,
227 [
'state',
'absent', [
'node_id',
'serial']],
228 [
'state',
'present', [
'node_id',
'serial']],
232 pod_id = module.params[
'pod_id']
233 serial = module.params[
'serial']
234 node_id = module.params[
'node_id']
235 switch = module.params[
'switch']
236 description = module.params[
'description']
237 role = module.params[
'role']
238 state = module.params[
'state']
243 aci_class=
'fabricNodeIdentP',
244 aci_rn=
'controller/nodeidentpol/nodep-{0}'.
format(serial),
245 module_object=serial,
246 target_filter={
'serial': serial},
252 if state ==
'present':
254 aci_class=
'fabricNodeIdentP',
262 dn=
'uni/controller/nodeidentpol/nodep-{0}'.
format(serial),
269 aci.get_diff(aci_class=
'fabricNodeIdentP')
273 elif state ==
'absent':
276 aci.exit_json(**aci.result)
279if __name__ ==
"__main__":