1 Puppet::Type.newtype(:file_line) do
4 Ensures that a given line is contained within a file. The implementation
5 matches the full line, including whitespace at the beginning and end. If
6 the line is not contained in the given file, Puppet will add the line to
7 ensure the desired state. Multiple resources may be declared to manage
8 multiple lines in the same file.
12 file_line { 'sudo_rule':
13 path => '/etc/sudoers',
14 line => '%sudo ALL=(ALL) ALL',
16 file_line { 'sudo_rule_nopw':
17 path => '/etc/sudoers',
18 line => '%sudonopw ALL=(ALL) NOPASSWD: ALL',
21 In this example, Puppet will ensure both of the specified lines are
22 contained in the file /etc/sudoers.
33 newparam(:name, :namevar => true) do
34 desc 'arbitrary name used as identity'
38 desc 'The line to be appended to the path.'
42 desc 'File to possibly append a line to.'
44 unless (Puppet.features.posix? and value =~ /^\//) or (Puppet.features.microsoft_windows? and (value =~ /^.:\// or value =~ /^\/\/[^\/]+\/[^\/]+/))
45 raise(Puppet::Error, "File paths must be fully qualified, not '#{value}'")
51 unless self[:line] and self[:path]
52 raise(Puppet::Error, "Both line and path are required attributes")