Add Samba to Core servers, with special shares for HomeAssistant.
authorMatt Birkholz <matt@birchwood-abbey.net>
Tue, 17 Sep 2024 19:55:10 +0000 (13:55 -0600)
committerMatt Birkholz <matt@birchwood-abbey.net>
Tue, 17 Sep 2024 20:04:13 +0000 (14:04 -0600)
README.org
roles_t/abbey-core/handlers/main.yml
roles_t/abbey-core/tasks/main.yml

index 295b58d7932bfbf2d8b467a913139bcbc153ec28..00d5405799dadf7fe846aa745402974b1ee9b97a 100644 (file)
@@ -1508,6 +1508,78 @@ minutes and =cronjob-midnight= at midnight.
     user: monkey
 #+END_SRC
 
+** Install Samba
+
+The abbey core provides NAS (Network Attached Storage) service to the
+cloister network.  It also provides writable shares for a Home
+Assistant appliance (Raspberry Pi).
+
+- Install ~samba~.
+- Create system user ~hass~.
+- Create =/home/hass/{media,backup,share}/= with appropriate
+  permissions.
+
+#+CAPTION: [[file:roles_t/abbey-core/tasks/main.yml][=roles_t/abbey-core/tasks/main.yml=]]
+#+BEGIN_SRC conf :tangle roles_t/abbey-core/tasks/main.yml
+
+- name: Install Samba.
+  become: yes
+  apt: pkg=samba
+
+- name: Add system user hass.
+  become: yes
+  user:
+    name: hass
+    system: yes
+
+- name: Add {{ ansible_user }} to hass group.
+  become: yes
+  user:
+    name: "{{ ansible_user }}"
+    append: yes
+    groups: hass
+
+- name: Configure shares.
+  become: yes
+  blockinfile:
+    block: |
+      [Shared]
+      path = /Shared
+      guest ok = yes
+      read only = yes
+
+      [HASS-backup]
+      comment = Home Assistant backup
+      path = /home/hass/backup
+      valid users = hass
+      read only = no
+
+      [HASS-media]
+      comment = Home Assistant media
+      path = /home/hass/media
+      valid users = hass
+      read only = yes
+
+      [HASS-share]
+      comment = Home Assistant share
+      path = /home/hass/share
+      valid users = hass
+      read only = no
+    dest: /etc/samba/smb.conf
+    marker: "# {mark} ABBEY MANAGED BLOCK"
+  notify: New shares.
+#+END_SRC
+
+#+CAPTION: [[file:roles_t/abbey-core/handlers/main.yml][=roles_t/abbey-core/handlers/main.yml=]]
+#+BEGIN_SRC conf :tangle roles_t/abbey-core/handlers/main.yml
+
+- name: New shares.
+  become: yes
+  systemd:
+    service: smbd
+    state: reloaded
+#+END_SRC
+
 
 * The Abbey Gate Role
 
index 576d5189e671e5bde69768d4821247b7bcf503b9..7db3b398d5f15beb14d1c342571fa73e602bf4dc 100644 (file)
@@ -24,3 +24,9 @@
   systemd:
     service: munin
     state: restarted
+
+- name: New shares.
+  become: yes
+  systemd:
+    service: smbd
+    state: reloaded
index ddd939e0aaeb202671276d3663e06364be2084d1..8930b1a221cfa1c21c5332782f280f802a020ad4 100644 (file)
 - name: Install netpbm.
   become: yes
   apt: pkg=netpbm
+
+- name: Install Samba.
+  become: yes
+  apt: pkg=samba
+
+- name: Add system user hass.
+  become: yes
+  user:
+    name: hass
+    system: yes
+
+- name: Add {{ ansible_user }} to hass group.
+  become: yes
+  user:
+    name: "{{ ansible_user }}"
+    append: yes
+    groups: hass
+
+- name: Configure shares.
+  become: yes
+  blockinfile:
+    block: |
+      [Shared]
+      path = /Shared
+      guest ok = yes
+      read only = yes
+
+      [HASS-backup]
+      comment = Home Assistant backup
+      path = /home/hass/backup
+      valid users = hass
+      read only = no
+
+      [HASS-media]
+      comment = Home Assistant media
+      path = /home/hass/media
+      valid users = hass
+      read only = yes
+
+      [HASS-share]
+      comment = Home Assistant share
+      path = /home/hass/share
+      valid users = hass
+      read only = no
+    dest: /etc/samba/smb.conf
+    marker: "# {mark} ABBEY MANAGED BLOCK"
+  notify: New shares.