Define some vars to manage master and slaves conf
This commit is contained in:
		
							parent
							
								
									2cbad0b42b
								
							
						
					
					
						commit
						9a35df05b4
					
				|  | @ -8,3 +8,4 @@ | ||||||
| * Ensure Netdata service is enabled and started. | * Ensure Netdata service is enabled and started. | ||||||
| * 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. | ||||||
|  |  | ||||||
|  | @ -23,6 +23,15 @@ A role to manage Netdata installation and configuration. | ||||||
| * **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`]. | ||||||
| * **netdata__conf_bind_port** : Port used by Netdata to listen [default : `19999`]. | * **netdata__conf_bind_port** : Port used by Netdata to listen [default : `19999`]. | ||||||
| * **netdata__conf_memory_mode** : The memory mode of the database [default : `ram`]. | * **netdata__conf_memory_mode** : The memory mode of the database [default : `ram`]. | ||||||
|  | * **netdata__slave_enable** : If node should send metrics to a master [default : `False`]. | ||||||
|  | * **netdata__slave_destination** : The destination to send metrics to [default : `netdata.{{ ansible_domain }}`]. | ||||||
|  | * **netdata__slave_api_key** : The API KEY to use to identify with the master [default : `''`]. | ||||||
|  | * **netdata__slave_buffer_size** : The buffer to use for sending metrics [default : ``]. | ||||||
|  | * **netdata__slave_reconnect** : If the connection fails, or it disconnects, retry after that many seconds [default : `5`]. | ||||||
|  | * **netdata__master_enable** : If node should receive metrics from other nodes [default : `False`]. | ||||||
|  | * **netdata__master_api_key** : The API key to authenticate slaves [default : `''`]. | ||||||
|  | * **netdata__master_history** : The number of entries in the database per hosts [default : `3600`]. | ||||||
|  | * **netdata__master_memory_mode** : The memory mode to be used for all hosts using this API key [default : `ram`]. | ||||||
| 
 | 
 | ||||||
| ## Example Playbook | ## Example Playbook | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -57,7 +57,7 @@ netdata__service_manage: True | ||||||
| 
 | 
 | ||||||
|                                                                    # ]]] |                                                                    # ]]] | ||||||
|                                                                    # ]]] |                                                                    # ]]] | ||||||
| # Configuration [[[ | # Common configuration [[[ | ||||||
| # ----------------------------- | # ----------------------------- | ||||||
| 
 | 
 | ||||||
| # .. envvar:: netdata__etc_src [[[. | # .. envvar:: netdata__etc_src [[[. | ||||||
|  | @ -95,4 +95,93 @@ netdata__conf_memory_mode: 'ram' | ||||||
| 
 | 
 | ||||||
|                                                                    # ]]] |                                                                    # ]]] | ||||||
| 
 | 
 | ||||||
|  |                                                                    # ]]] | ||||||
|  | # Slave configuration [[[ | ||||||
|  | # ----------------------------- | ||||||
|  | 
 | ||||||
|  | # .. envvar:: netdata__slave_enable [[[. | ||||||
|  | # | ||||||
|  | # If node should send metrics to a master. Possible options : | ||||||
|  | # | ||||||
|  | # | ||||||
|  | # ``False`` | ||||||
|  | #   Default. | ||||||
|  | # | ||||||
|  | # ``True`` | ||||||
|  | # | ||||||
|  | netdata__slave_enable: False | ||||||
|  | 
 | ||||||
|  |                                                                    # ]]] | ||||||
|  | # .. envvar:: netdata__slave_destination [[[. | ||||||
|  | # | ||||||
|  | # The destination to send metrics to. | ||||||
|  | # https://github.com/firehol/netdata/wiki/Replication-Overview#options-for-the-sending-node | ||||||
|  | # | ||||||
|  | netdata__slave_destination: 'netdata.{{ ansible_domain }}' | ||||||
|  | 
 | ||||||
|  |                                                                    # ]]] | ||||||
|  | # .. envvar:: netdata__slave_api_key [[[. | ||||||
|  | # | ||||||
|  | # The API KEY to use (as the sender). | ||||||
|  | # https://github.com/firehol/netdata/wiki/Replication-Overview#streaming-configuration | ||||||
|  | # | ||||||
|  | netdata__slave_api_key: '' | ||||||
|  | 
 | ||||||
|  |                                                                    # ]]] | ||||||
|  | # .. envvar:: netdata__slave_buffer_size [[[. | ||||||
|  | # | ||||||
|  | # The buffer to use for sending metrics. | ||||||
|  | # 1MB by default is good for 2-3 seconds of data. | ||||||
|  | # | ||||||
|  | netdata__slave_buffer_size: '1048576' | ||||||
|  | 
 | ||||||
|  |                                                                    # ]]] | ||||||
|  | # .. envvar:: netdata__slave_reconnect [[[. | ||||||
|  | # | ||||||
|  | # If the connection fails, or it disconnects, retry after that many seconds. | ||||||
|  | # | ||||||
|  | netdata__slave_reconnect: '5' | ||||||
|  | 
 | ||||||
|  |                                                                    # ]]] | ||||||
|  | 
 | ||||||
|  |                                                                    # ]]] | ||||||
|  | # Master configuration [[[ | ||||||
|  | # ----------------------------- | ||||||
|  | 
 | ||||||
|  | # .. envvar:: netdata__master_enable [[[. | ||||||
|  | # | ||||||
|  | # If node should receive metrics from other nodes. Possible options : | ||||||
|  | # | ||||||
|  | # | ||||||
|  | # ``False`` | ||||||
|  | #   Default. | ||||||
|  | # | ||||||
|  | # ``True`` | ||||||
|  | # | ||||||
|  | netdata__master_enable: False | ||||||
|  | 
 | ||||||
|  |                                                                    # ]]] | ||||||
|  | # .. envvar:: netdata__master_api_key [[[. | ||||||
|  | # | ||||||
|  | # The API key to authenticate slaves. | ||||||
|  | # | ||||||
|  | netdata__master_api_key: '' | ||||||
|  | 
 | ||||||
|  |                                                                    # ]]] | ||||||
|  | # .. envvar:: netdata__master_history [[[. | ||||||
|  | # | ||||||
|  | # The number of entries in the database per hosts. | ||||||
|  | # | ||||||
|  | netdata__master_history: '3600' | ||||||
|  | 
 | ||||||
|  |                                                                    # ]]] | ||||||
|  | # .. envvar:: netdata__master_memory_mode [[[. | ||||||
|  | # | ||||||
|  | # The memory mode to be used for all hosts using this API key. | ||||||
|  | # https://github.com/firehol/netdata/wiki/Memory-Requirements#memory-modes | ||||||
|  | # | ||||||
|  | netdata__master_memory_mode: 'ram' | ||||||
|  | 
 | ||||||
|  |                                                                    # ]]] | ||||||
|  | 
 | ||||||
|                                                                    # ]]] |                                                                    # ]]] | ||||||
|  |  | ||||||
|  | @ -0,0 +1,153 @@ | ||||||
|  | ## {{ ansible_managed }} | ||||||
|  | 
 | ||||||
|  | # netdata configuration for aggregating data from remote hosts | ||||||
|  | # | ||||||
|  | # API keys authorize a pair of sending-receiving netdata servers. | ||||||
|  | # Once their communication is authorized, they can exchange metrics for any | ||||||
|  | # number of hosts. | ||||||
|  | # | ||||||
|  | # You can generate API keys, with the linux command: uuidgen | ||||||
|  | # | ||||||
|  | # ----------------------------------------------------------------------------- | ||||||
|  | # 1. ON SLAVE NETDATA - THE ONE THAT WILL BE SENDING METRICS | ||||||
|  | 
 | ||||||
|  | [stream] | ||||||
|  | 	# Enable this on slaves, to have them send metrics. | ||||||
|  | 	{% if netdata__slave_enable -%} | ||||||
|  | 	enabled = yes | ||||||
|  | 	{% else %} | ||||||
|  | 	enabled = no | ||||||
|  | 	{%- endif %} | ||||||
|  | 
 | ||||||
|  | 	# The destination to send metrics to. | ||||||
|  | 	# A space separated list of: | ||||||
|  | 	#         [PROTOCOL:]HOST[%INTERFACE][:PORT] | ||||||
|  | 	# The first available will get the metrics. | ||||||
|  | 	# PROTOCOL = tcp or udp (only tcp is supported by masters) | ||||||
|  | 	# HOST = an IPv4, IPv6 IP, or a hostname. | ||||||
|  | 	#        IPv6 IPs should be given with brackets [ip:address] | ||||||
|  | 	# INTERFACE = the network interface to use | ||||||
|  | 	# PORT = the port number or service name (/etc/services) | ||||||
|  | 	# This communication is not HTTP (cannot be proxied by web proxies). | ||||||
|  | 	destination = {{ netdata__slave_destination }} | ||||||
|  | 
 | ||||||
|  | 	# The API_KEY to use (as the sender) | ||||||
|  | 	api key = {{ netdata__slave_api_key }} | ||||||
|  | 
 | ||||||
|  | 	# The timeout to connect and send metrics | ||||||
|  | 	timeout seconds = 60 | ||||||
|  | 
 | ||||||
|  | 	# If the destination line above does specify a port, use this | ||||||
|  | 	default port = 19999 | ||||||
|  | 
 | ||||||
|  | 	# The buffer to use for sending metrics. | ||||||
|  | 	# 1MB by default is good for 2-3 seconds of data, so increase this | ||||||
|  | 	# if you expect latencies. | ||||||
|  | 	buffer size bytes = {{ netdata__slave_buffer_size }} | ||||||
|  | 
 | ||||||
|  | 	# If the connection fails, or it disconnects, | ||||||
|  | 	# retry after that many seconds. | ||||||
|  | 	reconnect delay seconds = {{ netdata__slave_reconnect }} | ||||||
|  | 
 | ||||||
|  | 	# Attempt to sync the clock the of the master with the clock of the | ||||||
|  | 	# slave for that many iterations, when starting. | ||||||
|  | 	initial clock resync iterations = 60 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | # ----------------------------------------------------------------------------- | ||||||
|  | # 2. ON MASTER NETDATA - THE ONE THAT WILL BE RECEIVING METRICS | ||||||
|  | # | ||||||
|  | #    You can have one API key per slave, or the same API key for all slaves. | ||||||
|  | # | ||||||
|  | #    All options below are used in this order: | ||||||
|  | # | ||||||
|  | #    a) MACHINE_GUID (settings for each machine) | ||||||
|  | #    b) API_KEY      (settings for the API key) | ||||||
|  | #    c) this netdata defaults (as in netdata.conf) | ||||||
|  | # | ||||||
|  | #    You can combine the above (the more specific setting will be used). | ||||||
|  | 
 | ||||||
|  | # API key authentication | ||||||
|  | # If the key is not listed here, it will not be able to connect. | ||||||
|  | 
 | ||||||
|  | [{{ netdata__master_api_key }}] | ||||||
|  | 	# Default settings for the API key | ||||||
|  | 
 | ||||||
|  | 	# You can disable the API key, by setting this to: no | ||||||
|  | 	# The default (for unknown API keys) is also: no | ||||||
|  | 	{% if netdata__master_enable -%} | ||||||
|  | 	enabled = yes | ||||||
|  | 	{% else %} | ||||||
|  | 	enabled = no | ||||||
|  | 	{%- endif %} | ||||||
|  | 
 | ||||||
|  | 	# The default history in entries, for all hosts using this API key. | ||||||
|  | 	# You can also set it per host below. | ||||||
|  | 	# If you don't set it here, the history size of the central netdata | ||||||
|  | 	# will be used | ||||||
|  | 	default history = {{ netdata__master_history }} | ||||||
|  | 
 | ||||||
|  | 	# The default memory mode to be used for all hosts using this API key. | ||||||
|  | 	# You can also set it per host below. | ||||||
|  | 	# If you don't set it here, the memory mode of netdata.conf will be used. | ||||||
|  | 	# Valid modes: | ||||||
|  | 	#    save    save on exit, load on start | ||||||
|  | 	#    map     like swap (continuously syncing to disks) | ||||||
|  | 	#    ram     keep it in RAM, don't touch the disk | ||||||
|  | 	#    none    no database (passing through this netdata) | ||||||
|  | 	default memory mode = {{ netdata__master_memory_mode }} | ||||||
|  | 
 | ||||||
|  | 	# Shall we enable health monitoring for the hosts using this API key? | ||||||
|  | 	# 3 values: | ||||||
|  | 	#    yes     enable alarms | ||||||
|  | 	#    no      do not enable alarms | ||||||
|  | 	#    auto    enable alarms, only when the sending netdata is connected | ||||||
|  | 	# You can also set it per host, below. | ||||||
|  | 	# The default is the same as to netdata.conf | ||||||
|  | 	health enabled by default = auto | ||||||
|  | 
 | ||||||
|  | 	# postpone alarms for a short period after the sender is connected | ||||||
|  | 	default postpone alarms on connect seconds = 60 | ||||||
|  | 
 | ||||||
|  | 	# need to route metrics differently? set these. | ||||||
|  | 	# the defaults are the ones at the [stream] section | ||||||
|  | 	#default proxy enabled = yes | no | ||||||
|  | 	#default proxy destination = IP:PORT IP:PORT ... | ||||||
|  | 	#default proxy api key = API_KEY | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | # ----------------------------------------------------------------------------- | ||||||
|  | # 3. ON MASTER NETDATA - THE ONE THAT WILL BE RECEIVING METRICS | ||||||
|  | # | ||||||
|  | # THIS IS OPTIONAL - YOU DON'T NEED IT BY DEFAULT | ||||||
|  | # It only exists to give you finer control of the master settings for each | ||||||
|  | # slave host, when the same API key is used by many netdata slaves / proxies. | ||||||
|  | # | ||||||
|  | # Each netdata has a unique GUID - generated the first time netdata starts. | ||||||
|  | # You can find it at /var/lib/netdata/registry/netdata.public.unique.id | ||||||
|  | # The host sending data will have one. If the host is not ephemeral, | ||||||
|  | # you can give settings for each specific host here. | ||||||
|  | 
 | ||||||
|  | [MACHINE_GUID] | ||||||
|  | 	# enable this host: yes | no | ||||||
|  | 	# When disabled, the master will not receive metrics for this host. | ||||||
|  | 	# THIS IS NOT A SECURITY MECHANISM - AN ATTACKER CAN SET ANY OTHER GUID. | ||||||
|  | 	# Use only the API key for security. | ||||||
|  | 	enabled = no | ||||||
|  | 
 | ||||||
|  | 	# The number of entries in the database | ||||||
|  | 	history = 3600 | ||||||
|  | 
 | ||||||
|  | 	# The memory mode of the database: save | map | ram | none | ||||||
|  | 	memory mode = save | ||||||
|  | 
 | ||||||
|  | 	# Health / alarms control: yes | no | auto | ||||||
|  | 	health enabled = yes | ||||||
|  | 
 | ||||||
|  | 	# postpone alarms when the sender connects | ||||||
|  | 	postpone alarms on connect seconds = 60 | ||||||
|  | 
 | ||||||
|  | 	# need to route metrics differently? | ||||||
|  | 	#proxy enabled = yes | no | ||||||
|  | 	#proxy destination = IP:PORT IP:PORT ... | ||||||
|  | 	#proxy api key = API_KEY | ||||||
		Loading…
	
		Reference in New Issue