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
+37-37Lines changed: 37 additions & 37 deletions
Original file line number
Diff line number
Diff line change
@@ -14,7 +14,7 @@
14
14
15
15
##Overview
16
16
17
-
Adds a standard library of resources for Puppet modules.
17
+
Adds a standard library of resources for Puppet modules.
18
18
19
19
##Module Description
20
20
@@ -27,22 +27,22 @@ modules. Puppet modules make heavy use of this standard library. The stdlib modu
27
27
* Defined resource types
28
28
* Types
29
29
* Providers
30
-
30
+
31
31
> *Note:* As of version 3.7, Puppet Enterprise no longer includes the stdlib module. If you're running Puppet Enterprise, you should install the most recent release of stdlib for compatibility with Puppet modules.
32
32
33
33
##Setup
34
34
35
-
Installing the stdlib module adds the functions, facts, and resources of this standard library to Puppet.
35
+
Installing the stdlib module adds the functions, facts, and resources of this standard library to Puppet.
36
36
37
37
##Usage
38
38
39
-
After you've installed stdlib, all of its functions, facts, and resources are available for module use or development.
39
+
After you've installed stdlib, all of its functions, facts, and resources are available for module use or development.
40
40
41
-
If you want to use a standardized set of run stages for Puppet, `include stdlib` in your manifest.
41
+
If you want to use a standardized set of run stages for Puppet, `include stdlib` in your manifest.
42
42
43
43
## Reference
44
44
45
-
### Classes
45
+
### Classes
46
46
47
47
#### Public Classes
48
48
@@ -75,11 +75,11 @@ If you want to use a standardized set of run stages for Puppet, `include stdlib`
75
75
class { java: stage => 'runtime' }
76
76
}
77
77
```
78
-
78
+
79
79
### Resources
80
80
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
-
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
83
```
84
84
file_line { 'sudo_rule':
85
85
path => '/etc/sudoers',
@@ -90,15 +90,15 @@ If you want to use a standardized set of run stages for Puppet, `include stdlib`
90
90
line => '%sudonopw ALL=(ALL) NOPASSWD: ALL',
91
91
}
92
92
```
93
-
93
+
94
94
*`after`: Specify the line after which Puppet will add any new lines. (Existing lines are added in place.) Optional.
95
95
*`ensure`: Ensures whether the resource is present. Valid values are 'present', 'absent'.
96
96
*`line`: The line to be added to the file located by the `path` parameter.
97
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
98
*`multiple`: Determine if match can change multiple lines. Valid values are 'true', 'false'. Optional.
99
99
*`name`: An arbitrary name used as the identity of the resource.
100
100
*`path`: The file in which Puppet will ensure the line specified by the line parameter.
101
-
101
+
102
102
### Functions
103
103
104
104
*`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
@@ -144,11 +144,11 @@ strings; for example, 'hello\n' becomes 'hello'. Requires a single string or arr
144
144
user { 'dan': ensure => present, }
145
145
}
146
146
```
147
-
147
+
148
148
*Type*: rvalue
149
149
150
150
*`delete`: Deletes all instances of a given element from an array, substring from a
151
-
string, or key from a hash. For example, `delete(['a','b','c','b'], 'b')` returns ['a','c']; `delete('abracadabra', 'bra')` returns 'acada'. *Type*: rvalue
151
+
string, or key from a hash. For example, `delete(['a','b','c','b'], 'b')` returns ['a','c']; `delete('abracadabra', 'bra')` returns 'acada'. `delete({'a' => 1,'b' => 2,'c' => 3},['b','c'])` returns {'a'=> 1} *Type*: rvalue
152
152
153
153
*`delete_at`: Deletes a determined indexed value from an array. For example, `delete_at(['a','b','c'], 1)` returns ['a','c']. *Type*: rvalue
154
154
@@ -252,7 +252,7 @@ returns the value of the resource's parameter. For example, the following code r
*`prefix`: This function applies a prefix to all elements in an array. For example, `prefix(['a','b','c'], 'p')` returns ['pa','pb','pc']. *Type*: rvalue
@@ -366,9 +366,9 @@ Calling the class or definition from outside the current module will fail. For e
366
366
```
367
367
Class foo::bar is private
368
368
```
369
-
369
+
370
370
You can specify the error message you want to use:
371
-
371
+
372
372
```
373
373
private("You're not supposed to do that!")
374
374
```
@@ -377,8 +377,8 @@ Calling the class or definition from outside the current module will fail. For e
377
377
378
378
*`range`: When given range in the form of '(start, stop)', `range` extrapolates a range as an array. For example, `range("0", "9")` returns [0,1,2,3,4,5,6,7,8,9]. Zero-padded strings are converted to integers automatically, so `range("00", "09")` returns [0,1,2,3,4,5,6,7,8,9].
379
379
380
-
Non-integer strings are accepted; `range("a", "c")` returns ["a","b","c"], and `range("host01", "host10")` returns ["host01", "host02", ..., "host09", "host10"].
381
-
380
+
Non-integer strings are accepted; `range("a", "c")` returns ["a","b","c"], and `range("host01", "host10")` returns ["host01", "host02", ..., "host09", "host10"].
381
+
382
382
*Type*: rvalue
383
383
384
384
*`reject`: This function searches through an array and rejects all elements that match the provided regular expression. For example, `reject(['aaa','bbb','ccc','aaaddd'], 'aaa')` returns ['bbb','ccc']. *Type*: rvalue
@@ -403,7 +403,7 @@ manifests as a valid password attribute. *Type*: rvalue
403
403
*`strftime`: This function returns formatted time. For example, `strftime("%s")` returns the time since epoch, and `strftime("%Y=%m-%d")` returns the date. *Type*: rvalue
404
404
405
405
*Format:*
406
-
406
+
407
407
*`%a`: The abbreviated weekday name ('Sun')
408
408
*`%A`: The full weekday name ('Sunday')
409
409
*`%b`: The abbreviated month name ('Jan')
@@ -501,9 +501,9 @@ You can also use this with arrays. For example, `unique(["a","a","b","b","c","c"
501
501
validate_absolute_path($undefined)
502
502
```
503
503
504
-
*Type*: statement
504
+
*Type*: statement
505
505
506
-
* `validate_array`: Validate that all passed values are array data structures. Abort catalog compilation if any value fails this check.
506
+
* `validate_array`: Validate that all passed values are array data structures. Abort catalog compilation if any value fails this check.
507
507
508
508
The following values will pass:
509
509
@@ -533,13 +533,13 @@ The first argument of this function should be the string to test, and the second
You can pass a fourth argument as the error message raised and shown to the user:
544
544
545
545
```
@@ -551,13 +551,13 @@ The first argument of this function should be the string to test, and the second
551
551
* `validate_bool`: Validate that all passed values are either true or false. Abort catalog compilation if any value fails this check.
552
552
553
553
The following values will pass:
554
-
554
+
555
555
```
556
556
$iamtrue = true
557
557
validate_bool(true)
558
558
validate_bool(true, true, false, $iamtrue)
559
559
```
560
-
560
+
561
561
The following values will fail, causing compilation to abort:
562
562
563
563
```
@@ -576,7 +576,7 @@ The first argument of this function should be the string to test, and the second
576
576
```
577
577
validate_cmd($sudoerscontent, '/usr/sbin/visudo -c -f', 'Visudo failed to validate sudoers content')
578
578
```
579
-
579
+
580
580
*Type*: statement
581
581
582
582
* `validate_hash`: Validates that all passed values are hash data structures. Abort catalog compilation if any value fails this check.
@@ -596,7 +596,7 @@ The first argument of this function should be the string to test, and the second
596
596
$undefined = undef
597
597
validate_hash($undefined)
598
598
```
599
-
599
+
600
600
*Type*: statement
601
601
602
602
* `validate_re`: Performs simple validation of a string against one or more regular expressions. The first argument of this function should be the string to
@@ -619,8 +619,8 @@ of the regular expressions match the string passed in, compilation aborts with a
619
619
validate_re('one', [ '^two', '^three' ])
620
620
```
621
621
622
-
To set the error message:
623
-
622
+
To set the error message:
623
+
624
624
```
625
625
validate_re($::puppetversion, '^2.7', 'The $puppetversion fact value does not match 2.7')
626
626
```
@@ -630,19 +630,19 @@ of the regular expressions match the string passed in, compilation aborts with a
630
630
* `validate_slength`: 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.
0 commit comments