Commit | Line | Data |
---|---|---|
3ea0152b | 1 | --- |
8027d150 | 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: | |
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 | ||
f56d2ba7 | 21 | - name: apt-get autoremove |
8027d150 KS |
22 | command: |
23 | cmd: apt-get -y --purge autoremove | |
24 | warn: false | |
3ea0152b MJ |
25 | register: autoremove_output |
26 | changed_when: "'The following packages will be REMOVED' in autoremove_output.stdout" | |
27 | ||
28 | - name: reboot server | |
29 | command: /sbin/reboot | |
30 | async: 0 | |
31 | poll: 0 | |
32 | ignore_errors: true | |
33 | when: reboot == "yes" | |
34 | register: last_result | |
f56d2ba7 | 35 | |
3ea0152b MJ |
36 | - name: wait for the server to reboot |
37 | local_action: wait_for host={{ inventory_hostname }} | |
38 | port=22 | |
39 | delay=1 | |
40 | timeout=300 | |
41 | state=started | |
42 | when: last_result.changed | |
f56d2ba7 | 43 | become: false |