Saturday, 12 June 2021

[Updated] Managing apt and pihole updates with ansible

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.

Sunday, 6 June 2021

Three elegant ways to access Synology from Raspberry

We have just come back from a long outstanding holiday in Wales, and we wanted to show the pictures we took on various devices to our friends on the big TV. As we have a Synology NAS nicknamed "tera", we decided to upload pictures on there. The basic infrastructure has been in place as I already had a DHCP reservation on the dnsmasq built into pi-hole for the Synology NAS. 

The first way to access Synology is via its web console: https://tera:5000/, and I use this regularly for management purposes. It provides files services also for upload and download.

The second way is to use Connect to Server... function in the Go menu of File Manager in Raspberry Pi OS. Since I use my Synology NAS as an iperf3 server, I also had the relevant ssh public keys copied over from my dad-pi4g to Synology. All I had to do is to add my private keys for the ssh-agent to use by:

pi@dad-pi4g:~ $ ssh-add .ssh/id_rsa
Identity added: .ssh/id_rsa (pi@dad-pi4g)

Adding this connection created a link in File Manager that shows up permanently every time I open it.

The third way is via Midnight Commander that helps to move multiple files over more easily.