but not add them into Ceph.
required: false
default: True
- auid:
- description:
- - Sets the auid (authenticated user id) for the specified keyring
- required: false
- default: None
dest:
description:
- Destination to write the keyring
name: client.admin
state: present
secret: AQAin8tU2DsKFBAAFIAzVTzkL3+gtAjjpQiomw==
- auid: 0
caps:
mon: allow *
osd: allow *
]
cmd.extend(base_cmd)
-
- if auid:
- cmd.extend(['--set-uid', auid])
-
cmd = generate_caps(cmd, "ceph-authtool", caps)
return cmd
secret = generate_secret()
cmd_list.append(generate_ceph_authtool_cmd(
- cluster, name, secret, caps, auid, dest, container_image))
+ cluster, name, secret, caps, dest, container_image))
if import_key:
user = "client.admin"
caps=dict(type='dict', required=False, default=None),
secret=dict(type='str', required=False, default=None),
import_key=dict(type='bool', required=False, default=True),
- auid=dict(type='str', required=False, default=None),
- dest=dict(type='str', required=False, default='/etc/ceph'),
+ dest=dict(type='str', required=False, default='/etc/ceph/'),
)
module = AnsibleModule(
caps = module.params.get('caps')
secret = module.params.get('secret')
import_key = module.params.get('import_key')
- auid = module.params.get('auid')
dest = module.params.get('dest')
result = dict(
module.exit_json(**result)
rc, cmd, out, err = exec_commands(module, create_key(
- module, result, cluster, name, secret, caps, import_key, auid, file_path, container_image)) # noqa E501
+ module, result, cluster, name, secret, caps, import_key, dest, container_image)) # noqa E501
file_args = module.load_file_common_arguments(module.params)
file_args['path'] = file_path
fake_dest = "/fake/ceph"
fake_file_destination = os.path.join(
fake_dest + "/" + fake_cluster + "." + fake_name + ".keyring")
- fake_auid = None
expected_command_list = [
'ceph-authtool',
'--create-keyring',
'allow rwx',
]
result = ceph_key.generate_ceph_authtool_cmd(
- fake_cluster, fake_name, fake_secret, fake_caps, fake_auid, fake_file_destination) # noqa E501
- assert result == expected_command_list
-
- def test_generate_ceph_authtool_cmd_non_container_auid(self):
- fake_cluster = "fake"
- fake_name = "client.fake"
- fake_secret = "super-secret"
- fake_caps = {
- 'mon': 'allow *',
- 'osd': 'allow rwx',
- }
- fake_dest = "/fake/ceph"
- fake_file_destination = os.path.join(
- fake_dest + "/" + fake_cluster + "." + fake_name + ".keyring")
- fake_auid = 666
- expected_command_list = [
- 'ceph-authtool',
- '--create-keyring',
- fake_file_destination,
- '--name',
- fake_name,
- '--add-key',
- fake_secret,
- '--set-uid',
- fake_auid,
- '--cap',
- 'mon',
- 'allow *',
- '--cap',
- 'osd',
- 'allow rwx',
- ]
- result = ceph_key.generate_ceph_authtool_cmd(
- fake_cluster, fake_name, fake_secret, fake_caps, fake_auid, fake_file_destination) # noqa E501
+ fake_cluster, fake_name, fake_secret, fake_caps, fake_dest) # noqa E501
assert result == expected_command_list
def test_generate_ceph_authtool_cmd_container(self):
'osd': 'allow rwx',
}
fake_dest = "/fake/ceph"
- fake_auid = None
fake_file_destination = os.path.join(
fake_dest + "/" + fake_cluster + "." + fake_name + ".keyring")
fake_container_image = "docker.io/ceph/daemon:latest-luminous"
'osd',
'allow rwx']
result = ceph_key.generate_ceph_authtool_cmd(
- fake_cluster, fake_name, fake_secret, fake_caps, fake_auid, fake_file_destination, fake_containerized) # noqa E501
+ fake_cluster, fake_name, fake_secret, fake_caps, fake_dest, fake_container_image) # noqa E501
assert result == expected_command_list
def test_create_key_non_container(self):
'osd': 'allow rwx',
}
fake_import_key = True
- fake_auid = None
fake_dest = "/fake/ceph"
fake_file_destination = os.path.join(
fake_dest + "/" + fake_cluster + "." + fake_name + ".keyring")
'import', '-i', fake_file_destination],
]
result = ceph_key.create_key(fake_module, fake_result, fake_cluster,
- fake_name, fake_secret, fake_caps, fake_import_key, fake_auid, fake_file_destination) # noqa E501
+ fake_name, fake_secret, fake_caps, fake_import_key, fake_dest) # noqa E501
assert result == expected_command_list
def test_create_key_container(self):
}
fake_dest = "/fake/ceph"
fake_import_key = True
- fake_auid = None
fake_file_destination = os.path.join(
fake_dest + "/" + fake_cluster + "." + fake_name + ".keyring")
fake_container_image = "docker.io/ceph/daemon:latest-luminous"
'-i', fake_file_destination]
]
result = ceph_key.create_key(fake_module, fake_result, fake_cluster, fake_name, # noqa E501
- fake_secret, fake_caps, fake_import_key, fake_auid, fake_file_destination, fake_containerized) # noqa E501
+ fake_secret, fake_caps, fake_import_key, fake_dest, fake_container_image) # noqa E501
assert result == expected_command_list
def test_create_key_non_container_no_import(self):
}
fake_dest = "/fake/ceph"
fake_import_key = False
- fake_auid = None
fake_file_destination = os.path.join(
fake_dest + "/" + fake_cluster + "." + fake_name + ".keyring")
# create_key passes (one for ceph-authtool and one for itself) itw own array so the expected result is an array within an array # noqa E501
'allow rwx', ]
]
result = ceph_key.create_key(fake_module, fake_result, fake_cluster,
- fake_name, fake_secret, fake_caps, fake_import_key, fake_auid, fake_file_destination) # noqa E501
+ fake_name, fake_secret, fake_caps, fake_import_key, fake_dest) # noqa E501
assert result == expected_command_list
def test_create_key_container_no_import(self):
fake_import_key = False
fake_file_destination = os.path.join(
fake_dest + "/" + fake_cluster + "." + fake_name + ".keyring")
- fake_auid = None
# create_key passes (one for ceph-authtool and one for itself) itw own array so the expected result is an array within an array # noqa E501
fake_container_image = "docker.io/ceph/daemon:latest-luminous"
expected_command_list = [['docker', # noqa E128
'osd',
'allow rwx']]
result = ceph_key.create_key(fake_module, fake_result, fake_cluster, fake_name, # noqa E501
- fake_secret, fake_caps, fake_import_key, fake_auid, fake_file_destination, fake_containerized) # noqa E501
+ fake_secret, fake_caps, fake_import_key, fake_dest, fake_container_image) # noqa E501
assert result == expected_command_list
def test_update_key_non_container(self):