Skip to main content

Ansible Role: Proxy

Complete Proxy Server Role based on Traefik. This role installs and configures Traefik as a reverse proxy on Debian and Ubuntu systems.

Traefik is installed as a versioned directory under traefik_opt (e.g. /opt/traefik/traefik-v3.7.13-linux-amd64/), with {{ traefik_opt }}/traefik kept as a symlink to the active version's binary. This keeps the install idempotent — traefik_restart only fires when traefik_version actually changes — and old versioned downloads beyond traefik_keep_versions are pruned automatically.

Requirements​

This role requires Ansible 2.12 or higher. The target system should be Debian or Ubuntu.

Role Variables​

The following variables are defined in defaults/main.yml:

VariableDescriptionDefault Value
traefik_nameName of the service and usertraefik
traefik_versionTraefik version to installlatest
traefik_archRelease architecture to downloadamd64
traefik_keep_versionsNumber of old versioned installs to keep after pruning1
traefik_optInstallation directory/opt/{{ traefik_name }}
traefik_etcConfiguration directory/etc/{{ traefik_name }}
traefik_conf_dDynamic configuration directory{{ traefik_etc }}/conf.d
traefik_global_checkNewVersionCheck for new versionsfalse
traefik_global_sendAnonymousUsageSend anonymous usage datafalse
traefik_entrypointsDictionary defining Traefik entrypoints{ web: { address: ':80' }, websecure: { address: ':443' } }
traefik_apiEnable Traefik APIfalse
traefik_api_dashboardEnable Traefik Dashboardfalse
traefik_api_insecureEnable insecure API accessfalse
traefik_providers_fileEnable file providertrue
traefik_providers_file_directoryDirectory for dynamic configuration files/etc/traefik/conf.d/
traefik_providers_file_watchWatch for changes in dynamic configurationtrue
traefik_log_levelLog levelERROR
traefik_log_formatLog formatcommon
traefik_metrics_prometheusEnable Prometheus metricsfalse
traefik_routing_httpHTTP routing configuration dictionary{}
traefik_routing_tcpTCP routing configuration dictionary{}
traefik_routing_udpUDP routing configuration dictionary{}
traefik_routing_tlsTLS routing configuration dictionary{}

Dependencies​

None.

Example Playbook​

- hosts: proxy_servers
roles:
- role: ansible_role_proxy
vars:
traefik_api_dashboard: true
traefik_routing_http:
routers:
my-router:
rule: "Host(`example.com`)"
service: my-service
services:
my-service:
loadBalancer:
servers:
- url: "http://1.1.1.1:8080"

License​

GPL-3.0-only

Author Information​