Skip to content

Latest commit

 

History

History
111 lines (89 loc) · 2.83 KB

README.md

File metadata and controls

111 lines (89 loc) · 2.83 KB

ansible-traefik-in-docker

:shipit: Ansible galaxy role to deploy Traefik in docker

The purpose of this Ansible role is to allow you to manage a Traefik reverse proxy.

With this role you will be able to generate deploy a Traefik container on you server, configure desired HTTP/HTTPS redirections and generate HTTPS associated certificates (thanks to Let's Encrypt).

Requirements

The following packages have to be installed and well configured on the host :

Role Variables

User defined variables

The following vars have to be defined on each execution by the user to configure the reverse proxy mappings

Mandatory - Endpoints list configuration

traefik_endpoints:
  endpoint_name:
    # Fontend match on host to trigger the redirection
    host: "test.localhost"
    # Backend url to redirect to
    dest: "http://perdu.com"
    # If true generate let's encrypt certificate for specified host
    host_gen_cert: true

Overridable default variables

Name of the traefik docker container

traefik_container_name: "traefik"

Path on the host filesystem where will be the traefik conf file

traefik_root_location: "/opt/docker-data/{{ traefik_container_name }}"
traefik_conf_location: "{{ traefik_root_location }}/conf"
traefik_certs_location: "{{ traefik_root_location }}/certs"

Host exposed HTTP/HTTPS/Admin ports for traefik

traefik_http_port: 80
traefik_https_port: 443
traefik_http_admin_port: 8080

Let's Encrypt CA Server to use. If false or unset prod CA Server used

traefik_le_staging: true

Let's encrypt staging environnement documentation

Let's Encrypt contact email address

traefik_le_contact_email: [email protected]

Docker networks

traefik_docker_networks: []
#traefik_docker_networks:
#  - name: "docker_network"

Docker container restart policy

traefik_container_restart_policy: "always" #(always, no, on-failure, unless-stopped)

Dependencies

--

Example Playbook

See tests/test.yml
ansible-playbook tests/test.yml --ask-sudo-password -e traefik_root_location="$(PWD)/.workdir/"

- hosts: localhost
  roles:
    - role: ../ansible-traefik-in-docker
      traefik_http_port: 8090
      traefik_http_admin_port: 8080
      traefik_https_port: 4443
      traefik_le_staging: true
      traefik_endpoints:
        influxdb:
          host: "test.localhost"
          dest: "http://perdu.com"
          host_gen_cert: false

License

MIT

Author Information

https://github.com/BastienF/ansible-traefik-in-docker