aboutsummaryrefslogtreecommitdiff
path: root/ansible/roles/postfix-satellite
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2018-11-26 22:33:54 +0100
committerTrygve Laugstøl <trygvis@inamo.no>2018-11-26 22:33:54 +0100
commitb7bccaf7ff75fd2234b9232f595cbc8e226b80e9 (patch)
tree3e2822166b9be455f7589e56ca28a685bbccd2d8 /ansible/roles/postfix-satellite
parent6fe44ad6366232314d45502d387ccbc671e84d9f (diff)
downloadinfra-b7bccaf7ff75fd2234b9232f595cbc8e226b80e9.tar.gz
infra-b7bccaf7ff75fd2234b9232f595cbc8e226b80e9.tar.bz2
infra-b7bccaf7ff75fd2234b9232f595cbc8e226b80e9.tar.xz
infra-b7bccaf7ff75fd2234b9232f595cbc8e226b80e9.zip
o Importing bitraf-base, packages and postfix-satellite from Bitraf.
o Configuring nextcloud.
Diffstat (limited to 'ansible/roles/postfix-satellite')
-rw-r--r--ansible/roles/postfix-satellite/handlers/main.yml8
-rw-r--r--ansible/roles/postfix-satellite/tasks/main.yml4
-rw-r--r--ansible/roles/postfix-satellite/tasks/postfix-satellite.yml70
3 files changed, 82 insertions, 0 deletions
diff --git a/ansible/roles/postfix-satellite/handlers/main.yml b/ansible/roles/postfix-satellite/handlers/main.yml
new file mode 100644
index 0000000..b6cdb87
--- /dev/null
+++ b/ansible/roles/postfix-satellite/handlers/main.yml
@@ -0,0 +1,8 @@
+---
+- name: reload postfix
+ service: name=postfix state=reloaded
+ become: yes
+
+- name: postmap /etc/postfix/sasl_passwd
+ become: yes
+ shell: postmap /etc/postfix/sasl_passwd
diff --git a/ansible/roles/postfix-satellite/tasks/main.yml b/ansible/roles/postfix-satellite/tasks/main.yml
new file mode 100644
index 0000000..3aeb3cc
--- /dev/null
+++ b/ansible/roles/postfix-satellite/tasks/main.yml
@@ -0,0 +1,4 @@
+---
+- tags: postfix-satellite
+ become: true
+ include: postfix-satellite.yml
diff --git a/ansible/roles/postfix-satellite/tasks/postfix-satellite.yml b/ansible/roles/postfix-satellite/tasks/postfix-satellite.yml
new file mode 100644
index 0000000..46f2fea
--- /dev/null
+++ b/ansible/roles/postfix-satellite/tasks/postfix-satellite.yml
@@ -0,0 +1,70 @@
+- name: Update apt cache
+ apt:
+ update_cache: yes
+ cache_valid_time: 3600
+- name: Install package
+ package:
+ name: "{{ item }}"
+ state: present
+ with_items:
+ - postfix
+ - libsasl2-modules
+ - swaks
+
+- name: "Configure postfix: main.cf"
+ tags: postfix-satellite-config
+ notify: reload postfix
+ lineinfile:
+ dest: /etc/postfix/main.cf
+ line: "{{ item.key }} = {{ item.value }}"
+ regexp: "^{{ item.key }} ="
+ with_items:
+ - key: "mydomain"
+ value: "bitraf.no"
+ - key: "myorigin"
+ value: "bitraf.no"
+ - key: "mydestination"
+ value: ""
+ - key: "smtp_sasl_auth_enable"
+ value: "yes"
+ - key: "smtp_sasl_password_maps"
+ value: "hash:/etc/postfix/sasl_passwd"
+ - key: "smtp_sasl_security_options"
+ value: "noanonymous"
+ - key: "smtp_sasl_tls_security_options"
+ value: "noanonymous"
+ - key: "smtp_tls_security_level"
+ value: "encrypt"
+ - key: "header_size_limit"
+ value: "4096000"
+ - key: "relayhost"
+ value: "{{ postfix__relayhost }}"
+
+- name: Create /etc/postfix/sasl_passwd
+ tags: postfix-satellite-config
+ copy:
+ dest: /etc/postfix/sasl_passwd
+ content: ""
+ force: no
+ mode: 0600
+
+- name: "Configure postfix: sasl_passwd"
+ tags: postfix-satellite-config
+ no_log: yes
+ lineinfile:
+ dest: /etc/postfix/sasl_passwd
+ line: "{{ item.host }} {{ item.username }}:{{ item.password }}"
+ regexp: "^{{ item.host|regex_escape() }}"
+ with_items: "{{ postfix.sasl_password }}"
+ notify: postmap /etc/postfix/sasl_passwd
+
+- name: Enable postfix service
+ service:
+ name: postfix
+ state: started
+ enabled: yes
+
+- name: Remove old /etc/postfix/sasl directory
+ file:
+ state: absent
+ path: "/etc/postfix/sasl"