Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 9 Next »

Overview

We have two categories of Ansible playbooks; installations and tasks. Installation playbooks follow a hierarchy to install and configure VMs in the correct order where tasks are used for one-off or repeating jobs that we need to run, e.g. adding SSH access for a developer or running database backups.

Installation

Tasks

gl

Installation

Ansible is a Python so the easiest way to install it is using Pip;

$ sudo pip install ansible

Once it has installed it should be possible to run the following command from $TIS-DEVOPS

$ ansible jenkins -i ansible/inventory/build -m ping
10.1.0.4 | SUCCESS => {
    "changed": false, 
    "ping": "pong"
}

Creating a new stack

  1. Check out $TIS-DEVOPS
  2. Create a new directory under ansible/roles/docker-compose/templates/:stack_name, these files are treated like Jinja2 templates so variables can be used throughout.
  3. Add a docker-compose.yml in that new directory. If your application needs environment variables then use an environment section, i.e.  

    environment:
      DATABASE_HOST: "{{ database['host'] }}"
  4. Create new playbook under ansible/ directory that matches your service name

  5. Add the hosts to the Ansible inventory file for platforms you are targeting.
  6. Commit and push your changes to Github.

  7. Create a deploy job in Jenkins by copying the 'revalidation-dev-deploy' job and changing the export STACK=revalidation to match your stack name.

Cleaning up Docker Hosts

There are two steps required to clean up a host;

  1. Stop all running containers;

    $ docker stop $(docker ps -q)
  2. Remove all docker-compose files for the existing stacks; 

    $ sudo rm -rf /data/docker/stacks
  • No labels

0 Comments

You are not logged in. Any changes you make will be marked as anonymous. You may want to Log In if you already have an account.