Skip to content

Commit e82a889

Browse files
author
lucascbeyeler
committed
Playbook rewrite
1 parent 4efa68a commit e82a889

File tree

7 files changed

+332
-0
lines changed

7 files changed

+332
-0
lines changed

defaults/main.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
absent:
2+
- postfix
3+
- sendmail
4+
5+
ubuntu:
6+
- razor
7+
- pyzor
8+
9+
centos:
10+
- pyzor
11+
- perl-Razor-Agent

tasks/configure.yml

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
---
2+
#
3+
# Configuring Zimbra OSE
4+
################################################################################
5+
- name: Configuring Zimbra OSE's services for use
6+
command: ./zmsetup.pl -c /tmp/zcs/installZimbraScript
7+
args:
8+
chdir: /opt/zimbra/libexec/
9+
10+
- name: Setting LMTP Host Lookup from DNS to Native
11+
command: ./zmprov mcf zimbraMtaLmtpHostLookup native
12+
args:
13+
chdir: /opt/zimbra/bin/
14+
15+
- name: Enabling Zimbra's admin tthrough Proxy Server
16+
command: ./zmproxyconfig -e -w -C -H {{ hostname }}.{{ domain }}
17+
args:
18+
chdir: /opt/zimbra/libexec/
19+
become: yes
20+
become_user: zimbra
21+
22+
- name: Enabling HTTP to HTTPS redirect
23+
command: ./zmprov ms {{ hostname }}.{{ domain }} zimbraReverseProxyMailMode redirect
24+
args:
25+
chdir: /opt/zimbra/bin/
26+
27+
#
28+
# Configuring SpamAssassin
29+
################################################################################
30+
- name: Downloading and Installing Kevin McGrail's Custom Rules
31+
get_url:
32+
url: https://www.pccc.com/downloads/SpamAssassin/contrib/KAM.cf
33+
dest: /opt/zimbra/data/spamassassin/localrules/sakam.cf
34+
mode: 0440
35+
owner: zimbra
36+
group: zimbra
37+
38+
- name: Configuring sauser.cf With new Scores
39+
copy:
40+
src: sauser.cf
41+
dest: /opt/zimbra/data/spamassassin/localrules/sauser.cf
42+
owner: root
43+
group: root
44+
mode: 0440
45+
46+
#
47+
# Configuring Pyzor
48+
################################################################################
49+
- name: Downloading and Configuring Pyzor's Anti-spam Base
50+
shell: pyzor --homedir /opt/zimbra/data/amavisd/.pyzor discover
51+
become: true
52+
become_user: zimbra
53+
54+
#
55+
# Configuring Razor
56+
################################################################################
57+
- name: Creating Razor's Anti-spam Base
58+
shell: razor-admin -home=/opt/zimbra/data/amavisd/.razor -create
59+
become: true
60+
become_user: zimbra
61+
62+
- name: Downloading Razor's Anti-spam Base
63+
shell: razor-admin -home=/opt/zimbra/data/amavisd/.razor -discover
64+
become: true
65+
become_user: zimbra
66+
67+
- name: Registering your Razor installation
68+
shell: 'razor-admin -home=/opt/zimbra/data/amavisd/.razor -register'
69+
become: true
70+
become_user: zimbra
71+
72+
#
73+
# Configuring RBLs
74+
################################################################################
75+
- name: Importing zen.spamhaus.org RBL
76+
shell: ./zmprov ms {{hostname}}.{{domain}} +zimbraMtaRestriction 'reject_rbl_client zen.spamhaus.org'
77+
args:
78+
chdir: /opt/zimbra/bin/
79+
become: true
80+
become_user: zimbra
81+
82+
- name: Importing sbl.spamhaus.org RBL
83+
shell: ./zmprov ms {{hostname}}.{{domain}} +zimbraMtaRestriction 'reject_rbl_client sbl.spamhaus.org'
84+
args:
85+
chdir: /opt/zimbra/bin/
86+
become: true
87+
become_user: zimbra
88+
89+
- name: Importing dsn.rfc-ignorant.org RBL
90+
shell: ./zmprov ms {{hostname}}.{{domain}} +zimbraMtaRestriction 'reject_rbl_client dsn.rfc-ignorant.org'
91+
args:
92+
chdir: /opt/zimbra/bin/
93+
become: true
94+
become_user: zimbra
95+
96+
- name: Importing bl.spamcop.net RBL
97+
shell: ./zmprov ms {{hostname}}.{{domain}} +zimbraMtaRestriction 'reject_rbl_client bl.spamcop.net'
98+
args:
99+
chdir: /opt/zimbra/bin/
100+
become: true
101+
become_user: zimbra
102+
103+
- name: Importing dnsbl.sorbs.net RBL
104+
shell: ./zmprov ms {{hostname}}.{{domain}} +zimbraMtaRestriction 'reject_rbl_client dnsbl.sorbs.net'
105+
args:
106+
chdir: /opt/zimbra/bin/
107+
become: true
108+
become_user: zimbra
109+
110+
#
111+
# Configuring PolicyD
112+
################################################################################
113+
- name: Configuring PolicyD Database
114+
copy:
115+
src: 'config.php'
116+
dest: /opt/zimbra/common/share/webui/includes/config.php
117+
owner: root
118+
group: root
119+
mode: 0644
120+
121+
- name: Configuring PolicyD Web Interface
122+
file:
123+
src: /opt/zimbra/common/share/webui
124+
dest: /opt/zimbra/data/httpd/htdocs/webui
125+
state: link
126+
127+
- name: Enable PolicyD Web Interface
128+
lineinfile:
129+
dest: /opt/zimbra/conf/httpd.conf
130+
regexp: "^ DirectoryIndex index.html index.html.var"
131+
line: " DirectoryIndex index.html index.html.var index.php"
132+
state: present

