mirror of https://github.com/ceph/ceph-ansible.git
ceph_key: fetch key when needed
Fetch the key when it is present in the cluster but not on the node.
Signed-off-by: Guillaume Abrioux <gabrioux@redhat.com>
(cherry picked from commit ccfa249919
)
pull/5267/head
parent
323d4f8f0b
commit
a8f5e43624
|
@ -545,8 +545,17 @@ def run_module():
|
|||
caps = _info_key[0]['caps']
|
||||
_caps = _info_key[0]['caps']
|
||||
if secret == _secret and caps == _caps:
|
||||
if not os.path.isfile(file_path):
|
||||
rc, cmd, out, err = exec_commands(module, get_key(cluster, name, file_path, containerized)) # noqa E501
|
||||
result["rc"] = rc
|
||||
if rc != 0:
|
||||
result["stdout"] = "Couldn't fetch the key {0} at {1}.".format(name, file_path) # noqa E501
|
||||
module.exit_json(**result)
|
||||
result["stdout"] = "fetched the key {0} at {1}.".format(name, file_path) # noqa E501
|
||||
|
||||
result["stdout"] = "{0} already exists and doesn't need to be updated.".format(name) # noqa E501
|
||||
result["rc"] = 0
|
||||
module.set_fs_attributes_if_different(file_args, False)
|
||||
module.exit_json(**result)
|
||||
else:
|
||||
if os.path.isfile(file_path) and not secret or not caps:
|
||||
|
@ -570,17 +579,6 @@ def run_module():
|
|||
result["stderr"] = err
|
||||
module.exit_json(**result)
|
||||
changed = True
|
||||
# fetch the key on the system
|
||||
if key_exist != 1 and not import_key:
|
||||
rc, cmd, out, err = exec_commands(module, get_key(cluster, name, file_path, containerized)) # noqa E501
|
||||
result["rc"] = rc
|
||||
if rc != 0:
|
||||
result["stdout"] = "Couldn't fetch the key {0} at {1}.".format( # noqa E501
|
||||
name, file_path)
|
||||
module.exit_json(**result)
|
||||
|
||||
result["stdout"] = "fetched the key {0} at {1}.".format( # noqa E501
|
||||
name, file_path)
|
||||
|
||||
module.set_fs_attributes_if_different(file_args, False)
|
||||
|
||||
|
|
Loading…
Reference in New Issue