FreeBSD Postfix

Handlers

contrib/postfix/conf-light/handlers.d/postfix-freebsd.yml

Synopsis: Create handlers for Postfix.

Use template (3) to create handlers.

[contrib/postfix/conf-light/handlers.d/postfix-freebsd.yml]

 1---
 2postfix_freebsd:
 3  template: handlers-auto1.yml.j2
 4  handlers:
 5    - handler: Start postfix
 6      listen: start postfix
 7      module: vbotka.freebsd.service
 8      params:
 9        - "script: postfix"
10        - "command: start"
11
12    - handler: Stop postfix
13      listen: stop postfix
14      module: vbotka.freebsd.service
15      params:
16        - "script: postfix"
17        - "command: stop"
18
19    - handler: Reload postfix
20      listen: reload postfix
21      module: vbotka.freebsd.service
22      params:
23        - "script: postfix"
24        - "command: reload"
25      conditions:
26        - "- cl_service_postfix_enable | bool"
27
28    - handler: Restart postfix
29      listen: restart postfix
30      module: vbotka.freebsd.service
31      params:
32        - "script: postfix"
33        - "command: restart"
34      conditions:
35        - "- cl_service_postfix_enable | bool"
36
37    - handler: Postfix check
38      listen: postfix check
39      module: command
40      params:
41        - "cmd: /usr/local/sbin/postfix check"
42
43    - handler: Newaliases
44      listen: newaliases
45      module: command
46      params:
47        - "cmd: /usr/bin/newaliases"
48
49#    - handler: 'postmap smtp sasl passwords'
50#      module: command
51#      params:
52#        - 'cmd: /usr/local/sbin/postmap {{ postfix_main_cf_smtp_sasl_password_maps }}'
53
54#    - handler: 'postmap virtual aliases'
55#      module: command
56#      params:
57#        - cmd: /usr/local/sbin/postmap {{ postfix_virtual }}'

See also

See setup.yml how the handlers are created.

contrib/postfix/conf-light/handlers.d/sendmail-freebsd.yml

Synopsis: Create handlers for Sendmail.

Use template (3) to create handlers.

[contrib/postfix/conf-light/handlers.d/sendmail-freebsd.yml]

 1---
 2sendmail_freebsd:
 3  template: handlers-auto1.yml.j2
 4  handlers:
 5    - handler: Start sendmail
 6      listen: start sendmail
 7      module: vbotka.freebsd.service
 8      params:
 9        - 'script: sendmail'
10        - 'command: start'
11
12    - handler: Stop sendmail
13      listen: stop sendmail
14      module: vbotka.freebsd.service
15      params:
16        - 'script: sendmail'
17        - 'command: stop'
18
19    - handler: Reload sendmail
20      listen: reload sendmail
21      module: vbotka.freebsd.service
22      params:
23        - 'script: sendmail'
24        - 'command: reload'
25      conditions:
26        - "- cl_service_sendmail_enable | bool"
27
28    - handler: Restart sendmail
29      listen: restart sendmail
30      module: vbotka.freebsd.service
31      params:
32        - 'script: sendmail'
33        - 'command: restart'
34      conditions:
35        - "- cl_service_sendmail_enable | bool"

See also

See setup.yml how the handlers are created.

Packages

contrib/postfix/conf-light/packages.d/postfix.yml

Synopsis: Install Postfix.

Use package or port (3) to install Postfix.

[contrib/postfix/conf-light/packages.d/postfix.yml]

1---
2postfix:
3  module: pkgng
4  name:
5    - mail/postfix

See also

See packages.yml how the FreeBSD packages or ports are installed.

Services

contrib/postfix/conf-light/services.d/postfix.yml

Synopsis: Configure Postfix service.

Set service (3) state (4). Run the service on boot (5).

[contrib/postfix/conf-light/services.d/postfix.yml]

1---
2postfix:
3  name: postfix
4  state: "{{ cl_service_postfix_state }}"
5  enabled: "{{ cl_service_postfix_enable }}"

See also

See custom Postfix variables contrib/postfix/host_vars/srv.example.com/config-light-postfix.yml. See services.yml how the services are configured.

contrib/postfix/conf-light/services.d/sendmail.yml

Synopsis: Configure Sendmail service.

Set service (3) state (4). Do not run the service on boot (5).

[contrib/postfix/conf-light/services.d/sendmail.yml]

1---
2sendmail:
3  name: sendmail
4  state: "{{ cl_service_sendmail_state }}"
5  enabled: "{{ cl_service_sendmail_enable }}"

Files

contrib/postfix/host_vars/srv.example.com/config-light-postfix.yml

Synopsis: Custom variables for Postfix.

Put the host-specific variables (6) into the host_vars. Optionally other variables might be put into the group_vars.

