-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move attribute that drives custom cfgs to elkstack
This moves the node attribute that can configure additional custom configurations to elkstack. This really makes more sense than platformstack, as this is the only treal place that is aware of what is being deployed with elkstack (or not being deployed).
- Loading branch information
Showing
14 changed files
with
153 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,3 +35,13 @@ | |
config_templates_variables['elasticsearch_ip'] = server['elasticsearch_ip'] | ||
config_templates_variables['elasticsearch_protocol'] = server['elasticsearch_protocol'] | ||
server['config_templates_variables'] = config_templates_variables | ||
|
||
# arbitrary data structure for any arbitrary logstash config | ||
default['elkstack']['config']['custom_logstash']['name'] = [] | ||
# Currently for arbitrary logstash configs, the recipe that sets up the logstash file should add: | ||
# node.default['elkstack']['config']['custom_logstash']['name'].push('<service_name>') | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
patcon
Contributor
|
||
# and then populate node['elkstack']['config']['custom_logstash'][service_name][setting] with your values | ||
# default['elkstack']['config']['custom_logstash'][<name>]['name'] = 'my_logstashconfig' | ||
# default['elkstack']['config']['custom_logstash'][<name>]['source'] = 'my_logstashconfig.conf.erb' | ||
# default['elkstack']['config']['custom_logstash'][<name>]['cookbook'] = 'your_cookbook' | ||
# default['elkstack']['config']['custom_logstash'][<name>]['variables'] = { :warning => 'foo' } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# This defintion is designed to remove the repetition used throughout this cookbook. | ||
|
||
define :logstash_custom_config, variables: {}, service_name: nil, instance_name: nil, template_name: nil, template_source_file: nil, template_source_cookbook: nil, action: nil do | ||
|
||
params[:action] ||= :create | ||
params[:instance_name] ||= 'default' | ||
params[:template_name] ||= "#{params[:name]}.conf" | ||
params[:template_source_file] ||= "#{params[:name]}.conf.erb" | ||
params[:template_source_cookbook] ||= 'elkstack' | ||
params[:service_name] ||= 'default' | ||
|
||
logstash_config params[:instance_name] do | ||
templates_cookbook params[:template_source_cookbook] | ||
templates(params[:template_name] => params[:template_source_file]) | ||
variables params[:variables] | ||
# this is a trick to ensure the notification doesn't hurt us, if the logstash | ||
# cookbook is not currently available/included on this node | ||
begin | ||
resources("logstash_service[#{params[:service_name]}]"); | ||
if node['elkstack']['config']['restart_logstash_service'] | ||
notifies :restart, "logstash_service[#{params[:service_name]}]", :delayed | ||
end | ||
rescue Chef::Exceptions::ResourceNotFound | ||
Chef::Log.warn("Could not find logstash_service[#{params[:service_name]}], will not notify it to restart") | ||
end | ||
action params[:action] | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# Encoding: utf-8 | ||
|
||
require_relative 'spec_helper' | ||
|
||
describe 'elkstack::agent' do | ||
let(:chef_run) do | ||
stub_resources | ||
ChefSpec::SoloRunner.new(platform: 'ubuntu', version: '12.04') do |node| | ||
node.set['cpu']['total'] = 8 | ||
node.set['memory']['total'] = 4096 | ||
node.set['public_info']['remote_ip'] = '127.0.0.1' | ||
node.set['filesystem'] = [] | ||
node.set['platformstack']['elkstack_logging']['enabled'] = true | ||
|
||
# stub an additional template | ||
node.set['elkstack']['config']['custom_logstash']['name'] = ['foo'] | ||
node.set['elkstack']['config']['custom_logstash']['foo']['name'] = 'my_logstashconfig' | ||
node.set['elkstack']['config']['custom_logstash']['foo']['source'] = 'my_logstashconfig.conf.erb' | ||
node.set['elkstack']['config']['custom_logstash']['foo']['cookbook'] = 'your_cookbook' | ||
node.set['elkstack']['config']['custom_logstash']['foo']['variables'] = { :warning => 'foo' } | ||
end.converge(described_recipe) | ||
end | ||
|
||
it 'creates additional custom config files' do | ||
expect(chef_run).to create_logstash_config('agent') | ||
end | ||
|
||
end | ||
|
||
describe 'elkstack::logstash' do | ||
let(:chef_run) do | ||
stub_resources | ||
ChefSpec::SoloRunner.new(platform: 'ubuntu', version: '12.04') do |node| | ||
node.set['cpu']['total'] = 8 | ||
node.set['memory']['total'] = 4096 | ||
node.set['public_info']['remote_ip'] = '127.0.0.1' | ||
node.set['filesystem'] = [] | ||
node.set['platformstack']['elkstack_logging']['enabled'] = true | ||
|
||
# stub an additional template | ||
node.set['elkstack']['config']['custom_logstash']['name'] = ['foo'] | ||
node.set['elkstack']['config']['custom_logstash']['foo']['name'] = 'my_logstashconfig' | ||
node.set['elkstack']['config']['custom_logstash']['foo']['source'] = 'my_logstashconfig.conf.erb' | ||
node.set['elkstack']['config']['custom_logstash']['foo']['cookbook'] = 'your_cookbook' | ||
node.set['elkstack']['config']['custom_logstash']['foo']['variables'] = { :warning => 'foo' } | ||
end.converge(described_recipe) | ||
end | ||
|
||
it 'creates additional custom config files' do | ||
expect(chef_run).to create_logstash_config('default') | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
Why the
name
key? Why not just add a hash key for each and iterate over for each -- ie. skip maintaining a separate array in this line?