Commit 955ccc98 authored by Jérémy Viau-Trudel's avatar Jérémy Viau-Trudel
Browse files

Generate 2 containers

Usage documentation

demo instructions and test playbook
parent 149553ec
......@@ -4,13 +4,31 @@ This repo aim to develop one or more dockers for testing ansible playbooks.
At maturity, one should be able to use this repo to test a playbook.
# Usage
# Ubuntu 16.04
## Démarrer, arrêter, redémarrer ou détruire une machine.
An ubuntu 16.04 docker with ssh and python. Can only be accessed by user:password. Configuration hosts file example:
./control start|stop|restart|kill
## Première connection
cat hosts |grep =| sed 's/=/ /g' | awk '{printf("ssh %s@%s -p %s exit\n", $7, $3, $9)}' | xargs -I % -n 1 sh -c %
## Accéder manuellement à une machine
ssh root@0.0.0.0 -p 32774
[dev]
0.0.0.0 ansible_ssh_pass:1234 ansible_user=root ansible_port=32773
## Exécuter le playbook de test
ansible-playbook dev.yaml
# Supported OS
## Ubuntu 16.04
An ubuntu 16.04 docker with ssh and python. Can only be accessed by user:password. Configuration hosts file example:
......
......@@ -6,11 +6,17 @@
os=ubuntu.16.04
image=ansible-test-$os-image
container=ansible-test-$os-image
port=32773
container_1=ansible-test-$os-image-1
port_1=32773
container_2=ansible-test-$os-image-2
port_2=32774
password=1234
for i in 1 2; do
pre_container=container_$i
container="${!pre_container}"
pre_port=port_$i
port="${!pre_port}"
if [ "$1" == "stop" ] || [ "$1" == "delete" ] || [ "$1" == "restart" ] || [ "$1" == "kill" ]; then
docker stop $container
echo ""
......@@ -29,7 +35,7 @@ fi
if [ "$1" == "start" ] || [ "$1" == "restart" ]; then
docker build -t $image -f Dockerfile.$os .
docker run -d -p $port:22 --name $container $image
docker run --privileged -d -p $port:22 --name $container $image
echo ""
echo "DOCKER STARTED"
......@@ -41,7 +47,7 @@ if [ "$1" == "start" ] || [ "$1" == "restart" ]; then
echo "password: $password"
echo ""
fi
done
......
---
- hosts: dev
tasks:
- debug:
msg: "Connected to {{ inventory_hostname }}"
[dev]
test-container-1 ansible_host=0.0.0.0 ansible_ssh_pass=1234 ansible_user=root ansible_port=32773
test-container-2 ansible_host=0.0.0.0 ansible_ssh_pass=1234 ansible_user=root ansible_port=32774
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment