Add grafana role
This commit is contained in:
22
roles/grafana/templates/grafana.ini.j2
Normal file
22
roles/grafana/templates/grafana.ini.j2
Normal file
@ -0,0 +1,22 @@
|
||||
{%- macro ini_scalar(v) -%}
|
||||
{% if v is sameas True or v is sameas False %}
|
||||
{{ v | bool | lower }}{% if seq %},{% endif %}
|
||||
{% elif v is sameas None %}
|
||||
{{ "" }}
|
||||
{% else %}
|
||||
{{ v }}
|
||||
{%- endif %}
|
||||
{%- endmacro -%}
|
||||
|
||||
{%- macro render_config(config = {}) -%}
|
||||
{% for s, sc in config.items() | default({}) %}
|
||||
[{{ s }}]
|
||||
{% for k, v in sc.items() | default({}) %}
|
||||
{{ k }} = {{ ini_scalar(v) }}
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
{%- endmacro -%}
|
||||
|
||||
# {{ ansible_managed }}
|
||||
|
||||
{{ render_config(grafana_config) }}
|
44
roles/grafana/templates/nginx.conf.j2
Normal file
44
roles/grafana/templates/nginx.conf.j2
Normal file
@ -0,0 +1,44 @@
|
||||
server {
|
||||
listen 80;
|
||||
{% if ansible_all_ipv6_addresses | length %}
|
||||
listen [::]:80;
|
||||
{% endif %}
|
||||
server_name {{ grafana_domain }};
|
||||
|
||||
location /.well-known/acme-challenge/ {
|
||||
root /var/www/.acme-challenge;
|
||||
try_files $uri =404;
|
||||
}
|
||||
|
||||
{% if grafana_ssl_enabled is defined and
|
||||
grafana_ssl_enabled %}
|
||||
location / {
|
||||
return 301 https://$server_name$request_uri;
|
||||
}
|
||||
{% endif %}
|
||||
}
|
||||
|
||||
{% if grafana_ssl_enabled is defined and
|
||||
grafana_ssl_enabled %}
|
||||
server {
|
||||
listen 443 ssl;
|
||||
{% if ansible_all_ipv6_addresses | length %}
|
||||
listen [::]:443 ssl;
|
||||
{% endif %}
|
||||
server_name {{ grafana_domain }};
|
||||
|
||||
{% if grafana_ssl_certificate is defined %}
|
||||
ssl_certificate {{ grafana_ssl_certificate }};
|
||||
{% endif %}
|
||||
{% if grafana_ssl_certificate_key is defined %}
|
||||
ssl_certificate_key {{ grafana_ssl_certificate_key }};
|
||||
{% endif %}
|
||||
{% if grafana_ssl_dhparam is defined %}
|
||||
ssl_dhparam {{ grafana_ssl_dhparam }};
|
||||
{% endif %}
|
||||
|
||||
location / {
|
||||
proxy_pass http://localhost:{{ grafana_port }};
|
||||
}
|
||||
}
|
||||
{% endif %}
|
Reference in New Issue
Block a user