role_upgrade_pkgs/tasks/main.yml

39 lines
1.2 KiB
YAML

---
###########################################################################
#
# This role will apply available package upgrades to the target host.
#
# The 'update_cache' role should be run before running this role.
#
# This role should work for both Ubuntu as well as CentOS based target hosts.
#
###########################################################################
# tasks file for upgrade_pkgs
- debug: msg="Applying package updates"
- name: Upgraded packages (Ubuntu)
apt:
name: "*"
state: latest
when: ansible_distribution == "Ubuntu" or ansible_distribution == "Pop!_OS" or ansible_distribution == "Linux Mint"
- name: Clean up the autoremove packages (Ubuntu)
apt:
autoremove: true
purge: true
when: ansible_distribution == "Ubuntu" or ansible_distribution == "Pop!_OS" or ansible_distribution == "Linux Mint"
- name: Clean up any packages left in the 'rc' state (Ubuntu)
shell:
cmd: /usr/bin/apt -y --purge remove $(dpkg -l | grep "^rc " | sed 's/ \+/ /g' | cut -d ' ' -f2)
when: ansible_distribution == "Ubuntu" or ansible_distribution == "Pop!_OS" or ansible_distribution == "Linux Mint"
- name: Upgraded packages (CentOS)
yum:
name: "*"
state: latest
when: ansible_distribution == "CentOS"
# EOF