summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Fennell <matthew@fennell.dev>2024-01-07 12:46:01 +0000
committerMatthew Fennell <matthew@fennell.dev>2024-01-07 12:46:01 +0000
commit2e8dc1ce1150eb8c370808a2ddb16c515f0d4cbd (patch)
treef3d385ff59ad903c0e827d0c5b3fa27796ec4d98
parent14465fc9602ec96fc9d4e48bc0120e75415e1e26 (diff)
Add virtual host specific config
This commit uses the new per-host virtual_host variable to create the necessary prosody host-specific cfg files.
-rw-r--r--README.md6
-rw-r--r--files/virtual_host.cfg.lua.j25
-rw-r--r--playbook.yaml18
3 files changed, 25 insertions, 4 deletions
diff --git a/README.md b/README.md
index ffc6c3d..c921dde 100644
--- a/README.md
+++ b/README.md
@@ -45,8 +45,8 @@ you would like to deploy to. For instance:
```ini
[xmpp_server]
-fennell.dev
-koyo.haus
+fennell.dev virtual_host=chat.fennell.dev
+koyo.haus virtual_host=koyo.haus
```
### Create a staging inventory file
@@ -59,7 +59,7 @@ Create an inventory file in `inventory/staging.ini` like the following:
```ini
[xmpp_server]
-staging.koyo.haus
+staging.koyo.haus virtual_host=staging.koyo.haus
```
### Run the playbook on your staging hosts
diff --git a/files/virtual_host.cfg.lua.j2 b/files/virtual_host.cfg.lua.j2
new file mode 100644
index 0000000..5f0c363
--- /dev/null
+++ b/files/virtual_host.cfg.lua.j2
@@ -0,0 +1,5 @@
+-- SPDX-FileCopyrightText: 2024 Matthew Fennell <matthew@fennell.dev>
+--
+-- SPDX-License-Identifier: AGPL-3.0-only
+
+VirtualHost "{{ virtual_host }}"
diff --git a/playbook.yaml b/playbook.yaml
index b396d21..3da1246 100644
--- a/playbook.yaml
+++ b/playbook.yaml
@@ -26,7 +26,7 @@
- WWW
- XMPP
become: true
- - name: Ensure prosody is configured
+ - name: Ensure top-level prosody configuration is installed
ansible.builtin.copy:
src: "{{ playbook_dir }}/files/prosody.cfg.lua"
dest: /etc/prosody/prosody.cfg.lua
@@ -34,6 +34,22 @@
group: root
mode: "0640"
become: true
+ - name: Ensure host-specific prosody configuration is available
+ ansible.builtin.template:
+ src: "{{ playbook_dir }}/files/virtual_host.cfg.lua.j2"
+ dest: "/etc/prosody/conf.avail/{{ virtual_host }}.cfg.lua"
+ owner: root
+ group: root
+ mode: "0644"
+ become: true
+ - name: Ensure host-specific prosody configuration is set
+ ansible.builtin.file:
+ src: "/etc/prosody/conf.avail/{{ virtual_host }}.cfg.lua"
+ dest: "/etc/prosody/conf.d/{{ virtual_host }}.cfg.lua"
+ owner: root
+ group: root
+ state: link
+ become: true
- name: Ensure prosody config is reloaded
ansible.builtin.service:
name: prosody