From b105ce5e43e345871f49e8cbfc998f1bd5c3dea0 Mon Sep 17 00:00:00 2001
From: Chris Coley <chris@codingallnight.com>
Date: Mon, 18 Jun 2018 17:44:07 -0700
Subject: [PATCH] Adding a task list to install Postfix on Debian
---
defaults/main.yml | 3 +++
tasks/install-postfix_debian.yml | 21 +++++++++++++++++++++
tasks/main.yml | 10 ++++++++++
3 files changed, 34 insertions(+)
create mode 100644 tasks/install-postfix_debian.yml
diff --git a/defaults/main.yml b/defaults/main.yml
index c75a20e..97f9790 100644
--- a/defaults/main.yml
+++ b/defaults/main.yml
@@ -1,4 +1,7 @@
---
+# The name of this mail system, set in '/etc/mailname'
+postfix__mailname: '{{ ansible_fqdn }}'
+
## Variables for the main.cf template, in top-down order
postfix__myorigin:
postfix__smtpd_banner: '$myhostname ESMTP $mail_name ({{ ansible_distribution }})'
diff --git a/tasks/install-postfix_debian.yml b/tasks/install-postfix_debian.yml
new file mode 100644
index 0000000..446670b
--- /dev/null
+++ b/tasks/install-postfix_debian.yml
@@ -0,0 +1,21 @@
+---
+- name: Configure /etc/mailname on Debian hosts
+ copy:
+ content: "{{ postfix__mailname + '\n' }}"
+ dest: /etc/mailname
+ owner: root
+ group: root
+ mode: 0644
+ notify: ['reload postfix']
+
+- name: Install Postfix and related packages
+ apt:
+ name: '{{ item }}'
+ state: present
+ cache_valid_time: 3600
+ with_items:
+ - postfix
+ - mailutils
+ - make
+...
+# vi: set ts=2 sts=2 sw=2 et ft=yaml:
diff --git a/tasks/main.yml b/tasks/main.yml
index a4a28f3..60ca5c7 100644
--- a/tasks/main.yml
+++ b/tasks/main.yml
@@ -1,4 +1,14 @@
---
+- include_tasks: '{{ task_file }}'
+ loop_control:
+ loop_var: task_file
+ with_first_found:
+ - tasks/install-postfix_{{ ansible_distribution | lower }}-{{ ansible_distribution_version | lower }}.yml
+ - tasks/install-postfix_{{ ansible_distribution | lower }}-{{ ansible_distribution_release | lower }}.yml
+ - tasks/install-postfix_{{ ansible_distribution | lower }}-{{ ansible_distribution_major_version | lower }}.yml
+ - tasks/install-postfix_{{ ansible_distribution | lower }}.yml
+ - tasks/install-postfix_{{ ansible_os_family | lower }}.yml
+
- name: Generate Postfix 'main.cf' configuration
template:
src: templates/main.cf.j2
--
GitLab