update playbooks to use fqcn

Signed-off-by: Adam Miller <admiller@redhat.com>
This commit is contained in:
Adam Miller
2024-03-25 14:33:37 -05:00
committed by Chris Meyers
parent 0b5e59d9cb
commit 2034cca3a9
13 changed files with 132 additions and 132 deletions

View File

@@ -1,63 +1,63 @@
---
- name: Generate a random string for test
set_fact:
ansible.builtin.set_fact:
test_id: "{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
when: test_id is not defined
- name: Generate names
set_fact:
ansible.builtin.set_fact:
inv_name: "AWX-Collection-tests-ad_hoc_command_cancel-inventory-{{ test_id }}"
ssh_cred_name: "AWX-Collection-tests-ad_hoc_command_cancel-ssh-cred-{{ test_id }}"
org_name: "AWX-Collection-tests-ad_hoc_command_cancel-org-{{ test_id }}"
- name: Create a New Organization
organization:
awx.awx.organization:
name: "{{ org_name }}"
- name: Create an Inventory
inventory:
awx.awx.inventory:
name: "{{ inv_name }}"
organization: "{{ org_name }}"
state: present
- name: Add localhost to the Inventory
host:
awx.awx.host:
name: localhost
inventory: "{{ inv_name }}"
variables:
ansible_connection: local
- name: Create a Credential
credential:
awx.awx.credential:
name: "{{ ssh_cred_name }}"
organization: "{{ org_name }}"
credential_type: 'Machine'
state: present
- name: Launch an Ad Hoc Command
ad_hoc_command:
awx.awx.ad_hoc_command:
inventory: "{{ inv_name }}"
credential: "{{ ssh_cred_name }}"
module_name: "command"
module_args: "sleep 100"
register: command
- assert:
- ansible.builtin.assert:
that:
- "command is changed"
- name: Cancel the command
ad_hoc_command_cancel:
awx.awx.ad_hoc_command_cancel:
command_id: "{{ command.id }}"
request_timeout: 60
register: results
- assert:
- ansible.builtin.assert:
that:
- results is changed
- name: "Wait for up to a minute until the job enters the can_cancel: False state"
debug:
ansible.builtin.debug:
msg: "The job can_cancel status has transitioned into False, we can proceed with testing"
until: not job_status
retries: 6
@@ -66,51 +66,51 @@
job_status: "{{ lookup('awx.awx.controller_api', 'ad_hoc_commands/'+ command.id | string +'/cancel')['can_cancel'] }}"
- name: Cancel the command with hard error if it's not running
ad_hoc_command_cancel:
awx.awx.ad_hoc_command_cancel:
command_id: "{{ command.id }}"
fail_if_not_running: true
register: results
ignore_errors: true
- assert:
- ansible.builtin.assert:
that:
- results is failed
- name: Cancel an already canceled command (assert failure)
ad_hoc_command_cancel:
awx.awx.ad_hoc_command_cancel:
command_id: "{{ command.id }}"
fail_if_not_running: true
register: results
ignore_errors: true
- assert:
- ansible.builtin.assert:
that:
- results is failed
- name: Check module fails with correct msg
ad_hoc_command_cancel:
awx.awx.ad_hoc_command_cancel:
command_id: 9999999999
register: result
ignore_errors: true
- assert:
- ansible.builtin.assert:
that:
- "result.msg == 'Unable to find command with id 9999999999'"
- name: Delete the Credential
credential:
awx.awx.credential:
name: "{{ ssh_cred_name }}"
organization: "{{ org_name }}"
credential_type: 'Machine'
state: absent
- name: Delete the Inventory
inventory:
awx.awx.inventory:
name: "{{ inv_name }}"
organization: "{{ org_name }}"
state: absent
- name: Remove the Organization
organization:
awx.awx.organization:
name: "{{ org_name }}"
state: absent

View File

