Skip to content

Commit 1373e70

Browse files
author
Jeff McCune
committed
Make file_line default to ensure => present
The examples in the file_line resource documentation state the following resource should work: file_line { 'sudo_rule': path => '/etc/sudoers', line => '%sudo ALL=(ALL) ALL', } Without this patch the example does not work because ensure is not set to present. This patch fixes the problem by setting the default value of ensure to present.
1 parent 20aacc5 commit 1373e70

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

lib/puppet/type/file_line.rb

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,20 @@
2323
2424
EOT
2525

26-
ensurable
26+
ensurable do
27+
defaultto :present
28+
end
2729

2830
newparam(:name, :namevar => true) do
29-
desc 'arbitrary name used as identity'
31+
desc 'An arbitrary name used as the identity of the resource.'
3032
end
3133

3234
newparam(:line) do
33-
desc 'The line to be appended to the path.'
35+
desc 'The line to be appended to the file located by the path parameter.'
3436
end
3537

3638
newparam(:path) do
37-
desc 'File to possibly append a line to.'
39+
desc 'The file Puppet will ensure contains the line specified by the line parameter.'
3840
validate do |value|
3941
unless (Puppet.features.posix? and value =~ /^\//) or (Puppet.features.microsoft_windows? and (value =~ /^.:\// or value =~ /^\/\/[^\/]+\/[^\/]+/))
4042
raise(Puppet::Error, "File paths must be fully qualified, not '#{value}'")

spec/unit/puppet/type/file_line_spec.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,7 @@
2121
it 'should require that a file is specified' do
2222
expect { Puppet::Type.type(:file_line).new(:name => 'foo', :line => 'path') }.should raise_error(Puppet::Error, /Both line and path are required attributes/)
2323
end
24+
it 'should default to ensure => present' do
25+
file_line[:ensure].should eq :present
26+
end
2427
end

0 commit comments

Comments
 (0)