Skip to content
This repository has been archived by the owner on Jan 8, 2019. It is now read-only.

set the variables in recipe #1258

Merged
merged 1 commit into from
Aug 10, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
30 changes: 22 additions & 8 deletions cookbooks/bcpc/recipes/graphite.rb
Original file line number Diff line number Diff line change
Expand Up @@ -124,17 +124,24 @@
end
end

use_whitelist_str = node['bcpc']['graphite']['use_whitelist'] ? 'True' : 'False'

template '/opt/graphite/conf/carbon.conf' do
source 'carbon/carbon.conf.erb'
owner 'root'
group 'root'
mode 0o0644
variables(
'servers' => get_static_head_node_local_ip_list,
'local_data_dir' => node['bcpc']['graphite']['local_data_dir'],
'log_dir' => node['bcpc']['graphite']['local_log_dir'],
'relay_recv_nic' => node[:bcpc][:graphite][:ip],
'relay_idle_timeout' => node[:bcpc][:graphite][:carbon][:relay][:idle_timeout],
'relay_dests' => get_static_head_node_local_ip_list.map { |host| host + ':2024' }.sort.join(','),
'aggr_recv_nic' => node[:bcpc][:floating][:ip],
'aggr_dests' => node[:bcpc][:floating][:ip] + ':2004',
'cache_recv_nic' => node[:bcpc][:floating][:ip],
'cache_query_nic' => node[:bcpc][:floating][:ip],
'cache_max_updates_per_sec' => node['bcpc']['graphite']['carbon']['cache']['MAX_UPDATES_PER_SECOND'],
'min_quorum' => get_static_head_nodes_count / 2 + 1,
'use_whitelist' => use_whitelist_str
'use_whitelist' => node['bcpc']['graphite']['use_whitelist'] ? 'True' : 'False'
)
notifies :restart, 'service[carbon-cache]', :delayed
notifies :restart, 'service[carbon-aggregator]', :delayed
Expand Down Expand Up @@ -162,7 +169,7 @@
owner 'root'
group 'root'
mode 0o0644
variables('servers' => get_static_head_node_local_ip_list)
variables('relay_rules_dests' => get_static_head_node_local_ip_list.map { |host| host + ':2004' }.sort.join(','))
notifies :restart, 'service[carbon-relay]', :delayed
end

Expand Down Expand Up @@ -234,9 +241,16 @@
group 'www-data'
mode 0o0440
variables(
'web_port' => node['bcpc']['graphite']['web_port'],
'servers' => get_static_head_node_local_ip_list,
'min_quorum' => get_static_head_nodes_count / 2 + 1
'timezone' => node['bcpc']['graphite']['timezone'],
'memcache_hosts' => node['bcpc']['graphite']['ip'],
'whisper_dir' => node['bcpc']['graphite']['local_data_dir'],
'graphite_dbname' => node['bcpc']['graphite_dbname'],
'graphite_dbuser' => graphite_user,
'graphite_dbpassword' => graphite_password,
'graphite_nic' => node['bcpc']['graphite']['ip'],
'cluster_servers' => get_static_head_node_local_ip_list.map { |host| "\"#{host}:#{node['bcpc']['graphite']['web_port']}\"" }.sort.join(', '),
'intracluster_https' => node['bcpc']['graphite']['web_https'] ? 'True' : 'False',
'carbonlink_hosts' => node['bcpc']['floating']['ip']
)
notifies :restart, 'service[apache2]', :delayed
end
Expand Down
30 changes: 15 additions & 15 deletions cookbooks/bcpc/templates/default/carbon/carbon.conf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
# PID_DIR = /var/run/
#
# LOCAL_DATA_DIR = /opt/graphite/storage/whisper/
LOCAL_DATA_DIR = <%= node['bcpc']['graphite']['local_data_dir'] %>
LOG_DIR = <%= node['bcpc']['graphite']['local_log_dir'] %>
LOCAL_DATA_DIR = <%= @local_data_dir %>
LOG_DIR = <%= @log_dir %>

