Remove Collections module parameters deprecated in Controller 4.0.0

This commit is contained in:
beeankha
2021-08-03 12:35:11 -04:00
parent dae3f1a164
commit 9409dc0085
7 changed files with 201 additions and 767 deletions

View File

@@ -35,70 +35,24 @@
set_fact:
ssh_key_data: "{{ lookup('file', tempdir.stdout + '/id_rsa') }}"
- name: Test deprecation warnings
credential:
name: "{{ ssh_cred_name1 }}"
organization: Default
kind: ssh
authorize: false
authorize_password: 'test'
client: 'test'
security_token: 'test'
secret: 'test'
tenant: 'test'
subscription: 'test'
domain: 'test'
become_method: 'test'
become_username: 'test'
become_password: 'test'
vault_password: 'test'
project: 'test'
host: 'test'
username: 'test'
password: 'test'
ssh_key_data: 'test'
vault_id: 'test'
ssh_key_unlock: 'test'
state: absent
ignore_errors: true
register: result
- assert:
that:
- "'deprecations' in result"
# The 20 comes from the length of OLD_INPUT_NAMES + 1 for kind
- result['deprecations'] | length() == 20
- name: Create an Org-specific credential (old school)
- name: Create an Org-specific credential with an ID
credential:
name: "{{ ssh_cred_name1 }}"
organization: Default
credential_type: Machine
state: present
kind: ssh
register: result
- assert:
that:
- "result is changed"
- name: Re-create the Org-specific credential (new school) with an ID
credential:
name: "{{ result.id }}"
organization: Default
credential_type: 'Machine'
state: present
register: result
- assert:
that:
- "result is not changed"
- name: Delete a Org-specific credential
credential:
name: "{{ ssh_cred_name1 }}"
organization: Default
state: absent
kind: ssh
credential_type: Machine
register: result
- assert:
@@ -122,34 +76,14 @@
name: "{{ ssh_cred_name1 }}"
user: admin
state: absent
kind: ssh
credential_type: 'Machine'
register: result
- assert:
that:
- "result is changed"
- name: Create a valid SSH credential (old school)
credential:
name: "{{ ssh_cred_name2 }}"
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: "{{ ssh_key_data }}"
ssh_key_unlock: "passphrase"
register: result
- assert:
that:
- "result is changed"
- name: Create a valid SSH credential (new school)
- name: Create a valid SSH credential
credential:
name: "{{ ssh_cred_name2 }}"
organization: Default
@@ -166,13 +100,11 @@
ssh_key_unlock: "passphrase"
register: result
# This will be changed because we are setting ssh_key_data and ssh_key_unlock.
# These will come out as $encrypted$ which will always compare false to the values.
- assert:
that:
- result is changed
- name: Create a valid SSH credential (new school)
- name: Create a valid SSH credential
credential:
name: "{{ ssh_cred_name2 }}"
organization: Default
@@ -185,7 +117,6 @@
become_username: superuser
register: result
# This shows as "changed" because these listed inputs replace the existing inputs from the previous task
- assert:
that:
- result is changed
@@ -226,27 +157,7 @@
that:
- "result is changed"
- name: Create a valid SSH credential from lookup source (old school)
credential:
name: "{{ ssh_cred_name3 }}"
organization: Default
state: present
kind: ssh
description: An example SSH credential from lookup source
username: joe
password: secret
become_method: sudo
become_username: superuser
become_password: supersecret
ssh_key_data: "{{ lookup('file', tempdir.stdout + '/id_rsa') }}"
ssh_key_unlock: "passphrase"
register: result
- assert:
that:
- "result is changed"
- name: Create a valid SSH credential from lookup source (new school)
- name: Create a valid SSH credential from lookup source
credential:
name: "{{ ssh_cred_name3 }}"
organization: Default
@@ -263,42 +174,19 @@
ssh_key_unlock: "passphrase"
register: result
# This will be changed because we are passing in ssh_key_data and password
- assert:
that:
- result is changed
- name: Fail to create an SSH credential from a file source (old school format)
credential:
name: "{{ ssh_cred_name4 }}"
organization: Default
state: present
kind: ssh
description: An example SSH credential from file source
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
ignore_errors: true
- assert:
that:
- result is failed
- "'Unable to create credential {{ ssh_cred_name4 }}' in result.msg"
- "'Invalid certificate or key' in result.msg"
- name: Create an invalid SSH credential (passphrase required)
credential:
name: SSH Credential
organization: Default
state: present
kind: ssh
username: joe
ssh_key_data: "{{ ssh_key_data }}"
credential_type: Machine
inputs:
username: joe
ssh_key_data: "{{ ssh_key_data }}"
ignore_errors: true
register: result
@@ -312,8 +200,9 @@
name: SSH Credential
organization: Missing_Organization
state: present
kind: ssh
username: joe
credential_type: Machine
inputs:
username: joe
ignore_errors: true
register: result
@@ -329,7 +218,7 @@
name: "{{ ssh_cred_name2 }}"
organization: Default
state: absent
kind: ssh
credential_type: Machine
register: result
- assert:
@@ -341,7 +230,7 @@
name: "{{ ssh_cred_name3 }}"
organization: Default
state: absent
kind: ssh
credential_type: Machine
register: result
- assert:
@@ -353,7 +242,7 @@
name: "{{ ssh_cred_name4 }}"
organization: Default
state: absent
kind: ssh
credential_type: Machine
register: result
# This one was never really created so it shouldn't be deleted
@@ -366,9 +255,11 @@
name: "{{ vault_cred_name1 }}"
organization: Default
state: present
kind: vault
credential_type: Vault
description: An example Vault credential
vault_password: secret-vault
inputs:
vault_id: bar
vault_password: secret-vault
register: result
- assert:
@@ -380,7 +271,7 @@
name: "{{ vault_cred_name1 }}"
organization: Default
state: absent
kind: vault
credential_type: Vault
register: result
- assert:
@@ -392,7 +283,7 @@
name: "{{ vault_cred_name2 }}"
organization: Default
state: absent
kind: vault
credential_type: Vault
register: result
# The creation of vault_cred_name2 never worked so we shouldn't actually need to delete it
@@ -405,11 +296,12 @@
name: "{{ net_cred_name1 }}"
organization: Default
state: present
kind: net
username: joe
password: secret
authorize: true
authorize_password: authorize-me
credential_type: Network
inputs:
username: joe
password: secret
authorize: true
authorize_password: authorize-me
register: result
- assert:
@@ -421,7 +313,7 @@
name: "{{ net_cred_name1 }}"
organization: Default
state: absent
kind: net
credential_type: Network
register: result
- assert:
@@ -433,11 +325,12 @@
name: "{{ scm_cred_name1 }}"
organization: Default
state: present
kind: scm
username: joe
password: secret
ssh_key_data: "{{ ssh_key_data }}"
ssh_key_unlock: "passphrase"
credential_type: Source Control
inputs:
username: joe
password: secret
ssh_key_data: "{{ ssh_key_data }}"
ssh_key_unlock: "passphrase"
register: result
- assert:
@@ -449,7 +342,7 @@
name: "{{ scm_cred_name1 }}"
organization: Default
state: absent
kind: scm
credential_type: Source Control
register: result
- assert:
@@ -461,10 +354,11 @@
name: "{{ aws_cred_name1 }}"
organization: Default
state: present
kind: aws
username: joe
password: secret
security_token: aws-token
credential_type: Amazon Web Services
inputs:
username: joe
password: secret
security_token: aws-token
register: result
- assert:
@@ -476,7 +370,7 @@
name: "{{ aws_cred_name1 }}"
organization: Default
state: absent
kind: aws
credential_type: Amazon Web Services
register: result
- assert:
@@ -488,10 +382,11 @@
name: "{{ vmware_cred_name1 }}"
organization: Default
state: present
kind: vmware
host: https://example.org
username: joe
password: secret
credential_type: VMware vCenter
inputs:
host: https://example.org
username: joe
password: secret
register: result
- assert:
@@ -503,7 +398,7 @@
name: "{{ vmware_cred_name1 }}"
organization: Default
state: absent
kind: vmware
credential_type: VMware vCenter
register: result
- assert:
@@ -515,10 +410,11 @@
name: "{{ sat6_cred_name1 }}"
organization: Default
state: present
kind: satellite6
host: https://example.org
username: joe
password: secret
credential_type: Red Hat Satellite 6
inputs:
host: https://example.org
username: joe
password: secret
register: result
- assert:
@@ -530,7 +426,7 @@
name: "{{ sat6_cred_name1 }}"
organization: Default
state: absent
kind: satellite6
credential_type: Red Hat Satellite 6
register: result
- assert:
@@ -542,10 +438,11 @@
name: "{{ gce_cred_name1 }}"
organization: Default
state: present
kind: gce
username: joe
project: ABC123
ssh_key_data: "{{ ssh_key_data }}"
credential_type: Google Compute Engine
inputs:
username: joe
project: ABC123
ssh_key_data: "{{ ssh_key_data }}"
register: result
- assert:
@@ -557,7 +454,7 @@
name: "{{ gce_cred_name1 }}"
organization: Default
state: absent
kind: gce
credential_type: Google Compute Engine
register: result
- assert:
@@ -569,10 +466,11 @@
name: "{{ azurerm_cred_name1 }}"
organization: Default
state: present
kind: azure_rm
username: joe
password: secret
subscription: some-subscription
credential_type: Microsoft Azure Resource Manager
inputs:
username: joe
password: secret
subscription: some-subscription
register: result
- assert:
@@ -584,11 +482,12 @@
name: "{{ azurerm_cred_name1 }}"
organization: Default
state: present
kind: azure_rm
client: some-client
secret: some-secret
tenant: some-tenant
subscription: some-subscription
credential_type: Microsoft Azure Resource Manager
inputs:
client: some-client
secret: some-secret
tenant: some-tenant
subscription: some-subscription
register: result
- assert:
@@ -600,7 +499,7 @@
name: "{{ azurerm_cred_name1 }}"
organization: Default
state: absent
kind: azure_rm
credential_type: Microsoft Azure Resource Manager
register: result
- assert:
@@ -612,12 +511,13 @@
name: "{{ openstack_cred_name1 }}"
organization: Default
state: present
kind: openstack
host: https://keystone.example.org
username: joe
password: secret
project: tenant123
domain: some-domain
credential_type: OpenStack
inputs:
host: https://keystone.example.org
username: joe
password: secret
project: tenant123
domain: some-domain
register: result
- assert:
@@ -629,7 +529,7 @@
name: "{{ openstack_cred_name1 }}"
organization: Default
state: absent
kind: openstack
credential_type: OpenStack
register: result
- assert:
@@ -641,10 +541,11 @@
name: "{{ rhv_cred_name1 }}"
organization: Default
state: present
kind: rhv
host: https://example.org
username: joe
password: secret
credential_type: Red Hat Virtualization
inputs:
host: https://example.org
username: joe
password: secret
register: result
- assert:
@@ -656,7 +557,7 @@
name: "{{ rhv_cred_name1 }}"
organization: Default
state: absent
kind: rhv
credential_type: Red Hat Virtualization
register: result
- assert:
@@ -668,9 +569,10 @@
name: "{{ insights_cred_name1 }}"
organization: Default
state: present
kind: insights
username: joe
password: secret
credential_type: Insights
inputs:
username: joe
password: secret
register: result
- assert:
@@ -682,7 +584,7 @@
name: "{{ insights_cred_name1 }}"
organization: Default
state: absent
kind: insights
credential_type: Insights
register: result
- assert:
@@ -694,10 +596,11 @@
name: "{{ tower_cred_name1 }}"
organization: Default
state: present
kind: tower
host: https://controller.example.org
username: joe
password: secret
credential_type: Red Hat Ansible Automation Platform
inputs:
host: https://controller.example.org
username: joe
password: secret
register: result
- assert:
@@ -709,7 +612,7 @@
name: "{{ tower_cred_name1 }}"
organization: Default
state: absent
kind: tower
credential_type: Red Hat Ansible Automation Platform
register: result
- assert:
@@ -720,7 +623,7 @@
credential:
name: test-credential
description: Credential Description
kind: ssh
credential_type: Machine
organization: test-non-existing-org
state: present
register: result

