puppetmodule-stdlib 4.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (200) hide show
  1. data/CHANGELOG +253 -0
  2. data/CONTRIBUTING.md +65 -0
  3. data/Gemfile +33 -0
  4. data/LICENSE +19 -0
  5. data/Modulefile +11 -0
  6. data/README.markdown +1173 -0
  7. data/README_DEVELOPER.markdown +35 -0
  8. data/RELEASE_PROCESS.markdown +24 -0
  9. data/Rakefile +2 -0
  10. data/lib/facter/pe_version.rb +53 -0
  11. data/lib/facter/puppet_vardir.rb +26 -0
  12. data/lib/facter/root_home.rb +19 -0
  13. data/lib/facter/util/puppet_settings.rb +21 -0
  14. data/lib/puppet/parser/functions/abs.rb +36 -0
  15. data/lib/puppet/parser/functions/any2array.rb +33 -0
  16. data/lib/puppet/parser/functions/bool2num.rb +49 -0
  17. data/lib/puppet/parser/functions/capitalize.rb +34 -0
  18. data/lib/puppet/parser/functions/chomp.rb +35 -0
  19. data/lib/puppet/parser/functions/chop.rb +37 -0
  20. data/lib/puppet/parser/functions/concat.rb +37 -0
  21. data/lib/puppet/parser/functions/count.rb +22 -0
  22. data/lib/puppet/parser/functions/defined_with_params.rb +35 -0
  23. data/lib/puppet/parser/functions/delete.rb +46 -0
  24. data/lib/puppet/parser/functions/delete_at.rb +49 -0
  25. data/lib/puppet/parser/functions/downcase.rb +33 -0
  26. data/lib/puppet/parser/functions/empty.rb +28 -0
  27. data/lib/puppet/parser/functions/ensure_packages.rb +24 -0
  28. data/lib/puppet/parser/functions/ensure_resource.rb +35 -0
  29. data/lib/puppet/parser/functions/flatten.rb +33 -0
  30. data/lib/puppet/parser/functions/floor.rb +20 -0
  31. data/lib/puppet/parser/functions/fqdn_rotate.rb +46 -0
  32. data/lib/puppet/parser/functions/get_module_path.rb +17 -0
  33. data/lib/puppet/parser/functions/getparam.rb +35 -0
  34. data/lib/puppet/parser/functions/getvar.rb +26 -0
  35. data/lib/puppet/parser/functions/grep.rb +33 -0
  36. data/lib/puppet/parser/functions/has_interface_with.rb +52 -0
  37. data/lib/puppet/parser/functions/has_ip_address.rb +25 -0
  38. data/lib/puppet/parser/functions/has_ip_network.rb +25 -0
  39. data/lib/puppet/parser/functions/has_key.rb +28 -0
  40. data/lib/puppet/parser/functions/hash.rb +41 -0
  41. data/lib/puppet/parser/functions/is_array.rb +22 -0
  42. data/lib/puppet/parser/functions/is_domain_name.rb +47 -0
  43. data/lib/puppet/parser/functions/is_float.rb +27 -0
  44. data/lib/puppet/parser/functions/is_function_available.rb +23 -0
  45. data/lib/puppet/parser/functions/is_hash.rb +22 -0
  46. data/lib/puppet/parser/functions/is_integer.rb +27 -0
  47. data/lib/puppet/parser/functions/is_ip_address.rb +32 -0
  48. data/lib/puppet/parser/functions/is_mac_address.rb +27 -0
  49. data/lib/puppet/parser/functions/is_numeric.rb +27 -0
  50. data/lib/puppet/parser/functions/is_string.rb +26 -0
  51. data/lib/puppet/parser/functions/join.rb +41 -0
  52. data/lib/puppet/parser/functions/join_keys_to_values.rb +47 -0
  53. data/lib/puppet/parser/functions/keys.rb +26 -0
  54. data/lib/puppet/parser/functions/loadyaml.rb +20 -0
  55. data/lib/puppet/parser/functions/lstrip.rb +33 -0
  56. data/lib/puppet/parser/functions/max.rb +21 -0
  57. data/lib/puppet/parser/functions/member.rb +44 -0
  58. data/lib/puppet/parser/functions/merge.rb +33 -0
  59. data/lib/puppet/parser/functions/min.rb +21 -0
  60. data/lib/puppet/parser/functions/num2bool.rb +43 -0
  61. data/lib/puppet/parser/functions/parsejson.rb +24 -0
  62. data/lib/puppet/parser/functions/parseyaml.rb +24 -0
  63. data/lib/puppet/parser/functions/pick.rb +29 -0
  64. data/lib/puppet/parser/functions/prefix.rb +45 -0
  65. data/lib/puppet/parser/functions/range.rb +80 -0
  66. data/lib/puppet/parser/functions/reject.rb +31 -0
  67. data/lib/puppet/parser/functions/reverse.rb +28 -0
  68. data/lib/puppet/parser/functions/rstrip.rb +32 -0
  69. data/lib/puppet/parser/functions/shuffle.rb +46 -0
  70. data/lib/puppet/parser/functions/size.rb +48 -0
  71. data/lib/puppet/parser/functions/sort.rb +27 -0
  72. data/lib/puppet/parser/functions/squeeze.rb +36 -0
  73. data/lib/puppet/parser/functions/str2bool.rb +46 -0
  74. data/lib/puppet/parser/functions/str2saltedsha512.rb +32 -0
  75. data/lib/puppet/parser/functions/strftime.rb +107 -0
  76. data/lib/puppet/parser/functions/strip.rb +39 -0
  77. data/lib/puppet/parser/functions/suffix.rb +45 -0
  78. data/lib/puppet/parser/functions/swapcase.rb +39 -0
  79. data/lib/puppet/parser/functions/time.rb +49 -0
  80. data/lib/puppet/parser/functions/to_bytes.rb +28 -0
  81. data/lib/puppet/parser/functions/type.rb +50 -0
  82. data/lib/puppet/parser/functions/unique.rb +51 -0
  83. data/lib/puppet/parser/functions/upcase.rb +41 -0
  84. data/lib/puppet/parser/functions/uriescape.rb +36 -0
  85. data/lib/puppet/parser/functions/validate_absolute_path.rb +56 -0
  86. data/lib/puppet/parser/functions/validate_array.rb +33 -0
  87. data/lib/puppet/parser/functions/validate_augeas.rb +81 -0
  88. data/lib/puppet/parser/functions/validate_bool.rb +34 -0
  89. data/lib/puppet/parser/functions/validate_cmd.rb +47 -0
  90. data/lib/puppet/parser/functions/validate_hash.rb +33 -0
  91. data/lib/puppet/parser/functions/validate_re.rb +40 -0
  92. data/lib/puppet/parser/functions/validate_slength.rb +52 -0
  93. data/lib/puppet/parser/functions/validate_string.rb +33 -0
  94. data/lib/puppet/parser/functions/values.rb +39 -0
  95. data/lib/puppet/parser/functions/values_at.rb +98 -0
  96. data/lib/puppet/parser/functions/zip.rb +65 -0
  97. data/lib/puppet/provider/file_line/ruby.rb +59 -0
  98. data/lib/puppet/type/anchor.rb +41 -0
  99. data/lib/puppet/type/file_line.rb +70 -0
  100. data/manifests/init.pp +20 -0
  101. data/manifests/stages.pp +43 -0
  102. data/spec/functions/defined_with_params_spec.rb +37 -0
  103. data/spec/functions/ensure_packages_spec.rb +42 -0
  104. data/spec/functions/ensure_resource_spec.rb +40 -0
  105. data/spec/functions/getparam_spec.rb +34 -0
  106. data/spec/monkey_patches/alias_should_to_must.rb +8 -0
  107. data/spec/monkey_patches/publicize_methods.rb +10 -0
  108. data/spec/spec.opts +6 -0
  109. data/spec/spec_helper.rb +28 -0
  110. data/spec/unit/facter/pe_version_spec.rb +76 -0
  111. data/spec/unit/facter/root_home_spec.rb +40 -0
  112. data/spec/unit/facter/util/puppet_settings_spec.rb +35 -0
  113. data/spec/unit/puppet/parser/functions/abs_spec.rb +25 -0
  114. data/spec/unit/puppet/parser/functions/any2array_spec.rb +55 -0
  115. data/spec/unit/puppet/parser/functions/bool2num_spec.rb +24 -0
  116. data/spec/unit/puppet/parser/functions/capitalize_spec.rb +19 -0
  117. data/spec/unit/puppet/parser/functions/chomp_spec.rb +19 -0
  118. data/spec/unit/puppet/parser/functions/chop_spec.rb +19 -0
  119. data/spec/unit/puppet/parser/functions/concat_spec.rb +15 -0
  120. data/spec/unit/puppet/parser/functions/count_spec.rb +31 -0
  121. data/spec/unit/puppet/parser/functions/delete_at_spec.rb +19 -0
  122. data/spec/unit/puppet/parser/functions/delete_spec.rb +38 -0
  123. data/spec/unit/puppet/parser/functions/downcase_spec.rb +24 -0
  124. data/spec/unit/puppet/parser/functions/empty_spec.rb +23 -0
  125. data/spec/unit/puppet/parser/functions/flatten_spec.rb +27 -0
  126. data/spec/unit/puppet/parser/functions/floor_spec.rb +39 -0
  127. data/spec/unit/puppet/parser/functions/fqdn_rotate_spec.rb +33 -0
  128. data/spec/unit/puppet/parser/functions/get_module_path_spec.rb +46 -0
  129. data/spec/unit/puppet/parser/functions/getvar_spec.rb +37 -0
  130. data/spec/unit/puppet/parser/functions/grep_spec.rb +19 -0
  131. data/spec/unit/puppet/parser/functions/has_interface_with_spec.rb +64 -0
  132. data/spec/unit/puppet/parser/functions/has_ip_address_spec.rb +39 -0
  133. data/spec/unit/puppet/parser/functions/has_ip_network_spec.rb +36 -0
  134. data/spec/unit/puppet/parser/functions/has_key_spec.rb +42 -0
  135. data/spec/unit/puppet/parser/functions/hash_spec.rb +19 -0
  136. data/spec/unit/puppet/parser/functions/is_array_spec.rb +29 -0
  137. data/spec/unit/puppet/parser/functions/is_domain_name_spec.rb +64 -0
  138. data/spec/unit/puppet/parser/functions/is_float_spec.rb +33 -0
  139. data/spec/unit/puppet/parser/functions/is_function_available.rb +31 -0
  140. data/spec/unit/puppet/parser/functions/is_hash_spec.rb +29 -0
  141. data/spec/unit/puppet/parser/functions/is_integer_spec.rb +34 -0
  142. data/spec/unit/puppet/parser/functions/is_ip_address_spec.rb +39 -0
  143. data/spec/unit/puppet/parser/functions/is_mac_address_spec.rb +29 -0
  144. data/spec/unit/puppet/parser/functions/is_numeric_spec.rb +39 -0
  145. data/spec/unit/puppet/parser/functions/is_string_spec.rb +34 -0
  146. data/spec/unit/puppet/parser/functions/join_keys_to_values_spec.rb +40 -0
  147. data/spec/unit/puppet/parser/functions/join_spec.rb +19 -0
  148. data/spec/unit/puppet/parser/functions/keys_spec.rb +21 -0
  149. data/spec/unit/puppet/parser/functions/lstrip_spec.rb +19 -0
  150. data/spec/unit/puppet/parser/functions/max_spec.rb +27 -0
  151. data/spec/unit/puppet/parser/functions/member_spec.rb +24 -0
  152. data/spec/unit/puppet/parser/functions/merge_spec.rb +47 -0
  153. data/spec/unit/puppet/parser/functions/min_spec.rb +27 -0
  154. data/spec/unit/puppet/parser/functions/num2bool_spec.rb +67 -0
  155. data/spec/unit/puppet/parser/functions/parsejson_spec.rb +22 -0
  156. data/spec/unit/puppet/parser/functions/parseyaml_spec.rb +24 -0
  157. data/spec/unit/puppet/parser/functions/pick_spec.rb +34 -0
  158. data/spec/unit/puppet/parser/functions/prefix_spec.rb +19 -0
  159. data/spec/unit/puppet/parser/functions/range_spec.rb +34 -0
  160. data/spec/unit/puppet/parser/functions/reject_spec.rb +20 -0
  161. data/spec/unit/puppet/parser/functions/reverse_spec.rb +19 -0
  162. data/spec/unit/puppet/parser/functions/rstrip_spec.rb +24 -0
  163. data/spec/unit/puppet/parser/functions/shuffle_spec.rb +24 -0
  164. data/spec/unit/puppet/parser/functions/size_spec.rb +24 -0
  165. data/spec/unit/puppet/parser/functions/sort_spec.rb +24 -0
  166. data/spec/unit/puppet/parser/functions/squeeze_spec.rb +24 -0
  167. data/spec/unit/puppet/parser/functions/str2bool_spec.rb +31 -0
  168. data/spec/unit/puppet/parser/functions/str2saltedsha512_spec.rb +45 -0
  169. data/spec/unit/puppet/parser/functions/strftime_spec.rb +29 -0
  170. data/spec/unit/puppet/parser/functions/strip_spec.rb +18 -0
  171. data/spec/unit/puppet/parser/functions/suffix_spec.rb +19 -0
  172. data/spec/unit/puppet/parser/functions/swapcase_spec.rb +19 -0
  173. data/spec/unit/puppet/parser/functions/time_spec.rb +29 -0
  174. data/spec/unit/puppet/parser/functions/to_bytes_spec.rb +58 -0
  175. data/spec/unit/puppet/parser/functions/type_spec.rb +43 -0
  176. data/spec/unit/puppet/parser/functions/unique_spec.rb +24 -0
  177. data/spec/unit/puppet/parser/functions/upcase_spec.rb +24 -0
  178. data/spec/unit/puppet/parser/functions/uriescape_spec.rb +24 -0
  179. data/spec/unit/puppet/parser/functions/validate_absolute_path_spec.rb +83 -0
  180. data/spec/unit/puppet/parser/functions/validate_array_spec.rb +38 -0
  181. data/spec/unit/puppet/parser/functions/validate_augeas_spec.rb +102 -0
  182. data/spec/unit/puppet/parser/functions/validate_bool_spec.rb +51 -0
  183. data/spec/unit/puppet/parser/functions/validate_cmd_spec.rb +81 -0
  184. data/spec/unit/puppet/parser/functions/validate_hash_spec.rb +43 -0
  185. data/spec/unit/puppet/parser/functions/validate_re_spec.rb +76 -0
  186. data/spec/unit/puppet/parser/functions/validate_slength_spec.rb +48 -0
  187. data/spec/unit/puppet/parser/functions/validate_string_spec.rb +60 -0
  188. data/spec/unit/puppet/parser/functions/values_at_spec.rb +38 -0
  189. data/spec/unit/puppet/parser/functions/values_spec.rb +31 -0
  190. data/spec/unit/puppet/parser/functions/zip_spec.rb +15 -0
  191. data/spec/unit/puppet/provider/file_line/ruby_spec.rb +127 -0
  192. data/spec/unit/puppet/type/anchor_spec.rb +11 -0
  193. data/spec/unit/puppet/type/file_line_spec.rb +69 -0
  194. data/spec/watchr.rb +86 -0
  195. data/tests/file_line.pp +9 -0
  196. data/tests/has_interface_with.pp +10 -0
  197. data/tests/has_ip_address.pp +3 -0
  198. data/tests/has_ip_network.pp +4 -0
  199. data/tests/init.pp +1 -0
  200. metadata +252 -0
