diff options
author | Hunter Haugen <hunter@puppetlabs.com> | 2015-04-09 12:13:34 -0700 |
---|---|---|
committer | Hunter Haugen <hunter@puppetlabs.com> | 2015-04-09 12:13:34 -0700 |
commit | f2fa4fbd62b1cd10a25a19d7a8c4729b189e6312 (patch) | |
tree | 60d585c4de008eb8f8774894b16dd1fa15d25b99 | |
parent | 8fba5c058ba344421796cceca8f96dffcba0a4fc (diff) | |
parent | ee2225b63c4356dafffedc16ec0376af58d42dad (diff) |
Merge pull request #430 from mhaskel/gjngeldenhuis-docupdate
Clarifying behaviour of attributes and adding an extra example.
-rw-r--r-- | lib/puppet/type/file_line.rb | 30 |
1 files changed, 23 insertions, 7 deletions
diff --git a/lib/puppet/type/file_line.rb b/lib/puppet/type/file_line.rb index df263e6..29f9538 100644 --- a/lib/puppet/type/file_line.rb +++ b/lib/puppet/type/file_line.rb @@ -3,9 +3,9 @@ Puppet::Type.newtype(:file_line) do desc <<-EOT Ensures that a given line is contained within a file. The implementation matches the full line, including whitespace at the beginning and end. If - the line is not contained in the given file, Puppet will add the line to - ensure the desired state. Multiple resources may be declared to manage - multiple lines in the same file. + the line is not contained in the given file, Puppet will append the line to + the end of the file to ensure the desired state. Multiple resources may + be declared to manage multiple lines in the same file. Example: @@ -13,6 +13,7 @@ Puppet::Type.newtype(:file_line) do path => '/etc/sudoers', line => '%sudo ALL=(ALL) ALL', } + file_line { 'sudo_rule_nopw': path => '/etc/sudoers', line => '%sudonopw ALL=(ALL) NOPASSWD: ALL', @@ -21,6 +22,18 @@ Puppet::Type.newtype(:file_line) do In this example, Puppet will ensure both of the specified lines are contained in the file /etc/sudoers. + Match Example: + + file_line { 'bashrc_proxy': + ensure => present, + path => '/etc/bashrc', + line => 'export HTTP_PROXY=http://squid.puppetlabs.vm:3128', + match => '^export\ HTTP_PROXY\=', + } + + In this code example match will look for a line beginning with export + followed by HTTP_PROXY and replace it with the value in line. + **Autorequires:** If Puppet is managing the file that will contain the line being managed, the file_line resource will autorequire that file. @@ -36,12 +49,15 @@ Puppet::Type.newtype(:file_line) do end newparam(:match) do - desc 'An optional regular expression to run against existing lines in the file;\n' + - 'if a match is found, we replace that line rather than adding a new line.' + desc 'An optional ruby regular expression to run against existing lines in the file.' + + ' If a match is found, we replace that line rather than adding a new line.' + + ' A regex comparisson is performed against the line value and if it does not' + + ' match an exception will be raised. ' end newparam(:multiple) do - desc 'An optional value to determine if match can change multiple lines.' + desc 'An optional value to determine if match can change multiple lines.' + + ' If set to false, an exception will be raised if more than one line matches' newvalues(true, false) end @@ -50,7 +66,7 @@ Puppet::Type.newtype(:file_line) do end newparam(:line) do - desc 'The line to be appended to the file located by the path parameter.' + desc 'The line to be appended to the file or used to replace matches found by the match attribute.' end newparam(:path) do |