-
Notifications
You must be signed in to change notification settings - Fork 0
/
upgrade.yml
37 lines (36 loc) · 940 Bytes
/
upgrade.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
---
- name: Upgrade the hosts
hosts: upgradeable
gather_facts: no
become: yes
vars_prompt:
- name: "upgrade"
prompt: "Do you want to also run the upgrade? [Y,n]"
default: "y"
private: no
tasks:
- name: update apt cache if needed and autoremove packages
apt:
update_cache: yes
cache_valid_time: 14400 # apt-get update only if old than 4 hours
autoremove: yes
- name: install aptitude
apt:
name: "{{ item }}"
state: present
with_items:
- aptitude
- name: show apt-get upgrade
command: "apt-get --just-print upgrade"
args:
warn: no
changed_when: false
register: output
- debug:
var: output.stdout_lines
when: "output.stdout != 'None'"
- name: do safe-upgrade
apt:
upgrade: safe
register: aptout
when: "output.stdout != 'None' and upgrade in ('y','Y')"