Playbook rewrite

This commit is contained in:
lucascbeyeler 2017-07-09 16:55:00 -03:00
parent 4efa68ab68
commit e82a8896c9
7 changed files with 332 additions and 0 deletions

11
defaults/main.yml Normal file
View File

@ -0,0 +1,11 @@
absent:
- postfix
- sendmail
ubuntu:
- razor
- pyzor
centos:
- pyzor
- perl-Razor-Agent

132
tasks/configure.yml Normal file
View File

@ -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

View File

@ -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

20
tasks/main.yml Normal file
View File

@ -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

84
tasks/packages.yml Normal file
View File

@ -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/

View File

@ -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

28
vars/main.yml Normal file
View File

@ -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