watchtower_docker
Ansible role watchtower_docker
Installs and configures watchtower container based on official watchtower docker container
GitHub | Downloads | Version |
---|---|---|
Example Playbook
This example is taken from molecule/default/converge.yml
and is tested on each push, pull request and release.
---
- name: Converge
hosts: all
become: true
gather_facts: true
roles:
- role: "mullholland.watchtower_docker"
The machine needs to be prepared. In CI this is done using molecule/default/prepare.yml
:
---
- name: Prepare
hosts: all
become: true
gather_facts: true
vars:
pip_packages:
- "docker"
roles:
- role: mullholland.docker
- role: mullholland.repository_epel
- role: mullholland.pip
Role Variables
The default values for the variables are set in defaults/main.yml
:
---
# General config
watchtower_docker_network_name: "web"
watchtower_docker_base_path: "/opt"
watchtower_docker_timezone: "Europe/Berlin"
# User/Group of the stack. Everything is mapped to this, instead of root.
watchtower_docker_user: "homelab"
watchtower_docker_uid: "900"
watchtower_docker_group: "homelab"
watchtower_docker_gid: "900"
watchtower_docker_user_system: true
# which container version to install
# can also be latest
watchtower_docker_version: "containrrr/watchtower:latest"
# additional docker compose environment variables
# https://containrrr.dev/watchtower/arguments/
watchtower_docker_environment_variables:
- "WATCHTOWER_CLEANUP: true" # Removes old images after updating
- "WATCHTOWER_INCLUDE_RESTARTING: true" # Will also include restarting containers.
- "WATCHTOWER_ROLLING_RESTART: true" # Restart one image at time instead of stopping and starting all at once
- "WATCHTOWER_POLL_INTERVAL: 3600" # check every hour for image updates
# - "WATCHTOWER_LABEL_ENABLE: true" # Monitor and update containers that have a com.centurylinklabs.watchtower.enable label set to true, else update all
# Watchtower - Notifications
- "WATCHTOWER_LIFECYCLE_HOOKS: true" # to allow managing of lifecycle hooks via labels (https://containrrr.dev/watchtower/lifecycle-hooks/#executing_commands_before_and_after_updating)
# - "WATCHTOWER_NOTIFICATION_REPORT: true"
# - "WATCHTOWER_NOTIFICATION_URL: discord://token@channel"
# metrics
- "WATCHTOWER_HTTP_API_METRICS: true" # Enables a metrics endpoint
- 'WATCHTOWER_HTTP_API_TOKEN: SuperSecretToken'
watchtower_docker_volumes:
- "/var/run/docker.sock:/var/run/docker.sock:ro"
# which port to expose. can be empty if used with watchtower for example
watchtower_docker_ports: []
# - "8080:8080"
watchtower_docker_labels:
- "traefik.enable=false"
Requirements
- pip packages listed in requirements.txt.
State of used roles
The following roles are used to prepare a system. You can prepare your system in another way.
Requirement | GitHub | GitLab |
---|---|---|
mullholland.repository_epel | ||
mullholland.docker | ||
mullholland.pip |
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:
Compatibility
This role has been tested on these container images:
container | tags |
---|---|
EL | all |
Fedora | 38, 39 |
Ubuntu | all |
Debian | all |
The minimum version of Ansible required is 2.10, tests have been done to:
- The previous version.
- The current version.
- The development version.
If you find issues, please register them in GitHub.
License
MIT.
Author Information
Installs and configures watchtower container based on official watchtower docker container
ansible-galaxy install mullholland/ansible-role-watchtower_docker