-
-
Save barbietunnie/19a027fa28a67ff1f01688a849fcb664 to your computer and use it in GitHub Desktop.
Ubuntu upgrade with Ansible
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
- hosts: | |
- all | |
become: true | |
tasks: | |
- name: Update apt cache | |
apt: update_cache=yes | |
- name: Upgrade packages | |
apt: upgrade=dist | |
- name: Check if a reboot is required | |
register: reboot_required_file | |
stat: path=/var/run/reboot-required get_md5=no | |
- name: restart machine | |
become: yes | |
shell: sleep 2 && shutdown -r now "Ansible updates triggered" | |
async: 1 | |
poll: 0 | |
ignore_errors: true | |
when: reboot_required_file.stat.exists == true | |
- name: Waiting for server to come back | |
become: no | |
local_action: wait_for | |
port=22 | |
host={{ inventory_hostname }} | |
search_regex=OpenSSH | |
delay=10 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment