Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add postfix relay support #542

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions pillar/common.sls
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,8 @@ ntp:
- 2.uk.pool.ntp.org
- 3.uk.pool.ntp.org

smtp:
relay: False

netdata:
enabled: False
3 changes: 3 additions & 0 deletions pillar/portland_dev.sls
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
smtp:
RobHooper marked this conversation as resolved.
Show resolved Hide resolved
relay: True

network:
host_id: ocp26
ipv4: 20.106.239.92
Expand Down
1 change: 1 addition & 0 deletions pillar/top.sls
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ base:
'portland-dev':
- portland_dev
- docker
- private.smtp

'prometheus':
- prometheus_server
Expand Down
32 changes: 32 additions & 0 deletions salt/core/mail.sls
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,38 @@ postfix:
- pkg: postfix
- onchanges:
- debconf: postfix
file.keyvalue:
- name: /etc/postfix/main.cf
- key_values:
# On first run, myhostname may default to previous ISP value.
myhostname: "{{ pillar.network.host_id }}.{{ pillar.network.domain }}"
{%- if pillar.smtp.relay %}
relayhost: "[{{ pillar.smtp.host }}]:{{ pillar.smtp.port }}"
smtp_sasl_auth_enable: "yes"
smtp_sasl_security_options: "noanonymous"
smtp_sasl_password_maps: "hash:/etc/postfix/sasl_passwd"
smtp_use_tls: "yes"
RobHooper marked this conversation as resolved.
Show resolved Hide resolved
smtp_tls_note_starttls_offer: "yes"
{%- endif %}
- separator: ' = '
- append_if_not_found: True
- watch_in:
- service: postfix

{%- if pillar.smtp.relay %}
/etc/postfix/sasl_passwd:
file.managed:
- contents: "[{{ pillar.smtp.host }}]:{{ pillar.smtp.port }} {{ pillar.smtp.username }}:{{ pillar.smtp.password }}"
- mode: 600
cmd.run:
- name: postmap hash:/etc/postfix/sasl_passwd
- require:
- pkg: postfix
- onchanges:
- file: /etc/postfix/sasl_passwd
- watch_in:
- file: postfix
{% endif %}

# Install commands for users to interact with mail.
mailutils:
Expand Down
4 changes: 2 additions & 2 deletions salt/prometheus/files/conf-alertmanager.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ receivers:
smarthost: {{ pillar.smtp.host }}:{{ pillar.smtp.port }}
auth_username: {{ pillar.smtp.username }}
auth_password: {{ pillar.smtp.password }}
require_tls: {{ pillar.smtp.tls }}
require_tls: True
send_resolved: True
- name: rh-email
email_configs:
Expand All @@ -36,5 +36,5 @@ receivers:
smarthost: {{ pillar.smtp.host }}:{{ pillar.smtp.port }}
auth_username: {{ pillar.smtp.username }}
auth_password: {{ pillar.smtp.password }}
require_tls: {{ pillar.smtp.tls }}
require_tls: True
send_resolved: True