docker role for Proserver
- Debian 12, 13
- Ubuntu 24.04, 22.04
Installs Docker CE from the official Docker repository, configures the Docker daemon,
sets up DNS resolution for containers via dnsmasq, and optionally configures UFW firewall rules.
| Option | Description | Type | Required | Default |
|---|---|---|---|---|
repository |
Docker APT repository configuration. | dict of 'repository' options | no | |
daemon.json |
Docker daemon configuration. Written as JSON to /etc/docker/daemon.json. |
dict of 'daemon.json' options | no | |
daemon_environment |
Environment variables to set for the Docker daemon via a systemd override. | dict | no | |
use_ufw |
Whether to configure UFW firewall rules for Docker DNS resolution. Defaults to true on Ubuntu. |
bool | no | {{ ansible_facts['distribution'] == 'Ubuntu' }} |
| Option | Description | Type | Required | Default |
|---|---|---|---|---|
apt |
URL of the Docker APT repository. | str | no | https://download.docker.com/linux/{{ ansible_facts['distribution'] |
key |
URL of the Docker APT repository GPG key. | str | no | https://download.docker.com/linux/{{ ansible_facts['distribution'] |
| Option | Description | Type | Required | Default |
|---|---|---|---|---|
dns |
List of DNS servers for containers. | list of 'str' | no | ['100.96.0.1'] |
default-address-pools |
List of default address pools for Docker networks. | list of 'dict' | no | [{'base': '100.96.0.0/16', 'size': 24}] |
log-opts |
Logging driver options for Docker containers. | dict | no | {"max-size": "2m", "max-file": "2"} |
None.
Add this role to the requirements.yml of your playbook as follows:
roles:
- name: ansible-docker
src: https://github.com/punktDe/ansible-dockerAfterwards, install the role by running ansible-galaxy install -r requirements.yml
- hosts: all
roles:
- name: dockerThe following example describes setting up a Keycloak container.
For a full example, please refer to our ansible-keycloak role
- Create a template in the role that manages your docker container with the following contents:
{%- import (role_path + "/../docker/templates/systemd/container.service")|relpath(playbook_dir) as service with context -%}
{{ service.All(keycloak) }}- Configure the container parameters using Ansible variables. You can add other arbitrary variables to the root of the
keycloakdictionary (in this case,domainandprefix), and refer to them inside the same dictionary using thevars.prefix:
keycloak:
domain: auth.example.com
prefix:
opt: /var/opt/keycloak
container_name: keycloak
image: quay.io/keycloak/keycloak:latest
container_stop_timeout: 55
depends_on:
- postgresql
- nginx
volumes:
"/opt/keycloak/conf":
host_dir: "{{ vars.keycloak.prefix.opt | quote }}/conf"
relabel: unshared
read_only: yes
"/opt/keycloak/themes":
host_dir: "{{ vars.keycloak.prefix.opt | quote }}/current/themes"
"/opt/keycloak/providers":
host_dir: "{{ vars.keycloak.prefix.opt | quote }}/current/providers"
ports:
127.0.0.1:8080: 8080
environment:
KEYCLOAK_FRONTEND_URL: "https://{{ vars.keycloak.domain }}/auth"
KC_PROXY: "edge"
entrypoint: /bin/kc.sh start-dev
command: echo "hello world"- Finally, provision the service file:
- name: Install systemd service for Keycloak
template:
src: keycloak.service
dest: "/etc/systemd/system/keycloak.service"
trim_blocks: no