GithubHelp home page GithubHelp logo

g5paul / ansible-docker-compose Goto Github PK

View Code? Open in Web Editor NEW

This project forked from andymotta/ansible-docker-compose

0.0 2.0 0.0 22 KB

Test Ansible roles locally and in Docker containers, with docker-compose. Updated to work with Container OS Amazon Linux 2 and Centos 7 on Host OS Ubuntu 16.04.5 LTS.

License: Other

ansible-docker-compose's Introduction

ansible-docker-compose

This repo forked from ansible docker compose. Updated to work with Container OS Amazon Linux 2 and Centos 7 on Host OS Ubuntu 16.04.5 LTS.

  • Docker Compose support tested on Host OS Ubuntu 16.04.5 LTS with Container OS Centos 7
    • Docker version 18.06.0-ce
    • docker-compose version 1.8.0
  • Updated support for Amazon Linux 2 for Container OS
  • Updated docker compose file to version 2
  • Original Mac OS X support has not been re-tested

The purpose of this project is to be able to test Ansible roles locally and in Docker containers, with docker-compose.

To provide an example, included are roles to create a complete local stack load-balanced by HAProxy and served by Nginx, Compliments of Sysadmin Casts.

The control node is Ubuntu/trusty and target "hosts" are either Amazon Linux 2 with init and SSH access or Centos 7 with systemd and SSH access. Basically, not the way you want to run containers but both serve their purpose as lightweight training environments.

Getting Started

First install Docker and Docker Compose:

To build and run Amazon Linux containers on Ubuntu host run the following:

chmod 0600 ./env/ansible*
docker-compose -f docker-compose.yml -f docker-compose-host-ubuntu.yml build
docker-compose -f docker-compose.yml -f docker-compose-host-ubuntu.yml up -d
cat env/ssh_host_config >> ~/.ssh/config
ssh control # do this from the repo root

To build and run Centos containers on Ubuntu host run the following:

chmod 0600 ./env/ansible*
docker-compose -f docker-compose.yml -f docker-compose-container-centos.yml -f docker-compose-host-ubuntu.yml build
docker-compose -f docker-compose.yml -f docker-compose-container-centos.yml -f docker-compose-host-ubuntu.yml up -d
cat env/ssh_host_config >> ~/.ssh/config
ssh control # do this from the repo root

Running the example playbooks from 'control' node:

ansible@control:~$ cd ansible/
ansible@control:~/ansible$ ansible-playbook site.yml
ansible@control:~/ansible$ ansible-playbook playbooks/stack_status.yml`
open http://localhost:8001 # on your local Host 

After HAProxy role finishes, or when applying ansible-playbook blog.yml, continuously refresh http://localhost:8001/haproxy?stats to watch the backends being taken out of service 50% at a time to apply the blog.

curl http://localhost:8001 a few times. You will see "Served by web1/web2" cycling.

To see Apache benchmarks run ansible-playbook playbooks/stack_status.yml

Vault

If you want to add any secrets, store them in ansible-vault: ansible-vault edit group_vars/all/vault

  • Note: This works because the vault password is injected during the Dockerfile-control build. For testing only.

After you edit the vault, add the variable to group_vars/all/vars.yml An example is included.

How to re-build Docker images for Amazon Linux containers on Ubuntu host:

docker-compose -f docker-compose.yml -f docker-compose-host-ubuntu.yml down
docker-compose -f docker-compose.yml -f docker-compose-host-ubuntu.yml build
docker-compose -f docker-compose.yml -f docker-compose-host-ubuntu.yml up -d

How to re-build Docker images for Centos 7 containers on Ubuntu host:

docker-compose -f docker-compose.yml -f docker-compose-container-centos.yml -f docker-compose-host-ubuntu.yml down
docker-compose -f docker-compose.yml -f docker-compose-container-centos.yml -f docker-compose-host-ubuntu.yml build
docker-compose -f docker-compose.yml -f docker-compose-container-centos.yml -f docker-compose-host-ubuntu.yml up -d

Final Note:

Be sure not to copy the private key env/ansible anywhere. It was generated for the purposes of this test stack, not to be uploaded anywhere else.

ansible-docker-compose's People

Contributors

andymotta avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.