Merge remote-tracking branch 'upstream/stretch_kde_update' into january_19_merge

This commit is contained in:
ts
2019-01-11 12:01:38 +00:00
656 changed files with 46450 additions and 636 deletions

View File

@@ -41,9 +41,11 @@ DOCUMENTATION_DIR = "#{ROOT_DIR}/documentation/yard/doc"
# Path to resources
WORDLISTS_DIR = "#{ROOT_DIR}/lib/resources/wordlists"
LINELISTS_DIR = "#{ROOT_DIR}/lib/resources/linelists"
IMAGES_DIR = "#{ROOT_DIR}/lib/resources/images"
# Path to secgen_functions puppet module
# Path to build puppet modules
STDLIB_PUPPET_DIR = "#{MODULES_DIR}build/puppet/stdlib"
SECGEN_FUNCTIONS_PUPPET_DIR = "#{MODULES_DIR}build/puppet/secgen_functions"
## PACKER CONSTANTS ##
@@ -73,4 +75,4 @@ RETRIES_LIMIT = 10
# Version number of SecGen
# e.g. [release state (0 = alpha, 3 = final release)].[Major bug fix].[Minor bug fix].[Cosmetic or other features]
VERSION_NUMBER = '0.0.1.1'
VERSION_NUMBER = '0.0.1.1'

View File

@@ -36,24 +36,25 @@ class GemExec
end
end
Dir.chdir(working_dir)
output_hash = {:output => '', :status => 0, :exception => nil}
begin
# Times out after 30 minutes, (TODO: make this configurable)
output_hash[:output] = ProcessHelper.process("#{gem_path} #{arguments}", {:pty => true, :timeout => (60 * 30),
include_output_in_exception: true})
rescue Exception => ex
output_hash[:status] = 1
output_hash[:exception] = ex
if ex.class == ProcessHelper::UnexpectedExitStatusError
output_hash[:output] = ex.to_s.split('Command output: ')[1]
Print.err 'Non-zero exit status...'
elsif ex.class == ProcessHelper::TimeoutError
Print.err 'Timeout: Killing process...'
sleep(30)
output_hash[:output] = ex.to_s.split('Command output prior to timeout: ')[1]
else
output_hash[:output] = nil
Dir.chdir(working_dir) do
begin
# Times out after 30 minutes, (TODO: make this configurable)
output_hash[:output] = ProcessHelper.process("#{gem_path} #{arguments}", {:pty => true, :timeout => (60 * 30),
include_output_in_exception: true})
rescue Exception => ex
output_hash[:status] = 1
output_hash[:exception] = ex
if ex.class == ProcessHelper::UnexpectedExitStatusError
output_hash[:output] = ex.to_s.split('Command output: ')[1]
Print.err 'Non-zero exit status...'
elsif ex.class == ProcessHelper::TimeoutError
Print.err 'Timeout: Killing process...'
sleep(30)
output_hash[:output] = ex.to_s.split('Command output prior to timeout: ')[1]
else
output_hash[:output] = nil
end
end
end
output_hash

View File

@@ -163,6 +163,117 @@ class OVirtFunctions
end
end
def self.assign_networks(options, scenario_path, vm_names)
vms = []
Print.debug vm_names.to_s
ovirt_connection = get_ovirt_connection(options)
ovirt_vm_names = build_ovirt_names(scenario_path, options[:prefix], vm_names)
ovirt_vm_names.each do |vm_name|
Print.debug vm_name
vms << vms_service(ovirt_connection).list(search: "name=#{vm_name}")
end
Print.debug vms.to_s
network_name = options[:ovirtnetwork]
network_network = nil
network_profile = nil
# Replace 'network' with 'snoop' where the system name contains snoop
snoop_network_name = network_name.gsub(/network/, 'snoop')
snoop_profile = nil
# get the service that manages the nics
vnic_profiles_service = ovirt_connection.system_service.vnic_profiles_service
vnic_profiles_service.list.shuffle.each do |vnic_profile|
if vnic_profile.name =~ /#{network_name}/
Print.info "Found: #{vnic_profile.name} (#{vnic_profile.network.id})"
network_profile = vnic_profile
network_network = vnic_profile.network
vnic_profiles_service.list.each do |vnic_snoop_profile|
if vnic_snoop_profile.name =~ /snoop/ && vnic_snoop_profile.network.id == network_network.id
Print.info "Found: #{vnic_snoop_profile.name} (#{vnic_snoop_profile.network.id})"
snoop_profile = vnic_snoop_profile
end
end
break
end
end
vms.each do |vm_list|
vm_list.each do |vm|
Print.std " Assigning network to: #{vm.name}"
begin
# find the service that manages that vm
vm_service = vms_service(ovirt_connection).vm_service(vm.id)
# find the service that manages the nics of that vm
nics_service = vm_service.nics_service
# set the first nic
nic = nics_service.list.first
selected_profile = nil
if vm.name =~ /snoop/
Print.info " Assigning network: #{snoop_network_name}"
selected_profile = snoop_profile
else
Print.info " Assigning network: #{network_name}"
selected_profile = network_profile
end
# save profile changes
nic.vnic_profile = selected_profile
update = {}
nics_service.nic_service(nic.id).update(nic, update)
nic.interface = OvirtSDK4::NicInterface::E1000
# if the vm is up we need to unplug the nic while we change the interface
if vm.status != 'down'
nic.plugged = false
nics_service.nic_service(nic.id).update(nic, update)
end
nic.plugged = true
nics_service.nic_service(nic.id).update(nic, update)
# check if changes saved
nic_updated = nics_service.list.first
Print.info "#{nic_updated.vnic_profile.name}"
if nic_updated.vnic_profile != selected_profile
Print.err "NIC profile may not have saved correctly... trying again."
# try again!
nics_service.nic_service(nic.id).update(nic, update)
nics_service.nic_service(nic.id).update(nic, update)
nic_updated = nics_service.list.last
if nic_updated.vnic_profile != selected_profile
Print.err "NIC profile may STILL have not saved correctly!"
end
end
rescue Exception => e
Print.err 'Error adding network:'
Print.err e.message
end
end
end
end
def self.assign_affinity_group(options, scenario_path, vm_names)
vms = []
ovirt_vm_names = build_ovirt_names(scenario_path, options[:prefix], vm_names)
ovirt_vm_names.each do |vm_name|
# python affinity group
if system "python #{ROOT_DIR}/lib/helpers/ovirt_affinity.py #{options[:ovirtaffinitygroup]} #{vm_name} #{options[:ovirturl]} #{options[:ovirtuser]} #{options[:ovirtpass]}"
Print.std "Affinity group assigned"
else
Print.err "Failed to assign affinity group"
exit 1
end
end
end
def self.assign_permissions(options, scenario_path, vm_names)
ovirt_connection = get_ovirt_connection(options)
username = options[:prefix].chomp

View File

@@ -0,0 +1,80 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# The ruby ovirt sdk module doesn't access affinity groups correctly
# by Paul Staniforth
# and Z. Cliffe Schreuders
import logging
import getpass
import ovirtsdk4 as sdk
import ovirtsdk4.types as types
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("affinitygroup")
parser.add_argument("vm_name_search")
parser.add_argument("ovirt_url")
parser.add_argument("ovirt_username")
parser.add_argument("ovirt_password")
args = parser.parse_args()
print(args)
# Create the connection to the server:
connection = sdk.Connection(
url=args.ovirt_url,
username=args.ovirt_username,
password=args.ovirt_password,
debug=True,
log=logging.getLogger(),
)
# Locate the clusters service and use it to find the cluster
clusters_service = connection.system_service().clusters_service()
cluster = clusters_service.list(search='name=default')[0]
cluster_service = clusters_service.cluster_service(cluster.id)
cluster_affinitygroups_service = cluster_service.affinity_groups_service()
cluster_service = clusters_service.cluster_service(cluster.id)
cluster_affinitygroups_service = cluster_service.affinity_groups_service()
# could create the affinity group?
# cluster_affinitygroups_service.add(
# types.AffinityGroup(
# name='new_affinity_label10',
# description='software defined',
# vms_rule=types.AffinityRule(
# enabled=True,
# positive=True,
# enforcing=True,
# ),
# ),
# )
# Get the reference to the "vms" service:
vms_service = connection.system_service().vms_service()
# Find the virtual machine:
vms = vms_service.list(search='name=' + args.vm_name_search)
affinitygroups = cluster_affinitygroups_service.list()
for affinitygroup in affinitygroups:
print (affinitygroup.name + '--' + args.affinitygroup)
if affinitygroup.name == args.affinitygroup:
print ("Using Affinity_Group: " + affinitygroup.name + " Affinity_Group ID: " + affinitygroup.id)
group_service = cluster_affinitygroups_service.group_service(affinitygroup.id)
group_vms_service = group_service.vms_service()
for vm in vms:
print ("Adding VM: " + vm.name)
group_vms_service.add(
vm=types.Vm(
id=vm.id,
)
)
# Close the connection to the server:
connection.close()

View File

