I have a couple of Raspberry Pi to keep apt and pihole updated.
pi@dad-pi4g:~ $ sudo apt install ansible
pi@dad-pi4g:~ $ sudo nano /etc/ansible/hosts
[pi]
pi0
pi0w
pi1b
pi4b2
dad-pi4g
pi@dad-pi4g:~ $ nano apt.yml
---
- hosts: pi
tasks:
- become: yes
apt:
force_apt_get: yes
update_cache: yes
name: "*"
state: latest
- hosts: pi1b
tasks:
- name: update pihole
command: "pihole -up"
pi@dad-pi4g:~ $ ansible-playbook apt.yml
pi@dad-pi4g:~ $ ansible-playbook apt.yml
PLAY [pi] ************************************************************************************************************************************************************************************
TASK [Gathering Facts] ***********************************************************************************************************************************************************************
ok: [dad-pi4g]
ok: [pi4b2]
ok: [pi0w]
ok: [pi1b]
ok: [pi0]
TASK [apt] ***********************************************************************************************************************************************************************************
ok: [dad-pi4g]
ok: [pi4b2]
ok: [pi0w]
ok: [pi1b]
ok: [pi0]
PLAY [pi1b] **********************************************************************************************************************************************************************************
TASK [Gathering Facts] ***********************************************************************************************************************************************************************
ok: [pi1b]
TASK [update pihole] *************************************************************************************************************************************************************************
changed: [pi1b]
PLAY RECAP ***********************************************************************************************************************************************************************************
dad-pi4g : ok=2 changed=0 unreachable=0 failed=0
pi0 : ok=2 changed=0 unreachable=0 failed=0
pi0w : ok=2 changed=0 unreachable=0 failed=0
pi1b : ok=4 changed=1 unreachable=0 failed=0
pi4b2 : ok=2 changed=0 unreachable=0 failed=0
UPDATE
To keep track of changes I created my first git repository for this project :)
https://github.com/jordanarpad/ansible-update
UPDATE 2
As moving from Chromium OS to Raspberry Pi OS on my pi4g there had to be some changes made to git repository. I have used git add and git commit before git push to update the repository. I had to create a personal access token for the later.
No comments:
Post a Comment