add docker_ubuntu role

This commit is contained in:
Sergey Malyuk
2025-12-18 15:09:10 +03:00
parent c7d5c4bf59
commit 2c0224566e
10 changed files with 217 additions and 0 deletions

View File

@@ -0,0 +1,9 @@
---
- name: Converge
hosts: all
roles:
- role: genlab.docker_ubuntu
du_docker_version: "27.3.1"
du_registry_mirrors:
- https://docker.io
- https://mirror.gcr.io

View File

@@ -0,0 +1,27 @@
---
dependency:
name: galaxy
driver:
name: docker
platforms:
- name: ubuntu
image: geerlingguy/docker-${MOLECULE_DISTRO:-ubuntu2204}-ansible:latest
pre_build_image: true
command: ${MOLECULE_DOCKER_COMMAND:-""}
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:rw
cgroupns_mode: host
privileged: true
provisioner:
name: ansible
verifier:
name: ansible
lint: |
set -e
yamllint .
ansible-lint .

View File

@@ -0,0 +1,31 @@
---
- name: Verify
hosts: all
gather_facts: true
any_errors_fatal: true
tasks:
# https://github.com/ansible/molecule/issues/3587#issuecomment-1158650179
- name: "Include default vars"
ansible.builtin.include_vars:
dir: "{{ lookup('env', 'MOLECULE_PROJECT_DIRECTORY') }}/defaults/"
extensions: [ 'yml' ]
- name: "Sanity check Docker by running a `hello-world` container" # noqa: no-changed-when
ansible.builtin.command:
cmd: "docker run --rm hello-world"
- name: "Check if `Compose` is available from PATH" # noqa: no-changed-when
ansible.builtin.command:
cmd: "docker compose version"
- name: "Check if Docker has the expected version" # noqa: no-changed-when
register: docker_version
ansible.builtin.command:
cmd: "docker version --format '{{ '{{' }} .Server.Version {{ '}}' }}'"
- name: "Check if Docker has the expected version" # noqa: no-changed-when
ansible.builtin.assert:
that: "du_docker_version in docker_version.stdout"
success_msg: "Docker has the expected version ({{ docker_version.stdout }} )"
fail_msg: "Unexpected Docker version ({{ docker_version.stdout }})"