@@ -1,23 +1,23 @@
---
- name: Generate a test ID
set_fact:
ansible.builtin.set_fact:
test_id: "{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
when: test_id is not defined
- name: Generate hostnames
set_fact:
ansible.builtin.set_fact:
hostname1: "AWX-Collection-tests-instance1.{{ test_id }}.example.com"
hostname2: "AWX-Collection-tests-instance2.{{ test_id }}.example.com"
hostname3: "AWX-Collection-tests-instance3.{{ test_id }}.example.com"
register: facts
- name: Get the k8s setting
set_fact:
ansible.builtin.set_fact:
IS_K8S: "{{ controller_settings['IS_K8S'] | default(False) }}"
vars:
controller_settings: "{{ lookup('awx.awx.controller_api', 'settings/all') }}"
- debug:
- ansible.builtin.debug:
msg: "Skipping instance test since this is instance is not running on a K8s platform"
when: not IS_K8S
@@ -32,7 +32,7 @@
- "{{ hostname2 }}"
register: result
- assert:
- ansible.builtin.assert:
that:
- result is changed
@@ -44,7 +44,7 @@
capacity_adjustment: 0.4
register: result
- assert:
- ansible.builtin.assert:
that:
- result is changed
@@ -54,7 +54,7 @@
capacity_adjustment: 0.7
register: result
- assert:
- ansible.builtin.assert:
that:
- result is changed
@@ -78,7 +78,7 @@
node_state: installed
register: result
- assert:
- ansible.builtin.assert:
that:
- result is changed
@@ -89,7 +89,7 @@
node_state: installed
register: result
- assert:
- ansible.builtin.assert:
that:
- result is changed
@@ -103,7 +103,7 @@
- "{{ hostname2 }}"
register: result
- assert:
- ansible.builtin.assert:
that:
- result is changed
@@ -115,7 +115,7 @@
peers: []
register: result
- assert:
- ansible.builtin.assert:
that:
- result is changed

View File

