Initial commit: VM Creation done

This commit is contained in:
Lino Silva
2026-03-30 10:54:16 +01:00
commit 97e7d65f42
27 changed files with 474 additions and 0 deletions
+39
View File
@@ -0,0 +1,39 @@
---
- name: Create traefik directory
file:
path: /opt/traefik
state: directory
mode: '0755'
- name: Create traefik data directory
file:
path: /opt/traefik/data
state: directory
mode: '0755'
- name: Create proxy network
docker_network:
name: proxy
- name: Create acme.json for Let's Encrypt
file:
path: /opt/traefik/data/acme.json
state: touch
mode: '0600'
- name: Create traefik config file
template:
src: traefik.yml.j2
dest: /opt/traefik/data/traefik.yml
mode: '0644'
- name: Create docker-compose file
template:
src: docker-compose.yml.j2
dest: /opt/traefik/docker-compose.yml
mode: '0644'
- name: Start Traefik
community.docker.docker_compose_v2:
project_src: /opt/traefik
state: present
@@ -0,0 +1,36 @@
version: '3.8'
services:
traefik:
image: traefik:v3.0
container_name: traefik
restart: unless-stopped
security_opt:
- no-new-privileges:true
networks:
- proxy
ports:
- "80:80"
- "443:443"
- "8080:8080" # Dashboard
volumes:
- /etc/localtime:/etc/localtime:ro
- /var/run/docker.sock:/var/run/docker.sock:ro
- ./data/traefik.yml:/traefik.yml:ro
- ./data/acme.json:/acme.json
labels:
- "traefik.enable=true"
- "traefik.http.routers.traefik.entrypoints=http"
- "traefik.http.routers.traefik.rule=Host(`traefik.{{ domain | default('local') }}`)"
- "traefik.http.middlewares.traefik-https-redirect.redirectscheme.scheme=https"
- "traefik.http.middlewares.sslheader.headers.customrequestheaders.X-Forwarded-Proto=https"
- "traefik.http.routers.traefik.middlewares=traefik-https-redirect"
- "traefik.http.routers.traefik-secure.entrypoints=https"
- "traefik.http.routers.traefik-secure.rule=Host(`traefik.{{ domain | default('local') }}`)"
- "traefik.http.routers.traefik-secure.tls=true"
- "traefik.http.routers.traefik-secure.tls.certresolver=cloudflare"
- "traefik.http.routers.traefik-secure.service=api@internal"
networks:
proxy:
external: true
@@ -0,0 +1,33 @@
api:
dashboard: true
debug: true
entryPoints:
http:
address: ":80"
http:
redirections:
entryPoint:
to: https
scheme: https
https:
address: ":443"
serversTransport:
insecureSkipVerify: true
providers:
docker:
endpoint: "unix:///var/run/docker.sock"
exposedByDefault: false
certificatesResolvers:
cloudflare:
acme:
email: {{ letsencrypt_email | default('admin@example.com') }}
storage: acme.json
dnsChallenge:
provider: cloudflare
resolvers:
- "1.1.1.1:53"
- "1.0.0.1:53"