docker_env

Ansible role docker_env

Prepare Docker Environment for local testing.

GitHub Version Issues Pull Requests Downloads
github Version Issues PullRequests Ansible Role

Example Playbook

This example is taken from molecule/default/converge.yml and is tested on each push, pull request and release.

---
- name: Converge
  hosts: localhost
  become: true
  gather_facts: true
  serial:
    - 1
    - 2
    - 25%
    - 50%
  vars:
    docker_requirements: docker
    prepare_ubuntu: true
    prepare_centos: true
    prepare_rockylinux: true
    prepare_fedora: true
    prune_ubuntu: false
    prune_centos: false
    prune_rockylinux: false
    prune_fedora: false
    container_default_behavior: 'compatibility'

  roles:
    - role: buluma.docker_env

The machine needs to be prepared. In CI this is done using molecule/default/prepare.yml:

---
- name: Prepare
  hosts: all
  become: true
  gather_facts: false

  roles:
    - role: buluma.bootstrap

Also see a full explanation and example on how to use these roles.

Role Variables

The default values for the variables are set in defaults/main.yml:

---
# defaults file for docker_env

# default container variables
state: started
command: sleep 1d
privileged: true
interactive: true
tty: true
volumes:
  - /sys/fs/cgroup:/sys/fs/cgroup:rw
capabilities:
  - SYS_ADMIN
restart_policy: unless-stopped
container_default_behavior: no_defaults

# pull images/create containers
prepare_ubuntu: false
prepare_centos: false
prepare_rockylinux: false
prepare_fedora: false

# delete containers
prune_rockylinux: false
prune_centos: false
prune_ubuntu: false
prune_fedora: false

# prune everything, i.e. docker system prune
prune_everything: false

Requirements

State of used roles

The following roles are used to prepare a system. You can prepare your system in another way.

Requirement GitHub Version
buluma.bootstrap Ansible Molecule Version
buluma.epel Ansible Molecule Version
buluma.python_pip Ansible Molecule Version
buluma.docker Ansible Molecule Version

Dependencies

Most roles require some kind of preparation, this is done in molecule/default/prepare.yml. This role has a "hard" dependency on the following roles:

  • {'role': 'buluma.docker', 'when': "environment == 'production'"}

Context

This role is a part of many compatible roles. Have a look at the documentation of these roles for further information.

Here is an overview of related roles:

dependencies

Compatibility

This role has been tested on these container images:

container tags
Alpine all
Debian all
Fedora 38, 39
Ubuntu focal, bionic, jammy, lunar
opensuse all

The minimum version of Ansible required is 2.12, tests have been done to:

  • The previous version.
  • The current version.
  • The development version.

If you find issues, please register them in GitHub

Changelog

Role History

License

Apache-2.0

Author Information

Shadow Walker

About

Prepare Docker Environment for local testing.

Install
ansible-galaxy install buluma/ansible-role-docker_env
GitHub repository
License
apache-2.0
Downloads
33
Owner
DevOps Engineer