Skip to content

Commit

Permalink
Make config more DRY
Browse files Browse the repository at this point in the history
  • Loading branch information
tersmitten committed Apr 9, 2019
1 parent 87003b1 commit 1b630ee
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 11 deletions.
15 changes: 10 additions & 5 deletions handlers/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,24 @@
command: newaliases

- name: new virtual aliases
command: postmap hash:/etc/postfix/virtual
command: >
postmap hash:{{ postfix_virtual_aliases_file }}
- name: postmap sasl_passwd
command: postmap hash:/etc/postfix/sasl_passwd
command: >
postmap hash:{{ postfix_sasl_passwd_file }}
- name: postmap sender_canonical_maps
command: postmap hash:/etc/postfix/sender_canonical_maps
command: >
postmap hash:{{ postfix_sender_canonical_maps_file }}
- name: postmap recipient_canonical_maps
command: postmap hash:/etc/postfix/recipient_canonical_maps
command: >
postmap hash:{{ postfix_recipient_canonical_maps_file }}
- name: postmap generic
command: postmap hash:/etc/postfix/generic
command: >
postmap hash:{{ postfix_generic_file }}
- name: restart postfix
command: /bin/true
Expand Down
12 changes: 6 additions & 6 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
- name: configure sasl username/password
template:
src: etc/postfix/sasl_passwd.j2
dest: /etc/postfix/sasl_passwd
dest: "{{ postfix_sasl_passwd_file }}"
owner: root
group: root
mode: 0600
Expand All @@ -76,7 +76,7 @@

- name: configure aliases
lineinfile:
dest: /etc/aliases
dest: "{{ postfix_aliases_file }}"
regexp: '^{{ item.user }}:.*'
line: '{{ item.user }}: {{ item.alias }}'
owner: root
Expand All @@ -95,7 +95,7 @@

- name: configure virtual aliases
lineinfile:
dest: /etc/postfix/virtual
dest: "{{ postfix_virtual_aliases_file }}"
regexp: '^{{ item.virtual }}.*'
line: '{{ item.virtual }} {{ item.alias }}'
owner: root
Expand All @@ -114,7 +114,7 @@

- name: configure sender canonical maps
lineinfile:
dest: /etc/postfix/sender_canonical_maps
dest: "{{ postfix_sender_canonical_maps_file }}"
regexp: '^{{ item.sender }}.*'
line: '{{ item.sender }} {{ item.rewrite }}'
owner: root
Expand All @@ -133,7 +133,7 @@

- name: configure recipient canonical maps
lineinfile:
dest: /etc/postfix/recipient_canonical_maps
dest: "{{ postfix_recipient_canonical_maps_file }}"
regexp: '^{{ item.recipient }}.*'
line: '{{ item.recipient }} {{ item.rewrite }}'
owner: root
Expand All @@ -152,7 +152,7 @@

- name: configure generic table
lineinfile:
dest: /etc/postfix/generic
dest: "{{ postfix_generic_file }}"
regexp: '^{{ item.pattern }}.*'
line: '{{ item.pattern }} {{ item.result }}'
owner: root
Expand Down
7 changes: 7 additions & 0 deletions vars/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,10 @@ postfix_debconf_selections:
question: postfix/main_mailer_type
value: No configuration
vtype: select

postfix_aliases_file: /etc/aliases
postfix_virtual_aliases_file: /etc/postfix/virtual
postfix_sasl_passwd_file: /etc/postfix/sasl_passwd
postfix_sender_canonical_maps_file: /etc/postfix/recipient_canonical_maps
postfix_recipient_canonical_maps_file: /etc/postfix/sender_canonical_maps
postfix_generic_file: /etc/postfix/generic

0 comments on commit 1b630ee

Please sign in to comment.