From d7048a96ab01a28be635172a6599fad2847bc1d8 Mon Sep 17 00:00:00 2001 From: Chris Hammer Date: Wed, 9 Feb 2022 17:17:40 -0500 Subject: [PATCH] add file-removal-test.yml --- file-removal-test.yml | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 file-removal-test.yml diff --git a/file-removal-test.yml b/file-removal-test.yml new file mode 100644 index 0000000..65897f7 --- /dev/null +++ b/file-removal-test.yml @@ -0,0 +1,33 @@ +--- +- name: Remove a file from 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 - Remove file from machine - skipping {{ host_to_skip }}" + file: + path : /tmp/hello-ansible.txt + 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 + + +...