diff --git a/manifests/params/node.pp b/manifests/params/node.pp index 2af6a0b..b273409 100644 --- a/manifests/params/node.pp +++ b/manifests/params/node.pp @@ -1,78 +1,85 @@ # Parameters for the munin::node class. Add support for new OS # families here. class munin::params::node { $message = "Unsupported osfamily: ${::osfamily}" $address = $::fqdn $host_name = $::fqdn $bind_address = '*' $bind_port = 4949 $allow = [] $masterconfig = [] $mastergroup = undef $mastername = undef $nodeconfig = [] $plugins = {} $service_ensure = undef $export_node = 'enabled' $log_file = 'munin-node.log' $log_destination = 'file' $syslog_facility = undef $purge_configs = false $timeout = undef case $::osfamily { - 'Archlinux', + 'Archlinux': { + $config_root = '/etc/munin' + $log_dir = '/var/log/munin' + $service_name = 'munin-node' + $package_name = 'munin-node' + $plugin_share_dir = '/usr/lib/munin/plugins' + $file_group = 'root' + } 'RedHat': { $config_root = '/etc/munin' $log_dir = '/var/log/munin-node' $service_name = 'munin-node' $package_name = 'munin-node' $plugin_share_dir = '/usr/share/munin/plugins' $file_group = 'root' } 'Debian': { $config_root = '/etc/munin' $log_dir = '/var/log/munin' $service_name = 'munin-node' $package_name = 'munin-node' $plugin_share_dir = '/usr/share/munin/plugins' $file_group = 'root' } 'Solaris': { case $::operatingsystem { 'SmartOS': { $config_root = '/opt/local/etc/munin' $log_dir = '/var/opt/log/munin' $service_name = 'smf:/munin-node' $package_name = 'munin-node' $plugin_share_dir = '/opt/local/share/munin/plugins' $file_group = 'root' } default: { fail("Unsupported operatingsystem ${::operatingsystem} for osfamily ${::osfamily}") } } } 'FreeBSD', 'DragonFly': { $config_root = '/usr/local/etc/munin' $log_dir = '/var/log/munin' $service_name = 'munin-node' $package_name = 'munin-node' $plugin_share_dir = '/usr/local/share/munin/plugins' $file_group = 'wheel' } 'OpenBSD': { $config_root = '/etc/munin' $log_dir = '/var/log/munin' $service_name = 'munin_node' $package_name = 'munin-node' $plugin_share_dir = '/usr/local/libexec/munin/plugins' $file_group = 'wheel' } default: { fail($message) } } } diff --git a/spec/defines/munin_plugin_spec.rb b/spec/defines/munin_plugin_spec.rb index afd208e..a4fb37b 100644 --- a/spec/defines/munin_plugin_spec.rb +++ b/spec/defines/munin_plugin_spec.rb @@ -1,142 +1,143 @@ require 'spec_helper' t_conf_dir = {} t_conf_dir.default = '/etc/munin' t_conf_dir['Solaris'] = '/opt/local/etc/munin' t_conf_dir['FreeBSD'] = '/usr/local/etc/munin' t_share_dir = {} t_share_dir.default = '/usr/share/munin' t_share_dir['Solaris'] = '/opt/local/share/munin' t_share_dir['FreeBSD'] = '/usr/local/share/munin' +t_share_dir['Archlinux'] = '/usr/lib/munin' describe 'munin::plugin', type: 'define' do let(:title) { 'testplugin' } on_supported_os.each do |os, facts| # Avoid testing on distributions similar to RedHat and Debian next if os =~ %r{^(ubuntu|centos|scientific|oraclelinux)-} # No need to test all os versions as long as os version is not # used in the params class next if os =~ %r{^(debian-[67]|redhat-[56]|freebsd-9)-} context "on #{os}" do let(:facts) do facts end conf_dir = t_conf_dir[facts[:osfamily]] plugin_share_dir = "#{t_share_dir[facts[:osfamily]]}/plugins" context 'with no parameters' do it do expect { is_expected.to contain_file("#{conf_dir}/plugins/testplugin") } .to raise_error("expected that the catalogue would contain File[#{conf_dir}/plugins/testplugin]") end it do is_expected.to contain_file("#{conf_dir}/plugin-conf.d/testplugin.conf") .with_ensure('absent') end end context 'with ensure=link parameter' do let(:params) { { ensure: 'link' } } it do is_expected.to contain_file("#{conf_dir}/plugins/testplugin") .with_ensure('link') .with_target("#{plugin_share_dir}/testplugin") end it do is_expected.to contain_file("#{conf_dir}/plugin-conf.d/testplugin.conf") .with_ensure('absent') end end context 'with ensure=link and target parameters' do let(:title) { 'test_foo' } let(:params) do { ensure: 'link', target: 'test_' } end it do is_expected.to contain_file("#{conf_dir}/plugins/test_foo") .with_ensure('link') .with_target("#{plugin_share_dir}/test_") end it do is_expected.to contain_file("#{conf_dir}/plugin-conf.d/test_foo.conf") .with_ensure('absent') end end context 'with ensure=present and source parameters' do let(:params) do { ensure: 'present', source: 'puppet:///modules/munin/plugins/testplugin' } end it do is_expected.to contain_file("#{conf_dir}/plugins/testplugin") .with_ensure('present') .with_source('puppet:///modules/munin/plugins/testplugin') end it do is_expected.to contain_file("#{conf_dir}/plugin-conf.d/testplugin.conf") .with_ensure('absent') end end context 'with ensure=present, source and config parameters' do let(:params) do { ensure: 'present', source: 'puppet:///modules/munin/plugins/testplugin', config: ['something wonderful'] } end it do is_expected.to contain_file("#{conf_dir}/plugins/testplugin") .with_ensure('present') .with_source('puppet:///modules/munin/plugins/testplugin') end it do is_expected.to contain_file("#{conf_dir}/plugin-conf.d/testplugin.conf") .with_ensure('present') .with_content(%r{something wonderful}) end end context 'only configuration' do let(:params) do { config: ['env.rootdn cn=admin,dc=example,dc=org'], config_label: 'slapd_*' } end it do is_expected.to contain_file("#{conf_dir}/plugin-conf.d/testplugin.conf") .with_ensure('present') .with_content(%r{env.rootdn}) end it do expect { is_expected.to contain_file("#{conf_dir}/plugins/testplugin") } .to raise_error("expected that the catalogue would contain File[#{conf_dir}/plugins/testplugin]") end end context 'with absolute target' do let(:params) do { ensure: 'link', target: '/full/path/to/testplugin' } end it do is_expected.to contain_file("#{conf_dir}/plugins/testplugin") .with_ensure('link') .with_target('/full/path/to/testplugin') end end end end end