tasks/extras/modify-logo.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Change the default logo inside the webmail and on the login screen
2+
# This playbook is not required to run for a 100% install. To skip, just don't
3+
# inform the vars zmlogologin and zmlogoapp.
4+
# WARNING: It's required to use this playbook both files: The logo for the
5+
# webmail and the logo for the login screen.
6+
7+
- name: Send the logo file (LOGIN) from your PC to the Server
8+
copy:
9+
src: '{{ zmlogologin }}'
10+
dest: /opt/zimbra/jetty/webapps/zimbra/img/logoLoginBanner.png
11+
owner: zimbra
12+
group: zimbra
13+
mode: 0644
14+
15+
- name: Send the logo file (WEBMAIL) from your PC to the Server
16+
copy:
17+
src: '{{ zmlogoapp }}'
18+
dest: /opt/zimbra/jetty/webapps/zimbra/img/logoAppBanner.png
19+
owner: zimbra
20+
group: zimbra
21+
mode: 0644
22+
23+
- name: Configure the Zimbra Server to find the new logos
24+
shell: './zmprov md {{ domain }} zimbraSkinLogoURL https://{{ hostname }}.{{ domain }}'
25+
args:
26+
chdir: /opt/zimbra/bin
27+
become: true
28+
become_user: zimbra
29+
30+
- name: Configure the path for the login logo file
31+
shell: './zmprov md {{ domain }} zimbraSkinLogoLoginBanner /img/logoLoginBanner.png'
32+
args:
33+
chdir: /opt/zimbra/bin
34+
become: true
35+
become_user: zimbra
36+
37+
- name: Configure the path for the webmail logo file
38+
shell: './zmprov md {{ domain }} zimbraSkinLogoAppBanner /img/logoAppBanner.png'
39+
args:
40+
chdir: /opt/zimbra/bin
41+
become: true
42+
become_user: zimbra

tasks/main.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
#
3+
# Main file
4+
################################################################################
5+
- name: Checking if there is an Zimbra OSE install already
6+
command: getent passwd zimbra
7+
register: getent_passwd
8+
9+
- include: 'packages.yml'
10+
when: getent_passwd.rc == 0
11+
12+
- include: 'configure.yml'
13+
14+
- include: 'extras/modify-logo.yml'
15+
when: zmlogologin is defined and zmlogoapp is defined
16+
17+
- name: 'Reloading Zimbra OSE Services'
18+
command: zmcontrol restart
19+
become: yes
20+
become_user: zimbra

