From 3d0670b41c42bfa17dfb18fc90a971b739a66d16 Mon Sep 17 00:00:00 2001 From: =?utf8?q?S=C3=A9bastien=20Han?= Date: Fri, 16 Nov 2018 10:46:10 +0100 Subject: [PATCH] ceph_key: apply permissions using ansible code module MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Instead of applying file permissions from our code, let's rely on the ansible code 'file' module for this. This is now handled at the task declaration level instead of inside the module. Signed-off-by: Sébastien Han --- library/ceph_key.py | 23 +++-------------------- 1 file changed, 3 insertions(+), 20 deletions(-) diff --git a/library/ceph_key.py b/library/ceph_key.py index 9b42a06b7..710f33901 100644 --- a/library/ceph_key.py +++ b/library/ceph_key.py @@ -649,14 +649,6 @@ def run_module(): if entities is None: fatal("Failed to find some of the initial entities", module) - # get ceph's group and user id - if container_image: - ceph_uid = os.getenv('CEPH_UID') - ceph_grp = os.getenv('CEPH_UID') - else: - ceph_uid = pwd.getpwnam('ceph').pw_uid - ceph_grp = grp.getgrnam('ceph').gr_gid - output_format = "plain" for entity in entities: key_path = build_key_path(cluster, entity) @@ -679,18 +671,9 @@ def run_module(): rc, cmd, out, err = exec_commands( module, info_cmd) # noqa E501 - # apply ceph:ceph ownership and mode 0400 on keys - # FIXME by using - # file_args = module.load_file_common_arguments(module.params) - # file_args['path'] = dest - # module.set_fs_attributes_if_different(file_args, False) - try: - os.chown(key_path, ceph_uid, ceph_grp) - os.chmod(key_path, stat.S_IRUSR) - except OSError as e: - fatal("Failed to set owner/group/permissions of %s: %s" % ( - key_path, str(e)), module) - + file_args = module.load_file_common_arguments(module.params) + file_args['path'] = key_path + module.set_fs_attributes_if_different(file_args, False) else: module.fail_json( msg='State must either be "present" or "absent" or "update" or "list" or "info" or "fetch_initial_keys".', changed=False, rc=1) # noqa E501 -- 2.39.5