7from __future__
import absolute_import, division, print_function
10ANSIBLE_METADATA = {
'metadata_version':
'1.1',
11 'status': [
'preview'],
12 'supported_by':
'community'}
17short_description: Manage schemas
19- Manage schemas on Cisco ACI Multi-Site.
21- Dag Wieers (@dagwieers)
26 - The name of the schema.
32 - A list of templates for this schema.
36 - A list of sites mapped to templates
in this schema.
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 ]
46- Due to restrictions of the MSO REST API this module cannot create empty schemas (i.e. schemas without templates).
47 Use the M(mso_schema_template) to automatically create schemas
with templates.
49- module: mso_schema_site
50- module: mso_schema_template
51extends_documentation_fragment: mso
55- name: Add a new schema
59 password: SomeSecretPassword
64 displayName: Template 1
65 tenantId: north_europe
69 displayName: Template 2
73 delegate_to: localhost
79 password: SomeSecretPassword
82 delegate_to: localhost
88 password: SomeSecretPassword
91 delegate_to: localhost
92 register: query_result
94- name: Query all schemas
98 password: SomeSecretPassword
100 delegate_to: localhost
101 register: query_result
107from ansible.module_utils.basic import AnsibleModule
108from ansible.module_utils.network.aci.mso import MSOModule, mso_argument_spec, issubset
113 argument_spec.update(
114 schema=dict(type=
'str', aliases=[
'name']),
115 templates=dict(type=
'list'),
116 sites=dict(type=
'list'),
122 state=dict(type=
'str', default=
'present', choices=[
'absent',
'present',
'query']),
126 argument_spec=argument_spec,
127 supports_check_mode=
True,
129 [
'state',
'absent', [
'schema']],
130 [
'state',
'present', [
'schema',
'templates']],
134 schema = module.params[
'schema']
135 templates = module.params[
'templates']
136 sites = module.params[
'sites']
137 state = module.params[
'state']
146 mso.existing = mso.get_obj(path, displayName=schema)
148 schema_id = mso.existing[
'id']
149 path =
'schemas/{id}'.
format(id=schema_id)
151 mso.existing = mso.query_objs(path)
156 elif state ==
'absent':
157 mso.previous = mso.existing
159 if module.check_mode:
162 mso.existing = mso.request(path, method=
'DELETE')
164 elif state ==
'present':
165 mso.previous = mso.existing
174 mso.sanitize(payload, collate=
True)
177 if not issubset(mso.sent, mso.existing):
178 if module.check_mode:
179 mso.existing = mso.proposed
181 mso.existing = mso.request(path, method=
'PUT', data=mso.sent)
183 if module.check_mode:
184 mso.existing = mso.proposed
186 mso.existing = mso.request(path, method=
'POST', data=mso.sent)
191if __name__ ==
"__main__":
def issubset(subset, superset)