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:
WolfyDelta
2026-07-03 15:10:28 -04:00
parent a0e3c4eb52
commit 3c0da17540
+37 -25
View File
@@ -9,14 +9,6 @@
discord_webhook_token: "zdT2wisqhAZuZ_UPKmAmtV0z_rX-PZnyHIXsjpPHQO3uakBO2xQ3R44kOxb9QZ4QxebL" discord_webhook_token: "zdT2wisqhAZuZ_UPKmAmtV0z_rX-PZnyHIXsjpPHQO3uakBO2xQ3R44kOxb9QZ4QxebL"
tasks: 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 - name: Verify target is RedHat family
ansible.builtin.assert: ansible.builtin.assert:
that: that:
@@ -24,28 +16,48 @@
fail_msg: "This playbook is intended for Rocky/RHEL-family systems only." fail_msg: "This playbook is intended for Rocky/RHEL-family systems only."
success_msg: "Target is RedHat family." success_msg: "Target is RedHat family."
- name: Ensure dnf-utils is installed for needs-restarting - name: Refresh DNF metadata
ansible.builtin.dnf: ansible.builtin.raw: |
name: yum-utils dnf -y makecache
state: present
register: dnf_utils_result
- name: Update DNF metadata cache
ansible.builtin.dnf:
update_cache: true
register: dnf_cache_result register: dnf_cache_result
changed_when: false
failed_when: dnf_cache_result.rc != 0
become: true
- name: Upgrade installed packages - name: Check for available updates
ansible.builtin.dnf: ansible.builtin.raw: |
name: "*" dnf check-update
state: latest register: dnf_check_update_result
update_only: true 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 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 - name: Mark package upgrade unchanged when no updates exist
ansible.builtin.dnf: ansible.builtin.set_fact:
autoremove: true 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 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 - name: Check if reboot is required
ansible.builtin.command: ansible.builtin.command: