Commit beda1fe7 authored by Wong Hoi Sing Edison's avatar Wong Hoi Sing Edison Committed by Guillaume Abrioux
Browse files

library: flake8 ceph-ansible modules



This commit ensure all ceph-ansible modules pass flake8 properly.
Signed-off-by: default avatarWong Hoi Sing Edison <hswong3i@pantarei-design.com>
parent d191ba38
...@@ -112,7 +112,7 @@ option: ...@@ -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: ...@@ -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): ...@@ -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): ...@@ -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): ...@@ -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): ...@@ -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(): ...@@ -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(): ...@@ -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): ...@@ -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): ...@@ -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(): ...@@ -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 ...@@ -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: ...@@ -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): ...@@ -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): ...@@ -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): ...@@ -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(): ...@@ -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(): ...@@ -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: ...@@ -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): ...@@ -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): ...@@ -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): ...@@ -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): ...@@ -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): ...@@ -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(): ...@@ -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(): ...@@ -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