mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-25 14:20:22 -07:00
MSO: Refactor modules to common structure (#51354)
This PR includes: - Various fixes to jsonpatch interface - Added seealso: and notes: to docs - Various improvements to docs - A set of bugfixes found during integration tests Full integration tests follow.
This commit is contained in:
parent
2c2a79f712
commit
73636175da
13 changed files with 207 additions and 265 deletions
|
@ -135,7 +135,6 @@ def main():
|
|||
mso.fail_json(msg="Provided schema '{0}' does not exist".format(schema))
|
||||
|
||||
# Schema exists
|
||||
schema_id = schema_obj['id']
|
||||
schema_path = 'schemas/{id}'.format(**schema_obj)
|
||||
|
||||
# Get site
|
||||
|
@ -159,16 +158,16 @@ def main():
|
|||
mso.existing = []
|
||||
mso.exit_json()
|
||||
|
||||
sites_path = '/sites'
|
||||
site_path = '/sites/{0}'.format(site)
|
||||
ops = []
|
||||
|
||||
mso.previous = mso.existing
|
||||
if state == 'absent':
|
||||
mso.proposed = mso.sent = {}
|
||||
|
||||
if mso.existing:
|
||||
# Remove existing site
|
||||
mso.existing = {}
|
||||
ops.append(dict(op='remove', path='/sites/{0}'.format(site_idx)))
|
||||
mso.sent = mso.existing = {}
|
||||
ops.append(dict(op='remove', path=site_path))
|
||||
|
||||
elif state == 'present':
|
||||
if not mso.existing:
|
||||
|
@ -187,8 +186,9 @@ def main():
|
|||
|
||||
mso.sanitize(payload, collate=True)
|
||||
|
||||
mso.existing = mso.proposed = mso.sent
|
||||
ops.append(dict(op='add', path='/sites/-', value=mso.sent))
|
||||
ops.append(dict(op='add', path=sites_path + '/-', value=mso.sent))
|
||||
|
||||
mso.existing = mso.proposed
|
||||
|
||||
if not module.check_mode:
|
||||
mso.request(schema_path, method='PATCH', data=ops)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue