Skip to content

Commit

Permalink
[COOK-3736] Add OmniOS support
Browse files Browse the repository at this point in the history
Signed-off-by: Seth Vargo <[email protected]>
  • Loading branch information
Joshua Timberman authored and sethvargo committed Oct 7, 2013
1 parent f46584e commit 079eb33
Show file tree
Hide file tree
Showing 10 changed files with 113 additions and 13 deletions.
8 changes: 7 additions & 1 deletion .kitchen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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]
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
24 changes: 24 additions & 0 deletions TESTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 4 additions & 0 deletions attributes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 19 additions & 3 deletions recipes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion spec/client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
29 changes: 26 additions & 3 deletions spec/default_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 0 additions & 4 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion templates/default/50-default.conf.erb
Original file line number Diff line number Diff line change
@@ -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 %>
30 changes: 30 additions & 0 deletions templates/default/omnios-manifest.xml.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?xml version='1.0'?>
<!DOCTYPE service_bundle SYSTEM '/usr/share/lib/xml/dtd/service_bundle.dtd.1'>
<service_bundle type='manifest' name='export'>
<service name='<%= node['rsyslog']['service_name'] %>' type='service' version='0'>
<create_default_instance enabled='true'/>
<single_instance/>
<dependency name='network' grouping='require_all' restart_on='error' type='service'>
<service_fmri value='svc:/milestone/network:default'/>
</dependency>
<dependency name='filesystem' grouping='require_all' restart_on='error' type='service'>
<service_fmri value='svc:/system/filesystem/local'/>
</dependency>
<method_context/>
<exec_method name='start' type='method' exec='/opt/omni/sbin/rsyslogd -f %{config_file}' timeout_seconds='60'/>
<exec_method name='stop' type='method' exec=':kill' timeout_seconds='60'/>
<property_group name='startd' type='framework'>
<propval name='duration' type='astring' value='contract'/>
<propval name='ignore_error' type='astring' value='core,signal'/>
</property_group>
<property_group name='application' type='application'>
<propval name='config_file' type='astring' value='<%= node["rsyslog"]["config_prefix"] %>/rsyslog.conf'/>
</property_group>
<stability value='Evolving'/>
<template>
<common_name>
<loctext xml:lang='C'>rsyslog daemon</loctext>
</common_name>
</template>
</service>
</service_bundle>

0 comments on commit 079eb33

Please sign in to comment.