From e82a8896c96f21a4d07abaff2da312bd7509279d Mon Sep 17 00:00:00 2001 From: lucascbeyeler Date: Sun, 9 Jul 2017 16:55:00 -0300 Subject: [PATCH] Playbook rewrite --- defaults/main.yml | 11 +++ tasks/configure.yml | 132 +++++++++++++++++++++++++++++ tasks/extras/modify-logo.yml | 42 +++++++++ tasks/main.yml | 20 +++++ tasks/packages.yml | 84 ++++++++++++++++++ templates/installZimbra-keystrokes | 15 ++++ vars/main.yml | 28 ++++++ 7 files changed, 332 insertions(+) create mode 100644 defaults/main.yml create mode 100644 tasks/configure.yml create mode 100644 tasks/extras/modify-logo.yml create mode 100644 tasks/main.yml create mode 100644 tasks/packages.yml create mode 100644 templates/installZimbra-keystrokes create mode 100644 vars/main.yml diff --git a/defaults/main.yml b/defaults/main.yml new file mode 100644 index 0000000..611bdd4 --- /dev/null +++ b/defaults/main.yml @@ -0,0 +1,11 @@ +absent: + - postfix + - sendmail + +ubuntu: + - razor + - pyzor + +centos: + - pyzor + - perl-Razor-Agent diff --git a/tasks/configure.yml b/tasks/configure.yml new file mode 100644 index 0000000..da14ede --- /dev/null +++ b/tasks/configure.yml @@ -0,0 +1,132 @@ +--- +# +# Configuring Zimbra OSE +################################################################################ +- name: Configuring Zimbra OSE's services for use + command: ./zmsetup.pl -c /tmp/zcs/installZimbraScript + args: + chdir: /opt/zimbra/libexec/ + +- name: Setting LMTP Host Lookup from DNS to Native + command: ./zmprov mcf zimbraMtaLmtpHostLookup native + args: + chdir: /opt/zimbra/bin/ + +- name: Enabling Zimbra's admin tthrough Proxy Server + command: ./zmproxyconfig -e -w -C -H {{ hostname }}.{{ domain }} + args: + chdir: /opt/zimbra/libexec/ + become: yes + become_user: zimbra + +- name: Enabling HTTP to HTTPS redirect + command: ./zmprov ms {{ hostname }}.{{ domain }} zimbraReverseProxyMailMode redirect + args: + chdir: /opt/zimbra/bin/ + +# +# 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/extras/modify-logo.yml b/tasks/extras/modify-logo.yml new file mode 100644 index 0000000..0b40612 --- /dev/null +++ b/tasks/extras/modify-logo.yml @@ -0,0 +1,42 @@ +# Change the default logo inside the webmail and on the login screen +# This playbook is not required to run for a 100% install. To skip, just don't +# inform the vars zmlogologin and zmlogoapp. +# WARNING: It's required to use this playbook both files: The logo for the +# webmail and the logo for the login screen. + +- name: Send the logo file (LOGIN) from your PC to the Server + copy: + src: '{{ zmlogologin }}' + dest: /opt/zimbra/jetty/webapps/zimbra/img/logoLoginBanner.png + owner: zimbra + group: zimbra + mode: 0644 + +- name: Send the logo file (WEBMAIL) from your PC to the Server + copy: + src: '{{ zmlogoapp }}' + dest: /opt/zimbra/jetty/webapps/zimbra/img/logoAppBanner.png + owner: zimbra + group: zimbra + mode: 0644 + +- name: Configure the Zimbra Server to find the new logos + shell: './zmprov md {{ domain }} zimbraSkinLogoURL https://{{ hostname }}.{{ domain }}' + args: + chdir: /opt/zimbra/bin + become: true + become_user: zimbra + +- name: Configure the path for the login logo file + shell: './zmprov md {{ domain }} zimbraSkinLogoLoginBanner /img/logoLoginBanner.png' + args: + chdir: /opt/zimbra/bin + become: true + become_user: zimbra + +- name: Configure the path for the webmail logo file + shell: './zmprov md {{ domain }} zimbraSkinLogoAppBanner /img/logoAppBanner.png' + args: + chdir: /opt/zimbra/bin + become: true + become_user: zimbra diff --git a/tasks/main.yml b/tasks/main.yml new file mode 100644 index 0000000..bbb98c8 --- /dev/null +++ b/tasks/main.yml @@ -0,0 +1,20 @@ +--- +# +# Main file +################################################################################ +- name: Checking if there is an Zimbra OSE install already + command: getent passwd zimbra + register: getent_passwd + +- include: 'packages.yml' + when: getent_passwd.rc == 0 + +- include: 'configure.yml' + +- include: 'extras/modify-logo.yml' + when: zmlogologin is defined and zmlogoapp is defined + +- name: 'Reloading Zimbra OSE Services' + command: zmcontrol restart + become: yes + become_user: zimbra diff --git a/tasks/packages.yml b/tasks/packages.yml new file mode 100644 index 0000000..52de269 --- /dev/null +++ b/tasks/packages.yml @@ -0,0 +1,84 @@ +--- +# +# Setting variables +################################################################################ +- name: Loading the address to the most recent release of Zimbra OSE (8.7.11) + set_fact: zmurl=https://files.zimbra.com/downloads/8.7.11_GA/ + +- name: Check if your distro is Ubuntu Server 16.04 LTS + set_fact: zmpkg=zcs-8.7.11_GA_1854.UBUNTU14_64.20170531151956 + when: ansible_distribution_major_version|int >= 16 + +- name: Check if your distro is Ubuntu Server 14.04 LTS + set_fact: zmpkg=zcs-8.7.11_GA_1854.UBUNTU14_64.20170531151956 + when: ansible_distribution_major_version|int >= 14 and ansible_distribution_major_version|int <= 15 + +- name: Check if your distro is Red Hat Enterprise Linux or CentOS (Major 6) + set_fact: zmpkg=zcs-8.7.11_GA_1854.RHEL6_64.20170531151956 + when: ansible_distribution_major_version == "6" + +- name: Check if your distro is Red Hat Enterprise Linux or CentOS (Major 7) + set_fact: zmpkg=zcs-8.7.11_GA_1854.RHEL7_64.20170531151956 + when: ansible_distribution_major_version == "7" + +# +# Installing dependencies and removing other smtp servers +################################################################################ +- name: Ensure Sendmail and Postfix is not installed + package: + name: {{ absent }} + state: absent + +- name: Ensure Pyzor and Razor is installed (CentOS/RedHat) + yum: + name: {{ centos }} + state: present + +- name: Ensure Pyzor and Razor is installed (Ubuntu) + apt: + name: {{ ubuntu }} + state: present + +# +# Download and install Zimbra OSE +################################################################################ +- name: Download and unpacking Zimbra OSE + unarchive: + validate_certs: no + src: '{{ zmurl }}{{ zmpkg }}.tgz' + dest: /usr/local/src/ + copy: no + +- name: Create the folder to upload the scripts + file: + path: /tmp/zcs + state: directory + +- name: Uploading keystroke file + copy: + src: 'installZimbra-keystrokes' + dest: /tmp/zcs/installZimbra-keystrokes + owner: root + group: root + mode: 0644 + +- name: Uploading installer configuration file + template: + src: 'installZimbraScript.j2' + dest: /tmp/zcs/installZimbraScript + owner: root + group: root + mode: 0644 + +- name: Installing Zimbra OSE + command: ./install.sh -s < /tmp/zcs/installZimbra-keystrokes + args: + chdir: '/usr/local/src/{{ zmpkg }}/' + +# +# Install PolicyD +################################################################################ +- name: Installing PolicyD Service + shell: ./zmprov ms {{ hostname }}.{{ domain }} +zimbraServiceInstalled cbpolicyd +zimbraServiceEnabled cbpolicyd + args: + chdir: /opt/zimbra/bin/ diff --git a/templates/installZimbra-keystrokes b/templates/installZimbra-keystrokes new file mode 100644 index 0000000..ba2338b --- /dev/null +++ b/templates/installZimbra-keystrokes @@ -0,0 +1,15 @@ +y +y +{{ zimbra-ldap }} +{{ zimbra-logger }} +{{ zimbra-mta }} +{{ zimbra-dnscache }} +{{ zimbra-snmp }} +{{ zimbra-store }} +{{ zimbra-apache }} +{{ zimbra-spell }} +{{ zimbra-memcached }} +{{ zimbra-proxy }} +{{ zimbra-chat }} +{{ zimbra-drive }} +y diff --git a/vars/main.yml b/vars/main.yml new file mode 100644 index 0000000..d022951 --- /dev/null +++ b/vars/main.yml @@ -0,0 +1,28 @@ +--- +# +# Products to be installed +################################################################################ +zimbra-ldap: y +zimbra-logger: y +zimbra-mta: y +zimbra-dnscache: n +zimbra-snmp: n +zimbra-store: y +zimbra-apache: y +zimbra-spell: y +zimbra-memcached: y +zimbra-proxy: y +zimbra-chat: n +zimbra-drive: n + +# +# Zimbra configuration +################################################################################ + +hostname: localhost +domain: localdomain +zmpasswd: !23Change +zmnetwork: 192.168.200.0/8 +zmlogologin: +zmlogoapp: +timezone: UTC