diff --git a/handlers.yml b/handlers.yml
index 23ae9bb..5b24c95 100644
--- a/handlers.yml
+++ b/handlers.yml
@@ -22,10 +22,10 @@
daemon-reload: true
scope: user
-- name: start syncthing
+- name: restart syncthing
systemd:
name: syncthing
- state: started
+ state: restarted
enabled: true
scope: user
diff --git a/playbook.yml b/playbook.yml
index 155fbe1..ea30c97 100644
--- a/playbook.yml
+++ b/playbook.yml
@@ -6,33 +6,9 @@
community.general.pacman:
name: '{{ packages }}'
- - name: Platform vars
+ - name: Detect platform
+ ansible.builtin.import_tasks: 'tasks/platform.yml'
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/platform.yml b/tasks/platform.yml
index bad51f3..66e96cd 100644
--- a/tasks/platform.yml
+++ b/tasks/platform.yml
@@ -14,11 +14,9 @@
when: is_laptop.rc == 0
- name: Load desktop specific vars
- ansible.builtin.include_vars:
- dir: vars/desktop
+ ansible.builtin.include_vars: 'vars/desktop.yml'
when: platform == "desktop"
- name: Load laptop specific vars
- ansible.builtin.include_vars:
- dir: vars/laptop
+ ansible.builtin.include_vars: 'vars/laptop.yml'
when: platform == "laptop"
diff --git a/tasks/syncthing.yml b/tasks/syncthing.yml
index 3c36b5e..5e9b5bc 100644
--- a/tasks/syncthing.yml
+++ b/tasks/syncthing.yml
@@ -1,18 +1,14 @@
-- name: Create configuration dir
- ansible.builtin.file:
+- name: create configuration dir
+ file:
path: '{{ xdg_config_dir }}/syncthing'
state: directory
- mode: '0755'
-- name: Stop syncthing service
- ansible.builtin.systemd:
- name: syncthing
- scope: user
- state: stopped
-
-- name: Copy configuration file
- ansible.builtin.template:
- src: 'templates/syncthing.j2'
+# 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'
dest: '{{ xdg_config_dir }}/syncthing/config.xml'
- mode: '0640'
- notify: start syncthing
+ mode: '0600'
+ force: false
+ notify: restart syncthing
diff --git a/templates/desktop/syncthing.j2 b/templates/desktop/syncthing.j2
new file mode 100644
index 0000000..f4f290f
--- /dev/null
+++ b/templates/desktop/syncthing.j2
@@ -0,0 +1,132 @@
+
+
+ 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
new file mode 100644
index 0000000..4112f18
--- /dev/null
+++ b/templates/laptop/syncthing.j2
@@ -0,0 +1,132 @@
+
+
+ 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
deleted file mode 100644
index c48c0d8..0000000
--- a/templates/syncthing.j2
+++ /dev/null
@@ -1,152 +0,0 @@
-
-
-
- {% 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/vpn.yml b/vars/desktop.yml
similarity index 65%
rename from vars/desktop/vpn.yml
rename to vars/desktop.yml
index 51fb9e4..6a22f27 100644
--- a/vars/desktop/vpn.yml
+++ b/vars/desktop.yml
@@ -1,3 +1,23 @@
+platform_packages: []
+
+modprobe_templates:
+ - src: 'templates/desktop/modprobe/99-amdgpu.conf.j2'
+ dest: '/etc/modprobe.d/99-amdgpu.conf'
+
+mkinitcpio_templates:
+ - src: 'templates/desktop/mkinitcpio/1-modules.conf.j2'
+ dest: '/etc/mkinitcpio.conf.d/1-amdgpu.conf'
+
+ - src: 'templates/desktop/mkinitcpio/linux.preset.j2'
+ dest: '/etc/mkinitcpio.d/linux.preset'
+
+ - src: 'templates/desktop/mkinitcpio/linux-lts.preset.j2'
+ dest: '/etc/mkinitcpio.d/linux-lts.preset'
+
+boot_configuration:
+ disk: /dev/sdc
+ partition: 1
+
# TODO: scope variables to their destination file
vpn_default:
ip: '10.0.0.3'
@@ -5,20 +25,20 @@ vpn_default:
interface: 'wg0'
dns: '10.0.0.1'
domains:
- - '~vpn.{{ server_domain }}'
- - '~transmission.{{ server_domain }}'
+ - ~vpn.fudiggity.nl
+ - ~transmission.fudiggity.nl
public_key_path: '{{ vpn_config_dir }}/keys/public/default/desktop.pub'
private_key_path: '{{ vpn_config_dir }}/keys/private/default/desktop.key'
peers:
- - name: 'fudiggity'
+ - name: 'zeus'
allowed_ips:
- address: '10.0.0.0/24'
create_route: false
- address: '172.16.238.0/24'
create_route: true
- endpoint: '{{ server_domain }}:51902'
+ endpoint: 'fudiggity.nl: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 +49,7 @@ vpn_media:
interface: 'wg1'
dns: '10.0.1.1'
domains:
- - '~media-vpn.{{ server_domain }}'
+ - ~media-vpn.fudiggity.nl
public_key_path: '{{ vpn_config_dir }}/keys/public/media/desktop.pub'
private_key_path: '{{ vpn_config_dir }}/keys/private/media/desktop.key'
@@ -40,7 +60,7 @@ vpn_media:
allowed_ips:
- address: '10.0.1.0/24'
create_route: false
- endpoint: '{{ server_domain }}.nl:51903'
+ endpoint: 'fudiggity.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/desktop/syncthing.yml b/vars/desktop/syncthing.yml
deleted file mode 100644
index a9f0bc0..0000000
--- a/vars/desktop/syncthing.yml
+++ /dev/null
@@ -1,45 +0,0 @@
-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/system.yml b/vars/desktop/system.yml
deleted file mode 100644
index 61a2959..0000000
--- a/vars/desktop/system.yml
+++ /dev/null
@@ -1,19 +0,0 @@
-platform_packages: []
-
-modprobe_templates:
- - src: 'templates/desktop/modprobe/99-amdgpu.conf.j2'
- dest: '/etc/modprobe.d/99-amdgpu.conf'
-
-mkinitcpio_templates:
- - src: 'templates/desktop/mkinitcpio/1-modules.conf.j2'
- dest: '/etc/mkinitcpio.conf.d/1-amdgpu.conf'
-
- - src: 'templates/desktop/mkinitcpio/linux.preset.j2'
- dest: '/etc/mkinitcpio.d/linux.preset'
-
- - src: 'templates/desktop/mkinitcpio/linux-lts.preset.j2'
- dest: '/etc/mkinitcpio.d/linux-lts.preset'
-
-boot_configuration:
- disk: /dev/sdc
- partition: 1
diff --git a/vars/laptop/vpn.yml b/vars/laptop.yml
similarity index 59%
rename from vars/laptop/vpn.yml
rename to vars/laptop.yml
index 158db4e..cc46761 100644
--- a/vars/laptop/vpn.yml
+++ b/vars/laptop.yml
@@ -1,26 +1,47 @@
+platform_packages:
+ - iwd
+ - nvidia
+ - nvidia-prime
+ - nvidia-utils
+ - lib32-nvidia-utils
+
+boot_configuration:
+ disk: /dev/nvme0n1
+ partition: 1
+
+mkinitcpio_templates:
+ - src: 'templates/laptop/mkinitcpio/1-modules.conf.j2'
+ dest: '/etc/mkinitcpio.conf.d/1-modules.conf'
+
+ - src: 'templates/laptop/mkinitcpio/2-hooks.conf.j2'
+ dest: '/etc/mkinitcpio.conf.d/2-hooks.conf'
+
+ - src: 'templates/laptop/mkinitcpio/linux.preset.j2'
+ dest: '/etc/mkinitcpio.d/linux.preset'
+
+ - src: 'templates/laptop/mkinitcpio/linux-lts.preset.j2'
+ dest: '/etc/mkinitcpio.d/linux-lts.preset'
+
vpn_default:
ip: '10.0.0.2'
prefix: '24'
interface: 'wg0'
dns: '10.0.0.1'
domains:
- - '~vpn.{{ server_domain }}'
- - '~transmission.{{ server_domain }}'
- - '~syncthing.{{ server_domain }}'
+ - ~vpn.fudiggity.nl
+ - ~transmission.fudiggity.nl
public_key_path: '{{ vpn_config_dir }}/keys/public/default/laptop.pub'
private_key_path: '{{ vpn_config_dir }}/keys/private/default/laptop.key'
peers:
- - name: 'fudiggity'
+ - name: 'zeus'
allowed_ips:
- address: '10.0.0.0/24'
create_route: false
- address: '172.16.238.0/24'
create_route: true
- - address: '172.32.238.0/24'
- create_route: true
- endpoint: '{{ server_domain }}:51902'
+ endpoint: 'fudiggity.nl: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'
@@ -31,17 +52,17 @@ vpn_media:
interface: 'wg1'
dns: '10.0.1.1'
domains:
- - '~media-vpn.{{ server_domain }}'
+ - ~media-vpn.fudiggity.nl
public_key_path: '{{ vpn_config_dir }}/keys/public/media/laptop.pub'
private_key_path: '{{ vpn_config_dir }}/keys/private/media/laptop.key'
peers:
- - name: 'fudiggity-media'
+ - name: 'zeus-media'
allowed_ips:
- address: '10.0.1.0/24'
create_route: false
- endpoint: '{{ server_domain }}:51903'
+ endpoint: 'fudiggity.nl: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/laptop/syncthing.yml b/vars/laptop/syncthing.yml
deleted file mode 100644
index a817845..0000000
--- a/vars/laptop/syncthing.yml
+++ /dev/null
@@ -1,45 +0,0 @@
-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/system.yml b/vars/laptop/system.yml
deleted file mode 100644
index be95be8..0000000
--- a/vars/laptop/system.yml
+++ /dev/null
@@ -1,23 +0,0 @@
-platform_packages:
- - iwd
- - nvidia
- - nvidia-prime
- - nvidia-utils
- - lib32-nvidia-utils
-
-boot_configuration:
- disk: /dev/nvme0n1
- partition: 1
-
-mkinitcpio_templates:
- - src: 'templates/laptop/mkinitcpio/1-modules.conf.j2'
- dest: '/etc/mkinitcpio.conf.d/1-modules.conf'
-
- - src: 'templates/laptop/mkinitcpio/2-hooks.conf.j2'
- dest: '/etc/mkinitcpio.conf.d/2-hooks.conf'
-
- - src: 'templates/laptop/mkinitcpio/linux.preset.j2'
- dest: '/etc/mkinitcpio.d/linux.preset'
-
- - src: 'templates/laptop/mkinitcpio/linux-lts.preset.j2'
- dest: '/etc/mkinitcpio.d/linux-lts.preset'
diff --git a/vars/main.yml b/vars/main.yml
index 0bba8b7..4419e81 100644
--- a/vars/main.yml
+++ b/vars/main.yml
@@ -47,5 +47,3 @@ mkinitcpio_templates: []
boot_configuration:
vpn_config_dir: '/etc/wireguard'
-
-server_domain: fudiggity.nl
diff --git a/vars/mpd.yml b/vars/mpd.yml
index 258ec66..fa1b0be 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.{{ server_domain }}'
+mpd_remote_address: 'vpn.fudiggity.nl'
mpd_remote_port: '21000'
mpd_remote_stream_port: '8000' # note that this is not used (yet)