From e675fe20abde4db5f5764ed52c0ddc0674533b21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Sat, 31 Dec 2022 17:11:33 +0100 Subject: Reworte syncthing. --- manifests/syncthing.pp | 132 ++++++++++++------------------------------------- 1 file changed, 31 insertions(+), 101 deletions(-) (limited to 'manifests/syncthing.pp') diff --git a/manifests/syncthing.pp b/manifests/syncthing.pp index e31449a..389590c 100644 --- a/manifests/syncthing.pp +++ b/manifests/syncthing.pp @@ -1,7 +1,9 @@ +# Sets up a syncthing node, available to the net. +# Doesn't configure reverse proxies or firewalls. +# Also doesn't manage devices or folders in the instance. Those are +# currently seen as program state class profiles::syncthing ( - $data, Array[String] $enable_for = [], - Array[String] $augrules = [], ) { class { 'syncthing': @@ -10,8 +12,8 @@ class profiles::syncthing ( systemd::dropin_file { 'nospam.conf': - ensure => absent, - unit => 'syncthing@.service', + ensure => absent, + unit => 'syncthing@.service', content => @(EOF) [Service] ExecStart= @@ -21,107 +23,35 @@ class profiles::syncthing ( $enable_for.map |$user| { - user { $user: - home => "/home/${user}", - managehome => true, - } - - - $hp = "/home/${user}/.config/syncthing" + # TODO create deferred function returning passwd entries + # {{{ruby + # require 'etc' + # Etc.getpwnam('hugo') + # }}} + # {{{ + # => # + # }}} + $home = "/home/${user}" + + $conf_dir = "/home/${user}/.config/syncthing" syncthing::instance { $user: - home_path => $hp, - daemon_uid => $user, - } - - $data['devices'].each |$name, $d| { - syncthing::device { $name: - home_path => $hp, - instance_name => $user, - id => $d['id'], - } - } - - $data['folders'].each |$name, $d| { - syncthing::folder { $name: - home_path => $hp, - instance_name => $user, - id => $d['id'], - path => $d['path'], - devices => $d['devices'].map |$name| { [ $data['devices'][$name]['id'], 'present' ] }.hash + home_path => $conf_dir, + daemon_uid => $user, + gui => true, + gui_tls => false, + gui_address => '[::]', + # TODO ldap + gui_port => 8384, + options => { + 'startBrowser' => 'false', } + # defaults } - # $dir = "/home/${user}/.config/syncthing" - # file { "/home/${user}/.config": - # ensure => directory, - # owner => $user, - # group => $user, - # } - # exec { "/usr/bin/syncthing -generate='${dir}'": - # user => $user, - # creates => $dir, - # } - - # # service { "syncthing@${user}": - # # enable => true, - # # } - - # # augeas { 'syncthing_config': - # # # context => "/files/home/${user}.config/syncthing/config.xml/configuration", - # # changes => [ - # # "defvar base /home/${user}/.config/syncthing/", - # # 'set /augeas/load/Xml/incl[1] $base/*.xml', - # # 'load', - # # 'defvar $ctx $base/config.xml/configuration', - # # 'set $ctx/gui/#attribute/enabled false', - # # 'save', - # # 'rm $ctx/folder/', - # # 'set $ctx/folder[0]/#attribute/label Documentns', - # # 'set $ctx/folder[0]/#attribute/path ~/sync/doc', - # # 'set $ctx/folder[0]/#attribute/id rrrr-xxxx', - # # 'set $ctx/folder[0]/#attribute/device[0]/#attribute/id something-really-long', - # # 'save', - # # ], - # # } - - # $device_rules = flatten($data['devices'].map |$name, $d| { - # [ - # "defnode node device[#attribute/name=$name] ''", - # "set \$node/#attribute/name ${name}", - # "set \$node/#attribute/id ${d['id']}", - # ] - # }) - - # $folder_rules = flatten($data['folders'].map |$name, $d| { - # [ - # "defnode node folder[#attribute/label=$name] ''", - # "set \$node/#attribute/label ${name}", - # "set \$node/#attribute/path ${d['path']}", - # "set \$node/#attribute/id ${d['id']}", - # ] + flatten($d['devices'].map |$name| { - # alert($name) - # alert($data['devices'][$name]) - # [ "set \$node/device[0]/#attribute/id ${data['devices'][$name]['id']}", ] - # }) - # }) - - # augeas { 'syncthing-config': - # lens => 'Xml.lns', - # incl => "/home/${user}/.config/syncthing/config.xml", - # context => "/files/home/${user}/.config/syncthing/config.xml/configuration", - # changes => $device_rules + $folder_rules, - # # [ - # # 'rm folder/', - # # 'set folder[0]/#attribute/label Documentsn', - # # 'set folder[0]/#attribute/path ~/sync/doc', - # # # 'set folder[0]/#attribute/id rrrr-xxxx', - # # # 'set folder[0]/#attribute/device[0]/#attribute/id something-really-long', - # # ], - # } + # ensure_packages(['syncthing-gtk-python3']) } - - # # TODO manage synced data - - } -- cgit v1.2.3