@@ -0,0 +1,253 @@
1
+ 2013-04-11 - Jeff McCune <jeff@puppetlabs.com> - 4.0.1
2
+ * Fix README function documentation (ab3e30c)
3
+
4
+ 2013-04-11 - Jeff McCune <jeff@puppetlabs.com> - 4.0.0
5
+ * stdlib 4.0 drops support with Puppet 2.7
6
+ * stdlib 4.0 preserves support with Puppet 3
7
+
8
+ 2013-04-11 - Jeff McCune <jeff@puppetlabs.com> - 4.0.0
9
+ * Add ability to use puppet from git via bundler (9c5805f)
10
+
11
+ 2013-04-10 - Jeff McCune <jeff@puppetlabs.com> - 4.0.0
12
+ * (maint) Make stdlib usable as a Ruby GEM (e81a45e)
13
+
14
+ 2013-04-10 - Erik Dalén <dalen@spotify.com> - 4.0.0
15
+ * Add a count function (f28550e)
16
+
17
+ 2013-03-31 - Amos Shapira <ashapira@atlassian.com> - 4.0.0
18
+ * (#19998) Implement any2array (7a2fb80)
19
+
20
+ 2013-03-29 - Steve Huff <shuff@vecna.org> - 4.0.0
21
+ * (19864) num2bool match fix (8d217f0)
22
+
23
+ 2013-03-20 - Erik Dalén <dalen@spotify.com> - 4.0.0
24
+ * Allow comparisons of Numeric and number as String (ff5dd5d)
25
+
26
+ 2013-03-26 - Richard Soderberg <rsoderberg@mozilla.com> - 4.0.0
27
+ * add suffix function to accompany the prefix function (88a93ac)
28
+
29
+ 2013-03-19 - Kristof Willaert <kristof.willaert@gmail.com> - 4.0.0
30
+ * Add floor function implementation and unit tests (0527341)
31
+
32
+ 2012-04-03 - Eric Shamow <eric@puppetlabs.com> - 4.0.0
33
+ * (#13610) Add is_function_available to stdlib (961dcab)
34
+
35
+ 2012-12-17 - Justin Lambert <jlambert@eml.cc> - 4.0.0
36
+ * str2bool should return a boolean if called with a boolean (5d5a4d4)
37
+
38
+ 2012-10-23 - Uwe Stuehler <ustuehler@team.mobile.de> - 4.0.0
39
+ * Fix number of arguments check in flatten() (e80207b)
40
+
41
+ 2013-03-11 - Jeff McCune <jeff@puppetlabs.com> - 4.0.0
42
+ * Add contributing document (96e19d0)
43
+
44
+ 2013-03-04 - Raphaël Pinson <raphael.pinson@camptocamp.com> - 4.0.0
45
+ * Add missing documentation for validate_augeas and validate_cmd to README.markdown (a1510a1)
46
+
47
+ 2013-02-14 - Joshua Hoblitt <jhoblitt@cpan.org> - 4.0.0
48
+ * (#19272) Add has_element() function (95cf3fe)
49
+
50
+ 2013-02-07 - Raphaël Pinson <raphael.pinson@camptocamp.com> - 4.0.0
51
+ * validate_cmd(): Use Puppet::Util::Execution.execute when available (69248df)
52
+
53
+ 2012-12-06 - Raphaël Pinson <raphink@gmail.com> - 4.0.0
54
+ * Add validate_augeas function (3a97c23)
55
+
56
+ 2012-12-06 - Raphaël Pinson <raphink@gmail.com> - 4.0.0
57
+ * Add validate_cmd function (6902cc5)
58
+
59
+ 2013-01-14 - David Schmitt <david@dasz.at> - 4.0.0
60
+ * Add geppetto project definition (b3fc0a3)
61
+
62
+ 2013-01-02 - Jaka Hudoklin <jakahudoklin@gmail.com> - 4.0.0
63
+ * Add getparam function to get defined resource parameters (20e0e07)
64
+
65
+ 2013-01-05 - Jeff McCune <jeff@puppetlabs.com> - 4.0.0
66
+ * (maint) Add Travis CI Support (d082046)
67
+
68
+ 2012-12-04 - Jeff McCune <jeff@puppetlabs.com> - 4.0.0
69
+ * Clarify that stdlib 3 supports Puppet 3 (3a6085f)
70
+
71
+ 2012-11-30 - Erik Dalén <dalen@spotify.com> - 4.0.0
72
+ * maint: style guideline fixes (7742e5f)
73
+
74
+ 2012-11-09 - James Fryman <james@frymanet.com> - 4.0.0
75
+ * puppet-lint cleanup (88acc52)
76
+
77
+ 2012-11-06 - Joe Julian <me@joejulian.name> - 4.0.0
78
+ * Add function, uriescape, to URI.escape strings. Redmine #17459 (fd52b8d)
79
+
80
+ 2012-09-18 - Chad Metcalf <chad@wibidata.com> - 3.2.0
81
+ * Add an ensure_packages function. (8a8c09e)
82
+
83
+ 2012-11-23 - Erik Dalén <dalen@spotify.com> - 3.2.0
84
+ * (#17797) min() and max() functions (9954133)
85
+
86
+ 2012-05-23 - Peter Meier <peter.meier@immerda.ch> - 3.2.0
87
+ * (#14670) autorequire a file_line resource's path (dfcee63)
88
+
89
+ 2012-11-19 - Joshua Harlan Lifton <lifton@puppetlabs.com> - 3.2.0
90
+ * Add join_keys_to_values function (ee0f2b3)
91
+
92
+ 2012-11-17 - Joshua Harlan Lifton <lifton@puppetlabs.com> - 3.2.0
93
+ * Extend delete function for strings and hashes (7322e4d)
94
+
95
+ 2012-08-03 - Gary Larizza <gary@puppetlabs.com> - 3.2.0
96
+ * Add the pick() function (ba6dd13)
97
+
98
+ 2012-03-20 - Wil Cooley <wcooley@pdx.edu> - 3.2.0
99
+ * (#13974) Add predicate functions for interface facts (f819417)
100
+
101
+ 2012-11-06 - Joe Julian <me@joejulian.name> - 3.2.0
102
+ * Add function, uriescape, to URI.escape strings. Redmine #17459 (70f4a0e)
103
+
104
+ 2012-10-25 - Jeff McCune <jeff@puppetlabs.com> - 3.1.1
105
+ * (maint) Fix spec failures resulting from Facter API changes (97f836f)
106
+
107
+ 2012-10-23 - Matthaus Owens <matthaus@puppetlabs.com> - 3.1.0
108
+ * Add PE facts to stdlib (cdf3b05)
109
+
110
+ 2012-08-16 - Jeff McCune <jeff@puppetlabs.com> - 3.0.1
111
+ * Fix accidental removal of facts_dot_d.rb in 3.0.0 release
112
+
113
+ 2012-08-16 - Jeff McCune <jeff@puppetlabs.com> - 3.0.0
114
+ * stdlib 3.0 drops support with Puppet 2.6
115
+ * stdlib 3.0 preserves support with Puppet 2.7
116
+
117
+ 2012-08-07 - Dan Bode <dan@puppetlabs.com> - 3.0.0
118
+ * Add function ensure_resource and defined_with_params (ba789de)
119
+
120
+ 2012-07-10 - Hailee Kenney <hailee@puppetlabs.com> - 3.0.0
121
+ * (#2157) Remove facter_dot_d for compatibility with external facts (f92574f)
122
+
123
+ 2012-04-10 - Chris Price <chris@puppetlabs.com> - 3.0.0
124
+ * (#13693) moving logic from local spec_helper to puppetlabs_spec_helper (85f96df)
125
+
126
+ 2012-10-25 - Jeff McCune <jeff@puppetlabs.com> - 2.5.1
127
+ * (maint) Fix spec failures resulting from Facter API changes (97f836f)
128
+
129
+ 2012-10-23 - Matthaus Owens <matthaus@puppetlabs.com> - 2.5.0
130
+ * Add PE facts to stdlib (cdf3b05)
131
+
132
+ 2012-08-15 - Dan Bode <dan@puppetlabs.com> - 2.5.0
133
+ * Explicitly load functions used by ensure_resource (9fc3063)
134
+
135
+ 2012-08-13 - Dan Bode <dan@puppetlabs.com> - 2.5.0
136
+ * Add better docs about duplicate resource failures (97d327a)
137
+
138
+ 2012-08-13 - Dan Bode <dan@puppetlabs.com> - 2.5.0
139
+ * Handle undef for parameter argument (4f8b133)
140
+
141
+ 2012-08-07 - Dan Bode <dan@puppetlabs.com> - 2.5.0
142
+ * Add function ensure_resource and defined_with_params (a0cb8cd)
143
+
144
+ 2012-08-20 - Jeff McCune <jeff@puppetlabs.com> - 2.5.0
145
+ * Disable tests that fail on 2.6.x due to #15912 (c81496e)
146
+
147
+ 2012-08-20 - Jeff McCune <jeff@puppetlabs.com> - 2.5.0
148
+ * (Maint) Fix mis-use of rvalue functions as statements (4492913)
149
+
150
+ 2012-08-20 - Jeff McCune <jeff@puppetlabs.com> - 2.5.0
151
+ * Add .rspec file to repo root (88789e8)
152
+
153
+ 2012-06-07 - Chris Price <chris@puppetlabs.com> - 2.4.0
154
+ * Add support for a 'match' parameter to file_line (a06c0d8)
155
+
156
+ 2012-08-07 - Erik Dalén <dalen@spotify.com> - 2.4.0
157
+ * (#15872) Add to_bytes function (247b69c)
158
+
159
+ 2012-07-19 - Jeff McCune <jeff@puppetlabs.com> - 2.4.0
160
+ * (Maint) use PuppetlabsSpec::PuppetInternals.scope (master) (deafe88)
161
+
162
+ 2012-07-10 - Hailee Kenney <hailee@puppetlabs.com> - 2.4.0
163
+ * (#2157) Make facts_dot_d compatible with external facts (5fb0ddc)
164
+
165
+ 2012-03-16 - Steve Traylen <steve.traylen@cern.ch> - 2.4.0
166
+ * (#13205) Rotate array/string randomley based on fqdn, fqdn_rotate() (fef247b)
167
+
168
+ 2012-05-22 - Peter Meier <peter.meier@immerda.ch> - 2.3.3
169
+ * fix regression in #11017 properly (f0a62c7)
170
+
171
+ 2012-05-10 - Jeff McCune <jeff@puppetlabs.com> - 2.3.3
172
+ * Fix spec tests using the new spec_helper (7d34333)
173
+
174
+ 2012-05-10 - Puppet Labs <support@puppetlabs.com> - 2.3.2
175
+ * Make file_line default to ensure => present (1373e70)
176
+ * Memoize file_line spec instance variables (20aacc5)
177
+ * Fix spec tests using the new spec_helper (1ebfa5d)
178
+ * (#13595) initialize_everything_for_tests couples modules Puppet ver (3222f35)
179
+ * (#13439) Fix MRI 1.9 issue with spec_helper (15c5fd1)
180
+ * (#13439) Fix test failures with Puppet 2.6.x (665610b)
181
+ * (#13439) refactor spec helper for compatibility with both puppet 2.7 and master (82194ca)
182
+ * (#13494) Specify the behavior of zero padded strings (61891bb)
183
+
184
+ 2012-03-29 Puppet Labs <support@puppetlabs.com> - 2.1.3
185
+ * (#11607) Add Rakefile to enable spec testing
186
+ * (#12377) Avoid infinite loop when retrying require json
187
+
188
+ 2012-03-13 Puppet Labs <support@puppetlabs.com> - 2.3.1
189
+ * (#13091) Fix LoadError bug with puppet apply and puppet_vardir fact
190
+
191
+ 2012-03-12 Puppet Labs <support@puppetlabs.com> - 2.3.0
192
+ * Add a large number of new Puppet functions
193
+ * Backwards compatibility preserved with 2.2.x
194
+
195
+ 2011-12-30 Puppet Labs <support@puppetlabs.com> - 2.2.1
196
+ * Documentation only release for the Forge
197
+
198
+ 2011-12-30 Puppet Labs <support@puppetlabs.com> - 2.1.2
199
+ * Documentation only release for PE 2.0.x
200
+
201
+ 2011-11-08 Puppet Labs <support@puppetlabs.com> - 2.2.0
202
+ * #10285 - Refactor json to use pson instead.
203
+ * Maint - Add watchr autotest script
204
+ * Maint - Make rspec tests work with Puppet 2.6.4
205
+ * #9859 - Add root_home fact and tests
206
+
207
+ 2011-08-18 Puppet Labs <support@puppetlabs.com> - 2.1.1
208
+ * Change facts.d paths to match Facter 2.0 paths.
209
+ * /etc/facter/facts.d
210
+ * /etc/puppetlabs/facter/facts.d
211
+
212
+ 2011-08-17 Puppet Labs <support@puppetlabs.com> - 2.1.0
213
+ * Add R.I. Pienaar's facts.d custom facter fact
214
+ * facts defined in /etc/facts.d and /etc/puppetlabs/facts.d are
215
+ automatically loaded now.
216
+
217
+ 2011-08-04 Puppet Labs <support@puppetlabs.com> - 2.0.0
218
+ * Rename whole_line to file_line
219
+ * This is an API change and as such motivating a 2.0.0 release according to semver.org.
220
+
221
+ 2011-08-04 Puppet Labs <support@puppetlabs.com> - 1.1.0
222
+ * Rename append_line to whole_line
223
+ * This is an API change and as such motivating a 1.1.0 release.
224
+
225
+ 2011-08-04 Puppet Labs <support@puppetlabs.com> - 1.0.0
226
+ * Initial stable release
227
+ * Add validate_array and validate_string functions
228
+ * Make merge() function work with Ruby 1.8.5
229
+ * Add hash merging function
230
+ * Add has_key function
231
+ * Add loadyaml() function
232
+ * Add append_line native
233
+
234
+ 2011-06-21 Jeff McCune <jeff@puppetlabs.com> - 0.1.7
235
+ * Add validate_hash() and getvar() functions
236
+
237
+ 2011-06-15 Jeff McCune <jeff@puppetlabs.com> - 0.1.6
238
+ * Add anchor resource type to provide containment for composite classes
239
+
240
+ 2011-06-03 Jeff McCune <jeff@puppetlabs.com> - 0.1.5
241
+ * Add validate_bool() function to stdlib
242
+
243
+ 0.1.4 2011-05-26 Jeff McCune <jeff@puppetlabs.com>
244
+ * Move most stages after main
245
+
246
+ 0.1.3 2011-05-25 Jeff McCune <jeff@puppetlabs.com>
247
+ * Add validate_re() function
248
+
249
+ 0.1.2 2011-05-24 Jeff McCune <jeff@puppetlabs.com>
250
+ * Update to add annotated tag
251
+
252
+ 0.1.1 2011-05-24 Jeff McCune <jeff@puppetlabs.com>
253
+ * Add stdlib::stages class with a standard set of stages
@@ -0,0 +1,65 @@
1
+ # How to contribute
2
+
3
+ Third-party patches are essential for keeping stdlib great. We simply can't
4
+ access the huge number of platforms and myriad configurations for running
5
+ stdlib. We want to keep it as easy as possible to contribute changes that
6
+ get things working in your environment. There are a few guidelines that we
7
+ need contributors to follow so that we can have a chance of keeping on
8
+ top of things.
9
+
10
+ ## Getting Started
11
+
12
+ * Make sure you have a [Redmine account](http://projects.puppetlabs.com)
13
+ * Make sure you have a [GitHub account](https://github.com/signup/free)
14
+ * Submit a ticket for your issue, assuming one does not already exist.
15
+ * Clearly describe the issue including steps to reproduce when it is a bug.
16
+ * Make sure you fill in the earliest version that you know has the issue.
17
+ * Fork the repository on GitHub
18
+
19
+ ## Making Changes
20
+
21
+ * Create a topic branch from where you want to base your work.
22
+ * This is usually the master branch.
23
+ * Only target release branches if you are certain your fix must be on that
24
+ branch.
25
+ * To quickly create a topic branch based on master; `git branch
26
+ fix/master/my_contribution master` then checkout the new branch with `git
27
+ checkout fix/master/my_contribution`. Please avoid working directly on the
28
+ `master` branch.
29
+ * Make commits of logical units.
30
+ * Check for unnecessary whitespace with `git diff --check` before committing.
31
+ * Make sure your commit messages are in the proper format.
32
+
33
+ ````
34
+ (#99999) Make the example in CONTRIBUTING imperative and concrete
35
+
36
+ Without this patch applied the example commit message in the CONTRIBUTING
37
+ document is not a concrete example. This is a problem because the
38
+ contributor is left to imagine what the commit message should look like
39
+ based on a description rather than an example. This patch fixes the
40
+ problem by making the example concrete and imperative.
41
+
42
+ The first line is a real life imperative statement with a ticket number
43
+ from our issue tracker. The body describes the behavior without the patch,
44
+ why this is a problem, and how the patch fixes the problem when applied.
45
+ ````
46
+
47
+ * Make sure you have added the necessary tests for your changes.
48
+ * Run _all_ the tests to assure nothing else was accidentally broken.
49
+
50
+ ## Submitting Changes
51
+
52
+ * Sign the [Contributor License Agreement](http://links.puppetlabs.com/cla).
53
+ * Push your changes to a topic branch in your fork of the repository.
54
+ * Submit a pull request to the repository in the puppetlabs organization.
55
+ * Update your Redmine ticket to mark that you have submitted code and are ready for it to be reviewed.
56
+ * Include a link to the pull request in the ticket
57
+
58
+ # Additional Resources
59
+
60
+ * [More information on contributing](http://links.puppetlabs.com/contribute-to-puppet)
61
+ * [Bug tracker (Redmine)](http://projects.puppetlabs.com)
62
+ * [Contributor License Agreement](http://links.puppetlabs.com/cla)
63
+ * [General GitHub documentation](http://help.github.com/)
64
+ * [GitHub pull request documentation](http://help.github.com/send-pull-requests/)
65
+ * #puppet-dev IRC channel on freenode.org
data/Gemfile ADDED
@@ -0,0 +1,33 @@
1
+ source "https://rubygems.org"
2
+
3
+ def location_for(place, fake_version = nil)
4
+ mdata = /^(git:[^#]*)#(.*)/.match(place)
5
+ if mdata
6
+ [fake_version, { :git => mdata[1], :branch => mdata[2], :require => false }].compact
7
+ elsif place =~ /^file:\/\/(.*)/
8
+ ['>= 0', { :path => File.expand_path(mdata[1]), :require => false }]
9
+ else
10
+ [place, { :require => false }]
11
+ end
12
+ end
13
+
14
+ group :development do
15
+ gem 'watchr'
16
+ end
17
+
18
+ group :development, :test do
19
+ gem 'rake'
20
+ gem 'puppetmodule-stdlib', ">= 1.0.0", :path => File.expand_path("..", __FILE__)
21
+ gem 'rspec', "~> 2.11.0", :require => false
22
+ gem 'mocha', "~> 0.10.5", :require => false
23
+ gem 'puppetlabs_spec_helper', :require => false
24
+ gem 'rspec-puppet', :require => false
25
+ end
26
+
27
+ if puppetversion = ENV['PUPPET_GEM_VERSION']
28
+ gem 'puppet', *location_for(puppetversion)
29
+ else
30
+ gem 'puppet', :require => false
31
+ end
32
+
33
+ # vim:ft=ruby
data/LICENSE ADDED
@@ -0,0 +1,19 @@
1
+ Copyright (C) 2011 Puppet Labs Inc
2
+
3
+ and some parts:
4
+
5
+ Copyright (C) 2011 Krzysztof Wilczynski
6
+
7
+ Puppet Labs can be contacted at: info@puppetlabs.com
8
+
9
+ Licensed under the Apache License, Version 2.0 (the "License");
10
+ you may not use this file except in compliance with the License.
11
+ You may obtain a copy of the License at
12
+
13
+ http://www.apache.org/licenses/LICENSE-2.0
14
+
15
+ Unless required by applicable law or agreed to in writing, software
16
+ distributed under the License is distributed on an "AS IS" BASIS,
17
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18
+ See the License for the specific language governing permissions and
19
+ limitations under the License.
@@ -0,0 +1,11 @@
1
+ name 'puppetlabs-stdlib'
2
+ version '4.0.1'
3
+ source 'git://github.com/puppetlabs/puppetlabs-stdlib.git'
4
+ author 'puppetlabs'
5
+ license 'Apache 2.0'
6
+ summary 'Puppet Module Standard Library'
7
+ description 'Standard Library for Puppet Modules'
8
+ project_page 'https://github.com/puppetlabs/puppetlabs-stdlib'
9
+
10
+ ## Add dependencies, if any:
11
+ # dependency 'username/name', '>= 1.2.0'
@@ -0,0 +1,1173 @@
1
+ # Puppet Labs Standard Library #
2
+
3
+ [![Build Status](https://travis-ci.org/puppetlabs/puppetlabs-stdlib.png?branch=master)](https://travis-ci.org/puppetlabs/puppetlabs-stdlib)
4
+
5
+ This module provides a "standard library" of resources for developing Puppet
6
+ Modules. This modules will include the following additions to Puppet
7
+
8
+ * Stages
9
+ * Facts
10
+ * Functions
11
+ * Defined resource types
12
+ * Types
13
+ * Providers
14
+
15
+ This module is officially curated and provided by Puppet Labs. The modules
16
+ Puppet Labs writes and distributes will make heavy use of this standard
17
+ library.
18
+
19
+ To report or research a bug with any part of this module, please go to
20
+ [http://projects.puppetlabs.com/projects/stdlib](http://projects.puppetlabs.com/projects/stdlib)
21
+
22
+ # Versions #
23
+
24
+ This module follows semver.org (v1.0.0) versioning guidelines. The standard
25
+ library module is released as part of [Puppet
26
+ Enterprise](http://puppetlabs.com/puppet/puppet-enterprise/) and as a result
27
+ older versions of Puppet Enterprise that Puppet Labs still supports will have
28
+ bugfix maintenance branches periodically "merged up" into master. The current
29
+ list of integration branches are:
30
+
31
+ * v2.1.x (v2.1.1 released in PE 1)
32
+ * v2.2.x (Never released as part of PE, only to the Forge)
33
+ * v2.3.x (Released in PE 2)
34
+ * v3.0.x (Never released as part of PE, only to the Forge)
35
+ * v4.0.x (Drops support for Puppet 2.7)
36
+ * master (mainline development branch)
37
+
38
+ The first Puppet Enterprise version including the stdlib module is Puppet
39
+ Enterprise 1.2.
40
+
41
+ # Compatibility #
42
+
43
+ The stdlib module does not work with Puppet versions released prior to Puppet
44
+ 2.6.0.
45
+
46
+ ## stdlib 2.x ##
47
+
48
+ All stdlib releases in the 2.0 major version support Puppet 2.6 and Puppet 2.7.
49
+
50
+ ## stdlib 3.x ##
51
+
52
+ The 3.0 major release of stdlib drops support for Puppet 2.6. Stdlib 3.x
53
+ supports Puppet 2 and Puppet 3.
54
+
55
+ ## stdlib 4.x ##
56
+
57
+ The 4.0 major release of stdlib drops support for Puppet 2.7. Stdlib 4.x
58
+ supports Puppet 3. Notably, ruby 1.8.5 is no longer supported though ruby
59
+ 1.8.7, 1.9.3, and 2.0.0 are fully supported.
60
+
61
+ # Functions #
62
+
63
+ abs
64
+ ---
65
+ Returns the absolute value of a number, for example -34.56 becomes
66
+ 34.56. Takes a single integer and float value as an argument.
67
+
68
+
69
+ - *Type*: rvalue
70
+
71
+ any2array
72
+ ---------
73
+ This converts any object to an array containing that object. Empty argument
74
+ lists are converted to an empty array. Arrays are left untouched. Hashes are
75
+ converted to arrays of alternating keys and values.
76
+
77
+
78
+ - *Type*: rvalue
79
+
80
+ bool2num
81
+ --------
82
+ Converts a boolean to a number. Converts the values:
83
+ false, f, 0, n, and no to 0
84
+ true, t, 1, y, and yes to 1
85
+ Requires a single boolean or string as an input.
86
+
87
+
88
+ - *Type*: rvalue
89
+
90
+ capitalize
91
+ ----------
92
+ Capitalizes the first letter of a string or array of strings.
93
+ Requires either a single string or an array as an input.
94
+
95
+
96
+ - *Type*: rvalue
97
+
98
+ chomp
99
+ -----
100
+ Removes the record separator from the end of a string or an array of
101
+ strings, for example `hello\n` becomes `hello`.
102
+ Requires a single string or array as an input.
103
+
104
+
105
+ - *Type*: rvalue
106
+
107
+ chop
108
+ ----
109
+ Returns a new string with the last character removed. If the string ends
110
+ with `\r\n`, both characters are removed. Applying chop to an empty
111
+ string returns an empty string. If you wish to merely remove record
112
+ separators then you should use the `chomp` function.
113
+ Requires a string or array of strings as input.
114
+
115
+
116
+ - *Type*: rvalue
117
+
118
+ concat
119
+ ------
120
+ Appends the contents of array 2 onto array 1.
121
+
122
+ *Example:*
123
+
124
+ concat(['1','2','3'],['4','5','6'])
125
+
126
+ Would result in:
127
+
128
+ ['1','2','3','4','5','6']
129
+
130
+
131
+ - *Type*: rvalue
132
+
133
+ count
134
+ -----
135
+ Takes an array as first argument and an optional second argument.
136
+ Count the number of elements in array that matches second argument.
137
+ If called with only an array it counts the number of elements that are not nil/undef.
138
+
139
+
140
+ - *Type*: rvalue
141
+
142
+ defined_with_params
143
+ -------------------
144
+ Takes a resource reference and an optional hash of attributes.
145
+
146
+ Returns true if a resource with the specified attributes has already been added
147
+ to the catalog, and false otherwise.
148
+
149
+ user { 'dan':
150
+ ensure => present,
151
+ }
152
+
153
+ if ! defined_with_params(User[dan], {'ensure' => 'present' }) {
154
+ user { 'dan': ensure => present, }
155
+ }
156
+
157
+
158
+ - *Type*: rvalue
159
+
160
+ delete
161
+ ------
162
+ Deletes all instances of a given element from an array, substring from a
163
+ string, or key from a hash.
164
+
165
+ *Examples:*
166
+
167
+ delete(['a','b','c','b'], 'b')
168
+ Would return: ['a','c']
169
+
170
+ delete({'a'=>1,'b'=>2,'c'=>3}, 'b')
171
+ Would return: {'a'=>1,'c'=>3}
172
+
173
+ delete('abracadabra', 'bra')
174
+ Would return: 'acada'
175
+
176
+
177
+ - *Type*: rvalue
178
+
179
+ delete_at
180
+ ---------
181
+ Deletes a determined indexed value from an array.
182
+
183
+ *Examples:*
184
+
185
+ delete_at(['a','b','c'], 1)
186
+
187
+ Would return: ['a','c']
188
+
189
+
190
+ - *Type*: rvalue
191
+
192
+ downcase
193
+ --------
194
+ Converts the case of a string or all strings in an array to lower case.
195
+
196
+
197
+ - *Type*: rvalue
198
+
199
+ empty
200
+ -----
201
+ Returns true if the variable is empty.
202
+
203
+
204
+ - *Type*: rvalue
205
+
206
+ ensure_packages
207
+ ---------------
208
+ Takes a list of packages and only installs them if they don't already exist.
209
+
210
+
211
+ - *Type*: statement
212
+
213
+ ensure_resource
214
+ ---------------
215
+ Takes a resource type, title, and a list of attributes that describe a
216
+ resource.
217
+
218
+ user { 'dan':
219
+ ensure => present,
220
+ }
221
+
222
+ This example only creates the resource if it does not already exist:
223
+
224
+ ensure_resource('user, 'dan', {'ensure' => 'present' })
225
+
226
+ If the resource already exists but does not match the specified parameters,
227
+ this function will attempt to recreate the resource leading to a duplicate
228
+ resource definition error.
229
+
230
+
231
+
232
+ - *Type*: statement
233
+
234
+ flatten
235
+ -------
236
+ This function flattens any deeply nested arrays and returns a single flat array
237
+ as a result.
238
+
239
+ *Examples:*
240
+
241
+ flatten(['a', ['b', ['c']]])
242
+
243
+ Would return: ['a','b','c']
244
+
245
+
246
+ - *Type*: rvalue
247
+
248
+ floor
249
+ -----
250
+ Returns the largest integer less or equal to the argument.
251
+ Takes a single numeric value as an argument.
252
+
253
+
254
+ - *Type*: rvalue
255
+
256
+ fqdn_rotate
257
+ -----------
258
+ Rotates an array a random number of times based on a nodes fqdn.
259
+
260
+
261
+ - *Type*: rvalue
262
+
263
+ get_module_path
264
+ ---------------
265
+ Returns the absolute path of the specified module for the current
266
+ environment.
267
+
268
+ Example:
269
+ $module_path = get_module_path('stdlib')
270
+
271
+
272
+ - *Type*: rvalue
273
+
274
+ getparam
275
+ --------
276
+ Takes a resource reference and name of the parameter and
277
+ returns value of resource's parameter.
278
+
279
+ *Examples:*
280
+
281
+ define example_resource($param) {
282
+ }
283
+
284
+ example_resource { "example_resource_instance":
285
+ param => "param_value"
286
+ }
287
+
288
+ getparam(Example_resource["example_resource_instance"], "param")
289
+
290
+ Would return: param_value
291
+
292
+
293
+ - *Type*: rvalue
294
+
295
+ getvar
296
+ ------
297
+ Lookup a variable in a remote namespace.
298
+
299
+ For example:
300
+
301
+ $foo = getvar('site::data::foo')
302
+ # Equivalent to $foo = $site::data::foo
303
+
304
+ This is useful if the namespace itself is stored in a string:
305
+
306
+ $datalocation = 'site::data'
307
+ $bar = getvar("${datalocation}::bar")
308
+ # Equivalent to $bar = $site::data::bar
309
+
310
+
311
+ - *Type*: rvalue
312
+
313
+ grep
314
+ ----
315
+ This function searches through an array and returns any elements that match
316
+ the provided regular expression.
317
+
318
+ *Examples:*
319
+
320
+ grep(['aaa','bbb','ccc','aaaddd'], 'aaa')
321
+
322
+ Would return:
323
+
324
+ ['aaa','aaaddd']
325
+
326
+
327
+ - *Type*: rvalue
328
+
329
+ has_interface_with
330
+ ------------------
331
+ Returns boolean based on kind and value:
332
+ * macaddress
333
+ * netmask
334
+ * ipaddress
335
+ * network
336
+
337
+ has_interface_with("macaddress", "x:x:x:x:x:x")
338
+ has_interface_with("ipaddress", "127.0.0.1") => true
339
+ etc.
340
+
341
+ If no "kind" is given, then the presence of the interface is checked:
342
+ has_interface_with("lo") => true
343
+
344
+
345
+ - *Type*: rvalue
346
+
347
+ has_ip_address
348
+ --------------
349
+ Returns true if the client has the requested IP address on some interface.
350
+
351
+ This function iterates through the 'interfaces' fact and checks the
352
+ 'ipaddress_IFACE' facts, performing a simple string comparison.
353
+
354
+
355
+ - *Type*: rvalue
356
+
357
+ has_ip_network
358
+ --------------
359
+ Returns true if the client has an IP address within the requested network.
360
+
361
+ This function iterates through the 'interfaces' fact and checks the
362
+ 'network_IFACE' facts, performing a simple string comparision.
363
+
364
+
365
+ - *Type*: rvalue
366
+
367
+ has_key
368
+ -------
369
+ Determine if a hash has a certain key value.
370
+
371
+ Example:
372
+
373
+ $my_hash = {'key_one' => 'value_one'}
374
+ if has_key($my_hash, 'key_two') {
375
+ notice('we will not reach here')
376
+ }
377
+ if has_key($my_hash, 'key_one') {
378
+ notice('this will be printed')
379
+ }
380
+
381
+
382
+
383
+ - *Type*: rvalue
384
+
385
+ hash
386
+ ----
387
+ This function converts and array into a hash.
388
+
389
+ *Examples:*
390
+
391
+ hash(['a',1,'b',2,'c',3])
392
+
393
+ Would return: {'a'=>1,'b'=>2,'c'=>3}
394
+
395
+
396
+ - *Type*: rvalue
397
+
398
+ is_array
399
+ --------
400
+ Returns true if the variable passed to this function is an array.
401
+
402
+ - *Type*: rvalue
403
+
404
+ is_domain_name
405
+ --------------
406
+ Returns true if the string passed to this function is a syntactically correct domain name.
407
+
408
+ - *Type*: rvalue
409
+
410
+ is_float
411
+ --------
412
+ Returns true if the variable passed to this function is a float.
413
+
414
+ - *Type*: rvalue
415
+
416
+ is_function_available
417
+ ---------------------
418
+ This function accepts a string as an argument, determines whether the
419
+ Puppet runtime has access to a function by that name. It returns a
420
+ true if the function exists, false if not.
421
+
422
+ - *Type*: rvalue
423
+
424
+ is_hash
425
+ -------
426
+ Returns true if the variable passed to this function is a hash.
427
+
428
+ - *Type*: rvalue
429
+
430
+ is_integer
431
+ ----------
432
+ Returns true if the variable returned to this string is an integer.
433
+
434
+ - *Type*: rvalue
435
+
436
+ is_ip_address
437
+ -------------
438
+ Returns true if the string passed to this function is a valid IP address.
439
+
440
+ - *Type*: rvalue
441
+
442
+ is_mac_address
443
+ --------------
444
+ Returns true if the string passed to this function is a valid mac address.
445
+
446
+ - *Type*: rvalue
447
+
448
+ is_numeric
449
+ ----------
450
+ Returns true if the variable passed to this function is a number.
451
+
452
+ - *Type*: rvalue
453
+
454
+ is_string
455
+ ---------
456
+ Returns true if the variable passed to this function is a string.
457
+
458
+ - *Type*: rvalue
459
+
460
+ join
461
+ ----
462
+ This function joins an array into a string using a seperator.
463
+
464
+ *Examples:*
465
+
466
+ join(['a','b','c'], ",")
467
+
468
+ Would result in: "a,b,c"
469
+
470
+ - *Type*: rvalue
471
+
472
+ join_keys_to_values
473
+ -------------------
474
+ This function joins each key of a hash to that key's corresponding value with a
475
+ separator. Keys and values are cast to strings. The return value is an array in
476
+ which each element is one joined key/value pair.
477
+
478
+ *Examples:*
479
+
480
+ join_keys_to_values({'a'=>1,'b'=>2}, " is ")
481
+
482
+ Would result in: ["a is 1","b is 2"]
483
+
484
+ - *Type*: rvalue
485
+
486
+ keys
487
+ ----
488
+ Returns the keys of a hash as an array.
489
+
490
+ - *Type*: rvalue
491
+
492
+ loadyaml
493
+ --------
494
+ Load a YAML file containing an array, string, or hash, and return the data
495
+ in the corresponding native data type.
496
+
497
+ For example:
498
+
499
+ $myhash = loadyaml('/etc/puppet/data/myhash.yaml')
500
+
501
+
502
+ - *Type*: rvalue
503
+
504
+ lstrip
505
+ ------
506
+ Strips leading spaces to the left of a string.
507
+
508
+ - *Type*: rvalue
509
+
510
+ max
511
+ ---
512
+ Returns the highest value of all arguments.
513
+ Requires at least one argument.
514
+
515
+ - *Type*: rvalue
516
+
517
+ member
518
+ ------
519
+ This function determines if a variable is a member of an array.
520
+
521
+ *Examples:*
522
+
523
+ member(['a','b'], 'b')
524
+
525
+ Would return: true
526
+
527
+ member(['a','b'], 'c')
528
+
529
+ Would return: false
530
+
531
+ - *Type*: rvalue
532
+
533
+ merge
534
+ -----
535
+ Merges two or more hashes together and returns the resulting hash.
536
+
537
+ For example:
538
+
539
+ $hash1 = {'one' => 1, 'two', => 2}
540
+ $hash2 = {'two' => 'dos', 'three', => 'tres'}
541
+ $merged_hash = merge($hash1, $hash2)
542
+ # The resulting hash is equivalent to:
543
+ # $merged_hash = {'one' => 1, 'two' => 'dos', 'three' => 'tres'}
544
+
545
+ When there is a duplicate key, the key in the rightmost hash will "win."
546
+
547
+ - *Type*: rvalue
548
+
549
+ min
550
+ ---
551
+ Returns the lowest value of all arguments.
552
+ Requires at least one argument.
553
+
554
+ - *Type*: rvalue
555
+
556
+ num2bool
557
+ --------
558
+ This function converts a number or a string representation of a number into a
559
+ true boolean. Zero or anything non-numeric becomes false. Numbers higher then 0
560
+ become true.
561
+
562
+ - *Type*: rvalue
563
+
564
+ parsejson
565
+ ---------
566
+ This function accepts JSON as a string and converts into the correct Puppet
567
+ structure.
568
+
569
+ - *Type*: rvalue
570
+
571
+ parseyaml
572
+ ---------
573
+ This function accepts YAML as a string and converts it into the correct
574
+ Puppet structure.
575
+
576
+ - *Type*: rvalue
577
+
578
+ pick
579
+ ----
580
+ This function is similar to a coalesce function in SQL in that it will return
581
+ the first value in a list of values that is not undefined or an empty string
582
+ (two things in Puppet that will return a boolean false value). Typically,
583
+ this function is used to check for a value in the Puppet Dashboard/Enterprise
584
+ Console, and failover to a default value like the following:
585
+
586
+ $real_jenkins_version = pick($::jenkins_version, '1.449')
587
+
588
+ The value of $real_jenkins_version will first look for a top-scope variable
589
+ called 'jenkins_version' (note that parameters set in the Puppet Dashboard/
590
+ Enterprise Console are brought into Puppet as top-scope variables), and,
591
+ failing that, will use a default value of 1.449.
592
+
593
+ - *Type*: rvalue
594
+
595
+ prefix
596
+ ------
597
+ This function applies a prefix to all elements in an array.
598
+
599
+ *Examples:*
600
+
601
+ prefix(['a','b','c'], 'p')
602
+
603
+ Will return: ['pa','pb','pc']
604
+
605
+ - *Type*: rvalue
606
+
607
+ range
608
+ -----
609
+ When given range in the form of (start, stop) it will extrapolate a range as
610
+ an array.
611
+
612
+ *Examples:*
613
+
614
+ range("0", "9")
615
+
616
+ Will return: [0,1,2,3,4,5,6,7,8,9]
617
+
618
+ range("00", "09")
619
+
620
+ Will return: [0,1,2,3,4,5,6,7,8,9] (Zero padded strings are converted to
621
+ integers automatically)
622
+
623
+ range("a", "c")
624
+
625
+ Will return: ["a","b","c"]
626
+
627
+ range("host01", "host10")
628
+
629
+ Will return: ["host01", "host02", ..., "host09", "host10"]
630
+
631
+ - *Type*: rvalue
632
+
633
+ reject
634
+ ------
635
+ This function searches through an array and rejects all elements that match
636
+ the provided regular expression.
637
+
638
+ *Examples:*
639
+
640
+ reject(['aaa','bbb','ccc','aaaddd'], 'aaa')
641
+
642
+ Would return:
643
+
644
+ ['bbb','ccc']
645
+
646
+
647
+ - *Type*: rvalue
648
+
649
+ reverse
650
+ -------
651
+ Reverses the order of a string or array.
652
+
653
+ - *Type*: rvalue
654
+
655
+ rstrip
656
+ ------
657
+ Strips leading spaces to the right of the string.
658
+
659
+ - *Type*: rvalue
660
+
661
+ shuffle
662
+ -------
663
+ Randomizes the order of a string or array elements.
664
+
665
+ - *Type*: rvalue
666
+
667
+ size
668
+ ----
669
+ Returns the number of elements in a string or array.
670
+
671
+ - *Type*: rvalue
672
+
673
+ sort
674
+ ----
675
+ Sorts strings and arrays lexically.
676
+
677
+ - *Type*: rvalue
678
+
679
+ squeeze
680
+ -------
681
+ Returns a new string where runs of the same character that occur in this set
682
+ are replaced by a single character.
683
+
684
+ - *Type*: rvalue
685
+
686
+ str2bool
687
+ --------
688
+ This converts a string to a boolean. This attempt to convert strings that
689
+ contain things like: y, 1, t, true to 'true' and strings that contain things
690
+ like: 0, f, n, false, no to 'false'.
691
+
692
+
693
+ - *Type*: rvalue
694
+
695
+ str2saltedsha512
696
+ ----------------
697
+ This converts a string to a salted-SHA512 password hash (which is used for
698
+ OS X versions >= 10.7). Given any simple string, you will get a hex version
699
+ of a salted-SHA512 password hash that can be inserted into your Puppet
700
+ manifests as a valid password attribute.
701
+
702
+
703
+ - *Type*: rvalue
704
+
705
+ strftime
706
+ --------
707
+ This function returns formatted time.
708
+
709
+ *Examples:*
710
+
711
+ To return the time since epoch:
712
+
713
+ strftime("%s")
714
+
715
+ To return the date:
716
+
717
+ strftime("%Y-%m-%d")
718
+
719
+ *Format meaning:*
720
+
721
+ %a - The abbreviated weekday name (``Sun'')
722
+ %A - The full weekday name (``Sunday'')
723
+ %b - The abbreviated month name (``Jan'')
724
+ %B - The full month name (``January'')
725
+ %c - The preferred local date and time representation
726
+ %C - Century (20 in 2009)
727
+ %d - Day of the month (01..31)
728
+ %D - Date (%m/%d/%y)
729
+ %e - Day of the month, blank-padded ( 1..31)
730
+ %F - Equivalent to %Y-%m-%d (the ISO 8601 date format)
731
+ %h - Equivalent to %b
732
+ %H - Hour of the day, 24-hour clock (00..23)
733
+ %I - Hour of the day, 12-hour clock (01..12)
734
+ %j - Day of the year (001..366)
735
+ %k - hour, 24-hour clock, blank-padded ( 0..23)
736
+ %l - hour, 12-hour clock, blank-padded ( 0..12)
737
+ %L - Millisecond of the second (000..999)
738
+ %m - Month of the year (01..12)
739
+ %M - Minute of the hour (00..59)
740
+ %n - Newline (
741
+ )
742
+ %N - Fractional seconds digits, default is 9 digits (nanosecond)
743
+ %3N millisecond (3 digits)
744
+ %6N microsecond (6 digits)
745
+ %9N nanosecond (9 digits)
746
+ %p - Meridian indicator (``AM'' or ``PM'')
747
+ %P - Meridian indicator (``am'' or ``pm'')
748
+ %r - time, 12-hour (same as %I:%M:%S %p)
749
+ %R - time, 24-hour (%H:%M)
750
+ %s - Number of seconds since 1970-01-01 00:00:00 UTC.
751
+ %S - Second of the minute (00..60)
752
+ %t - Tab character ( )
753
+ %T - time, 24-hour (%H:%M:%S)
754
+ %u - Day of the week as a decimal, Monday being 1. (1..7)
755
+ %U - Week number of the current year,
756
+ starting with the first Sunday as the first
757
+ day of the first week (00..53)
758
+ %v - VMS date (%e-%b-%Y)
759
+ %V - Week number of year according to ISO 8601 (01..53)
760
+ %W - Week number of the current year,
761
+ starting with the first Monday as the first
762
+ day of the first week (00..53)
763
+ %w - Day of the week (Sunday is 0, 0..6)
764
+ %x - Preferred representation for the date alone, no time
765
+ %X - Preferred representation for the time alone, no date
766
+ %y - Year without a century (00..99)
767
+ %Y - Year with century
768
+ %z - Time zone as hour offset from UTC (e.g. +0900)
769
+ %Z - Time zone name
770
+ %% - Literal ``%'' character
771
+
772
+
773
+ - *Type*: rvalue
774
+
775
+ strip
776
+ -----
777
+ This function removes leading and trailing whitespace from a string or from
778
+ every string inside an array.
779
+
780
+ *Examples:*
781
+
782
+ strip(" aaa ")
783
+
784
+ Would result in: "aaa"
785
+
786
+
787
+ - *Type*: rvalue
788
+
789
+ suffix
790
+ ------
791
+ This function applies a suffix to all elements in an array.
792
+
793
+ *Examples:*
794
+
795
+ suffix(['a','b','c'], 'p')
796
+
797
+ Will return: ['ap','bp','cp']
798
+
799
+
800
+ - *Type*: rvalue
801
+
802
+ swapcase
803
+ --------
804
+ This function will swap the existing case of a string.
805
+
806
+ *Examples:*
807
+
808
+ swapcase("aBcD")
809
+
810
+ Would result in: "AbCd"
811
+
812
+
813
+ - *Type*: rvalue
814
+
815
+ time
816
+ ----
817
+ This function will return the current time since epoch as an integer.
818
+
819
+ *Examples:*
820
+
821
+ time()
822
+
823
+ Will return something like: 1311972653
824
+
825
+
826
+ - *Type*: rvalue
827
+
828
+ to_bytes
829
+ --------
830
+ Converts the argument into bytes, for example 4 kB becomes 4096.
831
+ Takes a single string value as an argument.
832
+
833
+
834
+ - *Type*: rvalue
835
+
836
+ type
837
+ ----
838
+ Returns the type when passed a variable. Type can be one of:
839
+
840
+ * string
841
+ * array
842
+ * hash
843
+ * float
844
+ * integer
845
+ * boolean
846
+
847
+
848
+ - *Type*: rvalue
849
+
850
+ unique
851
+ ------
852
+ This function will remove duplicates from strings and arrays.
853
+
854
+ *Examples:*
855
+
856
+ unique("aabbcc")
857
+
858
+ Will return:
859
+
860
+ abc
861
+
862
+ You can also use this with arrays:
863
+
864
+ unique(["a","a","b","b","c","c"])
865
+
866
+ This returns:
867
+
868
+ ["a","b","c"]
869
+
870
+
871
+ - *Type*: rvalue
872
+
873
+ upcase
874
+ ------
875
+ Converts a string or an array of strings to uppercase.
876
+
877
+ *Examples:*
878
+
879
+ upcase("abcd")
880
+
881
+ Will return:
882
+
883
+ ASDF
884
+
885
+
886
+ - *Type*: rvalue
887
+
888
+ uriescape
889
+ ---------
890
+ Urlencodes a string or array of strings.
891
+ Requires either a single string or an array as an input.
892
+
893
+
894
+ - *Type*: rvalue
895
+
896
+ validate_absolute_path
897
+ ----------------------
898
+ Validate the string represents an absolute path in the filesystem. This function works
899
+ for windows and unix style paths.
900
+
901
+ The following values will pass:
902
+
903
+ $my_path = "C:/Program Files (x86)/Puppet Labs/Puppet"
904
+ validate_absolute_path($my_path)
905
+ $my_path2 = "/var/lib/puppet"
906
+ validate_absolute_path($my_path2)
907
+
908
+
909
+ The following values will fail, causing compilation to abort:
910
+
911
+ validate_absolute_path(true)
912
+ validate_absolute_path([ 'var/lib/puppet', '/var/foo' ])
913
+ validate_absolute_path([ '/var/lib/puppet', 'var/foo' ])
914
+ $undefined = undef
915
+ validate_absolute_path($undefined)
916
+
917
+
918
+
919
+ - *Type*: statement
920
+
921
+ validate_array
922
+ --------------
923
+ Validate that all passed values are array data structures. Abort catalog
924
+ compilation if any value fails this check.
925
+
926
+ The following values will pass:
927
+
928
+ $my_array = [ 'one', 'two' ]
929
+ validate_array($my_array)
930
+
931
+ The following values will fail, causing compilation to abort:
932
+
933
+ validate_array(true)
934
+ validate_array('some_string')
935
+ $undefined = undef
936
+ validate_array($undefined)
937
+
938
+
939
+
940
+ - *Type*: statement
941
+
942
+ validate_augeas
943
+ ---------------
944
+ Perform validation of a string using an Augeas lens
945
+ The first argument of this function should be a string to
946
+ test, and the second argument should be the name of the Augeas lens to use.
947
+ If Augeas fails to parse the string with the lens, the compilation will
948
+ abort with a parse error.
949
+
950
+ A third argument can be specified, listing paths which should
951
+ not be found in the file. The `$file` variable points to the location
952
+ of the temporary file being tested in the Augeas tree.
953
+
954
+ For example, if you want to make sure your passwd content never contains
955
+ a user `foo`, you could write:
956
+
957
+ validate_augeas($passwdcontent, 'Passwd.lns', ['$file/foo'])
958
+
959
+ Or if you wanted to ensure that no users used the '/bin/barsh' shell,
960
+ you could use:
961
+
962
+ validate_augeas($passwdcontent, 'Passwd.lns', ['$file/*[shell="/bin/barsh"]']
963
+
964
+ If a fourth argument is specified, this will be the error message raised and
965
+ seen by the user.
966
+
967
+ A helpful error message can be returned like this:
968
+
969
+ validate_augeas($sudoerscontent, 'Sudoers.lns', [], 'Failed to validate sudoers content with Augeas')
970
+
971
+
972
+
973
+ - *Type*: statement
974
+
975
+ validate_bool
976
+ -------------
977
+ Validate that all passed values are either true or false. Abort catalog
978
+ compilation if any value fails this check.
979
+
980
+ The following values will pass:
981
+
982
+ $iamtrue = true
983
+ validate_bool(true)
984
+ validate_bool(true, true, false, $iamtrue)
985
+
986
+ The following values will fail, causing compilation to abort:
987
+
988
+ $some_array = [ true ]
989
+ validate_bool("false")
990
+ validate_bool("true")
991
+ validate_bool($some_array)
992
+
993
+
994
+
995
+ - *Type*: statement
996
+
997
+ validate_cmd
998
+ ------------
999
+ Perform validation of a string with an external command.
1000
+ The first argument of this function should be a string to
1001
+ test, and the second argument should be a path to a test command
1002
+ taking a file as last argument. If the command, launched against
1003
+ a tempfile containing the passed string, returns a non-null value,
1004
+ compilation will abort with a parse error.
1005
+
1006
+ If a third argument is specified, this will be the error message raised and
1007
+ seen by the user.
1008
+
1009
+ A helpful error message can be returned like this:
1010
+
1011
+ Example:
1012
+
1013
+ validate_cmd($sudoerscontent, '/usr/sbin/visudo -c -f', 'Visudo failed to validate sudoers content')
1014
+
1015
+
1016
+
1017
+ - *Type*: statement
1018
+
1019
+ validate_hash
1020
+ -------------
1021
+ Validate that all passed values are hash data structures. Abort catalog
1022
+ compilation if any value fails this check.
1023
+
1024
+ The following values will pass:
1025
+
1026
+ $my_hash = { 'one' => 'two' }
1027
+ validate_hash($my_hash)
1028
+
1029
+ The following values will fail, causing compilation to abort:
1030
+
1031
+ validate_hash(true)
1032
+ validate_hash('some_string')
1033
+ $undefined = undef
1034
+ validate_hash($undefined)
1035
+
1036
+
1037
+
1038
+ - *Type*: statement
1039
+
1040
+ validate_re
1041
+ -----------
1042
+ Perform simple validation of a string against one or more regular
1043
+ expressions. The first argument of this function should be a string to
1044
+ test, and the second argument should be a stringified regular expression
1045
+ (without the // delimiters) or an array of regular expressions. If none
1046
+ of the regular expressions match the string passed in, compilation will
1047
+ abort with a parse error.
1048
+
1049
+ If a third argument is specified, this will be the error message raised and
1050
+ seen by the user.
1051
+
1052
+ The following strings will validate against the regular expressions:
1053
+
1054
+ validate_re('one', '^one$')
1055
+ validate_re('one', [ '^one', '^two' ])
1056
+
1057
+ The following strings will fail to validate, causing compilation to abort:
1058
+
1059
+ validate_re('one', [ '^two', '^three' ])
1060
+
1061
+ A helpful error message can be returned like this:
1062
+
1063
+ validate_re($::puppetversion, '^2.7', 'The $puppetversion fact value does not match 2.7')
1064
+
1065
+
1066
+
1067
+ - *Type*: statement
1068
+
1069
+ validate_slength
1070
+ ----------------
1071
+ Validate that the first argument is a string (or an array of strings), and
1072
+ less/equal to than the length of the second argument. It fails if the first
1073
+ argument is not a string or array of strings, and if arg 2 is not convertable
1074
+ to a number.
1075
+
1076
+ The following values will pass:
1077
+
1078
+ validate_slength("discombobulate",17)
1079
+ validate_slength(["discombobulate","moo"],17)
1080
+
1081
+ The following valueis will not:
1082
+
1083
+ validate_slength("discombobulate",1)
1084
+ validate_slength(["discombobulate","thermometer"],5)
1085
+
1086
+
1087
+
1088
+ - *Type*: statement
1089
+
1090
+ validate_string
1091
+ ---------------
1092
+ Validate that all passed values are string data structures. Abort catalog
1093
+ compilation if any value fails this check.
1094
+
1095
+ The following values will pass:
1096
+
1097
+ $my_string = "one two"
1098
+ validate_string($my_string, 'three')
1099
+
1100
+ The following values will fail, causing compilation to abort:
1101
+
1102
+ validate_string(true)
1103
+ validate_string([ 'some', 'array' ])
1104
+ $undefined = undef
1105
+ validate_string($undefined)
1106
+
1107
+
1108
+ - *Type*: statement
1109
+
1110
+ values
1111
+ ------
1112
+ When given a hash this function will return the values of that hash.
1113
+
1114
+ *Examples:*
1115
+
1116
+ $hash = {
1117
+ 'a' => 1,
1118
+ 'b' => 2,
1119
+ 'c' => 3,
1120
+ }
1121
+ values($hash)
1122
+
1123
+ This example would return:
1124
+
1125
+ [1,2,3]
1126
+
1127
+
1128
+ - *Type*: rvalue
1129
+
1130
+ values_at
1131
+ ---------
1132
+ Finds value inside an array based on location.
1133
+
1134
+ The first argument is the array you want to analyze, and the second element can
1135
+ be a combination of:
1136
+
1137
+ * A single numeric index
1138
+ * A range in the form of 'start-stop' (eg. 4-9)
1139
+ * An array combining the above
1140
+
1141
+ *Examples*:
1142
+
1143
+ values_at(['a','b','c'], 2)
1144
+
1145
+ Would return ['c'].
1146
+
1147
+ values_at(['a','b','c'], ["0-1"])
1148
+
1149
+ Would return ['a','b'].
1150
+
1151
+ values_at(['a','b','c','d','e'], [0, "2-3"])
1152
+
1153
+ Would return ['a','c','d'].
1154
+
1155
+
1156
+ - *Type*: rvalue
1157
+
1158
+ zip
1159
+ ---
1160
+ Takes one element from first array and merges corresponding elements from second array. This generates a sequence of n-element arrays, where n is one more than the count of arguments.
1161
+
1162
+ *Example:*
1163
+
1164
+ zip(['1','2','3'],['4','5','6'])
1165
+
1166
+ Would result in:
1167
+
1168
+ ["1", "4"], ["2", "5"], ["3", "6"]
1169
+
1170
+
1171
+ - *Type*: rvalue
1172
+
1173
+ *This page autogenerated on 2013-04-11 13:54:25 -0700*