From 2e8dc1ce1150eb8c370808a2ddb16c515f0d4cbd Mon Sep 17 00:00:00 2001 From: Matthew Fennell Date: Sun, 7 Jan 2024 12:46:01 +0000 Subject: Add virtual host specific config This commit uses the new per-host virtual_host variable to create the necessary prosody host-specific cfg files. --- README.md | 6 +++--- files/virtual_host.cfg.lua.j2 | 5 +++++ playbook.yaml | 18 +++++++++++++++++- 3 files changed, 25 insertions(+), 4 deletions(-) create mode 100644 files/virtual_host.cfg.lua.j2 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 +-- +-- 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 -- cgit v1.2.3