--- # tasks file for linux_update - name: Update apt-get repo and cache apt: update_cache: true force_apt_get: true cache_valid_time: 3600 - name: Upgrade all apt packages apt: upgrade: safe force_apt_get: yes #clean: true autoremove: true retries: 3 delay: 3 - name: Check if a reboot is needed for Debian and Ubuntu boxes register: reboot_required_file stat: path=/var/run/reboot-required get_md5=no retries: 3 delay: 3 # - name: Reboot the Debian or Ubuntu server # reboot: # msg: "Reboot initiated by Ansible due to kernel updates" # connect_timeout: 5 # reboot_timeout: 300 # pre_reboot_delay: 0 # post_reboot_delay: 30 # test_command: uptime # when: reboot_required_file.stat.exists