re-work file-removal-test.yml to function like file-creation-single.yml
This commit is contained in:
@ -1,33 +1,36 @@
|
|||||||
---
|
---
|
||||||
- name: Remove a file from current inventory
|
- name: Create inventory based on passed extra_vars
|
||||||
hosts: all
|
hosts: localhost
|
||||||
gather_facts: no
|
gather_facts: no
|
||||||
become: no
|
become: no
|
||||||
|
|
||||||
|
|
||||||
vars:
|
vars:
|
||||||
# These vars are used to purposefully skip a node
|
provision_host: "{{ tower_provision_host | default('localhost') }}"
|
||||||
skip_host : "{{ tower_skip_host | default('no') }}"
|
|
||||||
host_to_skip : "{{ tower_host_to_skip | default('lab-dev-2') }}"
|
|
||||||
|
|
||||||
|
|
||||||
tasks:
|
tasks:
|
||||||
- block:
|
- name: "Create in-memory inventory for {{ provision_host }}"
|
||||||
- name: "Test #1a - Remove file from machine - skipping {{ host_to_skip }}"
|
add_host:
|
||||||
|
name: "{{ provision_host }}"
|
||||||
|
groups:
|
||||||
|
- remdiation
|
||||||
|
|
||||||
|
|
||||||
|
# =========================================================================== #
|
||||||
|
|
||||||
|
|
||||||
|
- name: Remove file from hosts
|
||||||
|
hosts: remdiation
|
||||||
|
gather_facts: no
|
||||||
|
become: no
|
||||||
|
|
||||||
|
|
||||||
|
tasks:
|
||||||
|
- name: "Remove file from {{ inventory_hostname }}"
|
||||||
file:
|
file:
|
||||||
path : /tmp/hello-ansible.txt
|
path : /tmp/hello-ansible.txt
|
||||||
state : absent
|
state : absent
|
||||||
when: inventory_hostname != host_to_skip
|
|
||||||
when:
|
|
||||||
- skip_host | bool
|
|
||||||
|
|
||||||
|
|
||||||
- name: "Test #1 - Remove file from machine"
|
|
||||||
file:
|
|
||||||
path : /tmp/hello-ansible.txt
|
|
||||||
state : absent
|
|
||||||
when:
|
|
||||||
- not skip_host | bool
|
|
||||||
|
|
||||||
|
|
||||||
...
|
...
|
||||||
|
Reference in New Issue
Block a user