Commit | Line | Data |
---|---|---|
3ea0152b | 1 | --- |
d0393040 | 2 | - name: "Dist upgrade and optional reboot" |
3ea0152b MJ |
3 | hosts: all |
4 | vars: | |
5 | restart: 'no' | |
6 | reboot_wait: 300 | |
7 | ||
8 | vars_prompt: | |
9 | - name: reboot | |
10 | prompt: "Enter 'yes' to reboot" | |
11 | default: 'no' | |
12 | private: no | |
13 | ||
14 | tasks: | |
d0393040 MJ |
15 | - name: "apt update && apt dist-upgrade && apt clean && apt autoremove --purge" |
16 | ansible.builtin.apt: | |
17 | update_cache: yes | |
18 | cache_valid_time: 3600 | |
19 | upgrade: dist | |
20 | clean: yes | |
21 | autoremove: yes | |
22 | purge: yes | |
3ea0152b | 23 | |
d0393040 | 24 | - name: "Reboot server" |
3ea0152b MJ |
25 | command: /sbin/reboot |
26 | async: 0 | |
27 | poll: 0 | |
28 | ignore_errors: true | |
29 | when: reboot == "yes" | |
30 | register: last_result | |
f56d2ba7 | 31 | |
3ea0152b MJ |
32 | - name: wait for the server to reboot |
33 | local_action: wait_for host={{ inventory_hostname }} | |
34 | port=22 | |
35 | delay=1 | |
36 | timeout=300 | |
37 | state=started | |
38 | when: last_result.changed | |
f56d2ba7 | 39 | become: false |