summaryrefslogtreecommitdiff
path: root/manifests/syncthing.pp
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2022-01-25 00:28:50 +0100
committerHugo Hörnquist <hugo@lysator.liu.se>2022-02-09 18:06:12 +0100
commitc503180c5100b3c2981b08ddec766fd4b55fec7f (patch)
tree94f192d077dd18ffec5a1d8030d97254b4331c2a /manifests/syncthing.pp
parentSyncthing rewrites. (diff)
downloadprofiles-c503180c5100b3c2981b08ddec766fd4b55fec7f.tar.gz
profiles-c503180c5100b3c2981b08ddec766fd4b55fec7f.tar.xz
Augas test.
Diffstat (limited to 'manifests/syncthing.pp')
-rw-r--r--manifests/syncthing.pp57
1 files changed, 52 insertions, 5 deletions
diff --git a/manifests/syncthing.pp b/manifests/syncthing.pp
index 9580905..0a30851 100644
--- a/manifests/syncthing.pp
+++ b/manifests/syncthing.pp
@@ -1,6 +1,7 @@
class profiles::syncthing (
$data,
Array[String] $enable_for = [],
+ Array[String] $augrules = [],
) {
case $facts['osfamily'] {
@@ -59,11 +60,57 @@ class profiles::syncthing (
# enable => true,
# }
- augeas { 'syncthing_config':
- context => "/files/home/${user}.config/syncthing/config.xml/configuration",
- changes => [
- 'set gui/#attribute/enabled false',
- ],
+ # 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',
+ # ],
}
}