Industrialising the installation of BlueMind with Ansible

Installing a BlueMind platform is typically straightforward, involving few steps once the architecture is defined. In some cases, however, installation needs to be industrialised in order to be played several times. This may be needed, for example, for hosts or clients with a large number of users and several platforms. 

Ansible is an automation engine designed to deal with such situations. This article describes how to deploy BlueMind using Ansible, although you may use any other tools such as Saltstack, Puppet or Chef.

What’s Ansible?

Ansible is an automation tool that facilitates application and system deployment. It saves having to write scripts or custom code to deploy or update an application.

Ansible’s strength is that you don’t need a deployment agent on the target server as all installation and configuration instructions are run by the SSH agent, which is widespread on Linux servers.

Specifically, Ansible can automate three types of tasks:

  • Provisioning: setting up the servers your infrastructure requires.
  • Configuration: changing the configuration of an application, an operating system or a device, starting and stopping services, installing or updating applications, implementing a security strategy, or performing a wide array of other configuration tasks.
  • Application deployment: facilitating development by automating the deployment of the applications developed in-house on your production systems.

This article describes how BlueMind can use Ansible to automate repetitive administration tasks. To find out more about using Ansible, we recommend Cloud Academy’s Introduction to Ansible.

Ansible and BlueMind

This article is not designed to tell you about Ansible but to show you how we use it in our deployment methods.

  • Respect of deployment rules

There are several ways of deploying an application with Ansible. The method we are showing here uses an inventory file which contains the BlueMind server(s) to be installed, BlueMind-specific roles made available by our teams through git repositories and example playbooks to order operations.

  • Installation harmonisation

Using Ansible has many benefits. It will save you time if you’re deploying multiple BlueMind instances for different clients. You can for example harmonise configurations according to clients and uses to industrialise deployment, thereby limiting inconsistencies between BlueMind instances.

Similarly, in another context, you can use Ansible to deploy your development, qualification, preproduction and production environments in order to ensure identical configurations. This will help maximise the success of your deployment or update projects. 

Below, we will look at how to deploy a simple BlueMind server capable of hosting hundreds of users. Then we will see how you can deploy an instance of BlueMind made up of two BlueMind servers, one core server and one back-end data server which will contain user data.

Finally, we will look at evolution prospects and how existing roles can be a starting point for the deployment of a dedicated elasticsearch server or a bm-edge server. You may also consider a disaster recovery plan to rebuild a server in case of loss – using backups.

Environment: 

Prerequisite: an Ansible server installed. In our case, we’re not using the latest version but roles are compatible: 

root@nmc-Ansible:~# Ansible --version 
Ansible 2.7.5 
  config file = /etc/Ansible/Ansible.cfg 
  configured module search path = [u'/root/.Ansible/plugins/modules', u'/usr/share/Ansible/plugins/modules'] 
  Ansible python module location = /usr/lib/python2.7/dist-packages/Ansible 
  executable location = /usr/bin/Ansible 
  python version = 2.7.13 (default, Sep 26 2018, 18:42:22) [GCC 6.3.0 20170516] 

Installing a BlueMind server: 

  • Get the file u500_requirements.yml here
Ansible-galaxy install -r u500_requirements.yml 
- extracting bluemind_requirements to /etc/Ansible/roles/bluemind_requirements 
- bluemind_requirements (master) was installed successfully 
- extracting bluemind_single_server to /etc/Ansible/roles/bluemind_single_server 
- bluemind_single_server (master) was installed successfully 

The Ansible-galaxy command is used to download all the roles available on git. Please not that newer versions may become available in the short or medium term.

  • Create the playbook: 
root@nmc-Ansible:/etc/Ansible# cat playbooks/bm/bluemind_single_server.yml 
--- 
- name: Configuring BlueMind requirements 
  hosts: all 
  become: yes 
  become_method: su 
  roles: 
    - bluemind_requirements 
    - bluemind_single_server 
  • Create your inventory file. Here we are using a yml file, available in /etc/Ansible/inventory 

cat inventory/bluemind_single_server.yml

