Convert modules/stdlib to a submodule
This commit is contained in:
parent
56157d3496
commit
8fd68aa0a1
350 changed files with 4 additions and 15555 deletions
3
.gitmodules
vendored
3
.gitmodules
vendored
|
@ -22,3 +22,6 @@
|
|||
[submodule "modules/systemd"]
|
||||
path = modules/systemd
|
||||
url = https://github.com/camptocamp/puppet-systemd
|
||||
[submodule "modules/stdlib"]
|
||||
path = modules/stdlib
|
||||
url = https://github.com/puppetlabs/puppetlabs-stdlib.git
|
||||
|
|
1
modules/stdlib
Submodule
1
modules/stdlib
Submodule
|
@ -0,0 +1 @@
|
|||
Subproject commit e8fb6917d102d8a45d5682b79f33b1ac0d52d73b
|
|
@ -1,418 +0,0 @@
|
|||
##2014-06-04 - Release 4.2.2
|
||||
### Summary
|
||||
|
||||
This release adds PE3.3 support in the metadata and fixes a few tests.
|
||||
|
||||
## 2014-05-08 - Release - 4.2.1
|
||||
### Summary
|
||||
This release moves a stray symlink that can cause problems.
|
||||
|
||||
## 2014-05-08 - Release - 4.2.0
|
||||
### Summary
|
||||
This release adds many new functions and fixes, and continues to be backwards compatible with stdlib 3.x
|
||||
|
||||
#### Features
|
||||
- New `base64()` function
|
||||
- New `deep_merge()` function
|
||||
- New `delete_undef_values()` function
|
||||
- New `delete_values()` function
|
||||
- New `difference()` function
|
||||
- New `intersection()` function
|
||||
- New `is_bool()` function
|
||||
- New `pick_default()` function
|
||||
- New `union()` function
|
||||
- New `validate_ipv4_address` function
|
||||
- New `validate_ipv6_address` function
|
||||
- Update `ensure_packages()` to take an option hash as a second parameter.
|
||||
- Update `range()` to take an optional third argument for range step
|
||||
- Update `validate_slength()` to take an optional third argument for minimum length
|
||||
- Update `file_line` resource to take `after` and `multiple` attributes
|
||||
|
||||
#### Bugfixes
|
||||
- Correct `is_string`, `is_domain_name`, `is_array`, `is_float`, and `is_function_available` for parsing odd types such as bools and hashes.
|
||||
- Allow facts.d facts to contain `=` in the value
|
||||
- Fix `root_home` fact on darwin systems
|
||||
- Fix `concat()` to work with a second non-array argument
|
||||
- Fix `floor()` to work with integer strings
|
||||
- Fix `is_integer()` to return true if passed integer strings
|
||||
- Fix `is_numeric()` to return true if passed integer strings
|
||||
- Fix `merge()` to work with empty strings
|
||||
- Fix `pick()` to raise the correct error type
|
||||
- Fix `uriescape()` to use the default URI.escape list
|
||||
- Add/update unit & acceptance tests.
|
||||
|
||||
|
||||
##2014-03-04 - Supported Release - 3.2.1
|
||||
###Summary
|
||||
This is a supported release
|
||||
|
||||
####Bugfixes
|
||||
- Fixed `is_integer`/`is_float`/`is_numeric` for checking the value of arithmatic expressions.
|
||||
|
||||
####Known bugs
|
||||
* No known bugs
|
||||
|
||||
---
|
||||
|
||||
##### 2013-05-06 - Jeff McCune <jeff@puppetlabs.com> - 4.1.0
|
||||
|
||||
* (#20582) Restore facter\_dot\_d to stdlib for PE users (3b887c8)
|
||||
* (maint) Update Gemfile with GEM\_FACTER\_VERSION (f44d535)
|
||||
|
||||
##### 2013-05-06 - Alex Cline <acline@us.ibm.com> - 4.1.0
|
||||
|
||||
* Terser method of string to array conversion courtesy of ethooz. (d38bce0)
|
||||
|
||||
##### 2013-05-06 - Alex Cline <acline@us.ibm.com> 4.1.0
|
||||
|
||||
* Refactor ensure\_resource expectations (b33cc24)
|
||||
|
||||
##### 2013-05-06 - Alex Cline <acline@us.ibm.com> 4.1.0
|
||||
|
||||
* Changed str-to-array conversion and removed abbreviation. (de253db)
|
||||
|
||||
##### 2013-05-03 - Alex Cline <acline@us.ibm.com> 4.1.0
|
||||
|
||||
* (#20548) Allow an array of resource titles to be passed into the ensure\_resource function (e08734a)
|
||||
|
||||
##### 2013-05-02 - Raphaël Pinson <raphael.pinson@camptocamp.com> - 4.1.0
|
||||
|
||||
* Add a dirname function (2ba9e47)
|
||||
|
||||
##### 2013-04-29 - Mark Smith-Guerrero <msmithgu@gmail.com> - 4.1.0
|
||||
|
||||
* (maint) Fix a small typo in hash() description (928036a)
|
||||
|
||||
##### 2013-04-12 - Jeff McCune <jeff@puppetlabs.com> - 4.0.2
|
||||
|
||||
* Update user information in gemspec to make the intent of the Gem clear.
|
||||
|
||||
##### 2013-04-11 - Jeff McCune <jeff@puppetlabs.com> - 4.0.1
|
||||
|
||||
* Fix README function documentation (ab3e30c)
|
||||
|
||||
##### 2013-04-11 - Jeff McCune <jeff@puppetlabs.com> - 4.0.0
|
||||
|
||||
* stdlib 4.0 drops support with Puppet 2.7
|
||||
* stdlib 4.0 preserves support with Puppet 3
|
||||
|
||||
##### 2013-04-11 - Jeff McCune <jeff@puppetlabs.com> - 4.0.0
|
||||
|
||||
* Add ability to use puppet from git via bundler (9c5805f)
|
||||
|
||||
##### 2013-04-10 - Jeff McCune <jeff@puppetlabs.com> - 4.0.0
|
||||
|
||||
* (maint) Make stdlib usable as a Ruby GEM (e81a45e)
|
||||
|
||||
##### 2013-04-10 - Erik Dalén <dalen@spotify.com> - 4.0.0
|
||||
|
||||
* Add a count function (f28550e)
|
||||
|
||||
##### 2013-03-31 - Amos Shapira <ashapira@atlassian.com> - 4.0.0
|
||||
|
||||
* (#19998) Implement any2array (7a2fb80)
|
||||
|
||||
##### 2013-03-29 - Steve Huff <shuff@vecna.org> - 4.0.0
|
||||
|
||||
* (19864) num2bool match fix (8d217f0)
|
||||
|
||||
##### 2013-03-20 - Erik Dalén <dalen@spotify.com> - 4.0.0
|
||||
|
||||
* Allow comparisons of Numeric and number as String (ff5dd5d)
|
||||
|
||||
##### 2013-03-26 - Richard Soderberg <rsoderberg@mozilla.com> - 4.0.0
|
||||
|
||||
* add suffix function to accompany the prefix function (88a93ac)
|
||||
|
||||
##### 2013-03-19 - Kristof Willaert <kristof.willaert@gmail.com> - 4.0.0
|
||||
|
||||
* Add floor function implementation and unit tests (0527341)
|
||||
|
||||
##### 2012-04-03 - Eric Shamow <eric@puppetlabs.com> - 4.0.0
|
||||
|
||||
* (#13610) Add is\_function\_available to stdlib (961dcab)
|
||||
|
||||
##### 2012-12-17 - Justin Lambert <jlambert@eml.cc> - 4.0.0
|
||||
|
||||
* str2bool should return a boolean if called with a boolean (5d5a4d4)
|
||||
|
||||
##### 2012-10-23 - Uwe Stuehler <ustuehler@team.mobile.de> - 4.0.0
|
||||
|
||||
* Fix number of arguments check in flatten() (e80207b)
|
||||
|
||||
##### 2013-03-11 - Jeff McCune <jeff@puppetlabs.com> - 4.0.0
|
||||
|
||||
* Add contributing document (96e19d0)
|
||||
|
||||
##### 2013-03-04 - Raphaël Pinson <raphael.pinson@camptocamp.com> - 4.0.0
|
||||
|
||||
* Add missing documentation for validate\_augeas and validate\_cmd to README.markdown (a1510a1)
|
||||
|
||||
##### 2013-02-14 - Joshua Hoblitt <jhoblitt@cpan.org> - 4.0.0
|
||||
|
||||
* (#19272) Add has\_element() function (95cf3fe)
|
||||
|
||||
##### 2013-02-07 - Raphaël Pinson <raphael.pinson@camptocamp.com> - 4.0.0
|
||||
|
||||
* validate\_cmd(): Use Puppet::Util::Execution.execute when available (69248df)
|
||||
|
||||
##### 2012-12-06 - Raphaël Pinson <raphink@gmail.com> - 4.0.0
|
||||
|
||||
* Add validate\_augeas function (3a97c23)
|
||||
|
||||
##### 2012-12-06 - Raphaël Pinson <raphink@gmail.com> - 4.0.0
|
||||
|
||||
* Add validate\_cmd function (6902cc5)
|
||||
|
||||
##### 2013-01-14 - David Schmitt <david@dasz.at> - 4.0.0
|
||||
|
||||
* Add geppetto project definition (b3fc0a3)
|
||||
|
||||
##### 2013-01-02 - Jaka Hudoklin <jakahudoklin@gmail.com> - 4.0.0
|
||||
|
||||
* Add getparam function to get defined resource parameters (20e0e07)
|
||||
|
||||
##### 2013-01-05 - Jeff McCune <jeff@puppetlabs.com> - 4.0.0
|
||||
|
||||
* (maint) Add Travis CI Support (d082046)
|
||||
|
||||
##### 2012-12-04 - Jeff McCune <jeff@puppetlabs.com> - 4.0.0
|
||||
|
||||
* Clarify that stdlib 3 supports Puppet 3 (3a6085f)
|
||||
|
||||
##### 2012-11-30 - Erik Dalén <dalen@spotify.com> - 4.0.0
|
||||
|
||||
* maint: style guideline fixes (7742e5f)
|
||||
|
||||
##### 2012-11-09 - James Fryman <james@frymanet.com> - 4.0.0
|
||||
|
||||
* puppet-lint cleanup (88acc52)
|
||||
|
||||
##### 2012-11-06 - Joe Julian <me@joejulian.name> - 4.0.0
|
||||
|
||||
* Add function, uriescape, to URI.escape strings. Redmine #17459 (fd52b8d)
|
||||
|
||||
##### 2012-09-18 - Chad Metcalf <chad@wibidata.com> - 3.2.0
|
||||
|
||||
* Add an ensure\_packages function. (8a8c09e)
|
||||
|
||||
##### 2012-11-23 - Erik Dalén <dalen@spotify.com> - 3.2.0
|
||||
|
||||
* (#17797) min() and max() functions (9954133)
|
||||
|
||||
##### 2012-05-23 - Peter Meier <peter.meier@immerda.ch> - 3.2.0
|
||||
|
||||
* (#14670) autorequire a file\_line resource's path (dfcee63)
|
||||
|
||||
##### 2012-11-19 - Joshua Harlan Lifton <lifton@puppetlabs.com> - 3.2.0
|
||||
|
||||
* Add join\_keys\_to\_values function (ee0f2b3)
|
||||
|
||||
##### 2012-11-17 - Joshua Harlan Lifton <lifton@puppetlabs.com> - 3.2.0
|
||||
|
||||
* Extend delete function for strings and hashes (7322e4d)
|
||||
|
||||
##### 2012-08-03 - Gary Larizza <gary@puppetlabs.com> - 3.2.0
|
||||
|
||||
* Add the pick() function (ba6dd13)
|
||||
|
||||
##### 2012-03-20 - Wil Cooley <wcooley@pdx.edu> - 3.2.0
|
||||
|
||||
* (#13974) Add predicate functions for interface facts (f819417)
|
||||
|
||||
##### 2012-11-06 - Joe Julian <me@joejulian.name> - 3.2.0
|
||||
|
||||
* Add function, uriescape, to URI.escape strings. Redmine #17459 (70f4a0e)
|
||||
|
||||
##### 2012-10-25 - Jeff McCune <jeff@puppetlabs.com> - 3.1.1
|
||||
|
||||
* (maint) Fix spec failures resulting from Facter API changes (97f836f)
|
||||
|
||||
##### 2012-10-23 - Matthaus Owens <matthaus@puppetlabs.com> - 3.1.0
|
||||
|
||||
* Add PE facts to stdlib (cdf3b05)
|
||||
|
||||
##### 2012-08-16 - Jeff McCune <jeff@puppetlabs.com> - 3.0.1
|
||||
|
||||
* Fix accidental removal of facts\_dot\_d.rb in 3.0.0 release
|
||||
|
||||
##### 2012-08-16 - Jeff McCune <jeff@puppetlabs.com> - 3.0.0
|
||||
|
||||
* stdlib 3.0 drops support with Puppet 2.6
|
||||
* stdlib 3.0 preserves support with Puppet 2.7
|
||||
|
||||
##### 2012-08-07 - Dan Bode <dan@puppetlabs.com> - 3.0.0
|
||||
|
||||
* Add function ensure\_resource and defined\_with\_params (ba789de)
|
||||
|
||||
##### 2012-07-10 - Hailee Kenney <hailee@puppetlabs.com> - 3.0.0
|
||||
|
||||
* (#2157) Remove facter\_dot\_d for compatibility with external facts (f92574f)
|
||||
|
||||
##### 2012-04-10 - Chris Price <chris@puppetlabs.com> - 3.0.0
|
||||
|
||||
* (#13693) moving logic from local spec\_helper to puppetlabs\_spec\_helper (85f96df)
|
||||
|
||||
##### 2012-10-25 - Jeff McCune <jeff@puppetlabs.com> - 2.5.1
|
||||
|
||||
* (maint) Fix spec failures resulting from Facter API changes (97f836f)
|
||||
|
||||
##### 2012-10-23 - Matthaus Owens <matthaus@puppetlabs.com> - 2.5.0
|
||||
|
||||
* Add PE facts to stdlib (cdf3b05)
|
||||
|
||||
##### 2012-08-15 - Dan Bode <dan@puppetlabs.com> - 2.5.0
|
||||
|
||||
* Explicitly load functions used by ensure\_resource (9fc3063)
|
||||
|
||||
##### 2012-08-13 - Dan Bode <dan@puppetlabs.com> - 2.5.0
|
||||
|
||||
* Add better docs about duplicate resource failures (97d327a)
|
||||
|
||||
##### 2012-08-13 - Dan Bode <dan@puppetlabs.com> - 2.5.0
|
||||
|
||||
* Handle undef for parameter argument (4f8b133)
|
||||
|
||||
##### 2012-08-07 - Dan Bode <dan@puppetlabs.com> - 2.5.0
|
||||
|
||||
* Add function ensure\_resource and defined\_with\_params (a0cb8cd)
|
||||
|
||||
##### 2012-08-20 - Jeff McCune <jeff@puppetlabs.com> - 2.5.0
|
||||
|
||||
* Disable tests that fail on 2.6.x due to #15912 (c81496e)
|
||||
|
||||
##### 2012-08-20 - Jeff McCune <jeff@puppetlabs.com> - 2.5.0
|
||||
|
||||
* (Maint) Fix mis-use of rvalue functions as statements (4492913)
|
||||
|
||||
##### 2012-08-20 - Jeff McCune <jeff@puppetlabs.com> - 2.5.0
|
||||
|
||||
* Add .rspec file to repo root (88789e8)
|
||||
|
||||
##### 2012-06-07 - Chris Price <chris@puppetlabs.com> - 2.4.0
|
||||
|
||||
* Add support for a 'match' parameter to file\_line (a06c0d8)
|
||||
|
||||
##### 2012-08-07 - Erik Dalén <dalen@spotify.com> - 2.4.0
|
||||
|
||||
* (#15872) Add to\_bytes function (247b69c)
|
||||
|
||||
##### 2012-07-19 - Jeff McCune <jeff@puppetlabs.com> - 2.4.0
|
||||
|
||||
* (Maint) use PuppetlabsSpec::PuppetInternals.scope (master) (deafe88)
|
||||
|
||||
##### 2012-07-10 - Hailee Kenney <hailee@puppetlabs.com> - 2.4.0
|
||||
|
||||
* (#2157) Make facts\_dot\_d compatible with external facts (5fb0ddc)
|
||||
|
||||
##### 2012-03-16 - Steve Traylen <steve.traylen@cern.ch> - 2.4.0
|
||||
|
||||
* (#13205) Rotate array/string randomley based on fqdn, fqdn\_rotate() (fef247b)
|
||||
|
||||
##### 2012-05-22 - Peter Meier <peter.meier@immerda.ch> - 2.3.3
|
||||
|
||||
* fix regression in #11017 properly (f0a62c7)
|
||||
|
||||
##### 2012-05-10 - Jeff McCune <jeff@puppetlabs.com> - 2.3.3
|
||||
|
||||
* Fix spec tests using the new spec\_helper (7d34333)
|
||||
|
||||
##### 2012-05-10 - Puppet Labs <support@puppetlabs.com> - 2.3.2
|
||||
|
||||
* Make file\_line default to ensure => present (1373e70)
|
||||
* Memoize file\_line spec instance variables (20aacc5)
|
||||
* Fix spec tests using the new spec\_helper (1ebfa5d)
|
||||
* (#13595) initialize\_everything\_for\_tests couples modules Puppet ver (3222f35)
|
||||
* (#13439) Fix MRI 1.9 issue with spec\_helper (15c5fd1)
|
||||
* (#13439) Fix test failures with Puppet 2.6.x (665610b)
|
||||
* (#13439) refactor spec helper for compatibility with both puppet 2.7 and master (82194ca)
|
||||
* (#13494) Specify the behavior of zero padded strings (61891bb)
|
||||
|
||||
##### 2012-03-29 Puppet Labs <support@puppetlabs.com> - 2.1.3
|
||||
|
||||
* (#11607) Add Rakefile to enable spec testing
|
||||
* (#12377) Avoid infinite loop when retrying require json
|
||||
|
||||
##### 2012-03-13 Puppet Labs <support@puppetlabs.com> - 2.3.1
|
||||
|
||||
* (#13091) Fix LoadError bug with puppet apply and puppet\_vardir fact
|
||||
|
||||
##### 2012-03-12 Puppet Labs <support@puppetlabs.com> - 2.3.0
|
||||
|
||||
* Add a large number of new Puppet functions
|
||||
* Backwards compatibility preserved with 2.2.x
|
||||
|
||||
##### 2011-12-30 Puppet Labs <support@puppetlabs.com> - 2.2.1
|
||||
|
||||
* Documentation only release for the Forge
|
||||
|
||||
##### 2011-12-30 Puppet Labs <support@puppetlabs.com> - 2.1.2
|
||||
|
||||
* Documentation only release for PE 2.0.x
|
||||
|
||||
##### 2011-11-08 Puppet Labs <support@puppetlabs.com> - 2.2.0
|
||||
|
||||
* #10285 - Refactor json to use pson instead.
|
||||
* Maint - Add watchr autotest script
|
||||
* Maint - Make rspec tests work with Puppet 2.6.4
|
||||
* #9859 - Add root\_home fact and tests
|
||||
|
||||
##### 2011-08-18 Puppet Labs <support@puppetlabs.com> - 2.1.1
|
||||
|
||||
* Change facts.d paths to match Facter 2.0 paths.
|
||||
* /etc/facter/facts.d
|
||||
* /etc/puppetlabs/facter/facts.d
|
||||
|
||||
##### 2011-08-17 Puppet Labs <support@puppetlabs.com> - 2.1.0
|
||||
|
||||
* Add R.I. Pienaar's facts.d custom facter fact
|
||||
* facts defined in /etc/facts.d and /etc/puppetlabs/facts.d are
|
||||
automatically loaded now.
|
||||
|
||||
##### 2011-08-04 Puppet Labs <support@puppetlabs.com> - 2.0.0
|
||||
|
||||
* Rename whole\_line to file\_line
|
||||
* This is an API change and as such motivating a 2.0.0 release according to semver.org.
|
||||
|
||||
##### 2011-08-04 Puppet Labs <support@puppetlabs.com> - 1.1.0
|
||||
|
||||
* Rename append\_line to whole\_line
|
||||
* This is an API change and as such motivating a 1.1.0 release.
|
||||
|
||||
##### 2011-08-04 Puppet Labs <support@puppetlabs.com> - 1.0.0
|
||||
|
||||
* Initial stable release
|
||||
* Add validate\_array and validate\_string functions
|
||||
* Make merge() function work with Ruby 1.8.5
|
||||
* Add hash merging function
|
||||
* Add has\_key function
|
||||
* Add loadyaml() function
|
||||
* Add append\_line native
|
||||
|
||||
##### 2011-06-21 Jeff McCune <jeff@puppetlabs.com> - 0.1.7
|
||||
|
||||
* Add validate\_hash() and getvar() functions
|
||||
|
||||
##### 2011-06-15 Jeff McCune <jeff@puppetlabs.com> - 0.1.6
|
||||
|
||||
* Add anchor resource type to provide containment for composite classes
|
||||
|
||||
##### 2011-06-03 Jeff McCune <jeff@puppetlabs.com> - 0.1.5
|
||||
|
||||
* Add validate\_bool() function to stdlib
|
||||
|
||||
##### 0.1.4 2011-05-26 Jeff McCune <jeff@puppetlabs.com>
|
||||
|
||||
* Move most stages after main
|
||||
|
||||
##### 0.1.3 2011-05-25 Jeff McCune <jeff@puppetlabs.com>
|
||||
|
||||
* Add validate\_re() function
|
||||
|
||||
##### 0.1.2 2011-05-24 Jeff McCune <jeff@puppetlabs.com>
|
||||
|
||||
* Update to add annotated tag
|
||||
|
||||
##### 0.1.1 2011-05-24 Jeff McCune <jeff@puppetlabs.com>
|
||||
|
||||
* Add stdlib::stages class with a standard set of stages
|
|
@ -1,65 +0,0 @@
|
|||
# How to contribute
|
||||
|
||||
Third-party patches are essential for keeping stdlib great. We simply can't
|
||||
access the huge number of platforms and myriad configurations for running
|
||||
stdlib. We want to keep it as easy as possible to contribute changes that
|
||||
get things working 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.
|
||||
|
||||
## Getting Started
|
||||
|
||||
* Make sure you have a [Jira account](http://tickets.puppetlabs.com)
|
||||
* Make sure you have a [GitHub account](https://github.com/signup/free)
|
||||
* Submit a ticket for your issue, assuming one does not already exist.
|
||||
* Clearly describe the issue including steps to reproduce when it is a bug.
|
||||
* Make sure you fill in the earliest version that you know has the issue.
|
||||
* Fork the repository on GitHub
|
||||
|
||||
## Making Changes
|
||||
|
||||
* Create a topic branch from where you want to base your work.
|
||||
* This is usually the master branch.
|
||||
* Only target release branches if you are certain your fix must be on that
|
||||
branch.
|
||||
* To quickly create a topic branch based on master; `git branch
|
||||
fix/master/my_contribution master` then checkout the new branch with `git
|
||||
checkout fix/master/my_contribution`. Please avoid working directly on the
|
||||
`master` branch.
|
||||
* Make commits of logical units.
|
||||
* Check for unnecessary whitespace with `git diff --check` before committing.
|
||||
* Make sure your commit messages are in the proper format.
|
||||
|
||||
````
|
||||
(#99999) Make the example in CONTRIBUTING imperative and concrete
|
||||
|
||||
Without this patch applied the example commit message in the CONTRIBUTING
|
||||
document is not a concrete example. This is a problem because the
|
||||
contributor is left to imagine what the commit message should look like
|
||||
based on a description rather than an example. This patch fixes the
|
||||
problem by making the example concrete and imperative.
|
||||
|
||||
The first line is a real life imperative statement with a ticket number
|
||||
from our issue tracker. The body describes the behavior without the patch,
|
||||
why this is a problem, and how the patch fixes the problem when applied.
|
||||
````
|
||||
|
||||
* Make sure you have added the necessary tests for your changes.
|
||||
* Run _all_ the tests to assure nothing else was accidentally broken.
|
||||
|
||||
## Submitting Changes
|
||||
|
||||
* Sign the [Contributor License Agreement](http://links.puppetlabs.com/cla).
|
||||
* Push your changes to a topic branch in your fork of the repository.
|
||||
* Submit a pull request to the repository in the puppetlabs organization.
|
||||
* Update your ticket to mark that you have submitted code and are ready for it to be reviewed.
|
||||
* Include a link to the pull request in the ticket
|
||||
|
||||
# Additional Resources
|
||||
|
||||
* [More information on contributing](http://links.puppetlabs.com/contribute-to-puppet)
|
||||
* [Bug tracker (Jira)](http://tickets.puppetlabs.com)
|
||||
* [Contributor License Agreement](http://links.puppetlabs.com/cla)
|
||||
* [General GitHub documentation](http://help.github.com/)
|
||||
* [GitHub pull request documentation](http://help.github.com/send-pull-requests/)
|
||||
* #puppet-dev IRC channel on freenode.org
|
|
@ -1,33 +0,0 @@
|
|||
source ENV['GEM_SOURCE'] || 'https://rubygems.org'
|
||||
|
||||
def location_for(place, fake_version = nil)
|
||||
if place =~ /^(git[:@][^#]*)#(.*)/
|
||||
[fake_version, { :git => $1, :branch => $2, :require => false }].compact
|
||||
elsif place =~ /^file:\/\/(.*)/
|
||||
['>= 0', { :path => File.expand_path($1), :require => false }]
|
||||
else
|
||||
[place, { :require => false }]
|
||||
end
|
||||
end
|
||||
|
||||
group :development, :test do
|
||||
gem 'rake', '~> 10.1.0', :require => false
|
||||
gem 'rspec-puppet', :require => false
|
||||
gem 'puppetlabs_spec_helper', :require => false
|
||||
gem 'serverspec', :require => false
|
||||
gem 'puppet-lint', :require => false
|
||||
gem 'pry', :require => false
|
||||
gem 'simplecov', :require => false
|
||||
gem 'beaker', :require => false
|
||||
gem 'beaker-rspec', :require => false
|
||||
end
|
||||
|
||||
ENV['GEM_PUPPET_VERSION'] ||= ENV['PUPPET_GEM_VERSION']
|
||||
puppetversion = ENV['GEM_PUPPET_VERSION']
|
||||
if puppetversion
|
||||
gem 'puppet', *location_for(puppetversion)
|
||||
else
|
||||
gem 'puppet', :require => false
|
||||
end
|
||||
|
||||
# vim:ft=ruby
|
|
@ -1,166 +0,0 @@
|
|||
GEM
|
||||
remote: https://rubygems.org/
|
||||
specs:
|
||||
CFPropertyList (2.2.8)
|
||||
addressable (2.3.6)
|
||||
archive-tar-minitar (0.5.2)
|
||||
autoparse (0.3.3)
|
||||
addressable (>= 2.3.1)
|
||||
extlib (>= 0.9.15)
|
||||
multi_json (>= 1.0.0)
|
||||
aws-sdk (1.42.0)
|
||||
json (~> 1.4)
|
||||
nokogiri (>= 1.4.4)
|
||||
beaker (1.12.1)
|
||||
aws-sdk (~> 1.38)
|
||||
blimpy (~> 0.6)
|
||||
docker-api
|
||||
fission (~> 0.4)
|
||||
google-api-client (~> 0.7.1)
|
||||
inifile (~> 2.0)
|
||||
json (~> 1.8)
|
||||
mime-types (~> 1.25)
|
||||
net-scp (~> 1.1)
|
||||
net-ssh (~> 2.6)
|
||||
nokogiri (= 1.5.10)
|
||||
rbvmomi (= 1.8.1)
|
||||
unf (~> 0.1)
|
||||
beaker-rspec (2.2.4)
|
||||
beaker (~> 1.10)
|
||||
rspec (~> 2.14)
|
||||
serverspec (~> 1.0)
|
||||
specinfra (~> 1.0)
|
||||
blimpy (0.6.7)
|
||||
fog
|
||||
minitar
|
||||
thor
|
||||
builder (3.2.2)
|
||||
coderay (1.1.0)
|
||||
diff-lcs (1.2.5)
|
||||
docile (1.1.3)
|
||||
docker-api (1.11.0)
|
||||
archive-tar-minitar
|
||||
excon (>= 0.34.0)
|
||||
json
|
||||
excon (0.34.0)
|
||||
extlib (0.9.16)
|
||||
facter (2.0.1)
|
||||
CFPropertyList (~> 2.2.6)
|
||||
faraday (0.9.0)
|
||||
multipart-post (>= 1.2, < 3)
|
||||
fission (0.5.0)
|
||||
CFPropertyList (~> 2.2)
|
||||
fog (1.11.1)
|
||||
builder
|
||||
excon (~> 0.20)
|
||||
formatador (~> 0.2.0)
|
||||
json (~> 1.7)
|
||||
mime-types
|
||||
net-scp (~> 1.1)
|
||||
net-ssh (>= 2.1.3)
|
||||
nokogiri (~> 1.5.0)
|
||||
ruby-hmac
|
||||
formatador (0.2.5)
|
||||
google-api-client (0.7.1)
|
||||
addressable (>= 2.3.2)
|
||||
autoparse (>= 0.3.3)
|
||||
extlib (>= 0.9.15)
|
||||
faraday (>= 0.9.0)
|
||||
jwt (>= 0.1.5)
|
||||
launchy (>= 2.1.1)
|
||||
multi_json (>= 1.0.0)
|
||||
retriable (>= 1.4)
|
||||
signet (>= 0.5.0)
|
||||
uuidtools (>= 2.1.0)
|
||||
hiera (1.3.3)
|
||||
json_pure
|
||||
highline (1.6.21)
|
||||
inifile (2.0.2)
|
||||
json (1.8.1)
|
||||
json_pure (1.8.1)
|
||||
jwt (1.0.0)
|
||||
launchy (2.4.2)
|
||||
addressable (~> 2.3)
|
||||
metaclass (0.0.4)
|
||||
method_source (0.8.2)
|
||||
mime-types (1.25.1)
|
||||
minitar (0.5.4)
|
||||
mocha (1.1.0)
|
||||
metaclass (~> 0.0.1)
|
||||
multi_json (1.10.1)
|
||||
multipart-post (2.0.0)
|
||||
net-scp (1.2.1)
|
||||
net-ssh (>= 2.6.5)
|
||||
net-ssh (2.9.1)
|
||||
nokogiri (1.5.10)
|
||||
pry (0.9.12.6)
|
||||
coderay (~> 1.0)
|
||||
method_source (~> 0.8)
|
||||
slop (~> 3.4)
|
||||
puppet (3.6.1)
|
||||
facter (> 1.6, < 3)
|
||||
hiera (~> 1.0)
|
||||
json_pure
|
||||
rgen (~> 0.6.5)
|
||||
puppet-lint (0.3.2)
|
||||
puppetlabs_spec_helper (0.4.1)
|
||||
mocha (>= 0.10.5)
|
||||
rake
|
||||
rspec (>= 2.9.0)
|
||||
rspec-puppet (>= 0.1.1)
|
||||
rake (10.1.1)
|
||||
rbvmomi (1.8.1)
|
||||
builder
|
||||
nokogiri (>= 1.4.1)
|
||||
trollop
|
||||
retriable (1.4.1)
|
||||
rgen (0.6.6)
|
||||
rspec (2.99.0)
|
||||
rspec-core (~> 2.99.0)
|
||||
rspec-expectations (~> 2.99.0)
|
||||
rspec-mocks (~> 2.99.0)
|
||||
rspec-core (2.99.0)
|
||||
rspec-expectations (2.99.0)
|
||||
diff-lcs (>= 1.1.3, < 2.0)
|
||||
rspec-mocks (2.99.0)
|
||||
rspec-puppet (1.0.1)
|
||||
rspec
|
||||
ruby-hmac (0.4.0)
|
||||
serverspec (1.7.0)
|
||||
highline
|
||||
net-ssh
|
||||
rspec (~> 2.13)
|
||||
specinfra (~> 1.13)
|
||||
signet (0.5.0)
|
||||
addressable (>= 2.2.3)
|
||||
faraday (>= 0.9.0.rc5)
|
||||
jwt (>= 0.1.5)
|
||||
multi_json (>= 1.0.0)
|
||||
simplecov (0.8.2)
|
||||
docile (~> 1.1.0)
|
||||
multi_json
|
||||
simplecov-html (~> 0.8.0)
|
||||
simplecov-html (0.8.0)
|
||||
slop (3.5.0)
|
||||
specinfra (1.15.0)
|
||||
thor (0.19.1)
|
||||
trollop (2.0)
|
||||
unf (0.1.4)
|
||||
unf_ext
|
||||
unf_ext (0.0.6)
|
||||
uuidtools (2.1.4)
|
||||
|
||||
PLATFORMS
|
||||
ruby
|
||||
|
||||
DEPENDENCIES
|
||||
beaker
|
||||
beaker-rspec (= 2.2.4)
|
||||
pry
|
||||
puppet
|
||||
puppet-lint
|
||||
puppetlabs_spec_helper
|
||||
rake (~> 10.1.0)
|
||||
rspec-puppet
|
||||
serverspec
|
||||
simplecov
|
|
@ -1,19 +0,0 @@
|
|||
Copyright (C) 2011 Puppet Labs Inc
|
||||
|
||||
and some parts:
|
||||
|
||||
Copyright (C) 2011 Krzysztof Wilczynski
|
||||
|
||||
Puppet Labs can be contacted at: info@puppetlabs.com
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
|
@ -1,11 +0,0 @@
|
|||
name 'puppetlabs-stdlib'
|
||||
version '4.2.2'
|
||||
source 'git://github.com/puppetlabs/puppetlabs-stdlib.git'
|
||||
author 'puppetlabs'
|
||||
license 'Apache 2.0'
|
||||
summary 'Puppet Module Standard Library'
|
||||
description 'Standard Library for Puppet Modules'
|
||||
project_page 'https://github.com/puppetlabs/puppetlabs-stdlib'
|
||||
|
||||
## Add dependencies, if any:
|
||||
# dependency 'username/name', '>= 1.2.0'
|
File diff suppressed because it is too large
Load diff
|
@ -1,35 +0,0 @@
|
|||
Puppet Specific Facts
|
||||
=====================
|
||||
|
||||
Facter is meant to stand alone and apart from Puppet. However, Facter often
|
||||
runs inside Puppet and all custom facts included in the stdlib module will
|
||||
almost always be evaluated in the context of Puppet and Facter working
|
||||
together.
|
||||
|
||||
Still, we don't want to write custom facts that blow up in the users face if
|
||||
Puppet is not loaded in memory. This is often the case if the user runs
|
||||
`facter` without also supplying the `--puppet` flag.
|
||||
|
||||
Ah! But Jeff, the custom fact won't be in the `$LOAD_PATH` unless the user
|
||||
supplies `--facter`! You might say...
|
||||
|
||||
Not (always) true I say! If the user happens to have a CWD of
|
||||
`<modulepath>/stdlib/lib` then the facts will automatically be evaluated and
|
||||
blow up.
|
||||
|
||||
In any event, it's pretty easy to write a fact that has no value if Puppet is
|
||||
not loaded. Simply do it like this:
|
||||
|
||||
Facter.add(:node_vardir) do
|
||||
setcode do
|
||||
# This will be nil if Puppet is not available.
|
||||
Facter::Util::PuppetSettings.with_puppet do
|
||||
Puppet[:vardir]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
The `Facter::Util::PuppetSettings.with_puppet` method accepts a block and
|
||||
yields to it only if the Puppet library is loaded. If the Puppet library is
|
||||
not loaded, then the method silently returns `nil` which Facter interprets as
|
||||
an undefined fact value. The net effect is that the fact won't be set.
|
|
@ -1,7 +0,0 @@
|
|||
NOTE
|
||||
====
|
||||
|
||||
This project's specs depend on puppet core, and thus they require the
|
||||
`puppetlabs_spec_helper` project. For more information please see the README
|
||||
in that project, which can be found here: [puppetlabs spec
|
||||
helper](https://github.com/puppetlabs/puppetlabs_spec_helper)
|
|
@ -1,24 +0,0 @@
|
|||
# Contributing to this module #
|
||||
|
||||
* Work in a topic branch
|
||||
* Submit a github pull request
|
||||
* Address any comments / feeback
|
||||
* Merge into master using --no-ff
|
||||
|
||||
# Releasing this module #
|
||||
|
||||
* This module adheres to http://semver.org/
|
||||
* Look for API breaking changes using git diff vX.Y.Z..master
|
||||
* If no API breaking changes, the minor version may be bumped.
|
||||
* If there are API breaking changes, the major version must be bumped.
|
||||
* If there are only small minor changes, the patch version may be bumped.
|
||||
* Update the CHANGELOG
|
||||
* Update the Modulefile
|
||||
* Commit these changes with a message along the lines of "Update CHANGELOG and
|
||||
Modulefile for release"
|
||||
* Create an annotated tag with git tag -a vX.Y.Z -m 'version X.Y.Z' (NOTE the
|
||||
leading v as per semver.org)
|
||||
* Push the tag with git push origin --tags
|
||||
* Build a new package with puppet-module or the rake build task if it exists
|
||||
* Publish the new package to the forge
|
||||
* Bonus points for an announcement to puppet-users.
|
|
@ -1,18 +0,0 @@
|
|||
require 'rubygems'
|
||||
require 'puppetlabs_spec_helper/rake_tasks'
|
||||
require 'puppet-lint/tasks/puppet-lint'
|
||||
PuppetLint.configuration.send('disable_80chars')
|
||||
PuppetLint.configuration.ignore_paths = ["spec/**/*.pp", "pkg/**/*.pp"]
|
||||
|
||||
desc "Validate manifests, templates, and ruby files in lib."
|
||||
task :validate do
|
||||
Dir['manifests/**/*.pp'].each do |manifest|
|
||||
sh "puppet parser validate --noop #{manifest}"
|
||||
end
|
||||
Dir['lib/**/*.rb'].each do |lib_file|
|
||||
sh "ruby -c #{lib_file}"
|
||||
end
|
||||
Dir['templates/**/*.erb'].each do |template|
|
||||
sh "erb -P -x -T '-' #{template} | ruby -c"
|
||||
end
|
||||
end
|
|
@ -1,349 +0,0 @@
|
|||
{
|
||||
"CHANGELOG.md": "a3a77d93597fffb4b829b6b56e5d2f16",
|
||||
"CONTRIBUTING.md": "7fcaaec4913b3d7c123510329ecc4b2d",
|
||||
"Gemfile": "38895f95212fe38cf47474a05cff2ad2",
|
||||
"Gemfile.lock": "381b13f5540032a5b9c731766d25c13a",
|
||||
"LICENSE": "38a048b9d82e713d4e1b2573e370a756",
|
||||
"Modulefile": "ee2ec9280b87e32529db8b20cf6b1a19",
|
||||
"README.markdown": "21410cab41d903b5c39c55739846b6b3",
|
||||
"README_DEVELOPER.markdown": "220a8b28521b5c5d2ea87c4ddb511165",
|
||||
"README_SPECS.markdown": "82bb4c6abbb711f40778b162ec0070c1",
|
||||
"RELEASE_PROCESS.markdown": "94b92bc99ac4106ba1a74d5c04e520f9",
|
||||
"Rakefile": "dfa334598bfd087adf11533a72d71106",
|
||||
"lib/facter/facter_dot_d.rb": "1f1fcf1bde3443e42a445d3573602304",
|
||||
"lib/facter/pe_version.rb": "4a9353952963b011759f3e6652a10da5",
|
||||
"lib/facter/puppet_vardir.rb": "c7ddc97e8a84ded3dd93baa5b9b3283d",
|
||||
"lib/facter/root_home.rb": "d9c8276acdceb7340d95f60c36dcdcc5",
|
||||
"lib/facter/util/puppet_settings.rb": "9f1d2593d0ae56bfca89d4b9266aeee1",
|
||||
"lib/puppet/parser/functions/abs.rb": "32161bd0435fdfc2aec2fc559d2b454b",
|
||||
"lib/puppet/parser/functions/any2array.rb": "a81e71d6b67a551d38770ba9a1948a75",
|
||||
"lib/puppet/parser/functions/base64.rb": "ae25adf92295df67ebd9edfabc9ecdd6",
|
||||
"lib/puppet/parser/functions/bool2num.rb": "8e627eee990e811e35e7e838c586bd77",
|
||||
"lib/puppet/parser/functions/capitalize.rb": "14481fc8c7c83fe002066ebcf6722f17",
|
||||
"lib/puppet/parser/functions/chomp.rb": "719d46923d75251f7b6b68b6e015cccc",
|
||||
"lib/puppet/parser/functions/chop.rb": "4691a56e6064b792ed4575e4ad3f3d20",
|
||||
"lib/puppet/parser/functions/concat.rb": "c522e67e558336e1ac26b0a3cfeeed2d",
|
||||
"lib/puppet/parser/functions/count.rb": "9eb74eccd93e2b3c87fd5ea14e329eba",
|
||||
"lib/puppet/parser/functions/deep_merge.rb": "d83696855578fb81b64b9e92b9c7cc7c",
|
||||
"lib/puppet/parser/functions/defined_with_params.rb": "ffab4433d03f32b551f2ea024a2948fc",
|
||||
"lib/puppet/parser/functions/delete.rb": "96e569dac96b8c9387e9303445d73048",
|
||||
"lib/puppet/parser/functions/delete_at.rb": "6bc24b79390d463d8be95396c963381a",
|
||||
"lib/puppet/parser/functions/delete_undef_values.rb": "b32d4a3925753b2eb2c318cbd7f14404",
|
||||
"lib/puppet/parser/functions/delete_values.rb": "39b147f7d369bb5f809044b6341954a2",
|
||||
"lib/puppet/parser/functions/difference.rb": "e31b95fbaf974cf853a510177368bfb9",
|
||||
"lib/puppet/parser/functions/dirname.rb": "bef7214eb89db3eb8f7ee5fc9dca0233",
|
||||
"lib/puppet/parser/functions/downcase.rb": "9204a04c2a168375a38d502db8811bbe",
|
||||
"lib/puppet/parser/functions/empty.rb": "ae92905c9d94ddca30bf56b7b1dabedf",
|
||||
"lib/puppet/parser/functions/ensure_packages.rb": "fbed5c0c9bf82b7746e01f15f89d184f",
|
||||
"lib/puppet/parser/functions/ensure_resource.rb": "6678127386e77bbc0f09db7b5a32ab6a",
|
||||
"lib/puppet/parser/functions/flatten.rb": "25777b76f9719162a8bab640e5595b7a",
|
||||
"lib/puppet/parser/functions/floor.rb": "42cad4c689231a51526c55a6f0985d1f",
|
||||
"lib/puppet/parser/functions/fqdn_rotate.rb": "20743a138c56fc806a35cb7b60137dbc",
|
||||
"lib/puppet/parser/functions/get_module_path.rb": "d4bf50da25c0b98d26b75354fa1bcc45",
|
||||
"lib/puppet/parser/functions/getparam.rb": "4dd7a0e35f4a3780dcfc9b19b4e0006e",
|
||||
"lib/puppet/parser/functions/getvar.rb": "10bf744212947bc6a7bfd2c9836dbd23",
|
||||
"lib/puppet/parser/functions/grep.rb": "5682995af458b05f3b53dd794c4bf896",
|
||||
"lib/puppet/parser/functions/has_interface_with.rb": "8d3ebca805dc6edb88b6b7a13d404787",
|
||||
"lib/puppet/parser/functions/has_ip_address.rb": "ee207f47906455a5aa49c4fb219dd325",
|
||||
"lib/puppet/parser/functions/has_ip_network.rb": "b4d726c8b2a0afac81ced8a3a28aa731",
|
||||
"lib/puppet/parser/functions/has_key.rb": "7cd9728c38f0b0065f832dabd62b0e7e",
|
||||
"lib/puppet/parser/functions/hash.rb": "9d072527dfc7354b69292e9302906530",
|
||||
"lib/puppet/parser/functions/intersection.rb": "924ac4aceec7b896952166a7ec08fdb1",
|
||||
"lib/puppet/parser/functions/is_array.rb": "875ca4356cb0d7a10606fb146b4a3d11",
|
||||
"lib/puppet/parser/functions/is_bool.rb": "e693b7c4b5366cff1380b6e0c7dd7b11",
|
||||
"lib/puppet/parser/functions/is_domain_name.rb": "cf72726c0fec831eb703ec9deea739eb",
|
||||
"lib/puppet/parser/functions/is_float.rb": "10e0d3ecf75fac15e415aee79acf70dc",
|
||||
"lib/puppet/parser/functions/is_function_available.rb": "628428bbcd9313ce09783d9484330e09",
|
||||
"lib/puppet/parser/functions/is_hash.rb": "8c7d9a05084dab0389d1b779c8a05b1a",
|
||||
"lib/puppet/parser/functions/is_integer.rb": "c665be82686aa4729959bb42c66a7510",
|
||||
"lib/puppet/parser/functions/is_ip_address.rb": "a714a736c1560e8739aaacd9030cca00",
|
||||
"lib/puppet/parser/functions/is_mac_address.rb": "288bd4b38d4df42a83681f13e7eaaee0",
|
||||
"lib/puppet/parser/functions/is_numeric.rb": "93ddc9d4c0834a5e5e0562d7b3cdce91",
|
||||
"lib/puppet/parser/functions/is_string.rb": "2bd9a652bbb2668323eee6c57729ff64",
|
||||
"lib/puppet/parser/functions/join.rb": "a285a05c015ae278608f6454aef211ea",
|
||||
"lib/puppet/parser/functions/join_keys_to_values.rb": "f29da49531228f6ca5b3aa0df00a14c2",
|
||||
"lib/puppet/parser/functions/keys.rb": "eb6ac815ea14fbf423580ed903ef7bad",
|
||||
"lib/puppet/parser/functions/loadyaml.rb": "2b912f257aa078e376d3b3f6a86c2a00",
|
||||
"lib/puppet/parser/functions/lstrip.rb": "210b103f78622e099f91cc2956b6f741",
|
||||
"lib/puppet/parser/functions/max.rb": "f652fd0b46ef7d2fbdb42b141f8fdd1d",
|
||||
"lib/puppet/parser/functions/member.rb": "541e67d06bc4155e79b00843a125e9bc",
|
||||
"lib/puppet/parser/functions/merge.rb": "f3dcc5c83440cdda2036cce69b61a14b",
|
||||
"lib/puppet/parser/functions/min.rb": "0d2a1b7e735ab251c5469e735fa3f4c6",
|
||||
"lib/puppet/parser/functions/num2bool.rb": "605c12fa518c87ed2c66ae153e0686ce",
|
||||
"lib/puppet/parser/functions/parsejson.rb": "e7f968c34928107b84cd0860daf50ab1",
|
||||
"lib/puppet/parser/functions/parseyaml.rb": "00f10ec1e2b050e23d80c256061ebdd7",
|
||||
"lib/puppet/parser/functions/pick.rb": "bf01f13bbfe2318e7f6a302ac7c4433f",
|
||||
"lib/puppet/parser/functions/pick_default.rb": "ad3ea60262de408767786d37a54d45dc",
|
||||
"lib/puppet/parser/functions/prefix.rb": "aebbea0290be82a4ae89ddfffbee1125",
|
||||
"lib/puppet/parser/functions/range.rb": "17a05dbae8f562f882450f9e648d4e2d",
|
||||
"lib/puppet/parser/functions/reject.rb": "689f6a7c961a55fe9dcd240921f4c7f9",
|
||||
"lib/puppet/parser/functions/reverse.rb": "1386371c0f5301055fdf99079e862b3e",
|
||||
"lib/puppet/parser/functions/rstrip.rb": "8a0d69876bdbc88a2054ba41c9c38961",
|
||||
"lib/puppet/parser/functions/shuffle.rb": "6445e6b4dc62c37b184a60eeaf34414b",
|
||||
"lib/puppet/parser/functions/size.rb": "8972d48c0f9e487d659bd7326b40b642",
|
||||
"lib/puppet/parser/functions/sort.rb": "504b033b438461ca4f9764feeb017833",
|
||||
"lib/puppet/parser/functions/squeeze.rb": "541f85b4203b55c9931d3d6ecd5c75f8",
|
||||
"lib/puppet/parser/functions/str2bool.rb": "6320f1a50fd28ec027981cd1fb8ffdd0",
|
||||
"lib/puppet/parser/functions/str2saltedsha512.rb": "49afad7b386be38ce53deaefef326e85",
|
||||
"lib/puppet/parser/functions/strftime.rb": "e02e01a598ca5d7d6eee0ba22440304a",
|
||||
"lib/puppet/parser/functions/strip.rb": "273d547c7b05c0598556464dfd12f5fd",
|
||||
"lib/puppet/parser/functions/suffix.rb": "109279db4180441e75545dbd5f273298",
|
||||
"lib/puppet/parser/functions/swapcase.rb": "4902f38f0b9292afec66d40fee4b02ec",
|
||||
"lib/puppet/parser/functions/time.rb": "08d88d52abd1e230e3a2f82107545d48",
|
||||
"lib/puppet/parser/functions/to_bytes.rb": "83f23c33adbfa42b2a9d9fc2db3daeb4",
|
||||
"lib/puppet/parser/functions/type.rb": "62f914d6c90662aaae40c5539701be60",
|
||||
"lib/puppet/parser/functions/union.rb": "137998fe47decf25aede20f0c0155a4c",
|
||||
"lib/puppet/parser/functions/unique.rb": "217ccce6d23235af92923f50f8556963",
|
||||
"lib/puppet/parser/functions/upcase.rb": "a5744a74577cfa136fca2835e75888d3",
|
||||
"lib/puppet/parser/functions/uriescape.rb": "321b8d2c33a5ea48337e1293774db4e0",
|
||||
"lib/puppet/parser/functions/validate_absolute_path.rb": "385137ac24a2dec6cecc4e6ea75be442",
|
||||
"lib/puppet/parser/functions/validate_array.rb": "72b29289b8af1cfc3662ef9be78911b8",
|
||||
"lib/puppet/parser/functions/validate_augeas.rb": "d4acca7b8a9fdada9ae39e5101902cc1",
|
||||
"lib/puppet/parser/functions/validate_bool.rb": "a712634a000024398b3c6cd4ecc46463",
|
||||
"lib/puppet/parser/functions/validate_cmd.rb": "78fd21cb3fc52efc3b53ba2b3301de18",
|
||||
"lib/puppet/parser/functions/validate_hash.rb": "e9cfaca68751524efe16ecf2f958a9a0",
|
||||
"lib/puppet/parser/functions/validate_ipv4_address.rb": "a8fb6f0ca36aa460d462c07c2af5d5a2",
|
||||
"lib/puppet/parser/functions/validate_ipv6_address.rb": "4699238e4cad60e7e1428905523eaeb7",
|
||||
"lib/puppet/parser/functions/validate_re.rb": "c6664b3943bc820415a43f16372dc2a9",
|
||||
"lib/puppet/parser/functions/validate_slength.rb": "7e67c213509b9383707819cc612b2a29",
|
||||
"lib/puppet/parser/functions/validate_string.rb": "6afcbc51f83f0714348b8d61e06ea7eb",
|
||||
"lib/puppet/parser/functions/values.rb": "066a6e4170e5034edb9a80463dff2bb5",
|
||||
"lib/puppet/parser/functions/values_at.rb": "094ac110ce9f7a5b16d0c80a0cf2243c",
|
||||
"lib/puppet/parser/functions/zip.rb": "a80782461ed9465f0cd0c010936f1855",
|
||||
"lib/puppet/provider/file_line/ruby.rb": "10d65268d2d1e75b5dae014974b79d60",
|
||||
"lib/puppet/type/anchor.rb": "bbd36bb49c3b554f8602d8d3df366c0c",
|
||||
"lib/puppet/type/file_line.rb": "a1eceef6bd7cbfe99892cf3ee57ef2b4",
|
||||
"manifests/init.pp": "f2ba5f36e7227ed87bbb69034fc0de8b",
|
||||
"manifests/stages.pp": "cc6ed1751d334b0ea278c0335c7f0b5a",
|
||||
"metadata.json": "42591a032ab4a712a52a294148361090",
|
||||
"spec/acceptance/abs_spec.rb": "435478ef1ba43a6cca1f7b4db14a4bcc",
|
||||
"spec/acceptance/any2array_spec.rb": "78187dc3683c8ecd15774d99024de47d",
|
||||
"spec/acceptance/base64_spec.rb": "1684d5dd176dd5bbd4c3c6b1e64fbcea",
|
||||
"spec/acceptance/bool2num_spec.rb": "c5e3aadb08a437f181247429f4125bab",
|
||||
"spec/acceptance/build_csv.rb": "f28ef587de764ade1513091c4906412c",
|
||||
"spec/acceptance/capitalize_spec.rb": "e77ea2c37144a75a67969c0d0839adfd",
|
||||
"spec/acceptance/chomp_spec.rb": "fb0862a6b7eeb3c290e280788e705061",
|
||||
"spec/acceptance/chop_spec.rb": "0bd1065b9c16a54b86adeb4e3be041fb",
|
||||
"spec/acceptance/concat_spec.rb": "3a0dae19a34bb13d406c8e0ec87d8fe5",
|
||||
"spec/acceptance/count_spec.rb": "5b35e597ae1051f41431812707d4b502",
|
||||
"spec/acceptance/deep_merge_spec.rb": "c335a947f1666e185e0210e661f1c78a",
|
||||
"spec/acceptance/defined_with_params_spec.rb": "f27c54ade9872c63c69316f62b03c119",
|
||||
"spec/acceptance/delete_at_spec.rb": "9c028b703ee0286565c9877757678f3f",
|
||||
"spec/acceptance/delete_spec.rb": "31e6dfcb9cc7c16b20d47c00e6a85a1d",
|
||||
"spec/acceptance/delete_undef_values_spec.rb": "6e6a66aee0c383c843b5f92ef8c8410c",
|
||||
"spec/acceptance/delete_values_spec.rb": "22c9b4914d4cbc0153aa3862cb4fb50e",
|
||||
"spec/acceptance/difference_spec.rb": "289f4f1788feaacb304ffd54971c7e7e",
|
||||
"spec/acceptance/dirname_spec.rb": "84db53878c4400a6c684c924cff05cfc",
|
||||
"spec/acceptance/downcase_spec.rb": "0f094849b94a94df491ee01186473104",
|
||||
"spec/acceptance/empty_spec.rb": "35c1f43e8a3e1fe7dd4335ef86e7efcc",
|
||||
"spec/acceptance/ensure_packages_spec.rb": "d4c02a9313e2b8339d9e4a2f5b200e0e",
|
||||
"spec/acceptance/ensure_resource_spec.rb": "9e03216abb2431e749be76a4302931df",
|
||||
"spec/acceptance/flatten_spec.rb": "83fb08cc168a105c1d5d0df66b1d9e84",
|
||||
"spec/acceptance/floor_spec.rb": "d7267b2914b1da6406224abb7489ca86",
|
||||
"spec/acceptance/fqdn_rotate_spec.rb": "a1fa84292395adec3c47b21c3dc79ec3",
|
||||
"spec/acceptance/get_module_path_spec.rb": "6a6552ff8d6d75ce795b0139c68a7993",
|
||||
"spec/acceptance/getparam_spec.rb": "b62a47524f434b903f9e155ad56959b3",
|
||||
"spec/acceptance/getvar_spec.rb": "ba2f081a88be97c0e7004a6296294f23",
|
||||
"spec/acceptance/grep_spec.rb": "98818b8b0557b80d6ff519f70ea7617c",
|
||||
"spec/acceptance/has_interface_with_spec.rb": "467183aeada0bec74143be6cf0b89a3d",
|
||||
"spec/acceptance/has_ip_address_spec.rb": "e0369b12725695c528e2d47b8ea2b4d8",
|
||||
"spec/acceptance/has_ip_network_spec.rb": "ca8dd6faa6df940784a60a49bec1330d",
|
||||
"spec/acceptance/has_key_spec.rb": "6509a26a0886f7d591eaa926b2f92407",
|
||||
"spec/acceptance/hash_spec.rb": "1c626457ba056bdd3936e28aa5bf503e",
|
||||
"spec/acceptance/intersection_spec.rb": "40f586af7f95408a5d4a2882a4aa98f1",
|
||||
"spec/acceptance/is_array_spec.rb": "c2ff70ce59b90b50a5aed67abaa5399d",
|
||||
"spec/acceptance/is_bool_spec.rb": "c001fdecff6b0a3c9dc78774987a0b15",
|
||||
"spec/acceptance/is_domain_name_spec.rb": "63e84285c26d8717fd5d4dda01e3f432",
|
||||
"spec/acceptance/is_float_spec.rb": "2f0164b4d732166aa46055a2cf7b4ea9",
|
||||
"spec/acceptance/is_function_available_spec.rb": "7745eba89f8719c9ca7ebf04d5b005f7",
|
||||
"spec/acceptance/is_hash_spec.rb": "cff723cd8fddac45033af5dc8406d4e4",
|
||||
"spec/acceptance/is_integer_spec.rb": "c09201d17d3914bba197872897fa3413",
|
||||
"spec/acceptance/is_ip_address_spec.rb": "aa14cf9abf404c3fe1e761ea957871fe",
|
||||
"spec/acceptance/is_mac_address_spec.rb": "30ff4c6a63be58daa3568305617ca2a7",
|
||||
"spec/acceptance/is_numeric_spec.rb": "fb9829c7a1a8d4a58836df6ff4c3386d",
|
||||
"spec/acceptance/is_string_spec.rb": "df3022de123b72f0022728eb2d8ce857",
|
||||
"spec/acceptance/join_keys_to_values_spec.rb": "8aa128bbaeea65aab8d92badee3ca2b5",
|
||||
"spec/acceptance/join_spec.rb": "c6378ed481265152bba9871fc5501ee6",
|
||||
"spec/acceptance/keys_spec.rb": "20486e3ebee53e50dc9de3b78b9d6ae6",
|
||||
"spec/acceptance/loadyaml_spec.rb": "5bce9c4b90e73bccdcd4f66fc988676b",
|
||||
"spec/acceptance/lstrip_spec.rb": "e29ab4039b65660ec2bd76a298adcae0",
|
||||
"spec/acceptance/max_spec.rb": "209cda4b83d677743afb1a8870330618",
|
||||
"spec/acceptance/member_spec.rb": "0dac8ec7c7f670fca429fc26cf8ccc14",
|
||||
"spec/acceptance/merge_spec.rb": "ac61d7627c66565a3a5cbfb2f9db21eb",
|
||||
"spec/acceptance/min_spec.rb": "152a7db28434a0d0378561d4f64cddcc",
|
||||
"spec/acceptance/nodesets/centos-6-vcloud.yml": "bdf9ce9d3b0f0b4995666ae9d64d878d",
|
||||
"spec/acceptance/nodesets/centos-64-x64-pe.yml": "ec075d95760df3d4702abea1ce0a829b",
|
||||
"spec/acceptance/nodesets/centos-64-x64.yml": "092dd2c588a9f87fa1fb12997c0723ef",
|
||||
"spec/acceptance/nodesets/default.yml": "3e5c36e6aa5a690229e720f4048bb8af",
|
||||
"spec/acceptance/nodesets/fedora-18-x64.yml": "80e41b1ee16ea489f53164bfdae58855",
|
||||
"spec/acceptance/nodesets/sles-11-x64.yml": "44e4c6c15c018333bfa9840a5e702f66",
|
||||
"spec/acceptance/nodesets/ubuntu-server-10044-x64.yml": "75e86400b7889888dc0781c0ae1a1297",
|
||||
"spec/acceptance/nodesets/ubuntu-server-12042-x64.yml": "d30d73e34cd50b043c7d14e305955269",
|
||||
"spec/acceptance/num2bool_spec.rb": "e4a00b913b08c68a689837e9f9336cb2",
|
||||
"spec/acceptance/parsejson_spec.rb": "ea3973d412ad6f72425fdfac6fbb2bb4",
|
||||
"spec/acceptance/parseyaml_spec.rb": "7bbfeed73d0626f69daedfc151957967",
|
||||
"spec/acceptance/pick_default_spec.rb": "1bc2562380ef6f6cded5ec90a03922be",
|
||||
"spec/acceptance/pick_spec.rb": "272c54c8f9398f499768331bdb4276ee",
|
||||
"spec/acceptance/prefix_spec.rb": "da620568c6771e7d492ec1ff697c531c",
|
||||
"spec/acceptance/range_spec.rb": "65e5b98ceca257658604d988fbec7d03",
|
||||
"spec/acceptance/reject_spec.rb": "b5185f1a6071c9bdc7aca92e6f899c3e",
|
||||
"spec/acceptance/reverse_spec.rb": "7bdee543e82532e97bbf7a067140031c",
|
||||
"spec/acceptance/rstrip_spec.rb": "28a64ceb7cb5ae8a93d31f49816190ab",
|
||||
"spec/acceptance/shuffle_spec.rb": "8a8652e57d56f2b4946cdf4d20052b7a",
|
||||
"spec/acceptance/size_spec.rb": "ae17d8a55921a0570972200c7c9327e1",
|
||||
"spec/acceptance/sort_spec.rb": "d44b1b8c090f0f00a2f38515fda431ea",
|
||||
"spec/acceptance/squeeze_spec.rb": "adcd65fa4e72203b97f1f14c8835c2cd",
|
||||
"spec/acceptance/str2bool_spec.rb": "55ad165ceef6b9ba32bf20ca3b53b44c",
|
||||
"spec/acceptance/str2saltedsha512_spec.rb": "b684c4214d06ae3d5bae055262a5ccaa",
|
||||
"spec/acceptance/strftime_spec.rb": "0f4eadbd74445b35de4a42c9790fbcc1",
|
||||
"spec/acceptance/strip_spec.rb": "6767da5bc735beb5362aeee6ff692c9e",
|
||||
"spec/acceptance/suffix_spec.rb": "07dfc7eed48b75fcc1b93d0308243eda",
|
||||
"spec/acceptance/swapcase_spec.rb": "5c3c1bc19a09fed6e01881f79b0b4ea5",
|
||||
"spec/acceptance/time_spec.rb": "044b2f634a1fa6ecc735998d68a93b73",
|
||||
"spec/acceptance/to_bytes_spec.rb": "f9df1f234b9409f5eaf56ef24e651c36",
|
||||
"spec/acceptance/type_spec.rb": "d103a7e1607ab9cea74cdef25af610b0",
|
||||
"spec/acceptance/union_spec.rb": "b6092941e0574f3c60910bebf84d2844",
|
||||
"spec/acceptance/unique_spec.rb": "9b00b21cefde3b5391f50eeb9cd2493b",
|
||||
"spec/acceptance/unsupported_spec.rb": "09b9265ecb05252cd5e5a18327c7ae97",
|
||||
"spec/acceptance/upcase_spec.rb": "ffd1d6f9e6ec24131fb78983c53a75f9",
|
||||
"spec/acceptance/uriescape_spec.rb": "13daa387714cbfc63b587aaa8dbf7fcd",
|
||||
"spec/acceptance/validate_absolute_path_spec.rb": "8b9ebfae80329231d84fcab606a3eeaf",
|
||||
"spec/acceptance/validate_array_spec.rb": "382641719e754622ffae562d10e38bf7",
|
||||
"spec/acceptance/validate_augeas_spec.rb": "ec0a9c030e2c3494889973d74d60b2a4",
|
||||
"spec/acceptance/validate_bool_spec.rb": "08bc139459204cf0a35098a5bc30ab95",
|
||||
"spec/acceptance/validate_cmd_spec.rb": "d08eacac4dd5bdb50b5b0f02a6494048",
|
||||
"spec/acceptance/validate_hash_spec.rb": "70ceacc18a0dee97b26ab2e50f925706",
|
||||
"spec/acceptance/validate_ipv4_address_spec.rb": "dc901bbd05c3764a93cb49154cea6e4b",
|
||||
"spec/acceptance/validate_ipv6_address_spec.rb": "c0872c56230ac2800cd5723eaa5bc53a",
|
||||
"spec/acceptance/validate_re_spec.rb": "b289909078d6ae0d015419f518566698",
|
||||
"spec/acceptance/validate_slength_spec.rb": "f0a05c1c2b895b096cb7326df4821594",
|
||||
"spec/acceptance/validate_string_spec.rb": "6c9ced99fb1e263e66e25427d24f8f7b",
|
||||
"spec/acceptance/values_at_spec.rb": "669b26c4d47742051472003518c3aa61",
|
||||
"spec/acceptance/values_spec.rb": "714a13735aa0db3ffd3dfc4cd2c2e330",
|
||||
"spec/acceptance/zip_spec.rb": "0a76aa26bd9552b8dae3294af7d233ab",
|
||||
"spec/classes/anchor_spec.rb": "40600ba2845f9bd360a9504a347f12ba",
|
||||
"spec/fixtures/dscacheutil/root": "e1a7622f55f3d1be258c9a5b16b474be",
|
||||
"spec/fixtures/manifests/site.pp": "d41d8cd98f00b204e9800998ecf8427e",
|
||||
"spec/functions/abs_spec.rb": "0a5864a29a8e9e99acc483268bd5917c",
|
||||
"spec/functions/any2array_spec.rb": "167e114cfa222de971bf8be141766b6a",
|
||||
"spec/functions/base64_spec.rb": "fe16d992be54dbb06d040f1b0e189571",
|
||||
"spec/functions/bool2num_spec.rb": "67c3055d5d4e4c9fbcaca82038a09081",
|
||||
"spec/functions/capitalize_spec.rb": "82a4209a033fc88c624f708c12e64e2a",
|
||||
"spec/functions/chomp_spec.rb": "3cd8e2fe6b12efeffad94cce5b693b7c",
|
||||
"spec/functions/chop_spec.rb": "4e9534d25b952b261c9f46add677c390",
|
||||
"spec/functions/concat_spec.rb": "d7657b1af27a96072aae711cee041181",
|
||||
"spec/functions/count_spec.rb": "db98ef89752a7112425f0aade10108e0",
|
||||
"spec/functions/deep_merge_spec.rb": "7961a696e1b45167cead127f841f1c99",
|
||||
"spec/functions/defined_with_params_spec.rb": "3bdfac38e3d6f06140ff2e926f4ebed2",
|
||||
"spec/functions/delete_at_spec.rb": "7fd4fe7db8d213925fbc80c992673d10",
|
||||
"spec/functions/delete_spec.rb": "fe66bdf9e61b9c992bc73ee54a37035c",
|
||||
"spec/functions/delete_undef_values_spec.rb": "83b9c3027463f5c8a90a6d47d219acd5",
|
||||
"spec/functions/delete_values_spec.rb": "ddcaa269caa95ad926b8a3ef82976da9",
|
||||
"spec/functions/difference_spec.rb": "e64c1501699fef8eb1037a3ca60a05a6",
|
||||
"spec/functions/dirname_spec.rb": "1d7cf70468c2cfa6dacfc75935322395",
|
||||
"spec/functions/downcase_spec.rb": "b0197829512f2e92a2d2b06ce8e2226f",
|
||||
"spec/functions/empty_spec.rb": "028c30267d648a172d8a81a9262c3abe",
|
||||
"spec/functions/ensure_packages_spec.rb": "f1b60599078cdcb3cff1368346108264",
|
||||
"spec/functions/ensure_resource_spec.rb": "7765dde3b9fc54b7dddb6597e0f7b523",
|
||||
"spec/functions/flatten_spec.rb": "583c9a70f93e492cfb22ffa1811f6aa0",
|
||||
"spec/functions/floor_spec.rb": "d01ef7dfe0245d7a0a73d7df13cb02e3",
|
||||
"spec/functions/fqdn_rotate_spec.rb": "c67b71737bee9936f5261d41a37bad46",
|
||||
"spec/functions/get_module_path_spec.rb": "b7ea196f548b1a9a745ab6671295ab27",
|
||||
"spec/functions/getparam_spec.rb": "75153d949eb122aa18f0c5e2c8e861e5",
|
||||
"spec/functions/getvar_spec.rb": "842bf88d47077a9ae64097b6e39c3364",
|
||||
"spec/functions/grep_spec.rb": "78179537496a7150469e591a95e255d8",
|
||||
"spec/functions/has_interface_with_spec.rb": "7c16d731c518b434c81b8cb2227cc916",
|
||||
"spec/functions/has_ip_address_spec.rb": "f53c7baeaf024ff577447f6c28c0f3a7",
|
||||
"spec/functions/has_ip_network_spec.rb": "885ea8a4c987b735d683b742bf846cb1",
|
||||
"spec/functions/has_key_spec.rb": "3e4e730d98bbdfb88438b6e08e45868e",
|
||||
"spec/functions/hash_spec.rb": "826337a92d8f7a189b7ac19615db0ed7",
|
||||
"spec/functions/intersection_spec.rb": "1b1f1a3900a1f1e165692b056e766fba",
|
||||
"spec/functions/is_array_spec.rb": "8c020af9c360abdbbf1ba887bb26babe",
|
||||
"spec/functions/is_bool_spec.rb": "3219ba1500de75161bfb4f292404d1fa",
|
||||
"spec/functions/is_domain_name_spec.rb": "8eed3a9eb9334bf6a473ad4e2cabc2ec",
|
||||
"spec/functions/is_float_spec.rb": "171fc0e382d9856c2d8db2b70c9ec9cd",
|
||||
"spec/functions/is_function_available.rb": "c8858a3c6253713cce0113a98d229b5d",
|
||||
"spec/functions/is_hash_spec.rb": "408e121a5e30c4c5c4a0a383beb6e209",
|
||||
"spec/functions/is_integer_spec.rb": "c848f20da5f62ac4bbaf0f6c1485c88f",
|
||||
"spec/functions/is_ip_address_spec.rb": "6040a9bae4e5c853966148b634501157",
|
||||
"spec/functions/is_mac_address_spec.rb": "644cd498b426ff2f9ea9cbc5d8e141d7",
|
||||
"spec/functions/is_numeric_spec.rb": "65f2ad0e70d9b60c601740351eba94fd",
|
||||
"spec/functions/is_string_spec.rb": "5c015d8267de852da3a12b984e077092",
|
||||
"spec/functions/join_keys_to_values_spec.rb": "7c7937411b7fe4bb944c0c022d3a96b0",
|
||||
"spec/functions/join_spec.rb": "c3b50c39390a86b493511be2c6722235",
|
||||
"spec/functions/keys_spec.rb": "35cc2ed490dc68da6464f245dfebd617",
|
||||
"spec/functions/loadyaml_spec.rb": "ce86614d8aaceec93653ecf299d3d441",
|
||||
"spec/functions/lstrip_spec.rb": "1fc2c2d80b5f724a358c3cfeeaae6249",
|
||||
"spec/functions/max_spec.rb": "5562bccc643443af7e4fa7c9d1e52b8b",
|
||||
"spec/functions/member_spec.rb": "067c60985efc57022ca1c5508d74d77f",
|
||||
"spec/functions/merge_spec.rb": "c17a7244453f2da22970acc02a6de110",
|
||||
"spec/functions/min_spec.rb": "bf80bf58261117bb24392670b624a611",
|
||||
"spec/functions/num2bool_spec.rb": "8cd5b46b7c8e612dfae3362e3a68a5f9",
|
||||
"spec/functions/parsejson_spec.rb": "37ab84381e035c31d6a3dd9bf73a3d53",
|
||||
"spec/functions/parseyaml_spec.rb": "65dfed872930ffe0d21954c15daaf498",
|
||||
"spec/functions/pick_default_spec.rb": "db0a9d261b7e1b82e2786716dd924e92",
|
||||
"spec/functions/pick_spec.rb": "34382f7483b6c10d38831de2169777c2",
|
||||
"spec/functions/prefix_spec.rb": "7245749e27bafe1b36c1c5bae6f705c7",
|
||||
"spec/functions/range_spec.rb": "c40b3c6d4031fc541c2421ff7b8c41fe",
|
||||
"spec/functions/reject_spec.rb": "8e16c9f064870e958b6278261e480954",
|
||||
"spec/functions/reverse_spec.rb": "48169990e59081ccbd112b6703418ce4",
|
||||
"spec/functions/rstrip_spec.rb": "a408e933753c9c323a05d7079d32cbb3",
|
||||
"spec/functions/shuffle_spec.rb": "2141a54d2fb3cf725b88184d639677f4",
|
||||
"spec/functions/size_spec.rb": "d126b696b21a8cd754d58f78ddba6f06",
|
||||
"spec/functions/sort_spec.rb": "7039cd230a94e95d9d1de2e1094acae2",
|
||||
"spec/functions/squeeze_spec.rb": "df5b349c208a9a2a4d4b8e6d9324756f",
|
||||
"spec/functions/str2bool_spec.rb": "e2a8a4d39680f3ed18621e26d67c6024",
|
||||
"spec/functions/str2saltedsha512_spec.rb": "1de174be8835ba6fef86b590887bb2cc",
|
||||
"spec/functions/strftime_spec.rb": "bf140883ecf3254277306fa5b25f0344",
|
||||
"spec/functions/strip_spec.rb": "a01796bebbdabd3fad12b0662ea5966e",
|
||||
"spec/functions/suffix_spec.rb": "ee875e2d09d7ffc363bf6c34d9ef322f",
|
||||
"spec/functions/swapcase_spec.rb": "0660ce8807608cc8f98ad1edfa76a402",
|
||||
"spec/functions/time_spec.rb": "b6d0279062779efe5153fe5cfafc5bbd",
|
||||
"spec/functions/to_bytes_spec.rb": "80aaf68cf7e938e46b5278c1907af6be",
|
||||
"spec/functions/type_spec.rb": "422f2c33458fe9b0cc9614d16f7573ba",
|
||||
"spec/functions/union_spec.rb": "c4f72a55e186813cd3a47a83ba3e9a61",
|
||||
"spec/functions/unique_spec.rb": "2df8b3b2edb9503943cb4dcb4a371867",
|
||||
"spec/functions/upcase_spec.rb": "813668919bc62cdd1d349dafc19fbbb3",
|
||||
"spec/functions/uriescape_spec.rb": "204e9b1566e330a0234761ac8ac7083f",
|
||||
"spec/functions/validate_absolute_path_spec.rb": "5a0b98675070e511810dab9e60dc43b6",
|
||||
"spec/functions/validate_array_spec.rb": "bcd231229554785c4270ca92ef99cb60",
|
||||
"spec/functions/validate_augeas_spec.rb": "eee1a0c3ef3051bda525b1e17d577ab0",
|
||||
"spec/functions/validate_bool_spec.rb": "7aeb6085fc9601c6bbe6c49e56d209a4",
|
||||
"spec/functions/validate_cmd_spec.rb": "efc88e8e21481acd36c7f948b1f226ea",
|
||||
"spec/functions/validate_hash_spec.rb": "8529c74051ceb71e6b1b97c9cecdf625",
|
||||
"spec/functions/validate_ipv4_address_spec.rb": "19f2f44fbbdf7a2e69aeaa2f0f402695",
|
||||
"spec/functions/validate_ipv6_address_spec.rb": "2d8617be4405bdbd84d140ba8be6c184",
|
||||
"spec/functions/validate_re_spec.rb": "d8ab477f9afcb748f144588ebb3a28a3",
|
||||
"spec/functions/validate_slength_spec.rb": "73273a083a26941b3f7c1e3b2e18b3e2",
|
||||
"spec/functions/validate_string_spec.rb": "64a4f681084cba55775a070f7fab5e0c",
|
||||
"spec/functions/values_at_spec.rb": "de45fd8abbc4c037c3c4fac2dcf186f9",
|
||||
"spec/functions/values_spec.rb": "0ac9e141ed1f612d7cc224f747b2d1d9",
|
||||
"spec/functions/zip_spec.rb": "06a86e4e70d2aea63812582aae1d26c4",
|
||||
"spec/lib/puppet_spec/compiler.rb": "3c1f03dd8ac2f6f90d7e8f879a3ce4c0",
|
||||
"spec/lib/puppet_spec/database.rb": "c74c0cf62980beea88c7749f876ccfa7",
|
||||
"spec/lib/puppet_spec/files.rb": "906da85e399302cee403e10e357d3f4c",
|
||||
"spec/lib/puppet_spec/fixtures.rb": "0722c5ccbfcba1fc27da1900e54b4463",
|
||||
"spec/lib/puppet_spec/matchers.rb": "dd30ba6b936e8c267511d67acb087c35",
|
||||
"spec/lib/puppet_spec/modules.rb": "445d2739aa8754568a14816280727d70",
|
||||
"spec/lib/puppet_spec/pops.rb": "adf661defa460b7189e3750535533d34",
|
||||
"spec/lib/puppet_spec/scope.rb": "01aeb89bdc2d29a2528ced26ec6402ec",
|
||||
"spec/lib/puppet_spec/settings.rb": "5da4e0dad8bf6b21cc4437c73753a56d",
|
||||
"spec/lib/puppet_spec/verbose.rb": "71dbccd9a45ed89d12fd1c44456a6820",
|
||||
"spec/monkey_patches/alias_should_to_must.rb": "b19ee31563afb91a72f9869f9d7362ff",
|
||||
"spec/monkey_patches/publicize_methods.rb": "c690e444b77c871375d321e413e28ca1",
|
||||
"spec/spec.opts": "a600ded995d948e393fbe2320ba8e51c",
|
||||
"spec/spec_helper.rb": "846cc69a2d612d55d130622759aa12e0",
|
||||
"spec/spec_helper_acceptance.rb": "d82b5682eac4ff46bbe5aa08c29d5e28",
|
||||
"spec/unit/facter/facter_dot_d_spec.rb": "cce0748b2671b1b104332a7c757e5206",
|
||||
"spec/unit/facter/pe_version_spec.rb": "ef031cca838f36f99b1dab3259df96a5",
|
||||
"spec/unit/facter/root_home_spec.rb": "ecd851e2b8a4a8578960cce094cf41ee",
|
||||
"spec/unit/facter/util/puppet_settings_spec.rb": "8666142d017e5804445f5596f3be76e8",
|
||||
"spec/unit/puppet/provider/file_line/ruby_spec.rb": "e118a65a3eb0ccd3d1bf99d7bb010669",
|
||||
"spec/unit/puppet/type/anchor_spec.rb": "3c3251acbc1085b121623f4617107fb9",
|
||||
"spec/unit/puppet/type/file_line_spec.rb": "72ba1d9ad9de5df592f3ff03551983cb",
|
||||
"tests/file_line.pp": "67727539aa7b7dd76f06626fe734f7f7",
|
||||
"tests/has_interface_with.pp": "59c98b4af0d39fc11d1ef4c7a6dc8f7a",
|
||||
"tests/has_ip_address.pp": "93ce02915f67ddfb43a049b2b84ef391",
|
||||
"tests/has_ip_network.pp": "abc05686797a776ea8c054657e6f7456",
|
||||
"tests/init.pp": "1d98070412c76824e66db4b7eb74d433"
|
||||
}
|
|
@ -1,202 +0,0 @@
|
|||
# A Facter plugin that loads facts from /etc/facter/facts.d
|
||||
# and /etc/puppetlabs/facter/facts.d.
|
||||
#
|
||||
# Facts can be in the form of JSON, YAML or Text files
|
||||
# and any executable that returns key=value pairs.
|
||||
#
|
||||
# In the case of scripts you can also create a file that
|
||||
# contains a cache TTL. For foo.sh store the ttl as just
|
||||
# a number in foo.sh.ttl
|
||||
#
|
||||
# The cache is stored in /tmp/facts_cache.yaml as a mode
|
||||
# 600 file and will have the end result of not calling your
|
||||
# fact scripts more often than is needed
|
||||
|
||||
class Facter::Util::DotD
|
||||
require 'yaml'
|
||||
|
||||
def initialize(dir="/etc/facts.d", cache_file="/tmp/facts_cache.yml")
|
||||
@dir = dir
|
||||
@cache_file = cache_file
|
||||
@cache = nil
|
||||
@types = {".txt" => :txt, ".json" => :json, ".yaml" => :yaml}
|
||||
end
|
||||
|
||||
def entries
|
||||
Dir.entries(@dir).reject{|f| f =~ /^\.|\.ttl$/}.sort.map {|f| File.join(@dir, f) }
|
||||
rescue
|
||||
[]
|
||||
end
|
||||
|
||||
def fact_type(file)
|
||||
extension = File.extname(file)
|
||||
|
||||
type = @types[extension] || :unknown
|
||||
|
||||
type = :script if type == :unknown && File.executable?(file)
|
||||
|
||||
return type
|
||||
end
|
||||
|
||||
def txt_parser(file)
|
||||
File.readlines(file).each do |line|
|
||||
if line =~ /^([^=]+)=(.+)$/
|
||||
var = $1; val = $2
|
||||
|
||||
Facter.add(var) do
|
||||
setcode { val }
|
||||
end
|
||||
end
|
||||
end
|
||||
rescue Exception => e
|
||||
Facter.warn("Failed to handle #{file} as text facts: #{e.class}: #{e}")
|
||||
end
|
||||
|
||||
def json_parser(file)
|
||||
begin
|
||||
require 'json'
|
||||
rescue LoadError
|
||||
retry if require 'rubygems'
|
||||
raise
|
||||
end
|
||||
|
||||
JSON.load(File.read(file)).each_pair do |f, v|
|
||||
Facter.add(f) do
|
||||
setcode { v }
|
||||
end
|
||||
end
|
||||
rescue Exception => e
|
||||
Facter.warn("Failed to handle #{file} as json facts: #{e.class}: #{e}")
|
||||
end
|
||||
|
||||
def yaml_parser(file)
|
||||
require 'yaml'
|
||||
|
||||
YAML.load_file(file).each_pair do |f, v|
|
||||
Facter.add(f) do
|
||||
setcode { v }
|
||||
end
|
||||
end
|
||||
rescue Exception => e
|
||||
Facter.warn("Failed to handle #{file} as yaml facts: #{e.class}: #{e}")
|
||||
end
|
||||
|
||||
def script_parser(file)
|
||||
result = cache_lookup(file)
|
||||
ttl = cache_time(file)
|
||||
|
||||
unless result
|
||||
result = Facter::Util::Resolution.exec(file)
|
||||
|
||||
if ttl > 0
|
||||
Facter.debug("Updating cache for #{file}")
|
||||
cache_store(file, result)
|
||||
cache_save!
|
||||
end
|
||||
else
|
||||
Facter.debug("Using cached data for #{file}")
|
||||
end
|
||||
|
||||
result.split("\n").each do |line|
|
||||
if line =~ /^(.+)=(.+)$/
|
||||
var = $1; val = $2
|
||||
|
||||
Facter.add(var) do
|
||||
setcode { val }
|
||||
end
|
||||
end
|
||||
end
|
||||
rescue Exception => e
|
||||
Facter.warn("Failed to handle #{file} as script facts: #{e.class}: #{e}")
|
||||
Facter.debug(e.backtrace.join("\n\t"))
|
||||
end
|
||||
|
||||
def cache_save!
|
||||
cache = load_cache
|
||||
File.open(@cache_file, "w", 0600) {|f| f.write(YAML.dump(cache)) }
|
||||
rescue
|
||||
end
|
||||
|
||||
def cache_store(file, data)
|
||||
load_cache
|
||||
|
||||
@cache[file] = {:data => data, :stored => Time.now.to_i}
|
||||
rescue
|
||||
end
|
||||
|
||||
def cache_lookup(file)
|
||||
cache = load_cache
|
||||
|
||||
return nil if cache.empty?
|
||||
|
||||
ttl = cache_time(file)
|
||||
|
||||
if cache[file]
|
||||
now = Time.now.to_i
|
||||
|
||||
return cache[file][:data] if ttl == -1
|
||||
return cache[file][:data] if (now - cache[file][:stored]) <= ttl
|
||||
return nil
|
||||
else
|
||||
return nil
|
||||
end
|
||||
rescue
|
||||
return nil
|
||||
end
|
||||
|
||||
def cache_time(file)
|
||||
meta = file + ".ttl"
|
||||
|
||||
return File.read(meta).chomp.to_i
|
||||
rescue
|
||||
return 0
|
||||
end
|
||||
|
||||
def load_cache
|
||||
unless @cache
|
||||
if File.exist?(@cache_file)
|
||||
@cache = YAML.load_file(@cache_file)
|
||||
else
|
||||
@cache = {}
|
||||
end
|
||||
end
|
||||
|
||||
return @cache
|
||||
rescue
|
||||
@cache = {}
|
||||
return @cache
|
||||
end
|
||||
|
||||
def create
|
||||
entries.each do |fact|
|
||||
type = fact_type(fact)
|
||||
parser = "#{type}_parser"
|
||||
|
||||
if respond_to?("#{type}_parser")
|
||||
Facter.debug("Parsing #{fact} using #{parser}")
|
||||
|
||||
send(parser, fact)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
mdata = Facter.version.match(/(\d+)\.(\d+)\.(\d+)/)
|
||||
if mdata
|
||||
(major, minor, patch) = mdata.captures.map { |v| v.to_i }
|
||||
if major < 2
|
||||
# Facter 1.7 introduced external facts support directly
|
||||
unless major == 1 and minor > 6
|
||||
Facter::Util::DotD.new("/etc/facter/facts.d").create
|
||||
Facter::Util::DotD.new("/etc/puppetlabs/facter/facts.d").create
|
||||
|
||||
# Windows has a different configuration directory that defaults to a vendor
|
||||
# specific sub directory of the %COMMON_APPDATA% directory.
|
||||
if Dir.const_defined? 'COMMON_APPDATA' then
|
||||
windows_facts_dot_d = File.join(Dir::COMMON_APPDATA, 'PuppetLabs', 'facter', 'facts.d')
|
||||
Facter::Util::DotD.new(windows_facts_dot_d).create
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,53 +0,0 @@
|
|||
# Fact: is_pe, pe_version, pe_major_version, pe_minor_version, pe_patch_version
|
||||
#
|
||||
# Purpose: Return various facts about the PE state of the system
|
||||
#
|
||||
# Resolution: Uses a regex match against puppetversion to determine whether the
|
||||
# machine has Puppet Enterprise installed, and what version (overall, major,
|
||||
# minor, patch) is installed.
|
||||
#
|
||||
# Caveats:
|
||||
#
|
||||
Facter.add("pe_version") do
|
||||
setcode do
|
||||
pe_ver = Facter.value("puppetversion").match(/Puppet Enterprise (\d+\.\d+\.\d+)/)
|
||||
pe_ver[1] if pe_ver
|
||||
end
|
||||
end
|
||||
|
||||
Facter.add("is_pe") do
|
||||
setcode do
|
||||
if Facter.value(:pe_version).to_s.empty? then
|
||||
false
|
||||
else
|
||||
true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Facter.add("pe_major_version") do
|
||||
confine :is_pe => true
|
||||
setcode do
|
||||
if pe_version = Facter.value(:pe_version)
|
||||
pe_version.to_s.split('.')[0]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Facter.add("pe_minor_version") do
|
||||
confine :is_pe => true
|
||||
setcode do
|
||||
if pe_version = Facter.value(:pe_version)
|
||||
pe_version.to_s.split('.')[1]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Facter.add("pe_patch_version") do
|
||||
confine :is_pe => true
|
||||
setcode do
|
||||
if pe_version = Facter.value(:pe_version)
|
||||
pe_version.to_s.split('.')[2]
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,26 +0,0 @@
|
|||
# This facter fact returns the value of the Puppet vardir setting for the node
|
||||
# running puppet or puppet agent. The intent is to enable Puppet modules to
|
||||
# automatically have insight into a place where they can place variable data,
|
||||
# regardless of the node's platform.
|
||||
#
|
||||
# The value should be directly usable in a File resource path attribute.
|
||||
|
||||
|
||||
begin
|
||||
require 'facter/util/puppet_settings'
|
||||
rescue LoadError => e
|
||||
# puppet apply does not add module lib directories to the $LOAD_PATH (See
|
||||
# #4248). It should (in the future) but for the time being we need to be
|
||||
# defensive which is what this rescue block is doing.
|
||||
rb_file = File.join(File.dirname(__FILE__), 'util', 'puppet_settings.rb')
|
||||
load rb_file if File.exists?(rb_file) or raise e
|
||||
end
|
||||
|
||||
Facter.add(:puppet_vardir) do
|
||||
setcode do
|
||||
# This will be nil if Puppet is not available.
|
||||
Facter::Util::PuppetSettings.with_puppet do
|
||||
Puppet[:vardir]
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,32 +0,0 @@
|
|||
# A facter fact to determine the root home directory.
|
||||
# This varies on PE supported platforms and may be
|
||||
# reconfigured by the end user.
|
||||
|
||||
module Facter::Util::RootHome
|
||||
class << self
|
||||
def get_root_home
|
||||
root_ent = Facter::Util::Resolution.exec("getent passwd root")
|
||||
# The home directory is the sixth element in the passwd entry
|
||||
# If the platform doesn't have getent, root_ent will be nil and we should
|
||||
# return it straight away.
|
||||
root_ent && root_ent.split(":")[5]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Facter.add(:root_home) do
|
||||
setcode { Facter::Util::RootHome.get_root_home }
|
||||
end
|
||||
|
||||
Facter.add(:root_home) do
|
||||
confine :kernel => :darwin
|
||||
setcode do
|
||||
str = Facter::Util::Resolution.exec("dscacheutil -q user -a name root")
|
||||
hash = {}
|
||||
str.split("\n").each do |pair|
|
||||
key,value = pair.split(/:/)
|
||||
hash[key] = value
|
||||
end
|
||||
hash['dir'].strip
|
||||
end
|
||||
end
|
|
@ -1,21 +0,0 @@
|
|||
module Facter
|
||||
module Util
|
||||
module PuppetSettings
|
||||
# This method is intended to provide a convenient way to evaluate a
|
||||
# Facter code block only if Puppet is loaded. This is to account for the
|
||||
# situation where the fact happens to be in the load path, but Puppet is
|
||||
# not loaded for whatever reason. Perhaps the user is simply running
|
||||
# facter without the --puppet flag and they happen to be working in a lib
|
||||
# directory of a module.
|
||||
def self.with_puppet
|
||||
begin
|
||||
Module.const_get("Puppet")
|
||||
rescue NameError
|
||||
nil
|
||||
else
|
||||
yield
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,36 +0,0 @@
|
|||
#
|
||||
# abs.rb
|
||||
#
|
||||
|
||||
module Puppet::Parser::Functions
|
||||
newfunction(:abs, :type => :rvalue, :doc => <<-EOS
|
||||
Returns the absolute value of a number, for example -34.56 becomes
|
||||
34.56. Takes a single integer and float value as an argument.
|
||||
EOS
|
||||
) do |arguments|
|
||||
|
||||
raise(Puppet::ParseError, "abs(): Wrong number of arguments " +
|
||||
"given (#{arguments.size} for 1)") if arguments.size < 1
|
||||
|
||||
value = arguments[0]
|
||||
|
||||
# Numbers in Puppet are often string-encoded which is troublesome ...
|
||||
if value.is_a?(String)
|
||||
if value.match(/^-?(?:\d+)(?:\.\d+){1}$/)
|
||||
value = value.to_f
|
||||
elsif value.match(/^-?\d+$/)
|
||||
value = value.to_i
|
||||
else
|
||||
raise(Puppet::ParseError, 'abs(): Requires float or ' +
|
||||
'integer to work with')
|
||||
end
|
||||
end
|
||||
|
||||
# We have numeric value to handle ...
|
||||
result = value.abs
|
||||
|
||||
return result
|
||||
end
|
||||
end
|
||||
|
||||
# vim: set ts=2 sw=2 et :
|
|
@ -1,33 +0,0 @@
|
|||
#
|
||||
# any2array.rb
|
||||
#
|
||||
|
||||
module Puppet::Parser::Functions
|
||||
newfunction(:any2array, :type => :rvalue, :doc => <<-EOS
|
||||
This converts any object to an array containing that object. Empty argument
|
||||
lists are converted to an empty array. Arrays are left untouched. Hashes are
|
||||
converted to arrays of alternating keys and values.
|
||||
EOS
|
||||
) do |arguments|
|
||||
|
||||
if arguments.empty?
|
||||
return []
|
||||
end
|
||||
|
||||
if arguments.length == 1
|
||||
if arguments[0].kind_of?(Array)
|
||||
return arguments[0]
|
||||
elsif arguments[0].kind_of?(Hash)
|
||||
result = []
|
||||
arguments[0].each do |key, value|
|
||||
result << key << value
|
||||
end
|
||||
return result
|
||||
end
|
||||
end
|
||||
|
||||
return arguments
|
||||
end
|
||||
end
|
||||
|
||||
# vim: set ts=2 sw=2 et :
|
|
@ -1,37 +0,0 @@
|
|||
module Puppet::Parser::Functions
|
||||
|
||||
newfunction(:base64, :type => :rvalue, :doc => <<-'ENDHEREDOC') do |args|
|
||||
|
||||
Base64 encode or decode a string based on the command and the string submitted
|
||||
|
||||
Usage:
|
||||
|
||||
$encodestring = base64('encode','thestring')
|
||||
$decodestring = base64('decode','dGhlc3RyaW5n')
|
||||
|
||||
ENDHEREDOC
|
||||
|
||||
require 'base64'
|
||||
|
||||
raise Puppet::ParseError, ("base64(): Wrong number of arguments (#{args.length}; must be = 2)") unless args.length == 2
|
||||
|
||||
actions = ['encode','decode']
|
||||
|
||||
unless actions.include?(args[0])
|
||||
raise Puppet::ParseError, ("base64(): the first argument must be one of 'encode' or 'decode'")
|
||||
end
|
||||
|
||||
unless args[1].is_a?(String)
|
||||
raise Puppet::ParseError, ("base64(): the second argument must be a string to base64")
|
||||
end
|
||||
|
||||
case args[0]
|
||||
when 'encode'
|
||||
result = Base64.encode64(args[1])
|
||||
when 'decode'
|
||||
result = Base64.decode64(args[1])
|
||||
end
|
||||
|
||||
return result
|
||||
end
|
||||
end
|
|
@ -1,49 +0,0 @@
|
|||
#
|
||||
# bool2num.rb
|
||||
#
|
||||
|
||||
module Puppet::Parser::Functions
|
||||
newfunction(:bool2num, :type => :rvalue, :doc => <<-EOS
|
||||
Converts a boolean to a number. Converts the values:
|
||||
false, f, 0, n, and no to 0
|
||||
true, t, 1, y, and yes to 1
|
||||
Requires a single boolean or string as an input.
|
||||
EOS
|
||||
) do |arguments|
|
||||
|
||||
raise(Puppet::ParseError, "bool2num(): Wrong number of arguments " +
|
||||
"given (#{arguments.size} for 1)") if arguments.size < 1
|
||||
|
||||
value = arguments[0]
|
||||
klass = value.class
|
||||
|
||||
# We can have either true or false, or string which resembles boolean ...
|
||||
unless [FalseClass, TrueClass, String].include?(klass)
|
||||
raise(Puppet::ParseError, 'bool2num(): Requires either ' +
|
||||
'boolean or string to work with')
|
||||
end
|
||||
|
||||
if value.is_a?(String)
|
||||
# We consider all the yes, no, y, n and so on too ...
|
||||
value = case value
|
||||
#
|
||||
# This is how undef looks like in Puppet ...
|
||||
# We yield 0 (or false if you wish) in this case.
|
||||
#
|
||||
when /^$/, '' then false # Empty string will be false ...
|
||||
when /^(1|t|y|true|yes)$/ then true
|
||||
when /^(0|f|n|false|no)$/ then false
|
||||
when /^(undef|undefined)$/ then false # This is not likely to happen ...
|
||||
else
|
||||
raise(Puppet::ParseError, 'bool2num(): Unknown type of boolean given')
|
||||
end
|
||||
end
|
||||
|
||||
# We have real boolean values as well ...
|
||||
result = value ? 1 : 0
|
||||
|
||||
return result
|
||||
end
|
||||
end
|
||||
|
||||
# vim: set ts=2 sw=2 et :
|
|
@ -1,34 +0,0 @@
|
|||
#
|
||||
# capitalize.rb
|
||||
#
|
||||
|
||||
module Puppet::Parser::Functions
|
||||
newfunction(:capitalize, :type => :rvalue, :doc => <<-EOS
|
||||
Capitalizes the first letter of a string or array of strings.
|
||||
Requires either a single string or an array as an input.
|
||||
EOS
|
||||
) do |arguments|
|
||||
|
||||
raise(Puppet::ParseError, "capitalize(): Wrong number of arguments " +
|
||||
"given (#{arguments.size} for 1)") if arguments.size < 1
|
||||
|
||||
value = arguments[0]
|
||||
klass = value.class
|
||||
|
||||
unless [Array, String].include?(klass)
|
||||
raise(Puppet::ParseError, 'capitalize(): Requires either ' +
|
||||
'array or string to work with')
|
||||
end
|
||||
|
||||
if value.is_a?(Array)
|
||||
# Numbers in Puppet are often string-encoded which is troublesome ...
|
||||
result = value.collect { |i| i.is_a?(String) ? i.capitalize : i }
|
||||
else
|
||||
result = value.capitalize
|
||||
end
|
||||
|
||||
return result
|
||||
end
|
||||
end
|
||||
|
||||
# vim: set ts=2 sw=2 et :
|
|
@ -1,35 +0,0 @@
|
|||
#
|
||||
# chomp.rb
|
||||
#
|
||||
|
||||
module Puppet::Parser::Functions
|
||||
newfunction(:chomp, :type => :rvalue, :doc => <<-'EOS'
|
||||
Removes the record separator from the end of a string or an array of
|
||||
strings, for example `hello\n` becomes `hello`.
|
||||
Requires a single string or array as an input.
|
||||
EOS
|
||||
) do |arguments|
|
||||
|
||||
raise(Puppet::ParseError, "chomp(): Wrong number of arguments " +
|
||||
"given (#{arguments.size} for 1)") if arguments.size < 1
|
||||
|
||||
value = arguments[0]
|
||||
klass = value.class
|
||||
|
||||
unless [Array, String].include?(klass)
|
||||
raise(Puppet::ParseError, 'chomp(): Requires either ' +
|
||||
'array or string to work with')
|
||||
end
|
||||
|
||||
if value.is_a?(Array)
|
||||
# Numbers in Puppet are often string-encoded which is troublesome ...
|
||||
result = value.collect { |i| i.is_a?(String) ? i.chomp : i }
|
||||
else
|
||||
result = value.chomp
|
||||
end
|
||||
|
||||
return result
|
||||
end
|
||||
end
|
||||
|
||||
# vim: set ts=2 sw=2 et :
|
|
@ -1,37 +0,0 @@
|
|||
#
|
||||
# chop.rb
|
||||
#
|
||||
|
||||
module Puppet::Parser::Functions
|
||||
newfunction(:chop, :type => :rvalue, :doc => <<-'EOS'
|
||||
Returns a new string with the last character removed. If the string ends
|
||||
with `\r\n`, both characters are removed. Applying chop to an empty
|
||||
string returns an empty string. If you wish to merely remove record
|
||||
separators then you should use the `chomp` function.
|
||||
Requires a string or array of strings as input.
|
||||
EOS
|
||||
) do |arguments|
|
||||
|
||||
raise(Puppet::ParseError, "chop(): Wrong number of arguments " +
|
||||
"given (#{arguments.size} for 1)") if arguments.size < 1
|
||||
|
||||
value = arguments[0]
|
||||
klass = value.class
|
||||
|
||||
unless [Array, String].include?(klass)
|
||||
raise(Puppet::ParseError, 'chop(): Requires either an ' +
|
||||
'array or string to work with')
|
||||
end
|
||||
|
||||
if value.is_a?(Array)
|
||||
# Numbers in Puppet are often string-encoded which is troublesome ...
|
||||
result = value.collect { |i| i.is_a?(String) ? i.chop : i }
|
||||
else
|
||||
result = value.chop
|
||||
end
|
||||
|
||||
return result
|
||||
end
|
||||
end
|
||||
|
||||
# vim: set ts=2 sw=2 et :
|
|
@ -1,41 +0,0 @@
|
|||
#
|
||||
# concat.rb
|
||||
#
|
||||
|
||||
module Puppet::Parser::Functions
|
||||
newfunction(:concat, :type => :rvalue, :doc => <<-EOS
|
||||
Appends the contents of array 2 onto array 1.
|
||||
|
||||
*Example:*
|
||||
|
||||
concat(['1','2','3'],['4','5','6'])
|
||||
|
||||
Would result in:
|
||||
|
||||
['1','2','3','4','5','6']
|
||||
EOS
|
||||
) do |arguments|
|
||||
|
||||
# Check that 2 arguments have been given ...
|
||||
raise(Puppet::ParseError, "concat(): Wrong number of arguments " +
|
||||
"given (#{arguments.size} for 2)") if arguments.size != 2
|
||||
|
||||
a = arguments[0]
|
||||
b = arguments[1]
|
||||
|
||||
# Check that the first parameter is an array
|
||||
unless a.is_a?(Array)
|
||||
raise(Puppet::ParseError, 'concat(): Requires array to work with')
|
||||
end
|
||||
|
||||
if b.is_a?(Array)
|
||||
result = a.concat(b)
|
||||
else
|
||||
result = a << b
|
||||
end
|
||||
|
||||
return result
|
||||
end
|
||||
end
|
||||
|
||||
# vim: set ts=2 sw=2 et :
|
|
@ -1,22 +0,0 @@
|
|||
module Puppet::Parser::Functions
|
||||
newfunction(:count, :type => :rvalue, :arity => -2, :doc => <<-EOS
|
||||
Takes an array as first argument and an optional second argument.
|
||||
Count the number of elements in array that matches second argument.
|
||||
If called with only an array it counts the number of elements that are not nil/undef.
|
||||
EOS
|
||||
) do |args|
|
||||
|
||||
if (args.size > 2) then
|
||||
raise(ArgumentError, "count(): Wrong number of arguments "+
|
||||
"given #{args.size} for 1 or 2.")
|
||||
end
|
||||
|
||||
collection, item = args
|
||||
|
||||
if item then
|
||||
collection.count item
|
||||
else
|
||||
collection.count { |obj| obj != nil && obj != :undef && obj != '' }
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,44 +0,0 @@
|
|||
module Puppet::Parser::Functions
|
||||
newfunction(:deep_merge, :type => :rvalue, :doc => <<-'ENDHEREDOC') do |args|
|
||||
Recursively merges two or more hashes together and returns the resulting hash.
|
||||
|
||||
For example:
|
||||
|
||||
$hash1 = {'one' => 1, 'two' => 2, 'three' => { 'four' => 4 } }
|
||||
$hash2 = {'two' => 'dos', 'three' => { 'five' => 5 } }
|
||||
$merged_hash = deep_merge($hash1, $hash2)
|
||||
# The resulting hash is equivalent to:
|
||||
# $merged_hash = { 'one' => 1, 'two' => 'dos', 'three' => { 'four' => 4, 'five' => 5 } }
|
||||
|
||||
When there is a duplicate key that is a hash, they are recursively merged.
|
||||
When there is a duplicate key that is not a hash, the key in the rightmost hash will "win."
|
||||
|
||||
ENDHEREDOC
|
||||
|
||||
if args.length < 2
|
||||
raise Puppet::ParseError, ("deep_merge(): wrong number of arguments (#{args.length}; must be at least 2)")
|
||||
end
|
||||
|
||||
deep_merge = Proc.new do |hash1,hash2|
|
||||
hash1.merge(hash2) do |key,old_value,new_value|
|
||||
if old_value.is_a?(Hash) && new_value.is_a?(Hash)
|
||||
deep_merge.call(old_value, new_value)
|
||||
else
|
||||
new_value
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
result = Hash.new
|
||||
args.each do |arg|
|
||||
next if arg.is_a? String and arg.empty? # empty string is synonym for puppet's undef
|
||||
# If the argument was not a hash, skip it.
|
||||
unless arg.is_a?(Hash)
|
||||
raise Puppet::ParseError, "deep_merge: unexpected argument type #{arg.class}, only expects hash arguments"
|
||||
end
|
||||
|
||||
result = deep_merge.call(result, arg)
|
||||
end
|
||||
return( result )
|
||||
end
|
||||
end
|
|
@ -1,35 +0,0 @@
|
|||
# Test whether a given class or definition is defined
|
||||
require 'puppet/parser/functions'
|
||||
|
||||
Puppet::Parser::Functions.newfunction(:defined_with_params,
|
||||
:type => :rvalue,
|
||||
:doc => <<-'ENDOFDOC'
|
||||
Takes a resource reference and an optional hash of attributes.
|
||||
|
||||
Returns true if a resource with the specified attributes has already been added
|
||||
to the catalog, and false otherwise.
|
||||
|
||||
user { 'dan':
|
||||
ensure => present,
|
||||
}
|
||||
|
||||
if ! defined_with_params(User[dan], {'ensure' => 'present' }) {
|
||||
user { 'dan': ensure => present, }
|
||||
}
|
||||
ENDOFDOC
|
||||
) do |vals|
|
||||
reference, params = vals
|
||||
raise(ArgumentError, 'Must specify a reference') unless reference
|
||||
if (! params) || params == ''
|
||||
params = {}
|
||||
end
|
||||
ret = false
|
||||
if resource = findresource(reference.to_s)
|
||||
matches = params.collect do |key, value|
|
||||
resource[key] == value
|
||||
end
|
||||
ret = params.empty? || !matches.include?(false)
|
||||
end
|
||||
Puppet.debug("Resource #{reference} was not determined to be defined")
|
||||
ret
|
||||
end
|
|
@ -1,46 +0,0 @@
|
|||
#
|
||||
# delete.rb
|
||||
#
|
||||
|
||||
# TODO(Krzysztof Wilczynski): We need to add support for regular expression ...
|
||||
|
||||
module Puppet::Parser::Functions
|
||||
newfunction(:delete, :type => :rvalue, :doc => <<-EOS
|
||||
Deletes all instances of a given element from an array, substring from a
|
||||
string, or key from a hash.
|
||||
|
||||
*Examples:*
|
||||
|
||||
delete(['a','b','c','b'], 'b')
|
||||
Would return: ['a','c']
|
||||
|
||||
delete({'a'=>1,'b'=>2,'c'=>3}, 'b')
|
||||
Would return: {'a'=>1,'c'=>3}
|
||||
|
||||
delete('abracadabra', 'bra')
|
||||
Would return: 'acada'
|
||||
EOS
|
||||
) do |arguments|
|
||||
|
||||
if (arguments.size != 2) then
|
||||
raise(Puppet::ParseError, "delete(): Wrong number of arguments "+
|
||||
"given #{arguments.size} for 2.")
|
||||
end
|
||||
|
||||
collection = arguments[0].dup
|
||||
item = arguments[1]
|
||||
|
||||
case collection
|
||||
when Array, Hash
|
||||
collection.delete item
|
||||
when String
|
||||
collection.gsub! item, ''
|
||||
else
|
||||
raise(TypeError, "delete(): First argument must be an Array, " +
|
||||
"String, or Hash. Given an argument of class #{collection.class}.")
|
||||
end
|
||||
collection
|
||||
end
|
||||
end
|
||||
|
||||
# vim: set ts=2 sw=2 et :
|
|
@ -1,49 +0,0 @@
|
|||
#
|
||||
# delete_at.rb
|
||||
#
|
||||
|
||||
module Puppet::Parser::Functions
|
||||
newfunction(:delete_at, :type => :rvalue, :doc => <<-EOS
|
||||
Deletes a determined indexed value from an array.
|
||||
|
||||
*Examples:*
|
||||
|
||||
delete_at(['a','b','c'], 1)
|
||||
|
||||
Would return: ['a','c']
|
||||
EOS
|
||||
) do |arguments|
|
||||
|
||||
raise(Puppet::ParseError, "delete_at(): Wrong number of arguments " +
|
||||
"given (#{arguments.size} for 2)") if arguments.size < 2
|
||||
|
||||
array = arguments[0]
|
||||
|
||||
unless array.is_a?(Array)
|
||||
raise(Puppet::ParseError, 'delete_at(): Requires array to work with')
|
||||
end
|
||||
|
||||
index = arguments[1]
|
||||
|
||||
if index.is_a?(String) and not index.match(/^\d+$/)
|
||||
raise(Puppet::ParseError, 'delete_at(): You must provide ' +
|
||||
'non-negative numeric index')
|
||||
end
|
||||
|
||||
result = array.clone
|
||||
|
||||
# Numbers in Puppet are often string-encoded which is troublesome ...
|
||||
index = index.to_i
|
||||
|
||||
if index > result.size - 1 # First element is at index 0 is it not?
|
||||
raise(Puppet::ParseError, 'delete_at(): Given index ' +
|
||||
'exceeds size of array given')
|
||||
end
|
||||
|
||||
result.delete_at(index) # We ignore the element that got deleted ...
|
||||
|
||||
return result
|
||||
end
|
||||
end
|
||||
|
||||
# vim: set ts=2 sw=2 et :
|
|
@ -1,34 +0,0 @@
|
|||
module Puppet::Parser::Functions
|
||||
newfunction(:delete_undef_values, :type => :rvalue, :doc => <<-EOS
|
||||
Returns a copy of input hash or array with all undefs deleted.
|
||||
|
||||
*Examples:*
|
||||
|
||||
$hash = delete_undef_values({a=>'A', b=>'', c=>undef, d => false})
|
||||
|
||||
Would return: {a => 'A', b => '', d => false}
|
||||
|
||||
$array = delete_undef_values(['A','',undef,false])
|
||||
|
||||
Would return: ['A','',false]
|
||||
|
||||
EOS
|
||||
) do |args|
|
||||
|
||||
raise(Puppet::ParseError,
|
||||
"delete_undef_values(): Wrong number of arguments given " +
|
||||
"(#{args.size})") if args.size < 1
|
||||
|
||||
unless args[0].is_a? Array or args[0].is_a? Hash
|
||||
raise(Puppet::ParseError,
|
||||
"delete_undef_values(): expected an array or hash, got #{args[0]} type #{args[0].class} ")
|
||||
end
|
||||
result = args[0].dup
|
||||
if result.is_a?(Hash)
|
||||
result.delete_if {|key, val| val.equal? :undef}
|
||||
elsif result.is_a?(Array)
|
||||
result.delete :undef
|
||||
end
|
||||
result
|
||||
end
|
||||
end
|
|
@ -1,26 +0,0 @@
|
|||
module Puppet::Parser::Functions
|
||||
newfunction(:delete_values, :type => :rvalue, :doc => <<-EOS
|
||||
Deletes all instances of a given value from a hash.
|
||||
|
||||
*Examples:*
|
||||
|
||||
delete_values({'a'=>'A','b'=>'B','c'=>'C','B'=>'D'}, 'B')
|
||||
|
||||
Would return: {'a'=>'A','c'=>'C','B'=>'D'}
|
||||
|
||||
EOS
|
||||
) do |arguments|
|
||||
|
||||
raise(Puppet::ParseError,
|
||||
"delete_values(): Wrong number of arguments given " +
|
||||
"(#{arguments.size} of 2)") if arguments.size != 2
|
||||
|
||||
hash, item = arguments
|
||||
|
||||
if not hash.is_a?(Hash)
|
||||
raise(TypeError, "delete_values(): First argument must be a Hash. " + \
|
||||
"Given an argument of class #{hash.class}.")
|
||||
end
|
||||
hash.dup.delete_if { |key, val| item == val }
|
||||
end
|
||||
end
|
|
@ -1,36 +0,0 @@
|
|||
#
|
||||
# difference.rb
|
||||
#
|
||||
|
||||
module Puppet::Parser::Functions
|
||||
newfunction(:difference, :type => :rvalue, :doc => <<-EOS
|
||||
This function returns the difference between two arrays.
|
||||
The returned array is a copy of the original array, removing any items that
|
||||
also appear in the second array.
|
||||
|
||||
*Examples:*
|
||||
|
||||
difference(["a","b","c"],["b","c","d"])
|
||||
|
||||
Would return: ["a"]
|
||||
EOS
|
||||
) do |arguments|
|
||||
|
||||
# Two arguments are required
|
||||
raise(Puppet::ParseError, "difference(): Wrong number of arguments " +
|
||||
"given (#{arguments.size} for 2)") if arguments.size != 2
|
||||
|
||||
first = arguments[0]
|
||||
second = arguments[1]
|
||||
|
||||
unless first.is_a?(Array) && second.is_a?(Array)
|
||||
raise(Puppet::ParseError, 'difference(): Requires 2 arrays')
|
||||
end
|
||||
|
||||
result = first - second
|
||||
|
||||
return result
|
||||
end
|
||||
end
|
||||
|
||||
# vim: set ts=2 sw=2 et :
|
|
@ -1,15 +0,0 @@
|
|||
module Puppet::Parser::Functions
|
||||
newfunction(:dirname, :type => :rvalue, :doc => <<-EOS
|
||||
Returns the dirname of a path.
|
||||
EOS
|
||||
) do |arguments|
|
||||
|
||||
raise(Puppet::ParseError, "dirname(): Wrong number of arguments " +
|
||||
"given (#{arguments.size} for 1)") if arguments.size < 1
|
||||
|
||||
path = arguments[0]
|
||||
return File.dirname(path)
|
||||
end
|
||||
end
|
||||
|
||||
# vim: set ts=2 sw=2 et :
|
|
@ -1,33 +0,0 @@
|
|||
#
|
||||
# downcase.rb
|
||||
#
|
||||
|
||||
module Puppet::Parser::Functions
|
||||
newfunction(:downcase, :type => :rvalue, :doc => <<-EOS
|
||||
Converts the case of a string or all strings in an array to lower case.
|
||||
EOS
|
||||
) do |arguments|
|
||||
|
||||
raise(Puppet::ParseError, "downcase(): Wrong number of arguments " +
|
||||
"given (#{arguments.size} for 1)") if arguments.size < 1
|
||||
|
||||
value = arguments[0]
|
||||
klass = value.class
|
||||
|
||||
unless [Array, String].include?(klass)
|
||||
raise(Puppet::ParseError, 'downcase(): Requires either ' +
|
||||
'array or string to work with')
|
||||
end
|
||||
|
||||
if value.is_a?(Array)
|
||||
# Numbers in Puppet are often string-encoded which is troublesome ...
|
||||
result = value.collect { |i| i.is_a?(String) ? i.downcase : i }
|
||||
else
|
||||
result = value.downcase
|
||||
end
|
||||
|
||||
return result
|
||||
end
|
||||
end
|
||||
|
||||
# vim: set ts=2 sw=2 et :
|
|
@ -1,28 +0,0 @@
|
|||
#
|
||||
# empty.rb
|
||||
#
|
||||
|
||||
module Puppet::Parser::Functions
|
||||
newfunction(:empty, :type => :rvalue, :doc => <<-EOS
|
||||
Returns true if the variable is empty.
|
||||
EOS
|
||||
) do |arguments|
|
||||
|
||||
raise(Puppet::ParseError, "empty(): Wrong number of arguments " +
|
||||
"given (#{arguments.size} for 1)") if arguments.size < 1
|
||||
|
||||
value = arguments[0]
|
||||
klass = value.class
|
||||
|
||||
unless [Array, Hash, String].include?(klass)
|
||||
raise(Puppet::ParseError, 'empty(): Requires either ' +
|
||||
'array, hash or string to work with')
|
||||
end
|
||||
|
||||
result = value.empty?
|
||||
|
||||
return result
|
||||
end
|
||||
end
|
||||
|
||||
# vim: set ts=2 sw=2 et :
|
|
@ -1,35 +0,0 @@
|
|||
#
|
||||
# ensure_packages.rb
|
||||
#
|
||||
|
||||
module Puppet::Parser::Functions
|
||||
newfunction(:ensure_packages, :type => :statement, :doc => <<-EOS
|
||||
Takes a list of packages and only installs them if they don't already exist.
|
||||
It optionally takes a hash as a second parameter that will be passed as the
|
||||
third argument to the ensure_resource() function.
|
||||
EOS
|
||||
) do |arguments|
|
||||
|
||||
if arguments.size > 2 or arguments.size == 0
|
||||
raise(Puppet::ParseError, "ensure_packages(): Wrong number of arguments " +
|
||||
"given (#{arguments.size} for 1 or 2)")
|
||||
elsif arguments.size == 2 and !arguments[1].is_a?(Hash)
|
||||
raise(Puppet::ParseError, 'ensure_packages(): Requires second argument to be a Hash')
|
||||
end
|
||||
|
||||
packages = Array(arguments[0])
|
||||
|
||||
if arguments[1]
|
||||
defaults = { 'ensure' => 'present' }.merge(arguments[1])
|
||||
else
|
||||
defaults = { 'ensure' => 'present' }
|
||||
end
|
||||
|
||||
Puppet::Parser::Functions.function(:ensure_resource)
|
||||
packages.each { |package_name|
|
||||
function_ensure_resource(['package', package_name, defaults ])
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
# vim: set ts=2 sw=2 et :
|
|
@ -1,45 +0,0 @@
|
|||
# Test whether a given class or definition is defined
|
||||
require 'puppet/parser/functions'
|
||||
|
||||
Puppet::Parser::Functions.newfunction(:ensure_resource,
|
||||
:type => :statement,
|
||||
:doc => <<-'ENDOFDOC'
|
||||
Takes a resource type, title, and a list of attributes that describe a
|
||||
resource.
|
||||
|
||||
user { 'dan':
|
||||
ensure => present,
|
||||
}
|
||||
|
||||
This example only creates the resource if it does not already exist:
|
||||
|
||||
ensure_resource('user', 'dan', {'ensure' => 'present' })
|
||||
|
||||
If the resource already exists but does not match the specified parameters,
|
||||
this function will attempt to recreate the resource leading to a duplicate
|
||||
resource definition error.
|
||||
|
||||
An array of resources can also be passed in and each will be created with
|
||||
the type and parameters specified if it doesn't already exist.
|
||||
|
||||
ensure_resource('user', ['dan','alex'], {'ensure' => 'present'})
|
||||
|
||||
ENDOFDOC
|
||||
) do |vals|
|
||||
type, title, params = vals
|
||||
raise(ArgumentError, 'Must specify a type') unless type
|
||||
raise(ArgumentError, 'Must specify a title') unless title
|
||||
params ||= {}
|
||||
|
||||
items = [title].flatten
|
||||
|
||||
items.each do |item|
|
||||
Puppet::Parser::Functions.function(:defined_with_params)
|
||||
if function_defined_with_params(["#{type}[#{item}]", params])
|
||||
Puppet.debug("Resource #{type}[#{item}] not created because it already exists")
|
||||
else
|
||||
Puppet::Parser::Functions.function(:create_resources)
|
||||
function_create_resources([type.capitalize, { item => params }])
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,33 +0,0 @@
|
|||
#
|
||||
# flatten.rb
|
||||
#
|
||||
|
||||
module Puppet::Parser::Functions
|
||||
newfunction(:flatten, :type => :rvalue, :doc => <<-EOS
|
||||
This function flattens any deeply nested arrays and returns a single flat array
|
||||
as a result.
|
||||
|
||||
*Examples:*
|
||||
|
||||
flatten(['a', ['b', ['c']]])
|
||||
|
||||
Would return: ['a','b','c']
|
||||
EOS
|
||||
) do |arguments|
|
||||
|
||||
raise(Puppet::ParseError, "flatten(): Wrong number of arguments " +
|
||||
"given (#{arguments.size} for 1)") if arguments.size != 1
|
||||
|
||||
array = arguments[0]
|
||||
|
||||
unless array.is_a?(Array)
|
||||
raise(Puppet::ParseError, 'flatten(): Requires array to work with')
|
||||
end
|
||||
|
||||
result = array.flatten
|
||||
|
||||
return result
|
||||
end
|
||||
end
|
||||
|
||||
# vim: set ts=2 sw=2 et :
|
|
@ -1,25 +0,0 @@
|
|||
module Puppet::Parser::Functions
|
||||
newfunction(:floor, :type => :rvalue, :doc => <<-EOS
|
||||
Returns the largest integer less or equal to the argument.
|
||||
Takes a single numeric value as an argument.
|
||||
EOS
|
||||
) do |arguments|
|
||||
|
||||
raise(Puppet::ParseError, "floor(): Wrong number of arguments " +
|
||||
"given (#{arguments.size} for 1)") if arguments.size != 1
|
||||
|
||||
begin
|
||||
arg = Float(arguments[0])
|
||||
rescue TypeError, ArgumentError => e
|
||||
raise(Puppet::ParseError, "floor(): Wrong argument type " +
|
||||
"given (#{arguments[0]} for Numeric)")
|
||||
end
|
||||
|
||||
raise(Puppet::ParseError, "floor(): Wrong argument type " +
|
||||
"given (#{arg.class} for Numeric)") if arg.is_a?(Numeric) == false
|
||||
|
||||
arg.floor
|
||||
end
|
||||
end
|
||||
|
||||
# vim: set ts=2 sw=2 et :
|
|
@ -1,46 +0,0 @@
|
|||
#
|
||||
# fqdn_rotate.rb
|
||||
#
|
||||
|
||||
module Puppet::Parser::Functions
|
||||
newfunction(:fqdn_rotate, :type => :rvalue, :doc => <<-EOS
|
||||
Rotates an array a random number of times based on a nodes fqdn.
|
||||
EOS
|
||||
) do |arguments|
|
||||
|
||||
raise(Puppet::ParseError, "fqdn_rotate(): Wrong number of arguments " +
|
||||
"given (#{arguments.size} for 1)") if arguments.size < 1
|
||||
|
||||
value = arguments[0]
|
||||
klass = value.class
|
||||
require 'digest/md5'
|
||||
|
||||
unless [Array, String].include?(klass)
|
||||
raise(Puppet::ParseError, 'fqdn_rotate(): Requires either ' +
|
||||
'array or string to work with')
|
||||
end
|
||||
|
||||
result = value.clone
|
||||
|
||||
string = value.is_a?(String) ? true : false
|
||||
|
||||
# Check whether it makes sense to rotate ...
|
||||
return result if result.size <= 1
|
||||
|
||||
# We turn any string value into an array to be able to rotate ...
|
||||
result = string ? result.split('') : result
|
||||
|
||||
elements = result.size
|
||||
|
||||
srand(Digest::MD5.hexdigest([lookupvar('::fqdn'),arguments].join(':')).hex)
|
||||
rand(elements).times {
|
||||
result.push result.shift
|
||||
}
|
||||
|
||||
result = string ? result.join : result
|
||||
|
||||
return result
|
||||
end
|
||||
end
|
||||
|
||||
# vim: set ts=2 sw=2 et :
|
|
@ -1,17 +0,0 @@
|
|||
module Puppet::Parser::Functions
|
||||
newfunction(:get_module_path, :type =>:rvalue, :doc => <<-EOT
|
||||
Returns the absolute path of the specified module for the current
|
||||
environment.
|
||||
|
||||
Example:
|
||||
$module_path = get_module_path('stdlib')
|
||||
EOT
|
||||
) do |args|
|
||||
raise(Puppet::ParseError, "get_module_path(): Wrong number of arguments, expects one") unless args.size == 1
|
||||
if module_path = Puppet::Module.find(args[0], compiler.environment.to_s)
|
||||
module_path.path
|
||||
else
|
||||
raise(Puppet::ParseError, "Could not find module #{args[0]} in environment #{compiler.environment}")
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,35 +0,0 @@
|
|||
# Test whether a given class or definition is defined
|
||||
require 'puppet/parser/functions'
|
||||
|
||||
Puppet::Parser::Functions.newfunction(:getparam,
|
||||
:type => :rvalue,
|
||||
:doc => <<-'ENDOFDOC'
|
||||
Takes a resource reference and name of the parameter and
|
||||
returns value of resource's parameter.
|
||||
|
||||
*Examples:*
|
||||
|
||||
define example_resource($param) {
|
||||
}
|
||||
|
||||
example_resource { "example_resource_instance":
|
||||
param => "param_value"
|
||||
}
|
||||
|
||||
getparam(Example_resource["example_resource_instance"], "param")
|
||||
|
||||
Would return: param_value
|
||||
ENDOFDOC
|
||||
) do |vals|
|
||||
reference, param = vals
|
||||
raise(ArgumentError, 'Must specify a reference') unless reference
|
||||
raise(ArgumentError, 'Must specify name of a parameter') unless param and param.instance_of? String
|
||||
|
||||
return '' if param.empty?
|
||||
|
||||
if resource = findresource(reference.to_s)
|
||||
return resource[param] if resource[param]
|
||||
end
|
||||
|
||||
return ''
|
||||
end
|
|
@ -1,26 +0,0 @@
|
|||
module Puppet::Parser::Functions
|
||||
|
||||
newfunction(:getvar, :type => :rvalue, :doc => <<-'ENDHEREDOC') do |args|
|
||||
Lookup a variable in a remote namespace.
|
||||
|
||||
For example:
|
||||
|
||||
$foo = getvar('site::data::foo')
|
||||
# Equivalent to $foo = $site::data::foo
|
||||
|
||||
This is useful if the namespace itself is stored in a string:
|
||||
|
||||
$datalocation = 'site::data'
|
||||
$bar = getvar("${datalocation}::bar")
|
||||
# Equivalent to $bar = $site::data::bar
|
||||
ENDHEREDOC
|
||||
|
||||
unless args.length == 1
|
||||
raise Puppet::ParseError, ("getvar(): wrong number of arguments (#{args.length}; must be 1)")
|
||||
end
|
||||
|
||||
self.lookupvar("#{args[0]}")
|
||||
|
||||
end
|
||||
|
||||
end
|
|
@ -1,33 +0,0 @@
|
|||
#
|
||||
# grep.rb
|
||||
#
|
||||
|
||||
module Puppet::Parser::Functions
|
||||
newfunction(:grep, :type => :rvalue, :doc => <<-EOS
|
||||
This function searches through an array and returns any elements that match
|
||||
the provided regular expression.
|
||||
|
||||
*Examples:*
|
||||
|
||||
grep(['aaa','bbb','ccc','aaaddd'], 'aaa')
|
||||
|
||||
Would return:
|
||||
|
||||
['aaa','aaaddd']
|
||||
EOS
|
||||
) do |arguments|
|
||||
|
||||
if (arguments.size != 2) then
|
||||
raise(Puppet::ParseError, "grep(): Wrong number of arguments "+
|
||||
"given #{arguments.size} for 2")
|
||||
end
|
||||
|
||||
a = arguments[0]
|
||||
pattern = Regexp.new(arguments[1])
|
||||
|
||||
a.grep(pattern)
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
# vim: set ts=2 sw=2 et :
|
|
@ -1,52 +0,0 @@
|
|||
#
|
||||
# has_interface_with
|
||||
#
|
||||
|
||||
module Puppet::Parser::Functions
|
||||
newfunction(:has_interface_with, :type => :rvalue, :doc => <<-EOS
|
||||
Returns boolean based on kind and value:
|
||||
* macaddress
|
||||
* netmask
|
||||
* ipaddress
|
||||
* network
|
||||
|
||||
has_interface_with("macaddress", "x:x:x:x:x:x")
|
||||
has_interface_with("ipaddress", "127.0.0.1") => true
|
||||
etc.
|
||||
|
||||
If no "kind" is given, then the presence of the interface is checked:
|
||||
has_interface_with("lo") => true
|
||||
EOS
|
||||
) do |args|
|
||||
|
||||
raise(Puppet::ParseError, "has_interface_with(): Wrong number of arguments " +
|
||||
"given (#{args.size} for 1 or 2)") if args.size < 1 or args.size > 2
|
||||
|
||||
interfaces = lookupvar('interfaces')
|
||||
|
||||
# If we do not have any interfaces, then there are no requested attributes
|
||||
return false if (interfaces == :undefined)
|
||||
|
||||
interfaces = interfaces.split(',')
|
||||
|
||||
if args.size == 1
|
||||
return interfaces.member?(args[0])
|
||||
end
|
||||
|
||||
kind, value = args
|
||||
|
||||
if lookupvar(kind) == value
|
||||
return true
|
||||
end
|
||||
|
||||
result = false
|
||||
interfaces.each do |iface|
|
||||
if value == lookupvar("#{kind}_#{iface}")
|
||||
result = true
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
result
|
||||
end
|
||||
end
|
|
@ -1,25 +0,0 @@
|
|||
#
|
||||
# has_ip_address
|
||||
#
|
||||
|
||||
module Puppet::Parser::Functions
|
||||
newfunction(:has_ip_address, :type => :rvalue, :doc => <<-EOS
|
||||
Returns true if the client has the requested IP address on some interface.
|
||||
|
||||
This function iterates through the 'interfaces' fact and checks the
|
||||
'ipaddress_IFACE' facts, performing a simple string comparison.
|
||||
EOS
|
||||
) do |args|
|
||||
|
||||
raise(Puppet::ParseError, "has_ip_address(): Wrong number of arguments " +
|
||||
"given (#{args.size} for 1)") if args.size != 1
|
||||
|
||||
Puppet::Parser::Functions.autoloader.load(:has_interface_with) \
|
||||
unless Puppet::Parser::Functions.autoloader.loaded?(:has_interface_with)
|
||||
|
||||
function_has_interface_with(['ipaddress', args[0]])
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
# vim:sts=2 sw=2
|
|
@ -1,25 +0,0 @@
|
|||
#
|
||||
# has_ip_network
|
||||
#
|
||||
|
||||
module Puppet::Parser::Functions
|
||||
newfunction(:has_ip_network, :type => :rvalue, :doc => <<-EOS
|
||||
Returns true if the client has an IP address within the requested network.
|
||||
|
||||
This function iterates through the 'interfaces' fact and checks the
|
||||
'network_IFACE' facts, performing a simple string comparision.
|
||||
EOS
|
||||
) do |args|
|
||||
|
||||
raise(Puppet::ParseError, "has_ip_network(): Wrong number of arguments " +
|
||||
"given (#{args.size} for 1)") if args.size != 1
|
||||
|
||||
Puppet::Parser::Functions.autoloader.load(:has_interface_with) \
|
||||
unless Puppet::Parser::Functions.autoloader.loaded?(:has_interface_with)
|
||||
|
||||
function_has_interface_with(['network', args[0]])
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
# vim:sts=2 sw=2
|
|
@ -1,28 +0,0 @@
|
|||
module Puppet::Parser::Functions
|
||||
|
||||
newfunction(:has_key, :type => :rvalue, :doc => <<-'ENDHEREDOC') do |args|
|
||||
Determine if a hash has a certain key value.
|
||||
|
||||
Example:
|
||||
|
||||
$my_hash = {'key_one' => 'value_one'}
|
||||
if has_key($my_hash, 'key_two') {
|
||||
notice('we will not reach here')
|
||||
}
|
||||
if has_key($my_hash, 'key_one') {
|
||||
notice('this will be printed')
|
||||
}
|
||||
|
||||
ENDHEREDOC
|
||||
|
||||
unless args.length == 2
|
||||
raise Puppet::ParseError, ("has_key(): wrong number of arguments (#{args.length}; must be 2)")
|
||||
end
|
||||
unless args[0].is_a?(Hash)
|
||||
raise Puppet::ParseError, "has_key(): expects the first argument to be a hash, got #{args[0].inspect} which is of type #{args[0].class}"
|
||||
end
|
||||
args[0].has_key?(args[1])
|
||||
|
||||
end
|
||||
|
||||
end
|
|
@ -1,41 +0,0 @@
|
|||
#
|
||||
# hash.rb
|
||||
#
|
||||
|
||||
module Puppet::Parser::Functions
|
||||
newfunction(:hash, :type => :rvalue, :doc => <<-EOS
|
||||
This function converts an array into a hash.
|
||||
|
||||
*Examples:*
|
||||
|
||||
hash(['a',1,'b',2,'c',3])
|
||||
|
||||
Would return: {'a'=>1,'b'=>2,'c'=>3}
|
||||
EOS
|
||||
) do |arguments|
|
||||
|
||||
raise(Puppet::ParseError, "hash(): Wrong number of arguments " +
|
||||
"given (#{arguments.size} for 1)") if arguments.size < 1
|
||||
|
||||
array = arguments[0]
|
||||
|
||||
unless array.is_a?(Array)
|
||||
raise(Puppet::ParseError, 'hash(): Requires array to work with')
|
||||
end
|
||||
|
||||
result = {}
|
||||
|
||||
begin
|
||||
# This is to make it compatible with older version of Ruby ...
|
||||
array = array.flatten
|
||||
result = Hash[*array]
|
||||
rescue Exception
|
||||
raise(Puppet::ParseError, 'hash(): Unable to compute ' +
|
||||
'hash from array given')
|
||||
end
|
||||
|
||||
return result
|
||||
end
|
||||
end
|
||||
|
||||
# vim: set ts=2 sw=2 et :
|
|
@ -1,34 +0,0 @@
|
|||
#
|
||||
# intersection.rb
|
||||
#
|
||||
|
||||
module Puppet::Parser::Functions
|
||||
newfunction(:intersection, :type => :rvalue, :doc => <<-EOS
|
||||
This function returns an array an intersection of two.
|
||||
|
||||
*Examples:*
|
||||
|
||||
intersection(["a","b","c"],["b","c","d"])
|
||||
|
||||
Would return: ["b","c"]
|
||||
EOS
|
||||
) do |arguments|
|
||||
|
||||
# Two arguments are required
|
||||
raise(Puppet::ParseError, "intersection(): Wrong number of arguments " +
|
||||
"given (#{arguments.size} for 2)") if arguments.size != 2
|
||||
|
||||
first = arguments[0]
|
||||
second = arguments[1]
|
||||
|
||||
unless first.is_a?(Array) && second.is_a?(Array)
|
||||
raise(Puppet::ParseError, 'intersection(): Requires 2 arrays')
|
||||
end
|
||||
|
||||
result = first & second
|
||||
|
||||
return result
|
||||
end
|
||||
end
|
||||
|
||||
# vim: set ts=2 sw=2 et :
|
|
@ -1,22 +0,0 @@
|
|||
#
|
||||
# is_array.rb
|
||||
#
|
||||
|
||||
module Puppet::Parser::Functions
|
||||
newfunction(:is_array, :type => :rvalue, :doc => <<-EOS
|
||||
Returns true if the variable passed to this function is an array.
|
||||
EOS
|
||||
) do |arguments|
|
||||
|
||||
raise(Puppet::ParseError, "is_array(): Wrong number of arguments " +
|
||||
"given (#{arguments.size} for 1)") if arguments.size < 1
|
||||
|
||||
type = arguments[0]
|
||||
|
||||
result = type.is_a?(Array)
|
||||
|
||||
return result
|
||||
end
|
||||
end
|
||||
|
||||
# vim: set ts=2 sw=2 et :
|
|
@ -1,22 +0,0 @@
|
|||
#
|
||||
# is_bool.rb
|
||||
#
|
||||
|
||||
module Puppet::Parser::Functions
|
||||
newfunction(:is_bool, :type => :rvalue, :doc => <<-EOS
|
||||
Returns true if the variable passed to this function is a boolean.
|
||||
EOS
|
||||
) do |arguments|
|
||||
|
||||
raise(Puppet::ParseError, "is_bool(): Wrong number of arguments " +
|
||||
"given (#{arguments.size} for 1)") if arguments.size != 1
|
||||
|
||||
type = arguments[0]
|
||||
|
||||
result = type.is_a?(TrueClass) || type.is_a?(FalseClass)
|
||||
|
||||
return result
|
||||
end
|
||||
end
|
||||
|
||||
# vim: set ts=2 sw=2 et :
|
|
@ -1,50 +0,0 @@
|
|||
#
|
||||
# is_domain_name.rb
|
||||
#
|
||||
|
||||
module Puppet::Parser::Functions
|
||||
newfunction(:is_domain_name, :type => :rvalue, :doc => <<-EOS
|
||||
Returns true if the string passed to this function is a syntactically correct domain name.
|
||||
EOS
|
||||
) do |arguments|
|
||||
|
||||
if (arguments.size != 1) then
|
||||
raise(Puppet::ParseError, "is_domain_name(): Wrong number of arguments "+
|
||||
"given #{arguments.size} for 1")
|
||||
end
|
||||
|
||||
domain = arguments[0]
|
||||
|
||||
# Limits (rfc1035, 3.1)
|
||||
domain_max_length=255
|
||||
label_min_length=1
|
||||
label_max_length=63
|
||||
|
||||
# Only allow string types
|
||||
return false unless domain.is_a?(String)
|
||||
|
||||
# Allow ".", it is the top level domain
|
||||
return true if domain == '.'
|
||||
|
||||
# Remove the final dot, if present.
|
||||
domain.chomp!('.')
|
||||
|
||||
# Check the whole domain
|
||||
return false if domain.empty?
|
||||
return false if domain.length > domain_max_length
|
||||
|
||||
# Check each label in the domain
|
||||
labels = domain.split('.')
|
||||
vlabels = labels.each do |label|
|
||||
break if label.length < label_min_length
|
||||
break if label.length > label_max_length
|
||||
break if label[-1..-1] == '-'
|
||||
break if label[0..0] == '-'
|
||||
break unless /^[a-z\d-]+$/i.match(label)
|
||||
end
|
||||
return vlabels == labels
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
# vim: set ts=2 sw=2 et :
|
|
@ -1,30 +0,0 @@
|
|||
#
|
||||
# is_float.rb
|
||||
#
|
||||
|
||||
module Puppet::Parser::Functions
|
||||
newfunction(:is_float, :type => :rvalue, :doc => <<-EOS
|
||||
Returns true if the variable passed to this function is a float.
|
||||
EOS
|
||||
) do |arguments|
|
||||
|
||||
if (arguments.size != 1) then
|
||||
raise(Puppet::ParseError, "is_float(): Wrong number of arguments "+
|
||||
"given #{arguments.size} for 1")
|
||||
end
|
||||
|
||||
value = arguments[0]
|
||||
|
||||
# Only allow Numeric or String types
|
||||
return false unless value.is_a?(Numeric) or value.is_a?(String)
|
||||
|
||||
if value != value.to_f.to_s and !value.is_a? Float then
|
||||
return false
|
||||
else
|
||||
return true
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
# vim: set ts=2 sw=2 et :
|
|
@ -1,26 +0,0 @@
|
|||
#
|
||||
# is_function_available.rb
|
||||
#
|
||||
|
||||
module Puppet::Parser::Functions
|
||||
newfunction(:is_function_available, :type => :rvalue, :doc => <<-EOS
|
||||
This function accepts a string as an argument, determines whether the
|
||||
Puppet runtime has access to a function by that name. It returns a
|
||||
true if the function exists, false if not.
|
||||
EOS
|
||||
) do |arguments|
|
||||
|
||||
if (arguments.size != 1) then
|
||||
raise(Puppet::ParseError, "is_function_available?(): Wrong number of arguments "+
|
||||
"given #{arguments.size} for 1")
|
||||
end
|
||||
|
||||
# Only allow String types
|
||||
return false unless arguments[0].is_a?(String)
|
||||
|
||||
function = Puppet::Parser::Functions.function(arguments[0].to_sym)
|
||||
function.is_a?(String) and not function.empty?
|
||||
end
|
||||
end
|
||||
|
||||
# vim: set ts=2 sw=2 et :
|
|
@ -1,22 +0,0 @@
|
|||
#
|
||||
# is_hash.rb
|
||||
#
|
||||
|
||||
module Puppet::Parser::Functions
|
||||
newfunction(:is_hash, :type => :rvalue, :doc => <<-EOS
|
||||
Returns true if the variable passed to this function is a hash.
|
||||
EOS
|
||||
) do |arguments|
|
||||
|
||||
raise(Puppet::ParseError, "is_hash(): Wrong number of arguments " +
|
||||
"given (#{arguments.size} for 1)") if arguments.size != 1
|
||||
|
||||
type = arguments[0]
|
||||
|
||||
result = type.is_a?(Hash)
|
||||
|
||||
return result
|
||||
end
|
||||
end
|
||||
|
||||
# vim: set ts=2 sw=2 et :
|
|
@ -1,45 +0,0 @@
|
|||
#
|
||||
# is_integer.rb
|
||||
#
|
||||
|
||||
module Puppet::Parser::Functions
|
||||
newfunction(:is_integer, :type => :rvalue, :doc => <<-EOS
|
||||
Returns true if the variable passed to this function is an Integer or
|
||||
a decimal (base 10) integer in String form. The string may
|
||||
start with a '-' (minus). A value of '0' is allowed, but a leading '0' digit may not
|
||||
be followed by other digits as this indicates that the value is octal (base 8).
|
||||
|
||||
If given any other argument `false` is returned.
|
||||
EOS
|
||||
) do |arguments|
|
||||
|
||||
if (arguments.size != 1) then
|
||||
raise(Puppet::ParseError, "is_integer(): Wrong number of arguments "+
|
||||
"given #{arguments.size} for 1")
|
||||
end
|
||||
|
||||
value = arguments[0]
|
||||
|
||||
# Regex is taken from the lexer of puppet
|
||||
# puppet/pops/parser/lexer.rb but modified to match also
|
||||
# negative values and disallow numbers prefixed with multiple
|
||||
# 0's
|
||||
#
|
||||
# TODO these parameter should be a constant but I'm not sure
|
||||
# if there is no risk to declare it inside of the module
|
||||
# Puppet::Parser::Functions
|
||||
|
||||
# Integer numbers like
|
||||
# -1234568981273
|
||||
# 47291
|
||||
numeric = %r{^-?(?:(?:[1-9]\d*)|0)$}
|
||||
|
||||
if value.is_a? Integer or (value.is_a? String and value.match numeric)
|
||||
return true
|
||||
else
|
||||
return false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# vim: set ts=2 sw=2 et :
|
|
@ -1,32 +0,0 @@
|
|||
#
|
||||
# is_ip_address.rb
|
||||
#
|
||||
|
||||
module Puppet::Parser::Functions
|
||||
newfunction(:is_ip_address, :type => :rvalue, :doc => <<-EOS
|
||||
Returns true if the string passed to this function is a valid IP address.
|
||||
EOS
|
||||
) do |arguments|
|
||||
|
||||
require 'ipaddr'
|
||||
|
||||
if (arguments.size != 1) then
|
||||
raise(Puppet::ParseError, "is_ip_address(): Wrong number of arguments "+
|
||||
"given #{arguments.size} for 1")
|
||||
end
|
||||
|
||||
begin
|
||||
ip = IPAddr.new(arguments[0])
|
||||
rescue ArgumentError
|
||||
return false
|
||||
end
|
||||
|
||||
if ip.ipv4? or ip.ipv6? then
|
||||
return true
|
||||
else
|
||||
return false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# vim: set ts=2 sw=2 et :
|
|
@ -1,27 +0,0 @@
|
|||
#
|
||||
# is_mac_address.rb
|
||||
#
|
||||
|
||||
module Puppet::Parser::Functions
|
||||
newfunction(:is_mac_address, :type => :rvalue, :doc => <<-EOS
|
||||
Returns true if the string passed to this function is a valid mac address.
|
||||
EOS
|
||||
) do |arguments|
|
||||
|
||||
if (arguments.size != 1) then
|
||||
raise(Puppet::ParseError, "is_mac_address(): Wrong number of arguments "+
|
||||
"given #{arguments.size} for 1")
|
||||
end
|
||||
|
||||
mac = arguments[0]
|
||||
|
||||
if /^[a-fA-F0-9]{1,2}:[a-fA-F0-9]{1,2}:[a-fA-F0-9]{1,2}:[a-fA-F0-9]{1,2}:[a-fA-F0-9]{1,2}:[a-fA-F0-9]{1,2}$/.match(mac) then
|
||||
return true
|
||||
else
|
||||
return false
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
# vim: set ts=2 sw=2 et :
|
|
@ -1,75 +0,0 @@
|
|||
#
|
||||
# is_numeric.rb
|
||||
#
|
||||
|
||||
module Puppet::Parser::Functions
|
||||
newfunction(:is_numeric, :type => :rvalue, :doc => <<-EOS
|
||||
Returns true if the given argument is a Numeric (Integer or Float),
|
||||
or a String containing either a valid integer in decimal base 10 form, or
|
||||
a valid floating point string representation.
|
||||
|
||||
The function recognizes only decimal (base 10) integers and float but not
|
||||
integers in hex (base 16) or octal (base 8) form.
|
||||
|
||||
The string representation may start with a '-' (minus). If a decimal '.' is used,
|
||||
it must be followed by at least one digit.
|
||||
|
||||
Valid examples:
|
||||
|
||||
77435
|
||||
10e-12
|
||||
-8475
|
||||
0.2343
|
||||
-23.561e3
|
||||
EOS
|
||||
) do |arguments|
|
||||
|
||||
if (arguments.size != 1) then
|
||||
raise(Puppet::ParseError, "is_numeric(): Wrong number of arguments "+
|
||||
"given #{arguments.size} for 1")
|
||||
end
|
||||
|
||||
value = arguments[0]
|
||||
|
||||
# Regex is taken from the lexer of puppet
|
||||
# puppet/pops/parser/lexer.rb but modified to match also
|
||||
# negative values and disallow invalid octal numbers or
|
||||
# numbers prefixed with multiple 0's (except in hex numbers)
|
||||
#
|
||||
# TODO these parameters should be constants but I'm not sure
|
||||
# if there is no risk to declare them inside of the module
|
||||
# Puppet::Parser::Functions
|
||||
|
||||
# TODO decide if this should be used
|
||||
# HEX numbers like
|
||||
# 0xaa230F
|
||||
# 0X1234009C
|
||||
# 0x0012
|
||||
# -12FcD
|
||||
#numeric_hex = %r{^-?0[xX][0-9A-Fa-f]+$}
|
||||
|
||||
# TODO decide if this should be used
|
||||
# OCTAL numbers like
|
||||
# 01234567
|
||||
# -045372
|
||||
#numeric_oct = %r{^-?0[1-7][0-7]*$}
|
||||
|
||||
# Integer/Float numbers like
|
||||
# -0.1234568981273
|
||||
# 47291
|
||||
# 42.12345e-12
|
||||
numeric = %r{^-?(?:(?:[1-9]\d*)|0)(?:\.\d+)?(?:[eE]-?\d+)?$}
|
||||
|
||||
if value.is_a? Numeric or (value.is_a? String and (
|
||||
value.match(numeric) #or
|
||||
# value.match(numeric_hex) or
|
||||
# value.match(numeric_oct)
|
||||
))
|
||||
return true
|
||||
else
|
||||
return false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# vim: set ts=2 sw=2 et :
|
|
@ -1,26 +0,0 @@
|
|||
#
|
||||
# is_string.rb
|
||||
#
|
||||
|
||||
module Puppet::Parser::Functions
|
||||
newfunction(:is_string, :type => :rvalue, :doc => <<-EOS
|
||||
Returns true if the variable passed to this function is a string.
|
||||
EOS
|
||||
) do |arguments|
|
||||
|
||||
raise(Puppet::ParseError, "is_string(): Wrong number of arguments " +
|
||||
"given (#{arguments.size} for 1)") if arguments.size < 1
|
||||
|
||||
type = arguments[0]
|
||||
|
||||
result = type.is_a?(String)
|
||||
|
||||
if result and (type == type.to_f.to_s or type == type.to_i.to_s) then
|
||||
return false
|
||||
end
|
||||
|
||||
return result
|
||||
end
|
||||
end
|
||||
|
||||
# vim: set ts=2 sw=2 et :
|
|
@ -1,41 +0,0 @@
|
|||
#
|
||||
# join.rb
|
||||
#
|
||||
|
||||
module Puppet::Parser::Functions
|
||||
newfunction(:join, :type => :rvalue, :doc => <<-EOS
|
||||
This function joins an array into a string using a separator.
|
||||
|
||||
*Examples:*
|
||||
|
||||
join(['a','b','c'], ",")
|
||||
|
||||
Would result in: "a,b,c"
|
||||
EOS
|
||||
) do |arguments|
|
||||
|
||||
# Technically we support two arguments but only first is mandatory ...
|
||||
raise(Puppet::ParseError, "join(): Wrong number of arguments " +
|
||||
"given (#{arguments.size} for 1)") if arguments.size < 1
|
||||
|
||||
array = arguments[0]
|
||||
|
||||
unless array.is_a?(Array)
|
||||
raise(Puppet::ParseError, 'join(): Requires array to work with')
|
||||
end
|
||||
|
||||
suffix = arguments[1] if arguments[1]
|
||||
|
||||
if suffix
|
||||
unless suffix.is_a?(String)
|
||||
raise(Puppet::ParseError, 'join(): Requires string to work with')
|
||||
end
|
||||
end
|
||||
|
||||
result = suffix ? array.join(suffix) : array.join
|
||||
|
||||
return result
|
||||
end
|
||||
end
|
||||
|
||||
# vim: set ts=2 sw=2 et :
|
|
@ -1,47 +0,0 @@
|
|||
#
|
||||
# join.rb
|
||||
#
|
||||
|
||||
module Puppet::Parser::Functions
|
||||
newfunction(:join_keys_to_values, :type => :rvalue, :doc => <<-EOS
|
||||
This function joins each key of a hash to that key's corresponding value with a
|
||||
separator. Keys and values are cast to strings. The return value is an array in
|
||||
which each element is one joined key/value pair.
|
||||
|
||||
*Examples:*
|
||||
|
||||
join_keys_to_values({'a'=>1,'b'=>2}, " is ")
|
||||
|
||||
Would result in: ["a is 1","b is 2"]
|
||||
EOS
|
||||
) do |arguments|
|
||||
|
||||
# Validate the number of arguments.
|
||||
if arguments.size != 2
|
||||
raise(Puppet::ParseError, "join_keys_to_values(): Takes exactly two " +
|
||||
"arguments, but #{arguments.size} given.")
|
||||
end
|
||||
|
||||
# Validate the first argument.
|
||||
hash = arguments[0]
|
||||
if not hash.is_a?(Hash)
|
||||
raise(TypeError, "join_keys_to_values(): The first argument must be a " +
|
||||
"hash, but a #{hash.class} was given.")
|
||||
end
|
||||
|
||||
# Validate the second argument.
|
||||
separator = arguments[1]
|
||||
if not separator.is_a?(String)
|
||||
raise(TypeError, "join_keys_to_values(): The second argument must be a " +
|
||||
"string, but a #{separator.class} was given.")
|
||||
end
|
||||
|
||||
# Join the keys to their values.
|
||||
hash.map do |k,v|
|
||||
String(k) + separator + String(v)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
# vim: set ts=2 sw=2 et :
|
|
@ -1,26 +0,0 @@
|
|||
#
|
||||
# keys.rb
|
||||
#
|
||||
|
||||
module Puppet::Parser::Functions
|
||||
newfunction(:keys, :type => :rvalue, :doc => <<-EOS
|
||||
Returns the keys of a hash as an array.
|
||||
EOS
|
||||
) do |arguments|
|
||||
|
||||
raise(Puppet::ParseError, "keys(): Wrong number of arguments " +
|
||||
"given (#{arguments.size} for 1)") if arguments.size < 1
|
||||
|
||||
hash = arguments[0]
|
||||
|
||||
unless hash.is_a?(Hash)
|
||||
raise(Puppet::ParseError, 'keys(): Requires hash to work with')
|
||||
end
|
||||
|
||||
result = hash.keys
|
||||
|
||||
return result
|
||||
end
|
||||
end
|
||||
|
||||
# vim: set ts=2 sw=2 et :
|
|
@ -1,20 +0,0 @@
|
|||
module Puppet::Parser::Functions
|
||||
|
||||
newfunction(:loadyaml, :type => :rvalue, :doc => <<-'ENDHEREDOC') do |args|
|
||||
Load a YAML file containing an array, string, or hash, and return the data
|
||||
in the corresponding native data type.
|
||||
|
||||
For example:
|
||||
|
||||
$myhash = loadyaml('/etc/puppet/data/myhash.yaml')
|
||||
ENDHEREDOC
|
||||
|
||||
unless args.length == 1
|
||||
raise Puppet::ParseError, ("loadyaml(): wrong number of arguments (#{args.length}; must be 1)")
|
||||
end
|
||||
|
||||
YAML.load_file(args[0])
|
||||
|
||||
end
|
||||
|
||||
end
|
|
@ -1,33 +0,0 @@
|
|||
#
|
||||
# lstrip.rb
|
||||
#
|
||||
|
||||
module Puppet::Parser::Functions
|
||||
newfunction(:lstrip, :type => :rvalue, :doc => <<-EOS
|
||||
Strips leading spaces to the left of a string.
|
||||
EOS
|
||||
) do |arguments|
|
||||
|
||||
raise(Puppet::ParseError, "lstrip(): Wrong number of arguments " +
|
||||
"given (#{arguments.size} for 1)") if arguments.size < 1
|
||||
|
||||
value = arguments[0]
|
||||
klass = value.class
|
||||
|
||||
unless [Array, String].include?(klass)
|
||||
raise(Puppet::ParseError, 'lstrip(): Requires either ' +
|
||||
'array or string to work with')
|
||||
end
|
||||
|
||||
if value.is_a?(Array)
|
||||
# Numbers in Puppet are often string-encoded which is troublesome ...
|
||||
result = value.collect { |i| i.is_a?(String) ? i.lstrip : i }
|
||||
else
|
||||
result = value.lstrip
|
||||
end
|
||||
|
||||
return result
|
||||
end
|
||||
end
|
||||
|
||||
# vim: set ts=2 sw=2 et :
|
|
@ -1,21 +0,0 @@
|
|||
module Puppet::Parser::Functions
|
||||
newfunction(:max, :type => :rvalue, :doc => <<-EOS
|
||||
Returns the highest value of all arguments.
|
||||
Requires at least one argument.
|
||||
EOS
|
||||
) do |args|
|
||||
|
||||
raise(Puppet::ParseError, "max(): Wrong number of arguments " +
|
||||
"need at least one") if args.size == 0
|
||||
|
||||
# Sometimes we get numbers as numerics and sometimes as strings.
|
||||
# We try to compare them as numbers when possible
|
||||
return args.max do |a,b|
|
||||
if a.to_s =~ /\A-?\d+(.\d+)?\z/ and b.to_s =~ /\A-?\d+(.\d+)?\z/ then
|
||||
a.to_f <=> b.to_f
|
||||
else
|
||||
a.to_s <=> b.to_s
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,44 +0,0 @@
|
|||
#
|
||||
# member.rb
|
||||
#
|
||||
|
||||
# TODO(Krzysztof Wilczynski): We need to add support for regular expression ...
|
||||
# TODO(Krzysztof Wilczynski): Support for strings and hashes too ...
|
||||
|
||||
module Puppet::Parser::Functions
|
||||
newfunction(:member, :type => :rvalue, :doc => <<-EOS
|
||||
This function determines if a variable is a member of an array.
|
||||
|
||||
*Examples:*
|
||||
|
||||
member(['a','b'], 'b')
|
||||
|
||||
Would return: true
|
||||
|
||||
member(['a','b'], 'c')
|
||||
|
||||
Would return: false
|
||||
EOS
|
||||
) do |arguments|
|
||||
|
||||
raise(Puppet::ParseError, "member(): Wrong number of arguments " +
|
||||
"given (#{arguments.size} for 2)") if arguments.size < 2
|
||||
|
||||
array = arguments[0]
|
||||
|
||||
unless array.is_a?(Array)
|
||||
raise(Puppet::ParseError, 'member(): Requires array to work with')
|
||||
end
|
||||
|
||||
item = arguments[1]
|
||||
|
||||
raise(Puppet::ParseError, 'member(): You must provide item ' +
|
||||
'to search for within array given') if item.empty?
|
||||
|
||||
result = array.include?(item)
|
||||
|
||||
return result
|
||||
end
|
||||
end
|
||||
|
||||
# vim: set ts=2 sw=2 et :
|
|
@ -1,34 +0,0 @@
|
|||
module Puppet::Parser::Functions
|
||||
newfunction(:merge, :type => :rvalue, :doc => <<-'ENDHEREDOC') do |args|
|
||||
Merges two or more hashes together and returns the resulting hash.
|
||||
|
||||
For example:
|
||||
|
||||
$hash1 = {'one' => 1, 'two', => 2}
|
||||
$hash2 = {'two' => 'dos', 'three', => 'tres'}
|
||||
$merged_hash = merge($hash1, $hash2)
|
||||
# The resulting hash is equivalent to:
|
||||
# $merged_hash = {'one' => 1, 'two' => 'dos', 'three' => 'tres'}
|
||||
|
||||
When there is a duplicate key, the key in the rightmost hash will "win."
|
||||
|
||||
ENDHEREDOC
|
||||
|
||||
if args.length < 2
|
||||
raise Puppet::ParseError, ("merge(): wrong number of arguments (#{args.length}; must be at least 2)")
|
||||
end
|
||||
|
||||
# The hash we accumulate into
|
||||
accumulator = Hash.new
|
||||
# Merge into the accumulator hash
|
||||
args.each do |arg|
|
||||
next if arg.is_a? String and arg.empty? # empty string is synonym for puppet's undef
|
||||
unless arg.is_a?(Hash)
|
||||
raise Puppet::ParseError, "merge: unexpected argument type #{arg.class}, only expects hash arguments"
|
||||
end
|
||||
accumulator.merge!(arg)
|
||||
end
|
||||
# Return the fully merged hash
|
||||
accumulator
|
||||
end
|
||||
end
|
|
@ -1,21 +0,0 @@
|
|||
module Puppet::Parser::Functions
|
||||
newfunction(:min, :type => :rvalue, :doc => <<-EOS
|
||||
Returns the lowest value of all arguments.
|
||||
Requires at least one argument.
|
||||
EOS
|
||||
) do |args|
|
||||
|
||||
raise(Puppet::ParseError, "min(): Wrong number of arguments " +
|
||||
"need at least one") if args.size == 0
|
||||
|
||||
# Sometimes we get numbers as numerics and sometimes as strings.
|
||||
# We try to compare them as numbers when possible
|
||||
return args.min do |a,b|
|
||||
if a.to_s =~ /\A^-?\d+(.\d+)?\z/ and b.to_s =~ /\A-?\d+(.\d+)?\z/ then
|
||||
a.to_f <=> b.to_f
|
||||
else
|
||||
a.to_s <=> b.to_s
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,43 +0,0 @@
|
|||
#
|
||||
# num2bool.rb
|
||||
#
|
||||
|
||||
module Puppet::Parser::Functions
|
||||
newfunction(:num2bool, :type => :rvalue, :doc => <<-EOS
|
||||
This function converts a number or a string representation of a number into a
|
||||
true boolean. Zero or anything non-numeric becomes false. Numbers higher then 0
|
||||
become true.
|
||||
EOS
|
||||
) do |arguments|
|
||||
|
||||
raise(Puppet::ParseError, "num2bool(): Wrong number of arguments " +
|
||||
"given (#{arguments.size} for 1)") if arguments.size != 1
|
||||
|
||||
number = arguments[0]
|
||||
|
||||
case number
|
||||
when Numeric
|
||||
# Yay, it's a number
|
||||
when String
|
||||
begin
|
||||
number = Float(number)
|
||||
rescue ArgumentError => ex
|
||||
raise(Puppet::ParseError, "num2bool(): '#{number}' does not look like a number: #{ex.message}")
|
||||
end
|
||||
else
|
||||
begin
|
||||
number = number.to_s
|
||||
rescue NoMethodError => ex
|
||||
raise(Puppet::ParseError, "num2bool(): Unable to parse argument: #{ex.message}")
|
||||
end
|
||||
end
|
||||
|
||||
# Truncate Floats
|
||||
number = number.to_i
|
||||
|
||||
# Return true for any positive number and false otherwise
|
||||
return number > 0
|
||||
end
|
||||
end
|
||||
|
||||
# vim: set ts=2 sw=2 et :
|
|
@ -1,24 +0,0 @@
|
|||
#
|
||||
# parsejson.rb
|
||||
#
|
||||
|
||||
module Puppet::Parser::Functions
|
||||
newfunction(:parsejson, :type => :rvalue, :doc => <<-EOS
|
||||
This function accepts JSON as a string and converts into the correct Puppet
|
||||
structure.
|
||||
EOS
|
||||
) do |arguments|
|
||||
|
||||
if (arguments.size != 1) then
|
||||
raise(Puppet::ParseError, "parsejson(): Wrong number of arguments "+
|
||||
"given #{arguments.size} for 1")
|
||||
end
|
||||
|
||||
json = arguments[0]
|
||||
|
||||
# PSON is natively available in puppet
|
||||
PSON.load(json)
|
||||
end
|
||||
end
|
||||
|
||||
# vim: set ts=2 sw=2 et :
|
|
@ -1,24 +0,0 @@
|
|||
#
|
||||
# parseyaml.rb
|
||||
#
|
||||
|
||||
module Puppet::Parser::Functions
|
||||
newfunction(:parseyaml, :type => :rvalue, :doc => <<-EOS
|
||||
This function accepts YAML as a string and converts it into the correct
|
||||
Puppet structure.
|
||||
EOS
|
||||
) do |arguments|
|
||||
|
||||
if (arguments.size != 1) then
|
||||
raise(Puppet::ParseError, "parseyaml(): Wrong number of arguments "+
|
||||
"given #{arguments.size} for 1")
|
||||
end
|
||||
|
||||
require 'yaml'
|
||||
|
||||
YAML::load(arguments[0])
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
# vim: set ts=2 sw=2 et :
|
|
@ -1,29 +0,0 @@
|
|||
module Puppet::Parser::Functions
|
||||
newfunction(:pick, :type => :rvalue, :doc => <<-EOS
|
||||
|
||||
This function is similar to a coalesce function in SQL in that it will return
|
||||
the first value in a list of values that is not undefined or an empty string
|
||||
(two things in Puppet that will return a boolean false value). Typically,
|
||||
this function is used to check for a value in the Puppet Dashboard/Enterprise
|
||||
Console, and failover to a default value like the following:
|
||||
|
||||
$real_jenkins_version = pick($::jenkins_version, '1.449')
|
||||
|
||||
The value of $real_jenkins_version will first look for a top-scope variable
|
||||
called 'jenkins_version' (note that parameters set in the Puppet Dashboard/
|
||||
Enterprise Console are brought into Puppet as top-scope variables), and,
|
||||
failing that, will use a default value of 1.449.
|
||||
|
||||
EOS
|
||||
) do |args|
|
||||
args = args.compact
|
||||
args.delete(:undef)
|
||||
args.delete(:undefined)
|
||||
args.delete("")
|
||||
if args[0].to_s.empty? then
|
||||
fail Puppet::ParseError, "pick(): must receive at least one non empty value"
|
||||
else
|
||||
return args[0]
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,35 +0,0 @@
|
|||
module Puppet::Parser::Functions
|
||||
newfunction(:pick_default, :type => :rvalue, :doc => <<-EOS
|
||||
|
||||
This function is similar to a coalesce function in SQL in that it will return
|
||||
the first value in a list of values that is not undefined or an empty string
|
||||
(two things in Puppet that will return a boolean false value). If no value is
|
||||
found, it will return the last argument.
|
||||
|
||||
Typically, this function is used to check for a value in the Puppet
|
||||
Dashboard/Enterprise Console, and failover to a default value like the
|
||||
following:
|
||||
|
||||
$real_jenkins_version = pick_default($::jenkins_version, '1.449')
|
||||
|
||||
The value of $real_jenkins_version will first look for a top-scope variable
|
||||
called 'jenkins_version' (note that parameters set in the Puppet Dashboard/
|
||||
Enterprise Console are brought into Puppet as top-scope variables), and,
|
||||
failing that, will use a default value of 1.449.
|
||||
|
||||
Note that, contrary to the pick() function, the pick_default does not fail if
|
||||
all arguments are empty. This allows pick_default to use an empty value as
|
||||
default.
|
||||
|
||||
EOS
|
||||
) do |args|
|
||||
fail "Must receive at least one argument." if args.empty?
|
||||
default = args.last
|
||||
args = args[0..-2].compact
|
||||
args.delete(:undef)
|
||||
args.delete(:undefined)
|
||||
args.delete("")
|
||||
args << default
|
||||
return args[0]
|
||||
end
|
||||
end
|
|
@ -1,45 +0,0 @@
|
|||
#
|
||||
# prefix.rb
|
||||
#
|
||||
|
||||
module Puppet::Parser::Functions
|
||||
newfunction(:prefix, :type => :rvalue, :doc => <<-EOS
|
||||
This function applies a prefix to all elements in an array.
|
||||
|
||||
*Examples:*
|
||||
|
||||
prefix(['a','b','c'], 'p')
|
||||
|
||||
Will return: ['pa','pb','pc']
|
||||
EOS
|
||||
) do |arguments|
|
||||
|
||||
# Technically we support two arguments but only first is mandatory ...
|
||||
raise(Puppet::ParseError, "prefix(): Wrong number of arguments " +
|
||||
"given (#{arguments.size} for 1)") if arguments.size < 1
|
||||
|
||||
array = arguments[0]
|
||||
|
||||
unless array.is_a?(Array)
|
||||
raise Puppet::ParseError, "prefix(): expected first argument to be an Array, got #{array.inspect}"
|
||||
end
|
||||
|
||||
prefix = arguments[1] if arguments[1]
|
||||
|
||||
if prefix
|
||||
unless prefix.is_a?(String)
|
||||
raise Puppet::ParseError, "prefix(): expected second argument to be a String, got #{prefix.inspect}"
|
||||
end
|
||||
end
|
||||
|
||||
# Turn everything into string same as join would do ...
|
||||
result = array.collect do |i|
|
||||
i = i.to_s
|
||||
prefix ? prefix + i : i
|
||||
end
|
||||
|
||||
return result
|
||||
end
|
||||
end
|
||||
|
||||
# vim: set ts=2 sw=2 et :
|
|
@ -1,88 +0,0 @@
|
|||
#
|
||||
# range.rb
|
||||
#
|
||||
|
||||
# TODO(Krzysztof Wilczynski): We probably need to approach numeric values differently ...
|
||||
|
||||
module Puppet::Parser::Functions
|
||||
newfunction(:range, :type => :rvalue, :doc => <<-EOS
|
||||
When given range in the form of (start, stop) it will extrapolate a range as
|
||||
an array.
|
||||
|
||||
*Examples:*
|
||||
|
||||
range("0", "9")
|
||||
|
||||
Will return: [0,1,2,3,4,5,6,7,8,9]
|
||||
|
||||
range("00", "09")
|
||||
|
||||
Will return: [0,1,2,3,4,5,6,7,8,9] (Zero padded strings are converted to
|
||||
integers automatically)
|
||||
|
||||
range("a", "c")
|
||||
|
||||
Will return: ["a","b","c"]
|
||||
|
||||
range("host01", "host10")
|
||||
|
||||
Will return: ["host01", "host02", ..., "host09", "host10"]
|
||||
|
||||
Passing a third argument will cause the generated range to step by that
|
||||
interval, e.g.
|
||||
|
||||
range("0", "9", "2")
|
||||
|
||||
Will return: [0,2,4,6,8]
|
||||
EOS
|
||||
) do |arguments|
|
||||
|
||||
# We support more than one argument but at least one is mandatory ...
|
||||
raise(Puppet::ParseError, "range(): Wrong number of " +
|
||||
"arguments given (#{arguments.size} for 1)") if arguments.size < 1
|
||||
|
||||
if arguments.size > 1
|
||||
start = arguments[0]
|
||||
stop = arguments[1]
|
||||
step = arguments[2].nil? ? 1 : arguments[2].to_i.abs
|
||||
|
||||
type = '..' # We select simplest type for Range available in Ruby ...
|
||||
|
||||
elsif arguments.size > 0
|
||||
value = arguments[0]
|
||||
|
||||
if m = value.match(/^(\w+)(\.\.\.?|\-)(\w+)$/)
|
||||
start = m[1]
|
||||
stop = m[3]
|
||||
|
||||
type = m[2]
|
||||
|
||||
elsif value.match(/^.+$/)
|
||||
raise(Puppet::ParseError, 'range(): Unable to compute range ' +
|
||||
'from the value given')
|
||||
else
|
||||
raise(Puppet::ParseError, 'range(): Unknown format of range given')
|
||||
end
|
||||
end
|
||||
|
||||
# Check whether we have integer value if so then make it so ...
|
||||
if start.match(/^\d+$/)
|
||||
start = start.to_i
|
||||
stop = stop.to_i
|
||||
else
|
||||
start = start.to_s
|
||||
stop = stop.to_s
|
||||
end
|
||||
|
||||
range = case type
|
||||
when /^(\.\.|\-)$/ then (start .. stop)
|
||||
when /^(\.\.\.)$/ then (start ... stop) # Exclusive of last element ...
|
||||
end
|
||||
|
||||
result = range.step(step).collect { |i| i } # Get them all ... Pokemon ...
|
||||
|
||||
return result
|
||||
end
|
||||
end
|
||||
|
||||
# vim: set ts=2 sw=2 et :
|
|
@ -1,31 +0,0 @@
|
|||
#
|
||||
# reject.rb
|
||||
#
|
||||
|
||||
module Puppet::Parser::Functions
|
||||
newfunction(:reject, :type => :rvalue, :doc => <<-EOS) do |args|
|
||||
This function searches through an array and rejects all elements that match
|
||||
the provided regular expression.
|
||||
|
||||
*Examples:*
|
||||
|
||||
reject(['aaa','bbb','ccc','aaaddd'], 'aaa')
|
||||
|
||||
Would return:
|
||||
|
||||
['bbb','ccc']
|
||||
EOS
|
||||
|
||||
if (args.size != 2)
|
||||
raise Puppet::ParseError,
|
||||
"reject(): Wrong number of arguments given #{args.size} for 2"
|
||||
end
|
||||
|
||||
ary = args[0]
|
||||
pattern = Regexp.new(args[1])
|
||||
|
||||
ary.reject { |e| e =~ pattern }
|
||||
end
|
||||
end
|
||||
|
||||
# vim: set ts=2 sw=2 et :
|
|
@ -1,28 +0,0 @@
|
|||
#
|
||||
# reverse.rb
|
||||
#
|
||||
|
||||
module Puppet::Parser::Functions
|
||||
newfunction(:reverse, :type => :rvalue, :doc => <<-EOS
|
||||
Reverses the order of a string or array.
|
||||
EOS
|
||||
) do |arguments|
|
||||
|
||||
raise(Puppet::ParseError, "reverse(): Wrong number of arguments " +
|
||||
"given (#{arguments.size} for 1)") if arguments.size < 1
|
||||
|
||||
value = arguments[0]
|
||||
klass = value.class
|
||||
|
||||
unless [Array, String].include?(klass)
|
||||
raise(Puppet::ParseError, 'reverse(): Requires either ' +
|
||||
'array or string to work with')
|
||||
end
|
||||
|
||||
result = value.reverse
|
||||
|
||||
return result
|
||||
end
|
||||
end
|
||||
|
||||
# vim: set ts=2 sw=2 et :
|
|
@ -1,32 +0,0 @@
|
|||
#
|
||||
# rstrip.rb
|
||||
#
|
||||
|
||||
module Puppet::Parser::Functions
|
||||
newfunction(:rstrip, :type => :rvalue, :doc => <<-EOS
|
||||
Strips leading spaces to the right of the string.
|
||||
EOS
|
||||
) do |arguments|
|
||||
|
||||
raise(Puppet::ParseError, "rstrip(): Wrong number of arguments " +
|
||||
"given (#{arguments.size} for 1)") if arguments.size < 1
|
||||
|
||||
value = arguments[0]
|
||||
klass = value.class
|
||||
|
||||
unless [Array, String].include?(klass)
|
||||
raise(Puppet::ParseError, 'rstrip(): Requires either ' +
|
||||
'array or string to work with')
|
||||
end
|
||||
|
||||
if value.is_a?(Array)
|
||||
result = value.collect { |i| i.is_a?(String) ? i.rstrip : i }
|
||||
else
|
||||
result = value.rstrip
|
||||
end
|
||||
|
||||
return result
|
||||
end
|
||||
end
|
||||
|
||||
# vim: set ts=2 sw=2 et :
|
|
@ -1,46 +0,0 @@
|
|||
#
|
||||
# shuffle.rb
|
||||
#
|
||||
|
||||
module Puppet::Parser::Functions
|
||||
newfunction(:shuffle, :type => :rvalue, :doc => <<-EOS
|
||||
Randomizes the order of a string or array elements.
|
||||
EOS
|
||||
) do |arguments|
|
||||
|
||||
raise(Puppet::ParseError, "shuffle(): Wrong number of arguments " +
|
||||
"given (#{arguments.size} for 1)") if arguments.size < 1
|
||||
|
||||
value = arguments[0]
|
||||
klass = value.class
|
||||
|
||||
unless [Array, String].include?(klass)
|
||||
raise(Puppet::ParseError, 'shuffle(): Requires either ' +
|
||||
'array or string to work with')
|
||||
end
|
||||
|
||||
result = value.clone
|
||||
|
||||
string = value.is_a?(String) ? true : false
|
||||
|
||||
# Check whether it makes sense to shuffle ...
|
||||
return result if result.size <= 1
|
||||
|
||||
# We turn any string value into an array to be able to shuffle ...
|
||||
result = string ? result.split('') : result
|
||||
|
||||
elements = result.size
|
||||
|
||||
# Simple implementation of Fisher–Yates in-place shuffle ...
|
||||
elements.times do |i|
|
||||
j = rand(elements - i) + i
|
||||
result[j], result[i] = result[i], result[j]
|
||||
end
|
||||
|
||||
result = string ? result.join : result
|
||||
|
||||
return result
|
||||
end
|
||||
end
|
||||
|
||||
# vim: set ts=2 sw=2 et :
|
|
@ -1,48 +0,0 @@
|
|||
#
|
||||
# size.rb
|
||||
#
|
||||
|
||||
# TODO(Krzysztof Wilczynski): Support for hashes would be nice too ...
|
||||
|
||||
module Puppet::Parser::Functions
|
||||
newfunction(:size, :type => :rvalue, :doc => <<-EOS
|
||||
Returns the number of elements in a string or array.
|
||||
EOS
|
||||
) do |arguments|
|
||||
|
||||
raise(Puppet::ParseError, "size(): Wrong number of arguments " +
|
||||
"given (#{arguments.size} for 1)") if arguments.size < 1
|
||||
|
||||
item = arguments[0]
|
||||
|
||||
if item.is_a?(String)
|
||||
|
||||
begin
|
||||
#
|
||||
# Check whether your item is a numeric value or not ...
|
||||
# This will take care about positive and/or negative numbers
|
||||
# for both integer and floating-point values ...
|
||||
#
|
||||
# Please note that Puppet has no notion of hexadecimal
|
||||
# nor octal numbers for its DSL at this point in time ...
|
||||
#
|
||||
Float(item)
|
||||
|
||||
raise(Puppet::ParseError, 'size(): Requires either ' +
|
||||
'string or array to work with')
|
||||
|
||||
rescue ArgumentError
|
||||
result = item.size
|
||||
end
|
||||
|
||||
elsif item.is_a?(Array)
|
||||
result = item.size
|
||||
else
|
||||
raise(Puppet::ParseError, 'size(): Unknown type given')
|
||||
end
|
||||
|
||||
return result
|
||||
end
|
||||
end
|
||||
|
||||
# vim: set ts=2 sw=2 et :
|
|
@ -1,27 +0,0 @@
|
|||
#
|
||||
# sort.rb
|
||||
#
|
||||
|
||||
module Puppet::Parser::Functions
|
||||
newfunction(:sort, :type => :rvalue, :doc => <<-EOS
|
||||
Sorts strings and arrays lexically.
|
||||
EOS
|
||||
) do |arguments|
|
||||
|
||||
if (arguments.size != 1) then
|
||||
raise(Puppet::ParseError, "sort(): Wrong number of arguments "+
|
||||
"given #{arguments.size} for 1")
|
||||
end
|
||||
|
||||
value = arguments[0]
|
||||
|
||||
if value.is_a?(Array) then
|
||||
value.sort
|
||||
elsif value.is_a?(String) then
|
||||
value.split("").sort.join("")
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
# vim: set ts=2 sw=2 et :
|
|
@ -1,36 +0,0 @@
|
|||
#
|
||||
# squeeze.rb
|
||||
#
|
||||
|
||||
module Puppet::Parser::Functions
|
||||
newfunction(:squeeze, :type => :rvalue, :doc => <<-EOS
|
||||
Returns a new string where runs of the same character that occur in this set are replaced by a single character.
|
||||
EOS
|
||||
) do |arguments|
|
||||
|
||||
if ((arguments.size != 2) and (arguments.size != 1)) then
|
||||
raise(Puppet::ParseError, "squeeze(): Wrong number of arguments "+
|
||||
"given #{arguments.size} for 2 or 1")
|
||||
end
|
||||
|
||||
item = arguments[0]
|
||||
squeezeval = arguments[1]
|
||||
|
||||
if item.is_a?(Array) then
|
||||
if squeezeval then
|
||||
item.collect { |i| i.squeeze(squeezeval) }
|
||||
else
|
||||
item.collect { |i| i.squeeze }
|
||||
end
|
||||
else
|
||||
if squeezeval then
|
||||
item.squeeze(squeezeval)
|
||||
else
|
||||
item.squeeze
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
# vim: set ts=2 sw=2 et :
|
|
@ -1,46 +0,0 @@
|
|||
#
|
||||
# str2bool.rb
|
||||
#
|
||||
|
||||
module Puppet::Parser::Functions
|
||||
newfunction(:str2bool, :type => :rvalue, :doc => <<-EOS
|
||||
This converts a string to a boolean. This attempt to convert strings that
|
||||
contain things like: y, 1, t, true to 'true' and strings that contain things
|
||||
like: 0, f, n, false, no to 'false'.
|
||||
EOS
|
||||
) do |arguments|
|
||||
|
||||
raise(Puppet::ParseError, "str2bool(): Wrong number of arguments " +
|
||||
"given (#{arguments.size} for 1)") if arguments.size < 1
|
||||
|
||||
string = arguments[0]
|
||||
|
||||
# If string is already Boolean, return it
|
||||
if !!string == string
|
||||
return string
|
||||
end
|
||||
|
||||
unless string.is_a?(String)
|
||||
raise(Puppet::ParseError, 'str2bool(): Requires either ' +
|
||||
'string to work with')
|
||||
end
|
||||
|
||||
# We consider all the yes, no, y, n and so on too ...
|
||||
result = case string
|
||||
#
|
||||
# This is how undef looks like in Puppet ...
|
||||
# We yield false in this case.
|
||||
#
|
||||
when /^$/, '' then false # Empty string will be false ...
|
||||
when /^(1|t|y|true|yes)$/ then true
|
||||
when /^(0|f|n|false|no)$/ then false
|
||||
when /^(undef|undefined)$/ then false # This is not likely to happen ...
|
||||
else
|
||||
raise(Puppet::ParseError, 'str2bool(): Unknown type of boolean given')
|
||||
end
|
||||
|
||||
return result
|
||||
end
|
||||
end
|
||||
|
||||
# vim: set ts=2 sw=2 et :
|
|
@ -1,32 +0,0 @@
|
|||
#
|
||||
# str2saltedsha512.rb
|
||||
#
|
||||
|
||||
module Puppet::Parser::Functions
|
||||
newfunction(:str2saltedsha512, :type => :rvalue, :doc => <<-EOS
|
||||
This converts a string to a salted-SHA512 password hash (which is used for
|
||||
OS X versions >= 10.7). Given any simple string, you will get a hex version
|
||||
of a salted-SHA512 password hash that can be inserted into your Puppet
|
||||
manifests as a valid password attribute.
|
||||
EOS
|
||||
) do |arguments|
|
||||
require 'digest/sha2'
|
||||
|
||||
raise(Puppet::ParseError, "str2saltedsha512(): Wrong number of arguments " +
|
||||
"passed (#{arguments.size} but we require 1)") if arguments.size != 1
|
||||
|
||||
password = arguments[0]
|
||||
|
||||
unless password.is_a?(String)
|
||||
raise(Puppet::ParseError, 'str2saltedsha512(): Requires a ' +
|
||||
"String argument, you passed: #{password.class}")
|
||||
end
|
||||
|
||||
seedint = rand(2**31 - 1)
|
||||
seedstring = Array(seedint).pack("L")
|
||||
saltedpass = Digest::SHA512.digest(seedstring + password)
|
||||
(seedstring + saltedpass).unpack('H*')[0]
|
||||
end
|
||||
end
|
||||
|
||||
# vim: set ts=2 sw=2 et :
|
|
@ -1,107 +0,0 @@
|
|||
#
|
||||
# strftime.rb
|
||||
#
|
||||
|
||||
module Puppet::Parser::Functions
|
||||
newfunction(:strftime, :type => :rvalue, :doc => <<-EOS
|
||||
This function returns formatted time.
|
||||
|
||||
*Examples:*
|
||||
|
||||
To return the time since epoch:
|
||||
|
||||
strftime("%s")
|
||||
|
||||
To return the date:
|
||||
|
||||
strftime("%Y-%m-%d")
|
||||
|
||||
*Format meaning:*
|
||||
|
||||
%a - The abbreviated weekday name (``Sun'')
|
||||
%A - The full weekday name (``Sunday'')
|
||||
%b - The abbreviated month name (``Jan'')
|
||||
%B - The full month name (``January'')
|
||||
%c - The preferred local date and time representation
|
||||
%C - Century (20 in 2009)
|
||||
%d - Day of the month (01..31)
|
||||
%D - Date (%m/%d/%y)
|
||||
%e - Day of the month, blank-padded ( 1..31)
|
||||
%F - Equivalent to %Y-%m-%d (the ISO 8601 date format)
|
||||
%h - Equivalent to %b
|
||||
%H - Hour of the day, 24-hour clock (00..23)
|
||||
%I - Hour of the day, 12-hour clock (01..12)
|
||||
%j - Day of the year (001..366)
|
||||
%k - hour, 24-hour clock, blank-padded ( 0..23)
|
||||
%l - hour, 12-hour clock, blank-padded ( 0..12)
|
||||
%L - Millisecond of the second (000..999)
|
||||
%m - Month of the year (01..12)
|
||||
%M - Minute of the hour (00..59)
|
||||
%n - Newline (\n)
|
||||
%N - Fractional seconds digits, default is 9 digits (nanosecond)
|
||||
%3N millisecond (3 digits)
|
||||
%6N microsecond (6 digits)
|
||||
%9N nanosecond (9 digits)
|
||||
%p - Meridian indicator (``AM'' or ``PM'')
|
||||
%P - Meridian indicator (``am'' or ``pm'')
|
||||
%r - time, 12-hour (same as %I:%M:%S %p)
|
||||
%R - time, 24-hour (%H:%M)
|
||||
%s - Number of seconds since 1970-01-01 00:00:00 UTC.
|
||||
%S - Second of the minute (00..60)
|
||||
%t - Tab character (\t)
|
||||
%T - time, 24-hour (%H:%M:%S)
|
||||
%u - Day of the week as a decimal, Monday being 1. (1..7)
|
||||
%U - Week number of the current year,
|
||||
starting with the first Sunday as the first
|
||||
day of the first week (00..53)
|
||||
%v - VMS date (%e-%b-%Y)
|
||||
%V - Week number of year according to ISO 8601 (01..53)
|
||||
%W - Week number of the current year,
|
||||
starting with the first Monday as the first
|
||||
day of the first week (00..53)
|
||||
%w - Day of the week (Sunday is 0, 0..6)
|
||||
%x - Preferred representation for the date alone, no time
|
||||
%X - Preferred representation for the time alone, no date
|
||||
%y - Year without a century (00..99)
|
||||
%Y - Year with century
|
||||
%z - Time zone as hour offset from UTC (e.g. +0900)
|
||||
%Z - Time zone name
|
||||
%% - Literal ``%'' character
|
||||
EOS
|
||||
) do |arguments|
|
||||
|
||||
# Technically we support two arguments but only first is mandatory ...
|
||||
raise(Puppet::ParseError, "strftime(): Wrong number of arguments " +
|
||||
"given (#{arguments.size} for 1)") if arguments.size < 1
|
||||
|
||||
format = arguments[0]
|
||||
|
||||
raise(Puppet::ParseError, 'strftime(): You must provide ' +
|
||||
'format for evaluation') if format.empty?
|
||||
|
||||
# The Time Zone argument is optional ...
|
||||
time_zone = arguments[1] if arguments[1]
|
||||
|
||||
time = Time.new
|
||||
|
||||
# There is probably a better way to handle Time Zone ...
|
||||
if time_zone and not time_zone.empty?
|
||||
original_zone = ENV['TZ']
|
||||
|
||||
local_time = time.clone
|
||||
local_time = local_time.utc
|
||||
|
||||
ENV['TZ'] = time_zone
|
||||
|
||||
time = local_time.localtime
|
||||
|
||||
ENV['TZ'] = original_zone
|
||||
end
|
||||
|
||||
result = time.strftime(format)
|
||||
|
||||
return result
|
||||
end
|
||||
end
|
||||
|
||||
# vim: set ts=2 sw=2 et :
|
|
@ -1,39 +0,0 @@
|
|||
#
|
||||
# strip.rb
|
||||
#
|
||||
|
||||
module Puppet::Parser::Functions
|
||||
newfunction(:strip, :type => :rvalue, :doc => <<-EOS
|
||||
This function removes leading and trailing whitespace from a string or from
|
||||
every string inside an array.
|
||||
|
||||
*Examples:*
|
||||
|
||||
strip(" aaa ")
|
||||
|
||||
Would result in: "aaa"
|
||||
EOS
|
||||
) do |arguments|
|
||||
|
||||
raise(Puppet::ParseError, "strip(): Wrong number of arguments " +
|
||||
"given (#{arguments.size} for 1)") if arguments.size < 1
|
||||
|
||||
value = arguments[0]
|
||||
klass = value.class
|
||||
|
||||
unless [Array, String].include?(klass)
|
||||
raise(Puppet::ParseError, 'strip(): Requires either ' +
|
||||
'array or string to work with')
|
||||
end
|
||||
|
||||
if value.is_a?(Array)
|
||||
result = value.collect { |i| i.is_a?(String) ? i.strip : i }
|
||||
else
|
||||
result = value.strip
|
||||
end
|
||||
|
||||
return result
|
||||
end
|
||||
end
|
||||
|
||||
# vim: set ts=2 sw=2 et :
|
|
@ -1,45 +0,0 @@
|
|||
#
|
||||
# suffix.rb
|
||||
#
|
||||
|
||||
module Puppet::Parser::Functions
|
||||
newfunction(:suffix, :type => :rvalue, :doc => <<-EOS
|
||||
This function applies a suffix to all elements in an array.
|
||||
|
||||
*Examples:*
|
||||
|
||||
suffix(['a','b','c'], 'p')
|
||||
|
||||
Will return: ['ap','bp','cp']
|
||||
EOS
|
||||
) do |arguments|
|
||||
|
||||
# Technically we support two arguments but only first is mandatory ...
|
||||
raise(Puppet::ParseError, "suffix(): Wrong number of arguments " +
|
||||
"given (#{arguments.size} for 1)") if arguments.size < 1
|
||||
|
||||
array = arguments[0]
|
||||
|
||||
unless array.is_a?(Array)
|
||||
raise Puppet::ParseError, "suffix(): expected first argument to be an Array, got #{array.inspect}"
|
||||
end
|
||||
|
||||
suffix = arguments[1] if arguments[1]
|
||||
|
||||
if suffix
|
||||
unless suffix.is_a? String
|
||||
raise Puppet::ParseError, "suffix(): expected second argument to be a String, got #{suffix.inspect}"
|
||||
end
|
||||
end
|
||||
|
||||
# Turn everything into string same as join would do ...
|
||||
result = array.collect do |i|
|
||||
i = i.to_s
|
||||
suffix ? i + suffix : i
|
||||
end
|
||||
|
||||
return result
|
||||
end
|
||||
end
|
||||
|
||||
# vim: set ts=2 sw=2 et :
|
|
@ -1,39 +0,0 @@
|
|||
#
|
||||
# swapcase.rb
|
||||
#
|
||||
|
||||
module Puppet::Parser::Functions
|
||||
newfunction(:swapcase, :type => :rvalue, :doc => <<-EOS
|
||||
This function will swap the existing case of a string.
|
||||
|
||||
*Examples:*
|
||||
|
||||
swapcase("aBcD")
|
||||
|
||||
Would result in: "AbCd"
|
||||
EOS
|
||||
) do |arguments|
|
||||
|
||||
raise(Puppet::ParseError, "swapcase(): Wrong number of arguments " +
|
||||
"given (#{arguments.size} for 1)") if arguments.size < 1
|
||||
|
||||
value = arguments[0]
|
||||
klass = value.class
|
||||
|
||||
unless [Array, String].include?(klass)
|
||||
raise(Puppet::ParseError, 'swapcase(): Requires either ' +
|
||||
'array or string to work with')
|
||||
end
|
||||
|
||||
if value.is_a?(Array)
|
||||
# Numbers in Puppet are often string-encoded which is troublesome ...
|
||||
result = value.collect { |i| i.is_a?(String) ? i.swapcase : i }
|
||||
else
|
||||
result = value.swapcase
|
||||
end
|
||||
|
||||
return result
|
||||
end
|
||||
end
|
||||
|
||||
# vim: set ts=2 sw=2 et :
|
|
@ -1,49 +0,0 @@
|
|||
#
|
||||
# time.rb
|
||||
#
|
||||
|
||||
module Puppet::Parser::Functions
|
||||
newfunction(:time, :type => :rvalue, :doc => <<-EOS
|
||||
This function will return the current time since epoch as an integer.
|
||||
|
||||
*Examples:*
|
||||
|
||||
time()
|
||||
|
||||
Will return something like: 1311972653
|
||||
EOS
|
||||
) do |arguments|
|
||||
|
||||
# The Time Zone argument is optional ...
|
||||
time_zone = arguments[0] if arguments[0]
|
||||
|
||||
if (arguments.size != 0) and (arguments.size != 1) then
|
||||
raise(Puppet::ParseError, "time(): Wrong number of arguments "+
|
||||
"given #{arguments.size} for 0 or 1")
|
||||
end
|
||||
|
||||
time = Time.new
|
||||
|
||||
# There is probably a better way to handle Time Zone ...
|
||||
if time_zone and not time_zone.empty?
|
||||
original_zone = ENV['TZ']
|
||||
|
||||
local_time = time.clone
|
||||
local_time = local_time.utc
|
||||
|
||||
ENV['TZ'] = time_zone
|
||||
|
||||
time = local_time.localtime
|
||||
|
||||
ENV['TZ'] = original_zone
|
||||
end
|
||||
|
||||
# Calling Time#to_i on a receiver changes it. Trust me I am the Doctor.
|
||||
result = time.strftime('%s')
|
||||
result = result.to_i
|
||||
|
||||
return result
|
||||
end
|
||||
end
|
||||
|
||||
# vim: set ts=2 sw=2 et :
|
|
@ -1,28 +0,0 @@
|
|||
module Puppet::Parser::Functions
|
||||
newfunction(:to_bytes, :type => :rvalue, :doc => <<-EOS
|
||||
Converts the argument into bytes, for example 4 kB becomes 4096.
|
||||
Takes a single string value as an argument.
|
||||
EOS
|
||||
) do |arguments|
|
||||
|
||||
raise(Puppet::ParseError, "to_bytes(): Wrong number of arguments " +
|
||||
"given (#{arguments.size} for 1)") if arguments.size != 1
|
||||
|
||||
arg = arguments[0]
|
||||
|
||||
return arg if arg.is_a? Numeric
|
||||
|
||||
value,prefix = */([0-9.e+-]*)\s*([^bB]?)/.match(arg)[1,2]
|
||||
|
||||
value = value.to_f
|
||||
case prefix
|
||||
when '' then return value.to_i
|
||||
when 'k' then return (value*(1<<10)).to_i
|
||||
when 'M' then return (value*(1<<20)).to_i
|
||||
when 'G' then return (value*(1<<30)).to_i
|
||||
when 'T' then return (value*(1<<40)).to_i
|
||||
when 'E' then return (value*(1<<50)).to_i
|
||||
else raise Puppet::ParseError, "to_bytes(): Unknown prefix #{prefix}"
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,50 +0,0 @@
|
|||
#
|
||||
# type.rb
|
||||
#
|
||||
|
||||
module Puppet::Parser::Functions
|
||||
newfunction(:type, :type => :rvalue, :doc => <<-EOS
|
||||
Returns the type when passed a variable. Type can be one of:
|
||||
|
||||
* string
|
||||
* array
|
||||
* hash
|
||||
* float
|
||||
* integer
|
||||
* boolean
|
||||
EOS
|
||||
) do |arguments|
|
||||
|
||||
raise(Puppet::ParseError, "type(): Wrong number of arguments " +
|
||||
"given (#{arguments.size} for 1)") if arguments.size < 1
|
||||
|
||||
value = arguments[0]
|
||||
|
||||
klass = value.class
|
||||
|
||||
if not [TrueClass, FalseClass, Array, Bignum, Fixnum, Float, Hash, String].include?(klass)
|
||||
raise(Puppet::ParseError, 'type(): Unknown type')
|
||||
end
|
||||
|
||||
klass = klass.to_s # Ugly ...
|
||||
|
||||
# We note that Integer is the parent to Bignum and Fixnum ...
|
||||
result = case klass
|
||||
when /^(?:Big|Fix)num$/ then 'integer'
|
||||
when /^(?:True|False)Class$/ then 'boolean'
|
||||
else klass
|
||||
end
|
||||
|
||||
if result == "String" then
|
||||
if value == value.to_i.to_s then
|
||||
result = "Integer"
|
||||
elsif value == value.to_f.to_s then
|
||||
result = "Float"
|
||||
end
|
||||
end
|
||||
|
||||
return result.downcase
|
||||
end
|
||||
end
|
||||
|
||||
# vim: set ts=2 sw=2 et :
|
|
@ -1,34 +0,0 @@
|
|||
#
|
||||
# union.rb
|
||||
#
|
||||
|
||||
module Puppet::Parser::Functions
|
||||
newfunction(:union, :type => :rvalue, :doc => <<-EOS
|
||||
This function returns a union of two arrays.
|
||||
|
||||
*Examples:*
|
||||
|
||||
union(["a","b","c"],["b","c","d"])
|
||||
|
||||
Would return: ["a","b","c","d"]
|
||||
EOS
|
||||
) do |arguments|
|
||||
|
||||
# Two arguments are required
|
||||
raise(Puppet::ParseError, "union(): Wrong number of arguments " +
|
||||
"given (#{arguments.size} for 2)") if arguments.size != 2
|
||||
|
||||
first = arguments[0]
|
||||
second = arguments[1]
|
||||
|
||||
unless first.is_a?(Array) && second.is_a?(Array)
|
||||
raise(Puppet::ParseError, 'union(): Requires 2 arrays')
|
||||
end
|
||||
|
||||
result = first | second
|
||||
|
||||
return result
|
||||
end
|
||||
end
|
||||
|
||||
# vim: set ts=2 sw=2 et :
|
|
@ -1,51 +0,0 @@
|
|||
#
|
||||
# unique.rb
|
||||
#
|
||||
|
||||
module Puppet::Parser::Functions
|
||||
newfunction(:unique, :type => :rvalue, :doc => <<-EOS
|
||||
This function will remove duplicates from strings and arrays.
|
||||
|
||||
*Examples:*
|
||||
|
||||
unique("aabbcc")
|
||||
|
||||
Will return:
|
||||
|
||||
abc
|
||||
|
||||
You can also use this with arrays:
|
||||
|
||||
unique(["a","a","b","b","c","c"])
|
||||
|
||||
This returns:
|
||||
|
||||
["a","b","c"]
|
||||
EOS
|
||||
) do |arguments|
|
||||
|
||||
raise(Puppet::ParseError, "unique(): Wrong number of arguments " +
|
||||
"given (#{arguments.size} for 1)") if arguments.size < 1
|
||||
|
||||
value = arguments[0]
|
||||
klass = value.class
|
||||
|
||||
unless [Array, String].include?(klass)
|
||||
raise(Puppet::ParseError, 'unique(): Requires either ' +
|
||||
'array or string to work with')
|
||||
end
|
||||
|
||||
result = value.clone
|
||||
|
||||
string = value.is_a?(String) ? true : false
|
||||
|
||||
# We turn any string value into an array to be able to shuffle ...
|
||||
result = string ? result.split('') : result
|
||||
result = result.uniq # Remove duplicates ...
|
||||
result = string ? result.join : result
|
||||
|
||||
return result
|
||||
end
|
||||
end
|
||||
|
||||
# vim: set ts=2 sw=2 et :
|
|
@ -1,41 +0,0 @@
|
|||
#
|
||||
# upcase.rb
|
||||
#
|
||||
|
||||
module Puppet::Parser::Functions
|
||||
newfunction(:upcase, :type => :rvalue, :doc => <<-EOS
|
||||
Converts a string or an array of strings to uppercase.
|
||||
|
||||
*Examples:*
|
||||
|
||||
upcase("abcd")
|
||||
|
||||
Will return:
|
||||
|
||||
ASDF
|
||||
EOS
|
||||
) do |arguments|
|
||||
|
||||
raise(Puppet::ParseError, "upcase(): Wrong number of arguments " +
|
||||
"given (#{arguments.size} for 1)") if arguments.size < 1
|
||||
|
||||
value = arguments[0]
|
||||
klass = value.class
|
||||
|
||||
unless [Array, String].include?(klass)
|
||||
raise(Puppet::ParseError, 'upcase(): Requires either ' +
|
||||
'array or string to work with')
|
||||
end
|
||||
|
||||
if value.is_a?(Array)
|
||||
# Numbers in Puppet are often string-encoded which is troublesome ...
|
||||
result = value.collect { |i| i.is_a?(String) ? i.upcase : i }
|
||||
else
|
||||
result = value.upcase
|
||||
end
|
||||
|
||||
return result
|
||||
end
|
||||
end
|
||||
|
||||
# vim: set ts=2 sw=2 et :
|
|
@ -1,35 +0,0 @@
|
|||
#
|
||||
# uriescape.rb
|
||||
#
|
||||
require 'uri'
|
||||
|
||||
module Puppet::Parser::Functions
|
||||
newfunction(:uriescape, :type => :rvalue, :doc => <<-EOS
|
||||
Urlencodes a string or array of strings.
|
||||
Requires either a single string or an array as an input.
|
||||
EOS
|
||||
) do |arguments|
|
||||
|
||||
raise(Puppet::ParseError, "uriescape(): Wrong number of arguments " +
|
||||
"given (#{arguments.size} for 1)") if arguments.size < 1
|
||||
|
||||
value = arguments[0]
|
||||
klass = value.class
|
||||
|
||||
unless [Array, String].include?(klass)
|
||||
raise(Puppet::ParseError, 'uriescape(): Requires either ' +
|
||||
'array or string to work with')
|
||||
end
|
||||
|
||||
if value.is_a?(Array)
|
||||
# Numbers in Puppet are often string-encoded which is troublesome ...
|
||||
result = value.collect { |i| i.is_a?(String) ? URI.escape(i,unsafe) : i }
|
||||
else
|
||||
result = URI.escape(value)
|
||||
end
|
||||
|
||||
return result
|
||||
end
|
||||
end
|
||||
|
||||
# vim: set ts=2 sw=2 et :
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue