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!

Test Status This role is tested on Ubuntu, Debian, and Rocky (RedHat-like) Linux distributions.

Downloads: Ansible Role

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 and docker_gid to the IDs of the docker 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: true
  • docker_service_state: started
  • docker_service_enabled: true
  • docker_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: false
  • docker_compose_package: docker-compose-plugin
  • docker_compose_package_state: present

This installs the Docker Compose Plugin.

To install Docker Compose:

  • docker_install_compose: true
  • docker_compose_version: "1.26.0"
  • docker_compose_arch: "{{ ansible_architecture }}"
  • docker_compose_path: /usr/local/bin/docker-compose

Repository Options

For Debian/Ubuntu, manage the APT repository with these variables:

  • docker_apt_release_channel: stable
  • docker_apt_arch: determine the architecture
  • docker_apt_repository: repository definition
  • docker_apt_ignore_key_error: True
  • docker_apt_gpg_key: URL for the GPG key
  • docker_apt_filename: Name of the source list file.

For RedHat/CentOS, manage the YUM repository with:

  • docker_yum_repo_url: appropriate repo URL
  • docker_yum_repo_enable_nightly: to enable Nightly repo
  • docker_yum_repo_enable_test: to enable Test repo
  • docker_yum_gpg_key: URL for the GPG key.

User Management

  • docker_users: List of users to add to the docker 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.

Informazioni sul progetto

Docker for Linux, Forked from geerlingguy.docker.

Installa
ansible-galaxy install bsmeding.docker
Licenza
mit
Download
7.2k
Proprietario
Network Automation Consultant | NetDevOps | DevNetOps | AI in networking | Home Automation