1
0
Fork 0
mirror of https://github.com/DO1JLR/ansible_playbook_servers.git synced 2024-09-14 19:53:56 +02:00
ansible_playbook_servers/roles/mailserver_preperation/templates/mysqlconfig.sql.j2

40 lines
1.4 KiB
Text
Raw Normal View History

{#- which table are we setting up #}
2021-01-03 01:01:18 +01:00
use vmail;
{#-
setup mailserver domain
#}
2021-01-03 01:01:18 +01:00
insert into domains (domain) values ('{{ mailserver_domain }}');
{#-
create all mail users, domains and enter password hashes...
CREATE TABLE `accounts` (
`id` int unsigned NOT NULL AUTO_INCREMENT,
`username` varchar(64) NOT NULL,
`domain` varchar(255) NOT NULL,
`password` varchar(255) NOT NULL,
`quota` int unsigned DEFAULT '0',
`enabled` boolean DEFAULT '0',
`sendonly` boolean DEFAULT '0',
PRIMARY KEY (id),
UNIQUE KEY (`username`, `domain`),
FOREIGN KEY (`domain`) REFERENCES `domains` (`domain`)
);
mailserver_accounts:
- username: 'foo'
domain: 'example.com'
password_hash:
quota: '0'
enabled: true
sendonly: false
#}
{% 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' }});
{% endfor %}
{#-
create all mail aliases and stuff like that...
#}
2021-01-03 01:01:18 +01:00
insert into aliases (source_username, source_domain, destination_username, destination_domain, enabled) values ('alias', '{{ domain }}', '{{ mail_user }}', '{{ domain }}', true);