Developing a monolithic application is fairly easy. However, it is a different ball game when multiple systems are involved. The complexity increases multi-fold for every new system brought into the environment.
Today, let's discuss about some of the mundane tasks performed in developing product and software applications and how to improve the situation by introducing automation to application deployment and config management.
Imagine an application exposing RESTful API on the Mule ESB server executing queries and performing updates on a legacy database running on MySQL and then posting the output on a Message Broker. In this scenario, for a developer working on Mule, the messaging broker and the DB are required to be set up on the dev machine in order to test the feature under development.
Precious time is wasted on-boarding new developers to the team as the dependent systems/software are installed on every dev box. The new developer has to either read through a detailed document on how and what to be configured or get help from others in the team. It is possible to go wrong with a small config change and spend endless hours figuring out the problem.
Also, during the course of development the messaging queue names can change and database tables get altered. Keeping the developer sandbox in sync with all the changes can be a big ask for the developer.
The problems are just not limited to development but manually performing installations and system upgrades can increase the time required to release a new feature in production.
Applications get deployed in different environments and requirements can change from one environment to another. The team may decide to run multiple instances of Mule in Staging and Production environments for load balancing purposes and manually performing the upgrades can be error prone and time consuming. Getting the deployment right and automating the tasks is the key to alleviating the pain associated with inter-system dependencies and achieving continuous delivery.
There are tools available to address the issues discussed here by helping manage software deployment and apply configurations in a much sophisticated manner. Lets look at two such tools: Vagrant and Ansible
Vagrant is a tool for managing virtual machines. It supports both VirtualBox and VMWare and with Vagrant it's easy to create and manage development environments. Instead of installing software on each and every machine it is easy to install the required software like MySQL and RabbitMQ on the Virtual Machine and export the box so that the VM with pre installed software is ready for use to all developers. Setting up a development environment can happen in a matter of minutes and there is no need to maintain a separate document as the Vagrant configuration file can server as a living document.
|By running a simple Command
vagrant box add precise64 http://files.vagrantup.com/precise64.box
Vagrant downloads a VM box (with Ubuntu OS) ready to be up and running.
The Vagrant configuration file is where additional things such
as port forwarding, shared folders, memory etc can be set up.
Now SSH to the VM, install Java, MySQL, RabbitMQ and
all other required software and then export the box with the command
Vagrant creates a new package with the name package.box installed
with all the required software ready to be distributed to developers
Installing the software solves one part of the problem but we also need a way of applying config changes and software updates. The tool that comes to our rescue is Ansible.
Ansible is a config management tool similar to Puppet and Chef but unlike Puppet it does not require an agent to be installed. Ansible has a concept of play book which is a YAML file describing the host machines and the list of tasks to be performed. Ansible reads the YAML file, SSH to all the host machines and runs each task in parallel.
In the above case of a Mule server connecting to a legacy database if we have to imagine that the DB is managed by a different team and when the schema changes, the play book can be changed to take care of running the upgrade script and the developers has to simply run the play book on their machine.
This is particularly useful for config management across multiple environments on different hosts. A new instance of production box can be set-up in a matter of minutes.
Ansible can also be used with Vagrant to set-up a virtual machine when it starts up. In addition to that, ansible supports Amazon EC2 and can be used as a complementary tool with Dockers.
- name: enable configuration file: dest=/etc/nginx/sites-enabled/default src=mysiteConfig state=link
notify: restart nginx
- name: restart nginx
service: name=nginx state=restarted
The above Snippet from an Ansible playbook has a task for copying ngnix configuration. It also has a handler “restart nginx” which is conditionally invoked to restart nginx if the content of the directory has changed.
A task is an ansible module which can perform an activity like copying a file, installing a software or restarting a service. There are hundreds of modules readily available for performing various tasks such as adding or removing users to MySQL and RabbitMQ, execute a script or run a command on remote node, etc.
By using tools like Vagrant and Ansible we reap the benefits of automation as the team starts delivering features in shorter cycles by spending less time on Software installation and dependency management.
If you would like to find out more about how Systems Integration could help you make the most out of your current infrastructure while enabling you to open your digital horizons, do give us a call at +44 (0)203 475 7980 or email us at firstname.lastname@example.org.
Other useful links: