mirror of
https://git.local.zernis.ch/simon/homeserver.zernis.ch.git
synced 2025-12-16 14:47:29 +01:00
first commit
This commit is contained in:
66
roles/defaults/tasks/postfix.yml
Normal file
66
roles/defaults/tasks/postfix.yml
Normal file
@@ -0,0 +1,66 @@
|
||||
---
|
||||
- name: Update /etc/hostname
|
||||
become: true
|
||||
ansible.builtin.hostname:
|
||||
name: '{{ hostname }}'
|
||||
|
||||
- name: Update /etc/hosts
|
||||
become: true
|
||||
ansible.builtin.lineinfile:
|
||||
path: /etc/hosts
|
||||
regexp: '^127.0.1.1'
|
||||
line: '127.0.1.1 {{ hostname }}.{{ domain }} {{ hostname }}'
|
||||
|
||||
- name: Update /etc/aliases | set email adress
|
||||
become: true
|
||||
ansible.builtin.lineinfile:
|
||||
path: /etc/aliases
|
||||
regexp: '^root:'
|
||||
line: 'root: {{ email_reports }}'
|
||||
notify: New aliases
|
||||
|
||||
- name: Ensure postfix is installed
|
||||
become: true
|
||||
ansible.builtin.package:
|
||||
name: postfix
|
||||
state: present
|
||||
|
||||
- name: Update Postfix configuration
|
||||
become: true
|
||||
ansible.builtin.lineinfile:
|
||||
dest: "{{ postfix_config_file }}"
|
||||
line: "{{ item.name }} = {{ item.value }}"
|
||||
regexp: "^{{ item.name }} ="
|
||||
mode: '0644'
|
||||
with_items:
|
||||
- name: inet_protocols
|
||||
value: "{{ postfix_inet_protocols }}"
|
||||
- name: relayhost
|
||||
value: "{{ postfix_relayhost }}"
|
||||
- name: myhostname
|
||||
value: "{{ hostname }}.{{ domain }}"
|
||||
- name: smtp_sasl_auth_enable
|
||||
value: "{{ smtp_sasl_enable }}"
|
||||
- name: smtp_sasl_password_maps
|
||||
value: "{{ smtp_sasl_file }}"
|
||||
- name: smtp_sasl_security_options
|
||||
value: "{{ smtp_sasl_options }}"
|
||||
|
||||
- name: Copy relay_passwd
|
||||
ansible.builtin.template:
|
||||
src: "../templates/relay_passwd.j2"
|
||||
dest: /etc/postfix/relay_passwd
|
||||
owner: root
|
||||
group: root
|
||||
mode: '0644'
|
||||
|
||||
notify:
|
||||
- Postmap relay_passwd
|
||||
- Restart postfix
|
||||
|
||||
- name: Ensure postfix is started and enabled at boot
|
||||
become: true
|
||||
ansible.builtin.service:
|
||||
name: postfix
|
||||
state: "{{ postfix_service_state }}"
|
||||
enabled: "{{ postfix_service_enabled }}"
|
||||
Reference in New Issue
Block a user