Updates_with_reporting.yaml 639 B

1234567891011121314151617181920212223242526
  1. ---
  2. - hosts: all
  3. gather_facts: yes
  4. become: yes
  5. tasks:
  6. - name: Perform a dist-upgrade.
  7. ansible.builtin.apt:
  8. update_cache: yes
  9. upgrade: dist
  10. register: apt_result
  11. ignore_errors: yes
  12. - name: Check if a reboot is required.
  13. ansible.builtin.stat:
  14. path: /var/run/reboot-required
  15. get_md5: no
  16. register: reboot_required_file
  17. - name: Reboot the server (if required).
  18. ansible.builtin.reboot:
  19. when: reboot_required_file.stat.exists == true
  20. - name: Remove dependencies that are no longer required.
  21. ansible.builtin.apt:
  22. autoremove: yes