-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
simplify template handling using jinja blocks (#9)
- Loading branch information
Showing
3 changed files
with
90 additions
and
129 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,70 +1 @@ | ||
# {{ ansible_managed }} | ||
{% if blocky__hosts_dns_enabled -%} | ||
# Added to blocky__custom_dns from inventory due to blocky__hosts_dns_enabled=true | ||
{% for host in groups[blocky__hosts_dns_invenory_group] -%} | ||
{% set fqdn = host + blocky__hosts_dns_domain %} | ||
{% if (hostvars[host]["blocky__hosts_dns_ignore"] is undefined or not hostvars[host]["blocky__hosts_dns_ignore"]) | ||
and fqdn not in blocky__custom_dns | ||
and hostvars[host][blocky__hosts_dns_host_ip_var] is defined | ||
and host != "localhost" %} | ||
{% set _ = blocky__custom_dns.update({ fqdn: hostvars[host][blocky__hosts_dns_host_ip_var] }) -%} | ||
{% else -%} | ||
# Skipping {{ host }} | ||
{% endif -%} | ||
{% endfor -%} | ||
{% endif -%} | ||
|
||
{% if blocky__cert_file | trim | length > 0 and blocky__key_file | trim | length > 0 -%} | ||
certFile: "{{ blocky__cert_file | trim }}" | ||
keyFile: "{{ blocky__key_file | trim }}" | ||
{% endif -%} | ||
{% if blocky__min_tls_version | trim | length > 0 -%} | ||
minTlsServeVersion: "{{ blocky__min_tls_version | trim }}" | ||
{% endif -%} | ||
|
||
upstreams: | ||
groups: | ||
{{ blocky__upstreams | to_nice_yaml(indent=2) | trim | indent(4) }} | ||
|
||
blocking: | ||
blockTTL: 10s | ||
denylists: | ||
{{ blocky__blocking_blacklists | to_nice_yaml(indent=2) | trim | indent(4) }} | ||
clientGroupsBlock: | ||
{{ blocky__blocking_client_groups_block | to_nice_yaml(indent=2) | trim | indent(4) }} | ||
allowlists: | ||
{{ blocky__blocking_whitelists | to_nice_yaml(indent=2) | trim | indent(4) }} | ||
|
||
ports: | ||
dns: {{ blocky__ports_dns | to_nice_yaml(indent=2) | trim | indent(2) }} | ||
http: {{ blocky__ports_http | to_nice_yaml(indent=2) | trim | indent(2) }} | ||
{% if blocky__ports_https | trim | length > 0 %} | ||
https: {{ blocky__ports_https | to_nice_yaml(indent=2) | trim | indent(2) }} | ||
{% endif %} | ||
{% if blocky__ports_tls | trim | length > 0 %} | ||
tls: {{ blocky__ports_tls | to_nice_yaml(indent=2) | trim | indent(2) }} | ||
{% endif %} | ||
|
||
log: | ||
level: {{ blocky__log_level | to_nice_yaml(indent=2) | trim | indent(2) }} | ||
|
||
caching: | ||
minTime: 5m | ||
maxTime: 60m | ||
prefetching: true | ||
|
||
customDNS: | ||
customTTL: 60m | ||
filterUnmappedTypes: true | ||
rewrite: | ||
mapping: | ||
{{ blocky__custom_dns | to_nice_yaml(indent=2) | trim | indent(4) }} | ||
|
||
conditional: | ||
fallbackUpstream: false | ||
mapping: | ||
{{ blocky__custom_domain | to_nice_yaml(indent=2) | trim | indent(4) }} | ||
|
||
prometheus: | ||
enable: true | ||
path: /metrics | ||
{% extends "config_base.j2" -%} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
# {{ ansible_managed }} | ||
{% block cert -%} | ||
{% if blocky__cert_file | trim and blocky__key_file | trim -%} | ||
certFile: "{{ blocky__cert_file | trim }}" | ||
keyFile: "{{ blocky__key_file | trim }}" | ||
{% endif -%} | ||
{% if blocky__min_tls_version | trim -%} | ||
minTlsServeVersion: "{{ blocky__min_tls_version | trim }}" | ||
{% endif -%} | ||
{% endblock %} | ||
{% block upstreams -%} | ||
upstreams: | ||
groups: | ||
{{ blocky__upstreams | to_nice_yaml(indent=2) | trim | indent(4) }} | ||
{% endblock %} | ||
|
||
{% block blocking -%} | ||
blocking: | ||
blockTTL: 10s | ||
denylists: | ||
{{ blocky__blocking_blacklists | to_nice_yaml(indent=2) | trim | indent(4) }} | ||
clientGroupsBlock: | ||
{{ blocky__blocking_client_groups_block | to_nice_yaml(indent=2) | trim | indent(4) }} | ||
allowlists: | ||
{{ blocky__blocking_whitelists | to_nice_yaml(indent=2) | trim | indent(4) }} | ||
{% endblock %} | ||
|
||
{% block ports -%} | ||
ports: | ||
dns: {{ blocky__ports_dns | to_nice_yaml(indent=2) | trim | indent(2) }} | ||
http: {{ blocky__ports_http | to_nice_yaml(indent=2) | trim | indent(2) }} | ||
{% if blocky__ports_https | trim %} | ||
https: {{ blocky__ports_https | to_nice_yaml(indent=2) | trim | indent(2) }} | ||
{% endif %} | ||
{% if blocky__ports_tls | trim %} | ||
tls: {{ blocky__ports_tls | to_nice_yaml(indent=2) | trim | indent(2) }} | ||
{% endif %} | ||
{% endblock %} | ||
|
||
{% block log -%} | ||
log: | ||
level: {{ blocky__log_level | to_nice_yaml(indent=2) | trim | indent(2) }} | ||
{% endblock %} | ||
|
||
{% block caching -%} | ||
caching: | ||
minTime: 5m | ||
maxTime: 60m | ||
prefetching: true | ||
{% endblock %} | ||
|
||
{% block custom_dns -%} | ||
{% if blocky__hosts_dns_enabled -%} | ||
{% for host in groups[blocky__hosts_dns_invenory_group] -%} | ||
{% set fqdn = host + blocky__hosts_dns_domain %} | ||
{% if (hostvars[host]["blocky__hosts_dns_ignore"] is undefined or not hostvars[host]["blocky__hosts_dns_ignore"]) | ||
and fqdn not in blocky__custom_dns | ||
and hostvars[host][blocky__hosts_dns_host_ip_var] is defined | ||
and host != "localhost" %} | ||
{% set _ = blocky__custom_dns.update({ fqdn: hostvars[host][blocky__hosts_dns_host_ip_var] }) -%} | ||
{% endif -%} | ||
{% endfor -%} | ||
{% endif -%} | ||
|
||
customDNS: | ||
customTTL: 60m | ||
filterUnmappedTypes: true | ||
rewrite: | ||
mapping: | ||
{{ blocky__custom_dns | to_nice_yaml(indent=2) | trim | indent(4) }} | ||
{% endblock %} | ||
|
||
{% block conditional -%} | ||
conditional: | ||
fallbackUpstream: false | ||
mapping: | ||
{{ blocky__custom_domain | to_nice_yaml(indent=2) | trim | indent(4) }} | ||
{% endblock %} | ||
|
||
{% block prometheus -%} | ||
prometheus: | ||
enable: true | ||
path: /metrics | ||
{% endblock %} |