View File

@@ -22,18 +22,6 @@
extra_vars:
sleep_interval: 300
- name: Check deprecation warnings
job_wait:
min_interval: 10
max_interval: 20
job_id: "99999999"
register: result
ignore_errors: true
- assert:
that:
- "'Min and max interval have been deprecated, please use interval instead; interval will be set to 15'"
- name: Validate that interval superceeds min/max
job_wait:
min_interval: 10

View File

@@ -8,59 +8,15 @@
pd_not: "AWX-Collection-tests-notification_template-pd-not-{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
irc_not: "AWX-Collection-tests-notification_template-irc-not-{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
- name: Test deprecation warnings with legacy name
notification_template:
name: "{{ slack_not }}"
organization: Default
notification_type: slack
username: maw
sender: maw
recipients:
- everyone
use_tls: true
host: all
use_ssl: false
password: password
port: 12
channels:
- general
token: chunkecheese
account_token: asdf1234
from_number: "1 (888) 733-4281"
to_numbers:
- 867-5309
account_sid: vicious
subdomain: 'redhat.com'
service_key: skeleton
client_name: Bill
message_from: me
color: green
notify: true
url: ansible.com
headers:
X-Custom-Header: value123
server: littimer.somewhere.com
nickname: chalk
targets:
- zombie
state: absent
register: result
ignore_errors: true
- assert:
that:
- "'deprecations' in result"
# The 25 can be count from the size of the OLD_INPUT_NAMES list in the module
- result['deprecations'] | length() == 25
- name: Create Slack notification with custom messages
notification_template:
name: "{{ slack_not }}"
organization: Default
notification_type: slack
token: a_token
channels:
- general
notification_configuration:
token: a_token
channels:
- general
messages:
started:
message: "{{ '{{' }} job_friendly_name {{' }}' }} {{ '{{' }} job.id {{' }}' }} started"
@@ -91,9 +47,10 @@
name: "{{ webhook_not }}"
organization: Default
notification_type: webhook
url: http://www.example.com/hook
headers:
X-Custom-Header: value123
notification_configuration:
url: http://www.example.com/hook
headers:
X-Custom-Header: value123
state: present
register: result
@@ -117,15 +74,16 @@
name: "{{ email_not }}"
organization: Default
notification_type: email
username: user
password: s3cr3t
sender: tower@example.com
recipients:
- user1@example.com
host: smtp.example.com
port: 25
use_tls: false
use_ssl: false
notification_configuration:
username: user
password: s3cr3t
sender: tower@example.com
recipients:
- user1@example.com
host: smtp.example.com
port: 25
use_tls: false
use_ssl: false
state: present
register: result
@@ -171,11 +129,12 @@
name: "{{ twillo_not }}"
organization: Default
notification_type: twilio
account_token: a_token
account_sid: a_sid
from_number: '+15551112222'
to_numbers:
- '+15553334444'
notification_configuration:
account_token: a_token
account_sid: a_sid
from_number: '+15551112222'
to_numbers:
- '+15553334444'
state: present
register: result
@@ -199,10 +158,11 @@
name: "{{ pd_not }}"
organization: Default
notification_type: pagerduty
token: a_token
subdomain: sub
client_name: client
service_key: a_key
notification_configuration:
token: a_token
subdomain: sub
client_name: client
service_key: a_key
state: present
register: result
@@ -226,13 +186,14 @@
name: "{{ irc_not }}"
organization: Default
notification_type: irc
nickname: tower
password: s3cr3t
targets:
- user1
port: 8080
server: irc.example.com
use_ssl: false
notification_configuration:
nickname: tower
password: s3cr3t
targets:
- user1
port: 8080
server: irc.example.com
use_ssl: false
state: present
register: result