Skip to content

Palachev/ansible-docker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Ansible Docker Installation

This repository contains an Ansible playbook and role to install and configure Docker and Docker Compose on both Ubuntu and CentOS systems.

🎯 Purpose

The goal of this project is to provide a reusable, production-ready Ansible setup that:

  • Installs Docker CE and Docker Compose.
  • Supports Ubuntu (Debian family) and CentOS (RedHat family).
  • Uses idempotent tasks and handlers for services.
  • Can be extended with monitoring, Kubernetes, and other DevOps tools.

🧰 Repository Structure

.
β”œβ”€β”€ ansible.cfg
β”œβ”€β”€ inventory.ini # List of hosts/groups
β”œβ”€β”€ roles.yml # Main playbook including roles
└── roles/
└── docker/ # Role for Docker installation
β”œβ”€β”€ tasks/
β”‚ β”œβ”€β”€ main.yml
β”‚ β”œβ”€β”€ install_ubuntu.yml
β”‚ └── install_centos.yml
β”œβ”€β”€ handlers/
β”‚ └── main.yml
��── defaults/
└── main.yml # Variables (Docker versions, URLs, etc.)
bash

##  Supported Platforms

- Ubuntu (Debian-family)
- CentOS / RHEL (RedHat-family)

##  Usage

1. Clone the repository:
```bash
git clone https://github.com/Palachev/ansible-docker.git
cd ansible-docker
  1. Edit inventory.ini to define your target hosts:
[linux]
ubuntu1 ansible_host=<IP_ADDRESS>
ubuntu2 ansible_host=<IP_ADDRESS>
centos1 ansible_host=<IP_ADDRESS>
Run the playbook:
  1. Run the playbook:
ansible-playbook -i inventory.ini roles.yml --ask-become-pass
  • --ask-become-pass will prompt for the sudo password.

  • The playbook detects the OS family and executes appropriate tasks automatically.

Variables

You can modify default variables in roles/docker/defaults/main.yml: docker_version

docker_compose_version

Repository URLs, etc.

βœ… Handlers Tasks notify the handler Restart docker whenever Docker is installed or updated. The handler runs only when changes occur, ensuring idempotent behavior.

πŸ’‘ Extending the Playbook This role can be extended to:

Add monitoring (Grafana, Prometheus)

Deploy Kubernetes clusters

Automate container migrations

Configure alerts and backups

πŸ“„ License MIT License (or your preferred license)

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors