modified update-rocky-prod.yml to use ansible-builtin.raw instead of the dnf module due to python version incompatibility between rocky 8 and the current ansible version
This commit is contained in:
@@ -9,14 +9,6 @@
|
||||
discord_webhook_token: "zdT2wisqhAZuZ_UPKmAmtV0z_rX-PZnyHIXsjpPHQO3uakBO2xQ3R44kOxb9QZ4QxebL"
|
||||
|
||||
tasks:
|
||||
- name: Show interpreter variables for this run
|
||||
ansible.builtin.debug:
|
||||
msg:
|
||||
inventory_hostname: "{{ inventory_hostname }}"
|
||||
ansible_host: "{{ ansible_host | default('UNDEFINED') }}"
|
||||
ansible_python_interpreter: "{{ ansible_python_interpreter | default('UNDEFINED') }}"
|
||||
discovered_interpreter_python: "{{ ansible_facts.discovered_interpreter_python | default('UNDEFINED') }}"
|
||||
|
||||
- name: Verify target is RedHat family
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
@@ -24,29 +16,49 @@
|
||||
fail_msg: "This playbook is intended for Rocky/RHEL-family systems only."
|
||||
success_msg: "Target is RedHat family."
|
||||
|
||||
- name: Ensure dnf-utils is installed for needs-restarting
|
||||
ansible.builtin.dnf:
|
||||
name: yum-utils
|
||||
state: present
|
||||
register: dnf_utils_result
|
||||
|
||||
- name: Update DNF metadata cache
|
||||
ansible.builtin.dnf:
|
||||
update_cache: true
|
||||
- name: Refresh DNF metadata
|
||||
ansible.builtin.raw: |
|
||||
dnf -y makecache
|
||||
register: dnf_cache_result
|
||||
changed_when: false
|
||||
failed_when: dnf_cache_result.rc != 0
|
||||
become: true
|
||||
|
||||
- name: Upgrade installed packages
|
||||
ansible.builtin.dnf:
|
||||
name: "*"
|
||||
state: latest
|
||||
update_only: true
|
||||
- name: Check for available updates
|
||||
ansible.builtin.raw: |
|
||||
dnf check-update
|
||||
register: dnf_check_update_result
|
||||
changed_when: false
|
||||
failed_when: dnf_check_update_result.rc not in [0, 100]
|
||||
become: true
|
||||
|
||||
- name: Upgrade packages
|
||||
ansible.builtin.raw: |
|
||||
dnf -y upgrade
|
||||
register: dnf_upgrade_result
|
||||
changed_when: dnf_check_update_result.rc == 100
|
||||
failed_when: dnf_upgrade_result.rc != 0
|
||||
become: true
|
||||
when: dnf_check_update_result.rc == 100
|
||||
|
||||
- name: Remove unneeded packages
|
||||
ansible.builtin.dnf:
|
||||
autoremove: true
|
||||
- name: Mark package upgrade unchanged when no updates exist
|
||||
ansible.builtin.set_fact:
|
||||
dnf_upgrade_result:
|
||||
changed: false
|
||||
rc: 0
|
||||
stdout: "No package updates available"
|
||||
when: dnf_check_update_result.rc == 0
|
||||
|
||||
- name: Autoremove unused packages
|
||||
ansible.builtin.raw: |
|
||||
dnf -y autoremove
|
||||
register: dnf_autoremove_result
|
||||
|
||||
changed_when: >
|
||||
'Removed:' in dnf_autoremove_result.stdout or
|
||||
'Removing' in dnf_autoremove_result.stdout
|
||||
failed_when: dnf_autoremove_result.rc != 0
|
||||
become: true
|
||||
|
||||
- name: Check if reboot is required
|
||||
ansible.builtin.command:
|
||||
cmd: needs-restarting -r
|
||||
|
||||
Reference in New Issue
Block a user