From 3772007c10963175dfa0acba24a5753073e50cd2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Mon, 24 Jan 2022 23:39:46 +0100 Subject: Syncthing rewrites. --- manifests/syncthing.pp | 53 ++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 49 insertions(+), 4 deletions(-) diff --git a/manifests/syncthing.pp b/manifests/syncthing.pp index 7d8183e..9580905 100644 --- a/manifests/syncthing.pp +++ b/manifests/syncthing.pp @@ -1,13 +1,33 @@ class profiles::syncthing ( - Array[String] $enable_for = [] + $data, + Array[String] $enable_for = [], ) { - # TODO add repo for those systems that need it + case $facts['osfamily'] { + 'Debian': { + file { '/etc/apt/trusted.gpg.d/syncthing.gpg': + ensure => file, + source => 'https://syncthing.net/release-key.gpg', + checksum => 'sha256', + checksum_value => 'a3806c3511f2cce3d2f12962f64b58b9192a15c9d862886cc46f9de8a25d7dbf', + } + + ensure_resource(exec, { 'apt update' => { refreshonly => true }}) + + file { '/etc/apt/sources.list.d/syncthing.list': + content => "deb https://apt.syncthing.net/ syncthing stable\n", + # TODO more general way to add apt repos + notify => Exec['apt update'], + before => Package['syncthing'] + } + } + } package { 'syncthing': ensure => installed } + systemd::dropin_file { 'nospam.conf': unit => 'syncthing@.service', content => @(EOF) @@ -18,11 +38,36 @@ class profiles::syncthing ( } $enable_for.map |$user| { - service { "syncthing@${user}": - enable => true, + + user { $user: + home => "/home/${user}", + managehome => true, + } + + $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 => [ + 'set gui/#attribute/enabled false', + ], } } # TODO manage synced data + } -- cgit v1.2.3