From a28a22722d6ec41c0f8c425a4ae286b501d604ee Mon Sep 17 00:00:00 2001 From: Radar231 Date: Thu, 22 Jul 2021 23:14:57 -0400 Subject: [PATCH] initial checkin --- README.md | 10 ++++++++++ tasks/main.yml | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 README.md create mode 100644 tasks/main.yml diff --git a/README.md b/README.md new file mode 100644 index 0000000..133e2c2 --- /dev/null +++ b/README.md @@ -0,0 +1,10 @@ +# Ansible Role: upgrade_pkgs + +## Introduction + +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. + diff --git a/tasks/main.yml b/tasks/main.yml new file mode 100644 index 0000000..a6bdc29 --- /dev/null +++ b/tasks/main.yml @@ -0,0 +1,38 @@ +--- +########################################################################### +# +# 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" + +- name: Clean up the autoremove packages (Ubuntu) + apt: + autoremove: true + purge: true + when: ansible_distribution == "Ubuntu" or ansible_distribution == "Pop!_OS" + +- 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" + +- name: Upgraded packages (CentOS) + yum: + name: "*" + state: latest + when: ansible_distribution == "CentOS" + +# EOF