COOK-4086, add omnios support

Signed-off-by: Sean OMeara <someara@opscode.com>
This commit is contained in:
Joshua Timberman 2014-02-19 01:13:02 -05:00 committed by Sean OMeara
parent 14fc7d7919
commit 14612d63fd
12 changed files with 153 additions and 26 deletions

View File

@ -5,49 +5,38 @@ driver_config:
platforms:
- name: ubuntu-12.04
driver_config:
box: opscode-ubuntu-12.04
box_url: https://opscode-vm-bento.s3.amazonaws.com/vagrant/opscode_ubuntu-12.04_provisionerless.box
run_list:
- recipe[apt]
- name: ubuntu-10.04
driver_config:
box: opscode-ubuntu-10.04
box_url: https://opscode-vm-bento.s3.amazonaws.com/vagrant/opscode_ubuntu-10.04_provisionerless.box
run_list:
- recipe[apt]
- name: centos-6.4
driver_config:
box: opscode-centos-6.4
box_url: https://opscode-vm-bento.s3.amazonaws.com/vagrant/opscode_centos-6.4_provisionerless.box
- name: centos-5.9
driver_config:
box: opscode-centos-5.9
box_url: https://opscode-vm-bento.s3.amazonaws.com/vagrant/opscode_centos-5.9_provisionerless.box
- name: omnios-r151006c
driver:
box: omnios-r151006c
box_url: http://omnios.omniti.com/media/OmniOS_Text_r151006c.iso
run_list:
- recipe[fake::omnios]
suites:
- name: default
run_list:
- recipe[postfix]
attributes: {}
- name: aliases
run_list:
- recipe[postfix::aliases]
attributes: {}
- name: client
run_list:
- recipe[postfix::client]
attributes: {}
- name: server
run_list:
- recipe[postfix::server]
attributes: {}
- name: sasl_auth
run_list:

View File

@ -3,6 +3,7 @@ site :opscode
metadata
group :integration do
cookbook "apt"
cookbook "yum"
cookbook 'apt'
cookbook 'yum'
cookbook 'fake', :path => 'test/fixtures/cookbooks/fake'
end

View File

@ -29,6 +29,10 @@ case node['platform']
when 'smartos'
default['postfix']['conf_dir'] = '/opt/local/etc/postfix'
default['postfix']['aliases_db'] = '/opt/local/etc/postfix/aliases'
when 'omnios'
default['postfix']['conf_dir'] = '/opt/omni/etc/postfix'
default['postfix']['aliases_db'] = 'opt/omni/etc/postfix/aliases'
default['postfix']['uid'] = 11
else
default['postfix']['conf_dir'] = '/etc/postfix'
default['postfix']['aliases_db'] = '/etc/aliases'
@ -59,7 +63,7 @@ when 'smartos'
when 'rhel'
cafile = '/etc/pki/tls/cert.pem'
else
cafile = '/etc/postfix/cacert.pem'
cafile = "#{node['postfix']['conf_dir']}/cacert.pem"
end
if node['postfix']['use_procmail']

View File

