ansible-edda/machine.yml
2022-08-27 22:07:23 +02:00

94 lines
2.3 KiB
YAML

---
- hosts: yggdrasil
vars_files:
- secrets.yml
tasks:
# ----------------------------------------------------------------------------------------------
# NTP.
# ----------------------------------------------------------------------------------------------
- name: Install systemd-timesyncd
apt:
name: systemd-timesyncd
- name: Enable/start NTP
service:
name: systemd-timesyncd
state: started
enabled: yes
# ----------------------------------------------------------------------------------------------
# E-mail configuration.
# ----------------------------------------------------------------------------------------------
- name: Configure mailname
template:
src: ./root/etc/mailname.j2
dest: /etc/mailname
mode: 0644
register: mail_mailname
- name: Configure aliases
template:
src: ./root/etc/aliases.j2
dest: /etc/aliases
mode: 0644
register: mail_aliases
- name: Update aliases
command: newaliases
when: mail_aliases is changed
- name: Configure mailutils
template:
src: ./root/etc/mailutils.conf.j2
dest: /etc/mailutils.conf
mode: 0644
- name: Install postfix
apt:
name:
- postfix
- ca-certificates
- libsasl2-modules
register: mail_postfix_install
- name: Configure postfix
template:
src: ./root/etc/postfix/main.cf.j2
dest: /etc/postfix/main.cf
mode: 0644
register: mail_postfix_cfg
- name: Configure credentials
template:
src: ./root/etc/postfix/sasl_passwd.j2
dest: /etc/postfix/sasl_passwd
mode: 0600
register: mail_postfix_credentials
- name: Create hash database
command: postmap /etc/postfix/sasl_passwd
when:
mail_postfix_credentials is changed
- name: Set hash database permissions
file:
path: /etc/postfix/sasl_passwd.db
mode: 0600
- name: Enable/restart postfix
service:
name: postfix
state: restarted
enabled: yes
when:
mail_mailname is changed or
mail_aliases is changed or
mail_postfix_install is changed or
mail_postfix_cfg is changed or
mail_postfix_credentials is changed