diff --git a/.fixtures.yml b/.fixtures.yml index 12ea392..bc5e41a 100644 --- a/.fixtures.yml +++ b/.fixtures.yml @@ -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}" diff --git a/Modulefile b/Modulefile index 865dc67..53d76c0 100644 --- a/Modulefile +++ b/Modulefile @@ -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' diff --git a/manifests/init.pp b/manifests/init.pp index 36d5335..50b481f 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -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': } } diff --git a/manifests/install.pp b/manifests/install.pp new file mode 100644 index 0000000..516a28a --- /dev/null +++ b/manifests/install.pp @@ -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, + } +} diff --git a/manifests/params.pp b/manifests/params.pp new file mode 100644 index 0000000..c0fc1ba --- /dev/null +++ b/manifests/params.pp @@ -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' +} diff --git a/spec/classes/module_skel_spec.rb b/spec/classes/module_skel_spec.rb deleted file mode 100644 index ffe1a31..0000000 --- a/spec/classes/module_skel_spec.rb +++ /dev/null @@ -1,9 +0,0 @@ -require 'spec_helper' - -describe 'port389', :type => :class do - - describe 'for osfamily RedHat' do - it { should contain_class('port389') } - end - -end diff --git a/spec/classes/port389_spec.rb b/spec/classes/port389_spec.rb new file mode 100644 index 0000000..db54f2d --- /dev/null +++ b/spec/classes/port389_spec.rb @@ -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