-
Notifications
You must be signed in to change notification settings - Fork 688
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Breaks out postfix config into discrete role
Previously we configured both postfix and procmail inside the "ossec-server" role, which was essentially shoehorning the config. It's appropriate to target the "securedrop_monitor_server" group with those config items, but technically there's not literally OSSEC server, but rather a separate service that deserves its own configuration logic. Tidies up some of the vars. We've documented use of the `ossec_from_address` publicly, so we can't simply drop reference to it. Since the associated logic now resides in the "postfix" role, it should be prefixed with the `postfix_` namespace. That's done, old values of `ossec_from_address` set at the site level, if set, will be honored.
- Loading branch information
Showing
16 changed files
with
100 additions
and
108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 0 additions & 23 deletions
23
install_files/ansible-base/roles/ossec-server/defaults/main.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,8 @@ | ||
--- | ||
smtp_relay_cert_dir: /etc/ssl/certs | ||
smtp_relay_cert_override_dir: '/etc/ssl/certs_local' | ||
smtp_relay_cert_override_file: '' | ||
|
||
# Email address listed in the FROM line when sending OSSEc email alerts. | ||
# Some mail servers require that this match the account that authenticated | ||
# to send mail. | ||
ossec_from_address: '' | ||
|
||
# Override capability for installing locally built deb packages in the staging | ||
# environment. By default, packages are installed via the FPF apt repo. | ||
install_local_packages: False | ||
|
||
ossec_group: ossec | ||
|
||
# Apt dependencies for the ossec server package | ||
ossec_postfix_dependencies: | ||
- procmail | ||
- postfix | ||
- mailutils | ||
|
||
# Configuration info for procmail and postfix | ||
postfix_hostname: ossec.server | ||
|
||
# Whether to enable Postfix for sending mail. Required in prod, | ||
# but unnecessary in staging contexts, where SASL authentication | ||
# will always fail, due to lack of site-specific credentials. | ||
ossec_server_enable_postfix: True | ||
|
||
ossec_agent_already_registered: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
install_files/ansible-base/roles/postfix/defaults/main.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
--- | ||
# Email address listed in the FROM line when sending OSSEc email alerts. | ||
# Some mail servers require that this match the account that authenticated | ||
# to send mail. Using the `ossec_from_address` for backwards-compatibility. | ||
postfix_from_address: "{{ ossec_from_address|default('') }}" | ||
|
||
# Apt dependencies for the ossec server package | ||
postfix_dependencies: | ||
- procmail | ||
- postfix | ||
- mailutils | ||
|
||
# Configuration info for procmail and postfix | ||
postfix_hostname: ossec.server | ||
|
||
# Whether to enable Postfix for sending mail. Required in prod, | ||
# but unnecessary in staging contexts, where SASL authentication | ||
# will always fail, due to lack of site-specific credentials. | ||
postfix_enable_service: True | ||
|
||
smtp_relay_cert_dir: /etc/ssl/certs | ||
smtp_relay_cert_override_dir: '/etc/ssl/certs_local' | ||
smtp_relay_cert_override_file: '' |
File renamed without changes.
File renamed without changes.
File renamed without changes.
19 changes: 19 additions & 0 deletions
19
install_files/ansible-base/roles/postfix/handlers/main.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
--- | ||
- name: update aliases | ||
command: postalias /etc/aliases | ||
|
||
- name: update sasl_passwd db | ||
command: postmap /etc/postfix/sasl_passwd | ||
|
||
- name: update generic_maps | ||
command: postmap /etc/postfix/generic | ||
|
||
- name: postmap_header_checks | ||
command: postmap /etc/postfix/header_checks | ||
|
||
- name: restart postfix | ||
service: | ||
name: postfix | ||
state: restarted | ||
# Don't bounce the service if set to disabled, e.g. in staging | ||
when: postfix_enable_service |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
install_files/ansible-base/roles/postfix/tasks/install_procmail.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
--- | ||
# This log file doesn't exist by default, so we need to create it. We don't | ||
# want to clobber the contents if it already exists, however, thus the "force: no". | ||
# The `copy` module will back off if the file already exists, which means permissions | ||
# will be ignored if the file exists. A subsequent task will handle permissions. | ||
- name: Create procmail log file. | ||
copy: | ||
dest: /var/log/procmail.log | ||
mode: "0660" | ||
owner: ossec | ||
group: root | ||
content: "" | ||
force: no | ||
tags: | ||
- procmail | ||
- permissions | ||
- logging | ||
|
||
# The previous task is essentially a `touch` command, without the side-effect of reporting | ||
# "changed" every time. In order to force correct ownership and permissions, we'll take a | ||
# second pass at the log file and only report "changed" if updates were made. | ||
- name: Update permissions on procmail log file. | ||
file: | ||
path: /var/log/procmail.log | ||
mode: "0660" | ||
owner: ossec | ||
group: root | ||
tags: | ||
- procmail | ||
- permissions | ||
- logging | ||
|
||
- name: Copy procmail config file. | ||
copy: | ||
src: procmailrc | ||
dest: /var/ossec/.procmailrc | ||
owner: root | ||
group: ossec | ||
tags: | ||
- procmail |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
--- | ||
- include: install_postfix.yml | ||
|
||
- include: install_procmail.yml | ||
|
||
# Configure SSL certificates for SMTP relay if manual | ||
# overrides are declared. See default vars | ||
# `smtp_relay_cert_override_file` and `smtp_relay_cert_override_dir`. | ||
- include: configure_custom_cert.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.