tasks/packages.yml

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
---
2+
#
3+
# Setting variables
4+
################################################################################
5+
- name: Loading the address to the most recent release of Zimbra OSE (8.7.11)
6+
set_fact: zmurl=https://files.zimbra.com/downloads/8.7.11_GA/
7+
8+
- name: Check if your distro is Ubuntu Server 16.04 LTS
9+
set_fact: zmpkg=zcs-8.7.11_GA_1854.UBUNTU14_64.20170531151956
10+
when: ansible_distribution_major_version|int >= 16
11+
12+
- name: Check if your distro is Ubuntu Server 14.04 LTS
13+
set_fact: zmpkg=zcs-8.7.11_GA_1854.UBUNTU14_64.20170531151956
14+
when: ansible_distribution_major_version|int >= 14 and ansible_distribution_major_version|int <= 15
15+
16+
- name: Check if your distro is Red Hat Enterprise Linux or CentOS (Major 6)
17+
set_fact: zmpkg=zcs-8.7.11_GA_1854.RHEL6_64.20170531151956
18+
when: ansible_distribution_major_version == "6"
19+
20+
- name: Check if your distro is Red Hat Enterprise Linux or CentOS (Major 7)
21+
set_fact: zmpkg=zcs-8.7.11_GA_1854.RHEL7_64.20170531151956
22+
when: ansible_distribution_major_version == "7"
23+
24+
#
25+
# Installing dependencies and removing other smtp servers
26+
################################################################################
27+
- name: Ensure Sendmail and Postfix is not installed
28+
package:
29+
name: {{ absent }}
30+
state: absent
31+
32+
- name: Ensure Pyzor and Razor is installed (CentOS/RedHat)
33+
yum:
34+
name: {{ centos }}
35+
state: present
36+
37+
- name: Ensure Pyzor and Razor is installed (Ubuntu)
38+
apt:
39+
name: {{ ubuntu }}
40+
state: present
41+
42+
#
43+
# Download and install Zimbra OSE
44+
################################################################################
45+
- name: Download and unpacking Zimbra OSE
46+
unarchive:
47+
validate_certs: no
48+
src: '{{ zmurl }}{{ zmpkg }}.tgz'
49+
dest: /usr/local/src/
50+
copy: no
51+
52+
- name: Create the folder to upload the scripts
53+
file:
54+
path: /tmp/zcs
55+
state: directory
56+
57+
- name: Uploading keystroke file
58+
copy:
59+
src: 'installZimbra-keystrokes'
60+
dest: /tmp/zcs/installZimbra-keystrokes
61+
owner: root
62+
group: root
63+
mode: 0644
64+
65+
- name: Uploading installer configuration file
66+
template:
67+
src: 'installZimbraScript.j2'
68+
dest: /tmp/zcs/installZimbraScript
69+
owner: root
70+
group: root
71+
mode: 0644
72+
73+
- name: Installing Zimbra OSE
74+
command: ./install.sh -s < /tmp/zcs/installZimbra-keystrokes
75+
args:
76+
chdir: '/usr/local/src/{{ zmpkg }}/'
77+
78+
#
79+
# Install PolicyD
80+
################################################################################
81+
- name: Installing PolicyD Service
82+
shell: ./zmprov ms {{ hostname }}.{{ domain }} +zimbraServiceInstalled cbpolicyd +zimbraServiceEnabled cbpolicyd
83+
args:
84+
chdir: /opt/zimbra/bin/

templates/installZimbra-keystrokes

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
y
2+
y
3+
{{ zimbra-ldap }}
4+
{{ zimbra-logger }}
5+
{{ zimbra-mta }}
6+
{{ zimbra-dnscache }}
7+
{{ zimbra-snmp }}
8+
{{ zimbra-store }}
9+
{{ zimbra-apache }}
10+
{{ zimbra-spell }}
11+
{{ zimbra-memcached }}
12+
{{ zimbra-proxy }}
13+
{{ zimbra-chat }}
14+
{{ zimbra-drive }}
15+
y

vars/main.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
---
2+
#
3+
# Products to be installed
4+
################################################################################
5+
zimbra-ldap: y
6+
zimbra-logger: y
7+
zimbra-mta: y
8+
zimbra-dnscache: n
9+
zimbra-snmp: n
10+
zimbra-store: y
11+
zimbra-apache: y
12+
zimbra-spell: y
13+
zimbra-memcached: y
14+
zimbra-proxy: y
15+
zimbra-chat: n
16+
zimbra-drive: n
17+
18+
#
19+
# Zimbra configuration
20+
################################################################################
21+
22+
hostname: localhost
23+
domain: localdomain
24+
zmpasswd: !23Change
25+
zmnetwork: 192.168.200.0/8
26+
zmlogologin:
27+
zmlogoapp:
28+
timezone: UTC

0 commit comments

Comments
 (0)