Skip to content

Ozarklake/ansible-role-docker

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

63 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Ansible Role: Docker

This role install and configures Docker as well as compose and Docker SDK for Python.

Requirements

This role developed and tested with following Ansible versions:

Name Version
ansible >= 2.9.13
ansible-base >= 2.10.1
ansible-core >= 2.11.2

Other Ansible versions was not tested but will probably work.

Installation

Use ansible-galaxy install igor_nikiforov.docker to install the latest stable release of role.

You could also install it from requirements ansible-galaxy install -r requirements.yml:

# requirements.yml
---
roles:
  - name: igor_nikiforov.docker
    version: v1.1.0

Platforms

Name Version
Debian buster
Ubuntu focal, groovy
CentOS 7.4+, 8
RedHat 7.4+, 8

Other OS distributions was not tested but will probably work. In case if not please raise a PR!

Variables

Name Description Default
docker_supported_architectures List of Docker supported architectures ["x86_64", "arm64", "armhf", "s390x"]
docker_install If True, Docker will be installed true
docker_version Docker version latest
docker_bash_completion_install If True, Docker bash completion will be installed true
docker_daemon_config Docker daemon configuration {}
docker_service_enabled Whether Docker service should start on boot true
docker_service_state State of Docker service started
docker_users List of users to be added to docker group []
docker_sdk_for_python_install If True, Docker SDK for Python will be installed false
docker_sdk_for_python_version Docker SDK for Python version latest
docker_compose_install If True, Docker Compose will be installed false
docker_compose_version Docker Compose version latest
docker_compose_bash_completion_install If True, Docker Compose bash completion will be installed true

Usage

Role supports all Docker daemon configuration parameters which could be passed via docker_daemon_config variable. You could find example of JSON config format in Docker official documentation. For usage in role you should convert config from JSON to YAML format, for example using this online tool.

Examples

# playbook.yml
---
- hosts: all
  become: True
  gather_facts: False

  pre_tasks:
    - wait_for_connection: { timeout: 300 }
    - setup:

  vars:
    docker_sdk_for_python_install: True
    docker_compose_install: True
    docker_daemon_config:
      default-address-pools:
        - { base: 172.16.0.0/16, size: 26 }
      log-driver: "json-file"
      log-opts:
        max-size: "10m"
        max-file: "3"

  tasks:
    - name: Install Docker
      import_role:
        name: docker

License

MIT

Author Information

Igor Nikiforov