Combine 4 vars to generate Netdata configuration
This commit is contained in:
parent
9a35df05b4
commit
ded78c8625
|
@ -9,3 +9,4 @@
|
||||||
* Manage IP address and port used.
|
* Manage IP address and port used.
|
||||||
* Manage memory mode.
|
* Manage memory mode.
|
||||||
* Define some vars to manage master and slaves configuration.
|
* Define some vars to manage master and slaves configuration.
|
||||||
|
* Combine 4 vars to generate Netdata configuration.
|
||||||
|
|
47
README.md
47
README.md
|
@ -17,7 +17,11 @@ A role to manage Netdata installation and configuration.
|
||||||
* **netdata__base_packages** : List of base packages in order to provide Netdata [default : `netdata`].
|
* **netdata__base_packages** : List of base packages in order to provide Netdata [default : `netdata`].
|
||||||
* **netdata__install_recommends** : If recommends packages should be install [default : `True`].
|
* **netdata__install_recommends** : If recommends packages should be install [default : `True`].
|
||||||
* **netdata__deploy_state** : The desired state this role should achieve. [default : `present`].
|
* **netdata__deploy_state** : The desired state this role should achieve. [default : `present`].
|
||||||
* **netdata__etc_src** : Directory used as source to templating /etc/netdata configuration content [default : `../templates/etc/netdata`].
|
* **netdata__group_name** : Name of the directory which contains configuration files for this specific group [default : `nonexistent-host-group`].
|
||||||
|
* **netdata__default_etc_src** : Directory which contains configuration files for Netdata from this role [default : `../templates/etc/netdata`].
|
||||||
|
* **netdata__etc_src** : Directory which contains configuration files that should be managed on all hosts [default : `../templates/etc/netdata`].
|
||||||
|
* **netdata__group_etc_src** : Directory which contains configuration files for Netdata that should be managed by a specific Ansible inventory group [default : `{{ (inventory_dir | realpath + "/../resources/") + "files/by-group/" + netdata__group_name + "/etc/netdata" }}`].
|
||||||
|
* **netdata__host_etc_src** : Directory which contains configuration files for Netdata that should be managed on specific host [default : `{{ (inventory_dir | realpath + "/../resources/") + "files/by-host/" + inventory_hostname + "/etc/netdata" }}`].
|
||||||
* **netdata__service_name** : The service name to manage [default : `netdata`].
|
* **netdata__service_name** : The service name to manage [default : `netdata`].
|
||||||
* **netdata__service_manage** : If the Netdata services should be managed [default : `True`].
|
* **netdata__service_manage** : If the Netdata services should be managed [default : `True`].
|
||||||
* **netdata__conf_bind_ip** : IP address used by Netdata to listen [default : `127.0.0.1`].
|
* **netdata__conf_bind_ip** : IP address used by Netdata to listen [default : `127.0.0.1`].
|
||||||
|
@ -45,28 +49,27 @@ A role to manage Netdata installation and configuration.
|
||||||
```
|
```
|
||||||
|
|
||||||
* Use your own Netdata's configuration as source :
|
* Use your own Netdata's configuration as source :
|
||||||
|
* Ensure you have resources directory contains only templates or sub-directories, such as :
|
||||||
``` yml
|
|
||||||
- hosts: mynode.DOMAIN
|
|
||||||
roles:
|
|
||||||
- role: ipr-cnrs.netdata
|
|
||||||
netdata__etc_src: '{{ inventory_dir + "/../resources/host/mynode.DOMAIN/etc/netdata/" }}'
|
|
||||||
```
|
|
||||||
|
|
||||||
* Ensure your directory contains only templates or sub-directories, such as :
|
|
||||||
|
|
||||||
``` sh
|
``` sh
|
||||||
mynode.DOMAIN
|
inventory
|
||||||
└── etc
|
├── group_vars
|
||||||
└── netdata
|
│ ├── all
|
||||||
├── fping.conf.j2
|
│ │ ├── ….yml
|
||||||
├── health_alarm_notify.conf.j2
|
│ │ └── netdata.yml
|
||||||
├── netdata.conf.j2
|
│ └── …
|
||||||
└── node.d
|
resources
|
||||||
├── named.conf.md.j2
|
├── files
|
||||||
├── README.md.j2
|
│ ├── by-group
|
||||||
├── sma_webbox.conf.md.j2
|
│ │ └── all
|
||||||
└── snmp.conf.md.j2
|
│ │ │ ├── etc
|
||||||
|
│ │ │ │ ├── netdata
|
||||||
|
│ │ │ │ │ ├── health.d
|
||||||
|
│ │ │ │ │ │ └── ram.conf.j2
|
||||||
|
│ │ │ │ │ ├── plugins.d
|
||||||
|
│ │ │ │ │ │ └── python.d.plugin
|
||||||
|
│ │ │ │ │ └── python.d
|
||||||
|
│ │ │ │ │ └── fail2ban.chart.py
|
||||||
```
|
```
|
||||||
|
|
||||||
* Listen on LAN, be careful, Netdata is not designed to be exposed (see [issue 64][netdata issue 164]) :
|
* Listen on LAN, be careful, Netdata is not designed to be exposed (see [issue 64][netdata issue 164]) :
|
||||||
|
@ -83,7 +86,7 @@ mynode.DOMAIN
|
||||||
|
|
||||||
This role will :
|
This role will :
|
||||||
* Install needed packages to provide `netdata` service.
|
* Install needed packages to provide `netdata` service.
|
||||||
* Manage Netdata configuration directory (/etc/netdata).
|
* Manage Netdata configuration directory (/etc/netdata) from several sources (netdata__default_etc_src, netdata__etc_src, netdata__group_etc_src and netdata__host_etc_src).
|
||||||
* Ensure Netdata service is enabled and started.
|
* Ensure Netdata service is enabled and started.
|
||||||
* Set up some basics configuration (bind ip, port,…).
|
* Set up some basics configuration (bind ip, port,…).
|
||||||
|
|
||||||
|
|
|
@ -60,14 +60,50 @@ netdata__service_manage: True
|
||||||
# Common configuration [[[
|
# Common configuration [[[
|
||||||
# -----------------------------
|
# -----------------------------
|
||||||
|
|
||||||
|
# .. envvar:: netdata__group_name [[[.
|
||||||
|
#
|
||||||
|
# Name of the directory which contains configuration files which should be
|
||||||
|
# generated on hosts in a specific group. This variable needs to be set on a
|
||||||
|
# group level in the inventory to take effect. Only one group is supported at
|
||||||
|
# a time.
|
||||||
|
netdata__group_name: 'nonexistent-host-group'
|
||||||
|
|
||||||
|
# ]]]
|
||||||
|
# .. envvar:: netdata__default_etc_src [[[.
|
||||||
|
#
|
||||||
|
# Directory which contains configuration files from this role that should be
|
||||||
|
# managed on all hosts.
|
||||||
|
netdata__default_etc_src: '../templates/etc/netdata'
|
||||||
|
|
||||||
|
# ]]]
|
||||||
# .. envvar:: netdata__etc_src [[[.
|
# .. envvar:: netdata__etc_src [[[.
|
||||||
# Directory with templates used to provide Netdata configuration (usually in
|
|
||||||
# '/etc/netdata').
|
|
||||||
#
|
#
|
||||||
# Must be a relative path to default directory of this role
|
# Directory which contains configuration files that should be managed on all
|
||||||
# or to your ansible inventory directory.
|
# hosts in the Ansible inventory.
|
||||||
#
|
#
|
||||||
netdata__etc_src: '../templates/etc/netdata'
|
# Must be a relative path to group directory of this role or to your
|
||||||
|
# ansible inventory directory.
|
||||||
|
netdata__etc_src: '{{ (inventory_dir | realpath + "/../resources/") + "files/by-group/all/etc/netdata/" }}'
|
||||||
|
|
||||||
|
# ]]]
|
||||||
|
# .. envvar:: netdata__group_etc_src [[[.
|
||||||
|
#
|
||||||
|
# Directory which contains configuration files for Netdata that should be
|
||||||
|
# managed on hosts in a specific Ansible inventory group.
|
||||||
|
#
|
||||||
|
# Must be a relative path to Netdata group directory on your Ansible inventory
|
||||||
|
# directory.
|
||||||
|
netdata__group_etc_src: '{{ (inventory_dir | realpath + "/../resources/") + "files/by-group/" + netdata__group_name + "/etc/netdata" }}'
|
||||||
|
|
||||||
|
# ]]]
|
||||||
|
# .. envvar:: netdata__host_etc_src [[[.
|
||||||
|
#
|
||||||
|
# Directory which contains configuration files for Netdata that should be
|
||||||
|
# managed on specific host in the Ansible inventory for Netdata.
|
||||||
|
#
|
||||||
|
# Must be a relative path to Netdata configuration directory for these hosts in
|
||||||
|
# your Ansible inventory directory.
|
||||||
|
netdata__host_etc_src: '{{ (inventory_dir | realpath + "/../resources/") + "files/by-host/" + inventory_hostname + "/etc/netdata" }}'
|
||||||
|
|
||||||
# ]]]
|
# ]]]
|
||||||
# .. envvar:: netdata__conf_bind_ip [[[.
|
# .. envvar:: netdata__conf_bind_ip [[[.
|
||||||
|
|
|
@ -20,7 +20,11 @@
|
||||||
owner: 'root'
|
owner: 'root'
|
||||||
group: 'netdata'
|
group: 'netdata'
|
||||||
mode: '0755'
|
mode: '0755'
|
||||||
with_filetree: '{{ netdata__etc_src }}'
|
with_filetree:
|
||||||
|
- '{{ netdata__host_etc_src }}'
|
||||||
|
- '{{ netdata__group_etc_src }}'
|
||||||
|
- '{{ netdata__etc_src }}'
|
||||||
|
- '{{ netdata__default_etc_src }}'
|
||||||
when: (item.state == 'directory') and (netdata__deploy_state == "present")
|
when: (item.state == 'directory') and (netdata__deploy_state == "present")
|
||||||
notify: ['Restart Netdata service']
|
notify: ['Restart Netdata service']
|
||||||
|
|
||||||
|
@ -31,7 +35,11 @@
|
||||||
owner: 'root'
|
owner: 'root'
|
||||||
group: 'netdata'
|
group: 'netdata'
|
||||||
mode: '{{ item.mode }}'
|
mode: '{{ item.mode }}'
|
||||||
with_filetree: '{{ netdata__etc_src }}'
|
with_filetree:
|
||||||
|
- '{{ netdata__host_etc_src }}'
|
||||||
|
- '{{ netdata__group_etc_src }}'
|
||||||
|
- '{{ netdata__etc_src }}'
|
||||||
|
- '{{ netdata__default_etc_src }}'
|
||||||
when: (item.state == 'file') and (netdata__deploy_state == "present")
|
when: (item.state == 'file') and (netdata__deploy_state == "present")
|
||||||
notify: ['Restart Netdata service']
|
notify: ['Restart Netdata service']
|
||||||
|
|
||||||
|
@ -41,6 +49,10 @@
|
||||||
dest: "/etc/netdata/{{ item.path | replace('.j2','') }}"
|
dest: "/etc/netdata/{{ item.path | replace('.j2','') }}"
|
||||||
state: 'link'
|
state: 'link'
|
||||||
force: true
|
force: true
|
||||||
with_filetree: '{{ netdata__etc_src }}'
|
with_filetree:
|
||||||
|
- '{{ netdata__host_etc_src }}'
|
||||||
|
- '{{ netdata__group_etc_src }}'
|
||||||
|
- '{{ netdata__etc_src }}'
|
||||||
|
- '{{ netdata__default_etc_src }}'
|
||||||
when: (item.state == 'link') and (netdata__deploy_state == "present")
|
when: (item.state == 'link') and (netdata__deploy_state == "present")
|
||||||
notify: ['Restart Netdata service']
|
notify: ['Restart Netdata service']
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
## {{ ansible_managed }}
|
## {{ ansible_managed }}
|
||||||
|
## From ipr-cnrs.netdata role
|
||||||
|
|
||||||
# NetData Configuration
|
# NetData Configuration
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
## {{ ansible_managed }}
|
## {{ ansible_managed }}
|
||||||
|
## From ipr-cnrs.netdata role
|
||||||
|
|
||||||
# netdata configuration for aggregating data from remote hosts
|
# netdata configuration for aggregating data from remote hosts
|
||||||
#
|
#
|
||||||
|
|
Loading…
Reference in New Issue