r/collectd-prometheus: Allow scraping from outside
The *collectd-prometheus* role now has a `collectd_prometheus_allow_outsize` variable. This variable controls whether or not external hosts are allowed to scrape data from *collectd*. When set to `false`, as is the default value, *collectd* will be configured to listen on the loopback interface only, and the TCP port will not be opened in the firewall.ntfy
parent
3127b9b8f7
commit
b78af05fd8
|
@ -1,2 +1,5 @@
|
||||||
collectd_load_prometheus_plugin: true
|
collectd_load_prometheus_plugin: true
|
||||||
collectd_prometheus_port: 9103
|
collectd_prometheus_port: 9103
|
||||||
|
collectd_prometheus_allow_outside: false
|
||||||
|
collectd_prometheus_host: >-
|
||||||
|
{% if not collectd_prometheus_allow_outside %}::1{% endif %}
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
- name: ensure collectd-local selinux module is installed
|
- name: ensure collectd-local selinux module is installed
|
||||||
copy:
|
copy:
|
||||||
src: collectd-local.pp
|
src: collectd-local.pp
|
||||||
|
mode: 'u=rw,go=r'
|
||||||
dest: /var/lib/selinux/collectd-local.pp
|
dest: /var/lib/selinux/collectd-local.pp
|
||||||
notify:
|
notify:
|
||||||
- install collectd-local selinux module
|
- install collectd-local selinux module
|
||||||
|
@ -32,3 +33,19 @@
|
||||||
- restart collectd
|
- restart collectd
|
||||||
tags:
|
tags:
|
||||||
- collectd-config
|
- collectd-config
|
||||||
|
|
||||||
|
- name: ensure firewall is configured for collectd write_prometheus plugin
|
||||||
|
firewalld:
|
||||||
|
port: '{{ collectd_prometheus_port }}/tcp'
|
||||||
|
permanent: false
|
||||||
|
immediate: true
|
||||||
|
state: '{{ "enabled" if collectd_prometheus_allow_outside else "disabled" }}'
|
||||||
|
tags: firewalld
|
||||||
|
|
||||||
|
- name: ensure firewall is configured for collectd write_prometheus plugin
|
||||||
|
firewalld:
|
||||||
|
port: '{{ collectd_prometheus_port }}/tcp'
|
||||||
|
permanent: true
|
||||||
|
immediate: false
|
||||||
|
state: '{{ "enabled" if collectd_prometheus_allow_outside else "disabled" }}'
|
||||||
|
tags: firewalld
|
||||||
|
|
|
@ -4,7 +4,7 @@ LoadPlugin write_prometheus
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<Plugin write_prometheus>
|
<Plugin write_prometheus>
|
||||||
Port {{ collectd_prometheus_port }}
|
Port {{ collectd_prometheus_port }}
|
||||||
{% if collectd_prometheus_host is defined %}
|
{% if collectd_prometheus_host|d %}
|
||||||
Host "{{ collectd_prometheus_host }}"
|
Host "{{ collectd_prometheus_host }}"
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</Plugin>
|
</Plugin>
|
||||||
|
|
Loading…
Reference in New Issue