Examples

FreeBSD Postfix

Handlers

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

Synopsis: Create handlers for Postfix.

Use template (2) to create handlers.

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

 1postfix_freebsd:
 2  template: handlers-auto1.yml.j2
 3  handlers:
 4
 5    - handler: enable and start postfix
 6      module: service
 7      params:
 8        - 'name: postfix'
 9        - 'state: started'
10        - 'enabled: true'
11
12    - handler: disable and stop postfix
13      module: service
14      params:
15        - 'name: postfix'
16        - 'state: stopped'
17        - 'enabled: false'
18
19    - handler: reload postfix
20      module: service
21      params:
22        - 'name: postfix'
23        - 'state: reloaded'
24      conditions:
25        - '- cl_service_postfix_enable|bool'
26
27    - handler: restart postfix
28      module: service
29      params:
30        - 'name: postfix'
31        - 'state: restarted'
32      conditions:
33        - '- cl_service_postfix_enable|bool'
34
35    - handler: postfix check
36      module: command
37      params:
38        - 'cmd: /usr/local/sbin/postfix check'
39
40    - handler: newaliases
41      module: command
42      params:
43        - 'cmd: /usr/bin/newaliases'
44
45#    - handler: 'postmap smtp sasl passwords'
46#      module: command
47#      params:
48#        - 'cmd: /usr/local/sbin/postmap {{ postfix_main_cf_smtp_sasl_password_maps }}'
49
50#    - handler: 'postmap virtual aliases'
51#      module: command
52#      params:
53#        - 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 (2) to create handlers.

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

 1sendmail_freebsd:
 2  template: handlers-auto1.yml.j2
 3  handlers:
 4
 5    - handler: enable and start sendmail
 6      module: service
 7      params:
 8        - 'name: sendmail'
 9        - 'state: started'
10        - 'enabled: true'
11
12    - handler: disable and stop sendmail
13      module: service
14      params:
15        - 'name: sendmail'
16        - 'state: stopped'
17        - 'enabled: false'
18
19    - handler: reload sendmail
20      module: service
21      params:
22        - 'name: sendmail'
23        - 'state: reloaded'
24      conditions:
25        - '- cl_service_sendmail_enable|bool'
26
27    - handler: restart sendmail
28      module: service
29      params:
30        - 'name: sendmail'
31        - 'state: restarted'
32      conditions:
33        - '- cl_service_sendmail_enable|bool'
34
35    - handler: start sendmail
36      module: service
37      params:
38        - 'name: sendmail'
39        - 'state: started'
40
41    - handler: stop sendmail
42      module: service
43      params:
44        - 'name: sendmail'
45        - 'state: stopped'

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]

1postfix:
2  module: pkgng
3  name:
4    - 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 (2) state (3). Run the service on boot (4).

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

1postfix:
2  name: postfix
3  state: "{{ cl_service_postfix_state }}"
4  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 (2) state (3). Do not run the service on boot (4).

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

1sendmail:
2  name: sendmail
3  state: "{{ cl_service_sendmail_state }}"
4  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: stopped
32cl_service_postfix_enable: true
33cl_service_postfix_state: started
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
41...

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

Synopsis: Create file.

Create file (2) from the template (4).

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

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

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

Synopsis: Modify file.

Modify file (2) with the lines (7).

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

 1periodic_conf:
 2  path: /etc/periodic.conf
 3  create: true
 4  owner: root
 5  group: wheel
 6  mode: '0644'
 7  lines:
 8    - regexp: '^daily_clean_hoststat_enable(.*)$'
 9      line: 'daily_clean_hoststat_enable="{{ cl_periodicconf_daily_clean_hoststat_enable }}"'
10    - regexp: '^daily_status_mail_rejects_enable(.*)$'
11      line: 'daily_status_mail_rejects_enable="{{ cl_periodicconf_daily_status_mail_rejects_enable }}"'
12    - regexp: '^daily_status_include_submit_mailq(.*)$'
13      line: 'daily_status_include_submit_mailq="{{ cl_periodicconf_daily_status_include_submit_mailq }}"'
14    - regexp: '^daily_submit_queuerun(.*)$'
15      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 (2) with the lines (9) and notify handlers (7).

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

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

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

Synopsis: Modify file.

Modify file (2) with the lines (7).

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

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

Armbian Simple SMTP

Packages

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

Synopsis: Install Simple SMTP.

Use package (3) to install sSMTP.

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

1ssmtp:
2  module: pkgng
3  name:
4    - mail/ssmtp

See also

See packages.yml how the Linux packages are installed.

Files

contrib/ssmtp/config-light-ssmtp.yml

Synopsis: Custom variables for sSMTP.

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

[contrib/ssmtp/config-light-ssmtp.yml]

 1---
 2
 3# sSMTP - Simple SMTP
 4# https://wiki.debian.org/sSMTP
 5
 6# linux-postinstall FQDN
 7lp_fqdn: srv.example.com
 8
 9# NEVER USE PLAINTEXT PASSWORD. USE VAULT INSTEAD
10smtp_client_password_mail_example_com: PASSWORD
11
12# conf-light/files.d/ssmtp-conf
13cl_ssmtp_srv: mail.example.com
14cl_ssmtp_srv_domain: example.com
15
16cl_ssmtp_postmaster_address: "postmaster@{{ lp_fqdn }}"
17cl_ssmtp_mailhub: "{{ cl_ssmtp_srv }}:587"
18cl_ssmtp_rewriteDomain: "{{ cl_ssmtp_srv_domain }}"
19
20cl_ssmtp_usetls: "Yes"
21cl_ssmtp_usestarttls: "Yes"
22
23cl_ssmtp_authuser: smtp_client
24cl_ssmtp_authpass: "{{ smtp_client_password_mail_example_com }}"
25cl_ssmtp_authmethod: LOGIN
26
27cl_ssmtp_FromLineOverride: "yes"
28
29# conf-light/files.d/revaliases
30cl_ssmtp_revaliases:
31  - "root:root@{{ cl_ssmtp_srv_domain }}:{{ cl_ssmtp_srv }}:587"
32  - "admin:admin@{{ cl_ssmtp_srv_domain }}:{{ cl_ssmtp_srv }}:587"
33  - "user1:user1@{{ cl_ssmtp_srv_domain }}:{{ cl_ssmtp_srv }}:587"
34
35# EOF
36...

contrib/ssmtp/conf-light/files.d/revaliases.yml

Synopsis: Create file.

Create file (2) from the template (8).

[contrib/ssmtp/conf-light/files.d/revaliases.yml]

1revaliases:
2  path: /etc/ssmtp/revaliases
3  force: true
4  owner: root
5  group: mail
6  mode: 'u=rw,g=r'
7  template:
8    path: revaliases.j2

See also

See template revaliases.j2. See how files are created from template files-template.yml.

contrib/ssmtp/conf-light/files.d/ssmtp-conf.yml

Synopsis: Create file.

Create file (2) from the template (8).

[contrib/ssmtp/conf-light/files.d/ssmtp-conf.yml]

1ssmtp_conf:
2  path: /etc/ssmtp/ssmtp.conf
3  force: true
4  owner: root
5  group: mail
6  mode: 'u=rw,g=r'
7  template:
8    path: ssmtp.conf.j2

See also

See template ssmtp.conf.j2. See how files are created from template files-template.yml.