Todo 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. Add reports
  2. #group variables
  3. group_vars:
  4. preprod-group:
  5. report_file: "/path/to/preprod_report.txt"
  6. infrastructure-group:
  7. report_file: "/path/to/infrastructure_report.txt"
  8. production-group:
  9. report_file: "/path/to/production_report.txt"
  10. #playbook
  11. - name: Generate update report
  12. shell: echo "Server: {{ inventory_hostname }} - Update status: {{ update_result.changed | ternary('Success', 'Failure') }}" >> "{{ hostvars[inventory_hostname]['report_file'] }}"
  13. delegate_to: localhost
  14. run_once: true
  15. - name: Generate installation report
  16. shell: echo "Server: {{ inventory_hostname }} - Installation status: {{ install_result.changed | ternary('Success', 'Failure') }}" >> "{{ hostvars[inventory_hostname]['report_file'] }}"
  17. delegate_to: localhost
  18. run_once: true
  19. Email reports
  20. #playbook
  21. - name: Email report files
  22. command: "echo | mail -s 'Server Update Report' -a {{ hostvars[inventory_hostname]['report_file'] }} your-email@example.com"
  23. delegate_to: localhost
  24. run_once: true
  25. #reporting
  26. Patching started
  27. list time and date
  28. List machines that patches where installed