Why Nostr? What is Njump?
2024-06-29 18:38:18

Larvitz :fedora: :redhat: on Nostr: Fully automated the patching of my linux servers with #Ansible using a workflow. The ...

Fully automated the patching of my linux servers with #Ansible using a workflow. The Job runs scheduled every day:

- Publishing a new Content-View version on Satellite and promoting it
- Patching all inventory hosts to the latest state
- Rebooting systems, if necessary

Ansible Playbook to patch systems:

- name: Patch all systems and reboot if required
hosts: "{{ host }}"
gather_facts: true
become: true

tasks:
- name: Ensure all updates are applied
ansible.builtin.package:
update_cache: true
name: "*"
state: latest
update_only: true

- name: Check to see if update is required
ansible.builtin.command: dnf needs-restarting -r
register: result
changed_when: false
failed_when: result.rc not in [0, 1]
ignore_errors: true

- name: Reboot server if needed
ansible.builtin.reboot:
when: result.rc | int == 1

#linux #maintanance #patch #ansible #rhel #sysadmin #homelab

Author Public Key
npub1fj6u59lnses9xu6xa6ewugrfg2e639lg32r24383525xq3deyuaspjaq90