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:
Lila Yasin 2025-08-20 10:19:53 -04:00 committed by GitHub
parent 461678df08
commit b730bfa193
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 81 additions and 66 deletions

View File

@ -344,7 +344,10 @@ def main():
unified_job_template = module.params.get('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')
if inventory:
new_fields['inventory'] = module.resolve_name_to_id('inventories', inventory)

View File

@ -82,7 +82,7 @@
- name: Use lookup to check that schedules was enabled
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
ansible.builtin.assert:
@ -359,8 +359,7 @@
loop:
- "{{ sched1 }}"
- "{{ sched2 }}"
failed_when: >
delete_schedules_results is failed
failed_when: false
- name: Delete the jt1
job_template:
@ -395,6 +394,7 @@
until: del_res is succeeded
retries: 5
delay: 3
failed_when: false
- name: Delete the Project1
project:
@ -414,8 +414,7 @@
organization: Default
credential_type: Red Hat Ansible Automation Platform
state: absent
failed_when: >
delete_credential1_fails
failed_when: false
# Labels can not be deleted
@ -424,8 +423,7 @@
name: "{{ ee1 }}"
image: "junk"
state: absent
failed_when: >
delete_execution_environment_fails
failed_when: false
- name: Delete instance groups
instance_group:
@ -434,23 +432,20 @@
loop:
- "{{ ig1 }}"
- "{{ ig2 }}"
failed_when: >
delete_instance_groups_fails
failed_when: false
- name: Remove the organization
organization:
name: "{{ org_name }}"
state: absent
failed_when: >
remove_org_fails
failed_when: false
- name: Delete slice inventory
inventory:
name: "{{ slice_inventory }}"
organization: "{{ org_name }}"
state: absent
failed_when: >
delete_slice_inventory_fails
failed_when: false
- name: Delete slice hosts
host:
@ -458,5 +453,4 @@
inventory: "{{ slice_inventory }}"
state: absent
loop: "{{ range(slice_num)|list }}"
failed_when: >
delete_slice_hosts_fails
failed_when: false

View File

@ -9,8 +9,9 @@
username: "AWX-Collection-tests-user-user-{{ test_id }}"
- name: Create a User
ansible.builtin.user:
name: "{{ username }}"
awx.awx.user:
username: "{{ username }}"
first_name: Joe
password: "{{ 65535 | random | to_uuid }}"
state: present
register: result
@ -20,11 +21,12 @@
that:
- result.changed
- name: Create a user with present
ansible.builtin.user:
name: "{{ username }}"
- name: Create a User with exists
awx.awx.user:
username: "{{ username }}"
first_name: Joe
password: "{{ 65535 | random | to_uuid }}"
state: present
state: exists
register: result
- name: Assert results did not change
@ -32,9 +34,10 @@
that:
- not result.changed
- name: Delete a user
ansible.builtin.user:
name: "{{ username }}"
- name: Delete a User
awx.awx.user:
username: "{{ username }}"
first_name: Joe
password: "{{ 65535 | random | to_uuid }}"
state: absent
register: result
@ -44,11 +47,12 @@
that:
- result.changed
- name: Create a user with present
ansible.builtin.user:
name: "{{ username }}"
- name: Create a User with exists
awx.awx.user:
username: "{{ username }}"
first_name: Joe
password: "{{ 65535 | random | to_uuid }}"
state: present
state: exists
register: result
- name: Assert result changed
@ -56,9 +60,11 @@
that:
- result.changed
- name: Change a user by ID
ansible.builtin.user:
name: "{{ result.id }}"
- name: Change a User by ID
awx.awx.user:
username: "{{ result.id }}"
last_name: User
email: joe@example.org
state: present
register: result
@ -68,8 +74,10 @@
- result.changed
- name: Check idempotency
ansible.builtin.user:
name: "{{ username }}"
awx.awx.user:
username: "{{ username }}"
first_name: Joe
last_name: User
register: result
- name: Assert result did not change
@ -78,8 +86,10 @@
- not (result.changed)
- name: Rename a User
ansible.builtin.user:
name: "{{ username }}"
awx.awx.user:
username: "{{ username }}"
new_username: "{{ username }}-renamed"
email: joe@example.org
register: result
- name: Assert result changed
@ -88,8 +98,9 @@
- result.changed
- name: Delete a User
ansible.builtin.user:
name: "{{ username }}-renamed"
awx.awx.user:
username: "{{ username }}-renamed"
email: joe@example.org
state: absent
register: result
@ -100,8 +111,11 @@
- name: Create an Auditor
awx.awx.user:
first_name: Joe
last_name: Auditor
username: "{{ username }}"
password: "{{ 65535 | random | to_uuid }}"
email: joe@example.org
state: present
auditor: true
register: result
@ -140,8 +154,9 @@
- result.changed
- name: Delete a Superuser
ansible.builtin.user:
name: "{{ username }}"
awx.awx.user:
username: "{{ username }}"
email: joe@example.org
state: absent
register: result
@ -151,10 +166,15 @@
- result.changed
- name: Test SSL parameter
ansible.builtin.user:
name: "{{ username }}"
awx.awx.user:
first_name: Joe
last_name: User
username: "{{ username }}"
password: "{{ 65535 | random | to_uuid }}"
email: joe@example.org
state: present
validate_certs: true
controller_host: http://foo.invalid
ignore_errors: true
register: result
@ -226,7 +246,11 @@
- name: Assert result failed
ansible.builtin.assert:
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
awx.awx.user:

View File

@ -273,6 +273,9 @@
- name: Create a workflow job template
awx.awx.workflow_job_template:
name: "{{ wfjt_name }}"
organization: Default
inventory: Demo Inventory
extra_vars: {'foo': 'bar', 'another-foo': {'barz': 'bar2'}}
labels:
- "{{ lab1 }}"
ask_inventory_on_launch: true
@ -285,7 +288,7 @@
- name: Assert workflow job template created
ansible.builtin.assert:
that:
- result.changed
- result.changed == true
- name: Create a workflow job template with exists
awx.awx.workflow_job_template:
@ -362,7 +365,7 @@
ask_tags_on_launch: true
ask_variables_on_launch: true
register: results
failed_when: false
ignore_errors: true
- name: Assert creation failed due to bad label
ansible.builtin.assert:
@ -407,8 +410,8 @@
- name: Create leaf node
awx.awx.workflow_job_template_node:
identifier: leaf
unified_job_template:
name: "{{ jt2_name }}"
unified_job_template: "{{ jt2_name }}"
lookup_organization: "{{ org_name }}"
workflow: "{{ wfjt_name }}"
execution_environment: "{{ ee1 }}"
forks: 12
@ -430,8 +433,7 @@
- name: Update prompts on leaf node
awx.awx.workflow_job_template_node:
identifier: leaf
unified_job_template:
name: "{{ jt2_name }}"
unified_job_template: "{{ jt2_name }}"
lookup_organization: "{{ org_name }}"
workflow: "{{ wfjt_name }}"
execution_environment: ""
@ -450,8 +452,7 @@
- name: Remove a node from a workflow that does not exist.
awx.awx.workflow_job_template_node:
identifier: root
unified_job_template:
name: "{{ jt1_name }}"
unified_job_template: "{{ jt1_name }}"
workflow: Does not exist
state: absent
register: results
@ -464,8 +465,7 @@
- name: Create root node
awx.awx.workflow_job_template_node:
identifier: root
unified_job_template:
name: "{{ jt1_name }}"
unified_job_template: "{{ jt1_name }}"
workflow: "{{ wfjt_name }}"
- name: Fail if no name is set for approval
@ -481,7 +481,6 @@
- name: Assert no name for approval failed
ansible.builtin.assert:
that:
- no_name_results.failed
- no_name_results.msg is search('Approval node name is required to create approval node.')
@ -501,16 +500,11 @@
that:
- no_identifier_results is defined
- 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
awx.awx.workflow_job_template_node:
identifier: approval_test
workflow: "{{ wfjt_name }}"
unified_job_template:
name: "NonExistentUJT"
type: "job_template"
register: no_unified_results
failed_when: false
ignore_errors: true
@ -524,7 +518,6 @@
ansible.builtin.assert:
that:
- no_unified_results is defined
- no_unified_results.failed
- name: Create approval node
awx.awx.workflow_job_template_node:
@ -614,7 +607,6 @@
- name: Assert remove of non-existent notification failed
ansible.builtin.assert:
that:
- remove_copied_workflow_node.failed
- not remove_copied_workflow_node.changed
- remove_copied_workflow_node.msg is search('returned 0 items')
@ -788,8 +780,6 @@
- name: Assert module failed as expected for non-existent org
ansible.builtin.assert:
that:
- result.failed
- not result.changed
- result.msg is search('returned 0 items, expected 1')
- result.msg is search('Non_Existing_Organization')
@ -863,7 +853,8 @@
- name: Assert workflow job template with nodes created
ansible.builtin.assert:
that:
- result.changed
- result is not failed
- result is defined
- name: Kick off a workflow and wait for it
awx.awx.workflow_launch:
@ -939,7 +930,10 @@
- name: Assert the workflow failed as expected
ansible.builtin.assert:
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
awx.awx.workflow_job_template:
@ -955,7 +949,7 @@
ansible.builtin.assert:
that:
- 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
- name: Create a workflow job template with a GitHub webhook and a GitHub credential