mirror of
https://github.com/KevinMidboe/playbooks-retailor.git
synced 2026-09-07 13:32:06 +00:00
docker
Installs Docker CE from the official Docker apt repository on Ubuntu/Debian.
What changed from the original role
The original role had several bugs that would have made it fail or behave unpredictably:
tasks/main.ymlwas dead code that duplicatedinstall.ymlincorrectly. Nothing ever included it (onlymain-distro-check.ymlwas wired up), and it referenced undefined variables (install_packages,clean_install_remove_packageshad nobecome, etc). It's been replaced by a single real entrypoint.install.ymladded the apt repo but never fetched the GPG key, soapt-get updatewould fail signature verification. Key download and repo registration are now in one idempotent flow usingget_url+apt_repositoryinstead of rawshellcommands.check_distro.ymlusedmeta: end_play, which ends the entire Ansible run for all hosts in the play, not just this role/host. This is almost never what you want in a multi-host play. It's replaced with adocker_distro_supportedfact that gates subsequent tasks, with an optional hardfail(docker_fail_on_unsupported_distro, defaulttrue).service.ymlhad the exact same task listed twice (one with awhenguard, one without). Deduplicated into a single task.- Package state
latestwas used for prerequisites and Docker itself, which causes unnecessary upgrades (and potential breakage) on every run. Changed topresent; usedocker_install_packages+ your own update strategy if you want upgrades. - No handler was ever notified. Installing/upgrading Docker packages now
notifies the
Restart Dockerhandler. dockergroup creation used theusermodule to create a "user" named docker, which is not the same as a group and wasn't added to any actual user. Replaced with a propergrouptask plus adocker_userslist you populate to add real users to the group.- All tasks now use fully-qualified module names (
ansible.builtin.*) andname:/state:keyword syntax instead of the deprecatedkey=valueshorthand.
Role variables
See defaults/main.yml for the full list. Commonly overridden:
docker_users:
- deploy
- ci
docker_install_packages:
- docker-ce
- docker-ce-cli
- containerd.io
- docker-buildx-plugin
- docker-compose-plugin
docker_fail_on_unsupported_distro: true
Example playbook
- hosts: docker_hosts
become: true
roles:
- role: docker
vars:
docker_users:
- "{{ ansible_user }}"
Tags
docker_check_distrodocker_installdocker_usersdocker_service