You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.markdown
+35-54Lines changed: 35 additions & 54 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -77,11 +77,7 @@ The `stdlib::stages` class declares various run stages for deploying infrastruct
77
77
78
78
#### `file_line`
79
79
80
-
Ensures that a given line is contained within a file. The implementation
81
-
matches the full line, including whitespace at the beginning and end. If
82
-
the line is not contained in the given file, Puppet will append the line to
83
-
the end of the file to ensure the desired state. Multiple resources may
84
-
be declared to manage multiple lines in the same file.
80
+
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 appends the line to the end of the file to ensure the desired state. Multiple resources can be declared to manage multiple lines in the same file.
85
81
86
82
Example:
87
83
@@ -95,8 +91,7 @@ Example:
95
91
line => '%sudonopw ALL=(ALL) NOPASSWD: ALL',
96
92
}
97
93
98
-
In this example, Puppet will ensure both of the specified lines are
99
-
contained in the file /etc/sudoers.
94
+
In this example, Puppet ensures that both of the specified lines are contained in the file `/etc/sudoers`.
100
95
101
96
Match Example:
102
97
@@ -107,8 +102,7 @@ Match Example:
107
102
match => '^export\ HTTP_PROXY\=',
108
103
}
109
104
110
-
In this code example match will look for a line beginning with export
111
-
followed by HTTP_PROXY and replace it with the value in line.
105
+
In this code example, `match` looks for a line beginning with export followed by HTTP_PROXY and replaces it with the value in line.
112
106
113
107
Match Example With `ensure => absent`:
114
108
@@ -120,20 +114,20 @@ Match Example With `ensure => absent`:
120
114
match_for_absence => true,
121
115
}
122
116
123
-
In this code examplematch will look for a line beginning with export
117
+
In this code example, `match` looks for a line beginning with export
124
118
followed by HTTP_PROXY and delete it. If multiple lines match, an
125
119
error will be raised unless the `multiple => true` parameter is set.
126
120
127
-
**Autorequires:** If Puppet is managing the file that will contain the line
128
-
being managed, the file_line resource will autorequire that file.
121
+
**Autorequires:** If Puppet is managing the file that contains the line being managed, the `file_line` resource autorequires that file.
129
122
130
123
##### Parameters
124
+
131
125
All parameters are optional, unless otherwise noted.
132
126
133
-
*`after`: Specifies the line after which Puppet will add any new lines. (Existing lines are added in place.) Valid options: String. Default: Undefined.
127
+
*`after`: Specifies the line after which Puppet adds any new lines. (Existing lines are added in place.) Valid options: String. Default: Undefined.
134
128
*`ensure`: Ensures whether the resource is present. Valid options: 'present', 'absent'. Default: 'present'.
135
129
*`line`: **Required.** Sets the line to be added to the file located by the `path` parameter. Valid options: String. Default: Undefined.
136
-
*`match`: Specifies a regular expression to run against existing lines in the file; if a match is found, it is replaced rather than adding a new line. A regex comparison is performed against the line value and if it does not match an exception will be raised. Valid options: String containing a regex. Default: Undefined.
130
+
*`match`: Specifies a regular expression to run against existing lines in the file; if a match is found, it is replaced rather than adding a new line. A regex comparison is performed against the line value, and if it does not match, an exception is raised. Valid options: String containing a regex. Default: Undefined.
137
131
*`match_for_absence`: An optional value to determine if match should be applied when `ensure => absent`. If set to true and match is set, the line that matches match will be deleted. If set to false (the default), match is ignored when `ensure => absent` and the value of `line` is used instead. Default: false.
138
132
*`multiple`: Determines if `match` and/or `after` can change multiple lines. If set to false, an exception will be raised if more than one line matches. Valid options: 'true', 'false'. Default: Undefined.
139
133
*`name`: Sets the name to use as the identity of the resource. This is necessary if you want the resource namevar to differ from the supplied `title` of the resource. Valid options: String. Default: Undefined.
@@ -172,10 +166,7 @@ Converts a boolean to a number. Converts values:
172
166
173
167
#### `bool2str`
174
168
175
-
Converts a boolean to a string using optionally supplied arguments. The optional
176
-
second and third arguments represent what true and false will be converted to
177
-
respectively. If only one argument is given, it will be converted from a boolean
178
-
to a string containing 'true' or 'false'.
169
+
Converts a boolean to a string using optionally supplied arguments. The optional second and third arguments represent what true and false are converted to respectively. If only one argument is given, it is converted from a boolean to a string containing 'true' or 'false'.
179
170
180
171
*Examples:*
181
172
~~~
@@ -188,7 +179,7 @@ Requires a single boolean as input. *Type*: rvalue.
188
179
189
180
#### `capitalize`
190
181
191
-
Capitalizes the first character of a string or array of strings, and lower-cases the remaining characters of each string. Requires either a single string or an array as an input. *Type*: rvalue.
182
+
Capitalizes the first character of a string or array of strings and lowercases the remaining characters of each string. Requires either a single string or an array as an input. *Type*: rvalue.
Rotates an array or string a random number of times, combining the `$fqdn` fact and an optional seed for repeatable randomness.
337
328
338
329
*Usage:*
330
+
339
331
~~~
340
332
fqdn_rotate(VALUE, [SEED])
341
333
~~~
334
+
342
335
*Examples:*
336
+
343
337
~~~
344
338
fqdn_rotate(['a', 'b', 'c', 'd'])
345
339
fqdn_rotate('abcd')
@@ -459,7 +453,7 @@ Returns an array an intersection of two. For example, `intersection(["a","b","c"
459
453
460
454
#### `is_a`
461
455
462
-
Boolean check to determine whether a variable is of a given data type. This is equivalent to the `=~` type checks. This function is only available in Puppet 4, or when using the "future" parser.
456
+
Boolean check to determine whether a variable is of a given data type. This is equivalent to the `=~` type checks. This function is available only in Puppet 4 or in Puppet 3 with the "future" parser.
463
457
464
458
~~~
465
459
foo = 3
@@ -477,8 +471,8 @@ Boolean check to determine whether a variable is of a given data type. This is e
477
471
}
478
472
~~~
479
473
480
-
See the documentation for "The Puppet Type System" for more information about types.
481
-
See the `assert_type()` function for flexible ways to assert the type of a value.
474
+
See the [the Puppet type system](https://docs.puppetlabs.com/references/latest/type.html#about-resource-types) for more information about types.
475
+
See the [`assert_type()`](https://docs.puppetlabs.com/references/latest/function.html#asserttype) function for flexible ways to assert the type of a value.
482
476
483
477
#### `is_array`
484
478
@@ -555,7 +549,7 @@ Loads the metadata.json of a target module. Can be used to determine module vers
555
549
notify { $metadata['author']: }
556
550
~~~
557
551
558
-
If you do not want to fail the catalog compilation if the metadata file for a module is not present:
552
+
If you do not want to fail the catalog compilation when a module's metadata file is absent:
559
553
560
554
~~~
561
555
$metadata = load_module_metadata('mysql', true)
@@ -606,13 +600,11 @@ Converts a number or a string representation of a number into a true boolean. Ze
606
600
607
601
#### `parsejson`
608
602
609
-
Converts a string of JSON into the correct Puppet structure. *Type*: rvalue.
610
-
The optional second argument will be returned if the data was not correct.
603
+
Converts a string of JSON into the correct Puppet structure. *Type*: rvalue. The optional second argument is returned if the data was not correct.
611
604
612
605
#### `parseyaml`
613
606
614
-
Converts a string of YAML into the correct Puppet structure. *Type*: rvalue.
615
-
The optional second argument will be returned if the data was not correct.
607
+
Converts a string of YAML into the correct Puppet structure. *Type*: rvalue. The optional second argument is returned if the data was not correct.
616
608
617
609
#### `pick`
618
610
@@ -626,7 +618,7 @@ From a list of values, returns the first value that is not undefined or an empty
626
618
627
619
#### `pick_default`
628
620
629
-
Will return the first value in a list of values. Contrary to the 'pick()' function, the 'pick_default()' does not fail if all arguments are empty. This allows it to use an empty value as default. *Type*: rvalue.
621
+
Returns the first value in a list of values. Contrary to the `pick()` function, the `pick_default()` does not fail if all arguments are empty. This allows it to use an empty value as default. *Type*: rvalue.
630
622
631
623
#### `prefix`
632
624
@@ -699,9 +691,7 @@ Strips spaces to the right of the string. *Type*: rvalue.
699
691
700
692
#### `seeded_rand`
701
693
702
-
Takes an integer max value and a string seed value and returns a
703
-
repeatable random integer smaller than max. Like `fqdn_rand`, but
704
-
this does not add node specific data to the seed. *Type*: rvalue.
694
+
Takes an integer max value and a string seed value and returns a repeatable random integer smaller than max. Like `fqdn_rand`, but does not add node specific data to the seed. *Type*: rvalue.
705
695
706
696
#### `shuffle`
707
697
@@ -721,7 +711,7 @@ Returns a new string where runs of the same character that occur in this set are
721
711
722
712
#### `str2bool`
723
713
724
-
Converts certain strings to a boolean. This attempts to convert strings that contain the values '1', 't', 'y', and 'yes' to 'true'. Strings that contain values '0', 'f', 'n', and 'no', or are an an empty string or undefined are converted to 'false'. Any other value will cause an error. *Type*: rvalue.
714
+
Converts certain strings to a boolean. This attempts to convert strings that contain the values '1', 't', 'y', or 'yes' to true. Strings that contain values '0', 'f', 'n', or 'no', or that are an empty string or undefined are converted to false. Any other value causes an error. *Type*: rvalue.
725
715
726
716
#### `str2saltedsha512`
727
717
@@ -804,18 +794,11 @@ Converts the argument into bytes, for example "4 kB" becomes "4096". Takes a sin
804
794
805
795
*Type*: rvalue.
806
796
807
-
Looks up into a complex structure of arrays and hashes to extract a value by
808
-
its path in the structure. The path is a string of hash keys or array indexes
809
-
starting with zero, separated by the path separator character (default "/").
810
-
The function will go down the structure by each path component and will try to
811
-
return the value at the end of the path.
797
+
Retrieves a value within multiple layers of hashes and arrays via a string containing a path. The path is a string of hash keys or array indexes starting with zero, separated by the path separator character (default "/"). The function goes through the structure by each path component and tries to return the value at the end of the path.
812
798
813
-
In addition to the required "path" argument the function accepts the default
814
-
argument. It will be returned if the path is not correct, no value was found or
815
-
a any other error have occurred. And the last argument can set the path
816
-
separator character.
799
+
In addition to the required path argument, the function accepts the default argument. It is returned if the path is not correct, if no value was found, or if any other error has occurred. The last argument can set the path separator character.
@@ -1171,7 +1152,7 @@ test, and the second argument should be a stringified regular expression (withou
1171
1152
1172
1153
#### `validate_slength`
1173
1154
1174
-
Validates that the first argument is a string (or an array of strings), and is less than or equal to the length of the second argument. It fails if the first argument is not a string or array of strings, or if arg 2 is not convertable to a number. Optionally, a minimum string length can be given as the third argument.
1155
+
Validates that the first argument is a string (or an array of strings), and is less than or equal to the length of the second argument. It fails if the first argument is not a string or array of strings, or if the second argument is not convertable to a number. Optionally, a minimum string length can be given as the third argument.
1175
1156
1176
1157
The following values pass:
1177
1158
@@ -1243,7 +1224,7 @@ Finds values inside an array based on location. The first argument is the array
1243
1224
1244
1225
Takes one element from first array given and merges corresponding elements from second array given. This generates a sequence of n-element arrays, where *n* is one more than the count of arguments. For example, `zip(['1','2','3'],['4','5','6'])` results in ["1", "4"], ["2", "5"], ["3", "6"]. *Type*: rvalue.
1245
1226
1246
-
##Limitations
1227
+
##Limitations
1247
1228
1248
1229
As of Puppet Enterprise 3.7, the stdlib module is no longer included in PE. PE users should install the most recent release of stdlib for compatibility with Puppet modules.
**stdlib 5.x**: When released, stdlib 5.x will drop support for Puppet 2.7.x. Please see [this discussion](https://github.com/puppetlabs/puppetlabs-stdlib/pull/176#issuecomment-30251414).
1261
1242
1262
-
##Development
1243
+
##Development
1263
1244
1264
-
Puppet Labs modules on the Puppet Forge are open projects, and community contributions are essential for keeping them great. We can’t access the huge number of platforms and myriad hardware, software, and deployment configurations that Puppet is intended to serve. We want to keep it as easy as possible to contribute changes so that our modules work in your environment. There are a few guidelines that we need contributors to follow so that we can have a chance of keeping on top of things. For more information, see our [module contribution guide.](https://docs.puppetlabs.com/forge/contributing.html)
1245
+
Puppet Labs modules on the Puppet Forge are open projects, and community contributions are essential for keeping them great. We can’t access the huge number of platforms and myriad hardware, software, and deployment configurations that Puppet is intended to serve. We want to keep it as easy as possible to contribute changes so that our modules work in your environment. There are a few guidelines that we need contributors to follow so that we can have a chance of keeping on top of things. For more information, see our [module contribution guide](https://docs.puppetlabs.com/forge/contributing.html).
1265
1246
1266
1247
To report or research a bug with any part of this module, please go to
The list of contributors can be found at: https://github.com/puppetlabs/puppetlabs-stdlib/graphs/contributors
1252
+
The list of contributors can be found at: [https://github.com/puppetlabs/puppetlabs-stdlib/graphs/contributors](https://github.com/puppetlabs/puppetlabs-stdlib/graphs/contributors).
0 commit comments