From 6c5e880938f45fb02e9844d9751a2e7705249334 Mon Sep 17 00:00:00 2001 From: Gregory Colpart Date: Mon, 2 Jan 2017 00:32:29 +0100 Subject: [PATCH] add slow_transport configuration for Postfix role and disable Postfix customization in evolinux-base role --- evolinux-base/README.md | 6 +- evolinux-base/defaults/main.yml | 6 +- evolinux-base/handlers/main.yml | 12 ---- evolinux-base/tasks/postfix.yml | 24 +------ .../tasks/postfix_slow_transports.yml | 69 ------------------- postfix/README.md | 4 +- postfix/handlers/main.yml | 7 ++ postfix/tasks/main.yml | 2 + postfix/tasks/slow_transport.yml | 44 ++++++++++++ 9 files changed, 61 insertions(+), 113 deletions(-) delete mode 100644 evolinux-base/tasks/postfix_slow_transports.yml create mode 100644 postfix/tasks/slow_transport.yml diff --git a/evolinux-base/README.md b/evolinux-base/README.md index 4ee52e26..7a086895 100644 --- a/evolinux-base/README.md +++ b/evolinux-base/README.md @@ -23,11 +23,7 @@ Main variables are : * `evolinux_delete_nfs`: delete NFS tools (default: `True`) * `evolinux_ntp_server`: custom NTP server host or IP (default: `Null`) * `evolinux_additional_packages`: optional additional packages to install (default: `[]`) -* `evolinux_postfix_slow_transports_enabled`: configure slow transports (default: `True`) ; -* `evolinux_postfix_remove_exim`: remove Exim4 packages (default: `True`) ; -* `evolinux_postfix_myorigin`: `myorigin` variable for Postfix (default: value of `ansible_fqdn`) ; -* `evolinux_postfix_myhostname`: `myhostname` variable for Postfix (default: value of `ansible_fqdn`) ; -* `evolinux_postfix_mydestination`: `mydestination` variable for Postfix (default: `$myhostname`) ; +* `evolinux_postfix_purge_exim`: purge Exim packages (default: `True`) ; * `evolinux_ssh_password_auth_addresses`: list of addresses that can authenticate with a password (default: `[]`) * `evolinux_ssh_disable_root`: disable SSH access for root (default: `True`) diff --git a/evolinux-base/defaults/main.yml b/evolinux-base/defaults/main.yml index f784dc03..f736776d 100644 --- a/evolinux-base/defaults/main.yml +++ b/evolinux-base/defaults/main.yml @@ -21,11 +21,7 @@ evolinux_apt_remove_aptitude: True # postfix -evolinux_postfix_myorigin: "{{ ansible_fqdn }}" -evolinux_postfix_myhostname: "{{ ansible_fqdn }}" -evolinux_postfix_mydestination: "$myhostname" -evolinux_postfix_slow_transports_enabled: True -evolinux_postfix_remove_exim: True +evolinux_postfix_purge_exim: True # kernel diff --git a/evolinux-base/handlers/main.yml b/evolinux-base/handlers/main.yml index ac04ad9f..489b6667 100644 --- a/evolinux-base/handlers/main.yml +++ b/evolinux-base/handlers/main.yml @@ -53,15 +53,3 @@ command: newaliases changed_when: False -- name: restart postfix - service: - name: postfix - state: restarted - -- name: reload postfix - service: - name: postfix - state: reloaded - -- name: postmap transport - command: postmap /etc/postfix/transport diff --git a/evolinux-base/tasks/postfix.yml b/evolinux-base/tasks/postfix.yml index 2f82c032..70cc2566 100644 --- a/evolinux-base/tasks/postfix.yml +++ b/evolinux-base/tasks/postfix.yml @@ -11,20 +11,6 @@ - packages - postfix -- name: main.cf is configured - lineinfile: - dest: /etc/postfix/main.cf - regexp: "^#? *{{ item.key }} *=" - line: "{{ item.key }} = {{ item.value }}" - with_items: - - { key: "myorigin", value: "{{ evolinux_postfix_myorigin }}" } - - { key: "myhostname", value: "{{ evolinux_postfix_myhostname }}" } - - { key: "mydestination", value: "{{ evolinux_postfix_mydestination }}" } - - { key: "disable_vrfy_command", value: "yes" } - notify: reload postfix - tags: - - postfix - - name: fetch users list shell: getent passwd | cut -d":" -f 1 | grep -v root register: non_root_users_list @@ -64,6 +50,8 @@ tags: - postfix +- meta: flush_handlers + - name: exim4 is absent apt: name: "{{ item }}" @@ -74,14 +62,8 @@ - exim4-base - exim4-config - exim4-daemon-light - when: evolinux_postfix_remove_exim + when: evolinux_postfix_purge_exim tags: - packages - postfix -- include: postfix_slow_transports.yml - when: evolinux_postfix_slow_transports_enabled - tags: - - postfix - -- meta: flush_handlers diff --git a/evolinux-base/tasks/postfix_slow_transports.yml b/evolinux-base/tasks/postfix_slow_transports.yml deleted file mode 100644 index da32df89..00000000 --- a/evolinux-base/tasks/postfix_slow_transports.yml +++ /dev/null @@ -1,69 +0,0 @@ ---- - -- name: slow transport is defined in master.cf - lineinfile: - dest: /etc/postfix/master.cf - regexp: "^slow " - line: "slow unix - - n - - smtp" - notify: reload postfix - tags: - - postfix - -- name: list of providers for slow transport - lineinfile: - dest: /etc/postfix/transport - line: "{{ item }}" - create: yes - with_items: - - "orange.fr slow:" - - "wanadoo.fr slow:" - - "voila.fr slow:" - - "laposte slow:" - - "yahoo.fr slow:" - - "yahoo.com slow:" - - "hotmail.fr slow:" - - "hotmail.com slow:" - notify: - - postmap transport - - reload postfix - tags: - - postfix - -# - name: main.cf is configured for slow transports -# lineinfile: -# dest: /etc/postfix/main.cf -# regexp: "^{{ item.key }} =" -# line: "{{ item.key }} = {{ item.value }}" -# with_items: -# - { key: "minimal_backoff_time", value: "2h" } -# - { key: "maximal_backoff_time", value: "6h" } -# - { key: "maximal_queue_lifetime", value: "4d" } -# - { key: "queue_run_delay", value: "100s" } -# - { key: "bounce_queue_lifetime", value: "1d" } -# - { key: "initial_destination_concurrency", value: "5" } -# - { key: "default_destination_concurrency_limit", value: "20" } -# - { key: "slow_destination_rate_delay", value: "0" } -# - { key: "slow_destination_concurrency_limit", value: "1" } -# - { key: "slow_destination_concurrency_failed_cohort_limit", value: "100" } -# - { key: "slow_destination_recipient_limit", value: "25" } -# - { key: "transport_maps", value: "hash:$config_directory/transport" } -# notify: reload postfix - -- name: main.cf is configured for slow transports - blockinfile: - dest: /etc/postfix/main.cf - marker: "# {mark} Slow transports configuration (managed by Ansible)" - block: | - minimal_backoff_time = 2h - maximal_backoff_time = 6h - maximal_queue_lifetime = 4d - queue_run_delay = 100s - bounce_queue_lifetime = 1d - initial_destination_concurrency = 5 - default_destination_concurrency_limit = 20 - slow_destination_rate_delay = 0 - slow_destination_concurrency_limit = 1 - slow_destination_concurrency_failed_cohort_limit = 100 - slow_destination_recipient_limit = 25 - transport_maps = hash:$config_directory/transport - notify: reload postfix diff --git a/postfix/README.md b/postfix/README.md index 9b76d369..8387f484 100644 --- a/postfix/README.md +++ b/postfix/README.md @@ -4,7 +4,9 @@ Install Postfix ## Tasks -Minimal configuration is in `tasks/main.yml`. +Minimal configuration is in `tasks/main.yml` and optional customization in : + +* `slow_transport.yml` : slow transport to specific destination. ## Available variables diff --git a/postfix/handlers/main.yml b/postfix/handlers/main.yml index ee3eb141..6c2e879b 100644 --- a/postfix/handlers/main.yml +++ b/postfix/handlers/main.yml @@ -4,3 +4,10 @@ name: postfix state: restarted +- name: reload postfix + service: + name: postfix + state: reloaded + +- name: postmap transport + command: postmap /etc/postfix/transport diff --git a/postfix/tasks/main.yml b/postfix/tasks/main.yml index d5926a63..2fb3f545 100644 --- a/postfix/tasks/main.yml +++ b/postfix/tasks/main.yml @@ -26,3 +26,5 @@ - meta: flush_handlers +- include: slow_transport.yml + when: postfix_slow_transport diff --git a/postfix/tasks/slow_transport.yml b/postfix/tasks/slow_transport.yml new file mode 100644 index 00000000..3bf8ae6d --- /dev/null +++ b/postfix/tasks/slow_transport.yml @@ -0,0 +1,44 @@ +--- + +- name: slow transport is defined in master.cf + lineinfile: + dest: /etc/postfix/master.cf + regexp: "^slow " + line: "slow unix - - n - - smtp" + +- name: list of providers for slow transport + lineinfile: + dest: /etc/postfix/transport + line: "{{ item }}" + create: yes + with_items: + - "orange.fr slow:" + - "wanadoo.fr slow:" + - "voila.fr slow:" + - "laposte slow:" + - "yahoo.fr slow:" + - "yahoo.com slow:" + - "hotmail.fr slow:" + - "hotmail.com slow:" + notify: postmap transport + +- name: main.cf is configured for slow transports + blockinfile: + dest: /etc/postfix/main.cf + marker: "# {mark} Slow transports configuration (installed by Ansible)" + block: | + minimal_backoff_time = 2h + maximal_backoff_time = 6h + maximal_queue_lifetime = 4d + queue_run_delay = 100s + bounce_queue_lifetime = 1d + initial_destination_concurrency = 5 + default_destination_concurrency_limit = 20 + slow_destination_rate_delay = 0 + slow_destination_concurrency_limit = 1 + slow_destination_concurrency_failed_cohort_limit = 100 + slow_destination_recipient_limit = 25 + transport_maps = hash:$config_directory/transport + notify: restart postfix + +- meta: flush_handlers