generated from DO1JLR/ansible_playbook_template
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
97 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
CREATE DATABASE IF NOT EXISTS vmail CHARACTER SET 'utf8'; | ||
|
||
USE vmail; | ||
|
||
CREATE TABLE `domains` ( | ||
`id` int unsigned NOT NULL AUTO_INCREMENT, | ||
`domain` varchar(255) NOT NULL, | ||
PRIMARY KEY (`id`), | ||
UNIQUE KEY (`domain`) | ||
); | ||
|
||
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`) | ||
); | ||
|
||
CREATE TABLE `aliases` ( | ||
`id` int unsigned NOT NULL AUTO_INCREMENT, | ||
`source_username` varchar(64) NOT NULL, | ||
`source_domain` varchar(255) NOT NULL, | ||
`destination_username` varchar(64) NOT NULL, | ||
`destination_domain` varchar(255) NOT NULL, | ||
`enabled` boolean DEFAULT '0', | ||
PRIMARY KEY (`id`), | ||
UNIQUE KEY (`source_username`, `source_domain`, `destination_username`, `destination_domain`), | ||
FOREIGN KEY (`source_domain`) REFERENCES `domains` (`domain`) | ||
); | ||
|
||
CREATE TABLE `tlspolicies` ( | ||
`id` int unsigned NOT NULL AUTO_INCREMENT, | ||
`domain` varchar(255) NOT NULL, | ||
`policy` enum('none', 'may', 'encrypt', 'dane', 'dane-only', 'fingerprint', 'verify', 'secure') NOT NULL, | ||
`params` varchar(255), | ||
PRIMARY KEY (`id`), | ||
UNIQUE KEY (`domain`) | ||
); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,3 +27,7 @@ | |
mode: 0644 | ||
owner: root | ||
group: root | ||
|
||
- name: configure mariadb | ||
include_tasks: mariadb.yml | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
--- | ||
- name: create database schema store dir | ||
become: true | ||
file: | ||
path: /root/.mariadb_schema | ||
state: directory | ||
mode: '0755' | ||
owner: root | ||
group: root | ||
|
||
- name: Copy database schema | ||
become: true | ||
copy: | ||
src: files/schema.sql | ||
dest: /root/.mariadb_schema/schema.sql | ||
register: mysqlschema | ||
|
||
- name: Copy mail config | ||
become: true | ||
template: | ||
src: templates/mysqlconfig.sql.j2 | ||
dest: /root/.mariadb_schema/config.sql | ||
register: mysqlconfig | ||
|
||
- name: Import database schema | ||
become: true | ||
mssql_db: | ||
name: vmail | ||
state: import | ||
target: '/root/.mariadb_schema/schema.sql' | ||
when: mysqlschema.changed | ||
|
||
- name: Import database schema | ||
become: true | ||
mssql_db: | ||
name: vmail | ||
state: import | ||
target: '/root/.mariadb_schema/config.sql' | ||
when: mysqlconfig.changed |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
use vmail; | ||
insert into domains (domain) values ('{{ mailserver_domain }}'); | ||
insert into accounts (username, domain, password, quota, enabled, sendonly) values ('{{ mail_user }}', '{{ domain }}', '{{ mail_user_pass_hash }}', 2048, true, false); | ||
insert into aliases (source_username, source_domain, destination_username, destination_domain, enabled) values ('alias', '{{ domain }}', '{{ mail_user }}', '{{ domain }}', true); |