diff --git a/tasks/main.yml b/tasks/main.yml index 46b7048..13edd64 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -4,6 +4,8 @@ apt: pkg: postfix +- include: postfixadmin.yml + - name: configuration pull directory local_action: file args: diff --git a/tasks/postfixadmin.yml b/tasks/postfixadmin.yml new file mode 100644 index 0000000..21b45c0 --- /dev/null +++ b/tasks/postfixadmin.yml @@ -0,0 +1,19 @@ +--- + +- name: postfix sql map directory + file: + path: /etc/postfix/sql/ + state: directory + +- name: postfix sql map configuration + template: + src: "{{item}}.j2" + dest: /etc/postfix/sql/{{item}} + with_items: + - mysql_virtual_alias_domain_catchall_maps.cf + - mysql_virtual_alias_domain_maps.cf + - mysql_virtual_domains_maps.cf + - mysql_virtual_mailbox_maps.cf + - mysql_virtual_alias_domain_mailbox_maps.cf + - mysql_virtual_alias_maps.cf + - mysql_virtual_mailbox_limit_maps.cf diff --git a/templates/mysql_virtual_alias_domain_catchall_maps.cf.j2 b/templates/mysql_virtual_alias_domain_catchall_maps.cf.j2 new file mode 100644 index 0000000..6b5172e --- /dev/null +++ b/templates/mysql_virtual_alias_domain_catchall_maps.cf.j2 @@ -0,0 +1,6 @@ +# handles catch-all settings of target-domain +user = postfix +password = password +hosts = localhost +dbname = postfix +query = SELECT goto FROM alias,alias_domain WHERE alias_domain.alias_domain = '%d' and alias.address = CONCAT('@', alias_domain.target_domain) AND alias.active = 1 AND alias_domain.active='1' diff --git a/templates/mysql_virtual_alias_domain_mailbox_maps.cf.j2 b/templates/mysql_virtual_alias_domain_mailbox_maps.cf.j2 new file mode 100644 index 0000000..a0d6a90 --- /dev/null +++ b/templates/mysql_virtual_alias_domain_mailbox_maps.cf.j2 @@ -0,0 +1,5 @@ +user = postfix +password = password +hosts = localhost +dbname = postfix +query = SELECT maildir FROM mailbox,alias_domain WHERE alias_domain.alias_domain = '%d' and mailbox.username = CONCAT('%u', '@', alias_domain.target_domain) AND mailbox.active = 1 AND alias_domain.active='1' diff --git a/templates/mysql_virtual_alias_domain_maps.cf.j2 b/templates/mysql_virtual_alias_domain_maps.cf.j2 new file mode 100644 index 0000000..effe89f --- /dev/null +++ b/templates/mysql_virtual_alias_domain_maps.cf.j2 @@ -0,0 +1,5 @@ +user = postfix +password = password +hosts = localhost +dbname = postfix +query = SELECT goto FROM alias,alias_domain WHERE alias_domain.alias_domain = '%d' and alias.address = CONCAT('%u', '@', alias_domain.target_domain) AND alias.active = 1 AND alias_domain.active='1' diff --git a/templates/mysql_virtual_alias_maps.cf.j2 b/templates/mysql_virtual_alias_maps.cf.j2 new file mode 100644 index 0000000..394d9fb --- /dev/null +++ b/templates/mysql_virtual_alias_maps.cf.j2 @@ -0,0 +1,6 @@ +user = postfix +password = password +hosts = localhost +dbname = postfix +query = SELECT goto FROM alias WHERE address='%s' AND active = '1' +#expansion_limit = 100 diff --git a/templates/mysql_virtual_domains_maps.cf.j2 b/templates/mysql_virtual_domains_maps.cf.j2 new file mode 100644 index 0000000..61e56f7 --- /dev/null +++ b/templates/mysql_virtual_domains_maps.cf.j2 @@ -0,0 +1,9 @@ +user = postfix +password = password +hosts = localhost +dbname = postfix +query = SELECT domain FROM domain WHERE domain='%s' AND active = '1' +#query = SELECT domain FROM domain WHERE domain='%s' +#optional query to use when relaying for backup MX +#query = SELECT domain FROM domain WHERE domain='%s' AND backupmx = '0' AND active = '1' +#expansion_limit = 100 diff --git a/templates/mysql_virtual_mailbox_limit_maps.cf.j2 b/templates/mysql_virtual_mailbox_limit_maps.cf.j2 new file mode 100644 index 0000000..c2e0ad1 --- /dev/null +++ b/templates/mysql_virtual_mailbox_limit_maps.cf.j2 @@ -0,0 +1,5 @@ +user = postfix +password = password +hosts = localhost +dbname = postfix +query = SELECT quota FROM mailbox WHERE username='%s' AND active = '1' diff --git a/templates/mysql_virtual_mailbox_maps.cf.j2 b/templates/mysql_virtual_mailbox_maps.cf.j2 new file mode 100644 index 0000000..6a75a90 --- /dev/null +++ b/templates/mysql_virtual_mailbox_maps.cf.j2 @@ -0,0 +1,6 @@ +user = postfix +password = password +hosts = localhost +dbname = postfix +query = SELECT maildir FROM mailbox WHERE username='%s' AND active = '1' +#expansion_limit = 100