Skip to content

Commit

Permalink
Added postfix_files feature as a simple means to add extra files/maps…
Browse files Browse the repository at this point in the history
… to the postfix config
  • Loading branch information
Thulium-Drake committed Jun 9, 2024
1 parent 7a485a9 commit be55414
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
12 changes: 12 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,18 @@
#
postfix_conf: {}

# Additional config maps/files, e.g.:
# postfix_files:
# - name: 'sasl_passwd'
# content: 'smtp.example.com user@example.com:myFirstPassword
# postmap: true
# - name: 'sender_canonical_maps'
# content: '/.+/ user@example.com'
postfix_files: []

# When handling above files, disable logging in case passwords are processed
postfix_no_log: true

# Whether to run 'postfix check' before it's started
postfix_check: true

Expand Down
9 changes: 9 additions & 0 deletions handlers/main.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
---
- name: Run postmap
command: postmap /etc/postfix/{{ file['name'] }}
when: file['postmap'] | default(false) | bool
no_log: "{{ postfix_no_log }}"
loop: "{{ postfix_files }}"
loop_control:
loop_var: file
changed_when: false

- name: Check postfix
command: postfix check
when: postfix_check
Expand Down
16 changes: 16 additions & 0 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,22 @@
{% endif %}
{% endfor %}
- name: Configure additional files
copy:
content: "{{ file['content'] }}"
dest: /etc/postfix/{{ file['name'] }}
owner: root
group: root
mode: '0644'
loop: "{{ postfix_files }}"
no_log: "{{ postfix_no_log }}"
loop_control:
loop_var: file
notify:
- Run postmap
- Check postfix
- Restart postfix

- name: Apply changes
when: __postfix_has_config_changed | d("") is search("True")
block:
Expand Down

0 comments on commit be55414

Please sign in to comment.