# Specify the database library used to store metric data on disk. Each database
# may have configurable options to change the behaviour of how it writes to
Expand Down Expand Up @@ -70,7 +70,7 @@ MAX_CACHE_SIZE = inf
# When the rate of required updates exceeds this, then carbon's caching will
# take effect and increase the overall throughput accordingly.
# MAX_UPDATES_PER_SECOND = 500
MAX_UPDATES_PER_SECOND = <%= node['bcpc']['graphite']['carbon']['cache']['MAX_UPDATES_PER_SECOND'] %>
MAX_UPDATES_PER_SECOND = <%= @cache_max_updates_per_sec %>

# If defined, this changes the MAX_UPDATES_PER_SECOND in Carbon when a
# stop/shutdown is initiated. This helps when MAX_UPDATES_PER_SECOND is
Expand Down Expand Up @@ -105,22 +105,22 @@ MIN_TIMESTAMP_RESOLUTION = 1
# interface to 0.0.0.0 listens on all interfaces. Port can be set to 0 to
# disable this listener if it is not required.
# LINE_RECEIVER_INTERFACE = 0.0.0.0
LINE_RECEIVER_INTERFACE = <%="#{node[:bcpc][:management][:ip]}"%>
LINE_RECEIVER_INTERFACE = <%= @cache_recv_nic %>
LINE_RECEIVER_PORT = 2003

# Set this to True to enable the UDP listener. By default this is off
# because it is very common to run multiple carbon daemons and managing
# another (rarely used) port for every carbon instance is not fun.
ENABLE_UDP_LISTENER = False
# UDP_RECEIVER_INTERFACE = 0.0.0.0
UDP_RECEIVER_INTERFACE = <%="#{node[:bcpc][:management][:ip]}"%>
UDP_RECEIVER_INTERFACE = <%= @cache_recv_nic %>
UDP_RECEIVER_PORT = 2003

# Set the interface and port for the pickle listener. Setting the interface to
# 0.0.0.0 listens on all interfaces. Port can be set to 0 to disable this
# listener if it is not required.
# PICKLE_RECEIVER_INTERFACE = 0.0.0.0
PICKLE_RECEIVER_INTERFACE = <%="#{node[:bcpc][:management][:ip]}"%>
PICKLE_RECEIVER_INTERFACE = <%= @cache_recv_nic %>
PICKLE_RECEIVER_PORT = 2004

# Set the interface and port for the protobuf listener. Setting the interface to
Expand All @@ -141,7 +141,7 @@ PICKLE_RECEIVER_PORT = 2004
USE_INSECURE_UNPICKLER = False

# CACHE_QUERY_INTERFACE = 0.0.0.0
CACHE_QUERY_INTERFACE = <%="#{node[:bcpc][:management][:ip]}"%>
CACHE_QUERY_INTERFACE = <%= @cache_query_nic %>
CACHE_QUERY_PORT = 7002

# Set this to False to drop datapoints received after the cache
Expand Down Expand Up @@ -352,11 +352,11 @@ ENABLE_TAGS = False

[relay]
# LINE_RECEIVER_INTERFACE = 0.0.0.0
LINE_RECEIVER_INTERFACE = <%="#{node[:bcpc][:graphite][:ip]}"%>
LINE_RECEIVER_INTERFACE = <%= @relay_recv_nic %>
# LINE_RECEIVER_PORT = 2013
LINE_RECEIVER_PORT = 2013
# PICKLE_RECEIVER_INTERFACE = 0.0.0.0
PICKLE_RECEIVER_INTERFACE = <%="#{node[:bcpc][:graphite][:ip]}"%>
PICKLE_RECEIVER_INTERFACE = <%= @relay_recv_nic %>
PICKLE_RECEIVER_PORT = 2014

