This repository provides automation for deploying the Demo Voting App. It combines the original Docker application with Ansible automation to simplify setup and management.
- Project Overview
- Original Voting App
- Ansible Automation Role
- Directory Structure
- Requirements
- Variables
- Usage
- Docker Compose Stack
- Run in Kubernetes
- Architecture
- License
This repository provides automation to deploy the Docker-based Voting App quickly on your servers. It ensures Docker is installed, configures the application, and starts the app stack using Docker Compose.
The application itself is sourced from Docker's example-voting-app. All original source code belongs to Docker and is licensed under its original terms.
- Front-end web app in Python (
vote) - Redis for messaging
- .NET worker consuming votes
- PostgreSQL database
- Node.js web app displaying results
Notes: Only one vote per client browser is accepted. This is a simple demo application to show how multiple languages, queues, and persistence work together in Docker.
The example-voting-app-role automates deployment of the Voting App stack:
- Creates a deployment user
- Installs Git, Python3, and pip
- Clones the voting app repo
- Cleans up conflicting Docker packages
- Installs Docker and Docker Compose
- Deploys the Docker Compose stack
- Handles Docker restarts when needed
Supports both Debian/Ubuntu and RedHat/CentOS distributions.
example-voting-app-role/
├── defaults/ # Default variables
├── files/ # Application source and build context (vote, result, worker)
├── handlers/ # Handlers (restart Docker)
├── meta/ # Role metadata
├── tasks/ # Main playbook tasks
├── templates/ # Docker Compose template
├── tests/ # Test inventory and playbooks
├── vars/ # Role variables
└── README.md # This README
- Ansible >= 2.12
- Sudo privileges
- Internet access to fetch Docker packages and app repo
Some key role variables (defined in vars/main.yml):
voting_app_repo: "https://github.com/dockersamples/example-voting-app.git"
voting_app_demo_user: deployuser
voting_app_demo_user_home: "/home/{{ voting_app_demo_user }}"
voting_app_demo_user_dir: "{{ voting_app_demo_user_home }}/Voting-App-Infrastructure-Automation/ansible-automation"
docker_remove_conflicts: ...
docker_prerequisites: ...
docker_gpg_key_url: ...
docker_repo: ...
docker_packages: ...Run the playbook locally or on a remote server:
ansible-navigator run -i inventory -m stdout automate-example-voting-app.ymlThis will:
- Install Docker and dependencies
- Clone the voting app repository
- Deploy the Docker Compose stack automatically
The stack uses the following services:
- redis: Redis cache
- db: Postgres database
- vote: Python web app
- worker: .NET worker
- result: Node.js web app
Docker Compose template is applied via the Ansible role to the deployment user's directory.
This repository contains two distinct parts, each under its own license:
-
Ansible Automation Role (
example-voting-app-role)- Author: Yatindra
- License: MIT License
- This role, including all tasks, handlers, templates, and variables, is fully authored by the repository owner and can be freely used, modified, and redistributed under the MIT terms.
-
Original Voting App (
vote,worker,resultdirectories and related files)- Source: Docker Example Voting App
- License: Refer to Docker's original license in the source repository
- These files remain under their original license. No modifications to the source code license have been made.
Usage Note:
You are free to use the Ansible automation role as you like under MIT. When redistributing or modifying the Docker app itself, ensure you comply with Docker's original license terms.
