Updating My Home Lab using Ansible
September 26, 2023 —
Gregg Szumowski
I have a variety of Raspberry Pis that I use for various tasks like my Tiny-Tiny RSS server, Gitea server, and Calibre server among other things. In order to keep them updated I use Ansible.
My update script is fairly simple:
$ cat update-pis.sh
#!/bin/bash
ansible-playbook ./playbooks/apt.yml --user memyselfandi \
--ask-pass --ask-become-pass -i ./inventory/hosts $@
The YAML playbook is likewise very simple:
$ cat ./playbooks/apt.yml
- hosts: "*"
become: yes
tasks:
- name: Update System Package Cache (apt)
apt:
update_cache: yes
upgrade: 'yes'
- name: Upgrade System Packages (apt)
apt: upgrade=full
- name: Remove unused dependencies
apt: autoremove=true
- name: Check if reboot is required
shell: "[ -f /var/run/reboot-required ]"
failed_when: False
register: reboot_required
changed_when: reboot_required.rc == 0
notify: reboot
handlers:
- name: reboot
command: /sbin/reboot
Although I can run this in a cronjob, I tend to run it manually (for now). I’m thinking about doing some major revisions to my Pi configuration anyway. Stay tuned for more on that subject.