File tree Expand file tree Collapse file tree 7 files changed +82
-3
lines changed Expand file tree Collapse file tree 7 files changed +82
-3
lines changed Original file line number Diff line number Diff line change 80
80
- playbook : nodejs-role.yml
81
81
distro : centos7
82
82
83
- # TODO: Not easy to test in CI at this time.
84
- # - playbook: orchestration.yml
85
- # distro: ubuntu2004
83
+ - shell_script : orchestration.sh
86
84
87
85
- playbook : security.yml
88
86
distro : centos8
Original file line number Diff line number Diff line change
1
+ [defaults]
2
+ inventory = hosts.ini
3
+ nocows = True
Original file line number Diff line number Diff line change
1
+ #! /bin/bash
2
+ #
3
+ # App server orchestration ad-hoc tasks.
4
+ set -e
5
+
6
+ # Configure Django on app server.
7
+ ansible app -b -m yum -a " name=MySQL-python state=present"
8
+ ansible app -b -m yum -a " name=python-setuptools state=present"
9
+ ansible app -b -m easy_install -a " name=django<2 state=present"
10
+
11
+ # Check Django version.
12
+ ansible app -a " python -c 'import django; print django.get_version()'"
13
+
14
+ # Other commands from the book.
15
+ ansible app -b -a " service ntpd status"
16
+ ansible app -b -m group -a " name=admin state=present"
17
+ ansible app -b -m user -a " name=johndoe group=admin createhome=yes"
18
+ ansible app -b -m user -a " name=johndoe state=absent remove=yes"
19
+ ansible app -b -m package -a " name=git state=present"
Original file line number Diff line number Diff line change
1
+ #! /bin/bash
2
+ #
3
+ # Database server orchestration ad-hoc tasks.
4
+ set -e
5
+
6
+ # Configure MySQL (MariaDB) server.
7
+ ansible db -b -m yum -a " name=mariadb-server state=present"
8
+ ansible db -b -m service -a " name=mariadb state=started enabled=yes"
9
+ ansible db -b -a " iptables -F"
10
+ ansible db -b -a " iptables -A INPUT -s 192.168.60.0/24 -p tcp -m tcp --dport 3306 -j ACCEPT"
11
+
12
+ # Configure DB user for Django.
13
+ ansible db -b -m yum -a " name=MySQL-python state=present"
14
+ ansible db -b -m mysql_user -a " name=django host=% password=12345 priv=*.*:ALL state=present"
Original file line number Diff line number Diff line change
1
+ [multi]
2
+ app
3
+ db
4
+
5
+ [multi:vars]
6
+ ansible_connection =docker
Original file line number Diff line number Diff line change
1
+ #! /bin/bash
2
+ #
3
+ # Multi-server tests for the orchestration example.
4
+ set -e
5
+
6
+ # Other commands from the book.
7
+ ansible multi -m stat -a " path=/etc/environment"
8
+ ansible multi -m copy -a " src=/etc/hosts dest=/tmp/hosts"
9
+ ansible multi -b -m fetch -a " src=/etc/hosts dest=/tmp"
10
+ ansible multi -m file -a " dest=/tmp/test mode=644 state=directory"
11
+ ansible multi -m file -a " dest=/tmp/test state=absent"
12
+ ansible multi -b -B 3600 -P 0 -a " yum -y update"
13
+ ansible multi -b -a " tail /var/log/messages"
14
+ ansible multi -b -m shell -a " tail /var/log/messages | grep ansible-command | wc -l"
Original file line number Diff line number Diff line change
1
+ #! /bin/bash
2
+ #
3
+ # Orchestration tests.
4
+ set -e
5
+
6
+ # Make sure pip3 is available.
7
+ sudo apt-get update
8
+ sudo apt-get install -y python3-pip python3-setuptools
9
+ pip3 install --upgrade setuptools pip
10
+
11
+ # Install dependencies.
12
+ sudo pip3 install ansible
13
+
14
+ cd orchestration/scripts
15
+
16
+ # Test Django app installation.
17
+ docker run -d --name app -p 80:80 --privileged -v /sys/fs/cgroup:/sys/fs/cgroup:ro geerlingguy/docker-centos7-ansible
18
+ ./django-app.sh
19
+
20
+ # Test Django db installation.
21
+ docker run -d --name db -p 3360:3360 --privileged -v /sys/fs/cgroup:/sys/fs/cgroup:ro geerlingguy/docker-centos7-ansible
22
+ ./django-db.sh
23
+
24
+ # Other tests from the book.
25
+ ./orchestration.sh
You can’t perform that action at this time.
0 commit comments