master
blallo 2021-02-23 18:47:25 +01:00
commit 7008a8fcd4
Signed by: blallo
GPG Key ID: 0CBE577C9B72DC3F
16 changed files with 146 additions and 0 deletions

View File

@ -0,0 +1 @@
{"dependencies":[["formatador",["~> 0.2"]],["excon",["~> 0.49"]],["builder",[">= 0"]],["fog-core",["~> 1.43.0"]],["mini_portile2",["~> 2.4.0"]],["nokogiri",[">= 1.6.0"]],["json",[">= 0"]],["ruby-libvirt",[">= 0.7.0"]],["fog-xml",["~> 0.1.1"]],["multi_json",["~> 1.10"]],["fog-json",[">= 0"]],["fog-libvirt",[">= 0.3.0"]],["vagrant-libvirt",["= 0.0.45"]]],"checksum":"fffd3c92382f68b8c2b567be0284154ab699575030b9530f4eb9eaf340d61e70","vagrant_version":"2.2.9"}

View File

@ -0,0 +1 @@
1.5:4a7308aa-0f0c-4650-960a-ab46a2f323a9

View File

@ -0,0 +1 @@
{"name":"debian/buster64","version":"10.4.0","provider":"libvirt","directory":"boxes/debian-VAGRANTSLASH-buster64/10.4.0/libvirt"}

View File

@ -0,0 +1 @@
1000

View File

@ -0,0 +1 @@
4a7308aa-0f0c-4650-960a-ab46a2f323a9

View File

@ -0,0 +1 @@
1581929e88a845b69398f3a365a435c9

View File

@ -0,0 +1 @@
{}

View File

@ -0,0 +1 @@
/home/leo/Documents/coding/playbooks/debian_toolbox/roles/syncthing

View File

@ -0,0 +1,9 @@
# This file loads the proper rgloader/loader.rb file that comes packaged
# with Vagrant so that encoded files can properly run with Vagrant.
if ENV["VAGRANT_INSTALLER_EMBEDDED_DIR"]
require File.expand_path(
"rgloader/loader", ENV["VAGRANT_INSTALLER_EMBEDDED_DIR"])
else
raise "Encoded files can't be read outside of the Vagrant installer."
end

31
Vagrantfile vendored 100644
View File

@ -0,0 +1,31 @@
# This guide is optimized for Vagrant 1.7 and above.
# Although versions 1.6.x should behave very similarly, it is recommended
# to upgrade instead of disabling the requirement below.
Vagrant.require_version ">= 1.7.0"
Vagrant.configure(2) do |config|
config.vm.box = "debian/buster64"
config.vm.define "debiantest" do |m|
m.vm.hostname = "debiantest"
m.vm.network :private_network, ip: "192.168.123.2", libvirt__dhcp_enabled: false
m.vm.synced_folder ".", "/vagrant", disabled: true
end
# Disable the new default behavior introduced in Vagrant 1.7, to
# ensure that all Vagrant machines will use the same SSH key pair.
# See https://github.com/mitchellh/vagrant/issues/5005
config.ssh.insert_key = false
config.vm.provider :libvirt do |lv|
lv.cpus = 2
lv.memory = 1024
end
config.vm.provision "ansible" do |ansible|
ansible.become = true
ansible.verbose = "v"
ansible.playbook = "playbook.yml"
ansible.inventory_path = "inventory"
end
end

3
ansible.cfg 100644
View File

@ -0,0 +1,3 @@
[defaults]
roles_path = ../
ansible_python_interpreter = /usr/bin/python3

View File

@ -0,0 +1,5 @@
---
- name: restart syncthing
systemd:
state: restarted
name: syncthing@syncthing.service

1
inventory 100644
View File

@ -0,0 +1 @@
debiantest

8
playbook.yml 100644
View File

@ -0,0 +1,8 @@
---
- hosts: debiantest
gather_facts: yes
vars_files:
- ./test_vars.yml
roles:
- syncthing

75
tasks/main.yml 100644
View File

@ -0,0 +1,75 @@
---
- name: Ensure syncthing user is present
user:
name: syncthing
state: present
create_home: yes
home: "{{ syncthing.home }}"
shell: /usr/sbin/nologin
- name: Ensure syncthing dir is present
file:
path: "{{ syncthing.dir }}"
state: directory
owner: syncthing
group: syncthing
mode: 0700
- name: Ensure syncthing is installed
apt:
name:
- syncthing
- python-lxml
- python3-lxml
state: latest
- name: Ensure syncthing is running
systemd:
name: syncthing@syncthing.service
state: started
enabled: yes
- name: Set the sync directory
xml:
path: "{{ syncthing.home }}/.config/syncthing/config.xml"
xpath: /configuration/folder
attribute: path
value: "{{ syncthing.dir }}"
notify: restart syncthing
retries: 3
delay: 3
register: result
until: not result.failed
- name: Add an user to log into the interface
xml:
path: "{{ syncthing.home }}/.config/syncthing/config.xml"
xpath: /configuration/gui/user
value: "{{ syncthing.user }}"
notify: restart syncthing
retries: 3
delay: 3
register: result
until: not result.failed
- name: Set the password
xml:
path: "{{ syncthing.home }}/.config/syncthing/config.xml"
xpath: /configuration/gui/password
value: "{{ syncthing.password }}"
notify: restart syncthing
retries: 3
delay: 3
register: result
until: not result.failed
- name: Make public the management interface
xml:
path: "{{ syncthing.home }}/.config/syncthing/config.xml"
xpath: /configuration/gui/address
value: 0.0.0.0:8384
notify: restart syncthing
retries: 3
delay: 3
register: result
until: not result.failed

6
test_vars.yml 100644
View File

@ -0,0 +1,6 @@
---
syncthing:
dir: /syncthing
home: /var/syncthing
user: testuser
password: $6$ZFrzgBIbv/QuQz1S$QjorAV4gEyUHNO.PthWAe9utbNAd4vogAgLJTXuAt8bmK7.bc5za5kXKPLy.VFSuRtp9DVljRFhZm1LpV.c9Y0 # this is: password