Updated logging rules based on OS type.
This commit is contained in:
@@ -30,6 +30,11 @@
|
||||
failed_when: upgradable_packages.rc not in [0, 100]
|
||||
when: ansible_os_family == "RedHat"
|
||||
|
||||
- name: Normalize upgradable count (RHEL)
|
||||
ansible.builtin.set_fact:
|
||||
upgradable_count: "{{ dnf_upgradable.stdout_lines | default([]) | length }}"
|
||||
when: os_family in ['rhel', 'centos', 'rocky']
|
||||
|
||||
- name: Get list of upgradable packages (Alpine)
|
||||
ansible.builtin.shell: |
|
||||
apk list --upgradable 2>/dev/null | awk -F'-[0-9]' '{print $1}'
|
||||
@@ -37,9 +42,14 @@
|
||||
changed_when: false
|
||||
when: ansible_os_family == "Alpine"
|
||||
|
||||
- name: Normalize upgradable count (Alpine)
|
||||
ansible.builtin.set_fact:
|
||||
upgradable_count: "{{ apk_upgradable.stdout_lines | default([]) | length }}"
|
||||
when: os_family == 'alpine'
|
||||
|
||||
- name: Log packages to be updated
|
||||
ansible.builtin.debug:
|
||||
msg: "Packages to be updated on {{ inventory_hostname }}: {{ upgradable_packages.stdout_lines | length }} packages"
|
||||
msg: "Packages to be updated on {{ inventory_hostname }}: {{ upgradable_count | default(0) }} packages"
|
||||
|
||||
- name: Perform full upgrade (Debian/Ubuntu)
|
||||
ansible.builtin.apt:
|
||||
@@ -51,6 +61,11 @@
|
||||
- ansible_os_family == "Debian"
|
||||
- patch_mode == "full" or patch_mode == "security"
|
||||
|
||||
- name: Normalize upgradable count (Debian)
|
||||
ansible.builtin.set_fact:
|
||||
upgradable_count: "{{ apt_upgradable.stdout_lines | default([]) | length }}"
|
||||
when: os_family in ['debian', 'ubuntu']
|
||||
|
||||
- name: Perform security-only upgrade (RHEL/CentOS)
|
||||
ansible.builtin.dnf:
|
||||
name: "*"
|
||||
|
||||
Reference in New Issue
Block a user