mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
* Fix linting errors.
* Fix bugs.
* Another linter error ignored.
* More fixes.
* Ignore sanity errors with older versions.
ci_complete
* Forgot to commit more changes.
(cherry picked from commit a54af8909c
)
This commit is contained in:
parent
54bf6ef6de
commit
e4eead189b
52 changed files with 115 additions and 94 deletions
7
changelogs/fragments/5111-fixes.yml
Normal file
7
changelogs/fragments/5111-fixes.yml
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
bugfixes:
|
||||||
|
- "funcd connection plugin - fix signature of ``exec_command`` (https://github.com/ansible-collections/community.general/pull/5111)."
|
||||||
|
- "packet_ip_subnet - fix error reporting in case of invalid CIDR prefix lengths (https://github.com/ansible-collections/community.general/pull/5111)."
|
||||||
|
- "dnsimple_info - correctly report missing library as ``requests`` and not ``another_library`` (https://github.com/ansible-collections/community.general/pull/5111)."
|
||||||
|
- "pip_package_info - remove usage of global variable (https://github.com/ansible-collections/community.general/pull/5111)."
|
||||||
|
- "manageiq_alert_profiles - avoid crash when reporting unknown profile caused by trying to return an undefined variable (https://github.com/ansible-collections/community.general/pull/5111)."
|
||||||
|
- "apache2_mod_proxy - avoid crash when reporting inability to parse balancer_member_page HTML caused by using an undefined variable in the error message (https://github.com/ansible-collections/community.general/pull/5111)."
|
|
@ -232,13 +232,13 @@ class CallbackModule(CallbackModule_default):
|
||||||
# Remove non-essential attributes
|
# Remove non-essential attributes
|
||||||
for attr in self.removed_attributes:
|
for attr in self.removed_attributes:
|
||||||
if attr in result:
|
if attr in result:
|
||||||
del(result[attr])
|
del result[attr]
|
||||||
|
|
||||||
# Remove empty attributes (list, dict, str)
|
# Remove empty attributes (list, dict, str)
|
||||||
for attr in result.copy():
|
for attr in result.copy():
|
||||||
if isinstance(result[attr], (MutableSequence, MutableMapping, binary_type, text_type)):
|
if isinstance(result[attr], (MutableSequence, MutableMapping, binary_type, text_type)):
|
||||||
if not result[attr]:
|
if not result[attr]:
|
||||||
del(result[attr])
|
del result[attr]
|
||||||
|
|
||||||
def _handle_exceptions(self, result):
|
def _handle_exceptions(self, result):
|
||||||
if 'exception' in result:
|
if 'exception' in result:
|
||||||
|
|
|
@ -63,7 +63,7 @@ class Connection(ConnectionBase):
|
||||||
self.client = fc.Client(self.host)
|
self.client = fc.Client(self.host)
|
||||||
return self
|
return self
|
||||||
|
|
||||||
def exec_command(self, cmd, become_user=None, sudoable=False, executable='/bin/sh', in_data=None):
|
def exec_command(self, cmd, in_data=None, sudoable=True):
|
||||||
""" run a command on the remote minion """
|
""" run a command on the remote minion """
|
||||||
|
|
||||||
if in_data:
|
if in_data:
|
||||||
|
|
|
@ -91,7 +91,7 @@ class iLORedfishUtils(RedfishUtils):
|
||||||
data = response['data']
|
data = response['data']
|
||||||
|
|
||||||
ntp_list = data[setkey]
|
ntp_list = data[setkey]
|
||||||
if(len(ntp_list) == 2):
|
if len(ntp_list) == 2:
|
||||||
ntp_list.pop(0)
|
ntp_list.pop(0)
|
||||||
|
|
||||||
ntp_list.append(mgr_attributes['mgr_attr_value'])
|
ntp_list.append(mgr_attributes['mgr_attr_value'])
|
||||||
|
|
|
@ -78,7 +78,7 @@ def memset_api_call(api_key, api_method, payload=None):
|
||||||
if msg is None:
|
if msg is None:
|
||||||
msg = response.json()
|
msg = response.json()
|
||||||
|
|
||||||
return(has_failed, msg, response)
|
return has_failed, msg, response
|
||||||
|
|
||||||
|
|
||||||
def check_zone_domain(data, domain):
|
def check_zone_domain(data, domain):
|
||||||
|
@ -92,7 +92,7 @@ def check_zone_domain(data, domain):
|
||||||
if zone_domain['domain'] == domain:
|
if zone_domain['domain'] == domain:
|
||||||
exists = True
|
exists = True
|
||||||
|
|
||||||
return(exists)
|
return exists
|
||||||
|
|
||||||
|
|
||||||
def check_zone(data, name):
|
def check_zone(data, name):
|
||||||
|
@ -109,7 +109,7 @@ def check_zone(data, name):
|
||||||
if counter == 1:
|
if counter == 1:
|
||||||
exists = True
|
exists = True
|
||||||
|
|
||||||
return(exists, counter)
|
return exists, counter
|
||||||
|
|
||||||
|
|
||||||
def get_zone_id(zone_name, current_zones):
|
def get_zone_id(zone_name, current_zones):
|
||||||
|
@ -135,4 +135,4 @@ def get_zone_id(zone_name, current_zones):
|
||||||
zone_id = None
|
zone_id = None
|
||||||
msg = 'Zone ID could not be returned as duplicate zone names were detected'
|
msg = 'Zone ID could not be returned as duplicate zone names were detected'
|
||||||
|
|
||||||
return(zone_exists, msg, counter, zone_id)
|
return zone_exists, msg, counter, zone_id
|
||||||
|
|
|
@ -122,8 +122,7 @@ def rax_find_image(module, rax_module, image, exit=True):
|
||||||
except ValueError:
|
except ValueError:
|
||||||
try:
|
try:
|
||||||
image = cs.images.find(human_id=image)
|
image = cs.images.find(human_id=image)
|
||||||
except(cs.exceptions.NotFound,
|
except (cs.exceptions.NotFound, cs.exceptions.NoUniqueMatch):
|
||||||
cs.exceptions.NoUniqueMatch):
|
|
||||||
try:
|
try:
|
||||||
image = cs.images.find(name=image)
|
image = cs.images.find(name=image)
|
||||||
except (cs.exceptions.NotFound,
|
except (cs.exceptions.NotFound,
|
||||||
|
|
|
@ -2055,7 +2055,7 @@ class RedfishUtils(object):
|
||||||
if property in data:
|
if property in data:
|
||||||
nic[property] = data[property]
|
nic[property] = data[property]
|
||||||
result['entries'] = nic
|
result['entries'] = nic
|
||||||
return(result)
|
return result
|
||||||
|
|
||||||
def get_nic_inventory(self, resource_uri):
|
def get_nic_inventory(self, resource_uri):
|
||||||
result = {}
|
result = {}
|
||||||
|
|
|
@ -15,6 +15,7 @@ try:
|
||||||
from redis import Redis
|
from redis import Redis
|
||||||
from redis import __version__ as redis_version
|
from redis import __version__ as redis_version
|
||||||
HAS_REDIS_PACKAGE = True
|
HAS_REDIS_PACKAGE = True
|
||||||
|
REDIS_IMP_ERR = None
|
||||||
except ImportError:
|
except ImportError:
|
||||||
REDIS_IMP_ERR = traceback.format_exc()
|
REDIS_IMP_ERR = traceback.format_exc()
|
||||||
HAS_REDIS_PACKAGE = False
|
HAS_REDIS_PACKAGE = False
|
||||||
|
@ -22,6 +23,7 @@ except ImportError:
|
||||||
try:
|
try:
|
||||||
import certifi
|
import certifi
|
||||||
HAS_CERTIFI_PACKAGE = True
|
HAS_CERTIFI_PACKAGE = True
|
||||||
|
CERTIFI_IMPORT_ERROR = None
|
||||||
except ImportError:
|
except ImportError:
|
||||||
CERTIFI_IMPORT_ERROR = traceback.format_exc()
|
CERTIFI_IMPORT_ERROR = traceback.format_exc()
|
||||||
HAS_CERTIFI_PACKAGE = False
|
HAS_CERTIFI_PACKAGE = False
|
||||||
|
|
|
@ -111,7 +111,7 @@ def poll_reload_status(api_key=None, job_id=None, payload=None):
|
||||||
memset_api = response.json()
|
memset_api = response.json()
|
||||||
msg = None
|
msg = None
|
||||||
|
|
||||||
return(memset_api, msg, stderr)
|
return memset_api, msg, stderr
|
||||||
|
|
||||||
|
|
||||||
def reload_dns(args=None):
|
def reload_dns(args=None):
|
||||||
|
@ -133,7 +133,7 @@ def reload_dns(args=None):
|
||||||
retvals['failed'] = has_failed
|
retvals['failed'] = has_failed
|
||||||
retvals['memset_api'] = response.json()
|
retvals['memset_api'] = response.json()
|
||||||
retvals['msg'] = msg
|
retvals['msg'] = msg
|
||||||
return(retvals)
|
return retvals
|
||||||
|
|
||||||
# set changed to true if the reload request was accepted.
|
# set changed to true if the reload request was accepted.
|
||||||
has_changed = True
|
has_changed = True
|
||||||
|
@ -153,7 +153,7 @@ def reload_dns(args=None):
|
||||||
if val is not None:
|
if val is not None:
|
||||||
retvals[val] = eval(val)
|
retvals[val] = eval(val)
|
||||||
|
|
||||||
return(retvals)
|
return retvals
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
|
|
@ -127,7 +127,7 @@ def get_facts(args=None):
|
||||||
retvals['failed'] = has_failed
|
retvals['failed'] = has_failed
|
||||||
retvals['msg'] = msg
|
retvals['msg'] = msg
|
||||||
retvals['stderr'] = "API returned an error: {0}" . format(response.status_code)
|
retvals['stderr'] = "API returned an error: {0}" . format(response.status_code)
|
||||||
return(retvals)
|
return retvals
|
||||||
|
|
||||||
# we don't want to return the same thing twice
|
# we don't want to return the same thing twice
|
||||||
msg = None
|
msg = None
|
||||||
|
@ -139,7 +139,7 @@ def get_facts(args=None):
|
||||||
if val is not None:
|
if val is not None:
|
||||||
retvals[val] = eval(val)
|
retvals[val] = eval(val)
|
||||||
|
|
||||||
return(retvals)
|
return retvals
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
|
|
@ -252,7 +252,7 @@ def get_facts(args=None):
|
||||||
retvals['failed'] = has_failed
|
retvals['failed'] = has_failed
|
||||||
retvals['msg'] = msg
|
retvals['msg'] = msg
|
||||||
retvals['stderr'] = "API returned an error: {0}" . format(response.status_code)
|
retvals['stderr'] = "API returned an error: {0}" . format(response.status_code)
|
||||||
return(retvals)
|
return retvals
|
||||||
|
|
||||||
# we don't want to return the same thing twice
|
# we don't want to return the same thing twice
|
||||||
msg = None
|
msg = None
|
||||||
|
@ -264,7 +264,7 @@ def get_facts(args=None):
|
||||||
if val is not None:
|
if val is not None:
|
||||||
retvals[val] = eval(val)
|
retvals[val] = eval(val)
|
||||||
|
|
||||||
return(retvals)
|
return retvals
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
|
|
@ -139,7 +139,7 @@ def check(args=None):
|
||||||
retvals['changed'] = has_changed
|
retvals['changed'] = has_changed
|
||||||
retvals['failed'] = has_failed
|
retvals['failed'] = has_failed
|
||||||
|
|
||||||
return(retvals)
|
return retvals
|
||||||
|
|
||||||
|
|
||||||
def create_zone(args=None, zone_exists=None, payload=None):
|
def create_zone(args=None, zone_exists=None, payload=None):
|
||||||
|
@ -185,7 +185,7 @@ def create_zone(args=None, zone_exists=None, payload=None):
|
||||||
_has_failed, _msg, response = memset_api_call(api_key=args['api_key'], api_method=api_method, payload=payload)
|
_has_failed, _msg, response = memset_api_call(api_key=args['api_key'], api_method=api_method, payload=payload)
|
||||||
memset_api = response.json()
|
memset_api = response.json()
|
||||||
|
|
||||||
return(has_failed, has_changed, memset_api, msg)
|
return has_failed, has_changed, memset_api, msg
|
||||||
|
|
||||||
|
|
||||||
def delete_zone(args=None, zone_exists=None, payload=None):
|
def delete_zone(args=None, zone_exists=None, payload=None):
|
||||||
|
@ -233,7 +233,7 @@ def delete_zone(args=None, zone_exists=None, payload=None):
|
||||||
else:
|
else:
|
||||||
has_failed, has_changed = False, False
|
has_failed, has_changed = False, False
|
||||||
|
|
||||||
return(has_failed, has_changed, memset_api, msg)
|
return has_failed, has_changed, memset_api, msg
|
||||||
|
|
||||||
|
|
||||||
def create_or_delete(args=None):
|
def create_or_delete(args=None):
|
||||||
|
@ -255,7 +255,7 @@ def create_or_delete(args=None):
|
||||||
retvals['failed'] = _has_failed
|
retvals['failed'] = _has_failed
|
||||||
retvals['msg'] = _msg
|
retvals['msg'] = _msg
|
||||||
|
|
||||||
return(retvals)
|
return retvals
|
||||||
|
|
||||||
zone_exists, _msg, counter, _zone_id = get_zone_id(zone_name=args['name'], current_zones=response.json())
|
zone_exists, _msg, counter, _zone_id = get_zone_id(zone_name=args['name'], current_zones=response.json())
|
||||||
|
|
||||||
|
@ -271,7 +271,7 @@ def create_or_delete(args=None):
|
||||||
if val is not None:
|
if val is not None:
|
||||||
retvals[val] = eval(val)
|
retvals[val] = eval(val)
|
||||||
|
|
||||||
return(retvals)
|
return retvals
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
|
|
@ -110,7 +110,7 @@ def check(args=None):
|
||||||
retvals['changed'] = has_changed
|
retvals['changed'] = has_changed
|
||||||
retvals['failed'] = has_failed
|
retvals['failed'] = has_failed
|
||||||
|
|
||||||
return(retvals)
|
return retvals
|
||||||
|
|
||||||
|
|
||||||
def create_zone_domain(args=None, zone_exists=None, zone_id=None, payload=None):
|
def create_zone_domain(args=None, zone_exists=None, zone_id=None, payload=None):
|
||||||
|
@ -138,7 +138,7 @@ def create_zone_domain(args=None, zone_exists=None, zone_id=None, payload=None):
|
||||||
if not has_failed:
|
if not has_failed:
|
||||||
has_changed = True
|
has_changed = True
|
||||||
|
|
||||||
return(has_failed, has_changed, msg)
|
return has_failed, has_changed, msg
|
||||||
|
|
||||||
|
|
||||||
def delete_zone_domain(args=None, payload=None):
|
def delete_zone_domain(args=None, payload=None):
|
||||||
|
@ -165,7 +165,7 @@ def delete_zone_domain(args=None, payload=None):
|
||||||
# unset msg as we don't want to return unnecessary info to the user.
|
# unset msg as we don't want to return unnecessary info to the user.
|
||||||
msg = None
|
msg = None
|
||||||
|
|
||||||
return(has_failed, has_changed, memset_api, msg)
|
return has_failed, has_changed, memset_api, msg
|
||||||
|
|
||||||
|
|
||||||
def create_or_delete_domain(args=None):
|
def create_or_delete_domain(args=None):
|
||||||
|
@ -188,7 +188,7 @@ def create_or_delete_domain(args=None):
|
||||||
retvals['failed'] = has_failed
|
retvals['failed'] = has_failed
|
||||||
retvals['msg'] = msg
|
retvals['msg'] = msg
|
||||||
retvals['stderr'] = "API returned an error: {0}" . format(response.status_code)
|
retvals['stderr'] = "API returned an error: {0}" . format(response.status_code)
|
||||||
return(retvals)
|
return retvals
|
||||||
|
|
||||||
zone_exists, msg, counter, zone_id = get_zone_id(zone_name=args['zone'], current_zones=response.json())
|
zone_exists, msg, counter, zone_id = get_zone_id(zone_name=args['zone'], current_zones=response.json())
|
||||||
|
|
||||||
|
@ -203,7 +203,7 @@ def create_or_delete_domain(args=None):
|
||||||
|
|
||||||
retvals['failed'] = has_failed
|
retvals['failed'] = has_failed
|
||||||
retvals['msg'] = stderr
|
retvals['msg'] = stderr
|
||||||
return(retvals)
|
return retvals
|
||||||
|
|
||||||
if args['state'] == 'present':
|
if args['state'] == 'present':
|
||||||
has_failed, has_changed, msg = create_zone_domain(args=args, zone_exists=zone_exists, zone_id=zone_id, payload=payload)
|
has_failed, has_changed, msg = create_zone_domain(args=args, zone_exists=zone_exists, zone_id=zone_id, payload=payload)
|
||||||
|
@ -217,7 +217,7 @@ def create_or_delete_domain(args=None):
|
||||||
if val is not None:
|
if val is not None:
|
||||||
retvals[val] = eval(val)
|
retvals[val] = eval(val)
|
||||||
|
|
||||||
return(retvals)
|
return retvals
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
|
|
@ -221,7 +221,7 @@ def create_zone_record(args=None, zone_id=None, records=None, payload=None):
|
||||||
# nothing to do; record is already correct so we populate
|
# nothing to do; record is already correct so we populate
|
||||||
# the return var with the existing record's details.
|
# the return var with the existing record's details.
|
||||||
memset_api = zone_record
|
memset_api = zone_record
|
||||||
return(has_changed, has_failed, memset_api, msg)
|
return has_changed, has_failed, memset_api, msg
|
||||||
else:
|
else:
|
||||||
# merge dicts ensuring we change any updated values
|
# merge dicts ensuring we change any updated values
|
||||||
payload = zone_record.copy()
|
payload = zone_record.copy()
|
||||||
|
@ -231,7 +231,7 @@ def create_zone_record(args=None, zone_id=None, records=None, payload=None):
|
||||||
has_changed = True
|
has_changed = True
|
||||||
# return the new record to the user in the returned var.
|
# return the new record to the user in the returned var.
|
||||||
memset_api = new_record
|
memset_api = new_record
|
||||||
return(has_changed, has_failed, memset_api, msg)
|
return has_changed, has_failed, memset_api, msg
|
||||||
has_failed, msg, response = memset_api_call(api_key=args['api_key'], api_method=api_method, payload=payload)
|
has_failed, msg, response = memset_api_call(api_key=args['api_key'], api_method=api_method, payload=payload)
|
||||||
if not has_failed:
|
if not has_failed:
|
||||||
has_changed = True
|
has_changed = True
|
||||||
|
@ -246,7 +246,7 @@ def create_zone_record(args=None, zone_id=None, records=None, payload=None):
|
||||||
has_changed = True
|
has_changed = True
|
||||||
# populate the return var with the new record's details.
|
# populate the return var with the new record's details.
|
||||||
memset_api = new_record
|
memset_api = new_record
|
||||||
return(has_changed, has_failed, memset_api, msg)
|
return has_changed, has_failed, memset_api, msg
|
||||||
has_failed, msg, response = memset_api_call(api_key=args['api_key'], api_method=api_method, payload=payload)
|
has_failed, msg, response = memset_api_call(api_key=args['api_key'], api_method=api_method, payload=payload)
|
||||||
if not has_failed:
|
if not has_failed:
|
||||||
has_changed = True
|
has_changed = True
|
||||||
|
@ -254,7 +254,7 @@ def create_zone_record(args=None, zone_id=None, records=None, payload=None):
|
||||||
# empty msg as we don't want to return a boatload of json to the user.
|
# empty msg as we don't want to return a boatload of json to the user.
|
||||||
msg = None
|
msg = None
|
||||||
|
|
||||||
return(has_changed, has_failed, memset_api, msg)
|
return has_changed, has_failed, memset_api, msg
|
||||||
|
|
||||||
|
|
||||||
def delete_zone_record(args=None, records=None, payload=None):
|
def delete_zone_record(args=None, records=None, payload=None):
|
||||||
|
@ -270,7 +270,7 @@ def delete_zone_record(args=None, records=None, payload=None):
|
||||||
for zone_record in records:
|
for zone_record in records:
|
||||||
if args['check_mode']:
|
if args['check_mode']:
|
||||||
has_changed = True
|
has_changed = True
|
||||||
return(has_changed, has_failed, memset_api, msg)
|
return has_changed, has_failed, memset_api, msg
|
||||||
payload['id'] = zone_record['id']
|
payload['id'] = zone_record['id']
|
||||||
api_method = 'dns.zone_record_delete'
|
api_method = 'dns.zone_record_delete'
|
||||||
has_failed, msg, response = memset_api_call(api_key=args['api_key'], api_method=api_method, payload=payload)
|
has_failed, msg, response = memset_api_call(api_key=args['api_key'], api_method=api_method, payload=payload)
|
||||||
|
@ -280,7 +280,7 @@ def delete_zone_record(args=None, records=None, payload=None):
|
||||||
# empty msg as we don't want to return a boatload of json to the user.
|
# empty msg as we don't want to return a boatload of json to the user.
|
||||||
msg = None
|
msg = None
|
||||||
|
|
||||||
return(has_changed, has_failed, memset_api, msg)
|
return has_changed, has_failed, memset_api, msg
|
||||||
|
|
||||||
|
|
||||||
def create_or_delete(args=None):
|
def create_or_delete(args=None):
|
||||||
|
@ -304,7 +304,7 @@ def create_or_delete(args=None):
|
||||||
retvals['failed'] = _has_failed
|
retvals['failed'] = _has_failed
|
||||||
retvals['msg'] = msg
|
retvals['msg'] = msg
|
||||||
retvals['stderr'] = "API returned an error: {0}" . format(response.status_code)
|
retvals['stderr'] = "API returned an error: {0}" . format(response.status_code)
|
||||||
return(retvals)
|
return retvals
|
||||||
|
|
||||||
zone_exists, _msg, counter, zone_id = get_zone_id(zone_name=args['zone'], current_zones=response.json())
|
zone_exists, _msg, counter, zone_id = get_zone_id(zone_name=args['zone'], current_zones=response.json())
|
||||||
|
|
||||||
|
@ -317,7 +317,7 @@ def create_or_delete(args=None):
|
||||||
retvals['failed'] = has_failed
|
retvals['failed'] = has_failed
|
||||||
retvals['msg'] = stderr
|
retvals['msg'] = stderr
|
||||||
retvals['stderr'] = stderr
|
retvals['stderr'] = stderr
|
||||||
return(retvals)
|
return retvals
|
||||||
|
|
||||||
# get a list of all records ( as we can't limit records by zone)
|
# get a list of all records ( as we can't limit records by zone)
|
||||||
api_method = 'dns.zone_record_list'
|
api_method = 'dns.zone_record_list'
|
||||||
|
@ -339,7 +339,7 @@ def create_or_delete(args=None):
|
||||||
if val is not None:
|
if val is not None:
|
||||||
retvals[val] = eval(val)
|
retvals[val] = eval(val)
|
||||||
|
|
||||||
return(retvals)
|
return retvals
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
|
|
@ -1252,7 +1252,6 @@ def setChanged():
|
||||||
|
|
||||||
|
|
||||||
def setMsg(message):
|
def setMsg(message):
|
||||||
global failed
|
|
||||||
msg.append(message)
|
msg.append(message)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -346,7 +346,7 @@ def get_connection_info(module):
|
||||||
if not password:
|
if not password:
|
||||||
password = os.environ.get('ONE_PASSWORD')
|
password = os.environ.get('ONE_PASSWORD')
|
||||||
|
|
||||||
if not(url and username and password):
|
if not (url and username and password):
|
||||||
module.fail_json(msg="One or more connection parameters (api_url, api_username, api_password) were not specified")
|
module.fail_json(msg="One or more connection parameters (api_url, api_username, api_password) were not specified")
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
|
|
|
@ -240,7 +240,7 @@ def get_connection_info(module):
|
||||||
if not password:
|
if not password:
|
||||||
password = os.environ.get('ONE_PASSWORD')
|
password = os.environ.get('ONE_PASSWORD')
|
||||||
|
|
||||||
if not(url and username and password):
|
if not (url and username and password):
|
||||||
module.fail_json(msg="One or more connection parameters (api_url, api_username, api_password) were not specified")
|
module.fail_json(msg="One or more connection parameters (api_url, api_username, api_password) were not specified")
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
|
|
|
@ -660,7 +660,7 @@ def get_connection_info(module):
|
||||||
if not password:
|
if not password:
|
||||||
password = os.environ.get('ONEFLOW_PASSWORD')
|
password = os.environ.get('ONEFLOW_PASSWORD')
|
||||||
|
|
||||||
if not(url and username and password):
|
if not (url and username and password):
|
||||||
module.fail_json(msg="One or more connection parameters (api_url, api_username, api_password) were not specified")
|
module.fail_json(msg="One or more connection parameters (api_url, api_username, api_password) were not specified")
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
|
|
|
@ -216,7 +216,7 @@ def parse_subnet_cidr(cidr):
|
||||||
try:
|
try:
|
||||||
prefixlen = int(prefixlen)
|
prefixlen = int(prefixlen)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
raise("Wrong prefix length in CIDR expression {0}".format(cidr))
|
raise Exception("Wrong prefix length in CIDR expression {0}".format(cidr))
|
||||||
return addr, prefixlen
|
return addr, prefixlen
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -183,7 +183,7 @@ def remove_datacenter(module, profitbricks):
|
||||||
name = module.params.get('name')
|
name = module.params.get('name')
|
||||||
changed = False
|
changed = False
|
||||||
|
|
||||||
if(uuid_match.match(name)):
|
if uuid_match.match(name):
|
||||||
_remove_datacenter(module, profitbricks, name)
|
_remove_datacenter(module, profitbricks, name)
|
||||||
changed = True
|
changed = True
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -324,7 +324,7 @@ def delete_volume(module, profitbricks):
|
||||||
break
|
break
|
||||||
|
|
||||||
for n in instance_ids:
|
for n in instance_ids:
|
||||||
if(uuid_match.match(n)):
|
if uuid_match.match(n):
|
||||||
_delete_volume(module, profitbricks, datacenter, n)
|
_delete_volume(module, profitbricks, datacenter, n)
|
||||||
changed = True
|
changed = True
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -143,6 +143,7 @@ except ImportError:
|
||||||
IPADDRESS_IMP_ERR = traceback.format_exc()
|
IPADDRESS_IMP_ERR = traceback.format_exc()
|
||||||
HAS_IPADDRESS = False
|
HAS_IPADDRESS = False
|
||||||
else:
|
else:
|
||||||
|
IPADDRESS_IMP_ERR = None
|
||||||
HAS_IPADDRESS = True
|
HAS_IPADDRESS = True
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -126,6 +126,7 @@ from ansible.module_utils.common.text.converters import to_native
|
||||||
try:
|
try:
|
||||||
import etcd3
|
import etcd3
|
||||||
HAS_ETCD = True
|
HAS_ETCD = True
|
||||||
|
ETCD_IMP_ERR = None
|
||||||
except ImportError:
|
except ImportError:
|
||||||
ETCD_IMP_ERR = traceback.format_exc()
|
ETCD_IMP_ERR = traceback.format_exc()
|
||||||
HAS_ETCD = False
|
HAS_ETCD = False
|
||||||
|
|
|
@ -309,7 +309,7 @@ def do_ini(module, filename, section=None, option=None, values=None,
|
||||||
# override option with no value to option with value if not allow_no_value
|
# override option with no value to option with value if not allow_no_value
|
||||||
if len(values) > 0:
|
if len(values) > 0:
|
||||||
for index, line in enumerate(section_lines):
|
for index, line in enumerate(section_lines):
|
||||||
if not changed_lines[index] and match_active_opt(option, section_lines[index]):
|
if not changed_lines[index] and match_active_opt(option, section_lines[index]): # pylint: disable=unnecessary-list-index-lookup
|
||||||
newline = assignment_format % (option, values.pop(0))
|
newline = assignment_format % (option, values.pop(0))
|
||||||
(changed, msg) = update_section_line(changed, section_lines, index, changed_lines, newline, msg)
|
(changed, msg) = update_section_line(changed, section_lines, index, changed_lines, newline, msg)
|
||||||
if len(values) == 0:
|
if len(values) == 0:
|
||||||
|
|
|
@ -445,8 +445,8 @@ def ensure(module, client):
|
||||||
module_otptoken['all'] = True
|
module_otptoken['all'] = True
|
||||||
ipa_otptoken = client.otptoken_add(name=uniqueid, item=module_otptoken)
|
ipa_otptoken = client.otptoken_add(name=uniqueid, item=module_otptoken)
|
||||||
else:
|
else:
|
||||||
if not(validate_modifications(ansible_to_ipa, module, ipa_otptoken,
|
if not validate_modifications(ansible_to_ipa, module, ipa_otptoken,
|
||||||
module_otptoken, unmodifiable_after_creation)):
|
module_otptoken, unmodifiable_after_creation):
|
||||||
module.fail_json(msg="Modifications requested in module are not valid")
|
module.fail_json(msg="Modifications requested in module are not valid")
|
||||||
|
|
||||||
# IPA will reject 'modifications' that do not actually modify anything
|
# IPA will reject 'modifications' that do not actually modify anything
|
||||||
|
|
|
@ -86,6 +86,7 @@ from os import path
|
||||||
try:
|
try:
|
||||||
from pdpyras import APISession
|
from pdpyras import APISession
|
||||||
HAS_PD_PY = True
|
HAS_PD_PY = True
|
||||||
|
PD_IMPORT_ERR = None
|
||||||
except ImportError:
|
except ImportError:
|
||||||
HAS_PD_PY = False
|
HAS_PD_PY = False
|
||||||
PD_IMPORT_ERR = traceback.format_exc()
|
PD_IMPORT_ERR = traceback.format_exc()
|
||||||
|
@ -93,6 +94,7 @@ except ImportError:
|
||||||
try:
|
try:
|
||||||
from pdpyras import PDClientError
|
from pdpyras import PDClientError
|
||||||
HAS_PD_CLIENT_ERR = True
|
HAS_PD_CLIENT_ERR = True
|
||||||
|
PD_CLIENT_ERR_IMPORT_ERR = None
|
||||||
except ImportError:
|
except ImportError:
|
||||||
HAS_PD_CLIENT_ERR = False
|
HAS_PD_CLIENT_ERR = False
|
||||||
PD_CLIENT_ERR_IMPORT_ERR = traceback.format_exc()
|
PD_CLIENT_ERR_IMPORT_ERR = traceback.format_exc()
|
||||||
|
|
|
@ -233,10 +233,11 @@ import json
|
||||||
try:
|
try:
|
||||||
from requests import Request, Session
|
from requests import Request, Session
|
||||||
except ImportError:
|
except ImportError:
|
||||||
HAS_ANOTHER_LIBRARY = False
|
HAS_REQUESTS = False
|
||||||
ANOTHER_LIBRARY_IMPORT_ERROR = traceback.format_exc()
|
REQUESTS_IMPORT_ERROR = traceback.format_exc()
|
||||||
else:
|
else:
|
||||||
HAS_ANOTHER_LIBRARY = True
|
HAS_REQUESTS = True
|
||||||
|
REQUESTS_IMPORT_ERROR = None
|
||||||
|
|
||||||
|
|
||||||
def build_url(account, key, is_sandbox):
|
def build_url(account, key, is_sandbox):
|
||||||
|
@ -261,7 +262,7 @@ def iterate_data(module, request_object):
|
||||||
request_object.url = base_url + '&page=' + str(page)
|
request_object.url = base_url + '&page=' + str(page)
|
||||||
new_results = Session().send(request_object)
|
new_results = Session().send(request_object)
|
||||||
data = data + new_results.json()["data"]
|
data = data + new_results.json()["data"]
|
||||||
return(data)
|
return data
|
||||||
else:
|
else:
|
||||||
module.fail_json('API Call failed, check ID, key and sandbox values')
|
module.fail_json('API Call failed, check ID, key and sandbox values')
|
||||||
|
|
||||||
|
@ -305,11 +306,10 @@ def main():
|
||||||
params['api_key'],
|
params['api_key'],
|
||||||
params['sandbox'])
|
params['sandbox'])
|
||||||
|
|
||||||
if not HAS_ANOTHER_LIBRARY:
|
if not HAS_REQUESTS:
|
||||||
# Needs: from ansible.module_utils.basic import missing_required_lib
|
|
||||||
module.exit_json(
|
module.exit_json(
|
||||||
msg=missing_required_lib('another_library'),
|
msg=missing_required_lib('requests'),
|
||||||
exception=ANOTHER_LIBRARY_IMPORT_ERROR)
|
exception=REQUESTS_IMPORT_ERROR)
|
||||||
|
|
||||||
# At minimum we need account and key
|
# At minimum we need account and key
|
||||||
if params['account_id'] and params['api_key']:
|
if params['account_id'] and params['api_key']:
|
||||||
|
|
|
@ -97,13 +97,13 @@ from ansible.module_utils.facts.packages import CLIMgr
|
||||||
|
|
||||||
class PIP(CLIMgr):
|
class PIP(CLIMgr):
|
||||||
|
|
||||||
def __init__(self, pip):
|
def __init__(self, pip, module):
|
||||||
|
|
||||||
self.CLI = pip
|
self.CLI = pip
|
||||||
|
self.module = module
|
||||||
|
|
||||||
def list_installed(self):
|
def list_installed(self):
|
||||||
global module
|
rc, out, err = self.module.run_command([self._cli, 'list', '-l', '--format=json'])
|
||||||
rc, out, err = module.run_command([self._cli, 'list', '-l', '--format=json'])
|
|
||||||
if rc != 0:
|
if rc != 0:
|
||||||
raise Exception("Unable to list packages rc=%s : %s" % (rc, err))
|
raise Exception("Unable to list packages rc=%s : %s" % (rc, err))
|
||||||
return json.loads(out)
|
return json.loads(out)
|
||||||
|
@ -116,7 +116,6 @@ class PIP(CLIMgr):
|
||||||
def main():
|
def main():
|
||||||
|
|
||||||
# start work
|
# start work
|
||||||
global module
|
|
||||||
module = AnsibleModule(
|
module = AnsibleModule(
|
||||||
argument_spec=dict(
|
argument_spec=dict(
|
||||||
clients=dict(type='list', elements='path', default=['pip']),
|
clients=dict(type='list', elements='path', default=['pip']),
|
||||||
|
@ -133,7 +132,7 @@ def main():
|
||||||
module.warn('Skipping invalid pip client: %s' % (pip))
|
module.warn('Skipping invalid pip client: %s' % (pip))
|
||||||
continue
|
continue
|
||||||
try:
|
try:
|
||||||
pip_mgr = PIP(pip)
|
pip_mgr = PIP(pip, module)
|
||||||
if pip_mgr.is_available():
|
if pip_mgr.is_available():
|
||||||
found += 1
|
found += 1
|
||||||
packages[pip] = pip_mgr.get_packages()
|
packages[pip] = pip_mgr.get_packages()
|
||||||
|
|
|
@ -224,7 +224,7 @@ class Yarn(object):
|
||||||
rc, out, err = self.module.run_command(cmd, check_rc=check_rc, cwd=cwd)
|
rc, out, err = self.module.run_command(cmd, check_rc=check_rc, cwd=cwd)
|
||||||
return out, err
|
return out, err
|
||||||
|
|
||||||
return(None, None)
|
return None, None
|
||||||
|
|
||||||
def list(self):
|
def list(self):
|
||||||
cmd = ['list', '--depth=0', '--json']
|
cmd = ['list', '--depth=0', '--json']
|
||||||
|
|
|
@ -84,6 +84,7 @@ try:
|
||||||
import dnf.repodict
|
import dnf.repodict
|
||||||
from dnf.conf import Conf
|
from dnf.conf import Conf
|
||||||
HAS_DNF_PACKAGES = True
|
HAS_DNF_PACKAGES = True
|
||||||
|
DNF_IMP_ERR = None
|
||||||
except ImportError:
|
except ImportError:
|
||||||
DNF_IMP_ERR = traceback.format_exc()
|
DNF_IMP_ERR = traceback.format_exc()
|
||||||
HAS_DNF_PACKAGES = False
|
HAS_DNF_PACKAGES = False
|
||||||
|
|
|
@ -162,7 +162,7 @@ OUTDATED_FLATPAK_VERSION_ERROR_MESSAGE = "Unknown option --columns=application"
|
||||||
|
|
||||||
def install_flat(module, binary, remote, names, method, no_dependencies):
|
def install_flat(module, binary, remote, names, method, no_dependencies):
|
||||||
"""Add new flatpaks."""
|
"""Add new flatpaks."""
|
||||||
global result
|
global result # pylint: disable=global-variable-not-assigned
|
||||||
uri_names = []
|
uri_names = []
|
||||||
id_names = []
|
id_names = []
|
||||||
for name in names:
|
for name in names:
|
||||||
|
@ -189,7 +189,7 @@ def install_flat(module, binary, remote, names, method, no_dependencies):
|
||||||
|
|
||||||
def uninstall_flat(module, binary, names, method):
|
def uninstall_flat(module, binary, names, method):
|
||||||
"""Remove existing flatpaks."""
|
"""Remove existing flatpaks."""
|
||||||
global result
|
global result # pylint: disable=global-variable-not-assigned
|
||||||
installed_flat_names = [
|
installed_flat_names = [
|
||||||
_match_installed_flat_name(module, binary, name, method)
|
_match_installed_flat_name(module, binary, name, method)
|
||||||
for name in names
|
for name in names
|
||||||
|
@ -224,7 +224,7 @@ def _match_installed_flat_name(module, binary, name, method):
|
||||||
# This is a difficult function, since if the user supplies a flatpakref url,
|
# This is a difficult function, since if the user supplies a flatpakref url,
|
||||||
# we have to rely on a naming convention:
|
# we have to rely on a naming convention:
|
||||||
# The flatpakref file name needs to match the flatpak name
|
# The flatpakref file name needs to match the flatpak name
|
||||||
global result
|
global result # pylint: disable=global-variable-not-assigned
|
||||||
parsed_name = _parse_flatpak_name(name)
|
parsed_name = _parse_flatpak_name(name)
|
||||||
# Try running flatpak list with columns feature
|
# Try running flatpak list with columns feature
|
||||||
command = [binary, "list", "--{0}".format(method), "--app", "--columns=application"]
|
command = [binary, "list", "--{0}".format(method), "--app", "--columns=application"]
|
||||||
|
@ -248,7 +248,7 @@ def _match_installed_flat_name(module, binary, name, method):
|
||||||
|
|
||||||
|
|
||||||
def _match_flat_using_outdated_flatpak_format(module, binary, parsed_name, method):
|
def _match_flat_using_outdated_flatpak_format(module, binary, parsed_name, method):
|
||||||
global result
|
global result # pylint: disable=global-variable-not-assigned
|
||||||
command = [binary, "list", "--{0}".format(method), "--app", "--columns=application"]
|
command = [binary, "list", "--{0}".format(method), "--app", "--columns=application"]
|
||||||
output = _flatpak_command(module, False, command)
|
output = _flatpak_command(module, False, command)
|
||||||
for row in output.split('\n'):
|
for row in output.split('\n'):
|
||||||
|
@ -257,7 +257,7 @@ def _match_flat_using_outdated_flatpak_format(module, binary, parsed_name, metho
|
||||||
|
|
||||||
|
|
||||||
def _match_flat_using_flatpak_column_feature(module, binary, parsed_name, method):
|
def _match_flat_using_flatpak_column_feature(module, binary, parsed_name, method):
|
||||||
global result
|
global result # pylint: disable=global-variable-not-assigned
|
||||||
command = [binary, "list", "--{0}".format(method), "--app"]
|
command = [binary, "list", "--{0}".format(method), "--app"]
|
||||||
output = _flatpak_command(module, False, command)
|
output = _flatpak_command(module, False, command)
|
||||||
for row in output.split('\n'):
|
for row in output.split('\n'):
|
||||||
|
@ -276,7 +276,7 @@ def _parse_flatpak_name(name):
|
||||||
|
|
||||||
|
|
||||||
def _flatpak_version(module, binary):
|
def _flatpak_version(module, binary):
|
||||||
global result
|
global result # pylint: disable=global-variable-not-assigned
|
||||||
command = [binary, "--version"]
|
command = [binary, "--version"]
|
||||||
output = _flatpak_command(module, False, command)
|
output = _flatpak_command(module, False, command)
|
||||||
version_number = output.split()[1]
|
version_number = output.split()[1]
|
||||||
|
@ -284,7 +284,7 @@ def _flatpak_version(module, binary):
|
||||||
|
|
||||||
|
|
||||||
def _flatpak_command(module, noop, command, ignore_failure=False):
|
def _flatpak_command(module, noop, command, ignore_failure=False):
|
||||||
global result
|
global result # pylint: disable=global-variable-not-assigned
|
||||||
result['command'] = ' '.join(command)
|
result['command'] = ' '.join(command)
|
||||||
if noop:
|
if noop:
|
||||||
result['rc'] = 0
|
result['rc'] = 0
|
||||||
|
|
|
@ -124,7 +124,7 @@ from ansible.module_utils.common.text.converters import to_bytes, to_native
|
||||||
|
|
||||||
def add_remote(module, binary, name, flatpakrepo_url, method):
|
def add_remote(module, binary, name, flatpakrepo_url, method):
|
||||||
"""Add a new remote."""
|
"""Add a new remote."""
|
||||||
global result
|
global result # pylint: disable=global-variable-not-assigned
|
||||||
command = [binary, "remote-add", "--{0}".format(method), name, flatpakrepo_url]
|
command = [binary, "remote-add", "--{0}".format(method), name, flatpakrepo_url]
|
||||||
_flatpak_command(module, module.check_mode, command)
|
_flatpak_command(module, module.check_mode, command)
|
||||||
result['changed'] = True
|
result['changed'] = True
|
||||||
|
@ -132,7 +132,7 @@ def add_remote(module, binary, name, flatpakrepo_url, method):
|
||||||
|
|
||||||
def remove_remote(module, binary, name, method):
|
def remove_remote(module, binary, name, method):
|
||||||
"""Remove an existing remote."""
|
"""Remove an existing remote."""
|
||||||
global result
|
global result # pylint: disable=global-variable-not-assigned
|
||||||
command = [binary, "remote-delete", "--{0}".format(method), "--force", name]
|
command = [binary, "remote-delete", "--{0}".format(method), "--force", name]
|
||||||
_flatpak_command(module, module.check_mode, command)
|
_flatpak_command(module, module.check_mode, command)
|
||||||
result['changed'] = True
|
result['changed'] = True
|
||||||
|
@ -153,7 +153,7 @@ def remote_exists(module, binary, name, method):
|
||||||
|
|
||||||
|
|
||||||
def _flatpak_command(module, noop, command):
|
def _flatpak_command(module, noop, command):
|
||||||
global result
|
global result # pylint: disable=global-variable-not-assigned
|
||||||
result['command'] = ' '.join(command)
|
result['command'] = ' '.join(command)
|
||||||
if noop:
|
if noop:
|
||||||
result['rc'] = 0
|
result['rc'] = 0
|
||||||
|
|
|
@ -160,7 +160,7 @@ def upgrade(module, xbps_path):
|
||||||
|
|
||||||
rc, stdout, stderr = module.run_command(cmdneedupgrade, check_rc=False)
|
rc, stdout, stderr = module.run_command(cmdneedupgrade, check_rc=False)
|
||||||
if rc == 0:
|
if rc == 0:
|
||||||
if(len(stdout.splitlines()) == 0):
|
if len(stdout.splitlines()) == 0:
|
||||||
module.exit_json(changed=False, msg='Nothing to upgrade')
|
module.exit_json(changed=False, msg='Nothing to upgrade')
|
||||||
elif module.check_mode:
|
elif module.check_mode:
|
||||||
module.exit_json(changed=True, msg='Would have performed upgrade')
|
module.exit_json(changed=True, msg='Would have performed upgrade')
|
||||||
|
|
|
@ -238,7 +238,7 @@ class ManageIQAlertProfiles(object):
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
msg = "Updating profile '{name}' failed: {error}"
|
msg = "Updating profile '{name}' failed: {error}"
|
||||||
msg = msg.format(name=old_profile['name'], error=e)
|
msg = msg.format(name=old_profile['name'], error=e)
|
||||||
self.module.fail_json(msg=msg, result=result)
|
self.module.fail_json(msg=msg)
|
||||||
|
|
||||||
if changed:
|
if changed:
|
||||||
msg = "Profile {name} updated successfully".format(name=desired_profile['name'])
|
msg = "Profile {name} updated successfully".format(name=desired_profile['name'])
|
||||||
|
|
|
@ -160,6 +160,7 @@ import traceback
|
||||||
try:
|
try:
|
||||||
import gitlab
|
import gitlab
|
||||||
HAS_PY_GITLAB = True
|
HAS_PY_GITLAB = True
|
||||||
|
GITLAB_IMP_ERR = None
|
||||||
except ImportError:
|
except ImportError:
|
||||||
GITLAB_IMP_ERR = traceback.format_exc()
|
GITLAB_IMP_ERR = traceback.format_exc()
|
||||||
HAS_PY_GITLAB = False
|
HAS_PY_GITLAB = False
|
||||||
|
|
|
@ -163,6 +163,7 @@ import traceback
|
||||||
try:
|
try:
|
||||||
import gitlab
|
import gitlab
|
||||||
HAS_PY_GITLAB = True
|
HAS_PY_GITLAB = True
|
||||||
|
GITLAB_IMP_ERR = None
|
||||||
except ImportError:
|
except ImportError:
|
||||||
GITLAB_IMP_ERR = traceback.format_exc()
|
GITLAB_IMP_ERR = traceback.format_exc()
|
||||||
HAS_PY_GITLAB = False
|
HAS_PY_GITLAB = False
|
||||||
|
|
|
@ -188,7 +188,7 @@ from ansible.module_utils.common.text.converters import to_native
|
||||||
from ansible_collections.community.general.plugins.module_utils.gitlab import auth_argument_spec, gitlab_authentication
|
from ansible_collections.community.general.plugins.module_utils.gitlab import auth_argument_spec, gitlab_authentication
|
||||||
|
|
||||||
try:
|
try:
|
||||||
cmp
|
cmp # pylint: disable=used-before-assignment
|
||||||
except NameError:
|
except NameError:
|
||||||
def cmp(a, b):
|
def cmp(a, b):
|
||||||
return (a > b) - (a < b)
|
return (a > b) - (a < b)
|
||||||
|
|
|
@ -211,6 +211,7 @@ except ImportError:
|
||||||
XMLTODICT_LIBRARY_IMPORT_ERROR = traceback.format_exc()
|
XMLTODICT_LIBRARY_IMPORT_ERROR = traceback.format_exc()
|
||||||
else:
|
else:
|
||||||
HAS_XMLTODICT_LIBRARY = True
|
HAS_XMLTODICT_LIBRARY = True
|
||||||
|
XMLTODICT_LIBRARY_IMPORT_ERROR = None
|
||||||
|
|
||||||
|
|
||||||
class PersistentMemory(object):
|
class PersistentMemory(object):
|
||||||
|
|
|
@ -164,10 +164,10 @@ class BE(object):
|
||||||
for line in out.splitlines():
|
for line in out.splitlines():
|
||||||
if self.is_freebsd:
|
if self.is_freebsd:
|
||||||
check = line.split()
|
check = line.split()
|
||||||
if(check == []):
|
if check == []:
|
||||||
continue
|
continue
|
||||||
full_name = check[0].split('/')
|
full_name = check[0].split('/')
|
||||||
if(full_name == []):
|
if full_name == []:
|
||||||
continue
|
continue
|
||||||
check[0] = full_name[len(full_name) - 1]
|
check[0] = full_name[len(full_name) - 1]
|
||||||
if check[0] == self.name:
|
if check[0] == self.name:
|
||||||
|
|
|
@ -328,7 +328,7 @@ class Homectl(object):
|
||||||
cmd = [self.module.get_bin_path('homectl', True)]
|
cmd = [self.module.get_bin_path('homectl', True)]
|
||||||
cmd.append('create')
|
cmd.append('create')
|
||||||
cmd.append('--identity=-') # Read the user record from standard input.
|
cmd.append('--identity=-') # Read the user record from standard input.
|
||||||
return(self.module.run_command(cmd, data=record))
|
return self.module.run_command(cmd, data=record)
|
||||||
|
|
||||||
def _hash_password(self, password):
|
def _hash_password(self, password):
|
||||||
method = crypt.METHOD_SHA512
|
method = crypt.METHOD_SHA512
|
||||||
|
|
|
@ -362,7 +362,7 @@ def format_disk_size(size_bytes, unit):
|
||||||
This function has been adapted from https://github.com/Distrotech/parted/blo
|
This function has been adapted from https://github.com/Distrotech/parted/blo
|
||||||
b/279d9d869ff472c52b9ec2e180d568f0c99e30b0/libparted/unit.c
|
b/279d9d869ff472c52b9ec2e180d568f0c99e30b0/libparted/unit.c
|
||||||
"""
|
"""
|
||||||
global units_si, units_iec
|
global units_si, units_iec # pylint: disable=global-variable-not-assigned
|
||||||
|
|
||||||
unit = unit.lower()
|
unit = unit.lower()
|
||||||
|
|
||||||
|
@ -458,7 +458,7 @@ def get_device_info(device, unit):
|
||||||
Fetches information about a disk and its partitions and it returns a
|
Fetches information about a disk and its partitions and it returns a
|
||||||
dictionary.
|
dictionary.
|
||||||
"""
|
"""
|
||||||
global module, parted_exec
|
global module, parted_exec # pylint: disable=global-variable-not-assigned
|
||||||
|
|
||||||
# If parted complains about missing labels, it means there are no partitions.
|
# If parted complains about missing labels, it means there are no partitions.
|
||||||
# In this case only, use a custom function to fetch information and emulate
|
# In this case only, use a custom function to fetch information and emulate
|
||||||
|
@ -485,7 +485,7 @@ def check_parted_label(device):
|
||||||
to 3.1 don't return data when there is no label. For more information see:
|
to 3.1 don't return data when there is no label. For more information see:
|
||||||
http://upstream.rosalinux.ru/changelogs/libparted/3.1/changelog.html
|
http://upstream.rosalinux.ru/changelogs/libparted/3.1/changelog.html
|
||||||
"""
|
"""
|
||||||
global parted_exec
|
global parted_exec # pylint: disable=global-variable-not-assigned
|
||||||
|
|
||||||
# Check the version
|
# Check the version
|
||||||
parted_major, parted_minor, dummy = parted_version()
|
parted_major, parted_minor, dummy = parted_version()
|
||||||
|
@ -531,7 +531,7 @@ def parted_version():
|
||||||
"""
|
"""
|
||||||
Returns the major and minor version of parted installed on the system.
|
Returns the major and minor version of parted installed on the system.
|
||||||
"""
|
"""
|
||||||
global module, parted_exec
|
global module, parted_exec # pylint: disable=global-variable-not-assigned
|
||||||
|
|
||||||
rc, out, err = module.run_command("%s --version" % parted_exec)
|
rc, out, err = module.run_command("%s --version" % parted_exec)
|
||||||
if rc != 0:
|
if rc != 0:
|
||||||
|
@ -550,7 +550,7 @@ def parted(script, device, align):
|
||||||
"""
|
"""
|
||||||
Runs a parted script.
|
Runs a parted script.
|
||||||
"""
|
"""
|
||||||
global module, parted_exec
|
global module, parted_exec # pylint: disable=global-variable-not-assigned
|
||||||
|
|
||||||
align_option = '-a %s' % align
|
align_option = '-a %s' % align
|
||||||
if align == 'undefined':
|
if align == 'undefined':
|
||||||
|
@ -601,7 +601,7 @@ def check_size_format(size_str):
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
global module, units_si, units_iec, parted_exec
|
global module, units_si, units_iec, parted_exec # pylint: disable=global-variable-not-assigned
|
||||||
|
|
||||||
changed = False
|
changed = False
|
||||||
output_script = ""
|
output_script = ""
|
||||||
|
|
|
@ -187,6 +187,7 @@ except ImportError:
|
||||||
PYRFC_LIBRARY_IMPORT_ERROR = traceback.format_exc()
|
PYRFC_LIBRARY_IMPORT_ERROR = traceback.format_exc()
|
||||||
else:
|
else:
|
||||||
HAS_PYRFC_LIBRARY = True
|
HAS_PYRFC_LIBRARY = True
|
||||||
|
PYRFC_LIBRARY_IMPORT_ERROR = None
|
||||||
try:
|
try:
|
||||||
import xmltodict
|
import xmltodict
|
||||||
except ImportError:
|
except ImportError:
|
||||||
|
@ -194,6 +195,7 @@ except ImportError:
|
||||||
XMLTODICT_LIBRARY_IMPORT_ERROR = traceback.format_exc()
|
XMLTODICT_LIBRARY_IMPORT_ERROR = traceback.format_exc()
|
||||||
else:
|
else:
|
||||||
HAS_XMLTODICT_LIBRARY = True
|
HAS_XMLTODICT_LIBRARY = True
|
||||||
|
XMLTODICT_LIBRARY_IMPORT_ERROR = None
|
||||||
|
|
||||||
|
|
||||||
def call_rfc_method(connection, method_name, kwargs):
|
def call_rfc_method(connection, method_name, kwargs):
|
||||||
|
|
|
@ -261,8 +261,8 @@ class BalancerMember(object):
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
soup = BeautifulSoup(balancer_member_page[0])
|
soup = BeautifulSoup(balancer_member_page[0])
|
||||||
except TypeError:
|
except TypeError as exc:
|
||||||
self.module.fail_json(msg="Cannot parse balancer_member_page HTML! " + str(soup))
|
self.module.fail_json(msg="Cannot parse balancer_member_page HTML! " + str(exc))
|
||||||
else:
|
else:
|
||||||
subsoup = soup.findAll('table')[1].findAll('tr')
|
subsoup = soup.findAll('table')[1].findAll('tr')
|
||||||
keys = subsoup[0].findAll('th')
|
keys = subsoup[0].findAll('th')
|
||||||
|
|
|
@ -61,7 +61,7 @@ if HAS_TLS and ssl_ctx is not None:
|
||||||
smtp_server2 = smtpd_tls.DebuggingServer(('127.0.0.1', port2), None, ssl_ctx=ssl_ctx, starttls=False)
|
smtp_server2 = smtpd_tls.DebuggingServer(('127.0.0.1', port2), None, ssl_ctx=ssl_ctx, starttls=False)
|
||||||
else:
|
else:
|
||||||
print('Start SMTP server on port', port1)
|
print('Start SMTP server on port', port1)
|
||||||
smtp_server1 = smtpd.DebuggingServer(('127.0.0.1', port1), None)
|
smtp_server1 = smtpd.DebuggingServer(('127.0.0.1', port1), None) # pylint: disable=used-before-assignment
|
||||||
if port2:
|
if port2:
|
||||||
print('WARNING: TLS is NOT supported on this system, not listening on port %s.' % port2)
|
print('WARNING: TLS is NOT supported on this system, not listening on port %s.' % port2)
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,7 @@ plugins/modules/cloud/univention/udm_user.py validate-modules:parameter-list-no-
|
||||||
plugins/modules/clustering/consul/consul.py validate-modules:doc-missing-type
|
plugins/modules/clustering/consul/consul.py validate-modules:doc-missing-type
|
||||||
plugins/modules/clustering/consul/consul.py validate-modules:undocumented-parameter
|
plugins/modules/clustering/consul/consul.py validate-modules:undocumented-parameter
|
||||||
plugins/modules/clustering/consul/consul_session.py validate-modules:parameter-state-invalid-choice
|
plugins/modules/clustering/consul/consul_session.py validate-modules:parameter-state-invalid-choice
|
||||||
|
plugins/modules/files/ini_file.py pylint:bad-option-value
|
||||||
plugins/modules/packaging/language/composer.py validate-modules:parameter-invalid # invalid alias - removed in 5.0.0
|
plugins/modules/packaging/language/composer.py validate-modules:parameter-invalid # invalid alias - removed in 5.0.0
|
||||||
plugins/modules/packaging/language/yarn.py use-argspec-type-path
|
plugins/modules/packaging/language/yarn.py use-argspec-type-path
|
||||||
plugins/modules/packaging/os/apt_rpm.py validate-modules:parameter-invalid # invalid alias - removed in 5.0.0
|
plugins/modules/packaging/os/apt_rpm.py validate-modules:parameter-invalid # invalid alias - removed in 5.0.0
|
||||||
|
|
|
@ -23,6 +23,7 @@ plugins/modules/cloud/univention/udm_user.py validate-modules:parameter-list-no-
|
||||||
plugins/modules/clustering/consul/consul.py validate-modules:doc-missing-type
|
plugins/modules/clustering/consul/consul.py validate-modules:doc-missing-type
|
||||||
plugins/modules/clustering/consul/consul.py validate-modules:undocumented-parameter
|
plugins/modules/clustering/consul/consul.py validate-modules:undocumented-parameter
|
||||||
plugins/modules/clustering/consul/consul_session.py validate-modules:parameter-state-invalid-choice
|
plugins/modules/clustering/consul/consul_session.py validate-modules:parameter-state-invalid-choice
|
||||||
|
plugins/modules/files/ini_file.py pylint:bad-option-value
|
||||||
plugins/modules/packaging/language/composer.py validate-modules:parameter-invalid # invalid alias - removed in 5.0.0
|
plugins/modules/packaging/language/composer.py validate-modules:parameter-invalid # invalid alias - removed in 5.0.0
|
||||||
plugins/modules/packaging/language/yarn.py use-argspec-type-path
|
plugins/modules/packaging/language/yarn.py use-argspec-type-path
|
||||||
plugins/modules/packaging/os/apt_rpm.py validate-modules:parameter-invalid # invalid alias - removed in 5.0.0
|
plugins/modules/packaging/os/apt_rpm.py validate-modules:parameter-invalid # invalid alias - removed in 5.0.0
|
||||||
|
|
|
@ -18,6 +18,7 @@ plugins/modules/cloud/univention/udm_user.py validate-modules:parameter-list-no-
|
||||||
plugins/modules/clustering/consul/consul.py validate-modules:doc-missing-type
|
plugins/modules/clustering/consul/consul.py validate-modules:doc-missing-type
|
||||||
plugins/modules/clustering/consul/consul.py validate-modules:undocumented-parameter
|
plugins/modules/clustering/consul/consul.py validate-modules:undocumented-parameter
|
||||||
plugins/modules/clustering/consul/consul_session.py validate-modules:parameter-state-invalid-choice
|
plugins/modules/clustering/consul/consul_session.py validate-modules:parameter-state-invalid-choice
|
||||||
|
plugins/modules/files/ini_file.py pylint:bad-option-value
|
||||||
plugins/modules/packaging/language/composer.py validate-modules:parameter-invalid # invalid alias - removed in 5.0.0
|
plugins/modules/packaging/language/composer.py validate-modules:parameter-invalid # invalid alias - removed in 5.0.0
|
||||||
plugins/modules/packaging/language/yarn.py use-argspec-type-path
|
plugins/modules/packaging/language/yarn.py use-argspec-type-path
|
||||||
plugins/modules/packaging/os/apt_rpm.py validate-modules:parameter-invalid # invalid alias - removed in 5.0.0
|
plugins/modules/packaging/os/apt_rpm.py validate-modules:parameter-invalid # invalid alias - removed in 5.0.0
|
||||||
|
|
|
@ -18,6 +18,7 @@ plugins/modules/cloud/univention/udm_user.py validate-modules:parameter-list-no-
|
||||||
plugins/modules/clustering/consul/consul.py validate-modules:doc-missing-type
|
plugins/modules/clustering/consul/consul.py validate-modules:doc-missing-type
|
||||||
plugins/modules/clustering/consul/consul.py validate-modules:undocumented-parameter
|
plugins/modules/clustering/consul/consul.py validate-modules:undocumented-parameter
|
||||||
plugins/modules/clustering/consul/consul_session.py validate-modules:parameter-state-invalid-choice
|
plugins/modules/clustering/consul/consul_session.py validate-modules:parameter-state-invalid-choice
|
||||||
|
plugins/modules/files/ini_file.py pylint:bad-option-value
|
||||||
plugins/modules/packaging/language/composer.py validate-modules:parameter-invalid # invalid alias - removed in 5.0.0
|
plugins/modules/packaging/language/composer.py validate-modules:parameter-invalid # invalid alias - removed in 5.0.0
|
||||||
plugins/modules/packaging/language/yarn.py use-argspec-type-path
|
plugins/modules/packaging/language/yarn.py use-argspec-type-path
|
||||||
plugins/modules/packaging/os/apt_rpm.py validate-modules:parameter-invalid # invalid alias - removed in 5.0.0
|
plugins/modules/packaging/os/apt_rpm.py validate-modules:parameter-invalid # invalid alias - removed in 5.0.0
|
||||||
|
|
|
@ -18,6 +18,7 @@ plugins/modules/cloud/spotinst/spotinst_aws_elastigroup.py validate-modules:para
|
||||||
plugins/modules/cloud/spotinst/spotinst_aws_elastigroup.py validate-modules:undocumented-parameter
|
plugins/modules/cloud/spotinst/spotinst_aws_elastigroup.py validate-modules:undocumented-parameter
|
||||||
plugins/modules/clustering/consul/consul.py validate-modules:doc-missing-type
|
plugins/modules/clustering/consul/consul.py validate-modules:doc-missing-type
|
||||||
plugins/modules/clustering/consul/consul.py validate-modules:undocumented-parameter
|
plugins/modules/clustering/consul/consul.py validate-modules:undocumented-parameter
|
||||||
|
plugins/modules/files/ini_file.py pylint:bad-option-value
|
||||||
plugins/modules/packaging/language/composer.py validate-modules:parameter-invalid # invalid alias - removed in 5.0.0
|
plugins/modules/packaging/language/composer.py validate-modules:parameter-invalid # invalid alias - removed in 5.0.0
|
||||||
plugins/modules/packaging/language/yarn.py use-argspec-type-path
|
plugins/modules/packaging/language/yarn.py use-argspec-type-path
|
||||||
plugins/modules/packaging/os/apt_rpm.py validate-modules:parameter-invalid # invalid alias - removed in 5.0.0
|
plugins/modules/packaging/os/apt_rpm.py validate-modules:parameter-invalid # invalid alias - removed in 5.0.0
|
||||||
|
|
|
@ -73,8 +73,8 @@ class TestMyModule():
|
||||||
}
|
}
|
||||||
mod_obj.params = args
|
mod_obj.params = args
|
||||||
lxca_cmms.main()
|
lxca_cmms.main()
|
||||||
assert(mock.call(argument_spec=expected_arguments_spec,
|
assert mock.call(argument_spec=expected_arguments_spec,
|
||||||
supports_check_mode=False) == ansible_mod_cls.call_args)
|
supports_check_mode=False) == ansible_mod_cls.call_args
|
||||||
|
|
||||||
@mock.patch('ansible_collections.community.general.plugins.module_utils.remote_management.lxca.common.setup_conn', autospec=True)
|
@mock.patch('ansible_collections.community.general.plugins.module_utils.remote_management.lxca.common.setup_conn', autospec=True)
|
||||||
@mock.patch('ansible_collections.community.general.plugins.modules.remote_management.lxca.lxca_cmms._cmms_by_uuid',
|
@mock.patch('ansible_collections.community.general.plugins.modules.remote_management.lxca.lxca_cmms._cmms_by_uuid',
|
||||||
|
|
|
@ -77,8 +77,8 @@ class TestMyModule():
|
||||||
}
|
}
|
||||||
mod_obj.params = args
|
mod_obj.params = args
|
||||||
lxca_nodes.main()
|
lxca_nodes.main()
|
||||||
assert(mock.call(argument_spec=expected_arguments_spec,
|
assert mock.call(argument_spec=expected_arguments_spec,
|
||||||
supports_check_mode=False) == ansible_mod_cls.call_args)
|
supports_check_mode=False) == ansible_mod_cls.call_args
|
||||||
|
|
||||||
@mock.patch('ansible_collections.community.general.plugins.module_utils.remote_management.lxca.common.setup_conn', autospec=True)
|
@mock.patch('ansible_collections.community.general.plugins.module_utils.remote_management.lxca.common.setup_conn', autospec=True)
|
||||||
@mock.patch('ansible_collections.community.general.plugins.modules.remote_management.lxca.lxca_nodes._nodes_by_uuid',
|
@mock.patch('ansible_collections.community.general.plugins.modules.remote_management.lxca.lxca_nodes._nodes_by_uuid',
|
||||||
|
|
|
@ -314,9 +314,9 @@ class TestPmem(ModuleTestCase):
|
||||||
test_result = result.exception.args[0]['result']
|
test_result = result.exception.args[0]['result']
|
||||||
expected = json.loads(namespace)
|
expected = json.loads(namespace)
|
||||||
|
|
||||||
for i, notuse in enumerate(test_result):
|
for i, result in enumerate(test_result):
|
||||||
self.assertEqual(test_result[i]['dev'], expected[i]['dev'])
|
self.assertEqual(result['dev'], expected[i]['dev'])
|
||||||
self.assertEqual(test_result[i]['size'], expected[i]['size'])
|
self.assertEqual(result['size'], expected[i]['size'])
|
||||||
|
|
||||||
def test_fail_when_required_args_missing(self):
|
def test_fail_when_required_args_missing(self):
|
||||||
with self.assertRaises(AnsibleFailJson):
|
with self.assertRaises(AnsibleFailJson):
|
||||||
|
|
Loading…
Reference in a new issue