annotate sync.py @ 14:ac4d24d01b68

add syncthing service
author drewp@bigasterisk.com
date Sat, 13 Nov 2021 12:13:39 -0800
parents
children 67fc0d4b1859
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
14
ac4d24d01b68 add syncthing service
drewp@bigasterisk.com
parents:
diff changeset
1 from pyinfra import host
ac4d24d01b68 add syncthing service
drewp@bigasterisk.com
parents:
diff changeset
2 from pyinfra.facts.server import LinuxDistribution
ac4d24d01b68 add syncthing service
drewp@bigasterisk.com
parents:
diff changeset
3 from pyinfra.operations import apt, systemd
ac4d24d01b68 add syncthing service
drewp@bigasterisk.com
parents:
diff changeset
4
ac4d24d01b68 add syncthing service
drewp@bigasterisk.com
parents:
diff changeset
5 bang_is_old = True # remove after upgrade
ac4d24d01b68 add syncthing service
drewp@bigasterisk.com
parents:
diff changeset
6 is_pi = host.get_fact(LinuxDistribution)['name'] in ['Debian', 'Raspbian GNU/Linux']
ac4d24d01b68 add syncthing service
drewp@bigasterisk.com
parents:
diff changeset
7 is_wifi_pi = host.name in ['frontdoor', 'living']
ac4d24d01b68 add syncthing service
drewp@bigasterisk.com
parents:
diff changeset
8
ac4d24d01b68 add syncthing service
drewp@bigasterisk.com
parents:
diff changeset
9 # bang instance is in k8s (/my/serv/filesync/syncthing); the rest are run with systemd.
ac4d24d01b68 add syncthing service
drewp@bigasterisk.com
parents:
diff changeset
10 # Configs are in ~/.config/syncthing/ on each box
ac4d24d01b68 add syncthing service
drewp@bigasterisk.com
parents:
diff changeset
11 if host.name in ['dash', 'dot', 'slash', 'plus']:
ac4d24d01b68 add syncthing service
drewp@bigasterisk.com
parents:
diff changeset
12 apt.packages(packages=['syncthing'])
ac4d24d01b68 add syncthing service
drewp@bigasterisk.com
parents:
diff changeset
13
ac4d24d01b68 add syncthing service
drewp@bigasterisk.com
parents:
diff changeset
14 # now we have /lib/systemd/system/syncthing@.service
ac4d24d01b68 add syncthing service
drewp@bigasterisk.com
parents:
diff changeset
15 user = 'ari' if host.name == 'dot' else 'drewp'
ac4d24d01b68 add syncthing service
drewp@bigasterisk.com
parents:
diff changeset
16 systemd.service(service=f'syncthing@{user}', running=True, enabled=True)
ac4d24d01b68 add syncthing service
drewp@bigasterisk.com
parents:
diff changeset
17
ac4d24d01b68 add syncthing service
drewp@bigasterisk.com
parents:
diff changeset
18 # also consider https://github.com/Martchus/syncthingtray tray status viewer on dtops