aboutsummaryrefslogtreecommitdiff
path: root/files
diff options
context:
space:
mode:
authorJulien Dessaux2023-01-23 17:33:53 +0100
committerJulien Dessaux2023-01-23 23:12:56 +0100
commitb6ee8f76c2883a934bcf412722e0cf83830173c9 (patch)
tree97d33cb1f4ea74e0b277a4ed6890b35bc022816e /files
parentImported from personal ansible repository (diff)
downloadsyncthing-ansible-role-b6ee8f76c2883a934bcf412722e0cf83830173c9.tar.gz
syncthing-ansible-role-b6ee8f76c2883a934bcf412722e0cf83830173c9.tar.bz2
syncthing-ansible-role-b6ee8f76c2883a934bcf412722e0cf83830173c9.zip
Simplify fact gathering by using the cli instead of a webapi request1.1
Diffstat (limited to '')
-rw-r--r--templates/syncthing.fact (renamed from files/syncthing.fact)9
1 files changed, 3 insertions, 6 deletions
diff --git a/files/syncthing.fact b/templates/syncthing.fact
index 79ea632..406366b 100644
--- a/files/syncthing.fact
+++ b/templates/syncthing.fact
@@ -8,14 +8,11 @@ use strict;
use warnings;
use JSON::PP;
-use LWP::UserAgent;
-my $id = '0000000-0000000-0000000-0000000-0000000-0000000-0000000-0000000';
+`doas -u {{ syncthing_pre.user_group }} syncthing generate --config {{ syncthing_pre.config_dir }} 2>&1` unless -e "{{ syncthing_pre.config_dir }}/config.xml";
-my $resp = LWP::UserAgent->new()->head('http://localhost:8384/');
-if ($resp->code == 200) {
- $id = $resp->header('X-Syncthing-Id');
-}
+my $id = `doas -u {{ syncthing_pre.user_group }} syncthing -device-id --config {{ syncthing_pre.config_dir }} --data {{ syncthing_pre.data_dir }} 2>&1`;
+chomp $id;
my %output = (
'id' => $id,