bsmeding.docker
Ansible Role: Docker
This Ansible Role installs Docker on Linux systems.
Only install the version when the Continuous Integration (CI) tests are PASSING!
This role is tested on Ubuntu, Debian, and Rocky (RedHat-like) Linux distributions.
Downloads:
Originally from geerlingguy.docker Additional features:
- Remove PodMan from RedHat Linux
- Create a user and group named
docker
- Add the current Ansible user to the
docker
group - Set
docker_uid
anddocker_gid
to the IDs of thedocker
user and group, for use in my other Ansible roles that work with Docker, allowing for seamless integration.
Requirements
None.
Role Variables
Here are the available variables, along with their default values (see defaults/main.yml
):
docker_edition
: can be 'ce' (Community Edition) or 'ee' (Enterprise Edition). Default is 'ce'.docker_packages
: the list of packages to install, which includes:- "docker-{{ docker_edition }}"
- "docker-{{ docker_edition }}-cli"
- "docker-{{ docker_edition }}-rootless-extras"
docker_packages_state
: defines the package installation state (present).
To specify a specific version of Docker, use:
- For Red Hat/CentOS:
docker-{{ docker_edition }}-<VERSION>
(needs to be added to all packages). - For Debian/Ubuntu:
docker-{{ docker_edition }}=<VERSION>
(needs to be added to all packages).
You can control the installation state with docker_packages_state
, which can be set to:
present
: to install.absent
: to uninstall.latest
: to install the latest version.
If the Docker package is updated, the Docker daemon will restart automatically.
For Docker service management, you can use these variables:
docker_service_manage
: truedocker_service_state
: starteddocker_service_enabled
: truedocker_restart_handler_state
: restarted
If you're installing Docker inside a Docker container without systemd
, set docker_service_manage
to false
.
Docker Compose Options
docker_install_compose_plugin
: falsedocker_compose_package
: docker-compose-plugindocker_compose_package_state
: present
This installs the Docker Compose Plugin.
To install Docker Compose:
docker_install_compose
: truedocker_compose_version
: "1.26.0"docker_compose_arch
: "{{ ansible_architecture }}"docker_compose_path
: /usr/local/bin/docker-compose
Repository Options
docker_add_repo
: true (set to false to use system defaults).docker_repo_url
: https://download.docker.com/linux (common for Debian and RHEL).
For Debian/Ubuntu, manage the APT repository with these variables:
docker_apt_release_channel
: stabledocker_apt_arch
: determine the architecturedocker_apt_repository
: repository definitiondocker_apt_ignore_key_error
: Truedocker_apt_gpg_key
: URL for the GPG keydocker_apt_filename
: Name of the source list file.
For RedHat/CentOS, manage the YUM repository with:
docker_yum_repo_url
: appropriate repo URLdocker_yum_repo_enable_nightly
: to enable Nightly repodocker_yum_repo_enable_test
: to enable Test repodocker_yum_gpg_key
: URL for the GPG key.
User Management
docker_users
: List of users to add to thedocker
group.
Custom Daemon Options
docker_daemon_options
: Custom options for the Docker daemon, defined in/etc/docker/daemon.json
.
Author Information
This role was created by Jeff Geerling in 2017, author of Ansible for DevOps. Some enhancements have been made by me (Bart Smeding).
INFO
If you encounter the error "Error connecting: Error while fetching server API version: Not supported URL scheme http+docker"}
, please upgrade the Ansible collections:
- name: community.general
- name: community.docker
Or change the requests Python library to a version lower than 2.32.0.
Docker for Linux, Forked from geerlingguy.docker.
ansible-galaxy install bsmeding.docker