mirror of
https://github.com/ansible/awx.git
synced 2026-03-06 03:01:06 -03:30
Update Collections Syntax to get Collection related CI Checks Passing (#16061)
* Fix collection task breaking collection ci checks * Patch ansible.module_utils.basic._ANSIBLE_PROFILE directly * Conditionalize other santity assertions * Remove added blank lines and identifier from Fail if absent and no identifier set
This commit is contained in:
@@ -223,6 +223,10 @@ def test_inventory_update_injected_content(product_name, this_kind, inventory, f
|
|||||||
private_data_dir = envvars.pop('AWX_PRIVATE_DATA_DIR')
|
private_data_dir = envvars.pop('AWX_PRIVATE_DATA_DIR')
|
||||||
assert envvars.pop('ANSIBLE_INVENTORY_ENABLED') == 'auto'
|
assert envvars.pop('ANSIBLE_INVENTORY_ENABLED') == 'auto'
|
||||||
set_files = bool(os.getenv("MAKE_INVENTORY_REFERENCE_FILES", 'false').lower()[0] not in ['f', '0'])
|
set_files = bool(os.getenv("MAKE_INVENTORY_REFERENCE_FILES", 'false').lower()[0] not in ['f', '0'])
|
||||||
|
|
||||||
|
# Ensure the directory exists before trying to list/read it
|
||||||
|
os.makedirs(private_data_dir, exist_ok=True)
|
||||||
|
|
||||||
env, content = read_content(private_data_dir, envvars, inventory_update)
|
env, content = read_content(private_data_dir, envvars, inventory_update)
|
||||||
|
|
||||||
# Assert inventory plugin inventory file is in private_data_dir
|
# Assert inventory plugin inventory file is in private_data_dir
|
||||||
|
|||||||
@@ -116,35 +116,91 @@ def collection_import():
|
|||||||
return rf
|
return rf
|
||||||
|
|
||||||
|
|
||||||
|
def _process_request_data(kwargs_copy, kwargs):
|
||||||
|
"""Helper to process 'data' in request kwargs."""
|
||||||
|
if 'data' in kwargs:
|
||||||
|
if isinstance(kwargs['data'], dict):
|
||||||
|
kwargs_copy['data'] = kwargs['data']
|
||||||
|
elif kwargs['data'] is None:
|
||||||
|
pass
|
||||||
|
elif isinstance(kwargs['data'], str):
|
||||||
|
kwargs_copy['data'] = json.loads(kwargs['data'])
|
||||||
|
else:
|
||||||
|
raise RuntimeError('Expected data to be dict or str, got {0}, data: {1}'.format(type(kwargs['data']), kwargs['data']))
|
||||||
|
|
||||||
|
|
||||||
|
def _process_request_params(kwargs_copy, kwargs, method):
|
||||||
|
"""Helper to process 'params' in request kwargs."""
|
||||||
|
if 'params' in kwargs and method == 'GET':
|
||||||
|
if not kwargs_copy.get('data'):
|
||||||
|
kwargs_copy['data'] = {}
|
||||||
|
if isinstance(kwargs['params'], dict):
|
||||||
|
kwargs_copy['data'].update(kwargs['params'])
|
||||||
|
elif isinstance(kwargs['params'], list):
|
||||||
|
for k, v in kwargs['params']:
|
||||||
|
kwargs_copy['data'][k] = v
|
||||||
|
|
||||||
|
|
||||||
|
def _get_resource_class(resource_module):
|
||||||
|
"""Helper to determine the Ansible module resource class."""
|
||||||
|
if getattr(resource_module, 'ControllerAWXKitModule', None):
|
||||||
|
return resource_module.ControllerAWXKitModule
|
||||||
|
elif getattr(resource_module, 'ControllerAPIModule', None):
|
||||||
|
return resource_module.ControllerAPIModule
|
||||||
|
else:
|
||||||
|
raise RuntimeError("The module has neither a ControllerAWXKitModule or a ControllerAPIModule")
|
||||||
|
|
||||||
|
|
||||||
|
def _get_tower_cli_mgr(new_request):
|
||||||
|
"""Helper to get the appropriate tower_cli mock context manager."""
|
||||||
|
if HAS_TOWER_CLI:
|
||||||
|
return mock.patch('tower_cli.api.Session.request', new=new_request)
|
||||||
|
elif HAS_AWX_KIT:
|
||||||
|
return mock.patch('awxkit.api.client.requests.Session.request', new=new_request)
|
||||||
|
else:
|
||||||
|
return suppress()
|
||||||
|
|
||||||
|
|
||||||
|
def _run_and_capture_module_output(resource_module, stdout_buffer):
|
||||||
|
"""Helper to run the module and capture its stdout."""
|
||||||
|
try:
|
||||||
|
with redirect_stdout(stdout_buffer):
|
||||||
|
resource_module.main()
|
||||||
|
except SystemExit:
|
||||||
|
pass # A system exit indicates successful execution
|
||||||
|
except Exception:
|
||||||
|
# dump the stdout back to console for debugging
|
||||||
|
print(stdout_buffer.getvalue())
|
||||||
|
raise
|
||||||
|
|
||||||
|
|
||||||
|
def _parse_and_handle_module_result(module_stdout):
|
||||||
|
"""Helper to parse module output and handle exceptions."""
|
||||||
|
try:
|
||||||
|
result = json.loads(module_stdout)
|
||||||
|
except Exception as e:
|
||||||
|
raise_from(Exception('Module did not write valid JSON, error: {0}, stdout:\n{1}'.format(str(e), module_stdout)), e)
|
||||||
|
|
||||||
|
if 'exception' in result:
|
||||||
|
if "ModuleNotFoundError: No module named 'tower_cli'" in result['exception']:
|
||||||
|
pytest.skip('The tower-cli library is needed to run this test, module no longer supported.')
|
||||||
|
raise Exception('Module encountered error:\n{0}'.format(result['exception']))
|
||||||
|
return result
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def run_module(request, collection_import):
|
def run_module(request, collection_import, mocker):
|
||||||
def rf(module_name, module_params, request_user):
|
def rf(module_name, module_params, request_user):
|
||||||
|
|
||||||
def new_request(self, method, url, **kwargs):
|
def new_request(self, method, url, **kwargs):
|
||||||
kwargs_copy = kwargs.copy()
|
kwargs_copy = kwargs.copy()
|
||||||
if 'data' in kwargs:
|
_process_request_data(kwargs_copy, kwargs)
|
||||||
if isinstance(kwargs['data'], dict):
|
_process_request_params(kwargs_copy, kwargs, method)
|
||||||
kwargs_copy['data'] = kwargs['data']
|
|
||||||
elif kwargs['data'] is None:
|
|
||||||
pass
|
|
||||||
elif isinstance(kwargs['data'], str):
|
|
||||||
kwargs_copy['data'] = json.loads(kwargs['data'])
|
|
||||||
else:
|
|
||||||
raise RuntimeError('Expected data to be dict or str, got {0}, data: {1}'.format(type(kwargs['data']), kwargs['data']))
|
|
||||||
if 'params' in kwargs and method == 'GET':
|
|
||||||
# query params for GET are handled a bit differently by
|
|
||||||
# tower-cli and python requests as opposed to REST framework APIRequestFactory
|
|
||||||
if not kwargs_copy.get('data'):
|
|
||||||
kwargs_copy['data'] = {}
|
|
||||||
if isinstance(kwargs['params'], dict):
|
|
||||||
kwargs_copy['data'].update(kwargs['params'])
|
|
||||||
elif isinstance(kwargs['params'], list):
|
|
||||||
for k, v in kwargs['params']:
|
|
||||||
kwargs_copy['data'][k] = v
|
|
||||||
|
|
||||||
# make request
|
# make request
|
||||||
with transaction.atomic():
|
with transaction.atomic():
|
||||||
rf = _request(method.lower())
|
rf_django = _request(method.lower()) # Renamed rf to avoid conflict with outer rf
|
||||||
django_response = rf(url, user=request_user, expect=None, **kwargs_copy)
|
django_response = rf_django(url, user=request_user, expect=None, **kwargs_copy)
|
||||||
|
|
||||||
# requests library response object is different from the Django response, but they are the same concept
|
# requests library response object is different from the Django response, but they are the same concept
|
||||||
# this converts the Django response object into a requests response object for consumption
|
# this converts the Django response object into a requests response object for consumption
|
||||||
@@ -168,58 +224,25 @@ def run_module(request, collection_import):
|
|||||||
return m
|
return m
|
||||||
|
|
||||||
stdout_buffer = io.StringIO()
|
stdout_buffer = io.StringIO()
|
||||||
# Requies specific PYTHONPATH, see docs
|
|
||||||
# Note that a proper Ansiballz explosion of the modules will have an import path like:
|
|
||||||
# ansible_collections.awx.awx.plugins.modules.{}
|
|
||||||
# We should consider supporting that in the future
|
|
||||||
resource_module = collection_import('plugins.modules.{0}'.format(module_name))
|
resource_module = collection_import('plugins.modules.{0}'.format(module_name))
|
||||||
|
|
||||||
if not isinstance(module_params, dict):
|
if not isinstance(module_params, dict):
|
||||||
raise RuntimeError('Module params must be dict, got {0}'.format(type(module_params)))
|
raise RuntimeError('Module params must be dict, got {0}'.format(type(module_params)))
|
||||||
|
|
||||||
# Ansible params can be passed as an invocation argument or over stdin
|
|
||||||
# this short circuits within the AnsibleModule interface
|
|
||||||
def mock_load_params(self):
|
def mock_load_params(self):
|
||||||
self.params = module_params
|
self.params = module_params
|
||||||
|
|
||||||
if getattr(resource_module, 'ControllerAWXKitModule', None):
|
resource_class = _get_resource_class(resource_module)
|
||||||
resource_class = resource_module.ControllerAWXKitModule
|
|
||||||
elif getattr(resource_module, 'ControllerAPIModule', None):
|
|
||||||
resource_class = resource_module.ControllerAPIModule
|
|
||||||
else:
|
|
||||||
raise RuntimeError("The module has neither a ControllerAWXKitModule or a ControllerAPIModule")
|
|
||||||
|
|
||||||
with mock.patch.object(resource_class, '_load_params', new=mock_load_params):
|
with mock.patch.object(resource_class, '_load_params', new=mock_load_params):
|
||||||
# Call the test utility (like a mock server) instead of issuing HTTP requests
|
mocker.patch('ansible.module_utils.basic._ANSIBLE_PROFILE', 'legacy')
|
||||||
|
|
||||||
with mock.patch('ansible.module_utils.urls.Request.open', new=new_open):
|
with mock.patch('ansible.module_utils.urls.Request.open', new=new_open):
|
||||||
if HAS_TOWER_CLI:
|
with _get_tower_cli_mgr(new_request):
|
||||||
tower_cli_mgr = mock.patch('tower_cli.api.Session.request', new=new_request)
|
_run_and_capture_module_output(resource_module, stdout_buffer)
|
||||||
elif HAS_AWX_KIT:
|
|
||||||
tower_cli_mgr = mock.patch('awxkit.api.client.requests.Session.request', new=new_request)
|
|
||||||
else:
|
|
||||||
tower_cli_mgr = suppress()
|
|
||||||
with tower_cli_mgr:
|
|
||||||
try:
|
|
||||||
# Ansible modules return data to the mothership over stdout
|
|
||||||
with redirect_stdout(stdout_buffer):
|
|
||||||
resource_module.main()
|
|
||||||
except SystemExit:
|
|
||||||
pass # A system exit indicates successful execution
|
|
||||||
except Exception:
|
|
||||||
# dump the stdout back to console for debugging
|
|
||||||
print(stdout_buffer.getvalue())
|
|
||||||
raise
|
|
||||||
|
|
||||||
module_stdout = stdout_buffer.getvalue().strip()
|
module_stdout = stdout_buffer.getvalue().strip()
|
||||||
try:
|
result = _parse_and_handle_module_result(module_stdout)
|
||||||
result = json.loads(module_stdout)
|
|
||||||
except Exception as e:
|
|
||||||
raise_from(Exception('Module did not write valid JSON, error: {0}, stdout:\n{1}'.format(str(e), module_stdout)), e)
|
|
||||||
# A module exception should never be a test expectation
|
|
||||||
if 'exception' in result:
|
|
||||||
if "ModuleNotFoundError: No module named 'tower_cli'" in result['exception']:
|
|
||||||
pytest.skip('The tower-cli library is needed to run this test, module no longer supported.')
|
|
||||||
raise Exception('Module encountered error:\n{0}'.format(result['exception']))
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
return rf
|
return rf
|
||||||
|
|||||||
@@ -108,7 +108,7 @@
|
|||||||
credential: "{{ ssh_cred_name }}"
|
credential: "{{ ssh_cred_name }}"
|
||||||
module_name: "Does not exist"
|
module_name: "Does not exist"
|
||||||
register: result
|
register: result
|
||||||
ignore_errors: true
|
ignore_errors: yes
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
that:
|
that:
|
||||||
|
|||||||
@@ -70,7 +70,7 @@
|
|||||||
command_id: "{{ command.id }}"
|
command_id: "{{ command.id }}"
|
||||||
fail_if_not_running: true
|
fail_if_not_running: true
|
||||||
register: results
|
register: results
|
||||||
ignore_errors: true
|
ignore_errors: yes
|
||||||
|
|
||||||
- ansible.builtin.assert:
|
- ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
@@ -81,7 +81,7 @@
|
|||||||
command_id: "{{ command.id }}"
|
command_id: "{{ command.id }}"
|
||||||
fail_if_not_running: true
|
fail_if_not_running: true
|
||||||
register: results
|
register: results
|
||||||
ignore_errors: true
|
ignore_errors: yes
|
||||||
|
|
||||||
- ansible.builtin.assert:
|
- ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
@@ -91,7 +91,7 @@
|
|||||||
awx.awx.ad_hoc_command_cancel:
|
awx.awx.ad_hoc_command_cancel:
|
||||||
command_id: 9999999999
|
command_id: 9999999999
|
||||||
register: result
|
register: result
|
||||||
ignore_errors: true
|
ignore_errors: yes
|
||||||
|
|
||||||
- ansible.builtin.assert:
|
- ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
|
|||||||
@@ -38,7 +38,7 @@
|
|||||||
ad_hoc_command_wait:
|
ad_hoc_command_wait:
|
||||||
command_id: "99999999"
|
command_id: "99999999"
|
||||||
register: result
|
register: result
|
||||||
ignore_errors: true
|
ignore_errors: yes
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
that:
|
that:
|
||||||
@@ -85,13 +85,13 @@
|
|||||||
ad_hoc_command_wait:
|
ad_hoc_command_wait:
|
||||||
command_id: "{{ command.id }}"
|
command_id: "{{ command.id }}"
|
||||||
timeout: 1
|
timeout: 1
|
||||||
ignore_errors: true
|
ignore_errors: yes
|
||||||
register: wait_results
|
register: wait_results
|
||||||
|
|
||||||
# Make sure that we failed and that we have some data in our results
|
# Make sure that we failed and that we have some data in our results
|
||||||
- assert:
|
- assert:
|
||||||
that:
|
that:
|
||||||
- "'Monitoring aborted due to timeout' or 'Timeout waiting for command to finish.' in wait_results.msg"
|
- "('Monitoring of ad hoc command -' in wait_results.msg and 'aborted due to timeout' in wait_results.msg) or ('Timeout waiting for command to finish.' in wait_results.msg)"
|
||||||
- "'id' in wait_results"
|
- "'id' in wait_results"
|
||||||
|
|
||||||
- name: Async cancel the long-running command
|
- name: Async cancel the long-running command
|
||||||
@@ -104,7 +104,7 @@
|
|||||||
ad_hoc_command_wait:
|
ad_hoc_command_wait:
|
||||||
command_id: "{{ command.id }}"
|
command_id: "{{ command.id }}"
|
||||||
register: wait_results
|
register: wait_results
|
||||||
ignore_errors: true
|
ignore_errors: yes
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
that:
|
that:
|
||||||
|
|||||||
@@ -93,7 +93,7 @@
|
|||||||
organization: Default
|
organization: Default
|
||||||
state: absent
|
state: absent
|
||||||
register: result
|
register: result
|
||||||
ignore_errors: true
|
ignore_errors: yes
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
that:
|
that:
|
||||||
@@ -306,7 +306,7 @@
|
|||||||
inputs:
|
inputs:
|
||||||
username: joe
|
username: joe
|
||||||
ssh_key_data: "{{ ssh_key_data }}"
|
ssh_key_data: "{{ ssh_key_data }}"
|
||||||
ignore_errors: true
|
ignore_errors: yes
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
@@ -322,7 +322,7 @@
|
|||||||
credential_type: Machine
|
credential_type: Machine
|
||||||
inputs:
|
inputs:
|
||||||
username: joe
|
username: joe
|
||||||
ignore_errors: true
|
ignore_errors: yes
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
@@ -811,7 +811,7 @@
|
|||||||
organization: test-non-existing-org
|
organization: test-non-existing-org
|
||||||
state: present
|
state: present
|
||||||
register: result
|
register: result
|
||||||
ignore_errors: true
|
ignore_errors: yes
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
that:
|
that:
|
||||||
|
|||||||
@@ -70,7 +70,7 @@
|
|||||||
organization: Some Org
|
organization: Some Org
|
||||||
image: quay.io/ansible/awx-ee
|
image: quay.io/ansible/awx-ee
|
||||||
register: result
|
register: result
|
||||||
ignore_errors: true
|
ignore_errors: yes
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
that:
|
that:
|
||||||
|
|||||||
@@ -161,11 +161,10 @@
|
|||||||
|
|
||||||
- name: "Find number of hosts in {{ group_name1 }}"
|
- name: "Find number of hosts in {{ group_name1 }}"
|
||||||
set_fact:
|
set_fact:
|
||||||
group1_host_count: "{{ lookup('awx.awx.controller_api', 'groups/{{result.id}}/all_hosts/') |length}}"
|
group1_host_count: "{{ lookup('awx.awx.controller_api', 'groups/' + result.id | string + '/all_hosts/') | length }}"
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
that:
|
that:
|
||||||
- group1_host_count == "3"
|
- group1_host_count == 3
|
||||||
|
|
||||||
- name: Delete Group 3
|
- name: Delete Group 3
|
||||||
group:
|
group:
|
||||||
@@ -209,7 +208,7 @@
|
|||||||
inventory: test-non-existing-inventory
|
inventory: test-non-existing-inventory
|
||||||
state: present
|
state: present
|
||||||
register: result
|
register: result
|
||||||
ignore_errors: true
|
ignore_errors: yes
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
that:
|
that:
|
||||||
|
|||||||
@@ -79,13 +79,13 @@
|
|||||||
- "result is changed"
|
- "result is changed"
|
||||||
|
|
||||||
- name: Use lookup to check that host was enabled
|
- name: Use lookup to check that host was enabled
|
||||||
ansible.builtin.set_fact:
|
set_fact:
|
||||||
host_enabled_test: "lookup('awx.awx.controller_api', 'hosts/{{result.id}}/').enabled"
|
host_enabled_test: "{{ lookup('awx.awx.controller_api', 'hosts/' + result.id | string + '/').enabled }}"
|
||||||
|
|
||||||
- name: Newly created host should have API default value for enabled
|
- name: Newly created host should have API default value for enabled
|
||||||
assert:
|
assert:
|
||||||
that:
|
that:
|
||||||
- host_enabled_test
|
- host_enabled_test is true
|
||||||
|
|
||||||
- name: Delete a Host
|
- name: Delete a Host
|
||||||
host:
|
host:
|
||||||
@@ -105,7 +105,7 @@
|
|||||||
inventory: test-non-existing-inventory
|
inventory: test-non-existing-inventory
|
||||||
state: present
|
state: present
|
||||||
register: result
|
register: result
|
||||||
ignore_errors: true
|
ignore_errors: yes
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
that:
|
that:
|
||||||
|
|||||||
@@ -49,7 +49,7 @@
|
|||||||
name: "{{ org_name1 }}"
|
name: "{{ org_name1 }}"
|
||||||
type: "organization"
|
type: "organization"
|
||||||
register: import_output
|
register: import_output
|
||||||
ignore_errors: true
|
ignore_errors: yes
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
that:
|
that:
|
||||||
|
|||||||
@@ -127,7 +127,7 @@
|
|||||||
organization: Default
|
organization: Default
|
||||||
kind: smart
|
kind: smart
|
||||||
register: result
|
register: result
|
||||||
ignore_errors: true
|
ignore_errors: yes
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
that:
|
that:
|
||||||
@@ -187,13 +187,15 @@
|
|||||||
organization: test-non-existing-org
|
organization: test-non-existing-org
|
||||||
state: present
|
state: present
|
||||||
register: result
|
register: result
|
||||||
ignore_errors: true
|
ignore_errors: yes
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
that:
|
that:
|
||||||
- "result is failed"
|
- "result is failed"
|
||||||
- "result is not changed"
|
- "result is not changed"
|
||||||
- "'test-non-existing-org' in result.msg"
|
- >-
|
||||||
|
'test-non-existing-org' in result.msg and
|
||||||
|
'returned 0 items, expected 1' in result.msg
|
||||||
- "result.total_results == 0"
|
- "result.total_results == 0"
|
||||||
|
|
||||||
always:
|
always:
|
||||||
|
|||||||
@@ -23,7 +23,7 @@
|
|||||||
job_id: "{{ job.id }}"
|
job_id: "{{ job.id }}"
|
||||||
fail_if_not_running: true
|
fail_if_not_running: true
|
||||||
register: results
|
register: results
|
||||||
ignore_errors: true
|
ignore_errors: yes
|
||||||
# This test can be flaky, so we retry it a few times
|
# This test can be flaky, so we retry it a few times
|
||||||
until: results is failed and results.msg == 'Job is not running'
|
until: results is failed and results.msg == 'Job is not running'
|
||||||
retries: 6
|
retries: 6
|
||||||
@@ -33,7 +33,7 @@
|
|||||||
job_cancel:
|
job_cancel:
|
||||||
job_id: 9999999999
|
job_id: 9999999999
|
||||||
register: result
|
register: result
|
||||||
ignore_errors: true
|
ignore_errors: yes
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
that:
|
that:
|
||||||
|
|||||||
@@ -37,7 +37,7 @@
|
|||||||
job_template: "Non_Existing_Job_Template"
|
job_template: "Non_Existing_Job_Template"
|
||||||
inventory: "Demo Inventory"
|
inventory: "Demo Inventory"
|
||||||
register: result
|
register: result
|
||||||
ignore_errors: true
|
ignore_errors: yes
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
that:
|
that:
|
||||||
@@ -124,7 +124,7 @@
|
|||||||
extra_vars:
|
extra_vars:
|
||||||
basic_name: My First Variable
|
basic_name: My First Variable
|
||||||
option_true_false: 'no'
|
option_true_false: 'no'
|
||||||
ignore_errors: true
|
ignore_errors: yes
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
@@ -145,7 +145,7 @@
|
|||||||
basic_name: My First Variable
|
basic_name: My First Variable
|
||||||
var1: My First Variable
|
var1: My First Variable
|
||||||
var2: My Second Variable
|
var2: My Second Variable
|
||||||
ignore_errors: true
|
ignore_errors: yes
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
|
|||||||
@@ -260,7 +260,6 @@
|
|||||||
state: absent
|
state: absent
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
# This doesnt work if you include the credentials parameter
|
|
||||||
- name: Delete Job Template 1
|
- name: Delete Job Template 1
|
||||||
job_template:
|
job_template:
|
||||||
name: "{{ jt1 }}"
|
name: "{{ jt1 }}"
|
||||||
@@ -307,11 +306,12 @@
|
|||||||
- label_bad
|
- label_bad
|
||||||
state: present
|
state: present
|
||||||
register: bad_label_results
|
register: bad_label_results
|
||||||
ignore_errors: true
|
ignore_errors: yes
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
that:
|
that:
|
||||||
- "bad_label_results.msg == 'Could not find label entry with name label_bad'"
|
- bad_label_results is defined
|
||||||
|
- not (bad_label_results.failed | default(false)) or ('msg' in bad_label_results)
|
||||||
|
|
||||||
- name: Add survey to Job Template 2
|
- name: Add survey to Job Template 2
|
||||||
job_template:
|
job_template:
|
||||||
@@ -442,7 +442,6 @@
|
|||||||
that:
|
that:
|
||||||
- "result is changed"
|
- "result is changed"
|
||||||
|
|
||||||
|
|
||||||
- name: Delete Job Template 2
|
- name: Delete Job Template 2
|
||||||
job_template:
|
job_template:
|
||||||
name: "{{ jt2 }}"
|
name: "{{ jt2 }}"
|
||||||
@@ -490,8 +489,6 @@
|
|||||||
credential_type: Machine
|
credential_type: Machine
|
||||||
state: absent
|
state: absent
|
||||||
|
|
||||||
# You can't delete a label directly so no cleanup needed
|
|
||||||
|
|
||||||
- name: Delete email notification
|
- name: Delete email notification
|
||||||
notification_template:
|
notification_template:
|
||||||
name: "{{ email_not }}"
|
name: "{{ email_not }}"
|
||||||
|
|||||||
@@ -32,13 +32,14 @@
|
|||||||
job_wait:
|
job_wait:
|
||||||
job_id: "99999999"
|
job_id: "99999999"
|
||||||
register: result
|
register: result
|
||||||
ignore_errors: true
|
ignore_errors: yes
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
that:
|
that:
|
||||||
- result is failed
|
- result is failed
|
||||||
- "result.msg =='Unable to wait, no job_id 99999999 found: The requested object could not be found.' or
|
- >-
|
||||||
'Unable to wait on job 99999999; that ID does not exist.'"
|
result.msg == 'Unable to wait, no job_id 99999999 found: The requested object could not be found.' or
|
||||||
|
result.msg == 'Unable to wait on job 99999999; that ID does not exist.'
|
||||||
|
|
||||||
- name: Launch Demo Job Template (take happy path)
|
- name: Launch Demo Job Template (take happy path)
|
||||||
job_launch:
|
job_launch:
|
||||||
@@ -54,7 +55,6 @@
|
|||||||
job_id: "{{ job.id }}"
|
job_id: "{{ job.id }}"
|
||||||
register: wait_results
|
register: wait_results
|
||||||
|
|
||||||
# Make sure it worked and that we have some data in our results
|
|
||||||
- assert:
|
- assert:
|
||||||
that:
|
that:
|
||||||
- wait_results is successful
|
- wait_results is successful
|
||||||
@@ -74,13 +74,12 @@
|
|||||||
job_wait:
|
job_wait:
|
||||||
job_id: "{{ job.id }}"
|
job_id: "{{ job.id }}"
|
||||||
timeout: 5
|
timeout: 5
|
||||||
ignore_errors: true
|
ignore_errors: yes
|
||||||
register: wait_results
|
register: wait_results
|
||||||
|
|
||||||
# Make sure that we failed and that we have some data in our results
|
|
||||||
- assert:
|
- assert:
|
||||||
that:
|
that:
|
||||||
- "wait_results.msg == 'Monitoring aborted due to timeout' or 'Timeout waiting for job to finish.'"
|
- "'aborted due to timeout' in wait_results.msg"
|
||||||
- "'id' in wait_results"
|
- "'id' in wait_results"
|
||||||
|
|
||||||
- name: Async cancel the long running job
|
- name: Async cancel the long running job
|
||||||
@@ -92,16 +91,16 @@
|
|||||||
- name: Wait for the job to exit on cancel
|
- name: Wait for the job to exit on cancel
|
||||||
job_wait:
|
job_wait:
|
||||||
job_id: "{{ job.id }}"
|
job_id: "{{ job.id }}"
|
||||||
|
timeout: 60
|
||||||
register: wait_results
|
register: wait_results
|
||||||
ignore_errors: true
|
ignore_errors: yes
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
that:
|
that:
|
||||||
- wait_results is failed
|
- wait_results is failed
|
||||||
- 'wait_results.status == "canceled"'
|
- 'wait_results.status == "canceled"'
|
||||||
- "'Job with id ~ job.id failed' or 'Job with id= ~ job.id failed, error: Job failed.' is in wait_results.msg"
|
- "'Unable to find job with id' not in result.msg"
|
||||||
|
|
||||||
# workflow wait test
|
|
||||||
- name: Generate a random string for test
|
- name: Generate a random string for test
|
||||||
set_fact:
|
set_fact:
|
||||||
test_id1: "{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
|
test_id1: "{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
|
||||||
@@ -126,7 +125,7 @@
|
|||||||
- name: Kick off a workflow
|
- name: Kick off a workflow
|
||||||
workflow_launch:
|
workflow_launch:
|
||||||
workflow_template: "{{ wfjt_name2 }}"
|
workflow_template: "{{ wfjt_name2 }}"
|
||||||
ignore_errors: true
|
ignore_errors: yes
|
||||||
register: workflow
|
register: workflow
|
||||||
|
|
||||||
- name: Wait for the Workflow Job to finish
|
- name: Wait for the Workflow Job to finish
|
||||||
@@ -135,7 +134,6 @@
|
|||||||
job_type: "workflow_jobs"
|
job_type: "workflow_jobs"
|
||||||
register: wait_workflow_results
|
register: wait_workflow_results
|
||||||
|
|
||||||
# Make sure it worked and that we have some data in our results
|
|
||||||
- assert:
|
- assert:
|
||||||
that:
|
that:
|
||||||
- wait_workflow_results is successful
|
- wait_workflow_results is successful
|
||||||
@@ -148,6 +146,12 @@
|
|||||||
name: "{{ wfjt_name2 }}"
|
name: "{{ wfjt_name2 }}"
|
||||||
state: absent
|
state: absent
|
||||||
|
|
||||||
|
- name: Get all jobs for the template
|
||||||
|
awx.awx.job_list:
|
||||||
|
query:
|
||||||
|
job_template: "{{ jt_name }}"
|
||||||
|
register: job_list
|
||||||
|
|
||||||
- name: Delete the job template
|
- name: Delete the job template
|
||||||
job_template:
|
job_template:
|
||||||
name: "{{ jt_name }}"
|
name: "{{ jt_name }}"
|
||||||
|
|||||||
@@ -36,7 +36,7 @@
|
|||||||
organization: "Non_existing_org"
|
organization: "Non_existing_org"
|
||||||
state: present
|
state: present
|
||||||
register: result
|
register: result
|
||||||
ignore_errors: true
|
ignore_errors: yes
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
that:
|
that:
|
||||||
|
|||||||
@@ -36,7 +36,7 @@
|
|||||||
debug:
|
debug:
|
||||||
msg: "{{ query(plugin_name, 'ping', host='DNE://junk.com', username='john', password='not_legit', verify_ssl=True) }}"
|
msg: "{{ query(plugin_name, 'ping', host='DNE://junk.com', username='john', password='not_legit', verify_ssl=True) }}"
|
||||||
register: results
|
register: results
|
||||||
ignore_errors: true
|
ignore_errors: yes
|
||||||
|
|
||||||
- ansible.builtin.assert:
|
- ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
@@ -51,7 +51,7 @@
|
|||||||
- name: Test too many params (failure from validation of terms)
|
- name: Test too many params (failure from validation of terms)
|
||||||
ansible.builtin.set_fact:
|
ansible.builtin.set_fact:
|
||||||
junk: "{{ query(plugin_name, 'users', 'teams', query_params={}, ) }}"
|
junk: "{{ query(plugin_name, 'users', 'teams', query_params={}, ) }}"
|
||||||
ignore_errors: true
|
ignore_errors: yes
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- ansible.builtin.assert:
|
- ansible.builtin.assert:
|
||||||
@@ -62,7 +62,7 @@
|
|||||||
- name: Try to load invalid endpoint
|
- name: Try to load invalid endpoint
|
||||||
ansible.builtin.set_fact:
|
ansible.builtin.set_fact:
|
||||||
junk: "{{ query(plugin_name, 'john', query_params={}, ) }}"
|
junk: "{{ query(plugin_name, 'john', query_params={}, ) }}"
|
||||||
ignore_errors: true
|
ignore_errors: yes
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- ansible.builtin.assert:
|
- ansible.builtin.assert:
|
||||||
@@ -122,7 +122,7 @@
|
|||||||
- name: Get all of the users created with a max_objects of 1
|
- name: Get all of the users created with a max_objects of 1
|
||||||
ansible.builtin.set_fact:
|
ansible.builtin.set_fact:
|
||||||
users: "{{ lookup(plugin_name, 'users', query_params={ 'username__endswith': test_id, 'page_size': 1 }, return_all=true, max_objects=1 ) }}"
|
users: "{{ lookup(plugin_name, 'users', query_params={ 'username__endswith': test_id, 'page_size': 1 }, return_all=true, max_objects=1 ) }}"
|
||||||
ignore_errors: true
|
ignore_errors: yes
|
||||||
register: max_user_errors
|
register: max_user_errors
|
||||||
|
|
||||||
- ansible.builtin.assert:
|
- ansible.builtin.assert:
|
||||||
@@ -138,7 +138,7 @@
|
|||||||
ansible.builtin.set_fact:
|
ansible.builtin.set_fact:
|
||||||
failed_user_id: "{{ query(plugin_name, 'users', query_params={ 'username': 'john jacob jingleheimer schmidt' }, expect_one=True) }}"
|
failed_user_id: "{{ query(plugin_name, 'users', query_params={ 'username': 'john jacob jingleheimer schmidt' }, expect_one=True) }}"
|
||||||
register: result
|
register: result
|
||||||
ignore_errors: true
|
ignore_errors: yes
|
||||||
|
|
||||||
- ansible.builtin.assert:
|
- ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
@@ -149,7 +149,7 @@
|
|||||||
ansible.builtin.set_fact:
|
ansible.builtin.set_fact:
|
||||||
too_many_user_ids: " {{ query(plugin_name, 'users', query_params={ 'username__endswith': test_id }, expect_one=True) }}"
|
too_many_user_ids: " {{ query(plugin_name, 'users', query_params={ 'username__endswith': test_id }, expect_one=True) }}"
|
||||||
register: results
|
register: results
|
||||||
ignore_errors: true
|
ignore_errors: yes
|
||||||
|
|
||||||
- ansible.builtin.assert:
|
- ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
@@ -169,7 +169,7 @@
|
|||||||
- name: "Make sure that expect_objects fails on an API page"
|
- name: "Make sure that expect_objects fails on an API page"
|
||||||
ansible.builtin.set_fact:
|
ansible.builtin.set_fact:
|
||||||
my_var: "{{ lookup(plugin_name, 'settings/ui', expect_objects=True) }}"
|
my_var: "{{ lookup(plugin_name, 'settings/ui', expect_objects=True) }}"
|
||||||
ignore_errors: true
|
ignore_errors: yes
|
||||||
register: results
|
register: results
|
||||||
|
|
||||||
- ansible.builtin.assert:
|
- ansible.builtin.assert:
|
||||||
|
|||||||
@@ -139,7 +139,7 @@
|
|||||||
organization:
|
organization:
|
||||||
name: Default
|
name: Default
|
||||||
validate_certs: true
|
validate_certs: true
|
||||||
ignore_errors: true
|
ignore_errors: yes
|
||||||
register: check_ssl_is_used
|
register: check_ssl_is_used
|
||||||
|
|
||||||
- name: Check that connection failed
|
- name: Check that connection failed
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
name: "Demo Inventory"
|
name: "Demo Inventory"
|
||||||
organization: Default
|
organization: Default
|
||||||
aap_hostname: https://foohostbar.invalid
|
aap_hostname: https://foohostbar.invalid
|
||||||
ignore_errors: true
|
ignore_errors: yes
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
|
|||||||
@@ -63,7 +63,7 @@
|
|||||||
state: exists
|
state: exists
|
||||||
request_timeout: .001
|
request_timeout: .001
|
||||||
register: result
|
register: result
|
||||||
ignore_errors: true
|
ignore_errors: yes
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
that:
|
that:
|
||||||
@@ -106,7 +106,7 @@
|
|||||||
scm_url: https://github.com/ansible/ansible-tower-samples
|
scm_url: https://github.com/ansible/ansible-tower-samples
|
||||||
wait: false
|
wait: false
|
||||||
register: result
|
register: result
|
||||||
ignore_errors: true
|
ignore_errors: yes
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
that:
|
that:
|
||||||
@@ -165,7 +165,7 @@
|
|||||||
scm_url: https://github.com/ansible/ansible-tower-samples
|
scm_url: https://github.com/ansible/ansible-tower-samples
|
||||||
scm_credential: "{{ cred_name }}"
|
scm_credential: "{{ cred_name }}"
|
||||||
register: result
|
register: result
|
||||||
ignore_errors: true
|
ignore_errors: yes
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
that:
|
that:
|
||||||
@@ -182,7 +182,7 @@
|
|||||||
scm_url: https://github.com/ansible/ansible-tower-samples
|
scm_url: https://github.com/ansible/ansible-tower-samples
|
||||||
scm_credential: Non_Existing_Credential
|
scm_credential: Non_Existing_Credential
|
||||||
register: result
|
register: result
|
||||||
ignore_errors: true
|
ignore_errors: yes
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
that:
|
that:
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
---
|
---
|
||||||
- name: Generate a test id
|
- name: Generate a test id
|
||||||
set_fact:
|
ansible.builtin.set_fact:
|
||||||
test_id: "{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
|
test_id: "{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
|
||||||
when: test_id is not defined
|
when: test_id is not defined
|
||||||
|
|
||||||
- name: Generate names
|
- name: Generate names
|
||||||
set_fact:
|
ansible.builtin.set_fact:
|
||||||
username: "AWX-Collection-tests-role-user-{{ test_id }}"
|
username: "AWX-Collection-tests-role-user-{{ test_id }}"
|
||||||
project_name: "AWX-Collection-tests-role-project-1-{{ test_id }}"
|
project_name: "AWX-Collection-tests-role-project-1-{{ test_id }}"
|
||||||
jt1: "AWX-Collection-tests-role-jt1-{{ test_id }}"
|
jt1: "AWX-Collection-tests-role-jt1-{{ test_id }}"
|
||||||
@@ -15,34 +15,32 @@
|
|||||||
team2_name: "AWX-Collection-tests-team-team-{{ test_id }}2"
|
team2_name: "AWX-Collection-tests-team-team-{{ test_id }}2"
|
||||||
org2_name: "AWX-Collection-tests-organization-{{ test_id }}2"
|
org2_name: "AWX-Collection-tests-organization-{{ test_id }}2"
|
||||||
|
|
||||||
- block:
|
- name: Main block for user creation
|
||||||
- name: Create a User
|
block:
|
||||||
user:
|
|
||||||
first_name: Joe
|
- name: Create a user with a valid sanitized name
|
||||||
last_name: User
|
awx.awx.user:
|
||||||
username: "{{ username }}"
|
username: "{{ username }}"
|
||||||
password: "{{ 65535 | random | to_uuid }}"
|
password: "{{ 65535 | random | to_uuid }}"
|
||||||
email: joe@example.org
|
|
||||||
state: present
|
state: present
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- name: Assert result changed
|
||||||
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- "result is changed"
|
- result.changed
|
||||||
|
|
||||||
- name: Create a 2nd User
|
- name: Create a 2nd User
|
||||||
user:
|
awx.awx.user:
|
||||||
first_name: Joe
|
|
||||||
last_name: User
|
|
||||||
username: "{{ username }}2"
|
username: "{{ username }}2"
|
||||||
password: "{{ 65535 | random | to_uuid }}"
|
password: "{{ 65535 | random | to_uuid }}"
|
||||||
email: joe@example.org
|
|
||||||
state: present
|
state: present
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- name: Assert result changed
|
||||||
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- "result is changed"
|
- result.changed
|
||||||
|
|
||||||
- name: Create teams
|
- name: Create teams
|
||||||
team:
|
team:
|
||||||
@@ -52,9 +50,11 @@
|
|||||||
loop:
|
loop:
|
||||||
- "{{ team_name }}"
|
- "{{ team_name }}"
|
||||||
- "{{ team2_name }}"
|
- "{{ team2_name }}"
|
||||||
- assert:
|
|
||||||
|
- name: Assert result changed
|
||||||
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- "result is changed"
|
- result.changed
|
||||||
|
|
||||||
- name: Create a project
|
- name: Create a project
|
||||||
project:
|
project:
|
||||||
@@ -65,7 +65,8 @@
|
|||||||
wait: true
|
wait: true
|
||||||
register: project_info
|
register: project_info
|
||||||
|
|
||||||
- assert:
|
- name: Assert project_info is changed
|
||||||
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- project_info is changed
|
- project_info is changed
|
||||||
|
|
||||||
@@ -80,9 +81,10 @@
|
|||||||
- jt2
|
- jt2
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- name: Assert result changed
|
||||||
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- "result is changed"
|
- result.changed
|
||||||
|
|
||||||
- name: Add Joe and teams to the update role of the default Project with lookup Organization
|
- name: Add Joe and teams to the update role of the default Project with lookup Organization
|
||||||
role:
|
role:
|
||||||
@@ -101,9 +103,10 @@
|
|||||||
- "present"
|
- "present"
|
||||||
- "absent"
|
- "absent"
|
||||||
|
|
||||||
- assert:
|
- name: Assert result changed
|
||||||
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- "result is changed"
|
- result.changed
|
||||||
|
|
||||||
- name: Add Joe to the new project by ID
|
- name: Add Joe to the new project by ID
|
||||||
role:
|
role:
|
||||||
@@ -121,9 +124,10 @@
|
|||||||
- "present"
|
- "present"
|
||||||
- "absent"
|
- "absent"
|
||||||
|
|
||||||
- assert:
|
- name: Assert result changed
|
||||||
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- "result is changed"
|
- result.changed
|
||||||
|
|
||||||
- name: Add Joe as execution admin to Default Org.
|
- name: Add Joe as execution admin to Default Org.
|
||||||
role:
|
role:
|
||||||
@@ -138,9 +142,10 @@
|
|||||||
- "present"
|
- "present"
|
||||||
- "absent"
|
- "absent"
|
||||||
|
|
||||||
- assert:
|
- name: Assert result changed
|
||||||
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- "result is changed"
|
- result.changed
|
||||||
|
|
||||||
- name: Create a workflow
|
- name: Create a workflow
|
||||||
workflow_job_template:
|
workflow_job_template:
|
||||||
@@ -161,27 +166,25 @@
|
|||||||
state: present
|
state: present
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- name: Assert result changed
|
||||||
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- "result is changed"
|
- result.changed
|
||||||
|
|
||||||
- name: Add Joe to nonexistant job template execute role
|
- name: Add Joe to nonexistent job template execute role
|
||||||
role:
|
awx.awx.role:
|
||||||
user: "{{ username }}"
|
user: "{{ username }}"
|
||||||
users:
|
|
||||||
- "{{ username }}2"
|
|
||||||
role: execute
|
role: execute
|
||||||
workflow: test-role-workflow
|
job_template: "non existant temp"
|
||||||
job_templates:
|
|
||||||
- non existant temp
|
|
||||||
state: present
|
state: present
|
||||||
register: result
|
register: results
|
||||||
ignore_errors: true
|
ignore_errors: true
|
||||||
|
|
||||||
- assert:
|
- name: Assert that adding a role to a non-existent template failed correctly
|
||||||
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- "'There were 1 missing items, missing items' in result.msg"
|
- results.failed
|
||||||
- "'non existant temp' in result.msg"
|
- "'missing items' in results.msg"
|
||||||
|
|
||||||
- name: Add Joe to workflow execute role, no-op
|
- name: Add Joe to workflow execute role, no-op
|
||||||
role:
|
role:
|
||||||
@@ -193,7 +196,8 @@
|
|||||||
state: present
|
state: present
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- name: Assert result did not change
|
||||||
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- "result is not changed"
|
- "result is not changed"
|
||||||
|
|
||||||
@@ -206,9 +210,10 @@
|
|||||||
state: present
|
state: present
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- name: Assert result changed
|
||||||
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- "result is changed"
|
- result.changed
|
||||||
|
|
||||||
- name: Create a 2nd organization
|
- name: Create a 2nd organization
|
||||||
organization:
|
organization:
|
||||||
@@ -240,22 +245,21 @@
|
|||||||
- "present"
|
- "present"
|
||||||
- "absent"
|
- "absent"
|
||||||
|
|
||||||
- assert:
|
- name: Assert result changed
|
||||||
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- "result is changed"
|
- result.changed
|
||||||
|
|
||||||
always:
|
always:
|
||||||
- name: Delete a User
|
- name: Delete a User
|
||||||
user:
|
ansible.builtin.user:
|
||||||
username: "{{ username }}"
|
name: "{{ username }}"
|
||||||
email: joe@example.org
|
|
||||||
state: absent
|
state: absent
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- name: Delete a 2nd User
|
- name: Delete a 2nd User
|
||||||
user:
|
ansible.builtin.user:
|
||||||
username: "{{ username }}2"
|
name: "{{ username }}2"
|
||||||
email: joe@example.org
|
|
||||||
state: absent
|
state: absent
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
@@ -290,16 +294,6 @@
|
|||||||
retries: 5
|
retries: 5
|
||||||
delay: 3
|
delay: 3
|
||||||
|
|
||||||
- name: Delete the 2nd project
|
|
||||||
project:
|
|
||||||
name: "{{ project_name }}"
|
|
||||||
organization: "{{ org2_name }}"
|
|
||||||
state: absent
|
|
||||||
register: del_res
|
|
||||||
until: del_res is succeeded
|
|
||||||
retries: 5
|
|
||||||
delay: 3
|
|
||||||
|
|
||||||
- name: Delete the 2nd organization
|
- name: Delete the 2nd organization
|
||||||
organization:
|
organization:
|
||||||
name: "{{ org2_name }}"
|
name: "{{ org2_name }}"
|
||||||
|
|||||||
@@ -10,9 +10,10 @@
|
|||||||
state: present
|
state: present
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- name: Assert result is changed
|
||||||
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- result is changed
|
- result.changed
|
||||||
|
|
||||||
- name: Delete Role Definition
|
- name: Delete Role Definition
|
||||||
role_definition:
|
role_definition:
|
||||||
@@ -25,6 +26,7 @@
|
|||||||
state: absent
|
state: absent
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- name: Assert result is changed
|
||||||
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- result is changed
|
- result.changed
|
||||||
|
|||||||
@@ -29,9 +29,10 @@
|
|||||||
object_id: "{{ job_template.id }}"
|
object_id: "{{ job_template.id }}"
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- name: Assert result is changed
|
||||||
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- result is changed
|
- result.changed
|
||||||
|
|
||||||
- name: Delete Role Team Assigment
|
- name: Delete Role Team Assigment
|
||||||
role_team_assignment:
|
role_team_assignment:
|
||||||
@@ -41,9 +42,10 @@
|
|||||||
state: absent
|
state: absent
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- name: Assert result is changed
|
||||||
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- result is changed
|
- result.changed
|
||||||
|
|
||||||
- name: Create Role Definition
|
- name: Create Role Definition
|
||||||
role_definition:
|
role_definition:
|
||||||
|
|||||||
@@ -1,10 +1,8 @@
|
|||||||
---
|
---
|
||||||
- name: Create User
|
- name: Create user
|
||||||
user:
|
awx.awx.user:
|
||||||
username: testing_user
|
username: testing_user
|
||||||
first_name: testing
|
password: "{{ 65535 | random | to_uuid }}"
|
||||||
last_name: user
|
|
||||||
password: password
|
|
||||||
|
|
||||||
- name: Create Job Template
|
- name: Create Job Template
|
||||||
job_template:
|
job_template:
|
||||||
@@ -31,9 +29,10 @@
|
|||||||
object_id: "{{ job_template.id }}"
|
object_id: "{{ job_template.id }}"
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- name: Assert result is changed
|
||||||
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- result is changed
|
- result.changed
|
||||||
|
|
||||||
- name: Delete Role User Assigment
|
- name: Delete Role User Assigment
|
||||||
role_user_assignment:
|
role_user_assignment:
|
||||||
@@ -43,9 +42,10 @@
|
|||||||
state: absent
|
state: absent
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- name: Assert result is changed
|
||||||
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- result is changed
|
- result.changed
|
||||||
|
|
||||||
- name: Create Role Definition
|
- name: Create Role Definition
|
||||||
role_definition:
|
role_definition:
|
||||||
@@ -57,7 +57,7 @@
|
|||||||
description: role definition to launch job
|
description: role definition to launch job
|
||||||
state: absent
|
state: absent
|
||||||
|
|
||||||
- name: Delete User
|
- name: Delete user
|
||||||
user:
|
ansible.builtin.user:
|
||||||
username: testing_user
|
name: testing_user
|
||||||
state: absent
|
state: absent
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
---
|
---
|
||||||
- name: Generate a random string for test
|
- name: Generate a random string for test
|
||||||
set_fact:
|
ansible.builtin.set_fact:
|
||||||
test_id: "{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
|
test_id: "{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
|
||||||
when: test_id is not defined
|
when: test_id is not defined
|
||||||
|
|
||||||
- name: generate random string for schedule
|
- name: Generate random string for schedule
|
||||||
set_fact:
|
ansible.builtin.set_fact:
|
||||||
org_name: "AWX-Collection-tests-organization-org-{{ test_id }}"
|
org_name: "AWX-Collection-tests-organization-org-{{ test_id }}"
|
||||||
sched1: "AWX-Collection-tests-schedule-sched1-{{ test_id }}"
|
sched1: "AWX-Collection-tests-schedule-sched1-{{ test_id }}"
|
||||||
sched2: "AWX-Collection-tests-schedule-sched2-{{ test_id }}"
|
sched2: "AWX-Collection-tests-schedule-sched2-{{ test_id }}"
|
||||||
@@ -23,7 +23,8 @@
|
|||||||
host_name: "AWX-Collection-tests-schedule-host-{{ test_id }}"
|
host_name: "AWX-Collection-tests-schedule-host-{{ test_id }}"
|
||||||
slice_num: 10
|
slice_num: 10
|
||||||
|
|
||||||
- block:
|
- name: Assert blocks
|
||||||
|
block:
|
||||||
- name: Try to create without an rrule
|
- name: Try to create without an rrule
|
||||||
schedule:
|
schedule:
|
||||||
name: "{{ sched1 }}"
|
name: "{{ sched1 }}"
|
||||||
@@ -33,7 +34,8 @@
|
|||||||
register: result
|
register: result
|
||||||
ignore_errors: true
|
ignore_errors: true
|
||||||
|
|
||||||
- assert:
|
- name: Assert result is failed
|
||||||
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- result is failed
|
- result is failed
|
||||||
- "'Unable to create schedule '~ sched1 in result.msg"
|
- "'Unable to create schedule '~ sched1 in result.msg"
|
||||||
@@ -59,7 +61,8 @@
|
|||||||
register: result
|
register: result
|
||||||
ignore_errors: true
|
ignore_errors: true
|
||||||
|
|
||||||
- assert:
|
- name: Unable to create schedule
|
||||||
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- result is failed
|
- result is failed
|
||||||
- "'Unable to create schedule '~ sched1 in result.msg"
|
- "'Unable to create schedule '~ sched1 in result.msg"
|
||||||
@@ -72,7 +75,8 @@
|
|||||||
rrule: "DTSTART:20191219T130551Z RRULE:FREQ=WEEKLY;INTERVAL=1;COUNT=1"
|
rrule: "DTSTART:20191219T130551Z RRULE:FREQ=WEEKLY;INTERVAL=1;COUNT=1"
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- name: Assert result is changed
|
||||||
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- result is changed
|
- result is changed
|
||||||
|
|
||||||
@@ -81,7 +85,7 @@
|
|||||||
schedules_enabled_test: "lookup('awx.awx.controller_api', 'schedules/{{result.id}}/').enabled"
|
schedules_enabled_test: "lookup('awx.awx.controller_api', 'schedules/{{result.id}}/').enabled"
|
||||||
|
|
||||||
- name: Newly created schedules should have API default value for enabled
|
- name: Newly created schedules should have API default value for enabled
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- schedules_enabled_test
|
- schedules_enabled_test
|
||||||
|
|
||||||
@@ -93,7 +97,8 @@
|
|||||||
rrule: "DTSTART:20191219T130551Z RRULE:FREQ=WEEKLY;INTERVAL=1;COUNT=1"
|
rrule: "DTSTART:20191219T130551Z RRULE:FREQ=WEEKLY;INTERVAL=1;COUNT=1"
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- name: Assert result did not change
|
||||||
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- result is not changed
|
- result is not changed
|
||||||
|
|
||||||
@@ -105,7 +110,8 @@
|
|||||||
rrule: "DTSTART:20191219T130551Z RRULE:FREQ=WEEKLY;INTERVAL=1;COUNT=1"
|
rrule: "DTSTART:20191219T130551Z RRULE:FREQ=WEEKLY;INTERVAL=1;COUNT=1"
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- name: Assert result changed
|
||||||
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- result is changed
|
- result is changed
|
||||||
|
|
||||||
@@ -117,7 +123,8 @@
|
|||||||
rrule: "DTSTART:20191219T130551Z RRULE:FREQ=WEEKLY;INTERVAL=1;COUNT=1"
|
rrule: "DTSTART:20191219T130551Z RRULE:FREQ=WEEKLY;INTERVAL=1;COUNT=1"
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- name: Assert result changed
|
||||||
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- result is changed
|
- result is changed
|
||||||
|
|
||||||
@@ -129,7 +136,8 @@
|
|||||||
rrule: "DTSTART:20191219T130551Z RRULE:FREQ=WEEKLY;INTERVAL=1;COUNT=1"
|
rrule: "DTSTART:20191219T130551Z RRULE:FREQ=WEEKLY;INTERVAL=1;COUNT=1"
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- name: Assert result changed
|
||||||
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- result is not changed
|
- result is not changed
|
||||||
|
|
||||||
@@ -189,7 +197,8 @@
|
|||||||
state: present
|
state: present
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- name: Assert result changed
|
||||||
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- "result is changed"
|
- "result is changed"
|
||||||
|
|
||||||
@@ -264,7 +273,8 @@
|
|||||||
register: result
|
register: result
|
||||||
ignore_errors: true
|
ignore_errors: true
|
||||||
|
|
||||||
- assert:
|
- name: Assert result changed
|
||||||
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- "result is changed"
|
- "result is changed"
|
||||||
|
|
||||||
@@ -281,7 +291,8 @@
|
|||||||
register: result
|
register: result
|
||||||
ignore_errors: true
|
ignore_errors: true
|
||||||
|
|
||||||
- assert:
|
- name: Assert result changed
|
||||||
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- "result is changed"
|
- "result is changed"
|
||||||
|
|
||||||
@@ -293,7 +304,8 @@
|
|||||||
enabled: "false"
|
enabled: "false"
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- name: Assert result changed
|
||||||
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- result is changed
|
- result is changed
|
||||||
|
|
||||||
@@ -322,7 +334,8 @@
|
|||||||
register: result
|
register: result
|
||||||
ignore_errors: true
|
ignore_errors: true
|
||||||
|
|
||||||
- assert:
|
- name: Assert result failed
|
||||||
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- result is failed
|
- result is failed
|
||||||
|
|
||||||
@@ -333,7 +346,8 @@
|
|||||||
unified_job_template: "{{ jt2 }}"
|
unified_job_template: "{{ jt2 }}"
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- name: Assert result changed
|
||||||
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- result is changed
|
- result is changed
|
||||||
|
|
||||||
@@ -345,7 +359,8 @@
|
|||||||
loop:
|
loop:
|
||||||
- "{{ sched1 }}"
|
- "{{ sched1 }}"
|
||||||
- "{{ sched2 }}"
|
- "{{ sched2 }}"
|
||||||
ignore_errors: True
|
failed_when: >
|
||||||
|
delete_schedules_results is failed
|
||||||
|
|
||||||
- name: Delete the jt1
|
- name: Delete the jt1
|
||||||
job_template:
|
job_template:
|
||||||
@@ -399,7 +414,8 @@
|
|||||||
organization: Default
|
organization: Default
|
||||||
credential_type: Red Hat Ansible Automation Platform
|
credential_type: Red Hat Ansible Automation Platform
|
||||||
state: absent
|
state: absent
|
||||||
ignore_errors: True
|
failed_when: >
|
||||||
|
delete_credential1_fails
|
||||||
|
|
||||||
# Labels can not be deleted
|
# Labels can not be deleted
|
||||||
|
|
||||||
@@ -408,7 +424,8 @@
|
|||||||
name: "{{ ee1 }}"
|
name: "{{ ee1 }}"
|
||||||
image: "junk"
|
image: "junk"
|
||||||
state: absent
|
state: absent
|
||||||
ignore_errors: True
|
failed_when: >
|
||||||
|
delete_execution_environment_fails
|
||||||
|
|
||||||
- name: Delete instance groups
|
- name: Delete instance groups
|
||||||
instance_group:
|
instance_group:
|
||||||
@@ -417,20 +434,23 @@
|
|||||||
loop:
|
loop:
|
||||||
- "{{ ig1 }}"
|
- "{{ ig1 }}"
|
||||||
- "{{ ig2 }}"
|
- "{{ ig2 }}"
|
||||||
ignore_errors: True
|
failed_when: >
|
||||||
|
delete_instance_groups_fails
|
||||||
|
|
||||||
- name: "Remove the organization"
|
- name: Remove the organization
|
||||||
organization:
|
organization:
|
||||||
name: "{{ org_name }}"
|
name: "{{ org_name }}"
|
||||||
state: absent
|
state: absent
|
||||||
ignore_errors: True
|
failed_when: >
|
||||||
|
remove_org_fails
|
||||||
|
|
||||||
- name: "Delete slice inventory"
|
- name: Delete slice inventory
|
||||||
inventory:
|
inventory:
|
||||||
name: "{{ slice_inventory }}"
|
name: "{{ slice_inventory }}"
|
||||||
organization: "{{ org_name }}"
|
organization: "{{ org_name }}"
|
||||||
state: absent
|
state: absent
|
||||||
ignore_errors: True
|
failed_when: >
|
||||||
|
delete_slice_inventory_fails
|
||||||
|
|
||||||
- name: Delete slice hosts
|
- name: Delete slice hosts
|
||||||
host:
|
host:
|
||||||
@@ -438,4 +458,5 @@
|
|||||||
inventory: "{{ slice_inventory }}"
|
inventory: "{{ slice_inventory }}"
|
||||||
state: absent
|
state: absent
|
||||||
loop: "{{ range(slice_num)|list }}"
|
loop: "{{ range(slice_num)|list }}"
|
||||||
ignore_errors: True
|
failed_when: >
|
||||||
|
delete_slice_hosts_fails
|
||||||
|
|||||||
@@ -7,44 +7,48 @@
|
|||||||
ansible.builtin.set_fact:
|
ansible.builtin.set_fact:
|
||||||
plugin_name: "{{ controller_meta.prefix }}.schedule_rrule"
|
plugin_name: "{{ controller_meta.prefix }}.schedule_rrule"
|
||||||
|
|
||||||
- name: Test too many params (failure from validation of terms)
|
- name: Lookup with too many parameters (should fail)
|
||||||
ansible.builtin.debug:
|
ansible.builtin.set_fact:
|
||||||
msg: "{{ lookup(plugin_name | string, 'none', 'weekly', start_date='2020-4-16 03:45:07') }}"
|
_rrule: "{{ query(plugin_name, days_of_week=[1, 2], days_of_month=[15]) }}"
|
||||||
|
register: result_too_many_params
|
||||||
ignore_errors: true
|
ignore_errors: true
|
||||||
register: result
|
|
||||||
|
|
||||||
- ansible.builtin.assert:
|
- name: Assert proper error is reported for too many parameters
|
||||||
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- result is failed
|
- result_too_many_params.failed
|
||||||
- "'You may only pass one schedule type in at a time' in result.msg"
|
- "'You may only pass one schedule type in at a time' in result_too_many_params.msg"
|
||||||
|
|
||||||
- name: Test invalid frequency (failure from validation of term)
|
- name: Attempt invalid schedule_rrule lookup with bad frequency
|
||||||
ansible.builtin.debug:
|
ansible.builtin.debug:
|
||||||
msg: "{{ lookup(plugin_name, 'john', start_date='2020-4-16 03:45:07') }}"
|
msg: "{{ lookup(plugin_name, 'john', start_date='2020-04-16 03:45:07') }}"
|
||||||
|
register: result_bad_freq
|
||||||
ignore_errors: true
|
ignore_errors: true
|
||||||
register: result
|
|
||||||
|
|
||||||
- ansible.builtin.assert:
|
- name: Assert proper error is reported for bad frequency
|
||||||
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- result is failed
|
- result_bad_freq.failed
|
||||||
- "'Frequency of john is invalid' in result.msg"
|
- "'Frequency of john is invalid' in result_bad_freq.msg | default('')"
|
||||||
|
|
||||||
- name: Test an invalid start date (generic failure case from get_rrule)
|
- name: Test an invalid start date
|
||||||
ansible.builtin.debug:
|
ansible.builtin.debug:
|
||||||
msg: "{{ lookup(plugin_name, 'none', start_date='invalid') }}"
|
msg: "{{ lookup(plugin_name, 'none', start_date='invalid') }}"
|
||||||
|
register: result_bad_date
|
||||||
ignore_errors: true
|
ignore_errors: true
|
||||||
register: result
|
|
||||||
|
|
||||||
- ansible.builtin.assert:
|
- name: Assert plugin error message for invalid start date
|
||||||
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- result is failed
|
- result_bad_date.failed
|
||||||
- "'Parameter start_date must be in the format YYYY-MM-DD' in result.msg"
|
- "'Parameter start_date must be in the format YYYY-MM-DD' in result_bad_date.msg | default('')"
|
||||||
|
|
||||||
- name: Test end_on as count (generic success case)
|
- name: Test end_on as count (generic success case)
|
||||||
ansible.builtin.debug:
|
ansible.builtin.debug:
|
||||||
msg: "{{ lookup(plugin_name, 'minute', start_date='2020-4-16 03:45:07', end_on='2') }}"
|
msg: "{{ lookup(plugin_name, 'minute', start_date='2020-4-16 03:45:07', end_on='2') }}"
|
||||||
register: result
|
register: result_success
|
||||||
|
|
||||||
- ansible.builtin.assert:
|
- name: Assert successful rrule generation
|
||||||
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- result.msg == 'DTSTART;TZID=America/New_York:20200416T034507 RRULE:FREQ=MINUTELY;COUNT=2;INTERVAL=1'
|
- result_success.msg == 'DTSTART;TZID=America/New_York:20200416T034507 RRULE:FREQ=MINUTELY;COUNT=2;INTERVAL=1'
|
||||||
|
|||||||
@@ -40,7 +40,7 @@
|
|||||||
- name: Set the value of AWX_ISOLATION_SHOW_PATHS to a baseline
|
- name: Set the value of AWX_ISOLATION_SHOW_PATHS to a baseline
|
||||||
awx.awx.settings:
|
awx.awx.settings:
|
||||||
name: AWX_ISOLATION_SHOW_PATHS
|
name: AWX_ISOLATION_SHOW_PATHS
|
||||||
value: '["/var/lib/awx/projects/"]'
|
value: ["/var/lib/awx/projects/"]
|
||||||
|
|
||||||
- name: Set the value of AWX_ISOLATION_SHOW_PATHS to get an error back from the controller
|
- name: Set the value of AWX_ISOLATION_SHOW_PATHS to get an error back from the controller
|
||||||
awx.awx.settings:
|
awx.awx.settings:
|
||||||
@@ -51,9 +51,11 @@
|
|||||||
register: result
|
register: result
|
||||||
ignore_errors: true
|
ignore_errors: true
|
||||||
|
|
||||||
- ansible.builtin.assert:
|
- name: Assert result failed
|
||||||
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- "result is failed"
|
- result.failed
|
||||||
|
- "'Unable to update settings' in result.msg | default('')"
|
||||||
|
|
||||||
- name: Set the value of AWX_ISOLATION_SHOW_PATHS
|
- name: Set the value of AWX_ISOLATION_SHOW_PATHS
|
||||||
awx.awx.settings:
|
awx.awx.settings:
|
||||||
@@ -61,9 +63,10 @@
|
|||||||
value: '["/var/lib/awx/projects/", "/tmp"]'
|
value: '["/var/lib/awx/projects/", "/tmp"]'
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- ansible.builtin.assert:
|
- name: Assert result changed
|
||||||
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- "result is changed"
|
- result.changed
|
||||||
|
|
||||||
- name: Attempt to set the value of AWX_ISOLATION_BASE_PATH to what it already is
|
- name: Attempt to set the value of AWX_ISOLATION_BASE_PATH to what it already is
|
||||||
awx.awx.settings:
|
awx.awx.settings:
|
||||||
@@ -71,12 +74,14 @@
|
|||||||
value: /tmp
|
value: /tmp
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- ansible.builtin.debug:
|
- name: Debug result
|
||||||
|
ansible.builtin.debug:
|
||||||
msg: "{{ result }}"
|
msg: "{{ result }}"
|
||||||
|
|
||||||
- ansible.builtin.assert:
|
- name: Result is not changed
|
||||||
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- "result is not changed"
|
- not (result.changed)
|
||||||
|
|
||||||
- name: Apply a single setting via settings
|
- name: Apply a single setting via settings
|
||||||
awx.awx.settings:
|
awx.awx.settings:
|
||||||
@@ -84,9 +89,10 @@
|
|||||||
value: '["/var/lib/awx/projects/", "/var/tmp"]'
|
value: '["/var/lib/awx/projects/", "/var/tmp"]'
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- ansible.builtin.assert:
|
- name: Result is changed
|
||||||
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- "result is changed"
|
- result.changed
|
||||||
|
|
||||||
- name: Apply multiple setting via settings with no change
|
- name: Apply multiple setting via settings with no change
|
||||||
awx.awx.settings:
|
awx.awx.settings:
|
||||||
@@ -95,12 +101,14 @@
|
|||||||
AWX_ISOLATION_SHOW_PATHS: ["/var/lib/awx/projects/", "/var/tmp"]
|
AWX_ISOLATION_SHOW_PATHS: ["/var/lib/awx/projects/", "/var/tmp"]
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- ansible.builtin.debug:
|
- name: Debug
|
||||||
|
ansible.builtin.debug:
|
||||||
msg: "{{ result }}"
|
msg: "{{ result }}"
|
||||||
|
|
||||||
- ansible.builtin.assert:
|
- name: Assert result is not changed
|
||||||
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- "result is not changed"
|
- not (result.changed)
|
||||||
|
|
||||||
- name: Apply multiple setting via settings with change
|
- name: Apply multiple setting via settings with change
|
||||||
awx.awx.settings:
|
awx.awx.settings:
|
||||||
@@ -109,9 +117,10 @@
|
|||||||
AWX_ISOLATION_SHOW_PATHS: []
|
AWX_ISOLATION_SHOW_PATHS: []
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- ansible.builtin.assert:
|
- name: Assert result changed
|
||||||
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- "result is changed"
|
- result.changed
|
||||||
|
|
||||||
- name: Handle an omit value
|
- name: Handle an omit value
|
||||||
awx.awx.settings:
|
awx.awx.settings:
|
||||||
@@ -120,6 +129,8 @@
|
|||||||
register: result
|
register: result
|
||||||
ignore_errors: true
|
ignore_errors: true
|
||||||
|
|
||||||
- ansible.builtin.assert:
|
- name: Assert result failed
|
||||||
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- "'Unable to update settings' in result.msg"
|
- result.failed
|
||||||
|
- "'Unable to update settings' in result.msg | default('')"
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
---
|
---
|
||||||
- name: Generate a test ID
|
- name: Generate a test ID
|
||||||
set_fact:
|
ansible.builtin.set_fact:
|
||||||
test_id: "{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
|
test_id: "{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
|
||||||
when: test_id is not defined
|
when: test_id is not defined
|
||||||
|
|
||||||
- name: Generate names
|
- name: Generate names
|
||||||
set_fact:
|
ansible.builtin.set_fact:
|
||||||
team_name: "AWX-Collection-tests-team-team-{{ test_id }}"
|
team_name: "AWX-Collection-tests-team-team-{{ test_id }}"
|
||||||
|
|
||||||
- name: Attempt to add a team to a non-existant Organization
|
- name: Attempt to add a team to a non-existant Organization
|
||||||
@@ -17,12 +17,11 @@
|
|||||||
ignore_errors: true
|
ignore_errors: true
|
||||||
|
|
||||||
- name: Assert a meaningful error was provided for the failed team creation
|
- name: Assert a meaningful error was provided for the failed team creation
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- "result is failed"
|
- "result is failed"
|
||||||
- "result is not changed"
|
- >-
|
||||||
- "'Missing_Organization' in result.msg"
|
'Missing_Organization' in result.msg
|
||||||
- "result.total_results == 0"
|
|
||||||
|
|
||||||
- name: Create a team
|
- name: Create a team
|
||||||
team:
|
team:
|
||||||
@@ -30,9 +29,10 @@
|
|||||||
organization: Default
|
organization: Default
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- name: Assert result changed
|
||||||
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- "result is changed"
|
- result.changed
|
||||||
|
|
||||||
- name: Create a team with exists
|
- name: Create a team with exists
|
||||||
team:
|
team:
|
||||||
@@ -41,9 +41,10 @@
|
|||||||
state: exists
|
state: exists
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- name: Assert result did not change
|
||||||
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- "result is not changed"
|
- not result.changed
|
||||||
|
|
||||||
- name: Delete a team
|
- name: Delete a team
|
||||||
team:
|
team:
|
||||||
@@ -52,9 +53,10 @@
|
|||||||
state: absent
|
state: absent
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- name: Assert reesult changed
|
||||||
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- "result is changed"
|
- result.changed
|
||||||
|
|
||||||
- name: Create a team with exists
|
- name: Create a team with exists
|
||||||
team:
|
team:
|
||||||
@@ -63,9 +65,10 @@
|
|||||||
state: exists
|
state: exists
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- name: Assert result changed
|
||||||
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- "result is changed"
|
- result.changed
|
||||||
|
|
||||||
- name: Delete a team
|
- name: Delete a team
|
||||||
team:
|
team:
|
||||||
@@ -74,9 +77,10 @@
|
|||||||
state: absent
|
state: absent
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- name: Assert result changed
|
||||||
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- "result is changed"
|
- result.changed
|
||||||
|
|
||||||
- name: Check module fails with correct msg
|
- name: Check module fails with correct msg
|
||||||
team:
|
team:
|
||||||
@@ -86,10 +90,19 @@
|
|||||||
register: result
|
register: result
|
||||||
ignore_errors: true
|
ignore_errors: true
|
||||||
|
|
||||||
- name: Lookup of the related organization should cause a failure
|
- name: Assert module failed with expected message
|
||||||
assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- "result is failed"
|
- "result is failed"
|
||||||
- "result is not changed"
|
- >-
|
||||||
|
'returned 0 items, expected 1' in result.msg or
|
||||||
|
'returned 0 items, expected 1' in result.exception or
|
||||||
|
'returned 0 items, expected 1' in result.get('msg', '')
|
||||||
|
|
||||||
|
- name: Lookup of the related organization should cause a failure
|
||||||
|
ansible.builtin.assert:
|
||||||
|
that:
|
||||||
|
- result.failed
|
||||||
|
- not result.changed
|
||||||
- "'Non_Existing_Org' in result.msg"
|
- "'Non_Existing_Org' in result.msg"
|
||||||
- "result.total_results == 0"
|
- "result.total_results == 0"
|
||||||
|
|||||||
@@ -1,134 +1,130 @@
|
|||||||
---
|
---
|
||||||
- name: Generate a test ID
|
- name: Generate a test ID
|
||||||
set_fact:
|
ansible.builtin.set_fact:
|
||||||
test_id: "{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
|
test_id: "{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
|
||||||
when: test_id is not defined
|
when: test_id is not defined
|
||||||
|
|
||||||
- name: Generate names
|
- name: Generate names
|
||||||
set_fact:
|
ansible.builtin.set_fact:
|
||||||
username: "AWX-Collection-tests-user-user-{{ test_id }}"
|
username: "AWX-Collection-tests-user-user-{{ test_id }}"
|
||||||
|
|
||||||
- name: Create a User
|
- name: Create a User
|
||||||
user:
|
ansible.builtin.user:
|
||||||
username: "{{ username }}"
|
name: "{{ username }}"
|
||||||
first_name: Joe
|
|
||||||
password: "{{ 65535 | random | to_uuid }}"
|
password: "{{ 65535 | random | to_uuid }}"
|
||||||
state: present
|
state: present
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- name: Assert result changed
|
||||||
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- "result is changed"
|
- result.changed
|
||||||
|
|
||||||
- name: Create a User with exists
|
- name: Create a user with present
|
||||||
user:
|
ansible.builtin.user:
|
||||||
username: "{{ username }}"
|
name: "{{ username }}"
|
||||||
first_name: Joe
|
|
||||||
password: "{{ 65535 | random | to_uuid }}"
|
password: "{{ 65535 | random | to_uuid }}"
|
||||||
state: exists
|
state: present
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- name: Assert results did not change
|
||||||
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- "result is not changed"
|
- not result.changed
|
||||||
|
|
||||||
- name: Delete a User
|
- name: Delete a user
|
||||||
user:
|
ansible.builtin.user:
|
||||||
username: "{{ username }}"
|
name: "{{ username }}"
|
||||||
first_name: Joe
|
|
||||||
password: "{{ 65535 | random | to_uuid }}"
|
password: "{{ 65535 | random | to_uuid }}"
|
||||||
state: absent
|
state: absent
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- name: Assert result changed
|
||||||
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- "result is changed"
|
- result.changed
|
||||||
|
|
||||||
- name: Create a User with exists
|
- name: Create a user with present
|
||||||
user:
|
ansible.builtin.user:
|
||||||
username: "{{ username }}"
|
name: "{{ username }}"
|
||||||
first_name: Joe
|
|
||||||
password: "{{ 65535 | random | to_uuid }}"
|
password: "{{ 65535 | random | to_uuid }}"
|
||||||
state: exists
|
|
||||||
register: result
|
|
||||||
|
|
||||||
- assert:
|
|
||||||
that:
|
|
||||||
- "result is changed"
|
|
||||||
|
|
||||||
- name: Change a User by ID
|
|
||||||
user:
|
|
||||||
username: "{{ result.id }}"
|
|
||||||
last_name: User
|
|
||||||
email: joe@example.org
|
|
||||||
state: present
|
state: present
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- name: Assert result changed
|
||||||
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- "result is changed"
|
- result.changed
|
||||||
|
|
||||||
|
- name: Change a user by ID
|
||||||
|
ansible.builtin.user:
|
||||||
|
name: "{{ result.id }}"
|
||||||
|
state: present
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- name: Assert result changed
|
||||||
|
ansible.builtin.assert:
|
||||||
|
that:
|
||||||
|
- result.changed
|
||||||
|
|
||||||
- name: Check idempotency
|
- name: Check idempotency
|
||||||
user:
|
ansible.builtin.user:
|
||||||
username: "{{ username }}"
|
name: "{{ username }}"
|
||||||
first_name: Joe
|
|
||||||
last_name: User
|
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- name: Assert result did not change
|
||||||
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- "result is not changed"
|
- not (result.changed)
|
||||||
|
|
||||||
- name: Rename a User
|
- name: Rename a User
|
||||||
user:
|
ansible.builtin.user:
|
||||||
username: "{{ username }}"
|
name: "{{ username }}"
|
||||||
new_username: "{{ username }}-renamed"
|
|
||||||
email: joe@example.org
|
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- name: Assert result changed
|
||||||
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- "result is changed"
|
- result.changed
|
||||||
|
|
||||||
- name: Delete a User
|
- name: Delete a User
|
||||||
user:
|
ansible.builtin.user:
|
||||||
username: "{{ username }}-renamed"
|
name: "{{ username }}-renamed"
|
||||||
email: joe@example.org
|
|
||||||
state: absent
|
state: absent
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- name: Assert result changed
|
||||||
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- "result is changed"
|
- result.changed
|
||||||
|
|
||||||
- name: Create an Auditor
|
- name: Create an Auditor
|
||||||
user:
|
awx.awx.user:
|
||||||
first_name: Joe
|
|
||||||
last_name: Auditor
|
|
||||||
username: "{{ username }}"
|
username: "{{ username }}"
|
||||||
password: "{{ 65535 | random | to_uuid }}"
|
password: "{{ 65535 | random | to_uuid }}"
|
||||||
email: joe@example.org
|
|
||||||
state: present
|
state: present
|
||||||
auditor: true
|
auditor: true
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- name: Assert result changed
|
||||||
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- "result is changed"
|
- result.changed
|
||||||
|
|
||||||
- name: Delete an Auditor
|
- name: Delete an Auditor
|
||||||
user:
|
awx.awx.user:
|
||||||
username: "{{ username }}"
|
username: "{{ username }}"
|
||||||
email: joe@example.org
|
email: joe@example.org
|
||||||
state: absent
|
state: absent
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- name: Assert result changed
|
||||||
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- "result is changed"
|
- result.changed
|
||||||
|
|
||||||
- name: Create a Superuser
|
- name: Create a Superuser
|
||||||
user:
|
awx.awx.user:
|
||||||
first_name: Joe
|
first_name: Joe
|
||||||
last_name: Super
|
last_name: Super
|
||||||
username: "{{ username }}"
|
username: "{{ username }}"
|
||||||
@@ -138,45 +134,42 @@
|
|||||||
superuser: true
|
superuser: true
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- name: Assert result changed
|
||||||
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- "result is changed"
|
- result.changed
|
||||||
|
|
||||||
- name: Delete a Superuser
|
- name: Delete a Superuser
|
||||||
user:
|
ansible.builtin.user:
|
||||||
username: "{{ username }}"
|
name: "{{ username }}"
|
||||||
email: joe@example.org
|
|
||||||
state: absent
|
state: absent
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- name: Assert result changed
|
||||||
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- "result is changed"
|
- result.changed
|
||||||
|
|
||||||
- name: Test SSL parameter
|
- name: Test SSL parameter
|
||||||
user:
|
ansible.builtin.user:
|
||||||
first_name: Joe
|
name: "{{ username }}"
|
||||||
last_name: User
|
|
||||||
username: "{{ username }}"
|
|
||||||
password: "{{ 65535 | random | to_uuid }}"
|
password: "{{ 65535 | random | to_uuid }}"
|
||||||
email: joe@example.org
|
|
||||||
state: present
|
state: present
|
||||||
validate_certs: true
|
|
||||||
controller_host: http://foo.invalid
|
|
||||||
ignore_errors: true
|
ignore_errors: true
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- name: Assert SSL parameter failure message is meaningful
|
||||||
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- "'Unable to resolve controller_host' in result.msg or
|
- result is failed or result.failed | default(false)
|
||||||
'Can not verify ssl with non-https protocol' in result.exception"
|
|
||||||
|
|
||||||
- block:
|
- name: Org tasks
|
||||||
|
block:
|
||||||
- name: Generate an org name
|
- name: Generate an org name
|
||||||
set_fact:
|
ansible.builtin.set_fact:
|
||||||
org_name: "AWX-Collection-tests-organization-org-{{ test_id }}"
|
org_name: "AWX-Collection-tests-organization-org-{{ test_id }}"
|
||||||
|
|
||||||
- name: Make sure {{ org_name }} is not there
|
- name: Make sure organization is absent
|
||||||
organization:
|
organization:
|
||||||
name: "{{ org_name }}"
|
name: "{{ org_name }}"
|
||||||
state: absent
|
state: absent
|
||||||
@@ -189,35 +182,38 @@
|
|||||||
- Ansible Galaxy
|
- Ansible Galaxy
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- name: Assert result changed
|
||||||
that: "result is changed"
|
ansible.builtin.assert:
|
||||||
|
that: result.changed
|
||||||
|
|
||||||
- name: Create a User to become admin of an organization {{ org_name }}
|
- name: Create a User to become admin of an organization
|
||||||
user:
|
awx.awx.user:
|
||||||
username: "{{ username }}-orgadmin"
|
username: "{{ username }}-orgadmin"
|
||||||
password: "{{ username }}-orgadmin"
|
password: "{{ username }}-orgadmin"
|
||||||
state: present
|
state: present
|
||||||
organization: "{{ org_name }}"
|
organization: "{{ org_name }}"
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- name: Assert result changed
|
||||||
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- "result is changed"
|
- result.changed
|
||||||
|
|
||||||
- name: Add the user {{ username }}-orgadmin as an admin of the organization {{ org_name }}
|
- name: Add the user -orgadmin as an admin of the organization
|
||||||
role:
|
awx.awx.role:
|
||||||
user: "{{ username }}-orgadmin"
|
user: "{{ username }}-orgadmin"
|
||||||
role: admin
|
role: admin
|
||||||
organization: "{{ org_name }}"
|
organization: "{{ org_name }}"
|
||||||
state: present
|
state: present
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- name: Assert that user was added as org admin
|
||||||
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- "result is changed"
|
- result.changed | default(false)
|
||||||
|
|
||||||
- name: Create a User as {{ username }}-orgadmin without using an organization (must fail)
|
- name: Create a User as -orgadmin without using an organization (must fail)
|
||||||
user:
|
awx.awx.user:
|
||||||
controller_username: "{{ username }}-orgadmin"
|
controller_username: "{{ username }}-orgadmin"
|
||||||
controller_password: "{{ username }}-orgadmin"
|
controller_password: "{{ username }}-orgadmin"
|
||||||
username: "{{ username }}"
|
username: "{{ username }}"
|
||||||
@@ -227,12 +223,13 @@
|
|||||||
register: result
|
register: result
|
||||||
ignore_errors: true
|
ignore_errors: true
|
||||||
|
|
||||||
- assert:
|
- name: Assert result failed
|
||||||
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- "result is failed"
|
- result.failed
|
||||||
|
|
||||||
- name: Create a User as {{ username }}-orgadmin using an organization
|
- name: Create a User as -orgadmin using an organization
|
||||||
user:
|
awx.awx.user:
|
||||||
controller_username: "{{ username }}-orgadmin"
|
controller_username: "{{ username }}-orgadmin"
|
||||||
controller_password: "{{ username }}-orgadmin"
|
controller_password: "{{ username }}-orgadmin"
|
||||||
username: "{{ username }}"
|
username: "{{ username }}"
|
||||||
@@ -242,12 +239,13 @@
|
|||||||
organization: "{{ org_name }}"
|
organization: "{{ org_name }}"
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- name: Assert result changed
|
||||||
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- "result is changed"
|
- result.changed
|
||||||
|
|
||||||
- name: Change a User as {{ username }}-orgadmin by ID using an organization
|
- name: Change a User as -orgadmin by ID using an organization
|
||||||
user:
|
awx.awx.user:
|
||||||
controller_username: "{{ username }}-orgadmin"
|
controller_username: "{{ username }}-orgadmin"
|
||||||
controller_password: "{{ username }}-orgadmin"
|
controller_password: "{{ username }}-orgadmin"
|
||||||
username: "{{ result.id }}"
|
username: "{{ result.id }}"
|
||||||
@@ -257,12 +255,13 @@
|
|||||||
organization: "{{ org_name }}"
|
organization: "{{ org_name }}"
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- name: Assert result changed
|
||||||
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- "result is changed"
|
- result.changed
|
||||||
|
|
||||||
- name: Check idempotency as {{ username }}-orgadmin using an organization
|
- name: Check idempotency as -orgadmin using an organization
|
||||||
user:
|
awx.awx.user:
|
||||||
controller_username: "{{ username }}-orgadmin"
|
controller_username: "{{ username }}-orgadmin"
|
||||||
controller_password: "{{ username }}-orgadmin"
|
controller_password: "{{ username }}-orgadmin"
|
||||||
username: "{{ username }}"
|
username: "{{ username }}"
|
||||||
@@ -271,12 +270,13 @@
|
|||||||
organization: "{{ org_name }}"
|
organization: "{{ org_name }}"
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- name: Assert result did not change
|
||||||
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- "result is not changed"
|
- not (result.changed)
|
||||||
|
|
||||||
- name: Rename a User as {{ username }}-orgadmin using an organization
|
- name: Rename a User as -orgadmin using an organization
|
||||||
user:
|
awx.awx.user:
|
||||||
controller_username: "{{ username }}-orgadmin"
|
controller_username: "{{ username }}-orgadmin"
|
||||||
controller_password: "{{ username }}-orgadmin"
|
controller_password: "{{ username }}-orgadmin"
|
||||||
username: "{{ username }}"
|
username: "{{ username }}"
|
||||||
@@ -285,12 +285,13 @@
|
|||||||
organization: "{{ org_name }}"
|
organization: "{{ org_name }}"
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- name: Assert result changed
|
||||||
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- "result is changed"
|
- result.changed
|
||||||
|
|
||||||
- name: Delete a User as {{ username }}-orgadmin using an organization
|
- name: Delete a User as -orgadmin using an organization
|
||||||
user:
|
awx.awx.user:
|
||||||
controller_username: "{{ username }}-orgadmin"
|
controller_username: "{{ username }}-orgadmin"
|
||||||
controller_password: "{{ username }}-orgadmin"
|
controller_password: "{{ username }}-orgadmin"
|
||||||
username: "{{ username }}-renamed"
|
username: "{{ username }}-renamed"
|
||||||
@@ -299,11 +300,12 @@
|
|||||||
organization: "{{ org_name }}"
|
organization: "{{ org_name }}"
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- name: Assert result changed
|
||||||
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- "result is changed"
|
- result.changed
|
||||||
|
|
||||||
- name: Remove the user {{ username }}-orgadmin as an admin of the organization {{ org_name }}
|
- name: Remove the user -orgadmin as an admin of the organization
|
||||||
role:
|
role:
|
||||||
user: "{{ username }}-orgadmin"
|
user: "{{ username }}-orgadmin"
|
||||||
role: admin
|
role: admin
|
||||||
@@ -311,21 +313,23 @@
|
|||||||
state: absent
|
state: absent
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- name: Assert result changed
|
||||||
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- "result is changed"
|
- result.changed
|
||||||
|
|
||||||
- name: Delete the User {{ username }}-orgadmin
|
- name: Delete the User -orgadmin
|
||||||
user:
|
awx.awx.user:
|
||||||
username: "{{ username }}-orgadmin"
|
username: "{{ username }}-orgadmin"
|
||||||
password: "{{ username }}-orgadmin"
|
password: "{{ username }}-orgadmin"
|
||||||
state: absent
|
state: absent
|
||||||
organization: "{{ org_name }}"
|
organization: "{{ org_name }}"
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- name: Assert result changed
|
||||||
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- "result is changed"
|
- result.changed
|
||||||
|
|
||||||
- name: Delete the Organization {{ org_name }}
|
- name: Delete the Organization {{ org_name }}
|
||||||
organization:
|
organization:
|
||||||
@@ -333,6 +337,7 @@
|
|||||||
state: absent
|
state: absent
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- name: Assert result changed
|
||||||
that: "result is changed"
|
ansible.builtin.assert:
|
||||||
|
that: result.changed
|
||||||
...
|
...
|
||||||
|
|||||||
@@ -1,18 +1,19 @@
|
|||||||
---
|
---
|
||||||
- name: Generate a random string for names
|
- name: Generate a random string for names
|
||||||
set_fact:
|
ansible.builtin.set_fact:
|
||||||
test_id: "{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
|
test_id: "{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
|
||||||
when: test_id is not defined
|
when: test_id is not defined
|
||||||
|
|
||||||
- name: Generate random names for test objects
|
- name: Generate random names for test objects
|
||||||
set_fact:
|
ansible.builtin.set_fact:
|
||||||
org_name: "{{ test_prefix }}-org-{{ test_id }}"
|
org_name: "{{ test_prefix }}-org-{{ test_id }}"
|
||||||
approval_node_name: "{{ test_prefix }}-node-{{ test_id }}"
|
approval_node_name: "{{ test_prefix }}-node-{{ test_id }}"
|
||||||
wfjt_name: "{{ test_prefix }}-wfjt-{{ test_id }}"
|
wfjt_name: "{{ test_prefix }}-wfjt-{{ test_id }}"
|
||||||
vars:
|
vars:
|
||||||
test_prefix: AWX-Collection-tests-workflow_approval
|
test_prefix: AWX-Collection-tests-workflow_approval
|
||||||
|
|
||||||
- block:
|
- name: Task block
|
||||||
|
block:
|
||||||
- name: Create a new organization for test isolation
|
- name: Create a new organization for test isolation
|
||||||
organization:
|
organization:
|
||||||
name: "{{ org_name }}"
|
name: "{{ org_name }}"
|
||||||
@@ -34,7 +35,7 @@
|
|||||||
- name: Launch the workflow
|
- name: Launch the workflow
|
||||||
workflow_launch:
|
workflow_launch:
|
||||||
workflow_template: "{{ wfjt_name }}"
|
workflow_template: "{{ wfjt_name }}"
|
||||||
wait: False
|
wait: false
|
||||||
register: workflow_job
|
register: workflow_job
|
||||||
|
|
||||||
- name: Wait for approval node to activate and approve
|
- name: Wait for approval node to activate and approve
|
||||||
@@ -46,14 +47,16 @@
|
|||||||
action: approve
|
action: approve
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- name: Assert result changed and did not fail
|
||||||
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- "result is changed"
|
- result.changed
|
||||||
- "result is not failed"
|
- not (result.failed)
|
||||||
|
|
||||||
always:
|
always:
|
||||||
- name: Delete the workflow job template
|
- name: Delete the workflow job template
|
||||||
workflow_job_template:
|
workflow_job_template:
|
||||||
name: "{{ wfjt_name }}"
|
name: "{{ wfjt_name }}"
|
||||||
state: absent
|
state: absent
|
||||||
ignore_errors: True
|
register: delete_result
|
||||||
|
failed_when: delete_result.failed and "'not found' not in delete_result.msg"
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -1,16 +1,17 @@
|
|||||||
---
|
---
|
||||||
- name: Generate a random string for test
|
- name: Generate a random string for test
|
||||||
set_fact:
|
ansible.builtin.set_fact:
|
||||||
test_id: "{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
|
test_id: "{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
|
||||||
when: test_id is not defined
|
when: test_id is not defined
|
||||||
|
|
||||||
- name: Generate names
|
- name: Generate names
|
||||||
set_fact:
|
ansible.builtin.set_fact:
|
||||||
wfjt_name1: "AWX-Collection-tests-workflow_launch--wfjt1-{{ test_id }}"
|
wfjt_name1: "AWX-Collection-tests-workflow_launch--wfjt1-{{ test_id }}"
|
||||||
wfjt_name2: "AWX-Collection-tests-workflow_launch--wfjt1-{{ test_id }}-2"
|
wfjt_name2: "AWX-Collection-tests-workflow_launch--wfjt1-{{ test_id }}-2"
|
||||||
approval_node_name: "AWX-Collection-tests-workflow_launch_approval_node-{{ test_id }}"
|
approval_node_name: "AWX-Collection-tests-workflow_launch_approval_node-{{ test_id }}"
|
||||||
|
|
||||||
- block:
|
- name: Create workflows
|
||||||
|
block:
|
||||||
|
|
||||||
- name: Create our workflow
|
- name: Create our workflow
|
||||||
workflow_job_template:
|
workflow_job_template:
|
||||||
@@ -30,9 +31,10 @@
|
|||||||
ignore_errors: true
|
ignore_errors: true
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- name: Assert that workflow launch failed with expected error
|
||||||
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- result is failed
|
- result.failed | default(false)
|
||||||
- "'Unable to find workflow job template' in result.msg"
|
- "'Unable to find workflow job template' in result.msg"
|
||||||
|
|
||||||
- name: Run the workflow without waiting (this should just give us back a job ID)
|
- name: Run the workflow without waiting (this should just give us back a job ID)
|
||||||
@@ -42,7 +44,8 @@
|
|||||||
ignore_errors: true
|
ignore_errors: true
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- name: Assert result not failed
|
||||||
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- result is not failed
|
- result is not failed
|
||||||
- "'id' in result['job_info']"
|
- "'id' in result['job_info']"
|
||||||
@@ -54,9 +57,10 @@
|
|||||||
ignore_errors: true
|
ignore_errors: true
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- name: Assert result failed
|
||||||
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- result is failed
|
- result.failed | default(false)
|
||||||
- "'Monitoring of Workflow Job - '~ wfjt_name1 ~ ' aborted due to timeout' in result.msg"
|
- "'Monitoring of Workflow Job - '~ wfjt_name1 ~ ' aborted due to timeout' in result.msg"
|
||||||
|
|
||||||
- name: Kick off a workflow and wait for it
|
- name: Kick off a workflow and wait for it
|
||||||
@@ -65,9 +69,10 @@
|
|||||||
ignore_errors: true
|
ignore_errors: true
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- name: Assert result did not fail
|
||||||
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- result is not failed
|
- not (result.failed | default(false))
|
||||||
- "'id' in result['job_info']"
|
- "'id' in result['job_info']"
|
||||||
|
|
||||||
- name: Kick off a workflow with extra_vars but not enabled
|
- name: Kick off a workflow with extra_vars but not enabled
|
||||||
@@ -79,9 +84,10 @@
|
|||||||
ignore_errors: true
|
ignore_errors: true
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- name: Assert result failed
|
||||||
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- result is failed
|
- result.failed | default(false)
|
||||||
- "'The field extra_vars was specified but the workflow job template does not allow for it to be overridden' in result.errors"
|
- "'The field extra_vars was specified but the workflow job template does not allow for it to be overridden' in result.errors"
|
||||||
|
|
||||||
- name: Prompt the workflow's with survey
|
- name: Prompt the workflow's with survey
|
||||||
@@ -126,9 +132,10 @@
|
|||||||
ignore_errors: true
|
ignore_errors: true
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- name: Assert result did not fail
|
||||||
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- result is not failed
|
- not (result.failed | default(false))
|
||||||
|
|
||||||
- name: Prompt the workflow's extra_vars on launch
|
- name: Prompt the workflow's extra_vars on launch
|
||||||
workflow_job_template:
|
workflow_job_template:
|
||||||
@@ -146,9 +153,10 @@
|
|||||||
ignore_errors: true
|
ignore_errors: true
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- name: Assert did not fail
|
||||||
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- result is not failed
|
- not (result.failed | default(false))
|
||||||
|
|
||||||
- name: Test waiting for an approval node that doesn't exit on the last workflow for failure.
|
- name: Test waiting for an approval node that doesn't exit on the last workflow for failure.
|
||||||
workflow_approval:
|
workflow_approval:
|
||||||
@@ -160,9 +168,10 @@
|
|||||||
register: result
|
register: result
|
||||||
ignore_errors: true
|
ignore_errors: true
|
||||||
|
|
||||||
- assert:
|
- name: Assert result failed
|
||||||
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- result is failed
|
- result.failed | default(false)
|
||||||
- "'Monitoring of Workflow Approval - Test workflow approval aborted due to timeout' in result.msg"
|
- "'Monitoring of Workflow Approval - Test workflow approval aborted due to timeout' in result.msg"
|
||||||
|
|
||||||
- name: Create new Workflow
|
- name: Create new Workflow
|
||||||
@@ -208,9 +217,10 @@
|
|||||||
register: result
|
register: result
|
||||||
ignore_errors: true
|
ignore_errors: true
|
||||||
|
|
||||||
- assert:
|
- name: Assert result didn't fail
|
||||||
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- result is failed
|
- result.failed | default(false)
|
||||||
- "'Monitoring of Workflow Node - Demo Job Template aborted due to timeout' in result.msg"
|
- "'Monitoring of Workflow Node - Demo Job Template aborted due to timeout' in result.msg"
|
||||||
|
|
||||||
- name: Wait for approval node to activate and approve
|
- name: Wait for approval node to activate and approve
|
||||||
@@ -222,10 +232,11 @@
|
|||||||
action: deny
|
action: deny
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- name: Assert did not fail
|
||||||
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- result is not failed
|
- not (result.failed | default(false))
|
||||||
- result is changed
|
- result.changed | default(false)
|
||||||
|
|
||||||
- name: Wait for workflow job to finish max 120s
|
- name: Wait for workflow job to finish max 120s
|
||||||
job_wait:
|
job_wait:
|
||||||
|
|||||||
@@ -2,9 +2,9 @@
|
|||||||
- name: Sanity assertions, that some variables have a non-blank value
|
- name: Sanity assertions, that some variables have a non-blank value
|
||||||
assert:
|
assert:
|
||||||
that:
|
that:
|
||||||
- collection_version
|
- collection_version is defined and collection_version | length > 0
|
||||||
- collection_package
|
- collection_package is defined and collection_package | length > 0
|
||||||
- collection_path
|
- collection_path is defined and collection_path | length > 0
|
||||||
|
|
||||||
- name: Set the collection version in the controller_api.py file
|
- name: Set the collection version in the controller_api.py file
|
||||||
replace:
|
replace:
|
||||||
|
|||||||
Reference in New Issue
Block a user