vbotka.freebsd_mailserver

freebsd_mailserver

质量 构建状态 GitHub 标签

Ansible 角色。 FreeBSD。安装和配置 Postfix 和 Dovecot2。

欢迎 分享您的反馈和报告问题

欢迎贡献

要求和依赖项

角色

在元文件中未列出角色。请手动安装。

集合

以下集合应为标准 Ansible 安装的一部分。如有必要,请手动安装。

  • community.crypto
  • community.general

推荐

变量

查看 vars 中的默认值和示例。

工作流程

  1. 如果需要,将 shell 更改为 /bin/sh
shell> ansible mailserver -e 'ansible_shell_type=csh ansible_shell_executable=/bin/csh' -a 'sudo pw usermod freebsd -s /bin/sh'
  1. 安装角色
shell> ansible-galaxy role install vbotka.freebsd_mailserver
shell> ansible-galaxy role install vbotka.ansible_lib

可选择性安装角色

shell> ansible-galaxy role install vbotka.freebsd_mailserver_sieve
shell> ansible-galaxy role install vbotka.freebsd_mailserver_spamassassin
  1. 如有必要,安装集合
shell> ansible-galaxy collection install community.crypto
shell> ansible-galaxy collection install community.general
  1. 根据需要调整变量。

  2. 生成 OpenSSL Diffie-Hellman 参数

默认情况下,文件 dovecot_ssl_dh 由 Ansible 模块 openssl_dhparam 创建。

dovecot_ssl_dh_generate: true
dovecot_ssl_dh_cmd_generate: false

可以使用自定义命令 dovecot_ssl_dh_cmd 来创建 dovecot_ssl_dh

dovecot_ssl_dh_generate: false
dovecot_ssl_dh_cmd_generate: true
dovecot_ssl_dh_cmd: "openssl dhparam -out {{ dovecot_ssl_dh }} {{dovecot_ssl_dh_bits }}"

选项 dovecot_ssl_dh_generate(默认值:true)和 dovecot_ssl_dh_cmd_generate(默认值:false)是互斥的。如果两个选项都为 false,则使用文件 dovecot_ssl_dh_path(默认值:files/dh.pem)。该文件仅供角色测试用。切勿在生产环境中使用它。

生成包含 Diffie-Hellman 参数的文件可能需要很长时间。例如,使用 Intel(R) Core(TM) i5-8200Y CPU @ 1.30GHz 生成 4096 位参数需要约 40 分钟。将文件单独生成以加快配置是个好主意。

dovecot_ssl_dh_generate: false
dovecot_ssl_dh_cmd_generate: false
dovecot_ssl_dh_path: <path-to-generated-Diffie-Hellman-file>
  1. 创建 playbook 和 inventory
shell> cat freebsd-mailserver.yml

- hosts: mailserver
  roles:
    - vbotka.freebsd_mailserver
shell> cat hosts
[mailserver]
<mailserver-ip-or-fqdn>
[mailserver:vars]
ansible_connection=ssh
ansible_user=freebsd
ansible_become=true
ansible_become_method=sudo
ansible_python_interpreter=/usr/local/bin/python3.9
ansible_perl_interpreter=/usr/local/bin/perl
  1. 检查语法
shell> ansible-playbook freebsd-mailserver.yml --syntax-check
  1. 安装程序包
  • 从角色 vbotka.freebsd_mailserver 安装程序包
shell> ansible-playbook freebsd-mailserver.yml -t fm-packages -e fm_install=true
  • 如果您启用了 sieve
freebsd_mailserver_dovecot_protocols: imap pop3 lmtp sieve

则从角色 vbotka.freebsd_mailserver_sieve 安装程序包

shell> ansible-playbook freebsd-mailserver-sieve.yml -t fm_ds_packages -e fm_ds_install=true
  • 如果您启用了 spamassassin
postfix_master_cf_service_def: "inet  n       -       -       -       -       smtpd -o content_filter=spamfilter"

则从角色 vbotka.freebsd_mailserver_spamassassin 安装程序包

shell> ansible-playbook freebsd-mailserver-spamassassin.yml -t fm_sa_packages -e fm_sa_install=true
  1. 创建 Dovecot 的默认配置
shell> ansible-playbook freebsd-mailserver.yml -t dovecot_example_conf
  1. 试运行并显示更改
shell> ansible-playbook freebsd-mailserver.yml --check --diff
  1. 安装并配置邮件服务器
shell> ansible-playbook freebsd-mailserver.yml
  1. 考虑在 http://mxtoolbox.com/ 测试邮件服务器。

检查模式

创建 Dovecot 的默认配置文件以避免缺少文件错误

shell> ansible-playbook freebsd-mailserver.yml -t dovecot_example_conf

然后,运行检查模式

shell> ansible-playbook freebsd-mailserver.yml --check

Ansible lint

运行 ansible-lint 时使用配置文件 .ansible-lint.local。某些规则可能被禁用,某些警告可能被忽略。请查看配置文件中的说明。

shell> ansible-lint -c .ansible-lint.local

参考

许可证

许可证

作者信息

Vladimir Botka

关于项目

FreeBSD. Install and configure Postfix and Dovecot.

安装
ansible-galaxy install vbotka.freebsd_mailserver
许可证
bsd-2-clause
下载
228
拥有者