[contrib/postfix/host_vars/srv.example.com/config-light-postfix.yml]

 1---
 2
 3# 28.4.2. Replace the Default MTA
 4# https://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/mail-changingmta.html
 5
 6cl_myhostname: srv.example.com
 7
 8# conf-light/files.d/mailer-conf
 9# Execute the Postfix sendmail program, named /usr/local/sbin/sendmail
10cl_mailerconf:
11  - sendmail      /usr/local/sbin/sendmail
12  - send-mail     /usr/local/sbin/sendmail
13  - mailq         /usr/local/sbin/sendmail
14  - newaliases    /usr/local/sbin/sendmail
15
16# conf-light/files.d/rc-rconf
17cl_rcconf_postfix_enable: "YES"
18cl_rcconf_sendmail_enable: "NO"
19cl_rcconf_sendmail_submit_enable: "NO"
20cl_rcconf_sendmail_outbound_enable: "NO"
21cl_rcconf_sendmail_msp_queue_enable: "NO"
22
23# conf-light/files.d/periodic-conf
24cl_periodicconf_daily_clean_hoststat_enable: "NO"
25cl_periodicconf_daily_status_mail_rejects_enable: "NO"
26cl_periodicconf_daily_status_include_submit_mailq: "NO"
27cl_periodicconf_daily_submit_queuerun: "NO"
28
29# Services
30cl_service_sendmail_enable: false
31cl_service_sendmail_state: stop
32cl_service_postfix_enable: true
33cl_service_postfix_state: start
34
35# If you are using SASL, you need to make sure that postfix has access
36# to read the sasldb file.  This is accomplished by adding postfix to
37# group mail and making the /usr/local/etc/sasldb* file(s) readable by
38# group mail (this should be the default for new installs).
39
40# EOF

contrib/postfix/conf-light/files.d/mailer-conf.yml

Synopsis: Create file.

Create file (3) from the template (5).

[contrib/postfix/conf-light/files.d/mailer-conf.yml]

1---
2mailerconf:
3  path: /etc/mail/mailer.conf
4  template:
5    path: mailer.conf.j2
6    force: true
7  owner: root
8  group: wheel
9  mode: "0644"

contrib/postfix/conf-light/files.d/periodic-conf.yml

Synopsis: Modify file.

Modify file (3) with the lines (8).

[contrib/postfix/conf-light/files.d/periodic-conf.yml]

 1---
 2periodic_conf:
 3  path: /etc/periodic.conf
 4  create: true
 5  owner: root
 6  group: wheel
 7  mode: "0644"
 8  lines:
 9    - regexp: ^daily_clean_hoststat_enable(.*)$
10      line: daily_clean_hoststat_enable="{{ cl_periodicconf_daily_clean_hoststat_enable }}"
11    - regexp: ^daily_status_mail_rejects_enable(.*)$
12      line: daily_status_mail_rejects_enable="{{ cl_periodicconf_daily_status_mail_rejects_enable }}"
13    - regexp: ^daily_status_include_submit_mailq(.*)$
14      line: daily_status_include_submit_mailq="{{ cl_periodicconf_daily_status_include_submit_mailq }}"
15    - regexp: ^daily_submit_queuerun(.*)$
16      line: daily_submit_queuerun="{{ cl_periodicconf_daily_submit_queuerun }}"

contrib/postfix/conf-light/files.d/postfix-main-cf.yml

Synopsis: Modify file and notify handlers.

Modify file (3) with the lines (10) and notify handlers (8).

[contrib/postfix/conf-light/files.d/postfix-main-cf.yml]

 1---
 2postfix_main_cf:
 3  path: /usr/local/etc/postfix/main.cf
 4  create: true
 5  owner: root
 6  group: wheel
 7  mode: "0644"
 8  handlers:
 9    - postfix_freebsd reload postfix
10  lines:
11    - regexp: ^myhostname\s*=\s*(.*)$
12      line: myhostname = {{ cl_myhostname }}

contrib/postfix/conf-light/files.d/rc-conf.yml

Synopsis: Modify file.

Modify file (3) with the lines (8).

[contrib/postfix/conf-light/files.d/rc-conf.yml]

 1---
 2rcconf:
 3  path: /etc/rc.conf
 4  create: true
 5  owner: root
 6  group: wheel
 7  mode: "0644"
 8  lines:
 9    - regexp: ^sendmail_enable(.*)$
10      line: sendmail_enable="{{ cl_rcconf_sendmail_enable }}"
11    - regexp: ^sendmail_submit_enable(.*)$
12      line: sendmail_submit_enable="{{ cl_rcconf_sendmail_submit_enable }}"
13    - regexp: ^sendmail_outbound_enable(.*)$
14      line: sendmail_outbound_enable="{{ cl_rcconf_sendmail_outbound_enable }}"
15    - regexp: ^sendmail_msp_queue_enable(.*)$
16      line: sendmail_msp_queue_enable="{{ cl_rcconf_sendmail_msp_queue_enable }}"
17    - regexp: ^postfix_enable(.*)$
18      line: postfix_enable="{{ cl_rcconf_postfix_enable }}"