From 5b84e726fbb5a57d6af6ba2479f678d8643ada46 Mon Sep 17 00:00:00 2001 From: L3D Date: Fri, 8 Jan 2021 23:47:14 +0100 Subject: [PATCH] continue templating --- roles/goaccess | 2 +- .../templates/mysqlconfig.sql.j2 | 32 ++++++++++++++++--- 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/roles/goaccess b/roles/goaccess index d9d4ce1..d5f1591 160000 --- a/roles/goaccess +++ b/roles/goaccess @@ -1 +1 @@ -Subproject commit d9d4ce15d8360ed07c698608408b97800dba028c +Subproject commit d5f15917d007b0bdad39dfaf20a358f76d222ef7 diff --git a/roles/mailserver_preperation/templates/mysqlconfig.sql.j2 b/roles/mailserver_preperation/templates/mysqlconfig.sql.j2 index 7cfd16f..cef10a3 100644 --- a/roles/mailserver_preperation/templates/mysqlconfig.sql.j2 +++ b/roles/mailserver_preperation/templates/mysqlconfig.sql.j2 @@ -21,19 +21,43 @@ insert into domains (domain) values ('{{ mailserver_domain }}'); FOREIGN KEY (`domain`) REFERENCES `domains` (`domain`) ); - mailserver_accounts: - - username: 'foo' + mailserver__accounts: + - username: 'alice' domain: 'example.com' password_hash: quota: '0' enabled: true sendonly: false + mailserver__alias: + - src_username: 'bob' + src_domain: 'example.com' + dest_username: 'alice' + dest_domain: 'example.com' + enabled: true + #} {% for account in mailserver__accounts %} -insert into accounts (username, domain, password, quota, enabled, sendonly) values ('{{ account["username"] }}', '{{ account["domain"] }}', '{{ account["password_hash"] }}', {{ account["quota"]|default(0) | int }}, {{ account["enabled"] | default(true) | | ternary('true', 'false') }} , {{ account["sendonly"] | default(false) | | ternary('true', 'false' }}); +{# + INSERT into accounts (username, domain, password, quota, enabled, sendonly) values ('{{ account["username"] }}', '{{ account["domain"] }}', '{{ account["password_hash"] }}', {{ account["quota"]|default(0) | int }}, {{ account["enabled"] | default(true) | | ternary('true', 'false') }} , {{ account["sendonly"] | default(false) | | ternary('true', 'false' }}); +#} +REPLACE into accounts + (username, domain, password, quota, enabled, sendonly) +values + ('{{ account["username"] }}', '{{ account["domain"] }}', '{{ account["password_hash"] }}', {{ account["quota"]|default(0) | int }}, {{ account["enabled"] | default(true) | | ternary('true', 'false') }} , {{ account["sendonly"] | default(false) | | ternary('true', 'false' }}); {% endfor %} {#- create all mail aliases and stuff like that... #} -insert into aliases (source_username, source_domain, destination_username, destination_domain, enabled) values ('alias', '{{ domain }}', '{{ mail_user }}', '{{ domain }}', true); +{% for alias in mailserver__alias %} +{# + INSERT into aliases + (source_username, source_domain, destination_username, destination_domain, enabled) + values + ('{{ alias["src_username"] }}', '{{ alias["src_domain"] }}', '{{ alias["dest_username"] }}', '{{ alias["dest_domain"] }}', {{ alias["enabled"] | default(true) | | ternary('true', 'false') }}); +#} +REPLACE into aliases + (source_username, source_domain, destination_username, destination_domain, enabled) +values + ('{{ alias["src_username"] }}', '{{ alias["src_domain"] }}', '{{ alias["dest_username"] }}', '{{ alias["dest_domain"] }}', {{ alias["enabled"] | default(true) | | ternary('true', 'false') }}); +{% endfor %}