| defaults | ||
| handlers | ||
| meta | ||
| tasks | ||
| templates | ||
| vars | ||
| .gitignore | ||
| AGENTS.md | ||
| CHANGELOG.md | ||
| README.md | ||
WARNING: Before the release of version 1.0.0, backwards compatibility is not a thing! This means that the role's API may change between releases. If you want to use this role in a production environment, please lock the role to a specific version or commit.
Containerhost
This role installs and configures either Docker or Podman on a host. Not much more to it, really. Docker wil be installed largely following the official installation guide, while Podman will be installed from the distro's repository.
Dependencies
None, really. The role will install dependencies needed for any of the modules in the community.docker collection it uses.
Requirements
On RHEL based systems, the EPEL repository must be enabled for the role to work properly. This is because some of the packages required to not make me a liar in the Dependencies section are only available in EPEL.
Role variables
| Variable | Description | Type | Default |
|---|---|---|---|
containerhost_runtime |
The container runtime to install/use. (either docker or podman) (required) |
string | null |
containerhost_docker_plugins |
This enables you to install Docker plugins like the Loki logging driver, for example. | list[dict] | [] |
containerhost_docker_daemon_options |
This enables you to configure options like insecure registries, log level, etc. for the Docker daemon. | dict | {} |
containerhost_docker_registries |
This enables you to configure private CA certs for registries that require them. | list[dict] | [] |
containerhost_docker_swarms |
Define one or more Docker Swarms and the inventory groups that map to managers/workers/nodes. | list[dict] | [] |
containerhost_docker_swarm_node_labels |
Swarm node labels (per-host mapping or host_vars labels). | dict | {} |
Note: A single Docker daemon can only participate in one swarm at a time, so ensure each host is only a member of one swarm group across your inventory.
Tags
The following tags are available to fine tune the execution of this role:
| Tag | Description |
|---|---|
containerhost |
Covers the entire role. |
containerhost:install |
Covers installation tasks. |
containerhost:configure |
Covers configuration tasks. |
containerhost:configure:swarm |
Covers Docker Swarm configuration tasks. |
Examples
A selfcontaining Playbook:
- name: Prepare container hosts.
hosts: container_hosts
gather_facts: false
roles:
- role: "containerhost"
become: true
containerhost_runtime: "docker"
containerhost_docker_plugins:
- name: "grafana/loki-docker-driver:3.3.2-amd64"
alias: "loki"
state: "enable"
containerhost_docker_daemon_options:
insecure-registries:
- "10.133.7.69:5000"
log-driver: "json-file"
log-opts:
max-size: "10m"
max-file: "3"
tasks:
...
Docker Swarm (single swarm)
- name: Configure Docker Swarm nodes
hosts: swarm_node
gather_facts: true
roles:
- role: "containerhost"
become: true
containerhost_runtime: "docker"
containerhost_docker_swarms:
- name: "lan"
manager_group: "swarm_manager"
worker_group: "swarm_worker"
node_group: "swarm_node"
containerhost_docker_swarm_node_labels:
manager01:
zone: "lan"
role: "manager"
worker01:
zone: "lan"
Docker Swarm (host_vars labels)
- name: Configure Docker Swarm nodes
hosts: swarm_node
gather_facts: true
roles:
- role: "containerhost"
become: true
containerhost_runtime: "docker"
containerhost_docker_swarms:
- name: "lan"
manager_group: "swarm_manager"
worker_group: "swarm_worker"
node_group: "swarm_node"
containerhost_docker_swarm_node_labels:
ingress_http: "true"
Docker Swarm (multiple swarms)
- name: Configure Docker Swarm nodes
hosts: swarm_node:dmz_swarm_node
gather_facts: true
roles:
- role: "containerhost"
become: true
containerhost_runtime: "docker"
containerhost_docker_swarms:
- name: "lan"
manager_group: "swarm_manager"
worker_group: "swarm_worker"
node_group: "swarm_node"
- name: "dmz"
manager_group: "dmz_swarm_manager"
worker_group: "dmz_swarm_worker"
node_group: "dmz_swarm_node"
containerhost_docker_swarm_node_labels:
manager01:
zone: "lan"
worker01:
zone: "lan"
dmz-manager01:
zone: "dmz"
dmz-worker01:
zone: "dmz"