From d595f6bce7b47b0df8df5e600a5acba40e86edce Mon Sep 17 00:00:00 2001 From: lucascbeyeler Date: Sun, 9 Jul 2017 17:13:25 -0300 Subject: [PATCH] Rewriting playbook for multiserver purpose --- tasks/configure.yml | 107 ------------------------------------ tasks/configure/all.yml | 8 --- tasks/configure/mailbox.yml | 43 +++++++++++++++ tasks/configure/mta.yml | 71 ++++++++++++++++++++++-- tasks/install/zimbra.yml | 5 ++ tasks/main.yml | 29 +++++++++- vars/main.yml | 1 + 7 files changed, 141 insertions(+), 123 deletions(-) delete mode 100644 tasks/configure.yml delete mode 100644 tasks/configure/all.yml diff --git a/tasks/configure.yml b/tasks/configure.yml deleted file mode 100644 index a92ee83..0000000 --- a/tasks/configure.yml +++ /dev/null @@ -1,107 +0,0 @@ ---- -# -# Configuring SpamAssassin -################################################################################ -- name: Downloading and Installing Kevin McGrail's Custom Rules - get_url: - url: https://www.pccc.com/downloads/SpamAssassin/contrib/KAM.cf - dest: /opt/zimbra/data/spamassassin/localrules/sakam.cf - mode: 0440 - owner: zimbra - group: zimbra - -- name: Configuring sauser.cf With new Scores - copy: - src: sauser.cf - dest: /opt/zimbra/data/spamassassin/localrules/sauser.cf - owner: root - group: root - mode: 0440 - -# -# Configuring Pyzor -################################################################################ -- name: Downloading and Configuring Pyzor's Anti-spam Base - shell: pyzor --homedir /opt/zimbra/data/amavisd/.pyzor discover - become: true - become_user: zimbra - -# -# Configuring Razor -################################################################################ -- name: Creating Razor's Anti-spam Base - shell: razor-admin -home=/opt/zimbra/data/amavisd/.razor -create - become: true - become_user: zimbra - -- name: Downloading Razor's Anti-spam Base - shell: razor-admin -home=/opt/zimbra/data/amavisd/.razor -discover - become: true - become_user: zimbra - -- name: Registering your Razor installation - shell: 'razor-admin -home=/opt/zimbra/data/amavisd/.razor -register' - become: true - become_user: zimbra - -# -# Configuring RBLs -################################################################################ -- name: Importing zen.spamhaus.org RBL - shell: ./zmprov ms {{hostname}}.{{domain}} +zimbraMtaRestriction 'reject_rbl_client zen.spamhaus.org' - args: - chdir: /opt/zimbra/bin/ - become: true - become_user: zimbra - -- name: Importing sbl.spamhaus.org RBL - shell: ./zmprov ms {{hostname}}.{{domain}} +zimbraMtaRestriction 'reject_rbl_client sbl.spamhaus.org' - args: - chdir: /opt/zimbra/bin/ - become: true - become_user: zimbra - -- name: Importing dsn.rfc-ignorant.org RBL - shell: ./zmprov ms {{hostname}}.{{domain}} +zimbraMtaRestriction 'reject_rbl_client dsn.rfc-ignorant.org' - args: - chdir: /opt/zimbra/bin/ - become: true - become_user: zimbra - -- name: Importing bl.spamcop.net RBL - shell: ./zmprov ms {{hostname}}.{{domain}} +zimbraMtaRestriction 'reject_rbl_client bl.spamcop.net' - args: - chdir: /opt/zimbra/bin/ - become: true - become_user: zimbra - -- name: Importing dnsbl.sorbs.net RBL - shell: ./zmprov ms {{hostname}}.{{domain}} +zimbraMtaRestriction 'reject_rbl_client dnsbl.sorbs.net' - args: - chdir: /opt/zimbra/bin/ - become: true - become_user: zimbra - -# -# Configuring PolicyD -################################################################################ -- name: Configuring PolicyD Database - copy: - src: 'config.php' - dest: /opt/zimbra/common/share/webui/includes/config.php - owner: root - group: root - mode: 0644 - -- name: Configuring PolicyD Web Interface - file: - src: /opt/zimbra/common/share/webui - dest: /opt/zimbra/data/httpd/htdocs/webui - state: link - -- name: Enable PolicyD Web Interface - lineinfile: - dest: /opt/zimbra/conf/httpd.conf - regexp: "^ DirectoryIndex index.html index.html.var" - line: " DirectoryIndex index.html index.html.var index.php" - state: present diff --git a/tasks/configure/all.yml b/tasks/configure/all.yml deleted file mode 100644 index 314904b..0000000 --- a/tasks/configure/all.yml +++ /dev/null @@ -1,8 +0,0 @@ ---- -# -# Configuring Zimbra OSE -################################################################################ -- name: Configuring Zimbra OSE's services for use - command: ./zmsetup.pl -c /tmp/zcs/installZimbraScript - args: - chdir: /opt/zimbra/libexec/ diff --git a/tasks/configure/mailbox.yml b/tasks/configure/mailbox.yml index 65e1649..de3f77a 100644 --- a/tasks/configure/mailbox.yml +++ b/tasks/configure/mailbox.yml @@ -13,3 +13,46 @@ command: ./zmprov ms {{ hostname }}.{{ domain }} zimbraReverseProxyMailMode redirect args: chdir: /opt/zimbra/bin/ + +- name: Setting LMTP Host Lookup from DNS to Native + command: ./zmprov mcf zimbraMtaLmtpHostLookup native + args: + chdir: /opt/zimbra/bin/ + +# +# Configuring RBLs +################################################################################ +- name: Importing zen.spamhaus.org RBL + shell: ./zmprov ms {{hostname}}.{{domain}} +zimbraMtaRestriction 'reject_rbl_client zen.spamhaus.org' + args: + chdir: /opt/zimbra/bin/ + become: true + become_user: zimbra + +- name: Importing sbl.spamhaus.org RBL + shell: ./zmprov ms {{hostname}}.{{domain}} +zimbraMtaRestriction 'reject_rbl_client sbl.spamhaus.org' + args: + chdir: /opt/zimbra/bin/ + become: true + become_user: zimbra + +- name: Importing dsn.rfc-ignorant.org RBL + shell: ./zmprov ms {{hostname}}.{{domain}} +zimbraMtaRestriction 'reject_rbl_client dsn.rfc-ignorant.org' + args: + chdir: /opt/zimbra/bin/ + become: true + become_user: zimbra + +- name: Importing bl.spamcop.net RBL + shell: ./zmprov ms {{hostname}}.{{domain}} +zimbraMtaRestriction 'reject_rbl_client bl.spamcop.net' + args: + chdir: /opt/zimbra/bin/ + become: true + become_user: zimbra + +- name: Importing dnsbl.sorbs.net RBL + shell: ./zmprov ms {{hostname}}.{{domain}} +zimbraMtaRestriction 'reject_rbl_client dnsbl.sorbs.net' + args: + chdir: /opt/zimbra/bin/ + become: true + become_user: zimbra diff --git a/tasks/configure/mta.yml b/tasks/configure/mta.yml index 89ca806..bd89daa 100644 --- a/tasks/configure/mta.yml +++ b/tasks/configure/mta.yml @@ -1,8 +1,69 @@ --- # -# Configuring Zimbra OSE +# Configuring SpamAssassin ################################################################################ -- name: Setting LMTP Host Lookup from DNS to Native - command: ./zmprov mcf zimbraMtaLmtpHostLookup native - args: - chdir: /opt/zimbra/bin/ +- name: Downloading and Installing Kevin McGrail's Custom Rules + get_url: + url: https://www.pccc.com/downloads/SpamAssassin/contrib/KAM.cf + dest: /opt/zimbra/data/spamassassin/localrules/sakam.cf + mode: 0440 + owner: zimbra + group: zimbra + +- name: Configuring sauser.cf With new Scores + copy: + src: sauser.cf + dest: /opt/zimbra/data/spamassassin/localrules/sauser.cf + owner: root + group: root + mode: 0440 + +# +# Configuring Pyzor +################################################################################ +- name: Downloading and Configuring Pyzor's Anti-spam Base + shell: pyzor --homedir /opt/zimbra/data/amavisd/.pyzor discover + become: true + become_user: zimbra + +# +# Configuring Razor +################################################################################ +- name: Creating Razor's Anti-spam Base + shell: razor-admin -home=/opt/zimbra/data/amavisd/.razor -create + become: true + become_user: zimbra + +- name: Downloading Razor's Anti-spam Base + shell: razor-admin -home=/opt/zimbra/data/amavisd/.razor -discover + become: true + become_user: zimbra + +- name: Registering your Razor installation + shell: 'razor-admin -home=/opt/zimbra/data/amavisd/.razor -register' + become: true + become_user: zimbra + +# +# Configuring PolicyD +################################################################################ +- name: Configuring PolicyD Database + copy: + src: 'config.php' + dest: /opt/zimbra/common/share/webui/includes/config.php + owner: root + group: root + mode: 0644 + +- name: Configuring PolicyD Web Interface + file: + src: /opt/zimbra/common/share/webui + dest: /opt/zimbra/data/httpd/htdocs/webui + state: link + +- name: Enable PolicyD Web Interface + lineinfile: + dest: /opt/zimbra/conf/httpd.conf + regexp: "^ DirectoryIndex index.html index.html.var" + line: " DirectoryIndex index.html index.html.var index.php" + state: present diff --git a/tasks/install/zimbra.yml b/tasks/install/zimbra.yml index b201250..5b73082 100644 --- a/tasks/install/zimbra.yml +++ b/tasks/install/zimbra.yml @@ -34,3 +34,8 @@ command: ./install.sh -s < /tmp/zcs/installZimbra-keystrokes args: chdir: '/usr/local/src/{{ zmpkg }}/' + +- name: Configuring Zimbra OSE's services for use + command: ./zmsetup.pl -c /tmp/zcs/installZimbraScript + args: + chdir: /opt/zimbra/libexec/ diff --git a/tasks/main.yml b/tasks/main.yml index bbb98c8..9c20320 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -1,19 +1,42 @@ --- # -# Main file +# Validations before run the playbook ################################################################################ - name: Checking if there is an Zimbra OSE install already command: getent passwd zimbra register: getent_passwd -- include: 'packages.yml' +# +# Installation process +################################################################################ +- include: 'install/vars.yml' when: getent_passwd.rc == 0 +- include: 'install/dependencies.yml' + when: getent_passwd.rc == 0 +- include: 'install/zimbra.yml' + when: getent_passwd.rc == 0 +- include: 'install/policyd.yml' + when: getent_passwd.rc == 0 and zimbra-policyd == 'y' -- include: 'configure.yml' +# +# Configuration process +################################################################################ +- include: 'configure/proxy.yml' + when: zimbra-proxy == 'y' +- include: 'configure/mailbox.yml' + when: zimbra-store == 'y' +- include: 'configure/mta.yml' + when: zimbra-mta == 'y' +# +# Extras configuration process +################################################################################ - include: 'extras/modify-logo.yml' when: zmlogologin is defined and zmlogoapp is defined +# +# Restarting Zimbra +################################################################################ - name: 'Reloading Zimbra OSE Services' command: zmcontrol restart become: yes diff --git a/vars/main.yml b/vars/main.yml index d022951..6406754 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -14,6 +14,7 @@ zimbra-memcached: y zimbra-proxy: y zimbra-chat: n zimbra-drive: n +zimbra-policyd: n # # Zimbra configuration