From 7d058d7dbb0ecdd7fe2b2d6dc4cf1a146e8511a3 Mon Sep 17 00:00:00 2001 From: Paul Lecuq Date: Thu, 28 Apr 2016 23:24:10 +0200 Subject: [PATCH] added tests with ubuntu 14.04 --- LICENSE | 2 +- README.md | 96 +++++++++++++++++++ defaults/main.yml | 2 + handlers/main.yml | 5 + meta/main.yml | 128 +++++++++++++++++++++++++ tasks/CentOS.yml | 7 ++ tasks/Ubuntu.yml | 6 ++ tasks/configure_zimbra.yml | 13 +++ tasks/install_zimbra.yml | 15 +++ tasks/main.yml | 60 ++++++++++++ tasks/provision_zimbra.yml | 17 ++++ templates/hosts.j2 | 7 ++ templates/resolv.conf.j2 | 2 + templates/zimbra_configuration.conf.j2 | 23 +++++ templates/zimbra_provisioning.j2 | 25 +++++ vars/Ubuntu.yml | 18 ++++ vars/main.yml | 15 +++ 17 files changed, 440 insertions(+), 1 deletion(-) create mode 100644 README.md create mode 100644 defaults/main.yml create mode 100644 handlers/main.yml create mode 100644 meta/main.yml create mode 100644 tasks/CentOS.yml create mode 100644 tasks/Ubuntu.yml create mode 100644 tasks/configure_zimbra.yml create mode 100644 tasks/install_zimbra.yml create mode 100644 tasks/main.yml create mode 100644 tasks/provision_zimbra.yml create mode 100644 templates/hosts.j2 create mode 100644 templates/resolv.conf.j2 create mode 100644 templates/zimbra_configuration.conf.j2 create mode 100644 templates/zimbra_provisioning.j2 create mode 100644 vars/Ubuntu.yml create mode 100644 vars/main.yml diff --git a/LICENSE b/LICENSE index a7e49f2..d9562f1 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2016 Paul Lecuq +Copyright (c) 2014 Alexandros Giouzenis Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md new file mode 100644 index 0000000..8b40107 --- /dev/null +++ b/README.md @@ -0,0 +1,96 @@ +Ansible Zimbra +========= + +Install, configure and provision a Full Zimbra Server. + +Requirements +------------ + +* CentOS 6, 7 +* RHEL 6, 7 +* Ubuntu 14.04 +* Correctly configure DNS +* Correctly configued `/etc/hosts` file : now auto-configured by this ansible role + +Role Variables +-------------- + +* `zimbra_download_url`, URL to download Zimbra +* `zimbra_file`, name of the downloaded file +* `zimbra_256sum_file`, `SHA256SUM` of the file +* `zimbra_password`, password for admin and everything +* `zimbra_default_domain`, default domain to create + +**zimbra_domains** + +* `name`, name of a domain +* `accounts`, Array of accounts +* `distribution_lists`, Array of Distribution Lists + +**accounts** + +* `name`, email of the account +* `password`, if empty the default pass is `12345678` + +**distribution_lists** + +* `name`, email of the Distribution List +* `members`, Array of email addresses of members +* `authorized_senders`, Array of domain accounts who can send email to the list + +Example Playbook +---------------- + +```yaml +--- +- hosts: all + sudo: yes + vars: + zimbra_download_url: https://files.zimbra.com/downloads/8.6.0_GA/zcs-8.6.0_GA_1153.RHEL6_64.20141215151155.tgz + zimbra_file: zcs-8.6.0_GA_1153.RHEL6_64.20141215151155 + zimbra_256sum_file: c2278e6632b9ca72487afdf24da2545238e325338090a9d8ad6e99b39593561c + zimbra_password: Passw0rd + zimbra_default_domain: 'mydom.com' + + zimbra_domains: + - name: 'mydom.com' + o: 'My Dom' + accounts: + - name: 'paul@mydom.com' + zimbra_is_admin_account: TRUE + password: Passw0rd + + - name: 'mydom2.com' + o: 'My dom 2' + + - name: 'mydom3.com' + o: 'My dom 3' + accounts: + - name: 'admin@mydom3.com' + password: Passw0rd + zimbra_is_domain_admin_account: TRUE + + distribution_lists: + - name: 'user@mydom3.com' + members: + - '1@mydom4.com' + - '2@mydom3.com' + authorized_senders: + - 'paul@mydom.com' + + - name: 'empty.com' + o: 'My dom 4' + + roles: + - role: zimbra +``` + +License +------- + +MIT + +Author Information +------------------ + +Based on ansible-zimbradev by pbruna diff --git a/defaults/main.yml b/defaults/main.yml new file mode 100644 index 0000000..e7a4f22 --- /dev/null +++ b/defaults/main.yml @@ -0,0 +1,2 @@ +--- +# defaults file for cartertdte.mta diff --git a/handlers/main.yml b/handlers/main.yml new file mode 100644 index 0000000..fc6b3c5 --- /dev/null +++ b/handlers/main.yml @@ -0,0 +1,5 @@ +--- +# handlers file for cartertdte.mta + +- name: postfix restart + service: name=postfix state=restarted \ No newline at end of file diff --git a/meta/main.yml b/meta/main.yml new file mode 100644 index 0000000..7b1f0ef --- /dev/null +++ b/meta/main.yml @@ -0,0 +1,128 @@ +--- +galaxy_info: + author: your name + description: + company: your company (optional) + # Some suggested licenses: + # - BSD (default) + # - MIT + # - GPLv2 + # - GPLv3 + # - Apache + # - CC-BY + license: license (GPLv2, CC-BY, etc) + min_ansible_version: 1.2 + # + # Below are all platforms currently available. Just uncomment + # the ones that apply to your role. If you don't see your + # platform on this list, let us know and we'll get it added! + # + #platforms: + #- name: EL + # versions: + # - all + # - 5 + # - 6 + # - 7 + #- name: GenericUNIX + # versions: + # - all + # - any + #- name: Fedora + # versions: + # - all + # - 16 + # - 17 + # - 18 + # - 19 + # - 20 + #- name: SmartOS + # versions: + # - all + # - any + #- name: opensuse + # versions: + # - all + # - 12.1 + # - 12.2 + # - 12.3 + # - 13.1 + # - 13.2 + #- name: Amazon + # versions: + # - all + # - 2013.03 + # - 2013.09 + #- name: GenericBSD + # versions: + # - all + # - any + #- name: FreeBSD + # versions: + # - all + # - 8.0 + # - 8.1 + # - 8.2 + # - 8.3 + # - 8.4 + # - 9.0 + # - 9.1 + # - 9.1 + # - 9.2 + #- name: Ubuntu + # versions: + # - all + # - lucid + # - maverick + # - natty + # - oneiric + # - precise + # - quantal + # - raring + # - saucy + # - trusty + #- name: SLES + # versions: + # - all + # - 10SP3 + # - 10SP4 + # - 11 + # - 11SP1 + # - 11SP2 + # - 11SP3 + #- name: GenericLinux + # versions: + # - all + # - any + #- name: Debian + # versions: + # - all + # - etch + # - lenny + # - squeeze + # - wheezy + # + # Below are all categories currently available. Just as with + # the platforms above, uncomment those that apply to your role. + # + #categories: + #- cloud + #- cloud:ec2 + #- cloud:gce + #- cloud:rax + #- clustering + #- database + #- database:nosql + #- database:sql + #- development + #- monitoring + #- networking + #- packaging + #- system + #- web +dependencies: [] + # List your role dependencies here, one per line. Only + # dependencies available via galaxy should be listed here. + # Be sure to remove the '[]' above if you add dependencies + # to this list. + diff --git a/tasks/CentOS.yml b/tasks/CentOS.yml new file mode 100644 index 0000000..2e66fed --- /dev/null +++ b/tasks/CentOS.yml @@ -0,0 +1,7 @@ +--- +# test + +- name: Install Zimbra Dependencies + yum: name={{ item }} state=present + with_items: + - "{{ zimbra_required_packages }}" diff --git a/tasks/Ubuntu.yml b/tasks/Ubuntu.yml new file mode 100644 index 0000000..40b928d --- /dev/null +++ b/tasks/Ubuntu.yml @@ -0,0 +1,6 @@ +--- +# Install zimbra dependencies + +- name: Install Zimbra Dependencies + apt: name={{ item }} state=present + with_items: zimbra_required_packages diff --git a/tasks/configure_zimbra.yml b/tasks/configure_zimbra.yml new file mode 100644 index 0000000..b214349 --- /dev/null +++ b/tasks/configure_zimbra.yml @@ -0,0 +1,13 @@ +# roles/bind/tasks/confgiure_zimbra.yml +# Configuration of Zimbra +--- + +- name: Copy configuration file + template: + src: zimbra_configuration.conf.j2 + dest: /tmp/zimbra_configuration.conf + owner: zimbra + mode: '0644' + +- name: Run Zimbra zmsetup.pl + command: /opt/zimbra/libexec/zmsetup.pl -c /tmp/zimbra_configuration.conf diff --git a/tasks/install_zimbra.yml b/tasks/install_zimbra.yml new file mode 100644 index 0000000..f7e8fc3 --- /dev/null +++ b/tasks/install_zimbra.yml @@ -0,0 +1,15 @@ +# roles/bind/tasks/install_zimbra.yml +# Install Zimbra Software +--- + +- name: Untar Zimbra src + unarchive: src=/opt/src/{{ zimbra_file }}.tgz dest=/tmp/ copy=no + +- name: Install Zimbra Software + shell: yes 'Y' | /tmp/{{ zimbra_file }}/install.sh -s --platform-override -x + args: + chdir: /tmp/{{ zimbra_file }}/ + creates: /opt/zimbra/bin/zmprov + +- name: Remove Zimbra src + file: path=/tmp/{{ zimbra_file }} state=absent diff --git a/tasks/main.yml b/tasks/main.yml new file mode 100644 index 0000000..8e86286 --- /dev/null +++ b/tasks/main.yml @@ -0,0 +1,60 @@ +--- +# tasks file for cartertdte.mta + +- name: Include distribution specific variables + include_vars: "{{ ansible_distribution }}.yml" + tags: zimbra + +- include: CentOS.yml + when: ansible_distribution == "CentOS" + tags: zimbra + +- include: Ubuntu.yml + when: ansible_distribution == "Ubuntu" + tags: zimbra + +- name: Set hostname + command: hostname {{ zimbra_hostname }} + +- name: Set hosts file + template: + src=hosts.j2 + dest=/etc/hosts + owner=root + mode=0644 + +- name: Disable and stop dnsmasq service + service: + name=dnsmasq + state=stopped + enabled=no + +- name: Create Source Software Directory + file: path=/opt/src state=directory + +- name: 'Download Zimbra .tgz file' + get_url: + url={{ zimbra_download_url }} + dest=/opt/src/{{ zimbra_file }}.tgz + timeout=60 + sha256sum={{ zimbra_256sum_file }} + +- name: Check if Zimbra is installed + stat: path=/opt/zimbra/bin/zmprov + register: zimbra_check_installation + +- include: install_zimbra.yml + when: zimbra_check_installation.stat.islnk is not defined + +- name: Check if Zimbra is configured + command: /opt/zimbra/bin/zmprov gd {{ zimbra_default_domain }} + ignore_errors: yes + register: zimbra_check_configuration + +- include: configure_zimbra.yml + when: zimbra_check_configuration.rc != 0 + +- name: Start zimbra + service: name=zimbra state=restarted + +- include: provision_zimbra.yml diff --git a/tasks/provision_zimbra.yml b/tasks/provision_zimbra.yml new file mode 100644 index 0000000..241ab5a --- /dev/null +++ b/tasks/provision_zimbra.yml @@ -0,0 +1,17 @@ +# roles/bind/tasks/provision_zimbra.yml +# Provision Zimbra with users and etc. +--- + +- name: Copy provisioning file + template: + src: zimbra_provisioning.j2 + dest: /tmp/zimbra_provisioning + owner: zimbra + mode: '0644' + +- name: Provision Zimbra + sudo_user: zimbra + shell: /opt/zimbra/bin/zmprov < /tmp/zimbra_provisioning + +- name: Delete provisioning file + file: path=/tmp/zimbra_provisioning state=absent diff --git a/templates/hosts.j2 b/templates/hosts.j2 new file mode 100644 index 0000000..da58c98 --- /dev/null +++ b/templates/hosts.j2 @@ -0,0 +1,7 @@ +# The following lines are desirable for IPv6 capable hosts +::1 localhost ip6-localhost ip6-loopback +ff02::1 ip6-allnodes +ff02::2 ip6-allrouters +127.0.0.1 localhost +{{ ansible_eth0.ipv4.address }} {{ zimbra_hostname }}.{{ zimbra_default_domain }} {{ zimbra_hostname }} + diff --git a/templates/resolv.conf.j2 b/templates/resolv.conf.j2 new file mode 100644 index 0000000..c744ebe --- /dev/null +++ b/templates/resolv.conf.j2 @@ -0,0 +1,2 @@ +search localdomain ffx.net +nameserver 127.0.0.1 diff --git a/templates/zimbra_configuration.conf.j2 b/templates/zimbra_configuration.conf.j2 new file mode 100644 index 0000000..7665892 --- /dev/null +++ b/templates/zimbra_configuration.conf.j2 @@ -0,0 +1,23 @@ +CREATEADMINPASS="{{ zimbra_password }}" +LDAPAMAVISPASS="{{ zimbra_password }}" +LDAPPOSTPASS="{{ zimbra_password }}" +LDAPROOTPASS="{{ zimbra_password }}" +LDAPADMINPASS="{{ zimbra_password }}" +LDAPREPPASS="{{ zimbra_password }}" +LDAPBESSEARCHSET="set" +LDAPHOST="{{ zimbra_hostname }}" +LDAPPORT="389" +LDAPREPLICATIONTYPE="master" +LDAPSERVERID="2" +ldap_nginx_password="{{ zimbra_password }}" +ldap_bes_searcher_password="{{ zimbra_password }}" +AVDOMAIN="{{ zimbra_default_domain }}" +AVUSER="admin@{{ zimbra_default_domain }}" +CREATEADMIN="admin@{{ zimbra_default_domain }}" +CREATEDOMAIN="{{ zimbra_default_domain }}" +DOCREATEADMIN="yes" +DOCREATEDOMAIN="yes" +EXPANDMENU="no" +HOSTNAME="{{ zimbra_hostname }}" +DOTRAINSA="yes" +ENABLEGALSYNCACCOUNTS="" diff --git a/templates/zimbra_provisioning.j2 b/templates/zimbra_provisioning.j2 new file mode 100644 index 0000000..2966928 --- /dev/null +++ b/templates/zimbra_provisioning.j2 @@ -0,0 +1,25 @@ +{% if zimbra_domains is defined %} +{% for domain in zimbra_domains %} +cd {{ domain.name }} o {{ domain.o | default('--')}} +{% if domain.accounts is defined %} +{% for account in domain.accounts %} +ca {{ account.name }} {{ password | default(12345678)}} zimbraIsAdminAccount {{zimbra_is_admin_account | default('FALSE')}} zimbraIsDomainAdminAccount {{ zimbra_is_domain_admin_account | default('FALSE') }} +{% endfor %} +{% endif %} +{% if domain.distribution_lists is defined %} +{% for dl in domain.distribution_lists %} +cdl {{ dl.name }} +{% if dl.members is defined %} +{% for member in dl.members %} +adlm {{ dl.name }} {{ member }} +{% endfor %} +{% endif %} +{% if dl.authorized_senders is defined %} +{% for user in dl.authorized_senders %} +grr dl {{ dl.name }} usr {{ user }} sendToDistList +{% endfor %} +{% endif %} +{% endfor %} +{% endif %} +{% endfor %} +{% endif %} diff --git a/vars/Ubuntu.yml b/vars/Ubuntu.yml new file mode 100644 index 0000000..1a03e7c --- /dev/null +++ b/vars/Ubuntu.yml @@ -0,0 +1,18 @@ +--- +# vars file for cartertdte.mta +zimbra_required_packages: + - netcat + - sudo + - libidn11 + - libgmp10 + - libaio1 + - libstdc++6 + - unzip + - perl + - libperl5.18 + - pax + - sysstat + - sqlite3 + - resolvconf + - dnsmasq + - wget diff --git a/vars/main.yml b/vars/main.yml new file mode 100644 index 0000000..31899a0 --- /dev/null +++ b/vars/main.yml @@ -0,0 +1,15 @@ +--- +# vars file for cartertdte.mta +zimbra_required_packages: + - nc + - sudo + - libidn + - gmp + - libaio + - libstdc++ + - unzip + - perl-5.10.1 + - sysstat + - sqlite + - libreoffice + - libreoffice-headless