bebox 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (402) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +78 -0
  3. data/Gemfile +3 -0
  4. data/Gemfile.lock +163 -0
  5. data/LICENSE +21 -0
  6. data/README.md +372 -0
  7. data/Rakefile +8 -0
  8. data/bebox.gemspec +40 -0
  9. data/bin/bebox +5 -0
  10. data/lib/bebox/cli.rb +42 -0
  11. data/lib/bebox/commands/commands_helper.rb +33 -0
  12. data/lib/bebox/commands/environment_commands.rb +46 -0
  13. data/lib/bebox/commands/general_commands.rb +24 -0
  14. data/lib/bebox/commands/node_commands.rb +68 -0
  15. data/lib/bebox/commands/prepare_commands.rb +59 -0
  16. data/lib/bebox/commands/project_commands.rb +44 -0
  17. data/lib/bebox/commands/provision_commands.rb +145 -0
  18. data/lib/bebox/environment.rb +114 -0
  19. data/lib/bebox/logger.rb +51 -0
  20. data/lib/bebox/node.rb +308 -0
  21. data/lib/bebox/profile.rb +102 -0
  22. data/lib/bebox/project.rb +259 -0
  23. data/lib/bebox/provision.rb +257 -0
  24. data/lib/bebox/role.rb +103 -0
  25. data/lib/bebox/version.rb +3 -0
  26. data/lib/bebox/wizards/environment_wizard.rb +45 -0
  27. data/lib/bebox/wizards/node_wizard.rb +163 -0
  28. data/lib/bebox/wizards/profile_wizard.rb +91 -0
  29. data/lib/bebox/wizards/project_wizard.rb +175 -0
  30. data/lib/bebox/wizards/provision_wizard.rb +80 -0
  31. data/lib/bebox/wizards/role_wizard.rb +97 -0
  32. data/lib/bebox.rb +2 -0
  33. data/lib/deb/puppet_3.6.0/augeas-lenses_0.10.0-0ubuntu4_all.deb +0 -0
  34. data/lib/deb/puppet_3.6.0/debconf-utils_1.5.42ubuntu1_all.deb +0 -0
  35. data/lib/deb/puppet_3.6.0/facter_2.0.1-1puppetlabs1_amd64.deb +0 -0
  36. data/lib/deb/puppet_3.6.0/hiera_1.3.2-1puppetlabs1_all.deb +0 -0
  37. data/lib/deb/puppet_3.6.0/libaugeas-ruby1.8_0.3.0-1.1ubuntu4_amd64.deb +0 -0
  38. data/lib/deb/puppet_3.6.0/libaugeas-ruby_0.3.0-1.1ubuntu4_all.deb +0 -0
  39. data/lib/deb/puppet_3.6.0/libaugeas0_0.10.0-0ubuntu4_amd64.deb +0 -0
  40. data/lib/deb/puppet_3.6.0/libjson-ruby_1.6.3-1_all.deb +0 -0
  41. data/lib/deb/puppet_3.6.0/libruby1.8_1.8.7.352-2ubuntu1.4_amd64.deb +0 -0
  42. data/lib/deb/puppet_3.6.0/libruby_4.8_all.deb +0 -0
  43. data/lib/deb/puppet_3.6.0/libshadow-ruby1.8_1.4.1-8build1_amd64.deb +0 -0
  44. data/lib/deb/puppet_3.6.0/puppet-common_3.6.0-1puppetlabs1_all.deb +0 -0
  45. data/lib/deb/puppet_3.6.0/puppet_3.6.0-1puppetlabs1_all.deb +0 -0
  46. data/lib/deb/puppet_3.6.0/ruby-json_1.6.3-1_amd64.deb +0 -0
  47. data/lib/deb/puppet_3.6.0/ruby-rgen_0.6.5-1puppetlabs1_all.deb +0 -0
  48. data/lib/deb/puppet_3.6.0/ruby1.8_1.8.7.352-2ubuntu1.4_amd64.deb +0 -0
  49. data/lib/deb/puppet_3.6.0/ruby_4.8_all.deb +0 -0
  50. data/lib/deb/puppet_3.6.0/virt-what_1.11-1_amd64.deb +0 -0
  51. data/lib/templates/node/Vagrantfile.erb +18 -0
  52. data/lib/templates/node/deploy_vagrant_node.erb +3 -0
  53. data/lib/templates/node/node.yml.erb +3 -0
  54. data/lib/templates/node/prepared_node.yml.erb +4 -0
  55. data/lib/templates/node/provisioned_node.yml.erb +4 -0
  56. data/lib/templates/project/Capfile.erb +2 -0
  57. data/lib/templates/project/Gemfile.erb +5 -0
  58. data/lib/templates/project/config/deploy/environment.erb +40 -0
  59. data/lib/templates/project/config/deploy/vagrant.erb +42 -0
  60. data/lib/templates/project/config/deploy.erb +120 -0
  61. data/lib/templates/project/dot_bebox.erb +4 -0
  62. data/lib/templates/project/gitignore.erb +7 -0
  63. data/lib/templates/project/ubuntu_dependencies +10 -0
  64. data/lib/templates/puppet/default_profiles/base/fundamental/ruby/Puppetfile +0 -0
  65. data/lib/templates/puppet/default_profiles/base/fundamental/ruby/manifests/init.pp +24 -0
  66. data/lib/templates/puppet/default_profiles/base/fundamental/sudo/Puppetfile +0 -0
  67. data/lib/templates/puppet/default_profiles/base/fundamental/sudo/manifests/init.pp +22 -0
  68. data/lib/templates/puppet/default_profiles/base/fundamental/users/Puppetfile +0 -0
  69. data/lib/templates/puppet/default_profiles/base/fundamental/users/manifests/init.pp +18 -0
  70. data/lib/templates/puppet/default_profiles/base/security/fail2ban/Puppetfile +2 -0
  71. data/lib/templates/puppet/default_profiles/base/security/fail2ban/manifests/init.pp +28 -0
  72. data/lib/templates/puppet/default_profiles/base/security/iptables/Puppetfile +2 -0
  73. data/lib/templates/puppet/default_profiles/base/security/iptables/manifests/init.pp +27 -0
  74. data/lib/templates/puppet/default_profiles/base/security/ssh/Puppetfile +2 -0
  75. data/lib/templates/puppet/default_profiles/base/security/ssh/manifests/init.pp +30 -0
  76. data/lib/templates/puppet/default_profiles/base/security/sysctl/Puppetfile +2 -0
  77. data/lib/templates/puppet/default_profiles/base/security/sysctl/manifests/init.pp +20 -0
  78. data/lib/templates/puppet/default_profiles/base/users/ssh/Puppetfile +2 -0
  79. data/lib/templates/puppet/default_profiles/base/users/ssh/manifests/init.pp +47 -0
  80. data/lib/templates/puppet/default_profiles/base/users/users/Puppetfile +0 -0
  81. data/lib/templates/puppet/default_profiles/base/users/users/manifests/init.pp +18 -0
  82. data/lib/templates/puppet/default_roles/fundamental/manifests/init.pp +16 -0
  83. data/lib/templates/puppet/default_roles/security/manifests/init.pp +17 -0
  84. data/lib/templates/puppet/default_roles/users/manifests/init.pp +15 -0
  85. data/lib/templates/puppet/profiles/Puppetfile.erb +24 -0
  86. data/lib/templates/puppet/profiles/manifests/init.pp.erb +17 -0
  87. data/lib/templates/puppet/roles/manifests/init.pp.erb +14 -0
  88. data/lib/templates/puppet/step-0/Puppetfile.erb +5 -0
  89. data/lib/templates/puppet/step-0/hiera/data/common.yaml.erb +26 -0
  90. data/lib/templates/puppet/step-0/hiera/data/environment.yaml.erb +26 -0
  91. data/lib/templates/puppet/step-0/hiera/data/node.yaml.erb +26 -0
  92. data/lib/templates/puppet/step-0/hiera/hiera.yaml.erb +11 -0
  93. data/lib/templates/puppet/step-0/manifests/node.erb +5 -0
  94. data/lib/templates/puppet/step-0/manifests/site.pp.erb +15 -0
  95. data/lib/templates/puppet/step-0/modules/rbenv/AUTHORS +11 -0
  96. data/lib/templates/puppet/step-0/modules/rbenv/CHANGELOG.md +70 -0
  97. data/lib/templates/puppet/step-0/modules/rbenv/Gemfile +8 -0
  98. data/lib/templates/puppet/step-0/modules/rbenv/Gemfile.lock +28 -0
  99. data/lib/templates/puppet/step-0/modules/rbenv/Modulefile +7 -0
  100. data/lib/templates/puppet/step-0/modules/rbenv/README.md +173 -0
  101. data/lib/templates/puppet/step-0/modules/rbenv/Rakefile +22 -0
  102. data/lib/templates/puppet/step-0/modules/rbenv/TODO +10 -0
  103. data/lib/templates/puppet/step-0/modules/rbenv/bin/autospec +16 -0
  104. data/lib/templates/puppet/step-0/modules/rbenv/bin/facter +16 -0
  105. data/lib/templates/puppet/step-0/modules/rbenv/bin/filebucket +16 -0
  106. data/lib/templates/puppet/step-0/modules/rbenv/bin/hiera +16 -0
  107. data/lib/templates/puppet/step-0/modules/rbenv/bin/htmldiff +16 -0
  108. data/lib/templates/puppet/step-0/modules/rbenv/bin/ldiff +16 -0
  109. data/lib/templates/puppet/step-0/modules/rbenv/bin/pi +16 -0
  110. data/lib/templates/puppet/step-0/modules/rbenv/bin/puppet +16 -0
  111. data/lib/templates/puppet/step-0/modules/rbenv/bin/puppet-lint +16 -0
  112. data/lib/templates/puppet/step-0/modules/rbenv/bin/puppet-module +16 -0
  113. data/lib/templates/puppet/step-0/modules/rbenv/bin/puppetca +16 -0
  114. data/lib/templates/puppet/step-0/modules/rbenv/bin/puppetd +16 -0
  115. data/lib/templates/puppet/step-0/modules/rbenv/bin/puppetdoc +16 -0
  116. data/lib/templates/puppet/step-0/modules/rbenv/bin/puppetmasterd +16 -0
  117. data/lib/templates/puppet/step-0/modules/rbenv/bin/puppetqd +16 -0
  118. data/lib/templates/puppet/step-0/modules/rbenv/bin/puppetrun +16 -0
  119. data/lib/templates/puppet/step-0/modules/rbenv/bin/rake +16 -0
  120. data/lib/templates/puppet/step-0/modules/rbenv/bin/ralsh +16 -0
  121. data/lib/templates/puppet/step-0/modules/rbenv/bin/rspec +16 -0
  122. data/lib/templates/puppet/step-0/modules/rbenv/bin/rspec-puppet-init +16 -0
  123. data/lib/templates/puppet/step-0/modules/rbenv/lib/puppet/provider/rbenvgem/default.rb +50 -0
  124. data/lib/templates/puppet/step-0/modules/rbenv/lib/puppet/type/rbenvgem.rb +62 -0
  125. data/lib/templates/puppet/step-0/modules/rbenv/manifests/bundle.pp +36 -0
  126. data/lib/templates/puppet/step-0/modules/rbenv/manifests/client.pp +48 -0
  127. data/lib/templates/puppet/step-0/modules/rbenv/manifests/compile.pp +102 -0
  128. data/lib/templates/puppet/step-0/modules/rbenv/manifests/definition.pp +31 -0
  129. data/lib/templates/puppet/step-0/modules/rbenv/manifests/dependencies/centos.pp +25 -0
  130. data/lib/templates/puppet/step-0/modules/rbenv/manifests/dependencies/suse.pp +28 -0
  131. data/lib/templates/puppet/step-0/modules/rbenv/manifests/dependencies/ubuntu.pp +17 -0
  132. data/lib/templates/puppet/step-0/modules/rbenv/manifests/dependencies.pp +8 -0
  133. data/lib/templates/puppet/step-0/modules/rbenv/manifests/gem.pp +29 -0
  134. data/lib/templates/puppet/step-0/modules/rbenv/manifests/install.pp +55 -0
  135. data/lib/templates/puppet/step-0/modules/rbenv/manifests/plugin/rbenvvars.pp +16 -0
  136. data/lib/templates/puppet/step-0/modules/rbenv/manifests/plugin/rubybuild.pp +16 -0
  137. data/lib/templates/puppet/step-0/modules/rbenv/manifests/plugin.pp +40 -0
  138. data/lib/templates/puppet/step-0/modules/rbenv/metadata.json +109 -0
  139. data/lib/templates/puppet/step-0/modules/rbenv/templates/Gemfile.erb +5 -0
  140. data/lib/templates/puppet/step-0/modules/rbenv/templates/dot.rbenvrc.erb +8 -0
  141. data/lib/templates/puppet/step-0/modules/stdlib/CHANGELOG.md +418 -0
  142. data/lib/templates/puppet/step-0/modules/stdlib/CONTRIBUTING.md +65 -0
  143. data/lib/templates/puppet/step-0/modules/stdlib/Gemfile +33 -0
  144. data/lib/templates/puppet/step-0/modules/stdlib/Gemfile.lock +166 -0
  145. data/lib/templates/puppet/step-0/modules/stdlib/LICENSE +19 -0
  146. data/lib/templates/puppet/step-0/modules/stdlib/Modulefile +11 -0
  147. data/lib/templates/puppet/step-0/modules/stdlib/README.markdown +1304 -0
  148. data/lib/templates/puppet/step-0/modules/stdlib/README_DEVELOPER.markdown +35 -0
  149. data/lib/templates/puppet/step-0/modules/stdlib/README_SPECS.markdown +7 -0
  150. data/lib/templates/puppet/step-0/modules/stdlib/RELEASE_PROCESS.markdown +24 -0
  151. data/lib/templates/puppet/step-0/modules/stdlib/Rakefile +18 -0
  152. data/lib/templates/puppet/step-0/modules/stdlib/checksums.json +349 -0
  153. data/lib/templates/puppet/step-0/modules/stdlib/lib/facter/facter_dot_d.rb +202 -0
  154. data/lib/templates/puppet/step-0/modules/stdlib/lib/facter/pe_version.rb +53 -0
  155. data/lib/templates/puppet/step-0/modules/stdlib/lib/facter/puppet_vardir.rb +26 -0
  156. data/lib/templates/puppet/step-0/modules/stdlib/lib/facter/root_home.rb +32 -0
  157. data/lib/templates/puppet/step-0/modules/stdlib/lib/facter/util/puppet_settings.rb +21 -0
  158. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/abs.rb +36 -0
  159. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/any2array.rb +33 -0
  160. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/base64.rb +37 -0
  161. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/bool2num.rb +49 -0
  162. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/capitalize.rb +34 -0
  163. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/chomp.rb +35 -0
  164. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/chop.rb +37 -0
  165. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/concat.rb +41 -0
  166. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/count.rb +22 -0
  167. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/deep_merge.rb +44 -0
  168. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/defined_with_params.rb +35 -0
  169. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/delete.rb +46 -0
  170. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/delete_at.rb +49 -0
  171. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/delete_undef_values.rb +34 -0
  172. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/delete_values.rb +26 -0
  173. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/difference.rb +36 -0
  174. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/dirname.rb +15 -0
  175. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/downcase.rb +33 -0
  176. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/empty.rb +28 -0
  177. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/ensure_packages.rb +35 -0
  178. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/ensure_resource.rb +45 -0
  179. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/flatten.rb +33 -0
  180. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/floor.rb +25 -0
  181. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/fqdn_rotate.rb +46 -0
  182. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/get_module_path.rb +17 -0
  183. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/getparam.rb +35 -0
  184. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/getvar.rb +26 -0
  185. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/grep.rb +33 -0
  186. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/has_interface_with.rb +52 -0
  187. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/has_ip_address.rb +25 -0
  188. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/has_ip_network.rb +25 -0
  189. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/has_key.rb +28 -0
  190. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/hash.rb +41 -0
  191. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/intersection.rb +34 -0
  192. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/is_array.rb +22 -0
  193. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/is_bool.rb +22 -0
  194. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/is_domain_name.rb +50 -0
  195. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/is_float.rb +30 -0
  196. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/is_function_available.rb +26 -0
  197. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/is_hash.rb +22 -0
  198. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/is_integer.rb +45 -0
  199. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/is_ip_address.rb +32 -0
  200. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/is_mac_address.rb +27 -0
  201. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/is_numeric.rb +75 -0
  202. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/is_string.rb +26 -0
  203. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/join.rb +41 -0
  204. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/join_keys_to_values.rb +47 -0
  205. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/keys.rb +26 -0
  206. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/loadyaml.rb +20 -0
  207. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/lstrip.rb +33 -0
  208. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/max.rb +21 -0
  209. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/member.rb +44 -0
  210. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/merge.rb +34 -0
  211. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/min.rb +21 -0
  212. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/num2bool.rb +43 -0
  213. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/parsejson.rb +24 -0
  214. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/parseyaml.rb +24 -0
  215. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/pick.rb +29 -0
  216. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/pick_default.rb +35 -0
  217. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/prefix.rb +45 -0
  218. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/range.rb +88 -0
  219. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/reject.rb +31 -0
  220. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/reverse.rb +28 -0
  221. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/rstrip.rb +32 -0
  222. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/shuffle.rb +46 -0
  223. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/size.rb +48 -0
  224. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/sort.rb +27 -0
  225. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/squeeze.rb +36 -0
  226. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/str2bool.rb +46 -0
  227. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/str2saltedsha512.rb +32 -0
  228. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/strftime.rb +107 -0
  229. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/strip.rb +39 -0
  230. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/suffix.rb +45 -0
  231. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/swapcase.rb +39 -0
  232. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/time.rb +49 -0
  233. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/to_bytes.rb +28 -0
  234. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/type.rb +50 -0
  235. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/union.rb +34 -0
  236. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/unique.rb +51 -0
  237. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/upcase.rb +41 -0
  238. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/uriescape.rb +35 -0
  239. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/validate_absolute_path.rb +56 -0
  240. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/validate_array.rb +33 -0
  241. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/validate_augeas.rb +81 -0
  242. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/validate_bool.rb +34 -0
  243. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/validate_cmd.rb +48 -0
  244. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/validate_hash.rb +33 -0
  245. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/validate_ipv4_address.rb +48 -0
  246. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/validate_ipv6_address.rb +49 -0
  247. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/validate_re.rb +40 -0
  248. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/validate_slength.rb +71 -0
  249. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/validate_string.rb +33 -0
  250. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/values.rb +39 -0
  251. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/values_at.rb +98 -0
  252. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/parser/functions/zip.rb +65 -0
  253. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/provider/file_line/ruby.rb +83 -0
  254. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/type/anchor.rb +46 -0
  255. data/lib/templates/puppet/step-0/modules/stdlib/lib/puppet/type/file_line.rb +79 -0
  256. data/lib/templates/puppet/step-0/modules/stdlib/manifests/init.pp +20 -0
  257. data/lib/templates/puppet/step-0/modules/stdlib/manifests/stages.pp +43 -0
  258. data/lib/templates/puppet/step-0/modules/stdlib/metadata.json +111 -0
  259. data/lib/templates/puppet/step-0/modules/sudo/.fixtures.yml +5 -0
  260. data/lib/templates/puppet/step-0/modules/sudo/.gemfile +14 -0
  261. data/lib/templates/puppet/step-0/modules/sudo/.gemfile.lock +43 -0
  262. data/lib/templates/puppet/step-0/modules/sudo/.travis.yml +34 -0
  263. data/lib/templates/puppet/step-0/modules/sudo/LICENSE +13 -0
  264. data/lib/templates/puppet/step-0/modules/sudo/Modulefile +9 -0
  265. data/lib/templates/puppet/step-0/modules/sudo/README.md +171 -0
  266. data/lib/templates/puppet/step-0/modules/sudo/Rakefile +1 -0
  267. data/lib/templates/puppet/step-0/modules/sudo/files/sudoers.aix +90 -0
  268. data/lib/templates/puppet/step-0/modules/sudo/files/sudoers.archlinux +90 -0
  269. data/lib/templates/puppet/step-0/modules/sudo/files/sudoers.deb +90 -0
  270. data/lib/templates/puppet/step-0/modules/sudo/files/sudoers.freebsd +98 -0
  271. data/lib/templates/puppet/step-0/modules/sudo/files/sudoers.omnios +90 -0
  272. data/lib/templates/puppet/step-0/modules/sudo/files/sudoers.rhel5 +97 -0
  273. data/lib/templates/puppet/step-0/modules/sudo/files/sudoers.rhel6 +115 -0
  274. data/lib/templates/puppet/step-0/modules/sudo/files/sudoers.solaris +90 -0
  275. data/lib/templates/puppet/step-0/modules/sudo/files/sudoers.suse +81 -0
  276. data/lib/templates/puppet/step-0/modules/sudo/files/sudoers.ubuntu +30 -0
  277. data/lib/templates/puppet/step-0/modules/sudo/files/sudoers.wheezy +17 -0
  278. data/lib/templates/puppet/step-0/modules/sudo/lib/augeas/lenses/fixedsudoers.aug +520 -0
  279. data/lib/templates/puppet/step-0/modules/sudo/manifests/allow.pp +76 -0
  280. data/lib/templates/puppet/step-0/modules/sudo/manifests/conf.pp +105 -0
  281. data/lib/templates/puppet/step-0/modules/sudo/manifests/configs.pp +24 -0
  282. data/lib/templates/puppet/step-0/modules/sudo/manifests/init.pp +151 -0
  283. data/lib/templates/puppet/step-0/modules/sudo/manifests/package/aix.pp +46 -0
  284. data/lib/templates/puppet/step-0/modules/sudo/manifests/package/solaris.pp +60 -0
  285. data/lib/templates/puppet/step-0/modules/sudo/manifests/package.pp +61 -0
  286. data/lib/templates/puppet/step-0/modules/sudo/manifests/params.pp +127 -0
  287. data/lib/templates/puppet/step-0/modules/sudo/metadata.json +59 -0
  288. data/lib/templates/puppet/step-0/modules/sudo/templates/users_groups.erb +9 -0
  289. data/lib/templates/puppet/step-0/modules/users/manifests/init.pp +15 -0
  290. data/lib/templates/puppet/step-0/modules/users/manifests/user.pp +50 -0
  291. data/lib/templates/puppet/step-1/Puppetfile.erb +5 -0
  292. data/lib/templates/puppet/step-1/hiera/data/common.yaml.erb +11 -0
  293. data/lib/templates/puppet/step-1/hiera/data/environment.yaml.erb +11 -0
  294. data/lib/templates/puppet/step-1/hiera/data/node.yaml.erb +11 -0
  295. data/lib/templates/puppet/step-1/hiera/hiera.yaml.erb +11 -0
  296. data/lib/templates/puppet/step-1/manifests/node.erb +5 -0
  297. data/lib/templates/puppet/step-1/manifests/site.pp.erb +15 -0
  298. data/lib/templates/puppet/step-1/modules/users/manifests/init.pp +15 -0
  299. data/lib/templates/puppet/step-1/modules/users/manifests/user.pp +49 -0
  300. data/lib/templates/puppet/step-2/Puppetfile.erb +5 -0
  301. data/lib/templates/puppet/step-2/hiera/data/common.yaml.erb +1 -0
  302. data/lib/templates/puppet/step-2/hiera/data/environment.yaml.erb +1 -0
  303. data/lib/templates/puppet/step-2/hiera/data/node.yaml.erb +1 -0
  304. data/lib/templates/puppet/step-2/hiera/hiera.yaml.erb +11 -0
  305. data/lib/templates/puppet/step-2/manifests/node.erb +3 -0
  306. data/lib/templates/puppet/step-2/manifests/site.pp.erb +10 -0
  307. data/lib/templates/puppet/step-3/Puppetfile.erb +5 -0
  308. data/lib/templates/puppet/step-3/hiera/data/common.yaml.erb +99 -0
  309. data/lib/templates/puppet/step-3/hiera/data/environment.yaml.erb +99 -0
  310. data/lib/templates/puppet/step-3/hiera/data/node.yaml.erb +99 -0
  311. data/lib/templates/puppet/step-3/hiera/hiera.yaml.erb +11 -0
  312. data/lib/templates/puppet/step-3/manifests/node.erb +5 -0
  313. data/lib/templates/puppet/step-3/manifests/site.pp.erb +15 -0
  314. data/spec/environment_spec.rb +82 -0
  315. data/spec/factories/environment.rb +20 -0
  316. data/spec/factories/node.rb +22 -0
  317. data/spec/factories/profile.rb +10 -0
  318. data/spec/factories/project.rb +17 -0
  319. data/spec/factories/provision.rb +13 -0
  320. data/spec/factories/role.rb +9 -0
  321. data/spec/fixtures/Capfile.test +2 -0
  322. data/spec/fixtures/Gemfile.test +5 -0
  323. data/spec/fixtures/config/deploy/environment.test +35 -0
  324. data/spec/fixtures/config/deploy/production.test +35 -0
  325. data/spec/fixtures/config/deploy/staging.test +35 -0
  326. data/spec/fixtures/config/deploy/vagrant.test +37 -0
  327. data/spec/fixtures/config/deploy.test +120 -0
  328. data/spec/fixtures/dot_bebox.test.erb +4 -0
  329. data/spec/fixtures/dot_gitignore.test +8 -0
  330. data/spec/fixtures/node/Vagrantfile.test.erb +18 -0
  331. data/spec/fixtures/node/node_0.test.erb +3 -0
  332. data/spec/fixtures/node/prepared_node_0.test.erb +4 -0
  333. data/spec/fixtures/node/provisioned_node_0.test.erb +4 -0
  334. data/spec/fixtures/node/vagrant_deploy.test +38 -0
  335. data/spec/fixtures/puppet/hiera/data/node0.server1.test.yaml.test +4 -0
  336. data/spec/fixtures/puppet/profiles/test/profile_0/Puppetfile.test +24 -0
  337. data/spec/fixtures/puppet/profiles/test/profile_0/Puppetfile_with_modules.test +20 -0
  338. data/spec/fixtures/puppet/profiles/test/profile_0/manifests/init.pp.test +17 -0
  339. data/spec/fixtures/puppet/profiles/test/profile_0/manifests/init_with_content.pp.test +22 -0
  340. data/spec/fixtures/puppet/roles/manifests/init.pp.test +14 -0
  341. data/spec/fixtures/puppet/steps/step-0/hiera/data/common.yaml.test +26 -0
  342. data/spec/fixtures/puppet/steps/step-0/hiera/data/node0.server1.test.yaml.test +0 -0
  343. data/spec/fixtures/puppet/steps/step-0/hiera/data/pname_env.yaml.test +26 -0
  344. data/spec/fixtures/puppet/steps/step-0/hiera/data/production.yaml.test +0 -0
  345. data/spec/fixtures/puppet/steps/step-0/hiera/data/staging.yaml.test +0 -0
  346. data/spec/fixtures/puppet/steps/step-0/hiera/data/vagrant.yaml.test +0 -0
  347. data/spec/fixtures/puppet/steps/step-0/hiera/hiera.yaml.test +11 -0
  348. data/spec/fixtures/puppet/steps/step-0/manifests/site.pp.test +10 -0
  349. data/spec/fixtures/puppet/steps/step-0/manifests/site_with_node.pp.test +15 -0
  350. data/spec/fixtures/puppet/steps/step-1/hiera/data/common.yaml.test +11 -0
  351. data/spec/fixtures/puppet/steps/step-1/hiera/data/node0.server1.test.yaml.test +0 -0
  352. data/spec/fixtures/puppet/steps/step-1/hiera/data/pname_env.yaml.test +11 -0
  353. data/spec/fixtures/puppet/steps/step-1/hiera/data/production.yaml.test +0 -0
  354. data/spec/fixtures/puppet/steps/step-1/hiera/data/staging.yaml.test +0 -0
  355. data/spec/fixtures/puppet/steps/step-1/hiera/data/vagrant.yaml.test +0 -0
  356. data/spec/fixtures/puppet/steps/step-1/hiera/hiera.yaml.test +11 -0
  357. data/spec/fixtures/puppet/steps/step-1/manifests/site.pp.test +10 -0
  358. data/spec/fixtures/puppet/steps/step-1/manifests/site_with_node.pp.test +15 -0
  359. data/spec/fixtures/puppet/steps/step-2/Puppetfile.test +6 -0
  360. data/spec/fixtures/puppet/steps/step-2/hiera/data/common.yaml.test +1 -0
  361. data/spec/fixtures/puppet/steps/step-2/hiera/data/node0.server1.test.yaml.test +1 -0
  362. data/spec/fixtures/puppet/steps/step-2/hiera/data/pname_env.yaml.test +1 -0
  363. data/spec/fixtures/puppet/steps/step-2/hiera/data/production.yaml.test +1 -0
  364. data/spec/fixtures/puppet/steps/step-2/hiera/data/staging.yaml.test +1 -0
  365. data/spec/fixtures/puppet/steps/step-2/hiera/data/vagrant.yaml.test +1 -0
  366. data/spec/fixtures/puppet/steps/step-2/hiera/hiera.yaml.test +11 -0
  367. data/spec/fixtures/puppet/steps/step-2/manifests/site.pp.test +10 -0
  368. data/spec/fixtures/puppet/steps/step-2/manifests/site_with_node.pp.test +13 -0
  369. data/spec/fixtures/puppet/steps/step-2/manifests/site_with_node_role_association.pp.test +16 -0
  370. data/spec/fixtures/puppet/steps/step-2/modules/profiles/manifests/test/profile_0.pp.test +17 -0
  371. data/spec/fixtures/puppet/steps/step-2/modules/roles/manifests/role_0.pp.test +16 -0
  372. data/spec/fixtures/puppet/steps/step-3/hiera/data/common.yaml.test +99 -0
  373. data/spec/fixtures/puppet/steps/step-3/hiera/data/node0.server1.test.yaml.test +1 -0
  374. data/spec/fixtures/puppet/steps/step-3/hiera/data/pname_env.yaml.test +99 -0
  375. data/spec/fixtures/puppet/steps/step-3/hiera/data/production.yaml.test +1 -0
  376. data/spec/fixtures/puppet/steps/step-3/hiera/data/staging.yaml.test +1 -0
  377. data/spec/fixtures/puppet/steps/step-3/hiera/data/vagrant.yaml.test +1 -0
  378. data/spec/fixtures/puppet/steps/step-3/hiera/hiera.yaml.test +11 -0
  379. data/spec/fixtures/puppet/steps/step-3/manifests/site.pp.test +10 -0
  380. data/spec/fixtures/puppet/steps/step-3/manifests/site_with_node.pp.test +15 -0
  381. data/spec/fixtures/puppet/ubuntu_dependencies.test +10 -0
  382. data/spec/node0.server1.test/prepare_phase_spec.rb +53 -0
  383. data/spec/node0.server1.test/provision_step_0_spec.rb +46 -0
  384. data/spec/node0.server1.test/provision_step_1_spec.rb +41 -0
  385. data/spec/node0.server1.test/provision_step_2_spec.rb +79 -0
  386. data/spec/node0.server1.test/provision_step_3_spec.rb +76 -0
  387. data/spec/node_role_spec.rb +20 -0
  388. data/spec/node_spec.rb +71 -0
  389. data/spec/node_wizard_spec.rb +22 -0
  390. data/spec/ordered_phases_spec.rb +55 -0
  391. data/spec/pre_prepare_spec.rb +78 -0
  392. data/spec/pre_provision_steps_spec.rb +40 -0
  393. data/spec/profile_spec.rb +70 -0
  394. data/spec/project_spec.rb +195 -0
  395. data/spec/project_wizard_spec.rb +51 -0
  396. data/spec/puppet_spec_helper.rb +15 -0
  397. data/spec/role_profiles_spec.rb +40 -0
  398. data/spec/role_spec.rb +56 -0
  399. data/spec/spec_helper.rb +37 -0
  400. data/spec/support/config_specs.yaml.example +2 -0
  401. data/spec/vagrant_spec_helper.rb +15 -0
  402. metadata +625 -0
