-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathci_3container.sh
executable file
·31 lines (25 loc) · 1.08 KB
/
ci_3container.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/usr/bin/env bash
run_fedora=$(docker ps -a --format "{{.Names}}" | grep fedora | wc -l)
run_centos=$(docker ps -a --format "{{.Names}}" | grep centos7 | wc -l)
run_ubuntu=$(docker ps -a --format "{{.Names}}" | grep ubuntu | wc -l)
if [ "$run_fedora" != 0 ]
then
echo "--- 'fedora' is present in docker ps -a. Trying to remove..."
docker stop fedora && docker rm fedora
fi
if [ "$run_centos" != 0 ]
then
echo "--- 'centos' is present in docker ps -a. Trying to remove..."
docker stop centos7 && docker rm centos7
fi
if [ "$run_ubuntu" != 0 ]
then
echo "--- 'ubuntu' is present in docker ps -a. Trying to remove..."
docker stop ubuntu && docker rm ubuntu
fi
echo "--- Starting docker containers..."
docker run -d --name fedora pycontribs/fedora sleep 6000
docker run -d --name centos7 pycontribs/centos:7 sleep 6000
docker run -d --name ubuntu pycontribs/ubuntu sleep 6000
echo "--- Starting ansible-playbook..."
ansible-playbook -i inventory/prod.yml --vault-password-file=secret site.yml && echo "--- All ok. Stopping containers..." && docker stop fedora ubuntu centos7