rsyslog/ansible/playbooks/validate.yml
dvirlabs cf83072c38
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
test
2026-06-09 17:40:36 +03:00

50 lines
2.8 KiB
YAML

---
# =============================================================================
# VALIDATE PLAYBOOK
# Purpose: Verify that all configured files exist and are readable on servers
# Usage: ansible-playbook validate.yml
# Output: Success if all files exist and readable, Failure if any are missing
# =============================================================================
- name: Validate deployed files
hosts: all
gather_facts: false
vars_files:
- ../deploy-config.yml
tasks:
# ─────────────────────────────────────────────────────────────────────
# TASK 1: Check each configured file status
# Gathers file stats (exists, readable, permissions, etc.)
# ─────────────────────────────────────────────────────────────────────
- name: Check if file is readable ({{ item.name }})
stat:
path: "{{ item.dest }}"
register: file_stats
loop: "{{ deploy_items }}"
loop_control:
loop_var: item
label: "{{ item.name }}"
# ─────────────────────────────────────────────────────────────────────
# TASK 2: Verify each file exists and is readable
# Fails if any configured file is missing or not readable
# ─────────────────────────────────────────────────────────────────────
- name: Verify all files exist and are readable
assert:
that:
- item.stat.exists
- item.stat.readable
msg: "{{ item.item.name }} ({{ item.item.dest }}) is missing or not readable"
loop: "{{ file_stats.results }}"
loop_control:
label: "{{ item.item.name }}"
# ─────────────────────────────────────────────────────────────────────
# TASK 3: Display validation result
# Shows success message if all files passed validation
# ─────────────────────────────────────────────────────────────────────
- name: Display validation result
debug:
msg: "✓ All {{ deploy_items | length }} file(s) are valid and readable on {{ inventory_hostname }}"