Skip to content

Commit 44596dc

Browse files
author
jbondpdx
committed
DOC-1095: edit file_line resource, match parameter
Was unclear and not accurate; rewrote the parameter, moved file_line from function list to resource section, added missing parameters for this resource.
1 parent 1493b21 commit 44596dc

1 file changed

Lines changed: 24 additions & 20 deletions

File tree

README.markdown

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ After you've installed stdlib, all of its functions, facts, and resources are av
4040

4141
If you want to use a standardized set of run stages for Puppet, `include stdlib` in your manifest.
4242

43-
##Reference
43+
## Reference
4444

4545
### Classes
4646

@@ -75,7 +75,30 @@ If you want to use a standardized set of run stages for Puppet, `include stdlib`
7575
class { java: stage => 'runtime' }
7676
}
7777
```
78+
79+
### Resources
7880

81+
* `file_line`: This resource ensures that a given line, including whitespace at the beginning and end, is contained within a file. If the line is not contained in the given file, Puppet will add the line. Multiple resources can be declared to manage multiple lines in the same file. You can also use match to replace existing lines.
82+
83+
```
84+
file_line { 'sudo_rule':
85+
path => '/etc/sudoers',
86+
line => '%sudo ALL=(ALL) ALL',
87+
}
88+
file_line { 'sudo_rule_nopw':
89+
path => '/etc/sudoers',
90+
line => '%sudonopw ALL=(ALL) NOPASSWD: ALL',
91+
}
92+
```
93+
94+
* `after`: Specify the line after which Puppet will add any new lines. (Existing lines are added in place.) Optional.
95+
* `ensure`: Ensures whether the resource is present. Valid values are 'present', 'absent'.
96+
* `line`: The line to be added to the file located by the `path` parameter.
97+
* `match`: A 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. Optional.
98+
* `multiple`: Determine if match can change multiple lines. Valid values are 'true', 'false'. Optional.
99+
* `name`: An arbitrary name used as the identity of the resource.
100+
* `path`: The file in which Puppet will ensure the line specified by the line parameter.
101+
79102
### Functions
80103

81104
* `abs`: Returns the absolute value of a number; for example, '-34.56' becomes '34.56'. Takes a single integer and float value as an argument. *Type*: rvalue
@@ -158,25 +181,6 @@ also appear in the second array. For example, `difference(["a","b","c"],["b","c"
158181

159182
*Type*: statement
160183

161-
* `file_line`: This resource ensures that a given line is contained within a file. You can also use match to replace existing lines.
162-
163-
*Example:*
164-
165-
```
166-
file_line { 'sudo_rule':
167-
path => '/etc/sudoers',
168-
line => '%sudo ALL=(ALL) ALL',
169-
}
170-
171-
file_line { 'change_mount':
172-
path => '/etc/fstab',
173-
line => '10.0.0.1:/vol/data /opt/data nfs defaults 0 0',
174-
match => '^172.16.17.2:/vol/old',
175-
}
176-
```
177-
178-
*Type*: resource
179-
180184
* `flatten`: This function flattens any deeply nested arrays and returns a single flat array as a result. For example, `flatten(['a', ['b', ['c']]])` returns ['a','b','c']. *Type*: rvalue
181185

182186
* `floor`: Returns the largest integer less than or equal to the argument.

0 commit comments

Comments
 (0)