Skip to content

Commit de3e842

Browse files
committed
Issue #221: Update everything in Django orchestration example to CentOS 8 and Django 3.
1 parent 9fa380e commit de3e842

File tree

5 files changed

+17
-13
lines changed

5 files changed

+17
-13
lines changed

orchestration/Vagrantfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ VAGRANTFILE_API_VERSION = "2"
55

66
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
77
# General Vagrant VM configuration.
8-
config.vm.box = "geerlingguy/centos7"
8+
config.vm.box = "geerlingguy/centos8"
99
config.ssh.insert_key = false
1010
config.vm.synced_folder ".", "/vagrant", disabled: true
1111
config.vm.provider :virtualbox do |v|

orchestration/scripts/app.sh

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,14 @@
44
set -e
55

66
# 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"
7+
ansible app -b -m yum -a "name=python3-pip state=present"
8+
ansible app -b -m pip -a "name=django<4 state=present"
109

1110
# Check Django version.
12-
ansible app -a "python -c 'import django; print django.get_version()'"
11+
ansible app -a "python3 -m django --version"
1312

1413
# Other commands from the book.
15-
ansible app -b -a "service ntpd status"
14+
# ansible app -b -a "systemctl status chronyd"
1615
ansible app -b -m group -a "name=admin state=present"
1716
ansible app -b -m user -a "name=johndoe group=admin createhome=yes"
1817
ansible app -b -m user -a "name=johndoe state=absent remove=yes"

orchestration/scripts/db.sh

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,14 @@ set -e
66
# Configure MySQL (MariaDB) server.
77
ansible db -b -m yum -a "name=mariadb-server state=present"
88
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"
9+
10+
# Configure firewalld.
11+
ansible db -b -m yum -a "name=firewalld state=present"
12+
ansible db -b -m service -a "name=firewalld state=started enabled=yes"
13+
ansible db -b -m firewalld -a "zone=database state=present permanent=yes"
14+
ansible db -b -m firewalld -a "source=192.168.60.0/24 zone=database state=enabled permanent=yes"
15+
ansible db -b -m firewalld -a "port=3306/tcp zone=database state=enabled permanent=yes"
1116

1217
# Configure DB user for Django.
13-
ansible db -b -m yum -a "name=MySQL-python state=present"
18+
ansible db -b -m yum -a "name=python3-PyMySQL state=present"
1419
ansible db -b -m mysql_user -a "name=django host=% password=12345 priv=*.*:ALL state=present"

orchestration/scripts/multi.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@ ansible multi -b -m fetch -a "src=/etc/hosts dest=/tmp"
1010
ansible multi -m file -a "dest=/tmp/test mode=644 state=directory"
1111
ansible multi -m file -a "dest=/tmp/test state=absent"
1212
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"
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"

tests/orchestration.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ sudo pip3 install ansible
1414
cd orchestration/scripts
1515

1616
# 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
17+
docker run -d --name app -p 80:80 --privileged -v /sys/fs/cgroup:/sys/fs/cgroup:ro geerlingguy/docker-centos8-ansible
1818
./django-app.sh
1919

2020
# 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
21+
docker run -d --name db -p 3360:3360 --privileged -v /sys/fs/cgroup:/sys/fs/cgroup:ro geerlingguy/docker-centos8-ansible
2222
./django-db.sh
2323

2424
# Other tests from the book.

0 commit comments

Comments
 (0)