Commit graph

471 commits

Author SHA1 Message Date
David Schmitt
9224143da2 Merge pull request #618 from ntpttr/fix/master/modules-3568
(MODULES-3568) Move dig to dig44 and deprecate dig
2016-07-13 09:50:30 +01:00
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
David Schmitt
3f86e3a731 (MODULES-3543) Fixup defined_with_params to work on all puppet versions 2016-06-30 11:10:24 +01:00
David Schmitt
af875b11ff (MODULES-3543) Fix define_with_params to handle undef properly
As described in PUP-6422,

	ensure_resources('File[/tmp/a]', { owner => undef })

would not actually create the file. This fixes it, and adds tests to prove
it.
2016-06-29 21:33:00 +01:00
Bryan Jen
7b1250478c (MODULES-3507) Updates file_line path validation 2016-06-28 16:45:56 -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
Stephen Benjamin
f47df3b4b5 (MODULES-3354) Use 1.8.7 hash in validate_email_address function 2016-05-11 15:52:50 -04:00
Bryan Jen
b2165dfc34 Merge pull request #601 from petems/MODULES-1439-any2bool_added
(MODULES-1439) Adds any2bool function
2016-05-05 10:13:10 -07: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
Peter Souter
420f76d8dc (MODULES-1439) Adds any2bool function
* Basically a combination of `string2bool` and `num2bool`
2016-05-02 20:04:56 +01: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
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
David Schmitt
79c871322f (MODULES-3271) Ensure that is_email_address works on unsupported rubies 2016-04-18 09:46:30 +01:00
Joseph Yaworski
0d46515b57 Add support for regular expressions to delete 2016-04-12 13:10:39 -04:00
Hunter Haugen
e3a6e2c601 Merge pull request #590 from alext/fix_concat_with_hash
(MODULES-3246) Fix concat with Hash arguments.
2016-04-11 15:02:58 -07:00
TP Honey
60864fd39b Merge pull request #583 from jyaworski/validate_email_address
Add validate_email_address function
2016-04-11 16:04:25 +01:00
Joseph Yaworski
bfe6cf68b3 Add validate_email_address function 2016-04-10 22:28:03 -04:00
Alex Tomlins
44596e73da (MODULES-3246) Fix concat with Hash arguments.
85d5ead Updated the concat function so that it wouldn't modify the
original array. A side-effect of this change is that it now always calls
`Array()` on the second argument. If thit is a Hash, this results in
`to_a` being called on the hash, which converts it to an array or
tuples. This is undesired.

Update the behaviour so that it doesn't (indirectly) call `to_a` on
anything, instead test for the type of the argument, wrapping it in an
array if it's not already an array.
2016-04-08 13:42:13 +01:00
Hunter Haugen
be1ff3f09e Merge pull request #585 from jearls/MODULES-2370-update-validate-to-not-require-line-when-matching-for-absence
[MODULES-2370] file_line.rb: Fix `line` attribute validation
2016-04-07 15:10:07 -07:00
David Schmitt
5639828bff (maint) also catch Psych::SyntaxError
Psych::SyntaxError is a RuntimeException. This still needs to
catch that. This was uncovered by the recent move to catch StandardError
rather than the catchall Exception that was here before.
2016-04-07 12:31:06 +01:00
Felix Frank
0cea94a82e catch StandardError rather than the gratuitous Exception 2016-03-29 01:59:54 +02:00
Johnson Earls
7e408ca797 [MODULES-2370] file_line.rb: Fix line attribute validation
`file_line` type: During validation, do not require `line` attribute if:
* `ensure` is `absent`,
* `match` is not empty,
* and `match_for_absence` is `true`.

Also update `spec` tests to reflect this.
2016-03-28 21:26:01 +00:00
Bryan Jen
b63849c786 Merge pull request #579 from sulaweyo/patch-2
Add check if Gem is defined
2016-03-28 11:44:00 -07: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
Sledge Sulaweyo
be6d4d2ffb Add check if Gem is defined
On e.g. Ubuntu 12.04 LTS Gem is not there by default so i added a check to not fail in that fact if this is the case.
2016-03-17 07:36:44 +01: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
Matt Bostock
b7df76cf7a Fix reference to validate_bool in function
The documentation in `validate_ip_address` references `validate_bool`,
but I believe this should read `validate_ip_address` instead, which
makes more sense.

Looks like this was copied from `validate_ipv4_address`, which I fixed
in 7b068781.
2016-01-19 16:22:01 +00: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
Bryan Jen
0073c6d8de Merge pull request #553 from logicminds/absolute_path
adds new parser called is_absolute_path
2015-12-21 17:41:55 -07:00
David Schmitt
35b5d6bcc1 Allow package_provider fact to resolve on PE 3.x
PE 3.x emits a puppetversion fact in the format "3.x.x (Puppet Enterprise 3.x.x)". This fact causes an error when invoked on PE 3.x: Could not retrieve fact='package_provider', resolution='<anonymous>': Malformed version number string 3.8.1 (Puppet Enterprise 3.8.1

This fix has been tested on PE 3.8.2 and should work for PE 3.3, 3.7, and 3.8.

Original-fix-by: Alex Harden <aharden@gmail.com>
2015-12-18 17:38:04 +00:00
Corey Osman
1da820e61e refactors the validate_absolute_path to utilize the is_absolute_path 2015-12-15 23:24:17 -08: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
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
Bryan Jen
88a9a314c3 Merge pull request #546 from jdevesa/validate_ip
Add validator for any IP address
2015-11-30 11:10:57 -07: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
Matt Bostock
7b068781a5 Fix reference to validate_bool in IP4 function
The documentation in `validate_ipv4_address` references `validate_bool`,
but I believe this should read `validate_ipv4_address` instead, which
makes more sense.
2015-11-23 23:45:55 +00:00
Reid Vandewiele
13e5d467c9 (FM-3773) Fix root_home fact on AIX 5.x
The -C (capital C) flag to lsuser is incorrect. It should be -c
(lowercase).

this commit updates the aix root_home fact to use `lsuser -c`, rather
than `lsuser -C`.
2015-11-19 15:44:52 -08: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