Merge pull request #5 from ansible/devel

Rebase from devel
This commit is contained in:
Sean Sullivan
2020-09-01 14:42:23 -05:00
committed by GitHub
370 changed files with 11094 additions and 5576 deletions

View File

@@ -0,0 +1 @@
skip/python2

View File

@@ -0,0 +1,77 @@
---
- name: Generate a random string for test
set_fact:
test_id: "{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
when: test_id is not defined
- name: Generate names
set_fact:
org_name1: "AWX-Collection-tests-tower_export-organization-{{ test_id }}"
org_name2: "AWX-Collection-tests-tower_export-organization2-{{ test_id }}"
inventory_name1: "AWX-Collection-tests-tower_export-inv1-{{ test_id }}"
- block:
- name: Create some organizations
tower_organization:
name: "{{ item }}"
loop:
- "{{ org_name1 }}"
- "{{ org_name2 }}"
- name: Create an inventory
tower_inventory:
name: "{{ inventory_name1 }}"
organization: "{{ org_name1 }}"
- name: Export all tower assets
tower_export:
all: true
register: all_assets
- assert:
that:
- all_assets is not changed
- all_assets is successful
- all_assets['assets']['organizations'] | length() >= 2
- name: Export all inventories
tower_export:
inventory: 'all'
register: inventory_export
- assert:
that:
- inventory_export is successful
- inventory_export is not changed
- inventory_export['assets']['inventory'] | length() >= 1
- "'organizations' not in inventory_export['assets']"
# This mimics the example in the module
- name: Export an all and a specific
tower_export:
inventory: 'all'
organizations: "{{ org_name1 }}"
register: mixed_export
- assert:
that:
- mixed_export is successful
- mixed_export is not changed
- mixed_export['assets']['inventory'] | length() >= 1
- mixed_export['assets']['organizations'] | length() == 1
- "'workflow_job_templates' not in mixed_export['assets']"
always:
- name: Remove our inventory
tower_inventory:
name: "{{ inventory_name1 }}"
organization: "{{ org_name1 }}"
state: absent
- name: Remove test organizations
tower_organization:
name: "{{ item }}"
state: absent
loop:
- "{{ org_name1 }}"
- "{{ org_name2 }}"

View File

@@ -0,0 +1 @@
skip/python2

View File

@@ -0,0 +1,108 @@
---
- name: Generate a random string for test
set_fact:
test_id: "{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
when: test_id is not defined
- name: Generate names
set_fact:
org_name1: "AWX-Collection-tests-tower_import-organization-{{ test_id }}"
org_name2: "AWX-Collection-tests-tower_import-organization2-{{ test_id }}"
- block:
- name: "Import something"
tower_import:
assets:
organizations:
- name: "{{ org_name1 }}"
description: ""
max_hosts: 0
custom_virtualenv: null
related:
notification_templates: []
notification_templates_started: []
notification_templates_success: []
notification_templates_error: []
notification_templates_approvals: []
natural_key:
name: "Default"
type: "organization"
register: import_output
- assert:
that:
- import_output is changed
- name: "Import something again (awxkit is not idempotent, this tests a failure)"
tower_import:
assets:
organizations:
- name: "{{ org_name1 }}"
description: ""
max_hosts: 0
custom_virtualenv: null
related:
notification_templates: []
notification_templates_started: []
notification_templates_success: []
notification_templates_error: []
notification_templates_approvals: []
natural_key:
name: "Default"
type: "organization"
register: import_output
ignore_errors: true
- assert:
that:
- import_output is failed
- "'Organization with this Name already exists' in import_output.msg"
- name: "Write out a json file"
copy:
content: |
{
"organizations": [
{
"name": "{{ org_name2 }}",
"description": "",
"max_hosts": 0,
"custom_virtualenv": null,
"related": {
"notification_templates": [],
"notification_templates_started": [],
"notification_templates_success": [],
"notification_templates_error": [],
"notification_templates_approvals": []
},
"natural_key": {
"name": "Default",
"type": "organization"
}
}
]
}
dest: ./org.json
- name: "Load assets from a file"
tower_import:
assets: "{{ lookup('file', 'org.json') | from_json() }}"
register: import_output
- assert:
that:
- import_output is changed
always:
- name: Remove organizations
tower_organization:
name: "{{ item }}"
state: absent
loop:
- "{{ org_name1 }}"
- "{{ org_name2 }}"
- name: Delete org.json
file:
path: ./org.json
state: absent

View File

@@ -1,101 +1,140 @@
---
- name: Generate a test ID
set_fact:
test_id: "{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
- name: Generate names
set_fact:
inv_name1: "AWX-Collection-tests-tower_inventory-inv1-{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
inv_name2: "AWX-Collection-tests-tower_inventory-inv2-{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
inv_name1: "AWX-Collection-tests-tower_inventory-inv1-{{ test_id }}"
inv_name2: "AWX-Collection-tests-tower_inventory-inv2-{{ test_id }}"
cred_name1: "AWX-Collection-tests-tower_inventory-cred1-{{ test_id }}"
- name: Create an Inventory
tower_inventory:
name: "{{ inv_name1 }}"
organization: Default
state: present
register: result
- block:
- name: Create an Insights Credential
tower_credential:
name: "{{ cred_name1 }}"
organization: Default
kind: insights
inputs:
username: joe
password: secret
state: present
register: result
- assert:
that:
- "result is changed"
- assert:
that:
- "result is changed"
- name: Test Inventory module idempotency
tower_inventory:
name: "{{ inv_name1 }}"
organization: Default
state: present
register: result
- name: Create an Inventory
tower_inventory:
name: "{{ inv_name1 }}"
organization: Default
insights_credential: "{{ cred_name1 }}"
state: present
register: result
- assert:
that:
- "result is not changed"
- assert:
that:
- "result is changed"
- name: Fail Change Regular to Smart
tower_inventory:
name: "{{ inv_name1 }}"
organization: Default
kind: smart
register: result
ignore_errors: true
- name: Test Inventory module idempotency
tower_inventory:
name: "{{ inv_name1 }}"
organization: Default
insights_credential: "{{ cred_name1 }}"
state: present
register: result
- assert:
that:
- "result is failed"
- assert:
that:
- "result is not changed"
- name: Create a smart inventory
tower_inventory:
name: "{{ inv_name2 }}"
organization: Default
kind: smart
host_filter: name=foo
register: result
- name: Fail Change Regular to Smart
tower_inventory:
name: "{{ inv_name1 }}"
organization: Default
kind: smart
register: result
ignore_errors: true
- assert:
that:
- "result is changed"
- assert:
that:
- "result is failed"
- name: Delete a smart inventory
tower_inventory:
name: "{{ inv_name2 }}"
organization: Default
kind: smart
host_filter: name=foo
state: absent
register: result
- name: Create a smart inventory
tower_inventory:
name: "{{ inv_name2 }}"
organization: Default
kind: smart
host_filter: name=foo
register: result
- assert:
that:
- "result is changed"
- assert:
that:
- "result is changed"
- name: Delete an Inventory
tower_inventory:
name: "{{ inv_name1 }}"
organization: Default
state: absent
register: result
- name: Delete a smart inventory
tower_inventory:
name: "{{ inv_name2 }}"
organization: Default
kind: smart
host_filter: name=foo
state: absent
register: result
- assert:
that:
- "result is changed"
- assert:
that:
- "result is changed"
- name: Delete a Non-Existent Inventory
tower_inventory:
name: "{{ inv_name1 }}"
organization: Default
state: absent
register: result
- name: Delete an Inventory
tower_inventory:
name: "{{ inv_name1 }}"
organization: Default
state: absent
register: result
- assert:
that:
- "result is not changed"
- assert:
that:
- "result is changed"
- name: Check module fails with correct msg
tower_inventory:
name: test-inventory
description: Inventory Description
organization: test-non-existing-org
state: present
register: result
ignore_errors: true
- name: Delete a Non-Existent Inventory
tower_inventory:
name: "{{ inv_name1 }}"
organization: Default
state: absent
register: result
- assert:
that:
- "result is not changed"
- "result.msg =='Failed to update inventory, organization not found: The requested object could not be found.'
or result.msg =='The organizations test-non-existing-org was not found on the Tower server'"
- assert:
that:
- "result is not changed"
- name: Check module fails with correct msg
tower_inventory:
name: test-inventory
description: Inventory Description
organization: test-non-existing-org
state: present
register: result
ignore_errors: true
- assert:
that:
- "result is not changed"
- "result.msg =='Failed to update inventory, organization not found: The requested object could not be found.'
or result.msg =='The organizations test-non-existing-org was not found on the Tower server'"
always:
- name: Delete Inventories
tower_inventory:
name: "{{ item }}"
organization: Default
state: absent
loop:
- "{{ inv_name1 }}"
- "{{ inv_name2 }}"
- name: Delete Insights Credential
tower_credential:
name: "{{ cred_name1 }}"
organization: "Default"
kind: insights
state: absent

View File

@@ -13,7 +13,7 @@
jt2: "AWX-Collection-tests-tower_job_template-jt2-{{ test_id }}"
lab1: "AWX-Collection-tests-tower_job_template-lab1-{{ test_id }}"
email_not: "AWX-Collection-tests-tower_job_template-email-not-{{ test_id }}"
webhook_not: "AWX-Collection-tests-tower_notification-wehbook-not-{{ test_id }}"
webhook_not: "AWX-Collection-tests-tower_notification_template-wehbook-not-{{ test_id }}"
- name: Create a Demo Project
tower_project:
@@ -49,7 +49,7 @@
organization: Default
- name: Add email notification
tower_notification:
tower_notification_template:
name: "{{ email_not }}"
organization: Default
notification_type: email
@@ -65,7 +65,7 @@
state: present
- name: Add webhook notification
tower_notification:
tower_notification_template:
name: "{{ webhook_not }}"
organization: Default
notification_type: webhook
@@ -366,13 +366,13 @@
# You can't delete a label directly so no cleanup needed
- name: Delete email notification
tower_notification:
tower_notification_template:
name: "{{ email_not }}"
organization: Default
state: absent
- name: Delete webhook notification
tower_notification:
tower_notification_template:
name: "{{ webhook_not }}"
organization: Default
state: absent

View File

@@ -1,15 +1,15 @@
---
- name: Generate names
set_fact:
slack_not: "AWX-Collection-tests-tower_notification-slack-not-{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
webhook_not: "AWX-Collection-tests-tower_notification-wehbook-not-{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
email_not: "AWX-Collection-tests-tower_notification-email-not-{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
twillo_not: "AWX-Collection-tests-tower_notification-twillo-not-{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
pd_not: "AWX-Collection-tests-tower_notification-pd-not-{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
irc_not: "AWX-Collection-tests-tower_notification-irc-not-{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
slack_not: "AWX-Collection-tests-tower_notification_template-slack-not-{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
webhook_not: "AWX-Collection-tests-tower_notification_template-wehbook-not-{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
email_not: "AWX-Collection-tests-tower_notification_template-email-not-{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
twillo_not: "AWX-Collection-tests-tower_notification_template-twillo-not-{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
pd_not: "AWX-Collection-tests-tower_notification_template-pd-not-{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
irc_not: "AWX-Collection-tests-tower_notification_template-irc-not-{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
- name: Test deprecation warnings
tower_notification:
- name: Test deprecation warnings with legacy name
tower_notification_template:
name: "{{ slack_not }}"
organization: Default
notification_type: slack
@@ -54,7 +54,7 @@
- result['deprecations'] | length() == 25
- name: Create Slack notification with custom messages
tower_notification:
tower_notification_template:
name: "{{ slack_not }}"
organization: Default
notification_type: slack
@@ -76,7 +76,7 @@
- result is changed
- name: Delete Slack notification
tower_notification:
tower_notification_template:
name: "{{ slack_not }}"
organization: Default
state: absent
@@ -87,7 +87,7 @@
- result is changed
- name: Add webhook notification
tower_notification:
tower_notification_template:
name: "{{ webhook_not }}"
organization: Default
notification_type: webhook
@@ -102,7 +102,7 @@
- result is changed
- name: Delete webhook notification
tower_notification:
tower_notification_template:
name: "{{ webhook_not }}"
organization: Default
state: absent
@@ -113,7 +113,7 @@
- result is changed
- name: Add email notification
tower_notification:
tower_notification_template:
name: "{{ email_not }}"
organization: Default
notification_type: email
@@ -134,7 +134,7 @@
- result is changed
- name: Delete email notification
tower_notification:
tower_notification_template:
name: "{{ email_not }}"
organization: Default
state: absent
@@ -145,7 +145,7 @@
- result is changed
- name: Add twilio notification
tower_notification:
tower_notification_template:
name: "{{ twillo_not }}"
organization: Default
notification_type: twilio
@@ -162,7 +162,7 @@
- result is changed
- name: Delete twilio notification
tower_notification:
tower_notification_template:
name: "{{ twillo_not }}"
organization: Default
state: absent
@@ -173,7 +173,7 @@
- result is changed
- name: Add PagerDuty notification
tower_notification:
tower_notification_template:
name: "{{ pd_not }}"
organization: Default
notification_type: pagerduty
@@ -189,7 +189,7 @@
- result is changed
- name: Delete PagerDuty notification
tower_notification:
tower_notification_template:
name: "{{ pd_not }}"
organization: Default
state: absent
@@ -200,7 +200,7 @@
- result is changed
- name: Add IRC notification
tower_notification:
tower_notification_template:
name: "{{ irc_not }}"
organization: Default
notification_type: irc
@@ -219,7 +219,7 @@
- result is changed
- name: Delete IRC notification
tower_notification:
tower_notification_template:
name: "{{ irc_not }}"
organization: Default
state: absent

View File

@@ -1,74 +1,112 @@
---
- name: Generate a test id
set_fact:
test_id: "{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
- name: Generate names
set_fact:
username: "AWX-Collection-tests-tower_role-user-{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
username: "AWX-Collection-tests-tower_role-user-{{ test_id }}"
project_name: "AWX-Collection-tests-tower_role-project-{{ test_id }}"
- name: Create a User
tower_user:
first_name: Joe
last_name: User
username: "{{ username }}"
password: "{{ 65535 | random | to_uuid }}"
email: joe@example.org
state: present
register: result
- block:
- name: Create a User
tower_user:
first_name: Joe
last_name: User
username: "{{ username }}"
password: "{{ 65535 | random | to_uuid }}"
email: joe@example.org
state: present
register: result
- assert:
that:
- "result is changed"
- assert:
that:
- "result is changed"
- name: Add Joe to the update role of the default Project
tower_role:
user: "{{ username }}"
role: update
project: Demo Project
state: "{{ item }}"
register: result
with_items:
- "present"
- "absent"
- name: Create a project
tower_project:
name: "{{ project_name }}"
organization: Default
scm_type: git
scm_url: https://github.com/ansible/test-playbooks
wait: false
register: project_info
- assert:
that:
- "result is changed"
- assert:
that:
- project_info is changed
- name: Create a workflow
tower_workflow_job_template:
name: test-role-workflow
organization: Default
state: present
- name: Add Joe to the update role of the default Project
tower_role:
user: "{{ username }}"
role: update
project: "Demo Project"
state: "{{ item }}"
register: result
with_items:
- "present"
- "absent"
- name: Add Joe to workflow execute role
tower_role:
user: "{{ username }}"
role: execute
workflow: test-role-workflow
state: present
register: result
- assert:
that:
- "result is changed"
- assert:
that:
- "result is changed"
- name: Add Joe to the new project by ID
tower_role:
user: "{{ username }}"
role: update
project: "{{ project_info['id'] }}"
state: "{{ item }}"
register: result
with_items:
- "present"
- "absent"
- name: Add Joe to workflow execute role, no-op
tower_role:
user: "{{ username }}"
role: execute
workflow: test-role-workflow
state: present
register: result
- assert:
that:
- "result is changed"
- assert:
that:
- "result is not changed"
- name: Create a workflow
tower_workflow_job_template:
name: test-role-workflow
organization: Default
state: present
- name: Delete a User
tower_user:
username: "{{ username }}"
email: joe@example.org
state: absent
register: result
- name: Add Joe to workflow execute role
tower_role:
user: "{{ username }}"
role: execute
workflow: test-role-workflow
state: present
register: result
- assert:
that:
- "result is changed"
- assert:
that:
- "result is changed"
- name: Add Joe to workflow execute role, no-op
tower_role:
user: "{{ username }}"
role: execute
workflow: test-role-workflow
state: present
register: result
- assert:
that:
- "result is not changed"
always:
- name: Delete a User
tower_user:
username: "{{ username }}"
email: joe@example.org
state: absent
register: result
- name: Delete the project
tower_project:
name: "{{ project_name }}"
organization: Default
state: absent
register: result

