Files
tower-tests/file-existence-test.yml

71 lines
1.3 KiB
YAML

---
- name: Create inventory based on extra_vars
hosts: all
gather_facts: no
become: no
vars_files:
- vars/defaults.yml
vars:
provision_host: "{{ tower_provision_host | default(ansible_play_hosts | join(',')) }}"
tasks:
- name: "Create in-memory inventory"
add_host:
name: "{{ item }}"
groups:
- remdiation
delegate_to: localhost
loop: "{{ provision_host.split(',') }}"
# =========================================================================== #
- name: Verify file existance and handle errors if needed
hosts: remdiation
gather_facts: no
become: no
vars_files:
- vars/defaults.yml
tasks:
- name: Run file test
block:
- name: "Test #1: register file contents"
command :
cmd : "cat {{ check_file }}"
changed_when : no
register : r_check_file
- name: "Test #2: Say Hello"
debug:
var: r_check_file.stdout
# 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: "Job has completed."
...