Commit | Line | Data |
---|---|---|
3ea0152b MJ |
1 | --- |
2 | - name: Dist upgrade and optionnal reboot | |
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: | |
15 | - name: apt-get update | |
16 | apt: update_cache=yes cache_valid_time=3600 | |
17 | ||
18 | - name: apt-get dist-upgrade | |
19 | apt: upgrade=dist | |
20 | ||
21 | - name: apt-get autoremove | |
22 | command: apt-get -y --purge autoremove | |
23 | register: autoremove_output | |
24 | changed_when: "'The following packages will be REMOVED' in autoremove_output.stdout" | |
25 | ||
26 | - name: reboot server | |
27 | command: /sbin/reboot | |
28 | async: 0 | |
29 | poll: 0 | |
30 | ignore_errors: true | |
31 | when: reboot == "yes" | |
32 | register: last_result | |
33 | ||
34 | - name: wait for the server to reboot | |
35 | local_action: wait_for host={{ inventory_hostname }} | |
36 | port=22 | |
37 | delay=1 | |
38 | timeout=300 | |
39 | state=started | |
40 | when: last_result.changed | |
41 | sudo: false |