# Carbon-relay has several options for metric routing controlled by RELAY_METHOD
Expand Down Expand Up @@ -384,7 +384,7 @@ RELAY_METHOD = consistent-hashing
# datapoint to more than one machine.
# REPLICATION_FACTOR = 1
# TODO: set REPLICATION_FACTOR to min_quorum if > 2 is needed.
# REPLICATION_FACTOR = <%="#{@min_quorum}"%>
# REPLICATION_FACTOR = <%= @min_quorum %>
REPLICATION_FACTOR = 2

# For REPLICATION_FACTOR >=2, set DIVERSE_REPLICAS to True to guarantee replicas
Expand Down Expand Up @@ -412,7 +412,7 @@ REPLICATION_FACTOR = 2
# If using RELAY_METHOD = rules, all destinations used in relay-rules.conf
# must be defined in this list
# DESTINATIONS = 127.0.0.1:2004
DESTINATIONS = <%= "#{@servers.map{|hst| "#{hst}:2024"}.sort.join(', ')}" %>
DESTINATIONS = <%= @relay_dests %>

# This define the protocol to use to contact the destination. It can be
# set to one of "line", "pickle", "udp" and "protobuf". This list can be
Expand Down Expand Up @@ -475,7 +475,7 @@ USE_FLOW_CONTROL = True
# If enabled this setting is used to timeout metric client connection if no
# metrics have been sent in specified time in seconds
#METRIC_CLIENT_IDLE_TIMEOUT = None
METRIC_CLIENT_IDLE_TIMEOUT = <%="#{node[:bcpc][:graphite][:carbon][:relay][:idle_timeout]}"%>
METRIC_CLIENT_IDLE_TIMEOUT = <%= @relay_idle_timeout %>

# Set this to True to enable whitelisting and blacklisting of metrics in
# CONF_DIR/whitelist.conf and CONF_DIR/blacklist.conf. If the whitelist is
Expand Down Expand Up @@ -528,12 +528,12 @@ MIN_RESET_INTERVAL=121

[aggregator]
# LINE_RECEIVER_INTERFACE = 0.0.0.0
LINE_RECEIVER_INTERFACE = <%="#{node[:bcpc][:management][:ip]}"%>
LINE_RECEIVER_INTERFACE = <%= @aggr_recv_nic %>
# LINE_RECEIVER_PORT = 2023
LINE_RECEIVER_PORT = 2023

# PICKLE_RECEIVER_INTERFACE = 0.0.0.0
PICKLE_RECEIVER_INTERFACE = <%="#{node[:bcpc][:management][:ip]}"%>
PICKLE_RECEIVER_INTERFACE = <%= @aggr_recv_nic %>
PICKLE_RECEIVER_PORT = 2024

# If set true, metric received will be forwarded to DESTINATIONS in addition to
Expand Down Expand Up @@ -561,7 +561,7 @@ FORWARD_ALL = True
# exactly match the webapp's CARBONLINK_HOSTS setting in terms of
# instances listed (order matters!).
# DESTINATIONS = 127.0.0.1:2004
DESTINATIONS = <%="#{node[:bcpc][:management][:ip]+':2004'}"%>
DESTINATIONS = <%= @aggr_dests %>

# If you want to add redundancy to your data by replicating every
# datapoint to more than one machine, increase this.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@

[default]
default = true
destinations = <%= "#{@servers.map{|hst| "#{hst}:2004"}.join(', ')}" %>
destinations = <%= @relay_rules_dests %>
20 changes: 10 additions & 10 deletions cookbooks/bcpc/templates/default/graphite/local_settings.py.erb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ ALLOWED_HOSTS = [ '*' ]
# Set your local timezone (Django's default is America/Chicago)
# If your graphs appear to be offset by a couple hours then this probably
# needs to be explicitly set to your local timezone.
TIME_ZONE = <%= node['bcpc']['graphite']['timezone'] %>
TIME_ZONE = <%= @timezone %>

# Override this to provide documentation specific to your Graphite deployment
#DOCUMENTATION_URL = "http://graphite.readthedocs.org/"
Expand Down Expand Up @@ -55,7 +55,7 @@ LOG_CACHE_PERFORMANCE = True
# You should not use the loopback address (127.0.0.1) here if using clustering
# as every webapp in the cluster should use the exact same values to prevent
# unneeded cache misses. Set to [] to disable caching of images and fetched data
MEMCACHE_HOSTS = ['<%="#{node[:bcpc][:graphite][:ip]}"%>:11211']
MEMCACHE_HOSTS = ['<%= @memcache_hosts %>:11211']
#DEFAULT_CACHE_DURATION = 60 # Cache images and data for 1 minute
#MEMCACHE_KEY_PREFIX = 'graphite'

Expand Down Expand Up @@ -84,7 +84,7 @@ MEMCACHE_HOSTS = ['<%="#{node[:bcpc][:graphite][:ip]}"%>:11211']
## Data directories
# NOTE: If any directory is unreadable in DATA_DIRS it will break metric browsing
#CERES_DIR = '/opt/graphite/storage/ceres'
WHISPER_DIR = '<%= node['bcpc']['graphite']['local_data_dir'] %>'
WHISPER_DIR = '<%= @whisper_dir %>'
#RRD_DIR = '/opt/graphite/storage/rrd'
#STANDARD_DIRS = [WHISPER_DIR, RRD_DIR] # Default: set from the above variables
#LOG_DIR = '/opt/graphite/storage/log/webapp'
Expand Down Expand Up @@ -151,10 +151,10 @@ WHISPER_DIR = '<%= node['bcpc']['graphite']['local_data_dir'] %>'
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': '<%="#{node['bcpc']['graphite_dbname']}"%>',
'USER': '<%="#{get_config('mysql-graphite-user')}"%>',
'PASSWORD': '<%="#{get_config!('password', 'mysql-graphite','os')}"%>',
'HOST': '<%="#{node[:bcpc][:graphite][:ip]}"%>',
'NAME': '<%= @graphite_dbname %>',
'USER': '<%= @graphite_dbuser %>',
'PASSWORD': '<%= @graphite_dbpassword %>',
'HOST': '<%= @graphite_nic %>',
'default-character-set': 'utf8'
},
}
Expand All @@ -169,8 +169,8 @@ DATABASES = {
# remote server in the cluster. These servers must each have local access to
# metric data. Note that the first server to return a match for a query will be
# used.
CLUSTER_SERVERS = [ <%="#{@servers.map{|hst| "\"#{hst}:#{@web_port}\""}.sort.join(', ')}"%> ]
INTRACLUSTER_HTTPS = <%="#{node['bcpc']['graphite']['web_https'] == true ? 'True' : 'False'}" %>
CLUSTER_SERVERS = [ <%= @cluster_servers %> ]
INTRACLUSTER_HTTPS = <%= @intracluster_https %>
## These are timeout values (in seconds) for requests to remote webapps
REMOTE_FIND_TIMEOUT = 6.0 # Timeout for metric find requests
REMOTE_FETCH_TIMEOUT = 10.0 # Timeout to fetch series data
Expand Down Expand Up @@ -199,7 +199,7 @@ REMOTE_FETCH_TIMEOUT = 10.0 # Timeout to fetch series data
# and a common scheme is to use 7102 for instance b, 7202 for instance c, etc.
#
# You *should* use 127.0.0.1 here in most cases
CARBONLINK_HOSTS = ['<%="#{node[:bcpc][:management][:ip]}"%>:7002']
CARBONLINK_HOSTS = ['<%= @carbonlink_hosts %>:7002']
#CARBONLINK_TIMEOUT = 1.0
#CARBONLINK_RETRY_DELAY = 15 # Seconds to blacklist a failed remote server

Expand Down