@@ -65,7 +65,7 @@ class ProjectFilesCreator
Print.std "Creating Puppet modules librarian-puppet file: #{pfile}"
template_based_file_write(PUPPET_TEMPLATE_FILE, pfile)
Print.std 'Preparing puppet modules using librarian-puppet'
librarian_output = GemExec.exe('librarian-puppet', path, 'install')
librarian_output = GemExec.exe('librarian-puppet', path, 'install --verbose')
if librarian_output[:status] != 0
Print.err 'Failed to prepare puppet modules!'
abort
@@ -142,14 +142,14 @@ class ProjectFilesCreator
Print.err "Error writing file: #{e.message}"
abort
end
# Create the CTFd zip file for import
ctfdfile = "#{@out_dir}/CTFd_importable.zip"
Print.std "Creating CTFd configuration: #{ctfdfile}"
ctfd_generator = CTFdGenerator.new(@systems, @scenario, @time)
ctfd_files = ctfd_generator.ctfd_files
# zip up the CTFd export
begin
Zip::ZipFile.open(ctfdfile, Zip::ZipFile::CREATE) { |zipfile|
@@ -171,8 +171,8 @@ class ProjectFilesCreator
Print.err "Error writing zip file: #{e.message}"
abort
end
Print.std "VM(s) can be built using 'vagrant up' in #{@out_dir}"
end
@@ -236,6 +236,13 @@ class ProjectFilesCreator
split_ip.join('.')
end
# Replace 'network' with 'snoop' where the system name contains snoop
def get_ovirt_network_name(system_name, network_name)
split_name = network_name.split('-')
split_name[1] = 'snoop' if system_name.include? 'snoop'
split_name.join('-')
end
# Returns binding for erb files (access to variables in this classes scope)
# @return binding
def get_binding

View File

@@ -46,7 +46,7 @@ class XmlScenarioGenerator
# (we just output the end result in terms of literal values)
if selected_module.write_to_module_with_id != ''
xml.comment "Used to calculate values: #{selected_module.module_path}"
xml.comment " (inputs: #{selected_module.received_inputs.inspect}, outputs: #{selected_module.output.inspect})"
xml.comment " (inputs: #{selected_module.received_inputs.inspect.encode(:xml => :text).gsub('--', '-')}, outputs: #{selected_module.output.inspect.encode(:xml => :text).gsub('--', '-')})"
return
end
case selected_module.module_type

View File

@@ -0,0 +1,7 @@
All your base are belong to us!
You've been hacked!
Hahaha... Your security is not so good.
Mess with the best, die like the rest.
Hack the planet!
When I was a child, I spake as a child, I understood as a child, I thought as a child: but when I became a man, I put away childish things
Your server is powned!

View File

@@ -0,0 +1,4 @@
Welcome to the server!
Greetings! Welcome to the server.
G-day mate!
Welcome back

View File

@@ -24,11 +24,9 @@ mustang
1234567890
michael
654321
pussy
superman
1qaz2wsx
7777777
fuckyou
121212
000000
qazwsx
@@ -48,7 +46,6 @@ andrew
tigger
sunshine
iloveyou
fuckme
2000
charlie
robert
@@ -60,7 +57,6 @@ starwars
klaster
112233
george
asshole
computer
michelle
jessica
@@ -73,7 +69,6 @@ zxcvbn
freedom
777777
pass
fuck
maggie
159753
aaaaaa

View File

@@ -8,7 +8,7 @@
forge "https://forgeapi.puppetlabs.com"
mod 'puppetlabs-stdlib', '4.18.0' # stdlib enables parsejson() in manifests and other useful functions
mod 'puppetlabs-stdlib', '4.18.0', :path => '<%= STDLIB_PUPPET_DIR %>' # stdlib enables parsejson() in manifests and other useful functions
mod 'SecGen-secgen_functions', :path => '<%= SECGEN_FUNCTIONS_PUPPET_DIR %>'
<% @currently_processing_system.module_selections.each do |selected_module| -%>

View File

@@ -108,9 +108,9 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
<%= selected_module.to_s_comment -%>
<% if selected_module.module_type == 'network' and selected_module.received_inputs.include? 'IP_address' %>
<%= ' # This module has a datastore entry for IP_address, using that instead of the default.' -%>
<%= ' # This module has a datastore entry for IP_address, using that instead of the default.' %>
<% elsif selected_module.module_type == 'network' and @options.has_key? :ip_ranges -%>
<%= ' # This module has a command line ip_range, using that instead of the default.' -%>
<%= ' # This module has a command line ip_range, using that instead of the default.' %>
<% end -%>
<% case selected_module.module_type
when 'base' -%>
@@ -129,28 +129,28 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
<%= system.name %>.vm.network :forwarded_port, guest: 5985, host: 5985, id: "winrm", auto_correct: true
<% end %>
<% when 'network' -%>
<% # DHCP networking -%>
<% if (selected_module.attributes['range'].first.nil? || selected_module.attributes['range'].first == "dhcp") and (!selected_module.received_inputs.include? 'IP_address' and !@options[:ip_ranges])-%>
<% if (@options.has_key? :ovirtnetwork) && (@options.has_key? :ovirtuser) && (@options.has_key? :ovirtpass) %>
<%= system.name %>.vm.network :<%= selected_module.attributes['type'].first %>, type: "dhcp", :ovirt__network_name => '<%= "#{@options[:ovirtnetwork]}" %>'
<% else %>
<%= system.name %>.vm.network :<%= selected_module.attributes['type'].first %>, type: "dhcp", auto_config: false
<% end %>
<% if (@options.has_key? :ovirtnetwork) && (@options.has_key? :ovirtuser) && (@options.has_key? :ovirtpass) %>
<%= system.name %>.vm.network :<%= selected_module.attributes['type'].first %>, type: "dhcp", :ovirt__network_name => '<%= get_ovirt_network_name(system.name, @options[:ovirtnetwork]) %>'
<% else %>
<%= system.name %>.vm.network :<%= selected_module.attributes['type'].first %>, type: "dhcp", auto_config: false
<% end %>
<% # Static networking -%>
<% else -%>
<% if (@options.has_key? :ovirtuser) && (@options.has_key? :ovirtpass) %>
<% if @ovirt_template and (@ovirt_template.include? 'kali_linux_msf' or @ovirt_template.include? 'debian_server' )%>
<%= system.name %>.vm.provision 'shell', inline: "echo \"auto lo\niface lo inet loopback\n\nauto eth0\niface eth0 inet static\n\taddress <%= resolve_network(selected_module)%>\" > /etc/network/interfaces"
<%= system.name %>.vm.provision 'shell', inline: "echo '' > /etc/environment"
<% elsif @ovirt_template and @ovirt_template.include? 'debian_desktop_kde' %>
<%= system.name %>.vm.provision 'shell', inline: "echo \"\nauto eth1\niface eth1 inet static\n\taddress <%= resolve_network(selected_module)%>\" >> /etc/network/interfaces"
<%= system.name %>.vm.provision 'shell', inline: "echo '' > /etc/environment"
<% elsif @ovirt_template and ( @ovirt_template.include? 'debian_stretch_server_n' or @ovirt_template.include? 'debian_stretch_desktop_kde') %>
<%= system.name %>.vm.provision 'shell', inline: "echo \"\nauto ens3\niface ens3 inet static\n\taddress <%= resolve_network(selected_module)%>\" > /etc/network/interfaces"
<% else %>
<%= system.name %>.vm.network :<%= selected_module.attributes['type'].first %>, :ovirt__ip => "<%= resolve_network(selected_module)%>", :ovirt__network_name => '<%= "#{@options[:ovirtnetwork]}" %>'
<% end %>
<% else %>
<%= system.name %>.vm.network :<%= selected_module.attributes['type'].first %>, ip: "<%= resolve_network(selected_module)%>"
<% end %>
<% # Static oVirt networking -%>
<% if (@options.has_key? :ovirtuser) && (@options.has_key? :ovirtpass) -%>
<% interface = 'ens3' -%>
<% if @ovirt_base_template and @ovirt_base_template =~ /kali|debian_desktop_kde/ -%>
<% interface = 'eth0' -%>
<% end -%>
# use some shell scripting to identify the name of the network interface (eth0/ens3/...), and set the IP address statically
<%= system.name %>.vm.provision 'shell', inline: "echo -e \"auto lo\niface lo inet loopback\n\nauto <%= interface %>\niface <%= interface %> inet static\n\taddress <%= resolve_network(selected_module)%>\" > /etc/network/interfaces"
<%= system.name %>.vm.provision 'shell', inline: "echo '' > /etc/environment"
<% # Static Virtualbox networking -%>
<% else -%>
<%= system.name %>.vm.network :<%= selected_module.attributes['type'].first %>, ip: "<%= resolve_network(selected_module)%>"
<% end -%>
<% end -%>
<% when 'vulnerability', 'service', 'utility', 'build' -%>
<% module_name = selected_module.module_path_name -%>

View File

@@ -15,7 +15,7 @@
<platform>unix</platform>
<distro>Debian 9.5.0 Stretch amd64</distro>
<url>https://app.vagrantup.com/secgen/boxes/debian_stretch_server/versions/1.1/providers/virtualbox.box</url>
<ovirt_template>debian_stretch_server_n</ovirt_template>
<ovirt_template>debian_stretch_server_291118</ovirt_template>
<software_license>various</software_license>
</base>
</base>

View File

@@ -14,7 +14,7 @@
<platform>unix</platform>
<distro>Debian 9.5.0 Stretch amd64</distro>
<url>https://app.vagrantup.com/secgen/boxes/debian_stretch_desktop_kde/versions/1.1/providers/virtualbox.box</url>
<ovirt_template>debian_stretch_desktop_kde</ovirt_template>
<ovirt_template>stretch_desktop_kde_301118</ovirt_template>
<reference>https://atlas.hashicorp.com/puppetlabs</reference>
<software_license>various</software_license>

View File

@@ -0,0 +1,812 @@
# Change log
All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org).
## Supported Release 4.18.0
### Summary
Small release that reverts the Puppet version requirement lower bound to again include Puppet 2.7+ and bumps the upper bound to now include Puppet 5.
#### Fixed
- Reverts lower bound of Puppet requirement to 2.7.20
## Supported Release 4.17.1
### Summary
Small release to address a bug (PUP-7650). Also pushes the Puppet version compatibility to 4.7.0.
#### Bugfixes
- (MODULES-5095) Workaround for PUP-7650
- (FM-6197) Formatting fixes for file_line resource
## Supported Release 4.17.0
### Summary
This release adds support for internationalization. It also contains Japanese translations for the README, summary and description of the metadata.json and major cleanups in the README. Additional folders have been introduced called locales and readmes where translation files can be found. A number of features and bug fixes are also included in this release. It also adds a new function `glob()` for expanding file lists. Also works around an issue that appeared in puppet 4.6.0 involving types being declared multiple times.
#### Features
- Addition of POT file / folder structure for i18n.
- Addition of Internationalized READMEs.
- `glob()` function
### Fixed
- Occasional duplicate type definitions when using `defined_with_params()`
- `file_line` encoding issue on ruby 1.8 (unsupported)
- Huge readme refresh
## Supported Release 4.16.0
### Summary
This release sees a massive update to all unit tests to test UTF8 characters. There are also multiple cleanups in preparation for internationalization. Alongside this, improvements to ipv6 support, a new length function compatible with Puppet 4, and an update to path types. Also contains multiple bug fixes around functionality and tests.
#### Features
- Addition of coverage in all unit tests for functions, data and resource types for UTF8 for i18n.
- All strings within the readme and functions that are split over two lines have been combined in preparation for i18n parser/decorator.
- Improvement on the ipv6 support for type - Improves regex to catch some valid (but lesser known) ipv6 strings, mostly those which are a mix of ipv6 strings and embedded ipv6 numbers.
- Adds a new parameter `encoding` to allow non UTF-8 files to specify a file encoding. This prevents receiving the error message "invalid byte sequence in UTF-8" when special characters that are not UTF-8 encoded appear in the input stream, such as the copyright symbol.
- Addition of the new length function. Returns the length of a given string, array or hash. To eventually replace the deprecated size() function as can handle the new type functionality introduced in Puppet 4.
- Permit double slash in absolute/Unix path types.
#### Bugfixes
- Fix unsupported data type error with rspec-puppet master.
- Now allows test module metadata.json to be read by Puppet.
- Fix acceptance test failure "Hiera is not a class".
- Removal of unsupported platforms and future parser setting in acceptance tests.
- Regex for tuple checking has been loosened.
- Ensure_packages function - Now only tries to apply the resource if not defined.
- (MODULES-4528) Use versioncmp to check Puppet version for 4.10.x compat.
- Adds comments to warn for UTF8 incompatibility of the functions that may not be compatible with UTF8 with Ruby < 2.4.0.
## Supported Release 4.15.0
### Summary
This release introduces multiple new functions, a new fact and the addition of Ubuntu Xenial support. Also includes a bugfix and documentation update.
#### Features
- Addition of puppet_server fact to return agents server.
- Addition of a pry function.
- Addition of tests for ensure_resources.
- Addition of FQDN UUID generation function.
- Addition of Ubuntu Xenial to OS Support.
####Bugfixes
- Ensure_packages now works with Ruby < 2.0.
- Updated the documentation of str2bool function.
## Supported Release 4.14.0
### Summary
Adds several new features and updates, especially around refining the deprecation and validate_legacy functions. Also includes a Gemfile update around an issue with parallel_tests dependancy for different versions of Ruby.
#### Features
- Deprecation function now uses puppet stacktrace if available.
- join_key_to_values function now handles array values. If values are arrays, multiple keys are added for each element.
- Updated Gemfile to deal with parallel_tests Ruby dependancy (MODULES-3983).
- Updated/Fixed ipv4 regex validator (MODULES-3980).
- Deprecation clarification added to README.
#### Bugfixes
- README typo fixes.
- Use .dup to duplicate classes for modification (MODULES-3829).
- Fixes spec failures that were caused by a change in the tested error message in validate_legacy_spec.
- Broken link to validate_legacy docs fixed.
- Updates deprecation tests to include future parser.
## Supported Release 4.13.1
### Summary
This bugfix release addresses the `undefined method 'optional_repeated_param'` error messages seen by users of puppet 3.7.
It also improves the user experience around function deprecations by emitting one warning per function(-name) instead of only one deprecation overall. This allows users to identify all deprecated functions used in one agent run, with less back-and-forth.
#### Bugfixes
* Emit deprecations warnings for each function, instead of once per process. (MODULES-3961)
* Use a universally available API for the v4 deprecation stubs of `is_*` and `validate_*`. (MODULES-3962)
* Make `getvar()` compatible to ruby 1.8.7. (MODULES-3969)
* Add v4 deprecation stubs for the `is_` counterparts of the deprecated functions to emit the deprecations warnings in all cases.
## Supported Release 4.13.0
### Summary
This version of stdlib deprecates a whole host of functions, and provides stepping stones to move to Puppet 4 type validations. Be sure to check out the new `deprecation()` and `validate_legacy()` functions to migrate off the deprecated v3-style data validations.
Many thanks to all community contributors: bob, Dmitry Ilyin, Dominic Cleal, Joris, Joseph Yaworski, Loic Antoine-Gombeaud, Maksym Melnychok, Michiel Brandenburg, Nate Potter, Romain Tartière, Stephen Benjamin, and Steve Moore, as well as anyone contributing in the code review process and by submitting issues.
Special thanks to [Voxpupuli's](https://voxpupuli.org/) Igor Galić for donating the puppet-tea types to kickstart this part of stdlib.
#### Deprecations
* `validate_absolute_path`, `validate_array`, `validate_bool`, `validate_hash`, `validate_integer`, `validate_ip_address`, `validate_ipv4_address`, `validate_ipv6_address`, `validate_numeric`, `validate_re`, `validate_slength`, `validate_string`, and their `is_` counter parts are now deprecated on Puppet 4. See the `validate_legacy()` description in the README for help on migrating away from those functions.
* The `dig` function is provided by core puppet since 4.5.0 with slightly different calling convention. The stdlib version can still be accessed as `dig44` for now.
#### Features
* Add Puppet 4 data types for Unix, and Windows paths, and URLs.
* Add `deprecation` function to warn users of functionality that will be removed soon.
* Add `validate_legacy` function to help with migrating to Puppet 4 data types.
* Add `any2bool` function, a combination of of `string2bool` and `num2bool`.
* Add `delete_regex` function to delete array elements matching a regular expression.
* Add `puppet_environmentpath` fact to expose the `environmentpath` setting.
* Add `regexpescape` function to safely insert arbitrary strings into regular expressions.
* Add `shell_escape`, `shell_join`, and `shell_split` functions for safer working with shell scripts..
* The `delete` function now also accepts regular expressions as search term.
* The `loadyaml` function now accepts a default value, which is returned when there is an error loading the file.
#### Bugfixes
* Fix `file_line.match_for_absence` implementation and description to actually work. (MODULES-3590)
* Fix `getparam` so that it can now also return `false`. (MODULES-3933)
* Fix the fixture setup for testing and adjust `load_module_metadata` and `loadjson` tests.
* Fix `defined_with_params` to handle `undef` correctly on all puppet versions. (PUP-6422, MODULES-3543)
* Fix `file_line.path` validation to use puppet's built in `absolute_path?` matcher.
#### Minor Improvements
* README changes: improved descriptions of `deep_merge`, `delete`, `ensure_packages`, `file_line.after`, `range`, and `validate_numeric`.
* The `getvar` function now returns nil in all situations where the variable is not found.
* Update the `dig44` function with better `undef`, `nil`, and `false` handling.
* Better wording on `str2bool` argument validation error message.
### Known issues
* The `validate_legacy` function relies on internal APIs from Puppet 4.4.0 (PE 2016.1) onwards, and doesn't work on earlier versions.
* Puppet 4.5.0 (PE 2016.2) has a number of improvements around data types - especially error handling - that make working with them much nicer.
## Supported Release 4.12.0
###Summary
This release provides several new functions, bugfixes, modulesync changes, and some documentation updates.
####Features
- Adds `clamp`. This function keeps values within a specified range.
- Adds `validate_x509_rsa_key_pair`. This function validates an x509 RSA certificate and key pair.
- Adds `dig`. This function performs a deep lookup in nested hashes or arrays.
- Extends the `base64` support to fit `rfc2045` and `rfc4648`.
- Adds `is_ipv6_address` and `is_ipv4_address`. These functions validate the specified ipv4 or ipv6 addresses.
- Adds `enclose_ipv6`. This function encloses IPv6 addresses in square brackets.
- Adds `ensure_resources`. This function takes a list of resources and creates them if they do not exist.
- Extends `suffix` to support applying a suffix to keys in a hash.
- Apply modulesync changes.
- Add validate_email_address function.
####Bugfixes
- Fixes `fqdn_rand_string` tests, since Puppet 4.4.0 and later have a higher `fqdn_rand` ceiling.
- (MODULES-3152) Adds a check to `package_provider` to prevent failures if Gem is not installed.
- Fixes to README.md.
- Fixes catch StandardError rather than the gratuitous Exception
- Fixes file_line attribute validation.
- Fixes concat with Hash arguments.
## Supported Release 4.11.0
###Summary
Provides a validate_absolute_paths and Debian 8 support. There is a fix to the is_package_provider fact and a test improvement.
####Features
- Adds new parser called is_absolute_path
- Supports Debian 8
####Bugfixes
- Allow package_provider fact to resolve on PE 3.x
####Improvements
- ensures that the test passes independently of changes to rubygems for ensure_resource
##2015-12-15 - Supported Release 4.10.0
###Summary
Includes the addition of several new functions and considerable improvements to the existing functions, tests and documentation. Includes some bug fixes which includes compatibility, test and fact issues.
####Features
- Adds service_provider fact
- Adds is_a() function
- Adds package_provider fact
- Adds validate_ip_address function
- Adds seeded_rand function
####Bugfixes
- Fix backwards compatibility from an improvement to the parseyaml function
- Renaming of load_module_metadata test to include _spec.rb
- Fix root_home fact on AIX 5.x, now '-c' rather than '-C'
- Fixed Gemfile to work with ruby 1.8.7
####Improvements
- (MODULES-2462) Improvement of parseyaml function
- Improvement of str2bool function
- Improvement to readme
- Improvement of intersection function
- Improvement of validate_re function
- Improved speed on Facter resolution of service_provider
- empty function now handles numeric values
- Package_provider now prevents deprecation warning about the allow_virtual parameter
- load_module_metadata now succeeds on empty file
- Check added to ensure puppetversion value is not nil
- Improvement to bool2str to return a string of choice using boolean
- Improvement to naming convention in validate_ipv4_address function
## Supported Release 4.9.1
###Summary
Small release for support of newer PE versions. This increments the version of PE in the metadata.json file.
##2015-09-08 - Supported Release 4.9.0
###Summary
This release adds new features including the new functions dos2unix, unix2dos, try_get_value, convert_base as well as other features and improvements.
####Features
- (MODULES-2370) allow `match` parameter to influence `ensure => absent` behavior
- (MODULES-2410) Add new functions dos2unix and unix2dos
- (MODULE-2456) Modify union to accept more than two arrays
- Adds a convert_base function, which can convert numbers between bases
- Add a new function "try_get_value"
####Bugfixes
- n/a
####Improvements
- (MODULES-2478) Support root_home fact on AIX through "lsuser" command
- Acceptance test improvements
- Unit test improvements
- Readme improvements
## 2015-08-10 - Supported Release 4.8.0
### Summary
This release adds a function for reading metadata.json from any module, and expands file\_line's abilities.
#### Features
- New parameter `replace` on `file_line`
- New function `load_module_metadata()` to load metadata.json and return the content as a hash.
- Added hash support to `size()`
#### Bugfixes
- Fix various docs typos
- Fix `file_line` resource on puppet < 3.3
##2015-06-22 - Supported Release 4.7.0
###Summary
Adds Solaris 12 support along with improved Puppet 4 support. There are significant test improvements, and some minor fixes.
####Features
- Add support for Solaris 12
####Bugfixes
- Fix for AIO Puppet 4
- Fix time for ruby 1.8.7
- Specify rspec-puppet version
- range() fix for typeerror and missing functionality
- Fix pw_hash() on JRuby < 1.7.17
- fqdn_rand_string: fix argument error message
- catch and rescue from looking up non-existent facts
- Use puppet_install_helper, for Puppet 4
####Improvements
- Enforce support for Puppet 4 testing
- fqdn_rotate/fqdn_rand_string acceptance tests and implementation
- Simplify mac address regex
- validate_integer, validate_numeric: explicitely reject hashes in arrays
- Readme edits
- Remove all the pops stuff for rspec-puppet
- Sync via modulesync
- Add validate_slength optional 3rd arg
- Move tests directory to examples directory
##2015-04-14 - Supported Release 4.6.0
###Summary
Adds functions and function argument abilities, and improves compatibility with the new puppet parser
####Features
- MODULES-444: `concat()` can now take more than two arrays
- `basename()` added to have Ruby File.basename functionality
- `delete()` can now take an array of items to remove
- `prefix()` can now take a hash
- `upcase()` can now take a hash or array of upcaseable things
- `validate_absolute_path()` can now take an array
- `validate_cmd()` can now use % in the command to embed the validation file argument in the string
- MODULES-1473: deprecate `type()` function in favor of `type3x()`
- MODULES-1473: Add `type_of()` to give better type information on future parser
- Deprecate `private()` for `assert_private()` due to future parser
- Adds `ceiling()` to take the ceiling of a number
- Adds `fqdn_rand_string()` to generate random string based on fqdn
- Adds `pw_hash()` to generate password hashes
- Adds `validate_integer()`
- Adds `validate_numeric()` (like `validate_integer()` but also accepts floats)
####Bugfixes
- Fix seeding of `fqdn_rotate()`
- `ensure_resource()` is more verbose on debug mode
- Stricter argument checking for `dirname()`
- Fix `is_domain_name()` to better match RFC
- Fix `uriescape()` when called with array
- Fix `file_line` resource when using the `after` attribute with `match`
##2015-01-14 - Supported Release 4.5.1
###Summary
This release changes the temporary facter_dot_d cache locations outside of the /tmp directory due to a possible security vunerability. CVE-2015-1029
####Bugfixes
- Facter_dot_d cache will now be stored in puppet libdir instead of tmp
##2014-12-15 - Supported Release 4.5.0
###Summary
This release improves functionality of the member function and adds improved future parser support.
####Features
- MODULES-1329: Update member() to allow the variable to be an array.
- Sync .travis.yml, Gemfile, Rakefile, and CONTRIBUTING.md via modulesync
####Bugfixes
- Fix range() to work with numeric ranges with the future parser
- Accurately express SLES support in metadata.json (was missing 10SP4 and 12)
- Don't require `line` to match the `match` parameter
##2014-11-10 - Supported Release 4.4.0
###Summary
This release has an overhauled readme, new private manifest function, and fixes many future parser bugs.
####Features
- All new shiny README
- New `private()` function for making private manifests (yay!)
####Bugfixes
- Code reuse in `bool2num()` and `zip()`
- Fix many functions to handle `generate()` no longer returning a string on new puppets
- `concat()` no longer modifies the first argument (whoops)
- strict variable support for `getvar()`, `member()`, `values_at`, and `has_interface_with()`
- `to_bytes()` handles PB and EB now
- Fix `tempfile` ruby requirement for `validate_augeas()` and `validate_cmd()`
- Fix `validate_cmd()` for windows
- Correct `validate_string()` docs to reflect non-handling of `undef`
- Fix `file_line` matching on older rubies
##2014-07-15 - Supported Release 4.3.2
###Summary
This release merely updates metadata.json so the module can be uninstalled and
upgraded via the puppet module command.
##2014-07-14 - Supported Release 4.3.1
### Summary
This supported release updates the metadata.json to work around upgrade behavior of the PMT.
#### Bugfixes
- Synchronize metadata.json with PMT-generated metadata to pass checksums
##2014-06-27 - Supported Release 4.3.0
### Summary
This release is the first supported release of the stdlib 4 series. It remains
backwards-compatible with the stdlib 3 series. It adds two new functions, one bugfix, and many testing updates.
#### Features
- New `bool2str()` function
- New `camelcase()` function
#### Bugfixes
- Fix `has_interface_with()` when interfaces fact is nil
##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

View File

@@ -0,0 +1,6 @@
## Maintenance
Maintainers:
- Puppet Forge Modules Team `forge-modules |at| puppet |dot| com`
Tickets: https://tickets.puppet.com/browse/MODULES. Make sure to set component to `stdlib`.

View File

@@ -0,0 +1,23 @@
stdlib puppet module
Copyright (C) 2011-2016 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.

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,35 @@
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.

View File

@@ -0,0 +1,7 @@
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)

View File

@@ -0,0 +1,24 @@
# 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.

View File

