Commit graph

148 commits

Author SHA1 Message Date
Nate Potter
a2f980d44d (MODULES-3568) Move dig to dig44 and deprecate dig
A new version of dig was introduced in Puppet 4.5.0 that
isn't compatible with the stdlib version of dig. To maintain
backwards compatibility and ensure that tests for stdlib aren't
broken, this patch renames dig to dig44 and adds a deprecation
warning to the stdlib dig function.
2016-07-08 08:53:24 -07:00
Joseph Yaworski
dd71c02880 Add a delete_regex function
To maintain backwards compatibility, add a delete_regex function instead
of modifying delete itself.
2016-05-13 13:25:35 -04:00
Bryan Jen
ecfdbb2690 Merge pull request #600 from dmitryilyin/master
Add the default value to the "loadyaml" function
2016-05-12 14:14:14 -07:00
bob
8f1efdad22 Add a missing s in the ensure_packages hash example 2016-05-11 10:52:25 +01:00
Joseph Yaworski
540546b9b4 Use reject instead of delete_if 2016-05-04 11:32:10 -04:00
Bryan Jen
f48747b8af Merge pull request #603 from puppetlabs/4.12.x
Mergeback 4.12.x
2016-05-03 15:09:33 -07:00
Joris
9e1f74f3fc Expose the functions of ruby's built-in Shellwords module (#580)
* Add shell_escape function, shell_join function & shell_split function
2016-04-28 18:44:30 +01:00
Hunter Haugen
db6e2f81b4 Remove hard linebreaks 2016-04-27 15:34:19 -07:00
Dmitry Ilyin
870a272cee Add the default value to the "loadyaml" function
This value will be returned if the is no file
to load or a file could not be parsed.
It's similar to the "parseyaml" function's
default value.

Add the "loadjson" function too
2016-04-26 21:58:29 +03:00
Hunter Haugen
232de137f1 Revert "Add support for regular expressions to delete"
This reverts commit 0d46515b57.

It introduced backwards-incompatible functionality.
2016-04-25 14:33:43 -07:00
Joseph Yaworski
0d46515b57 Add support for regular expressions to delete 2016-04-12 13:10:39 -04:00
Reinhard Vicinus
85ff2a28a8 improve suffix function to support the same feature set as prefix 2016-03-22 16:24:09 +01:00
Hunter Haugen
b6383d259c Merge pull request #576 from yadavnikhil/master
ensure_packages.rb: Modifed to pass hiera parameters (as hash,array) as first argument
2016-03-17 09:25:38 -07:00
Nikhil Yadav
0da9ca7e4a Add ensure_resources() function
New function "ensure_resources()" to support passing hash as parameter OR from hiera backend

This new function is extension of ensure_resource() which will now support to pass multiple values as hash/array OR from hiera backend variables in title argument with additional parameters needed.

It will
process multiple values for a resource type from the passed argument & pass each entry (type, title, params) to ensure_resource() in required format for further processing.
Now user can have duplicate resource check functionality extended to multiple entries with this new function.

Use:
For multiple resources using
hash:
ensure_resources('user', {'dan' => { gid => 'mygroup', uid =>'600' } ,  'alex' => { gid => 'mygroup' }}, {'ensure' =>'present'})

From Hiera Backend:

userlist:
  dan:
    gid: 'mygroup'

uid: '600'
  alex:
 gid: 'mygroup'

Call:
ensure_resources('user',hiera_hash('userlist'), {'ensure' => 'present'})

ensure_packages()
Modified to also support Hash type argument for packages

This modification will call newly added ensure_resources() for processing Hash as second argument.
The original functionality remains same for Array type arguments.

Use:
hiera:

packagelist:
  ksh:
    ensure: latest
  mlocate: {}
  myrpm:
    provider: rpm
    source: "/tmp/myrpm-1.0.0.x86_64.rpm"
    install_options:
      --prefix:
        /users/home
  openssl:
    provider: rpm
    source: "/tmp/openssl-1.0.1e-42.el7.x86_64.rpm"

