@@ -77,6 +77,43 @@ Returns the absolute value of a number, for example -34.56 becomes
7777
7878- * Type* : rvalue
7979
80+ anchor
81+ ------
82+ A simple resource type intended to be used as an anchor in a composite class.
83+
84+ In Puppet 2.6, when a class declares another class, the resources in the
85+ interior class are not contained by the exterior class. This interacts badly
86+ with the pattern of composing complex modules from smaller classes, as it
87+ makes it impossible for end users to specify order relationships between the
88+ exterior class and other modules.
89+
90+ The anchor type lets you work around this. By sandwiching any interior
91+ classes between two no-op resources that _ are_ contained by the exterior
92+ class, you can ensure that all resources in the module are contained.
93+
94+ class ntp {
95+ # These classes will have the correct order relationship with each
96+ # other. However, without anchors, they won't have any order
97+ # relationship to Class['ntp'].
98+ class { 'ntp::package': }
99+ -> class { 'ntp::config': }
100+ -> class { 'ntp::service': }
101+
102+ # These two resources "anchor" the composed classes within the ntp
103+ # class.
104+ anchor { 'ntp::begin': } -> Class['ntp::package']
105+ Class['ntp::service'] -> anchor { 'ntp::end': }
106+ }
107+
108+ This allows the end user of the ntp module to establish require and before
109+ relationships with Class[ 'ntp'] :
110+
111+ class { 'ntp': } -> class { 'mcollective': }
112+ class { 'mcollective': } -> class { 'ntp': }
113+
114+
115+ - * Type* : resource
116+
80117any2array
81118---------
82119This converts any object to an array containing that object. Empty argument
@@ -103,6 +140,19 @@ true, t, 1, y, and yes to 1
103140 Requires a single boolean or string as an input.
104141
105142
143+ - * Type* : rvalue
144+
145+ bool2str
146+ --------
147+ Converts a boolean to a string.
148+ Requires a single boolean as an input.
149+
150+ - * Type* : rvalue
151+
152+ camelcase
153+ ---------
154+ Converts the case of a string or all strings in an array to camel case.
155+
106156- * Type* : rvalue
107157
108158capitalize
@@ -160,6 +210,23 @@ Count the number of elements in array that matches second argument.
160210If called with only an array it counts the number of elements that are not nil/undef.
161211
162212
213+ - * Type* : rvalue
214+
215+ deep_merge
216+ ----------
217+ Recursively merges two or more hashes together and returns the resulting hash.
218+
219+ * Example:*
220+
221+ $hash1 = {'one' => 1, 'two' => 2, 'three' => { 'four' => 4 } }
222+ $hash2 = {'two' => 'dos', 'three' => { 'five' => 5 } }
223+ $merged_hash = deep_merge($hash1, $hash2)
224+ # The resulting hash is equivalent to:
225+ # $merged_hash = { 'one' => 1, 'two' => 'dos', 'three' => { 'four' => 4, 'five' => 5 } }
226+
227+ When there is a duplicate key that is a hash, they are recursively merged.
228+ When there is a duplicate key that is not a hash, the key in the rightmost hash will "win."
229+
163230- * Type* : rvalue
164231
165232defined_with_params
@@ -713,6 +780,30 @@ failing that, will use a default value of 1.449.
713780
714781- * Type* : rvalue
715782
783+ pick_default
784+ ------------
785+ This function is similar to a coalesce function in SQL in that it will return
786+ the first value in a list of values that is not undefined or an empty string
787+ (two things in Puppet that will return a boolean false value). If no value is
788+ found, it will return the last argument.
789+
790+ Typically, this function is used to check for a value in the Puppet
791+ Dashboard/Enterprise Console, and failover to a default value like the
792+ following:
793+
794+ $real_jenkins_version = pick_default($::jenkins_version, '1.449')
795+
796+ The value of $real_jenkins_version will first look for a top-scope variable
797+ called 'jenkins_version' (note that parameters set in the Puppet Dashboard/
798+ Enterprise Console are brought into Puppet as top-scope variables), and,
799+ failing that, will use a default value of 1.449.
800+
801+ Note that, contrary to the pick() function, the pick_default does not fail if
802+ all arguments are empty. This allows pick_default to use an empty value as
803+ default.
804+
805+ - * Type* : rvalue
806+
716807prefix
717808------
718809This function applies a prefix to all elements in an array.
@@ -1166,6 +1257,43 @@ The following values will fail, causing compilation to abort:
11661257
11671258
11681259
1260+ - * Type* : statement
1261+
1262+ validate_ipv4_address
1263+ ---------------------
1264+ Validate that all values passed are valid IPv4 addresses.
1265+ Fail compilation if any value fails this check.
1266+
1267+ The following values will pass:
1268+
1269+ $my_ip = "1.2.3.4"
1270+ validate_ipv4_address($my_ip)
1271+ validate_bool("8.8.8.8", "172.16.0.1", $my_ip)
1272+
1273+ The following values will fail, causing compilation to abort:
1274+
1275+ $some_array = [ 1, true, false, "garbage string", "3ffe:505:2" ]
1276+ validate_ipv4_address($some_array)
1277+
1278+ - * Type* : statement
1279+
1280+ validate_ipv6_address
1281+ ---------------------
1282+ Validate that all values passed are valid IPv6 addresses.
1283+ Fail compilation if any value fails this check.
1284+
1285+ The following values will pass:
1286+
1287+ $my_ip = "3ffe:505:2"
1288+ validate_ipv6_address(1)
1289+ validate_ipv6_address($my_ip)
1290+ validate_bool("fe80::baf6:b1ff:fe19:7507", $my_ip)
1291+
1292+ The following values will fail, causing compilation to abort:
1293+
1294+ $some_array = [ true, false, "garbage string", "1.2.3.4" ]
1295+ validate_ipv6_address($some_array)
1296+
11691297- * Type* : statement
11701298
11711299validate_re
0 commit comments