diff --git a/README.md b/README.md index b34e100..2c84a01 100644 --- a/README.md +++ b/README.md @@ -4,12 +4,11 @@ This role will check for available package upgrades on the target host. -This role should work on both Ubuntu and CentOS based hosts. - NOTE: The following variable(s) must be specified in the calling playbook (usually done by doing a 'gather_facts' action); * {{ ansible_distribution }} +* {{ ansible_os_family }} diff --git a/tasks/main.yml b/tasks/main.yml index fb83fdd..2c613f5 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -3,8 +3,6 @@ # # This role will check for available package upgrades on the target host. # -# This role should work on both Ubuntu and CentOS based hosts. -# ########################################################################### # # NOTE: @@ -12,6 +10,7 @@ # done by doing a 'gather_facts' action); # # {{ ansible_distribution }} +# {{ ansible_os_family }} # ########################################################################### # tasks file for chk_upgrades @@ -19,35 +18,19 @@ - debug: msg="Checking for package updates" ############################################################ -- name: Checked for updates (Ubuntu) +- name: Checked for updates (Debian based repos) shell: cmd: apt list --upgradable - register: uchkout + register: dchkout when: ansible_os_family == "Debian" -- name: Show output from update check (Ubuntu 1) - debug: msg={{ uchkout.stdout_lines }} - when: uchkout.stdout_lines is defined and ansible_os_family == "Debian" +- name: Show output from update check (deb 1) + debug: msg={{ dchkout.stdout_lines }} + when: dchkout.stdout_lines is defined and ansible_os_family == "Debian" -- name: Show output from update check (Ubuntu 2) - debug: msg={{ uchkout }} - when: uchkout.stdout_lines is undefined and ansible_os_family == "Debian" - -############################################################ -- name: Checked for updates (CentOS) - shell: - cmd: yum check-update --quiet - ignore_errors: true - register: cchkout - when: ansible_distribution == "CentOS" - -- name: Show output from update check (CentOS 1) - debug: msg={{ cchkout.stdout_lines }} - when: cchkout.stdout_lines is defined and ansible_distribution == "CentOS" - -- name: Show output from update check (CentOS 2) - debug: msg={{ cchkout }} - when: cchkout.stdout_lines is undefined and ansible_distribution == "CentOS" +- name: Show output from update check (deb 2) + debug: msg={{ dchkout }} + when: dchkout.stdout_lines is undefined and ansible_os_family == "Debian" ############################################################ - name: Checked for updates (Alpine)