Added postgresql for prosody.
--- a/prosody/defaults/main.yaml Sun Jun 14 14:50:21 2020 -0500
+++ b/prosody/defaults/main.yaml Sun Jun 14 15:22:14 2020 -0500
@@ -1,1 +1,6 @@
---
+
+prosody_ssl_dir: "/etc/prosody/certs/{{prosody_vhost}}"
+
+prosody_db: "prosody_{{prosody_instance}}"
+prosody_db_port: "5432"
--- a/prosody/tasks/main.yaml Sun Jun 14 14:50:21 2020 -0500
+++ b/prosody/tasks/main.yaml Sun Jun 14 15:22:14 2020 -0500
@@ -2,8 +2,11 @@
- name: install prosody
become: yes
- apt: name="prosody"
+ apt: name="{{item}}"
notify: restart prosody
+ loop:
+ - "prosody"
+ - "lua-dbi-postgresql"
- name: configure prosody
become: yes
@@ -31,6 +34,22 @@
- "{{prosody_ssl_privkey_src}}"
- "{{prosody_ssl_cert_src}}"
+- name: install db schema file
+ become: yes
+ template:
+ src: "setup_db.psql.j2"
+ dest: "/tmp/setup_db_{{prosody_db}}.psql"
+ owner: "postgres"
+ group: "postgres"
+ mode: "0600"
+ changed_when: false
+
+- name: install psql
+ become: yes
+ become_user: "postgres"
+ command: "psql -f /tmp/setup_db_{{prosody_db}}.psql"
+ changed_when: false
+
- name: enable prosody site
become: yes
file:
--- a/prosody/templates/prosody.cfg.lua.j2 Sun Jun 14 14:50:21 2020 -0500
+++ b/prosody/templates/prosody.cfg.lua.j2 Sun Jun 14 15:22:14 2020 -0500
@@ -1,8 +1,19 @@
VirtualHost "{{prosody_vhost}}"
- ssl = {
- key = "{{prosody_ssl_privkey}}";
- certificate = "{{prosody_ssl_cert}}";
- }
+
+ssl = {
+ key = "{{prosody_ssl_privkey}}";
+ certificate = "{{prosody_ssl_cert}}";
+}
+
+storage = "sql"
+sql = {
+ driver = "PostgreSQL";
+ database = "{{prosody_db}}";
+ host = "localhost";
+ port = {{prosody_db_port}};
+ username = "{{prosody_db}}";
+ password = "{{prosody_db_pass}}";
+}
------ Components ------
-- You can specify components to add hosts that provide special services,
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/prosody/templates/setup_db.psql.j2 Sun Jun 14 15:22:14 2020 -0500
@@ -0,0 +1,2 @@
+CREATE USER {{prosody_db}} WITH ENCRYPTED PASSWORD '{{prosody_db_pass}}';
+CREATE DATABASE {{prosody_db}} ENCODING 'UTF8' LC_COLLATE='C.UTF-8' LC_CTYPE='C.UTF-8' template=template0 OWNER {{prosody_db}};