From b6ee8f76c2883a934bcf412722e0cf83830173c9 Mon Sep 17 00:00:00 2001 From: Julien Dessaux Date: Mon, 23 Jan 2023 17:33:53 +0100 Subject: Simplify fact gathering by using the cli instead of a webapi request --- templates/syncthing.fact | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 templates/syncthing.fact (limited to 'templates') diff --git a/templates/syncthing.fact b/templates/syncthing.fact new file mode 100644 index 0000000..406366b --- /dev/null +++ b/templates/syncthing.fact @@ -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; -- cgit v1.2.3