Call:
ensure_packages($packagelist)
2016-03-15 09:29:38 +05:30
Emilien Macchi
0378336f9c Add enclose_ipv6 function
Copy a function from puppetlabs/apache, created by Benedikt Bock by
55cc3b4e8f4bc859a1255cb57be2c7923005d822 .

This function enclose IPv6 addresses in square brackets.
It takes an array of ip addresses and encloses the ipv6 addresses with
square brackets.

Co-Authored-By: Benedikt Bock <benedikt_bock@web.de>
2016-03-13 18:20:49 -04:00
Hunter Haugen
69ca8d09c6 Merge pull request #570 from gfidente/master
Add is_ipv4_address and is_ipv6_address functions
2016-02-18 10:32:25 -08:00
guessi
dc64e721ee Extend Base64() function support 2016-02-18 23:38:19 +08:00
Maksym Melnychok
3169a43f4c Add dig() function
Deprecates #try_get_value()
2016-02-16 00:51:28 -08:00
Giulio Fidente
d85aec41a3 Add is_ipv4_address and is_ipv6_address functions
These are useful when making decisions based on the type of IP
address received.
2016-01-22 18:01:49 +01:00
David Schmitt
f875770245 Merge pull request #552 from mattbostock/add_x509_rsa_key_pair
Add a function to validate an x509 RSA key pair
2016-01-08 11:13:16 +00:00
Matt Bostock
97320ab421 Add a function to validate an x509 RSA key pair
Add a function to validate an x509 RSA certificate and key pair, as
commonly used for TLS certificates.

The rationale behind this is that we store our TLS certificates and
private keys in Hiera YAML files, and poor indentation or formatting in
the YAML file could cause a valid certificate to be considered invalid.

Will cause the Puppet run to fail if:

- an invalid certificate is detected
- an invalid RSA key is detected
- the certificate does not match the key, i.e. the certificate
  has not been signed by the supplied key

The test certificates I've used in the spec tests were generated using
the Go standard library:

    $ go run $GOROOT/src/crypto/tls/generate_cert.go -host localhost

Example output:

    ==> cache-1.router: Error: Not a valid RSA key: Neither PUB key nor PRIV key:: nested asn1 error at /var/govuk/puppet/modules/nginx/manifests/config/ssl.pp:30 on node cache-1.router.dev.gov.uk
2016-01-08 11:09:45 +00:00
David Schmitt
9cce93054a Merge pull request #545 from mpolenchuk/master
Add clamp function
2016-01-04 15:35:42 +00:00
Michael Polenchuk
27782242bc Add clamp function
Clamp keeps value within the range.
Employ of soft() makes the whole thing is independant of order.
2015-12-31 12:46:07 +03:00
Corey Osman
1b048ff9d6 adds new parser called is_absolute_path
* is_absolute_path returns boolean true if the given path
    is absolute, returns false otherwise.
  * works for windows and unix
