mirror of
https://github.com/ansible/awx.git
synced 2026-01-09 23:12:08 -03:30
sanity tests
This commit is contained in:
parent
cd100fd770
commit
4bd910493a
@ -89,7 +89,7 @@ class InventoryModule(BaseInventoryPlugin):
|
||||
if path.endswith('@controller_inventory') or path.endswith('@tower_inventory'):
|
||||
self.no_config_file_supplied = True
|
||||
return True
|
||||
elif super(InventoryModule, self).verify_file(path):
|
||||
elif super().verify_file(path):
|
||||
return path.endswith(
|
||||
(
|
||||
'controller_inventory.yml',
|
||||
@ -109,7 +109,7 @@ class InventoryModule(BaseInventoryPlugin):
|
||||
self.display.warning(warning)
|
||||
|
||||
def parse(self, inventory, loader, path, cache=True):
|
||||
super(InventoryModule, self).parse(inventory, loader, path)
|
||||
super().parse(inventory, loader, path)
|
||||
if not self.no_config_file_supplied and os.path.isfile(path):
|
||||
self._read_config_data(path)
|
||||
|
||||
@ -132,7 +132,7 @@ class InventoryModule(BaseInventoryPlugin):
|
||||
except ValueError as e:
|
||||
raise AnsibleOptionsError(
|
||||
'Invalid type for configuration option inventory_id, ' 'not integer, and cannot convert to string: {err}'.format(err=to_native(e))
|
||||
)
|
||||
) from e
|
||||
inventory_id = inventory_id.replace('/', '')
|
||||
inventory_url = '/api/v2/inventories/{inv_id}/script/'.format(inv_id=inventory_id)
|
||||
|
||||
|
||||
@ -137,7 +137,7 @@ class LookupModule(LookupBase):
|
||||
AnsibleError('{0}'.format(LIBRARY_IMPORT_ERROR)),
|
||||
LIBRARY_IMPORT_ERROR
|
||||
)
|
||||
super(LookupModule, self).__init__(*args, **kwargs)
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
@staticmethod
|
||||
def parse_date_time(date_string):
|
||||
@ -169,8 +169,8 @@ class LookupModule(LookupBase):
|
||||
if 'start_date' in kwargs:
|
||||
try:
|
||||
rrule_kwargs['dtstart'] = LookupModule.parse_date_time(kwargs['start_date'])
|
||||
except Exception:
|
||||
raise AnsibleError('Parameter start_date must be in the format YYYY-MM-DD [HH:MM:SS]')
|
||||
except Exception as e:
|
||||
raise AnsibleError('Parameter start_date must be in the format YYYY-MM-DD [HH:MM:SS]') from e
|
||||
|
||||
# If we are a none frequency we don't need anything else
|
||||
if frequency == 'none':
|
||||
|
||||
@ -22,7 +22,7 @@ class ControllerAWXKitModule(ControllerModule):
|
||||
def __init__(self, argument_spec, **kwargs):
|
||||
kwargs['supports_check_mode'] = False
|
||||
|
||||
super(ControllerAWXKitModule, self).__init__(argument_spec=argument_spec, **kwargs)
|
||||
super().__init__(argument_spec=argument_spec, **kwargs)
|
||||
|
||||
# Die if we don't have AWX_KIT installed
|
||||
if not HAS_AWX_KIT:
|
||||
|
||||
@ -30,7 +30,7 @@ class ControllerAPIModule(ControllerModule):
|
||||
def __init__(self, argument_spec, direct_params=None, error_callback=None, warn_callback=None, **kwargs):
|
||||
kwargs['supports_check_mode'] = True
|
||||
|
||||
super(ControllerAPIModule, self).__init__(
|
||||
super().__init__(
|
||||
argument_spec=argument_spec, direct_params=direct_params, error_callback=error_callback, warn_callback=warn_callback, **kwargs
|
||||
)
|
||||
self.session = Request(cookies=CookieJar(), validate_certs=self.verify_ssl)
|
||||
|
||||
@ -95,7 +95,7 @@ class ControllerModule(AnsibleModule):
|
||||
if direct_params is not None:
|
||||
self.params = direct_params
|
||||
else:
|
||||
super(ControllerModule, self).__init__(argument_spec=full_argspec, **kwargs)
|
||||
super().__init__(argument_spec=full_argspec, **kwargs)
|
||||
|
||||
self.load_config_files()
|
||||
|
||||
@ -238,10 +238,10 @@ class ControllerModule(AnsibleModule):
|
||||
pass
|
||||
|
||||
except Exception as e:
|
||||
raise ConfigFileException("An unknown exception occured trying to ini load config file: {0}".format(e))
|
||||
raise ConfigFileException("An unknown exception occured trying to ini load config file: {0}".format(e)) from e
|
||||
|
||||
except Exception as e:
|
||||
raise ConfigFileException("An unknown exception occured trying to load config file: {0}".format(e))
|
||||
raise ConfigFileException("An unknown exception occured trying to load config file: {0}".format(e)) from e
|
||||
|
||||
# If we made it here, we have a dict which has values in it from our config, any final settings logic can be performed here
|
||||
for honorred_setting in self.short_params:
|
||||
@ -265,15 +265,15 @@ class ControllerModule(AnsibleModule):
|
||||
if self.error_callback:
|
||||
self.error_callback(**kwargs)
|
||||
else:
|
||||
super(ControllerModule, self).fail_json(**kwargs)
|
||||
super().fail_json(**kwargs)
|
||||
|
||||
def exit_json(self, **kwargs):
|
||||
# Try to log out if we are authenticated
|
||||
self.logout()
|
||||
super(ControllerModule, self).exit_json(**kwargs)
|
||||
super().exit_json(**kwargs)
|
||||
|
||||
def warn(self, warning):
|
||||
if self.warn_callback is not None:
|
||||
self.warn_callback(warning)
|
||||
else:
|
||||
super(ControllerModule, self).warn(warning)
|
||||
super().warn(warning)
|
||||
|
||||
@ -113,7 +113,7 @@ class TowerLegacyModule(AnsibleModule):
|
||||
)
|
||||
)
|
||||
|
||||
super(TowerLegacyModule, self).__init__(argument_spec=args, **kwargs)
|
||||
super().__init__(argument_spec=args, **kwargs)
|
||||
|
||||
if not HAS_TOWER_CLI:
|
||||
self.fail_json(msg=missing_required_lib('ansible-tower-cli'), exception=TOWER_CLI_IMP_ERR)
|
||||
|
||||
@ -362,7 +362,7 @@ def main():
|
||||
authorize=dict(type='bool'),
|
||||
authorize_password=dict(no_log=True),
|
||||
client=dict(),
|
||||
security_token=dict(no_log=True),
|
||||
security_token=dict(no_log=False),
|
||||
secret=dict(no_log=True),
|
||||
subscription=dict(),
|
||||
tenant=dict(),
|
||||
|
||||
@ -41,6 +41,7 @@ options:
|
||||
- Signifies that this InstanceGroup should act as a ContainerGroup. If no credential is specified, the underlying Pod's ServiceAccount will be used.
|
||||
required: False
|
||||
type: bool
|
||||
default: False
|
||||
policy_instance_percentage:
|
||||
description:
|
||||
- Minimum percentage of all instances that will be automatically assigned to this group when new instances come online.
|
||||
@ -91,7 +92,7 @@ def main():
|
||||
name=dict(required=True),
|
||||
new_name=dict(),
|
||||
credential=dict(),
|
||||
is_container_group=dict(type='bool', default=None),
|
||||
is_container_group=dict(type='bool', default=False),
|
||||
policy_instance_percentage=dict(type='int', default='0'),
|
||||
policy_instance_minimum=dict(type='int', default='0'),
|
||||
policy_instance_list=dict(type='list', elements='str'),
|
||||
|
||||
@ -164,7 +164,7 @@ def main():
|
||||
skip_tags=dict(type='list', elements='str'),
|
||||
verbosity=dict(type='int', choices=[0, 1, 2, 3, 4, 5]),
|
||||
diff_mode=dict(type='bool'),
|
||||
credential_passwords=dict(type='dict', no_log=True),
|
||||
credential_passwords=dict(type='dict', no_log=False),
|
||||
wait=dict(default=False, type='bool'),
|
||||
interval=dict(default=1.0, type='float'),
|
||||
timeout=dict(default=None, type='int'),
|
||||
|
||||
@ -140,12 +140,10 @@ options:
|
||||
type: bool
|
||||
aliases:
|
||||
- diff_mode_enabled
|
||||
default: 'no'
|
||||
use_fact_cache:
|
||||
description:
|
||||
- Enable use of fact caching for the job template.
|
||||
type: bool
|
||||
default: 'no'
|
||||
aliases:
|
||||
- fact_caching_enabled
|
||||
host_config_key:
|
||||
@ -156,75 +154,64 @@ options:
|
||||
description:
|
||||
- Prompt user for (scm branch) on launch.
|
||||
type: bool
|
||||
default: 'False'
|
||||
ask_diff_mode_on_launch:
|
||||
description:
|
||||
- Prompt user to enable diff mode (show changes) to files when supported by modules.
|
||||
type: bool
|
||||
default: 'False'
|
||||
aliases:
|
||||
- ask_diff_mode
|
||||
ask_variables_on_launch:
|
||||
description:
|
||||
- Prompt user for (extra_vars) on launch.
|
||||
type: bool
|
||||
default: 'False'
|
||||
aliases:
|
||||
- ask_extra_vars
|
||||
ask_limit_on_launch:
|
||||
description:
|
||||
- Prompt user for a limit on launch.
|
||||
type: bool
|
||||
default: 'False'
|
||||
aliases:
|
||||
- ask_limit
|
||||
ask_tags_on_launch:
|
||||
description:
|
||||
- Prompt user for job tags on launch.
|
||||
type: bool
|
||||
default: 'False'
|
||||
aliases:
|
||||
- ask_tags
|
||||
ask_skip_tags_on_launch:
|
||||
description:
|
||||
- Prompt user for job tags to skip on launch.
|
||||
type: bool
|
||||
default: 'False'
|
||||
aliases:
|
||||
- ask_skip_tags
|
||||
ask_job_type_on_launch:
|
||||
description:
|
||||
- Prompt user for job type on launch.
|
||||
type: bool
|
||||
default: 'False'
|
||||
aliases:
|
||||
- ask_job_type
|
||||
ask_verbosity_on_launch:
|
||||
description:
|
||||
- Prompt user to choose a verbosity level on launch.
|
||||
type: bool
|
||||
default: 'False'
|
||||
aliases:
|
||||
- ask_verbosity
|
||||
ask_inventory_on_launch:
|
||||
description:
|
||||
- Prompt user for inventory on launch.
|
||||
type: bool
|
||||
default: 'False'
|
||||
aliases:
|
||||
- ask_inventory
|
||||
ask_credential_on_launch:
|
||||
description:
|
||||
- Prompt user for credential on launch.
|
||||
type: bool
|
||||
default: 'False'
|
||||
aliases:
|
||||
- ask_credential
|
||||
survey_enabled:
|
||||
description:
|
||||
- Enable a survey on the job template.
|
||||
type: bool
|
||||
default: 'no'
|
||||
survey_spec:
|
||||
description:
|
||||
- JSON/YAML dict formatted survey definition.
|
||||
@ -233,12 +220,10 @@ options:
|
||||
description:
|
||||
- Activate privilege escalation.
|
||||
type: bool
|
||||
default: 'no'
|
||||
allow_simultaneous:
|
||||
description:
|
||||
- Allow simultaneous runs of the job template.
|
||||
type: bool
|
||||
default: 'no'
|
||||
aliases:
|
||||
- concurrent_jobs_enabled
|
||||
timeout:
|
||||
@ -388,24 +373,24 @@ def main():
|
||||
skip_tags=dict(),
|
||||
start_at_task=dict(),
|
||||
timeout=dict(type='int', default=0),
|
||||
use_fact_cache=dict(type='bool', aliases=['fact_caching_enabled'], default=False),
|
||||
host_config_key=dict(no_log=True),
|
||||
ask_diff_mode_on_launch=dict(type='bool', aliases=['ask_diff_mode'], default=False),
|
||||
ask_variables_on_launch=dict(type='bool', aliases=['ask_extra_vars'], default=False),
|
||||
ask_limit_on_launch=dict(type='bool', aliases=['ask_limit'], default=False),
|
||||
ask_tags_on_launch=dict(type='bool', aliases=['ask_tags'], default=False),
|
||||
ask_skip_tags_on_launch=dict(type='bool', aliases=['ask_skip_tags'], default=False),
|
||||
ask_job_type_on_launch=dict(type='bool', aliases=['ask_job_type'], default=False),
|
||||
ask_verbosity_on_launch=dict(type='bool', aliases=['ask_verbosity'], default=False),
|
||||
ask_inventory_on_launch=dict(type='bool', aliases=['ask_inventory'], default=False),
|
||||
ask_credential_on_launch=dict(type='bool', aliases=['ask_credential'], default=False),
|
||||
survey_enabled=dict(type='bool', default=False),
|
||||
use_fact_cache=dict(type='bool', aliases=['fact_caching_enabled']),
|
||||
host_config_key=dict(no_log=False),
|
||||
ask_diff_mode_on_launch=dict(type='bool', aliases=['ask_diff_mode']),
|
||||
ask_variables_on_launch=dict(type='bool', aliases=['ask_extra_vars']),
|
||||
ask_limit_on_launch=dict(type='bool', aliases=['ask_limit']),
|
||||
ask_tags_on_launch=dict(type='bool', aliases=['ask_tags']),
|
||||
ask_skip_tags_on_launch=dict(type='bool', aliases=['ask_skip_tags']),
|
||||
ask_job_type_on_launch=dict(type='bool', aliases=['ask_job_type']),
|
||||
ask_verbosity_on_launch=dict(type='bool', aliases=['ask_verbosity']),
|
||||
ask_inventory_on_launch=dict(type='bool', aliases=['ask_inventory']),
|
||||
ask_credential_on_launch=dict(type='bool', aliases=['ask_credential']),
|
||||
survey_enabled=dict(type='bool'),
|
||||
survey_spec=dict(type="dict"),
|
||||
become_enabled=dict(type='bool', default=False),
|
||||
diff_mode=dict(type='bool', aliases=['diff_mode_enabled'], default=False),
|
||||
allow_simultaneous=dict(type='bool', aliases=['concurrent_jobs_enabled'], default=False),
|
||||
become_enabled=dict(type='bool'),
|
||||
diff_mode=dict(type='bool', aliases=['diff_mode_enabled']),
|
||||
allow_simultaneous=dict(type='bool', aliases=['concurrent_jobs_enabled']),
|
||||
scm_branch=dict(),
|
||||
ask_scm_branch_on_launch=dict(type='bool', default=False),
|
||||
ask_scm_branch_on_launch=dict(type='bool'),
|
||||
job_slice_count=dict(type='int', default='1'),
|
||||
webhook_service=dict(choices=['github', 'gitlab', '']),
|
||||
webhook_credential=dict(),
|
||||
|
||||
@ -184,7 +184,7 @@ def run_module(request, collection_import):
|
||||
try:
|
||||
result = json.loads(module_stdout)
|
||||
except Exception as e:
|
||||
raise Exception('Module did not write valid JSON, error: {0}, stdout:\n{1}'.format(str(e), module_stdout))
|
||||
raise Exception('Module did not write valid JSON, error: {0}, stdout:\n{1}'.format(str(e), module_stdout)) from e
|
||||
# A module exception should never be a test expectation
|
||||
if 'exception' in result:
|
||||
if "ModuleNotFoundError: No module named 'tower_cli'" in result['exception']:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user