diff options
Diffstat (limited to 'README.md')
-rw-r--r-- | README.md | 129 |
1 files changed, 126 insertions, 3 deletions
@@ -115,6 +115,18 @@ file_line { 'bashrc_proxy': In the example above, `match` looks for a line beginning with 'export' followed by 'HTTP_PROXY' and replaces it with the value in line. +Match Example: + + file_line { 'bashrc_proxy': + ensure => present, + path => '/etc/bashrc', + line => 'export HTTP_PROXY=http://squid.puppetlabs.vm:3128', + match => '^export\ HTTP_PROXY\=', + append_on_no_match => false, + } + +In this code example, `match` looks for a line beginning with export followed by HTTP_PROXY and replaces it with the value in line. If a match is not found, then no changes are made to the file. + Match Example with `ensure => absent`: ```puppet @@ -289,6 +301,10 @@ Unacceptable input example: httds://notquiteright.org ``` +#### `Stdlib::MAC` + +Matches MAC addresses defined in [RFC5342](https://tools.ietf.org/html/rfc5342). + #### `Stdlib::Unixpath` Matches paths on Unix operating systems. @@ -469,9 +485,9 @@ Converts a Boolean to a number. Converts values: * `false`, 'f', '0', 'n', and 'no' to 0. * `true`, 't', '1', 'y', and 'yes' to 1. - Argument: a single Boolean or string as an input. +Argument: a single Boolean or string as an input. - *Type*: rvalue. +*Type*: rvalue. #### `bool2str` @@ -895,6 +911,31 @@ userlist: ensure_resources('user', hiera_hash('userlist'), {'ensure' => 'present'}) ``` +#### `fact` + +Return the value of a given fact. Supports the use of dot-notation for referring to structured facts. If a fact requested does not exist, returns Undef. + +Example usage: + +```puppet +fact('kernel') +fact('osfamily') +fact('os.architecture') +``` + +Array indexing: + +```puppet +$first_processor = fact('processors.models.0') +$second_processor = fact('processors.models.1') +``` + +Fact containing a "." in the fact name: + +```puppet +fact('vmware."VRA.version"') +``` + #### `flatten` Flattens deeply nested arrays and returns a single flat array as a result. @@ -1167,6 +1208,13 @@ Returns `true` if the string passed to this function is a syntactically correct *Type*: rvalue. +#### `is_email_address` + +Returns true if the string passed to this function is a valid email address. + +*Type*: rvalue. + + #### `is_float` **Deprecated. Will be removed in a future version of stdlib. See [`validate_legacy`](#validate_legacy).** @@ -1509,6 +1557,10 @@ For example, `reject(['aaa','bbb','ccc','aaaddd'], 'aaa')` returns ['bbb','ccc'] Reverses the order of a string or array. +#### `round` + + Rounds a number to the nearest integer + *Type*: rvalue. #### `rstrip` @@ -1702,6 +1754,30 @@ Arguments: A single string. *Type*: rvalue. +#### `to_json` + +Converts input into a JSON String. + +For example, `{ "key" => "value" }` becomes `{"key":"value"}`. + +*Type*: rvalue. + +#### `to_json_pretty` + +Converts input into a pretty JSON String. + +For example, `{ "key" => "value" }` becomes `{\n \"key\": \"value\"\n}`. + +*Type*: rvalue. + +#### `to_yaml` + +Converts input into a YAML String. + +For example, `{ "key" => "value" }` becomes `"---\nkey: value\n"`. + +*Type*: rvalue. + #### `try_get_value` **DEPRECATED:** replaced by `dig()`. @@ -1958,6 +2034,53 @@ validate_cmd($haproxycontent, '/usr/sbin/haproxy -f % -c', 'Haproxy failed to va *Type*: statement. +#### `validate_domain_name` + +**Deprecated. Will be removed in a future version of stdlib. See [`validate_legacy`](#validate_legacy).** + +Validate that all values passed are syntactically correct domain names. Aborts catalog compilation if any value fails this check. + +The following values pass: + +~~~ +$my_domain_name = 'server.domain.tld' +validate_domain_name($my_domain_name) +validate_domain_name('domain.tld', 'puppet.com', $my_domain_name) +~~~ + +The following values fail, causing compilation to abort: + +~~~ +validate_domain_name(1) +validate_domain_name(true) +validate_domain_name('invalid domain') +validate_domain_name('-foo.example.com') +validate_domain_name('www.example.2com') +~~~ + +*Type*: statement. + +#### `validate_email_address` + +Validate that all values passed are valid email addresses. Fail compilation if any value fails this check. + +The following values will pass: + +~~~ +$my_email = "waldo@gmail.com" +validate_email_address($my_email) +validate_email_address("bob@gmail.com", "alice@gmail.com", $my_email) +~~~ + +The following values will fail, causing compilation to abort: + +~~~ +$some_array = [ 'bad_email@/d/efdf.com' ] +validate_email_address($some_array) +~~~ + +*Type*: statement. + #### `validate_hash` **Deprecated. Will be removed in a future version of stdlib. See [`validate_legacy`](#validate_legacy).** @@ -2091,7 +2214,7 @@ Arguments: Example: ```puppet -validate_legacy("Optional[String]", "validate_re", "Value to be validated", ["."]) +validate_legacy('Optional[String]', 'validate_re', 'Value to be validated', ["."]) ``` This function supports updating modules from Puppet 3-style argument validation (using the stdlib `validate_*` functions) to Puppet 4 data types, without breaking functionality for those depending on Puppet 3-style validation. |