Update integration test playbooks to work with most current Collections modules

This commit is contained in:
beeankha
2021-08-17 13:29:33 -04:00
parent c58fef949d
commit c89296e76d
11 changed files with 93 additions and 69 deletions

View File

@@ -51,6 +51,12 @@ options:
description: description:
- The credential type being created. - The credential type being created.
- Can be a built-in credential type such as "Machine", or a custom credential type such as "My Credential Type" - Can be a built-in credential type such as "Machine", or a custom credential type such as "My Credential Type"
- Choices include Amazon Web Services, Ansible Galaxy/Automation Hub API Token, Centrify Vault Credential Provider Lookup,
Container Registry, CyberArk AIM Central Credential Provider Lookup, CyberArk Conjur Secret Lookup, Google Compute Engine,
GitHub Personal Access Token, GitLab Personal Access Token, HashiCorp Vault Secret Lookup, HashiCorp Vault Signed SSH,
Insights, Machine, Microsoft Azure Key Vault, Microsoft Azure Resource Manager, Network, OpenShift or Kubernetes API
Bearer Token, OpenStack, Red Hat Ansible Automation Platform, Red Hat Satellite 6, Red Hat Virtualization, Source Control,
Thycotic DevOps Secrets Vault, Thycotic Secret Server, Vault, VMware vCenter, or a custom credential type
type: str type: str
inputs: inputs:
description: description:

View File

@@ -495,10 +495,10 @@ def main():
if field_val is not None: if field_val is not None:
new_fields[field_name] = field_val new_fields[field_name] = field_val
# Special treatment of extra_vars parameter # Special treatment of extra_vars parameter
extra_vars = module.params.get('extra_vars') extra_vars = module.params.get('extra_vars')
if extra_vars is not None: if extra_vars is not None:
new_fields['extra_vars'] = json.dumps(extra_vars) new_fields['extra_vars'] = json.dumps(extra_vars)
# Attempt to look up the related items the user specified (these will fail the module if not found) # Attempt to look up the related items the user specified (these will fail the module if not found)
inventory = module.params.get('inventory') inventory = module.params.get('inventory')

View File

@@ -58,6 +58,16 @@
- results is failed - results is failed
- "results['msg'] == 'Monitoring of ad hoc command aborted due to timeout'" - "results['msg'] == 'Monitoring of ad hoc command aborted due to timeout'"
- block:
- name: "Wait for up to a minute until the job enters the can_cancel: False state"
debug:
msg: "The job can_cancel status has transitioned into False, we can proveed with testing"
until: not job_status
retries: 6
delay: 10
vars:
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 - name: Cancel the command with hard error if it's not running
ad_hoc_command_cancel: ad_hoc_command_cancel:
command_id: "{{ command.id }}" command_id: "{{ command.id }}"

View File

@@ -26,7 +26,7 @@
credential: credential:
name: "{{ cred_name1 }}" name: "{{ cred_name1 }}"
organization: Default organization: Default
kind: insights credential_type: Insights
inputs: inputs:
username: joe username: joe
password: secret password: secret
@@ -180,5 +180,5 @@
credential: credential:
name: "{{ cred_name1 }}" name: "{{ cred_name1 }}"
organization: "Default" organization: "Default"
kind: insights credential_type: Insights
state: absent state: absent

View File

@@ -9,13 +9,14 @@
credential: credential:
description: Credentials for Openstack Test project description: Credentials for Openstack Test project
name: "{{ openstack_cred }}" name: "{{ openstack_cred }}"
kind: openstack credential_type: OpenStack
organization: Default organization: Default
project: Test inputs:
username: admin project: Test
host: https://example.org:5000 username: admin
password: passw0rd host: https://example.org:5000
domain: test password: passw0rd
domain: test
register: credential_result register: credential_result
- name: Add an inventory - name: Add an inventory
@@ -57,13 +58,14 @@
credential: credential:
description: Credentials for Openstack Test project description: Credentials for Openstack Test project
name: "{{ openstack_cred }}" name: "{{ openstack_cred }}"
kind: openstack credential_type: OpenStack
organization: Default organization: Default
project: Test inputs:
username: admin project: Test
host: https://example.org:5000 username: admin
password: passw0rd host: https://example.org:5000
domain: test password: passw0rd
domain: test
state: absent state: absent
- assert: - assert:

