Files
ansible-role-docker/README.md
uzurka 55fbc2d877
All checks were successful
CI Workflow / validate (push) Successful in 18s
Updated README
2024-12-20 10:23:25 +01:00

111 lines
3.6 KiB
Markdown

# Ansible Role: Docker
An Ansible Role that installs [Docker](https://www.docker.com) for Debian. This role allows to add `docker` group to users, can also manage docker networks and containers.
## Role Variables
Available variables are listed below, along with default values (see `defaults/main.yml`):
### Docker package
```yaml
# Edition can be one of: 'ce' (Community Edition) or 'ee' (Enterprise Edition).
docker_edition: 'ce'
docker_package: "docker-{{ docker_edition }}"
docker_package_state: present
```
You can control whether the package is installed, uninstalled, or at the latest version by setting `docker_package_state` to `present`, `absent`, or `latest`, respectively. Note that the Docker daemon will be automatically restarted if the Docker package is updated. This is a side effect of flushing all handlers (running any of the handlers that have been notified by this and any other role up to this point in the play).
### Docker service state
```yaml
docker_service_state: started
docker_service_enabled: true
docker_restart_handler_state: restarted
```
Variables to control the state of the `docker` service, and whether it should start on boot. If you're installing Docker inside a Docker container without systemd or sysvinit, you should set these to `stopped` and set the enabled variable to `no`.
### Docker installation
```yaml
docker_apt_release_channel: stable
docker_apt_arch: amd64
docker_apt_repository: "deb [arch={{ docker_apt_arch }}] https://download.docker.com/linux/{{ ansible_distribution|lower }} {{ ansible_distribution_release }} {{ docker_apt_release_channel }}"
```
You can switch the channel to `edge` if you want to use the Edge release.
### Docker users
```yaml
docker_users:
- user1
- user2
```
A list of system users to be added to the `docker` group (so they can use Docker on the server).
A list of system users to be added to the `docker` group (so they can use Docker on the server).
```yaml
docker_daemon_options:
storage-driver: "overlay2"
log-opts:
max-size: "100m"
```
### Docker networks
See official documentation for `docker_network` module for more informations.
```yaml
docker_networks:
- name: network1
- name: network2
state: absent
```
A list of docker networks to manage.
### Docker containers
See official documentation for `docker_container` module for more informations.
```yaml
docker_containers:
- name: postgres
image: postgres:9.6
state: started
restart_policy: unless-stopped
env:
POSTGRES_USER: foo
POSTGRES_PASSWORD: bar
POSTGRES_DB: baz
- name: memcached
image: memcached:alpine
state: started
restart_policy: unless-stopped
- name: elasticsearch
image: docker.elastic.co/elasticsearch/elasticsearch:5.6.13
state: started
restart_policy: unless-stopped
memory: 1g
ulimits:
- memlock:-1:-1 # <type>:<soft>:<hard>
```
### Tags
| Tag | DESCRIPTION |
|-----------------------|-------------------------|
| docker | Global tag |
| docker_asserts | Asserts tasks |
| docker_install | Install docker |
| docker_users | Configure docker users |
| docker_networks | Configure docker networks |
| docker_containers | Deploy docker containers |
## License
MIT view [LICENSE](LICENSE)
## Sources
- https://github.com/geerlingguy/ansible-role-docker
- https://github.com/manala/ansible-roles/tree/master/manala.docker
- https://docs.ansible.com/ansible/latest/modules/docker_container_module.html
- https://github.com/atosatto/ansible-dockerswarm/