2015-12-15 23:24:17 -08:00
jbondpdx
8fcefcfdb1 more carriage returns 2015-12-14 13:35:23 -08:00
jbondpdx
802e3adf16 more carriage returns, no 2015-12-14 11:57:01 -08:00
jbondpdx
d00bccc96f removing mid-line carriage returns 2015-12-14 11:50:51 -08:00
jbondpdx
4abc6e6e3b edits to README 2015-12-14 11:19:53 -08:00
Kjetil Torgrim Homme
8aecd63378 (#2886) seeded_rand: new function
seeded_rand is needed for repeatable randomness across nodes in a cluster
2015-12-08 14:59:12 +01:00
Jaume Devesa
fe23e01a4b Add validator for any IP address
Provide a validator for IP addresses, regardless they are IPv4 or IPv6,
and its documentation.
2015-11-30 17:34:00 +01:00
Helen Campbell
99db982741 pick_default addition to readme 2015-11-09 15:14:34 +00:00
Matt Flaschen
1421aa4a87 Fix capitalize docs
Capitalize lower-cases the remaining characters (due to the Ruby function having this behavior); document this, and make minor wording tweaks.
2015-10-27 18:09:18 -04:00
marrero984
2c3c6fde98 (#2183) updated str2bool readme wording 2015-10-22 14:02:13 -07:00
David Schmitt
2db7440c67 Merge pull request #538 from mmckinst/bool2str_enhance
add functionality to bool2str function
2015-10-16 09:31:01 +01:00
Mark McKinstry
6de1a6e062 add functionality to bool2str to return strings of your choice for a boolean 2015-10-15 22:22:10 -04:00
Colleen Murphy
25410c4598 Let load_module_metadata succeed on empty file
Some modules or module versions don't have a metadata.json file, but we
might still want to use the load_module_metadata function on them. The
lack of a file can still give us important information. For example, it
might tell us that the version of the module installed is "very old"
even if we can't read the version number directly. This patch adds a
parameter to let the user specify if an empty file is acceptable. To
preserve backwards compatibility it does not change the current default
behavior, which is to raise an error if metadata.json does not exist.
2015-10-14 16:16:01 -07:00
David Schmitt
ad173f2d05 (MODULES-2421) improve description of file_line
This mostly needed extraction of the existing doc strings from
the type.
2015-10-13 15:03:26 +01:00
Helen Campbell
c7c4d41a82 Added acceptance test and updated readme 2015-09-28 16:18:56 +01:00
David Schmitt
bfa21edbae (FM-3701) Update README for is_a 2015-09-28 11:12:25 +01:00
Helen Campbell
92b068ad20 Adding update to empty function readme 2015-09-23 11:27:48 +01:00
David Schmitt
55ece7815a (MAINT) validate_re: Clarify docs and error message 2015-09-17 18:48:32 +01:00
Bryan Jen
0ea0e40228 Merge pull request #523 from DavidS/modules-2516-is_a
(MODULES-2561) add is_a function
2015-09-14 10:49:50 -07:00
Bryan Jen
c0df8192ee Merge pull request #511 from dmitryilyin/parseyaml_default
[MODULES-2462] Improve parseyaml function
2015-09-14 10:40:35 -07:00
David Schmitt
00c881d0da (MODULES-2516) Adds an is_a() function
The data type system is very hard to understand. Many people don't
understand why

    type_of([1,2,3]) == Array

will fail, but

    type_of([1,2,3]) <= Array

passes. This does a simpler validation that doesn't rely on explicit
data types. Instead, use

    $foo = [1,2,3]
    if $foo.is_a(Array) {
      notify { 'This is an array': }
    }

This is based on code by Ben Ford <ben.ford@puppetlabs.com>.

  * Added acceptance tests
  * Added dispatch
  * Improved unit tests
  * Added docs to README
2015-09-14 18:26:25 +01:00
TP Honey
2a7a93ffb4 Merge pull request #518 from logicminds/case_insensitive
accept any case of boolean strings
2015-09-09 11:20:18 +01:00
Dmitry Ilyin
411978db32 [MAINT] Improve 'try_get_value' readme 2015-09-04 19:24:15 +03:00
Corey Osman
f2f2db4795 accept any case of boolean strings
* previously the str2bool function did not accept 'TRUE' as a bool
    type.  This causes the function to now accept TRUE, FALSE strings
    as a boolean type in order to be converted to a proper boolean.
  * This would also cause Y,N, YES, NO to be accepted as boolean types
    as well.
2015-09-04 08:09:26 -07:00
David Schmitt
64267eb650 Merge pull request #513 from dmitryilyin/fetch
Add a new function "try_get_value"
2015-09-02 09:23:46 +01:00
Dmitry Ilyin
823a352f0f Add a new function "try_get_value"
* Extracts a value from a deeply-nested data structure
* Returns default if a value could not be extracted
2015-09-01 21:45:44 +03:00
fhats
2d4f5aa4d9 Adds a convert_base function, which can convert numbers between bases
Squashed, improved docs, updated error handling and unit tests by David S.
2015-08-27 10:42:13 +01:00