only backup target concat file + remove backup param from concat::fragment

Disable filebucket backup of all file resources except for the the
target file that's being concatenated.
This commit is contained in:
Joshua Hoblitt 2013-10-23 15:42:44 -07:00
parent 94cbeca231
commit 4d884d3242
6 changed files with 17 additions and 34 deletions

View file

@ -33,8 +33,7 @@ define concat::fragment(
$ensure = 'present', $ensure = 'present',
$mode = '0644', $mode = '0644',
$owner = $::id, $owner = $::id,
$group = undef, $group = undef
$backup = 'puppet'
) { ) {
validate_absolute_path($target) validate_absolute_path($target)
validate_re($ensure, '^$|^present$|^absent$|^file$|^directory$') validate_re($ensure, '^$|^present$|^absent$|^file$|^directory$')
@ -44,7 +43,6 @@ define concat::fragment(
validate_string($mode) validate_string($mode)
validate_string($owner) validate_string($owner)
validate_string($group) validate_string($group)
validate_string($backup)
include concat::setup include concat::setup
@ -78,7 +76,7 @@ define concat::fragment(
group => $safe_group, group => $safe_group,
source => $source, source => $source,
content => $content, content => $content,
backup => $backup, backup => false,
alias => "concat_fragment_${name}", alias => "concat_fragment_${name}",
notify => Exec["concat_${target}"] notify => Exec["concat_${target}"]
} }

View file

@ -126,8 +126,8 @@ define concat(
owner => $owner, owner => $owner,
group => $safe_group, group => $safe_group,
mode => $mode, mode => $mode,
backup => $backup, replace => $replace,
replace => $replace backup => false,
} }
if $ensure == 'present' { if $ensure == 'present' {
@ -157,6 +157,7 @@ define concat(
path => $path, path => $path,
alias => "concat_${name}", alias => "concat_${name}",
source => "${fragdir}/${concat_name}", source => "${fragdir}/${concat_name}",
backup => $backup,
} }
# remove extra whitespace from string interopolation to make testing easier # remove extra whitespace from string interopolation to make testing easier
@ -190,12 +191,12 @@ define concat(
"${fragdir}/${concat_name}" "${fragdir}/${concat_name}"
]: ]:
ensure => absent, ensure => absent,
backup => false,
force => true, force => true,
} }
file { $name: file { $name:
ensure => absent, ensure => absent,
backup => $backup,
} }
exec { "concat_${name}": exec { "concat_${name}":

View file

@ -26,6 +26,10 @@ class concat::setup {
fail ('$concat_basedir not defined. Try running again with pluginsync=true on the [master] and/or [main] section of your node\'s \'/etc/puppet/puppet.conf\'.') fail ('$concat_basedir not defined. Try running again with pluginsync=true on the [master] and/or [main] section of your node\'s \'/etc/puppet/puppet.conf\'.')
} }
File {
backup => false,
}
file { "${concatdir}/bin/concatfragments.sh": file { "${concatdir}/bin/concatfragments.sh":
owner => $owner, owner => $owner,
group => $root_group, group => $root_group,

View file

@ -14,6 +14,7 @@ describe 'concat::setup', :type => :class do
:group => id == 'root' ? 0 : id, :group => id == 'root' ? 0 : id,
:mode => '0755', :mode => '0755',
:source => 'puppet:///modules/concat/concatfragments.sh', :source => 'puppet:///modules/concat/concatfragments.sh',
:backup => false,
}) })
end end
@ -24,6 +25,7 @@ describe 'concat::setup', :type => :class do
:owner => id, :owner => id,
:group => id == 'root' ? 0 : id, :group => id == 'root' ? 0 : id,
:mode => '0750', :mode => '0750',
:backup => false,
}) })
end end
end end
@ -31,6 +33,7 @@ describe 'concat::setup', :type => :class do
it do it do
should contain_file('/usr/local/bin/concatfragments.sh').with({ should contain_file('/usr/local/bin/concatfragments.sh').with({
:ensure => 'absent', :ensure => 'absent',
:backup => false,
}) })
end end
end end

View file

@ -50,8 +50,8 @@ describe 'concat::fragment', :type => :define do
:group => safe_group, :group => safe_group,
:source => p[:source], :source => p[:source],
:content => p[:content], :content => p[:content],
:backup => p[:backup],
:alias => "concat_fragment_#{title}", :alias => "concat_fragment_#{title}",
:backup => false,
}) })
end end
end end
@ -217,23 +217,4 @@ describe 'concat::fragment', :type => :define do
end end
end # group => end # group =>
context 'backup =>' do
context 'apenny' do
it_behaves_like 'fragment', 'motd_header', {
:backup => 'apenny',
:target => '/etc/motd',
}
end
context 'false' do
let(:title) { 'motd_header' }
let(:facts) {{ :concat_basedir => '/tmp', :id => 'root' }}
let(:params) {{ :backup => false, :target => '/etc/motd' }}
it 'should fail' do
expect { should }.to raise_error(Puppet::Error, /is not a string/)
end
end
end # backup =>
end end

View file

@ -33,7 +33,7 @@ describe 'concat', :type => :define do
:owner => p[:owner], :owner => p[:owner],
:group => p[:group], :group => p[:group],
:mode => p[:mode], :mode => p[:mode],
:backup => p[:backup], :backup => false,
:replace => p[:replace], :replace => p[:replace],
} }
@ -80,6 +80,7 @@ describe 'concat', :type => :define do
:path => p[:path], :path => p[:path],
:alias => "concat_#{title}", :alias => "concat_#{title}",
:source => "#{fragdir}/#{concat_name}", :source => "#{fragdir}/#{concat_name}",
:backup => p[:backup],
})) }))
end end
@ -130,12 +131,7 @@ describe 'concat', :type => :define do
it do it do
should contain_file(title).with(file_defaults.merge({ should contain_file(title).with(file_defaults.merge({
:ensure => 'absent', :ensure => 'absent',
})) :backup => p[:backup],
end
it do
should contain_file(title).with(file_defaults.merge({
:ensure => 'absent',
})) }))
end end