View File

@@ -11,7 +11,7 @@
jt2_name: "AWX-Collection-tests-tower_workflow_job_template-jt2-{{ test_id }}"
wfjt_name: "AWX-Collection-tests-tower_workflow_job_template-wfjt-{{ test_id }}"
email_not: "AWX-Collection-tests-tower_job_template-email-not-{{ test_id }}"
webhook_not: "AWX-Collection-tests-tower_notification-wehbook-not-{{ test_id }}"
webhook_not: "AWX-Collection-tests-tower_notification_template-wehbook-not-{{ test_id }}"
- name: Create an SCM Credential
tower_credential:
@@ -25,7 +25,7 @@
- "result is changed"
- name: Add email notification
tower_notification:
tower_notification_template:
name: "{{ email_not }}"
organization: Default
notification_type: email
@@ -41,7 +41,7 @@
state: present
- name: Add webhook notification
tower_notification:
tower_notification_template:
name: "{{ webhook_not }}"
organization: Default
notification_type: webhook
@@ -264,13 +264,13 @@
- "result is changed"
- name: Delete email notification
tower_notification:
tower_notification_template:
name: "{{ email_not }}"
organization: Default
state: absent
- name: Delete webhook notification
tower_notification:
tower_notification_template:
name: "{{ webhook_not }}"
organization: Default
state: absent

View File

@@ -53,7 +53,7 @@
- assert:
that:
- result is failed
- "'Monitoring aborted due to timeout' in result.msg"
- "'Monitoring of Workflow Job - {{ wfjt_name1 }} aborted due to timeout' in result.msg"
- name: Kick off a workflow and wait for it
tower_workflow_launch:

View File

@@ -3,4 +3,13 @@ plugins/modules/tower_send.py validate-modules:deprecation-mismatch
plugins/modules/tower_workflow_template.py validate-modules:deprecation-mismatch
plugins/modules/tower_credential.py pylint:wrong-collection-deprecated-version-tag
plugins/modules/tower_job_wait.py pylint:wrong-collection-deprecated-version-tag
plugins/modules/tower_notification.py pylint:wrong-collection-deprecated-version-tag
plugins/modules/tower_notification_template.py pylint:wrong-collection-deprecated-version-tag
plugins/inventory/tower.py pylint:raise-missing-from
plugins/inventory/tower.py pylint:super-with-arguments
plugins/lookup/tower_schedule_rrule.py pylint:raise-missing-from
plugins/module_utils/tower_api.py pylint:super-with-arguments
plugins/module_utils/tower_awxkit.py pylint:super-with-arguments
plugins/module_utils/tower_legacy.py pylint:super-with-arguments
plugins/module_utils/tower_module.py pylint:super-with-arguments
plugins/module_utils/tower_module.py pylint:raise-missing-from
test/awx/conftest.py pylint:raise-missing-from

View File

@@ -4,3 +4,12 @@ plugins/modules/tower_send.py validate-modules:deprecation-mismatch
plugins/modules/tower_send.py validate-modules:invalid-documentation
plugins/modules/tower_workflow_template.py validate-modules:deprecation-mismatch
plugins/modules/tower_workflow_template.py validate-modules:invalid-documentation
plugins/inventory/tower.py pylint:raise-missing-from
plugins/inventory/tower.py pylint:super-with-arguments
plugins/lookup/tower_schedule_rrule.py pylint:raise-missing-from
plugins/module_utils/tower_api.py pylint:super-with-arguments
plugins/module_utils/tower_awxkit.py pylint:super-with-arguments
plugins/module_utils/tower_legacy.py pylint:super-with-arguments
plugins/module_utils/tower_module.py pylint:super-with-arguments
plugins/module_utils/tower_module.py pylint:raise-missing-from
test/awx/conftest.py pylint:raise-missing-from