@@ -1,11 +1,11 @@
---
- name: Generate a random string for test
set_fact:
ansible.builtin.set_fact:
test_id: "{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
when: test_id is not defined
- name: Generate usernames
set_fact:
ansible.builtin.set_fact:
usernames:
- "AWX-Collection-tests-api_lookup-user1-{{ test_id }}"
- "AWX-Collection-tests-api_lookup-user2-{{ test_id }}"
@@ -20,7 +20,7 @@
register: controller_meta
- name: Generate the name of our plugin
set_fact:
ansible.builtin.set_fact:
plugin_name: "{{ controller_meta.prefix }}.controller_api"
- name: Create all of our users
@@ -38,7 +38,7 @@
register: results
ignore_errors: true
- assert:
- ansible.builtin.assert:
that:
- "'dne' in (results.msg | lower)"
@@ -49,48 +49,48 @@
loop: "{{ hosts }}"
- name: Test too many params (failure from validation of terms)
set_fact:
ansible.builtin.set_fact:
junk: "{{ query(plugin_name, 'users', 'teams', query_params={}, ) }}"
ignore_errors: true
register: result
- assert:
- ansible.builtin.assert:
that:
- result is failed
- "'You must pass exactly one endpoint to query' in result.msg"
- name: Try to load invalid endpoint
set_fact:
ansible.builtin.set_fact:
junk: "{{ query(plugin_name, 'john', query_params={}, ) }}"
ignore_errors: true
register: result
- assert:
- ansible.builtin.assert:
that:
- result is failed
- "'The requested object could not be found at' in result.msg"
- name: Load user of a specific name without promoting objects
set_fact:
ansible.builtin.set_fact:
users_list: "{{ lookup(plugin_name, 'users', query_params={ 'username' : user_creation_results['results'][0]['item'] }, return_objects=False) }}"
- assert:
- ansible.builtin.assert:
that:
- users_list['results'] | length() == 1
- users_list['count'] == 1
- users_list['results'][0]['id'] == user_creation_results['results'][0]['id']
- name: Load user of a specific name with promoting objects
set_fact:
ansible.builtin.set_fact:
user_objects: "{{ query(plugin_name, 'users', query_params={ 'username' : user_creation_results['results'][0]['item'] }, return_objects=True ) }}"
- assert:
- ansible.builtin.assert:
that:
- user_objects | length() == 1
- users_list['results'][0]['id'] == user_objects[0]['id']
- name: Loop over one user with the loop syntax
assert:
ansible.builtin.assert:
that:
- item['id'] == user_creation_results['results'][0]['id']
loop: "{{ query(plugin_name, 'users', query_params={ 'username' : user_creation_results['results'][0]['item'] } ) }}"
@@ -98,91 +98,91 @@
label: "{{ item.id }}"
- name: Get a page of users as just ids
set_fact:
ansible.builtin.set_fact:
users: "{{ query(plugin_name, 'users', query_params={ 'username__endswith': test_id, 'page_size': 2 }, return_ids=True ) }}"
- debug:
msg: "{{ users }}"
- name: Assert that user list has 2 ids only and that they are strings, not ints
assert:
- name: assert that user list has 2 ids only and that they are strings, not ints
ansible.builtin.assert:
that:
- users | length() == 2
- user_creation_results['results'][0]['id'] not in users
- user_creation_results['results'][0]['id'] | string in users
- name: Get all users of a system through next attribute
set_fact:
ansible.builtin.set_fact:
users: "{{ query(plugin_name, 'users', query_params={ 'username__endswith': test_id, 'page_size': 1 }, return_all=true ) }}"
- assert:
- ansible.builtin.assert:
that:
- users | length() >= 3
- name: Get all of the users created with a max_objects of 1
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 ) }}"
ignore_errors: true
register: max_user_errors
- assert:
- ansible.builtin.assert:
that:
- max_user_errors is failed
- "'List view at users returned 3 objects, which is more than the maximum allowed by max_objects' in max_user_errors.msg"
- name: Get the ID of the first user created and verify that it is correct
assert:
ansible.builtin.assert:
that: "query(plugin_name, 'users', query_params={ 'username' : user_creation_results['results'][0]['item'] }, return_ids=True)[0] == user_creation_results['results'][0]['id'] | string"
- name: Try to get an ID of someone who does not exist
set_fact:
ansible.builtin.set_fact:
failed_user_id: "{{ query(plugin_name, 'users', query_params={ 'username': 'john jacob jingleheimer schmidt' }, expect_one=True) }}"
register: result
ignore_errors: true
- assert:
- ansible.builtin.assert:
that:
- result is failed
- "'Expected one object from endpoint users' in result['msg']"
- name: Lookup too many users
set_fact:
ansible.builtin.set_fact:
too_many_user_ids: " {{ query(plugin_name, 'users', query_params={ 'username__endswith': test_id }, expect_one=True) }}"
register: results
ignore_errors: true
- assert:
- ansible.builtin.assert:
that:
- results is failed
- "'Expected one object from endpoint users, but obtained 3' in results['msg']"
- name: Get the ping page
set_fact:
ansible.builtin.set_fact:
ping_data: "{{ lookup(plugin_name, 'ping' ) }}"
register: results
- assert:
- ansible.builtin.assert:
that:
- results is succeeded
- "'active_node' in ping_data"
- name: "Make sure that expect_objects fails on an API page"
set_fact:
ansible.builtin.set_fact:
my_var: "{{ lookup(plugin_name, 'settings/ui', expect_objects=True) }}"
ignore_errors: true
register: results
- assert:
- ansible.builtin.assert:
that:
- results is failed
- "'Did not obtain a list or detail view at settings/ui, and expect_objects or expect_one is set to True' in results.msg"
# DOCS Example Tests
- name: Load the UI settings
set_fact:
ansible.builtin.set_fact:
controller_settings: "{{ lookup('awx.awx.controller_api', 'settings/ui') }}"
- assert:
- ansible.builtin.assert:
that:
- "'CUSTOM_LOGO' in controller_settings"
@@ -191,7 +191,7 @@
msg: "Admin users: {{ query('awx.awx.controller_api', 'users', query_params={ 'is_superuser': true }) | map(attribute='username') | join(', ') }}"
register: results
- assert:
- ansible.builtin.assert:
that:
- "'admin' in results.msg"
@@ -211,7 +211,7 @@
register: role_revoke
when: "query('awx.awx.controller_api', 'users', query_params={ 'username': 'DNE_TESTING' }) | length == 1"
- assert:
- ansible.builtin.assert:
that:
- role_revoke is skipped
@@ -227,7 +227,7 @@
) | map(attribute='name') | list }}
register: group_creation
- assert:
- ansible.builtin.assert:
that: group_creation is changed
always:

View File

@@ -1,50 +1,50 @@
---
- name: Get our collection package
controller_meta:
awx.awx.controller_meta:
register: controller_meta
- name: Generate the name of our plugin
set_fact:
ansible.builtin.set_fact:
plugin_name: "{{ controller_meta.prefix }}.schedule_rrule"
- name: Test too many params (failure from validation of terms)
debug:
ansible.builtin.debug:
msg: "{{ query(plugin_name | string, 'none', 'weekly', start_date='2020-4-16 03:45:07') }}"
ignore_errors: true
register: result
- assert:
- ansible.builtin.assert:
that:
- result is failed
- "'You may only pass one schedule type in at a time' in result.msg"
- name: Test invalid frequency (failure from validation of term)
debug:
ansible.builtin.debug:
msg: "{{ query(plugin_name, 'john', start_date='2020-4-16 03:45:07') }}"
ignore_errors: true
register: result
- assert:
- ansible.builtin.assert:
that:
- result is failed
- "'Frequency of john is invalid' in result.msg"
- name: Test an invalid start date (generic failure case from get_rrule)
debug:
ansible.builtin.debug:
msg: "{{ query(plugin_name, 'none', start_date='invalid') }}"
ignore_errors: true
register: result
- assert:
- ansible.builtin.assert:
that:
- result is failed
- "'Parameter start_date must be in the format YYYY-MM-DD' in result.msg"
- name: Test end_on as count (generic success case)
debug:
ansible.builtin.debug:
msg: "{{ query(plugin_name, 'minute', start_date='2020-4-16 03:45:07', end_on='2') }}"
register: result
- assert:
- ansible.builtin.assert:
that:
- result.msg == 'DTSTART;TZID=America/New_York:20200416T034507 RRULE:FREQ=MINUTELY;COUNT=2;INTERVAL=1'

