mirror of https://github.com/ansible/ansible.git
add some Tower module integration tests (and fix a bug or two) (#37421)
* add additional test coverage for tower modules * add test coverage for the tower_credential module * add test coverage for the tower_user module * fix a bug in py3 for tower_credential when ssh_key_data is specified * add test coverage for tower_host, tower_label, and tower_project * add test coverage for tower_inventory and tower_job_template * add more test coverage for tower modules - tower_job_launch - tower_job_list - tower_job_wait - tower_job_cancel * add a check mode/version assertion for tower module integration tests * add test coverage for the tower_role module * add test coverage for the tower_group module * add more integration test edge cases for various tower modules * give the job_wait module more time before failing * randomize passwords in the tower_user and tower_group testspull/32221/merge
parent
594840c1d6
commit
872a7b4a7a
@ -0,0 +1,2 @@
|
|||||||
|
cloud/tower
|
||||||
|
posix/ci/cloud/group4/tower
|
@ -0,0 +1,510 @@
|
|||||||
|
- name: create a tempdir for an SSH key
|
||||||
|
local_action: shell mktemp -d
|
||||||
|
register: tempdir
|
||||||
|
|
||||||
|
- name: Generate a local SSH key
|
||||||
|
local_action: "shell ssh-keygen -b 2048 -t rsa -f {{ tempdir.stdout }}/id_rsa -q -N 'passphrase'"
|
||||||
|
|
||||||
|
- name: Create a User-specific credential
|
||||||
|
tower_credential:
|
||||||
|
name: SSH Credential
|
||||||
|
organization: Default
|
||||||
|
user: admin
|
||||||
|
state: present
|
||||||
|
kind: ssh
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "result is changed"
|
||||||
|
|
||||||
|
- name: Delete a User-specific credential
|
||||||
|
tower_credential:
|
||||||
|
name: SSH Credential
|
||||||
|
organization: Default
|
||||||
|
user: admin
|
||||||
|
state: absent
|
||||||
|
kind: ssh
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "result is changed"
|
||||||
|
|
||||||
|
- name: Create a valid SSH credential
|
||||||
|
tower_credential:
|
||||||
|
name: SSH Credential
|
||||||
|
organization: Default
|
||||||
|
state: present
|
||||||
|
kind: ssh
|
||||||
|
description: An example SSH credential
|
||||||
|
username: joe
|
||||||
|
password: secret
|
||||||
|
become_method: sudo
|
||||||
|
become_username: superuser
|
||||||
|
become_password: supersecret
|
||||||
|
ssh_key_data: "{{ tempdir.stdout }}/id_rsa"
|
||||||
|
ssh_key_unlock: "passphrase"
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "result is changed"
|
||||||
|
|
||||||
|
- name: Create an invalid SSH credential (passphrase required)
|
||||||
|
tower_credential:
|
||||||
|
name: SSH Credential
|
||||||
|
organization: Default
|
||||||
|
state: present
|
||||||
|
kind: ssh
|
||||||
|
username: joe
|
||||||
|
ssh_key_data: "{{ tempdir.stdout }}/id_rsa"
|
||||||
|
ignore_errors: yes
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "result is failed"
|
||||||
|
- "'must be set when SSH key is encrypted' in result.module_stderr"
|
||||||
|
|
||||||
|
- name: Create an invalid SSH credential (ssh_key_data file is missing)
|
||||||
|
tower_credential:
|
||||||
|
name: SSH Credential
|
||||||
|
organization: Default
|
||||||
|
state: present
|
||||||
|
kind: ssh
|
||||||
|
username: joe
|
||||||
|
ssh_key_data: "{{ tempdir.stdout }}/not_a_valid_file"
|
||||||
|
ignore_errors: yes
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "result is failed"
|
||||||
|
- "'file not found' in result.msg"
|
||||||
|
|
||||||
|
- name: Create an invalid SSH credential (ssh_key_data is a directory)
|
||||||
|
tower_credential:
|
||||||
|
name: SSH Credential
|
||||||
|
organization: Default
|
||||||
|
state: present
|
||||||
|
kind: ssh
|
||||||
|
username: joe
|
||||||
|
ssh_key_data: "{{ tempdir.stdout }}"
|
||||||
|
ignore_errors: yes
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "result is failed"
|
||||||
|
- "'attempted to read contents of directory' in result.msg"
|
||||||
|
|
||||||
|
- name: Create an invalid SSH credential (Organization not found)
|
||||||
|
tower_credential:
|
||||||
|
name: SSH Credential
|
||||||
|
organization: Missing Organization
|
||||||
|
state: present
|
||||||
|
kind: ssh
|
||||||
|
username: joe
|
||||||
|
ignore_errors: yes
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "result is failed"
|
||||||
|
- "'The requested object could not be found' in result.module_stderr"
|
||||||
|
|
||||||
|
- name: Delete an SSH credential
|
||||||
|
tower_credential:
|
||||||
|
name: SSH Credential
|
||||||
|
organization: Default
|
||||||
|
state: absent
|
||||||
|
kind: ssh
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "result is changed"
|
||||||
|
|
||||||
|
- name: Create a valid Vault credential
|
||||||
|
tower_credential:
|
||||||
|
name: Vault Credential
|
||||||
|
organization: Default
|
||||||
|
state: present
|
||||||
|
kind: vault
|
||||||
|
description: An example Vault credential
|
||||||
|
vault_password: secret-vault
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "result is changed"
|
||||||
|
|
||||||
|
- name: Create a valid Vault credential w/ kind=ssh (deprecated)
|
||||||
|
tower_credential:
|
||||||
|
name: Vault Credential
|
||||||
|
organization: Default
|
||||||
|
state: present
|
||||||
|
kind: ssh
|
||||||
|
description: An example Vault credential
|
||||||
|
vault_password: secret-vault
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "result is changed"
|
||||||
|
|
||||||
|
- name: Delete a Vault credential
|
||||||
|
tower_credential:
|
||||||
|
name: Vault Credential
|
||||||
|
organization: Default
|
||||||
|
state: absent
|
||||||
|
kind: vault
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "result is changed"
|
||||||
|
|
||||||
|
- name: Create a valid Network credential
|
||||||
|
tower_credential:
|
||||||
|
name: Network Credential
|
||||||
|
organization: Default
|
||||||
|
state: present
|
||||||
|
kind: net
|
||||||
|
username: joe
|
||||||
|
password: secret
|
||||||
|
authorize: true
|
||||||
|
authorize_password: authorize-me
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "result is changed"
|
||||||
|
|
||||||
|
- name: Delete a Network credential
|
||||||
|
tower_credential:
|
||||||
|
name: Network Credential
|
||||||
|
organization: Default
|
||||||
|
state: absent
|
||||||
|
kind: net
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "result is changed"
|
||||||
|
|
||||||
|
- name: Create a valid SCM credential
|
||||||
|
tower_credential:
|
||||||
|
name: SCM Credential
|
||||||
|
organization: Default
|
||||||
|
state: present
|
||||||
|
kind: scm
|
||||||
|
username: joe
|
||||||
|
password: secret
|
||||||
|
ssh_key_data: "{{ tempdir.stdout }}/id_rsa"
|
||||||
|
ssh_key_unlock: "passphrase"
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "result is changed"
|
||||||
|
|
||||||
|
- name: Delete an SCM credential
|
||||||
|
tower_credential:
|
||||||
|
name: SCM Credential
|
||||||
|
organization: Default
|
||||||
|
state: absent
|
||||||
|
kind: scm
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "result is changed"
|
||||||
|
|
||||||
|
- name: Create a valid AWS credential
|
||||||
|
tower_credential:
|
||||||
|
name: AWS Credential
|
||||||
|
organization: Default
|
||||||
|
state: present
|
||||||
|
kind: aws
|
||||||
|
username: joe
|
||||||
|
password: secret
|
||||||
|
security_token: aws-token
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "result is changed"
|
||||||
|
|
||||||
|
- name: Delete an AWS credential
|
||||||
|
tower_credential:
|
||||||
|
name: AWS Credential
|
||||||
|
organization: Default
|
||||||
|
state: absent
|
||||||
|
kind: aws
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "result is changed"
|
||||||
|
|
||||||
|
- name: Create a valid VMWare credential
|
||||||
|
tower_credential:
|
||||||
|
name: VMWare Credential
|
||||||
|
organization: Default
|
||||||
|
state: present
|
||||||
|
kind: vmware
|
||||||
|
host: https://example.org
|
||||||
|
username: joe
|
||||||
|
password: secret
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "result is changed"
|
||||||
|
|
||||||
|
- name: Delete an VMWare credential
|
||||||
|
tower_credential:
|
||||||
|
name: VMWare Credential
|
||||||
|
organization: Default
|
||||||
|
state: absent
|
||||||
|
kind: vmware
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "result is changed"
|
||||||
|
|
||||||
|
- name: Create a valid Satellite6 credential
|
||||||
|
tower_credential:
|
||||||
|
name: Satellite6 Credential
|
||||||
|
organization: Default
|
||||||
|
state: present
|
||||||
|
kind: satellite6
|
||||||
|
host: https://example.org
|
||||||
|
username: joe
|
||||||
|
password: secret
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "result is changed"
|
||||||
|
|
||||||
|
- name: Delete a Satellite6 credential
|
||||||
|
tower_credential:
|
||||||
|
name: Satellite6 Credential
|
||||||
|
organization: Default
|
||||||
|
state: absent
|
||||||
|
kind: satellite6
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "result is changed"
|
||||||
|
|
||||||
|
- name: Create a valid CloudForms credential
|
||||||
|
tower_credential:
|
||||||
|
name: CloudForms Credential
|
||||||
|
organization: Default
|
||||||
|
state: present
|
||||||
|
kind: cloudforms
|
||||||
|
host: https://example.org
|
||||||
|
username: joe
|
||||||
|
password: secret
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "result is changed"
|
||||||
|
|
||||||
|
- name: Delete a CloudForms credential
|
||||||
|
tower_credential:
|
||||||
|
name: CloudForms Credential
|
||||||
|
organization: Default
|
||||||
|
state: absent
|
||||||
|
kind: cloudforms
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "result is changed"
|
||||||
|
|
||||||
|
- name: Create a valid GCE credential
|
||||||
|
tower_credential:
|
||||||
|
name: GCE Credential
|
||||||
|
organization: Default
|
||||||
|
state: present
|
||||||
|
kind: gce
|
||||||
|
username: joe
|
||||||
|
project: ABC123
|
||||||
|
ssh_key_data: "{{ tempdir.stdout }}/id_rsa"
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "result is changed"
|
||||||
|
|
||||||
|
- name: Delete a GCE credential
|
||||||
|
tower_credential:
|
||||||
|
name: GCE Credential
|
||||||
|
organization: Default
|
||||||
|
state: absent
|
||||||
|
kind: gce
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "result is changed"
|
||||||
|
|
||||||
|
- name: Create a valid AzureRM credential
|
||||||
|
tower_credential:
|
||||||
|
name: AzureRM Credential
|
||||||
|
organization: Default
|
||||||
|
state: present
|
||||||
|
kind: azure_rm
|
||||||
|
username: joe
|
||||||
|
password: secret
|
||||||
|
subscription: some-subscription
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "result is changed"
|
||||||
|
|
||||||
|
- name: Create a valid AzureRM credential with a tenant
|
||||||
|
tower_credential:
|
||||||
|
name: AzureRM Credential
|
||||||
|
organization: Default
|
||||||
|
state: present
|
||||||
|
kind: azure_rm
|
||||||
|
client: some-client
|
||||||
|
secret: some-secret
|
||||||
|
tenant: some-tenant
|
||||||
|
subscription: some-subscription
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "result is changed"
|
||||||
|
|
||||||
|
- name: Delete an AzureRM credential
|
||||||
|
tower_credential:
|
||||||
|
name: AzureRM Credential
|
||||||
|
organization: Default
|
||||||
|
state: absent
|
||||||
|
kind: azure_rm
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "result is changed"
|
||||||
|
|
||||||
|
- name: Create a valid OpenStack credential
|
||||||
|
tower_credential:
|
||||||
|
name: OpenStack Credential
|
||||||
|
organization: Default
|
||||||
|
state: present
|
||||||
|
kind: openstack
|
||||||
|
host: https://keystone.example.org
|
||||||
|
username: joe
|
||||||
|
password: secret
|
||||||
|
project: tenant123
|
||||||
|
domain: some-domain
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "result is changed"
|
||||||
|
|
||||||
|
- name: Delete a OpenStack credential
|
||||||
|
tower_credential:
|
||||||
|
name: OpenStack Credential
|
||||||
|
organization: Default
|
||||||
|
state: absent
|
||||||
|
kind: openstack
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "result is changed"
|
||||||
|
|
||||||
|
- name: Create a valid RHV credential
|
||||||
|
tower_credential:
|
||||||
|
name: RHV Credential
|
||||||
|
organization: Default
|
||||||
|
state: present
|
||||||
|
kind: rhv
|
||||||
|
host: https://example.org
|
||||||
|
username: joe
|
||||||
|
password: secret
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "result is changed"
|
||||||
|
|
||||||
|
- name: Delete an RHV credential
|
||||||
|
tower_credential:
|
||||||
|
name: RHV Credential
|
||||||
|
organization: Default
|
||||||
|
state: absent
|
||||||
|
kind: rhv
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "result is changed"
|
||||||
|
|
||||||
|
- name: Create a valid Insights credential
|
||||||
|
tower_credential:
|
||||||
|
name: Insights Credential
|
||||||
|
organization: Default
|
||||||
|
state: present
|
||||||
|
kind: insights
|
||||||
|
username: joe
|
||||||
|
password: secret
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "result is changed"
|
||||||
|
|
||||||
|
- name: Delete an Insights credential
|
||||||
|
tower_credential:
|
||||||
|
name: Insights Credential
|
||||||
|
organization: Default
|
||||||
|
state: absent
|
||||||
|
kind: insights
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "result is changed"
|
||||||
|
|
||||||
|
- name: Create a valid Tower-to-Tower credential
|
||||||
|
tower_credential:
|
||||||
|
name: Tower Credential
|
||||||
|
organization: Default
|
||||||
|
state: present
|
||||||
|
kind: tower
|
||||||
|
host: https://tower.example.org
|
||||||
|
username: joe
|
||||||
|
password: secret
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "result is changed"
|
||||||
|
|
||||||
|
- name: Delete a Tower-to-Tower credential
|
||||||
|
tower_credential:
|
||||||
|
name: Tower Credential
|
||||||
|
organization: Default
|
||||||
|
state: absent
|
||||||
|
kind: tower
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "result is changed"
|
@ -0,0 +1,2 @@
|
|||||||
|
cloud/tower
|
||||||
|
posix/ci/cloud/group4/tower
|
@ -0,0 +1,34 @@
|
|||||||
|
- name: create a tempdir for hostvars
|
||||||
|
local_action: shell mktemp -d
|
||||||
|
register: tempdir
|
||||||
|
|
||||||
|
- name: write a file w/ hostvars
|
||||||
|
local_action:
|
||||||
|
module: lineinfile
|
||||||
|
dest: "{{ tempdir.stdout }}/vars"
|
||||||
|
line: '{"foo": "bar"}'
|
||||||
|
create: true
|
||||||
|
|
||||||
|
- name: Create a Group
|
||||||
|
tower_group:
|
||||||
|
name: Some Group
|
||||||
|
inventory: Demo Inventory
|
||||||
|
state: present
|
||||||
|
source: ec2
|
||||||
|
variables: "@{{ tempdir.stdout }}/vars"
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "result is changed"
|
||||||
|
|
||||||
|
- name: Delete a Group
|
||||||
|
tower_group:
|
||||||
|
name: Some Group
|
||||||
|
inventory: Demo Inventory
|
||||||
|
state: absent
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "result is changed"
|
@ -0,0 +1,2 @@
|
|||||||
|
cloud/tower
|
||||||
|
posix/ci/cloud/group4/tower
|
@ -0,0 +1,33 @@
|
|||||||
|
- name: create a tempdir for hostvars
|
||||||
|
local_action: shell mktemp -d
|
||||||
|
register: tempdir
|
||||||
|
|
||||||
|
- name: write a file w/ hostvars
|
||||||
|
local_action:
|
||||||
|
module: lineinfile
|
||||||
|
dest: "{{ tempdir.stdout }}/vars"
|
||||||
|
line: '{"foo": "bar"}'
|
||||||
|
create: true
|
||||||
|
|
||||||
|
- name: Create a Host
|
||||||
|
tower_host:
|
||||||
|
name: "some-host"
|
||||||
|
inventory: "Demo Inventory"
|
||||||
|
state: present
|
||||||
|
variables: "@{{ tempdir.stdout }}/vars"
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "result is changed"
|
||||||
|
|
||||||
|
- name: Delete a Host
|
||||||
|
tower_host:
|
||||||
|
name: "some-host"
|
||||||
|
inventory: "Demo Inventory"
|
||||||
|
state: absent
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "result is changed"
|
@ -0,0 +1,2 @@
|
|||||||
|
cloud/tower
|
||||||
|
posix/ci/cloud/group4/tower
|
@ -0,0 +1,21 @@
|
|||||||
|
- name: Create an Inventory
|
||||||
|
tower_inventory:
|
||||||
|
name: my-inventory
|
||||||
|
organization: Default
|
||||||
|
state: present
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "result is changed"
|
||||||
|
|
||||||
|
- name: Delete an Inventory
|
||||||
|
tower_inventory:
|
||||||
|
name: my-inventory
|
||||||
|
organization: Default
|
||||||
|
state: absent
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "result is changed"
|
@ -0,0 +1,2 @@
|
|||||||
|
cloud/tower
|
||||||
|
posix/ci/cloud/group4/tower
|
@ -0,0 +1,15 @@
|
|||||||
|
- name: Launch a Job Template
|
||||||
|
tower_job_launch:
|
||||||
|
job_template: "Demo Job Template"
|
||||||
|
inventory: "Demo Inventory"
|
||||||
|
credential: "Demo Credential"
|
||||||
|
register: job
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "job is changed"
|
||||||
|
- "job.status == 'pending'"
|
||||||
|
|
||||||
|
- name: Cancel the job
|
||||||
|
tower_job_cancel:
|
||||||
|
job_id: "{{ job.id }}"
|
@ -0,0 +1,2 @@
|
|||||||
|
cloud/tower
|
||||||
|
posix/ci/cloud/group4/tower
|
@ -0,0 +1,11 @@
|
|||||||
|
- name: Launch a Job Template
|
||||||
|
tower_job_launch:
|
||||||
|
job_template: "Demo Job Template"
|
||||||
|
inventory: "Demo Inventory"
|
||||||
|
credential: "Demo Credential"
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "result is changed"
|
||||||
|
- "result.status == 'pending'"
|
@ -0,0 +1,2 @@
|
|||||||
|
cloud/tower
|
||||||
|
posix/ci/cloud/group4/tower
|
@ -0,0 +1,20 @@
|
|||||||
|
- name: Launch a Job Template
|
||||||
|
tower_job_launch:
|
||||||
|
job_template: "Demo Job Template"
|
||||||
|
inventory: "Demo Inventory"
|
||||||
|
credential: "Demo Credential"
|
||||||
|
register: job
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "job is changed"
|
||||||
|
- "job.status == 'pending'"
|
||||||
|
|
||||||
|
- name: List jobs w/ a matching primary key
|
||||||
|
tower_job_list:
|
||||||
|
query: {"id": "{{ job.id }}"}
|
||||||
|
register: matching_jobs
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "{{ matching_jobs.count }} == 1"
|
@ -0,0 +1,2 @@
|
|||||||
|
cloud/tower
|
||||||
|
posix/ci/cloud/group4/tower
|
@ -0,0 +1,54 @@
|
|||||||
|
- name: Create an SCM Credential
|
||||||
|
tower_credential:
|
||||||
|
name: SCM Credential for JT
|
||||||
|
organization: Default
|
||||||
|
kind: scm
|
||||||
|
|
||||||
|
- name: Create a Demo Project
|
||||||
|
tower_project:
|
||||||
|
name: Job Template Test Project
|
||||||
|
organization: Default
|
||||||
|
state: present
|
||||||
|
scm_type: git
|
||||||
|
scm_url: https://github.com/ansible/ansible-tower-samples.git
|
||||||
|
scm_credential: SCM Credential for JT
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- name: Update the project (to clone the git repo)
|
||||||
|
uri:
|
||||||
|
url: "https://{{ lookup('env', 'TOWER_HOST') }}/api/v2/projects/{{ result.id }}/update/"
|
||||||
|
method: POST
|
||||||
|
user: "{{ lookup('env', 'TOWER_USERNAME') }}"
|
||||||
|
password: "{{ lookup('env', 'TOWER_PASSWORD') }}"
|
||||||
|
validate_certs: false
|
||||||
|
status_code: 202
|
||||||
|
force_basic_auth: true
|
||||||
|
|
||||||
|
- name: Wait for the project to be status=successful
|
||||||
|
uri:
|
||||||
|
url: "https://{{ lookup('env', 'TOWER_HOST') }}/api/v2/projects/{{ result.id }}/"
|
||||||
|
method: GET
|
||||||
|
user: "{{ lookup('env', 'TOWER_USERNAME') }}"
|
||||||
|
password: "{{ lookup('env', 'TOWER_PASSWORD') }}"
|
||||||
|
validate_certs: false
|
||||||
|
force_basic_auth: true
|
||||||
|
return_content: true
|
||||||
|
register: result
|
||||||
|
until: result.json.status == "successful"
|
||||||
|
retries: 15
|
||||||
|
delay: 1
|
||||||
|
|
||||||
|
- name: Create a Job Template
|
||||||
|
tower_job_template:
|
||||||
|
name: hello-world
|
||||||
|
project: Job Template Test Project
|
||||||
|
inventory: Demo Inventory
|
||||||
|
playbook: hello_world.yml
|
||||||
|
machine_credential: Demo Credential
|
||||||
|
job_type: run
|
||||||
|
state: present
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "result is changed"
|
@ -0,0 +1,2 @@
|
|||||||
|
cloud/tower
|
||||||
|
posix/ci/cloud/group4/tower
|
@ -0,0 +1,16 @@
|
|||||||
|
- name: Launch a Job Template
|
||||||
|
tower_job_launch:
|
||||||
|
job_template: "Demo Job Template"
|
||||||
|
inventory: "Demo Inventory"
|
||||||
|
credential: "Demo Credential"
|
||||||
|
register: job
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "job is changed"
|
||||||
|
- "job.status == 'pending'"
|
||||||
|
|
||||||
|
- name: Wait for the Job to finish
|
||||||
|
tower_job_wait:
|
||||||
|
job_id: "{{ job.id }}"
|
||||||
|
timeout: 60
|
@ -0,0 +1,2 @@
|
|||||||
|
cloud/tower
|
||||||
|
posix/ci/cloud/group4/tower
|
@ -0,0 +1,7 @@
|
|||||||
|
- name: Create a Label
|
||||||
|
tower_label:
|
||||||
|
name: important
|
||||||
|
organization: Default
|
||||||
|
state: present
|
||||||
|
|
||||||
|
# TODO: Deleting labels doesn't seem to work currently
|
@ -1,3 +1,13 @@
|
|||||||
|
- name: confirm Tower version w/ check mode
|
||||||
|
tower_organization:
|
||||||
|
name: Default
|
||||||
|
check_mode: yes
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "result.tower_version == '{{ lookup('env', 'TOWER_VERSION') }}'"
|
||||||
|
|
||||||
- name: Make sure the default Default organization exists
|
- name: Make sure the default Default organization exists
|
||||||
tower_organization:
|
tower_organization:
|
||||||
name: Default
|
name: Default
|
||||||
|
@ -0,0 +1,2 @@
|
|||||||
|
cloud/tower
|
||||||
|
posix/ci/cloud/group4/tower
|
@ -0,0 +1,27 @@
|
|||||||
|
- name: Create an SCM Credential
|
||||||
|
tower_credential:
|
||||||
|
name: SCM Credential for Project
|
||||||
|
organization: Default
|
||||||
|
kind: scm
|
||||||
|
|
||||||
|
- name: Create a Project
|
||||||
|
tower_project:
|
||||||
|
name: my-project
|
||||||
|
organization: Default
|
||||||
|
state: present
|
||||||
|
scm_credential: SCM Credential for Project
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "result is changed"
|
||||||
|
|
||||||
|
- name: Delete a Project
|
||||||
|
tower_project:
|
||||||
|
name: my-project
|
||||||
|
state: absent
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "result is changed"
|
@ -0,0 +1,2 @@
|
|||||||
|
cloud/tower
|
||||||
|
posix/ci/cloud/group4/tower
|
@ -0,0 +1,39 @@
|
|||||||
|
- name: Create a User
|
||||||
|
tower_user:
|
||||||
|
first_name: Joe
|
||||||
|
last_name: User
|
||||||
|
username: joe
|
||||||
|
password: "{{ 65535 | random | to_uuid }}"
|
||||||
|
email: joe@example.org
|
||||||
|
state: present
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "result is changed"
|
||||||
|
|
||||||
|
- name: Add Joe to the update role of the default Project
|
||||||
|
tower_role:
|
||||||
|
user: joe
|
||||||
|
role: update
|
||||||
|
project: Demo Project
|
||||||
|
state: "{{ item }}"
|
||||||
|
register: result
|
||||||
|
with_items:
|
||||||
|
- "present"
|
||||||
|
- "absent"
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "result is changed"
|
||||||
|
|
||||||
|
- name: Delete a User
|
||||||
|
tower_user:
|
||||||
|
username: joe
|
||||||
|
email: joe@example.org
|
||||||
|
state: absent
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "result is changed"
|
@ -1,4 +1,33 @@
|
|||||||
|
- name: Attempt to add a Tower team to a non-existant Organization
|
||||||
|
tower_team:
|
||||||
|
name: Test Team
|
||||||
|
organization: Missing Organization
|
||||||
|
state: present
|
||||||
|
register: result
|
||||||
|
ignore_errors: yes
|
||||||
|
|
||||||
|
- name: Assert a meaningful error was provided for the failed Tower team creation
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- "'The requested object could not be found.' in result.exception"
|
||||||
|
|
||||||
- name: Create a Tower team
|
- name: Create a Tower team
|
||||||
tower_team:
|
tower_team:
|
||||||
name: Test Team
|
name: Test Team
|
||||||
organization: Default
|
organization: Default
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "result is changed"
|
||||||
|
|
||||||
|
- name: Delete a Tower team
|
||||||
|
tower_team:
|
||||||
|
name: Test Team
|
||||||
|
organization: Default
|
||||||
|
state: absent
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "result is changed"
|
||||||
|
@ -0,0 +1,2 @@
|
|||||||
|
cloud/tower
|
||||||
|
posix/ci/cloud/group4/tower
|
@ -0,0 +1,76 @@
|
|||||||
|
- name: Create a User
|
||||||
|
tower_user:
|
||||||
|
first_name: Joe
|
||||||
|
last_name: User
|
||||||
|
username: joe
|
||||||
|
password: "{{ 65535 | random | to_uuid }}"
|
||||||
|
email: joe@example.org
|
||||||
|
state: present
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "result is changed"
|
||||||
|
|
||||||
|
- name: Delete a User
|
||||||
|
tower_user:
|
||||||
|
username: joe
|
||||||
|
email: joe@example.org
|
||||||
|
state: absent
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "result is changed"
|
||||||
|
|
||||||
|
- name: Create an Auditor
|
||||||
|
tower_user:
|
||||||
|
first_name: Joe
|
||||||
|
last_name: Auditor
|
||||||
|
username: joe
|
||||||
|
password: "{{ 65535 | random | to_uuid }}"
|
||||||
|
email: joe@example.org
|
||||||
|
state: present
|
||||||
|
auditor: true
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "result is changed"
|
||||||
|
|
||||||
|
- name: Delete an Auditor
|
||||||
|
tower_user:
|
||||||
|
username: joe
|
||||||
|
email: joe@example.org
|
||||||
|
state: absent
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "result is changed"
|
||||||
|
|
||||||
|
- name: Create a Superuser
|
||||||
|
tower_user:
|
||||||
|
first_name: Joe
|
||||||
|
last_name: Super
|
||||||
|
username: joe
|
||||||
|
password: "{{ 65535 | random | to_uuid }}"
|
||||||
|
email: joe@example.org
|
||||||
|
state: present
|
||||||
|
superuser: true
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "result is changed"
|
||||||
|
|
||||||
|
- name: Delete a Superuser
|
||||||
|
tower_user:
|
||||||
|
username: joe
|
||||||
|
email: joe@example.org
|
||||||
|
state: absent
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "result is changed"
|
Loading…
Reference in New Issue