@@ -0,0 +1,107 @@
1
+ #
2
+ # strftime.rb
3
+ #
4
+
5
+ module Puppet::Parser::Functions
6
+ newfunction(:strftime, :type => :rvalue, :doc => <<-EOS
7
+ This function returns formatted time.
8
+
9
+ *Examples:*
10
+
11
+ To return the time since epoch:
12
+
13
+ strftime("%s")
14
+
15
+ To return the date:
16
+
17
+ strftime("%Y-%m-%d")
18
+
19
+ *Format meaning:*
20
+
21
+ %a - The abbreviated weekday name (``Sun'')
22
+ %A - The full weekday name (``Sunday'')
23
+ %b - The abbreviated month name (``Jan'')
24
+ %B - The full month name (``January'')
25
+ %c - The preferred local date and time representation
26
+ %C - Century (20 in 2009)
27
+ %d - Day of the month (01..31)
28
+ %D - Date (%m/%d/%y)
29
+ %e - Day of the month, blank-padded ( 1..31)
30
+ %F - Equivalent to %Y-%m-%d (the ISO 8601 date format)
31
+ %h - Equivalent to %b
32
+ %H - Hour of the day, 24-hour clock (00..23)
33
+ %I - Hour of the day, 12-hour clock (01..12)
34
+ %j - Day of the year (001..366)
35
+ %k - hour, 24-hour clock, blank-padded ( 0..23)
36
+ %l - hour, 12-hour clock, blank-padded ( 0..12)
37
+ %L - Millisecond of the second (000..999)
38
+ %m - Month of the year (01..12)
39
+ %M - Minute of the hour (00..59)
40
+ %n - Newline (\n)
41
+ %N - Fractional seconds digits, default is 9 digits (nanosecond)
42
+ %3N millisecond (3 digits)
43
+ %6N microsecond (6 digits)
44
+ %9N nanosecond (9 digits)
45
+ %p - Meridian indicator (``AM'' or ``PM'')
46
+ %P - Meridian indicator (``am'' or ``pm'')
47
+ %r - time, 12-hour (same as %I:%M:%S %p)
48
+ %R - time, 24-hour (%H:%M)
49
+ %s - Number of seconds since 1970-01-01 00:00:00 UTC.
50
+ %S - Second of the minute (00..60)
51
+ %t - Tab character (\t)
52
+ %T - time, 24-hour (%H:%M:%S)
53
+ %u - Day of the week as a decimal, Monday being 1. (1..7)
54
+ %U - Week number of the current year,
55
+ starting with the first Sunday as the first
56
+ day of the first week (00..53)
57
+ %v - VMS date (%e-%b-%Y)
58
+ %V - Week number of year according to ISO 8601 (01..53)
59
+ %W - Week number of the current year,
60
+ starting with the first Monday as the first
61
+ day of the first week (00..53)
62
+ %w - Day of the week (Sunday is 0, 0..6)
63
+ %x - Preferred representation for the date alone, no time
64
+ %X - Preferred representation for the time alone, no date
65
+ %y - Year without a century (00..99)
66
+ %Y - Year with century
67
+ %z - Time zone as hour offset from UTC (e.g. +0900)
68
+ %Z - Time zone name
69
+ %% - Literal ``%'' character
70
+ EOS
71
+ ) do |arguments|
72
+
73
+ # Technically we support two arguments but only first is mandatory ...
74
+ raise(Puppet::ParseError, "strftime(): Wrong number of arguments " +
75
+ "given (#{arguments.size} for 1)") if arguments.size < 1
76
+
77
+ format = arguments[0]
78
+
79
+ raise(Puppet::ParseError, 'strftime(): You must provide ' +
80
+ 'format for evaluation') if format.empty?
81
+
82
+ # The Time Zone argument is optional ...
83
+ time_zone = arguments[1] if arguments[1]
84
+
85
+ time = Time.new
86
+
87
+ # There is probably a better way to handle Time Zone ...
88
+ if time_zone and not time_zone.empty?
89
+ original_zone = ENV['TZ']
90
+
91
+ local_time = time.clone
92
+ local_time = local_time.utc
93
+
94
+ ENV['TZ'] = time_zone
95
+
96
+ time = local_time.localtime
97
+
98
+ ENV['TZ'] = original_zone
99
+ end
100
+
101
+ result = time.strftime(format)
102
+
103
+ return result
104
+ end
105
+ end
106
+
107
+ # vim: set ts=2 sw=2 et :
@@ -0,0 +1,39 @@
1
+ #
2
+ # strip.rb
3
+ #
4
+
5
+ module Puppet::Parser::Functions
6
+ newfunction(:strip, :type => :rvalue, :doc => <<-EOS
7
+ This function removes leading and trailing whitespace from a string or from
8
+ every string inside an array.
9
+
10
+ *Examples:*
11
+
12
+ strip(" aaa ")
13
+
14
+ Would result in: "aaa"
15
+ EOS
16
+ ) do |arguments|
17
+
18
+ raise(Puppet::ParseError, "strip(): Wrong number of arguments " +
19
+ "given (#{arguments.size} for 1)") if arguments.size < 1
20
+
21
+ value = arguments[0]
22
+ klass = value.class
23
+
24
+ unless [Array, String].include?(klass)
25
+ raise(Puppet::ParseError, 'strip(): Requires either ' +
26
+ 'array or string to work with')
27
+ end
28
+
29
+ if value.is_a?(Array)
30
+ result = value.collect { |i| i.is_a?(String) ? i.strip : i }
31
+ else
32
+ result = value.strip
33
+ end
34
+
35
+ return result
36
+ end
37
+ end
38
+
39
+ # vim: set ts=2 sw=2 et :
@@ -0,0 +1,45 @@
1
+ #
2
+ # suffix.rb
3
+ #
4
+
5
+ module Puppet::Parser::Functions
6
+ newfunction(:suffix, :type => :rvalue, :doc => <<-EOS
7
+ This function applies a suffix to all elements in an array.
8
+
9
+ *Examples:*
10
+
11
+ suffix(['a','b','c'], 'p')
12
+
13
+ Will return: ['ap','bp','cp']
14
+ EOS
15
+ ) do |arguments|
16
+
17
+ # Technically we support two arguments but only first is mandatory ...
18
+ raise(Puppet::ParseError, "suffix(): Wrong number of arguments " +
19
+ "given (#{arguments.size} for 1)") if arguments.size < 1
20
+
21
+ array = arguments[0]
22
+
23
+ unless array.is_a?(Array)
24
+ raise Puppet::ParseError, "suffix(): expected first argument to be an Array, got #{array.inspect}"
25
+ end
26
+
27
+ suffix = arguments[1] if arguments[1]
28
+
29
+ if suffix
30
+ unless suffix.is_a? String
31
+ raise Puppet::ParseError, "suffix(): expected second argument to be a String, got #{suffix.inspect}"
32
+ end
33
+ end
34
+
35
+ # Turn everything into string same as join would do ...
36
+ result = array.collect do |i|
37
+ i = i.to_s
38
+ suffix ? i + suffix : i
39
+ end
40
+
41
+ return result
42
+ end
43
+ end
44
+
45
+ # vim: set ts=2 sw=2 et :
@@ -0,0 +1,39 @@
1
+ #
2
+ # swapcase.rb
3
+ #
4
+
5
+ module Puppet::Parser::Functions
6
+ newfunction(:swapcase, :type => :rvalue, :doc => <<-EOS
7
+ This function will swap the existing case of a string.
8
+
9
+ *Examples:*
10
+
11
+ swapcase("aBcD")
12
+
13
+ Would result in: "AbCd"
14
+ EOS
15
+ ) do |arguments|
16
+
17
+ raise(Puppet::ParseError, "swapcase(): Wrong number of arguments " +
18
+ "given (#{arguments.size} for 1)") if arguments.size < 1
19
+
20
+ value = arguments[0]
21
+ klass = value.class
22
+
23
+ unless [Array, String].include?(klass)
24
+ raise(Puppet::ParseError, 'swapcase(): Requires either ' +
25
+ 'array or string to work with')
26
+ end
27
+
28
+ if value.is_a?(Array)
29
+ # Numbers in Puppet are often string-encoded which is troublesome ...
30
+ result = value.collect { |i| i.is_a?(String) ? i.swapcase : i }
31
+ else
32
+ result = value.swapcase
33
+ end
34
+
35
+ return result
36
+ end
37
+ end
38
+
39
+ # vim: set ts=2 sw=2 et :
@@ -0,0 +1,49 @@
1
+ #
2
+ # time.rb
3
+ #
4
+
5
+ module Puppet::Parser::Functions
6
+ newfunction(:time, :type => :rvalue, :doc => <<-EOS
7
+ This function will return the current time since epoch as an integer.
8
+
9
+ *Examples:*
10
+
11
+ time()
12
+
13
+ Will return something like: 1311972653
14
+ EOS
15
+ ) do |arguments|
16
+
17
+ # The Time Zone argument is optional ...
18
+ time_zone = arguments[0] if arguments[0]
19
+
20
+ if (arguments.size != 0) and (arguments.size != 1) then
21
+ raise(Puppet::ParseError, "time(): Wrong number of arguments "+
22
+ "given #{arguments.size} for 0 or 1")
23
+ end
24
+
25
+ time = Time.new
26
+
27
+ # There is probably a better way to handle Time Zone ...
28
+ if time_zone and not time_zone.empty?
29
+ original_zone = ENV['TZ']
30
+
31
+ local_time = time.clone
32
+ local_time = local_time.utc
33
+
34
+ ENV['TZ'] = time_zone
35
+
36
+ time = local_time.localtime
37
+
38
+ ENV['TZ'] = original_zone
39
+ end
40
+
41
+ # Calling Time#to_i on a receiver changes it. Trust me I am the Doctor.
42
+ result = time.strftime('%s')
43
+ result = result.to_i
44
+
45
+ return result
46
+ end
47
+ end
48
+
49
+ # vim: set ts=2 sw=2 et :
@@ -0,0 +1,28 @@
1
+ module Puppet::Parser::Functions
2
+ newfunction(:to_bytes, :type => :rvalue, :doc => <<-EOS
3
+ Converts the argument into bytes, for example 4 kB becomes 4096.
4
+ Takes a single string value as an argument.
5
+ EOS
6
+ ) do |arguments|
7
+
8
+ raise(Puppet::ParseError, "to_bytes(): Wrong number of arguments " +
9
+ "given (#{arguments.size} for 1)") if arguments.size != 1
10
+
11
+ arg = arguments[0]
12
+
13
+ return arg if arg.is_a? Numeric
14
+
15
+ value,prefix = */([0-9.e+-]*)\s*([^bB]?)/.match(arg)[1,2]
16
+
17
+ value = value.to_f
18
+ case prefix
19
+ when '' then return value.to_i
20
+ when 'k' then return (value*(1<<10)).to_i
21
+ when 'M' then return (value*(1<<20)).to_i
22
+ when 'G' then return (value*(1<<30)).to_i
23
+ when 'T' then return (value*(1<<40)).to_i
24
+ when 'E' then return (value*(1<<50)).to_i
25
+ else raise Puppet::ParseError, "to_bytes(): Unknown prefix #{prefix}"
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,50 @@
1
+ #
2
+ # type.rb
3
+ #
4
+
5
+ module Puppet::Parser::Functions
6
+ newfunction(:type, :type => :rvalue, :doc => <<-EOS
7
+ Returns the type when passed a variable. Type can be one of:
8
+
9
+ * string
10
+ * array
11
+ * hash
12
+ * float
13
+ * integer
14
+ * boolean
15
+ EOS
16
+ ) do |arguments|
17
+
18
+ raise(Puppet::ParseError, "type(): Wrong number of arguments " +
19
+ "given (#{arguments.size} for 1)") if arguments.size < 1
20
+
21
+ value = arguments[0]
22
+
23
+ klass = value.class
24
+
25
+ if not [TrueClass, FalseClass, Array, Bignum, Fixnum, Float, Hash, String].include?(klass)
26
+ raise(Puppet::ParseError, 'type(): Unknown type')
27
+ end
28
+
29
+ klass = klass.to_s # Ugly ...
30
+
31
+ # We note that Integer is the parent to Bignum and Fixnum ...
32
+ result = case klass
33
+ when /^(?:Big|Fix)num$/ then 'integer'
34
+ when /^(?:True|False)Class$/ then 'boolean'
35
+ else klass
36
+ end
37
+
38
+ if result == "String" then
39
+ if value == value.to_i.to_s then
40
+ result = "Integer"
41
+ elsif value == value.to_f.to_s then
42
+ result = "Float"
43
+ end
44
+ end
45
+
46
+ return result.downcase
47
+ end
48
+ end
49
+
50
+ # vim: set ts=2 sw=2 et :
@@ -0,0 +1,34 @@
1
+ #
2
+ # union.rb
3
+ #
4
+
5
+ module Puppet::Parser::Functions
6
+ newfunction(:union, :type => :rvalue, :doc => <<-EOS
7
+ This function returns a union of two arrays.
8
+
9
+ *Examples:*
10
+
11
+ union(["a","b","c"],["b","c","d"])
12
+
13
+ Would return: ["a","b","c","d"]
14
+ EOS
15
+ ) do |arguments|
16
+
17
+ # Two arguments are required
18
+ raise(Puppet::ParseError, "union(): Wrong number of arguments " +
19
+ "given (#{arguments.size} for 2)") if arguments.size != 2
20
+
21
+ first = arguments[0]
22
+ second = arguments[1]
23
+
24
+ unless first.is_a?(Array) && second.is_a?(Array)
25
+ raise(Puppet::ParseError, 'union(): Requires 2 arrays')
26
+ end
27
+
28
+ result = first | second
29
+
30
+ return result
31
+ end
32
+ end
33
+
34
+ # vim: set ts=2 sw=2 et :
@@ -0,0 +1,51 @@
1
+ #
2
+ # unique.rb
3
+ #
4
+
5
+ module Puppet::Parser::Functions
6
+ newfunction(:unique, :type => :rvalue, :doc => <<-EOS
7
+ This function will remove duplicates from strings and arrays.
8
+
9
+ *Examples:*
10
+
11
+ unique("aabbcc")
12
+
13
+ Will return:
14
+
15
+ abc
16
+
17
+ You can also use this with arrays:
18
+
19
+ unique(["a","a","b","b","c","c"])
20
+
21
+ This returns:
22
+
23
+ ["a","b","c"]
24
+ EOS
25
+ ) do |arguments|
26
+
27
+ raise(Puppet::ParseError, "unique(): Wrong number of arguments " +
28
+ "given (#{arguments.size} for 1)") if arguments.size < 1
29
+
30
+ value = arguments[0]
31
+ klass = value.class
32
+
33
+ unless [Array, String].include?(klass)
34
+ raise(Puppet::ParseError, 'unique(): Requires either ' +
35
+ 'array or string to work with')
36
+ end
37
+
38
+ result = value.clone
39
+
40
+ string = value.is_a?(String) ? true : false
41
+
42
+ # We turn any string value into an array to be able to shuffle ...
43
+ result = string ? result.split('') : result
44
+ result = result.uniq # Remove duplicates ...
45
+ result = string ? result.join : result
46
+
47
+ return result
48
+ end
49
+ end
50
+
51
+ # vim: set ts=2 sw=2 et :
@@ -0,0 +1,41 @@
1
+ #
2
+ # upcase.rb
3
+ #
4
+
5
+ module Puppet::Parser::Functions
6
+ newfunction(:upcase, :type => :rvalue, :doc => <<-EOS
7
+ Converts a string or an array of strings to uppercase.
8
+
9
+ *Examples:*
10
+
11
+ upcase("abcd")
12
+
13
+ Will return:
14
+
15
+ ASDF
16
+ EOS
17
+ ) do |arguments|
18
+
19
+ raise(Puppet::ParseError, "upcase(): Wrong number of arguments " +
20
+ "given (#{arguments.size} for 1)") if arguments.size < 1
21
+
22
+ value = arguments[0]
23
+ klass = value.class
24
+
25
+ unless [Array, String].include?(klass)
26
+ raise(Puppet::ParseError, 'upcase(): Requires either ' +
27
+ 'array or string to work with')
28
+ end
29
+
30
+ if value.is_a?(Array)
31
+ # Numbers in Puppet are often string-encoded which is troublesome ...
32
+ result = value.collect { |i| i.is_a?(String) ? i.upcase : i }
33
+ else
34
+ result = value.upcase
35
+ end
36
+
37
+ return result
38
+ end
39
+ end
40
+
41
+ # vim: set ts=2 sw=2 et :
@@ -0,0 +1,35 @@
1
+ #
2
+ # uriescape.rb
3
+ #
4
+ require 'uri'
5
+
6
+ module Puppet::Parser::Functions
7
+ newfunction(:uriescape, :type => :rvalue, :doc => <<-EOS
8
+ Urlencodes a string or array of strings.
9
+ Requires either a single string or an array as an input.
10
+ EOS
11
+ ) do |arguments|
12
+
13
+ raise(Puppet::ParseError, "uriescape(): Wrong number of arguments " +
14
+ "given (#{arguments.size} for 1)") if arguments.size < 1
15
+
16
+ value = arguments[0]
17
+ klass = value.class
18
+
19
+ unless [Array, String].include?(klass)
20
+ raise(Puppet::ParseError, 'uriescape(): Requires either ' +
21
+ 'array or string to work with')
22
+ end
23
+
24
+ if value.is_a?(Array)
25
+ # Numbers in Puppet are often string-encoded which is troublesome ...
26
+ result = value.collect { |i| i.is_a?(String) ? URI.escape(i,unsafe) : i }
27
+ else
28
+ result = URI.escape(value)
29
+ end
30
+
31
+ return result
32
+ end
33
+ end
34
+
35
+ # vim: set ts=2 sw=2 et :
@@ -0,0 +1,56 @@
1
+ module Puppet::Parser::Functions
2
+ newfunction(:validate_absolute_path, :doc => <<-'ENDHEREDOC') do |args|
3
+ Validate the string represents an absolute path in the filesystem. This function works
4
+ for windows and unix style paths.
5
+
6
+ The following values will pass:
7
+
8
+ $my_path = "C:/Program Files (x86)/Puppet Labs/Puppet"
9
+ validate_absolute_path($my_path)
10
+ $my_path2 = "/var/lib/puppet"
11
+ validate_absolute_path($my_path2)
12
+
13
+
14
+ The following values will fail, causing compilation to abort:
15
+
16
+ validate_absolute_path(true)
17
+ validate_absolute_path([ 'var/lib/puppet', '/var/foo' ])
18
+ validate_absolute_path([ '/var/lib/puppet', 'var/foo' ])
19
+ $undefined = undef
20
+ validate_absolute_path($undefined)
21
+
22
+ ENDHEREDOC
23
+
24
+ require 'puppet/util'
25
+
26
+ unless args.length > 0 then
27
+ raise Puppet::ParseError, ("validate_absolute_path(): wrong number of arguments (#{args.length}; must be > 0)")
28
+ end
29
+
30
+ args.each do |arg|
31
+ # This logic was borrowed from
32
+ # [lib/puppet/file_serving/base.rb](https://github.com/puppetlabs/puppet/blob/master/lib/puppet/file_serving/base.rb)
33
+
34
+ # Puppet 2.7 and beyond will have Puppet::Util.absolute_path? Fall back to a back-ported implementation otherwise.
35
+ if Puppet::Util.respond_to?(:absolute_path?) then
36
+ unless Puppet::Util.absolute_path?(arg, :posix) or Puppet::Util.absolute_path?(arg, :windows)
37
+ raise Puppet::ParseError, ("#{arg.inspect} is not an absolute path.")
38
+ end
39
+ else
40
+ # This code back-ported from 2.7.x's lib/puppet/util.rb Puppet::Util.absolute_path?
41
+ # Determine in a platform-specific way whether a path is absolute. This
42
+ # defaults to the local platform if none is specified.
43
+ # Escape once for the string literal, and once for the regex.
44
+ slash = '[\\\\/]'
45
+ name = '[^\\\\/]+'
46
+ regexes = {
47
+ :windows => %r!^(([A-Z]:#{slash})|(#{slash}#{slash}#{name}#{slash}#{name})|(#{slash}#{slash}\?#{slash}#{name}))!i,
48
+ :posix => %r!^/!,
49
+ }
50
+
51
+ rval = (!!(arg =~ regexes[:posix])) || (!!(arg =~ regexes[:windows]))
52
+ rval or raise Puppet::ParseError, ("#{arg.inspect} is not an absolute path.")
53
+ end
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,33 @@
1
+ module Puppet::Parser::Functions
2
+
3
+ newfunction(:validate_array, :doc => <<-'ENDHEREDOC') do |args|
4
+ Validate that all passed values are array data structures. Abort catalog
5
+ compilation if any value fails this check.
6
+
7
+ The following values will pass:
8
+
9
+ $my_array = [ 'one', 'two' ]
10
+ validate_array($my_array)
11
+
12
+ The following values will fail, causing compilation to abort:
13
+
14
+ validate_array(true)
15
+ validate_array('some_string')
16
+ $undefined = undef
17
+ validate_array($undefined)
18
+
19
+ ENDHEREDOC
20
+
21
+ unless args.length > 0 then
22
+ raise Puppet::ParseError, ("validate_array(): wrong number of arguments (#{args.length}; must be > 0)")
23
+ end
24
+
25
+ args.each do |arg|
26
+ unless arg.is_a?(Array)
27
+ raise Puppet::ParseError, ("#{arg.inspect} is not an Array. It looks to be a #{arg.class}")
28
+ end
29
+ end
30
+
31
+ end
32
+
33
+ end