Skip to content

Commit

Permalink
add basic port389::install class
Browse files Browse the repository at this point in the history
  • Loading branch information
Joshua Hoblitt committed Jan 16, 2014
1 parent 2374d20 commit e984464
Show file tree
Hide file tree
Showing 7 changed files with 106 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .fixtures.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ fixtures:
repositories:
stdlib:
repo: 'git://github.com/puppetlabs/puppetlabs-stdlib.git'
ref: '3.0.0'
ref: '4.0.0'
symlinks:
port389: "#{source_dir}"
2 changes: 1 addition & 1 deletion Modulefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ project_page 'https://github.com/jhoblitt/puppet-port389'
source 'https://github.com/jhoblitt/puppet-port389.git'
summary 'Manage port 389 Directory Server'
description 'Manage port 389 Directory Server'
dependency 'puppetlabs/stdlib', '>= 3.0.0'
dependency 'puppetlabs/stdlib', '>= 4.0.0'
14 changes: 13 additions & 1 deletion manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,18 @@
#
# include port389
#
class port389 {
class port389(
$package_ensure = $port389::params::package_ensure,
$package_name = $port389::params::package_name,
) inherits port389::params {
if !(is_string($package_ensure) or is_array($package_ensure)) {
fail('package_ensure must be a string or an array')
}
if !(is_string($package_name) or is_array($package_name)) {
fail('package_name must be a string or an array')
}

anchor { 'port389::begin': } ->
class { 'port389::install': } ->
anchor { 'port389::end': }
}
15 changes: 15 additions & 0 deletions manifests/install.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# private class
class port389::install (
$package_ensure = $port389::package_ensure,
$package_name = $port389::package_name,
) {
if $caller_module_name != $module_name {
fail("Use of private class ${name} by ${caller_module_name}")
}

ensure_packages(any2array($package_ensure))

package { $package_name:
ensure => present,
}
}
34 changes: 34 additions & 0 deletions manifests/params.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# private class
class port389::params {
case $::osfamily {
'redhat': {}
default: {
fail("Module ${module_name} is not supported on ${::operatingsystem}")
}
}

# console also requires java
$package_name = [
'389-admin',
'389-admin-console',
'389-admin-console-doc',
#'389-admin-debuginfo',
'389-adminutil',
#'389-adminutil-debuginfo',
'389-adminutil-devel',
'389-console',
'389-ds',
'389-ds-base',
'389-ds-base-devel',
'389-ds-base-libs',
'389-ds-console',
'389-ds-console-doc',
'389-dsgw',
#'389-dsgw-debuginfo',
]

# console requires /usr/sbin/httpd.worker provided by `httpd`
# we need to ensure the presence of this package but do not want 'ownership'
# of it
$package_ensure = 'httpd'
}
9 changes: 0 additions & 9 deletions spec/classes/module_skel_spec.rb

This file was deleted.

42 changes: 42 additions & 0 deletions spec/classes/port389_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
require 'spec_helper'

describe 'port389', :type => :class do

describe 'on osfamily RedHat' do
let(:facts) {{ :osfamily => 'RedHat' }}

it('should import') { should contain_class('port389') }

it('should include package dependency') { should contain_package('httpd') }
[
'389-admin',
'389-admin-console',
'389-admin-console-doc',
#'389-admin-debuginfo',
'389-adminutil',
#'389-adminutil-debuginfo',
'389-adminutil-devel',
'389-console',
'389-ds',
'389-ds-base',
'389-ds-base-devel',
'389-ds-base-libs',
'389-ds-console',
'389-ds-console-doc',
'389-dsgw',
#'389-dsgw-debuginfo',
].each do |pkg|
it('should include package') { should contain_package(pkg) }
end
end # on osfamily RedHat

describe 'on an unsupported osfamily' do
let(:facts) {{ :osfamily => 'Debian', :operatingsystem => 'Debian' }}

it 'should fail' do
expect { should contain_class('port389') }.
to raise_error(Puppet::Error, /not supported on Debian/)
end
end # on an unsupported osfamily

end

0 comments on commit e984464

Please sign in to comment.