@@ -0,0 +1,37 @@
require 'puppetlabs_spec_helper/rake_tasks'
require 'puppet-lint/tasks/puppet-lint'
require 'puppet_blacksmith/rake_tasks' if Bundler.rubygems.find_name('puppet-blacksmith').any?
PuppetLint.configuration.fail_on_warnings = true
PuppetLint.configuration.send('relative')
desc 'Generate pooler nodesets'
task :gen_nodeset do
require 'beaker-hostgenerator'
require 'securerandom'
require 'fileutils'
agent_target = ENV['TEST_TARGET']
if ! agent_target
STDERR.puts 'TEST_TARGET environment variable is not set'
STDERR.puts 'setting to default value of "redhat-64default."'
agent_target = 'redhat-64default.'
end
master_target = ENV['MASTER_TEST_TARGET']
if ! master_target
STDERR.puts 'MASTER_TEST_TARGET environment variable is not set'
STDERR.puts 'setting to default value of "redhat7-64mdcl"'
master_target = 'redhat7-64mdcl'
end
targets = "#{master_target}-#{agent_target}"
cli = BeakerHostGenerator::CLI.new([targets])
nodeset_dir = "tmp/nodesets"
nodeset = "#{nodeset_dir}/#{targets}-#{SecureRandom.uuid}.yaml"
FileUtils.mkdir_p(nodeset_dir)
File.open(nodeset, 'w') do |fh|
fh.print(cli.execute)
end
puts nodeset
end

View File

@@ -0,0 +1,40 @@
version: 1.1.x.{build}
skip_commits:
message: /^\(?doc\)?.*/
clone_depth: 10
init:
- SET
- 'mkdir C:\ProgramData\PuppetLabs\code && exit 0'
- 'mkdir C:\ProgramData\PuppetLabs\facter && exit 0'
- 'mkdir C:\ProgramData\PuppetLabs\hiera && exit 0'
- 'mkdir C:\ProgramData\PuppetLabs\puppet\var && exit 0'
environment:
matrix:
- PUPPET_GEM_VERSION: ~> 4.0
RUBY_VER: 21
- PUPPET_GEM_VERSION: ~> 4.0
RUBY_VER: 21-x64
- PUPPET_GEM_VERSION: ~> 4.0
RUBY_VER: 23
- PUPPET_GEM_VERSION: ~> 4.0
RUBY_VER: 23-x64
- PUPPET_GEM_VERSION: 4.2.3
RUBY_VER: 21-x64
matrix:
fast_finish: true
install:
- SET PATH=C:\Ruby%RUBY_VER%\bin;%PATH%
- bundle install --jobs 4 --retry 2 --without system_tests
- type Gemfile.lock
build: off
test_script:
- bundle exec puppet -V
- ruby -v
- bundle exec rake spec SPEC_OPTS='--format documentation'
notifications:
- provider: Email
to:
- nobody@nowhere.com
on_build_success: false
on_build_failure: false
on_build_status_changed: false

View File

