mirror of https://github.com/ceph/ceph-ansible.git
radosgw_zonegroup: add support check mode
Signed-off-by: Seena Fallah <seenafallah@gmail.com>pull/7523/head
parent
e8d34b6ee6
commit
beb046cba9
|
@ -345,25 +345,14 @@ def run_module():
|
||||||
endpoints = module.params.get('endpoints')
|
endpoints = module.params.get('endpoints')
|
||||||
master = module.params.get('master')
|
master = module.params.get('master')
|
||||||
|
|
||||||
if module.check_mode:
|
|
||||||
module.exit_json(
|
|
||||||
changed=False,
|
|
||||||
stdout='',
|
|
||||||
stderr='',
|
|
||||||
rc=0,
|
|
||||||
start='',
|
|
||||||
end='',
|
|
||||||
delta='',
|
|
||||||
)
|
|
||||||
|
|
||||||
startd = datetime.datetime.now()
|
startd = datetime.datetime.now()
|
||||||
changed = False
|
changed = False
|
||||||
|
|
||||||
# will return either the image name or None
|
# will return either the image name or None
|
||||||
container_image = is_containerized()
|
container_image = is_containerized()
|
||||||
|
|
||||||
|
rc, cmd, out, err = exec_commands(module, get_zonegroup(module, container_image=container_image)) # noqa: E501
|
||||||
if state == "present":
|
if state == "present":
|
||||||
rc, cmd, out, err = exec_commands(module, get_zonegroup(module, container_image=container_image)) # noqa: E501
|
|
||||||
if rc == 0:
|
if rc == 0:
|
||||||
zonegroup = json.loads(out)
|
zonegroup = json.loads(out)
|
||||||
_rc, _cmd, _out, _err = exec_commands(module, get_realm(module, container_image=container_image)) # noqa: E501
|
_rc, _cmd, _out, _err = exec_commands(module, get_realm(module, container_image=container_image)) # noqa: E501
|
||||||
|
@ -380,25 +369,23 @@ def run_module():
|
||||||
'master': master,
|
'master': master,
|
||||||
'realm_id': realm['id']
|
'realm_id': realm['id']
|
||||||
}
|
}
|
||||||
if current != asked:
|
changed = current != asked
|
||||||
|
if changed and not module.check_mode:
|
||||||
rc, cmd, out, err = exec_commands(module, modify_zonegroup(module, container_image=container_image)) # noqa: E501
|
rc, cmd, out, err = exec_commands(module, modify_zonegroup(module, container_image=container_image)) # noqa: E501
|
||||||
changed = True
|
|
||||||
else:
|
else:
|
||||||
rc, cmd, out, err = exec_commands(module, create_zonegroup(module, container_image=container_image)) # noqa: E501
|
if not module.check_mode:
|
||||||
|
rc, cmd, out, err = exec_commands(module, create_zonegroup(module, container_image=container_image)) # noqa: E501
|
||||||
changed = True
|
changed = True
|
||||||
|
|
||||||
elif state == "absent":
|
elif state == "absent":
|
||||||
rc, cmd, out, err = exec_commands(module, get_zonegroup(module, container_image=container_image)) # noqa: E501
|
|
||||||
if rc == 0:
|
if rc == 0:
|
||||||
rc, cmd, out, err = exec_commands(module, remove_zonegroup(module, container_image=container_image)) # noqa: E501
|
if not module.check_mode:
|
||||||
|
rc, cmd, out, err = exec_commands(module, remove_zonegroup(module, container_image=container_image)) # noqa: E501
|
||||||
changed = True
|
changed = True
|
||||||
else:
|
else:
|
||||||
rc = 0
|
rc = 0
|
||||||
out = "Zonegroup {} doesn't exist".format(name)
|
out = "Zonegroup {} doesn't exist".format(name)
|
||||||
|
|
||||||
elif state == "info":
|
|
||||||
rc, cmd, out, err = exec_commands(module, get_zonegroup(module, container_image=container_image)) # noqa: E501
|
|
||||||
|
|
||||||
exit_module(module=module, out=out, rc=rc, cmd=cmd, err=err, startd=startd, changed=changed) # noqa: E501
|
exit_module(module=module, out=out, rc=rc, cmd=cmd, err=err, startd=startd, changed=changed) # noqa: E501
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue