mirror of https://github.com/ceph/ceph-ansible.git
library: flake8 ceph-ansible modules
This commit ensure all ceph-ansible modules pass flake8 properly. Signed-off-by: Wong Hoi Sing Edison <hswong3i@pantarei-design.com>pull/6655/head
parent
d191ba38d3
commit
beda1fe773
|
@ -112,7 +112,7 @@ option:
|
||||||
default: unlimited
|
default: unlimited
|
||||||
bucketmaxobjects:
|
bucketmaxobjects:
|
||||||
description:
|
description:
|
||||||
- with bucket quota enabled specify maximum number of objects # noqa E501
|
- with bucket quota enabled specify maximum number of objects # noqa: E501
|
||||||
required: false
|
required: false
|
||||||
default: unlimited
|
default: unlimited
|
||||||
buckets:
|
buckets:
|
||||||
|
@ -263,7 +263,7 @@ error_messages:
|
||||||
returned: always
|
returned: always
|
||||||
type: list
|
type: list
|
||||||
sample: [
|
sample: [
|
||||||
"test2: could not modify user: unable to modify user, cannot add duplicate email\n" # noqa E501
|
"test2: could not modify user: unable to modify user, cannot add duplicate email\n" # noqa: E501
|
||||||
]
|
]
|
||||||
|
|
||||||
failed_users:
|
failed_users:
|
||||||
|
@ -334,36 +334,36 @@ def create_users(rgw, users, result):
|
||||||
if email:
|
if email:
|
||||||
if autogenkey:
|
if autogenkey:
|
||||||
try:
|
try:
|
||||||
rgw.create_user(username, fullname, email=email, key_type='s3', # noqa E501
|
rgw.create_user(username, fullname, email=email, key_type='s3', # noqa: E501
|
||||||
generate_key=autogenkey,
|
generate_key=autogenkey,
|
||||||
max_buckets=maxbucket, suspended=suspend) # noqa E501
|
max_buckets=maxbucket, suspended=suspend) # noqa: E501
|
||||||
except radosgw.exception.RadosGWAdminError as e:
|
except radosgw.exception.RadosGWAdminError as e:
|
||||||
result['error_messages'].append(username + ' ' + e.get_code()) # noqa E501
|
result['error_messages'].append(username + ' ' + e.get_code()) # noqa: E501
|
||||||
fail_flag = True
|
fail_flag = True
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
rgw.create_user(username, fullname, email=email, key_type='s3', # noqa E501
|
rgw.create_user(username, fullname, email=email, key_type='s3', # noqa: E501
|
||||||
access_key=accesskey, secret_key=secretkey, # noqa E501
|
access_key=accesskey, secret_key=secretkey, # noqa: E501
|
||||||
max_buckets=maxbucket, suspended=suspend) # noqa E501
|
max_buckets=maxbucket, suspended=suspend) # noqa: E501
|
||||||
except radosgw.exception.RadosGWAdminError as e:
|
except radosgw.exception.RadosGWAdminError as e:
|
||||||
result['error_messages'].append(username + ' ' + e.get_code()) # noqa E501
|
result['error_messages'].append(username + ' ' + e.get_code()) # noqa: E501
|
||||||
fail_flag = True
|
fail_flag = True
|
||||||
else:
|
else:
|
||||||
if autogenkey:
|
if autogenkey:
|
||||||
try:
|
try:
|
||||||
rgw.create_user(username, fullname, key_type='s3',
|
rgw.create_user(username, fullname, key_type='s3',
|
||||||
generate_key=autogenkey,
|
generate_key=autogenkey,
|
||||||
max_buckets=maxbucket, suspended=suspend) # noqa E501
|
max_buckets=maxbucket, suspended=suspend) # noqa: E501
|
||||||
except radosgw.exception.RadosGWAdminError as e:
|
except radosgw.exception.RadosGWAdminError as e:
|
||||||
result['error_messages'].append(username + ' ' + e.get_code()) # noqa E501
|
result['error_messages'].append(username + ' ' + e.get_code()) # noqa: E501
|
||||||
fail_flag = True
|
fail_flag = True
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
rgw.create_user(username, fullname, key_type='s3',
|
rgw.create_user(username, fullname, key_type='s3',
|
||||||
access_key=accesskey, secret_key=secretkey, # noqa E501
|
access_key=accesskey, secret_key=secretkey, # noqa: E501
|
||||||
max_buckets=maxbucket, suspended=suspend) # noqa E501
|
max_buckets=maxbucket, suspended=suspend) # noqa: E501
|
||||||
except radosgw.exception.RadosGWAdminError as e:
|
except radosgw.exception.RadosGWAdminError as e:
|
||||||
result['error_messages'].append(username + ' ' + e.get_code()) # noqa E501
|
result['error_messages'].append(username + ' ' + e.get_code()) # noqa: E501
|
||||||
fail_flag = True
|
fail_flag = True
|
||||||
|
|
||||||
if not fail_flag and userquota:
|
if not fail_flag and userquota:
|
||||||
|
@ -371,15 +371,15 @@ def create_users(rgw, users, result):
|
||||||
rgw.set_quota(username, 'user', max_objects=usermaxobjects,
|
rgw.set_quota(username, 'user', max_objects=usermaxobjects,
|
||||||
max_size_kb=usermaxsize, enabled=True)
|
max_size_kb=usermaxsize, enabled=True)
|
||||||
except radosgw.exception.RadosGWAdminError as e:
|
except radosgw.exception.RadosGWAdminError as e:
|
||||||
result['error_messages'].append(username + ' ' + e.get_code()) # noqa E501
|
result['error_messages'].append(username + ' ' + e.get_code()) # noqa: E501
|
||||||
fail_flag = True
|
fail_flag = True
|
||||||
|
|
||||||
if not fail_flag and bucketquota:
|
if not fail_flag and bucketquota:
|
||||||
try:
|
try:
|
||||||
rgw.set_quota(username, 'bucket', max_objects=bucketmaxobjects, # noqa E501
|
rgw.set_quota(username, 'bucket', max_objects=bucketmaxobjects, # noqa: E501
|
||||||
max_size_kb=bucketmaxsize, enabled=True)
|
max_size_kb=bucketmaxsize, enabled=True)
|
||||||
except radosgw.exception.RadosGWAdminError as e:
|
except radosgw.exception.RadosGWAdminError as e:
|
||||||
result['error_messages'].append(username + ' ' + e.get_code()) # noqa E501
|
result['error_messages'].append(username + ' ' + e.get_code()) # noqa: E501
|
||||||
fail_flag = True
|
fail_flag = True
|
||||||
|
|
||||||
if fail_flag:
|
if fail_flag:
|
||||||
|
@ -450,12 +450,12 @@ def create_buckets(rgw, buckets, result):
|
||||||
except radosgw.exception.RadosGWAdminError:
|
except radosgw.exception.RadosGWAdminError:
|
||||||
pass
|
pass
|
||||||
failed_buckets.append(bucket)
|
failed_buckets.append(bucket)
|
||||||
result['error_messages'].append(bucket + ' could not be linked' + ', NoSuchUser ' + user) # noqa E501
|
result['error_messages'].append(bucket + ' could not be linked' + ', NoSuchUser ' + user) # noqa: E501
|
||||||
|
|
||||||
else:
|
else:
|
||||||
# something went wrong
|
# something went wrong
|
||||||
failed_buckets.append(bucket)
|
failed_buckets.append(bucket)
|
||||||
result['error_messages'].append(bucket + ' could not be created') # noqa E501
|
result['error_messages'].append(bucket + ' could not be created') # noqa: E501
|
||||||
|
|
||||||
result['added_buckets'] = ", ".join(added_buckets)
|
result['added_buckets'] = ", ".join(added_buckets)
|
||||||
result['failed_buckets'] = ", ".join(failed_buckets)
|
result['failed_buckets'] = ", ".join(failed_buckets)
|
||||||
|
@ -467,7 +467,7 @@ def create_bucket(rgw, bucket):
|
||||||
host=rgw._connection[0],
|
host=rgw._connection[0],
|
||||||
port=rgw.port,
|
port=rgw.port,
|
||||||
is_secure=rgw.is_secure,
|
is_secure=rgw.is_secure,
|
||||||
calling_format=boto.s3.connection.OrdinaryCallingFormat(), # noqa E501
|
calling_format=boto.s3.connection.OrdinaryCallingFormat(), # noqa: E501
|
||||||
)
|
)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -489,23 +489,23 @@ def main():
|
||||||
admin_access_key=dict(type='str', required=True),
|
admin_access_key=dict(type='str', required=True),
|
||||||
admin_secret_key=dict(type='str', required=True),
|
admin_secret_key=dict(type='str', required=True),
|
||||||
buckets=dict(type='list', required=False, elements='dict',
|
buckets=dict(type='list', required=False, elements='dict',
|
||||||
options=dict(bucket=dict(type='str', required=True), # noqa E501
|
options=dict(bucket=dict(type='str', required=True), # noqa: E501
|
||||||
user=dict(type='str', required=True))), # noqa E501
|
user=dict(type='str', required=True))), # noqa: E501
|
||||||
users=dict(type='list', required=False, elements='dict',
|
users=dict(type='list', required=False, elements='dict',
|
||||||
options=dict(username=dict(type='str', required=True), # noqa E501
|
options=dict(username=dict(type='str', required=True), # noqa: E501
|
||||||
fullname=dict(type='str', required=True), # noqa E501
|
fullname=dict(type='str', required=True), # noqa: E501
|
||||||
email=dict(type='str', required=False), # noqa E501
|
email=dict(type='str', required=False), # noqa: E501
|
||||||
maxbucket=dict(type='int', required=False, default=1000), # noqa E501
|
maxbucket=dict(type='int', required=False, default=1000), # noqa: E501
|
||||||
suspend=dict(type='bool', required=False, default=False), # noqa E501
|
suspend=dict(type='bool', required=False, default=False), # noqa: E501
|
||||||
autogenkey=dict(type='bool', required=False, default=True), # noqa E501
|
autogenkey=dict(type='bool', required=False, default=True), # noqa: E501
|
||||||
accesskey=dict(type='str', required=False), # noqa E501
|
accesskey=dict(type='str', required=False), # noqa: E501
|
||||||
secretkey=dict(type='str', required=False), # noqa E501
|
secretkey=dict(type='str', required=False), # noqa: E501
|
||||||
userquota=dict(type='bool', required=False, default=False), # noqa E501
|
userquota=dict(type='bool', required=False, default=False), # noqa: E501
|
||||||
usermaxsize=dict(type='str', required=False, default='-1'), # noqa E501
|
usermaxsize=dict(type='str', required=False, default='-1'), # noqa: E501
|
||||||
usermaxobjects=dict(type='int', required=False, default=-1), # noqa E501
|
usermaxobjects=dict(type='int', required=False, default=-1), # noqa: E501
|
||||||
bucketquota=dict(type='bool', required=False, default=False), # noqa E501
|
bucketquota=dict(type='bool', required=False, default=False), # noqa: E501
|
||||||
bucketmaxsize=dict(type='str', required=False, default='-1'), # noqa E501
|
bucketmaxsize=dict(type='str', required=False, default='-1'), # noqa: E501
|
||||||
bucketmaxobjects=dict(type='int', required=False, default=-1)))) # noqa E501
|
bucketmaxobjects=dict(type='int', required=False, default=-1)))) # noqa: E501
|
||||||
|
|
||||||
# the AnsibleModule object
|
# the AnsibleModule object
|
||||||
module = AnsibleModule(argument_spec=fields,
|
module = AnsibleModule(argument_spec=fields,
|
||||||
|
@ -533,8 +533,8 @@ def main():
|
||||||
# radosgw connection
|
# radosgw connection
|
||||||
rgw = radosgw.connection.RadosGWAdminConnection(host=rgw_host,
|
rgw = radosgw.connection.RadosGWAdminConnection(host=rgw_host,
|
||||||
port=port,
|
port=port,
|
||||||
access_key=admin_access_key, # noqa E501
|
access_key=admin_access_key, # noqa: E501
|
||||||
secret_key=admin_secret_key, # noqa E501
|
secret_key=admin_secret_key, # noqa: E501
|
||||||
aws_signature='AWS4',
|
aws_signature='AWS4',
|
||||||
is_secure=is_secure)
|
is_secure=is_secure)
|
||||||
|
|
||||||
|
|
|
@ -108,9 +108,9 @@ def sort_osd_crush_location(location, module):
|
||||||
"region",
|
"region",
|
||||||
"root",
|
"root",
|
||||||
]
|
]
|
||||||
return sorted(location, key=lambda crush: crush_bucket_types.index(crush[0])) # noqa E501
|
return sorted(location, key=lambda crush: crush_bucket_types.index(crush[0])) # noqa: E501
|
||||||
except ValueError as error:
|
except ValueError as error:
|
||||||
fatal("{} is not a valid CRUSH bucket, valid bucket types are {}".format(error.args[0].split()[0], crush_bucket_types), module) # noqa E501
|
fatal("{} is not a valid CRUSH bucket, valid bucket types are {}".format(error.args[0].split()[0], crush_bucket_types), module) # noqa: E501
|
||||||
|
|
||||||
|
|
||||||
def create_and_move_buckets_list(cluster, location, containerized=None):
|
def create_and_move_buckets_list(cluster, location, containerized=None):
|
||||||
|
@ -122,10 +122,10 @@ def create_and_move_buckets_list(cluster, location, containerized=None):
|
||||||
for item in location:
|
for item in location:
|
||||||
bucket_type, bucket_name = item
|
bucket_type, bucket_name = item
|
||||||
# ceph osd crush add-bucket maroot root
|
# ceph osd crush add-bucket maroot root
|
||||||
cmd_list.append(generate_cmd(cluster, "add-bucket", bucket_name, bucket_type, containerized)) # noqa E501
|
cmd_list.append(generate_cmd(cluster, "add-bucket", bucket_name, bucket_type, containerized)) # noqa: E501
|
||||||
if previous_bucket:
|
if previous_bucket:
|
||||||
# ceph osd crush move monrack root=maroot
|
# ceph osd crush move monrack root=maroot
|
||||||
cmd_list.append(generate_cmd(cluster, "move", previous_bucket, "%s=%s" % (bucket_type, bucket_name), containerized)) # noqa E501
|
cmd_list.append(generate_cmd(cluster, "move", previous_bucket, "%s=%s" % (bucket_type, bucket_name), containerized)) # noqa: E501
|
||||||
previous_bucket = item[1]
|
previous_bucket = item[1]
|
||||||
return cmd_list
|
return cmd_list
|
||||||
|
|
||||||
|
@ -172,7 +172,7 @@ def run_module():
|
||||||
startd = datetime.datetime.now()
|
startd = datetime.datetime.now()
|
||||||
|
|
||||||
# run the Ceph command to add buckets
|
# run the Ceph command to add buckets
|
||||||
rc, cmd, out, err = exec_commands(module, create_and_move_buckets_list(cluster, location, containerized)) # noqa E501
|
rc, cmd, out, err = exec_commands(module, create_and_move_buckets_list(cluster, location, containerized)) # noqa: E501
|
||||||
|
|
||||||
endd = datetime.datetime.now()
|
endd = datetime.datetime.now()
|
||||||
delta = endd - startd
|
delta = endd - startd
|
||||||
|
|
|
@ -17,9 +17,15 @@ __metaclass__ = type
|
||||||
|
|
||||||
from ansible.module_utils.basic import AnsibleModule
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
try:
|
try:
|
||||||
from ansible.module_utils.ca_common import exit_module, generate_ceph_cmd, is_containerized, exec_command
|
from ansible.module_utils.ca_common import exit_module, \
|
||||||
|
generate_ceph_cmd, \
|
||||||
|
is_containerized, \
|
||||||
|
exec_command
|
||||||
except ImportError:
|
except ImportError:
|
||||||
from module_utils.ca_common import exit_module, generate_ceph_cmd, is_containerized, exec_command
|
from module_utils.ca_common import exit_module, \
|
||||||
|
generate_ceph_cmd, \
|
||||||
|
is_containerized, \
|
||||||
|
exec_command
|
||||||
import datetime
|
import datetime
|
||||||
import json
|
import json
|
||||||
|
|
||||||
|
@ -71,7 +77,8 @@ options:
|
||||||
description:
|
description:
|
||||||
- The ceph bucket type for replicated rule.
|
- The ceph bucket type for replicated rule.
|
||||||
required: false
|
required: false
|
||||||
choices: ['osd', 'host', 'chassis', 'rack', 'row', 'pdu', 'pod', 'room', 'datacenter', 'zone', 'region', 'root']
|
choices: ['osd', 'host', 'chassis', 'rack', 'row', 'pdu', 'pod',
|
||||||
|
'room', 'datacenter', 'zone', 'region', 'root']
|
||||||
device_class:
|
device_class:
|
||||||
description:
|
description:
|
||||||
- The ceph device class for replicated rule.
|
- The ceph device class for replicated rule.
|
||||||
|
@ -135,7 +142,10 @@ def create_rule(module, container_image=None):
|
||||||
if profile:
|
if profile:
|
||||||
args.append(profile)
|
args.append(profile)
|
||||||
|
|
||||||
cmd = generate_ceph_cmd(['osd', 'crush', 'rule'], args, cluster=cluster, container_image=container_image)
|
cmd = generate_ceph_cmd(['osd', 'crush', 'rule'],
|
||||||
|
args,
|
||||||
|
cluster=cluster,
|
||||||
|
container_image=container_image)
|
||||||
|
|
||||||
return cmd
|
return cmd
|
||||||
|
|
||||||
|
@ -150,7 +160,10 @@ def get_rule(module, container_image=None):
|
||||||
|
|
||||||
args = ['dump', name, '--format=json']
|
args = ['dump', name, '--format=json']
|
||||||
|
|
||||||
cmd = generate_ceph_cmd(['osd', 'crush', 'rule'], args, cluster=cluster, container_image=container_image)
|
cmd = generate_ceph_cmd(['osd', 'crush', 'rule'],
|
||||||
|
args,
|
||||||
|
cluster=cluster,
|
||||||
|
container_image=container_image)
|
||||||
|
|
||||||
return cmd
|
return cmd
|
||||||
|
|
||||||
|
@ -165,7 +178,10 @@ def remove_rule(module, container_image=None):
|
||||||
|
|
||||||
args = ['rm', name]
|
args = ['rm', name]
|
||||||
|
|
||||||
cmd = generate_ceph_cmd(['osd', 'crush', 'rule'], args, cluster=cluster, container_image=container_image)
|
cmd = generate_ceph_cmd(['osd', 'crush', 'rule'],
|
||||||
|
args,
|
||||||
|
cluster=cluster,
|
||||||
|
container_image=container_image)
|
||||||
|
|
||||||
return cmd
|
return cmd
|
||||||
|
|
||||||
|
@ -175,11 +191,11 @@ def main():
|
||||||
argument_spec=dict(
|
argument_spec=dict(
|
||||||
name=dict(type='str', required=True),
|
name=dict(type='str', required=True),
|
||||||
cluster=dict(type='str', required=False, default='ceph'),
|
cluster=dict(type='str', required=False, default='ceph'),
|
||||||
state=dict(type='str', required=False, choices=['present', 'absent', 'info'], default='present'),
|
state=dict(type='str', required=False, choices=['present', 'absent', 'info'], default='present'), # noqa: E501
|
||||||
rule_type=dict(type='str', required=False, choices=['replicated', 'erasure']),
|
rule_type=dict(type='str', required=False, choices=['replicated', 'erasure']), # noqa: E501
|
||||||
bucket_root=dict(type='str', required=False),
|
bucket_root=dict(type='str', required=False),
|
||||||
bucket_type=dict(type='str', required=False, choices=['osd', 'host', 'chassis', 'rack', 'row', 'pdu', 'pod',
|
bucket_type=dict(type='str', required=False, choices=['osd', 'host', 'chassis', 'rack', 'row', 'pdu', 'pod', # noqa: E501
|
||||||
'room', 'datacenter', 'zone', 'region', 'root']),
|
'room', 'datacenter', 'zone', 'region', 'root']), # noqa: E501
|
||||||
device_class=dict(type='str', required=False),
|
device_class=dict(type='str', required=False),
|
||||||
profile=dict(type='str', required=False)
|
profile=dict(type='str', required=False)
|
||||||
),
|
),
|
||||||
|
@ -214,28 +230,28 @@ def main():
|
||||||
container_image = is_containerized()
|
container_image = is_containerized()
|
||||||
|
|
||||||
if state == "present":
|
if state == "present":
|
||||||
rc, cmd, out, err = exec_command(module, get_rule(module, container_image=container_image))
|
rc, cmd, out, err = exec_command(module, get_rule(module, container_image=container_image)) # noqa: E501
|
||||||
if rc != 0:
|
if rc != 0:
|
||||||
rc, cmd, out, err = exec_command(module, create_rule(module, container_image=container_image))
|
rc, cmd, out, err = exec_command(module, create_rule(module, container_image=container_image)) # noqa: E501
|
||||||
changed = True
|
changed = True
|
||||||
else:
|
else:
|
||||||
rule = json.loads(out)
|
rule = json.loads(out)
|
||||||
if (rule['type'] == 1 and rule_type == 'erasure') or (rule['type'] == 3 and rule_type == 'replicated'):
|
if (rule['type'] == 1 and rule_type == 'erasure') or (rule['type'] == 3 and rule_type == 'replicated'): # noqa: E501
|
||||||
module.fail_json(msg="Can not convert crush rule {} to {}".format(name, rule_type), changed=False, rc=1)
|
module.fail_json(msg="Can not convert crush rule {} to {}".format(name, rule_type), changed=False, rc=1) # noqa: E501
|
||||||
|
|
||||||
elif state == "absent":
|
elif state == "absent":
|
||||||
rc, cmd, out, err = exec_command(module, get_rule(module, container_image=container_image))
|
rc, cmd, out, err = exec_command(module, get_rule(module, container_image=container_image)) # noqa: E501
|
||||||
if rc == 0:
|
if rc == 0:
|
||||||
rc, cmd, out, err = exec_command(module, remove_rule(module, container_image=container_image))
|
rc, cmd, out, err = exec_command(module, remove_rule(module, container_image=container_image)) # noqa: E501
|
||||||
changed = True
|
changed = True
|
||||||
else:
|
else:
|
||||||
rc = 0
|
rc = 0
|
||||||
out = "Crush Rule {} doesn't exist".format(name)
|
out = "Crush Rule {} doesn't exist".format(name)
|
||||||
|
|
||||||
elif state == "info":
|
elif state == "info":
|
||||||
rc, cmd, out, err = exec_command(module, get_rule(module, container_image=container_image))
|
rc, cmd, out, err = exec_command(module, get_rule(module, container_image=container_image)) # noqa: E501
|
||||||
|
|
||||||
exit_module(module=module, out=out, rc=rc, cmd=cmd, err=err, startd=startd, changed=changed)
|
exit_module(module=module, out=out, rc=rc, cmd=cmd, err=err, startd=startd, changed=changed) # noqa: E501
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
|
@ -22,7 +22,7 @@ try:
|
||||||
exec_command, \
|
exec_command, \
|
||||||
exit_module
|
exit_module
|
||||||
except ImportError:
|
except ImportError:
|
||||||
from module_utils.ca_common import generate_ceph_cmd, is_containerized, exec_command, exit_module
|
from module_utils.ca_common import generate_ceph_cmd, is_containerized, exec_command, exit_module # noqa: E501
|
||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
import json
|
import json
|
||||||
|
@ -122,7 +122,11 @@ def create_user(module, container_image=None):
|
||||||
|
|
||||||
args = ['ac-user-create', '-i', '-', name]
|
args = ['ac-user-create', '-i', '-', name]
|
||||||
|
|
||||||
cmd = generate_ceph_cmd(sub_cmd=['dashboard'], args=args, cluster=cluster, container_image=container_image, interactive=True)
|
cmd = generate_ceph_cmd(sub_cmd=['dashboard'],
|
||||||
|
args=args,
|
||||||
|
cluster=cluster,
|
||||||
|
container_image=container_image,
|
||||||
|
interactive=True)
|
||||||
|
|
||||||
return cmd
|
return cmd
|
||||||
|
|
||||||
|
@ -140,7 +144,10 @@ def set_roles(module, container_image=None):
|
||||||
|
|
||||||
args.extend(roles)
|
args.extend(roles)
|
||||||
|
|
||||||
cmd = generate_ceph_cmd(sub_cmd=['dashboard'], args=args, cluster=cluster, container_image=container_image)
|
cmd = generate_ceph_cmd(sub_cmd=['dashboard'],
|
||||||
|
args=args,
|
||||||
|
cluster=cluster,
|
||||||
|
container_image=container_image)
|
||||||
|
|
||||||
return cmd
|
return cmd
|
||||||
|
|
||||||
|
@ -155,7 +162,11 @@ def set_password(module, container_image=None):
|
||||||
|
|
||||||
args = ['ac-user-set-password', '-i', '-', name]
|
args = ['ac-user-set-password', '-i', '-', name]
|
||||||
|
|
||||||
cmd = generate_ceph_cmd(sub_cmd=['dashboard'], args=args, cluster=cluster, container_image=container_image, interactive=True)
|
cmd = generate_ceph_cmd(sub_cmd=['dashboard'],
|
||||||
|
args=args,
|
||||||
|
cluster=cluster,
|
||||||
|
container_image=container_image,
|
||||||
|
interactive=True)
|
||||||
|
|
||||||
return cmd
|
return cmd
|
||||||
|
|
||||||
|
@ -170,7 +181,10 @@ def get_user(module, container_image=None):
|
||||||
|
|
||||||
args = ['ac-user-show', name, '--format=json']
|
args = ['ac-user-show', name, '--format=json']
|
||||||
|
|
||||||
cmd = generate_ceph_cmd(sub_cmd=['dashboard'], args=args, cluster=cluster, container_image=container_image)
|
cmd = generate_ceph_cmd(sub_cmd=['dashboard'],
|
||||||
|
args=args,
|
||||||
|
cluster=cluster,
|
||||||
|
container_image=container_image)
|
||||||
|
|
||||||
return cmd
|
return cmd
|
||||||
|
|
||||||
|
@ -185,7 +199,10 @@ def remove_user(module, container_image=None):
|
||||||
|
|
||||||
args = ['ac-user-delete', name]
|
args = ['ac-user-delete', name]
|
||||||
|
|
||||||
cmd = generate_ceph_cmd(sub_cmd=['dashboard'], args=args, cluster=cluster, container_image=container_image)
|
cmd = generate_ceph_cmd(sub_cmd=['dashboard'],
|
||||||
|
args=args,
|
||||||
|
cluster=cluster,
|
||||||
|
container_image=container_image)
|
||||||
|
|
||||||
return cmd
|
return cmd
|
||||||
|
|
||||||
|
@ -194,11 +211,11 @@ def run_module():
|
||||||
module_args = dict(
|
module_args = dict(
|
||||||
cluster=dict(type='str', required=False, default='ceph'),
|
cluster=dict(type='str', required=False, default='ceph'),
|
||||||
name=dict(type='str', required=True),
|
name=dict(type='str', required=True),
|
||||||
state=dict(type='str', required=False, choices=['present', 'absent', 'info'], default='present'),
|
state=dict(type='str', required=False, choices=['present', 'absent', 'info'], default='present'), # noqa: E501
|
||||||
password=dict(type='str', required=False, no_log=True),
|
password=dict(type='str', required=False, no_log=True),
|
||||||
roles=dict(type='list',
|
roles=dict(type='list',
|
||||||
required=False,
|
required=False,
|
||||||
choices=['administrator', 'read-only', 'block-manager', 'rgw-manager', 'cluster-manager', 'pool-manager', 'cephfs-manager'],
|
choices=['administrator', 'read-only', 'block-manager', 'rgw-manager', 'cluster-manager', 'pool-manager', 'cephfs-manager'], # noqa: E501
|
||||||
default=[]),
|
default=[]),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -232,33 +249,33 @@ def run_module():
|
||||||
container_image = is_containerized()
|
container_image = is_containerized()
|
||||||
|
|
||||||
if state == "present":
|
if state == "present":
|
||||||
rc, cmd, out, err = exec_command(module, get_user(module, container_image=container_image))
|
rc, cmd, out, err = exec_command(module, get_user(module, container_image=container_image)) # noqa: E501
|
||||||
if rc == 0:
|
if rc == 0:
|
||||||
user = json.loads(out)
|
user = json.loads(out)
|
||||||
user['roles'].sort()
|
user['roles'].sort()
|
||||||
roles.sort()
|
roles.sort()
|
||||||
if user['roles'] != roles:
|
if user['roles'] != roles:
|
||||||
rc, cmd, out, err = exec_command(module, set_roles(module, container_image=container_image))
|
rc, cmd, out, err = exec_command(module, set_roles(module, container_image=container_image)) # noqa: E501
|
||||||
changed = True
|
changed = True
|
||||||
rc, cmd, out, err = exec_command(module, set_password(module, container_image=container_image), stdin=password)
|
rc, cmd, out, err = exec_command(module, set_password(module, container_image=container_image), stdin=password) # noqa: E501
|
||||||
else:
|
else:
|
||||||
rc, cmd, out, err = exec_command(module, create_user(module, container_image=container_image), stdin=password)
|
rc, cmd, out, err = exec_command(module, create_user(module, container_image=container_image), stdin=password) # noqa: E501
|
||||||
rc, cmd, out, err = exec_command(module, set_roles(module, container_image=container_image))
|
rc, cmd, out, err = exec_command(module, set_roles(module, container_image=container_image)) # noqa: E501
|
||||||
changed = True
|
changed = True
|
||||||
|
|
||||||
elif state == "absent":
|
elif state == "absent":
|
||||||
rc, cmd, out, err = exec_command(module, get_user(module, container_image=container_image))
|
rc, cmd, out, err = exec_command(module, get_user(module, container_image=container_image)) # noqa: E501
|
||||||
if rc == 0:
|
if rc == 0:
|
||||||
rc, cmd, out, err = exec_command(module, remove_user(module, container_image=container_image))
|
rc, cmd, out, err = exec_command(module, remove_user(module, container_image=container_image)) # noqa: E501
|
||||||
changed = True
|
changed = True
|
||||||
else:
|
else:
|
||||||
rc = 0
|
rc = 0
|
||||||
out = "Dashboard User {} doesn't exist".format(name)
|
out = "Dashboard User {} doesn't exist".format(name)
|
||||||
|
|
||||||
elif state == "info":
|
elif state == "info":
|
||||||
rc, cmd, out, err = exec_command(module, get_user(module, container_image=container_image))
|
rc, cmd, out, err = exec_command(module, get_user(module, container_image=container_image)) # noqa: E501
|
||||||
|
|
||||||
exit_module(module=module, out=out, rc=rc, cmd=cmd, err=err, startd=startd, changed=changed)
|
exit_module(module=module, out=out, rc=rc, cmd=cmd, err=err, startd=startd, changed=changed) # noqa: E501
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
|
|
@ -121,7 +121,7 @@ def get_profile(module, name, cluster='ceph', container_image=None):
|
||||||
return cmd
|
return cmd
|
||||||
|
|
||||||
|
|
||||||
def create_profile(module, name, k, m, stripe_unit, cluster='ceph', force=False, container_image=None):
|
def create_profile(module, name, k, m, stripe_unit, cluster='ceph', force=False, container_image=None): # noqa: E501
|
||||||
'''
|
'''
|
||||||
Create a profile
|
Create a profile
|
||||||
'''
|
'''
|
||||||
|
@ -198,9 +198,10 @@ def run_module():
|
||||||
container_image = is_containerized()
|
container_image = is_containerized()
|
||||||
|
|
||||||
if state == "present":
|
if state == "present":
|
||||||
rc, cmd, out, err = exec_command(module, get_profile(module, name, cluster, container_image=container_image))
|
rc, cmd, out, err = exec_command(module, get_profile(module, name, cluster, container_image=container_image)) # noqa: E501
|
||||||
if rc == 0:
|
if rc == 0:
|
||||||
# the profile already exists, let's check whether we have to update it
|
# the profile already exists, let's check whether we have to
|
||||||
|
# update it
|
||||||
current_profile = json.loads(out)
|
current_profile = json.loads(out)
|
||||||
if current_profile['k'] != k or \
|
if current_profile['k'] != k or \
|
||||||
current_profile['m'] != m or \
|
current_profile['m'] != m or \
|
||||||
|
@ -212,7 +213,7 @@ def run_module():
|
||||||
m,
|
m,
|
||||||
stripe_unit,
|
stripe_unit,
|
||||||
cluster,
|
cluster,
|
||||||
force=True, container_image=container_image))
|
force=True, container_image=container_image)) # noqa: E501
|
||||||
changed = True
|
changed = True
|
||||||
else:
|
else:
|
||||||
# the profile doesn't exist, it has to be created
|
# the profile doesn't exist, it has to be created
|
||||||
|
@ -220,14 +221,14 @@ def run_module():
|
||||||
name,
|
name,
|
||||||
k,
|
k,
|
||||||
m,
|
m,
|
||||||
stripe_unit,
|
stripe_unit, # noqa: E501
|
||||||
cluster,
|
cluster,
|
||||||
container_image=container_image))
|
container_image=container_image)) # noqa: E501
|
||||||
if rc == 0:
|
if rc == 0:
|
||||||
changed = True
|
changed = True
|
||||||
|
|
||||||
elif state == "absent":
|
elif state == "absent":
|
||||||
rc, cmd, out, err = exec_command(module, delete_profile(module, name, cluster, container_image=container_image))
|
rc, cmd, out, err = exec_command(module, delete_profile(module, name, cluster, container_image=container_image)) # noqa: E501
|
||||||
if not err:
|
if not err:
|
||||||
out = 'Profile {} removed.'.format(name)
|
out = 'Profile {} removed.'.format(name)
|
||||||
changed = True
|
changed = True
|
||||||
|
@ -235,7 +236,7 @@ def run_module():
|
||||||
rc = 0
|
rc = 0
|
||||||
out = "Skipping, the profile {} doesn't exist".format(name)
|
out = "Skipping, the profile {} doesn't exist".format(name)
|
||||||
|
|
||||||
exit_module(module=module, out=out, rc=rc, cmd=cmd, err=err, startd=startd, changed=changed)
|
exit_module(module=module, out=out, rc=rc, cmd=cmd, err=err, startd=startd, changed=changed) # noqa: E501
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
|
|
@ -119,7 +119,10 @@ def create_fs(module, container_image=None):
|
||||||
|
|
||||||
args = ['new', name, metadata, data]
|
args = ['new', name, metadata, data]
|
||||||
|
|
||||||
cmd = generate_ceph_cmd(sub_cmd=['fs'], args=args, cluster=cluster, container_image=container_image)
|
cmd = generate_ceph_cmd(sub_cmd=['fs'],
|
||||||
|
args=args,
|
||||||
|
cluster=cluster,
|
||||||
|
container_image=container_image)
|
||||||
|
|
||||||
return cmd
|
return cmd
|
||||||
|
|
||||||
|
@ -134,7 +137,10 @@ def get_fs(module, container_image=None):
|
||||||
|
|
||||||
args = ['get', name, '--format=json']
|
args = ['get', name, '--format=json']
|
||||||
|
|
||||||
cmd = generate_ceph_cmd(sub_cmd=['fs'], args=args, cluster=cluster, container_image=container_image)
|
cmd = generate_ceph_cmd(sub_cmd=['fs'],
|
||||||
|
args=args,
|
||||||
|
cluster=cluster,
|
||||||
|
container_image=container_image)
|
||||||
|
|
||||||
return cmd
|
return cmd
|
||||||
|
|
||||||
|
@ -149,7 +155,10 @@ def remove_fs(module, container_image=None):
|
||||||
|
|
||||||
args = ['rm', name, '--yes-i-really-mean-it']
|
args = ['rm', name, '--yes-i-really-mean-it']
|
||||||
|
|
||||||
cmd = generate_ceph_cmd(sub_cmd=['fs'], args=args, cluster=cluster, container_image=container_image)
|
cmd = generate_ceph_cmd(sub_cmd=['fs'],
|
||||||
|
args=args,
|
||||||
|
cluster=cluster,
|
||||||
|
container_image=container_image)
|
||||||
|
|
||||||
return cmd
|
return cmd
|
||||||
|
|
||||||
|
@ -164,7 +173,10 @@ def fail_fs(module, container_image=None):
|
||||||
|
|
||||||
args = ['fail', name]
|
args = ['fail', name]
|
||||||
|
|
||||||
cmd = generate_ceph_cmd(sub_cmd=['fs'], args=args, cluster=cluster, container_image=container_image)
|
cmd = generate_ceph_cmd(sub_cmd=['fs'],
|
||||||
|
args=args,
|
||||||
|
cluster=cluster,
|
||||||
|
container_image=container_image)
|
||||||
|
|
||||||
return cmd
|
return cmd
|
||||||
|
|
||||||
|
@ -180,7 +192,10 @@ def set_fs(module, container_image=None):
|
||||||
|
|
||||||
args = ['set', name, 'max_mds', str(max_mds)]
|
args = ['set', name, 'max_mds', str(max_mds)]
|
||||||
|
|
||||||
cmd = generate_ceph_cmd(sub_cmd=['fs'], args=args, cluster=cluster, container_image=container_image)
|
cmd = generate_ceph_cmd(sub_cmd=['fs'],
|
||||||
|
args=args,
|
||||||
|
cluster=cluster,
|
||||||
|
container_image=container_image)
|
||||||
|
|
||||||
return cmd
|
return cmd
|
||||||
|
|
||||||
|
@ -189,7 +204,7 @@ def run_module():
|
||||||
module_args = dict(
|
module_args = dict(
|
||||||
cluster=dict(type='str', required=False, default='ceph'),
|
cluster=dict(type='str', required=False, default='ceph'),
|
||||||
name=dict(type='str', required=True),
|
name=dict(type='str', required=True),
|
||||||
state=dict(type='str', required=False, choices=['present', 'absent', 'info'], default='present'),
|
state=dict(type='str', required=False, choices=['present', 'absent', 'info'], default='present'), # noqa: E501
|
||||||
data=dict(type='str', required=False),
|
data=dict(type='str', required=False),
|
||||||
metadata=dict(type='str', required=False),
|
metadata=dict(type='str', required=False),
|
||||||
max_mds=dict(type='int', required=False),
|
max_mds=dict(type='int', required=False),
|
||||||
|
@ -224,25 +239,25 @@ def run_module():
|
||||||
container_image = is_containerized()
|
container_image = is_containerized()
|
||||||
|
|
||||||
if state == "present":
|
if state == "present":
|
||||||
rc, cmd, out, err = exec_command(module, get_fs(module, container_image=container_image))
|
rc, cmd, out, err = exec_command(module, get_fs(module, container_image=container_image)) # noqa: E501
|
||||||
if rc == 0:
|
if rc == 0:
|
||||||
fs = json.loads(out)
|
fs = json.loads(out)
|
||||||
if max_mds and fs["mdsmap"]["max_mds"] != max_mds:
|
if max_mds and fs["mdsmap"]["max_mds"] != max_mds:
|
||||||
rc, cmd, out, err = exec_command(module, set_fs(module, container_image=container_image))
|
rc, cmd, out, err = exec_command(module, set_fs(module, container_image=container_image)) # noqa: E501
|
||||||
if rc == 0:
|
if rc == 0:
|
||||||
changed = True
|
changed = True
|
||||||
else:
|
else:
|
||||||
rc, cmd, out, err = exec_command(module, create_fs(module, container_image=container_image))
|
rc, cmd, out, err = exec_command(module, create_fs(module, container_image=container_image)) # noqa: E501
|
||||||
if max_mds and max_mds > 1:
|
if max_mds and max_mds > 1:
|
||||||
exec_command(module, set_fs(module, container_image=container_image))
|
exec_command(module, set_fs(module, container_image=container_image)) # noqa: E501
|
||||||
if rc == 0:
|
if rc == 0:
|
||||||
changed = True
|
changed = True
|
||||||
|
|
||||||
elif state == "absent":
|
elif state == "absent":
|
||||||
rc, cmd, out, err = exec_command(module, get_fs(module, container_image=container_image))
|
rc, cmd, out, err = exec_command(module, get_fs(module, container_image=container_image)) # noqa: E501
|
||||||
if rc == 0:
|
if rc == 0:
|
||||||
exec_command(module, fail_fs(module, container_image=container_image))
|
exec_command(module, fail_fs(module, container_image=container_image)) # noqa: E501
|
||||||
rc, cmd, out, err = exec_command(module, remove_fs(module, container_image=container_image))
|
rc, cmd, out, err = exec_command(module, remove_fs(module, container_image=container_image)) # noqa: E501
|
||||||
if rc == 0:
|
if rc == 0:
|
||||||
changed = True
|
changed = True
|
||||||
else:
|
else:
|
||||||
|
@ -250,9 +265,9 @@ def run_module():
|
||||||
out = "Ceph File System {} doesn't exist".format(name)
|
out = "Ceph File System {} doesn't exist".format(name)
|
||||||
|
|
||||||
elif state == "info":
|
elif state == "info":
|
||||||
rc, cmd, out, err = exec_command(module, get_fs(module, container_image=container_image))
|
rc, cmd, out, err = exec_command(module, get_fs(module, container_image=container_image)) # noqa: E501
|
||||||
|
|
||||||
exit_module(module=module, out=out, rc=rc, cmd=cmd, err=err, startd=startd, changed=changed)
|
exit_module(module=module, out=out, rc=rc, cmd=cmd, err=err, startd=startd, changed=changed) # noqa: E501
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
|
|
@ -119,7 +119,7 @@ options:
|
||||||
description:
|
description:
|
||||||
- Fetch client.admin and bootstrap key.
|
- Fetch client.admin and bootstrap key.
|
||||||
This is only needed for Nautilus and above.
|
This is only needed for Nautilus and above.
|
||||||
Writes down to the filesystem the initial keys generated by the monitor. # noqa E501
|
Writes down to the filesystem the initial keys generated by the monitor. # noqa: E501
|
||||||
This command can ONLY run from a monitor node.
|
This command can ONLY run from a monitor node.
|
||||||
required: false
|
required: false
|
||||||
default: false
|
default: false
|
||||||
|
@ -134,8 +134,8 @@ options:
|
||||||
EXAMPLES = '''
|
EXAMPLES = '''
|
||||||
|
|
||||||
keys_to_create:
|
keys_to_create:
|
||||||
- { name: client.key, key: "AQAin8tUUK84ExAA/QgBtI7gEMWdmnvKBzlXdQ==", caps: { mon: "allow rwx", mds: "allow *" } , mode: "0600" } # noqa e501
|
- { name: client.key, key: "AQAin8tUUK84ExAA/QgBtI7gEMWdmnvKBzlXdQ==", caps: { mon: "allow rwx", mds: "allow *" } , mode: "0600" } # noqa: E501
|
||||||
- { name: client.cle, caps: { mon: "allow r", osd: "allow *" } , mode: "0600" } # noqa e501
|
- { name: client.cle, caps: { mon: "allow r", osd: "allow *" } , mode: "0600" } # noqa: E501
|
||||||
|
|
||||||
caps:
|
caps:
|
||||||
mon: "allow rwx"
|
mon: "allow rwx"
|
||||||
|
@ -208,8 +208,8 @@ caps:
|
||||||
RETURN = '''# '''
|
RETURN = '''# '''
|
||||||
|
|
||||||
|
|
||||||
CEPH_INITIAL_KEYS = ['client.admin', 'client.bootstrap-mds', 'client.bootstrap-mgr', # noqa E501
|
CEPH_INITIAL_KEYS = ['client.admin', 'client.bootstrap-mds', 'client.bootstrap-mgr', # noqa: E501
|
||||||
'client.bootstrap-osd', 'client.bootstrap-rbd', 'client.bootstrap-rbd-mirror', 'client.bootstrap-rgw'] # noqa E501
|
'client.bootstrap-osd', 'client.bootstrap-rbd', 'client.bootstrap-rbd-mirror', 'client.bootstrap-rgw'] # noqa: E501
|
||||||
|
|
||||||
|
|
||||||
def str_to_bool(val):
|
def str_to_bool(val):
|
||||||
|
@ -256,7 +256,7 @@ def generate_caps(_type, caps):
|
||||||
return caps_cli
|
return caps_cli
|
||||||
|
|
||||||
|
|
||||||
def generate_ceph_authtool_cmd(cluster, name, secret, caps, dest, container_image=None): # noqa E501
|
def generate_ceph_authtool_cmd(cluster, name, secret, caps, dest, container_image=None): # noqa: E501
|
||||||
'''
|
'''
|
||||||
Generate 'ceph-authtool' command line to execute
|
Generate 'ceph-authtool' command line to execute
|
||||||
'''
|
'''
|
||||||
|
@ -284,7 +284,7 @@ def generate_ceph_authtool_cmd(cluster, name, secret, caps, dest, container_imag
|
||||||
return cmd
|
return cmd
|
||||||
|
|
||||||
|
|
||||||
def create_key(module, result, cluster, user, user_key, name, secret, caps, import_key, dest, container_image=None): # noqa E501
|
def create_key(module, result, cluster, user, user_key, name, secret, caps, import_key, dest, container_image=None): # noqa: E501
|
||||||
'''
|
'''
|
||||||
Create a CephX key
|
Create a CephX key
|
||||||
'''
|
'''
|
||||||
|
@ -360,7 +360,7 @@ def get_key(cluster, user, user_key, name, dest, container_image=None):
|
||||||
return cmd_list
|
return cmd_list
|
||||||
|
|
||||||
|
|
||||||
def info_key(cluster, name, user, user_key, output_format, container_image=None): # noqa E501
|
def info_key(cluster, name, user, user_key, output_format, container_image=None): # noqa: E501
|
||||||
'''
|
'''
|
||||||
Get information about a CephX key
|
Get information about a CephX key
|
||||||
'''
|
'''
|
||||||
|
@ -429,7 +429,7 @@ def lookup_ceph_initial_entities(module, out):
|
||||||
try:
|
try:
|
||||||
out_dict = json.loads(out)
|
out_dict = json.loads(out)
|
||||||
except ValueError as e:
|
except ValueError as e:
|
||||||
fatal("Could not decode 'ceph auth list' json output: {}".format(e), module) # noqa E501
|
fatal("Could not decode 'ceph auth list' json output: {}".format(e), module) # noqa: E501
|
||||||
|
|
||||||
entities = []
|
entities = []
|
||||||
if "auth_dump" in out_dict:
|
if "auth_dump" in out_dict:
|
||||||
|
@ -439,16 +439,16 @@ def lookup_ceph_initial_entities(module, out):
|
||||||
if v in CEPH_INITIAL_KEYS:
|
if v in CEPH_INITIAL_KEYS:
|
||||||
entities.append(v)
|
entities.append(v)
|
||||||
else:
|
else:
|
||||||
fatal("'auth_dump' key not present in json output:", module) # noqa E501
|
fatal("'auth_dump' key not present in json output:", module) # noqa: E501
|
||||||
|
|
||||||
if len(entities) != len(CEPH_INITIAL_KEYS) and not str_to_bool(os.environ.get('CEPH_ROLLING_UPDATE', False)): # noqa E501
|
if len(entities) != len(CEPH_INITIAL_KEYS) and not str_to_bool(os.environ.get('CEPH_ROLLING_UPDATE', False)): # noqa: E501
|
||||||
# must be missing in auth_dump, as if it were in CEPH_INITIAL_KEYS
|
# must be missing in auth_dump, as if it were in CEPH_INITIAL_KEYS
|
||||||
# it'd be in entities from the above test. Report what's missing.
|
# it'd be in entities from the above test. Report what's missing.
|
||||||
missing = []
|
missing = []
|
||||||
for e in CEPH_INITIAL_KEYS:
|
for e in CEPH_INITIAL_KEYS:
|
||||||
if e not in entities:
|
if e not in entities:
|
||||||
missing.append(e)
|
missing.append(e)
|
||||||
fatal("initial keyring does not contain keys: " + ' '.join(missing), module) # noqa E501
|
fatal("initial keyring does not contain keys: " + ' '.join(missing), module) # noqa: E501
|
||||||
return entities
|
return entities
|
||||||
|
|
||||||
|
|
||||||
|
@ -479,15 +479,15 @@ def run_module():
|
||||||
module_args = dict(
|
module_args = dict(
|
||||||
cluster=dict(type='str', required=False, default='ceph'),
|
cluster=dict(type='str', required=False, default='ceph'),
|
||||||
name=dict(type='str', required=False),
|
name=dict(type='str', required=False),
|
||||||
state=dict(type='str', required=False, default='present', choices=['present', 'update', 'absent', # noqa E501
|
state=dict(type='str', required=False, default='present', choices=['present', 'update', 'absent', # noqa: E501
|
||||||
'list', 'info', 'fetch_initial_keys', 'generate_secret']), # noqa E501
|
'list', 'info', 'fetch_initial_keys', 'generate_secret']), # noqa: E501
|
||||||
caps=dict(type='dict', required=False, default=None),
|
caps=dict(type='dict', required=False, default=None),
|
||||||
secret=dict(type='str', required=False, default=None, no_log=True),
|
secret=dict(type='str', required=False, default=None, no_log=True),
|
||||||
import_key=dict(type='bool', required=False, default=True),
|
import_key=dict(type='bool', required=False, default=True),
|
||||||
dest=dict(type='str', required=False, default='/etc/ceph/'),
|
dest=dict(type='str', required=False, default='/etc/ceph/'),
|
||||||
user=dict(type='str', required=False, default='client.admin'),
|
user=dict(type='str', required=False, default='client.admin'),
|
||||||
user_key=dict(type='str', required=False, default=None),
|
user_key=dict(type='str', required=False, default=None),
|
||||||
output_format=dict(type='str', required=False, default='json', choices=['json', 'plain', 'xml', 'yaml']) # noqa E501
|
output_format=dict(type='str', required=False, default='json', choices=['json', 'plain', 'xml', 'yaml']) # noqa: E501
|
||||||
)
|
)
|
||||||
|
|
||||||
module = AnsibleModule(
|
module = AnsibleModule(
|
||||||
|
@ -563,12 +563,12 @@ def run_module():
|
||||||
if import_key:
|
if import_key:
|
||||||
_info_key = []
|
_info_key = []
|
||||||
rc, cmd, out, err = exec_commands(
|
rc, cmd, out, err = exec_commands(
|
||||||
module, info_key(cluster, name, user, user_key_path, output_format, container_image)) # noqa E501
|
module, info_key(cluster, name, user, user_key_path, output_format, container_image)) # noqa: E501
|
||||||
key_exist = rc
|
key_exist = rc
|
||||||
if not caps and key_exist != 0:
|
if not caps and key_exist != 0:
|
||||||
fatal("Capabilities must be provided when state is 'present'", module) # noqa E501
|
fatal("Capabilities must be provided when state is 'present'", module) # noqa: E501
|
||||||
if key_exist != 0 and secret is None and caps is None:
|
if key_exist != 0 and secret is None and caps is None:
|
||||||
fatal("Keyring doesn't exist, you must provide 'secret' and 'caps'", module) # noqa E501
|
fatal("Keyring doesn't exist, you must provide 'secret' and 'caps'", module) # noqa: E501
|
||||||
if key_exist == 0:
|
if key_exist == 0:
|
||||||
_info_key = json.loads(out)
|
_info_key = json.loads(out)
|
||||||
if not secret:
|
if not secret:
|
||||||
|
@ -579,25 +579,25 @@ def run_module():
|
||||||
_caps = _info_key[0]['caps']
|
_caps = _info_key[0]['caps']
|
||||||
if secret == _secret and caps == _caps:
|
if secret == _secret and caps == _caps:
|
||||||
if not os.path.isfile(file_path):
|
if not os.path.isfile(file_path):
|
||||||
rc, cmd, out, err = exec_commands(module, get_key(cluster, user, user_key_path, name, file_path, container_image)) # noqa E501
|
rc, cmd, out, err = exec_commands(module, get_key(cluster, user, user_key_path, name, file_path, container_image)) # noqa: E501
|
||||||
result["rc"] = rc
|
result["rc"] = rc
|
||||||
if rc != 0:
|
if rc != 0:
|
||||||
result["stdout"] = "Couldn't fetch the key {0} at {1}.".format(name, file_path) # noqa E501
|
result["stdout"] = "Couldn't fetch the key {0} at {1}.".format(name, file_path) # noqa: E501
|
||||||
module.exit_json(**result)
|
module.exit_json(**result)
|
||||||
result["stdout"] = "fetched the key {0} at {1}.".format(name, file_path) # noqa E501
|
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["stdout"] = "{0} already exists and doesn't need to be updated.".format(name) # noqa: E501
|
||||||
result["rc"] = 0
|
result["rc"] = 0
|
||||||
module.set_fs_attributes_if_different(file_args, False)
|
module.set_fs_attributes_if_different(file_args, False)
|
||||||
module.exit_json(**result)
|
module.exit_json(**result)
|
||||||
else:
|
else:
|
||||||
if os.path.isfile(file_path) and not secret or not caps:
|
if os.path.isfile(file_path) and not secret or not caps:
|
||||||
result["stdout"] = "{0} already exists in {1} you must provide secret *and* caps when import_key is {2}".format(name, dest, import_key) # noqa E501
|
result["stdout"] = "{0} already exists in {1} you must provide secret *and* caps when import_key is {2}".format(name, dest, import_key) # noqa: E501
|
||||||
result["rc"] = 0
|
result["rc"] = 0
|
||||||
module.exit_json(**result)
|
module.exit_json(**result)
|
||||||
if (key_exist == 0 and (secret != _secret or caps != _caps)) or key_exist != 0: # noqa E501
|
if (key_exist == 0 and (secret != _secret or caps != _caps)) or key_exist != 0: # noqa: E501
|
||||||
rc, cmd, out, err = exec_commands(module, create_key(
|
rc, cmd, out, err = exec_commands(module, create_key(
|
||||||
module, result, cluster, user, user_key_path, name, secret, caps, import_key, file_path, container_image)) # noqa E501
|
module, result, cluster, user, user_key_path, name, secret, caps, import_key, file_path, container_image)) # noqa: E501
|
||||||
if rc != 0:
|
if rc != 0:
|
||||||
result["stdout"] = "Couldn't create or update {0}".format(name)
|
result["stdout"] = "Couldn't create or update {0}".format(name)
|
||||||
result["stderr"] = err
|
result["stderr"] = err
|
||||||
|
@ -608,7 +608,7 @@ def run_module():
|
||||||
elif state == "absent":
|
elif state == "absent":
|
||||||
if key_exist == 0:
|
if key_exist == 0:
|
||||||
rc, cmd, out, err = exec_commands(
|
rc, cmd, out, err = exec_commands(
|
||||||
module, delete_key(cluster, user, user_key_path, name, container_image)) # noqa E501
|
module, delete_key(cluster, user, user_key_path, name, container_image)) # noqa: E501
|
||||||
if rc == 0:
|
if rc == 0:
|
||||||
changed = True
|
changed = True
|
||||||
else:
|
else:
|
||||||
|
@ -616,7 +616,7 @@ def run_module():
|
||||||
|
|
||||||
elif state == "info":
|
elif state == "info":
|
||||||
rc, cmd, out, err = exec_commands(
|
rc, cmd, out, err = exec_commands(
|
||||||
module, info_key(cluster, name, user, user_key_path, output_format, container_image)) # noqa E501
|
module, info_key(cluster, name, user, user_key_path, output_format, container_image)) # noqa: E501
|
||||||
|
|
||||||
elif state == "list":
|
elif state == "list":
|
||||||
rc, cmd, out, err = exec_commands(
|
rc, cmd, out, err = exec_commands(
|
||||||
|
@ -657,7 +657,7 @@ def run_module():
|
||||||
# we use info_cmd[0] because info_cmd is an array made of an array
|
# we use info_cmd[0] because info_cmd is an array made of an array
|
||||||
info_cmd[0].extend(extra_args)
|
info_cmd[0].extend(extra_args)
|
||||||
rc, cmd, out, err = exec_commands(
|
rc, cmd, out, err = exec_commands(
|
||||||
module, info_cmd) # noqa E501
|
module, info_cmd) # noqa: E501
|
||||||
|
|
||||||
file_args = module.load_file_common_arguments(module.params)
|
file_args = module.load_file_common_arguments(module.params)
|
||||||
file_args['path'] = key_path
|
file_args['path'] = key_path
|
||||||
|
|
|
@ -17,9 +17,13 @@ __metaclass__ = type
|
||||||
|
|
||||||
from ansible.module_utils.basic import AnsibleModule
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
try:
|
try:
|
||||||
from ansible.module_utils.ca_common import exit_module, generate_ceph_cmd, is_containerized
|
from ansible.module_utils.ca_common import exit_module, \
|
||||||
|
generate_ceph_cmd, \
|
||||||
|
is_containerized
|
||||||
except ImportError:
|
except ImportError:
|
||||||
from module_utils.ca_common import exit_module, generate_ceph_cmd, is_containerized
|
from module_utils.ca_common import exit_module, \
|
||||||
|
generate_ceph_cmd, \
|
||||||
|
is_containerized
|
||||||
import datetime
|
import datetime
|
||||||
|
|
||||||
|
|
||||||
|
@ -80,7 +84,7 @@ def main():
|
||||||
argument_spec=dict(
|
argument_spec=dict(
|
||||||
name=dict(type='str', required=True),
|
name=dict(type='str', required=True),
|
||||||
cluster=dict(type='str', required=False, default='ceph'),
|
cluster=dict(type='str', required=False, default='ceph'),
|
||||||
state=dict(type='str', required=False, default='enable', choices=['enable', 'disable']),
|
state=dict(type='str', required=False, default='enable', choices=['enable', 'disable']), # noqa: E501
|
||||||
),
|
),
|
||||||
supports_check_mode=True,
|
supports_check_mode=True,
|
||||||
)
|
)
|
||||||
|
@ -93,7 +97,10 @@ def main():
|
||||||
|
|
||||||
container_image = is_containerized()
|
container_image = is_containerized()
|
||||||
|
|
||||||
cmd = generate_ceph_cmd(['mgr', 'module'], [state, name], cluster=cluster, container_image=container_image)
|
cmd = generate_ceph_cmd(['mgr', 'module'],
|
||||||
|
[state, name],
|
||||||
|
cluster=cluster,
|
||||||
|
container_image=container_image)
|
||||||
|
|
||||||
if module.check_mode:
|
if module.check_mode:
|
||||||
exit_module(
|
exit_module(
|
||||||
|
|
|
@ -17,9 +17,9 @@ __metaclass__ = type
|
||||||
|
|
||||||
from ansible.module_utils.basic import AnsibleModule
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
try:
|
try:
|
||||||
from ansible.module_utils.ca_common import exit_module, generate_ceph_cmd, is_containerized
|
from ansible.module_utils.ca_common import exit_module, generate_ceph_cmd, is_containerized # noqa: E501
|
||||||
except ImportError:
|
except ImportError:
|
||||||
from module_utils.ca_common import exit_module, generate_ceph_cmd, is_containerized
|
from module_utils.ca_common import exit_module, generate_ceph_cmd, is_containerized # noqa: E501
|
||||||
import datetime
|
import datetime
|
||||||
|
|
||||||
|
|
||||||
|
@ -95,7 +95,7 @@ def main():
|
||||||
argument_spec=dict(
|
argument_spec=dict(
|
||||||
ids=dict(type='list', required=True),
|
ids=dict(type='list', required=True),
|
||||||
cluster=dict(type='str', required=False, default='ceph'),
|
cluster=dict(type='str', required=False, default='ceph'),
|
||||||
state=dict(type='str', required=True, choices=['destroy', 'down', 'in', 'out', 'purge', 'rm']),
|
state=dict(type='str', required=True, choices=['destroy', 'down', 'in', 'out', 'purge', 'rm']), # noqa: E501
|
||||||
),
|
),
|
||||||
supports_check_mode=True,
|
supports_check_mode=True,
|
||||||
)
|
)
|
||||||
|
@ -105,13 +105,13 @@ def main():
|
||||||
state = module.params.get('state')
|
state = module.params.get('state')
|
||||||
|
|
||||||
if state in ['destroy', 'purge'] and len(ids) > 1:
|
if state in ['destroy', 'purge'] and len(ids) > 1:
|
||||||
module.fail_json(msg='destroy and purge only support one OSD at at time', rc=1)
|
module.fail_json(msg='destroy and purge only support one OSD at at time', rc=1) # noqa: E501
|
||||||
|
|
||||||
startd = datetime.datetime.now()
|
startd = datetime.datetime.now()
|
||||||
|
|
||||||
container_image = is_containerized()
|
container_image = is_containerized()
|
||||||
|
|
||||||
cmd = generate_ceph_cmd(['osd', state], ids, cluster=cluster, container_image=container_image)
|
cmd = generate_ceph_cmd(['osd', state], ids, cluster=cluster, container_image=container_image) # noqa: E501
|
||||||
|
|
||||||
if state in ['destroy', 'purge']:
|
if state in ['destroy', 'purge']:
|
||||||
cmd.append('--yes-i-really-mean-it')
|
cmd.append('--yes-i-really-mean-it')
|
||||||
|
|
|
@ -17,9 +17,13 @@ __metaclass__ = type
|
||||||
|
|
||||||
from ansible.module_utils.basic import AnsibleModule
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
try:
|
try:
|
||||||
from ansible.module_utils.ca_common import exit_module, generate_ceph_cmd, is_containerized
|
from ansible.module_utils.ca_common import exit_module, \
|
||||||
|
generate_ceph_cmd, \
|
||||||
|
is_containerized
|
||||||
except ImportError:
|
except ImportError:
|
||||||
from module_utils.ca_common import exit_module, generate_ceph_cmd, is_containerized
|
from module_utils.ca_common import exit_module, \
|
||||||
|
generate_ceph_cmd, \
|
||||||
|
is_containerized
|
||||||
import datetime
|
import datetime
|
||||||
|
|
||||||
|
|
||||||
|
@ -41,7 +45,8 @@ options:
|
||||||
description:
|
description:
|
||||||
- name of the ceph OSD flag.
|
- name of the ceph OSD flag.
|
||||||
required: true
|
required: true
|
||||||
choices: ['noup', 'nodown', 'noout', 'nobackfill', 'norebalance', 'norecover', 'noscrub', 'nodeep-scrub']
|
choices: ['noup', 'nodown', 'noout', 'nobackfill', 'norebalance',
|
||||||
|
'norecover', 'noscrub', 'nodeep-scrub']
|
||||||
cluster:
|
cluster:
|
||||||
description:
|
description:
|
||||||
- The ceph cluster name.
|
- The ceph cluster name.
|
||||||
|
@ -78,9 +83,9 @@ RETURN = '''# '''
|
||||||
def main():
|
def main():
|
||||||
module = AnsibleModule(
|
module = AnsibleModule(
|
||||||
argument_spec=dict(
|
argument_spec=dict(
|
||||||
name=dict(type='str', required=True, choices=['noup', 'nodown', 'noout', 'nobackfill', 'norebalance', 'norecover', 'noscrub', 'nodeep-scrub']),
|
name=dict(type='str', required=True, choices=['noup', 'nodown', 'noout', 'nobackfill', 'norebalance', 'norecover', 'noscrub', 'nodeep-scrub']), # noqa: E501
|
||||||
cluster=dict(type='str', required=False, default='ceph'),
|
cluster=dict(type='str', required=False, default='ceph'),
|
||||||
state=dict(type='str', required=False, default='present', choices=['present', 'absent']),
|
state=dict(type='str', required=False, default='present', choices=['present', 'absent']), # noqa: E501
|
||||||
),
|
),
|
||||||
supports_check_mode=True,
|
supports_check_mode=True,
|
||||||
)
|
)
|
||||||
|
@ -94,9 +99,9 @@ def main():
|
||||||
container_image = is_containerized()
|
container_image = is_containerized()
|
||||||
|
|
||||||
if state == 'present':
|
if state == 'present':
|
||||||
cmd = generate_ceph_cmd(['osd', 'set'], [name], cluster=cluster, container_image=container_image)
|
cmd = generate_ceph_cmd(['osd', 'set'], [name], cluster=cluster, container_image=container_image) # noqa: E501
|
||||||
else:
|
else:
|
||||||
cmd = generate_ceph_cmd(['osd', 'unset'], [name], cluster=cluster, container_image=container_image)
|
cmd = generate_ceph_cmd(['osd', 'unset'], [name], cluster=cluster, container_image=container_image) # noqa: E501
|
||||||
|
|
||||||
if module.check_mode:
|
if module.check_mode:
|
||||||
exit_module(
|
exit_module(
|
||||||
|
|
|
@ -298,7 +298,8 @@ def get_pool_details(module,
|
||||||
user_key, # noqa: E501
|
user_key, # noqa: E501
|
||||||
container_image=container_image)) # noqa: E501
|
container_image=container_image)) # noqa: E501
|
||||||
|
|
||||||
# This is a trick because "target_size_ratio" isn't present at the same level in the dict
|
# This is a trick because "target_size_ratio" isn't present at the same
|
||||||
|
# level in the dict
|
||||||
# ie:
|
# ie:
|
||||||
# {
|
# {
|
||||||
# 'pg_num': 8,
|
# 'pg_num': 8,
|
||||||
|
@ -308,8 +309,8 @@ def get_pool_details(module,
|
||||||
# 'target_size_ratio': 0.1
|
# 'target_size_ratio': 0.1
|
||||||
# }
|
# }
|
||||||
# }
|
# }
|
||||||
# If 'target_size_ratio' is present in 'options', we set it, this way we end up
|
# If 'target_size_ratio' is present in 'options', we set it, this way we
|
||||||
# with a dict containing all needed keys at the same level.
|
# end up with a dict containing all needed keys at the same level.
|
||||||
if 'target_size_ratio' in out['options'].keys():
|
if 'target_size_ratio' in out['options'].keys():
|
||||||
out['target_size_ratio'] = out['options']['target_size_ratio']
|
out['target_size_ratio'] = out['options']['target_size_ratio']
|
||||||
else:
|
else:
|
||||||
|
@ -334,7 +335,7 @@ def compare_pool_config(user_pool_config, running_pool_details):
|
||||||
filter_keys = ['pg_num', 'pg_placement_num', 'size',
|
filter_keys = ['pg_num', 'pg_placement_num', 'size',
|
||||||
'pg_autoscale_mode', 'target_size_ratio']
|
'pg_autoscale_mode', 'target_size_ratio']
|
||||||
for key in filter_keys:
|
for key in filter_keys:
|
||||||
if (str(running_pool_details[key]) != user_pool_config[key]['value'] and
|
if (str(running_pool_details[key]) != user_pool_config[key]['value'] and # noqa: E501
|
||||||
user_pool_config[key]['value']):
|
user_pool_config[key]['value']):
|
||||||
delta[key] = user_pool_config[key]
|
delta[key] = user_pool_config[key]
|
||||||
|
|
||||||
|
|
|
@ -2,9 +2,13 @@
|
||||||
|
|
||||||
from ansible.module_utils.basic import AnsibleModule
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
try:
|
try:
|
||||||
from ansible.module_utils.ca_common import exec_command, is_containerized, fatal
|
from ansible.module_utils.ca_common import exec_command, \
|
||||||
|
is_containerized, \
|
||||||
|
fatal
|
||||||
except ImportError:
|
except ImportError:
|
||||||
from module_utils.ca_common import exec_command, is_containerized, fatal
|
from module_utils.ca_common import exec_command, \
|
||||||
|
is_containerized, \
|
||||||
|
fatal
|
||||||
import datetime
|
import datetime
|
||||||
import copy
|
import copy
|
||||||
import json
|
import json
|
||||||
|
@ -75,7 +79,7 @@ options:
|
||||||
required: false
|
required: false
|
||||||
db_vg:
|
db_vg:
|
||||||
description:
|
description:
|
||||||
- If db is a lv, this must be the name of the volume group it belongs to. # noqa E501
|
- If db is a lv, this must be the name of the volume group it belongs to. # noqa: E501
|
||||||
- Only applicable if objectstore is 'bluestore'.
|
- Only applicable if objectstore is 'bluestore'.
|
||||||
required: false
|
required: false
|
||||||
wal:
|
wal:
|
||||||
|
@ -85,7 +89,7 @@ options:
|
||||||
required: false
|
required: false
|
||||||
wal_vg:
|
wal_vg:
|
||||||
description:
|
description:
|
||||||
- If wal is a lv, this must be the name of the volume group it belongs to. # noqa E501
|
- If wal is a lv, this must be the name of the volume group it belongs to. # noqa: E501
|
||||||
- Only applicable if objectstore is 'bluestore'.
|
- Only applicable if objectstore is 'bluestore'.
|
||||||
required: false
|
required: false
|
||||||
crush_device_class:
|
crush_device_class:
|
||||||
|
@ -175,7 +179,7 @@ EXAMPLES = '''
|
||||||
action: create
|
action: create
|
||||||
|
|
||||||
|
|
||||||
- name: set up a bluestore osd with an lv for data and partitions for block.wal and block.db # noqa e501
|
- name: set up a bluestore osd with an lv for data and partitions for block.wal and block.db # noqa: E501
|
||||||
ceph_volume:
|
ceph_volume:
|
||||||
objectstore: bluestore
|
objectstore: bluestore
|
||||||
data: data-lv
|
data: data-lv
|
||||||
|
@ -271,7 +275,7 @@ def batch(module, container_image, report=None):
|
||||||
fatal('osds_per_device must be provided if action is "batch"', module)
|
fatal('osds_per_device must be provided if action is "batch"', module)
|
||||||
|
|
||||||
if osds_per_device < 1:
|
if osds_per_device < 1:
|
||||||
fatal('osds_per_device must be greater than 0 if action is "batch"', module) # noqa E501
|
fatal('osds_per_device must be greater than 0 if action is "batch"', module) # noqa: E501
|
||||||
|
|
||||||
if not batch_devices:
|
if not batch_devices:
|
||||||
fatal('batch_devices must be provided if action is "batch"', module)
|
fatal('batch_devices must be provided if action is "batch"', module)
|
||||||
|
@ -440,7 +444,7 @@ def is_lv(module, vg, lv, container_image):
|
||||||
Check if an LV exists
|
Check if an LV exists
|
||||||
'''
|
'''
|
||||||
|
|
||||||
args = ['--noheadings', '--reportformat', 'json', '--select', 'lv_name={},vg_name={}'.format(lv, vg)] # noqa E501
|
args = ['--noheadings', '--reportformat', 'json', '--select', 'lv_name={},vg_name={}'.format(lv, vg)] # noqa: E501
|
||||||
|
|
||||||
cmd = build_cmd(args, container_image, binary='lvs')
|
cmd = build_cmd(args, container_image, binary='lvs')
|
||||||
|
|
||||||
|
@ -509,7 +513,7 @@ def run_module():
|
||||||
'bluestore', 'filestore'], default='bluestore'),
|
'bluestore', 'filestore'], default='bluestore'),
|
||||||
action=dict(type='str', required=False, choices=[
|
action=dict(type='str', required=False, choices=[
|
||||||
'create', 'zap', 'batch', 'prepare', 'activate', 'list',
|
'create', 'zap', 'batch', 'prepare', 'activate', 'list',
|
||||||
'inventory'], default='create'), # noqa 4502
|
'inventory'], default='create'), # noqa: 4502
|
||||||
data=dict(type='str', required=False),
|
data=dict(type='str', required=False),
|
||||||
data_vg=dict(type='str', required=False),
|
data_vg=dict(type='str', required=False),
|
||||||
journal=dict(type='str', required=False),
|
journal=dict(type='str', required=False),
|
||||||
|
@ -577,11 +581,11 @@ def run_module():
|
||||||
try:
|
try:
|
||||||
out_dict = json.loads(out)
|
out_dict = json.loads(out)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
fatal("Could not decode json output: {} from the command {}".format(out, cmd), module) # noqa E501
|
fatal("Could not decode json output: {} from the command {}".format(out, cmd), module) # noqa: E501
|
||||||
|
|
||||||
if out_dict:
|
if out_dict:
|
||||||
data = module.params['data']
|
data = module.params['data']
|
||||||
result['stdout'] = 'skipped, since {0} is already used for an osd'.format(data) # noqa E501
|
result['stdout'] = 'skipped, since {0} is already used for an osd'.format(data) # noqa: E501
|
||||||
result['rc'] = 0
|
result['rc'] = 0
|
||||||
module.exit_json(**result)
|
module.exit_json(**result)
|
||||||
|
|
||||||
|
@ -592,7 +596,7 @@ def run_module():
|
||||||
elif action == 'activate':
|
elif action == 'activate':
|
||||||
if container_image:
|
if container_image:
|
||||||
fatal(
|
fatal(
|
||||||
"This is not how container's activation happens, nothing to activate", module) # noqa E501
|
"This is not how container's activation happens, nothing to activate", module) # noqa: E501
|
||||||
|
|
||||||
# Activate the OSD
|
# Activate the OSD
|
||||||
rc, cmd, out, err = exec_command(
|
rc, cmd, out, err = exec_command(
|
||||||
|
@ -603,16 +607,16 @@ def run_module():
|
||||||
skip = []
|
skip = []
|
||||||
for device_type in ['journal', 'data', 'db', 'wal']:
|
for device_type in ['journal', 'data', 'db', 'wal']:
|
||||||
# 1/ if we passed vg/lv
|
# 1/ if we passed vg/lv
|
||||||
if module.params.get('{}_vg'.format(device_type), None) and module.params.get(device_type, None): # noqa E501
|
if module.params.get('{}_vg'.format(device_type), None) and module.params.get(device_type, None): # noqa: E501
|
||||||
# 2/ check this is an actual lv/vg
|
# 2/ check this is an actual lv/vg
|
||||||
ret = is_lv(module, module.params['{}_vg'.format(device_type)], module.params[device_type], container_image) # noqa E501
|
ret = is_lv(module, module.params['{}_vg'.format(device_type)], module.params[device_type], container_image) # noqa: E501
|
||||||
skip.append(ret)
|
skip.append(ret)
|
||||||
# 3/ This isn't a lv/vg device
|
# 3/ This isn't a lv/vg device
|
||||||
if not ret:
|
if not ret:
|
||||||
module.params['{}_vg'.format(device_type)] = False
|
module.params['{}_vg'.format(device_type)] = False
|
||||||
module.params[device_type] = False
|
module.params[device_type] = False
|
||||||
# 4/ no journal|data|db|wal|_vg was passed, so it must be a raw device # noqa E501
|
# 4/ no journal|data|db|wal|_vg was passed, so it must be a raw device # noqa: E501
|
||||||
elif not module.params.get('{}_vg'.format(device_type), None) and module.params.get(device_type, None): # noqa E501
|
elif not module.params.get('{}_vg'.format(device_type), None) and module.params.get(device_type, None): # noqa: E501
|
||||||
skip.append(True)
|
skip.append(True)
|
||||||
|
|
||||||
cmd = zap_devices(module, container_image)
|
cmd = zap_devices(module, container_image)
|
||||||
|
|
|
@ -139,7 +139,7 @@ def main():
|
||||||
rc, out, err = module.run_command(cmd)
|
rc, out, err = module.run_command(cmd)
|
||||||
|
|
||||||
if rc == 0:
|
if rc == 0:
|
||||||
if name in [x["name"] for x in json.loads(out) if x["style"] == "cephadm:v1"]:
|
if name in [x["name"] for x in json.loads(out) if x["style"] == "cephadm:v1"]: # noqa: E501
|
||||||
exit_module(
|
exit_module(
|
||||||
module=module,
|
module=module,
|
||||||
out='{} is already adopted'.format(name),
|
out='{} is already adopted'.format(name),
|
||||||
|
@ -160,7 +160,7 @@ def main():
|
||||||
if image:
|
if image:
|
||||||
cmd.extend(['--image', image])
|
cmd.extend(['--image', image])
|
||||||
|
|
||||||
cmd.extend(['adopt', '--cluster', cluster, '--name', name, '--style', style])
|
cmd.extend(['adopt', '--cluster', cluster, '--name', name, '--style', style]) # noqa: E501
|
||||||
|
|
||||||
if not pull:
|
if not pull:
|
||||||
cmd.append('--skip-pull')
|
cmd.append('--skip-pull')
|
||||||
|
|
|
@ -95,7 +95,8 @@ options:
|
||||||
required: false
|
required: false
|
||||||
registry_json:
|
registry_json:
|
||||||
description:
|
description:
|
||||||
- JSON file with custom registry login info (URL, username, password).
|
- JSON file with custom registry login info (URL,
|
||||||
|
username, password).
|
||||||
required: false
|
required: false
|
||||||
author:
|
author:
|
||||||
- Dimitri Savineau <dsavinea@redhat.com>
|
- Dimitri Savineau <dsavinea@redhat.com>
|
||||||
|
|
|
@ -53,13 +53,13 @@ author:
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import os # noqa E402
|
import os # noqa: E402
|
||||||
import logging # noqa E402
|
import logging # noqa: E402
|
||||||
from logging.handlers import RotatingFileHandler # noqa E402
|
from logging.handlers import RotatingFileHandler # noqa: E402
|
||||||
from ansible.module_utils.basic import * # noqa E402
|
from ansible.module_utils.basic import * # noqa: E402,F403
|
||||||
|
|
||||||
from ceph_iscsi_config.client import GWClient # noqa E402
|
from ceph_iscsi_config.client import GWClient # noqa: E402
|
||||||
import ceph_iscsi_config.settings as settings # noqa E402
|
import ceph_iscsi_config.settings as settings # noqa: E402
|
||||||
|
|
||||||
|
|
||||||
# the main function is called ansible_main to allow the call stack
|
# the main function is called ansible_main to allow the call stack
|
||||||
|
@ -78,7 +78,7 @@ def ansible_main():
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
module = AnsibleModule(argument_spec=fields, # noqa F405
|
module = AnsibleModule(argument_spec=fields, # noqa: F405
|
||||||
supports_check_mode=False)
|
supports_check_mode=False)
|
||||||
|
|
||||||
client_iqn = module.params['client_iqn']
|
client_iqn = module.params['client_iqn']
|
||||||
|
|
|
@ -56,17 +56,17 @@ author:
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import os # noqa E402
|
import os # noqa: E402
|
||||||
import logging # noqa E402
|
import logging # noqa: E402
|
||||||
|
|
||||||
from logging.handlers import RotatingFileHandler # noqa E402
|
from logging.handlers import RotatingFileHandler # noqa: E402
|
||||||
from ansible.module_utils.basic import * # noqa E402
|
from ansible.module_utils.basic import * # noqa: E402,F403
|
||||||
|
|
||||||
import ceph_iscsi_config.settings as settings # noqa E402
|
import ceph_iscsi_config.settings as settings # noqa: E402
|
||||||
from ceph_iscsi_config.common import Config # noqa E402
|
from ceph_iscsi_config.common import Config # noqa: E402
|
||||||
|
|
||||||
from ceph_iscsi_config.gateway import GWTarget # noqa E402
|
from ceph_iscsi_config.gateway import GWTarget # noqa: E402
|
||||||
from ceph_iscsi_config.utils import valid_ip # noqa E402
|
from ceph_iscsi_config.utils import valid_ip # noqa: E402
|
||||||
|
|
||||||
|
|
||||||
# the main function is called ansible_main to allow the call stack
|
# the main function is called ansible_main to allow the call stack
|
||||||
|
@ -83,7 +83,7 @@ def ansible_main():
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module = AnsibleModule(argument_spec=fields, # noqa F405
|
module = AnsibleModule(argument_spec=fields, # noqa: F405
|
||||||
supports_check_mode=False)
|
supports_check_mode=False)
|
||||||
|
|
||||||
cfg = Config(logger)
|
cfg = Config(logger)
|
||||||
|
|
|
@ -8,11 +8,11 @@ module: igw_lun
|
||||||
short_description: Manage ceph rbd images to present as iscsi LUNs to clients
|
short_description: Manage ceph rbd images to present as iscsi LUNs to clients
|
||||||
description:
|
description:
|
||||||
- This module calls the 'lun' configuration management module installed
|
- This module calls the 'lun' configuration management module installed
|
||||||
on the iscsi gateway node(s). The lun module handles the creation and resize # noqa E501
|
on the iscsi gateway node(s). The lun module handles the creation and resize # noqa: E501
|
||||||
of rbd images, and then maps these rbd devices to the gateway node(s) to be
|
of rbd images, and then maps these rbd devices to the gateway node(s) to be
|
||||||
exposed through the kernel's LIO target.
|
exposed through the kernel's LIO target.
|
||||||
|
|
||||||
To support module debugging, this module logs to /var/log/ansible-module-igw_config.log # noqa E501
|
To support module debugging, this module logs to /var/log/ansible-module-igw_config.log # noqa: E501
|
||||||
on the target machine(s).
|
on the target machine(s).
|
||||||
|
|
||||||
option:
|
option:
|
||||||
|
@ -70,15 +70,15 @@ author:
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import os # noqa E402
|
import os # noqa: E402
|
||||||
import logging # noqa E402
|
import logging # noqa: E402
|
||||||
from logging.handlers import RotatingFileHandler # noqa E402
|
from logging.handlers import RotatingFileHandler # noqa: E402
|
||||||
|
|
||||||
from ansible.module_utils.basic import * # noqa E402
|
from ansible.module_utils.basic import * # noqa: E402,F403
|
||||||
|
|
||||||
from ceph_iscsi_config.lun import LUN # noqa E402
|
from ceph_iscsi_config.lun import LUN # noqa: E402
|
||||||
from ceph_iscsi_config.utils import valid_size # noqa E402
|
from ceph_iscsi_config.utils import valid_size # noqa: E402
|
||||||
import ceph_iscsi_config.settings as settings # noqa E402
|
import ceph_iscsi_config.settings as settings # noqa: E402
|
||||||
|
|
||||||
|
|
||||||
# the main function is called ansible_main to allow the call stack
|
# the main function is called ansible_main to allow the call stack
|
||||||
|
@ -103,7 +103,7 @@ def ansible_main():
|
||||||
}
|
}
|
||||||
|
|
||||||
# not supporting check mode currently
|
# not supporting check mode currently
|
||||||
module = AnsibleModule(argument_spec=fields, # noqa F405
|
module = AnsibleModule(argument_spec=fields, # noqa: F405
|
||||||
supports_check_mode=False)
|
supports_check_mode=False)
|
||||||
|
|
||||||
pool = module.params["pool"]
|
pool = module.params["pool"]
|
||||||
|
|
|
@ -34,18 +34,18 @@ author:
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import os # noqa E402
|
import os # noqa: E402
|
||||||
import logging # noqa E402
|
import logging # noqa: E402
|
||||||
import socket # noqa E402
|
import socket # noqa: E402,F401
|
||||||
import rados # noqa E402
|
import rados # noqa: E402
|
||||||
import rbd # noqa E402
|
import rbd # noqa: E402
|
||||||
|
|
||||||
from logging.handlers import RotatingFileHandler # noqa E402
|
from logging.handlers import RotatingFileHandler # noqa: E402
|
||||||
from ansible.module_utils.basic import * # noqa E402
|
from ansible.module_utils.basic import * # noqa: E402,F403
|
||||||
|
|
||||||
import ceph_iscsi_config.settings as settings # noqa E402
|
import ceph_iscsi_config.settings as settings # noqa: E402
|
||||||
from ceph_iscsi_config.common import Config # noqa E402
|
from ceph_iscsi_config.common import Config # noqa: E402
|
||||||
from ceph_iscsi_config.lun import RBDDev # noqa E402
|
from ceph_iscsi_config.lun import RBDDev # noqa: E402
|
||||||
|
|
||||||
__author__ = 'pcuzner@redhat.com'
|
__author__ = 'pcuzner@redhat.com'
|
||||||
|
|
||||||
|
@ -81,7 +81,7 @@ def delete_images(cfg):
|
||||||
|
|
||||||
if rbd_dev.error:
|
if rbd_dev.error:
|
||||||
if rbd_dev.error_msg:
|
if rbd_dev.error_msg:
|
||||||
logger.error("Could not remove {}. Error: {}. Manually run the " # noqa E501
|
logger.error("Could not remove {}. Error: {}. Manually run the " # noqa: E501
|
||||||
"rbd command line tool to delete.".
|
"rbd command line tool to delete.".
|
||||||
format(image, rbd_dev.error_msg))
|
format(image, rbd_dev.error_msg))
|
||||||
else:
|
else:
|
||||||
|
@ -117,7 +117,7 @@ def ansible_main():
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module = AnsibleModule(argument_spec=fields, # noqa F405
|
module = AnsibleModule(argument_spec=fields, # noqa: F405
|
||||||
supports_check_mode=False)
|
supports_check_mode=False)
|
||||||
|
|
||||||
run_mode = module.params['mode']
|
run_mode = module.params['mode']
|
||||||
|
|
|
@ -182,7 +182,9 @@ def create_realm(module, container_image=None):
|
||||||
if default:
|
if default:
|
||||||
args.append('--default')
|
args.append('--default')
|
||||||
|
|
||||||
cmd = generate_radosgw_cmd(cluster=cluster, args=args, container_image=container_image)
|
cmd = generate_radosgw_cmd(cluster=cluster,
|
||||||
|
args=args,
|
||||||
|
container_image=container_image)
|
||||||
|
|
||||||
return cmd
|
return cmd
|
||||||
|
|
||||||
|
@ -197,7 +199,9 @@ def get_realm(module, container_image=None):
|
||||||
|
|
||||||
args = ['get', '--rgw-realm=' + name, '--format=json']
|
args = ['get', '--rgw-realm=' + name, '--format=json']
|
||||||
|
|
||||||
cmd = generate_radosgw_cmd(cluster=cluster, args=args, container_image=container_image)
|
cmd = generate_radosgw_cmd(cluster=cluster,
|
||||||
|
args=args,
|
||||||
|
container_image=container_image)
|
||||||
|
|
||||||
return cmd
|
return cmd
|
||||||
|
|
||||||
|
@ -212,7 +216,9 @@ def remove_realm(module, container_image=None):
|
||||||
|
|
||||||
args = ['delete', '--rgw-realm=' + name]
|
args = ['delete', '--rgw-realm=' + name]
|
||||||
|
|
||||||
cmd = generate_radosgw_cmd(cluster=cluster, args=args, container_image=container_image)
|
cmd = generate_radosgw_cmd(cluster=cluster,
|
||||||
|
args=args,
|
||||||
|
container_image=container_image)
|
||||||
|
|
||||||
return cmd
|
return cmd
|
||||||
|
|
||||||
|
@ -228,9 +234,17 @@ def pull_realm(module, container_image=None):
|
||||||
access_key = module.params.get('access_key')
|
access_key = module.params.get('access_key')
|
||||||
secret_key = module.params.get('secret_key')
|
secret_key = module.params.get('secret_key')
|
||||||
|
|
||||||
args = ['pull', '--rgw-realm=' + name, '--url=' + url, '--access-key=' + access_key, '--secret=' + secret_key]
|
args = [
|
||||||
|
'pull',
|
||||||
|
'--rgw-realm=' + name,
|
||||||
|
'--url=' + url,
|
||||||
|
'--access-key=' + access_key,
|
||||||
|
'--secret=' + secret_key
|
||||||
|
]
|
||||||
|
|
||||||
cmd = generate_radosgw_cmd(cluster=cluster, args=args, container_image=container_image)
|
cmd = generate_radosgw_cmd(cluster=cluster,
|
||||||
|
args=args,
|
||||||
|
container_image=container_image)
|
||||||
|
|
||||||
return cmd
|
return cmd
|
||||||
|
|
||||||
|
@ -256,7 +270,7 @@ def run_module():
|
||||||
module_args = dict(
|
module_args = dict(
|
||||||
cluster=dict(type='str', required=False, default='ceph'),
|
cluster=dict(type='str', required=False, default='ceph'),
|
||||||
name=dict(type='str', required=True),
|
name=dict(type='str', required=True),
|
||||||
state=dict(type='str', required=False, choices=['present', 'absent', 'info', 'pull'], default='present'),
|
state=dict(type='str', required=False, choices=['present', 'absent', 'info', 'pull'], default='present'), # noqa: E501
|
||||||
default=dict(type='bool', required=False, default=False),
|
default=dict(type='bool', required=False, default=False),
|
||||||
url=dict(type='str', required=False),
|
url=dict(type='str', required=False),
|
||||||
access_key=dict(type='str', required=False),
|
access_key=dict(type='str', required=False),
|
||||||
|
@ -291,27 +305,27 @@ def run_module():
|
||||||
container_image = is_containerized()
|
container_image = is_containerized()
|
||||||
|
|
||||||
if state == "present":
|
if state == "present":
|
||||||
rc, cmd, out, err = exec_commands(module, get_realm(module, container_image=container_image))
|
rc, cmd, out, err = exec_commands(module, get_realm(module, container_image=container_image)) # noqa: E501
|
||||||
if rc != 0:
|
if rc != 0:
|
||||||
rc, cmd, out, err = exec_commands(module, create_realm(module, container_image=container_image))
|
rc, cmd, out, err = exec_commands(module, create_realm(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_realm(module, container_image=container_image))
|
rc, cmd, out, err = exec_commands(module, get_realm(module, container_image=container_image)) # noqa: E501
|
||||||
if rc == 0:
|
if rc == 0:
|
||||||
rc, cmd, out, err = exec_commands(module, remove_realm(module, container_image=container_image))
|
rc, cmd, out, err = exec_commands(module, remove_realm(module, container_image=container_image)) # noqa: E501
|
||||||
changed = True
|
changed = True
|
||||||
else:
|
else:
|
||||||
rc = 0
|
rc = 0
|
||||||
out = "Realm {} doesn't exist".format(name)
|
out = "Realm {} doesn't exist".format(name)
|
||||||
|
|
||||||
elif state == "info":
|
elif state == "info":
|
||||||
rc, cmd, out, err = exec_commands(module, get_realm(module, container_image=container_image))
|
rc, cmd, out, err = exec_commands(module, get_realm(module, container_image=container_image)) # noqa: E501
|
||||||
|
|
||||||
elif state == "pull":
|
elif state == "pull":
|
||||||
rc, cmd, out, err = exec_commands(module, pull_realm(module, container_image=container_image))
|
rc, cmd, out, err = exec_commands(module, pull_realm(module, container_image=container_image)) # noqa: E501
|
||||||
|
|
||||||
exit_module(module=module, out=out, rc=rc, cmd=cmd, err=err, startd=startd, changed=changed)
|
exit_module(module=module, out=out, rc=rc, cmd=cmd, err=err, startd=startd, changed=changed) # noqa: E501
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
|
|
@ -250,7 +250,9 @@ def create_user(module, container_image=None):
|
||||||
if admin:
|
if admin:
|
||||||
args.append('--admin')
|
args.append('--admin')
|
||||||
|
|
||||||
cmd = generate_radosgw_cmd(cluster=cluster, args=args, container_image=container_image)
|
cmd = generate_radosgw_cmd(cluster=cluster,
|
||||||
|
args=args,
|
||||||
|
container_image=container_image)
|
||||||
|
|
||||||
return cmd
|
return cmd
|
||||||
|
|
||||||
|
@ -303,7 +305,9 @@ def modify_user(module, container_image=None):
|
||||||
if admin:
|
if admin:
|
||||||
args.append('--admin')
|
args.append('--admin')
|
||||||
|
|
||||||
cmd = generate_radosgw_cmd(cluster=cluster, args=args, container_image=container_image)
|
cmd = generate_radosgw_cmd(cluster=cluster,
|
||||||
|
args=args,
|
||||||
|
container_image=container_image)
|
||||||
|
|
||||||
return cmd
|
return cmd
|
||||||
|
|
||||||
|
@ -359,7 +363,9 @@ def remove_user(module, container_image=None):
|
||||||
if zone:
|
if zone:
|
||||||
args.extend(['--rgw-zone=' + zone])
|
args.extend(['--rgw-zone=' + zone])
|
||||||
|
|
||||||
cmd = generate_radosgw_cmd(cluster=cluster, args=args, container_image=container_image)
|
cmd = generate_radosgw_cmd(cluster=cluster,
|
||||||
|
args=args,
|
||||||
|
container_image=container_image)
|
||||||
|
|
||||||
return cmd
|
return cmd
|
||||||
|
|
||||||
|
@ -385,7 +391,7 @@ def run_module():
|
||||||
module_args = dict(
|
module_args = dict(
|
||||||
cluster=dict(type='str', required=False, default='ceph'),
|
cluster=dict(type='str', required=False, default='ceph'),
|
||||||
name=dict(type='str', required=True),
|
name=dict(type='str', required=True),
|
||||||
state=dict(type='str', required=False, choices=['present', 'absent', 'info'], default='present'),
|
state=dict(type='str', required=False, choices=['present', 'absent', 'info'], default='present'), # noqa: E501
|
||||||
display_name=dict(type='str', required=False),
|
display_name=dict(type='str', required=False),
|
||||||
email=dict(type='str', required=False),
|
email=dict(type='str', required=False),
|
||||||
access_key=dict(type='str', required=False, no_log=True),
|
access_key=dict(type='str', required=False, no_log=True),
|
||||||
|
@ -432,7 +438,7 @@ def run_module():
|
||||||
container_image = is_containerized()
|
container_image = is_containerized()
|
||||||
|
|
||||||
if state == "present":
|
if state == "present":
|
||||||
rc, cmd, out, err = exec_commands(module, get_user(module, container_image=container_image))
|
rc, cmd, out, err = exec_commands(module, get_user(module, container_image=container_image)) # noqa: E501
|
||||||
if rc == 0:
|
if rc == 0:
|
||||||
user = json.loads(out)
|
user = json.loads(out)
|
||||||
current = {
|
current = {
|
||||||
|
@ -456,25 +462,25 @@ def run_module():
|
||||||
asked['secret_key'] = secret_key
|
asked['secret_key'] = secret_key
|
||||||
|
|
||||||
if current != asked:
|
if current != asked:
|
||||||
rc, cmd, out, err = exec_commands(module, modify_user(module, container_image=container_image))
|
rc, cmd, out, err = exec_commands(module, modify_user(module, container_image=container_image)) # noqa: E501
|
||||||
changed = True
|
changed = True
|
||||||
else:
|
else:
|
||||||
rc, cmd, out, err = exec_commands(module, create_user(module, container_image=container_image))
|
rc, cmd, out, err = exec_commands(module, create_user(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_user(module, container_image=container_image))
|
rc, cmd, out, err = exec_commands(module, get_user(module, container_image=container_image)) # noqa: E501
|
||||||
if rc == 0:
|
if rc == 0:
|
||||||
rc, cmd, out, err = exec_commands(module, remove_user(module, container_image=container_image))
|
rc, cmd, out, err = exec_commands(module, remove_user(module, container_image=container_image)) # noqa: E501
|
||||||
changed = True
|
changed = True
|
||||||
else:
|
else:
|
||||||
rc = 0
|
rc = 0
|
||||||
out = "User {} doesn't exist".format(name)
|
out = "User {} doesn't exist".format(name)
|
||||||
|
|
||||||
elif state == "info":
|
elif state == "info":
|
||||||
rc, cmd, out, err = exec_commands(module, get_user(module, container_image=container_image))
|
rc, cmd, out, err = exec_commands(module, get_user(module, container_image=container_image)) # noqa: E501
|
||||||
|
|
||||||
exit_module(module=module, out=out, rc=rc, cmd=cmd, err=err, startd=startd, changed=changed)
|
exit_module(module=module, out=out, rc=rc, cmd=cmd, err=err, startd=startd, changed=changed) # noqa: E501
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
|
|
@ -231,7 +231,9 @@ def create_zone(module, container_image=None):
|
||||||
if master:
|
if master:
|
||||||
args.append('--master')
|
args.append('--master')
|
||||||
|
|
||||||
cmd = generate_radosgw_cmd(cluster=cluster, args=args, container_image=container_image)
|
cmd = generate_radosgw_cmd(cluster=cluster,
|
||||||
|
args=args,
|
||||||
|
container_image=container_image)
|
||||||
|
|
||||||
return cmd
|
return cmd
|
||||||
|
|
||||||
|
@ -273,7 +275,9 @@ def modify_zone(module, container_image=None):
|
||||||
if master:
|
if master:
|
||||||
args.append('--master')
|
args.append('--master')
|
||||||
|
|
||||||
cmd = generate_radosgw_cmd(cluster=cluster, args=args, container_image=container_image)
|
cmd = generate_radosgw_cmd(cluster=cluster,
|
||||||
|
args=args,
|
||||||
|
container_image=container_image)
|
||||||
|
|
||||||
return cmd
|
return cmd
|
||||||
|
|
||||||
|
@ -370,7 +374,9 @@ def remove_zone(module, container_image=None):
|
||||||
'--rgw-zone=' + name
|
'--rgw-zone=' + name
|
||||||
]
|
]
|
||||||
|
|
||||||
cmd = generate_radosgw_cmd(cluster=cluster, args=args, container_image=container_image)
|
cmd = generate_radosgw_cmd(cluster=cluster,
|
||||||
|
args=args,
|
||||||
|
container_image=container_image)
|
||||||
|
|
||||||
return cmd
|
return cmd
|
||||||
|
|
||||||
|
@ -396,7 +402,7 @@ def run_module():
|
||||||
module_args = dict(
|
module_args = dict(
|
||||||
cluster=dict(type='str', required=False, default='ceph'),
|
cluster=dict(type='str', required=False, default='ceph'),
|
||||||
name=dict(type='str', required=True),
|
name=dict(type='str', required=True),
|
||||||
state=dict(type='str', required=False, choices=['present', 'absent', 'info'], default='present'),
|
state=dict(type='str', required=False, choices=['present', 'absent', 'info'], default='present'), # noqa: E501
|
||||||
realm=dict(type='str', require=True),
|
realm=dict(type='str', require=True),
|
||||||
zonegroup=dict(type='str', require=True),
|
zonegroup=dict(type='str', require=True),
|
||||||
endpoints=dict(type='list', require=False, default=[]),
|
endpoints=dict(type='list', require=False, default=[]),
|
||||||
|
@ -436,14 +442,14 @@ def run_module():
|
||||||
container_image = is_containerized()
|
container_image = is_containerized()
|
||||||
|
|
||||||
if state == "present":
|
if state == "present":
|
||||||
rc, cmd, out, err = exec_commands(module, get_zone(module, container_image=container_image))
|
rc, cmd, out, err = exec_commands(module, get_zone(module, container_image=container_image)) # noqa: E501
|
||||||
if rc == 0:
|
if rc == 0:
|
||||||
zone = json.loads(out)
|
zone = json.loads(out)
|
||||||
_rc, _cmd, _out, _err = exec_commands(module, get_realm(module, container_image=container_image))
|
_rc, _cmd, _out, _err = exec_commands(module, get_realm(module, container_image=container_image)) # noqa: E501
|
||||||
if _rc != 0:
|
if _rc != 0:
|
||||||
fatal(_err, module)
|
fatal(_err, module)
|
||||||
realm = json.loads(_out)
|
realm = json.loads(_out)
|
||||||
_rc, _cmd, _out, _err = exec_commands(module, get_zonegroup(module, container_image=container_image))
|
_rc, _cmd, _out, _err = exec_commands(module, get_zonegroup(module, container_image=container_image)) # noqa: E501
|
||||||
if _rc != 0:
|
if _rc != 0:
|
||||||
fatal(_err, module)
|
fatal(_err, module)
|
||||||
zonegroup = json.loads(_out)
|
zonegroup = json.loads(_out)
|
||||||
|
@ -452,7 +458,7 @@ def run_module():
|
||||||
if not secret_key:
|
if not secret_key:
|
||||||
secret_key = ''
|
secret_key = ''
|
||||||
current = {
|
current = {
|
||||||
'endpoints': next(zone['endpoints'] for zone in zonegroup['zones'] if zone['name'] == name),
|
'endpoints': next(zone['endpoints'] for zone in zonegroup['zones'] if zone['name'] == name), # noqa: E501
|
||||||
'access_key': zone['system_key']['access_key'],
|
'access_key': zone['system_key']['access_key'],
|
||||||
'secret_key': zone['system_key']['secret_key'],
|
'secret_key': zone['system_key']['secret_key'],
|
||||||
'realm_id': zone['realm_id']
|
'realm_id': zone['realm_id']
|
||||||
|
@ -464,25 +470,25 @@ def run_module():
|
||||||
'realm_id': realm['id']
|
'realm_id': realm['id']
|
||||||
}
|
}
|
||||||
if current != asked:
|
if current != asked:
|
||||||
rc, cmd, out, err = exec_commands(module, modify_zone(module, container_image=container_image))
|
rc, cmd, out, err = exec_commands(module, modify_zone(module, container_image=container_image)) # noqa: E501
|
||||||
changed = True
|
changed = True
|
||||||
else:
|
else:
|
||||||
rc, cmd, out, err = exec_commands(module, create_zone(module, container_image=container_image))
|
rc, cmd, out, err = exec_commands(module, create_zone(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_zone(module, container_image=container_image))
|
rc, cmd, out, err = exec_commands(module, get_zone(module, container_image=container_image)) # noqa: E501
|
||||||
if rc == 0:
|
if rc == 0:
|
||||||
rc, cmd, out, err = exec_commands(module, remove_zone(module, container_image=container_image))
|
rc, cmd, out, err = exec_commands(module, remove_zone(module, container_image=container_image)) # noqa: E501
|
||||||
changed = True
|
changed = True
|
||||||
else:
|
else:
|
||||||
rc = 0
|
rc = 0
|
||||||
out = "Zone {} doesn't exist".format(name)
|
out = "Zone {} doesn't exist".format(name)
|
||||||
|
|
||||||
elif state == "info":
|
elif state == "info":
|
||||||
rc, cmd, out, err = exec_commands(module, get_zone(module, container_image=container_image))
|
rc, cmd, out, err = exec_commands(module, get_zone(module, container_image=container_image)) # noqa: E501
|
||||||
|
|
||||||
exit_module(module=module, out=out, rc=rc, cmd=cmd, err=err, startd=startd, changed=changed)
|
exit_module(module=module, out=out, rc=rc, cmd=cmd, err=err, startd=startd, changed=changed) # noqa: E501
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
|
|
@ -204,7 +204,9 @@ def create_zonegroup(module, container_image=None):
|
||||||
if master:
|
if master:
|
||||||
args.append('--master')
|
args.append('--master')
|
||||||
|
|
||||||
cmd = generate_radosgw_cmd(cluster=cluster, args=args, container_image=container_image)
|
cmd = generate_radosgw_cmd(cluster=cluster,
|
||||||
|
args=args,
|
||||||
|
container_image=container_image)
|
||||||
|
|
||||||
return cmd
|
return cmd
|
||||||
|
|
||||||
|
@ -232,7 +234,9 @@ def modify_zonegroup(module, container_image=None):
|
||||||
if master:
|
if master:
|
||||||
args.append('--master')
|
args.append('--master')
|
||||||
|
|
||||||
cmd = generate_radosgw_cmd(cluster=cluster, args=args, container_image=container_image)
|
cmd = generate_radosgw_cmd(cluster=cluster,
|
||||||
|
args=args,
|
||||||
|
container_image=container_image)
|
||||||
|
|
||||||
return cmd
|
return cmd
|
||||||
|
|
||||||
|
@ -246,7 +250,12 @@ def get_zonegroup(module, container_image=None):
|
||||||
name = module.params.get('name')
|
name = module.params.get('name')
|
||||||
realm = module.params.get('realm')
|
realm = module.params.get('realm')
|
||||||
|
|
||||||
args = ['get', '--rgw-realm=' + realm, '--rgw-zonegroup=' + name, '--format=json']
|
args = [
|
||||||
|
'get',
|
||||||
|
'--rgw-realm=' + realm,
|
||||||
|
'--rgw-zonegroup=' + name,
|
||||||
|
'--format=json'
|
||||||
|
]
|
||||||
|
|
||||||
cmd = generate_radosgw_cmd(cluster=cluster,
|
cmd = generate_radosgw_cmd(cluster=cluster,
|
||||||
args=args,
|
args=args,
|
||||||
|
@ -290,7 +299,9 @@ def remove_zonegroup(module, container_image=None):
|
||||||
|
|
||||||
args = ['delete', '--rgw-realm=' + realm, '--rgw-zonegroup=' + name]
|
args = ['delete', '--rgw-realm=' + realm, '--rgw-zonegroup=' + name]
|
||||||
|
|
||||||
cmd = generate_radosgw_cmd(cluster=cluster, args=args, container_image=container_image)
|
cmd = generate_radosgw_cmd(cluster=cluster,
|
||||||
|
args=args,
|
||||||
|
container_image=container_image)
|
||||||
|
|
||||||
return cmd
|
return cmd
|
||||||
|
|
||||||
|
@ -316,7 +327,7 @@ def run_module():
|
||||||
module_args = dict(
|
module_args = dict(
|
||||||
cluster=dict(type='str', required=False, default='ceph'),
|
cluster=dict(type='str', required=False, default='ceph'),
|
||||||
name=dict(type='str', required=True),
|
name=dict(type='str', required=True),
|
||||||
state=dict(type='str', required=False, choices=['present', 'absent', 'info'], default='present'),
|
state=dict(type='str', required=False, choices=['present', 'absent', 'info'], default='present'), # noqa: E501
|
||||||
realm=dict(type='str', require=True),
|
realm=dict(type='str', require=True),
|
||||||
endpoints=dict(type='list', require=False, default=[]),
|
endpoints=dict(type='list', require=False, default=[]),
|
||||||
default=dict(type='bool', required=False, default=False),
|
default=dict(type='bool', required=False, default=False),
|
||||||
|
@ -352,10 +363,10 @@ def run_module():
|
||||||
container_image = is_containerized()
|
container_image = is_containerized()
|
||||||
|
|
||||||
if state == "present":
|
if state == "present":
|
||||||
rc, cmd, out, err = exec_commands(module, get_zonegroup(module, container_image=container_image))
|
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))
|
_rc, _cmd, _out, _err = exec_commands(module, get_realm(module, container_image=container_image)) # noqa: E501
|
||||||
if _rc != 0:
|
if _rc != 0:
|
||||||
fatal(_err, module)
|
fatal(_err, module)
|
||||||
realm = json.loads(_out)
|
realm = json.loads(_out)
|
||||||
|
@ -370,25 +381,25 @@ def run_module():
|
||||||
'realm_id': realm['id']
|
'realm_id': realm['id']
|
||||||
}
|
}
|
||||||
if current != asked:
|
if current != asked:
|
||||||
rc, cmd, out, err = exec_commands(module, modify_zonegroup(module, container_image=container_image))
|
rc, cmd, out, err = exec_commands(module, modify_zonegroup(module, container_image=container_image)) # noqa: E501
|
||||||
changed = True
|
changed = True
|
||||||
else:
|
else:
|
||||||
rc, cmd, out, err = exec_commands(module, create_zonegroup(module, container_image=container_image))
|
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))
|
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))
|
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":
|
elif state == "info":
|
||||||
rc, cmd, out, err = exec_commands(module, get_zonegroup(module, container_image=container_image))
|
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)
|
exit_module(module=module, out=out, rc=rc, cmd=cmd, err=err, startd=startd, changed=changed) # noqa: E501
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
|
Loading…
Reference in New Issue