@@ -0,0 +1,515 @@
{
"CHANGELOG.md": "9e903df11077b3badd03beef16493e3f",
"CONTRIBUTING.md": "77d0440d7cd4206497f99065c60bed46",
"Gemfile": "bedf635025b279d7c7732adcc8ae9a29",
"LICENSE": "3b83ef96387f14655fc854ddc3c6bd57",
"MAINTAINERS.md": "b40ec4f2c16145af6f723c2c34bb2ff9",
"NOTICE": "b2e552587e5969886fdd60481e8b0351",
"README.md": "ac4c03f7f00304de7ed5a9eb9c6b84b7",
"README_DEVELOPER.markdown": "220a8b28521b5c5d2ea87c4ddb511165",
"README_SPECS.markdown": "82bb4c6abbb711f40778b162ec0070c1",
"RELEASE_PROCESS.markdown": "94b92bc99ac4106ba1a74d5c04e520f9",
"Rakefile": "3851f083966b9bbd6d46e50dba5aa52a",
"appveyor.yml": "7e0ff52cc2abe3fa4f2d8d978bf18ad7",
"examples/file_line.pp": "d8126b139dd1dce21ff26910d1c5a245",
"examples/has_interface_with.pp": "d69d520cf3ff4d0b495480afaca359ef",
"examples/has_ip_address.pp": "32f42575e49aa66f0f2398a70ae2a9f4",
"examples/has_ip_network.pp": "bfb8db068c58d77c4dd7ae9697536537",
"examples/init.pp": "b52fd907330ddbd9c3e070cf39f7b317",
"lib/facter/facter_dot_d.rb": "d71e93183a680ac78bc0389fd50470a0",
"lib/facter/package_provider.rb": "539766a71dfb2f65e94a7c91bf413fcf",
"lib/facter/pe_version.rb": "60d47406026c8201e51394227ddf780d",
"lib/facter/puppet_settings.rb": "9438c0839ae28dc52fffb8348ae5124f",
"lib/facter/root_home.rb": "35702ae0c7410ec4d2101113e2f697fa",
"lib/facter/service_provider.rb": "66cc42526eae631e306b397391f1f01c",
"lib/facter/util/puppet_settings.rb": "9f1d2593d0ae56bfca89d4b9266aeee1",
"lib/puppet/functions/deprecation.rb": "59b803eaa15b5a559040497bffc172ae",
"lib/puppet/functions/is_a.rb": "9dad7f8c9b75348cd97aca986ac0b29a",
"lib/puppet/functions/is_absolute_path.rb": "96b217f26d06dbac87a2c6a8cfd2d8c8",
"lib/puppet/functions/is_array.rb": "9292a646010d167417a1936b0b0c17b9",
"lib/puppet/functions/is_bool.rb": "73957f9efd75ed8a7ab867f9de6da117",
"lib/puppet/functions/is_float.rb": "af3bd6bb56878bac8cc4fe4f7564e4f9",
"lib/puppet/functions/is_ip_address.rb": "ee231c66c3e039778bf46702d89815a6",
"lib/puppet/functions/is_ipv4_address.rb": "900d33249906c4daa02aa79cac896548",
"lib/puppet/functions/is_ipv6_address.rb": "568fba9af6a83c8b536fafcda82eb448",
"lib/puppet/functions/is_numeric.rb": "33051800b886cc3b2119826b77c9821a",
"lib/puppet/functions/is_string.rb": "230e9eabc5c9e1d8d5fb7b3c6c12b300",
"lib/puppet/functions/length.rb": "03cf801867a919f801d290424fd2bb8d",
"lib/puppet/functions/type_of.rb": "bec00841aae556993c926ab298bc81cd",
"lib/puppet/functions/validate_absolute_path.rb": "54a610baa115c7505f1b35976b632a8e",
"lib/puppet/functions/validate_array.rb": "9052b0026da174636c276a2512cf5acc",
"lib/puppet/functions/validate_bool.rb": "fe979e402a5a3a19d013ce84b39ef06a",
"lib/puppet/functions/validate_hash.rb": "92ea8fc21bbbf6cc41f6bb9cfcaefce7",
"lib/puppet/functions/validate_integer.rb": "b0982b68a599262da2c6f2e032bc7713",
"lib/puppet/functions/validate_ip_address.rb": "65a12af9a2c2a9c70d820d04d19ec891",
"lib/puppet/functions/validate_ipv4_address.rb": "4a5039b99ac97cc0447faa343b9f7416",
"lib/puppet/functions/validate_ipv6_address.rb": "fbdf685432416505fed27d5647c26f9c",
"lib/puppet/functions/validate_legacy.rb": "d9f115f30c511cef536a821b94826094",
"lib/puppet/functions/validate_numeric.rb": "41b2cc7335395f617c2bfbeac8f579da",
"lib/puppet/functions/validate_re.rb": "42092f592ebf89b8a504b10c900230d8",
"lib/puppet/functions/validate_slength.rb": "3ae6fcc3f60032c923d06ab3e457b84e",
"lib/puppet/functions/validate_string.rb": "cc967a9d0ea156b2208d1760d7f6e1b2",
"lib/puppet/parser/functions/abs.rb": "a8e46ecf4fb378d314916599651cebe5",
"lib/puppet/parser/functions/any2array.rb": "a81e71d6b67a551d38770ba9a1948a75",
"lib/puppet/parser/functions/any2bool.rb": "8bbb74cb81ebdb164e1965415364080b",
"lib/puppet/parser/functions/assert_private.rb": "cb9cd79ed4e3d647a48467dfb6237d5c",
"lib/puppet/parser/functions/base64.rb": "0d121a32fbfe25b06a4e91b0259af91d",
"lib/puppet/parser/functions/basename.rb": "c61952b3f68fd86408c84fca2c3febb1",
"lib/puppet/parser/functions/bool2num.rb": "01b070b02611fda7e1491de0a8cd89fc",
"lib/puppet/parser/functions/bool2str.rb": "c00885242abf381ba482644ded70b688",
"lib/puppet/parser/functions/camelcase.rb": "bd5da699dfe1ec27ffe91b06187c5900",
"lib/puppet/parser/functions/capitalize.rb": "c94c50b0f147a22861c3b93c724e4343",
"lib/puppet/parser/functions/ceiling.rb": "7de4a96c8bb645fd5ce5c38438667228",
"lib/puppet/parser/functions/chomp.rb": "35a16c85bc59dc285baae631da1ae771",
"lib/puppet/parser/functions/chop.rb": "3beb80906fa3c759945a2664fe510b20",
"lib/puppet/parser/functions/clamp.rb": "6920e6c11b575fc65dadb21220c01a7a",
"lib/puppet/parser/functions/concat.rb": "d10e5428917895d4bb90c638b148b7fa",
"lib/puppet/parser/functions/convert_base.rb": "c3b3e59a49318af98dcb88aed7156629",
"lib/puppet/parser/functions/count.rb": "325bbd89a29e6ed0f31e0462d0a0d301",
"lib/puppet/parser/functions/deep_merge.rb": "d83696855578fb81b64b9e92b9c7cc7c",
"lib/puppet/parser/functions/defined_with_params.rb": "2d964410afbee415446c94d9692a2112",
"lib/puppet/parser/functions/delete.rb": "7af1540fee4285d93b6b28fb490db70a",
"lib/puppet/parser/functions/delete_at.rb": "a2cba60ac86a676d4ed1ff846a917014",
"lib/puppet/parser/functions/delete_regex.rb": "91cd012ef5a636ffe541814ed232b909",
"lib/puppet/parser/functions/delete_undef_values.rb": "52beef9ee37f84ed2278a69ec4383125",
"lib/puppet/parser/functions/delete_values.rb": "b410f5618b4a6158a921acb7b2dc628d",
"lib/puppet/parser/functions/deprecation.rb": "4323210434d36e37977251f906a232b8",
"lib/puppet/parser/functions/difference.rb": "467e44aeaebd0ee0a51c8b89e3769f1f",
"lib/puppet/parser/functions/dig.rb": "1a2a8918f646c13dcb9876a22f9295ab",
"lib/puppet/parser/functions/dig44.rb": "3078b97ee941c261944857373d400ed6",
"lib/puppet/parser/functions/dirname.rb": "8a5579f9a9a13fd737ba65eccf8e6d5a",
"lib/puppet/parser/functions/dos2unix.rb": "be8359a5106a7832be4180e8207dd586",
"lib/puppet/parser/functions/downcase.rb": "02376505a00accd0ce6b148f869c9c86",
"lib/puppet/parser/functions/empty.rb": "6d7d2dde2971f6a40fa913f0af1c610c",
"lib/puppet/parser/functions/enclose_ipv6.rb": "ec39936a9a51dc5cb8ada6eeb829b239",
"lib/puppet/parser/functions/ensure_packages.rb": "362fac217452d0eee783be7c7ab3a569",
"lib/puppet/parser/functions/ensure_resource.rb": "de703fe63392b939fc2b4392975263de",
"lib/puppet/parser/functions/ensure_resources.rb": "c92d8b69d6354eda24aa3a13d88177b2",
"lib/puppet/parser/functions/flatten.rb": "6a27f5b922a24fec6e823f6f51c98090",
"lib/puppet/parser/functions/floor.rb": "07ba3b1662a14c60fe908b51231355ee",
"lib/puppet/parser/functions/fqdn_rand_string.rb": "9ac5f18e563094aee62ef7586267025d",
"lib/puppet/parser/functions/fqdn_rotate.rb": "2483d17df4e6cb25d92b4e8520f30957",
"lib/puppet/parser/functions/fqdn_uuid.rb": "d357e8837ba2ed8196e926f3697be521",
"lib/puppet/parser/functions/get_module_path.rb": "d4bf50da25c0b98d26b75354fa1bcc45",
"lib/puppet/parser/functions/getparam.rb": "440a9c381b9ad589504e2e9919e83c06",
"lib/puppet/parser/functions/getvar.rb": "0c8c5cef7e158e232a8cf6e42c10d0ff",
"lib/puppet/parser/functions/glob.rb": "c4106d2aff24f4b5a32b54bf4cd452a2",
"lib/puppet/parser/functions/grep.rb": "c2f2dbdf79d16584579c3a7bc7b5902f",
"lib/puppet/parser/functions/has_interface_with.rb": "db65f5aac94e8fe105c7ca0cd1f66403",
"lib/puppet/parser/functions/has_ip_address.rb": "6ce9e6cdfb499b6ce86bf531848a18be",
"lib/puppet/parser/functions/has_ip_network.rb": "3cc7b923fd3cde5062ed9d0eaaa8155f",
"lib/puppet/parser/functions/has_key.rb": "7cd9728c38f0b0065f832dabd62b0e7e",
"lib/puppet/parser/functions/hash.rb": "c1ebb21cc5b984153a87c252a9854db2",
"lib/puppet/parser/functions/intersection.rb": "87469eb81ab00bbacfd744165beeaeec",
"lib/puppet/parser/functions/is_absolute_path.rb": "1ce9a6d1cd0a79087d73cb879ed04542",
"lib/puppet/parser/functions/is_array.rb": "bbce6768b688bc0f36978ecb0f60f7f4",
"lib/puppet/parser/functions/is_bool.rb": "b8800ff7a11b4e8c03616041e218225f",
"lib/puppet/parser/functions/is_domain_name.rb": "5c6106c070945a605c5adbd1852f0691",
"lib/puppet/parser/functions/is_email_address.rb": "1eb786779743e93a7bb9fe8087b38b8d",
"lib/puppet/parser/functions/is_float.rb": "6257620b98c5099293be7aa4088b88ce",
"lib/puppet/parser/functions/is_function_available.rb": "f13934d6b41561ef54d88cf0da86231b",
"lib/puppet/parser/functions/is_hash.rb": "6f1ccf659c41cb5dab4db9fa89f0b364",
"lib/puppet/parser/functions/is_integer.rb": "a4ae475a5a799c0cc46519e86aed2973",
"lib/puppet/parser/functions/is_ip_address.rb": "2eabe60c213df2e642a03ebfd4852497",
"lib/puppet/parser/functions/is_ipv4_address.rb": "ab854b47367921f657410fbe79054f0b",
"lib/puppet/parser/functions/is_ipv6_address.rb": "2a2be7adbdd5ca23c3e21f00d7d8bac7",
"lib/puppet/parser/functions/is_mac_address.rb": "1af27510d3b9b936384192a4e1dfbf8c",
"lib/puppet/parser/functions/is_numeric.rb": "bfd99f39e2506953ad00178db6fa07ea",
"lib/puppet/parser/functions/is_string.rb": "c1405dd293e9e3c738b83c4ef5aab1ef",
"lib/puppet/parser/functions/join.rb": "2ed4f56d296a4535da142e01b11a126d",
"lib/puppet/parser/functions/join_keys_to_values.rb": "71ad24ac1809739713c461141aedd082",
"lib/puppet/parser/functions/keys.rb": "c10485a3d6c53b6d57a891b9852898de",
"lib/puppet/parser/functions/load_module_metadata.rb": "805c5476a6e7083d133e167129885924",
"lib/puppet/parser/functions/loadjson.rb": "ffecf61ba2ec8011915d37009b1a273e",
"lib/puppet/parser/functions/loadyaml.rb": "668265f14327cba1d1400f2078b7b26b",
"lib/puppet/parser/functions/lstrip.rb": "e9cbd5c2233233940e7344478362fb9f",
"lib/puppet/parser/functions/max.rb": "529eb6ac3d88c03caa788167594bd487",
"lib/puppet/parser/functions/member.rb": "03d618926bbb9efd117950e6078c3878",
"lib/puppet/parser/functions/merge.rb": "f3dcc5c83440cdda2036cce69b61a14b",
"lib/puppet/parser/functions/min.rb": "8d829c8a55c9330ab02f962926221d4f",
"lib/puppet/parser/functions/num2bool.rb": "ddb603cf74f92e16a00f1447a4403429",
"lib/puppet/parser/functions/parsejson.rb": "15165fd3807d9f3d657697fa854d643d",
"lib/puppet/parser/functions/parseyaml.rb": "db54578d9d798ced75952217cf11b737",
"lib/puppet/parser/functions/pick.rb": "bf01f13bbfe2318e7f6a302ac7c4433f",
"lib/puppet/parser/functions/pick_default.rb": "ad3ea60262de408767786d37a54d45dc",
"lib/puppet/parser/functions/prefix.rb": "ece9341c5b232a25c58545718a54e92f",
"lib/puppet/parser/functions/private.rb": "1500a21d5cf19961c5b1d476df892d92",
"lib/puppet/parser/functions/pry.rb": "79a48e45196e4bbf0a3e658781513cf4",
"lib/puppet/parser/functions/pw_hash.rb": "3d540eb4c483cc9c111794ac2d24a4a7",
"lib/puppet/parser/functions/range.rb": "ab19430b6b9737cf56263eb65d80cba1",
"lib/puppet/parser/functions/regexpescape.rb": "6378fdd413237a37c322859877147a50",
"lib/puppet/parser/functions/reject.rb": "689f6a7c961a55fe9dcd240921f4c7f9",
"lib/puppet/parser/functions/reverse.rb": "209e7ef512963251571c515e2d0aee10",
"lib/puppet/parser/functions/rstrip.rb": "f3226709247741825f07d9ec20bd3887",
"lib/puppet/parser/functions/seeded_rand.rb": "2ad22e7613d894ae779c0c5b0e65dade",
"lib/puppet/parser/functions/shell_escape.rb": "13662933244e1af42ddca71ced4ac9e5",
"lib/puppet/parser/functions/shell_join.rb": "b99a23d5e62e2e1b98accde5c22e45c9",
"lib/puppet/parser/functions/shell_split.rb": "5317d71f3a7e293624b57aaca23f57d5",
"lib/puppet/parser/functions/shuffle.rb": "6c0555524ebc9ed5dd8295b836fb7163",
"lib/puppet/parser/functions/size.rb": "c171d46b87e377ebcc710ad5a5925a2b",
"lib/puppet/parser/functions/sort.rb": "0b7d1411decc4a92450828809fad0779",
"lib/puppet/parser/functions/squeeze.rb": "403ea46228a8e45e89c91168ed301fb6",
"lib/puppet/parser/functions/str2bool.rb": "ff82f179970a9429614bd37fa7a1ae2a",
"lib/puppet/parser/functions/str2saltedsha512.rb": "457ab12e4329494ae6276cfa4f20eb23",
"lib/puppet/parser/functions/strftime.rb": "8f15e2e3732b6d1d357a1fa1826800d4",
"lib/puppet/parser/functions/strip.rb": "da0ce253cb63a4863f15f9d145217db5",
"lib/puppet/parser/functions/suffix.rb": "1ce493098f17ea47e9435f994adbc6cd",
"lib/puppet/parser/functions/swapcase.rb": "48cad9bf415b5d79584c8e17ab7a06cc",
"lib/puppet/parser/functions/time.rb": "cd96d1f039f8875af083091e3637190b",
"lib/puppet/parser/functions/to_bytes.rb": "45248fd0bba8cfb24eac830fc0add17a",
"lib/puppet/parser/functions/try_get_value.rb": "09cd079ec5f0e5e2ac862c9ebe0f54fe",
"lib/puppet/parser/functions/type.rb": "4709f7ab8a8aad62d77a3c5d91a3aa08",
"lib/puppet/parser/functions/type3x.rb": "5d0391205bd1cfe8de985a44e8c3e8a9",
"lib/puppet/parser/functions/union.rb": "c02fca3fe102875ba020072b7edee532",
"lib/puppet/parser/functions/unique.rb": "0f79a96896149f7034cd85e31eed1e54",
"lib/puppet/parser/functions/unix2dos.rb": "b1f5087fcaca69d9395094204cce887a",
"lib/puppet/parser/functions/upcase.rb": "e875fc4f03adec1ff3b42d22f177441e",
"lib/puppet/parser/functions/uriescape.rb": "ba78def2cd0e60bdc4412df6c7b891ec",
"lib/puppet/parser/functions/validate_absolute_path.rb": "c4b12e101055380386a235cd2c92ad10",
"lib/puppet/parser/functions/validate_array.rb": "bee8327014714d4cd8dbb5c46611f594",
"lib/puppet/parser/functions/validate_augeas.rb": "61e828e7759ba3e1e563e1fdd68aa80f",
"lib/puppet/parser/functions/validate_bool.rb": "971700229c4b581f67f6fadc9019eb2c",
"lib/puppet/parser/functions/validate_cmd.rb": "7df12370db442eddddcf4dd7a5364b5e",
"lib/puppet/parser/functions/validate_email_address.rb": "a72656cbfeda622cdd5cfdafdf464095",
"lib/puppet/parser/functions/validate_hash.rb": "c2ae6299148ea200f8dfcf9204875182",
"lib/puppet/parser/functions/validate_integer.rb": "65aa35f7450794aaadb6ad2c2e114df7",
"lib/puppet/parser/functions/validate_ip_address.rb": "b23c3d5ce6839e32d0186411147a6a44",
"lib/puppet/parser/functions/validate_ipv4_address.rb": "593e8f832469cb6a48c5f16ee66c3b2d",
"lib/puppet/parser/functions/validate_ipv6_address.rb": "48d3733012818993eae662839183d139",
"lib/puppet/parser/functions/validate_numeric.rb": "0e36d370262b8bdef2f88f0a3cb5b30e",
"lib/puppet/parser/functions/validate_re.rb": "d5963c404e3ac1670553f306221c2655",
"lib/puppet/parser/functions/validate_slength.rb": "6cbcfe15378ca4a780bac786223aacac",
"lib/puppet/parser/functions/validate_string.rb": "8afa7b0dcfe17bfbbb5704ad54664cc2",
"lib/puppet/parser/functions/validate_x509_rsa_key_pair.rb": "f17427dfc42128dc1df0ab04f37942e5",
"lib/puppet/parser/functions/values.rb": "c35978761496406cc3dafdccaa014236",
"lib/puppet/parser/functions/values_at.rb": "f7e6ad2a1126acd4fb5f7fcf9bfc2e2b",
"lib/puppet/parser/functions/zip.rb": "133f3d4c54640844e656e2e6e790318e",
"lib/puppet/provider/file_line/ruby.rb": "97dee0cadfaf112550e8424e143acc55",
"lib/puppet/type/anchor.rb": "bbd36bb49c3b554f8602d8d3df366c0c",
"lib/puppet/type/file_line.rb": "d65885f7f0afe49ee199d6bf873a5daf",
"locales/config.yaml": "574ee65e2a2a9d2f67edbc58735f50d4",
"locales/ja/puppetlabs-stdlib.po": "805e5d893d2025ad57da8ec0614a6753",
"locales/puppetlabs-stdlib.pot": "23c892ac0683aef4b09aabe0037750ae",
"manifests/init.pp": "9560a09f657d7eebbfdb920cefcc1d4f",
"manifests/stages.pp": "72eb4fa624474faf23b39e57cf1590bd",
"metadata.json": "9b16fea098773d2333c65079ca466a06",
"readmes/README_ja_JP.md": "173d377936c83b2cd622bb471d154a02",
"spec/acceptance/abs_spec.rb": "5b60756b2b4da28314025f51989592d7",
"spec/acceptance/anchor_spec.rb": "0fdbe266d8b7c3dc172e338b978109ba",
"spec/acceptance/any2array_spec.rb": "444cfd34154539d896e5ef1488386372",
"spec/acceptance/base64_spec.rb": "6a1dd4144ba354f9bed14eb70f7d2cba",
"spec/acceptance/bool2num_spec.rb": "edc9cb8b89b95410326475d27ce74bd5",
"spec/acceptance/build_csv.rb": "f28ef587de764ade1513091c4906412c",
"spec/acceptance/capitalize_spec.rb": "4bb6471ec3a8a07260da8e249fae6ccd",
"spec/acceptance/ceiling_spec.rb": "46489eef94aa21bb1560383bb17d7d02",
"spec/acceptance/chomp_spec.rb": "8372fe8a875b1a599a89df1191f43bc0",
"spec/acceptance/chop_spec.rb": "d73d1c7c6a44df65677362bd2899bbc1",
"spec/acceptance/clamp_spec.rb": "8afaae07bf89e0af35474da489fd590f",
"spec/acceptance/concat_spec.rb": "bad5f40e0a501b436ec4264cd278290b",
"spec/acceptance/count_spec.rb": "f8abd435b077edd06ad76a96a2e610c0",
"spec/acceptance/deep_merge_spec.rb": "5f16342cb8c1b52d6a08717a2ef87117",
"spec/acceptance/defined_with_params_spec.rb": "8b47a7255b9d662009217f3cfd17ca03",
"spec/acceptance/delete_at_spec.rb": "b0c853ffe5fc121e051233d62f6e72b3",
"spec/acceptance/delete_spec.rb": "6ccb838a13037a56d1413aecb4fdac00",
"spec/acceptance/delete_undef_values_spec.rb": "7d849a978d3ecdaaf5e922acc6038ad8",
"spec/acceptance/delete_values_spec.rb": "b9f3dbffbb89fec32c6a5b2bd3b20901",
"spec/acceptance/deprecation_spec.rb": "cadc56a94cbc2f13965d698f581f582d",
"spec/acceptance/difference_spec.rb": "2f4e8ddd760f2d4dc9a4fb7b653e982f",
"spec/acceptance/dirname_spec.rb": "76e6b66474f070d8a89f3fe5bd187e85",
"spec/acceptance/downcase_spec.rb": "53f0f5b1867e0fd87ba59833c18b5ca2",
"spec/acceptance/empty_spec.rb": "be8a610f87790a321dbd4cc0542e2885",
"spec/acceptance/ensure_resource_spec.rb": "c0193d79f1db1985d313bedb93a4c7ae",
"spec/acceptance/flatten_spec.rb": "3ab1f9c9e761e5d758eeee7a2e32f295",
"spec/acceptance/floor_spec.rb": "4a20f6fc7142ef9357c8d18a408b5e52",
"spec/acceptance/fqdn_rand_string_spec.rb": "7744b45e282013c5fe637dbaf42f85b9",
"spec/acceptance/fqdn_rotate_spec.rb": "366816bb1d3102f64025d61e22eec79c",
"spec/acceptance/get_module_path_spec.rb": "d5d2258b2345359d1e51a638b97523cb",
"spec/acceptance/getparam_spec.rb": "d4037f1f546cf7a3e7dcabe787e637b5",
"spec/acceptance/getvar_spec.rb": "8451bced69bfd5599a552ddf49976d98",
"spec/acceptance/grep_spec.rb": "5e6650532658915d1004a6e6c0f1229d",
"spec/acceptance/has_interface_with_spec.rb": "e028fc7fc1023293ba32c48c9f46752a",
"spec/acceptance/has_ip_address_spec.rb": "f3443be46277f6084ca8e531562d8ac7",
"spec/acceptance/has_ip_network_spec.rb": "fa7a38450bef7e4408deb6b978d5a42f",
"spec/acceptance/has_key_spec.rb": "68e42fb69d15f27916e7943ab727afc6",
"spec/acceptance/hash_spec.rb": "1e8ff803d76d8f9e506c8a366a93ad90",
"spec/acceptance/intersection_spec.rb": "755c135f67811666b3c5152c5c5349c2",
"spec/acceptance/is_a_spec.rb": "4cdd8df78a6285de21d634c032e5a7c9",
"spec/acceptance/is_array_spec.rb": "1de1fb0b55759d4012033ae3ce0723c2",
"spec/acceptance/is_bool_spec.rb": "9984cd966d81c217f8ff4e252a4a66d1",
"spec/acceptance/is_domain_name_spec.rb": "948dc0c7372027e8f2bb9db85b8d66b2",
"spec/acceptance/is_float_spec.rb": "731d9b71e7b4ee5055339d08b2b5f707",
"spec/acceptance/is_function_available_spec.rb": "413964bfe8e18c34d8809590afcc4118",
"spec/acceptance/is_hash_spec.rb": "9095a364cba82a95a1edd0f92d2218c7",
"spec/acceptance/is_integer_spec.rb": "bc4e7192073531638be9f8a4d391a827",
"spec/acceptance/is_ip_address_spec.rb": "c2ee8738d62b4c9d42b3ef1a1b8573fc",
"spec/acceptance/is_ipv4_address_spec.rb": "09f6f3ad6a1c0a9e5dcfaab34a081ffc",
"spec/acceptance/is_ipv6_address_spec.rb": "d19a98176b2b7367e740d338df08c2ae",
"spec/acceptance/is_mac_address_spec.rb": "b53f033cc4943a19f597895df0b5210a",
"spec/acceptance/is_numeric_spec.rb": "95ecae5adde23e6b61cd090704c4572d",
"spec/acceptance/is_string_spec.rb": "d9ad89b30aff62aea4fb805c991c6abf",
"spec/acceptance/join_keys_to_values_spec.rb": "908f62013e1d797ddc0ba68c0fb7913b",
"spec/acceptance/join_spec.rb": "5609c646859140109af4ae1c63cc69d2",
"spec/acceptance/keys_spec.rb": "15edb2f0a5630dfadd9bd6c038e5cf95",
"spec/acceptance/loadjson_spec.rb": "7bf8eb220ed02b77e9956dade1acfcb3",
"spec/acceptance/loadyaml_spec.rb": "3810faad7411bc1d9c9274671bb68a9a",
"spec/acceptance/lstrip_spec.rb": "27a6e2c9e2afc5b3e0e98301798a80ad",
"spec/acceptance/max_spec.rb": "c39a2006dacdbd24a8acc5dc25f1a9f3",
"spec/acceptance/member_spec.rb": "10b9635c1daf636d66aabea6ff796e6a",
"spec/acceptance/merge_spec.rb": "a1502ebd4d069c5f818f7fd8da79e02d",
"spec/acceptance/min_spec.rb": "a6e73a33255bc202de93fd8fe679c510",
"spec/acceptance/nodesets/centos-7-x64.yml": "a713f3abd3657f0ae2878829badd23cd",
"spec/acceptance/nodesets/debian-8-x64.yml": "d2d2977900989f30086ad251a14a1f39",
"spec/acceptance/nodesets/default.yml": "b42da5a1ea0c964567ba7495574b8808",
"spec/acceptance/nodesets/docker/centos-7.yml": "8a3892807bdd62306ae4774f41ba11ae",
"spec/acceptance/nodesets/docker/debian-8.yml": "ac8e871d1068c96de5e85a89daaec6df",
"spec/acceptance/nodesets/docker/ubuntu-14.04.yml": "dc42ee922a96908d85b8f0f08203ce58",
"spec/acceptance/num2bool_spec.rb": "33ab633c5a6aa1e5e9c0cac9ec23c0d5",
"spec/acceptance/parsejson_spec.rb": "56353143de570034f59a87244bb9ff7b",
"spec/acceptance/parseyaml_spec.rb": "a564b2217350398d8a3f1b212d0c2ada",
"spec/acceptance/pick_default_spec.rb": "bc3512e0cc3bc34da5f44ae18573af5d",
"spec/acceptance/pick_spec.rb": "661747652e50bb522ad0c627fb8c3c58",
"spec/acceptance/prefix_spec.rb": "2b9df68e18e16144caa4440fd6acaa01",
"spec/acceptance/pw_hash_spec.rb": "979f0d209f1ef227a31d27a452fc2ed3",
"spec/acceptance/range_spec.rb": "f913a26f4bbe8b9432b6cb80a3b6d1ed",
"spec/acceptance/reject_spec.rb": "c63eb909288cf2210f72d3afa1e07b32",
"spec/acceptance/reverse_spec.rb": "eca705328f8e246a648e3f62434e662a",
"spec/acceptance/rstrip_spec.rb": "bad1e42f66d07b5d09ca1133b392bf6a",
"spec/acceptance/shuffle_spec.rb": "adc420bc01d83dde117b04baa4a5e2d8",
"spec/acceptance/size_spec.rb": "d923ec158f5c2275b9823dd118edd953",
"spec/acceptance/sort_spec.rb": "3ac4acd4233fbe624d926604d58acea6",
"spec/acceptance/squeeze_spec.rb": "2270c35766a5162cd732f0f761f0dc34",
"spec/acceptance/str2bool_spec.rb": "73ca9cbf9079ef52de10f90cb871e80c",
"spec/acceptance/str2saltedsha512_spec.rb": "1e89299c3802ba386589a5133a07dccc",
"spec/acceptance/strftime_spec.rb": "6cdfc95c02af2419eb14d173a23df678",
"spec/acceptance/strip_spec.rb": "711b6b73fce659ab83956c4454500e55",
"spec/acceptance/suffix_spec.rb": "c2ca0539e9e7b71f36ff470d3c18b303",
"spec/acceptance/swapcase_spec.rb": "30290d4378f19fa8bac4bc3347a36298",
"spec/acceptance/time_spec.rb": "74b6d4f21d46ca612a98efed9c48944c",
"spec/acceptance/to_bytes_spec.rb": "ff7d57f85cf1e211b0998235636edfd9",
"spec/acceptance/try_get_value_spec.rb": "8b62b969ece6f02c65f0cf3d365324b1",
"spec/acceptance/type_spec.rb": "909aa4d0c2463b04a3d3ff72cb0d4b42",
"spec/acceptance/union_spec.rb": "41b8705ac890ddd915a5f6c8b33620cd",
"spec/acceptance/unique_spec.rb": "0108f76cc12ecb0551a37a002a9bda85",
"spec/acceptance/upcase_spec.rb": "30721f352edd513a0cc36c94aa0fe760",
"spec/acceptance/uriescape_spec.rb": "69857543c97c35b23094cc6da0828055",
"spec/acceptance/validate_absolute_path_spec.rb": "b7f57e45a4d4d2a187bf9db99c481f98",
"spec/acceptance/validate_array_spec.rb": "ec0db1f08eb8d64fec1025b65b544365",
"spec/acceptance/validate_augeas_spec.rb": "744354dd9726be3624db10935ae2b13f",
"spec/acceptance/validate_bool_spec.rb": "950632bafc509e1965cd6a57646d87f6",
"spec/acceptance/validate_cmd_spec.rb": "1605939801210b1a53dc8873492551e0",
"spec/acceptance/validate_hash_spec.rb": "b79b1ef06301e1b97863281e3c419b0e",
"spec/acceptance/validate_ipv4_address_spec.rb": "547520f1ad1d55c52a257f4fb85ecc33",
"spec/acceptance/validate_ipv6_address_spec.rb": "feedad9317be19409e351011c7b852b9",
"spec/acceptance/validate_re_spec.rb": "bcc18798eccca866883b965baefc3cc9",
"spec/acceptance/validate_slength_spec.rb": "29311e9e910bba57a86be9a4893b43e5",
"spec/acceptance/validate_string_spec.rb": "cd36b419ebb8630618ec795781081101",
"spec/acceptance/values_at_spec.rb": "17e39ac5e094fb05522cb363e12186ab",
"spec/acceptance/values_spec.rb": "25d5abaffd9a108a52cdb156b5120e85",
"spec/acceptance/zip_spec.rb": "30ac38a83f8e92d642a20b53c5b66292",
"spec/aliases/absolute_path_spec.rb": "4326af270230f6d1aef6b1c68a31c53b",
"spec/aliases/absolutepath_spec.rb": "ab9a78b2aa5f6eb102ee648c5f88da61",
"spec/aliases/array_spec.rb": "09c3559333ec646387e4141ed37d671e",
"spec/aliases/bool_spec.rb": "c3f734df3cd334860bba95386b8e8ba6",
"spec/aliases/float_spec.rb": "dda76444d67dcf4e9ab4bf8d1a668b23",
"spec/aliases/hash_spec.rb": "8b0753fbb41a41655235f999a8cd8a17",
"spec/aliases/httpsurl_spec.rb": "49fa0c1da3f055228aaa7ab12471f126",
"spec/aliases/httpurl_spec.rb": "fe92b61091197895e9e0070adcaec1e9",
"spec/aliases/integer_spec.rb": "3d5c27c864e2385251f1c16a46ef717d",
"spec/aliases/ip_address.rb": "297c6577c0763f5121f9ca9c19718dfe",
"spec/aliases/ipv4_spec.rb": "8f3be58256671754f32287609c7a64ba",
"spec/aliases/ipv6_spec.rb": "68bc3bdf8f2dbb049f8f8daf93d78e82",
"spec/aliases/numeric_spec.rb": "a0031bb0085673ec7cc28d9c9b5a72e4",
"spec/aliases/string_spec.rb": "8953daa594d54b8efc91fecf73629608",
"spec/aliases/unixpath_spec.rb": "1fac6f23e14c3589d26284a081c25c77",
"spec/aliases/windowspath_spec.rb": "4a3aec398b2c6ae86cb6d68ac5e8ab06",
"spec/fixtures/dscacheutil/root": "e1a7622f55f3d1be258c9a5b16b474be",
"spec/fixtures/lsuser/root": "2ed657fa157372a81634539bb1a56be8",
"spec/fixtures/test/manifests/absolute_path.pp": "79e9da69f05adc0e1ed41c20bf14e95f",
"spec/fixtures/test/manifests/absolutepath.pp": "8561fa141028cd38d0b8409cd69a1372",
"spec/fixtures/test/manifests/array.pp": "0e1d4146a9b2dd56063b2cab6f3d7571",
"spec/fixtures/test/manifests/bool.pp": "cf75826f36025bd73ff7f479acf7196d",
"spec/fixtures/test/manifests/deftype.pp": "b9dbd15e3f4a2dd53aac7f26322abf0c",
"spec/fixtures/test/manifests/ensure_resources.pp": "3265ae7af9382cfe7d9a13527265dcc9",
"spec/fixtures/test/manifests/float.pp": "132f9a63e60bba2fba68be83208c2e28",
"spec/fixtures/test/manifests/hash.pp": "84d647482ef0c7dc35348c13fb0ca23e",
"spec/fixtures/test/manifests/httpsurl.pp": "9047fc382d215ae55c065b0798a82a2d",
"spec/fixtures/test/manifests/httpurl.pp": "7165bf5607a4808f3da3f9baca911240",
"spec/fixtures/test/manifests/integer.pp": "3cb3807714ddcde25cd8eeca61581e3b",
"spec/fixtures/test/manifests/ip_address.pp": "78deea27fe1ff9e85c360eced4d2c256",
"spec/fixtures/test/manifests/ipv4.pp": "b4f0dfe6ae06d4f8b284d24e55f6a6a2",
"spec/fixtures/test/manifests/ipv6.pp": "4764f683b6013556e20d8669b21b5bdc",
"spec/fixtures/test/manifests/numeric.pp": "bffd26d7c0bb53628369f42c14b342cb",
"spec/fixtures/test/manifests/string.pp": "27b69c1eb36250bfbd474a0ef9ba847b",
"spec/fixtures/test/manifests/unixpath.pp": "fd062024efdf731e19026901d3fcc075",
"spec/fixtures/test/manifests/windowspath.pp": "7f942ec8f883a3ac0fcaf960ea24b7d8",
"spec/functions/abs_spec.rb": "7c0ebbd787b788d32b9bb21fe9061a2f",
"spec/functions/any2array_spec.rb": "22b7ce032a34d02b6858360025eb7644",
"spec/functions/any2bool_spec.rb": "d090dde9be26601a38980e8f77fa5970",
"spec/functions/assert_private_spec.rb": "a7e79ac7a1b28610a0e57e38e913c9fa",
"spec/functions/base64_spec.rb": "fa279d9a4f3060ee3f467e35b050d528",
"spec/functions/basename_spec.rb": "4aec9efc4fc6ed35de82d93b34dc0fab",
"spec/functions/bool2num_spec.rb": "6609136ff067b90d41cf27bf8838c3ea",
"spec/functions/bool2str_spec.rb": "52560617234393f960aedb496b49a628",
"spec/functions/camelcase_spec.rb": "4a13d3323535291fef3f40a96710acdb",
"spec/functions/capitalize_spec.rb": "31a8d497b274653d5ede70a0187d4053",
"spec/functions/ceiling_spec.rb": "47bd74569f8979d9195df06a863de93b",
"spec/functions/chomp_spec.rb": "8be3a83a34945dcaa6e8e193cf2751e4",
"spec/functions/chop_spec.rb": "8e1f661e93dd87b8bbeebe293fe16612",
"spec/functions/clamp_spec.rb": "65dab1e9aceb2cb4e41ef9c0c65a7ba3",
"spec/functions/concat_spec.rb": "4161a254ff4c21497e61a62ce84dafe8",
"spec/functions/convert_base_spec.rb": "f031e84b18cb010bc6233be3e4bcff83",
"spec/functions/count_spec.rb": "14ab4e4b10fe33d69d0662357cd4bf8b",
"spec/functions/deep_merge_spec.rb": "5a4e826aaa0a0c0e4247b72e03bdfbd1",
"spec/functions/defined_with_params_spec.rb": "c592e82de04ab45222b36478ee7040e6",
"spec/functions/delete_at_spec.rb": "188a3143799bd5cf121982883c7dc1c8",
"spec/functions/delete_regex_spec.rb": "c049a3926aded4b6a804f1c824c57d2f",
"spec/functions/delete_spec.rb": "d7c589404fdc3a6b65da7ecf1f7e0b02",
"spec/functions/delete_undef_values_spec.rb": "a2c138145333e1873ee4bf23d091f86a",
"spec/functions/delete_values_spec.rb": "e20b68a589002f1e2b52873d3dbcfb49",
"spec/functions/deprecation_spec.rb": "f5d7355b687eaaa15c20fdb214671c2a",
"spec/functions/difference_spec.rb": "66ba399c0bace1a131ecdb365e0afd4e",
"spec/functions/dig44_spec.rb": "89631bb7282f7d3c9b75d79f48446c65",
"spec/functions/dig_spec.rb": "61708160da38852c3c78bc8563e0fcb2",
"spec/functions/dirname_spec.rb": "e80baeab6a166284f5069263fb5e37b7",
"spec/functions/dos2unix_spec.rb": "d0cfe5fe19d2bf33320e6f47789826c6",
"spec/functions/downcase_spec.rb": "e2c24d41c6fb840f7b66c5205c942780",
"spec/functions/empty_spec.rb": "e6d06c193869ce8c97d3e67d5c5c5b4f",
"spec/functions/ensure_packages_spec.rb": "cb741ab1e99e7ad9057eea258730cd19",
"spec/functions/ensure_resource_spec.rb": "e1ebbf9475781d86b58541a5846eda0b",
"spec/functions/flatten_spec.rb": "5d59251fa8da0e4c8a376a513a25bc7a",
"spec/functions/floor_spec.rb": "7d110b1f994432e1c6c7c004a3dedbe4",
"spec/functions/fqdn_rand_string_spec.rb": "950a33e5ad8056fbfe564ec7e3b9a583",
"spec/functions/fqdn_rotate_spec.rb": "83f00ce0c48dec632e1aaa8192bb51cf",
"spec/functions/fqdn_uuid_spec.rb": "1b2980fcbecc4b51bdc6de01e9b001b7",
"spec/functions/get_module_path_spec.rb": "ef22bd80ce5dedb069830d5aa10572c1",
"spec/functions/getparam_spec.rb": "359d7c9349ec0e5666bb38e2d9224621",
"spec/functions/getvar_spec.rb": "3c7884e012bdb596df3d0640533dab96",
"spec/functions/glob_spec.rb": "98e054f995a0d38002d9373b5e6acbc0",
"spec/functions/grep_spec.rb": "0e917284860c5f96fdf56301012ba199",
"spec/functions/has_interface_with_spec.rb": "473c000e461c3497f8461eb17cf73430",
"spec/functions/has_ip_address_spec.rb": "7b36b993ea32757e74be9909906bd165",
"spec/functions/has_ip_network_spec.rb": "7086a27623ba91c5ff069397a32172c4",
"spec/functions/has_key_spec.rb": "eaa046db8632d6f76893e4b9df7b3e31",
"spec/functions/hash_spec.rb": "53a059e13781fac6b4f8eb660655d58f",
"spec/functions/intersection_spec.rb": "e906cb8ceb39b644b4b338adcd4dda26",
"spec/functions/is_a_spec.rb": "7d6322426d629e5302c52455d9c4cd55",
"spec/functions/is_array_spec.rb": "26d7eab025f333d2c4a8baf89ef4e36e",
"spec/functions/is_bool_spec.rb": "40569a4cdb50af0cc21ad749ac18e6ef",
"spec/functions/is_domain_name_spec.rb": "4ea3825d5b77a5d75eab8228dcc738f9",
"spec/functions/is_email_address_spec.rb": "699c4573dfd00db8993a18afc0eaf875",
"spec/functions/is_float_spec.rb": "8aedd9e622cd1b861d99523532dc4fc1",
"spec/functions/is_function_available.rb": "f8ab234d536532c3629ff6a5068e7877",
"spec/functions/is_hash_spec.rb": "11563529f0f1f821769edb3131277100",
"spec/functions/is_integer_spec.rb": "21a139f9a87b1561bfec60de26c435a2",
"spec/functions/is_ip_address_spec.rb": "04a15328803bb47ae431eff63aa555df",
"spec/functions/is_ipv4_address_spec.rb": "339b8c79925bb70c0de19468d58ab64a",
"spec/functions/is_ipv6_address_spec.rb": "9743a0f2bfda70ace128d2f476a208b9",
"spec/functions/is_mac_address_spec.rb": "532b8c4c63b37849e7fb9122d163ae3a",
"spec/functions/is_numeric_spec.rb": "cb846f44e8f6d79161686d7b3729967c",
"spec/functions/is_string_spec.rb": "56f34694781dfcf774e43bca06057fec",
"spec/functions/join_keys_to_values_spec.rb": "f99dff6550fdb7c245ed4dcaca0a16a3",
"spec/functions/join_spec.rb": "e190fbce526b3f4f7bb8aac029338ece",
"spec/functions/keys_spec.rb": "fba0bfa928b5684d5c918d6c06edd06d",
"spec/functions/length.rb": "c07a267ccccc4b4edbbfad155dc21475",
"spec/functions/load_module_metadata_spec.rb": "431fbe84d627a5c4398f432caaec96f8",
"spec/functions/loadjson_spec.rb": "76cbe175c90a596892b799d8e4d599e5",
"spec/functions/loadyaml_spec.rb": "60e283bc07adc67bc2c934424bf01b8d",
"spec/functions/lstrip_spec.rb": "892229ce8657490c72fc860fb0dda1b6",
"spec/functions/max_spec.rb": "47de8d59070d8d51b2184731f5d1aa43",
"spec/functions/member_spec.rb": "6a988e6368c1ce090b47fe41efbc041c",
"spec/functions/merge_spec.rb": "56297527d192640bbe82c7ccf1e39815",
"spec/functions/min_spec.rb": "8b38e2a989912406cd2c57dcd3a460c4",
"spec/functions/num2bool_spec.rb": "7c4fd30e41a11b1bd0d9e5233340f16b",
"spec/functions/parsejson_spec.rb": "958db1dde2f2244f458c399e0c3231e0",
"spec/functions/parseyaml_spec.rb": "19a2add90ca08d5a17c4e3aff89fe3c0",
"spec/functions/pick_default_spec.rb": "ab9ef2e9111cfd2709313e0e3c3befa2",
"spec/functions/pick_spec.rb": "786044a71e3bd673212949c12f37b10f",
"spec/functions/prefix_spec.rb": "2402d2ad5108050bb5c20b3ea58b64be",
"spec/functions/private_spec.rb": "f404771c4590a0cd7ce61ddff8f3eb7b",
"spec/functions/pw_hash_spec.rb": "640609cc73b4c8bbcdfc88c3e9797664",
"spec/functions/range_spec.rb": "d3af56cc8a137059423f8738e343ccff",
"spec/functions/regexpescape_spec.rb": "ce027e1b99674f39de8ddffcfed8396e",
"spec/functions/reject_spec.rb": "8ecbca64a9817ebef76be96dcf6cdeeb",
"spec/functions/reverse_spec.rb": "e40754fd34e96ac206308958504ae315",
"spec/functions/rstrip_spec.rb": "748f4587c12b5a590b985f111e282a8d",
"spec/functions/seeded_rand_spec.rb": "eb56445d10962d81ed935b53826da349",
"spec/functions/shell_escape_spec.rb": "bf108573c041f0c228f6d47d367d0aa3",
"spec/functions/shell_join_spec.rb": "92f31bd98d6e8e30e5f758f50bcb8a75",
"spec/functions/shell_split_spec.rb": "430f58733cc7855e56bfc918971b3fc1",
"spec/functions/shuffle_spec.rb": "be5d43184f2ca42db4f452085a4730fd",
"spec/functions/size_spec.rb": "f5e35878331bb12d9639522e38cc81c8",
"spec/functions/sort_spec.rb": "d9533dd37c6263b92895f7eba8485248",
"spec/functions/squeeze_spec.rb": "ffcf3b44cbdd45e14eb1173d2b7d1d99",
"spec/functions/str2bool_spec.rb": "607b25fb0badd0da5acb86c63437c8be",
"spec/functions/str2saltedsha512_spec.rb": "07586b0026757cd39229c12c7221808b",
"spec/functions/strftime_spec.rb": "580fbff889a97adabd7d7de54740b4a2",
"spec/functions/strip_spec.rb": "023132b8bd0820da254f74c6fe31bb80",
"spec/functions/suffix_spec.rb": "dfe26a61bf0185291b6ae868e9d0de20",
"spec/functions/swapcase_spec.rb": "90bace1b004aa63d46eb6481c6dce2b1",
"spec/functions/time_spec.rb": "6dc8f5b42cf89345d2de424bfe19be90",
"spec/functions/to_bytes_spec.rb": "b771f8490d922de46a519e407d358139",
"spec/functions/try_get_value_spec.rb": "b917b899f5d29764dd4b1b07e07ec6ce",
"spec/functions/type3x_spec.rb": "eed4ce3a2bc92d14effedefef9690654",
"spec/functions/type_of_spec.rb": "83755d9390b9c00e086a007edff7fd9b",
"spec/functions/type_spec.rb": "7a61b4af7d3d83be590d783a7e5e80f8",
"spec/functions/union_spec.rb": "a290a38e443b856a476d14d4b1dc72fb",
"spec/functions/unique_spec.rb": "97fbcc73a0e0d82e23c723837627c712",
"spec/functions/unix2dos_spec.rb": "628c8a0c608d1fa0dd09bd1b5af97c1f",
"spec/functions/upcase_spec.rb": "4f0461a20c03d618f0c18da39bebcf65",
"spec/functions/uriescape_spec.rb": "1458afbe7e7e11dcaad8d295a7f2be59",
"spec/functions/validate_absolute_path_spec.rb": "5adbf0a0ac8b23e86195deaf3e4bd371",
"spec/functions/validate_array_spec.rb": "3aa76f3731754c637acc94b59c79efb0",
"spec/functions/validate_augeas_spec.rb": "d598e89a23912be9f24d39b809f30b47",
"spec/functions/validate_bool_spec.rb": "d1b43cd294d0588ac6d67d5d3c77a42a",
"spec/functions/validate_cmd_spec.rb": "34a4e623ab0ce7d4c218a837f896c1ea",
"spec/functions/validate_email_address_spec.rb": "1296f9934d102258091379ee07f9a2a8",
"spec/functions/validate_hash_spec.rb": "0b3ac3f7262f13ef14e3df937c8d104c",
"spec/functions/validate_integer_spec.rb": "ec55ab34e3ec4f09722349cd6aac77a6",
"spec/functions/validate_ip_address_spec.rb": "ba8c92e30f1af9e6839a2901e002c3f3",
"spec/functions/validate_ipv4_address_spec.rb": "d5d956651629f95ea531ac03b71e247b",
"spec/functions/validate_ipv6_address_spec.rb": "7ee0d6097666558d8627de424c26ef75",
"spec/functions/validate_legacy_spec.rb": "a1a3af70e71d0a6b848d75c518949b3b",
"spec/functions/validate_numeric_spec.rb": "c2f01b9c9aeae75683563ef7d3951bbb",
"spec/functions/validate_re_spec.rb": "27bcf99cd815b755548cd3979753b2f3",
"spec/functions/validate_slength_spec.rb": "c292023b2e61298499ff1f791fc03005",
"spec/functions/validate_string_spec.rb": "bc6735359ada0b3ccf69f515231e3808",
"spec/functions/validate_x509_rsa_key_pair_spec.rb": "24810bdb8ac473ae1168f1b2c5708170",
"spec/functions/values_at_spec.rb": "866ba43a4b606f6e9e72ac91c07408bd",
"spec/functions/values_spec.rb": "6b8f39665cb8fdb03658d838e50b55b0",
"spec/functions/zip_spec.rb": "986defd43a001ff28fe7c90b0366812e",
"spec/monkey_patches/alias_should_to_must.rb": "b19ee31563afb91a72f9869f9d7362ff",
"spec/monkey_patches/publicize_methods.rb": "c690e444b77c871375d321e413e28ca1",
"spec/spec_helper.rb": "b2db3bc02b4ac2fd5142a6621c641b07",
"spec/spec_helper_acceptance.rb": "cd589056b52031da19d9c31ed86ea922",
"spec/spec_helper_local.rb": "1e3ad3c06a11cbcb813dc1d31973cbda",
"spec/support/shared_data.rb": "9758f8ba2958965d287387a2513dac73",
"spec/unit/ensure_resources_spec.rb": "30cad259a3cc6c73f90209804183c818",
"spec/unit/facter/facter_dot_d_spec.rb": "420339a544851f2c7ee6fa4c651bdce8",
"spec/unit/facter/package_provider_spec.rb": "3a6ba799822fbcabc9adab5880260b7a",
"spec/unit/facter/pe_version_spec.rb": "d0fa6c0d5b01a4b9fd36ed4168635e9f",
"spec/unit/facter/root_home_spec.rb": "036c160d5543f4f3e80a300a3a170b77",
"spec/unit/facter/service_provider_spec.rb": "a97efb411817a44c511cd6cd79d9af8c",
"spec/unit/facter/util/puppet_settings_spec.rb": "6f9df9b10a1b39245ecdf002616a4122",
"spec/unit/puppet/parser/functions/enclose_ipv6_spec.rb": "0145a78254ea716e5e7600d9464318a8",
"spec/unit/puppet/parser/functions/is_absolute_path_spec.rb": "52f8d3b9011fb1fd8a2a429fe8b2ae08",
"spec/unit/puppet/provider/file_line/ruby_spec.rb": "d269e18953fc297786a8393b20842abc",
"spec/unit/puppet/type/anchor_spec.rb": "06a669dffa44d716bf19b4e7f5f1d75d",
"spec/unit/puppet/type/file_line_spec.rb": "83e11166de4abe69cdf0dc7450e79778",
"types/absolutepath.pp": "3ae6f48dd95835df87c5dacea13c88d2",
"types/compat/absolute_path.pp": "6d0e102d1098d85d97c8f13051cb2c10",
"types/compat/array.pp": "43c41022dd743d55c8e9e82ce3ed741c",
"types/compat/bool.pp": "6e0cd7b2a7e1b9efaa0e273937211e58",
"types/compat/float.pp": "fd134a0e0e1abd420cec2107780a7afa",
"types/compat/hash.pp": "3535d98f0f3eaec44d443190f258e9ba",
"types/compat/integer.pp": "e85a20e42b3afaf5ec0718a8d9f9c5e3",
"types/compat/ip_address.pp": "d42c7435de30a469a71b69c45d642da7",
"types/compat/ipv4.pp": "c84eb3764f45b256a09be68afe61b749",
"types/compat/ipv6.pp": "d3c0fada5425d576aeca14ddbee78653",
"types/compat/numeric.pp": "f864539d78e95dabf0bab361b4ccc042",
"types/compat/re.pp": "70b05d4697e61f9af0c212ba063f395d",
"types/compat/string.pp": "b9a179664c85e121aa0277021627d126",
"types/httpsurl.pp": "108225d0273e17d541b239882287ed15",
"types/httpurl.pp": "4ba64825b11af75997c59b5acf07c62d",
"types/unixpath.pp": "5fc80523e7f474dd84056c44fafd9544",
"types/windowspath.pp": "4c1eda331ecb43de98c29ed22d0ad448"
}

