Continue reading: How to deploy a microservice application to AWS

How to deploy a microservice application to AWS

In this post, I will use an example to show how you can:

  • Write a small microservice with a REST API in Java, using the Dropwizard framework
  • Containerize the application using Google JIB
  • Deploy the application to AWS using Ansible
    • With a robust, clustered and self-healing setup

Continue reading

Continue reading: How to structure Ansible variables when provisioning infrastructure

How to structure Ansible variables when provisioning infrastructure

How should you structure your Ansible variables in playbooks calling cloud modules? Ansible has extensive support for variables at different levels (there are 21 different levels!).

The inventory group_vars and host_vars offer enough flexibility for many use cases. However, when you are setting up cloud infrastructure, you don’t really have any hosts yet. Maybe you are setting up load balancers, instances, security groups and such things. Perhaps you want to setup the same things in several different environments (like “staging” and “production”). You want to re-use the same playbook, but adapt what it does by using different variable values in different environments.

In this post, I will demonstrate a way to structure Ansible variables in a playbook which pretends to setup a AWS AutoScalingGroup. I will show how you can separate the configuration for different environments by using a inventory directory. As a bonus, I will give you a neat trick to automatically load a extra variable file for each environment. We will use this to load a separate secrets file which is encrypted with git-crypt.

Continue reading

Continue reading: How to run Ansible tasks in parallel

How to run Ansible tasks in parallel

When you use Ansible to provision hosts, running a task on a set of hosts in parallel is not a problem. You simply use the `serial` keyword in a playbook. See: http://docs.ansible.com/ansible/latest/playbooks_delegation.html#rolling-update-batch-size What about when you want to run a task several times in parallel, either on each host, or on a single host? A

Continue reading
Continue reading: How to append to lists in Ansible

How to append to lists in Ansible

Since I have found the Ansible documentation to be lacking, and StackOverflow insufficient in this matter, I feel the need to share how you can append to a list using Ansible.

I’ve created a demonstration playbook and published it on GitHub. See: https://github.com/betrcode/ansible-append-list

Continue reading