diff --git a/defaults/main.yml b/defaults/main.yml index c75a20e7973189959cb34fa2e8e010801cca7300..97f9790818ad84183bd1cf0f38a80e317f621edc 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 0000000000000000000000000000000000000000..446670bf991ffd93c6f0c81fad9b4bb5027cd00b --- /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 a4a28f32c2d226a388fed7fcc496fe75f443becc..60ca5c76441905988575a113bf74746467700057 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