View File

@@ -0,0 +1,9 @@
# This is a simple smoke test
# of the file_line resource type.
file { '/tmp/dansfile':
ensure => file,
}
-> file_line { 'dans_line':
line => 'dan is awesome',
path => '/tmp/dansfile',
}

View File

@@ -0,0 +1,9 @@
include ::stdlib
info('has_interface_with(\'lo\'):', has_interface_with('lo'))
info('has_interface_with(\'loX\'):', has_interface_with('loX'))
info('has_interface_with(\'ipaddress\', \'127.0.0.1\'):', has_interface_with('ipaddress', '127.0.0.1'))
info('has_interface_with(\'ipaddress\', \'127.0.0.100\'):', has_interface_with('ipaddress', '127.0.0.100'))
info('has_interface_with(\'network\', \'127.0.0.0\'):', has_interface_with('network', '127.0.0.0'))
info('has_interface_with(\'network\', \'128.0.0.0\'):', has_interface_with('network', '128.0.0.0'))
info('has_interface_with(\'netmask\', \'255.0.0.0\'):', has_interface_with('netmask', '255.0.0.0'))
info('has_interface_with(\'netmask\', \'256.0.0.0\'):', has_interface_with('netmask', '256.0.0.0'))

View File

@@ -0,0 +1,3 @@
include ::stdlib
info('has_ip_address(\'192.168.1.256\'):', has_ip_address('192.168.1.256'))
info('has_ip_address(\'127.0.0.1\'):', has_ip_address('127.0.0.1'))

