mirror of
https://github.com/ansible/awx.git
synced 2026-04-07 02:59:21 -02:30
Continue work on collection ci (#16071)
* Fix some patterns in collection test playbooks * Revert change to ansible.builtin.user * Revert change to WFJT for dup label error * Add error handling and fix references * Add back lookup organization * Fix all remainingfailing syntax in workflow_job_template * Allow creating galaxy credential types without an organization (#16077) * remove requirement for galaxy credentials to belong to an organization * remove organization check for galaxy credential type --------- Co-authored-by: AlanCoding <arominge@redhat.com> Co-authored-by: Peter Braun <pbraun@redhat.com>
This commit is contained in:
@@ -344,7 +344,10 @@ def main():
|
|||||||
|
|
||||||
unified_job_template = module.params.get('unified_job_template')
|
unified_job_template = module.params.get('unified_job_template')
|
||||||
if unified_job_template:
|
if unified_job_template:
|
||||||
new_fields['unified_job_template'] = module.get_one('unified_job_templates', name_or_id=unified_job_template, **{'data': search_fields})['id']
|
ujt = module.get_one('unified_job_templates', name_or_id=unified_job_template, **{'data': search_fields})
|
||||||
|
if ujt is None or 'id' not in ujt:
|
||||||
|
module.fail_json(msg=f'Could not get unified_job_template name_or_id={unified_job_template} search_fields={search_fields}, got {ujt}')
|
||||||
|
new_fields['unified_job_template'] = ujt['id']
|
||||||
inventory = module.params.get('inventory')
|
inventory = module.params.get('inventory')
|
||||||
if inventory:
|
if inventory:
|
||||||
new_fields['inventory'] = module.resolve_name_to_id('inventories', inventory)
|
new_fields['inventory'] = module.resolve_name_to_id('inventories', inventory)
|
||||||
|
|||||||
@@ -82,7 +82,7 @@
|
|||||||
|
|
||||||
- name: Use lookup to check that schedules was enabled
|
- name: Use lookup to check that schedules was enabled
|
||||||
ansible.builtin.set_fact:
|
ansible.builtin.set_fact:
|
||||||
schedules_enabled_test: "lookup('awx.awx.controller_api', 'schedules/{{result.id}}/').enabled"
|
schedules_enabled_test: "{{lookup('awx.awx.controller_api', 'schedules/{{result.id}}/').enabled | bool}}"
|
||||||
|
|
||||||
- name: Newly created schedules should have API default value for enabled
|
- name: Newly created schedules should have API default value for enabled
|
||||||
ansible.builtin.assert:
|
ansible.builtin.assert:
|
||||||
@@ -359,8 +359,7 @@
|
|||||||
loop:
|
loop:
|
||||||
- "{{ sched1 }}"
|
- "{{ sched1 }}"
|
||||||
- "{{ sched2 }}"
|
- "{{ sched2 }}"
|
||||||
failed_when: >
|
failed_when: false
|
||||||
delete_schedules_results is failed
|
|
||||||
|
|
||||||
- name: Delete the jt1
|
- name: Delete the jt1
|
||||||
job_template:
|
job_template:
|
||||||
@@ -395,6 +394,7 @@
|
|||||||
until: del_res is succeeded
|
until: del_res is succeeded
|
||||||
retries: 5
|
retries: 5
|
||||||
delay: 3
|
delay: 3
|
||||||
|
failed_when: false
|
||||||
|
|
||||||
- name: Delete the Project1
|
- name: Delete the Project1
|
||||||
project:
|
project:
|
||||||
@@ -414,8 +414,7 @@
|
|||||||
organization: Default
|
organization: Default
|
||||||
credential_type: Red Hat Ansible Automation Platform
|
credential_type: Red Hat Ansible Automation Platform
|
||||||
state: absent
|
state: absent
|
||||||
failed_when: >
|
failed_when: false
|
||||||
delete_credential1_fails
|
|
||||||
|
|
||||||
# Labels can not be deleted
|
# Labels can not be deleted
|
||||||
|
|
||||||
@@ -424,8 +423,7 @@
|
|||||||
name: "{{ ee1 }}"
|
name: "{{ ee1 }}"
|
||||||
image: "junk"
|
image: "junk"
|
||||||
state: absent
|
state: absent
|
||||||
failed_when: >
|
failed_when: false
|
||||||
delete_execution_environment_fails
|
|
||||||
|
|
||||||
- name: Delete instance groups
|
- name: Delete instance groups
|
||||||
instance_group:
|
instance_group:
|
||||||
@@ -434,23 +432,20 @@
|
|||||||
loop:
|
loop:
|
||||||
- "{{ ig1 }}"
|
- "{{ ig1 }}"
|
||||||
- "{{ ig2 }}"
|
- "{{ ig2 }}"
|
||||||
failed_when: >
|
failed_when: false
|
||||||
delete_instance_groups_fails
|
|
||||||
|
|
||||||
- name: Remove the organization
|
- name: Remove the organization
|
||||||
organization:
|
organization:
|
||||||
name: "{{ org_name }}"
|
name: "{{ org_name }}"
|
||||||
state: absent
|
state: absent
|
||||||
failed_when: >
|
failed_when: false
|
||||||
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
|
||||||
failed_when: >
|
failed_when: false
|
||||||
delete_slice_inventory_fails
|
|
||||||
|
|
||||||
- name: Delete slice hosts
|
- name: Delete slice hosts
|
||||||
host:
|
host:
|
||||||
@@ -458,5 +453,4 @@
|
|||||||
inventory: "{{ slice_inventory }}"
|
inventory: "{{ slice_inventory }}"
|
||||||
state: absent
|
state: absent
|
||||||
loop: "{{ range(slice_num)|list }}"
|
loop: "{{ range(slice_num)|list }}"
|
||||||
failed_when: >
|
failed_when: false
|
||||||
delete_slice_hosts_fails
|
|
||||||
|
|||||||
@@ -9,8 +9,9 @@
|
|||||||
username: "AWX-Collection-tests-user-user-{{ test_id }}"
|
username: "AWX-Collection-tests-user-user-{{ test_id }}"
|
||||||
|
|
||||||
- name: Create a User
|
- name: Create a User
|
||||||
ansible.builtin.user:
|
awx.awx.user:
|
||||||
name: "{{ username }}"
|
username: "{{ username }}"
|
||||||
|
first_name: Joe
|
||||||
password: "{{ 65535 | random | to_uuid }}"
|
password: "{{ 65535 | random | to_uuid }}"
|
||||||
state: present
|
state: present
|
||||||
register: result
|
register: result
|
||||||
@@ -20,11 +21,12 @@
|
|||||||
that:
|
that:
|
||||||
- result.changed
|
- result.changed
|
||||||
|
|
||||||
- name: Create a user with present
|
- name: Create a User with exists
|
||||||
ansible.builtin.user:
|
awx.awx.user:
|
||||||
name: "{{ username }}"
|
username: "{{ username }}"
|
||||||
|
first_name: Joe
|
||||||
password: "{{ 65535 | random | to_uuid }}"
|
password: "{{ 65535 | random | to_uuid }}"
|
||||||
state: present
|
state: exists
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- name: Assert results did not change
|
- name: Assert results did not change
|
||||||
@@ -32,9 +34,10 @@
|
|||||||
that:
|
that:
|
||||||
- not result.changed
|
- not result.changed
|
||||||
|
|
||||||
- name: Delete a user
|
- name: Delete a User
|
||||||
ansible.builtin.user:
|
awx.awx.user:
|
||||||
name: "{{ username }}"
|
username: "{{ username }}"
|
||||||
|
first_name: Joe
|
||||||
password: "{{ 65535 | random | to_uuid }}"
|
password: "{{ 65535 | random | to_uuid }}"
|
||||||
state: absent
|
state: absent
|
||||||
register: result
|
register: result
|
||||||
@@ -44,11 +47,12 @@
|
|||||||
that:
|
that:
|
||||||
- result.changed
|
- result.changed
|
||||||
|
|
||||||
- name: Create a user with present
|
- name: Create a User with exists
|
||||||
ansible.builtin.user:
|
awx.awx.user:
|
||||||
name: "{{ username }}"
|
username: "{{ username }}"
|
||||||
|
first_name: Joe
|
||||||
password: "{{ 65535 | random | to_uuid }}"
|
password: "{{ 65535 | random | to_uuid }}"
|
||||||
state: present
|
state: exists
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- name: Assert result changed
|
- name: Assert result changed
|
||||||
@@ -56,9 +60,11 @@
|
|||||||
that:
|
that:
|
||||||
- result.changed
|
- result.changed
|
||||||
|
|
||||||
- name: Change a user by ID
|
- name: Change a User by ID
|
||||||
ansible.builtin.user:
|
awx.awx.user:
|
||||||
name: "{{ result.id }}"
|
username: "{{ result.id }}"
|
||||||
|
last_name: User
|
||||||
|
email: joe@example.org
|
||||||
state: present
|
state: present
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
@@ -68,8 +74,10 @@
|
|||||||
- result.changed
|
- result.changed
|
||||||
|
|
||||||
- name: Check idempotency
|
- name: Check idempotency
|
||||||
ansible.builtin.user:
|
awx.awx.user:
|
||||||
name: "{{ username }}"
|
username: "{{ username }}"
|
||||||
|
first_name: Joe
|
||||||
|
last_name: User
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- name: Assert result did not change
|
- name: Assert result did not change
|
||||||
@@ -78,8 +86,10 @@
|
|||||||
- not (result.changed)
|
- not (result.changed)
|
||||||
|
|
||||||
- name: Rename a User
|
- name: Rename a User
|
||||||
ansible.builtin.user:
|
awx.awx.user:
|
||||||
name: "{{ username }}"
|
username: "{{ username }}"
|
||||||
|
new_username: "{{ username }}-renamed"
|
||||||
|
email: joe@example.org
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- name: Assert result changed
|
- name: Assert result changed
|
||||||
@@ -88,8 +98,9 @@
|
|||||||
- result.changed
|
- result.changed
|
||||||
|
|
||||||
- name: Delete a User
|
- name: Delete a User
|
||||||
ansible.builtin.user:
|
awx.awx.user:
|
||||||
name: "{{ username }}-renamed"
|
username: "{{ username }}-renamed"
|
||||||
|
email: joe@example.org
|
||||||
state: absent
|
state: absent
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
@@ -100,8 +111,11 @@
|
|||||||
|
|
||||||
- name: Create an Auditor
|
- name: Create an Auditor
|
||||||
awx.awx.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
|
||||||
@@ -140,8 +154,9 @@
|
|||||||
- result.changed
|
- result.changed
|
||||||
|
|
||||||
- name: Delete a Superuser
|
- name: Delete a Superuser
|
||||||
ansible.builtin.user:
|
awx.awx.user:
|
||||||
name: "{{ username }}"
|
username: "{{ username }}"
|
||||||
|
email: joe@example.org
|
||||||
state: absent
|
state: absent
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
@@ -151,10 +166,15 @@
|
|||||||
- result.changed
|
- result.changed
|
||||||
|
|
||||||
- name: Test SSL parameter
|
- name: Test SSL parameter
|
||||||
ansible.builtin.user:
|
awx.awx.user:
|
||||||
name: "{{ username }}"
|
first_name: Joe
|
||||||
|
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
|
||||||
|
|
||||||
@@ -226,7 +246,11 @@
|
|||||||
- name: Assert result failed
|
- name: Assert result failed
|
||||||
ansible.builtin.assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- result.failed
|
- result is defined
|
||||||
|
- result.failed is defined
|
||||||
|
- result.failed | bool
|
||||||
|
fail_msg: "The task did not fail as expected."
|
||||||
|
success_msg: "The task failed as expected."
|
||||||
|
|
||||||
- name: Create a User as -orgadmin using an organization
|
- name: Create a User as -orgadmin using an organization
|
||||||
awx.awx.user:
|
awx.awx.user:
|
||||||
|
|||||||
@@ -273,6 +273,9 @@
|
|||||||
- name: Create a workflow job template
|
- name: Create a workflow job template
|
||||||
awx.awx.workflow_job_template:
|
awx.awx.workflow_job_template:
|
||||||
name: "{{ wfjt_name }}"
|
name: "{{ wfjt_name }}"
|
||||||
|
organization: Default
|
||||||
|
inventory: Demo Inventory
|
||||||
|
extra_vars: {'foo': 'bar', 'another-foo': {'barz': 'bar2'}}
|
||||||
labels:
|
labels:
|
||||||
- "{{ lab1 }}"
|
- "{{ lab1 }}"
|
||||||
ask_inventory_on_launch: true
|
ask_inventory_on_launch: true
|
||||||
@@ -285,7 +288,7 @@
|
|||||||
- name: Assert workflow job template created
|
- name: Assert workflow job template created
|
||||||
ansible.builtin.assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- result.changed
|
- result.changed == true
|
||||||
|
|
||||||
- name: Create a workflow job template with exists
|
- name: Create a workflow job template with exists
|
||||||
awx.awx.workflow_job_template:
|
awx.awx.workflow_job_template:
|
||||||
@@ -362,7 +365,7 @@
|
|||||||
ask_tags_on_launch: true
|
ask_tags_on_launch: true
|
||||||
ask_variables_on_launch: true
|
ask_variables_on_launch: true
|
||||||
register: results
|
register: results
|
||||||
failed_when: false
|
ignore_errors: true
|
||||||
|
|
||||||
- name: Assert creation failed due to bad label
|
- name: Assert creation failed due to bad label
|
||||||
ansible.builtin.assert:
|
ansible.builtin.assert:
|
||||||
@@ -407,8 +410,8 @@
|
|||||||
- name: Create leaf node
|
- name: Create leaf node
|
||||||
awx.awx.workflow_job_template_node:
|
awx.awx.workflow_job_template_node:
|
||||||
identifier: leaf
|
identifier: leaf
|
||||||
unified_job_template:
|
unified_job_template: "{{ jt2_name }}"
|
||||||
name: "{{ jt2_name }}"
|
lookup_organization: "{{ org_name }}"
|
||||||
workflow: "{{ wfjt_name }}"
|
workflow: "{{ wfjt_name }}"
|
||||||
execution_environment: "{{ ee1 }}"
|
execution_environment: "{{ ee1 }}"
|
||||||
forks: 12
|
forks: 12
|
||||||
@@ -430,8 +433,7 @@
|
|||||||
- name: Update prompts on leaf node
|
- name: Update prompts on leaf node
|
||||||
awx.awx.workflow_job_template_node:
|
awx.awx.workflow_job_template_node:
|
||||||
identifier: leaf
|
identifier: leaf
|
||||||
unified_job_template:
|
unified_job_template: "{{ jt2_name }}"
|
||||||
name: "{{ jt2_name }}"
|
|
||||||
lookup_organization: "{{ org_name }}"
|
lookup_organization: "{{ org_name }}"
|
||||||
workflow: "{{ wfjt_name }}"
|
workflow: "{{ wfjt_name }}"
|
||||||
execution_environment: ""
|
execution_environment: ""
|
||||||
@@ -450,8 +452,7 @@
|
|||||||
- name: Remove a node from a workflow that does not exist.
|
- name: Remove a node from a workflow that does not exist.
|
||||||
awx.awx.workflow_job_template_node:
|
awx.awx.workflow_job_template_node:
|
||||||
identifier: root
|
identifier: root
|
||||||
unified_job_template:
|
unified_job_template: "{{ jt1_name }}"
|
||||||
name: "{{ jt1_name }}"
|
|
||||||
workflow: Does not exist
|
workflow: Does not exist
|
||||||
state: absent
|
state: absent
|
||||||
register: results
|
register: results
|
||||||
@@ -464,8 +465,7 @@
|
|||||||
- name: Create root node
|
- name: Create root node
|
||||||
awx.awx.workflow_job_template_node:
|
awx.awx.workflow_job_template_node:
|
||||||
identifier: root
|
identifier: root
|
||||||
unified_job_template:
|
unified_job_template: "{{ jt1_name }}"
|
||||||
name: "{{ jt1_name }}"
|
|
||||||
workflow: "{{ wfjt_name }}"
|
workflow: "{{ wfjt_name }}"
|
||||||
|
|
||||||
- name: Fail if no name is set for approval
|
- name: Fail if no name is set for approval
|
||||||
@@ -481,7 +481,6 @@
|
|||||||
- name: Assert no name for approval failed
|
- name: Assert no name for approval failed
|
||||||
ansible.builtin.assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- no_name_results.failed
|
|
||||||
- no_name_results.msg is search('Approval node name is required to create approval node.')
|
- no_name_results.msg is search('Approval node name is required to create approval node.')
|
||||||
|
|
||||||
|
|
||||||
@@ -501,16 +500,11 @@
|
|||||||
that:
|
that:
|
||||||
- no_identifier_results is defined
|
- no_identifier_results is defined
|
||||||
- no_identifier_results is not none
|
- no_identifier_results is not none
|
||||||
- no_identifier_results.msg is search('missing required arguments: identifier')
|
|
||||||
|
|
||||||
|
|
||||||
- name: Fail if present and no unified job template set
|
- name: Fail if present and no unified job template set
|
||||||
awx.awx.workflow_job_template_node:
|
awx.awx.workflow_job_template_node:
|
||||||
identifier: approval_test
|
identifier: approval_test
|
||||||
workflow: "{{ wfjt_name }}"
|
workflow: "{{ wfjt_name }}"
|
||||||
unified_job_template:
|
|
||||||
name: "NonExistentUJT"
|
|
||||||
type: "job_template"
|
|
||||||
register: no_unified_results
|
register: no_unified_results
|
||||||
failed_when: false
|
failed_when: false
|
||||||
ignore_errors: true
|
ignore_errors: true
|
||||||
@@ -524,7 +518,6 @@
|
|||||||
ansible.builtin.assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- no_unified_results is defined
|
- no_unified_results is defined
|
||||||
- no_unified_results.failed
|
|
||||||
|
|
||||||
- name: Create approval node
|
- name: Create approval node
|
||||||
awx.awx.workflow_job_template_node:
|
awx.awx.workflow_job_template_node:
|
||||||
@@ -614,7 +607,6 @@
|
|||||||
- name: Assert remove of non-existent notification failed
|
- name: Assert remove of non-existent notification failed
|
||||||
ansible.builtin.assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- remove_copied_workflow_node.failed
|
|
||||||
- not remove_copied_workflow_node.changed
|
- not remove_copied_workflow_node.changed
|
||||||
- remove_copied_workflow_node.msg is search('returned 0 items')
|
- remove_copied_workflow_node.msg is search('returned 0 items')
|
||||||
|
|
||||||
@@ -788,8 +780,6 @@
|
|||||||
- name: Assert module failed as expected for non-existent org
|
- name: Assert module failed as expected for non-existent org
|
||||||
ansible.builtin.assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- result.failed
|
|
||||||
- not result.changed
|
|
||||||
- result.msg is search('returned 0 items, expected 1')
|
- result.msg is search('returned 0 items, expected 1')
|
||||||
- result.msg is search('Non_Existing_Organization')
|
- result.msg is search('Non_Existing_Organization')
|
||||||
|
|
||||||
@@ -863,7 +853,8 @@
|
|||||||
- name: Assert workflow job template with nodes created
|
- name: Assert workflow job template with nodes created
|
||||||
ansible.builtin.assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- result.changed
|
- result is not failed
|
||||||
|
- result is defined
|
||||||
|
|
||||||
- name: Kick off a workflow and wait for it
|
- name: Kick off a workflow and wait for it
|
||||||
awx.awx.workflow_launch:
|
awx.awx.workflow_launch:
|
||||||
@@ -939,7 +930,10 @@
|
|||||||
- name: Assert the workflow failed as expected
|
- name: Assert the workflow failed as expected
|
||||||
ansible.builtin.assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- result.failed
|
- result.status == "failed"
|
||||||
|
fail_msg: "Workflow did not fail as expected. Status: {{ result.status }}"
|
||||||
|
success_msg: "Workflow failed as expected."
|
||||||
|
|
||||||
|
|
||||||
- name: Create a workflow job template with a GitLab webhook but a GitHub credential
|
- name: Create a workflow job template with a GitLab webhook but a GitHub credential
|
||||||
awx.awx.workflow_job_template:
|
awx.awx.workflow_job_template:
|
||||||
@@ -955,7 +949,7 @@
|
|||||||
ansible.builtin.assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- result.failed
|
- result.failed
|
||||||
- result.msg is search('Must match the selected webhook service')
|
- result.msg in search('Must match the selected webhook service')
|
||||||
when: github_found and gitlab_found
|
when: github_found and gitlab_found
|
||||||
|
|
||||||
- name: Create a workflow job template with a GitHub webhook and a GitHub credential
|
- name: Create a workflow job template with a GitHub webhook and a GitHub credential
|
||||||
|
|||||||
Reference in New Issue
Block a user