-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathupdateAllPackages.yml
More file actions
42 lines (34 loc) · 968 Bytes
/
updateAllPackages.yml
File metadata and controls
42 lines (34 loc) · 968 Bytes
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
38
39
40
41
42
- hosts:
- service
- rsync
- jumphost
become: true
become_user: root
tasks:
- name: Update apt repo and cache on all Debian/Ubuntu boxes
apt: update_cache=yes force_apt_get=yes cache_valid_time=3600
- name: Install unattended-upgrades
apt:
name:
- unattended-upgrades
state: present
- name: Upgrade all packages on servers
apt: upgrade=dist force_apt_get=yes
- name: Check if a reboot is needed on all servers
stat: path=/var/run/reboot-required get_checksum=no
register: reboot_required_file
- hosts:
- service
- rsync
become: true
become_user: root
tasks:
- name: Reboot the box if kernel updated
reboot:
msg: "Reboot initiated by Ansible for kernel updates"
connect_timeout: 5
reboot_timeout: 300
pre_reboot_delay: 0
post_reboot_delay: 30
test_command: uptime
when: reboot_required_file.stat.exists