diff --git a/.kitchen.yml b/.kitchen.yml index 55bf6996..b2c74ad7 100644 --- a/.kitchen.yml +++ b/.kitchen.yml @@ -11,6 +11,10 @@ platforms: - recipe[apt] - name: centos-6.4 - name: centos-5.9 + - name: omnios-r151006c + driver_config: + box: omnios-r151006c + box_url: http://omnios.omniti.com/media/OmniOS_r151006c-r1.box suites: - name: default @@ -22,8 +26,10 @@ suites: attributes: rsyslog: use_relp: true + # CentOS and OmniOS do not support relp excludes: - - centos-5.9 # Centos5 does not support relp + - centos-5.9 + - omnios-r151006c - name: client run_list: - recipe[rsyslog::client] diff --git a/README.md b/README.md index 9d944110..d47bf220 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,7 @@ Tested on: - Ubuntu 9.10 - Ubuntu 10.04 - RedHat 6.3 +- OmniOS r151006c ### Other To use the `recipe[rsyslog::client]` recipe, you'll need to set up the `rsyslog.server_search` or `rsyslog.server_ip` attributes. See the __Recipes__ and __Examples__ sections below. diff --git a/TESTING.md b/TESTING.md index 0b9023c6..a00e5631 100644 --- a/TESTING.md +++ b/TESTING.md @@ -52,3 +52,27 @@ Development 9. Mark the JIRA ticket as "Fix Provided" For more information, see [Opscode's Contribution Guidelines](https://wiki.opscode.com/display/chef/How+to+Contribute). + +Testing OmniOS +-------------- + +This patch to test-kitchen is required to test using the OmniOS box, +as the path to `pkgadd` (`/usr/sbin`) is not in the default `vagrant` +user's path when logging in without a TTY. + +https://github.com/opscode/test-kitchen/pull/164 + +If your local version of Vagrant is 1.2.0 or higher, you may need to +install the `vagrant-guest-omnios` plugin to get OS detection for +OmniOS to work properly. + +https://github.com/clintoncwolfe/vagrant-guest-omnios + +TL;DR: + + vagrant plugin install vagrant-guest-omnios + +The Solaris package which is installed on OmniOS does not create +symlinks in `/usr/bin` for the various Chef binaries. + +https://github.com/opscode/test-kitchen/issues/213 diff --git a/attributes/default.rb b/attributes/default.rb index 77ef4cdb..2a2e1787 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -56,6 +56,10 @@ default['rsyslog']['config_prefix'] = '/opt/local/etc' default['rsyslog']['modules'] = %w(immark imsolaris imtcp imudp) default['rsyslog']['group'] = 'root' +when 'omnios' + default['rsyslog']['service_name'] = 'system/rsyslogd' + default['rsyslog']['modules'] = %w(immark imsolaris imtcp imudp) + default['rsyslog']['group'] = 'root' end # 50-default template attributes diff --git a/recipes/default.rb b/recipes/default.rb index 99de8f57..fb1f0632 100644 --- a/recipes/default.rb +++ b/recipes/default.rb @@ -47,7 +47,6 @@ owner 'root' group 'root' mode '0644' - variables(:facility_logs => node['rsyslog']['default_facility_logs']) notifies :restart, "service[#{node['rsyslog']['service_name']}]" end @@ -56,13 +55,30 @@ service 'syslog' do action [:stop, :disable] end -# syslog needs to be stopped before rsyslog can be started on SmartOS -elsif platform_family?('smartos') +elsif platform_family?('smartos', 'omnios') + # syslog needs to be stopped before rsyslog can be started on SmartOS, OmniOS service 'system-log' do action :disable end end +if platform_family?('omnios') + # manage the SMF manifest on OmniOS + template '/var/svc/manifest/system/rsyslogd.xml' do + source 'omnios-manifest.xml.erb' + owner 'root' + group 'root' + mode '0644' + notifies :run, 'execute[import rsyslog manifest]', :immediately + end + + execute 'import rsyslog manifest' do + action :nothing + command 'svccfg import /var/svc/manifest/system/rsyslogd.xml' + notifies :restart, "service[#{node['rsyslog']['service_name']}]" + end +end + service node['rsyslog']['service_name'] do supports :restart => true, :reload => true, :status => true action [:enable, :start] diff --git a/spec/client_spec.rb b/spec/client_spec.rb index e9db20ba..a9906dfd 100644 --- a/spec/client_spec.rb +++ b/spec/client_spec.rb @@ -7,7 +7,7 @@ $stdout.stub(:puts) end - it 'exists fatally' do + it 'exits fatally' do expect { ChefSpec::ChefRunner.new.converge('rsyslog::client') }.to raise_error(SystemExit) end end diff --git a/spec/default_spec.rb b/spec/default_spec.rb index 09f743cf..04acc4ea 100644 --- a/spec/default_spec.rb +++ b/spec/default_spec.rb @@ -210,12 +210,35 @@ end context 'system-log service' do + { 'omnios' => '151002', 'smartos' => 'joyent_20130111T180733Z' }.each do |p, pv| + let(:chef_run) do + ChefSpec::ChefRunner.new(platform: p, version: pv).converge('rsyslog::default') + end + + it "stops the system-log service on #{p}" do + expect(chef_run).to disable_service('system-log') + end + end + end + + context 'on OmniOS' do let(:chef_run) do - ChefSpec::ChefRunner.new(platform: 'smartos', version: 'joyent_20130111T180733Z').converge('rsyslog::default') + ChefSpec::ChefRunner.new(platform: 'omnios', version: '151002').converge('rsyslog::default') + end + + let(:template) { chef_run.template('/var/svc/manifest/system/rsyslogd.xml') } + let(:execute) { chef_run.execute('import rsyslog manifest') } + + it 'creates the custom SMF manifest' do + expect(chef_run).to create_file(template.path) + end + + it 'notifies svccfg to import the manifest' do + expect(template).to notify('execute[import rsyslog manifest]', :run) end - it 'stops the system-log service on SmartOS' do - expect(chef_run).to disable_service('system-log') + it 'notifies rsyslog to restart when importing the manifest' do + expect(execute).to notify('service[system/rsyslogd]', :restart) end end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 0af1c988..8fbb73f4 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -6,7 +6,3 @@ berksfile = Berkshelf::Berksfile.from_file('Berksfile') berksfile.install(path: 'vendor/cookbooks', only: 'integration') end - -RSpec.configure do |config| - config.expect_with(:rspec) { |c| c.syntax = :expect } -end diff --git a/templates/default/50-default.conf.erb b/templates/default/50-default.conf.erb index 8a9effbc..e6a18d75 100644 --- a/templates/default/50-default.conf.erb +++ b/templates/default/50-default.conf.erb @@ -1,6 +1,6 @@ # Generated by Chef for <%= node['fqdn'] %> # For more information see rsyslog.conf(5) and /etc/rsyslog.conf -<% @facility_logs.each do |key, value| %> +<% node['rsyslog']['default_facility_logs'].each do |key, value| %> <%= key %> <%= value %> <% end %> diff --git a/templates/default/omnios-manifest.xml.erb b/templates/default/omnios-manifest.xml.erb new file mode 100644 index 00000000..4bff7e1d --- /dev/null +++ b/templates/default/omnios-manifest.xml.erb @@ -0,0 +1,30 @@ + + + + ' type='service' version='0'> + + + + + + + + + + + + + + + + + + + + + +