Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
tersmitten committed Aug 23, 2023
1 parent 23cdb42 commit 9db9bd0
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 26 deletions.
20 changes: 10 additions & 10 deletions handlers/main.yml
Original file line number Diff line number Diff line change
@@ -1,54 +1,54 @@
# handlers file
---
- name: new aliases
command: >
ansible.builtin.command: >
newaliases
when: postfix_default_database_type != 'regexp'

- name: new virtual aliases
command: >
ansible.builtin.command: >
postmap {{ postfix_default_database_type }}:{{ postfix_virtual_aliases_file }}
when: postfix_default_database_type != 'regexp'

- name: postmap sasl_passwd
command: >
ansible.builtin.command: >
postmap {{ postfix_default_database_type }}:{{ postfix_sasl_passwd_file }}
when: postfix_default_database_type != 'regexp'

- name: postmap sender_canonical_maps
command: >
ansible.builtin.command: >
postmap {{ postfix_sender_canonical_maps_database_type }}:{{ postfix_sender_canonical_maps_file }}
when: postfix_sender_canonical_maps_database_type != 'regexp'

- name: postmap recipient_canonical_maps
command: >
ansible.builtin.command: >
postmap {{ postfix_recipient_canonical_maps_database_type }}:{{ postfix_recipient_canonical_maps_file }}
when: postfix_recipient_canonical_maps_database_type != 'regexp'

- name: postmap transport_maps
command: >
ansible.builtin.command: >
postmap {{ postfix_transport_maps_database_type }}:{{ postfix_transport_maps_file }}
when: postfix_transport_maps_database_type != 'regexp'

- name: postmap sender_dependent_relayhost_maps
command: >
ansible.builtin.command: >
postmap {{ postfix_default_database_type }}:{{ postfix_sender_dependent_relayhost_maps_file }}
when: postfix_default_database_type != 'regexp'

- name: postmap generic
command: >
ansible.builtin.command: >
postmap {{ postfix_smtp_generic_maps_database_type }}:{{ postfix_smtp_generic_maps_file }}
when: postfix_smtp_generic_maps_database_type != 'regexp'

- name: remove pid
file:
ansible.builtin.file:
path: "~postfix/pid/master.pid"
state: absent
listen: restart postfix
when: is_docker_guest

- name: restart service
service:
ansible.builtin.service:
name: postfix
state: restarted
listen: restart postfix
Expand Down
32 changes: 16 additions & 16 deletions tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# tasks file
---
- name: facts | set
set_fact:
ansible.builtin.set_fact:
is_docker_guest: "{{ ansible_virtualization_role | default('host') == 'guest' and ansible_virtualization_type | default('none') == 'docker' }}"
tags:
- configuration
- postfix
- postfix-facts

- name: configure debconf
debconf:
ansible.builtin.debconf:
name: "{{ item.name }}"
question: "{{ item.question }}"
value: "{{ item.value }}"
Expand All @@ -21,7 +21,7 @@
- postfix-install

- name: install package
apt:
ansible.builtin.apt:
name: "{{ postfix_install }}"
state: "{{ apt_install_state | default('latest') }}"
update_cache: true
Expand All @@ -32,7 +32,7 @@
- postfix-install

- name: configure mailname
template:
ansible.builtin.template:
src: "{{ postfix_mailname_file.lstrip('/') }}.j2"
dest: "{{ postfix_mailname_file }}"
owner: root
Expand All @@ -45,7 +45,7 @@
- postfix-mailname

- name: update configuration file
template:
ansible.builtin.template:
src: "{{ postfix_main_cf.lstrip('/') }}.j2"
dest: "{{ postfix_main_cf }}"
owner: root
Expand All @@ -58,7 +58,7 @@
- postfix-configuration

- name: configure sasl username/password
template:
ansible.builtin.template:
src: "{{ postfix_sasl_passwd_file.lstrip('/') }}.j2"
dest: "{{ postfix_sasl_passwd_file }}"
owner: root
Expand All @@ -77,7 +77,7 @@
- postfix-sasl-passwd

- name: configure aliases
template:
ansible.builtin.template:
src: "{{ postfix_aliases_file.lstrip('/') }}.j2"
dest: "{{ postfix_aliases_file }}"
owner: root
Expand All @@ -92,7 +92,7 @@
- postfix-aliases

- name: check if aliases.db exists
stat:
ansible.builtin.stat:
path: "{{ postfix_aliases_file }}.db"
register: _aliasesdb
changed_when: not _aliasesdb.stat.exists
Expand All @@ -106,7 +106,7 @@
- postfix-aliases

- name: configure virtual aliases
lineinfile:
ansible.builtin.lineinfile:
dest: "{{ postfix_virtual_aliases_file }}"
regexp: '^{{ item.virtual | regex_escape }}\s.*'
line: '{{ item.virtual }} {{ item.alias }}'
Expand All @@ -125,7 +125,7 @@
- postfix-virtual-aliases

- name: configure sender canonical maps
lineinfile:
ansible.builtin.lineinfile:
dest: "{{ postfix_sender_canonical_maps_file }}"
regexp: '^{{ item.sender | regex_escape }}\s.*'
line: '{{ item.sender }} {{ item.rewrite }}'
Expand All @@ -144,7 +144,7 @@
- postfix-sender-canonical-maps

- name: configure recipient canonical maps
lineinfile:
ansible.builtin.lineinfile:
dest: "{{ postfix_recipient_canonical_maps_file }}"
regexp: '^{{ item.recipient | regex_escape }}\s.*'
line: '{{ item.recipient }} {{ item.rewrite }}'
Expand All @@ -163,7 +163,7 @@
- postfix-recipient-canonical-maps

- name: configure transport maps
lineinfile:
ansible.builtin.lineinfile:
dest: "{{ postfix_transport_maps_file }}"
regexp: '^{{ item.pattern | regex_escape }}\s.*'
line: '{{ item.pattern }} {{ item.result }}'
Expand All @@ -182,7 +182,7 @@
- postfix-transport-maps

- name: configure sender dependent relayhost maps
lineinfile:
ansible.builtin.lineinfile:
dest: "{{ postfix_sender_dependent_relayhost_maps_file }}"
regexp: '^{{ item.pattern | regex_escape }}\s.*'
line: '{{ item.pattern }} {{ item.result }}'
Expand All @@ -201,7 +201,7 @@
- postfix-sender-dependent-relayhost-maps

- name: configure generic table
lineinfile:
ansible.builtin.lineinfile:
dest: "{{ postfix_smtp_generic_maps_file }}"
regexp: '^{{ item.pattern | regex_escape }}\s.*'
line: '{{ item.pattern }} {{ item.result }}'
Expand All @@ -220,7 +220,7 @@
- postfix-generic-table

- name: configure header checks
template:
ansible.builtin.template:
src: "{{ postfix_header_checks_file.lstrip('/') }}.j2"
dest: "{{ postfix_header_checks_file }}"
owner: root
Expand All @@ -234,7 +234,7 @@
- postfix-header-checks-table

- name: start and enable service
service:
ansible.builtin.service:
name: postfix
state: "{{ service_default_state | default('started') }}"
enabled: "{{ service_default_enabled | default(true) | bool }}"
Expand Down

0 comments on commit 9db9bd0

Please sign in to comment.