diff --git a/handlers.yml b/handlers.yml
index 5b24c95..23ae9bb 100644
--- a/handlers.yml
+++ b/handlers.yml
@@ -22,10 +22,10 @@
daemon-reload: true
scope: user
-- name: restart syncthing
+- name: start syncthing
systemd:
name: syncthing
- state: restarted
+ state: started
enabled: true
scope: user
diff --git a/playbook.yml b/playbook.yml
index ea30c97..155fbe1 100644
--- a/playbook.yml
+++ b/playbook.yml
@@ -6,9 +6,33 @@
community.general.pacman:
name: '{{ packages }}'
- - name: Detect platform
- ansible.builtin.import_tasks: 'tasks/platform.yml'
+ - name: Platform vars
tags: platform_vars
+ block:
+ - name: Detect platform
+ ansible.builtin.command: laptop-detect
+ register: is_laptop
+ failed_when: is_laptop.rc == 2
+
+ - name: Set platform (desktop)
+ ansible.builtin.set_fact:
+ platform: desktop
+ when: is_laptop.rc == 1
+
+ - name: Set platform (laptop)
+ ansible.builtin.set_fact:
+ platform: laptop
+ when: is_laptop.rc == 0
+
+ - name: Load desktop specific vars
+ ansible.builtin.include_vars:
+ dir: vars/desktop
+ when: platform == 'desktop'
+
+ - name: Load laptop specific vars
+ ansible.builtin.include_vars:
+ dir: vars/laptop
+ when: platform == 'laptop'
- name: Install platform specific packages
become: true
diff --git a/tasks/syncthing.yml b/tasks/syncthing.yml
index 5e9b5bc..3c36b5e 100644
--- a/tasks/syncthing.yml
+++ b/tasks/syncthing.yml
@@ -1,14 +1,18 @@
-- name: create configuration dir
- file:
+- name: Create configuration dir
+ ansible.builtin.file:
path: '{{ xdg_config_dir }}/syncthing'
state: directory
+ mode: '0755'
-# Syncthing config files should not be overwritten,
-# see https://docs.syncthing.net/users/config.html#config-file-format
-- name: copy configuration file
- template:
- src: 'templates/{{ platform }}/syncthing.j2'
+- name: Stop syncthing service
+ ansible.builtin.systemd:
+ name: syncthing
+ scope: user
+ state: stopped
+
+- name: Copy configuration file
+ ansible.builtin.template:
+ src: 'templates/syncthing.j2'
dest: '{{ xdg_config_dir }}/syncthing/config.xml'
- mode: '0600'
- force: false
- notify: restart syncthing
+ mode: '0640'
+ notify: start syncthing
diff --git a/templates/desktop/syncthing.j2 b/templates/desktop/syncthing.j2
deleted file mode 100644
index f4f290f..0000000
--- a/templates/desktop/syncthing.j2
+++ /dev/null
@@ -1,132 +0,0 @@
-
-
- basic
-
-
- 0
-
- 3600
-
- 0
- 0
- 0
- random
- false
- 0
- 0
- 10
- false
- false
- false
- 25
- .stfolder
- false
- 0
- 0
- false
- standard
- standard
- false
- true
-
-
- basic
-
-
- 0
-
-
- 3600
-
- 0
- 0
- 0
- random
- false
- 0
- 0
- -1
- false
- false
- false
- 25
- .stfolder
- false
- 0
- 0
- false
- standard
- standard
- false
- true
-
-
- dynamic
- false
- false
- 0
- 0
- 0
-
-
- tcp://10.0.0.1:22000
- false
- false
- 0
- 0
- 0
-
-
- 127.0.0.1:8384
- Qo5fAhxR7LnwvJ7eGYr4gigkHm2LrT6y
- dark
-
-
-
- default
- default
- true
- true
- 21027
- [ff12::8384]:21027
- 0
- 0
- 60
- true
- 10
- true
- true
- 60
- 30
- 10
- 3
- 0
- rxdDP3h2
- https://data.syncthing.net/newdata
- false
- 1800
- true
- 12
- false
- 24
- false
- 5
- false
- 1
- https://upgrades.syncthing.net/meta.json
- false
- 10
- authenticationUserAndPassword
- 0
- ~
- true
- 0
- https://crash.syncthing.net/newcrash
- true
- 180
- 20
- default
- auto
- 0
-
-
diff --git a/templates/laptop/syncthing.j2 b/templates/laptop/syncthing.j2
deleted file mode 100644
index 4112f18..0000000
--- a/templates/laptop/syncthing.j2
+++ /dev/null
@@ -1,132 +0,0 @@
-
-
- basic
-
-
- 0
-
- 3600
-
- 0
- 0
- 0
- random
- false
- 0
- 0
- 10
- false
- false
- false
- 25
- .stfolder
- false
- 0
- 0
- false
- standard
- standard
- false
- true
-
-
- basic
-
-
- 0
-
-
- 3600
-
- 0
- 0
- 0
- random
- false
- 0
- 0
- 10
- false
- false
- false
- 25
- .stfolder
- false
- 0
- 0
- false
- standard
- standard
- false
- true
-
-
- tcp://10.0.0.1:22000
- false
- false
- 0
- 0
- 0
-
-
- dynamic
- false
- false
- 0
- 0
- 0
-
-
- 127.0.0.1:8384
- 2y25PxNtQjtDoe6qnDSiWpmSMpJnvoyi
- dark
-
-
-
- default
- default
- true
- true
- 21027
- [ff12::8384]:21027
- 0
- 0
- 60
- true
- 10
- true
- true
- 60
- 30
- 10
- -1
- 0
- A3FvpLVX
- https://data.syncthing.net/newdata
- false
- 1800
- true
- 12
- false
- 24
- false
- 5
- false
- 1
- https://upgrades.syncthing.net/meta.json
- false
- 10
- authenticationUserAndPassword
- 0
- ~
- true
- 0
- https://crash.syncthing.net/newcrash
- true
- 180
- 20
- default
- auto
- 0
-
-
diff --git a/templates/syncthing.j2 b/templates/syncthing.j2
new file mode 100644
index 0000000..c48c0d8
--- /dev/null
+++ b/templates/syncthing.j2
@@ -0,0 +1,152 @@
+
+
+
+ {% for folder in syncthing_folders -%}
+
+
+ {% for id in folder.devices -%}
+
+
+
+ {%- endfor %}
+
+ basic
+ 20
+
+ 3600
+
+ basic
+
+
+ 0
+ 0
+ 0
+ random
+ false
+ 0
+ 0
+ -1
+ false
+ false
+ false
+ 25
+ .stfolder
+ false
+ 0
+ 2
+ false
+ standard
+ standard
+ false
+ false
+ false
+ false
+ false
+ false
+
+ {%- endfor %}
+
+ {% for device in syncthing_devices -%}
+
+ {{ device.address }}
+ false
+ false
+ 0
+ 0
+ 0
+ false
+ 0
+ 0
+
+ {%- endfor %}
+
+
+ {{ syncthing_listen_address }}:{{ syncthing_gui_port }}
+ {{ syncthing_api_key }}
+ default
+ true
+
+
+
+ tcp://{{ syncthing_listen_address }}:{{ syncthing_protocol_port }}
+
+
+
+
+
+ basic
+
+
+
+
+
+ 1
+
+
+ 3600
+
+ basic
+
+
+ 0
+ 0
+ 0
+ random
+ false
+ 0
+ 0
+ 10
+ false
+ false
+ false
+ 25
+ .stfolder
+ false
+ 0
+ 2
+ false
+ standard
+ standard
+ false
+ false
+
+
+
+ dynamic
+ false
+ false
+ 0
+ 0
+ 0
+ false
+ 0
+ 0
+
+
+
+ (?d).DS_Store
+
+
+
diff --git a/vars/desktop/syncthing.yml b/vars/desktop/syncthing.yml
new file mode 100644
index 0000000..a9f0bc0
--- /dev/null
+++ b/vars/desktop/syncthing.yml
@@ -0,0 +1,45 @@
+syncthing_listen_address: '0.0.0.0'
+syncthing_protocol_port: 22000
+syncthing_gui_port: 8384
+
+syncthing_config_version: 37
+syncthing_api_key: !vault |
+ $ANSIBLE_VAULT;1.1;AES256
+ 39643534383666343331666336356662333165633032356532323730316535616363393330376263
+ 6164323430343961646635323739373363623764646361360a666566363736323739313533323562
+ 34653032646230313063613265313836383033353336333461376432363530633632313234323733
+ 6162646332623837370a646537336139336361666336363861353030633136373063333433643435
+ 64666465356566313263376330643664313266646139663433663366316232613562663863366334
+ 3061663839656563353663373135393233653130383735366538
+
+syncthing_devices:
+ - name: Desktop
+ id: &syncthing_desktop_id CSDXP5E-4UBNC36-32EHTPK-L6Y6JVZ-HQHM42R-FJXN2LI-2MTYRFX-3ZZPUQN
+ address: dynamic
+
+ - name: Fudiggity
+ id: &syncthing_server_id ZM5JO5E-UYU6XUI-P25TLIP-TLPQD7J-NSPSYZS-A5OOYST-J62ICAQ-Y2A5YQV
+ address: tcp://syncthing.{{ server_domain }}:22000
+
+ - name: XPS15
+ id: &syncthing_xps_id 2AC4LRC-YIJDWWK-YCOEZLT-4OWWC2E-7VEZQQB-F3AAPZR-HU75FE4-PGWWXQH
+ address: tcp://10.0.0.2:22000
+
+syncthing_folders:
+ - id: default
+ label: Default
+ path: '{{ ansible_env.HOME }}/syncthing/default'
+ type: sendreceive
+ devices:
+ - *syncthing_desktop_id
+ - *syncthing_server_id
+ - *syncthing_xps_id
+
+ - id: pictures
+ label: Pictures
+ path: '{{ ansible_env.HOME }}/syncthing/pictures'
+ type: sendreceive
+ devices:
+ - *syncthing_desktop_id
+ - *syncthing_server_id
+ - *syncthing_xps_id
diff --git a/vars/desktop/vpn.yml b/vars/desktop/vpn.yml
index e5f97d6..51fb9e4 100644
--- a/vars/desktop/vpn.yml
+++ b/vars/desktop/vpn.yml
@@ -5,20 +5,20 @@ vpn_default:
interface: 'wg0'
dns: '10.0.0.1'
domains:
- - ~vpn.fudiggity.nl
- - ~transmission.fudiggity.nl
+ - '~vpn.{{ server_domain }}'
+ - '~transmission.{{ server_domain }}'
public_key_path: '{{ vpn_config_dir }}/keys/public/default/desktop.pub'
private_key_path: '{{ vpn_config_dir }}/keys/private/default/desktop.key'
peers:
- - name: 'zeus'
+ - name: 'fudiggity'
allowed_ips:
- address: '10.0.0.0/24'
create_route: false
- address: '172.16.238.0/24'
create_route: true
- endpoint: 'fudiggity.nl:51902'
+ endpoint: '{{ server_domain }}:51902'
public_key: 'CeybSMpJiicXmndIuhe89Bay3z3PEdYNyAwIFsacBEo='
preshared_key_path: '{{ vpn_config_dir }}/keys/private/default/preshared-zeus.psk'
preshared_key_source_path: 'files/desktop/wireguard/default/preshared.psk'
@@ -29,7 +29,7 @@ vpn_media:
interface: 'wg1'
dns: '10.0.1.1'
domains:
- - ~media-vpn.fudiggity.nl
+ - '~media-vpn.{{ server_domain }}'
public_key_path: '{{ vpn_config_dir }}/keys/public/media/desktop.pub'
private_key_path: '{{ vpn_config_dir }}/keys/private/media/desktop.key'
@@ -40,7 +40,7 @@ vpn_media:
allowed_ips:
- address: '10.0.1.0/24'
create_route: false
- endpoint: 'fudiggity.nl:51903'
+ endpoint: '{{ server_domain }}.nl:51903'
public_key: 'EugKeo63C5N5kz9ShMHtYswO9Qh6mE00MtfLSFmqqjg='
preshared_key_path: '{{ vpn_config_dir }}/keys/private/media/preshared-zeus.psk'
preshared_key_source_path: 'files/desktop/wireguard/media/preshared.psk'
diff --git a/vars/laptop/syncthing.yml b/vars/laptop/syncthing.yml
new file mode 100644
index 0000000..a817845
--- /dev/null
+++ b/vars/laptop/syncthing.yml
@@ -0,0 +1,45 @@
+syncthing_listen_address: '0.0.0.0'
+syncthing_protocol_port: 22000
+syncthing_gui_port: 8384
+
+syncthing_config_version: 37
+syncthing_api_key: !vault |
+ $ANSIBLE_VAULT;1.1;AES256
+ 35346637623066636261633331343438313736356137633466306633613563343630363565643763
+ 6631623461663330633537386539376435356338393537620a666234373932636162653830316339
+ 65336339383630313837323137613137303862613061326131313437316637383637666638313235
+ 6463333235646536620a316163666431323530353330356633393035663933613761313031656561
+ 66333431636134366466373533616438326230323965333763316336393764303737663461363636
+ 3061373832313462623765353130616237343966333332623262
+
+syncthing_devices:
+ - name: Desktop
+ id: &syncthing_desktop_id CSDXP5E-4UBNC36-32EHTPK-L6Y6JVZ-HQHM42R-FJXN2LI-2MTYRFX-3ZZPUQN
+ address: tcp://10.0.0.3:22000
+
+ - name: Fudiggity
+ id: &syncthing_server_id ZM5JO5E-UYU6XUI-P25TLIP-TLPQD7J-NSPSYZS-A5OOYST-J62ICAQ-Y2A5YQV
+ address: tcp://syncthing.{{ server_domain }}:22000
+
+ - name: XPS15
+ id: &syncthing_xps_id 2AC4LRC-YIJDWWK-YCOEZLT-4OWWC2E-7VEZQQB-F3AAPZR-HU75FE4-PGWWXQH
+ address: dynamic
+
+syncthing_folders:
+ - id: default
+ label: Default
+ path: '{{ ansible_env.HOME }}/syncthing/default'
+ type: sendreceive
+ devices:
+ - *syncthing_desktop_id
+ - *syncthing_server_id
+ - *syncthing_xps_id
+
+ - id: pictures
+ label: Pictures
+ path: '{{ ansible_env.HOME }}/syncthing/pictures'
+ type: sendreceive
+ devices:
+ - *syncthing_desktop_id
+ - *syncthing_server_id
+ - *syncthing_xps_id
diff --git a/vars/laptop/vpn.yml b/vars/laptop/vpn.yml
index 44aeccb..158db4e 100644
--- a/vars/laptop/vpn.yml
+++ b/vars/laptop/vpn.yml
@@ -4,20 +4,23 @@ vpn_default:
interface: 'wg0'
dns: '10.0.0.1'
domains:
- - ~vpn.fudiggity.nl
- - ~transmission.fudiggity.nl
+ - '~vpn.{{ server_domain }}'
+ - '~transmission.{{ server_domain }}'
+ - '~syncthing.{{ server_domain }}'
public_key_path: '{{ vpn_config_dir }}/keys/public/default/laptop.pub'
private_key_path: '{{ vpn_config_dir }}/keys/private/default/laptop.key'
peers:
- - name: 'zeus'
+ - name: 'fudiggity'
allowed_ips:
- address: '10.0.0.0/24'
create_route: false
- address: '172.16.238.0/24'
create_route: true
- endpoint: 'fudiggity.nl:51902'
+ - address: '172.32.238.0/24'
+ create_route: true
+ endpoint: '{{ server_domain }}:51902'
public_key: 'CeybSMpJiicXmndIuhe89Bay3z3PEdYNyAwIFsacBEo='
preshared_key_path: '{{ vpn_config_dir }}/keys/private/default/preshared-zeus.psk'
preshared_key_source_path: 'files/laptop/wireguard/default/preshared.psk'
@@ -28,17 +31,17 @@ vpn_media:
interface: 'wg1'
dns: '10.0.1.1'
domains:
- - ~media-vpn.fudiggity.nl
+ - '~media-vpn.{{ server_domain }}'
public_key_path: '{{ vpn_config_dir }}/keys/public/media/laptop.pub'
private_key_path: '{{ vpn_config_dir }}/keys/private/media/laptop.key'
peers:
- - name: 'zeus-media'
+ - name: 'fudiggity-media'
allowed_ips:
- address: '10.0.1.0/24'
create_route: false
- endpoint: 'fudiggity.nl:51903'
+ endpoint: '{{ server_domain }}:51903'
public_key: 'EugKeo63C5N5kz9ShMHtYswO9Qh6mE00MtfLSFmqqjg='
preshared_key_path: '{{ vpn_config_dir }}/keys/private/media/preshared-zeus.psk'
preshared_key_source_path: 'files/laptop/wireguard/media/preshared.psk'
diff --git a/vars/main.yml b/vars/main.yml
index 4419e81..0bba8b7 100644
--- a/vars/main.yml
+++ b/vars/main.yml
@@ -47,3 +47,5 @@ mkinitcpio_templates: []
boot_configuration:
vpn_config_dir: '/etc/wireguard'
+
+server_domain: fudiggity.nl
diff --git a/vars/mpd.yml b/vars/mpd.yml
index fa1b0be..258ec66 100644
--- a/vars/mpd.yml
+++ b/vars/mpd.yml
@@ -1,7 +1,7 @@
mpd_listen_address: '127.0.0.1'
mpd_listen_port: '6600'
-mpd_remote_address: 'vpn.fudiggity.nl'
+mpd_remote_address: 'vpn.{{ server_domain }}'
mpd_remote_port: '21000'
mpd_remote_stream_port: '8000' # note that this is not used (yet)