ctucx.git: ansible-configs

My personal ansible roles and playbooks [deprecated in favor of nixos]

commit f17cf1783dea06760c60695ed1d9963b28a7166c
parent 1007732075405be83f03bee4abf2cba6778de15f
Author: Leah (ctucx) <leah@ctu.cx>
Date: Tue, 23 Feb 2021 19:28:18 +0100

roles/radicale: generate config from variables
5 files changed, 33 insertions(+), 56 deletions(-)
diff --git a/config-files/radicale.conf b/config-files/radicale.conf
@@ -1,48 +0,0 @@
-# Config file for Radicale - A simple calendar server
-
-[server]
-hosts = 127.0.0.1:5232
-#max_connections = 8
-#max_content_length = 100000000
-#timeout = 30
-#ssl = False
-#certificate = /etc/ssl/radicale.cert.pem
-#key = /etc/ssl/radicale.key.pem
-#certificate_authority =
-
-[encoding]
-request = utf-8
-stock = utf-8
-
-
-[auth]
-type = htpasswd
-htpasswd_filename = /etc/radicale/users
-htpasswd_encryption = plain
-#delay = 1
-#realm = Radicale - Password Required
-
-
-[rights]
-#type = owner_only
-#file = /etc/radicale/rights
-
-
-[storage]
-#type = multifilesystem
-#filesystem_folder = /var/lib/radicale/collections
-#max_sync_token_age = 2592000
-#hook =
-
-
-[web]
-type = internal
-
-
-[logging]
-#level = warning
-#mask_passwords = True
-
-
-[headers]
-Access-Control-Allow-Origin = *
diff --git a/configuration/wanderduene.yml b/configuration/wanderduene.yml
@@ -301,7 +301,6 @@ services:
 
   radicale:
     enable: true
-    configFile: config-files/radicale.conf
     users: "{{ lookup('diskcache', 'passwordstore', 'Server/{{system.hostname}}/radicale.users returnall=true')}}"
     nginx:
       enable: true
diff --git a/roles/radicale/tasks/configure.yml b/roles/radicale/tasks/configure.yml
@@ -1,8 +1,8 @@
 ---
 
-- name: copy radicale-config to destination host 
-  copy: 
-    src: "{{ services.radicale.configFile }}"
+- name: "Generate file: /etc/radicale/config" 
+  template:
+    src: radicale.conf.j2
     dest: /etc/radicale/config
     mode: 0640
     owner: root

@@ -10,7 +10,7 @@
   notify: "Restart radicale"
 
 - name: "Create file: /etc/radicale/users"
-  copy: 
+  copy:
     content: "{{ services.radicale.users }}"
     dest: /etc/radicale/users
     mode: 0640

@@ -19,7 +19,7 @@
   notify: "Restart radicale"
 
 - name: "Download InfCloud 0.13 to webapps-directory"
-  ansible.builtin.unarchive:
+  unarchive:
     src: https://www.inf-it.com/InfCloud_0.13.1.zip
     dest: /usr/share/webapps
     remote_src: yes
diff --git a/roles/radicale/templates/nginx-vhost.conf.j2 b/roles/radicale/templates/nginx-vhost.conf.j2
@@ -10,7 +10,7 @@ server {
 	server_name {{ services.radicale.nginx.domain }};
 
 	location / {
-		proxy_pass       http://127.0.0.1:5232/; # The / is important!
+		proxy_pass       http://127.0.0.1:{{ services.radicale.port | default(5232) }}/; # The / is important!
 		proxy_set_header Host $host;
 		proxy_set_header X-Real-IP $remote_addr;
 		proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

@@ -35,7 +35,7 @@ server {
 	server_name {{ services.radicale.nginx.domain }};
 
 	location / {
-		proxy_pass       http://127.0.0.1:5232/; # The / is important!
+		proxy_pass       http://127.0.0.1:{{ services.radicale.port | default(5232) }}/; # The / is important!
 		proxy_set_header Host $host;
 		proxy_set_header X-Real-IP $remote_addr;
 		proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
diff --git a/roles/radicale/templates/radicale.conf.j2 b/roles/radicale/templates/radicale.conf.j2
@@ -0,0 +1,25 @@
+#
+# !!! This file is managed by Ansible !!!
+#
+
+[server]
+hosts = 127.0.0.1:{{ services.radicale.port | default(5232) }}
+
+[encoding]
+request = utf-8
+stock = utf-8
+
+[auth]
+type = htpasswd
+htpasswd_filename = /etc/radicale/users
+htpasswd_encryption = {{ services.radicale.passwordEncryption | default("plain") }}
+
+[web]
+type = internal
+
+[headers]
+Access-Control-Allow-Origin = *
+
+{% if services.radicale.extraConfig is defined %}
+{{ services.radicale.extraConfig }}
+{% endif %}+
\ No newline at end of file