• Reduce public cloud costs by 30%

    with the Atos Multicloud solution

Configuration Management in CloudCenter: Ansible

Arthur Rimbun - 21st September 2017

In today’s increasingly complex IT infrastructure, a software product does not typically work as a standalone application. Companies – and large enterprises in particular – deploy IT systems that are complex and tightly integrated with one another, creating plenty of integration challenges as well as opportunities for automation.

CloudCenter is no exception. Being a platform that allows seamless deployment into many public and private clouds, it supports integration with many existing software that already exist in the market. An example was already covered in a previous blog post, which describes CloudCenter’s ability to integrate with configuration management tools, such as Puppet and Chef. Essentially, what this means is that IT infrastructure engineers can leverage their existing Puppet modules or Chef recipes to bootstrap virtual machines that are deployed using CloudCenter.

Ansible is another popular configuration management tool available in the market. While CloudCenter does not provide integration with Ansible out-of-the-box, it is fairly easy to write a custom script that allows a deployed virtual machine to be configured by an Ansible playbook. In the below tutorial, I shall walk you through the steps involved in setting up a basic virtual machine with an Ansible client installed. You can then use the installed Ansible client to execute any playbook – and thus configure the server – as you see fit. Hence, you get the best of both worlds: the elegance and ease-of-use of CloudCenter to orchestrate and manage your hybrid-cloud deployment, and the simplicity of Ansible to configure the deployed services. The following high-level diagram illustrates the workflow of Ansible in relation to CloudCenter.

The Ansible Service

CloudCenter comes pre-packaged with a set of common services that can be deployed straight into the cloud, such as the HAProxy load balancer, Tomcat web server, and MySQL database, among many others. CloudCenter also supports modelling all three as a 3-tier application profile, if you wish to do so. It also supports adding custom services. I have provided below a sample service code for installing Ansible client on CentOS and RedHat operating systems.

#!/bin/bash

exec > >(tee -a /usr/local/osmosix/logs/service.log) 2>&1

SVCNAME=ansible

OSSVC_HOME=/usr/local/osmosix/service

  • /usr/local/osmosix/etc/userenv
  • $OSSVC_HOME/utils/cfgutil.sh
  • $OSSVC_HOME/utils/os_info_util.sh

installAnsibleClient() {

    yum clean all

    yum -y update

    yum -y install python-pip python-devel

    pip install --upgrade pip

    pip install ansible

 

    exitCode=$?

    [ $exitCode -ne 0 ] && exit $exitCode

    echo "Install finished"

}

case $1 in

    install)

        installAnsibleClient

        ;;

esac

The script above is simple at its core: it installs PIP (Python package manager) and uses it to download and install the Ansible client on the virtual machine. Following standard CloudCenter new service addition procedure, the script should be placed in a file called service and packaged in an ansible.zip file. In the Agent Lifecycle Actions section, you will need to specify the path to the ZIP file and the “service install” command to execute the script during bootstrap. The screenshots below illustrate what the service looks like in the Add a New Service page in CloudCenter.

Figure 1: Virtual machine setting for Ansible service

Figure 2: Installation script setting for Ansible service. Note that this is being configured to read from Engage ESM’s S3 repository.

Save the newly created service, and that’s about it really! You will then be able to create a service profile that utilises this newly-created Ansible service, and point it to the location of the Ansible playbook you wish to execute. In a future post, I will walk through the steps of how you can use the Ansible service to install a Tomcat application using the publicly-available standalone Tomcat Ansible playbook.