1
0
Fork 0

Simplify fact gathering by using the cli instead of a webapi request

This commit is contained in:
Julien Dessaux 2023-01-23 17:33:53 +01:00
parent 23e2941b3a
commit b6ee8f76c2
Signed by: adyxax
GPG key ID: F92E51B86E07177E
6 changed files with 84 additions and 60 deletions

20
templates/syncthing.fact Normal file
View file

@ -0,0 +1,20 @@
#!/usr/bin/env perl
###############################################################################
# \_o< WARNING : This file is being managed by ansible! >o_/ #
# ~~~~ ~~~~ #
###############################################################################
use strict;
use warnings;
use JSON::PP;
`doas -u {{ syncthing_pre.user_group }} syncthing generate --config {{ syncthing_pre.config_dir }} 2>&1` unless -e "{{ syncthing_pre.config_dir }}/config.xml";
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,
);
print encode_json \%output;