implemented compose by url, parse, local yaml.

This commit is contained in:
boris committed 2026-07-10 13:32:40 +01:00
1 parent 53695f4fff
commit 784fff8faf
218 files changed
+2271 -640

No files matched your search

@@ -0,0 +1,81 @@
{% set ns = namespace(route_count=0) %}
{% for host in groups[traefik_dynamic_inventory_group] | default([]) %}
{% set ns.route_count = ns.route_count + (hostvars[host].nbops_traefik_file_routes | default([]) | length) %}
{% endfor %}
{% if ns.route_count == 0 %}
http:
routers: {}
services: {}
{% else %}
http:
routers:
{% for host in groups[traefik_dynamic_inventory_group] | default([]) %}
{% for route in hostvars[host].nbops_traefik_file_routes | default([]) %}
{{ route.name }}:
{% if route.rule is defined %}
rule: "{{ route.rule }}"
{% else %}
rule: "Host(`{{ route.domain | default(route.name ~ '.' ~ nbops_service_domain_suffix) }}`)"
{% endif %}
entryPoints:
- {{ route.entrypoint | default(nbops_traefik_entrypoint) }}
{% if route.middlewares | default([]) | length > 0 %}
middlewares:
{% for middleware in route.middlewares %}
- {{ middleware }}
{% endfor %}
{% endif %}
service: {{ route.service | default(route.name) }}
{% if route.tls | default(nbops_traefik_tls) | bool %}
tls:
certResolver: {{ route.cert_resolver | default('letsencrypt') }}
{% endif %}
{% endfor %}
{% endfor %}
services:
{% for host in groups[traefik_dynamic_inventory_group] | default([]) %}
{% for route in hostvars[host].nbops_traefik_file_routes | default([]) %}
{{ route.service | default(route.name) }}:
loadBalancer:
servers:
{% if route.url is defined %}
- url: "{{ route.url }}"
{% else %}
- url: "{{ route.scheme | default('http') }}://{{ route.target_host | default(hostvars[host].ansible_host | default(host)) }}:{{ route.port | default(route.service_port | default(route.target_port | default(80))) }}"
{% endif %}
{% if route.pass_host_header | default(true) | bool %}
passHostHeader: true
{% else %}
passHostHeader: false
{% endif %}
{% if route.servers_transport is defined %}
serversTransport: {{ route.servers_transport }}
{% endif %}
{% endfor %}
{% endfor %}
{% if traefik_dynamic_servers_transports | length > 0 %}
serversTransports:
{% for transport in traefik_dynamic_servers_transports %}
{{ transport.name }}:
{% if transport.server_name is defined %}
serverName: "{{ transport.server_name }}"
{% endif %}
{% if transport.insecure_skip_verify | default(false) | bool %}
insecureSkipVerify: true
{% endif %}
{% if transport.root_cas | default([]) | length > 0 %}
rootCAs:
{% for ca in transport.root_cas %}
- {{ ca }}
{% endfor %}
{% endif %}
{% if transport.certificates | default([]) | length > 0 %}
certificates:
{% for certificate in transport.certificates %}
- certFile: {{ certificate.cert_file }}
keyFile: {{ certificate.key_file }}
{% endfor %}
{% endif %}
{% endfor %}
{% endif %}
{% endif %}