--- # ============================================================================= # VALIDATE PLAYBOOK # Purpose: Verify that dvir.txt exists and is readable on target servers # Usage: ansible-playbook validate.yml # Output: Success if file exists and is readable, Failure if not # ============================================================================= - name: Validate file exists hosts: all gather_facts: false tasks: # ───────────────────────────────────────────────────────────────────── # TASK 1: Check file status # Gathers file stats (exists, readable, permissions, etc.) # ───────────────────────────────────────────────────────────────────── - name: Check if file is readable stat: path: /tmp/dvir.txt register: file_stat # ───────────────────────────────────────────────────────────────────── # TASK 2: Assert file requirements # Verifies that the file exists and is readable # Fails the playbook if either condition is false # ───────────────────────────────────────────────────────────────────── - name: Verify file exists and is readable assert: that: - file_stat.stat.exists - file_stat.stat.readable msg: "dvir.txt not found or not readable" # ───────────────────────────────────────────────────────────────────── # TASK 3: Display validation result # Shows success message if all checks passed # ───────────────────────────────────────────────────────────────────── - name: Display validation result debug: msg: "✓ dvir.txt is valid and readable"