View File

@@ -11,7 +11,7 @@
register: result
- name: Changing setting to true should have changed the value
assert:
ansible.builtin.assert:
that:
- "result is changed"
@@ -22,7 +22,7 @@
register: result
- name: Changing setting to true again should not change the value
assert:
ansible.builtin.assert:
that:
- "result is not changed"
@@ -33,17 +33,17 @@
register: result
- name: Changing setting back to false should have changed the value
assert:
ansible.builtin.assert:
that:
- "result is changed"
- name: Set the value of AWX_ISOLATION_SHOW_PATHS to a baseline
settings:
awx.awx.settings:
name: AWX_ISOLATION_SHOW_PATHS
value: '["/var/lib/awx/projects/"]'
- name: Set the value of AWX_ISOLATION_SHOW_PATHS to get an error back from the controller
settings:
awx.awx.settings:
settings:
AWX_ISOLATION_SHOW_PATHS:
'not': 'a valid'
@@ -51,75 +51,75 @@
register: result
ignore_errors: true
- assert:
- ansible.builtin.assert:
that:
- "result is failed"
- name: Set the value of AWX_ISOLATION_SHOW_PATHS
settings:
awx.awx.settings:
name: AWX_ISOLATION_SHOW_PATHS
value: '["/var/lib/awx/projects/", "/tmp"]'
register: result
- assert:
- ansible.builtin.assert:
that:
- "result is changed"
- name: Attempt to set the value of AWX_ISOLATION_BASE_PATH to what it already is
settings:
awx.awx.settings:
name: AWX_ISOLATION_BASE_PATH
value: /tmp
register: result
- debug:
- ansible.builtin.debug:
msg: "{{ result }}"
- assert:
- ansible.builtin.assert:
that:
- "result is not changed"
- name: Apply a single setting via settings
settings:
awx.awx.settings:
name: AWX_ISOLATION_SHOW_PATHS
value: '["/var/lib/awx/projects/", "/var/tmp"]'
register: result
- assert:
- ansible.builtin.assert:
that:
- "result is changed"
- name: Apply multiple setting via settings with no change
settings:
awx.awx.settings:
settings:
AWX_ISOLATION_BASE_PATH: /tmp
AWX_ISOLATION_SHOW_PATHS: ["/var/lib/awx/projects/", "/var/tmp"]
register: result
- debug:
- ansible.builtin.debug:
msg: "{{ result }}"
- assert:
- ansible.builtin.assert:
that:
- "result is not changed"
- name: Apply multiple setting via settings with change
settings:
awx.awx.settings:
settings:
AWX_ISOLATION_BASE_PATH: /tmp
AWX_ISOLATION_SHOW_PATHS: []
register: result
- assert:
- ansible.builtin.assert:
that:
- "result is changed"
- name: Handle an omit value
settings:
awx.awx.settings:
name: AWX_ISOLATION_BASE_PATH
value: '{{ junk_var | default(omit) }}'
register: result
ignore_errors: true
- assert:
- ansible.builtin.assert:
that:
- "'Unable to update settings' in result.msg"

View File

@@ -10,7 +10,7 @@
test: ad_hoc_command,host,role
tasks:
- name: DEBUG - make sure variables are what we expect
debug:
ansible.builtin.debug:
msg: |
Running tests at location:
{{ loc_tests }}
@@ -18,7 +18,7 @@
{{ test | trim | split(',') }}
- name: "Include test targets"
include_tasks: "{{ loc_tests }}{{ test_name }}/tasks/main.yml"
ansible.builtin.include_tasks: "{{ loc_tests }}{{ test_name }}/tasks/main.yml"
loop: "{{ test | trim | split(',') }}"
loop_control:
loop_var: test_name