View File

@@ -18,7 +18,7 @@
- name: Wait for a job template to complete - name: Wait for a job template to complete
job_wait: job_wait:
job_id: "{{ result.id }}" job_id: "{{ result.id }}"
max_interval: 10 interval: 10
timeout: 120 timeout: 120
register: result register: result
@@ -173,7 +173,7 @@
- name: Wait for a job template to complete - name: Wait for a job template to complete
job_wait: job_wait:
job_id: "{{ result.id }}" job_id: "{{ result.id }}"
max_interval: 10 interval: 10
timeout: 120 timeout: 120
register: result register: result

View File

@@ -37,20 +37,20 @@
credential: credential:
name: "{{ cred1 }}" name: "{{ cred1 }}"
organization: Default organization: Default
kind: tower credential_type: Red Hat Ansible Automation Platform
register: cred1_result register: cred1_result
- name: Create Credential2 - name: Create Credential2
credential: credential:
name: "{{ cred2 }}" name: "{{ cred2 }}"
organization: Default organization: Default
kind: ssh credential_type: Machine
- name: Create Credential3 - name: Create Credential3
credential: credential:
name: "{{ cred3 }}" name: "{{ cred3 }}"
organization: Default organization: Default
kind: ssh credential_type: Machine
- name: Create Labels - name: Create Labels
label: label:
@@ -75,15 +75,16 @@
name: "{{ email_not }}" name: "{{ email_not }}"
organization: Default organization: Default
notification_type: email notification_type: email
username: user notification_configuration:
password: s3cr3t username: user
sender: tower@example.com password: s3cr3t
recipients: sender: tower@example.com
- user1@example.com recipients:
host: smtp.example.com - user1@example.com
port: 25 host: smtp.example.com
use_tls: false port: 25
use_ssl: false use_tls: false
use_ssl: false
state: present state: present
- name: Add webhook notification - name: Add webhook notification
@@ -91,9 +92,10 @@
name: "{{ webhook_not }}" name: "{{ webhook_not }}"
organization: Default organization: Default
notification_type: webhook notification_type: webhook
url: http://www.example.com/hook notification_configuration:
headers: url: http://www.example.com/hook
X-Custom-Header: value123 headers:
X-Custom-Header: value123
state: present state: present
register: result register: result
@@ -386,21 +388,21 @@
credential: credential:
name: "{{ cred1 }}" name: "{{ cred1 }}"
organization: Default organization: Default
kind: tower credential_type: Red Hat Ansible Automation Platform
state: absent state: absent
- name: Delete Credential2 - name: Delete Credential2
credential: credential:
name: "{{ cred2 }}" name: "{{ cred2 }}"
organization: Default organization: Default
kind: ssh credential_type: Machine
state: absent state: absent
- name: Delete Credential3 - name: Delete Credential3
credential: credential:
name: "{{ cred3 }}" name: "{{ cred3 }}"
organization: Default organization: Default
kind: ssh credential_type: Machine
state: absent state: absent
# You can't delete a label directly so no cleanup needed # You can't delete a label directly so no cleanup needed

View File

@@ -14,7 +14,7 @@
credential: credential:
name: "{{ scm_cred_name }}" name: "{{ scm_cred_name }}"
organization: Default organization: Default
kind: scm credential_type: Source Control
register: result register: result
- assert: - assert:
@@ -59,7 +59,7 @@
- name: Create credential - name: Create credential
credential: credential:
kind: scm credential_type: Source Control
name: "{{ cred_name }}" name: "{{ cred_name }}"
organization: "{{ org_name }}" organization: "{{ org_name }}"
register: result register: result
@@ -207,7 +207,7 @@
credential: credential:
name: "{{ scm_cred_name }}" name: "{{ scm_cred_name }}"
organization: Default organization: Default
kind: scm credential_type: Source Control
state: absent state: absent
register: result register: result
@@ -228,7 +228,7 @@
- name: Delete credential - name: Delete credential
credential: credential:
kind: scm credential_type: Source Control
name: "{{ cred_name }}" name: "{{ cred_name }}"
organization: "{{ org_name }}" organization: "{{ org_name }}"
state: absent state: absent