View File

@@ -0,0 +1,3 @@
include ::stdlib
info('has_ip_network(\'127.0.0.0\'):', has_ip_network('127.0.0.0'))
info('has_ip_network(\'128.0.0.0\'):', has_ip_network('128.0.0.0'))

View File

@@ -0,0 +1 @@
include ::stdlib

View File

@@ -0,0 +1,202 @@
# 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 $libdir/facts_dot_d.cache 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=File.join(Puppet[:libdir], "facts_dot_d.cache"))
@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 StandardError => 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 StandardError => 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 StandardError => 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 StandardError => 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

View File

@@ -0,0 +1,21 @@
# Fact: package_provider
#
# Purpose: Returns the default provider Puppet will choose to manage packages
# on this system
#
# Resolution: Instantiates a dummy package resource and return the provider
#
# Caveats:
#
require 'puppet/type'
require 'puppet/type/package'
Facter.add(:package_provider) do
setcode do
if defined? Gem and Gem::Version.new(Facter.value(:puppetversion).split(' ')[0]) >= Gem::Version.new('3.6')
Puppet::Type.type(:package).newpackage(:name => 'dummy', :allow_virtual => 'true')[:provider].to_s
else
Puppet::Type.type(:package).newpackage(:name => 'dummy')[:provider].to_s
end
end
end

View File

@@ -0,0 +1,58 @@
# 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
puppet_ver = Facter.value("puppetversion")
if puppet_ver != nil
pe_ver = puppet_ver.match(/Puppet Enterprise (\d+\.\d+\.\d+)/)
pe_ver[1] if pe_ver
else
nil
end
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

View File

@@ -0,0 +1,43 @@
# These facter facts return the value of the Puppet vardir and environment path
# settings 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, or for modules running on the puppet master to know
# where environments are stored.
#
# The values 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
# These will be nil if Puppet is not available.
Facter.add(:puppet_vardir) do
setcode do
Facter::Util::PuppetSettings.with_puppet do
Puppet[:vardir]
end
end
end
Facter.add(:puppet_environmentpath) do
setcode do
Facter::Util::PuppetSettings.with_puppet do
Puppet[:environmentpath]
end
end
end
Facter.add(:puppet_server) do
setcode do
Facter::Util::PuppetSettings.with_puppet do
Puppet[:server]
end
end
end

View File

@@ -0,0 +1,45 @@
# 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
Facter.add(:root_home) do
confine :kernel => :aix
root_home = nil
setcode do
str = Facter::Util::Resolution.exec("lsuser -c -a home root")
str && str.split("\n").each do |line|
next if line =~ /^#/
root_home = line.split(/:/)[1]
end
root_home
end
end

View File

@@ -0,0 +1,17 @@
# Fact: service_provider
#
# Purpose: Returns the default provider Puppet will choose to manage services
# on this system
#
# Resolution: Instantiates a dummy service resource and return the provider
#
# Caveats:
#
require 'puppet/type'
require 'puppet/type/service'
Facter.add(:service_provider) do
setcode do
Puppet::Type.type(:service).newservice(:name => 'dummy')[:provider].to_s
end
end

View File

@@ -0,0 +1,21 @@
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

View File

@@ -0,0 +1,29 @@
# Function to print deprecation warnings, Logs a warning once for a given key. The uniqueness key - can appear once. The msg is the message text including any positional information that is formatted by the user/caller of the method It is affected by the puppet setting 'strict', which can be set to :error (outputs as an error message), :off (no message / error is displayed) and :warning (default, outputs a warning) *Type*: String, String.
#
Puppet::Functions.create_function(:deprecation) do
dispatch :deprecation do
param 'String', :key
param 'String', :message
end
def deprecation(key, message)
if defined? Puppet::Pops::PuppetStack.stacktrace()
stacktrace = Puppet::Pops::PuppetStack.stacktrace()
file = stacktrace[0]
line = stacktrace[1]
message = "#{message} at #{file}:#{line}"
end
# depending on configuration setting of strict
case Puppet.settings[:strict]
when :off
# do nothing
when :error
fail("deprecation. #{key}. #{message}")
else
unless ENV['STDLIB_LOG_DEPRECATIONS'] == 'false'
Puppet.deprecation_warning(message, key)
end
end
end
end

View File

@@ -0,0 +1,32 @@
# Boolean check to determine whether a variable is of a given data type. This is equivalent to the `=~` type checks.
#
# @example how to check a data type
# # check a data type
# foo = 3
# $bar = [1,2,3]
# $baz = 'A string!'
#
# if $foo.is_a(Integer) {
# notify { 'foo!': }
# }
# if $bar.is_a(Array) {
# notify { 'bar!': }
# }
# if $baz.is_a(String) {
# notify { 'baz!': }
# }
#
# See the documentation for "The Puppet Type System" for more information about types.
# See the `assert_type()` function for flexible ways to assert the type of a value.
#
Puppet::Functions.create_function(:is_a) do
dispatch :is_a do
param 'Any', :value
param 'Type', :type
end
def is_a(value, type)
# See puppet's lib/puppet/pops/evaluator/evaluator_impl.rb eval_MatchExpression
Puppet::Pops::Types::TypeCalculator.instance?(type, value)
end
end

View File

@@ -0,0 +1,15 @@
Puppet::Functions.create_function(:is_absolute_path) do
dispatch :deprecation_gen do
param 'Any', :scope
repeated_param 'Any', :args
end
# Workaround PUP-4438 (fixed: https://github.com/puppetlabs/puppet/commit/e01c4dc924cd963ff6630008a5200fc6a2023b08#diff-c937cc584953271bb3d3b3c2cb141790R221) to support puppet < 4.1.0 and puppet < 3.8.1.
def call(scope, *args)
manipulated_args = [scope] + args
self.class.dispatcher.dispatch(self, scope, manipulated_args)
end
def deprecation_gen(scope, *args)
call_function('deprecation', 'is_absolute_path', "This method is deprecated, please use match expressions with Stdlib::Compat::Absolute_Path instead. They are described at https://docs.puppet.com/puppet/latest/reference/lang_data_type.html#match-expressions.")
scope.send("function_is_absolute_path", args)
end
end

View File

@@ -0,0 +1,15 @@
Puppet::Functions.create_function(:is_array) do
dispatch :deprecation_gen do
param 'Any', :scope
repeated_param 'Any', :args
end
# Workaround PUP-4438 (fixed: https://github.com/puppetlabs/puppet/commit/e01c4dc924cd963ff6630008a5200fc6a2023b08#diff-c937cc584953271bb3d3b3c2cb141790R221) to support puppet < 4.1.0 and puppet < 3.8.1.
def call(scope, *args)
manipulated_args = [scope] + args
self.class.dispatcher.dispatch(self, scope, manipulated_args)
end
def deprecation_gen(scope, *args)
call_function('deprecation', 'is_array', "This method is deprecated, please use match expressions with Stdlib::Compat::Array instead. They are described at https://docs.puppet.com/puppet/latest/reference/lang_data_type.html#match-expressions.")
scope.send("function_is_array", args)
end
end

View File

@@ -0,0 +1,15 @@
Puppet::Functions.create_function(:is_bool) do
dispatch :deprecation_gen do
param 'Any', :scope
repeated_param 'Any', :args
end
# Workaround PUP-4438 (fixed: https://github.com/puppetlabs/puppet/commit/e01c4dc924cd963ff6630008a5200fc6a2023b08#diff-c937cc584953271bb3d3b3c2cb141790R221) to support puppet < 4.1.0 and puppet < 3.8.1.
def call(scope, *args)
manipulated_args = [scope] + args
self.class.dispatcher.dispatch(self, scope, manipulated_args)
end
def deprecation_gen(scope, *args)
call_function('deprecation', 'is_bool', "This method is deprecated, please use match expressions with Stdlib::Compat::Bool instead. They are described at https://docs.puppet.com/puppet/latest/reference/lang_data_type.html#match-expressions.")
scope.send("function_is_bool", args)
end
end

View File

@@ -0,0 +1,15 @@
Puppet::Functions.create_function(:is_float) do
dispatch :deprecation_gen do
param 'Any', :scope
repeated_param 'Any', :args
end
# Workaround PUP-4438 (fixed: https://github.com/puppetlabs/puppet/commit/e01c4dc924cd963ff6630008a5200fc6a2023b08#diff-c937cc584953271bb3d3b3c2cb141790R221) to support puppet < 4.1.0 and puppet < 3.8.1.
def call(scope, *args)
manipulated_args = [scope] + args
self.class.dispatcher.dispatch(self, scope, manipulated_args)
end
def deprecation_gen(scope, *args)
call_function('deprecation', 'is_float', "This method is deprecated, please use match expressions with Stdlib::Compat::Float instead. They are described at https://docs.puppet.com/puppet/latest/reference/lang_data_type.html#match-expressions.")
scope.send("function_is_float", args)
end
end

View File

@@ -0,0 +1,15 @@
Puppet::Functions.create_function(:is_ip_address) do
dispatch :deprecation_gen do
param 'Any', :scope
repeated_param 'Any', :args
end
# Workaround PUP-4438 (fixed: https://github.com/puppetlabs/puppet/commit/e01c4dc924cd963ff6630008a5200fc6a2023b08#diff-c937cc584953271bb3d3b3c2cb141790R221) to support puppet < 4.1.0 and puppet < 3.8.1.
def call(scope, *args)
manipulated_args = [scope] + args
self.class.dispatcher.dispatch(self, scope, manipulated_args)
end
def deprecation_gen(scope, *args)
call_function('deprecation', 'is_ip_address', "This method is deprecated, please use match expressions with Stdlib::Compat::Ip_address instead. They are described at https://docs.puppet.com/puppet/latest/reference/lang_data_type.html#match-expressions.")
scope.send("function_is_ip_address", args)
end
end

View File

@@ -0,0 +1,15 @@
Puppet::Functions.create_function(:is_ipv4_address) do
dispatch :deprecation_gen do
param 'Any', :scope
repeated_param 'Any', :args
end
# Workaround PUP-4438 (fixed: https://github.com/puppetlabs/puppet/commit/e01c4dc924cd963ff6630008a5200fc6a2023b08#diff-c937cc584953271bb3d3b3c2cb141790R221) to support puppet < 4.1.0 and puppet < 3.8.1.
def call(scope, *args)
manipulated_args = [scope] + args
self.class.dispatcher.dispatch(self, scope, manipulated_args)
end
def deprecation_gen(scope, *args)
call_function('deprecation', 'is_ipv4_address', "This method is deprecated, please use match expressions with Stdlib::Compat::Ipv4 instead. They are described at https://docs.puppet.com/puppet/latest/reference/lang_data_type.html#match-expressions.")
scope.send("function_is_ipv4_address", args)
end
end

View File

@@ -0,0 +1,15 @@
Puppet::Functions.create_function(:is_ipv6_address) do
dispatch :deprecation_gen do
param 'Any', :scope
repeated_param 'Any', :args
end
# Workaround PUP-4438 (fixed: https://github.com/puppetlabs/puppet/commit/e01c4dc924cd963ff6630008a5200fc6a2023b08#diff-c937cc584953271bb3d3b3c2cb141790R221) to support puppet < 4.1.0 and puppet < 3.8.1.
def call(scope, *args)
manipulated_args = [scope] + args
self.class.dispatcher.dispatch(self, scope, manipulated_args)
end
def deprecation_gen(scope, *args)
call_function('deprecation', 'is_ipv4_address', "This method is deprecated, please use match expressions with Stdlib::Compat::Ipv6 instead. They are described at https://docs.puppet.com/puppet/latest/reference/lang_data_type.html#match-expressions.")
scope.send("function_is_ipv6_address", args)
end
end

View File

@@ -0,0 +1,15 @@
Puppet::Functions.create_function(:is_numeric) do
dispatch :deprecation_gen do
param 'Any', :scope
repeated_param 'Any', :args
end
# Workaround PUP-4438 (fixed: https://github.com/puppetlabs/puppet/commit/e01c4dc924cd963ff6630008a5200fc6a2023b08#diff-c937cc584953271bb3d3b3c2cb141790R221) to support puppet < 4.1.0 and puppet < 3.8.1.
def call(scope, *args)
manipulated_args = [scope] + args
self.class.dispatcher.dispatch(self, scope, manipulated_args)
end
def deprecation_gen(scope, *args)
call_function('deprecation', 'is_numeric', "This method is deprecated, please use match expressions with Stdlib::Compat::Numeric instead. They are described at https://docs.puppet.com/puppet/latest/reference/lang_data_type.html#match-expressions.")
scope.send("function_is_numeric", args)
end
end

View File

@@ -0,0 +1,15 @@
Puppet::Functions.create_function(:is_string) do
dispatch :deprecation_gen do
param 'Any', :scope
repeated_param 'Any', :args
end
# Workaround PUP-4438 (fixed: https://github.com/puppetlabs/puppet/commit/e01c4dc924cd963ff6630008a5200fc6a2023b08#diff-c937cc584953271bb3d3b3c2cb141790R221) to support puppet < 4.1.0 and puppet < 3.8.1.
def call(scope, *args)
manipulated_args = [scope] + args
self.class.dispatcher.dispatch(self, scope, manipulated_args)
end
def deprecation_gen(scope, *args)
call_function('deprecation', 'is_string', "This method is deprecated, please use match expressions with Stdlib::Compat::String instead. They are described at https://docs.puppet.com/puppet/latest/reference/lang_data_type.html#match-expressions.")
scope.send("function_is_string", args)
end
end

View File

