feat: add outbound proxy

This commit is contained in:
Adrien Waksberg 2022-04-05 09:04:29 +02:00
parent 1cadd9c5b6
commit 0d1261e384
5 changed files with 46 additions and 0 deletions

View file

@ -35,6 +35,14 @@ Install and configure Grafana
url: https://github.com/sensu/grafana-sensu-go-datasource/releases/download/1.0.2/sensu-sensugo-datasource-1.0.2.zip url: https://github.com/sensu/grafana-sensu-go-datasource/releases/download/1.0.2/sensu-sensugo-datasource-1.0.2.zip
``` ```
- `grafana_proxy_url` - set an URL proxy for outbound http and https requests
- `grafana_proxy_ignore` - array with subnets or hosts to ignore
```
- localhost
- 10.0.0.0/8
```
## How to use ## How to use
``` ```

View file

@ -2,3 +2,4 @@
grafana_config: {} grafana_config: {}
grafana_ldap_config: {} grafana_ldap_config: {}
grafana_plugins: [] grafana_plugins: []
grafana_proxy_ignore: []

View file

@ -16,6 +16,15 @@ def test_config_file(host):
assert path.contains('[security]') assert path.contains('[security]')
assert path.contains('admin_user = "sysadmin"') assert path.contains('admin_user = "sysadmin"')
def test_default_config_file(host):
path = host.file('/etc/default/grafana-server')
assert path.exists
assert path.is_file
assert path.user == 'root'
assert path.group == 'root'
assert path.mode == 0o644
assert path.contains('LOG_DIR=/var/log/grafana')
def test_ldap_config_file(host): def test_ldap_config_file(host):
path = host.file('/etc/grafana/ldap.toml') path = host.file('/etc/grafana/ldap.toml')
assert path.exists assert path.exists

View file

@ -32,6 +32,16 @@
until: result is succeeded until: result is succeeded
tags: grafana tags: grafana
- name: copy default environment variables file
ansible.builtin.template:
src: default.j2
dest: /etc/default/grafana-server
owner: root
group: root
mode: 0644
notify: restart grafana
tags: grafana
- name: copy configuration file - name: copy configuration file
ansible.builtin.template: ansible.builtin.template:
src: grafana.ini.j2 src: grafana.ini.j2

18
templates/default.j2 Normal file
View file

@ -0,0 +1,18 @@
# {{ ansible_managed }}
GRAFANA_HOME=/usr/share/grafana
LOG_DIR=/var/log/grafana
DATA_DIR=/var/lib/grafana
MAX_OPEN_FILES=10000
CONF_DIR=/etc/grafana
CONF_FILE=/etc/grafana/grafana.ini
RESTART_ON_UPGRADE=true
PLUGINS_DIR=/var/lib/grafana/plugins
PROVISIONING_CFG_DIR=/etc/grafana/provisioning
PID_FILE_DIR=/run/grafana
{% if grafana_proxy_url is defined %}
https_proxy={{ grafana_proxy_url }}
http_proxy={{ grafana_proxy_url }}
no_proxy={{ grafana_proxy_ignore|join(',') }}
{% endif %}