Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue #221: Add tests for current multi-server ad-hoc orchestration e…
…xamples.
- Loading branch information
1 parent
b510094
commit 9fa380e
Showing
7 changed files
with
82 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[defaults] | ||
inventory = hosts.ini | ||
nocows = True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/bin/bash | ||
# | ||
# App server orchestration ad-hoc tasks. | ||
set -e | ||
|
||
# Configure Django on app server. | ||
ansible app -b -m yum -a "name=MySQL-python state=present" | ||
ansible app -b -m yum -a "name=python-setuptools state=present" | ||
ansible app -b -m easy_install -a "name=django<2 state=present" | ||
|
||
# Check Django version. | ||
ansible app -a "python -c 'import django; print django.get_version()'" | ||
|
||
# Other commands from the book. | ||
ansible app -b -a "service ntpd status" | ||
ansible app -b -m group -a "name=admin state=present" | ||
ansible app -b -m user -a "name=johndoe group=admin createhome=yes" | ||
ansible app -b -m user -a "name=johndoe state=absent remove=yes" | ||
ansible app -b -m package -a "name=git state=present" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/bin/bash | ||
# | ||
# Database server orchestration ad-hoc tasks. | ||
set -e | ||
|
||
# Configure MySQL (MariaDB) server. | ||
ansible db -b -m yum -a "name=mariadb-server state=present" | ||
ansible db -b -m service -a "name=mariadb state=started enabled=yes" | ||
ansible db -b -a "iptables -F" | ||
ansible db -b -a "iptables -A INPUT -s 192.168.60.0/24 -p tcp -m tcp --dport 3306 -j ACCEPT" | ||
|
||
# Configure DB user for Django. | ||
ansible db -b -m yum -a "name=MySQL-python state=present" | ||
ansible db -b -m mysql_user -a "name=django host=% password=12345 priv=*.*:ALL state=present" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[multi] | ||
app | ||
db | ||
|
||
[multi:vars] | ||
ansible_connection=docker |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/bin/bash | ||
# | ||
# Multi-server tests for the orchestration example. | ||
set -e | ||
|
||
# Other commands from the book. | ||
ansible multi -m stat -a "path=/etc/environment" | ||
ansible multi -m copy -a "src=/etc/hosts dest=/tmp/hosts" | ||
ansible multi -b -m fetch -a "src=/etc/hosts dest=/tmp" | ||
ansible multi -m file -a "dest=/tmp/test mode=644 state=directory" | ||
ansible multi -m file -a "dest=/tmp/test state=absent" | ||
ansible multi -b -B 3600 -P 0 -a "yum -y update" | ||
ansible multi -b -a "tail /var/log/messages" | ||
ansible multi -b -m shell -a "tail /var/log/messages | grep ansible-command | wc -l" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/bin/bash | ||
# | ||
# Orchestration tests. | ||
set -e | ||
|
||
# Make sure pip3 is available. | ||
sudo apt-get update | ||
sudo apt-get install -y python3-pip python3-setuptools | ||
pip3 install --upgrade setuptools pip | ||
|
||
# Install dependencies. | ||
sudo pip3 install ansible | ||
|
||
cd orchestration/scripts | ||
|
||
# Test Django app installation. | ||
docker run -d --name app -p 80:80 --privileged -v /sys/fs/cgroup:/sys/fs/cgroup:ro geerlingguy/docker-centos7-ansible | ||
./django-app.sh | ||
|
||
# Test Django db installation. | ||
docker run -d --name db -p 3360:3360 --privileged -v /sys/fs/cgroup:/sys/fs/cgroup:ro geerlingguy/docker-centos7-ansible | ||
./django-db.sh | ||
|
||
# Other tests from the book. | ||
./orchestration.sh |