@@ -0,0 +1,14 @@
#A function to eventually replace the old size() function for stdlib - The original size function did not handle Puppets new type capabilities, so this function is a Puppet 4 compatible solution.
Puppet::Functions.create_function(:length) do
dispatch :length do
param 'Variant[String,Array,Hash]', :value
end
def length(value)
if value.is_a?(String)
result = value.length
elsif value.is_a?(Array) || value.is_a?(Hash)
result = value.size
end
return result
end
end

View File

@@ -0,0 +1,19 @@
# Returns the type when passed a value.
#
# @example how to compare values' types
# # compare the types of two values
# if type_of($first_value) != type_of($second_value) { fail("first_value and second_value are different types") }
# @example how to compare against an abstract type
# unless type_of($first_value) <= Numeric { fail("first_value must be Numeric") }
# unless type_of{$first_value) <= Collection[1] { fail("first_value must be an Array or Hash, and contain at least one element") }
#
# See the documentation for "The Puppet Type System" for more information about types.
# See the `assert_type()` function for flexible ways to assert the type of a value.
#
# The built-in type() function in puppet is generally preferred over this function
# this function is provided for backwards compatibility.
Puppet::Functions.create_function(:type_of) do
def type_of(value)
Puppet::Pops::Types::TypeCalculator.infer_set(value)
end
end

View File

@@ -0,0 +1,15 @@
Puppet::Functions.create_function(:validate_absolute_path) do
dispatch :deprecation_gen do
param 'Any', :scope
repeated_param 'Any', :args
end
# Workaround PUP-4438 (fixed: https://github.com/puppetlabs/puppet/commit/e01c4dc924cd963ff6630008a5200fc6a2023b08#diff-c937cc584953271bb3d3b3c2cb141790R221) to support puppet < 4.1.0 and puppet < 3.8.1.
def call(scope, *args)
manipulated_args = [scope] + args
self.class.dispatcher.dispatch(self, scope, manipulated_args)
end
def deprecation_gen(scope, *args)
call_function('deprecation', 'validate_absolute_path', "This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::Absolute_Path. There is further documentation for validate_legacy function in the README.")
scope.send("function_validate_absolute_path", args)
end
end

View File

@@ -0,0 +1,15 @@
Puppet::Functions.create_function(:validate_array) do
dispatch :deprecation_gen do
param 'Any', :scope
repeated_param 'Any', :args
end
# Workaround PUP-4438 (fixed: https://github.com/puppetlabs/puppet/commit/e01c4dc924cd963ff6630008a5200fc6a2023b08#diff-c937cc584953271bb3d3b3c2cb141790R221) to support puppet < 4.1.0 and puppet < 3.8.1.
def call(scope, *args)
manipulated_args = [scope] + args
self.class.dispatcher.dispatch(self, scope, manipulated_args)
end
def deprecation_gen(scope, *args)
call_function('deprecation', 'validate_array', "This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::Array. There is further documentation for validate_legacy function in the README.")
scope.send("function_validate_array", args)
end
end

View File

@@ -0,0 +1,15 @@
Puppet::Functions.create_function(:validate_bool) do
dispatch :deprecation_gen do
param 'Any', :scope
repeated_param 'Any', :args
end
# Workaround PUP-4438 (fixed: https://github.com/puppetlabs/puppet/commit/e01c4dc924cd963ff6630008a5200fc6a2023b08#diff-c937cc584953271bb3d3b3c2cb141790R221) to support puppet < 4.1.0 and puppet < 3.8.1.
def call(scope, *args)
manipulated_args = [scope] + args
self.class.dispatcher.dispatch(self, scope, manipulated_args)
end
def deprecation_gen(scope, *args)
call_function('deprecation', 'validate_bool', "This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::Bool. There is further documentation for validate_legacy function in the README.")
scope.send("function_validate_bool", args)
end
end

View File

@@ -0,0 +1,15 @@
Puppet::Functions.create_function(:validate_hash) do
dispatch :deprecation_gen do
param 'Any', :scope
repeated_param 'Any', :args
end
# Workaround PUP-4438 (fixed: https://github.com/puppetlabs/puppet/commit/e01c4dc924cd963ff6630008a5200fc6a2023b08#diff-c937cc584953271bb3d3b3c2cb141790R221) to support puppet < 4.1.0 and puppet < 3.8.1.
def call(scope, *args)
manipulated_args = [scope] + args
self.class.dispatcher.dispatch(self, scope, manipulated_args)
end
def deprecation_gen(scope, *args)
call_function('deprecation', 'validate_hash', "This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::Hash. There is further documentation for validate_legacy function in the README.")
scope.send("function_validate_hash", args)
end
end

View File

@@ -0,0 +1,15 @@
Puppet::Functions.create_function(:validate_integer) do
dispatch :deprecation_gen do
param 'Any', :scope
repeated_param 'Any', :args
end
# Workaround PUP-4438 (fixed: https://github.com/puppetlabs/puppet/commit/e01c4dc924cd963ff6630008a5200fc6a2023b08#diff-c937cc584953271bb3d3b3c2cb141790R221) to support puppet < 4.1.0 and puppet < 3.8.1.
def call(scope, *args)
manipulated_args = [scope] + args
self.class.dispatcher.dispatch(self, scope, manipulated_args)
end
def deprecation_gen(scope, *args)
call_function('deprecation', 'validate_integer', "This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::Integer. There is further documentation for validate_legacy function in the README.")
scope.send("function_validate_integer", args)
end
end

View File

@@ -0,0 +1,15 @@
Puppet::Functions.create_function(:validate_ip_address) do
dispatch :deprecation_gen do
param 'Any', :scope
repeated_param 'Any', :args
end
# Workaround PUP-4438 (fixed: https://github.com/puppetlabs/puppet/commit/e01c4dc924cd963ff6630008a5200fc6a2023b08#diff-c937cc584953271bb3d3b3c2cb141790R221) to support puppet < 4.1.0 and puppet < 3.8.1.
def call(scope, *args)
manipulated_args = [scope] + args
self.class.dispatcher.dispatch(self, scope, manipulated_args)
end
def deprecation_gen(scope, *args)
call_function('deprecation', 'validate_ip_address', "This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::Ip_Address. There is further documentation for validate_legacy function in the README.")
scope.send("function_validate_ip_address", args)
end
end

View File

@@ -0,0 +1,15 @@
Puppet::Functions.create_function(:validate_ipv4_address) do
dispatch :deprecation_gen do
param 'Any', :scope
repeated_param 'Any', :args
end
# Workaround PUP-4438 (fixed: https://github.com/puppetlabs/puppet/commit/e01c4dc924cd963ff6630008a5200fc6a2023b08#diff-c937cc584953271bb3d3b3c2cb141790R221) to support puppet < 4.1.0 and puppet < 3.8.1.
def call(scope, *args)
manipulated_args = [scope] + args
self.class.dispatcher.dispatch(self, scope, manipulated_args)
end
def deprecation_gen(scope, *args)
call_function('deprecation', 'validate_ipv4_address', "This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::Ipv4_Address. There is further documentation for validate_legacy function in the README.")
scope.send("function_validate_ipv4_address", args)
end
end

View File

@@ -0,0 +1,15 @@
Puppet::Functions.create_function(:validate_ipv6_address) do
dispatch :deprecation_gen do
param 'Any', :scope
repeated_param 'Any', :args
end
# Workaround PUP-4438 (fixed: https://github.com/puppetlabs/puppet/commit/e01c4dc924cd963ff6630008a5200fc6a2023b08#diff-c937cc584953271bb3d3b3c2cb141790R221) to support puppet < 4.1.0 and puppet < 3.8.1.
def call(scope, *args)
manipulated_args = [scope] + args
self.class.dispatcher.dispatch(self, scope, manipulated_args)
end
def deprecation_gen(scope, *args)
call_function('deprecation', 'validate_ipv6_address', "This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::Ipv6_address. There is further documentation for validate_legacy function in the README.")
scope.send("function_validate_ipv6_address", args)
end
end

View File

@@ -0,0 +1,62 @@
Puppet::Functions.create_function(:validate_legacy) do
# The function checks a value against both the target_type (new) and the previous_validation function (old).
dispatch :validate_legacy do
param 'Any', :scope
param 'Type', :target_type
param 'String', :function_name
param 'Any', :value
repeated_param 'Any', :args
end
dispatch :validate_legacy_s do
param 'Any', :scope
param 'String', :type_string
param 'String', :function_name
param 'Any', :value
repeated_param 'Any', :args
end
# Workaround PUP-4438 (fixed: https://github.com/puppetlabs/puppet/commit/e01c4dc924cd963ff6630008a5200fc6a2023b08#diff-c937cc584953271bb3d3b3c2cb141790R221) to support puppet < 4.1.0 and puppet < 3.8.1.
def call(scope, *args)
manipulated_args = [scope] + args
self.class.dispatcher.dispatch(self, scope, manipulated_args)
end
def validate_legacy_s(scope, type_string, *args)
t = Puppet::Pops::Types::TypeParser.new.parse(type_string, scope)
validate_legacy(scope, t, *args)
end
def validate_legacy(scope, target_type, function_name, value, *prev_args)
if assert_type(target_type, value)
if previous_validation(scope, function_name, value, *prev_args)
# Silently passes
else
Puppet.notice("Accepting previously invalid value for target type '#{target_type}'")
end
else
inferred_type = Puppet::Pops::Types::TypeCalculator.infer_set(value)
error_msg = Puppet::Pops::Types::TypeMismatchDescriber.new.describe_mismatch("validate_legacy(#{function_name})", target_type, inferred_type)
if previous_validation(scope, function_name, value, *prev_args)
call_function('deprecation', 'validate_legacy', error_msg)
else
call_function('fail', error_msg)
end
end
end
def previous_validation(scope, function_name, value, *prev_args)
# Call the previous validation function and catch any errors. Return true if no errors are thrown.
begin
scope.send("function_#{function_name}".to_s, [value, *prev_args])
true
rescue Puppet::ParseError
false
end
end
def assert_type(type, value)
Puppet::Pops::Types::TypeCalculator.instance?(type, value)
end
end

View File

@@ -0,0 +1,15 @@
Puppet::Functions.create_function(:validate_numeric) do
dispatch :deprecation_gen do
param 'Any', :scope
repeated_param 'Any', :args
end
# Workaround PUP-4438 (fixed: https://github.com/puppetlabs/puppet/commit/e01c4dc924cd963ff6630008a5200fc6a2023b08#diff-c937cc584953271bb3d3b3c2cb141790R221) to support puppet < 4.1.0 and puppet < 3.8.1.
def call(scope, *args)
manipulated_args = [scope] + args
self.class.dispatcher.dispatch(self, scope, manipulated_args)
end
def deprecation_gen(scope, *args)
call_function('deprecation', 'validate_numeric', "This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::Numeric. There is further documentation for validate_legacy function in the README.")
scope.send("function_validate_numeric", args)
end
end

View File

@@ -0,0 +1,15 @@
Puppet::Functions.create_function(:validate_re) do
dispatch :deprecation_gen do
param 'Any', :scope
repeated_param 'Any', :args
end
# Workaround PUP-4438 (fixed: https://github.com/puppetlabs/puppet/commit/e01c4dc924cd963ff6630008a5200fc6a2023b08#diff-c937cc584953271bb3d3b3c2cb141790R221) to support puppet < 4.1.0 and puppet < 3.8.1.
def call(scope, *args)
manipulated_args = [scope] + args
self.class.dispatcher.dispatch(self, scope, manipulated_args)
end
def deprecation_gen(scope, *args)
call_function('deprecation', 'validate_re', "This method is deprecated, please use the stdlib validate_legacy function, with Pattern[]. There is further documentation for validate_legacy function in the README.")
scope.send("function_validate_re", args)
end
end

View File

@@ -0,0 +1,15 @@
Puppet::Functions.create_function(:validate_slength) do
dispatch :deprecation_gen do
param 'Any', :scope
repeated_param 'Any', :args
end
# Workaround PUP-4438 (fixed: https://github.com/puppetlabs/puppet/commit/e01c4dc924cd963ff6630008a5200fc6a2023b08#diff-c937cc584953271bb3d3b3c2cb141790R221) to support puppet < 4.1.0 and puppet < 3.8.1.
def call(scope, *args)
manipulated_args = [scope] + args
self.class.dispatcher.dispatch(self, scope, manipulated_args)
end
def deprecation_gen(scope, *args)
call_function('deprecation', 'validate_slength', "This method is deprecated, please use the stdlib validate_legacy function, with String[]. There is further documentation for validate_legacy function in the README.")
scope.send("function_validate_slength", args)
end
end

View File

@@ -0,0 +1,15 @@
Puppet::Functions.create_function(:validate_string) do
dispatch :deprecation_gen do
param 'Any', :scope
repeated_param 'Any', :args
end
# Workaround PUP-4438 (fixed: https://github.com/puppetlabs/puppet/commit/e01c4dc924cd963ff6630008a5200fc6a2023b08#diff-c937cc584953271bb3d3b3c2cb141790R221) to support puppet < 4.1.0 and puppet < 3.8.1.
def call(scope, *args)
manipulated_args = [scope] + args
self.class.dispatcher.dispatch(self, scope, manipulated_args)
end
def deprecation_gen(scope, *args)
call_function('deprecation', 'validate_string', "This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::String. There is further documentation for validate_legacy function in the README.")
scope.send("function_validate_string", args)
end
end

View File

@@ -0,0 +1,34 @@
#
# 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 :

View File

@@ -0,0 +1,33 @@
#
# 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 :

View File

@@ -0,0 +1,54 @@
#
# any2bool.rb
#
module Puppet::Parser::Functions
newfunction(:any2bool, :type => :rvalue, :doc => <<-EOS
This converts 'anything' to a boolean. In practise it does the following:
* Strings such as Y,y,1,T,t,TRUE,yes,'true' will return true
* Strings such as 0,F,f,N,n,FALSE,no,'false' will return false
* Booleans will just return their original value
* Number (or a string representation of a number) > 0 will return true, otherwise false
* undef will return false
* Anything else will return true
EOS
) do |arguments|
raise(Puppet::ParseError, "any2bool(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.size < 1
# If argument is already Boolean, return it
if !!arguments[0] == arguments[0]
return arguments[0]
end
arg = arguments[0]
if arg == nil
return false
end
if arg == :undef
return false
end
valid_float = !!Float(arg) rescue false
if arg.is_a?(Numeric)
return function_num2bool( [ arguments[0] ] )
end
if arg.is_a?(String)
if valid_float
return function_num2bool( [ arguments[0] ] )
else
return function_str2bool( [ arguments[0] ] )
end
end
return true
end
end
# vim: set ts=2 sw=2 et :

View File

@@ -0,0 +1,28 @@
#
# assert_private.rb
#
module Puppet::Parser::Functions
newfunction(:assert_private, :doc => <<-'EOS'
Sets the current class or definition as private.
Calling the class or definition from outside the current module will fail.
EOS
) do |args|
raise(Puppet::ParseError, "assert_private(): Wrong number of arguments given (#{args.size}}) for 0 or 1)") if args.size > 1
scope = self
if scope.lookupvar('module_name') != scope.lookupvar('caller_module_name')
message = nil
if args[0] and args[0].is_a? String
message = args[0]
else
manifest_name = scope.source.name
manifest_type = scope.source.type
message = (manifest_type.to_s == 'hostclass') ? 'Class' : 'Definition'
message += " #{manifest_name} is private"
end
raise(Puppet::ParseError, message)
end
end
end

View File

@@ -0,0 +1,71 @@
# Please note: This function is an implementation of a Ruby class and as such may not be entirely UTF8 compatible. To ensure compatibility please use this function with Ruby 2.4.0 or greater - https://bugs.ruby-lang.org/issues/10085.
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')
# explicitly define encode/decode method: default, strict, urlsafe
$method = 'default'
$encodestring = base64('encode', 'thestring', $method)
$decodestring = base64('decode', 'dGhlc3RyaW5n', $method)
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
method = ['default','strict','urlsafe']
if args.length <= 2
chosenMethod = 'default'
else
chosenMethod = args[2]
end
unless method.include?(chosenMethod)
raise Puppet::ParseError, ("base64(): the third argument must be one of 'default', 'strict', or 'urlsafe'")
end
case args[0]
when 'encode'
case chosenMethod
when 'default'
result = Base64.encode64(args[1])
when 'strict'
result = Base64.strict_encode64(args[1])
when 'urlsafe'
result = Base64.urlsafe_encode64(args[1])
end
when 'decode'
case chosenMethod
when 'default'
result = Base64.decode64(args[1])
when 'strict'
result = Base64.strict_decode64(args[1])
when 'urlsafe'
result = Base64.urlsafe_decode64(args[1])
end
end
return result
end
end

View File

@@ -0,0 +1,34 @@
module Puppet::Parser::Functions
newfunction(:basename, :type => :rvalue, :doc => <<-EOS
Strips directory (and optional suffix) from a filename
EOS
) do |arguments|
if arguments.size < 1 then
raise(Puppet::ParseError, "basename(): No arguments given")
elsif arguments.size > 2 then
raise(Puppet::ParseError, "basename(): Too many arguments given (#{arguments.size})")
else
unless arguments[0].is_a?(String)
raise(Puppet::ParseError, 'basename(): Requires string as first argument')
end
if arguments.size == 1 then
rv = File.basename(arguments[0])
elsif arguments.size == 2 then
unless arguments[1].is_a?(String)
raise(Puppet::ParseError, 'basename(): Requires string as second argument')
end
rv = File.basename(arguments[0], arguments[1])
end
end
return rv
end
end
# vim: set ts=2 sw=2 et :

View File

@@ -0,0 +1,25 @@
#
# 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 = function_str2bool([arguments[0]])
# We have real boolean values as well ...
result = value ? 1 : 0
return result
end
end
# vim: set ts=2 sw=2 et :

View File

@@ -0,0 +1,44 @@
#
# bool2str.rb
#
module Puppet::Parser::Functions
newfunction(:bool2str, :type => :rvalue, :doc => <<-EOS
Converts a boolean to a string using optionally supplied arguments. The
optional second and third arguments represent what true and false will be
converted to respectively. If only one argument is given, it will be
converted from a boolean to a string containing 'true' or 'false'.
*Examples:*
bool2str(true) => 'true'
bool2str(true, 'yes', 'no') => 'yes'
bool2str(false, 't', 'f') => 'f'
Requires a single boolean as an input.
EOS
) do |arguments|
unless arguments.size == 1 or arguments.size == 3
raise(Puppet::ParseError, "bool2str(): Wrong number of arguments given (#{arguments.size} for 3)")
end
value = arguments[0]
true_string = arguments[1] || 'true'
false_string = arguments[2] || 'false'
klass = value.class
# We can have either true or false, and nothing else
unless [FalseClass, TrueClass].include?(klass)
raise(Puppet::ParseError, 'bool2str(): Requires a boolean to work with')
end
unless [true_string, false_string].all?{|x| x.kind_of?(String)}
raise(Puppet::ParseError, "bool2str(): Requires strings to convert to" )
end
return value ? true_string : false_string
end
end
# vim: set ts=2 sw=2 et :

View File

@@ -0,0 +1,32 @@
#
# camelcase.rb
# Please note: This function is an implementation of a Ruby class and as such may not be entirely UTF8 compatible. To ensure compatibility please use this function with Ruby 2.4.0 or greater - https://bugs.ruby-lang.org/issues/10085.
#
module Puppet::Parser::Functions
newfunction(:camelcase, :type => :rvalue, :doc => <<-EOS
Converts the case of a string or all strings in an array to camel case.
EOS
) do |arguments|
raise(Puppet::ParseError, "camelcase(): 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, 'camelcase(): 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.split('_').map{|e| e.capitalize}.join : i }
else
result = value.split('_').map{|e| e.capitalize}.join
end
return result
end
end
# vim: set ts=2 sw=2 et :

View File

@@ -0,0 +1,30 @@
#
# capitalize.rb
# Please note: This function is an implementation of a Ruby class and as such may not be entirely UTF8 compatible. To ensure compatibility please use this function with Ruby 2.4.0 or greater - https://bugs.ruby-lang.org/issues/10085.
#
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]
unless value.is_a?(Array) || value.is_a?(String)
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

View File

@@ -0,0 +1,22 @@
module Puppet::Parser::Functions
newfunction(:ceiling, :type => :rvalue, :doc => <<-EOS
Returns the smallest integer greater or equal to the argument.
Takes a single numeric value as an argument.
EOS
) do |arguments|
raise(Puppet::ParseError, "ceiling(): 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, "ceiling(): Wrong argument type given (#{arguments[0]} for Numeric)")
end
raise(Puppet::ParseError, "ceiling(): Wrong argument type given (#{arg.class} for Numeric)") if arg.is_a?(Numeric) == false
arg.ceil
end
end
# vim: set ts=2 sw=2 et :

View File

@@ -0,0 +1,32 @@
#
# 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]
unless value.is_a?(Array) || value.is_a?(String)
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 :

View File

@@ -0,0 +1,34 @@
#
# 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]
unless value.is_a?(Array) || value.is_a?(String)
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 :

View File

@@ -0,0 +1,29 @@
#
# clamp.rb
#
module Puppet::Parser::Functions
newfunction(:clamp, :type => :rvalue, :arity => -2, :doc => <<-EOS
Clamps value to a range.
EOS
) do |args|
args.flatten!
raise(Puppet::ParseError, 'clamp(): Wrong number of arguments, need three to clamp') if args.size != 3
# check values out
args.each do |value|
case [value.class]
when [String]
raise(Puppet::ParseError, "clamp(): Required explicit numeric (#{value}:String)") unless value =~ /^\d+$/
when [Hash]
raise(Puppet::ParseError, "clamp(): The Hash type is not allowed (#{value})")
end
end
# convert to numeric each element
# then sort them and get a middle value
args.map{ |n| n.to_i }.sort[1]
end
end

View File

@@ -0,0 +1,40 @@
#
# concat.rb
#
module Puppet::Parser::Functions
newfunction(:concat, :type => :rvalue, :doc => <<-EOS
Appends the contents of multiple arrays into array 1.
*Example:*
concat(['1','2','3'],['4','5','6'],['7','8','9'])
Would result in:
['1','2','3','4','5','6','7','8','9']
EOS
) do |arguments|
# Check that more than 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]
# Check that the first parameter is an array
unless a.is_a?(Array)
raise(Puppet::ParseError, 'concat(): Requires array to work with')
end
result = a
arguments.shift
arguments.each do |x|
result = result + (x.is_a?(Array) ? x : [x])
end
return result
end
end
# vim: set ts=2 sw=2 et :

View File

@@ -0,0 +1,35 @@
module Puppet::Parser::Functions
newfunction(:convert_base, :type => :rvalue, :arity => 2, :doc => <<-'ENDHEREDOC') do |args|
Converts a given integer or base 10 string representing an integer to a specified base, as a string.
Usage:
$binary_repr = convert_base(5, 2) # $binary_repr is now set to "101"
$hex_repr = convert_base("254", "16") # $hex_repr is now set to "fe"
ENDHEREDOC
raise Puppet::ParseError, ("convert_base(): First argument must be either a string or an integer") unless (args[0].is_a?(Integer) or args[0].is_a?(String))
raise Puppet::ParseError, ("convert_base(): Second argument must be either a string or an integer") unless (args[1].is_a?(Integer) or args[1].is_a?(String))
if args[0].is_a?(String)
raise Puppet::ParseError, ("convert_base(): First argument must be an integer or a string corresponding to an integer in base 10") unless args[0] =~ /^[0-9]+$/
end
if args[1].is_a?(String)
raise Puppet::ParseError, ("convert_base(): First argument must be an integer or a string corresponding to an integer in base 10") unless args[1] =~ /^[0-9]+$/
end
number_to_convert = args[0]
new_base = args[1]
number_to_convert = number_to_convert.to_i()
new_base = new_base.to_i()
raise Puppet::ParseError, ("convert_base(): base must be at least 2 and must not be greater than 36") unless new_base >= 2 and new_base <= 36
return number_to_convert.to_s(new_base)
end
end

View File

@@ -0,0 +1,21 @@
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

View File

@@ -0,0 +1,44 @@
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

View File

@@ -0,0 +1,56 @@
# 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 Puppet::Util::Package.versioncmp(Puppet.version, '4.6.0') >= 0
# Workaround for PE-20308
if reference.is_a?(String)
type_name, title = Puppet::Resource.type_and_title(reference, nil)
type = Puppet::Pops::Evaluator::Runtime3ResourceSupport.find_resource_type_or_class(find_global_scope, type_name.downcase)
elsif reference.is_a?(Puppet::Resource)
type = reference.resource_type
title = reference.title
else
raise(ArgumentError, "Reference is not understood: '#{reference.class}'")
end
#end workaround
else
type = reference.to_s
title = nil
end
if resource = findresource(type, title)
matches = params.collect do |key, value|
# eql? avoids bugs caused by monkeypatching in puppet
resource_is_undef = resource[key].eql?(:undef) || resource[key].nil?
value_is_undef = value.eql?(:undef) || value.nil?
(resource_is_undef && value_is_undef) || (resource[key] == value)
end
ret = params.empty? || !matches.include?(false)
end
Puppet.debug("Resource #{reference} was not determined to be defined")
ret
end

View File

@@ -0,0 +1,43 @@
#
# delete.rb
#
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({'a'=>1,'b'=>2,'c'=>3}, ['b','c'])
Would return: {'a'=>1}
delete('abracadabra', 'bra')
Would return: 'acada'
EOS
) do |arguments|
raise(Puppet::ParseError, "delete(): Wrong number of arguments given #{arguments.size} for 2") unless arguments.size == 2
collection = arguments[0].dup
Array(arguments[1]).each do |item|
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
end
collection
end
end
# vim: set ts=2 sw=2 et :

View File

@@ -0,0 +1,46 @@
#
# 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 :

View File

@@ -0,0 +1,44 @@
#
# delete_regex.rb
# Please note: This function is an implementation of a Ruby class and as such may not be entirely UTF8 compatible. To ensure compatibility please use this function with Ruby 2.4.0 or greater - https://bugs.ruby-lang.org/issues/10085.
#
module Puppet::Parser::Functions
newfunction(:delete_regex, :type => :rvalue, :doc => <<-EOS
deletes all instances of a given element that match a regular expression
from an array or key from a hash. Multiple regular expressions are assumed
to be matched as an OR.
*Examples:*
delete_regex(['a','b','c','b'], 'b')
Would return: ['a','c']
delete_regex(['a','b','c','b'], ['b', 'c'])
Would return: ['a']
delete_regex({'a'=>1,'b'=>2,'c'=>3}, 'b')
Would return: {'a'=>1,'c'=>3}
delete_regex({'a'=>1,'b'=>2,'c'=>3}, '^a$')
Would return: {'b'=>2,'c'=>3}
EOS
) do |arguments|
raise(Puppet::ParseError, "delete_regex(): Wrong number of arguments given #{arguments.size} for 2") unless arguments.size == 2
collection = arguments[0].dup
Array(arguments[1]).each do |item|
case collection
when Array, Hash, String
collection.reject! { |coll_item| (coll_item =~ %r{\b#{item}\b}) }
else
raise(TypeError, "delete_regex(): First argument must be an Array, Hash, or String. Given an argument of class #{collection.class}.")
end
end
collection
end
end
# vim: set ts=2 sw=2 et :

View File

@@ -0,0 +1,31 @@
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

View File

@@ -0,0 +1,23 @@
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

View File

@@ -0,0 +1,16 @@
module Puppet::Parser::Functions
newfunction(:deprecation, :doc => <<-EOS
Function to print deprecation warnings (this is the 3.X version of it), The uniqueness key - can appear once. The msg is the message text including any positional information that is formatted by the user/caller of the method.).
EOS
) do |arguments|
raise(Puppet::ParseError, "deprecation: Wrong number of arguments given (#{arguments.size} for 2)") unless arguments.size == 2
key = arguments[0]
message = arguments[1]
if ENV['STDLIB_LOG_DEPRECATIONS'] == "true"
warning("deprecation. #{key}. #{message}")
end
end
end

View File

@@ -0,0 +1,35 @@
#
# 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 :

View File

@@ -0,0 +1,16 @@
#
# dig.rb
#
module Puppet::Parser::Functions
newfunction(:dig, :type => :rvalue, :doc => <<-EOS
DEPRECATED: This function has been replaced in Puppet 4.5.0, please use dig44() for backwards compatibility or use the new version.
EOS
) do |arguments|
warning("dig() DEPRECATED: This function has been replaced in Puppet 4.5.0, please use dig44() for backwards compatibility or use the new version.")
if ! Puppet::Parser::Functions.autoloader.loaded?(:dig44)
Puppet::Parser::Functions.autoloader.load(:dig44)
end
function_dig44(arguments)
end
end

View File

@@ -0,0 +1,70 @@
#
# dig44.rb
#
module Puppet::Parser::Functions
newfunction(
:dig44,
:type => :rvalue,
:arity => -2,
:doc => <<-eos
DEPRECATED: This function has been replaced in puppet 4.5.0.
Looks up into a complex structure of arrays and hashes and returns a value
or the default value if nothing was found.
Key can contain slashes to describe path components. The function will go down
the structure and try to extract the required value.
$data = {
'a' => {
'b' => [
'b1',
'b2',
'b3',
]
}
}
$value = dig44($data, ['a', 'b', '2'], 'not_found')
=> $value = 'b3'
a -> first hash key
b -> second hash key
2 -> array index starting with 0
not_found -> (optional) will be returned if there is no value or the path
did not match. Defaults to nil.
In addition to the required "key" argument, the function accepts a default
argument. It will be returned if no value was found or a path component is
missing. And the fourth argument can set a variable path separator.
eos
) do |arguments|
# Two arguments are required
raise(Puppet::ParseError, "dig44(): Wrong number of arguments given (#{arguments.size} for at least 2)") if arguments.size < 2
data, path, default = *arguments
unless data.is_a?(Hash) or data.is_a?(Array)
raise(Puppet::ParseError, "dig44(): first argument must be a hash or an array, given #{data.class.name}")
end
unless path.is_a? Array
raise(Puppet::ParseError, "dig44(): second argument must be an array, given #{path.class.name}")
end
value = path.reduce(data) do |structure, key|
if structure.is_a? Hash or structure.is_a? Array
if structure.is_a? Array
key = Integer key rescue break
end
break if structure[key].nil? or structure[key] == :undef
structure[key]
else
break
end
end
value.nil? ? default : value
end
end

View File

@@ -0,0 +1,21 @@
module Puppet::Parser::Functions
newfunction(:dirname, :type => :rvalue, :doc => <<-EOS
Returns the dirname of a path.
EOS
) do |arguments|
if arguments.size < 1 then
raise(Puppet::ParseError, "dirname(): No arguments given")
end
if arguments.size > 1 then
raise(Puppet::ParseError, "dirname(): Too many arguments given (#{arguments.size})")
end
unless arguments[0].is_a?(String)
raise(Puppet::ParseError, 'dirname(): Requires string as argument')
end
return File.dirname(arguments[0])
end
end
# vim: set ts=2 sw=2 et :

View File

@@ -0,0 +1,15 @@
# Custom Puppet function to convert dos to unix format
module Puppet::Parser::Functions
newfunction(:dos2unix, :type => :rvalue, :arity => 1, :doc => <<-EOS
Returns the Unix version of the given string.
Takes a single string argument.
EOS
) do |arguments|
unless arguments[0].is_a?(String)
raise(Puppet::ParseError, 'dos2unix(): Requires string as argument')
end
arguments[0].gsub(/\r\n/, "\n")
end
end

View File

@@ -0,0 +1,31 @@
#
# downcase.rb
# Please note: This function is an implementation of a Ruby class and as such may not be entirely UTF8 compatible. To ensure compatibility please use this function with Ruby 2.4.0 or greater - https://bugs.ruby-lang.org/issues/10085.
#
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]
unless value.is_a?(Array) || value.is_a?(String)
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 :

View File

@@ -0,0 +1,29 @@
#
# 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]
unless value.is_a?(Array) || value.is_a?(Hash) || value.is_a?(String) || value.is_a?(Numeric)
raise(Puppet::ParseError, 'empty(): Requires either array, hash, string or integer to work with')
end
if value.is_a?(Numeric)
return false
else
result = value.empty?
return result
end
end
end
# vim: set ts=2 sw=2 et :

View File

@@ -0,0 +1,42 @@
#
# enclose_ipv6.rb
#
module Puppet::Parser::Functions
newfunction(:enclose_ipv6, :type => :rvalue, :doc => <<-EOS
Takes an array of ip addresses and encloses the ipv6 addresses with square brackets.
EOS
) do |arguments|
require 'ipaddr'
rescuable_exceptions = [ ArgumentError ]
if defined?(IPAddr::InvalidAddressError)
rescuable_exceptions << IPAddr::InvalidAddressError
end
if (arguments.size != 1) then
raise(Puppet::ParseError, "enclose_ipv6(): Wrong number of arguments given #{arguments.size} for 1")
end
unless arguments[0].is_a?(String) or arguments[0].is_a?(Array) then
raise(Puppet::ParseError, "enclose_ipv6(): Wrong argument type given #{arguments[0].class} expected String or Array")
end
input = [arguments[0]].flatten.compact
result = []
input.each do |val|
unless val == '*'
begin
ip = IPAddr.new(val)
rescue *rescuable_exceptions
raise(Puppet::ParseError, "enclose_ipv6(): Wrong argument given #{val} is not an ip address.")
end
val = "[#{ip.to_s}]" if ip.ipv6?
end
result << val
end
return result.uniq
end
end

View File

@@ -0,0 +1,48 @@
#
# 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
if arguments[0].is_a?(Hash)
if arguments[1]
defaults = { 'ensure' => 'present' }.merge(arguments[1])
else
defaults = { 'ensure' => 'present' }
end
Puppet::Parser::Functions.function(:ensure_resources)
function_ensure_resources(['package', arguments[0].dup, defaults ])
else
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|
raise(Puppet::ParseError, 'ensure_packages(): Empty String provided for package name') if package_name.length == 0
if !findresource("Package[#{package_name}]")
function_ensure_resource(['package', package_name, defaults ])
end
}
end
end
end
# vim: set ts=2 sw=2 et :

View File

@@ -0,0 +1,46 @@
# 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}] with params #{params} not created because it already exists")
else
Puppet.debug("Create new resource #{type}[#{item}] with params #{params}")
Puppet::Parser::Functions.function(:create_resources)
function_create_resources([type.capitalize, { item => params }])
end
end
end

View File

@@ -0,0 +1,54 @@
require 'puppet/parser/functions'
Puppet::Parser::Functions.newfunction(:ensure_resources,
:type => :statement,
:doc => <<-'ENDOFDOC'
Takes a resource type, title (only hash), and a list of attributes that describe a
resource.
user { 'dan':
gid => 'mygroup',
ensure => present,
}
An hash of resources should be passed in and each will be created with
the type and parameters specified if it doesn't already exist.
ensure_resources('user', {'dan' => { gid => 'mygroup', uid => '600' } , 'alex' => { gid => 'mygroup' }}, {'ensure' => 'present'})
From Hiera Backend:
userlist:
dan:
gid: 'mygroup'
uid: '600'
alex:
gid: 'mygroup'
Call:
ensure_resources('user', hiera_hash('userlist'), {'ensure' => 'present'})
ENDOFDOC
) do |vals|
type, title, params = vals
raise(ArgumentError, 'Must specify a type') unless type
raise(ArgumentError, 'Must specify a title') unless title
params ||= {}
if title.is_a?(Hash)
resource_hash = title.dup
resources = resource_hash.keys
Puppet::Parser::Functions.function(:ensure_resource)
resources.each { |resource_name|
if resource_hash[resource_name]
params_merged = params.merge(resource_hash[resource_name])
else
params_merged = params
end
function_ensure_resource([ type, resource_name, params_merged ])
}
else
raise(Puppet::ParseError, 'ensure_resources(): Requires second argument to be a Hash')
end
end

Some files were not shown because too many files have changed in this diff Show More