Commit 562c35a2 authored by Sasha Gerrand's avatar Sasha Gerrand Committed by Sasha Gerrand
Browse files

Remove Chef Solo support

As of v3.0, this cookbook only supports Chef >= v12.0 and Chef Zero supports
running in local mode.
parent 88da6bed
module RsyslogCookbook
# helpers for the various service providers on Ubuntu systems
module Helpers
# determine if chef solo search is available
def chef_solo_search_installed?
klass = ::Search.const_get('Helper')
return klass.is_a?(Class)
rescue NameError
return false
end
end
end
......@@ -21,28 +21,16 @@
return if node['rsyslog']['server']
include_recipe 'rsyslog::default'
extend RsyslogCookbook::Helpers
# On Chef Solo, we use the node['rsyslog']['server_ip'] attribute, and on
# normal Chef, we leverage the search query.
if Chef::Config[:solo] && !chef_solo_search_installed?
if node['rsyslog']['server_ip']
server_ips = Array(node['rsyslog']['server_ip'])
else
Chef::Application.fatal!("Chef Solo does not support search. You must set node['rsyslog']['server_ip'] or use the chef-solo-search cookbook!")
end
else
results = search(:node, node['rsyslog']['server_search']).map do |server|
ipaddress = server['ipaddress']
# If both server and client are on the same cloud and local network, they may be
# instructed to communicate via the internal interface by enabling `use_local_ipv4`
if node['rsyslog']['use_local_ipv4'] && server.attribute?('cloud') && server['cloud']['local_ipv4']
ipaddress = server['cloud']['local_ipv4']
end
ipaddress
results = search(:node, node['rsyslog']['server_search']).map do |server|
ipaddress = server['ipaddress']
# If both server and client are on the same cloud and local network, they may be
# instructed to communicate via the internal interface by enabling `use_local_ipv4`
if node['rsyslog']['use_local_ipv4'] && server.attribute?('cloud') && server['cloud']['local_ipv4']
ipaddress = server['cloud']['local_ipv4']
end
server_ips = Array(node['rsyslog']['server_ip']) + Array(results)
ipaddress
end
server_ips = Array(node['rsyslog']['server_ip']) + Array(results)
rsyslog_servers = []
......
require 'spec_helper'
describe 'rsyslog::client' do
context "when node['rsyslog']['server_ip'] is not set" do
before do
allow(Chef::Log).to receive(:fatal)
allow($stdout).to receive(:puts)
end
it 'exits fatally' do
expect { ChefSpec::SoloRunner.new.converge(described_recipe) }.to raise_error(SystemExit)
end
end
let(:chef_run) do
ChefSpec::SoloRunner.new(platform: 'ubuntu', version: '12.04') do |node|
node.set['rsyslog']['server_ip'] = server_ip
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment