Merge pull request #10903 from beeankha/misc_collections_updates

Fix Test Playbooks, Update README, Make Module Docs More Informative
This commit is contained in:
Bianca Henderson
2021-08-18 12:41:38 -04:00
committed by GitHub
13 changed files with 121 additions and 89 deletions

View File

@@ -15,7 +15,7 @@
This Ansible collection allows for easy interaction with an AWX server via Ansible playbooks. This Ansible collection allows for easy interaction with an AWX server via Ansible playbooks.
This source for this collection lives in the `awx_collection` folder inside of the This source for this collection lives in the `awx_collection` folder inside of the
AWX source. AWX GitHub repository.
The previous home for this collection was inside the folder [lib/ansible/modules/web_infrastructure/ansible_tower](https://github.com/ansible/ansible/tree/stable-2.9/lib/ansible/modules/web_infrastructure/ansible_tower) in the Ansible repo, The previous home for this collection was inside the folder [lib/ansible/modules/web_infrastructure/ansible_tower](https://github.com/ansible/ansible/tree/stable-2.9/lib/ansible/modules/web_infrastructure/ansible_tower) in the Ansible repo,
as well as other places for the inventory plugin, module utils, and as well as other places for the inventory plugin, module utils, and
doc fragment. doc fragment.
@@ -72,7 +72,11 @@ Notable releases of the `awx.awx` collection:
The following notes are changes that may require changes to playbooks: The following notes are changes that may require changes to playbooks:
- The module tower_notification was renamed tower_notification_template. In ansible >= 2.10 there is a seamless redirect. Ansible 2.9 does not respect the redirect. - The `credential` module no longer allows `kind` as a parameter; additionally, `inputs` must now be used with a variety of key/value parameters to go with it (e.g., `become_method`)
- The `job_wait` module no longer allows `min_interval`/ `max_interval` parameters; use `interval` instead
- The `notification_template` requires various notification configuration information to be listed as a dictionary under the `notification_configuration` parameter (e.g., `use_ssl`)
- In the `inventory_source` module, the `source_project` (when provided) lookup defaults to the specified organization in the same way the inventory is looked up
- The module `tower_notification` was renamed `tower_notification_template`. In `ansible >= 2.10` there is a seamless redirect. Ansible 2.9 does not respect the redirect.
- When a project is created, it will wait for the update/sync to finish by default; this can be turned off with the `wait` parameter, if desired. - When a project is created, it will wait for the update/sync to finish by default; this can be turned off with the `wait` parameter, if desired.
- Creating a "scan" type job template is no longer supported. - Creating a "scan" type job template is no longer supported.
- Specifying a custom certificate via the `TOWER_CERTIFICATE` environment variable no longer works. - Specifying a custom certificate via the `TOWER_CERTIFICATE` environment variable no longer works.
@@ -94,16 +98,16 @@ The following notes are changes that may require changes to playbooks:
- Some return values (e.g., `credential_type`) have been removed. Use of `id` is recommended. - Some return values (e.g., `credential_type`) have been removed. Use of `id` is recommended.
- `tower_job_template` no longer supports the deprecated `extra_vars_path` parameter, please use `extra_vars` with the lookup plugin to replace this functionality. - `tower_job_template` no longer supports the deprecated `extra_vars_path` parameter, please use `extra_vars` with the lookup plugin to replace this functionality.
- The `notification_configuration` parameter of `tower_notification_template` has changed from a string to a dict. Please use the `lookup` plugin to read an existing file into a dict. - The `notification_configuration` parameter of `tower_notification_template` has changed from a string to a dict. Please use the `lookup` plugin to read an existing file into a dict.
- `tower_credential` no longer supports passing a file name to ssh_key_data. - `tower_credential` no longer supports passing a file name to `ssh_key_data`.
- The HipChat `notification_type` has been removed and can no longer be created using the `tower_notification_template` module. - The HipChat `notification_type` has been removed and can no longer be created using the `tower_notification_template` module.
## Running Unit Tests ## Running Unit Tests
Tests to verify compatibility with the most recent AWX code are in `awx_collection/test/awx`. Tests to verify compatibility with the most recent AWX code are in `awx_collection/test/awx`.
These can be ran by `make test_collection` in the development container. These can be ran via the `make test_collection` command in the development container.
To run outside of the development container, or to run against To run tests outside of the development container, or to run against
Ansible source, set up a working environment: Ansible source, set up a dedicated virtual environment:
``` ```
mkvirtualenv my_new_venv mkvirtualenv my_new_venv
@@ -118,11 +122,11 @@ py.test awx_collection/test/awx/
## Running Integration Tests ## Running Integration Tests
The integration tests require a virtualenv with `ansible` >= 2.9 and `awxkit`. The integration tests require a virtualenv with `ansible >= 2.9` and `awxkit`.
The collection must first be installed, which can be done using `make install_collection`. The collection must first be installed, which can be done using `make install_collection`.
You also need a configuration file, as described in the running section. You also need a configuration file, as described in the [Running](https://github.com/ansible/awx/blob/devel/awx_collection/README.md#running) section.
Run the tests: How to run the tests:
``` ```
# ansible-test must be run from the directory in which the collection is installed # ansible-test must be run from the directory in which the collection is installed
@@ -133,5 +137,5 @@ ansible-test integration
## Licensing ## Licensing
All content in this folder is licensed under the same license as Ansible, All content in this folder is licensed under the same license as Ansible,
which is the same as license that applied before the split into an which is the same as the license that applied before the split into an
independent collection. independent collection.

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 proceed 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

View File

@@ -15,7 +15,7 @@
This Ansible collection allows for easy interaction with an {% if collection_package | lower() == 'awx' %}AWX{% else %}Red Hat Ansible Automation Platform{% endif %} server via Ansible playbooks. This Ansible collection allows for easy interaction with an {% if collection_package | lower() == 'awx' %}AWX{% else %}Red Hat Ansible Automation Platform{% endif %} server via Ansible playbooks.
This source for this collection lives in the `awx_collection` folder inside of the This source for this collection lives in the `awx_collection` folder inside of the
AWX source. AWX GitHub repository.
The previous home for this collection was inside the folder [lib/ansible/modules/web_infrastructure/ansible_tower](https://github.com/ansible/ansible/tree/stable-2.9/lib/ansible/modules/web_infrastructure/ansible_tower) in the Ansible repo, The previous home for this collection was inside the folder [lib/ansible/modules/web_infrastructure/ansible_tower](https://github.com/ansible/ansible/tree/stable-2.9/lib/ansible/modules/web_infrastructure/ansible_tower) in the Ansible repo,
as well as other places for the inventory plugin, module utils, and as well as other places for the inventory plugin, module utils, and
doc fragment. doc fragment.
@@ -83,7 +83,11 @@ Notable releases of the `{{ collection_namespace }}.{{ collection_package }}` co
The following notes are changes that may require changes to playbooks: The following notes are changes that may require changes to playbooks:
- The module tower_notification was renamed tower_notification_template. In ansible >= 2.10 there is a seamless redirect. Ansible 2.9 does not respect the redirect. - The `credential` module no longer allows `kind` as a parameter; additionally, `inputs` must now be used with a variety of key/value parameters to go with it (e.g., `become_method`)
- The `job_wait` module no longer allows `min_interval`/ `max_interval` parameters; use `interval` instead
- The `notification_template` requires various notification configuration information to be listed as a dictionary under the `notification_configuration` parameter (e.g., `use_ssl`)
- In the `inventory_source` module, the `source_project` (when provided) lookup defaults to the specified organization in the same way the inventory is looked up
- The module `tower_notification` was renamed `tower_notification_template`. In `ansible >= 2.10` there is a seamless redirect. Ansible 2.9 does not respect the redirect.
- When a project is created, it will wait for the update/sync to finish by default; this can be turned off with the `wait` parameter, if desired. - When a project is created, it will wait for the update/sync to finish by default; this can be turned off with the `wait` parameter, if desired.
- Creating a "scan" type job template is no longer supported. - Creating a "scan" type job template is no longer supported.
- Specifying a custom certificate via the `TOWER_CERTIFICATE` environment variable no longer works. - Specifying a custom certificate via the `TOWER_CERTIFICATE` environment variable no longer works.
@@ -105,17 +109,17 @@ The following notes are changes that may require changes to playbooks:
- Some return values (e.g., `credential_type`) have been removed. Use of `id` is recommended. - Some return values (e.g., `credential_type`) have been removed. Use of `id` is recommended.
- `tower_job_template` no longer supports the deprecated `extra_vars_path` parameter, please use `extra_vars` with the lookup plugin to replace this functionality. - `tower_job_template` no longer supports the deprecated `extra_vars_path` parameter, please use `extra_vars` with the lookup plugin to replace this functionality.
- The `notification_configuration` parameter of `tower_notification_template` has changed from a string to a dict. Please use the `lookup` plugin to read an existing file into a dict. - The `notification_configuration` parameter of `tower_notification_template` has changed from a string to a dict. Please use the `lookup` plugin to read an existing file into a dict.
- `tower_credential` no longer supports passing a file name to ssh_key_data. - `tower_credential` no longer supports passing a file name to `ssh_key_data`.
- The HipChat `notification_type` has been removed and can no longer be created using the `tower_notification_template` module. - The HipChat `notification_type` has been removed and can no longer be created using the `tower_notification_template` module.
{% if collection_package | lower() == "awx" %} {% if collection_package | lower() == "awx" %}
## Running Unit Tests ## Running Unit Tests
Tests to verify compatibility with the most recent AWX code are in `awx_collection/test/awx`. Tests to verify compatibility with the most recent AWX code are in `awx_collection/test/awx`.
These can be ran by `make test_collection` in the development container. These can be ran via the `make test_collection` command in the development container.
To run outside of the development container, or to run against To run tests outside of the development container, or to run against
Ansible source, set up a working environment: Ansible source, set up a dedicated virtual environment:
``` ```
mkvirtualenv my_new_venv mkvirtualenv my_new_venv
@@ -130,11 +134,11 @@ py.test awx_collection/test/awx/
## Running Integration Tests ## Running Integration Tests
The integration tests require a virtualenv with `ansible` >= 2.9 and `awxkit`. The integration tests require a virtualenv with `ansible >= 2.9` and `awxkit`.
The collection must first be installed, which can be done using `make install_collection`. The collection must first be installed, which can be done using `make install_collection`.
You also need a configuration file, as described in the running section. You also need a configuration file, as described in the [Running](https://github.com/ansible/awx/blob/devel/awx_collection/README.md#running) section.
Run the tests: How to run the tests:
``` ```
# ansible-test must be run from the directory in which the collection is installed # ansible-test must be run from the directory in which the collection is installed
@@ -146,5 +150,5 @@ ansible-test integration
## Licensing ## Licensing
All content in this folder is licensed under the same license as Ansible, All content in this folder is licensed under the same license as Ansible,
which is the same as license that applied before the split into an which is the same as the license that applied before the split into an
independent collection. independent collection.