main.yml 582 B

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