Extracted from the environment repository, wave 1. Scrubbed of private references: namespace mortis, no repository paths or issue numbers in comments and docs, the removed docker_ufw_rules guard dropped, the molecule scenario uses the FQCN and no provisioner environment overrides. ansible-lint mocks the role's FQCN because CI checks the Collection out outside an ansible_collections path. Verified: the commit hooks. Not verified: the molecule scenario (CI only). Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01MmzvM9skAvYcph2c9EiPcm
56 lines
1.9 KiB
YAML
56 lines
1.9 KiB
YAML
---
|
|
# The real Docker Engine cannot run in an unprivileged test container (dockerd needs the
|
|
# bridge, iptables and a delegated cgroup), so the role installs stand-in packages from a
|
|
# local APT repository. The repository is built and signed here, with a throwaway key, so the
|
|
# role's own tasks run unchanged: fetch the key, write the source line, install, enable and
|
|
# start the unit, join the group. Like the pihole and system_baseline scenarios, this needs
|
|
# the Ubuntu mirrors for gnupg and for the curl the role installs.
|
|
- name: Prepare
|
|
hosts: all
|
|
vars:
|
|
docker_molecule_repo: /srv/docker-stub-repo
|
|
docker_molecule_work: /var/tmp/docker-stub-work
|
|
tasks:
|
|
- name: Install gnupg, which signs the stand-in repository
|
|
ansible.builtin.apt:
|
|
name: gnupg
|
|
state: present
|
|
update_cache: true
|
|
|
|
- name: Copy the repository builder
|
|
ansible.builtin.copy:
|
|
src: build-stub-repo.sh
|
|
dest: /var/tmp/build-stub-repo.sh
|
|
owner: root
|
|
group: root
|
|
mode: "0755"
|
|
|
|
- name: Build and sign the stand-in repository
|
|
ansible.builtin.command:
|
|
argv:
|
|
- /var/tmp/build-stub-repo.sh
|
|
- "{{ docker_molecule_repo }}"
|
|
- "{{ ansible_facts['distribution_release'] }}"
|
|
- "{{ docker_molecule_work }}"
|
|
creates: "{{ docker_molecule_repo }}/docker.asc"
|
|
|
|
- name: Remove the signing key and the builder
|
|
ansible.builtin.file:
|
|
path: "{{ item }}"
|
|
state: absent
|
|
loop:
|
|
- "{{ docker_molecule_work }}"
|
|
- /var/tmp/build-stub-repo.sh
|
|
|
|
- name: Create a user for the docker group
|
|
ansible.builtin.user:
|
|
name: moleculeuser
|
|
shell: /usr/sbin/nologin
|
|
create_home: false
|
|
|
|
- name: Seed a Docker data directory for the removal test
|
|
ansible.builtin.file:
|
|
path: /var/lib/docker/molecule-marker
|
|
state: directory
|
|
mode: "0755"
|