View File

@@ -15,16 +15,17 @@
variables: variables:
ansible_connection: local ansible_connection: local
- name: create an unused SSH / Machine credential - name: Create an unused SSH / Machine credential
credential: credential:
name: dummy name: dummy
kind: ssh credential_type: Machine
ssh_key_data: | inputs:
-----BEGIN EC PRIVATE KEY----- ssh_key_data: |
MHcCAQEEIIUl6R1xgzR6siIUArz4XBPtGZ09aetma2eWf1v3uYymoAoGCCqGSM49 -----BEGIN EC PRIVATE KEY-----
AwEHoUQDQgAENJNjgeZDAh/+BY860s0yqrLDprXJflY0GvHIr7lX3ieCtrzOMCVU MHcCAQEEIIUl6R1xgzR6siIUArz4XBPtGZ09aetma2eWf1v3uYymoAoGCCqGSM49
QWzw35pc5tvuP34SSi0ZE1E+7cVMDDOF3w== AwEHoUQDQgAENJNjgeZDAh/+BY860s0yqrLDprXJflY0GvHIr7lX3ieCtrzOMCVU
-----END EC PRIVATE KEY----- QWzw35pc5tvuP34SSi0ZE1E+7cVMDDOF3w==
-----END EC PRIVATE KEY-----
organization: Default organization: Default
- block: - block:
@@ -51,5 +52,5 @@
- name: Delete dummy credential - name: Delete dummy credential
credential: credential:
name: dummy name: dummy
kind: ssh credential_type: Machine
state: absent state: absent

View File

@@ -1,16 +1,17 @@
--- ---
- name: generate random string for project - name: Generate random string for project
set_fact: set_fact:
rand_string: "{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}" rand_string: "{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
- name: Generate manual project dir name
- name: Generate manual project name
set_fact: set_fact:
project_name: "manual project {{ rand_string }}" project_name: "Manual_Project_{{ rand_string }}"
- name: Generate manual project dir name - name: Generate manual project dir name
set_fact: set_fact:
project_dir_name: "proj_{{ rand_string }}" project_dir_name: "proj_{{ rand_string }}"
- name: create a project directory for manual project - name: Create a project directory for manual project
import_tasks: create_project_dir.yml import_tasks: create_project_dir.yml
- name: Create a manual project - name: Create a manual project

View File

@@ -29,7 +29,7 @@
credential: credential:
name: "{{ scm_cred_name }}" name: "{{ scm_cred_name }}"
organization: Default organization: Default
kind: scm credential_type: Source Control
register: result register: result
- assert: - assert:
@@ -41,15 +41,16 @@
name: "{{ email_not }}" name: "{{ email_not }}"
organization: Default organization: Default
notification_type: email notification_type: email
username: user notification_configuration:
password: s3cr3t username: user
sender: tower@example.com password: s3cr3t
recipients: sender: tower@example.com
- user1@example.com recipients:
host: smtp.example.com - user1@example.com
port: 25 host: smtp.example.com
use_tls: false port: 25
use_ssl: false use_tls: false
use_ssl: false
state: present state: present
- name: Add webhook notification - name: Add webhook notification
@@ -57,9 +58,10 @@
name: "{{ webhook_not }}" name: "{{ webhook_not }}"
organization: Default organization: Default
notification_type: webhook notification_type: webhook
url: http://www.example.com/hook notification_configuration:
headers: url: http://www.example.com/hook
X-Custom-Header: value123 headers:
X-Custom-Header: value123
state: present state: present
register: result register: result
@@ -664,7 +666,7 @@
credential: credential:
name: "{{ scm_cred_name }}" name: "{{ scm_cred_name }}"
organization: Default organization: Default
kind: scm credential_type: Source Control
state: absent state: absent
register: result register: result