Skip to content

Commit

Permalink
Edit README
Browse files Browse the repository at this point in the history
  • Loading branch information
medanthelinium committed Mar 13, 2024
1 parent 26fa8b2 commit 95b5e4e
Showing 1 changed file with 44 additions and 26 deletions.
70 changes: 44 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,38 +4,56 @@ A Docker role which can be used to deploy Docker containers as SystemD services.

Installs the latest version of Docker from the official repos

Compatible with Ubuntu 20.04 and 22.04
Compatible with Ubuntu 20.04 & 22.04, as well as Debian 12.

### Usage
Create a template in the role that manages your docker container with the following contents:
```
#jinja2: trim_blocks: False
The following example describes setting up a Keycloak container.

For a full example, please refer to our [ansible-keycloak](https://github.com/punktDe/ansible-keycloak) role

* Create a template in the role that manages your docker container with the following contents:
```jinja2
{%- import (role_path + "/../docker/templates/systemd/container.service")|relpath(playbook_dir) as service with context -%}
{{ service.All(example_container) }}
{{ service.All(keycloak) }}
```

Configure the container parameters using Ansible variables
```
example_container:
container_name: example
image: example:latest
container_stop_timeout: 55
volumes:
"/etc/config.cfg": { host_dir: "/var/example/config.cfg", relabel: unshared, read_only: yes }
ports:
8080: 80
environment:
KEY: "value"
entrypoint:
/etc/entrypoint
command:
echo "hello world"
* Configure the container parameters using Ansible variables. You can add other arbitrary variables to the root of the `keycloak` dictionary (in this case, `domain` and `prefix`), and refer to them inside the same dictionary using the `vars.` prefix:
```yaml
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 example_container
* Finally, provision the service file:
```yaml
- name: Install systemd service for Keycloak
template:
src: example_container.service
dest: "/etc/systemd/system/example_container.service"
src: keycloak.service
dest: "/etc/systemd/system/keycloak.service"
trim_blocks: no
```

0 comments on commit 95b5e4e

Please sign in to comment.