servers/roles/opensmtpd/tasks/main.yml

34 lines
786 B
YAML

- name: Install mail server
package:
name: opensmtpd
# Alpine puts its configuration in /etc/smtpd, Debian in /etc
- when: ansible_os_family == 'Debian'
block:
- name: Create configuration directory
file:
path: /etc/smtpd
state: directory
- name: Link configuration
file:
path: "/etc/smtpd/{{ item }}"
src: "/etc/{{ item }}"
state: link
loop:
- smtpd.conf
- aliases
notify: restart smtpd
- name: Configure mail server
template:
dest: /etc/smtpd/smtpd.conf
src: smtpd.conf.j2
follow: true
notify: restart smtpd
- name: Enable mail server
service:
name: "{% if ansible_os_family == 'Alpine' %}smtpd{% else %}opensmtpd{% endif %}"
enabled: yes
state: started