--- # Test playbook for system_info role - name: Test system_info role hosts: localhost become: true gather_facts: true vars: system_info_stats_base_dir: "/tmp/ansible-test/stats/machines" system_info_create_stats_dir: true pre_tasks: - name: Display test information debug: msg: - "Testing system_info role" - "Target: {{ ansible_fqdn }}" - "Stats directory: {{ system_info_stats_base_dir }}" roles: - role: ../../system_info post_tasks: - name: Verify JSON file was created stat: path: "{{ system_info_stats_base_dir }}/{{ ansible_fqdn }}/system_info.json" register: json_file_check delegate_to: localhost become: false - name: Verify summary file was created stat: path: "{{ system_info_stats_base_dir }}/{{ ansible_fqdn }}/summary.txt" register: summary_file_check delegate_to: localhost become: false - name: Display test results debug: msg: - "=== Test Results ===" - "JSON file created: {{ json_file_check.stat.exists }}" - "Summary file created: {{ summary_file_check.stat.exists }}" - "Test {{ 'PASSED' if (json_file_check.stat.exists and summary_file_check.stat.exists) else 'FAILED' }}" - name: Assert test passed assert: that: - json_file_check.stat.exists - summary_file_check.stat.exists success_msg: "All tests passed successfully" fail_msg: "Test failed - files were not created"