updates to several things ;)
This commit is contained in:
6
README.md
Normal file
6
README.md
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
# Tower Tests
|
||||||
|
A simple series of plays, files, templates, etc for testing Ansible Tower and/or Ansible Automation Platform
|
||||||
|
|
||||||
|
|
||||||
|
### Authors:
|
||||||
|
> Chris Hammer (chris.hammer@redhat.com)
|
3
facts.d/127.0.0.1
Normal file
3
facts.d/127.0.0.1
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"discovered_interpreter_python": "/usr/bin/python3"
|
||||||
|
}
|
3
facts.d/localhost
Normal file
3
facts.d/localhost
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"discovered_interpreter_python": "/usr/bin/python3"
|
||||||
|
}
|
33
file-creation-test.yml
Normal file
33
file-creation-test.yml
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
---
|
||||||
|
- name: Create a test file on current inventory
|
||||||
|
hosts: all
|
||||||
|
gather_facts: no
|
||||||
|
become: no
|
||||||
|
|
||||||
|
|
||||||
|
vars:
|
||||||
|
# These vars are used to purposefully skip a node
|
||||||
|
skip_host : "{{ tower_skip_host | default('no') }}"
|
||||||
|
host_to_skip : "{{ tower_host_to_skip | default('lab-dev-2') }}"
|
||||||
|
|
||||||
|
|
||||||
|
tasks:
|
||||||
|
- block:
|
||||||
|
- name: "Test #1a - Copy file to machine - skipping {{ host_to_skip }}"
|
||||||
|
copy:
|
||||||
|
src : files/hello-ansible.txt
|
||||||
|
dest : /tmp/hello-ansible.txt
|
||||||
|
when: inventory_hostname != host_to_skip
|
||||||
|
when:
|
||||||
|
- skip_host | bool
|
||||||
|
|
||||||
|
|
||||||
|
- name: "Test #1 - Copy file to machine"
|
||||||
|
copy:
|
||||||
|
src : files/hello-ansible.txt
|
||||||
|
dest : /tmp/hello-ansible.txt
|
||||||
|
when:
|
||||||
|
- not skip_host | bool
|
||||||
|
|
||||||
|
|
||||||
|
...
|
59
inmem-test.yml
Normal file
59
inmem-test.yml
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
---
|
||||||
|
- name: Utilize workflow based on an in-memory inventory
|
||||||
|
hosts: localhost
|
||||||
|
gather_facts: no
|
||||||
|
become: no
|
||||||
|
|
||||||
|
|
||||||
|
vars:
|
||||||
|
provision_host: "{{ tower_provision_host | default('localhost') }}"
|
||||||
|
|
||||||
|
|
||||||
|
tasks:
|
||||||
|
- name: "Create in-memory inventory for {{ provision_host }}"
|
||||||
|
add_host:
|
||||||
|
name: "{{ provision_host }}"
|
||||||
|
groups:
|
||||||
|
- remdiation
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# =========================================================================== #
|
||||||
|
|
||||||
|
|
||||||
|
- name: Verify file existance and handle errors if needed
|
||||||
|
hosts: remdiation
|
||||||
|
gather_facts: no
|
||||||
|
become: no
|
||||||
|
|
||||||
|
|
||||||
|
tasks:
|
||||||
|
- name: Run file test
|
||||||
|
block:
|
||||||
|
- name: "Test #1: register file contents"
|
||||||
|
command :
|
||||||
|
cmd : cat /tmp/hello-ansible.txt
|
||||||
|
changed_when : no
|
||||||
|
register : r_check_file
|
||||||
|
|
||||||
|
|
||||||
|
rescue:
|
||||||
|
- name: Exception caught
|
||||||
|
debug:
|
||||||
|
msg:
|
||||||
|
- "host : {{ inventory_hostname }}"
|
||||||
|
- "rc : {{ r_check_file.rc }}"
|
||||||
|
- "stdout : {{ r_check_file.stdout }}"
|
||||||
|
- "stderr : {{ r_check_file.stderr }}"
|
||||||
|
|
||||||
|
|
||||||
|
always:
|
||||||
|
- name: Job complete
|
||||||
|
debug:
|
||||||
|
msg:
|
||||||
|
- "host : {{ inventory_hostname }}"
|
||||||
|
- "failed : {{ r_check_file.failed }} {{ r_check_file.msg }}"
|
||||||
|
|
||||||
|
|
||||||
|
...
|
@ -5,28 +5,32 @@
|
|||||||
become: no
|
become: no
|
||||||
|
|
||||||
|
|
||||||
|
vars:
|
||||||
|
# These vars are used to purposefully skip a node
|
||||||
|
skip_host : "{{ tower_skip_host | default('no') }}"
|
||||||
|
host_to_skip : "{{ tower_host_to_skip | default('lab-dev-2') }}"
|
||||||
|
|
||||||
|
|
||||||
tasks:
|
tasks:
|
||||||
- name: Run tests against various hosts
|
- name: "Test #1 - whoami"
|
||||||
block:
|
command :
|
||||||
- name: "Test #1 - whoami"
|
cmd : whoami
|
||||||
command :
|
changed_when : no
|
||||||
cmd : whoami
|
register : r_cmd_whoami
|
||||||
changed_when : no
|
|
||||||
register : r_cmd_whoami
|
|
||||||
|
|
||||||
|
|
||||||
- name: "Results #1 - whoami"
|
- name: "Results #1 - whoami"
|
||||||
debug:
|
debug:
|
||||||
msg:
|
msg:
|
||||||
- "rc : {{ r_cmd_whoami.rc }}"
|
- "rc : {{ r_cmd_whoami.rc }}"
|
||||||
- "stdout : {{ r_cmd_whoami.stdout }}"
|
- "stdout : {{ r_cmd_whoami.stdout }}"
|
||||||
- "stderr : {{ r_cmd_whoami.stderr }}"
|
- "stderr : {{ r_cmd_whoami.stderr }}"
|
||||||
|
|
||||||
|
|
||||||
- name: "Test #2 - Copy file to machine"
|
- name: "Test #2 - induce failure (but only for a specified host)"
|
||||||
copy:
|
command:
|
||||||
src : files/hello-ansible.txt
|
cmd: /bin/false
|
||||||
dest : /tmp/hello-ansible.txt
|
when:
|
||||||
|
- fail_host | bool and inventory_hostname == host_to_fail
|
||||||
|
|
||||||
...
|
...
|
||||||
|
Reference in New Issue
Block a user