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]

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
postfix_freebsd:
  template: handlers-auto1.yml.j2
  handlers:

    - handler: 'enable and start postfix'
      module: service
      params:
        - 'name: postfix'
        - 'state: started'
        - 'enabled: true'

    - handler: 'disable and stop postfix'
      module: service
      params:
        - 'name: postfix'
        - 'state: stopped'
        - 'enabled: false'

    - handler: 'reload postfix'
      module: service
      params:
        - 'name: postfix'
        - 'state: reloaded'
      conditions:
        - '- cl_service_postfix_enable|bool'

    - handler: 'restart postfix'
      module: service
      params:
        - 'name: postfix'
        - 'state: restarted'
      conditions:
        - '- cl_service_postfix_enable|bool'

    - handler: 'postfix check'
      module: command
      params:
        - 'cmd: /usr/local/sbin/postfix check'

    - handler: 'newaliases'
      module: command
      params:
        - 'cmd: /usr/bin/newaliases'

#    - handler: 'postmap smtp sasl passwords'
#      module: command
#      params:
#        - 'cmd: /usr/local/sbin/postmap {{ postfix_main_cf_smtp_sasl_password_maps }}'

#    - handler: 'postmap virtual aliases'
#      module: command
#      params:
#        - 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]

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
sendmail_freebsd:
  template: handlers-auto1.yml.j2
  handlers:

    - handler: 'enable and start sendmail'
      module: service
      params:
        - 'name: sendmail'
        - 'state: started'
        - 'enabled: true'

    - handler: 'disable and stop sendmail'
      module: service
      params:
        - 'name: sendmail'
        - 'state: stopped'
        - 'enabled: false'

    - handler: 'reload sendmail'
      module: service
      params:
        - 'name: sendmail'
        - 'state: reloaded'
      conditions:
        - '- cl_service_sendmail_enable|bool'

    - handler: 'restart sendmail'
      module: service
      params:
        - 'name: sendmail'
        - 'state: restarted'
      conditions:
        - '- cl_service_sendmail_enable|bool'

    - handler: 'start sendmail'
      module: service
      params:
        - 'name: sendmail'
        - 'state: started'

    - handler: 'stop sendmail'
      module: service
      params:
        - 'name: sendmail'
        - '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]

1
2
3
postfix:
  name:
    - '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]

1
2
3
4
postfix:
  name: 'postfix'
  state: '{{ cl_service_postfix_state }}'
  enabled: '{{ cl_service_postfix_enable }}'

See also

See custom Postfix variables contrib/postfix/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]

1
2
3
4
sendmail:
  name: 'sendmail'
  state: '{{ cl_service_sendmail_state }}'
  enabled: '{{ cl_service_sendmail_enable }}'

See also

See custom Postfix variables contrib/postfix/config-light-postfix.yml.

Files

contrib/postfix/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/config-light-postfix.yml]

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
---

# 28.4.2. Replace the Default MTA
# https://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/mail-changingmta.html

cl_myhostname: host99.region9.example.com

# conf-light/files.d/mailer-conf
# Execute the Postfix sendmail program, named /usr/local/sbin/sendmail
cl_mailerconf:
  - 'sendmail      /usr/local/sbin/sendmail'
  - 'send-mail     /usr/local/sbin/sendmail'
  - 'mailq         /usr/local/sbin/sendmail'
  - 'newaliases    /usr/local/sbin/sendmail'

# conf-light/files.d/rc-rconf
cl_rcconf_postfix_enable: 'YES'
cl_rcconf_sendmail_enable: 'NO'
cl_rcconf_sendmail_submit_enable: 'NO'
cl_rcconf_sendmail_outbound_enable: 'NO'
cl_rcconf_sendmail_msp_queue_enable: 'NO'

# conf-light/files.d/periodic-conf
cl_periodicconf_daily_clean_hoststat_enable: "NO"
cl_periodicconf_daily_status_mail_rejects_enable: "NO"
cl_periodicconf_daily_status_include_submit_mailq: "NO"
cl_periodicconf_daily_submit_queuerun: "NO"

# Services
cl_service_sendmail_enable: false
cl_service_sendmail_state: 'stopped'
cl_service_postfix_enable: true
cl_service_postfix_state: 'started'

# If you are using SASL, you need to make sure that postfix has access
# to read the sasldb file.  This is accomplished by adding postfix to
# group mail and making the /usr/local/etc/sasldb* file(s) readable by
# group mail (this should be the default for new installs).

# EOF
...

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]

1
2
3
4
5
6
7
8
mailerconf:
  path: '/etc/mail/mailer.conf'
  template:
    path: 'mailer.conf.j2'
    force: true
  owner: 'root'
  group: 'wheel'
  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]

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

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

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

1
2
3
ssmtp:
  name:
    - '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
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
---

# sSMTP - Simple SMTP
# https://wiki.debian.org/sSMTP

# linux-postinstall FQDN
lp_fqdn: "host99.region9.example.com"

# NEVER USE PLAINTEXT PASSWORD. USE VAULT INSTEAD
smtp_client_password_mail_example_com: "PASSWORD"

# conf-light/files.d/ssmtp-conf
cl_ssmtp_srv: "mail.example.com"
cl_ssmtp_srv_domain: "example.com"

cl_ssmtp_postmaster_address: "postmaster@{{ lp_fqdn }}"
cl_ssmtp_mailhub: "{{ cl_ssmtp_srv }}:587"
cl_ssmtp_rewriteDomain: "{{ cl_ssmtp_srv_domain }}"

cl_ssmtp_usetls: "Yes"
cl_ssmtp_usestarttls: "Yes"

cl_ssmtp_authuser: "smtp_client"
cl_ssmtp_authpass: "{{ smtp_client_password_mail_example_com }}"
cl_ssmtp_authmethod: "LOGIN"

cl_ssmtp_FromLineOverride: "yes"

# conf-light/files.d/revaliases
cl_ssmtp_revaliases:
  - "root:root@{{ cl_ssmtp_srv_domain }}:{{ cl_ssmtp_srv }}:587"
  - "admin:admin@{{ cl_ssmtp_srv_domain }}:{{ cl_ssmtp_srv }}:587"
  - "user1:user1@{{ cl_ssmtp_srv_domain }}:{{ cl_ssmtp_srv }}:587"

# EOF
...

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]

1
2
3
4
5
6
7
8
revaliases:
  path: '/etc/ssmtp/revaliases'
  force: true
  owner: 'root'
  group: 'mail'
  mode: 'u=rw,g=r'
  template:
    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]

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

See also

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