changeset 14:ac4d24d01b68

add syncthing service
author drewp@bigasterisk.com
date Sat, 13 Nov 2021 12:13:39 -0800
parents d0ca4e569009
children 516a91a3ec08
files sync.py tasks.py
diffstat 2 files changed, 22 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sync.py	Sat Nov 13 12:13:39 2021 -0800
@@ -0,0 +1,18 @@
+from pyinfra import host
+from pyinfra.facts.server import LinuxDistribution
+from pyinfra.operations import apt, systemd
+
+bang_is_old = True  # remove after upgrade
+is_pi = host.get_fact(LinuxDistribution)['name'] in ['Debian', 'Raspbian GNU/Linux']
+is_wifi_pi = host.name in ['frontdoor', 'living']
+
+# bang instance is in k8s (/my/serv/filesync/syncthing); the rest are run with systemd.
+# Configs are in ~/.config/syncthing/ on each box
+if host.name in ['dash', 'dot', 'slash', 'plus']:
+    apt.packages(packages=['syncthing'])
+
+    # now we have /lib/systemd/system/syncthing@.service
+    user = 'ari' if host.name == 'dot' else 'drewp'
+    systemd.service(service=f'syncthing@{user}', running=True, enabled=True)
+
+    # also consider https://github.com/Martchus/syncthingtray tray status viewer on dtops
--- a/tasks.py	Sat Nov 13 12:13:10 2021 -0800
+++ b/tasks.py	Sat Nov 13 12:13:39 2021 -0800
@@ -46,6 +46,10 @@
     ctx.run(cmd + 'inventory.py kube.py ', pty=True)
 
 
+@task
+def sync(ctx):
+    ctx.run(cmd + 'inventory.py sync.py ', pty=True)
+
 
 @task
 def get_fact(ctx, host='dash', fact='server.LinuxDistribution'):