-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate_packages.yml
41 lines (36 loc) · 940 Bytes
/
update_packages.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
38
39
40
41
---
- hosts: all
tasks:
- name: Update all installed packages using YUM module
yum:
name: '*'
state: latest
update_cache: yes
update_only: yes
register: yum_update_status
when: ansible_os_family == "RedHat"
- name: Remove packates not needed anymore
yum:
autoremove: yes
when: ansible_os_family == "RedHat"
- name: Reboot when packages were updated
reboot:
when: yum_update_status.changed
- hosts: all
tasks:
- name: Update all installed packages using APT module
apt:
name: '*'
state: latest
update_cache: yes
only_upgrade: yes
register: apt_update_status
when: ansible_os_family == "Debian"
- name: Remove packages not needed anymore
apt:
autoremove: yes
when: ansible_os_family == "Debian"
- name: Reboot when packages were updated
reboot:
post_reboot_delay: 60
when: apt_update_status.changed