Skip to content

Commit

Permalink
fix for #68
Browse files Browse the repository at this point in the history
  • Loading branch information
vkhatri committed Sep 12, 2016
1 parent d4ca46c commit 3c85bef
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 6 deletions.
6 changes: 0 additions & 6 deletions attributes/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,6 @@
default['filebeat']['config']['filebeat']['prospectors'] = []
# default['filebeat']['config']['filebeat']['spool_size'] = 1024
# default['filebeat']['config']['filebeat']['idle_timeout'] = '5s'
default['filebeat']['config']['filebeat']['registry_file'] = if node['platform'] == 'windows'
"#{node['filebeat']['conf_dir']}/registry"
else
'/var/lib/filebeat/registry'
end
default['filebeat']['config']['filebeat']['config_dir'] = node['filebeat']['prospectors_dir']
=begin
# Add Prospectors using Node Attribute Example
apache_logs = {
Expand Down
7 changes: 7 additions & 0 deletions recipes/attributes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,10 @@
else
::File.join(node['filebeat']['conf_dir'], 'conf.d')
end

node.default['filebeat']['config']['filebeat']['registry_file'] = if node['platform'] == 'windows'
"#{node['filebeat']['conf_dir']}/registry"
else
'/var/lib/filebeat/registry'
end
node.default['filebeat']['config']['filebeat']['config_dir'] = node['filebeat']['prospectors_dir']
42 changes: 42 additions & 0 deletions spec/unit/recipes/default_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
end.converge(described_recipe)
end

let(:node) { chef_run.node }

include_examples 'filebeat'

it 'create prospector directory /etc/filebeat/conf.d' do
Expand All @@ -41,6 +43,18 @@
it 'install filebeat package' do
expect(chef_run).to install_package('filebeat')
end

it "has correct default['filebeat']['config']['filebeat']['registry_file']" do
expect(node['filebeat']['config']['filebeat']['registry_file']).to eq('/var/lib/filebeat/registry')
end

it "has correct default['filebeat']['config']['filebeat']['config_dir']" do
expect(node['filebeat']['config']['filebeat']['config_dir']).to eq('/etc/filebeat/conf.d')
end

it "has correct default['filebeat']['conf_dir']" do
expect(node['filebeat']['conf_dir']).to eq('/etc/filebeat')
end
end

context 'ubuntu' do
Expand All @@ -50,6 +64,8 @@
end.converge(described_recipe)
end

let(:node) { chef_run.node }

include_examples 'filebeat'

it 'create prospector directory /etc/filebeat/conf.d' do
Expand All @@ -71,6 +87,18 @@
it 'install filebeat package' do
expect(chef_run).to install_package('filebeat')
end

it "has correct default['filebeat']['config']['filebeat']['registry_file']" do
expect(node['filebeat']['config']['filebeat']['registry_file']).to eq('/var/lib/filebeat/registry')
end

it "has correct default['filebeat']['config']['filebeat']['config_dir']" do
expect(node['filebeat']['config']['filebeat']['config_dir']).to eq('/etc/filebeat/conf.d')
end

it "has correct default['filebeat']['conf_dir']" do
expect(node['filebeat']['conf_dir']).to eq('/etc/filebeat')
end
end

context 'windows' do
Expand All @@ -80,6 +108,8 @@
end.converge(described_recipe)
end

let(:node) { chef_run.node }

include_examples 'filebeat'

it 'create prospector directory C:/opt/filebeat/filebeat-1.3.0-windows/conf.d' do
Expand Down Expand Up @@ -109,5 +139,17 @@
it 'run powershell_script to install filebeat as service' do
expect(chef_run).to run_powershell_script('install filebeat as service')
end

it "has correct default['filebeat']['conf_dir']" do
expect(node['filebeat']['conf_dir']).to eq('C:/opt/filebeat/filebeat-1.3.0-windows')
end

it "has correct default['filebeat']['config']['filebeat']['registry_file']" do
expect(node['filebeat']['config']['filebeat']['registry_file']).to eq('C:/opt/filebeat/filebeat-1.3.0-windows/registry')
end

it "has correct default['filebeat']['config']['filebeat']['config_dir']" do
expect(node['filebeat']['config']['filebeat']['config_dir']).to eq('C:/opt/filebeat/filebeat-1.3.0-windows/conf.d')
end
end
end

0 comments on commit 3c85bef

Please sign in to comment.