Skip to content

An Ansible Role to install and configure Docker on Linux.

License

Notifications You must be signed in to change notification settings

while-true-do/ansible-role-srv_docker

Repository files navigation

Github (tag) Github (license) Github (issues) Github (pull requests)

Travis (com)

Ansible (min. version) Ansible (platforms) Ansible (tags)

Ansible Role: srv_docker

An Ansible Role to install and configure Docker on Linux.

Motivation

Docker and Docker Containers are widely used. Setting up a docker service is very common and useful.

Description

This role is setting up docker and configuring it from official repositories.

  • install docker or docker-ce
  • control the docker-ce repository
  • optional: install docker-compose
  • start docker service
  • create docker group
  • add users to group

Requirements

Used Modules:

Installation

Install from Github

git clone https://github.com/while-true-do/ansible-role-srv_docker.git while_true_do.srv_docker

Install from Ansible Galaxy

ansible-galaxy install while_true_do.srv_docker

Usage

Role Variables

---
# defaults file for while_true_do.srv_docker

## Package Management
wtd_srv_docker_package: "docker"
# State can be present|latest|absent
wtd_srv_docker_package_state: "present"

# Define the source of docker:
# Source can be dist|ce
# dist = repository of your distribution
# ce = official community docker repository
wtd_srv_docker_package_source: "dist"
# Only used for source = ce|ee
# *_enabled can be 0|1
wtd_srv_docker_package_edge_enabled: 0
wtd_srv_docker_package_test_enabled: 0

# Docker Compose Packages
# State can be present|latest|absent|unmanaged
wtd_srv_docker_compose_package_state: "unmanaged"
# Source can be binary
wtd_srv_docker_compose_package_source: "binary"
# Only used, when source = binary
wtd_srv_docker_compose_package_version: "1.24.1"
wtd_srv_docker_compose_package_path: "/usr/local/bin/docker-compose"

## Service Management
wtd_srv_docker_service: "docker"
# State can be started|stopped
wtd_srv_docker_service_state: "started"
wtd_srv_docker_service_enabled: true

## User and Group Management
wtd_srv_docker_group: "docker"
# State can be present|absent
wtd_srv_docker_group_state: "present"
# A list of user names.
wtd_srv_docker_group_users: []

Example Playbook

Running Ansible Roles can be done in a playbook.

Simple

---
- hosts: all
  roles:
    - role: while_true_do.srv_docker

Advanced

Add users to the docker group.

- hosts: all
  roles:
    - role: while_true_do.srv_docker
      wtd_srv_docker_group_users:
        - user1
        - user2
      wtd_srv_docker_service_enabled: "no"

Use the docker-ce version and install docker-compose.

- hosts: all
  roles:
    - role: while_true_do.srv_docker
      wtd_srv_docker_compose_package_state: "present"
      wtd_srv_docker_package_source: "ce"

Known Issues

  1. RedHat Testing is currently not possible in public, due to limitations in subscriptions.
  2. Some services and features cannot be tested properly, due to limitations in docker.

Testing

Most of the "generic" tests are located in the Test Library.

Ansible specific testing is done with Molecule.

Infrastructure testing is done with testinfra.

Automated testing is done with Travis CI.

Contribute

Thank you so much for considering to contribute. We are very happy, when somebody is joining the hard work. Please fell free to open Bugs, Feature Requests or Pull Requests after reading the Contribution Guideline.

See who has contributed already in the kudos.txt.

License

This work is licensed under a BSD-3-Clause License.

Contact