Commit 6a2a20cd authored by Tim Smith's avatar Tim Smith
Browse files

Merge pull request #100 from sgerrand/remove-chef-solo

Remove Chef Solo
parents 88da6bed 87345e57
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|
ChefSpec::ServerRunner.new(platform: 'ubuntu', version: '12.04') do |node|
node.set['rsyslog']['server_ip'] = server_ip
node.set['rsyslog']['custom_remote'] = custom_remote
end.converge(described_recipe)
......@@ -52,7 +41,7 @@ describe 'rsyslog::client' do
context 'on SmartOS' do
let(:chef_run) do
ChefSpec::SoloRunner.new(platform: 'smartos', version: 'joyent_20130111T180733Z') do |node|
ChefSpec::ServerRunner.new(platform: 'smartos', version: 'joyent_20130111T180733Z') do |node|
node.set['rsyslog']['server_ip'] = server_ip
node.set['rsyslog']['custom_remote'] = custom_remote
end.converge(described_recipe)
......@@ -95,7 +84,7 @@ describe 'rsyslog::client' do
context 'on SmartOS' do
let(:chef_run) do
ChefSpec::SoloRunner.new(platform: 'smartos', version: 'joyent_20130111T180733Z') do |node|
ChefSpec::ServerRunner.new(platform: 'smartos', version: 'joyent_20130111T180733Z') do |node|
node.set['rsyslog']['server_ip'] = server_ip
end.converge(described_recipe)
end
......
......@@ -2,7 +2,7 @@ require 'spec_helper'
describe 'rsyslog::default' do
let(:chef_run) do
ChefSpec::SoloRunner.new(platform: 'ubuntu', version: '12.04').converge(described_recipe)
ChefSpec::ServerRunner.new(platform: 'ubuntu', version: '12.04').converge(described_recipe)
end
let(:service_resource) { 'service[rsyslog]' }
......@@ -13,7 +13,7 @@ describe 'rsyslog::default' do
context "when node['rsyslog']['relp'] is true" do
let(:chef_run) do
ChefSpec::SoloRunner.new(platform: 'ubuntu', version: '12.04') do |node|
ChefSpec::ServerRunner.new(platform: 'ubuntu', version: '12.04') do |node|
node.set['rsyslog']['use_relp'] = true
end.converge(described_recipe)
end
......@@ -26,7 +26,7 @@ describe 'rsyslog::default' do
context "when node['rsyslog']['enable_tls'] is true" do
context "when node['rsyslog']['tls_ca_file'] is not set" do
let(:chef_run) do
ChefSpec::SoloRunner.new(platform: 'ubuntu', version: '12.04') do |node|
ChefSpec::ServerRunner.new(platform: 'ubuntu', version: '12.04') do |node|
node.set['rsyslog']['enable_tls'] = true
end.converge(described_recipe)
end
......@@ -38,7 +38,7 @@ describe 'rsyslog::default' do
context "when node['rsyslog']['tls_ca_file'] is set" do
let(:chef_run) do
ChefSpec::SoloRunner.new(platform: 'ubuntu', version: '12.04') do |node|
ChefSpec::ServerRunner.new(platform: 'ubuntu', version: '12.04') do |node|
node.set['rsyslog']['enable_tls'] = true
node.set['rsyslog']['tls_ca_file'] = '/etc/path/to/ssl-ca.crt'
end.converge(described_recipe)
......@@ -55,7 +55,7 @@ describe 'rsyslog::default' do
end
let(:chef_run) do
ChefSpec::SoloRunner.new(platform: 'ubuntu', version: '12.04') do |node|
ChefSpec::ServerRunner.new(platform: 'ubuntu', version: '12.04') do |node|
node.set['rsyslog']['enable_tls'] = true
node.set['rsyslog']['tls_ca_file'] = '/etc/path/to/ssl-ca.crt'
node.set['rsyslog']['protocol'] = 'udp'
......@@ -87,7 +87,7 @@ describe 'rsyslog::default' do
context 'on SmartOS' do
let(:chef_run) do
ChefSpec::SoloRunner.new(platform: 'smartos', version: 'joyent_20130111T180733Z').converge(described_recipe)
ChefSpec::ServerRunner.new(platform: 'smartos', version: 'joyent_20130111T180733Z').converge(described_recipe)
end
let(:directory) { chef_run.directory('/opt/local/etc/rsyslog.d') }
......@@ -153,7 +153,7 @@ describe 'rsyslog::default' do
context 'on SmartOS' do
let(:chef_run) do
ChefSpec::SoloRunner.new(platform: 'smartos', version: 'joyent_20130111T180733Z').converge(described_recipe)
ChefSpec::ServerRunner.new(platform: 'smartos', version: 'joyent_20130111T180733Z').converge(described_recipe)
end
let(:template) { chef_run.template('/opt/local/etc/rsyslog.conf') }
......@@ -206,7 +206,7 @@ describe 'rsyslog::default' do
context 'on SmartOS' do
let(:chef_run) do
ChefSpec::SoloRunner.new(platform: 'smartos', version: 'joyent_20130111T180733Z').converge(described_recipe)
ChefSpec::ServerRunner.new(platform: 'smartos', version: 'joyent_20130111T180733Z').converge(described_recipe)
end
let(:template) { chef_run.template('/opt/local/etc/rsyslog.d/50-default.conf') }
......@@ -236,7 +236,7 @@ describe 'rsyslog::default' do
context 'COOK-3608 maillog regression test' do
let(:chef_run) do
ChefSpec::SoloRunner.new(platform: 'redhat', version: '6.3').converge(described_recipe)
ChefSpec::ServerRunner.new(platform: 'redhat', version: '6.3').converge(described_recipe)
end
it 'outputs mail.* to /var/log/maillog' do
......@@ -246,7 +246,7 @@ describe 'rsyslog::default' do
context 'syslog service' do
let(:chef_run) do
ChefSpec::SoloRunner.new(platform: 'redhat', version: '5.8').converge(described_recipe)
ChefSpec::ServerRunner.new(platform: 'redhat', version: '5.8').converge(described_recipe)
end
it 'stops and starts the syslog service on RHEL' do
......@@ -258,7 +258,7 @@ describe 'rsyslog::default' do
context 'system-log service' do
{ 'omnios' => '151002', 'smartos' => 'joyent_20130111T180733Z' }.each do |p, pv|
let(:chef_run) do
ChefSpec::SoloRunner.new(platform: p, version: pv).converge(described_recipe)
ChefSpec::ServerRunner.new(platform: p, version: pv).converge(described_recipe)
end
it "stops the system-log service on #{p}" do
......@@ -269,7 +269,7 @@ describe 'rsyslog::default' do
context 'on OmniOS' do
let(:chef_run) do
ChefSpec::SoloRunner.new(platform: 'omnios', version: '151002').converge(described_recipe)
ChefSpec::ServerRunner.new(platform: 'omnios', version: '151002').converge(described_recipe)
end
let(:template) { chef_run.template('/var/svc/manifest/system/rsyslogd.xml') }
......
......@@ -2,7 +2,7 @@ require 'spec_helper'
describe 'rsyslog::server' do
let(:chef_run) do
ChefSpec::SoloRunner.new(platform: 'ubuntu', version: '12.04') do |node|
ChefSpec::ServerRunner.new(platform: 'ubuntu', version: '12.04') do |node|
node.set['rsyslog']['server'] = false
end.converge(described_recipe)
end
......@@ -56,7 +56,7 @@ describe 'rsyslog::server' do
context 'on SmartOS' do
let(:chef_run) do
ChefSpec::SoloRunner.new(platform: 'smartos', version: 'joyent_20130111T180733Z') do |node|
ChefSpec::ServerRunner.new(platform: 'smartos', version: 'joyent_20130111T180733Z') do |node|
node.set['rsyslog']['server'] = false
end.converge(described_recipe)
end
......@@ -103,7 +103,7 @@ describe 'rsyslog::server' do
end
let(:chef_run) do
ChefSpec::SoloRunner.new(platform: 'smartos', version: 'joyent_20130111T180733Z') do |node|
ChefSpec::ServerRunner.new(platform: 'smartos', version: 'joyent_20130111T180733Z') do |node|
node.set['rsyslog']['server'] = false
end.converge(described_recipe)
end
......
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