@ -19,8 +19,8 @@ require File.expand_path('../support/helpers', __FILE__)
describe 'postfix::aliases' do
include Helpers::Postfix
it 'manages /etc/aliases' do
file('/etc/aliases').must_match(/^# This file is generated by Chef for/)
it 'manages aliases' do
file("#{node['postfix']['conf_dir']}/aliases").must_match(/^# This file is generated by Chef for/)
end
end

View File

@ -32,7 +32,7 @@ describe 'postfix::default' do
end
it 'configures postfix main.cf' do
file('/etc/postfix/main.cf').must_match(/^# Generated by Chef for /)
file("#{node['postfix']['conf_dir']}/main.cf").must_match(/^# Generated by Chef for /)
end
end

View File

@ -18,8 +18,8 @@ require File.expand_path('../support/helpers', __FILE__)
describe 'postfix::sasl_auth' do
include Helpers::Postfix
it 'manages /etc/postfix/sasl_passwd' do
file('/etc/postfix/sasl_passwd').must_match(/^# This file is generated by Chef for/)
it "manages postfix sasl_passwd" do
file("#{node['potfix']['conf_dir']}/sasl_passwd").must_match(/^# This file is generated by Chef for/)
end
it 'configures postfix to use /etc/postfix/sasl_passwd' do

View File

@ -18,6 +18,7 @@ include_recipe 'postfix'
execute 'update-postfix-aliases' do
command 'newaliases'
environment :PATH => "#{ENV['PATH']}:/opt/omni/bin:/opt/omni/sbin" if platform_family?('omnios')
action :nothing
end

View File

@ -36,6 +36,40 @@ when 'rhel', 'fedora'
notifies :start, 'service[postfix]'
not_if '/usr/bin/test /etc/alternatives/mta -ef /usr/sbin/sendmail.postfix'
end
when 'omnios'
manifest_path = ::File.join(Chef::Config[:file_cache_path], "manifest-postfix.xml")
# we need to manage the postfix group and user
# and then subscribe to the package install because it creates a
# postdrop group and adds postfix user to it.
group 'postfix' do
append true
end
user 'postfix' do
uid node['postfix']['uid']
gid 'postfix'
home '/var/spool/postfix'
subscribes :manage, 'package[postfix]'
notifies :run, 'execute[/opt/omni/sbin/postfix set-permissions]', :immediately
end
# we don't guard this because if the user creation was successful (or happened out of band), then this won't get executed when the action is :nothing.
execute '/opt/omni/sbin/postfix set-permissions'
template manifest_path do
source 'manifest-postfix.xml.erb'
owner 'root'
group 'root'
mode 00644
notifies :run, "execute[load postfix manifest]", :immediately
end
execute "load postfix manifest" do
action :nothing
command "svccfg import #{manifest_path}"
notifies :restart, "service[postfix]"
end
end
if !node['postfix']['sender_canonical_map_entries'].empty?

View File

@ -48,11 +48,17 @@ execute 'postmap-sasl_passwd' do
end
template node['postfix']['sasl_password_file'] do
command "postmap #{node['postfix']['conf_dir']}/sasl_passwd"
environment :PATH => "#{ENV['PATH']}:/opt/omni/bin:/opt/omni/sbin" if platform_family?('omnios')
action :nothing
end
template "#{node['postfix']['conf_dir']}/sasl_passwd" do
source 'sasl_passwd.erb'
owner 'root'
group 'root'
mode 0400
notifies :run, 'execute[postmap-sasl_passwd]', :immediately
notifies :restart, 'service[postfix]'
variables(settings: node['postfix']['sasl'])
variables(:settings => node['postfix']['sasl'])
end

View File

@ -0,0 +1,84 @@
<?xml version="1.0"?>
<!DOCTYPE service_bundle SYSTEM "/usr/share/lib/xml/dtd/service_bundle.dtd.1">
<!--
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
-->
<service_bundle type="manifest" name="SFEpostfix:postfix">
<service name="network/smtp/postfix" type="service" version="1">
<create_default_instance enabled="false" />
<single_instance />
<dependency name="network" grouping="require_all" restart_on="error" type="service">
<service_fmri value="svc:/milestone/network:default" />
</dependency>
<dependency name="filesystem-local" grouping="require_all" restart_on="error" type="service">
<service_fmri value="svc:/system/filesystem/local" />
</dependency>
<dependency name="name-services" grouping="require_all" restart_on="refresh" type="service">
<service_fmri value="svc:/milestone/name-services" />
</dependency>
<dependency name="system-log" grouping="optional_all" restart_on="error" type="service">
<service_fmri value="svc:/system/system-log" />
</dependency>
<!--
If autofs is enabled, wait for it to get users" home
directories.
-->
<dependency name="autofs" grouping="optional_all" restart_on="error" type="service">
<service_fmri value="svc:/system/filesystem/autofs" />
</dependency>
<dependent name="postfix_multi-user" grouping="optional_all" restart_on="none">
<service_fmri value="svc:/milestone/multi-user" />
</dependent>
<exec_method type="method" name="start"
exec="/opt/omni/sbin/postfix start"
timeout_seconds="180" />
<exec_method type="method" name="stop"
exec="/opt/omni/sbin/postfix stop"
timeout_seconds="60" />
<exec_method type="method" name="restart"
exec="/opt/omni/sbin/postfix reload"
timeout_seconds="60" />
<stability value="Unstable" />
<template>
<common_name>
<loctext xml:lang="C">
Postfix Mailserver
</loctext>
</common_name>
<documentation>
<manpage title="postfix" section="1" manpath="/usr/local/man" />
</documentation>
</template>
</service>
</service_bundle>

View File

@ -0,0 +1,3 @@
name "fake"
version "0.0.1"
description "Not a real cookbook, used for testing only."

View File

@ -0,0 +1,5 @@
execute "pkg set-publisher -g http://pkg.omniti.com/omniti-ms/ ms.omniti.com" do
not_if "pkg publisher ms.omniti.com"
end
execute "pkg refresh --full"