bluemind_single_server: 
  hosts: 
    nmc-core.blue-mind.loc: 
      Ansible_host: 192.168.0.15 
      Ansible_become_password: « SET_ROOT_PASSWORD_HERE" 
      Ansible_ssh_common_args: '-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null' 
      Ansible_user: bluemind 
  vars: 
    sw_password: "admin" 
    external_url: "mail.blue-mind.loc" 
    subscription_contact: "admin@blue-mind.loc" 
    local_works_directory: "/usr/local/bluemind/" 
    email_domain: "blue-mind.loc" 
    subscription_file: "/usr/local/bluemind/subscribe.bmz" 

A few explanatory notes: 

The following global variables are required: 

  • The public server address, vars.external_url
  • The contact name for who will receive subscription notifications vars.subscription_contact
  • Email_domain which represents the default domain you want to create.
  • Sw_password is the password needed for the /setup and access to the tick console – if you choose to install it.
  • Local_works_directory is storage location for the information needed to run Ansible roles. You might want to create a client file, for instance.
  • subscription_file is the location of the subscription file, required for installation by Ansible.

Start the installation: 

Ansible-playbook -l bluemind_single_server playbooks/bm/bluemind_single_server.yml 
PLAY [Configuring BlueMind requirements] 
*********************
TASK [Gathering Facts] 
*********************
ok: [nmc-core.blue-mind.loc] 
TASK [bluemind_requirements :  Load Operating System : Debian 9] 
*********************
ok: [nmc-core.blue-mind.loc] => (item=/etc/Ansible/roles/bluemind_requirements/vars/debian_family.yml) 
TASK [bluemind_requirements : include_tasks] 
*********************
skipping: [nmc-core.blue-mind.loc] 
TASK [bluemind_requirements : include_tasks] 
*********************
included: /etc/Ansible/roles/bluemind_requirements/tasks/debian.yml for nmc-core.blue-mind.loc 
TASK [bluemind_requirements : assert] 
*********************
ok: [nmc-core.blue-mind.loc] => { 
    "changed": false, 
    "msg": "All assertions passed" 
} 
TASK [bluemind_requirements : set /etc/hostname] 
*********************
ok: [nmc-core.blue-mind.loc] 
TASK [bluemind_requirements : Ensure en_US.UTF-8 locale exists] 
*********************
changed: [nmc-core.blue-mind.loc] 
TASK [bluemind_requirements : Set LC_ALL] 
*********************
changed: [nmc-core.blue-mind.loc] 
TASK [bluemind_requirements : Set LANG] 
*********************
changed: [nmc-core.blue-mind.loc] 
TASK [bluemind_requirements : Install apt Packages] 
*********************
changed: [nmc-core.blue-mind.loc] 
TASK [bluemind_requirements : Update] 
*********************
ok: [nmc-core.blue-mind.loc] 
TASK [bluemind_requirements : Upgrade apt packages] 
*********************
changed: [nmc-core.blue-mind.loc] 
TASK [bluemind_requirements : Install your subscribe file] 
*********************
changed: [nmc-core.blue-mind.loc -> localhost] 
TASK [bluemind_requirements : Copy BlueMind repository file into the server] 
*********************
changed: [nmc-core.blue-mind.loc] 
TASK [bluemind_requirements : Adding BlueMind Public Key] 
*********************
changed: [nmc-core.blue-mind.loc] 
TASK [bluemind_requirements : Configure BM repository priority] 
*********************
changed: [nmc-core.blue-mind.loc] 
TASK [bluemind_requirements : apt_repository] 
*********************
skipping: [nmc-core.blue-mind.loc] 
TASK [bluemind_requirements : Update repositories] 
*********************
changed: [nmc-core.blue-mind.loc] 
TASK [bluemind_single_server : include_tasks] 
*********************
skipping: [nmc-core.blue-mind.loc] 
TASK [bluemind_single_server : include_tasks] 
*********************
included: /etc/Ansible/roles/bluemind_single_server/tasks/debian.yml for nmc-core.blue-mind.loc 
TASK [bluemind_single_server : Install BlueMind Packages] 
*********************
changed: [nmc-core.blue-mind.loc] 
TASK [bluemind_single_server : Install BlueMind] 
*********************
changed: [nmc-core.blue-mind.loc] 
PLAY RECAP 
*********************
nmc-core.blue-mind.loc     : ok=19   changed=12   unreachable=0    failed=0 

