add copy to modules

This commit is contained in:
sean-m-sullivan
2021-02-21 19:49:14 -06:00
parent 74a5247d9d
commit 9a7dd38cbb
15 changed files with 536 additions and 28 deletions

View File

@@ -203,6 +203,29 @@
that:
- result is not changed
- name: Copy ssh Credential
tower_credential:
name: "copy_{{ ssh_cred_name2 }}"
copy_from: "{{ ssh_cred_name2 }}"
credential_type: Machine
register: result
- assert:
that:
- result is changed
- name: Delete an SSH credential
tower_credential:
name: "copy_{{ ssh_cred_name2 }}"
organization: Default
state: absent
credential_type: Machine
register: result
- assert:
that:
- "result is changed"
- name: Create a valid SSH credential from lookup source (old school)
tower_credential:
name: "{{ ssh_cred_name3 }}"
@@ -369,7 +392,7 @@
- result is failed
- "'Unable to create credential {{ vault_cred_name2 }}' in result.msg"
- "'Additional properties are not allowed' in result.msg"
- "'\\'vault_password\\' was unexpected' in result.msg"
- "'\\'vault_********\\' was unexpected' in result.msg"
- name: Delete a Vault credential
tower_credential:

View File

@@ -29,9 +29,79 @@
that:
- "result is changed"
- name: Create a Group
tower_group:
name: "{{ group_name2 }}"
inventory: "{{ inv_name }}"
state: present
variables:
foo: bar
register: result
- assert:
that:
- "result is changed"
- name: Create a Group
tower_group:
name: "{{ group_name3 }}"
inventory: "{{ inv_name }}"
state: present
variables:
foo: bar
register: result
- assert:
that:
- "result is changed"
- name: add hosts
tower_host:
name: "{{ item }}"
inventory: "{{ inv_name }}"
loop:
- "{{ host_name1 }}"
- "{{ host_name2 }}"
- "{{ host_name3 }}"
- name: Create a Group with hosts and sub group
tower_group:
name: "{{ group_name1 }}"
inventory: "{{ inv_name }}"
hosts:
- "{{ host_name1 }}"
- "{{ host_name2 }}"
children:
- "{{ group_name2 }}"
state: present
variables:
foo: bar
register: result
- name: Create a Group with hosts and sub group
tower_group:
name: "{{ group_name1 }}"
inventory: "{{ inv_name }}"
hosts:
- "{{ host_name3 }}"
children:
- "{{ group_name3 }}"
state: present
preserve_existing_hosts: True
preserve_existing_children: True
register: result
- name: "Find number of hosts in {{ group_name1 }}"
set_fact:
group1_host_count: "{{ lookup('awx.awx.tower_api', 'groups/{{result.id}}/all_hosts/') |length}}"
- assert:
that:
- group1_host_count == "3"
- name: Delete a Group
tower_group:
name: "{{ result.id }}"
name: "{{ group_name1 }}"
inventory: "{{ inv_name }}"
state: absent
register: result
@@ -40,6 +110,28 @@
that:
- "result is changed"
- name: Delete a Group
tower_group:
name: "{{ group_name2 }}"
inventory: "{{ inv_name }}"
state: absent
register: result
- assert:
that:
- "result is changed"
- name: Delete a Group
tower_group:
name: "{{ group_name3 }}"
inventory: "{{ inv_name }}"
state: absent
register: result
- assert:
that:
- "result is not changed"
- name: Check module fails with correct msg
tower_group:
name: test-group

View File

@@ -36,7 +36,6 @@
- assert:
that:
- "result is changed"
- name: Test Inventory module idempotency
tower_inventory:
name: "{{ result.id }}"
@@ -48,6 +47,30 @@
- assert:
that:
- "result is not changed"
- name: Copy an inventory
tower_inventory:
name: "copy_{{ inv_name1 }}"
copy_from: "{{ inv_name1 }}"
organization: Default
description: "Our Foo Cloud Servers"
state: present
register: result
- assert:
that:
- "result is changed"
- name: Delete an Inventory
tower_inventory:
name: "copy_{{ inv_name1 }}"
organization: Default
state: absent
register: result
- assert:
that:
- "result is changed"
- name: Fail Change Regular to Smart
tower_inventory:
@@ -133,6 +156,7 @@
loop:
- "{{ inv_name1 }}"
- "{{ inv_name2 }}"
- "copy_{{ inv_name1 }}"
- name: Delete Insights Credential
tower_credential:

View File

@@ -155,6 +155,19 @@
that:
- "result is changed"
- name: Copy Job Template
tower_job_template:
name: "copy_{{ jt1 }}"
copy_from: "{{ jt1 }}"
state: "present"
- name: Delete copied Job Template
tower_job_template:
name: "copy_{{ jt1 }}"
job_type: run
state: absent
register: result
# This doesnt work if you include the credentials parameter
- name: Delete Job Template 1
tower_job_template:

View File

@@ -133,6 +133,28 @@
that:
- result is changed
- name: Copy email notification
tower_notification_template:
name: "copy_{{ email_not }}"
copy_from: "{{ email_not }}"
organization: Default
register: result
- assert:
that:
- result is changed
- name: Delete copied email notification
tower_notification_template:
name: "copy_{{ email_not }}"
organization: Default
state: absent
register: result
- assert:
that:
- result is changed
- name: Delete email notification
tower_notification_template:
name: "{{ email_not }}"

View File

@@ -75,13 +75,14 @@
scm_credential: "{{ cred_name }}"
check_mode: true
- name: Create a new test project
- name: "Copy tower project from {{ project_name1 }}"
tower_project:
name: "{{ project_name2 }}"
copy_from: "{{ project_name1 }}"
organization: "{{ org_name }}"
scm_type: git
scm_url: https://github.com/ansible/test-playbooks
scm_credential: "{{ cred_name }}"
state: present
register: result
# If this fails it may be because the check_mode task actually already created

View File

@@ -244,6 +244,52 @@
that:
- "result is changed"
- name: Copy a workflow job template
tower_workflow_job_template:
name: "copy_{{ wfjt_name }}"
copy_from: "{{ wfjt_name }}"
organization: Default
register: result
- assert:
that:
- "result is changed"
- name: Fail Remove "on start" webhook notification from copied workflow job template
tower_workflow_job_template:
name: "copy_{{ wfjt_name }}"
notification_templates_started:
- "{{ email_not }}123"
register: remove_copied_workflow_node
ignore_errors: true
- assert:
that:
- "remove_copied_workflow_node is failed"
- "remove_copied_workflow_node is not changed"
- "'returned 0 items' in remove_copied_workflow_node.msg"
- name: Remove "on start" webhook notification from copied workflow job template
tower_workflow_job_template:
name: "copy_{{ wfjt_name }}"
notification_templates_started:
- "{{ email_not }}"
register: result
- assert:
that:
- "result is changed"
- name: Delete copied workflow job template
tower_workflow_job_template:
name: "copy_{{ wfjt_name }}"
state: absent
register: result
- assert:
that:
- "result is changed"
- name: Remove "on start" webhook notification from workflow job template
tower_workflow_job_template:
name: "{{ wfjt_name }}"