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
Published at
2024-06-29 18:38:18Event JSON
{
"id": "ad2dbd52a5526d51027c5a83380878e5091fc0b26e47b7bc02783f7015e99e22",
"pubkey": "4cb5ca17f38660537346eeb2ee206942b3a897e88a86aac4f1a2a86045b9273b",
"created_at": 1719686298,
"kind": 1,
"tags": [
[
"t",
"ansible"
],
[
"t",
"rhel"
],
[
"t",
"patch"
],
[
"t",
"homelab"
],
[
"t",
"maintanance"
],
[
"t",
"linux"
],
[
"imeta",
"url https://media.burningboard.net/media_attachments/files/112/701/325/620/219/387/original/84fcf340b9724550.png",
"m image/png"
],
[
"t",
"sysadmin"
],
[
"proxy",
"https://burningboard.net/@Larvitz/112701361243976949",
"web"
],
[
"proxy",
"https://burningboard.net/users/Larvitz/statuses/112701361243976949",
"activitypub"
],
[
"L",
"pink.momostr"
],
[
"l",
"pink.momostr.activitypub:https://burningboard.net/users/Larvitz/statuses/112701361243976949",
"pink.momostr"
],
[
"expiration",
"1722278305"
]
],
"content": "Fully automated the patching of my linux servers with #Ansible using a workflow. The Job runs scheduled every day:\n\n- Publishing a new Content-View version on Satellite and promoting it\n- Patching all inventory hosts to the latest state\n- Rebooting systems, if necessary\n\nAnsible Playbook to patch systems:\n\n- name: Patch all systems and reboot if required\n hosts: \"{{ host }}\"\n gather_facts: true\n become: true\n\n tasks:\n - name: Ensure all updates are applied\n ansible.builtin.package:\n update_cache: true\n name: \"*\"\n state: latest\n update_only: true\n\n - name: Check to see if update is required\n ansible.builtin.command: dnf needs-restarting -r\n register: result\n changed_when: false\n failed_when: result.rc not in [0, 1]\n ignore_errors: true\n\n - name: Reboot server if needed\n ansible.builtin.reboot:\n when: result.rc | int == 1\n\n#linux #maintanance #patch #ansible #rhel #sysadmin #homelab\nhttps://media.burningboard.net/media_attachments/files/112/701/325/620/219/387/original/84fcf340b9724550.png\n",
"sig": "f691abe92c53e3f8cf9d88854af9a025745844bf2afe4b04ad2818c2d09f593508fa7aa223cb02b88d07a8ddb6f1b0f302fe3717c678196415e8a15ff9255da5"
}