Once the installation is complete, you just need to configure your server.

The bluemind_requirements role is used to push the subscription on the BlueMind server(s). The subscription is retrieved from the subscription file bmz which must be entered in the variables of the “bluemind_single_server” group.

The bluemind_requirements role is also used to check that the system configuration meets BlueMind’s expectations.

As of BlueMind 4.1, BlueMind updates can be run from command line. This means that all you’ll need to do is run a playbook for BlueMind packages to be updated and for the /setup to play without having to connect to the web interface. 

And don’t forget that this type of instruction needs to be run in a screen/tmux or similar tool.

Updating the BlueMind server: 

root@nmc-Ansible:/etc/Ansible# Ansible-playbook -l bluemind_single_server playbooks/bm/bluemind_upgrade.yml 
PLAY [Configuring BlueMind requirements] 
*********************
TASK [Gathering Facts] 
*********************
ok: [nmc-core.blue-mind.loc] 
TASK [bluemind_upgrade : include_tasks] 
*********************
skipping: [nmc-core.blue-mind.loc] 
TASK [bluemind_upgrade : include_tasks] 
*********************
included: /etc/Ansible/roles/bluemind_upgrade/tasks/debian.yml for nmc-core.blue-mind.loc 
TASK [bluemind_upgrade : apt update cache] 
*********************
ok: [nmc-core.blue-mind.loc] 
TASK [bluemind_upgrade : Verify aptitude package] 
*********************
changed: [nmc-core.blue-mind.loc] 
TASK [bluemind_upgrade : apt update & clean] 
*********************
changed: [nmc-core.blue-mind.loc] 
TASK [bluemind_upgrade : apt dist-upgrade] 
*********************
ok: [nmc-core.blue-mind.loc] 
TASK [bluemind_upgrade : shell] 
*********************
changed: [nmc-core.blue-mind.loc] 
PLAY RECAP 
*********************
nmc-core.blue-mind.loc     : ok=7    changed=3    unreachable=0    failed=0   

Installing a shard + a core: 

In this second example, we are installing a BlueMind core server and deporting email, contacts, calendars, etc. data to a dedicated server (called shard in BlueMind speak).

As above, get the u1000_requirements.yml file here.

Ansible-galaxy install -r u1000_requirements.yml

The variables are: 

--- 
bluemind: 
  hosts: 
    nmc-core.blue-mind.loc: 
      Ansible_host: 192.168.0.15 
      Ansible_become_password: "SET_ROOT_PASSWORD_HERE" 
      Ansible_ssh_common_args: '-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null' 
      Ansible_user: bluemind 
    nmc-data.blue-mind.loc: 
      Ansible_host: 192.168.0.16 
      Ansible_become_password: "SET_ROOT_PASSWORD_HERE" 
      Ansible_ssh_common_args: '-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null' 
      Ansible_user: bluemind 
  vars: 
    sw_password: "admin" 
    external_url: "mail.blue-mind.loc" 
    tick_module: true 
    synchro_ldap_module: false 
    subscription_contact: "admin@blue-mind.loc" 
    synchro_ad_module: false 
    local_works_directory: "/usr/local/bluemind/" 
    email_domain: "blue-mind.loc" 
    subscription_file: "/usr/local/bluemind/subscribe.bmz" 
    shardip: "192.168.0.16" 
    export_ldap_module: false 
    core_server_fqdn: "nmc-core.blue-mind.loc" 

In this case, the possibility to install tick, LDAP or AP synchronisation or LDAP export modules is embedded in the bluemind-core.

New modules may become available in the future – e.g. to deploy bm-mapi or corporate signatures.

root@nmc-Ansible:/etc/Ansible# Ansible-playbook -l bluemind playbooks/bm/bluemind_core_cyrus.yml 
PLAY [Configuring BlueMind requirements] 
*********************
TASK [Gathering Facts] 
*********************
ok: [nmc-core.blue-mind.loc] 
ok: [nmc-data.blue-mind.loc] 
TASK [bluemind_requirements :  Load Operating System : Debian 9] 
*********************
ok: [nmc-data.blue-mind.loc] => (item=/etc/Ansible/roles/bluemind_requirements/vars/debian_family.yml) 
ok: [nmc-core.blue-mind.loc] => (item=/etc/Ansible/roles/bluemind_requirements/vars/debian_family.yml) 
TASK [bluemind_requirements : include_tasks] 
*********************
skipping: [nmc-data.blue-mind.loc] 
skipping: [nmc-core.blue-mind.loc] 
TASK [bluemind_requirements : include_tasks] 
*********************
included: /etc/Ansible/roles/bluemind_requirements/tasks/debian.yml for nmc-data.blue-mind.loc, nmc-core.blue-mind.loc 
TASK [bluemind_requirements : assert] 
*********************
ok: [nmc-data.blue-mind.loc] => { 
    "changed": false, 
    "msg": "All assertions passed" 
} 
ok: [nmc-core.blue-mind.loc] => { 
    "changed": false, 
    "msg": "All assertions passed" 
} 
TASK [bluemind_requirements : set /etc/hostname] 
*********************
ok: [nmc-core.blue-mind.loc] 
ok: [nmc-data.blue-mind.loc] 
TASK [bluemind_requirements : Ensure en_US.UTF-8 locale exists] 
*********************
ok: [nmc- core.blue-mind.loc] 
changed: [nmc-data.blue-mind.loc] 
TASK [bluemind_requirements : Set LC_ALL] 
*********************
ok: [nmc-core.blue-mind.loc] 
changed: [nmc-data.blue-mind.loc] 
TASK [bluemind_requirements : Set LANG] 
*********************
changed: [nmc-data.blue-mind.loc] 
ok: [nmc-core.blue-mind.loc] 
TASK [bluemind_requirements : Install apt Packages] 
*********************
changed: [nmc-core.blue-mind.loc] 
changed: [nmc-data.blue-mind.loc] 
TASK [bluemind_requirements : Update] 
*********************
ok: [nmc-data.blue-mind.loc] 
ok: [nmc-core.blue-mind.loc] 
TASK [bluemind_requirements : Upgrade apt packages] 
*********************
changed: [nmc-data.blue-mind.loc] 
changed: [nmc-core.blue-mind.loc] 
TASK [bluemind_requirements : Install your subscribe file] 
*********************
changed: [nmc-data.blue-mind.loc -> localhost] 
changed: [nmc-core.blue-mind.loc -> localhost] 
TASK [bluemind_requirements : Copy BlueMind repository file into the server] 
*********************
changed: [nmc-core.blue-mind.loc] 
changed: [nmc-data.blue-mind.loc] 
TASK [bluemind_requirements : Adding BlueMind Public Key] 
********************* 
changed: [nmc-data.blue-mind.loc] 
changed: [nmc-core.blue-mind.loc] 
TASK [bluemind_requirements : Configure BM repository priority] 
*********************
changed: [nmc-data.blue-mind.loc] 
changed: [nmc-core.blue-mind.loc] 
TASK [bluemind_requirements : apt_repository] 
*********************
skipping: [nmc-data.blue-mind.loc] 
skipping: [nmc-core.blue-mind.loc] 
TASK [bluemind_requirements : Update repositories] 
*********************
changed: [nmc-data.blue-mind.loc] 
changed: [nmc-core.blue-mind.loc] 
PLAY [Install BlueMind Data] 
*********************
TASK [Gathering Facts] 
*********************
ok: [nmc-data.blue-mind.loc] 
TASK [bluemind_cyrus : include_tasks] 
*********************
skipping: [nmc-data.blue-mind.loc] 
TASK [bluemind_cyrus : include_tasks] 
*********************
included: /etc/Ansible/roles/bluemind_cyrus/tasks/debian.yml for nmc-data.blue-mind.loc 
TASK [bluemind_cyrus : Install BlueMind Packages] 
*********************
changed: [nmc-data.blue-mind.loc] 
TASK [bluemind_cyrus : Install Tick Packages] 
*********************
changed: [nmc-data.blue-mind.loc] 
PLAY [Install BlueMind Core] 
*********************
TASK [Gathering Facts] 
********************* 
ok: [nmc-core.blue-mind.loc] 
TASK [bluemind_core : include_tasks] 
*********************
skipping: [nmc-core.blue-mind.loc] 
TASK [bluemind_core : include_tasks] 
*********************
included: /etc/Ansible/roles/bluemind_core/tasks/debian.yml for nmc-core.blue-mind.loc 
TASK [bluemind_core : Install BlueMind Packages] 
*********************
changed: [nmc-core.blue-mind.loc] 
TASK [bluemind_core : Install Tick Packages] 
*********************
changed: [nmc-core.blue-mind.loc] 
TASK [bluemind_core : Install Export LDAP Packages] 
*********************
skipping: [nmc-core.blue-mind.loc] 
TASK [bluemind_core : Install Synhcro LDAP Packages] 
*********************
skipping: [nmc-core.blue-mind.loc] 
TASK [bluemind_core : Install Synchro AD Packages] 
*********************
skipping: [nmc-core.blue-mind.loc] 
TASK [bluemind_core : Install and configure Core Service with a shard server] 
*********************
changed: [nmc-core.blue-mind.loc] 
TASK [bluemind_core : Install and configure Core Service] 
*********************
skipping: [nmc-core.blue-mind.loc] 
TASK [bluemind_core : Fetch mcast.id] 
*********************
changed: [nmc-core.blue-mind.loc] 
TASK [bluemind_core : Fetch bm-core.tok] 
*********************
changed: [nmc-core.blue-mind.loc] 
TASK [bluemind_core : Disabled bm-cyrus-imapd if shard is defined] 
*********************
changed: [nmc-core.blue-mind.loc] 
TASK [bluemind_core : Disabled bm-lmtpd if shard is defined] 
*********************
changed: [nmc-core.blue-mind.loc] 
TASK [bluemind_core : Configure Tick] 
*********************
changed: [nmc-core.blue-mind.loc] 
RUNNING HANDLER [bluemind_core : restart NGINX] 
********************* 
changed: [nmc-core.blue-mind.loc] 
RUNNING HANDLER [bluemind_core : stop bm-cyrus-imapd] 
*********************
changed: [nmc-core.blue-mind.loc] 
RUNNING HANDLER [bluemind_core : stop bm-lmtpd] 
*********************
changed: [nmc-core.blue-mind.loc] 
PLAY RECAP 
*********************
nmc-core.blue-mind.loc     : ok=29   changed=18   unreachable=0    failed=0    
nmc-data.blue-mind.loc     : ok=20   changed=12   unreachable=0    failed=0    

Finally, deploying a BlueMind instance made up of a core server, a back-end data server and a dedicated elasticsearch server is possible as shown for 3,000 users .

In conclusion…

One of the key challenges of installing a new email system is being able to perform continuous integration and deployment with no downtime. This typically requires a lot of coding work involving multiple tools and therefore time and resources.

Ansible is a powerful open-source automation tool that reduces the use of time and resources to a minimum while ensuring the service’s availability. On installations with a large number of users, BlueMind, with Ansible, helps reduce downtime, minimises human error and saves a huge amount of time.

Multiple additional roles are in the pipeline, including the possibility to run scheduled tasks, configure the BlueMind system or corporate signatures, LDAP syncing, etc.

While we are using Ansible in this article, other tools such as Saltstack, Puppet or Chef are equally valid. BlueMind can help you adapt these Ansible examples to other deployment tools.

Find out about our DevOps and continuous integration approach here.

By Manuel Guilley, BlueMind Integrator.

Picture of Manuel Guilley

Manuel Guilley

BlueMind Integrator
Share this article

Leave a Reply

Your email address will not be published. Required fields are marked *

95 − = 89

Subscription to the newsletter

One e-mail per month to keep up to date with all BlueMind news