# HG changeset patch # User Luke Hoersten # Date 1592166134 18000 # Node ID 2d7ba960b157cfbe3ce9643b0ec554239d45d8d2 # Parent aaf10cecfc1f07a3de3bb0436a7ba3f5c9825e46 Added postgresql for prosody. diff -r aaf10cecfc1f -r 2d7ba960b157 prosody/defaults/main.yaml --- 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" diff -r aaf10cecfc1f -r 2d7ba960b157 prosody/tasks/main.yaml --- 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: diff -r aaf10cecfc1f -r 2d7ba960b157 prosody/templates/prosody.cfg.lua.j2 --- 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, diff -r aaf10cecfc1f -r 2d7ba960b157 prosody/templates/setup_db.psql.j2 --- /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}};