diff --git a/manifests/config.pp b/manifests/config.pp index fe255cb..3b492af 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -1,8 +1,11 @@ -define fluentd::config($config) { +define fluentd::config( + Enum['present','absent'] $ensure = 'present', + Hash $config = {}, +) { include fluentd file { "${fluentd::config_path}/${title}": - ensure => present, + ensure => $ensure, content => fluent_config($config), require => Class['Fluentd::Install'], notify => Class['Fluentd::Service'], diff --git a/spec/defines/config_spec.rb b/spec/defines/config_spec.rb index 5bd01ad..129b6f7 100644 --- a/spec/defines/config_spec.rb +++ b/spec/defines/config_spec.rb @@ -24,6 +24,7 @@ it do is_expected.to contain_file('/etc/td-agent/config.d/stdout.conf'). + with(:ensure => 'present'). with_content(//). with_content(/@type forward/). with_content(//). @@ -34,5 +35,19 @@ with_content(/<\/match>/) end end + + context 'when config contains ensure absent' do + let(:params) do + { + ensure: 'absent', + config: { } + } + end + + it do + is_expected.to contain_file('/etc/td-agent/config.d/stdout.conf'). + with(:ensure => 'absent') + end + end end end