Octopus is an Ansible deployment project for the poll application.
The goal is to deploy a distributed application on five Debian machines without Docker or any other container technology.
The application is split into five services:
poll -> Redis -> worker -> PostgreSQL -> result
poll: Python Flask web client that receives votes.redis: queue used to temporarily store votes.worker: Java service that consumes votes from Redis.postgresql: PostgreSQL database that stores votes.result: Node.js web client that displays vote results.
User browser
|
v
[poll-1]
Python Flask app on port 80
|
v
[redis-1]
Redis queue
|
v
[worker-1]
Java worker
|
v
[postgresql-1]
PostgreSQL database
|
v
[result-1]
Node.js result app on port 80
.
├── playbook.yml
├── requirements.yml
├── poll.tar
├── result.tar
├── worker.tar
├── group_vars
│ └── all.yml
└── roles
├── base
│ └── tasks
│ └── main.yml
├── redis
│ ├── files
│ │ └── redis.conf
│ ├── handlers
│ │ └── main.yml
│ └── tasks
│ └── main.yml
├── postgresql
│ ├── files
│ │ ├── pg_hba.conf
│ │ └── schema.sql
│ ├── handlers
│ │ └── main.yml
│ └── tasks
│ └── main.yml
├── poll
│ ├── files
│ │ └── poll.service
│ ├── handlers
│ │ └── main.yml
│ └── tasks
│ └── main.yml
├── worker
│ ├── files
│ │ └── worker.service
│ ├── handlers
│ │ └── main.yml
│ └── tasks
│ └── main.yml
└── result
├── files
│ └── result.service
├── handlers
│ └── main.yml
└── tasks
└── main.yml
The Ansible controller needs:
- Ansible
- SSH access to the target machines
- A vault password file configured through
ANSIBLE_VAULT_PASSWORD_FILE - The
community.postgresqlAnsible collection
Install the required collection with:
ansible-galaxy collection install -r requirements.ymlThe playbook expects an inventory with these groups:
[redis]
redis-1 ansible_host=<redis-ip>
[postgresql]
postgresql-1 ansible_host=<postgresql-ip>
[poll]
poll-1 ansible_host=<poll-ip>
[worker]
worker-1 ansible_host=<worker-ip>
[result]
result-1 ansible_host=<result-ip>Each group must contain one Debian machine.
The production inventory is not required in this repository if the evaluator provides it.
Do not commit a local production file containing personal IP addresses.
Set the vault password file path:
export ANSIBLE_VAULT_PASSWORD_FILE=<path-to-vault-password-file>Run the playbook:
ansible-playbook -i production playbook.ymlRun a syntax check only:
ansible-playbook -i production playbook.yml --syntax-check