Ansible Deployments - Health123/wiki GitHub Wiki

Ansible Deployments

Clusters are provisioned and deployed using Ansible playbooks. To get started, install ansible and it's dependencies using the ansible setup guide.

This doc will describe the commands and parameters before showing practical examples.

The formats for provision and deploy commands are:

./ansible/provision <target> <branch> <env> <tags>

./ansible/deploy <target> <branch> <env> <tags>

target (required)

A target has a set of operational dependencies, such as external database hosts, source repos, or ec2 provisioning, that must be specified. These variables are specified in ansible/vars and are partitioned by target and environment, such that for a given target each environment will still have its own configuration.

branch (required)

This is a git ref, which may be a branch name, tag, or commit ref. This is usually a branch name for staging environments and a commit ref in production environments.

env (required)

This is the project environment. (e.g. RAILS_ENV or RACK_ENV)

tags (optional)

Ansible plays can be filtered or optionally executed using tags. Optionally specifying a tag here will limit execution to only the Ansible plays which match that tag. A newly provisioned cluster will typically not use the tags parameter.

A unique cluster is identified by the concatenation: target-branch-env

Provisioned instances are assigned DNS entries in the form: target-branch-env

Examples

Provision and deploy the staging cluster for the health123 master branch.

ansible/provision health123 master staging
ansible/deploy health123 master staging

Provision and deploy the staging cluster for the main Vera branch. The independent target allows different databases and environment to be specified. The vera1 branch allows the correct repo branch to be deployed.

ansible/provision vera vera1 staging
ansible/deploy vera vera1 staging

Provision and deploy a staging cluster for a feature branch. Using the health123-vera target allows this cluster to see the staging database and share the expected health123-vera configuration, yet deploy to independent hardware without impacting the main staging cluster or merging to the main staging branch.

ansible/provision vera some-feature-branch staging
ansible/deploy vera some-feature-branch staging
⚠️ **GitHub.com Fallback** ⚠️